board-am3517evm.c 13 KB

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