mach-bast.c 14 KB

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