pxa2xx_palmld.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/drivers/pcmcia/pxa2xx_palmld.c
  4. *
  5. * Driver for Palm LifeDrive PCMCIA
  6. *
  7. * Copyright (C) 2006 Alex Osborne <ato@meshy.org>
  8. * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
  9. */
  10. #include <linux/module.h>
  11. #include <linux/platform_device.h>
  12. #include <linux/gpio.h>
  13. #include <asm/mach-types.h>
  14. #include <mach/palmld.h>
  15. #include "soc_common.h"
  16. static struct gpio palmld_pcmcia_gpios[] = {
  17. { GPIO_NR_PALMLD_PCMCIA_POWER, GPIOF_INIT_LOW, "PCMCIA Power" },
  18. { GPIO_NR_PALMLD_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
  19. };
  20. static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  21. {
  22. int ret;
  23. ret = gpio_request_array(palmld_pcmcia_gpios,
  24. ARRAY_SIZE(palmld_pcmcia_gpios));
  25. skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
  26. skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
  27. return ret;
  28. }
  29. static void palmld_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  30. {
  31. gpio_free_array(palmld_pcmcia_gpios, ARRAY_SIZE(palmld_pcmcia_gpios));
  32. }
  33. static void palmld_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  34. struct pcmcia_state *state)
  35. {
  36. state->detect = 1; /* always inserted */
  37. state->vs_3v = 1;
  38. state->vs_Xv = 0;
  39. }
  40. static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  41. const socket_state_t *state)
  42. {
  43. gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
  44. gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
  45. !!(state->flags & SS_RESET));
  46. return 0;
  47. }
  48. static struct pcmcia_low_level palmld_pcmcia_ops = {
  49. .owner = THIS_MODULE,
  50. .first = 1,
  51. .nr = 1,
  52. .hw_init = palmld_pcmcia_hw_init,
  53. .hw_shutdown = palmld_pcmcia_hw_shutdown,
  54. .socket_state = palmld_pcmcia_socket_state,
  55. .configure_socket = palmld_pcmcia_configure_socket,
  56. };
  57. static struct platform_device *palmld_pcmcia_device;
  58. static int __init palmld_pcmcia_init(void)
  59. {
  60. int ret;
  61. if (!machine_is_palmld())
  62. return -ENODEV;
  63. palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  64. if (!palmld_pcmcia_device)
  65. return -ENOMEM;
  66. ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
  67. sizeof(palmld_pcmcia_ops));
  68. if (!ret)
  69. ret = platform_device_add(palmld_pcmcia_device);
  70. if (ret)
  71. platform_device_put(palmld_pcmcia_device);
  72. return ret;
  73. }
  74. static void __exit palmld_pcmcia_exit(void)
  75. {
  76. platform_device_unregister(palmld_pcmcia_device);
  77. }
  78. module_init(palmld_pcmcia_init);
  79. module_exit(palmld_pcmcia_exit);
  80. MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
  81. " Marek Vasut <marek.vasut@gmail.com>");
  82. MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
  83. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  84. MODULE_LICENSE("GPL");