board-am3517evm.c 13 KB

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