mach-smdk2416.c 6.0 KB

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