board-am3517evm.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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_i2c_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_i2c_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_tca6416_info_0[] = {
  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_ui_tca6416_info[] = {
  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_tca6416_info_0,
  182. ARRAY_SIZE(am3517evm_tca6416_info_0));
  183. omap_register_i2c_bus(3, 400, am3517evm_ui_tca6416_info,
  184. ARRAY_SIZE(am3517evm_ui_tca6416_info));
  185. return 0;
  186. }
  187. static int lcd_enabled;
  188. static int dvi_enabled;
  189. static void __init am3517_evm_display_init(void)
  190. {
  191. int r;
  192. omap_mux_init_gpio(LCD_PANEL_PWR, OMAP_PIN_INPUT_PULLUP);
  193. omap_mux_init_gpio(LCD_PANEL_BKLIGHT_PWR, OMAP_PIN_INPUT_PULLDOWN);
  194. omap_mux_init_gpio(LCD_PANEL_PWM, OMAP_PIN_INPUT_PULLDOWN);
  195. /*
  196. * Enable GPIO 182 = LCD Backlight Power
  197. */
  198. r = gpio_request(LCD_PANEL_BKLIGHT_PWR, "lcd_backlight_pwr");
  199. if (r) {
  200. printk(KERN_ERR "failed to get lcd_backlight_pwr\n");
  201. return;
  202. }
  203. gpio_direction_output(LCD_PANEL_BKLIGHT_PWR, 1);
  204. /*
  205. * Enable GPIO 181 = LCD Panel PWM
  206. */
  207. r = gpio_request(LCD_PANEL_PWM, "lcd_pwm");
  208. if (r) {
  209. printk(KERN_ERR "failed to get lcd_pwm\n");
  210. goto err_1;
  211. }
  212. gpio_direction_output(LCD_PANEL_PWM, 1);
  213. /*
  214. * Enable GPIO 176 = LCD Panel Power enable pin
  215. */
  216. r = gpio_request(LCD_PANEL_PWR, "lcd_panel_pwr");
  217. if (r) {
  218. printk(KERN_ERR "failed to get lcd_panel_pwr\n");
  219. goto err_2;
  220. }
  221. gpio_direction_output(LCD_PANEL_PWR, 1);
  222. printk(KERN_INFO "Display initialized successfully\n");
  223. return;
  224. err_2:
  225. gpio_free(LCD_PANEL_PWM);
  226. err_1:
  227. gpio_free(LCD_PANEL_BKLIGHT_PWR);
  228. }
  229. static int am3517_evm_panel_enable_lcd(struct omap_dss_device *dssdev)
  230. {
  231. if (dvi_enabled) {
  232. printk(KERN_ERR "cannot enable LCD, DVI is enabled\n");
  233. return -EINVAL;
  234. }
  235. gpio_set_value(LCD_PANEL_PWR, 1);
  236. lcd_enabled = 1;
  237. return 0;
  238. }
  239. static void am3517_evm_panel_disable_lcd(struct omap_dss_device *dssdev)
  240. {
  241. gpio_set_value(LCD_PANEL_PWR, 0);
  242. lcd_enabled = 0;
  243. }
  244. static struct omap_dss_device am3517_evm_lcd_device = {
  245. .type = OMAP_DISPLAY_TYPE_DPI,
  246. .name = "lcd",
  247. .driver_name = "sharp_lq_panel",
  248. .phy.dpi.data_lines = 16,
  249. .platform_enable = am3517_evm_panel_enable_lcd,
  250. .platform_disable = am3517_evm_panel_disable_lcd,
  251. };
  252. static int am3517_evm_panel_enable_tv(struct omap_dss_device *dssdev)
  253. {
  254. return 0;
  255. }
  256. static void am3517_evm_panel_disable_tv(struct omap_dss_device *dssdev)
  257. {
  258. }
  259. static struct omap_dss_device am3517_evm_tv_device = {
  260. .type = OMAP_DISPLAY_TYPE_VENC,
  261. .name = "tv",
  262. .driver_name = "venc",
  263. .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
  264. .platform_enable = am3517_evm_panel_enable_tv,
  265. .platform_disable = am3517_evm_panel_disable_tv,
  266. };
  267. static int am3517_evm_panel_enable_dvi(struct omap_dss_device *dssdev)
  268. {
  269. if (lcd_enabled) {
  270. printk(KERN_ERR "cannot enable DVI, LCD is enabled\n");
  271. return -EINVAL;
  272. }
  273. dvi_enabled = 1;
  274. return 0;
  275. }
  276. static void am3517_evm_panel_disable_dvi(struct omap_dss_device *dssdev)
  277. {
  278. dvi_enabled = 0;
  279. }
  280. static struct omap_dss_device am3517_evm_dvi_device = {
  281. .type = OMAP_DISPLAY_TYPE_DPI,
  282. .name = "dvi",
  283. .driver_name = "generic_panel",
  284. .phy.dpi.data_lines = 24,
  285. .platform_enable = am3517_evm_panel_enable_dvi,
  286. .platform_disable = am3517_evm_panel_disable_dvi,
  287. };
  288. static struct omap_dss_device *am3517_evm_dss_devices[] = {
  289. &am3517_evm_lcd_device,
  290. &am3517_evm_tv_device,
  291. &am3517_evm_dvi_device,
  292. };
  293. static struct omap_dss_board_info am3517_evm_dss_data = {
  294. .num_devices = ARRAY_SIZE(am3517_evm_dss_devices),
  295. .devices = am3517_evm_dss_devices,
  296. .default_device = &am3517_evm_lcd_device,
  297. };
  298. struct platform_device am3517_evm_dss_device = {
  299. .name = "omapdss",
  300. .id = -1,
  301. .dev = {
  302. .platform_data = &am3517_evm_dss_data,
  303. },
  304. };
  305. /*
  306. * Board initialization
  307. */
  308. static struct omap_board_config_kernel am3517_evm_config[] __initdata = {
  309. };
  310. static struct platform_device *am3517_evm_devices[] __initdata = {
  311. &am3517_evm_dss_device,
  312. };
  313. static void __init am3517_evm_init_irq(void)
  314. {
  315. omap_board_config = am3517_evm_config;
  316. omap_board_config_size = ARRAY_SIZE(am3517_evm_config);
  317. omap2_init_common_hw(NULL, NULL);
  318. omap_init_irq();
  319. omap_gpio_init();
  320. }
  321. static const struct ehci_hcd_omap_platform_data ehci_pdata __initconst = {
  322. .port_mode[0] = EHCI_HCD_OMAP_MODE_PHY,
  323. .port_mode[1] = EHCI_HCD_OMAP_MODE_PHY,
  324. .port_mode[2] = EHCI_HCD_OMAP_MODE_UNKNOWN,
  325. .phy_reset = true,
  326. .reset_gpio_port[0] = 57,
  327. .reset_gpio_port[1] = -EINVAL,
  328. .reset_gpio_port[2] = -EINVAL
  329. };
  330. #ifdef CONFIG_OMAP_MUX
  331. static struct omap_board_mux board_mux[] __initdata = {
  332. { .reg_offset = OMAP_MUX_TERMINATOR },
  333. };
  334. #else
  335. #define board_mux NULL
  336. #endif
  337. static struct resource am3517_hecc_resources[] = {
  338. {
  339. .start = AM35XX_IPSS_HECC_BASE,
  340. .end = AM35XX_IPSS_HECC_BASE + 0x3FFF,
  341. .flags = IORESOURCE_MEM,
  342. },
  343. {
  344. .start = INT_35XX_HECC0_IRQ,
  345. .end = INT_35XX_HECC0_IRQ,
  346. .flags = IORESOURCE_IRQ,
  347. },
  348. };
  349. static struct platform_device am3517_hecc_device = {
  350. .name = "ti_hecc",
  351. .id = -1,
  352. .num_resources = ARRAY_SIZE(am3517_hecc_resources),
  353. .resource = am3517_hecc_resources,
  354. };
  355. static struct ti_hecc_platform_data am3517_evm_hecc_pdata = {
  356. .scc_hecc_offset = AM35XX_HECC_SCC_HECC_OFFSET,
  357. .scc_ram_offset = AM35XX_HECC_SCC_RAM_OFFSET,
  358. .hecc_ram_offset = AM35XX_HECC_RAM_OFFSET,
  359. .mbx_offset = AM35XX_HECC_MBOX_OFFSET,
  360. .int_line = AM35XX_HECC_INT_LINE,
  361. .version = AM35XX_HECC_VERSION,
  362. };
  363. static void am3517_evm_hecc_init(struct ti_hecc_platform_data *pdata)
  364. {
  365. am3517_hecc_device.dev.platform_data = pdata;
  366. platform_device_register(&am3517_hecc_device);
  367. }
  368. static void __init am3517_evm_init(void)
  369. {
  370. omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
  371. am3517_evm_i2c_init();
  372. platform_add_devices(am3517_evm_devices,
  373. ARRAY_SIZE(am3517_evm_devices));
  374. omap_serial_init();
  375. /* Configure GPIO for EHCI port */
  376. omap_mux_init_gpio(57, OMAP_PIN_OUTPUT);
  377. usb_ehci_init(&ehci_pdata);
  378. am3517_evm_hecc_init(&am3517_evm_hecc_pdata);
  379. /* DSS */
  380. am3517_evm_display_init();
  381. /* RTC - S35390A */
  382. am3517_evm_rtc_init();
  383. i2c_register_board_info(1, am3517evm_i2c_boardinfo,
  384. ARRAY_SIZE(am3517evm_i2c_boardinfo));
  385. /*Ethernet*/
  386. am3517_evm_ethernet_init(&am3517_evm_emac_pdata);
  387. }
  388. static void __init am3517_evm_map_io(void)
  389. {
  390. omap2_set_globals_343x();
  391. omap34xx_map_common_io();
  392. }
  393. MACHINE_START(OMAP3517EVM, "OMAP3517/AM3517 EVM")
  394. .phys_io = 0x48000000,
  395. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  396. .boot_params = 0x80000100,
  397. .map_io = am3517_evm_map_io,
  398. .init_irq = am3517_evm_init_irq,
  399. .init_machine = am3517_evm_init,
  400. .timer = &omap_timer,
  401. MACHINE_END