mach-anw6410.c 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  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/mach/arch.h>
  31. #include <asm/mach/map.h>
  32. #include <asm/mach/irq.h>
  33. #include <mach/hardware.h>
  34. #include <mach/regs-fb.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 <mach/s3c6410.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. /* DM9000 */
  48. #define ANW6410_PA_DM9000 (0x18000000)
  49. /* A hardware buffer to control external devices is mapped at 0x30000000.
  50. * It can not be read. So current status must be kept in anw6410_extdev_status.
  51. */
  52. #define ANW6410_VA_EXTDEV S3C_ADDR(0x02000000)
  53. #define ANW6410_PA_EXTDEV (0x30000000)
  54. #define ANW6410_EN_DM9000 (1<<11)
  55. #define ANW6410_EN_LCD (1<<14)
  56. static __u32 anw6410_extdev_status;
  57. static struct s3c2410_uartcfg anw6410_uartcfgs[] __initdata = {
  58. [0] = {
  59. .hwport = 0,
  60. .flags = 0,
  61. .ucon = 0x3c5,
  62. .ulcon = 0x03,
  63. .ufcon = 0x51,
  64. },
  65. [1] = {
  66. .hwport = 1,
  67. .flags = 0,
  68. .ucon = 0x3c5,
  69. .ulcon = 0x03,
  70. .ufcon = 0x51,
  71. },
  72. };
  73. /* framebuffer and LCD setup. */
  74. static void __init anw6410_lcd_mode_set(void)
  75. {
  76. u32 tmp;
  77. /* set the LCD type */
  78. tmp = __raw_readl(S3C64XX_SPCON);
  79. tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK;
  80. tmp |= S3C64XX_SPCON_LCD_SEL_RGB;
  81. __raw_writel(tmp, S3C64XX_SPCON);
  82. /* remove the LCD bypass */
  83. tmp = __raw_readl(S3C64XX_MODEM_MIFPCON);
  84. tmp &= ~MIFPCON_LCD_BYPASS;
  85. __raw_writel(tmp, S3C64XX_MODEM_MIFPCON);
  86. }
  87. /* GPF1 = LCD panel power
  88. * GPF4 = LCD backlight control
  89. */
  90. static void anw6410_lcd_power_set(struct plat_lcd_data *pd,
  91. unsigned int power)
  92. {
  93. if (power) {
  94. anw6410_extdev_status |= (ANW6410_EN_LCD << 16);
  95. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  96. gpio_direction_output(S3C64XX_GPF(1), 1);
  97. gpio_direction_output(S3C64XX_GPF(4), 1);
  98. } else {
  99. anw6410_extdev_status &= ~(ANW6410_EN_LCD << 16);
  100. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  101. gpio_direction_output(S3C64XX_GPF(1), 0);
  102. gpio_direction_output(S3C64XX_GPF(4), 0);
  103. }
  104. }
  105. static struct plat_lcd_data anw6410_lcd_power_data = {
  106. .set_power = anw6410_lcd_power_set,
  107. };
  108. static struct platform_device anw6410_lcd_powerdev = {
  109. .name = "platform-lcd",
  110. .dev.parent = &s3c_device_fb.dev,
  111. .dev.platform_data = &anw6410_lcd_power_data,
  112. };
  113. static struct s3c_fb_pd_win anw6410_fb_win0 = {
  114. /* this is to ensure we use win0 */
  115. .win_mode = {
  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. .max_bpp = 32,
  126. .default_bpp = 16,
  127. };
  128. /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */
  129. static struct s3c_fb_platdata anw6410_lcd_pdata __initdata = {
  130. .setup_gpio = s3c64xx_fb_gpio_setup_24bpp,
  131. .win[0] = &anw6410_fb_win0,
  132. .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB,
  133. .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC,
  134. };
  135. /* DM9000AEP 10/100 ethernet controller */
  136. static void __init anw6410_dm9000_enable(void)
  137. {
  138. anw6410_extdev_status |= (ANW6410_EN_DM9000 << 16);
  139. __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV);
  140. }
  141. static struct resource anw6410_dm9000_resource[] = {
  142. [0] = {
  143. .start = ANW6410_PA_DM9000,
  144. .end = ANW6410_PA_DM9000 + 3,
  145. .flags = IORESOURCE_MEM,
  146. },
  147. [1] = {
  148. .start = ANW6410_PA_DM9000 + 4,
  149. .end = ANW6410_PA_DM9000 + 4 + 500,
  150. .flags = IORESOURCE_MEM,
  151. },
  152. [2] = {
  153. .start = IRQ_EINT(15),
  154. .end = IRQ_EINT(15),
  155. .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH,
  156. },
  157. };
  158. static struct dm9000_plat_data anw6410_dm9000_pdata = {
  159. .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM),
  160. /* dev_addr can be set to provide hwaddr. */
  161. };
  162. static struct platform_device anw6410_device_eth = {
  163. .name = "dm9000",
  164. .id = -1,
  165. .num_resources = ARRAY_SIZE(anw6410_dm9000_resource),
  166. .resource = anw6410_dm9000_resource,
  167. .dev = {
  168. .platform_data = &anw6410_dm9000_pdata,
  169. },
  170. };
  171. static struct map_desc anw6410_iodesc[] __initdata = {
  172. {
  173. .virtual = (unsigned long)ANW6410_VA_EXTDEV,
  174. .pfn = __phys_to_pfn(ANW6410_PA_EXTDEV),
  175. .length = SZ_64K,
  176. .type = MT_DEVICE,
  177. },
  178. };
  179. static struct platform_device *anw6410_devices[] __initdata = {
  180. &s3c_device_fb,
  181. &anw6410_lcd_powerdev,
  182. &anw6410_device_eth,
  183. };
  184. static void __init anw6410_map_io(void)
  185. {
  186. s3c64xx_init_io(anw6410_iodesc, ARRAY_SIZE(anw6410_iodesc));
  187. s3c24xx_init_clocks(12000000);
  188. s3c24xx_init_uarts(anw6410_uartcfgs, ARRAY_SIZE(anw6410_uartcfgs));
  189. anw6410_lcd_mode_set();
  190. }
  191. static void __init anw6410_machine_init(void)
  192. {
  193. s3c_fb_set_platdata(&anw6410_lcd_pdata);
  194. gpio_request(S3C64XX_GPF(1), "panel power");
  195. gpio_request(S3C64XX_GPF(4), "LCD backlight");
  196. anw6410_dm9000_enable();
  197. platform_add_devices(anw6410_devices, ARRAY_SIZE(anw6410_devices));
  198. }
  199. MACHINE_START(ANW6410, "A&W6410")
  200. /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */
  201. .phys_io = S3C_PA_UART & 0xfff00000,
  202. .io_pg_offst = (((u32)S3C_VA_UART) >> 18) & 0xfffc,
  203. .boot_params = S3C64XX_PA_SDRAM + 0x100,
  204. .init_irq = s3c6410_init_irq,
  205. .map_io = anw6410_map_io,
  206. .init_machine = anw6410_machine_init,
  207. .timer = &s3c24xx_timer,
  208. MACHINE_END