pxa2xx_palmtx.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /*
  2. * linux/drivers/pcmcia/pxa2xx_palmtx.c
  3. *
  4. * Driver for Palm T|X PCMCIA
  5. *
  6. * Copyright (C) 2007-2011 Marek Vasut <marek.vasut@gmail.com>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. *
  12. */
  13. #include <linux/module.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/gpio.h>
  16. #include <asm/mach-types.h>
  17. #include <mach/palmtx.h>
  18. #include "soc_common.h"
  19. static struct gpio palmtx_pcmcia_gpios[] = {
  20. { GPIO_NR_PALMTX_PCMCIA_POWER1, GPIOF_INIT_LOW, "PCMCIA Power 1" },
  21. { GPIO_NR_PALMTX_PCMCIA_POWER2, GPIOF_INIT_LOW, "PCMCIA Power 2" },
  22. { GPIO_NR_PALMTX_PCMCIA_RESET, GPIOF_INIT_HIGH,"PCMCIA Reset" },
  23. };
  24. static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  25. {
  26. int ret;
  27. ret = gpio_request_array(palmtx_pcmcia_gpios,
  28. ARRAY_SIZE(palmtx_pcmcia_gpios));
  29. skt->stat[SOC_STAT_RDY].gpio = GPIO_NR_PALMTX_PCMCIA_READY;
  30. skt->stat[SOC_STAT_RDY].name = "PCMCIA Ready";
  31. return ret;
  32. }
  33. static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  34. {
  35. gpio_free_array(palmtx_pcmcia_gpios, ARRAY_SIZE(palmtx_pcmcia_gpios));
  36. }
  37. static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  38. struct pcmcia_state *state)
  39. {
  40. state->detect = 1; /* always inserted */
  41. state->wrprot = 0;
  42. state->vs_3v = 1;
  43. state->vs_Xv = 0;
  44. }
  45. static int
  46. palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  47. const socket_state_t *state)
  48. {
  49. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
  50. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
  51. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
  52. !!(state->flags & SS_RESET));
  53. return 0;
  54. }
  55. static struct pcmcia_low_level palmtx_pcmcia_ops = {
  56. .owner = THIS_MODULE,
  57. .first = 0,
  58. .nr = 1,
  59. .hw_init = palmtx_pcmcia_hw_init,
  60. .hw_shutdown = palmtx_pcmcia_hw_shutdown,
  61. .socket_state = palmtx_pcmcia_socket_state,
  62. .configure_socket = palmtx_pcmcia_configure_socket,
  63. };
  64. static struct platform_device *palmtx_pcmcia_device;
  65. static int __init palmtx_pcmcia_init(void)
  66. {
  67. int ret;
  68. if (!machine_is_palmtx())
  69. return -ENODEV;
  70. palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  71. if (!palmtx_pcmcia_device)
  72. return -ENOMEM;
  73. ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
  74. sizeof(palmtx_pcmcia_ops));
  75. if (!ret)
  76. ret = platform_device_add(palmtx_pcmcia_device);
  77. if (ret)
  78. platform_device_put(palmtx_pcmcia_device);
  79. return ret;
  80. }
  81. static void __exit palmtx_pcmcia_exit(void)
  82. {
  83. platform_device_unregister(palmtx_pcmcia_device);
  84. }
  85. module_init(palmtx_pcmcia_init);
  86. module_exit(palmtx_pcmcia_exit);
  87. MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
  88. MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
  89. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  90. MODULE_LICENSE("GPL");