pcm970-baseboard.c 5.2 KB

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