eseries.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. /*
  2. * Hardware definitions for the Toshiba eseries PDAs
  3. *
  4. * Copyright (c) 2003 Ian Molton <spyro@f2s.com>
  5. *
  6. * This file is licensed under
  7. * the terms of the GNU General Public License version 2. This program
  8. * is licensed "as is" without any warranty of any kind, whether express
  9. * or implied.
  10. *
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/init.h>
  14. #include <linux/gpio.h>
  15. #include <linux/delay.h>
  16. #include <linux/platform_device.h>
  17. #include <asm/setup.h>
  18. #include <asm/mach/arch.h>
  19. #include <asm/mach-types.h>
  20. #include <mach/mfp-pxa25x.h>
  21. #include <mach/hardware.h>
  22. #include <mach/eseries-gpio.h>
  23. #include <mach/udc.h>
  24. #include <mach/irda.h>
  25. #include "generic.h"
  26. #include "clock.h"
  27. /* Only e800 has 128MB RAM */
  28. void __init eseries_fixup(struct machine_desc *desc,
  29. struct tag *tags, char **cmdline, struct meminfo *mi)
  30. {
  31. mi->nr_banks=1;
  32. mi->bank[0].start = 0xa0000000;
  33. mi->bank[0].node = 0;
  34. if (machine_is_e800())
  35. mi->bank[0].size = (128*1024*1024);
  36. else
  37. mi->bank[0].size = (64*1024*1024);
  38. }
  39. struct pxa2xx_udc_mach_info e7xx_udc_mach_info = {
  40. .gpio_vbus = GPIO_E7XX_USB_DISC,
  41. .gpio_pullup = GPIO_E7XX_USB_PULLUP,
  42. .gpio_pullup_inverted = 1
  43. };
  44. static void e7xx_irda_transceiver_mode(struct device *dev, int mode)
  45. {
  46. if (mode & IR_OFF) {
  47. gpio_set_value(GPIO_E7XX_IR_OFF, 1);
  48. pxa2xx_transceiver_mode(dev, mode);
  49. } else {
  50. pxa2xx_transceiver_mode(dev, mode);
  51. gpio_set_value(GPIO_E7XX_IR_OFF, 0);
  52. }
  53. }
  54. int e7xx_irda_init(void)
  55. {
  56. int ret;
  57. ret = gpio_request(GPIO_E7XX_IR_OFF, "IrDA power");
  58. if (ret)
  59. goto out;
  60. ret = gpio_direction_output(GPIO_E7XX_IR_OFF, 0);
  61. if (ret)
  62. goto out;
  63. e7xx_irda_transceiver_mode(NULL, IR_SIRMODE | IR_OFF);
  64. out:
  65. return ret;
  66. }
  67. static void e7xx_irda_shutdown(struct device *dev)
  68. {
  69. e7xx_irda_transceiver_mode(dev, IR_SIRMODE | IR_OFF);
  70. gpio_free(GPIO_E7XX_IR_OFF);
  71. }
  72. struct pxaficp_platform_data e7xx_ficp_platform_data = {
  73. .transceiver_cap = IR_SIRMODE | IR_OFF,
  74. .transceiver_mode = e7xx_irda_transceiver_mode,
  75. .shutdown = e7xx_irda_shutdown,
  76. };
  77. int eseries_tmio_enable(struct platform_device *dev)
  78. {
  79. /* Reset - bring SUSPEND high before PCLR */
  80. gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
  81. gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 0);
  82. msleep(1);
  83. gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 1);
  84. msleep(1);
  85. gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 1);
  86. msleep(1);
  87. return 0;
  88. }
  89. int eseries_tmio_disable(struct platform_device *dev)
  90. {
  91. gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
  92. gpio_set_value(GPIO_ESERIES_TMIO_PCLR, 0);
  93. return 0;
  94. }
  95. int eseries_tmio_suspend(struct platform_device *dev)
  96. {
  97. gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 0);
  98. return 0;
  99. }
  100. int eseries_tmio_resume(struct platform_device *dev)
  101. {
  102. gpio_set_value(GPIO_ESERIES_TMIO_SUSPEND, 1);
  103. msleep(1);
  104. return 0;
  105. }
  106. void eseries_get_tmio_gpios(void)
  107. {
  108. gpio_request(GPIO_ESERIES_TMIO_SUSPEND, NULL);
  109. gpio_request(GPIO_ESERIES_TMIO_PCLR, NULL);
  110. gpio_direction_output(GPIO_ESERIES_TMIO_SUSPEND, 0);
  111. gpio_direction_output(GPIO_ESERIES_TMIO_PCLR, 0);
  112. }
  113. /* TMIO controller uses the same resources on all e-series machines. */
  114. struct resource eseries_tmio_resources[] = {
  115. [0] = {
  116. .start = PXA_CS4_PHYS,
  117. .end = PXA_CS4_PHYS + 0x1fffff,
  118. .flags = IORESOURCE_MEM,
  119. },
  120. [1] = {
  121. .start = IRQ_GPIO(GPIO_ESERIES_TMIO_IRQ),
  122. .end = IRQ_GPIO(GPIO_ESERIES_TMIO_IRQ),
  123. .flags = IORESOURCE_IRQ,
  124. },
  125. };
  126. /* Some e-series hardware cannot control the 32K clock */
  127. static void clk_32k_dummy(struct clk *clk)
  128. {
  129. }
  130. static const struct clkops clk_32k_dummy_ops = {
  131. .enable = clk_32k_dummy,
  132. .disable = clk_32k_dummy,
  133. };
  134. static struct clk tmio_dummy_clk = {
  135. .ops = &clk_32k_dummy_ops,
  136. .rate = 32768,
  137. };
  138. static struct clk_lookup eseries_clkregs[] = {
  139. INIT_CLKREG(&tmio_dummy_clk, NULL, "CLK_CK32K"),
  140. };
  141. void eseries_register_clks(void)
  142. {
  143. clks_register(eseries_clkregs, ARRAY_SIZE(eseries_clkregs));
  144. }