mach-smdk6410.c 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  1. /* linux/arch/arm/mach-s3c6410/mach-smdk6410.c
  2. *
  3. * Copyright 2008 Openmoko, Inc.
  4. * Copyright 2008 Simtec Electronics
  5. * Ben Dooks <ben@simtec.co.uk>
  6. * http://armlinux.simtec.co.uk/
  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. */
  13. #include <linux/kernel.h>
  14. #include <linux/types.h>
  15. #include <linux/interrupt.h>
  16. #include <linux/list.h>
  17. #include <linux/timer.h>
  18. #include <linux/init.h>
  19. #include <linux/serial_core.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/io.h>
  22. #include <linux/i2c.h>
  23. #include <linux/fb.h>
  24. #include <linux/gpio.h>
  25. #include <linux/delay.h>
  26. #include <linux/smsc911x.h>
  27. #include <linux/regulator/fixed.h>
  28. #ifdef CONFIG_SMDK6410_WM1190_EV1
  29. #include <linux/mfd/wm8350/core.h>
  30. #include <linux/mfd/wm8350/pmic.h>
  31. #endif
  32. #include <video/platform_lcd.h>
  33. #include <asm/mach/arch.h>
  34. #include <asm/mach/map.h>
  35. #include <asm/mach/irq.h>
  36. #include <mach/hardware.h>
  37. #include <mach/regs-fb.h>
  38. #include <mach/map.h>
  39. #include <asm/irq.h>
  40. #include <asm/mach-types.h>
  41. #include <plat/regs-serial.h>
  42. #include <plat/regs-modem.h>
  43. #include <plat/regs-gpio.h>
  44. #include <plat/regs-sys.h>
  45. #include <plat/iic.h>
  46. #include <plat/fb.h>
  47. #include <plat/gpio-cfg.h>
  48. #include <plat/s3c6410.h>
  49. #include <plat/clock.h>
  50. #include <plat/devs.h>
  51. #include <plat/cpu.h>
  52. #define UCON S3C2410_UCON_DEFAULT | S3C2410_UCON_UCLK
  53. #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB
  54. #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE
  55. static struct s3c2410_uartcfg smdk6410_uartcfgs[] __initdata = {
  56. [0] = {
  57. .hwport = 0,
  58. .flags = 0,
  59. .ucon = UCON,
  60. .ulcon = ULCON,
  61. .ufcon = UFCON,
  62. },
  63. [1] = {
  64. .hwport = 1,
  65. .flags = 0,
  66. .ucon = UCON,
  67. .ulcon = ULCON,
  68. .ufcon = UFCON,
  69. },
  70. [2] = {
  71. .hwport = 2,
  72. .flags = 0,
  73. .ucon = UCON,
  74. .ulcon = ULCON,
  75. .ufcon = UFCON,
  76. },
  77. [3] = {
  78. .hwport = 3,
  79. .flags = 0,
  80. .ucon = UCON,
  81. .ulcon = ULCON,
  82. .ufcon = UFCON,
  83. },
  84. };
  85. /* framebuffer and LCD setup. */
  86. /* GPF15 = LCD backlight control
  87. * GPF13 => Panel power
  88. * GPN5 = LCD nRESET signal
  89. * PWM_TOUT1 => backlight brightness
  90. */
  91. static void smdk6410_lcd_power_set(struct plat_lcd_data *pd,
  92. unsigned int power)
  93. {
  94. if (power) {
  95. gpio_direction_output(S3C64XX_GPF(13), 1);
  96. gpio_direction_output(S3C64XX_GPF(15), 1);
  97. /* fire nRESET on power up */
  98. gpio_direction_output(S3C64XX_GPN(5), 0);
  99. msleep(10);
  100. gpio_direction_output(S3C64XX_GPN(5), 1);
  101. msleep(1);
  102. } else {
  103. gpio_direction_output(S3C64XX_GPF(15), 0);
  104. gpio_direction_output(S3C64XX_GPF(13), 0);
  105. }
  106. }
  107. static struct plat_lcd_data smdk6410_lcd_power_data = {
  108. .set_power = smdk6410_lcd_power_set,
  109. };
  110. static struct platform_device smdk6410_lcd_powerdev = {
  111. .name = "platform-lcd",
  112. .dev.parent = &s3c_device_fb.dev,
  113. .dev.platform_data = &smdk6410_lcd_power_data,
  114. };
  115. static struct s3c_fb_pd_win smdk6410_fb_win0 = {
  116. /* this is to ensure we use win0 */
  117. .win_mode = {
  118. .pixclock = 41094,
  119. .left_margin = 8,
  120. .right_margin = 13,
  121. .upper_margin = 7,
  122. .lower_margin = 5,
  123. .hsync_len = 3,
  124. .vsync_len = 1,
  125. .xres = 800,
  126. .yres = 480,
  127. },
  128. .max_bpp = 32,
  129. .default_bpp = 16,
  130. };
  131. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  132. static struct s3c_fb_platdata smdk6410_lcd_pdata __initdata = {
  133. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  134. .win[0] = &smdk6410_fb_win0,
  135. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  136. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  137. };
  138. static struct resource smdk6410_smsc911x_resources[] = {
  139. [0] = {
  140. .start = 0x18000000,
  141. .end = 0x18000000 + SZ_64K - 1,
  142. .flags = IORESOURCE_MEM,
  143. },
  144. [1] = {
  145. .start = S3C_EINT(10),
  146. .end = S3C_EINT(10),
  147. .flags = IORESOURCE_IRQ | IRQ_TYPE_LEVEL_LOW,
  148. },
  149. };
  150. static struct smsc911x_platform_config smdk6410_smsc911x_pdata = {
  151. .irq_polarity = SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
  152. .irq_type = SMSC911X_IRQ_TYPE_OPEN_DRAIN,
  153. .flags = SMSC911X_USE_32BIT | SMSC911X_FORCE_INTERNAL_PHY,
  154. .phy_interface = PHY_INTERFACE_MODE_MII,
  155. };
  156. static struct platform_device smdk6410_smsc911x = {
  157. .name = "smsc911x",
  158. .id = -1,
  159. .num_resources = ARRAY_SIZE(smdk6410_smsc911x_resources),
  160. .resource = &smdk6410_smsc911x_resources[0],
  161. .dev = {
  162. .platform_data = &smdk6410_smsc911x_pdata,
  163. },
  164. };
  165. #ifdef CONFIG_REGULATOR
  166. static struct regulator_consumer_supply smdk6410_b_pwr_5v_consumers[] = {
  167. {
  168. /* WM8580 */
  169. .supply = "PVDD",
  170. .dev_name = "0-001b",
  171. },
  172. {
  173. /* WM8580 */
  174. .supply = "AVDD",
  175. .dev_name = "0-001b",
  176. },
  177. };
  178. static struct regulator_init_data smdk6410_b_pwr_5v_data = {
  179. .constraints = {
  180. .always_on = 1,
  181. },
  182. .num_consumer_supplies = ARRAY_SIZE(smdk6410_b_pwr_5v_consumers),
  183. .consumer_supplies = smdk6410_b_pwr_5v_consumers,
  184. };
  185. static struct fixed_voltage_config smdk6410_b_pwr_5v_pdata = {
  186. .supply_name = "B_PWR_5V",
  187. .microvolts = 5000000,
  188. .init_data = &smdk6410_b_pwr_5v_data,
  189. };
  190. static struct platform_device smdk6410_b_pwr_5v = {
  191. .name = "reg-fixed-voltage",
  192. .id = -1,
  193. .dev = {
  194. .platform_data = &smdk6410_b_pwr_5v_pdata,
  195. },
  196. };
  197. #endif
  198. static struct map_desc smdk6410_iodesc[] = {};
  199. static struct platform_device *smdk6410_devices[] __initdata = {
  200. #ifdef CONFIG_SMDK6410_SD_CH0
  201. &s3c_device_hsmmc0,
  202. #endif
  203. #ifdef CONFIG_SMDK6410_SD_CH1
  204. &s3c_device_hsmmc1,
  205. #endif
  206. &s3c_device_i2c0,
  207. &s3c_device_i2c1,
  208. &s3c_device_fb,
  209. &s3c_device_usb,
  210. &s3c_device_usb_hsotg,
  211. #ifdef CONFIG_REGULATOR
  212. &smdk6410_b_pwr_5v,
  213. #endif
  214. &smdk6410_lcd_powerdev,
  215. &smdk6410_smsc911x,
  216. };
  217. #ifdef CONFIG_SMDK6410_WM1190_EV1
  218. /* S3C64xx internal logic & PLL */
  219. static struct regulator_init_data wm8350_dcdc1_data = {
  220. .constraints = {
  221. .name = "PVDD_INT/PVDD_PLL",
  222. .min_uV = 1200000,
  223. .max_uV = 1200000,
  224. .always_on = 1,
  225. .apply_uV = 1,
  226. },
  227. };
  228. /* Memory */
  229. static struct regulator_init_data wm8350_dcdc3_data = {
  230. .constraints = {
  231. .name = "PVDD_MEM",
  232. .min_uV = 1800000,
  233. .max_uV = 1800000,
  234. .always_on = 1,
  235. .state_mem = {
  236. .uV = 1800000,
  237. .mode = REGULATOR_MODE_NORMAL,
  238. .enabled = 1,
  239. },
  240. .initial_state = PM_SUSPEND_MEM,
  241. },
  242. };
  243. /* USB, EXT, PCM, ADC/DAC, USB, MMC */
  244. static struct regulator_consumer_supply wm8350_dcdc4_consumers[] = {
  245. {
  246. /* WM8580 */
  247. .supply = "DVDD",
  248. .dev_name = "0-001b",
  249. },
  250. };
  251. static struct regulator_init_data wm8350_dcdc4_data = {
  252. .constraints = {
  253. .name = "PVDD_HI/PVDD_EXT/PVDD_SYS/PVCCM2MTV",
  254. .min_uV = 3000000,
  255. .max_uV = 3000000,
  256. .always_on = 1,
  257. },
  258. .num_consumer_supplies = ARRAY_SIZE(wm8350_dcdc4_consumers),
  259. .consumer_supplies = wm8350_dcdc4_consumers,
  260. };
  261. /* ARM core */
  262. static struct regulator_consumer_supply dcdc6_consumers[] = {
  263. {
  264. .supply = "vddarm",
  265. }
  266. };
  267. static struct regulator_init_data wm8350_dcdc6_data = {
  268. .constraints = {
  269. .name = "PVDD_ARM",
  270. .min_uV = 1000000,
  271. .max_uV = 1300000,
  272. .always_on = 1,
  273. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  274. },
  275. .num_consumer_supplies = ARRAY_SIZE(dcdc6_consumers),
  276. .consumer_supplies = dcdc6_consumers,
  277. };
  278. /* Alive */
  279. static struct regulator_init_data wm8350_ldo1_data = {
  280. .constraints = {
  281. .name = "PVDD_ALIVE",
  282. .min_uV = 1200000,
  283. .max_uV = 1200000,
  284. .always_on = 1,
  285. .apply_uV = 1,
  286. },
  287. };
  288. /* OTG */
  289. static struct regulator_init_data wm8350_ldo2_data = {
  290. .constraints = {
  291. .name = "PVDD_OTG",
  292. .min_uV = 3300000,
  293. .max_uV = 3300000,
  294. .always_on = 1,
  295. },
  296. };
  297. /* LCD */
  298. static struct regulator_init_data wm8350_ldo3_data = {
  299. .constraints = {
  300. .name = "PVDD_LCD",
  301. .min_uV = 3000000,
  302. .max_uV = 3000000,
  303. .always_on = 1,
  304. },
  305. };
  306. /* OTGi/1190-EV1 HPVDD & AVDD */
  307. static struct regulator_init_data wm8350_ldo4_data = {
  308. .constraints = {
  309. .name = "PVDD_OTGI/HPVDD/AVDD",
  310. .min_uV = 1200000,
  311. .max_uV = 1200000,
  312. .apply_uV = 1,
  313. .always_on = 1,
  314. },
  315. };
  316. static struct {
  317. int regulator;
  318. struct regulator_init_data *initdata;
  319. } wm1190_regulators[] = {
  320. { WM8350_DCDC_1, &wm8350_dcdc1_data },
  321. { WM8350_DCDC_3, &wm8350_dcdc3_data },
  322. { WM8350_DCDC_4, &wm8350_dcdc4_data },
  323. { WM8350_DCDC_6, &wm8350_dcdc6_data },
  324. { WM8350_LDO_1, &wm8350_ldo1_data },
  325. { WM8350_LDO_2, &wm8350_ldo2_data },
  326. { WM8350_LDO_3, &wm8350_ldo3_data },
  327. { WM8350_LDO_4, &wm8350_ldo4_data },
  328. };
  329. static int __init smdk6410_wm8350_init(struct wm8350 *wm8350)
  330. {
  331. int i;
  332. /* Configure the IRQ line */
  333. s3c_gpio_setpull(S3C64XX_GPN(12), S3C_GPIO_PULL_UP);
  334. /* Instantiate the regulators */
  335. for (i = 0; i < ARRAY_SIZE(wm1190_regulators); i++)
  336. wm8350_register_regulator(wm8350,
  337. wm1190_regulators[i].regulator,
  338. wm1190_regulators[i].initdata);
  339. return 0;
  340. }
  341. static struct wm8350_platform_data __initdata smdk6410_wm8350_pdata = {
  342. .init = smdk6410_wm8350_init,
  343. .irq_high = 1,
  344. };
  345. #endif
  346. static struct i2c_board_info i2c_devs0[] __initdata = {
  347. { I2C_BOARD_INFO("24c08", 0x50), },
  348. { I2C_BOARD_INFO("wm8580", 0x1b), },
  349. #ifdef CONFIG_SMDK6410_WM1190_EV1
  350. { I2C_BOARD_INFO("wm8350", 0x1a),
  351. .platform_data = &smdk6410_wm8350_pdata,
  352. .irq = S3C_EINT(12),
  353. },
  354. #endif
  355. };
  356. static struct i2c_board_info i2c_devs1[] __initdata = {
  357. { I2C_BOARD_INFO("24c128", 0x57), }, /* Samsung S524AD0XD1 */
  358. };
  359. static void __init smdk6410_map_io(void)
  360. {
  361. u32 tmp;
  362. s3c64xx_init_io(smdk6410_iodesc, ARRAY_SIZE(smdk6410_iodesc));
  363. s3c24xx_init_clocks(12000000);
  364. s3c24xx_init_uarts(smdk6410_uartcfgs, ARRAY_SIZE(smdk6410_uartcfgs));
  365. /* set the LCD type */
  366. tmp = __raw_readl(S3C64XX_SPCON);
  367. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  368. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  369. __raw_writel(tmp, S3C64XX_SPCON);
  370. /* remove the lcd bypass */
  371. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  372. tmp &= ~MIFPCON_LCD_BYPASS;
  373. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  374. }
  375. static void __init smdk6410_machine_init(void)
  376. {
  377. s3c_i2c0_set_platdata(NULL);
  378. s3c_i2c1_set_platdata(NULL);
  379. s3c_fb_set_platdata(&smdk6410_lcd_pdata);
  380. gpio_request(S3C64XX_GPN(5), "LCD power");
  381. gpio_request(S3C64XX_GPF(13), "LCD power");
  382. gpio_request(S3C64XX_GPF(15), "LCD power");
  383. i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
  384. i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
  385. platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
  386. }
  387. MACHINE_START(SMDK6410, "SMDK6410")
  388. /* Maintainer: Ben Dooks <ben@fluff.org> */
  389. .phys_io = S3C_PA_UART & 0xfff00000,
  390. .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
  391. .boot_params = S3C64XX_PA_SDRAM + 0x100,
  392. .init_irq = s3c6410_init_irq,
  393. .map_io = smdk6410_map_io,
  394. .init_machine = smdk6410_machine_init,
  395. .timer = &s3c24xx_timer,
  396. MACHINE_END