mach-smdkc100.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. /* linux/arch/arm/mach-s5pc100/mach-smdkc100.c
  2. *
  3. * Copyright 2009 Samsung Electronics Co.
  4. * Author: Byungho Min <bhmin@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. */
  11. #include <linux/kernel.h>
  12. #include <linux/types.h>
  13. #include <linux/interrupt.h>
  14. #include <linux/list.h>
  15. #include <linux/timer.h>
  16. #include <linux/init.h>
  17. #include <linux/serial_core.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/io.h>
  20. #include <linux/gpio.h>
  21. #include <linux/i2c.h>
  22. #include <linux/fb.h>
  23. #include <linux/delay.h>
  24. #include <linux/input.h>
  25. #include <linux/pwm_backlight.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <mach/map.h>
  29. #include <mach/regs-fb.h>
  30. #include <mach/regs-gpio.h>
  31. #include <video/platform_lcd.h>
  32. #include <asm/irq.h>
  33. #include <asm/mach-types.h>
  34. #include <plat/regs-serial.h>
  35. #include <plat/gpio-cfg.h>
  36. #include <plat/clock.h>
  37. #include <plat/devs.h>
  38. #include <plat/cpu.h>
  39. #include <plat/s5pc100.h>
  40. #include <plat/fb.h>
  41. #include <plat/iic.h>
  42. #include <plat/ata.h>
  43. #include <plat/adc.h>
  44. #include <plat/keypad.h>
  45. #include <plat/ts.h>
  46. #include <plat/audio.h>
  47. /* Following are default values for UCON, ULCON and UFCON UART registers */
  48. #define SMDKC100_UCON_DEFAULT (S3C2410_UCON_TXILEVEL | \
  49. S3C2410_UCON_RXILEVEL | \
  50. S3C2410_UCON_TXIRQMODE | \
  51. S3C2410_UCON_RXIRQMODE | \
  52. S3C2410_UCON_RXFIFO_TOI | \
  53. S3C2443_UCON_RXERR_IRQEN)
  54. #define SMDKC100_ULCON_DEFAULT S3C2410_LCON_CS8
  55. #define SMDKC100_UFCON_DEFAULT (S3C2410_UFCON_FIFOMODE | \
  56. S3C2440_UFCON_RXTRIG8 | \
  57. S3C2440_UFCON_TXTRIG16)
  58. static struct s3c2410_uartcfg smdkc100_uartcfgs[] __initdata = {
  59. [0] = {
  60. .hwport = 0,
  61. .flags = 0,
  62. .ucon = SMDKC100_UCON_DEFAULT,
  63. .ulcon = SMDKC100_ULCON_DEFAULT,
  64. .ufcon = SMDKC100_UFCON_DEFAULT,
  65. },
  66. [1] = {
  67. .hwport = 1,
  68. .flags = 0,
  69. .ucon = SMDKC100_UCON_DEFAULT,
  70. .ulcon = SMDKC100_ULCON_DEFAULT,
  71. .ufcon = SMDKC100_UFCON_DEFAULT,
  72. },
  73. [2] = {
  74. .hwport = 2,
  75. .flags = 0,
  76. .ucon = SMDKC100_UCON_DEFAULT,
  77. .ulcon = SMDKC100_ULCON_DEFAULT,
  78. .ufcon = SMDKC100_UFCON_DEFAULT,
  79. },
  80. [3] = {
  81. .hwport = 3,
  82. .flags = 0,
  83. .ucon = SMDKC100_UCON_DEFAULT,
  84. .ulcon = SMDKC100_ULCON_DEFAULT,
  85. .ufcon = SMDKC100_UFCON_DEFAULT,
  86. },
  87. };
  88. /* I2C0 */
  89. static struct i2c_board_info i2c_devs0[] __initdata = {
  90. {I2C_BOARD_INFO("wm8580", 0x1b),},
  91. };
  92. /* I2C1 */
  93. static struct i2c_board_info i2c_devs1[] __initdata = {
  94. };
  95. /* LCD power controller */
  96. static void smdkc100_lcd_power_set(struct plat_lcd_data *pd,
  97. unsigned int power)
  98. {
  99. if (power) {
  100. /* module reset */
  101. gpio_direction_output(S5PC100_GPH0(6), 1);
  102. mdelay(100);
  103. gpio_direction_output(S5PC100_GPH0(6), 0);
  104. mdelay(10);
  105. gpio_direction_output(S5PC100_GPH0(6), 1);
  106. mdelay(10);
  107. }
  108. }
  109. static struct plat_lcd_data smdkc100_lcd_power_data = {
  110. .set_power = smdkc100_lcd_power_set,
  111. };
  112. static struct platform_device smdkc100_lcd_powerdev = {
  113. .name = "platform-lcd",
  114. .dev.parent = &s3c_device_fb.dev,
  115. .dev.platform_data = &smdkc100_lcd_power_data,
  116. };
  117. /* Frame Buffer */
  118. static struct s3c_fb_pd_win smdkc100_fb_win0 = {
  119. /* this is to ensure we use win0 */
  120. .win_mode = {
  121. .left_margin = 8,
  122. .right_margin = 13,
  123. .upper_margin = 7,
  124. .lower_margin = 5,
  125. .hsync_len = 3,
  126. .vsync_len = 1,
  127. .xres = 800,
  128. .yres = 480,
  129. .refresh = 80,
  130. },
  131. .max_bpp = 32,
  132. .default_bpp = 16,
  133. };
  134. static struct s3c_fb_platdata smdkc100_lcd_pdata __initdata = {
  135. .win[0] = &smdkc100_fb_win0,
  136. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  137. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  138. .setup_gpio = s5pc100_fb_gpio_setup_24bpp,
  139. };
  140. static struct s3c_ide_platdata smdkc100_ide_pdata __initdata = {
  141. .setup_gpio = s5pc100_ide_setup_gpio,
  142. };
  143. static uint32_t smdkc100_keymap[] __initdata = {
  144. /* KEY(row, col, keycode) */
  145. KEY(0, 3, KEY_1), KEY(0, 4, KEY_2), KEY(0, 5, KEY_3),
  146. KEY(0, 6, KEY_4), KEY(0, 7, KEY_5),
  147. KEY(1, 3, KEY_A), KEY(1, 4, KEY_B), KEY(1, 5, KEY_C),
  148. KEY(1, 6, KEY_D), KEY(1, 7, KEY_E)
  149. };
  150. static struct matrix_keymap_data smdkc100_keymap_data __initdata = {
  151. .keymap = smdkc100_keymap,
  152. .keymap_size = ARRAY_SIZE(smdkc100_keymap),
  153. };
  154. static struct samsung_keypad_platdata smdkc100_keypad_data __initdata = {
  155. .keymap_data = &smdkc100_keymap_data,
  156. .rows = 2,
  157. .cols = 8,
  158. };
  159. static int smdkc100_backlight_init(struct device *dev)
  160. {
  161. int ret;
  162. ret = gpio_request(S5PC100_GPD(0), "Backlight");
  163. if (ret) {
  164. printk(KERN_ERR "failed to request GPF for PWM-OUT0\n");
  165. return ret;
  166. }
  167. /* Configure GPIO pin with S5PC100_GPD_TOUT_0 */
  168. s3c_gpio_cfgpin(S5PC100_GPD(0), S3C_GPIO_SFN(2));
  169. return 0;
  170. }
  171. static void smdkc100_backlight_exit(struct device *dev)
  172. {
  173. s3c_gpio_cfgpin(S5PC100_GPD(0), S3C_GPIO_OUTPUT);
  174. gpio_free(S5PC100_GPD(0));
  175. }
  176. static struct platform_pwm_backlight_data smdkc100_backlight_data = {
  177. .pwm_id = 0,
  178. .max_brightness = 255,
  179. .dft_brightness = 255,
  180. .pwm_period_ns = 78770,
  181. .init = smdkc100_backlight_init,
  182. .exit = smdkc100_backlight_exit,
  183. };
  184. static struct platform_device smdkc100_backlight_device = {
  185. .name = "pwm-backlight",
  186. .dev = {
  187. .parent = &s3c_device_timer[0].dev,
  188. .platform_data = &smdkc100_backlight_data,
  189. },
  190. };
  191. static struct platform_device *smdkc100_devices[] __initdata = {
  192. &s3c_device_adc,
  193. &s3c_device_cfcon,
  194. &s3c_device_i2c0,
  195. &s3c_device_i2c1,
  196. &s3c_device_fb,
  197. &s3c_device_hsmmc0,
  198. &s3c_device_hsmmc1,
  199. &s3c_device_hsmmc2,
  200. &s3c_device_ts,
  201. &s3c_device_wdt,
  202. &smdkc100_lcd_powerdev,
  203. &samsung_asoc_dma,
  204. &s5pc100_device_iis0,
  205. &samsung_device_keypad,
  206. &s5pc100_device_ac97,
  207. &s3c_device_rtc,
  208. &s5p_device_fimc0,
  209. &s5p_device_fimc1,
  210. &s5p_device_fimc2,
  211. &s5pc100_device_spdif,
  212. &s3c_device_timer[0],
  213. &smdkc100_backlight_device,
  214. };
  215. static struct s3c2410_ts_mach_info s3c_ts_platform __initdata = {
  216. .delay = 10000,
  217. .presc = 49,
  218. .oversampling_shift = 2,
  219. };
  220. static void __init smdkc100_map_io(void)
  221. {
  222. s5p_init_io(NULL, 0, S5P_VA_CHIPID);
  223. s3c24xx_init_clocks(12000000);
  224. s3c24xx_init_uarts(smdkc100_uartcfgs, ARRAY_SIZE(smdkc100_uartcfgs));
  225. }
  226. static void __init smdkc100_machine_init(void)
  227. {
  228. s3c24xx_ts_set_platdata(&s3c_ts_platform);
  229. /* I2C */
  230. s3c_i2c0_set_platdata(NULL);
  231. s3c_i2c1_set_platdata(NULL);
  232. i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
  233. i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
  234. s3c_fb_set_platdata(&smdkc100_lcd_pdata);
  235. s3c_ide_set_platdata(&smdkc100_ide_pdata);
  236. samsung_keypad_set_platdata(&smdkc100_keypad_data);
  237. s5pc100_spdif_setup_gpio(S5PC100_SPDIF_GPD);
  238. /* LCD init */
  239. gpio_request(S5PC100_GPH0(6), "GPH0");
  240. smdkc100_lcd_power_set(&smdkc100_lcd_power_data, 0);
  241. platform_add_devices(smdkc100_devices, ARRAY_SIZE(smdkc100_devices));
  242. }
  243. MACHINE_START(SMDKC100, "SMDKC100")
  244. /* Maintainer: Byungho Min <bhmin@samsung.com> */
  245. .boot_params = S5P_PA_SDRAM + 0x100,
  246. .init_irq = s5pc100_init_irq,
  247. .map_io = smdkc100_map_io,
  248. .init_machine = smdkc100_machine_init,
  249. .timer = &s3c24xx_timer,
  250. MACHINE_END