board-apollon.c 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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/irq.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/delay.h>
  27. #include <asm/hardware.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/flash.h>
  31. #include <asm/arch/gpio.h>
  32. #include <asm/arch/mux.h>
  33. #include <asm/arch/usb.h>
  34. #include <asm/arch/board.h>
  35. #include <asm/arch/common.h>
  36. #include "prcm-regs.h"
  37. /* LED & Switch macros */
  38. #define LED0_GPIO13 13
  39. #define LED1_GPIO14 14
  40. #define LED2_GPIO15 15
  41. #define SW_ENTER_GPIO16 16
  42. #define SW_UP_GPIO17 17
  43. #define SW_DOWN_GPIO58 58
  44. static struct mtd_partition apollon_partitions[] = {
  45. {
  46. .name = "X-Loader + U-Boot",
  47. .offset = 0,
  48. .size = SZ_128K,
  49. .mask_flags = MTD_WRITEABLE,
  50. },
  51. {
  52. .name = "params",
  53. .offset = MTDPART_OFS_APPEND,
  54. .size = SZ_128K,
  55. },
  56. {
  57. .name = "kernel",
  58. .offset = MTDPART_OFS_APPEND,
  59. .size = SZ_2M,
  60. },
  61. {
  62. .name = "rootfs",
  63. .offset = MTDPART_OFS_APPEND,
  64. .size = SZ_16M,
  65. },
  66. {
  67. .name = "filesystem00",
  68. .offset = MTDPART_OFS_APPEND,
  69. .size = SZ_32M,
  70. },
  71. {
  72. .name = "filesystem01",
  73. .offset = MTDPART_OFS_APPEND,
  74. .size = MTDPART_SIZ_FULL,
  75. },
  76. };
  77. static struct flash_platform_data apollon_flash_data = {
  78. .parts = apollon_partitions,
  79. .nr_parts = ARRAY_SIZE(apollon_partitions),
  80. };
  81. static struct resource apollon_flash_resource = {
  82. .start = APOLLON_CS0_BASE,
  83. .end = APOLLON_CS0_BASE + SZ_128K,
  84. .flags = IORESOURCE_MEM,
  85. };
  86. static struct platform_device apollon_onenand_device = {
  87. .name = "onenand",
  88. .id = -1,
  89. .dev = {
  90. .platform_data = &apollon_flash_data,
  91. },
  92. .num_resources = ARRAY_SIZE(&apollon_flash_resource),
  93. .resource = &apollon_flash_resource,
  94. };
  95. static struct resource apollon_smc91x_resources[] = {
  96. [0] = {
  97. .start = APOLLON_ETHR_START, /* Physical */
  98. .end = APOLLON_ETHR_START + 0xf,
  99. .flags = IORESOURCE_MEM,
  100. },
  101. [1] = {
  102. .start = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  103. .end = OMAP_GPIO_IRQ(APOLLON_ETHR_GPIO_IRQ),
  104. .flags = IORESOURCE_IRQ,
  105. },
  106. };
  107. static struct platform_device apollon_smc91x_device = {
  108. .name = "smc91x",
  109. .id = -1,
  110. .num_resources = ARRAY_SIZE(apollon_smc91x_resources),
  111. .resource = apollon_smc91x_resources,
  112. };
  113. static struct platform_device apollon_lcd_device = {
  114. .name = "apollon_lcd",
  115. .id = -1,
  116. };
  117. static struct platform_device *apollon_devices[] __initdata = {
  118. &apollon_onenand_device,
  119. &apollon_smc91x_device,
  120. &apollon_lcd_device,
  121. };
  122. static inline void __init apollon_init_smc91x(void)
  123. {
  124. /* Make sure CS1 timings are correct */
  125. GPMC_CONFIG1_1 = 0x00011203;
  126. GPMC_CONFIG2_1 = 0x001f1f01;
  127. GPMC_CONFIG3_1 = 0x00080803;
  128. GPMC_CONFIG4_1 = 0x1c091c09;
  129. GPMC_CONFIG5_1 = 0x041f1f1f;
  130. GPMC_CONFIG6_1 = 0x000004c4;
  131. GPMC_CONFIG7_1 = 0x00000f40 | (APOLLON_CS1_BASE >> 24);
  132. udelay(100);
  133. omap_cfg_reg(W4__24XX_GPIO74);
  134. if (omap_request_gpio(APOLLON_ETHR_GPIO_IRQ) < 0) {
  135. printk(KERN_ERR "Failed to request GPIO%d for smc91x IRQ\n",
  136. APOLLON_ETHR_GPIO_IRQ);
  137. return;
  138. }
  139. omap_set_gpio_direction(APOLLON_ETHR_GPIO_IRQ, 1);
  140. }
  141. static void __init omap_apollon_init_irq(void)
  142. {
  143. omap2_init_common_hw();
  144. omap_init_irq();
  145. omap_gpio_init();
  146. apollon_init_smc91x();
  147. }
  148. static struct omap_uart_config apollon_uart_config __initdata = {
  149. .enabled_uarts = (1 << 0) | (0 << 1) | (0 << 2),
  150. };
  151. static struct omap_mmc_config apollon_mmc_config __initdata = {
  152. .mmc [0] = {
  153. .enabled = 1,
  154. .wire4 = 1,
  155. .wp_pin = -1,
  156. .power_pin = -1,
  157. .switch_pin = -1,
  158. },
  159. };
  160. static struct omap_lcd_config apollon_lcd_config __initdata = {
  161. .ctrl_name = "internal",
  162. };
  163. static struct omap_board_config_kernel apollon_config[] = {
  164. { OMAP_TAG_UART, &apollon_uart_config },
  165. { OMAP_TAG_MMC, &apollon_mmc_config },
  166. { OMAP_TAG_LCD, &apollon_lcd_config },
  167. };
  168. static void __init apollon_led_init(void)
  169. {
  170. /* LED0 - AA10 */
  171. omap_cfg_reg(AA10_242X_GPIO13);
  172. omap_request_gpio(LED0_GPIO13);
  173. omap_set_gpio_direction(LED0_GPIO13, 0);
  174. omap_set_gpio_dataout(LED0_GPIO13, 0);
  175. /* LED1 - AA6 */
  176. omap_cfg_reg(AA6_242X_GPIO14);
  177. omap_request_gpio(LED1_GPIO14);
  178. omap_set_gpio_direction(LED1_GPIO14, 0);
  179. omap_set_gpio_dataout(LED1_GPIO14, 0);
  180. /* LED2 - AA4 */
  181. omap_cfg_reg(AA4_242X_GPIO15);
  182. omap_request_gpio(LED2_GPIO15);
  183. omap_set_gpio_direction(LED2_GPIO15, 0);
  184. omap_set_gpio_dataout(LED2_GPIO15, 0);
  185. }
  186. static irqreturn_t apollon_sw_interrupt(int irq, void *ignored)
  187. {
  188. static unsigned int led0, led1, led2;
  189. if (irq == OMAP_GPIO_IRQ(SW_ENTER_GPIO16))
  190. omap_set_gpio_dataout(LED0_GPIO13, led0 ^= 1);
  191. else if (irq == OMAP_GPIO_IRQ(SW_UP_GPIO17))
  192. omap_set_gpio_dataout(LED1_GPIO14, led1 ^= 1);
  193. else if (irq == OMAP_GPIO_IRQ(SW_DOWN_GPIO58))
  194. omap_set_gpio_dataout(LED2_GPIO15, led2 ^= 1);
  195. return IRQ_HANDLED;
  196. }
  197. static void __init apollon_sw_init(void)
  198. {
  199. /* Enter SW - Y11 */
  200. omap_cfg_reg(Y11_242X_GPIO16);
  201. omap_request_gpio(SW_ENTER_GPIO16);
  202. omap_set_gpio_direction(SW_ENTER_GPIO16, 1);
  203. /* Up SW - AA12 */
  204. omap_cfg_reg(AA12_242X_GPIO17);
  205. omap_request_gpio(SW_UP_GPIO17);
  206. omap_set_gpio_direction(SW_UP_GPIO17, 1);
  207. /* Down SW - AA8 */
  208. omap_cfg_reg(AA8_242X_GPIO58);
  209. omap_request_gpio(SW_DOWN_GPIO58);
  210. omap_set_gpio_direction(SW_DOWN_GPIO58, 1);
  211. set_irq_type(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), IRQT_RISING);
  212. if (request_irq(OMAP_GPIO_IRQ(SW_ENTER_GPIO16), &apollon_sw_interrupt,
  213. IRQF_SHARED, "enter sw",
  214. &apollon_sw_interrupt))
  215. return;
  216. set_irq_type(OMAP_GPIO_IRQ(SW_UP_GPIO17), IRQT_RISING);
  217. if (request_irq(OMAP_GPIO_IRQ(SW_UP_GPIO17), &apollon_sw_interrupt,
  218. IRQF_SHARED, "up sw",
  219. &apollon_sw_interrupt))
  220. return;
  221. set_irq_type(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), IRQT_RISING);
  222. if (request_irq(OMAP_GPIO_IRQ(SW_DOWN_GPIO58), &apollon_sw_interrupt,
  223. IRQF_SHARED, "down sw",
  224. &apollon_sw_interrupt))
  225. return;
  226. }
  227. static void __init omap_apollon_init(void)
  228. {
  229. apollon_led_init();
  230. apollon_sw_init();
  231. /* REVISIT: where's the correct place */
  232. omap_cfg_reg(W19_24XX_SYS_NIRQ);
  233. /* Use Interal loop-back in MMC/SDIO Module Input Clock selection */
  234. CONTROL_DEVCONF |= (1 << 24);
  235. /*
  236. * Make sure the serial ports are muxed on at this point.
  237. * You have to mux them off in device drivers later on
  238. * if not needed.
  239. */
  240. platform_add_devices(apollon_devices, ARRAY_SIZE(apollon_devices));
  241. omap_board_config = apollon_config;
  242. omap_board_config_size = ARRAY_SIZE(apollon_config);
  243. omap_serial_init();
  244. }
  245. static void __init omap_apollon_map_io(void)
  246. {
  247. omap2_map_common_io();
  248. }
  249. MACHINE_START(OMAP_APOLLON, "OMAP24xx Apollon")
  250. /* Maintainer: Kyungmin Park <kyungmin.park@samsung.com> */
  251. .phys_io = 0x48000000,
  252. .io_pg_offst = ((0xd8000000) >> 18) & 0xfffc,
  253. .boot_params = 0x80000100,
  254. .map_io = omap_apollon_map_io,
  255. .init_irq = omap_apollon_init_irq,
  256. .init_machine = omap_apollon_init,
  257. .timer = &omap_timer,
  258. MACHINE_END