mach-anubis.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. /* linux/arch/arm/mach-s3c2440/mach-anubis.c
  2. *
  3. * Copyright 2003-2009 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/gpio.h>
  18. #include <linux/serial_core.h>
  19. #include <linux/serial_s3c.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/ata_platform.h>
  22. #include <linux/i2c.h>
  23. #include <linux/io.h>
  24. #include <linux/sm501.h>
  25. #include <linux/sm501-regs.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <asm/mach/irq.h>
  29. #include <mach/hardware.h>
  30. #include <asm/irq.h>
  31. #include <asm/mach-types.h>
  32. #include <mach/regs-gpio.h>
  33. #include <mach/regs-lcd.h>
  34. #include <mach/gpio-samsung.h>
  35. #include <linux/platform_data/mtd-nand-s3c2410.h>
  36. #include <linux/platform_data/i2c-s3c2410.h>
  37. #include <linux/mtd/mtd.h>
  38. #include <linux/mtd/rawnand.h>
  39. #include <linux/mtd/nand_ecc.h>
  40. #include <linux/mtd/partitions.h>
  41. #include <net/ax88796.h>
  42. #include <plat/devs.h>
  43. #include <plat/cpu.h>
  44. #include <linux/platform_data/asoc-s3c24xx_simtec.h>
  45. #include <plat/samsung-time.h>
  46. #include "anubis.h"
  47. #include "common.h"
  48. #include "simtec.h"
  49. #define COPYRIGHT ", Copyright 2005-2009 Simtec Electronics"
  50. static struct map_desc anubis_iodesc[] __initdata = {
  51. /* ISA IO areas */
  52. {
  53. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  54. .pfn = __phys_to_pfn(0x0),
  55. .length = SZ_4M,
  56. .type = MT_DEVICE,
  57. }, {
  58. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  59. .pfn = __phys_to_pfn(0x0),
  60. .length = SZ_4M,
  61. .type = MT_DEVICE,
  62. },
  63. /* we could possibly compress the next set down into a set of smaller tables
  64. * pagetables, but that would mean using an L2 section, and it still means
  65. * we cannot actually feed the same register to an LDR due to 16K spacing
  66. */
  67. /* CPLD control registers */
  68. {
  69. .virtual = (u32)ANUBIS_VA_CTRL1,
  70. .pfn = __phys_to_pfn(ANUBIS_PA_CTRL1),
  71. .length = SZ_4K,
  72. .type = MT_DEVICE,
  73. }, {
  74. .virtual = (u32)ANUBIS_VA_IDREG,
  75. .pfn = __phys_to_pfn(ANUBIS_PA_IDREG),
  76. .length = SZ_4K,
  77. .type = MT_DEVICE,
  78. },
  79. };
  80. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  81. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  82. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  83. static struct s3c2410_uartcfg anubis_uartcfgs[] __initdata = {
  84. [0] = {
  85. .hwport = 0,
  86. .flags = 0,
  87. .ucon = UCON,
  88. .ulcon = ULCON,
  89. .ufcon = UFCON,
  90. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  91. },
  92. [1] = {
  93. .hwport = 2,
  94. .flags = 0,
  95. .ucon = UCON,
  96. .ulcon = ULCON,
  97. .ufcon = UFCON,
  98. .clk_sel = S3C2410_UCON_CLKSEL1 | S3C2410_UCON_CLKSEL2,
  99. },
  100. };
  101. /* NAND Flash on Anubis board */
  102. static int external_map[] = { 2 };
  103. static int chip0_map[] = { 0 };
  104. static int chip1_map[] = { 1 };
  105. static struct mtd_partition __initdata anubis_default_nand_part[] = {
  106. [0] = {
  107. .name = "Boot Agent",
  108. .size = SZ_16K,
  109. .offset = 0,
  110. },
  111. [1] = {
  112. .name = "/boot",
  113. .size = SZ_4M - SZ_16K,
  114. .offset = SZ_16K,
  115. },
  116. [2] = {
  117. .name = "user1",
  118. .offset = SZ_4M,
  119. .size = SZ_32M - SZ_4M,
  120. },
  121. [3] = {
  122. .name = "user2",
  123. .offset = SZ_32M,
  124. .size = MTDPART_SIZ_FULL,
  125. }
  126. };
  127. static struct mtd_partition __initdata anubis_default_nand_part_large[] = {
  128. [0] = {
  129. .name = "Boot Agent",
  130. .size = SZ_128K,
  131. .offset = 0,
  132. },
  133. [1] = {
  134. .name = "/boot",
  135. .size = SZ_4M - SZ_128K,
  136. .offset = SZ_128K,
  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 Anubis 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 __initdata anubis_nand_sets[] = {
  156. [1] = {
  157. .name = "External",
  158. .nr_chips = 1,
  159. .nr_map = external_map,
  160. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  161. .partitions = anubis_default_nand_part,
  162. },
  163. [0] = {
  164. .name = "chip0",
  165. .nr_chips = 1,
  166. .nr_map = chip0_map,
  167. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  168. .partitions = anubis_default_nand_part,
  169. },
  170. [2] = {
  171. .name = "chip1",
  172. .nr_chips = 1,
  173. .nr_map = chip1_map,
  174. .nr_partitions = ARRAY_SIZE(anubis_default_nand_part),
  175. .partitions = anubis_default_nand_part,
  176. },
  177. };
  178. static void anubis_nand_select(struct s3c2410_nand_set *set, int slot)
  179. {
  180. unsigned int tmp;
  181. slot = set->nr_map[slot] & 3;
  182. pr_debug("anubis_nand: selecting slot %d (set %p,%p)\n",
  183. slot, set, set->nr_map);
  184. tmp = __raw_readb(ANUBIS_VA_CTRL1);
  185. tmp &= ~ANUBIS_CTRL1_NANDSEL;
  186. tmp |= slot;
  187. pr_debug("anubis_nand: ctrl1 now %02x\n", tmp);
  188. __raw_writeb(tmp, ANUBIS_VA_CTRL1);
  189. }
  190. static struct s3c2410_platform_nand __initdata anubis_nand_info = {
  191. .tacls = 25,
  192. .twrph0 = 55,
  193. .twrph1 = 40,
  194. .nr_sets = ARRAY_SIZE(anubis_nand_sets),
  195. .sets = anubis_nand_sets,
  196. .select_chip = anubis_nand_select,
  197. .ecc_mode = NAND_ECC_SOFT,
  198. };
  199. /* IDE channels */
  200. static struct pata_platform_info anubis_ide_platdata = {
  201. .ioport_shift = 5,
  202. };
  203. static struct resource anubis_ide0_resource[] = {
  204. [0] = DEFINE_RES_MEM(S3C2410_CS3, 8 * 32),
  205. [2] = DEFINE_RES_MEM(S3C2410_CS3 + (1 << 26) + (6 * 32), 32),
  206. [3] = DEFINE_RES_IRQ(ANUBIS_IRQ_IDE0),
  207. };
  208. static struct platform_device anubis_device_ide0 = {
  209. .name = "pata_platform",
  210. .id = 0,
  211. .num_resources = ARRAY_SIZE(anubis_ide0_resource),
  212. .resource = anubis_ide0_resource,
  213. .dev = {
  214. .platform_data = &anubis_ide_platdata,
  215. .coherent_dma_mask = ~0,
  216. },
  217. };
  218. static struct resource anubis_ide1_resource[] = {
  219. [0] = DEFINE_RES_MEM(S3C2410_CS4, 8 * 32),
  220. [1] = DEFINE_RES_MEM(S3C2410_CS4 + (1 << 26) + (6 * 32), 32),
  221. [2] = DEFINE_RES_IRQ(ANUBIS_IRQ_IDE0),
  222. };
  223. static struct platform_device anubis_device_ide1 = {
  224. .name = "pata_platform",
  225. .id = 1,
  226. .num_resources = ARRAY_SIZE(anubis_ide1_resource),
  227. .resource = anubis_ide1_resource,
  228. .dev = {
  229. .platform_data = &anubis_ide_platdata,
  230. .coherent_dma_mask = ~0,
  231. },
  232. };
  233. /* Asix AX88796 10/100 ethernet controller */
  234. static struct ax_plat_data anubis_asix_platdata = {
  235. .flags = AXFLG_MAC_FROMDEV,
  236. .wordlength = 2,
  237. .dcr_val = 0x48,
  238. .rcr_val = 0x40,
  239. };
  240. static struct resource anubis_asix_resource[] = {
  241. [0] = DEFINE_RES_MEM(S3C2410_CS5, 0x20 * 0x20),
  242. [1] = DEFINE_RES_IRQ(ANUBIS_IRQ_ASIX),
  243. };
  244. static struct platform_device anubis_device_asix = {
  245. .name = "ax88796",
  246. .id = 0,
  247. .num_resources = ARRAY_SIZE(anubis_asix_resource),
  248. .resource = anubis_asix_resource,
  249. .dev = {
  250. .platform_data = &anubis_asix_platdata,
  251. }
  252. };
  253. /* SM501 */
  254. static struct resource anubis_sm501_resource[] = {
  255. [0] = DEFINE_RES_MEM(S3C2410_CS2, SZ_8M),
  256. [1] = DEFINE_RES_MEM(S3C2410_CS2 + SZ_64M - SZ_2M, SZ_2M),
  257. [2] = DEFINE_RES_IRQ(IRQ_EINT0),
  258. };
  259. static struct sm501_initdata anubis_sm501_initdata = {
  260. .gpio_high = {
  261. .set = 0x3F000000, /* 24bit panel */
  262. .mask = 0x0,
  263. },
  264. .misc_timing = {
  265. .set = 0x010100, /* SDRAM timing */
  266. .mask = 0x1F1F00,
  267. },
  268. .misc_control = {
  269. .set = SM501_MISC_PNL_24BIT,
  270. .mask = 0,
  271. },
  272. .devices = SM501_USE_GPIO,
  273. /* set the SDRAM and bus clocks */
  274. .mclk = 72 * MHZ,
  275. .m1xclk = 144 * MHZ,
  276. };
  277. static struct sm501_platdata_gpio_i2c anubis_sm501_gpio_i2c[] = {
  278. [0] = {
  279. .bus_num = 1,
  280. .pin_scl = 44,
  281. .pin_sda = 45,
  282. },
  283. [1] = {
  284. .bus_num = 2,
  285. .pin_scl = 40,
  286. .pin_sda = 41,
  287. },
  288. };
  289. static struct sm501_platdata anubis_sm501_platdata = {
  290. .init = &anubis_sm501_initdata,
  291. .gpio_base = -1,
  292. .gpio_i2c = anubis_sm501_gpio_i2c,
  293. .gpio_i2c_nr = ARRAY_SIZE(anubis_sm501_gpio_i2c),
  294. };
  295. static struct platform_device anubis_device_sm501 = {
  296. .name = "sm501",
  297. .id = 0,
  298. .num_resources = ARRAY_SIZE(anubis_sm501_resource),
  299. .resource = anubis_sm501_resource,
  300. .dev = {
  301. .platform_data = &anubis_sm501_platdata,
  302. },
  303. };
  304. /* Standard Anubis devices */
  305. static struct platform_device *anubis_devices[] __initdata = {
  306. &s3c2410_device_dclk,
  307. &s3c_device_ohci,
  308. &s3c_device_wdt,
  309. &s3c_device_adc,
  310. &s3c_device_i2c0,
  311. &s3c_device_rtc,
  312. &s3c_device_nand,
  313. &anubis_device_ide0,
  314. &anubis_device_ide1,
  315. &anubis_device_asix,
  316. &anubis_device_sm501,
  317. };
  318. /* I2C devices. */
  319. static struct i2c_board_info anubis_i2c_devs[] __initdata = {
  320. {
  321. I2C_BOARD_INFO("tps65011", 0x48),
  322. .irq = IRQ_EINT20,
  323. }
  324. };
  325. /* Audio setup */
  326. static struct s3c24xx_audio_simtec_pdata __initdata anubis_audio = {
  327. .have_mic = 1,
  328. .have_lout = 1,
  329. .output_cdclk = 1,
  330. .use_mpllin = 1,
  331. .amp_gpio = S3C2410_GPB(2),
  332. .amp_gain[0] = S3C2410_GPD(10),
  333. .amp_gain[1] = S3C2410_GPD(11),
  334. };
  335. static void __init anubis_map_io(void)
  336. {
  337. s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
  338. s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
  339. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  340. /* check for the newer revision boards with large page nand */
  341. if ((__raw_readb(ANUBIS_VA_IDREG) & ANUBIS_IDREG_REVMASK) >= 4) {
  342. printk(KERN_INFO "ANUBIS-B detected (revision %d)\n",
  343. __raw_readb(ANUBIS_VA_IDREG) & ANUBIS_IDREG_REVMASK);
  344. anubis_nand_sets[0].partitions = anubis_default_nand_part_large;
  345. anubis_nand_sets[0].nr_partitions = ARRAY_SIZE(anubis_default_nand_part_large);
  346. } else {
  347. /* ensure that the GPIO is setup */
  348. gpio_request_one(S3C2410_GPA(0), GPIOF_OUT_INIT_HIGH, NULL);
  349. gpio_free(S3C2410_GPA(0));
  350. }
  351. }
  352. static void __init anubis_init_time(void)
  353. {
  354. s3c2440_init_clocks(12000000);
  355. samsung_timer_init();
  356. }
  357. static void __init anubis_init(void)
  358. {
  359. s3c_i2c0_set_platdata(NULL);
  360. s3c_nand_set_platdata(&anubis_nand_info);
  361. simtec_audio_add(NULL, false, &anubis_audio);
  362. platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices));
  363. i2c_register_board_info(0, anubis_i2c_devs,
  364. ARRAY_SIZE(anubis_i2c_devs));
  365. }
  366. MACHINE_START(ANUBIS, "Simtec-Anubis")
  367. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  368. .atag_offset = 0x100,
  369. .map_io = anubis_map_io,
  370. .init_machine = anubis_init,
  371. .init_irq = s3c2440_init_irq,
  372. .init_time = anubis_init_time,
  373. MACHINE_END