board-am3517evm.c 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. /*
  2. * linux/arch/arm/mach-omap2/board-am3517evm.c
  3. *
  4. * Copyright (C) 2009 Texas Instruments Incorporated
  5. * Author: Ranjith Lohithakshan <ranjithl@ti.com>
  6. *
  7. * Based on mach-omap2/board-omap3evm.c
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
  14. * whether express or implied; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/clk.h>
  21. #include <linux/platform_device.h>
  22. #include <linux/gpio.h>
  23. #include <linux/i2c/pca953x.h>
  24. #include <linux/can/platform/ti_hecc.h>
  25. #include <linux/davinci_emac.h>
  26. #include <linux/mmc/host.h>
  27. #include <linux/usb/musb.h>
  28. #include <linux/platform_data/gpio-omap.h>
  29. #include "am35xx.h"
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/map.h>
  33. #include "common.h"
  34. #include <video/omapdss.h>
  35. #include <video/omap-panel-generic-dpi.h>
  36. #include <video/omap-panel-tfp410.h>
  37. #include "am35xx-emac.h"
  38. #include "mux.h"
  39. #include "control.h"
  40. #include "hsmmc.h"
  41. #define LCD_PANEL_PWR 176
  42. #define LCD_PANEL_BKLIGHT_PWR 182
  43. #define LCD_PANEL_PWM 181
  44. static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = {
  45. {
  46. I2C_BOARD_INFO("s35390a", 0x30),
  47. },
  48. };
  49. /*
  50. * RTC - S35390A
  51. */
  52. #define GPIO_RTCS35390A_IRQ 55
  53. static void __init am3517_evm_rtc_init(void)
  54. {
  55. int r;
  56. omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
  57. r = gpio_request_one(GPIO_RTCS35390A_IRQ, GPIOF_IN, "rtcs35390a-irq");
  58. if (r < 0) {
  59. printk(KERN_WARNING "failed to request GPIO#%d\n",
  60. GPIO_RTCS35390A_IRQ);
  61. return;
  62. }
  63. am3517evm_i2c1_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
  64. }
  65. /*
  66. * I2C GPIO Expander - TCA6416
  67. */
  68. /* Mounted on Base-Board */
  69. static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
  70. .gpio_base = OMAP_MAX_GPIO_LINES,
  71. };
  72. static struct i2c_board_info __initdata am3517evm_i2c2_boardinfo[] = {
  73. {
  74. I2C_BOARD_INFO("tlv320aic23", 0x1A),
  75. },
  76. {
  77. I2C_BOARD_INFO("tca6416", 0x21),
  78. .platform_data = &am3517evm_gpio_expander_info_0,
  79. },
  80. };
  81. /* Mounted on UI Card */
  82. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
  83. .gpio_base = OMAP_MAX_GPIO_LINES + 16,
  84. };
  85. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
  86. .gpio_base = OMAP_MAX_GPIO_LINES + 32,
  87. };
  88. static struct i2c_board_info __initdata am3517evm_i2c3_boardinfo[] = {
  89. {
  90. I2C_BOARD_INFO("tca6416", 0x20),
  91. .platform_data = &am3517evm_ui_gpio_expander_info_1,
  92. },
  93. {
  94. I2C_BOARD_INFO("tca6416", 0x21),
  95. .platform_data = &am3517evm_ui_gpio_expander_info_2,
  96. },
  97. };
  98. static int __init am3517_evm_i2c_init(void)
  99. {
  100. omap_register_i2c_bus(1, 400, NULL, 0);
  101. omap_register_i2c_bus(2, 400, am3517evm_i2c2_boardinfo,
  102. ARRAY_SIZE(am3517evm_i2c2_boardinfo));
  103. omap_register_i2c_bus(3, 400, am3517evm_i2c3_boardinfo,
  104. ARRAY_SIZE(am3517evm_i2c3_boardinfo));
  105. return 0;
  106. }
  107. static int lcd_enabled;
  108. static int dvi_enabled;
  109. #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
  110. defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
  111. static struct gpio am3517_evm_dss_gpios[] __initdata = {
  112. /* GPIO 182 = LCD Backlight Power */
  113. { LCD_PANEL_BKLIGHT_PWR, GPIOF_OUT_INIT_HIGH, "lcd_backlight_pwr" },
  114. /* GPIO 181 = LCD Panel PWM */
  115. { LCD_PANEL_PWM, GPIOF_OUT_INIT_HIGH, "lcd bl enable" },
  116. /* GPIO 176 = LCD Panel Power enable pin */
  117. { LCD_PANEL_PWR, GPIOF_OUT_INIT_HIGH, "dvi enable" },
  118. };
  119. static void __init am3517_evm_display_init(void)
  120. {
  121. int r;
  122. omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
  123. omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
  124. omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
  125. r = gpio_request_array(am3517_evm_dss_gpios,
  126. ARRAY_SIZE(am3517_evm_dss_gpios));
  127. if (r) {
  128. printk(KERN_ERR "failed to get DSS panel control GPIOs\n");
  129. return;
  130. }
  131. printk(KERN_INFO "Display initialized successfully\n");
  132. }
  133. #else
  134. static void __init am3517_evm_display_init(void) {}
  135. #endif
  136. static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
  137. {
  138. if (dvi_enabled) {
  139. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  140. return -EINVAL;
  141. }
  142. gpio_set_value(LCD_PANEL_PWR, 1);
  143. lcd_enabled = 1;
  144. return 0;
  145. }
  146. static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
  147. {
  148. gpio_set_value(LCD_PANEL_PWR, 0);
  149. lcd_enabled = 0;
  150. }
  151. static struct panel_generic_dpi_data lcd_panel = {
  152. .name = "sharp_lq",
  153. .platform_enable = am3517_evm_panel_enable_lcd,
  154. .platform_disable = am3517_evm_panel_disable_lcd,
  155. };
  156. static struct omap_dss_device am3517_evm_lcd_device = {
  157. .type = OMAP_DISPLAY_TYPE_DPI,
  158. .name = "lcd",
  159. .driver_name = "generic_dpi_panel",
  160. .data = &lcd_panel,
  161. .phy.dpi.data_lines = 16,
  162. };
  163. static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
  164. {
  165. return 0;
  166. }
  167. static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
  168. {
  169. }
  170. static struct omap_dss_device am3517_evm_tv_device = {
  171. .type = OMAP_DISPLAY_TYPE_VENC,
  172. .name = "tv",
  173. .driver_name = "venc",
  174. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  175. .platform_enable = am3517_evm_panel_enable_tv,
  176. .platform_disable = am3517_evm_panel_disable_tv,
  177. };
  178. static struct tfp410_platform_data dvi_panel = {
  179. .power_down_gpio = -1,
  180. .i2c_bus_num = -1,
  181. };
  182. static struct omap_dss_device am3517_evm_dvi_device = {
  183. .type = OMAP_DISPLAY_TYPE_DPI,
  184. .name = "dvi",
  185. .driver_name = "tfp410",
  186. .data = &dvi_panel,
  187. .phy.dpi.data_lines = 24,
  188. };
  189. static struct omap_dss_device *am3517_evm_dss_devices[] = {
  190. &am3517_evm_lcd_device,
  191. &am3517_evm_tv_device,
  192. &am3517_evm_dvi_device,
  193. };
  194. static struct omap_dss_board_info am3517_evm_dss_data = {
  195. .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
  196. .devices = am3517_evm_dss_devices,
  197. .default_device = &am3517_evm_lcd_device,
  198. };
  199. /*
  200. * Board initialization
  201. */
  202. static struct omap_musb_board_data musb_board_data = {
  203. .interface_type = MUSB_INTERFACE_ULPI,
  204. .mode = MUSB_OTG,
  205. .power = 500,
  206. .set_phy_power = am35x_musb_phy_power,
  207. .clear_irq = am35x_musb_clear_irq,
  208. .set_mode = am35x_set_mode,
  209. .reset = am35x_musb_reset,
  210. };
  211. static __init void am3517_evm_musb_init(void)
  212. {
  213. u32 devconf2;
  214. /*
  215. * Set up USB clock/mode in the DEVCONF2 register.
  216. */
  217. devconf2 = omap_ctrl_readl(AM35XX_CONTROL_DEVCONF2);
  218. /* USB2.0 PHY reference clock is 13 MHz */
  219. devconf2 &= ~(CONF2_REFFREQ | CONF2_OTGMODE | CONF2_PHY_GPIOMODE);
  220. devconf2 |= CONF2_REFFREQ_13MHZ | CONF2_SESENDEN | CONF2_VBDTCTEN
  221. | CONF2_DATPOL;
  222. omap_ctrl_writel(devconf2, AM35XX_CONTROL_DEVCONF2);
  223. usb_musb_init(&musb_board_data);
  224. }
  225. static __init void am3517_evm_mcbsp1_init(void)
  226. {
  227. u32 devconf0;
  228. /* McBSP1 CLKR/FSR signal to be connected to CLKX/FSX pin */
  229. devconf0 = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  230. devconf0 |= OMAP2_MCBSP1_CLKR_MASK | OMAP2_MCBSP1_FSR_MASK;
  231. omap_ctrl_writel(devconf0, OMAP2_CONTROL_DEVCONF0);
  232. }
  233. static struct usbhs_omap_platform_data usbhs_bdata __initdata = {
  234. .port_mode[0] = OMAP_EHCI_PORT_MODE_PHY,
  235. #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
  236. defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
  237. .port_mode[1] = OMAP_USBHS_PORT_MODE_UNUSED,
  238. #else
  239. .port_mode[1] = OMAP_EHCI_PORT_MODE_PHY,
  240. #endif
  241. .port_mode[2] = OMAP_USBHS_PORT_MODE_UNUSED,
  242. .phy_reset = true,
  243. .reset_gpio_port[0] = 57,
  244. .reset_gpio_port[1] = -EINVAL,
  245. .reset_gpio_port[2] = -EINVAL
  246. };
  247. #ifdef CONFIG_OMAP_MUX
  248. static struct omap_board_mux board_mux[] __initdata = {
  249. /* USB OTG DRVVBUS offset = 0x212 */
  250. OMAP3_MUX(SAD2D_MCAD23, OMAP_MUX_MODE0 | OMAP_PIN_INPUT_PULLDOWN),
  251. { .reg_offset = OMAP_MUX_TERMINATOR },
  252. };
  253. #endif
  254. static struct resource am3517_hecc_resources[] = {
  255. {
  256. .start = AM35XX_IPSS_HECC_BASE,
  257. .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
  258. .flags = IORESOURCE_MEM,
  259. },
  260. {
  261. .start = 24 + OMAP_INTC_START,
  262. .flags = IORESOURCE_IRQ,
  263. },
  264. };
  265. static struct platform_device am3517_hecc_device = {
  266. .name = "ti_hecc",
  267. .id = -1,
  268. .num_resources = ARRAY_SIZE(am3517_hecc_resources),
  269. .resource = am3517_hecc_resources,
  270. };
  271. static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
  272. .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
  273. .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
  274. .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
  275. .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
  276. .int_line = AM35XX_HECC_INT_LINE,
  277. .version = AM35XX_HECC_VERSION,
  278. };
  279. static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
  280. {
  281. am3517_hecc_device.dev.platform_data = pdata;
  282. platform_device_register(&am3517_hecc_device);
  283. }
  284. static struct omap2_hsmmc_info mmc[] = {
  285. {
  286. .mmc = 1,
  287. .caps = MMC_CAP_4_BIT_DATA,
  288. .gpio_cd = 127,
  289. .gpio_wp = 126,
  290. },
  291. {
  292. .mmc = 2,
  293. .caps = MMC_CAP_4_BIT_DATA,
  294. .gpio_cd = 128,
  295. .gpio_wp = 129,
  296. },
  297. {} /* Terminator */
  298. };
  299. static void __init am3517_evm_init(void)
  300. {
  301. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  302. am3517_evm_i2c_init();
  303. omap_display_init(&am3517_evm_dss_data);
  304. omap_serial_init();
  305. omap_sdrc_init(NULL, NULL);
  306. /* Configure GPIO for EHCI port */
  307. omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
  308. usbhs_init(&usbhs_bdata);
  309. am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
  310. /* DSS */
  311. am3517_evm_display_init();
  312. /* RTC - S35390A */
  313. am3517_evm_rtc_init();
  314. i2c_register_board_info(1, am3517evm_i2c1_boardinfo,
  315. ARRAY_SIZE(am3517evm_i2c1_boardinfo));
  316. /*Ethernet*/
  317. am35xx_emac_init(AM35XX_DEFAULT_MDIO_FREQUENCY, 1);
  318. /* MUSB */
  319. am3517_evm_musb_init();
  320. /* McBSP1 */
  321. am3517_evm_mcbsp1_init();
  322. /* MMC init function */
  323. omap_hsmmc_init(mmc);
  324. }
  325. MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
  326. .atag_offset = 0x100,
  327. .reserve = omap_reserve,
  328. .map_io = omap3_map_io,
  329. .init_early = am35xx_init_early,
  330. .init_irq = omap3_init_irq,
  331. .handle_irq = omap3_intc_handle_irq,
  332. .init_machine = am3517_evm_init,
  333. .init_late = am35xx_init_late,
  334. .init_time = omap3_sync32k_timer_init,
  335. .restart = omap3xxx_restart,
  336. MACHINE_END