mach-anubis.c 7.4 KB

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