board-apollon.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /*
  2. * linux/arch/arm/mach-omap2/board-apollon.c
  3. *
  4. * Copyright (C) 2005,2006 Samsung Electronics
  5. * Author: Kyungmin Park <kyungmin.park@samsung.com>
  6. *
  7. * Modified from mach-omap/omap2/board-h4.c
  8. *
  9. * Code for apollon OMAP2 board. Should work on many OMAP2 systems where
  10. * the bootloader passes the board-specific data to the kernel.
  11. * Do not put any board specific code to this file; create a new machine
  12. * type if you need custom low-level initializations.
  13. *
  14. * This program is free software; you can redistribute it and/or modify
  15. * it under the terms of the GNU General Public License version 2 as
  16. * published by the Free Software Foundation.
  17. */
  18. #include <linux/kernel.h>
  19. #include <linux/init.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/mtd/mtd.h>
  22. #include <linux/mtd/partitions.h>
  23. #include <linux/mtd/onenand.h>
  24. #include <linux/delay.h>
  25. #include <linux/leds.h>
  26. #include <linux/err.h>
  27. #include <linux/clk.h>
  28. #include <linux/smc91x.h>
  29. #include <linux/gpio.h>
  30. #include <mach/hardware.h>
  31. #include <asm/mach-types.h>
  32. #include <asm/mach/arch.h>
  33. #include <asm/mach/flash.h>
  34. #include <plat/led.h>
  35. #include <plat/usb.h>
  36. #include <plat/board.h>
  37. #include "common.h"
  38. #include <plat/gpmc.h>
  39. #include <video/omapdss.h>
  40. #include <video/omap-panel-generic-dpi.h>
  41. #include "mux.h"
  42. #include "control.h"
  43. /* LED & Switch macros */
  44. #define LED0_GPIO13 13
  45. #define LED1_GPIO14 14
  46. #define LED2_GPIO15 15
  47. #define SW_ENTER_GPIO16 16
  48. #define SW_UP_GPIO17 17
  49. #define SW_DOWN_GPIO58 58
  50. #define APOLLON_FLASH_CS 0
  51. #define APOLLON_ETH_CS 1
  52. #define APOLLON_ETHR_GPIO_IRQ 74
  53. static struct mtd_partition apollon_partitions[] = {
  54. {
  55. .name = "X-Loader + U-Boot",
  56. .offset = 0,
  57. .size = SZ_128K,
  58. .mask_flags = MTD_WRITEABLE,
  59. },
  60. {
  61. .name = "params",
  62. .offset = MTDPART_OFS_APPEND,
  63. .size = SZ_128K,
  64. },
  65. {
  66. .name = "kernel",
  67. .offset = MTDPART_OFS_APPEND,
  68. .size = SZ_2M,
  69. },
  70. {
  71. .name = "rootfs",
  72. .offset = MTDPART_OFS_APPEND,
  73. .size = SZ_16M,
  74. },
  75. {
  76. .name = "filesystem00",
  77. .offset = MTDPART_OFS_APPEND,
  78. .size = SZ_32M,
  79. },
  80. {
  81. .name = "filesystem01",
  82. .offset = MTDPART_OFS_APPEND,
  83. .size = MTDPART_SIZ_FULL,
  84. },
  85. };
  86. static struct onenand_platform_data apollon_flash_data = {
  87. .parts = apollon_partitions,
  88. .nr_parts = ARRAY_SIZE(apollon_partitions),
  89. };
  90. static struct resource apollon_flash_resource[] = {
  91. [0] = {
  92. .flags = IORESOURCE_MEM,
  93. },
  94. };
  95. static struct platform_device apollon_onenand_device = {
  96. .name = "onenand-flash",
  97. .id = -1,
  98. .dev = {
  99. .platform_data = &apollon_flash_data,
  100. },
  101. .num_resources = ARRAY_SIZE(apollon_flash_resource),
  102. .resource = apollon_flash_resource,
  103. };
  104. static void __init apollon_flash_init(void)
  105. {
  106. unsigned long base;
  107. if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) {
  108. printk(KERN_ERR "Cannot request OneNAND GPMC CS\n");
  109. return;
  110. }
  111. apollon_flash_resource[0].start = base;
  112. apollon_flash_resource[0].end = base + SZ_128K - 1;
  113. }
  114. static struct smc91x_platdata appolon_smc91x_info = {
  115. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  116. .leda = RPC_LED_100_10,
  117. .ledb = RPC_LED_TX_RX,
  118. };
  119. static struct resource apollon_smc91x_resources[] = {
  120. [0] = {
  121. .flags = IORESOURCE_MEM,
  122. },
  123. [1] = {
  124. .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  125. .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  126. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  127. },
  128. };
  129. static struct platform_device apollon_smc91x_device = {
  130. .name = "smc91x",
  131. .id = -1,
  132. .dev = {
  133. .platform_data = &appolon_smc91x_info,
  134. },
  135. .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
  136. .resource = apollon_smc91x_resources,
  137. };
  138. static struct omap_led_config apollon_led_config[] = {
  139. {
  140. .cdev = {
  141. .name = "apollon:led0",
  142. },
  143. .gpio = LED0_GPIO13,
  144. },
  145. {
  146. .cdev = {
  147. .name = "apollon:led1",
  148. },
  149. .gpio = LED1_GPIO14,
  150. },
  151. {
  152. .cdev = {
  153. .name = "apollon:led2",
  154. },
  155. .gpio = LED2_GPIO15,
  156. },
  157. };
  158. static struct omap_led_platform_data apollon_led_data = {
  159. .nr_leds = ARRAY_SIZE(apollon_led_config),
  160. .leds = apollon_led_config,
  161. };
  162. static struct platform_device apollon_led_device = {
  163. .name = "omap-led",
  164. .id = -1,
  165. .dev = {
  166. .platform_data = &apollon_led_data,
  167. },
  168. };
  169. static struct platform_device *apollon_devices[] __initdata = {
  170. &apollon_onenand_device,
  171. &apollon_smc91x_device,
  172. &apollon_led_device,
  173. };
  174. static inline void __init apollon_init_smc91x(void)
  175. {
  176. unsigned long base;
  177. unsigned int rate;
  178. struct clk *gpmc_fck;
  179. int eth_cs;
  180. int err;
  181. gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
  182. if (IS_ERR(gpmc_fck)) {
  183. WARN_ON(1);
  184. return;
  185. }
  186. clk_enable(gpmc_fck);
  187. rate = clk_get_rate(gpmc_fck);
  188. eth_cs = APOLLON_ETH_CS;
  189. /* Make sure CS1 timings are correct */
  190. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
  191. if (rate >= 160000000) {
  192. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
  193. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
  194. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
  195. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  196. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  197. } else if (rate >= 130000000) {
  198. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  199. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  200. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  201. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  202. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  203. } else {/* rate = 100000000 */
  204. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  205. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  206. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  207. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
  208. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
  209. }
  210. if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
  211. printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
  212. goto out;
  213. }
  214. apollon_smc91x_resources[0].start = base + 0x300;
  215. apollon_smc91x_resources[0].end = base + 0x30f;
  216. udelay(100);
  217. omap_mux_init_gpio(APOLLON_ETHR_GPIO_IRQ, 0);
  218. err = gpio_request_one(APOLLON_ETHR_GPIO_IRQ, GPIOF_IN, "SMC91x irq");
  219. if (err) {
  220. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  221. APOLLON_ETHR_GPIO_IRQ);
  222. gpmc_cs_free(APOLLON_ETH_CS);
  223. }
  224. out:
  225. clk_disable(gpmc_fck);
  226. clk_put(gpmc_fck);
  227. }
  228. static struct omap_usb_config apollon_usb_config __initdata = {
  229. .register_dev = 1,
  230. .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
  231. .pins[0] = 6,
  232. };
  233. static struct panel_generic_dpi_data apollon_panel_data = {
  234. .name = "apollon",
  235. };
  236. static struct omap_dss_device apollon_lcd_device = {
  237. .name = "lcd",
  238. .driver_name = "generic_dpi_panel",
  239. .type = OMAP_DISPLAY_TYPE_DPI,
  240. .phy.dpi.data_lines = 18,
  241. .data = &apollon_panel_data,
  242. };
  243. static struct omap_dss_device *apollon_dss_devices[] = {
  244. &apollon_lcd_device,
  245. };
  246. static struct omap_dss_board_info apollon_dss_data = {
  247. .num_devices = ARRAY_SIZE(apollon_dss_devices),
  248. .devices = apollon_dss_devices,
  249. .default_device = &apollon_lcd_device,
  250. };
  251. static struct gpio apollon_gpio_leds[] __initdata = {
  252. { LED0_GPIO13, GPIOF_OUT_INIT_LOW, "LED0" }, /* LED0 - AA10 */
  253. { LED1_GPIO14, GPIOF_OUT_INIT_LOW, "LED1" }, /* LED1 - AA6 */
  254. { LED2_GPIO15, GPIOF_OUT_INIT_LOW, "LED2" }, /* LED2 - AA4 */
  255. };
  256. static void __init apollon_led_init(void)
  257. {
  258. omap_mux_init_signal("vlynq_clk.gpio_13", 0);
  259. omap_mux_init_signal("vlynq_rx1.gpio_14", 0);
  260. omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
  261. gpio_request_array(apollon_gpio_leds, ARRAY_SIZE(apollon_gpio_leds));
  262. }
  263. static void __init apollon_usb_init(void)
  264. {
  265. /* USB device */
  266. /* DEVICE_SUSPEND */
  267. omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
  268. gpio_request_one(12, GPIOF_OUT_INIT_LOW, "USB suspend");
  269. omap2_usbfs_init(&apollon_usb_config);
  270. }
  271. #ifdef CONFIG_OMAP_MUX
  272. static struct omap_board_mux board_mux[] __initdata = {
  273. { .reg_offset = OMAP_MUX_TERMINATOR },
  274. };
  275. #endif
  276. static void __init omap_apollon_init(void)
  277. {
  278. u32 v;
  279. omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
  280. apollon_init_smc91x();
  281. apollon_led_init();
  282. apollon_flash_init();
  283. apollon_usb_init();
  284. /* REVISIT: where's the correct place */
  285. omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP);
  286. /* LCD PWR_EN */
  287. omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
  288. /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
  289. v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  290. v |= (1 << 24);
  291. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  292. /*
  293. * Make sure the serial ports are muxed on at this point.
  294. * You have to mux them off in device drivers later on
  295. * if not needed.
  296. */
  297. platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
  298. omap_serial_init();
  299. omap_sdrc_init(NULL, NULL);
  300. omap_display_init(&apollon_dss_data);
  301. }
  302. MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
  303. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  304. .atag_offset = 0x100,
  305. .reserve = omap_reserve,
  306. .map_io = omap242x_map_io,
  307. .init_early = omap2420_init_early,
  308. .init_irq = omap2_init_irq,
  309. .handle_irq = omap2_intc_handle_irq,
  310. .init_machine = omap_apollon_init,
  311. .timer = &omap2_timer,
  312. .restart = omap_prcm_restart,
  313. MACHINE_END