board-apollon.c 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  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 <mach/hardware.h>
  30. #include <asm/mach-types.h>
  31. #include <asm/mach/arch.h>
  32. #include <asm/mach/flash.h>
  33. #include <mach/gpio.h>
  34. #include <plat/led.h>
  35. #include <plat/usb.h>
  36. #include <plat/board.h>
  37. #include <plat/common.h>
  38. #include <plat/gpmc.h>
  39. #include <plat/control.h>
  40. #include "mux.h"
  41. /* LED & Switch macros */
  42. #define LED0_GPIO13 13
  43. #define LED1_GPIO14 14
  44. #define LED2_GPIO15 15
  45. #define SW_ENTER_GPIO16 16
  46. #define SW_UP_GPIO17 17
  47. #define SW_DOWN_GPIO58 58
  48. #define APOLLON_FLASH_CS 0
  49. #define APOLLON_ETH_CS 1
  50. #define APOLLON_ETHR_GPIO_IRQ 74
  51. static struct mtd_partition apollon_partitions[] = {
  52. {
  53. .name = "X-Loader + U-Boot",
  54. .offset = 0,
  55. .size = SZ_128K,
  56. .mask_flags = MTD_WRITEABLE,
  57. },
  58. {
  59. .name = "params",
  60. .offset = MTDPART_OFS_APPEND,
  61. .size = SZ_128K,
  62. },
  63. {
  64. .name = "kernel",
  65. .offset = MTDPART_OFS_APPEND,
  66. .size = SZ_2M,
  67. },
  68. {
  69. .name = "rootfs",
  70. .offset = MTDPART_OFS_APPEND,
  71. .size = SZ_16M,
  72. },
  73. {
  74. .name = "filesystem00",
  75. .offset = MTDPART_OFS_APPEND,
  76. .size = SZ_32M,
  77. },
  78. {
  79. .name = "filesystem01",
  80. .offset = MTDPART_OFS_APPEND,
  81. .size = MTDPART_SIZ_FULL,
  82. },
  83. };
  84. static struct onenand_platform_data apollon_flash_data = {
  85. .parts = apollon_partitions,
  86. .nr_parts = ARRAY_SIZE(apollon_partitions),
  87. };
  88. static struct resource apollon_flash_resource[] = {
  89. [0] = {
  90. .flags = IORESOURCE_MEM,
  91. },
  92. };
  93. static struct platform_device apollon_onenand_device = {
  94. .name = "onenand-flash",
  95. .id = -1,
  96. .dev = {
  97. .platform_data = &apollon_flash_data,
  98. },
  99. .num_resources = ARRAY_SIZE(apollon_flash_resource),
  100. .resource = apollon_flash_resource,
  101. };
  102. static void __init apollon_flash_init(void)
  103. {
  104. unsigned long base;
  105. if (gpmc_cs_request(APOLLON_FLASH_CS, SZ_128K, &base) < 0) {
  106. printk(KERN_ERR "Cannot request OneNAND GPMC CS\n");
  107. return;
  108. }
  109. apollon_flash_resource[0].start = base;
  110. apollon_flash_resource[0].end = base + SZ_128K - 1;
  111. }
  112. static struct smc91x_platdata appolon_smc91x_info = {
  113. .flags = SMC91X_USE_16BIT | SMC91X_NOWAIT,
  114. .leda = RPC_LED_100_10,
  115. .ledb = RPC_LED_TX_RX,
  116. };
  117. static struct resource apollon_smc91x_resources[] = {
  118. [0] = {
  119. .flags = IORESOURCE_MEM,
  120. },
  121. [1] = {
  122. .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  123. .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  124. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHEDGE,
  125. },
  126. };
  127. static struct platform_device apollon_smc91x_device = {
  128. .name = "smc91x",
  129. .id = -1,
  130. .dev = {
  131. .platform_data = &appolon_smc91x_info,
  132. },
  133. .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
  134. .resource = apollon_smc91x_resources,
  135. };
  136. static struct platform_device apollon_lcd_device = {
  137. .name = "apollon_lcd",
  138. .id = -1,
  139. };
  140. static struct omap_led_config apollon_led_config[] = {
  141. {
  142. .cdev = {
  143. .name = "apollon:led0",
  144. },
  145. .gpio = LED0_GPIO13,
  146. },
  147. {
  148. .cdev = {
  149. .name = "apollon:led1",
  150. },
  151. .gpio = LED1_GPIO14,
  152. },
  153. {
  154. .cdev = {
  155. .name = "apollon:led2",
  156. },
  157. .gpio = LED2_GPIO15,
  158. },
  159. };
  160. static struct omap_led_platform_data apollon_led_data = {
  161. .nr_leds = ARRAY_SIZE(apollon_led_config),
  162. .leds = apollon_led_config,
  163. };
  164. static struct platform_device apollon_led_device = {
  165. .name = "omap-led",
  166. .id = -1,
  167. .dev = {
  168. .platform_data = &apollon_led_data,
  169. },
  170. };
  171. static struct platform_device *apollon_devices[] __initdata = {
  172. &apollon_onenand_device,
  173. &apollon_smc91x_device,
  174. &apollon_lcd_device,
  175. &apollon_led_device,
  176. };
  177. static inline void __init apollon_init_smc91x(void)
  178. {
  179. unsigned long base;
  180. unsigned int rate;
  181. struct clk *gpmc_fck;
  182. int eth_cs;
  183. gpmc_fck = clk_get(NULL, "gpmc_fck"); /* Always on ENABLE_ON_INIT */
  184. if (IS_ERR(gpmc_fck)) {
  185. WARN_ON(1);
  186. return;
  187. }
  188. clk_enable(gpmc_fck);
  189. rate = clk_get_rate(gpmc_fck);
  190. eth_cs = APOLLON_ETH_CS;
  191. /* Make sure CS1 timings are correct */
  192. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG1, 0x00011200);
  193. if (rate >= 160000000) {
  194. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f01);
  195. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080803);
  196. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1c0b1c0a);
  197. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  198. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  199. } else if (rate >= 130000000) {
  200. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  201. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  202. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  203. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x041f1F1F);
  204. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000004C4);
  205. } else {/* rate = 100000000 */
  206. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG2, 0x001f1f00);
  207. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG3, 0x00080802);
  208. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG4, 0x1C091C09);
  209. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG5, 0x031A1F1F);
  210. gpmc_cs_write_reg(eth_cs, GPMC_CS_CONFIG6, 0x000003C2);
  211. }
  212. if (gpmc_cs_request(APOLLON_ETH_CS, SZ_16M, &base) < 0) {
  213. printk(KERN_ERR "Failed to request GPMC CS for smc91x\n");
  214. goto out;
  215. }
  216. apollon_smc91x_resources[0].start = base + 0x300;
  217. apollon_smc91x_resources[0].end = base + 0x30f;
  218. udelay(100);
  219. omap_mux_init_gpio(74, 0);
  220. if (gpio_request(APOLLON_ETHR_GPIO_IRQ, "SMC91x irq") < 0) {
  221. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  222. APOLLON_ETHR_GPIO_IRQ);
  223. gpmc_cs_free(APOLLON_ETH_CS);
  224. goto out;
  225. }
  226. gpio_direction_input(APOLLON_ETHR_GPIO_IRQ);
  227. out:
  228. clk_disable(gpmc_fck);
  229. clk_put(gpmc_fck);
  230. }
  231. static struct omap_usb_config apollon_usb_config __initdata = {
  232. .register_dev = 1,
  233. .hmc_mode = 0x14, /* 0:dev 1:host1 2:disable */
  234. .pins[0] = 6,
  235. };
  236. static struct omap_lcd_config apollon_lcd_config __initdata = {
  237. .ctrl_name = "internal",
  238. };
  239. static struct omap_board_config_kernel apollon_config[] = {
  240. { OMAP_TAG_LCD, &apollon_lcd_config },
  241. };
  242. static void __init omap_apollon_init_irq(void)
  243. {
  244. omap_board_config = apollon_config;
  245. omap_board_config_size = ARRAY_SIZE(apollon_config);
  246. omap2_init_common_hw(NULL, NULL);
  247. omap_init_irq();
  248. omap_gpio_init();
  249. apollon_init_smc91x();
  250. }
  251. static void __init apollon_led_init(void)
  252. {
  253. /* LED0 - AA10 */
  254. omap_mux_init_signal("vlynq_clk.gpio_13", 0);
  255. gpio_request(LED0_GPIO13, "LED0");
  256. gpio_direction_output(LED0_GPIO13, 0);
  257. /* LED1 - AA6 */
  258. omap_mux_init_signal("vlynq_rx1.gpio_14", 0);
  259. gpio_request(LED1_GPIO14, "LED1");
  260. gpio_direction_output(LED1_GPIO14, 0);
  261. /* LED2 - AA4 */
  262. omap_mux_init_signal("vlynq_rx0.gpio_15", 0);
  263. gpio_request(LED2_GPIO15, "LED2");
  264. gpio_direction_output(LED2_GPIO15, 0);
  265. }
  266. static void __init apollon_usb_init(void)
  267. {
  268. /* USB device */
  269. /* DEVICE_SUSPEND */
  270. omap_mux_init_signal("mcbsp2_clkx.gpio_12", 0);
  271. gpio_request(12, "USB suspend");
  272. gpio_direction_output(12, 0);
  273. omap2_usbfs_init(&apollon_usb_config);
  274. }
  275. #ifdef CONFIG_OMAP_MUX
  276. static struct omap_board_mux board_mux[] __initdata = {
  277. { .reg_offset = OMAP_MUX_TERMINATOR },
  278. };
  279. #else
  280. #define board_mux NULL
  281. #endif
  282. static void __init omap_apollon_init(void)
  283. {
  284. u32 v;
  285. omap2420_mux_init(board_mux, OMAP_PACKAGE_ZAC);
  286. apollon_led_init();
  287. apollon_flash_init();
  288. apollon_usb_init();
  289. /* REVISIT: where's the correct place */
  290. omap_mux_init_signal("sys_nirq", OMAP_PULL_ENA | OMAP_PULL_UP);
  291. /* LCD PWR_EN */
  292. omap_mux_init_signal("mcbsp2_dr.gpio_11", OMAP_PULL_ENA | OMAP_PULL_UP);
  293. /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
  294. v = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
  295. v |= (1 << 24);
  296. omap_ctrl_writel(v, OMAP2_CONTROL_DEVCONF0);
  297. /*
  298. * Make sure the serial ports are muxed on at this point.
  299. * You have to mux them off in device drivers later on
  300. * if not needed.
  301. */
  302. platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
  303. omap_serial_init();
  304. }
  305. static void __init omap_apollon_map_io(void)
  306. {
  307. omap2_set_globals_242x();
  308. omap242x_map_common_io();
  309. }
  310. MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
  311. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  312. .phys_io = 0x48000000,
  313. .io_pg_offst = ((0xfa000000) >> 18) & 0xfffc,
  314. .boot_params = 0x80000100,
  315. .map_io = omap_apollon_map_io,
  316. .reserve = omap_reserve,
  317. .init_irq = omap_apollon_init_irq,
  318. .init_machine = omap_apollon_init,
  319. .timer = &omap_timer,
  320. MACHINE_END