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> |
Ben Dooks | ec976d6 | 2009-05-13 22:52:24 +0100 | [diff] [blame] | 35 | #include <linux/gpio.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 36 | #include <linux/device.h> |
| 37 | #include <linux/platform_device.h> |
| 38 | #include <linux/proc_fs.h> |
Ben Dooks | 1b8fc18 | 2007-02-11 18:56:03 +0100 | [diff] [blame] | 39 | #include <linux/serial_core.h> |
Tushar Behera | 334a1c7 | 2014-02-14 10:32:45 +0900 | [diff] [blame] | 40 | #include <linux/serial_s3c.h> |
Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 41 | #include <linux/io.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 42 | |
| 43 | #include <asm/mach/arch.h> |
| 44 | #include <asm/mach/map.h> |
| 45 | #include <asm/mach/irq.h> |
| 46 | #include <asm/mach/flash.h> |
| 47 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 48 | #include <mach/hardware.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 49 | #include <asm/irq.h> |
| 50 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 51 | #include <mach/fb.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 52 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 53 | #include <mach/regs-lcd.h> |
| 54 | #include <mach/regs-gpio.h> |
Linus Walleij | b0161ca | 2014-01-14 14:24:24 +0100 | [diff] [blame] | 55 | #include <mach/gpio-samsung.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 56 | |
Arnd Bergmann | 436d42c | 2012-08-24 15:22:12 +0200 | [diff] [blame] | 57 | #include <linux/platform_data/i2c-s3c2410.h> |
Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 58 | #include <plat/devs.h> |
| 59 | #include <plat/cpu.h> |
Ben Dooks | 40b956f | 2010-05-04 14:38:49 +0900 | [diff] [blame] | 60 | #include <plat/gpio-cfg.h> |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 61 | |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 62 | #include <linux/mtd/mtd.h> |
| 63 | #include <linux/mtd/partitions.h> |
| 64 | #include <linux/mtd/map.h> |
| 65 | #include <linux/mtd/physmap.h> |
| 66 | |
Romain Naour | 7f78b6e | 2013-01-09 18:47:04 -0800 | [diff] [blame] | 67 | #include <plat/samsung-time.h> |
| 68 | |
Kukjin Kim | b27b072 | 2012-01-03 14:02:03 +0100 | [diff] [blame] | 69 | #include "common.h" |
| 70 | |
Tushar Behera | 7d4aa90 | 2012-05-12 16:12:20 +0900 | [diff] [blame] | 71 | static struct resource amlm5900_nor_resource = |
| 72 | DEFINE_RES_MEM(0x00000000, SZ_16M); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 73 | |
| 74 | static struct mtd_partition amlm5900_mtd_partitions[] = { |
| 75 | { |
| 76 | .name = "System", |
| 77 | .size = 0x240000, |
| 78 | .offset = 0, |
| 79 | .mask_flags = MTD_WRITEABLE, /* force read-only */ |
| 80 | }, { |
| 81 | .name = "Kernel", |
| 82 | .size = 0x100000, |
| 83 | .offset = MTDPART_OFS_APPEND, |
| 84 | }, { |
| 85 | .name = "Ramdisk", |
| 86 | .size = 0x300000, |
| 87 | .offset = MTDPART_OFS_APPEND, |
| 88 | }, { |
| 89 | .name = "JFFS2", |
| 90 | .size = 0x9A0000, |
| 91 | .offset = MTDPART_OFS_APPEND, |
| 92 | }, { |
| 93 | .name = "Settings", |
| 94 | .size = MTDPART_SIZ_FULL, |
| 95 | .offset = MTDPART_OFS_APPEND, |
| 96 | } |
| 97 | }; |
| 98 | |
| 99 | static struct physmap_flash_data amlm5900_flash_data = { |
| 100 | .width = 2, |
| 101 | .parts = amlm5900_mtd_partitions, |
| 102 | .nr_parts = ARRAY_SIZE(amlm5900_mtd_partitions), |
| 103 | }; |
| 104 | |
| 105 | static struct platform_device amlm5900_device_nor = { |
| 106 | .name = "physmap-flash", |
| 107 | .id = 0, |
| 108 | .dev = { |
| 109 | .platform_data = &amlm5900_flash_data, |
| 110 | }, |
| 111 | .num_resources = 1, |
| 112 | .resource = &amlm5900_nor_resource, |
| 113 | }; |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 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, |
Ben Dooks | 3e1b776 | 2008-10-31 16:14:40 +0000 | [diff] [blame] | 153 | &s3c_device_i2c0, |
Ben Dooks | b813248 | 2009-11-23 00:13:39 +0000 | [diff] [blame] | 154 | &s3c_device_ohci, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 155 | &s3c_device_rtc, |
| 156 | &s3c_device_usbgadget, |
| 157 | &s3c_device_sdi, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 158 | &amlm5900_device_nor, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 159 | }; |
| 160 | |
Ben Dooks | e078761 | 2007-05-28 18:57:31 +0100 | [diff] [blame] | 161 | static void __init amlm5900_map_io(void) |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 162 | { |
| 163 | s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc)); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 164 | s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs)); |
Romain Naour | 7f78b6e | 2013-01-09 18:47:04 -0800 | [diff] [blame] | 165 | samsung_set_timer_source(SAMSUNG_PWM3, SAMSUNG_PWM4); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Heiko Stuebner | 07ee5e7 | 2014-05-09 05:49:29 +0900 | [diff] [blame^] | 168 | static void __init amlm5900_init_time(void) |
| 169 | { |
| 170 | s3c2410_init_clocks(12000000); |
| 171 | samsung_timer_init(); |
| 172 | } |
| 173 | |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 174 | #ifdef CONFIG_FB_S3C2410 |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 175 | static struct s3c2410fb_display __initdata amlm5900_lcd_info = { |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 176 | .width = 160, |
| 177 | .height = 160, |
| 178 | |
Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 179 | .type = S3C2410_LCDCON1_STN4, |
| 180 | |
Krzysztof Helt | 6981669 | 2007-10-16 01:29:06 -0700 | [diff] [blame] | 181 | .pixclock = 680000, /* HCLK = 100MHz */ |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 182 | .xres = 160, |
| 183 | .yres = 160, |
| 184 | .bpp = 4, |
Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 185 | .left_margin = 1 << (4 + 3), |
| 186 | .right_margin = 8 << 3, |
Krzysztof Helt | 93d11f5 | 2007-10-16 01:29:00 -0700 | [diff] [blame] | 187 | .hsync_len = 48, |
Krzysztof Helt | 5f20f69 | 2007-10-16 01:28:59 -0700 | [diff] [blame] | 188 | .upper_margin = 0, |
| 189 | .lower_margin = 0, |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 190 | |
Krzysztof Helt | f28ef57 | 2007-10-16 01:28:58 -0700 | [diff] [blame] | 191 | .lcdcon5 = 0x00000001, |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 192 | }; |
| 193 | |
| 194 | static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = { |
| 195 | |
| 196 | .displays = &amlm5900_lcd_info, |
| 197 | .num_displays = 1, |
| 198 | .default_display = 0, |
| 199 | |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 200 | .gpccon = 0xaaaaaaaa, |
| 201 | .gpccon_mask = 0xffffffff, |
| 202 | .gpcup = 0x0000ffff, |
| 203 | .gpcup_mask = 0xffffffff, |
| 204 | |
| 205 | .gpdcon = 0xaaaaaaaa, |
| 206 | .gpdcon_mask = 0xffffffff, |
| 207 | .gpdup = 0x0000ffff, |
| 208 | .gpdup_mask = 0xffffffff, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 209 | }; |
| 210 | #endif |
| 211 | |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 212 | static irqreturn_t |
Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 213 | amlm5900_wake_interrupt(int irq, void *ignored) |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 214 | { |
| 215 | return IRQ_HANDLED; |
| 216 | } |
| 217 | |
| 218 | static void amlm5900_init_pm(void) |
| 219 | { |
| 220 | int ret = 0; |
| 221 | |
| 222 | ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt, |
| 223 | IRQF_TRIGGER_RISING | IRQF_SHARED, |
| 224 | "amlm5900_wakeup", &amlm5900_wake_interrupt); |
| 225 | if (ret != 0) { |
| 226 | printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret); |
| 227 | } else { |
| 228 | enable_irq_wake(IRQ_EINT9); |
| 229 | /* configure the suspend/resume status pin */ |
Ben Dooks | 40b956f | 2010-05-04 14:38:49 +0900 | [diff] [blame] | 230 | s3c_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT); |
Ben Dooks | fb37874 | 2010-05-06 11:03:50 +0900 | [diff] [blame] | 231 | s3c_gpio_setpull(S3C2410_GPF(2), S3C_GPIO_PULL_UP); |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 232 | } |
| 233 | } |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 234 | static void __init amlm5900_init(void) |
| 235 | { |
David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 236 | amlm5900_init_pm(); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 237 | #ifdef CONFIG_FB_S3C2410 |
Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 238 | s3c24xx_fb_set_platdata(&amlm5900_fb_info); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 239 | #endif |
Ben Dooks | 3e1b776 | 2008-10-31 16:14:40 +0000 | [diff] [blame] | 240 | s3c_i2c0_set_platdata(NULL); |
Ben Dooks | 57e5171 | 2007-04-20 11:19:16 +0100 | [diff] [blame] | 241 | platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices)); |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | MACHINE_START(AML_M5900, "AML_M5900") |
Nicolas Pitre | 69d5071 | 2011-07-05 22:38:17 -0400 | [diff] [blame] | 245 | .atag_offset = 0x100, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 246 | .map_io = amlm5900_map_io, |
Heiko Stuebner | f182aa1 | 2013-03-07 12:38:19 +0900 | [diff] [blame] | 247 | .init_irq = s3c2410_init_irq, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 248 | .init_machine = amlm5900_init, |
Heiko Stuebner | 07ee5e7 | 2014-05-09 05:49:29 +0900 | [diff] [blame^] | 249 | .init_time = amlm5900_init_time, |
Kukjin Kim | b27b072 | 2012-01-03 14:02:03 +0100 | [diff] [blame] | 250 | .restart = s3c2410_restart, |
David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 251 | MACHINE_END |