mach-anubis.c 9.3 KB

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