mach-osiris.c 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /* linux/arch/arm/mach-s3c2440/mach-osiris.c
  2. *
  3. * Copyright (c) 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/device.h>
  18. #include <linux/serial_core.h>
  19. #include <asm/mach/arch.h>
  20. #include <asm/mach/map.h>
  21. #include <asm/mach/irq.h>
  22. #include <asm/arch/osiris-map.h>
  23. #include <asm/arch/osiris-cpld.h>
  24. #include <asm/hardware.h>
  25. #include <asm/io.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/arch/regs-serial.h>
  29. #include <asm/arch/regs-gpio.h>
  30. #include <asm/arch/regs-mem.h>
  31. #include <asm/arch/regs-lcd.h>
  32. #include <asm/arch/nand.h>
  33. #include <linux/mtd/mtd.h>
  34. #include <linux/mtd/nand.h>
  35. #include <linux/mtd/nand_ecc.h>
  36. #include <linux/mtd/partitions.h>
  37. #include <asm/plat-s3c24xx/clock.h>
  38. #include <asm/plat-s3c24xx/devs.h>
  39. #include <asm/plat-s3c24xx/cpu.h>
  40. /* onboard perihperal map */
  41. static struct map_desc osiris_iodesc[] __initdata = {
  42. /* ISA IO areas (may be over-written later) */
  43. {
  44. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  45. .pfn = __phys_to_pfn(S3C2410_CS5),
  46. .length = SZ_16M,
  47. .type = MT_DEVICE,
  48. }, {
  49. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  50. .pfn = __phys_to_pfn(S3C2410_CS5),
  51. .length = SZ_16M,
  52. .type = MT_DEVICE,
  53. },
  54. /* CPLD control registers */
  55. {
  56. .virtual = (u32)OSIRIS_VA_CTRL0,
  57. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL0),
  58. .length = SZ_16K,
  59. .type = MT_DEVICE,
  60. }, {
  61. .virtual = (u32)OSIRIS_VA_CTRL1,
  62. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL1),
  63. .length = SZ_16K,
  64. .type = MT_DEVICE,
  65. }, {
  66. .virtual = (u32)OSIRIS_VA_CTRL2,
  67. .pfn = __phys_to_pfn(OSIRIS_PA_CTRL2),
  68. .length = SZ_16K,
  69. .type = MT_DEVICE,
  70. }, {
  71. .virtual = (u32)OSIRIS_VA_IDREG,
  72. .pfn = __phys_to_pfn(OSIRIS_PA_IDREG),
  73. .length = SZ_16K,
  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 osiris_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 osiris_uartcfgs[] __initdata = {
  95. [0] = {
  96. .hwport = 0,
  97. .flags = 0,
  98. .ucon = UCON,
  99. .ulcon = ULCON,
  100. .ufcon = UFCON,
  101. .clocks = osiris_serial_clocks,
  102. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  103. },
  104. [1] = {
  105. .hwport = 1,
  106. .flags = 0,
  107. .ucon = UCON,
  108. .ulcon = ULCON,
  109. .ufcon = UFCON,
  110. .clocks = osiris_serial_clocks,
  111. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  112. },
  113. [2] = {
  114. .hwport = 2,
  115. .flags = 0,
  116. .ucon = UCON,
  117. .ulcon = ULCON,
  118. .ufcon = UFCON,
  119. .clocks = osiris_serial_clocks,
  120. .clocks_size = ARRAY_SIZE(osiris_serial_clocks),
  121. }
  122. };
  123. /* NAND Flash on Osiris board */
  124. static int external_map[] = { 2 };
  125. static int chip0_map[] = { 0 };
  126. static int chip1_map[] = { 1 };
  127. static struct mtd_partition osiris_default_nand_part[] = {
  128. [0] = {
  129. .name = "Boot Agent",
  130. .size = SZ_16K,
  131. .offset = 0,
  132. },
  133. [1] = {
  134. .name = "/boot",
  135. .size = SZ_4M - SZ_16K,
  136. .offset = SZ_16K,
  137. },
  138. [2] = {
  139. .name = "user1",
  140. .offset = SZ_4M,
  141. .size = SZ_32M - SZ_4M,
  142. },
  143. [3] = {
  144. .name = "user2",
  145. .offset = SZ_32M,
  146. .size = MTDPART_SIZ_FULL,
  147. }
  148. };
  149. /* the Osiris has 3 selectable slots for nand-flash, the two
  150. * on-board chip areas, as well as the external slot.
  151. *
  152. * Note, there is no current hot-plug support for the External
  153. * socket.
  154. */
  155. static struct s3c2410_nand_set osiris_nand_sets[] = {
  156. [1] = {
  157. .name = "External",
  158. .nr_chips = 1,
  159. .nr_map = external_map,
  160. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  161. .partitions = osiris_default_nand_part,
  162. },
  163. [0] = {
  164. .name = "chip0",
  165. .nr_chips = 1,
  166. .nr_map = chip0_map,
  167. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  168. .partitions = osiris_default_nand_part,
  169. },
  170. [2] = {
  171. .name = "chip1",
  172. .nr_chips = 1,
  173. .nr_map = chip1_map,
  174. .nr_partitions = ARRAY_SIZE(osiris_default_nand_part),
  175. .partitions = osiris_default_nand_part,
  176. },
  177. };
  178. static void osiris_nand_select(struct s3c2410_nand_set *set, int slot)
  179. {
  180. unsigned int tmp;
  181. slot = set->nr_map[slot] & 3;
  182. pr_debug("osiris_nand: selecting slot %d (set %p,%p)\n",
  183. slot, set, set->nr_map);
  184. tmp = __raw_readb(OSIRIS_VA_CTRL0);
  185. tmp &= ~OSIRIS_CTRL0_NANDSEL;
  186. tmp |= slot;
  187. pr_debug("osiris_nand: ctrl0 now %02x\n", tmp);
  188. __raw_writeb(tmp, OSIRIS_VA_CTRL0);
  189. }
  190. static struct s3c2410_platform_nand osiris_nand_info = {
  191. .tacls = 25,
  192. .twrph0 = 60,
  193. .twrph1 = 60,
  194. .nr_sets = ARRAY_SIZE(osiris_nand_sets),
  195. .sets = osiris_nand_sets,
  196. .select_chip = osiris_nand_select,
  197. };
  198. /* PCMCIA control and configuration */
  199. static struct resource osiris_pcmcia_resource[] = {
  200. [0] = {
  201. .start = 0x0f000000,
  202. .end = 0x0f100000,
  203. .flags = IORESOURCE_MEM,
  204. },
  205. [1] = {
  206. .start = 0x0c000000,
  207. .end = 0x0c100000,
  208. .flags = IORESOURCE_MEM,
  209. }
  210. };
  211. static struct platform_device osiris_pcmcia = {
  212. .name = "osiris-pcmcia",
  213. .id = -1,
  214. .num_resources = ARRAY_SIZE(osiris_pcmcia_resource),
  215. .resource = osiris_pcmcia_resource,
  216. };
  217. /* Standard Osiris devices */
  218. static struct platform_device *osiris_devices[] __initdata = {
  219. &s3c_device_i2c,
  220. &s3c_device_nand,
  221. &osiris_pcmcia,
  222. };
  223. static struct clk *osiris_clocks[] = {
  224. &s3c24xx_dclk0,
  225. &s3c24xx_dclk1,
  226. &s3c24xx_clkout0,
  227. &s3c24xx_clkout1,
  228. &s3c24xx_uclk,
  229. };
  230. static void __init osiris_map_io(void)
  231. {
  232. unsigned long flags;
  233. /* initialise the clocks */
  234. s3c24xx_dclk0.parent = NULL;
  235. s3c24xx_dclk0.rate = 12*1000*1000;
  236. s3c24xx_dclk1.parent = NULL;
  237. s3c24xx_dclk1.rate = 24*1000*1000;
  238. s3c24xx_clkout0.parent = &s3c24xx_dclk0;
  239. s3c24xx_clkout1.parent = &s3c24xx_dclk1;
  240. s3c24xx_uclk.parent = &s3c24xx_clkout1;
  241. s3c24xx_register_clocks(osiris_clocks, ARRAY_SIZE(osiris_clocks));
  242. s3c_device_nand.dev.platform_data = &osiris_nand_info;
  243. s3c24xx_init_io(osiris_iodesc, ARRAY_SIZE(osiris_iodesc));
  244. s3c24xx_init_clocks(0);
  245. s3c24xx_init_uarts(osiris_uartcfgs, ARRAY_SIZE(osiris_uartcfgs));
  246. /* fix bus configuration (nBE settings wrong on ABLE pre v2.20) */
  247. local_irq_save(flags);
  248. __raw_writel(__raw_readl(S3C2410_BWSCON) | S3C2410_BWSCON_ST1 | S3C2410_BWSCON_ST2 | S3C2410_BWSCON_ST3 | S3C2410_BWSCON_ST4 | S3C2410_BWSCON_ST5, S3C2410_BWSCON);
  249. local_irq_restore(flags);
  250. /* write-protect line to the NAND */
  251. s3c2410_gpio_setpin(S3C2410_GPA0, 1);
  252. }
  253. static void __init osiris_init(void)
  254. {
  255. platform_add_devices(osiris_devices, ARRAY_SIZE(osiris_devices));
  256. };
  257. MACHINE_START(OSIRIS, "Simtec-OSIRIS")
  258. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  259. .phys_io = S3C2410_PA_UART,
  260. .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc,
  261. .boot_params = S3C2410_SDRAM_PA + 0x100,
  262. .map_io = osiris_map_io,
  263. .init_machine = osiris_init,
  264. .init_irq = s3c24xx_init_irq,
  265. .timer = &s3c24xx_timer,
  266. MACHINE_END