mach-anubis.c 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. /* linux/arch/arm/mach-s3c2440/mach-anubis.c
  2. *
  3. * Copyright (c) 2003-2005 Simtec Electronics
  4. * http://armlinux.simtec.co.uk/
  5. * Ben Dooks <ben@simtec.co.uk>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/list.h>
  15. #include <linux/timer.h>
  16. #include <linux/init.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/platform_device.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/map.h>
  21. #include <asm/mach/irq.h>
  22. #include <asm/arch/anubis-map.h>
  23. #include <asm/arch/anubis-irq.h>
  24. #include <asm/arch/anubis-cpld.h>
  25. #include <asm/hardware.h>
  26. #include <asm/io.h>
  27. #include <asm/irq.h>
  28. #include <asm/mach-types.h>
  29. #include <asm/arch/regs-serial.h>
  30. #include <asm/arch/regs-gpio.h>
  31. #include <asm/arch/regs-mem.h>
  32. #include <asm/arch/regs-lcd.h>
  33. #include <asm/arch/nand.h>
  34. #include <linux/mtd/mtd.h>
  35. #include <linux/mtd/nand.h>
  36. #include <linux/mtd/nand_ecc.h>
  37. #include <linux/mtd/partitions.h>
  38. #include <net/ax88796.h>
  39. #include <asm/plat-s3c24xx/clock.h>
  40. #include <asm/plat-s3c24xx/devs.h>
  41. #include <asm/plat-s3c24xx/cpu.h>
  42. #define COPYRIGHT ", (c) 2005 Simtec Electronics"
  43. static struct map_desc anubis_iodesc[] __initdata = {
  44. /* ISA IO areas */
  45. {
  46. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  47. .pfn = __phys_to_pfn(0x0),
  48. .length = SZ_4M,
  49. .type = MT_DEVICE,
  50. }, {
  51. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  52. .pfn = __phys_to_pfn(0x0),
  53. .length = SZ_4M,
  54. .type = MT_DEVICE,
  55. },
  56. /* we could possibly compress the next set down into a set of smaller tables
  57. * pagetables, but that would mean using an L2 section, and it still means
  58. * we cannot actually feed the same register to an LDR due to 16K spacing
  59. */
  60. /* CPLD control registers */
  61. {
  62. .virtual = (u32)ANUBIS_VA_CTRL1,
  63. .pfn = __phys_to_pfn(ANUBIS_PA_CTRL1),
  64. .length = SZ_4K,
  65. .type = MT_DEVICE,
  66. }, {
  67. .virtual = (u32)ANUBIS_VA_IDREG,
  68. .pfn = __phys_to_pfn(ANUBIS_PA_IDREG),
  69. .length = SZ_4K,
  70. .type = MT_DEVICE,
  71. },
  72. };
  73. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  74. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  75. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  76. static struct s3c24xx_uart_clksrc anubis_serial_clocks[] = {
  77. [0] = {
  78. .name = "uclk",
  79. .divisor = 1,
  80. .min_baud = 0,
  81. .max_baud = 0,
  82. },
  83. [1] = {
  84. .name = "pclk",
  85. .divisor = 1,
  86. .min_baud = 0,
  87. .max_baud = 0,
  88. }
  89. };
  90. static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = {
  91. [0] = {
  92. .hwport = 0,
  93. .flags = 0,
  94. .ucon = UCON,
  95. .ulcon = ULCON,
  96. .ufcon = UFCON,
  97. .clocks = anubis_serial_clocks,
  98. .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
  99. },
  100. [1] = {
  101. .hwport = 2,
  102. .flags = 0,
  103. .ucon = UCON,
  104. .ulcon = ULCON,
  105. .ufcon = UFCON,
  106. .clocks = anubis_serial_clocks,
  107. .clocks_size = ARRAY_SIZE(anubis_serial_clocks),
  108. },
  109. };
  110. /* NAND Flash on Anubis board */
  111. static int external_map[] = { 2 };
  112. static int chip0_map[] = { 0 };
  113. static int chip1_map[] = { 1 };
  114. static struct mtd_partition anubis_default_nand_part[] = {
  115. [0] = {
  116. .name = "Boot Agent",
  117. .size = SZ_16K,
  118. .offset = 0,
  119. },
  120. [1] = {
  121. .name = "/boot",
  122. .size = SZ_4M - SZ_16K,
  123. .offset = SZ_16K,
  124. },
  125. [2] = {
  126. .name = "user1",
  127. .offset = SZ_4M,
  128. .size = SZ_32M - SZ_4M,
  129. },
  130. [3] = {
  131. .name = "user2",
  132. .offset = SZ_32M,
  133. .size = MTDPART_SIZ_FULL,
  134. }
  135. };
  136. /* the Anubis has 3 selectable slots for nand-flash, the two
  137. * on-board chip areas, as well as the external slot.
  138. *
  139. * Note, there is no current hot-plug support for the External
  140. * socket.
  141. */
  142. static struct s3c2410_nand_set anubis_nand_sets[] = {
  143. [1] = {
  144. .name = "External",
  145. .nr_chips = 1,
  146. .nr_map = external_map,
  147. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  148. .partitions = anubis_default_nand_part,
  149. },
  150. [0] = {
  151. .name = "chip0",
  152. .nr_chips = 1,
  153. .nr_map = chip0_map,
  154. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  155. .partitions = anubis_default_nand_part,
  156. },
  157. [2] = {
  158. .name = "chip1",
  159. .nr_chips = 1,
  160. .nr_map = chip1_map,
  161. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  162. .partitions = anubis_default_nand_part,
  163. },
  164. };
  165. static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
  166. {
  167. unsigned int tmp;
  168. slot = set->nr_map[slot] & 3;
  169. pr_debug("anubis_nand: selecting slot %d (set %p,%p)\n",
  170. slot, set, set->nr_map);
  171. tmp = __raw_readb(ANUBIS_VA_CTRL1);
  172. tmp &= ~ANUBIS_CTRL1_NANDSEL;
  173. tmp |= slot;
  174. pr_debug("anubis_nand: ctrl1 now %02x\n", tmp);
  175. __raw_writeb(tmp, ANUBIS_VA_CTRL1);
  176. }
  177. static struct s3c2410_platform_nand anubis_nand_info = {
  178. .tacls = 25,
  179. .twrph0 = 55,
  180. .twrph1 = 40,
  181. .nr_sets = ARRAY_SIZE(anubis_nand_sets),
  182. .sets = anubis_nand_sets,
  183. .select_chip = anubis_nand_select,
  184. };
  185. /* IDE channels */
  186. static struct resource anubis_ide0_resource[] = {
  187. {
  188. .start = S3C2410_CS3,
  189. .end = S3C2410_CS3 + (8*32) - 1,
  190. .flags = IORESOURCE_MEM,
  191. }, {
  192. .start = S3C2410_CS3 + (1<<26),
  193. .end = S3C2410_CS3 + (1<<26) + (8*32) - 1,
  194. .flags = IORESOURCE_MEM,
  195. }, {
  196. .start = IRQ_IDE0,
  197. .end = IRQ_IDE0,
  198. .flags = IORESOURCE_IRQ,
  199. },
  200. };
  201. static struct platform_device anubis_device_ide0 = {
  202. .name = "simtec-ide",
  203. .id = 0,
  204. .num_resources = ARRAY_SIZE(anubis_ide0_resource),
  205. .resource = anubis_ide0_resource,
  206. };
  207. static struct resource anubis_ide1_resource[] = {
  208. {
  209. .start = S3C2410_CS4,
  210. .end = S3C2410_CS4 + (8*32) - 1,
  211. .flags = IORESOURCE_MEM,
  212. }, {
  213. .start = S3C2410_CS4 + (1<<26),
  214. .end = S3C2410_CS4 + (1<<26) + (8*32) - 1,
  215. .flags = IORESOURCE_MEM,
  216. }, {
  217. .start = IRQ_IDE0,
  218. .end = IRQ_IDE0,
  219. .flags = IORESOURCE_IRQ,
  220. },
  221. };
  222. static struct platform_device anubis_device_ide1 = {
  223. .name = "simtec-ide",
  224. .id = 1,
  225. .num_resources = ARRAY_SIZE(anubis_ide1_resource),
  226. .resource = anubis_ide1_resource,
  227. };
  228. /* Asix AX88796 10/100 ethernet controller */
  229. static struct ax_plat_data anubis_asix_platdata = {
  230. .flags = AXFLG_MAC_FROMDEV,
  231. .wordlength = 2,
  232. .dcr_val = 0x48,
  233. .rcr_val = 0x40,
  234. };
  235. static struct resource anubis_asix_resource[] = {
  236. [0] = {
  237. .start = S3C2410_CS5,
  238. .end = S3C2410_CS5 + (0x20 * 0x20) -1,
  239. .flags = IORESOURCE_MEM
  240. },
  241. [1] = {
  242. .start = IRQ_ASIX,
  243. .end = IRQ_ASIX,
  244. .flags = IORESOURCE_IRQ
  245. }
  246. };
  247. static struct platform_device anubis_device_asix = {
  248. .name = "ax88796",
  249. .id = 0,
  250. .num_resources = ARRAY_SIZE(anubis_asix_resource),
  251. .resource = anubis_asix_resource,
  252. .dev = {
  253. .platform_data = &anubis_asix_platdata,
  254. }
  255. };
  256. /* Standard Anubis devices */
  257. static struct platform_device *anubis_devices[] __initdata = {
  258. &s3c_device_usb,
  259. &s3c_device_wdt,
  260. &s3c_device_adc,
  261. &s3c_device_i2c,
  262. &s3c_device_rtc,
  263. &s3c_device_nand,
  264. &anubis_device_ide0,
  265. &anubis_device_ide1,
  266. &anubis_device_asix,
  267. };
  268. static struct clk *anubis_clocks[] = {
  269. &s3c24xx_dclk0,
  270. &s3c24xx_dclk1,
  271. &s3c24xx_clkout0,
  272. &s3c24xx_clkout1,
  273. &s3c24xx_uclk,
  274. };
  275. static void __init anubis_map_io(void)
  276. {
  277. /* initialise the clocks */
  278. s3c24xx_dclk0.parent = NULL;
  279. s3c24xx_dclk0.rate = 12*1000*1000;
  280. s3c24xx_dclk1.parent = NULL;
  281. s3c24xx_dclk1.rate = 24*1000*1000;
  282. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  283. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  284. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  285. s3c24xx_register_clocks(anubis_clocks, ARRAY_SIZE(anubis_clocks));
  286. s3c_device_nand.dev.platform_data = &anubis_nand_info;
  287. s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
  288. s3c24xx_init_clocks(0);
  289. s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
  290. /* ensure that the GPIO is setup */
  291. s3c2410_gpio_setpin(S3C2410_GPA0, 1);
  292. }
  293. static void __init anubis_init(void)
  294. {
  295. platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices));
  296. }
  297. MACHINE_START(ANUBIS, "Simtec-Anubis")
  298. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  299. .phys_io = S3C2410_PA_UART,
  300. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  301. .boot_params = S3C2410_SDRAM_PA + 0x100,
  302. .map_io = anubis_map_io,
  303. .init_machine = anubis_init,
  304. .init_irq = s3c24xx_init_irq,
  305. .timer = &s3c24xx_timer,
  306. MACHINE_END