mach-bast.c 14 KB

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