mach-anw6410.c 5.6 KB

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