board-am3517evm.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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/platform_device.h>
  21. #include <linux/gpio.h>
  22. #include <linux/i2c/pca953x.h>
  23. #include <linux/can/platform/ti_hecc.h>
  24. #include <linux/davinci_emac.h>
  25. #include <mach/hardware.h>
  26. #include <mach/am35xx.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/map.h>
  30. #include <plat/board.h>
  31. #include <plat/common.h>
  32. #include <plat/control.h>
  33. #include <plat/usb.h>
  34. #include <plat/display.h>
  35. #include "mux.h"
  36. #define AM35XX_EVM_PHY_MASK (0xF)
  37. #define AM35XX_EVM_MDIO_FREQUENCY (1000000)
  38. static struct emac_platform_data am3517_evm_emac_pdata = {
  39. .phy_mask = AM35XX_EVM_PHY_MASK,
  40. .mdio_max_freq = AM35XX_EVM_MDIO_FREQUENCY,
  41. .rmii_en = 1,
  42. };
  43. static struct resource am3517_emac_resources[] = {
  44. {
  45. .start = AM35XX_IPSS_EMAC_BASE,
  46. .end = AM35XX_IPSS_EMAC_BASE + 0x3FFFF,
  47. .flags = IORESOURCE_MEM,
  48. },
  49. {
  50. .start = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
  51. .end = INT_35XX_EMAC_C0_RXTHRESH_IRQ,
  52. .flags = IORESOURCE_IRQ,
  53. },
  54. {
  55. .start = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
  56. .end = INT_35XX_EMAC_C0_RX_PULSE_IRQ,
  57. .flags = IORESOURCE_IRQ,
  58. },
  59. {
  60. .start = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
  61. .end = INT_35XX_EMAC_C0_TX_PULSE_IRQ,
  62. .flags = IORESOURCE_IRQ,
  63. },
  64. {
  65. .start = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
  66. .end = INT_35XX_EMAC_C0_MISC_PULSE_IRQ,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. static struct platform_device am3517_emac_device = {
  71. .name = "davinci_emac",
  72. .id = -1,
  73. .num_resources = ARRAY_SIZE(am3517_emac_resources),
  74. .resource = am3517_emac_resources,
  75. };
  76. static void am3517_enable_ethernet_int(void)
  77. {
  78. u32 regval;
  79. regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
  80. regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
  81. AM35XX_CPGMAC_C0_TX_PULSE_CLR |
  82. AM35XX_CPGMAC_C0_MISC_PULSE_CLR |
  83. AM35XX_CPGMAC_C0_RX_THRESH_CLR);
  84. omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
  85. regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
  86. }
  87. static void am3517_disable_ethernet_int(void)
  88. {
  89. u32 regval;
  90. regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
  91. regval = (regval | AM35XX_CPGMAC_C0_RX_PULSE_CLR |
  92. AM35XX_CPGMAC_C0_TX_PULSE_CLR);
  93. omap_ctrl_writel(regval, AM35XX_CONTROL_LVL_INTR_CLEAR);
  94. regval = omap_ctrl_readl(AM35XX_CONTROL_LVL_INTR_CLEAR);
  95. }
  96. void am3517_evm_ethernet_init(struct emac_platform_data *pdata)
  97. {
  98. unsigned int regval;
  99. pdata->ctrl_reg_offset = AM35XX_EMAC_CNTRL_OFFSET;
  100. pdata->ctrl_mod_reg_offset = AM35XX_EMAC_CNTRL_MOD_OFFSET;
  101. pdata->ctrl_ram_offset = AM35XX_EMAC_CNTRL_RAM_OFFSET;
  102. pdata->mdio_reg_offset = AM35XX_EMAC_MDIO_OFFSET;
  103. pdata->ctrl_ram_size = AM35XX_EMAC_CNTRL_RAM_SIZE;
  104. pdata->version = EMAC_VERSION_2;
  105. pdata->hw_ram_addr = AM35XX_EMAC_HW_RAM_ADDR;
  106. pdata->interrupt_enable = am3517_enable_ethernet_int;
  107. pdata->interrupt_disable = am3517_disable_ethernet_int;
  108. am3517_emac_device.dev.platform_data = pdata;
  109. platform_device_register(&am3517_emac_device);
  110. regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
  111. regval = regval & (~(AM35XX_CPGMACSS_SW_RST));
  112. omap_ctrl_writel(regval, AM35XX_CONTROL_IP_SW_RESET);
  113. regval = omap_ctrl_readl(AM35XX_CONTROL_IP_SW_RESET);
  114. return ;
  115. }
  116. #define LCD_PANEL_PWR 176
  117. #define LCD_PANEL_BKLIGHT_PWR 182
  118. #define LCD_PANEL_PWM 181
  119. static struct i2c_board_info __initdata am3517evm_i2c1_boardinfo[] = {
  120. {
  121. I2C_BOARD_INFO("s35390a", 0x30),
  122. .type = "s35390a",
  123. },
  124. };
  125. /*
  126. * RTC - S35390A
  127. */
  128. #define GPIO_RTCS35390A_IRQ 55
  129. static void __init am3517_evm_rtc_init(void)
  130. {
  131. int r;
  132. omap_mux_init_gpio(GPIO_RTCS35390A_IRQ, OMAP_PIN_INPUT_PULLUP);
  133. r = gpio_request(GPIO_RTCS35390A_IRQ, "rtcs35390a-irq");
  134. if (r < 0) {
  135. printk(KERN_WARNING "failed to request GPIO#%d\n",
  136. GPIO_RTCS35390A_IRQ);
  137. return;
  138. }
  139. r = gpio_direction_input(GPIO_RTCS35390A_IRQ);
  140. if (r < 0) {
  141. printk(KERN_WARNING "GPIO#%d cannot be configured as input\n",
  142. GPIO_RTCS35390A_IRQ);
  143. gpio_free(GPIO_RTCS35390A_IRQ);
  144. return;
  145. }
  146. am3517evm_i2c1_boardinfo[0].irq = gpio_to_irq(GPIO_RTCS35390A_IRQ);
  147. }
  148. /*
  149. * I2C GPIO Expander - TCA6416
  150. */
  151. /* Mounted on Base-Board */
  152. static struct pca953x_platform_data am3517evm_gpio_expander_info_0 = {
  153. .gpio_base = OMAP_MAX_GPIO_LINES,
  154. };
  155. static struct i2c_board_info __initdata am3517evm_i2c2_boardinfo[] = {
  156. {
  157. I2C_BOARD_INFO("tca6416", 0x21),
  158. .platform_data = &am3517evm_gpio_expander_info_0,
  159. },
  160. };
  161. /* Mounted on UI Card */
  162. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_1 = {
  163. .gpio_base = OMAP_MAX_GPIO_LINES + 16,
  164. };
  165. static struct pca953x_platform_data am3517evm_ui_gpio_expander_info_2 = {
  166. .gpio_base = OMAP_MAX_GPIO_LINES + 32,
  167. };
  168. static struct i2c_board_info __initdata am3517evm_i2c3_boardinfo[] = {
  169. {
  170. I2C_BOARD_INFO("tca6416", 0x20),
  171. .platform_data = &am3517evm_ui_gpio_expander_info_1,
  172. },
  173. {
  174. I2C_BOARD_INFO("tca6416", 0x21),
  175. .platform_data = &am3517evm_ui_gpio_expander_info_2,
  176. },
  177. };
  178. static int __init am3517_evm_i2c_init(void)
  179. {
  180. omap_register_i2c_bus(1, 400, NULL, 0);
  181. omap_register_i2c_bus(2, 400, am3517evm_i2c2_boardinfo,
  182. ARRAY_SIZE(am3517evm_i2c2_boardinfo));
  183. omap_register_i2c_bus(3, 400, am3517evm_i2c3_boardinfo,
  184. ARRAY_SIZE(am3517evm_i2c3_boardinfo));
  185. return 0;
  186. }
  187. static int lcd_enabled;
  188. static int dvi_enabled;
  189. #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
  190. defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
  191. static void __init am3517_evm_display_init(void)
  192. {
  193. int r;
  194. omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
  195. omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
  196. omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
  197. /*
  198. * Enable GPIO 182 = LCD Backlight Power
  199. */
  200. r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
  201. if (r) {
  202. printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
  203. return;
  204. }
  205. gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
  206. /*
  207. * Enable GPIO 181 = LCD Panel PWM
  208. */
  209. r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
  210. if (r) {
  211. printk(KERN_ERR "failed to get lcd_pwm\n");
  212. goto err_1;
  213. }
  214. gpio_direction_output(LCD_PANEL_PWM, 1);
  215. /*
  216. * Enable GPIO 176 = LCD Panel Power enable pin
  217. */
  218. r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
  219. if (r) {
  220. printk(KERN_ERR "failed to get lcd_panel_pwr\n");
  221. goto err_2;
  222. }
  223. gpio_direction_output(LCD_PANEL_PWR, 1);
  224. printk(KERN_INFO "Display initialized successfully\n");
  225. return;
  226. err_2:
  227. gpio_free(LCD_PANEL_PWM);
  228. err_1:
  229. gpio_free(LCD_PANEL_BKLIGHT_PWR);
  230. }
  231. #else
  232. static void __init am3517_evm_display_init(void) {}
  233. #endif
  234. static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
  235. {
  236. if (dvi_enabled) {
  237. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  238. return -EINVAL;
  239. }
  240. gpio_set_value(LCD_PANEL_PWR, 1);
  241. lcd_enabled = 1;
  242. return 0;
  243. }
  244. static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
  245. {
  246. gpio_set_value(LCD_PANEL_PWR, 0);
  247. lcd_enabled = 0;
  248. }
  249. static struct omap_dss_device am3517_evm_lcd_device = {
  250. .type = OMAP_DISPLAY_TYPE_DPI,
  251. .name = "lcd",
  252. .driver_name = "sharp_lq_panel",
  253. .phy.dpi.data_lines = 16,
  254. .platform_enable = am3517_evm_panel_enable_lcd,
  255. .platform_disable = am3517_evm_panel_disable_lcd,
  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 omap_dss_device am3517_evm_dvi_device = {
  286. .type = OMAP_DISPLAY_TYPE_DPI,
  287. .name = "dvi",
  288. .driver_name = "generic_panel",
  289. .phy.dpi.data_lines = 24,
  290. .platform_enable = am3517_evm_panel_enable_dvi,
  291. .platform_disable = am3517_evm_panel_disable_dvi,
  292. };
  293. static struct omap_dss_device *am3517_evm_dss_devices[] = {
  294. &am3517_evm_lcd_device,
  295. &am3517_evm_tv_device,
  296. &am3517_evm_dvi_device,
  297. };
  298. static struct omap_dss_board_info am3517_evm_dss_data = {
  299. .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
  300. .devices = am3517_evm_dss_devices,
  301. .default_device = &am3517_evm_lcd_device,
  302. };
  303. struct platform_device am3517_evm_dss_device = {
  304. .name = "omapdss",
  305. .id = -1,
  306. .dev = {
  307. .platform_data = &am3517_evm_dss_data,
  308. },
  309. };
  310. /*
  311. * Board initialization
  312. */
  313. static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
  314. };
  315. static struct platform_device *am3517_evm_devices[] __initdata = {
  316. &am3517_evm_dss_device,
  317. };
  318. static void __init am3517_evm_init_irq(void)
  319. {
  320. omap_board_config = am3517_evm_config;
  321. omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
  322. omap2_init_common_hw(NULL, NULL);
  323. omap_init_irq();
  324. omap_gpio_init();
  325. }
  326. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  327. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  328. #if defined(CONFIG_PANEL_SHARP_LQ043T1DG01) || \
  329. defined(CONFIG_PANEL_SHARP_LQ043T1DG01_MODULE)
  330. .port_mode[1] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  331. #else
  332. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  333. #endif
  334. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  335. .phy_reset = true,
  336. .reset_gpio_port[0] = 57,
  337. .reset_gpio_port[1] = -EINVAL,
  338. .reset_gpio_port[2] = -EINVAL
  339. };
  340. #ifdef CONFIG_OMAP_MUX
  341. static struct omap_board_mux board_mux[] __initdata = {
  342. { .reg_offset = OMAP_MUX_TERMINATOR },
  343. };
  344. #else
  345. #define board_mux NULL
  346. #endif
  347. static struct resource am3517_hecc_resources[] = {
  348. {
  349. .start = AM35XX_IPSS_HECC_BASE,
  350. .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
  351. .flags = IORESOURCE_MEM,
  352. },
  353. {
  354. .start = INT_35XX_HECC0_IRQ,
  355. .end = INT_35XX_HECC0_IRQ,
  356. .flags = IORESOURCE_IRQ,
  357. },
  358. };
  359. static struct platform_device am3517_hecc_device = {
  360. .name = "ti_hecc",
  361. .id = -1,
  362. .num_resources = ARRAY_SIZE(am3517_hecc_resources),
  363. .resource = am3517_hecc_resources,
  364. };
  365. static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
  366. .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
  367. .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
  368. .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
  369. .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
  370. .int_line = AM35XX_HECC_INT_LINE,
  371. .version = AM35XX_HECC_VERSION,
  372. };
  373. static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
  374. {
  375. am3517_hecc_device.dev.platform_data = pdata;
  376. platform_device_register(&am3517_hecc_device);
  377. }
  378. static void __init am3517_evm_init(void)
  379. {
  380. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  381. am3517_evm_i2c_init();
  382. platform_add_devices(am3517_evm_devices,
  383. ARRAY_SIZE(am3517_evm_devices));
  384. omap_serial_init();
  385. /* Configure GPIO for EHCI port */
  386. omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
  387. usb_ehci_init(&ehci_pdata);
  388. am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
  389. /* DSS */
  390. am3517_evm_display_init();
  391. /* RTC - S35390A */
  392. am3517_evm_rtc_init();
  393. i2c_register_board_info(1, am3517evm_i2c1_boardinfo,
  394. ARRAY_SIZE(am3517evm_i2c1_boardinfo));
  395. /*Ethernet*/
  396. am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
  397. }
  398. MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
  399. .phys_io = 0x48000000,
  400. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  401. .boot_params = 0x80000100,
  402. .map_io = omap3_map_io,
  403. .reserve = omap_reserve,
  404. .init_irq = am3517_evm_init_irq,
  405. .init_machine = am3517_evm_init,
  406. .timer = &omap_timer,
  407. MACHINE_END