pxa2xx_palmtx.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * linux/drivers/pcmcia/pxa2xx_palmtx.c
  3. *
  4. * Driver for Palm T|X PCMCIA
  5. *
  6. * Copyright (C) 2007-2008 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 <asm/mach-types.h>
  16. #include <asm/arch/gpio.h>
  17. #include <asm/arch/palmtx.h>
  18. #include "soc_common.h"
  19. static int palmtx_pcmcia_hw_init(struct soc_pcmcia_socket *skt)
  20. {
  21. skt->irq = IRQ_GPIO(GPIO_NR_PALMTX_PCMCIA_READY);
  22. return 0;
  23. }
  24. static void palmtx_pcmcia_hw_shutdown(struct soc_pcmcia_socket *skt)
  25. {
  26. }
  27. static void palmtx_pcmcia_socket_state(struct soc_pcmcia_socket *skt,
  28. struct pcmcia_state *state)
  29. {
  30. state->detect = 1; /* always inserted */
  31. state->ready = !!gpio_get_value(GPIO_NR_PALMTX_PCMCIA_READY);
  32. state->bvd1 = 1;
  33. state->bvd2 = 1;
  34. state->wrprot = 0;
  35. state->vs_3v = 1;
  36. state->vs_Xv = 0;
  37. }
  38. static int
  39. palmtx_pcmcia_configure_socket(struct soc_pcmcia_socket *skt,
  40. const socket_state_t *state)
  41. {
  42. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER1, 1);
  43. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_POWER2, 1);
  44. gpio_set_value(GPIO_NR_PALMTX_PCMCIA_RESET,
  45. !!(state->flags & SS_RESET));
  46. return 0;
  47. }
  48. static void palmtx_pcmcia_socket_init(struct soc_pcmcia_socket *skt)
  49. {
  50. }
  51. static void palmtx_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt)
  52. {
  53. }
  54. static struct pcmcia_low_level palmtx_pcmcia_ops = {
  55. .owner = THIS_MODULE,
  56. .first = 0,
  57. .nr = 1,
  58. .hw_init = palmtx_pcmcia_hw_init,
  59. .hw_shutdown = palmtx_pcmcia_hw_shutdown,
  60. .socket_state = palmtx_pcmcia_socket_state,
  61. .configure_socket = palmtx_pcmcia_configure_socket,
  62. .socket_init = palmtx_pcmcia_socket_init,
  63. .socket_suspend = palmtx_pcmcia_socket_suspend,
  64. };
  65. static struct platform_device *palmtx_pcmcia_device;
  66. static int __init palmtx_pcmcia_init(void)
  67. {
  68. int ret;
  69. if (!machine_is_palmtx())
  70. return -ENODEV;
  71. palmtx_pcmcia_device = platform_device_alloc("pxa2xx-pcmcia", -1);
  72. if (!palmtx_pcmcia_device)
  73. return -ENOMEM;
  74. ret = platform_device_add_data(palmtx_pcmcia_device, &palmtx_pcmcia_ops,
  75. sizeof(palmtx_pcmcia_ops));
  76. if (!ret)
  77. ret = platform_device_add(palmtx_pcmcia_device);
  78. if (ret)
  79. platform_device_put(palmtx_pcmcia_device);
  80. return ret;
  81. }
  82. static void __exit palmtx_pcmcia_exit(void)
  83. {
  84. platform_device_unregister(palmtx_pcmcia_device);
  85. }
  86. fs_initcall(palmtx_pcmcia_init);
  87. module_exit(palmtx_pcmcia_exit);
  88. MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>");
  89. MODULE_DESCRIPTION("PCMCIA support for Palm T|X");
  90. MODULE_ALIAS("platform:pxa2xx-pcmcia");
  91. MODULE_LICENSE("GPL");