pcm970-baseboard.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /*
  2. * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16. * MA 02110-1301, USA.
  17. */
  18. #include <linux/gpio.h>
  19. #include <linux/irq.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/can/platform/sja1000.h>
  22. #include <asm/mach/arch.h>
  23. #include <mach/common.h>
  24. #include <mach/iomux-mx27.h>
  25. #include <mach/hardware.h>
  26. #include "devices-imx27.h"
  27. #include "devices.h"
  28. static const int pcm970_pins[] __initconst = {
  29. /* SDHC */
  30. PB4_PF_SD2_D0,
  31. PB5_PF_SD2_D1,
  32. PB6_PF_SD2_D2,
  33. PB7_PF_SD2_D3,
  34. PB8_PF_SD2_CMD,
  35. PB9_PF_SD2_CLK,
  36. /* display */
  37. PA5_PF_LSCLK,
  38. PA6_PF_LD0,
  39. PA7_PF_LD1,
  40. PA8_PF_LD2,
  41. PA9_PF_LD3,
  42. PA10_PF_LD4,
  43. PA11_PF_LD5,
  44. PA12_PF_LD6,
  45. PA13_PF_LD7,
  46. PA14_PF_LD8,
  47. PA15_PF_LD9,
  48. PA16_PF_LD10,
  49. PA17_PF_LD11,
  50. PA18_PF_LD12,
  51. PA19_PF_LD13,
  52. PA20_PF_LD14,
  53. PA21_PF_LD15,
  54. PA22_PF_LD16,
  55. PA23_PF_LD17,
  56. PA24_PF_REV,
  57. PA25_PF_CLS,
  58. PA26_PF_PS,
  59. PA27_PF_SPL_SPR,
  60. PA28_PF_HSYNC,
  61. PA29_PF_VSYNC,
  62. PA30_PF_CONTRAST,
  63. PA31_PF_OE_ACD,
  64. /*
  65. * it seems the data line misses a pullup, so we must enable
  66. * the internal pullup as a local workaround
  67. */
  68. PD17_PF_I2C_DATA | GPIO_PUEN,
  69. PD18_PF_I2C_CLK,
  70. /* Camera */
  71. PB10_PF_CSI_D0,
  72. PB11_PF_CSI_D1,
  73. PB12_PF_CSI_D2,
  74. PB13_PF_CSI_D3,
  75. PB14_PF_CSI_D4,
  76. PB15_PF_CSI_MCLK,
  77. PB16_PF_CSI_PIXCLK,
  78. PB17_PF_CSI_D5,
  79. PB18_PF_CSI_D6,
  80. PB19_PF_CSI_D7,
  81. PB20_PF_CSI_VSYNC,
  82. PB21_PF_CSI_HSYNC,
  83. };
  84. static int pcm970_sdhc2_get_ro(struct device *dev)
  85. {
  86. return gpio_get_value(GPIO_PORTC + 28);
  87. }
  88. static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
  89. {
  90. int ret;
  91. ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_TRIGGER_FALLING,
  92. "imx-mmc-detect", data);
  93. if (ret)
  94. return ret;
  95. ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
  96. if (ret) {
  97. free_irq(IRQ_GPIOC(29), data);
  98. return ret;
  99. }
  100. gpio_direction_input(GPIO_PORTC + 28);
  101. return 0;
  102. }
  103. static void pcm970_sdhc2_exit(struct device *dev, void *data)
  104. {
  105. free_irq(IRQ_GPIOC(29), data);
  106. gpio_free(GPIO_PORTC + 28);
  107. }
  108. static const struct imxmmc_platform_data sdhc_pdata __initconst = {
  109. .get_ro = pcm970_sdhc2_get_ro,
  110. .init = pcm970_sdhc2_init,
  111. .exit = pcm970_sdhc2_exit,
  112. };
  113. static struct imx_fb_videomode pcm970_modes[] = {
  114. {
  115. .mode = {
  116. .name = "Sharp-LQ035Q7",
  117. .refresh = 60,
  118. .xres = 240,
  119. .yres = 320,
  120. .pixclock = 188679, /* in ps (5.3MHz) */
  121. .hsync_len = 7,
  122. .left_margin = 5,
  123. .right_margin = 16,
  124. .vsync_len = 1,
  125. .upper_margin = 7,
  126. .lower_margin = 9,
  127. },
  128. /*
  129. * - HSYNC active high
  130. * - VSYNC active high
  131. * - clk notenabled while idle
  132. * - clock not inverted
  133. * - data not inverted
  134. * - data enable low active
  135. * - enable sharp mode
  136. */
  137. .pcr = 0xF00080C0,
  138. .bpp = 16,
  139. }, {
  140. .mode = {
  141. .name = "TX090",
  142. .refresh = 60,
  143. .xres = 240,
  144. .yres = 320,
  145. .pixclock = 38255,
  146. .left_margin = 144,
  147. .right_margin = 0,
  148. .upper_margin = 7,
  149. .lower_margin = 40,
  150. .hsync_len = 96,
  151. .vsync_len = 1,
  152. },
  153. /*
  154. * - HSYNC active low (1 << 22)
  155. * - VSYNC active low (1 << 23)
  156. * - clk notenabled while idle
  157. * - clock not inverted
  158. * - data not inverted
  159. * - data enable low active
  160. * - enable sharp mode
  161. */
  162. .pcr = 0xF0008080 | (1<<22) | (1<<23) | (1<<19),
  163. .bpp = 32,
  164. },
  165. };
  166. static const struct imx_fb_platform_data pcm038_fb_data __initconst = {
  167. .mode = pcm970_modes,
  168. .num_modes = ARRAY_SIZE(pcm970_modes),
  169. .pwmr = 0x00A903FF,
  170. .lscr1 = 0x00120300,
  171. .dmacr = 0x00020010,
  172. };
  173. static struct resource pcm970_sja1000_resources[] = {
  174. {
  175. .start = MX27_CS4_BASE_ADDR,
  176. .end = MX27_CS4_BASE_ADDR + 0x100 - 1,
  177. .flags = IORESOURCE_MEM,
  178. }, {
  179. .start = IRQ_GPIOE(19),
  180. .end = IRQ_GPIOE(19),
  181. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  182. },
  183. };
  184. static struct sja1000_platform_data pcm970_sja1000_platform_data = {
  185. .osc_freq = 16000000,
  186. .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
  187. .cdr = CDR_CBP,
  188. };
  189. static struct platform_device pcm970_sja1000 = {
  190. .name = "sja1000_platform",
  191. .dev = {
  192. .platform_data = &pcm970_sja1000_platform_data,
  193. },
  194. .resource = pcm970_sja1000_resources,
  195. .num_resources = ARRAY_SIZE(pcm970_sja1000_resources),
  196. };
  197. /*
  198. * system init for baseboard usage. Will be called by pcm038 init.
  199. *
  200. * Add platform devices present on this baseboard and init
  201. * them from CPU side as far as required to use them later on
  202. */
  203. void __init pcm970_baseboard_init(void)
  204. {
  205. mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
  206. "PCM970");
  207. imx27_add_imx_fb(&pcm038_fb_data);
  208. mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
  209. imx27_add_mxc_mmc(1, &sdhc_pdata);
  210. platform_device_register(&pcm970_sja1000);
  211. }