mach-bast.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595
  1. /* linux/arch/arm/mach-s3c2410/mach-bast.c
  2. *
  3. * Copyright 2003-2008 Simtec Electronics
  4. * Ben Dooks <ben@simtec.co.uk>
  5. *
  6. * http://www.simtec.co.uk/products/EB2410ITX/
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/kernel.h>
  13. #include <linux/types.h>
  14. #include <linux/interrupt.h>
  15. #include <linux/list.h>
  16. #include <linux/timer.h>
  17. #include <linux/init.h>
  18. #include <linux/gpio.h>
  19. #include <linux/syscore_ops.h>
  20. #include <linux/serial_core.h>
  21. #include <linux/serial_s3c.h>
  22. #include <linux/platform_device.h>
  23. #include <linux/dm9000.h>
  24. #include <linux/ata_platform.h>
  25. #include <linux/i2c.h>
  26. #include <linux/io.h>
  27. #include <linux/serial_8250.h>
  28. #include <linux/mtd/mtd.h>
  29. #include <linux/mtd/nand.h>
  30. #include <linux/mtd/nand_ecc.h>
  31. #include <linux/mtd/partitions.h>
  32. #include <linux/platform_data/asoc-s3c24xx_simtec.h>
  33. #include <linux/platform_data/hwmon-s3c.h>
  34. #include <linux/platform_data/i2c-s3c2410.h>
  35. #include <linux/platform_data/mtd-nand-s3c2410.h>
  36. #include <net/ax88796.h>
  37. #include <asm/irq.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/map.h>
  40. #include <asm/mach/irq.h>
  41. #include <asm/mach-types.h>
  42. #include <mach/fb.h>
  43. #include <mach/hardware.h>
  44. #include <mach/regs-gpio.h>
  45. #include <mach/regs-lcd.h>
  46. #include <mach/gpio-samsung.h>
  47. #include <plat/cpu.h>
  48. #include <plat/cpu-freq.h>
  49. #include <plat/devs.h>
  50. #include <plat/gpio-cfg.h>
  51. #include <plat/samsung-time.h>
  52. #include "bast.h"
  53. #include "common.h"
  54. #include "simtec.h"
  55. #define COPYRIGHT ", Copyright 2004-2008 Simtec Electronics"
  56. /* macros for virtual address mods for the io space entries */
  57. #define VA_C5(item) ((unsigned long)(item) + BAST_VAM_CS5)
  58. #define VA_C4(item) ((unsigned long)(item) + BAST_VAM_CS4)
  59. #define VA_C3(item) ((unsigned long)(item) + BAST_VAM_CS3)
  60. #define VA_C2(item) ((unsigned long)(item) + BAST_VAM_CS2)
  61. /* macros to modify the physical addresses for io space */
  62. #define PA_CS2(item) (__phys_to_pfn((item) + S3C2410_CS2))
  63. #define PA_CS3(item) (__phys_to_pfn((item) + S3C2410_CS3))
  64. #define PA_CS4(item) (__phys_to_pfn((item) + S3C2410_CS4))
  65. #define PA_CS5(item) (__phys_to_pfn((item) + S3C2410_CS5))
  66. static struct map_desc bast_iodesc[] __initdata = {
  67. /* ISA IO areas */
  68. {
  69. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  70. .pfn = PA_CS2(BAST_PA_ISAIO),
  71. .length = SZ_16M,
  72. .type = MT_DEVICE,
  73. }, {
  74. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  75. .pfn = PA_CS3(BAST_PA_ISAIO),
  76. .length = SZ_16M,
  77. .type = MT_DEVICE,
  78. },
  79. /* bast CPLD control registers, and external interrupt controls */
  80. {
  81. .virtual = (u32)BAST_VA_CTRL1,
  82. .pfn = __phys_to_pfn(BAST_PA_CTRL1),
  83. .length = SZ_1M,
  84. .type = MT_DEVICE,
  85. }, {
  86. .virtual = (u32)BAST_VA_CTRL2,
  87. .pfn = __phys_to_pfn(BAST_PA_CTRL2),
  88. .length = SZ_1M,
  89. .type = MT_DEVICE,
  90. }, {
  91. .virtual = (u32)BAST_VA_CTRL3,
  92. .pfn = __phys_to_pfn(BAST_PA_CTRL3),
  93. .length = SZ_1M,
  94. .type = MT_DEVICE,
  95. }, {
  96. .virtual = (u32)BAST_VA_CTRL4,
  97. .pfn = __phys_to_pfn(BAST_PA_CTRL4),
  98. .length = SZ_1M,
  99. .type = MT_DEVICE,
  100. },
  101. /* PC104 IRQ mux */
  102. {
  103. .virtual = (u32)BAST_VA_PC104_IRQREQ,
  104. .pfn = __phys_to_pfn(BAST_PA_PC104_IRQREQ),
  105. .length = SZ_1M,
  106. .type = MT_DEVICE,
  107. }, {
  108. .virtual = (u32)BAST_VA_PC104_IRQRAW,
  109. .pfn = __phys_to_pfn(BAST_PA_PC104_IRQRAW),
  110. .length = SZ_1M,
  111. .type = MT_DEVICE,
  112. }, {
  113. .virtual = (u32)BAST_VA_PC104_IRQMASK,
  114. .pfn = __phys_to_pfn(BAST_PA_PC104_IRQMASK),
  115. .length = SZ_1M,
  116. .type = MT_DEVICE,
  117. },
  118. /* peripheral space... one for each of fast/slow/byte/16bit */
  119. /* note, ide is only decoded in word space, even though some registers
  120. * are only 8bit */
  121. /* slow, byte */
  122. { VA_C2(BAST_VA_ISAIO), PA_CS2(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  123. { VA_C2(BAST_VA_ISAMEM), PA_CS2(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  124. { VA_C2(BAST_VA_SUPERIO), PA_CS2(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  125. /* slow, word */
  126. { VA_C3(BAST_VA_ISAIO), PA_CS3(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  127. { VA_C3(BAST_VA_ISAMEM), PA_CS3(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  128. { VA_C3(BAST_VA_SUPERIO), PA_CS3(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  129. /* fast, byte */
  130. { VA_C4(BAST_VA_ISAIO), PA_CS4(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  131. { VA_C4(BAST_VA_ISAMEM), PA_CS4(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  132. { VA_C4(BAST_VA_SUPERIO), PA_CS4(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  133. /* fast, word */
  134. { VA_C5(BAST_VA_ISAIO), PA_CS5(BAST_PA_ISAIO), SZ_16M, MT_DEVICE },
  135. { VA_C5(BAST_VA_ISAMEM), PA_CS5(BAST_PA_ISAMEM), SZ_16M, MT_DEVICE },
  136. { VA_C5(BAST_VA_SUPERIO), PA_CS5(BAST_PA_SUPERIO), SZ_1M, MT_DEVICE },
  137. };
  138. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  139. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  140. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  141. static struct s3c2410_uartcfg bast_uartcfgs[] __initdata = {
  142. [0] = {
  143. .hwport = 0,
  144. .flags = 0,
  145. .ucon = UCON,
  146. .ulcon = ULCON,
  147. .ufcon = UFCON,
  148. },
  149. [1] = {
  150. .hwport = 1,
  151. .flags = 0,
  152. .ucon = UCON,
  153. .ulcon = ULCON,
  154. .ufcon = UFCON,
  155. },
  156. /* port 2 is not actually used */
  157. [2] = {
  158. .hwport = 2,
  159. .flags = 0,
  160. .ucon = UCON,
  161. .ulcon = ULCON,
  162. .ufcon = UFCON,
  163. }
  164. };
  165. /* NAND Flash on BAST board */
  166. #ifdef CONFIG_PM
  167. static int bast_pm_suspend(void)
  168. {
  169. /* ensure that an nRESET is not generated on resume. */
  170. gpio_direction_output(S3C2410_GPA(21), 1);
  171. return 0;
  172. }
  173. static void bast_pm_resume(void)
  174. {
  175. s3c_gpio_cfgpin(S3C2410_GPA(21), S3C2410_GPA21_nRSTOUT);
  176. }
  177. #else
  178. #define bast_pm_suspend NULL
  179. #define bast_pm_resume NULL
  180. #endif
  181. static struct syscore_ops bast_pm_syscore_ops = {
  182. .suspend = bast_pm_suspend,
  183. .resume = bast_pm_resume,
  184. };
  185. static int smartmedia_map[] = { 0 };
  186. static int chip0_map[] = { 1 };
  187. static int chip1_map[] = { 2 };
  188. static int chip2_map[] = { 3 };
  189. static struct mtd_partition __initdata bast_default_nand_part[] = {
  190. [0] = {
  191. .name = "Boot Agent",
  192. .size = SZ_16K,
  193. .offset = 0,
  194. },
  195. [1] = {
  196. .name = "/boot",
  197. .size = SZ_4M - SZ_16K,
  198. .offset = SZ_16K,
  199. },
  200. [2] = {
  201. .name = "user",
  202. .offset = SZ_4M,
  203. .size = MTDPART_SIZ_FULL,
  204. }
  205. };
  206. /* the bast has 4 selectable slots for nand-flash, the three
  207. * on-board chip areas, as well as the external SmartMedia
  208. * slot.
  209. *
  210. * Note, there is no current hot-plug support for the SmartMedia
  211. * socket.
  212. */
  213. static struct s3c2410_nand_set __initdata bast_nand_sets[] = {
  214. [0] = {
  215. .name = "SmartMedia",
  216. .nr_chips = 1,
  217. .nr_map = smartmedia_map,
  218. .options = NAND_SCAN_SILENT_NODEV,
  219. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  220. .partitions = bast_default_nand_part,
  221. },
  222. [1] = {
  223. .name = "chip0",
  224. .nr_chips = 1,
  225. .nr_map = chip0_map,
  226. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  227. .partitions = bast_default_nand_part,
  228. },
  229. [2] = {
  230. .name = "chip1",
  231. .nr_chips = 1,
  232. .nr_map = chip1_map,
  233. .options = NAND_SCAN_SILENT_NODEV,
  234. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  235. .partitions = bast_default_nand_part,
  236. },
  237. [3] = {
  238. .name = "chip2",
  239. .nr_chips = 1,
  240. .nr_map = chip2_map,
  241. .options = NAND_SCAN_SILENT_NODEV,
  242. .nr_partitions = ARRAY_SIZE(bast_default_nand_part),
  243. .partitions = bast_default_nand_part,
  244. }
  245. };
  246. static void bast_nand_select(struct s3c2410_nand_set *set, int slot)
  247. {
  248. unsigned int tmp;
  249. slot = set->nr_map[slot] & 3;
  250. pr_debug("bast_nand: selecting slot %d (set %p,%p)\n",
  251. slot, set, set->nr_map);
  252. tmp = __raw_readb(BAST_VA_CTRL2);
  253. tmp &= BAST_CPLD_CTLR2_IDERST;
  254. tmp |= slot;
  255. tmp |= BAST_CPLD_CTRL2_WNAND;
  256. pr_debug("bast_nand: ctrl2 now %02x\n", tmp);
  257. __raw_writeb(tmp, BAST_VA_CTRL2);
  258. }
  259. static struct s3c2410_platform_nand __initdata bast_nand_info = {
  260. .tacls = 30,
  261. .twrph0 = 60,
  262. .twrph1 = 60,
  263. .nr_sets = ARRAY_SIZE(bast_nand_sets),
  264. .sets = bast_nand_sets,
  265. .select_chip = bast_nand_select,
  266. };
  267. /* DM9000 */
  268. static struct resource bast_dm9k_resource[] = {
  269. [0] = DEFINE_RES_MEM(S3C2410_CS5 + BAST_PA_DM9000, 4),
  270. [1] = DEFINE_RES_MEM(S3C2410_CS5 + BAST_PA_DM9000 + 0x40, 0x40),
  271. [2] = DEFINE_RES_NAMED(BAST_IRQ_DM9000 , 1, NULL, IORESOURCE_IRQ \
  272. | IORESOURCE_IRQ_HIGHLEVEL),
  273. };
  274. /* for the moment we limit ourselves to 16bit IO until some
  275. * better IO routines can be written and tested
  276. */
  277. static struct dm9000_plat_data bast_dm9k_platdata = {
  278. .flags = DM9000_PLATF_16BITONLY,
  279. };
  280. static struct platform_device bast_device_dm9k = {
  281. .name = "dm9000",
  282. .id = 0,
  283. .num_resources = ARRAY_SIZE(bast_dm9k_resource),
  284. .resource = bast_dm9k_resource,
  285. .dev = {
  286. .platform_data = &bast_dm9k_platdata,
  287. }
  288. };
  289. /* serial devices */
  290. #define SERIAL_BASE (S3C2410_CS2 + BAST_PA_SUPERIO)
  291. #define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ)
  292. #define SERIAL_CLK (1843200)
  293. static struct plat_serial8250_port bast_sio_data[] = {
  294. [0] = {
  295. .mapbase = SERIAL_BASE + 0x2f8,
  296. .irq = BAST_IRQ_PCSERIAL1,
  297. .flags = SERIAL_FLAGS,
  298. .iotype = UPIO_MEM,
  299. .regshift = 0,
  300. .uartclk = SERIAL_CLK,
  301. },
  302. [1] = {
  303. .mapbase = SERIAL_BASE + 0x3f8,
  304. .irq = BAST_IRQ_PCSERIAL2,
  305. .flags = SERIAL_FLAGS,
  306. .iotype = UPIO_MEM,
  307. .regshift = 0,
  308. .uartclk = SERIAL_CLK,
  309. },
  310. { }
  311. };
  312. static struct platform_device bast_sio = {
  313. .name = "serial8250",
  314. .id = PLAT8250_DEV_PLATFORM,
  315. .dev = {
  316. .platform_data = &bast_sio_data,
  317. },
  318. };
  319. /* we have devices on the bus which cannot work much over the
  320. * standard 100KHz i2c bus frequency
  321. */
  322. static struct s3c2410_platform_i2c __initdata bast_i2c_info = {
  323. .flags = 0,
  324. .slave_addr = 0x10,
  325. .frequency = 100*1000,
  326. };
  327. /* Asix AX88796 10/100 ethernet controller */
  328. static struct ax_plat_data bast_asix_platdata = {
  329. .flags = AXFLG_MAC_FROMDEV,
  330. .wordlength = 2,
  331. .dcr_val = 0x48,
  332. .rcr_val = 0x40,
  333. };
  334. static struct resource bast_asix_resource[] = {
  335. [0] = DEFINE_RES_MEM(S3C2410_CS5 + BAST_PA_ASIXNET, 0x18 * 0x20),
  336. [1] = DEFINE_RES_MEM(S3C2410_CS5 + BAST_PA_ASIXNET + (0x1f * 0x20), 1),
  337. [2] = DEFINE_RES_IRQ(BAST_IRQ_ASIX),
  338. };
  339. static struct platform_device bast_device_asix = {
  340. .name = "ax88796",
  341. .id = 0,
  342. .num_resources = ARRAY_SIZE(bast_asix_resource),
  343. .resource = bast_asix_resource,
  344. .dev = {
  345. .platform_data = &bast_asix_platdata
  346. }
  347. };
  348. /* Asix AX88796 10/100 ethernet controller parallel port */
  349. static struct resource bast_asixpp_resource[] = {
  350. [0] = DEFINE_RES_MEM(S3C2410_CS5 + BAST_PA_ASIXNET + (0x18 * 0x20), \
  351. 0x30 * 0x20),
  352. };
  353. static struct platform_device bast_device_axpp = {
  354. .name = "ax88796-pp",
  355. .id = 0,
  356. .num_resources = ARRAY_SIZE(bast_asixpp_resource),
  357. .resource = bast_asixpp_resource,
  358. };
  359. /* LCD/VGA controller */
  360. static struct s3c2410fb_display __initdata bast_lcd_info[] = {
  361. {
  362. .type = S3C2410_LCDCON1_TFT,
  363. .width = 640,
  364. .height = 480,
  365. .pixclock = 33333,
  366. .xres = 640,
  367. .yres = 480,
  368. .bpp = 4,
  369. .left_margin = 40,
  370. .right_margin = 20,
  371. .hsync_len = 88,
  372. .upper_margin = 30,
  373. .lower_margin = 32,
  374. .vsync_len = 3,
  375. .lcdcon5 = 0x00014b02,
  376. },
  377. {
  378. .type = S3C2410_LCDCON1_TFT,
  379. .width = 640,
  380. .height = 480,
  381. .pixclock = 33333,
  382. .xres = 640,
  383. .yres = 480,
  384. .bpp = 8,
  385. .left_margin = 40,
  386. .right_margin = 20,
  387. .hsync_len = 88,
  388. .upper_margin = 30,
  389. .lower_margin = 32,
  390. .vsync_len = 3,
  391. .lcdcon5 = 0x00014b02,
  392. },
  393. {
  394. .type = S3C2410_LCDCON1_TFT,
  395. .width = 640,
  396. .height = 480,
  397. .pixclock = 33333,
  398. .xres = 640,
  399. .yres = 480,
  400. .bpp = 16,
  401. .left_margin = 40,
  402. .right_margin = 20,
  403. .hsync_len = 88,
  404. .upper_margin = 30,
  405. .lower_margin = 32,
  406. .vsync_len = 3,
  407. .lcdcon5 = 0x00014b02,
  408. },
  409. };
  410. /* LCD/VGA controller */
  411. static struct s3c2410fb_mach_info __initdata bast_fb_info = {
  412. .displays = bast_lcd_info,
  413. .num_displays = ARRAY_SIZE(bast_lcd_info),
  414. .default_display = 1,
  415. };
  416. /* I2C devices fitted. */
  417. static struct i2c_board_info bast_i2c_devs[] __initdata = {
  418. {
  419. I2C_BOARD_INFO("tlv320aic23", 0x1a),
  420. }, {
  421. I2C_BOARD_INFO("simtec-pmu", 0x6b),
  422. }, {
  423. I2C_BOARD_INFO("ch7013", 0x75),
  424. },
  425. };
  426. static struct s3c_hwmon_pdata bast_hwmon_info = {
  427. /* LCD contrast (0-6.6V) */
  428. .in[0] = &(struct s3c_hwmon_chcfg) {
  429. .name = "lcd-contrast",
  430. .mult = 3300,
  431. .div = 512,
  432. },
  433. /* LED current feedback */
  434. .in[1] = &(struct s3c_hwmon_chcfg) {
  435. .name = "led-feedback",
  436. .mult = 3300,
  437. .div = 1024,
  438. },
  439. /* LCD feedback (0-6.6V) */
  440. .in[2] = &(struct s3c_hwmon_chcfg) {
  441. .name = "lcd-feedback",
  442. .mult = 3300,
  443. .div = 512,
  444. },
  445. /* Vcore (1.8-2.0V), Vref 3.3V */
  446. .in[3] = &(struct s3c_hwmon_chcfg) {
  447. .name = "vcore",
  448. .mult = 3300,
  449. .div = 1024,
  450. },
  451. };
  452. /* Standard BAST devices */
  453. // cat /sys/devices/platform/s3c24xx-adc/s3c-hwmon/in_0
  454. static struct platform_device *bast_devices[] __initdata = {
  455. &s3c2410_device_dclk,
  456. &s3c_device_ohci,
  457. &s3c_device_lcd,
  458. &s3c_device_wdt,
  459. &s3c_device_i2c0,
  460. &s3c_device_rtc,
  461. &s3c_device_nand,
  462. &s3c_device_adc,
  463. &s3c_device_hwmon,
  464. &bast_device_dm9k,
  465. &bast_device_asix,
  466. &bast_device_axpp,
  467. &bast_sio,
  468. };
  469. static struct s3c_cpufreq_board __initdata bast_cpufreq = {
  470. .refresh = 7800, /* 7.8usec */
  471. .auto_io = 1,
  472. .need_io = 1,
  473. };
  474. static struct s3c24xx_audio_simtec_pdata __initdata bast_audio = {
  475. .have_mic = 1,
  476. .have_lout = 1,
  477. };
  478. static void __init bast_map_io(void)
  479. {
  480. s3c_hwmon_set_platdata(&bast_hwmon_info);
  481. s3c24xx_init_io(bast_iodesc, ARRAY_SIZE(bast_iodesc));
  482. s3c24xx_init_uarts(bast_uartcfgs, ARRAY_SIZE(bast_uartcfgs));
  483. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  484. }
  485. static void __init bast_init_time(void)
  486. {
  487. s3c2410_init_clocks(12000000);
  488. samsung_timer_init();
  489. }
  490. static void __init bast_init(void)
  491. {
  492. register_syscore_ops(&bast_pm_syscore_ops);
  493. s3c_i2c0_set_platdata(&bast_i2c_info);
  494. s3c_nand_set_platdata(&bast_nand_info);
  495. s3c24xx_fb_set_platdata(&bast_fb_info);
  496. platform_add_devices(bast_devices, ARRAY_SIZE(bast_devices));
  497. i2c_register_board_info(0, bast_i2c_devs,
  498. ARRAY_SIZE(bast_i2c_devs));
  499. usb_simtec_init();
  500. nor_simtec_init();
  501. simtec_audio_add(NULL, true, &bast_audio);
  502. WARN_ON(gpio_request(S3C2410_GPA(21), "bast nreset"));
  503. s3c_cpufreq_setboard(&bast_cpufreq);
  504. }
  505. MACHINE_START(BAST, "Simtec-BAST")
  506. /* Maintainer: Ben Dooks <ben@simtec.co.uk> */
  507. .atag_offset = 0x100,
  508. .map_io = bast_map_io,
  509. .init_irq = s3c2410_init_irq,
  510. .init_machine = bast_init,
  511. .init_time = bast_init_time,
  512. MACHINE_END