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