mach-smdk6410.c 9.0 KB

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