Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 1 | /* linux/arch/arm/mach-s3c2410/mach-amlm5900.c |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 2 | * |
| 3 | * linux/arch/arm/mach-s3c2410/mach-amlm5900.c |
| 4 | * |
| 5 | * Copyright (c) 2006 American Microsystems Limited |
| 6 | * David Anders <danders@amltd.com> |
| 7 | |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | * |
| 23 | * @History: |
| 24 | * derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by |
| 25 | * Ben Dooks <ben@simtec.co.uk> |
| 26 | * |
| 27 | ***********************************************************************/ |
| 28 | |
| 29 | #include <linux/kernel.h> |
| 30 | #include <linux/types.h> |
| 31 | #include <linux/interrupt.h> |
| 32 | #include <linux/list.h> |
| 33 | #include <linux/timer.h> |
| 34 | #include <linux/init.h> |
| 35 | #include <linux/device.h> |
| 36 | #include <linux/platform_device.h> |
| 37 | #include <linux/proc_fs.h> |
Ben Dooks | 1b8fc18 | 2007-02-11 18:56:03 +0100 | [diff] [blame] | 38 | #include <linux/serial_core.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 39 | #include <linux/io.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 40 | |
| 41 | #include <asm/mach/arch.h> |
| 42 | #include <asm/mach/map.h> |
| 43 | #include <asm/mach/irq.h> |
| 44 | #include <asm/mach/flash.h> |
| 45 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 46 | #include <mach/hardware.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 47 | #include <asm/irq.h> |
| 48 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 49 | #include <mach/fb.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 50 | |
Ben Dooks | 531b617 | 2007-07-22 16:05:25 +0100 | [diff] [blame] | 51 | #include <asm/plat-s3c/regs-serial.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 52 | #include <mach/regs-lcd.h> |
| 53 | #include <mach/regs-gpio.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 54 | |
Ben Dooks | a21765a | 2007-02-11 18:31:01 +0100 | [diff] [blame] | 55 | #include <asm/plat-s3c24xx/devs.h> |
| 56 | #include <asm/plat-s3c24xx/cpu.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 57 | |
| 58 | #ifdef CONFIG_MTD_PARTITIONS |
| 59 | |
| 60 | #include <linux/mtd/mtd.h> |
| 61 | #include <linux/mtd/partitions.h> |
| 62 | #include <linux/mtd/map.h> |
| 63 | #include <linux/mtd/physmap.h> |
| 64 | |
| 65 | static struct resource amlm5900_nor_resource = { |
| 66 | .start = 0x00000000, |
| 67 | .end = 0x01000000 - 1, |
| 68 | .flags = IORESOURCE_MEM, |
| 69 | }; |
| 70 | |
| 71 | |
| 72 | |
| 73 | static struct mtd_partition amlm5900_mtd_partitions[] = { |
| 74 | { |
| 75 | .name = "System", |
| 76 | .size = 0x240000, |
| 77 | .offset = 0, |
| 78 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 79 | }, { |
| 80 | .name = "Kernel", |
| 81 | .size = 0x100000, |
| 82 | .offset = MTDPART_OFS_APPEND, |
| 83 | }, { |
| 84 | .name = "Ramdisk", |
| 85 | .size = 0x300000, |
| 86 | .offset = MTDPART_OFS_APPEND, |
| 87 | }, { |
| 88 | .name = "JFFS2", |
| 89 | .size = 0x9A0000, |
| 90 | .offset = MTDPART_OFS_APPEND, |
| 91 | }, { |
| 92 | .name = "Settings", |
| 93 | .size = MTDPART_SIZ_FULL, |
| 94 | .offset = MTDPART_OFS_APPEND, |
| 95 | } |
| 96 | }; |
| 97 | |
| 98 | static struct physmap_flash_data amlm5900_flash_data = { |
| 99 | .width = 2, |
| 100 | .parts = amlm5900_mtd_partitions, |
| 101 | .nr_parts = ARRAY_SIZE(amlm5900_mtd_partitions), |
| 102 | }; |
| 103 | |
| 104 | static struct platform_device amlm5900_device_nor = { |
| 105 | .name = "physmap-flash", |
| 106 | .id = 0, |
| 107 | .dev = { |
| 108 | .platform_data = &amlm5900_flash_data, |
| 109 | }, |
| 110 | .num_resources = 1, |
| 111 | .resource = &amlm5900_nor_resource, |
| 112 | }; |
| 113 | #endif |
| 114 | |
| 115 | static struct map_desc amlm5900_iodesc[] __initdata = { |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 116 | }; |
| 117 | |
| 118 | #define UCON S3C2410_UCON_DEFAULT |
| 119 | #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB |
| 120 | #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE |
| 121 | |
| 122 | static struct s3c2410_uartcfg amlm5900_uartcfgs[] = { |
| 123 | [0] = { |
| 124 | .hwport = 0, |
| 125 | .flags = 0, |
| 126 | .ucon = UCON, |
| 127 | .ulcon = ULCON, |
| 128 | .ufcon = UFCON, |
| 129 | }, |
| 130 | [1] = { |
| 131 | .hwport = 1, |
| 132 | .flags = 0, |
| 133 | .ucon = UCON, |
| 134 | .ulcon = ULCON, |
| 135 | .ufcon = UFCON, |
| 136 | }, |
| 137 | [2] = { |
| 138 | .hwport = 2, |
| 139 | .flags = 0, |
| 140 | .ucon = UCON, |
| 141 | .ulcon = ULCON, |
| 142 | .ufcon = UFCON, |
| 143 | } |
| 144 | }; |
| 145 | |
| 146 | |
| 147 | static struct platform_device *amlm5900_devices[] __initdata = { |
| 148 | #ifdef CONFIG_FB_S3C2410 |
| 149 | &s3c_device_lcd, |
| 150 | #endif |
| 151 | &s3c_device_adc, |
| 152 | &s3c_device_wdt, |
| 153 | &s3c_device_i2c, |
| 154 | &s3c_device_usb, |
| 155 | &s3c_device_rtc, |
| 156 | &s3c_device_usbgadget, |
| 157 | &s3c_device_sdi, |
| 158 | #ifdef CONFIG_MTD_PARTITIONS |
| 159 | &amlm5900_device_nor, |
| 160 | #endif |
| 161 | }; |
| 162 | |
Ben Dooks | e078761 | 2007-05-28 18:57:31 +0100 | [diff] [blame] | 163 | static void __init amlm5900_map_io(void) |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 164 | { |
| 165 | s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc)); |
| 166 | s3c24xx_init_clocks(0); |
| 167 | s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs)); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 168 | } |
| 169 | |
| 170 | #ifdef CONFIG_FB_S3C2410 |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 171 | static struct s3c2410fb_display __initdata amlm5900_lcd_info = { |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 172 | .width = 160, |
| 173 | .height = 160, |
| 174 | |
Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 175 | .type = S3C2410_LCDCON1_STN4, |
| 176 | |
Krzysztof Helt | 6981669 | 2007-10-16 01:29:06 -0700 | [diff] [blame] | 177 | .pixclock = 680000, /* HCLK = 100MHz */ |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 178 | .xres = 160, |
| 179 | .yres = 160, |
| 180 | .bpp = 4, |
Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 181 | .left_margin = 1 << (4 + 3), |
| 182 | .right_margin = 8 << 3, |
Krzysztof Helt | 93d11f5 | 2007-10-16 01:29:00 -0700 | [diff] [blame] | 183 | .hsync_len = 48, |
Krzysztof Helt | 5f20f69 | 2007-10-16 01:28:59 -0700 | [diff] [blame] | 184 | .upper_margin = 0, |
| 185 | .lower_margin = 0, |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 186 | |
Krzysztof Helt | f28ef57 | 2007-10-16 01:28:58 -0700 | [diff] [blame] | 187 | .lcdcon5 = 0x00000001, |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 188 | }; |
| 189 | |
| 190 | static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = { |
| 191 | |
| 192 | .displays = &amlm5900_lcd_info, |
| 193 | .num_displays = 1, |
| 194 | .default_display = 0, |
| 195 | |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 196 | .gpccon = 0xaaaaaaaa, |
| 197 | .gpccon_mask = 0xffffffff, |
| 198 | .gpcup = 0x0000ffff, |
| 199 | .gpcup_mask = 0xffffffff, |
| 200 | |
| 201 | .gpdcon = 0xaaaaaaaa, |
| 202 | .gpdcon_mask = 0xffffffff, |
| 203 | .gpdup = 0x0000ffff, |
| 204 | .gpdup_mask = 0xffffffff, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 205 | }; |
| 206 | #endif |
| 207 | |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 208 | static irqreturn_t |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 209 | amlm5900_wake_interrupt(int irq, void *ignored) |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 210 | { |
| 211 | return IRQ_HANDLED; |
| 212 | } |
| 213 | |
| 214 | static void amlm5900_init_pm(void) |
| 215 | { |
| 216 | int ret = 0; |
| 217 | |
| 218 | ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt, |
| 219 | IRQF_TRIGGER_RISING | IRQF_SHARED, |
| 220 | "amlm5900_wakeup", &amlm5900_wake_interrupt); |
| 221 | if (ret != 0) { |
| 222 | printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret); |
| 223 | } else { |
| 224 | enable_irq_wake(IRQ_EINT9); |
| 225 | /* configure the suspend/resume status pin */ |
| 226 | s3c2410_gpio_cfgpin(S3C2410_GPF2, S3C2410_GPF2_OUTP); |
| 227 | s3c2410_gpio_pullup(S3C2410_GPF2, 0); |
| 228 | } |
| 229 | } |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 230 | static void __init amlm5900_init(void) |
| 231 | { |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 232 | amlm5900_init_pm(); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 233 | #ifdef CONFIG_FB_S3C2410 |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 234 | s3c24xx_fb_set_platdata(&amlm5900_fb_info); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 235 | #endif |
Ben Dooks | 57e5171 | 2007-04-20 11:19:16 +0100 | [diff] [blame] | 236 | platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices)); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 237 | } |
| 238 | |
| 239 | MACHINE_START(AML_M5900, "AML_M5900") |
| 240 | .phys_io = S3C2410_PA_UART, |
| 241 | .io_pg_offst = (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, |
| 242 | .boot_params = S3C2410_SDRAM_PA + 0x100, |
| 243 | .map_io = amlm5900_map_io, |
| 244 | .init_irq = s3c24xx_init_irq, |
| 245 | .init_machine = amlm5900_init, |
| 246 | .timer = &s3c24xx_timer, |
| 247 | MACHINE_END |