mach-anw6410.c 5.8 KB

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