mach-anubis.c 9.6 KB

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