board-am3517evm.c 10 KB

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