sa1100_cerf.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * drivers/pcmcia/sa1100_cerf.c
  3. *
  4. * PCMCIA implementation routines for CerfBoard
  5. * Based off the Assabet.
  6. *
  7. */
  8. #include <linux/module.h>
  9. #include <linux/kernel.h>
  10. #include <linux/device.h>
  11. #include <linux/init.h>
  12. #include <linux/delay.h>
  13. #include <linux/gpio.h>
  14. #include <mach/hardware.h>
  15. #include <asm/mach-types.h>
  16. #include <asm/irq.h>
  17. #include <mach/cerf.h>
  18. #include "sa1100_generic.h"
  19. #define CERF_SOCKET 1
  20. static int cerf_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  21. {
  22. int ret;
  23. ret = gpio_request_one(CERF_GPIO_CF_RESET, GPIOF_OUT_INIT_LOW, "CF_RESET");
  24. if (ret)
  25. return ret;
  26. skt->stat[SOC_STAT_CD].gpio = CERF_GPIO_CF_CD;
  27. skt->stat[SOC_STAT_CD].name = "CF_CD";
  28. skt->stat[SOC_STAT_BVD1].gpio = CERF_GPIO_CF_BVD1;
  29. skt->stat[SOC_STAT_BVD1].name = "CF_BVD1";
  30. skt->stat[SOC_STAT_BVD2].gpio = CERF_GPIO_CF_BVD2;
  31. skt->stat[SOC_STAT_BVD2].name = "CF_BVD2";
  32. skt->stat[SOC_STAT_RDY].gpio = CERF_GPIO_CF_IRQ;
  33. skt->stat[SOC_STAT_RDY].name = "CF_IRQ";
  34. return 0;
  35. }
  36. static void cerf_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  37. {
  38. gpio_free(CERF_GPIO_CF_RESET);
  39. }
  40. static void
  41. cerf_pcmcia_socket_state(struct soc_pcmcia_socket *skt, struct pcmcia_state *state)
  42. {
  43. state->vs_3v = 1;
  44. state->vs_Xv = 0;
  45. }
  46. static int
  47. cerf_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  48. const socket_state_t *state)
  49. {
  50. switch (state->Vcc) {
  51. case 0:
  52. case 50:
  53. case 33:
  54. break;
  55. default:
  56. printk(KERN_ERR "%s(): unrecognized Vcc %u\n",
  57. __func__, state->Vcc);
  58. return -1;
  59. }
  60. gpio_set_value(CERF_GPIO_CF_RESET, !!(state->flags & SS_RESET));
  61. return 0;
  62. }
  63. static struct pcmcia_low_level cerf_pcmcia_ops = {
  64. .owner = THIS_MODULE,
  65. .hw_init = cerf_pcmcia_hw_init,
  66. .hw_shutdown = cerf_pcmcia_hw_shutdown,
  67. .socket_state = cerf_pcmcia_socket_state,
  68. .configure_socket = cerf_pcmcia_configure_socket,
  69. };
  70. int pcmcia_cerf_init(struct device *dev)
  71. {
  72. int ret = -ENODEV;
  73. if (machine_is_cerf())
  74. ret = sa11xx_drv_pcmcia_probe(dev, &cerf_pcmcia_ops, CERF_SOCKET, 1);
  75. return ret;
  76. }