mach-smdkv210.c 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. /* linux/arch/arm/mach-s5pv210/mach-smdkv210.c
  2. *
  3. * Copyright (c) 2010 Samsung Electronics Co., Ltd.
  4. * http://www.samsung.com/
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation.
  9. */
  10. #include <linux/kernel.h>
  11. #include <linux/types.h>
  12. #include <linux/i2c.h>
  13. #include <linux/init.h>
  14. #include <linux/serial_core.h>
  15. #include <linux/sysdev.h>
  16. #include <linux/dm9000.h>
  17. #include <linux/fb.h>
  18. #include <linux/gpio.h>
  19. #include <linux/delay.h>
  20. #include <linux/pwm_backlight.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/setup.h>
  24. #include <asm/mach-types.h>
  25. #include <video/platform_lcd.h>
  26. #include <mach/map.h>
  27. #include <mach/regs-clock.h>
  28. #include <mach/regs-fb.h>
  29. #include <plat/regs-serial.h>
  30. #include <plat/regs-srom.h>
  31. #include <plat/gpio-cfg.h>
  32. #include <plat/s5pv210.h>
  33. #include <plat/devs.h>
  34. #include <plat/cpu.h>
  35. #include <plat/adc.h>
  36. #include <plat/ts.h>
  37. #include <plat/ata.h>
  38. #include <plat/iic.h>
  39. #include <plat/keypad.h>
  40. #include <plat/pm.h>
  41. #include <plat/fb.h>
  42. #include <plat/gpio-cfg.h>
  43. #include <plat/s5p-time.h>
  44. /* Following are default values for UCON, ULCON and UFCON UART registers */
  45. #define SMDKV210_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  46. S3C2410_UCON_RXILEVEL | \
  47. S3C2410_UCON_TXIRQMODE | \
  48. S3C2410_UCON_RXIRQMODE | \
  49. S3C2410_UCON_RXFIFO_TOI | \
  50. S3C2443_UCON_RXERR_IRQEN)
  51. #define SMDKV210_ULCON_DEFAULT S3C2410_LCON_CS8
  52. #define SMDKV210_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
  53. S5PV210_UFCON_TXTRIG4 | \
  54. S5PV210_UFCON_RXTRIG4)
  55. static struct s3c2410_uartcfg smdkv210_uartcfgs[] __initdata = {
  56. [0] = {
  57. .hwport = 0,
  58. .flags = 0,
  59. .ucon = SMDKV210_UCON_DEFAULT,
  60. .ulcon = SMDKV210_ULCON_DEFAULT,
  61. .ufcon = SMDKV210_UFCON_DEFAULT,
  62. },
  63. [1] = {
  64. .hwport = 1,
  65. .flags = 0,
  66. .ucon = SMDKV210_UCON_DEFAULT,
  67. .ulcon = SMDKV210_ULCON_DEFAULT,
  68. .ufcon = SMDKV210_UFCON_DEFAULT,
  69. },
  70. [2] = {
  71. .hwport = 2,
  72. .flags = 0,
  73. .ucon = SMDKV210_UCON_DEFAULT,
  74. .ulcon = SMDKV210_ULCON_DEFAULT,
  75. .ufcon = SMDKV210_UFCON_DEFAULT,
  76. },
  77. [3] = {
  78. .hwport = 3,
  79. .flags = 0,
  80. .ucon = SMDKV210_UCON_DEFAULT,
  81. .ulcon = SMDKV210_ULCON_DEFAULT,
  82. .ufcon = SMDKV210_UFCON_DEFAULT,
  83. },
  84. };
  85. static struct s3c_ide_platdata smdkv210_ide_pdata __initdata = {
  86. .setup_gpio = s5pv210_ide_setup_gpio,
  87. };
  88. static uint32_t smdkv210_keymap[] __initdata = {
  89. /* KEY(row, col, keycode) */
  90. KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
  91. KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
  92. KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
  93. KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
  94. };
  95. static struct matrix_keymap_data smdkv210_keymap_data __initdata = {
  96. .keymap = smdkv210_keymap,
  97. .keymap_size = ARRAY_SIZE(smdkv210_keymap),
  98. };
  99. static struct samsung_keypad_platdata smdkv210_keypad_data __initdata = {
  100. .keymap_data = &smdkv210_keymap_data,
  101. .rows = 8,
  102. .cols = 8,
  103. };
  104. static struct resource smdkv210_dm9000_resources[] = {
  105. [0] = {
  106. .start = S5PV210_PA_SROM_BANK5,
  107. .end = S5PV210_PA_SROM_BANK5,
  108. .flags = IORESOURCE_MEM,
  109. },
  110. [1] = {
  111. .start = S5PV210_PA_SROM_BANK5 + 2,
  112. .end = S5PV210_PA_SROM_BANK5 + 2,
  113. .flags = IORESOURCE_MEM,
  114. },
  115. [2] = {
  116. .start = IRQ_EINT(9),
  117. .end = IRQ_EINT(9),
  118. .flags = IORESOURCE_IRQ | IORESOURCE_IRQ_HIGHLEVEL,
  119. },
  120. };
  121. static struct dm9000_plat_data smdkv210_dm9000_platdata = {
  122. .flags = DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM,
  123. .dev_addr = { 0x00, 0x09, 0xc0, 0xff, 0xec, 0x48 },
  124. };
  125. struct platform_device smdkv210_dm9000 = {
  126. .name = "dm9000",
  127. .id = -1,
  128. .num_resources = ARRAY_SIZE(smdkv210_dm9000_resources),
  129. .resource = smdkv210_dm9000_resources,
  130. .dev = {
  131. .platform_data = &smdkv210_dm9000_platdata,
  132. },
  133. };
  134. static void smdkv210_lte480wv_set_power(struct plat_lcd_data *pd,
  135. unsigned int power)
  136. {
  137. if (power) {
  138. #if !defined(CONFIG_BACKLIGHT_PWM)
  139. gpio_request(S5PV210_GPD0(3), "GPD0");
  140. gpio_direction_output(S5PV210_GPD0(3), 1);
  141. gpio_free(S5PV210_GPD0(3));
  142. #endif
  143. /* fire nRESET on power up */
  144. gpio_request(S5PV210_GPH0(6), "GPH0");
  145. gpio_direction_output(S5PV210_GPH0(6), 1);
  146. gpio_set_value(S5PV210_GPH0(6), 0);
  147. mdelay(10);
  148. gpio_set_value(S5PV210_GPH0(6), 1);
  149. mdelay(10);
  150. gpio_free(S5PV210_GPH0(6));
  151. } else {
  152. #if !defined(CONFIG_BACKLIGHT_PWM)
  153. gpio_request(S5PV210_GPD0(3), "GPD0");
  154. gpio_direction_output(S5PV210_GPD0(3), 0);
  155. gpio_free(S5PV210_GPD0(3));
  156. #endif
  157. }
  158. }
  159. static struct plat_lcd_data smdkv210_lcd_lte480wv_data = {
  160. .set_power = smdkv210_lte480wv_set_power,
  161. };
  162. static struct platform_device smdkv210_lcd_lte480wv = {
  163. .name = "platform-lcd",
  164. .dev.parent = &s3c_device_fb.dev,
  165. .dev.platform_data = &smdkv210_lcd_lte480wv_data,
  166. };
  167. static struct s3c_fb_pd_win smdkv210_fb_win0 = {
  168. .win_mode = {
  169. .left_margin = 13,
  170. .right_margin = 8,
  171. .upper_margin = 7,
  172. .lower_margin = 5,
  173. .hsync_len = 3,
  174. .vsync_len = 1,
  175. .xres = 800,
  176. .yres = 480,
  177. },
  178. .max_bpp = 32,
  179. .default_bpp = 24,
  180. };
  181. static struct s3c_fb_platdata smdkv210_lcd0_pdata __initdata = {
  182. .win[0] = &smdkv210_fb_win0,
  183. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  184. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  185. .setup_gpio = s5pv210_fb_gpio_setup_24bpp,
  186. };
  187. static int smdkv210_backlight_init(struct device *dev)
  188. {
  189. int ret;
  190. ret = gpio_request(S5PV210_GPD0(3), "Backlight");
  191. if (ret) {
  192. printk(KERN_ERR "failed to request GPD for PWM-OUT 3\n");
  193. return ret;
  194. }
  195. /* Configure GPIO pin with S5PV210_GPD_0_3_TOUT_3 */
  196. s3c_gpio_cfgpin(S5PV210_GPD0(3), S3C_GPIO_SFN(2));
  197. return 0;
  198. }
  199. static void smdkv210_backlight_exit(struct device *dev)
  200. {
  201. s3c_gpio_cfgpin(S5PV210_GPD0(3), S3C_GPIO_OUTPUT);
  202. gpio_free(S5PV210_GPD0(3));
  203. }
  204. static struct platform_pwm_backlight_data smdkv210_backlight_data = {
  205. .pwm_id = 3,
  206. .max_brightness = 255,
  207. .dft_brightness = 255,
  208. .pwm_period_ns = 78770,
  209. .init = smdkv210_backlight_init,
  210. .exit = smdkv210_backlight_exit,
  211. };
  212. static struct platform_device smdkv210_backlight_device = {
  213. .name = "pwm-backlight",
  214. .dev = {
  215. .parent = &s3c_device_timer[3].dev,
  216. .platform_data = &smdkv210_backlight_data,
  217. },
  218. };
  219. static struct platform_device *smdkv210_devices[] __initdata = {
  220. &s3c_device_adc,
  221. &s3c_device_cfcon,
  222. &s3c_device_fb,
  223. &s3c_device_hsmmc0,
  224. &s3c_device_hsmmc1,
  225. &s3c_device_hsmmc2,
  226. &s3c_device_hsmmc3,
  227. &s3c_device_i2c0,
  228. &s3c_device_i2c1,
  229. &s3c_device_i2c2,
  230. &s3c_device_rtc,
  231. &s3c_device_ts,
  232. &s3c_device_wdt,
  233. &s5pv210_device_ac97,
  234. &s5pv210_device_iis0,
  235. &s5pv210_device_spdif,
  236. &samsung_asoc_dma,
  237. &samsung_device_keypad,
  238. &smdkv210_dm9000,
  239. &smdkv210_lcd_lte480wv,
  240. &s3c_device_timer[3],
  241. &smdkv210_backlight_device,
  242. };
  243. static void __init smdkv210_dm9000_init(void)
  244. {
  245. unsigned int tmp;
  246. gpio_request(S5PV210_MP01(5), "nCS5");
  247. s3c_gpio_cfgpin(S5PV210_MP01(5), S3C_GPIO_SFN(2));
  248. gpio_free(S5PV210_MP01(5));
  249. tmp = (5 << S5P_SROM_BCX__TACC__SHIFT);
  250. __raw_writel(tmp, S5P_SROM_BC5);
  251. tmp = __raw_readl(S5P_SROM_BW);
  252. tmp &= (S5P_SROM_BW__CS_MASK << S5P_SROM_BW__NCS5__SHIFT);
  253. tmp |= (1 << S5P_SROM_BW__NCS5__SHIFT);
  254. __raw_writel(tmp, S5P_SROM_BW);
  255. }
  256. static struct i2c_board_info smdkv210_i2c_devs0[] __initdata = {
  257. { I2C_BOARD_INFO("24c08", 0x50), }, /* Samsung S524AD0XD1 */
  258. { I2C_BOARD_INFO("wm8580", 0x1b), },
  259. };
  260. static struct i2c_board_info smdkv210_i2c_devs1[] __initdata = {
  261. /* To Be Updated */
  262. };
  263. static struct i2c_board_info smdkv210_i2c_devs2[] __initdata = {
  264. /* To Be Updated */
  265. };
  266. static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
  267. .delay = 10000,
  268. .presc = 49,
  269. .oversampling_shift = 2,
  270. };
  271. static void __init smdkv210_map_io(void)
  272. {
  273. s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  274. s3c24xx_init_clocks(24000000);
  275. s3c24xx_init_uarts(smdkv210_uartcfgs, ARRAY_SIZE(smdkv210_uartcfgs));
  276. s5p_set_timer_source(S5P_PWM2, S5P_PWM4);
  277. }
  278. static void __init smdkv210_machine_init(void)
  279. {
  280. s3c_pm_init();
  281. smdkv210_dm9000_init();
  282. samsung_keypad_set_platdata(&smdkv210_keypad_data);
  283. s3c24xx_ts_set_platdata(&s3c_ts_platform);
  284. s3c_i2c0_set_platdata(NULL);
  285. s3c_i2c1_set_platdata(NULL);
  286. s3c_i2c2_set_platdata(NULL);
  287. i2c_register_board_info(0, smdkv210_i2c_devs0,
  288. ARRAY_SIZE(smdkv210_i2c_devs0));
  289. i2c_register_board_info(1, smdkv210_i2c_devs1,
  290. ARRAY_SIZE(smdkv210_i2c_devs1));
  291. i2c_register_board_info(2, smdkv210_i2c_devs2,
  292. ARRAY_SIZE(smdkv210_i2c_devs2));
  293. s3c_ide_set_platdata(&smdkv210_ide_pdata);
  294. s3c_fb_set_platdata(&smdkv210_lcd0_pdata);
  295. platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices));
  296. }
  297. MACHINE_START(SMDKV210, "SMDKV210")
  298. /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */
  299. .boot_params = S5P_PA_SDRAM + 0x100,
  300. .init_irq = s5pv210_init_irq,
  301. .map_io = smdkv210_map_io,
  302. .init_machine = smdkv210_machine_init,
  303. .timer = &s5p_timer,
  304. MACHINE_END