mach-smdk2416.c 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. // SPDX-License-Identifier: GPL-2.0
  2. //
  3. // Copyright (c) 2009 Yauhen Kharuzhy <jekhor@gmail.com>,
  4. // as part of OpenInkpot project
  5. // Copyright (c) 2009 Promwad Innovation Company
  6. // Yauhen Kharuzhy <yauhen.kharuzhy@promwad.com>
  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/serial_core.h>
  14. #include <linux/serial_s3c.h>
  15. #include <linux/platform_device.h>
  16. #include <linux/io.h>
  17. #include <linux/mtd/partitions.h>
  18. #include <linux/gpio.h>
  19. #include <linux/fb.h>
  20. #include <linux/delay.h>
  21. #include <asm/mach/arch.h>
  22. #include <asm/mach/map.h>
  23. #include <asm/mach/irq.h>
  24. #include <video/samsung_fimd.h>
  25. #include <mach/hardware.h>
  26. #include <asm/irq.h>
  27. #include <asm/mach-types.h>
  28. #include <mach/regs-gpio.h>
  29. #include <mach/regs-lcd.h>
  30. #include <mach/regs-s3c2443-clock.h>
  31. #include <mach/gpio-samsung.h>
  32. #include <linux/platform_data/leds-s3c24xx.h>
  33. #include <linux/platform_data/i2c-s3c2410.h>
  34. #include <plat/gpio-cfg.h>
  35. #include <plat/devs.h>
  36. #include <plat/cpu.h>
  37. #include <linux/platform_data/mtd-nand-s3c2410.h>
  38. #include <plat/sdhci.h>
  39. #include <linux/platform_data/usb-s3c2410_udc.h>
  40. #include <linux/platform_data/s3c-hsudc.h>
  41. #include <plat/samsung-time.h>
  42. #include <plat/fb.h>
  43. #include "common.h"
  44. #include "common-smdk.h"
  45. static struct map_desc smdk2416_iodesc[] __initdata = {
  46. /* ISA IO Space map (memory space selected by A24) */
  47. {
  48. .virtual = (u32)S3C24XX_VA_ISA_WORD,
  49. .pfn = __phys_to_pfn(S3C2410_CS2),
  50. .length = 0x10000,
  51. .type = MT_DEVICE,
  52. }, {
  53. .virtual = (u32)S3C24XX_VA_ISA_WORD + 0x10000,
  54. .pfn = __phys_to_pfn(S3C2410_CS2 + (1<<24)),
  55. .length = SZ_4M,
  56. .type = MT_DEVICE,
  57. }, {
  58. .virtual = (u32)S3C24XX_VA_ISA_BYTE,
  59. .pfn = __phys_to_pfn(S3C2410_CS2),
  60. .length = 0x10000,
  61. .type = MT_DEVICE,
  62. }, {
  63. .virtual = (u32)S3C24XX_VA_ISA_BYTE + 0x10000,
  64. .pfn = __phys_to_pfn(S3C2410_CS2 + (1<<24)),
  65. .length = SZ_4M,
  66. .type = MT_DEVICE,
  67. }
  68. };
  69. #define UCON (S3C2410_UCON_DEFAULT | \
  70. S3C2440_UCON_PCLK | \
  71. S3C2443_UCON_RXERR_IRQEN)
  72. #define ULCON (S3C2410_LCON_CS8 | S3C2410_LCON_PNONE)
  73. #define UFCON (S3C2410_UFCON_RXTRIG8 | \
  74. S3C2410_UFCON_FIFOMODE | \
  75. S3C2440_UFCON_TXTRIG16)
  76. static struct s3c2410_uartcfg smdk2416_uartcfgs[] __initdata = {
  77. [0] = {
  78. .hwport = 0,
  79. .flags = 0,
  80. .ucon = UCON,
  81. .ulcon = ULCON,
  82. .ufcon = UFCON,
  83. },
  84. [1] = {
  85. .hwport = 1,
  86. .flags = 0,
  87. .ucon = UCON,
  88. .ulcon = ULCON,
  89. .ufcon = UFCON,
  90. },
  91. /* IR port */
  92. [2] = {
  93. .hwport = 2,
  94. .flags = 0,
  95. .ucon = UCON,
  96. .ulcon = ULCON | 0x50,
  97. .ufcon = UFCON,
  98. },
  99. [3] = {
  100. .hwport = 3,
  101. .flags = 0,
  102. .ucon = UCON,
  103. .ulcon = ULCON,
  104. .ufcon = UFCON,
  105. }
  106. };
  107. static void smdk2416_hsudc_gpio_init(void)
  108. {
  109. s3c_gpio_setpull(S3C2410_GPH(14), S3C_GPIO_PULL_UP);
  110. s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_NONE);
  111. s3c_gpio_cfgpin(S3C2410_GPH(14), S3C_GPIO_SFN(1));
  112. s3c2410_modify_misccr(S3C2416_MISCCR_SEL_SUSPND, 0);
  113. }
  114. static void smdk2416_hsudc_gpio_uninit(void)
  115. {
  116. s3c2410_modify_misccr(S3C2416_MISCCR_SEL_SUSPND, 1);
  117. s3c_gpio_setpull(S3C2410_GPH(14), S3C_GPIO_PULL_NONE);
  118. s3c_gpio_cfgpin(S3C2410_GPH(14), S3C_GPIO_SFN(0));
  119. }
  120. static struct s3c24xx_hsudc_platdata smdk2416_hsudc_platdata = {
  121. .epnum = 9,
  122. .gpio_init = smdk2416_hsudc_gpio_init,
  123. .gpio_uninit = smdk2416_hsudc_gpio_uninit,
  124. };
  125. static struct s3c_fb_pd_win smdk2416_fb_win[] = {
  126. [0] = {
  127. .default_bpp = 16,
  128. .max_bpp = 32,
  129. .xres = 800,
  130. .yres = 480,
  131. },
  132. };
  133. static struct fb_videomode smdk2416_lcd_timing = {
  134. .pixclock = 41094,
  135. .left_margin = 8,
  136. .right_margin = 13,
  137. .upper_margin = 7,
  138. .lower_margin = 5,
  139. .hsync_len = 3,
  140. .vsync_len = 1,
  141. .xres = 800,
  142. .yres = 480,
  143. };
  144. static void s3c2416_fb_gpio_setup_24bpp(void)
  145. {
  146. unsigned int gpio;
  147. for (gpio = S3C2410_GPC(1); gpio <= S3C2410_GPC(4); gpio++) {
  148. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  149. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  150. }
  151. for (gpio = S3C2410_GPC(8); gpio <= S3C2410_GPC(15); gpio++) {
  152. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  153. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  154. }
  155. for (gpio = S3C2410_GPD(0); gpio <= S3C2410_GPD(15); gpio++) {
  156. s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
  157. s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
  158. }
  159. }
  160. static struct s3c_fb_platdata smdk2416_fb_platdata = {
  161. .win[0] = &smdk2416_fb_win[0],
  162. .vtiming = &smdk2416_lcd_timing,
  163. .setup_gpio = s3c2416_fb_gpio_setup_24bpp,
  164. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  165. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  166. };
  167. static struct s3c_sdhci_platdata smdk2416_hsmmc0_pdata __initdata = {
  168. .max_width = 4,
  169. .cd_type = S3C_SDHCI_CD_GPIO,
  170. .ext_cd_gpio = S3C2410_GPF(1),
  171. .ext_cd_gpio_invert = 1,
  172. };
  173. static struct s3c_sdhci_platdata smdk2416_hsmmc1_pdata __initdata = {
  174. .max_width = 4,
  175. .cd_type = S3C_SDHCI_CD_NONE,
  176. };
  177. static struct platform_device *smdk2416_devices[] __initdata = {
  178. &s3c_device_fb,
  179. &s3c_device_wdt,
  180. &s3c_device_ohci,
  181. &s3c_device_i2c0,
  182. &s3c_device_hsmmc0,
  183. &s3c_device_hsmmc1,
  184. &s3c_device_usb_hsudc,
  185. &s3c2443_device_dma,
  186. };
  187. static void __init smdk2416_init_time(void)
  188. {
  189. s3c2416_init_clocks(12000000);
  190. samsung_timer_init();
  191. }
  192. static void __init smdk2416_map_io(void)
  193. {
  194. s3c24xx_init_io(smdk2416_iodesc, ARRAY_SIZE(smdk2416_iodesc));
  195. s3c24xx_init_uarts(smdk2416_uartcfgs, ARRAY_SIZE(smdk2416_uartcfgs));
  196. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  197. }
  198. static void __init smdk2416_machine_init(void)
  199. {
  200. s3c_i2c0_set_platdata(NULL);
  201. s3c_fb_set_platdata(&smdk2416_fb_platdata);
  202. s3c_sdhci0_set_platdata(&smdk2416_hsmmc0_pdata);
  203. s3c_sdhci1_set_platdata(&smdk2416_hsmmc1_pdata);
  204. s3c24xx_hsudc_set_platdata(&smdk2416_hsudc_platdata);
  205. gpio_request(S3C2410_GPB(4), "USBHost Power");
  206. gpio_direction_output(S3C2410_GPB(4), 1);
  207. gpio_request(S3C2410_GPB(3), "Display Power");
  208. gpio_direction_output(S3C2410_GPB(3), 1);
  209. gpio_request(S3C2410_GPB(1), "Display Reset");
  210. gpio_direction_output(S3C2410_GPB(1), 1);
  211. platform_add_devices(smdk2416_devices, ARRAY_SIZE(smdk2416_devices));
  212. smdk_machine_init();
  213. }
  214. MACHINE_START(SMDK2416, "SMDK2416")
  215. /* Maintainer: Yauhen Kharuzhy <jekhor@gmail.com> */
  216. .atag_offset = 0x100,
  217. .init_irq = s3c2416_init_irq,
  218. .map_io = smdk2416_map_io,
  219. .init_machine = smdk2416_machine_init,
  220. .init_time = smdk2416_init_time,
  221. MACHINE_END