mach-anubis.c 9.8 KB

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