mach-anubis.c 10.0 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/nand.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. };
  198. /* IDE channels */
  199. static struct pata_platform_info anubis_ide_platdata = {
  200. .ioport_shift = 5,
  201. };
  202. static struct resource anubis_ide0_resource[] = {
  203. [0] = DEFINE_RES_MEM(S3C2410_CS3, 8 * 32),
  204. [2] = DEFINE_RES_MEM(S3C2410_CS3 + (1 << 26) + (6 * 32), 32),
  205. [3] = DEFINE_RES_IRQ(ANUBIS_IRQ_IDE0),
  206. };
  207. static struct platform_device anubis_device_ide0 = {
  208. .name = "pata_platform",
  209. .id = 0,
  210. .num_resources = ARRAY_SIZE(anubis_ide0_resource),
  211. .resource = anubis_ide0_resource,
  212. .dev = {
  213. .platform_data = &anubis_ide_platdata,
  214. .coherent_dma_mask = ~0,
  215. },
  216. };
  217. static struct resource anubis_ide1_resource[] = {
  218. [0] = DEFINE_RES_MEM(S3C2410_CS4, 8 * 32),
  219. [1] = DEFINE_RES_MEM(S3C2410_CS4 + (1 << 26) + (6 * 32), 32),
  220. [2] = DEFINE_RES_IRQ(ANUBIS_IRQ_IDE0),
  221. };
  222. static struct platform_device anubis_device_ide1 = {
  223. .name = "pata_platform",
  224. .id = 1,
  225. .num_resources = ARRAY_SIZE(anubis_ide1_resource),
  226. .resource = anubis_ide1_resource,
  227. .dev = {
  228. .platform_data = &anubis_ide_platdata,
  229. .coherent_dma_mask = ~0,
  230. },
  231. };
  232. /* Asix AX88796 10/100 ethernet controller */
  233. static struct ax_plat_data anubis_asix_platdata = {
  234. .flags = AXFLG_MAC_FROMDEV,
  235. .wordlength = 2,
  236. .dcr_val = 0x48,
  237. .rcr_val = 0x40,
  238. };
  239. static struct resource anubis_asix_resource[] = {
  240. [0] = DEFINE_RES_MEM(S3C2410_CS5, 0x20 * 0x20),
  241. [1] = DEFINE_RES_IRQ(ANUBIS_IRQ_ASIX),
  242. };
  243. static struct platform_device anubis_device_asix = {
  244. .name = "ax88796",
  245. .id = 0,
  246. .num_resources = ARRAY_SIZE(anubis_asix_resource),
  247. .resource = anubis_asix_resource,
  248. .dev = {
  249. .platform_data = &anubis_asix_platdata,
  250. }
  251. };
  252. /* SM501 */
  253. static struct resource anubis_sm501_resource[] = {
  254. [0] = DEFINE_RES_MEM(S3C2410_CS2, SZ_8M),
  255. [1] = DEFINE_RES_MEM(S3C2410_CS2 + SZ_64M - SZ_2M, SZ_2M),
  256. [2] = DEFINE_RES_IRQ(IRQ_EINT0),
  257. };
  258. static struct sm501_initdata anubis_sm501_initdata = {
  259. .gpio_high = {
  260. .set = 0x3F000000, /* 24bit panel */
  261. .mask = 0x0,
  262. },
  263. .misc_timing = {
  264. .set = 0x010100, /* SDRAM timing */
  265. .mask = 0x1F1F00,
  266. },
  267. .misc_control = {
  268. .set = SM501_MISC_PNL_24BIT,
  269. .mask = 0,
  270. },
  271. .devices = SM501_USE_GPIO,
  272. /* set the SDRAM and bus clocks */
  273. .mclk = 72 * MHZ,
  274. .m1xclk = 144 * MHZ,
  275. };
  276. static struct sm501_platdata_gpio_i2c anubis_sm501_gpio_i2c[] = {
  277. [0] = {
  278. .bus_num = 1,
  279. .pin_scl = 44,
  280. .pin_sda = 45,
  281. },
  282. [1] = {
  283. .bus_num = 2,
  284. .pin_scl = 40,
  285. .pin_sda = 41,
  286. },
  287. };
  288. static struct sm501_platdata anubis_sm501_platdata = {
  289. .init = &anubis_sm501_initdata,
  290. .gpio_base = -1,
  291. .gpio_i2c = anubis_sm501_gpio_i2c,
  292. .gpio_i2c_nr = ARRAY_SIZE(anubis_sm501_gpio_i2c),
  293. };
  294. static struct platform_device anubis_device_sm501 = {
  295. .name = "sm501",
  296. .id = 0,
  297. .num_resources = ARRAY_SIZE(anubis_sm501_resource),
  298. .resource = anubis_sm501_resource,
  299. .dev = {
  300. .platform_data = &anubis_sm501_platdata,
  301. },
  302. };
  303. /* Standard Anubis devices */
  304. static struct platform_device *anubis_devices[] __initdata = {
  305. &s3c2410_device_dclk,
  306. &s3c_device_ohci,
  307. &s3c_device_wdt,
  308. &s3c_device_adc,
  309. &s3c_device_i2c0,
  310. &s3c_device_rtc,
  311. &s3c_device_nand,
  312. &anubis_device_ide0,
  313. &anubis_device_ide1,
  314. &anubis_device_asix,
  315. &anubis_device_sm501,
  316. };
  317. /* I2C devices. */
  318. static struct i2c_board_info anubis_i2c_devs[] __initdata = {
  319. {
  320. I2C_BOARD_INFO("tps65011", 0x48),
  321. .irq = IRQ_EINT20,
  322. }
  323. };
  324. /* Audio setup */
  325. static struct s3c24xx_audio_simtec_pdata __initdata anubis_audio = {
  326. .have_mic = 1,
  327. .have_lout = 1,
  328. .output_cdclk = 1,
  329. .use_mpllin = 1,
  330. .amp_gpio = S3C2410_GPB(2),
  331. .amp_gain[0] = S3C2410_GPD(10),
  332. .amp_gain[1] = S3C2410_GPD(11),
  333. };
  334. static void __init anubis_map_io(void)
  335. {
  336. s3c24xx_init_io(anubis_iodesc, ARRAY_SIZE(anubis_iodesc));
  337. s3c24xx_init_uarts(anubis_uartcfgs, ARRAY_SIZE(anubis_uartcfgs));
  338. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  339. /* check for the newer revision boards with large page nand */
  340. if ((__raw_readb(ANUBIS_VA_IDREG) & ANUBIS_IDREG_REVMASK) >= 4) {
  341. printk(KERN_INFO "ANUBIS-B detected (revision %d)\n",
  342. __raw_readb(ANUBIS_VA_IDREG) & ANUBIS_IDREG_REVMASK);
  343. anubis_nand_sets[0].partitions = anubis_default_nand_part_large;
  344. anubis_nand_sets[0].nr_partitions = ARRAY_SIZE(anubis_default_nand_part_large);
  345. } else {
  346. /* ensure that the GPIO is setup */
  347. gpio_request_one(S3C2410_GPA(0), GPIOF_OUT_INIT_HIGH, NULL);
  348. gpio_free(S3C2410_GPA(0));
  349. }
  350. }
  351. static void __init anubis_init_time(void)
  352. {
  353. s3c2440_init_clocks(12000000);
  354. samsung_timer_init();
  355. }
  356. static void __init anubis_init(void)
  357. {
  358. s3c_i2c0_set_platdata(NULL);
  359. s3c_nand_set_platdata(&anubis_nand_info);
  360. simtec_audio_add(NULL, false, &anubis_audio);
  361. platform_add_devices(anubis_devices, ARRAY_SIZE(anubis_devices));
  362. i2c_register_board_info(0, anubis_i2c_devs,
  363. ARRAY_SIZE(anubis_i2c_devs));
  364. }
  365. MACHINE_START(ANUBIS, "Simtec-Anubis")
  366. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  367. .atag_offset = 0x100,
  368. .map_io = anubis_map_io,
  369. .init_machine = anubis_init,
  370. .init_irq = s3c2440_init_irq,
  371. .init_time = anubis_init_time,
  372. MACHINE_END