pxa2xx_palmld.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * linux/drivers/pcmcia/pxa2xx_palmld.c
  3. *
  4. * Driver for Palm LifeDrive PCMCIA
  5. *
  6. * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
  7. * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. *
  13. */
  14. #include <linux/module.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/gpio.h>
  17. #include <asm/mach-types.h>
  18. #include <mach/palmld.h>
  19. #include "soc_common.h"
  20. static struct gpio palmld_pcmcia_gpios[] = {
  21. { GPIO_NR_PALMLD_PCMCIA_POWER, GPIOF_INIT_LOW, "PCMCIA Power" },
  22. { GPIO_NR_PALMLD_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
  23. { GPIO_NR_PALMLD_PCMCIA_READY, GPIOF_IN, "PCMCIA Ready" },
  24. };
  25. static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  26. {
  27. int ret;
  28. ret = gpio_request_array(palmld_pcmcia_gpios,
  29. ARRAY_SIZE(palmld_pcmcia_gpios));
  30. skt->socket.pci_irq = IRQ_GPIO(GPIO_NR_PALMLD_PCMCIA_READY);
  31. return ret;
  32. }
  33. static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  34. {
  35. gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
  36. }
  37. static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  38. struct pcmcia_state *state)
  39. {
  40. state->detect = 1; /* always inserted */
  41. state->ready = !!gpio_get_value(GPIO_NR_PALMLD_PCMCIA_READY);
  42. state->bvd1 = 1;
  43. state->bvd2 = 1;
  44. state->wrprot = 0;
  45. state->vs_3v = 1;
  46. state->vs_Xv = 0;
  47. }
  48. static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  49. const socket_state_t *state)
  50. {
  51. gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
  52. gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
  53. !!(state->flags & SS_RESET));
  54. return 0;
  55. }
  56. static void palmld_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
  57. {
  58. }
  59. static void palmld_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
  60. {
  61. }
  62. static struct pcmcia_low_level palmld_pcmcia_ops = {
  63. .owner = THIS_MODULE,
  64. .first = 1,
  65. .nr = 1,
  66. .hw_init = palmld_pcmcia_hw_init,
  67. .hw_shutdown = palmld_pcmcia_hw_shutdown,
  68. .socket_state = palmld_pcmcia_socket_state,
  69. .configure_socket = palmld_pcmcia_configure_socket,
  70. .socket_init = palmld_pcmcia_socket_init,
  71. .socket_suspend = palmld_pcmcia_socket_suspend,
  72. };
  73. static struct platform_device *palmld_pcmcia_device;
  74. static int __init palmld_pcmcia_init(void)
  75. {
  76. int ret;
  77. if (!machine_is_palmld())
  78. return -ENODEV;
  79. palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  80. if (!palmld_pcmcia_device)
  81. return -ENOMEM;
  82. ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
  83. sizeof(palmld_pcmcia_ops));
  84. if (!ret)
  85. ret = platform_device_add(palmld_pcmcia_device);
  86. if (ret)
  87. platform_device_put(palmld_pcmcia_device);
  88. return ret;
  89. }
  90. static void __exit palmld_pcmcia_exit(void)
  91. {
  92. platform_device_unregister(palmld_pcmcia_device);
  93. }
  94. module_init(palmld_pcmcia_init);
  95. module_exit(palmld_pcmcia_exit);
  96. MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
  97. " Marek Vasut <marek.vasut@gmail.com>");
  98. MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
  99. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  100. MODULE_LICENSE("GPL");