sa1111_jornada720.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // SPDX-License-Identifier: GPL-2.0
  2. /*
  3. * drivers/pcmcia/sa1100_jornada720.c
  4. *
  5. * Jornada720 PCMCIA specific routines
  6. *
  7. */
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/device.h>
  11. #include <linux/errno.h>
  12. #include <linux/init.h>
  13. #include <linux/io.h>
  14. #include <mach/hardware.h>
  15. #include <asm/hardware/sa1111.h>
  16. #include <asm/mach-types.h>
  17. #include "sa1111_generic.h"
  18. /* Does SOCKET1_3V actually do anything? */
  19. #define SOCKET0_POWER GPIO_GPIO0
  20. #define SOCKET0_3V GPIO_GPIO2
  21. #define SOCKET1_POWER (GPIO_GPIO1 | GPIO_GPIO3)
  22. #define SOCKET1_3V GPIO_GPIO3
  23. static int
  24. jornada720_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, const socket_state_t *state)
  25. {
  26. struct sa1111_pcmcia_socket *s = to_skt(skt);
  27. unsigned int pa_dwr_mask, pa_dwr_set;
  28. int ret;
  29. printk(KERN_INFO "%s(): config socket %d vcc %d vpp %d\n", __func__,
  30. skt->nr, state->Vcc, state->Vpp);
  31. switch (skt->nr) {
  32. case 0:
  33. pa_dwr_mask = SOCKET0_POWER | SOCKET0_3V;
  34. switch (state->Vcc) {
  35. default:
  36. case 0:
  37. pa_dwr_set = 0;
  38. break;
  39. case 33:
  40. pa_dwr_set = SOCKET0_POWER | SOCKET0_3V;
  41. break;
  42. case 50:
  43. pa_dwr_set = SOCKET0_POWER;
  44. break;
  45. }
  46. break;
  47. case 1:
  48. pa_dwr_mask = SOCKET1_POWER;
  49. switch (state->Vcc) {
  50. default:
  51. case 0:
  52. pa_dwr_set = 0;
  53. break;
  54. case 33:
  55. pa_dwr_set = SOCKET1_POWER;
  56. break;
  57. case 50:
  58. pa_dwr_set = SOCKET1_POWER;
  59. break;
  60. }
  61. break;
  62. default:
  63. return -1;
  64. }
  65. if (state->Vpp != state->Vcc && state->Vpp != 0) {
  66. printk(KERN_ERR "%s(): slot cannot support VPP %u\n",
  67. __func__, state->Vpp);
  68. return -EPERM;
  69. }
  70. ret = sa1111_pcmcia_configure_socket(skt, state);
  71. if (ret == 0)
  72. sa1111_set_io(s->dev, pa_dwr_mask, pa_dwr_set);
  73. return ret;
  74. }
  75. static struct pcmcia_low_level jornada720_pcmcia_ops = {
  76. .owner = THIS_MODULE,
  77. .configure_socket = jornada720_pcmcia_configure_socket,
  78. .first = 0,
  79. .nr = 2,
  80. };
  81. int pcmcia_jornada720_init(struct sa1111_dev *sadev)
  82. {
  83. unsigned int pin = GPIO_A0 | GPIO_A1 | GPIO_A2 | GPIO_A3;
  84. /* Fixme: why messing around with SA11x0's GPIO1? */
  85. GRER |= 0x00000002;
  86. /* Set GPIO_A<3:1> to be outputs for PCMCIA/CF power controller: */
  87. sa1111_set_io_dir(sadev, pin, 0, 0);
  88. sa1111_set_io(sadev, pin, 0);
  89. sa1111_set_sleep_io(sadev, pin, 0);
  90. sa11xx_drv_pcmcia_ops(&jornada720_pcmcia_ops);
  91. return sa1111_pcmcia_add(sadev, &jornada720_pcmcia_ops,
  92. sa11xx_drv_pcmcia_add_one);
  93. }