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. static const int pcm970_pins[] __initconst = {
  28. /* SDHC */
  29. PB4_PF_SD2_D0,
  30. PB5_PF_SD2_D1,
  31. PB6_PF_SD2_D2,
  32. PB7_PF_SD2_D3,
  33. PB8_PF_SD2_CMD,
  34. PB9_PF_SD2_CLK,
  35. /* display */
  36. PA5_PF_LSCLK,
  37. PA6_PF_LD0,
  38. PA7_PF_LD1,
  39. PA8_PF_LD2,
  40. PA9_PF_LD3,
  41. PA10_PF_LD4,
  42. PA11_PF_LD5,
  43. PA12_PF_LD6,
  44. PA13_PF_LD7,
  45. PA14_PF_LD8,
  46. PA15_PF_LD9,
  47. PA16_PF_LD10,
  48. PA17_PF_LD11,
  49. PA18_PF_LD12,
  50. PA19_PF_LD13,
  51. PA20_PF_LD14,
  52. PA21_PF_LD15,
  53. PA22_PF_LD16,
  54. PA23_PF_LD17,
  55. PA24_PF_REV,
  56. PA25_PF_CLS,
  57. PA26_PF_PS,
  58. PA27_PF_SPL_SPR,
  59. PA28_PF_HSYNC,
  60. PA29_PF_VSYNC,
  61. PA30_PF_CONTRAST,
  62. PA31_PF_OE_ACD,
  63. /*
  64. * it seems the data line misses a pullup, so we must enable
  65. * the internal pullup as a local workaround
  66. */
  67. PD17_PF_I2C_DATA | GPIO_PUEN,
  68. PD18_PF_I2C_CLK,
  69. /* Camera */
  70. PB10_PF_CSI_D0,
  71. PB11_PF_CSI_D1,
  72. PB12_PF_CSI_D2,
  73. PB13_PF_CSI_D3,
  74. PB14_PF_CSI_D4,
  75. PB15_PF_CSI_MCLK,
  76. PB16_PF_CSI_PIXCLK,
  77. PB17_PF_CSI_D5,
  78. PB18_PF_CSI_D6,
  79. PB19_PF_CSI_D7,
  80. PB20_PF_CSI_VSYNC,
  81. PB21_PF_CSI_HSYNC,
  82. };
  83. static int pcm970_sdhc2_get_ro(struct device *dev)
  84. {
  85. return gpio_get_value(GPIO_PORTC + 28);
  86. }
  87. static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
  88. {
  89. int ret;
  90. ret = request_irq(IRQ_GPIOC(29), detect_irq, IRQF_TRIGGER_FALLING,
  91. "imx-mmc-detect", data);
  92. if (ret)
  93. return ret;
  94. ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
  95. if (ret) {
  96. free_irq(IRQ_GPIOC(29), data);
  97. return ret;
  98. }
  99. gpio_direction_input(GPIO_PORTC + 28);
  100. return 0;
  101. }
  102. static void pcm970_sdhc2_exit(struct device *dev, void *data)
  103. {
  104. free_irq(IRQ_GPIOC(29), data);
  105. gpio_free(GPIO_PORTC + 28);
  106. }
  107. static const struct imxmmc_platform_data sdhc_pdata __initconst = {
  108. .get_ro = pcm970_sdhc2_get_ro,
  109. .init = pcm970_sdhc2_init,
  110. .exit = pcm970_sdhc2_exit,
  111. };
  112. static struct imx_fb_videomode pcm970_modes[] = {
  113. {
  114. .mode = {
  115. .name = "Sharp-LQ035Q7",
  116. .refresh = 60,
  117. .xres = 240,
  118. .yres = 320,
  119. .pixclock = 188679, /* in ps (5.3MHz) */
  120. .hsync_len = 7,
  121. .left_margin = 5,
  122. .right_margin = 16,
  123. .vsync_len = 1,
  124. .upper_margin = 7,
  125. .lower_margin = 9,
  126. },
  127. /*
  128. * - HSYNC active high
  129. * - VSYNC active high
  130. * - clk notenabled while idle
  131. * - clock not inverted
  132. * - data not inverted
  133. * - data enable low active
  134. * - enable sharp mode
  135. */
  136. .pcr = 0xF00080C0,
  137. .bpp = 16,
  138. }, {
  139. .mode = {
  140. .name = "TX090",
  141. .refresh = 60,
  142. .xres = 240,
  143. .yres = 320,
  144. .pixclock = 38255,
  145. .left_margin = 144,
  146. .right_margin = 0,
  147. .upper_margin = 7,
  148. .lower_margin = 40,
  149. .hsync_len = 96,
  150. .vsync_len = 1,
  151. },
  152. /*
  153. * - HSYNC active low (1 << 22)
  154. * - VSYNC active low (1 << 23)
  155. * - clk notenabled while idle
  156. * - clock not inverted
  157. * - data not inverted
  158. * - data enable low active
  159. * - enable sharp mode
  160. */
  161. .pcr = 0xF0008080 | (1<<22) | (1<<23) | (1<<19),
  162. .bpp = 32,
  163. },
  164. };
  165. static const struct imx_fb_platform_data pcm038_fb_data __initconst = {
  166. .mode = pcm970_modes,
  167. .num_modes = ARRAY_SIZE(pcm970_modes),
  168. .pwmr = 0x00A903FF,
  169. .lscr1 = 0x00120300,
  170. .dmacr = 0x00020010,
  171. };
  172. static struct resource pcm970_sja1000_resources[] = {
  173. {
  174. .start = MX27_CS4_BASE_ADDR,
  175. .end = MX27_CS4_BASE_ADDR + 0x100 - 1,
  176. .flags = IORESOURCE_MEM,
  177. }, {
  178. .start = IRQ_GPIOE(19),
  179. .end = IRQ_GPIOE(19),
  180. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_LOWEDGE,
  181. },
  182. };
  183. static struct sja1000_platform_data pcm970_sja1000_platform_data = {
  184. .osc_freq = 16000000,
  185. .ocr = OCR_TX1_PULLDOWN | OCR_TX0_PUSHPULL,
  186. .cdr = CDR_CBP,
  187. };
  188. static struct platform_device pcm970_sja1000 = {
  189. .name = "sja1000_platform",
  190. .dev = {
  191. .platform_data = &pcm970_sja1000_platform_data,
  192. },
  193. .resource = pcm970_sja1000_resources,
  194. .num_resources = ARRAY_SIZE(pcm970_sja1000_resources),
  195. };
  196. /*
  197. * system init for baseboard usage. Will be called by pcm038 init.
  198. *
  199. * Add platform devices present on this baseboard and init
  200. * them from CPU side as far as required to use them later on
  201. */
  202. void __init pcm970_baseboard_init(void)
  203. {
  204. mxc_gpio_setup_multiple_pins(pcm970_pins, ARRAY_SIZE(pcm970_pins),
  205. "PCM970");
  206. imx27_add_imx_fb(&pcm038_fb_data);
  207. mxc_gpio_mode(GPIO_PORTC | 28 | GPIO_GPIO | GPIO_IN);
  208. imx27_add_mxc_mmc(1, &sdhc_pdata);
  209. platform_device_register(&pcm970_sja1000);
  210. }