mach-anw6410.c 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. // SPDX-License-Identifier: GPL-2.0
  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. // Copyright 2009 Kwangwoo Lee
  8. // Kwangwoo Lee <kwangwoo.lee@gmail.com>
  9. #include <linux/kernel.h>
  10. #include <linux/types.h>
  11. #include <linux/interrupt.h>
  12. #include <linux/list.h>
  13. #include <linux/timer.h>
  14. #include <linux/init.h>
  15. #include <linux/serial_core.h>
  16. #include <linux/serial_s3c.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/io.h>
  19. #include <linux/i2c.h>
  20. #include <linux/fb.h>
  21. #include <linux/gpio.h>
  22. #include <linux/delay.h>
  23. #include <linux/dm9000.h>
  24. #include <video/platform_lcd.h>
  25. #include <video/samsung_fimd.h>
  26. #include <asm/mach/arch.h>
  27. #include <asm/mach/map.h>
  28. #include <asm/mach/irq.h>
  29. #include <mach/hardware.h>
  30. #include <mach/map.h>
  31. #include <asm/irq.h>
  32. #include <asm/mach-types.h>
  33. #include <linux/platform_data/i2c-s3c2410.h>
  34. #include <plat/fb.h>
  35. #include <plat/devs.h>
  36. #include <plat/cpu.h>
  37. #include <mach/irqs.h>
  38. #include <mach/regs-gpio.h>
  39. #include <mach/gpio-samsung.h>
  40. #include <plat/samsung-time.h>
  41. #include "common.h"
  42. #include "regs-modem.h"
  43. /* DM9000 */
  44. #define ANW6410_PA_DM9000 (0x18000000)
  45. /* A hardware buffer to control external devices is mapped at 0x30000000.
  46. * It can not be read. So current status must be kept in anw6410_extdev_status.
  47. */
  48. #define ANW6410_VA_EXTDEV S3C_ADDR(0x02000000)
  49. #define ANW6410_PA_EXTDEV (0x30000000)
  50. #define ANW6410_EN_DM9000 (1<<11)
  51. #define ANW6410_EN_LCD (1<<14)
  52. static __u32 anw6410_extdev_status;
  53. static struct s3c2410_uartcfg anw6410_uartcfgs[] __initdata = {
  54. [0] = {
  55. .hwport = 0,
  56. .flags = 0,
  57. .ucon = 0x3c5,
  58. .ulcon = 0x03,
  59. .ufcon = 0x51,
  60. },
  61. [1] = {
  62. .hwport = 1,
  63. .flags = 0,
  64. .ucon = 0x3c5,
  65. .ulcon = 0x03,
  66. .ufcon = 0x51,
  67. },
  68. };
  69. /* framebuffer and LCD setup. */
  70. static void __init anw6410_lcd_mode_set(void)
  71. {
  72. u32 tmp;
  73. /* set the LCD type */
  74. tmp = __raw_readl(S3C64XX_SPCON);
  75. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  76. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  77. __raw_writel(tmp, S3C64XX_SPCON);
  78. /* remove the LCD bypass */
  79. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  80. tmp &= ~MIFPCON_LCD_BYPASS;
  81. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  82. }
  83. /* GPF1 = LCD panel power
  84. * GPF4 = LCD backlight control
  85. */
  86. static void anw6410_lcd_power_set(struct plat_lcd_data *pd,
  87. unsigned int power)
  88. {
  89. if (power) {
  90. anw6410_extdev_status |= (ANW6410_EN_LCD << 16);
  91. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  92. gpio_direction_output(S3C64XX_GPF(1), 1);
  93. gpio_direction_output(S3C64XX_GPF(4), 1);
  94. } else {
  95. anw6410_extdev_status &= ~(ANW6410_EN_LCD << 16);
  96. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  97. gpio_direction_output(S3C64XX_GPF(1), 0);
  98. gpio_direction_output(S3C64XX_GPF(4), 0);
  99. }
  100. }
  101. static struct plat_lcd_data anw6410_lcd_power_data = {
  102. .set_power = anw6410_lcd_power_set,
  103. };
  104. static struct platform_device anw6410_lcd_powerdev = {
  105. .name = "platform-lcd",
  106. .dev.parent = &s3c_device_fb.dev,
  107. .dev.platform_data = &anw6410_lcd_power_data,
  108. };
  109. static struct s3c_fb_pd_win anw6410_fb_win0 = {
  110. .max_bpp = 32,
  111. .default_bpp = 16,
  112. .xres = 800,
  113. .yres = 480,
  114. };
  115. static struct fb_videomode anw6410_lcd_timing = {
  116. .left_margin = 8,
  117. .right_margin = 13,
  118. .upper_margin = 7,
  119. .lower_margin = 5,
  120. .hsync_len = 3,
  121. .vsync_len = 1,
  122. .xres = 800,
  123. .yres = 480,
  124. };
  125. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  126. static struct s3c_fb_platdata anw6410_lcd_pdata __initdata = {
  127. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  128. .vtiming = &anw6410_lcd_timing,
  129. .win[0] = &anw6410_fb_win0,
  130. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  131. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  132. };
  133. /* DM9000AEP 10/100 ethernet controller */
  134. static void __init anw6410_dm9000_enable(void)
  135. {
  136. anw6410_extdev_status |= (ANW6410_EN_DM9000 << 16);
  137. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  138. }
  139. static struct resource anw6410_dm9000_resource[] = {
  140. [0] = DEFINE_RES_MEM(ANW6410_PA_DM9000, 4),
  141. [1] = DEFINE_RES_MEM(ANW6410_PA_DM9000 + 4, 501),
  142. [2] = DEFINE_RES_NAMED(IRQ_EINT(15), 1, NULL, IORESOURCE_IRQ \
  143. | IRQF_TRIGGER_HIGH),
  144. };
  145. static struct dm9000_plat_data anw6410_dm9000_pdata = {
  146. .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  147. /* dev_addr can be set to provide hwaddr. */
  148. };
  149. static struct platform_device anw6410_device_eth = {
  150. .name = "dm9000",
  151. .id = -1,
  152. .num_resources = ARRAY_SIZE(anw6410_dm9000_resource),
  153. .resource = anw6410_dm9000_resource,
  154. .dev = {
  155. .platform_data = &anw6410_dm9000_pdata,
  156. },
  157. };
  158. static struct map_desc anw6410_iodesc[] __initdata = {
  159. {
  160. .virtual = (unsigned long)ANW6410_VA_EXTDEV,
  161. .pfn = __phys_to_pfn(ANW6410_PA_EXTDEV),
  162. .length = SZ_64K,
  163. .type = MT_DEVICE,
  164. },
  165. };
  166. static struct platform_device *anw6410_devices[] __initdata = {
  167. &s3c_device_fb,
  168. &anw6410_lcd_powerdev,
  169. &anw6410_device_eth,
  170. };
  171. static void __init anw6410_map_io(void)
  172. {
  173. s3c64xx_init_io(anw6410_iodesc, ARRAY_SIZE(anw6410_iodesc));
  174. s3c64xx_set_xtal_freq(12000000);
  175. s3c24xx_init_uarts(anw6410_uartcfgs, ARRAY_SIZE(anw6410_uartcfgs));
  176. samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4);
  177. anw6410_lcd_mode_set();
  178. }
  179. static void __init anw6410_machine_init(void)
  180. {
  181. s3c_fb_set_platdata(&anw6410_lcd_pdata);
  182. gpio_request(S3C64XX_GPF(1), "panel power");
  183. gpio_request(S3C64XX_GPF(4), "LCD backlight");
  184. anw6410_dm9000_enable();
  185. platform_add_devices(anw6410_devices, ARRAY_SIZE(anw6410_devices));
  186. }
  187. MACHINE_START(ANW6410, "A&W6410")
  188. /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */
  189. .atag_offset = 0x100,
  190. .nr_irqs = S3C64XX_NR_IRQS,
  191. .init_irq = s3c6410_init_irq,
  192. .map_io = anw6410_map_io,
  193. .init_machine = anw6410_machine_init,
  194. .init_time = samsung_timer_init,
  195. .restart = s3c64xx_restart,
  196. MACHINE_END