pxa2xx_palmld.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. };
  24. static int palmld_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  25. {
  26. int ret;
  27. ret = gpio_request_array(palmld_pcmcia_gpios,
  28. ARRAY_SIZE(palmld_pcmcia_gpios));
  29. skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMLD_PCMCIA_READY;
  30. skt->stat[SOC_STAT_RDY].name = "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->vs_3v = 1;
  42. state->vs_Xv = 0;
  43. }
  44. static int palmld_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  45. const socket_state_t *state)
  46. {
  47. gpio_set_value(GPIO_NR_PALMLD_PCMCIA_POWER, 1);
  48. gpio_set_value(GPIO_NR_PALMLD_PCMCIA_RESET,
  49. !!(state->flags & SS_RESET));
  50. return 0;
  51. }
  52. static struct pcmcia_low_level palmld_pcmcia_ops = {
  53. .owner = THIS_MODULE,
  54. .first = 1,
  55. .nr = 1,
  56. .hw_init = palmld_pcmcia_hw_init,
  57. .hw_shutdown = palmld_pcmcia_hw_shutdown,
  58. .socket_state = palmld_pcmcia_socket_state,
  59. .configure_socket = palmld_pcmcia_configure_socket,
  60. };
  61. static struct platform_device *palmld_pcmcia_device;
  62. static int __init palmld_pcmcia_init(void)
  63. {
  64. int ret;
  65. if (!machine_is_palmld())
  66. return -ENODEV;
  67. palmld_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  68. if (!palmld_pcmcia_device)
  69. return -ENOMEM;
  70. ret = platform_device_add_data(palmld_pcmcia_device, &palmld_pcmcia_ops,
  71. sizeof(palmld_pcmcia_ops));
  72. if (!ret)
  73. ret = platform_device_add(palmld_pcmcia_device);
  74. if (ret)
  75. platform_device_put(palmld_pcmcia_device);
  76. return ret;
  77. }
  78. static void __exit palmld_pcmcia_exit(void)
  79. {
  80. platform_device_unregister(palmld_pcmcia_device);
  81. }
  82. module_init(palmld_pcmcia_init);
  83. module_exit(palmld_pcmcia_exit);
  84. MODULE_AUTHOR("Alex Osborne <ato@meshy.org>,"
  85. " Marek Vasut <marek.vasut@gmail.com>");
  86. MODULE_DESCRIPTION("PCMCIA support for Palm LifeDrive");
  87. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  88. MODULE_LICENSE("GPL");