Ben Dooks | 431107e | 2010-01-26 10:11:04 +0900 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c64xx/mach-anw6410.c |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 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 | |
| 16 | #include <linux/kernel.h> |
| 17 | #include <linux/types.h> |
| 18 | #include <linux/interrupt.h> |
| 19 | #include <linux/list.h> |
| 20 | #include <linux/timer.h> |
| 21 | #include <linux/init.h> |
| 22 | #include <linux/serial_core.h> |
| 23 | #include <linux/platform_device.h> |
| 24 | #include <linux/io.h> |
| 25 | #include <linux/i2c.h> |
| 26 | #include <linux/fb.h> |
| 27 | #include <linux/gpio.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/dm9000.h> |
| 30 | |
| 31 | #include <video/platform_lcd.h> |
| 32 | |
Jamie Iles | 774b51f | 2011-11-04 01:10:04 +0000 | [diff] [blame] | 33 | #include <asm/hardware/vic.h> |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 34 | #include <asm/mach/arch.h> |
| 35 | #include <asm/mach/map.h> |
| 36 | #include <asm/mach/irq.h> |
| 37 | |
| 38 | #include <mach/hardware.h> |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 39 | #include <mach/map.h> |
| 40 | |
| 41 | #include <asm/irq.h> |
| 42 | #include <asm/mach-types.h> |
| 43 | |
| 44 | #include <plat/regs-serial.h> |
| 45 | #include <plat/iic.h> |
| 46 | #include <plat/fb.h> |
Ajay Kumar | 49965e6 | 2011-07-21 01:23:19 +0900 | [diff] [blame] | 47 | #include <plat/regs-fb-v4.h> |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 48 | |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 49 | #include <plat/clock.h> |
| 50 | #include <plat/devs.h> |
| 51 | #include <plat/cpu.h> |
Ben Dooks | 3501c9a | 2010-01-26 10:45:40 +0900 | [diff] [blame] | 52 | #include <mach/regs-gpio.h> |
| 53 | #include <mach/regs-modem.h> |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 54 | |
Kukjin Kim | b024043b | 2011-12-22 23:27:42 +0100 | [diff] [blame] | 55 | #include "common.h" |
| 56 | |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 57 | /* DM9000 */ |
| 58 | #define ANW6410_PA_DM9000 (0x18000000) |
| 59 | |
| 60 | /* A hardware buffer to control external devices is mapped at 0x30000000. |
| 61 | * It can not be read. So current status must be kept in anw6410_extdev_status. |
| 62 | */ |
| 63 | #define ANW6410_VA_EXTDEV S3C_ADDR(0x02000000) |
| 64 | #define ANW6410_PA_EXTDEV (0x30000000) |
| 65 | |
| 66 | #define ANW6410_EN_DM9000 (1<<11) |
| 67 | #define ANW6410_EN_LCD (1<<14) |
| 68 | |
| 69 | static __u32 anw6410_extdev_status; |
| 70 | |
| 71 | static struct s3c2410_uartcfg anw6410_uartcfgs[] __initdata = { |
| 72 | [0] = { |
| 73 | .hwport = 0, |
| 74 | .flags = 0, |
| 75 | .ucon = 0x3c5, |
| 76 | .ulcon = 0x03, |
| 77 | .ufcon = 0x51, |
| 78 | }, |
| 79 | [1] = { |
| 80 | .hwport = 1, |
| 81 | .flags = 0, |
| 82 | .ucon = 0x3c5, |
| 83 | .ulcon = 0x03, |
| 84 | .ufcon = 0x51, |
| 85 | }, |
| 86 | }; |
| 87 | |
| 88 | /* framebuffer and LCD setup. */ |
| 89 | static void __init anw6410_lcd_mode_set(void) |
| 90 | { |
| 91 | u32 tmp; |
| 92 | |
| 93 | /* set the LCD type */ |
| 94 | tmp = __raw_readl(S3C64XX_SPCON); |
| 95 | tmp &= ~S3C64XX_SPCON_LCD_SEL_MASK; |
| 96 | tmp |= S3C64XX_SPCON_LCD_SEL_RGB; |
| 97 | __raw_writel(tmp, S3C64XX_SPCON); |
| 98 | |
| 99 | /* remove the LCD bypass */ |
| 100 | tmp = __raw_readl(S3C64XX_MODEM_MIFPCON); |
| 101 | tmp &= ~MIFPCON_LCD_BYPASS; |
| 102 | __raw_writel(tmp, S3C64XX_MODEM_MIFPCON); |
| 103 | } |
| 104 | |
| 105 | /* GPF1 = LCD panel power |
| 106 | * GPF4 = LCD backlight control |
| 107 | */ |
| 108 | static void anw6410_lcd_power_set(struct plat_lcd_data *pd, |
| 109 | unsigned int power) |
| 110 | { |
| 111 | if (power) { |
| 112 | anw6410_extdev_status |= (ANW6410_EN_LCD << 16); |
| 113 | __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV); |
| 114 | |
| 115 | gpio_direction_output(S3C64XX_GPF(1), 1); |
| 116 | gpio_direction_output(S3C64XX_GPF(4), 1); |
| 117 | } else { |
| 118 | anw6410_extdev_status &= ~(ANW6410_EN_LCD << 16); |
| 119 | __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV); |
| 120 | |
| 121 | gpio_direction_output(S3C64XX_GPF(1), 0); |
| 122 | gpio_direction_output(S3C64XX_GPF(4), 0); |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | static struct plat_lcd_data anw6410_lcd_power_data = { |
| 127 | .set_power = anw6410_lcd_power_set, |
| 128 | }; |
| 129 | |
| 130 | static struct platform_device anw6410_lcd_powerdev = { |
| 131 | .name = "platform-lcd", |
| 132 | .dev.parent = &s3c_device_fb.dev, |
| 133 | .dev.platform_data = &anw6410_lcd_power_data, |
| 134 | }; |
| 135 | |
| 136 | static struct s3c_fb_pd_win anw6410_fb_win0 = { |
| 137 | /* this is to ensure we use win0 */ |
| 138 | .win_mode = { |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 139 | .left_margin = 8, |
| 140 | .right_margin = 13, |
| 141 | .upper_margin = 7, |
| 142 | .lower_margin = 5, |
| 143 | .hsync_len = 3, |
| 144 | .vsync_len = 1, |
| 145 | .xres = 800, |
| 146 | .yres = 480, |
| 147 | }, |
| 148 | .max_bpp = 32, |
| 149 | .default_bpp = 16, |
| 150 | }; |
| 151 | |
| 152 | /* 405566 clocks per frame => 60Hz refresh requires 24333960Hz clock */ |
| 153 | static struct s3c_fb_platdata anw6410_lcd_pdata __initdata = { |
| 154 | .setup_gpio = s3c64xx_fb_gpio_setup_24bpp, |
| 155 | .win[0] = &anw6410_fb_win0, |
| 156 | .vidcon0 = VIDCON0_VIDOUT_RGB | VIDCON0_PNRMODE_RGB, |
| 157 | .vidcon1 = VIDCON1_INV_HSYNC | VIDCON1_INV_VSYNC, |
| 158 | }; |
| 159 | |
| 160 | /* DM9000AEP 10/100 ethernet controller */ |
| 161 | static void __init anw6410_dm9000_enable(void) |
| 162 | { |
| 163 | anw6410_extdev_status |= (ANW6410_EN_DM9000 << 16); |
| 164 | __raw_writel(anw6410_extdev_status, ANW6410_VA_EXTDEV); |
| 165 | } |
| 166 | |
| 167 | static struct resource anw6410_dm9000_resource[] = { |
| 168 | [0] = { |
| 169 | .start = ANW6410_PA_DM9000, |
| 170 | .end = ANW6410_PA_DM9000 + 3, |
| 171 | .flags = IORESOURCE_MEM, |
| 172 | }, |
| 173 | [1] = { |
| 174 | .start = ANW6410_PA_DM9000 + 4, |
| 175 | .end = ANW6410_PA_DM9000 + 4 + 500, |
| 176 | .flags = IORESOURCE_MEM, |
| 177 | }, |
| 178 | [2] = { |
| 179 | .start = IRQ_EINT(15), |
| 180 | .end = IRQ_EINT(15), |
| 181 | .flags = IORESOURCE_IRQ | IRQF_TRIGGER_HIGH, |
| 182 | }, |
| 183 | }; |
| 184 | |
| 185 | static struct dm9000_plat_data anw6410_dm9000_pdata = { |
| 186 | .flags = (DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM), |
| 187 | /* dev_addr can be set to provide hwaddr. */ |
| 188 | }; |
| 189 | |
| 190 | static struct platform_device anw6410_device_eth = { |
| 191 | .name = "dm9000", |
| 192 | .id = -1, |
| 193 | .num_resources = ARRAY_SIZE(anw6410_dm9000_resource), |
| 194 | .resource = anw6410_dm9000_resource, |
| 195 | .dev = { |
| 196 | .platform_data = &anw6410_dm9000_pdata, |
| 197 | }, |
| 198 | }; |
| 199 | |
| 200 | static struct map_desc anw6410_iodesc[] __initdata = { |
| 201 | { |
| 202 | .virtual = (unsigned long)ANW6410_VA_EXTDEV, |
| 203 | .pfn = __phys_to_pfn(ANW6410_PA_EXTDEV), |
| 204 | .length = SZ_64K, |
| 205 | .type = MT_DEVICE, |
| 206 | }, |
| 207 | }; |
| 208 | |
| 209 | static struct platform_device *anw6410_devices[] __initdata = { |
| 210 | &s3c_device_fb, |
| 211 | &anw6410_lcd_powerdev, |
| 212 | &anw6410_device_eth, |
| 213 | }; |
| 214 | |
| 215 | static void __init anw6410_map_io(void) |
| 216 | { |
| 217 | s3c64xx_init_io(anw6410_iodesc, ARRAY_SIZE(anw6410_iodesc)); |
| 218 | s3c24xx_init_clocks(12000000); |
| 219 | s3c24xx_init_uarts(anw6410_uartcfgs, ARRAY_SIZE(anw6410_uartcfgs)); |
| 220 | |
| 221 | anw6410_lcd_mode_set(); |
| 222 | } |
| 223 | |
| 224 | static void __init anw6410_machine_init(void) |
| 225 | { |
| 226 | s3c_fb_set_platdata(&anw6410_lcd_pdata); |
| 227 | |
| 228 | gpio_request(S3C64XX_GPF(1), "panel power"); |
| 229 | gpio_request(S3C64XX_GPF(4), "LCD backlight"); |
| 230 | |
| 231 | anw6410_dm9000_enable(); |
| 232 | |
| 233 | platform_add_devices(anw6410_devices, ARRAY_SIZE(anw6410_devices)); |
| 234 | } |
| 235 | |
| 236 | MACHINE_START(ANW6410, "A&W6410") |
| 237 | /* Maintainer: Kwangwoo Lee <kwangwoo.lee@gmail.com> */ |
Nicolas Pitre | 170a590 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 238 | .atag_offset = 0x100, |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 239 | |
| 240 | .init_irq = s3c6410_init_irq, |
Jamie Iles | 774b51f | 2011-11-04 01:10:04 +0000 | [diff] [blame] | 241 | .handle_irq = vic_handle_irq, |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 242 | .map_io = anw6410_map_io, |
| 243 | .init_machine = anw6410_machine_init, |
| 244 | .timer = &s3c24xx_timer, |
Kukjin Kim | ff84ded | 2012-01-03 14:03:30 +0100 | [diff] [blame] | 245 | .restart = s3c64xx_restart, |
Kwangwoo Lee | 1f26a8a | 2009-04-28 10:35:57 +0900 | [diff] [blame] | 246 | MACHINE_END |