| 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> | 
| Russell King | fced80c | 2008-09-06 12:10:45 +0100 | [diff] [blame] | 40 | #include <linux/io.h> | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 41 |  | 
 | 42 | #include <asm/mach/arch.h> | 
 | 43 | #include <asm/mach/map.h> | 
 | 44 | #include <asm/mach/irq.h> | 
 | 45 | #include <asm/mach/flash.h> | 
 | 46 |  | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 47 | #include <mach/hardware.h> | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 48 | #include <asm/irq.h> | 
 | 49 | #include <asm/mach-types.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 50 | #include <mach/fb.h> | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 51 |  | 
| Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 52 | #include <plat/regs-serial.h> | 
| Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 53 | #include <mach/regs-lcd.h> | 
 | 54 | #include <mach/regs-gpio.h> | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 55 |  | 
| Ben Dooks | 3e1b776 | 2008-10-31 16:14:40 +0000 | [diff] [blame] | 56 | #include <plat/iic.h> | 
| Ben Dooks | a2b7ba9 | 2008-10-07 22:26:09 +0100 | [diff] [blame] | 57 | #include <plat/devs.h> | 
 | 58 | #include <plat/cpu.h> | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 59 |  | 
 | 60 | #ifdef CONFIG_MTD_PARTITIONS | 
 | 61 |  | 
 | 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 |  | 
 | 67 | static struct resource amlm5900_nor_resource = { | 
 | 68 | 		.start = 0x00000000, | 
 | 69 | 		.end   = 0x01000000 - 1, | 
 | 70 | 		.flags = IORESOURCE_MEM, | 
 | 71 | }; | 
 | 72 |  | 
 | 73 |  | 
 | 74 |  | 
 | 75 | static struct mtd_partition amlm5900_mtd_partitions[] = { | 
 | 76 | 	{ | 
 | 77 | 		.name		= "System", | 
 | 78 | 		.size		= 0x240000, | 
 | 79 | 		.offset		= 0, | 
 | 80 | 		.mask_flags 	= MTD_WRITEABLE,  /* force read-only */ | 
 | 81 | 	}, { | 
 | 82 | 		.name		= "Kernel", | 
 | 83 | 		.size		= 0x100000, | 
 | 84 | 		.offset		= MTDPART_OFS_APPEND, | 
 | 85 | 	}, { | 
 | 86 | 		.name		= "Ramdisk", | 
 | 87 | 		.size		= 0x300000, | 
 | 88 | 		.offset		= MTDPART_OFS_APPEND, | 
 | 89 | 	}, { | 
 | 90 | 		.name		= "JFFS2", | 
 | 91 | 		.size		= 0x9A0000, | 
 | 92 | 		.offset		= MTDPART_OFS_APPEND, | 
 | 93 | 	}, { | 
 | 94 | 		.name		= "Settings", | 
 | 95 | 		.size		= MTDPART_SIZ_FULL, | 
 | 96 | 		.offset		= MTDPART_OFS_APPEND, | 
 | 97 | 	} | 
 | 98 | }; | 
 | 99 |  | 
 | 100 | static struct physmap_flash_data amlm5900_flash_data = { | 
 | 101 | 	.width		= 2, | 
 | 102 | 	.parts		= amlm5900_mtd_partitions, | 
 | 103 | 	.nr_parts	= ARRAY_SIZE(amlm5900_mtd_partitions), | 
 | 104 | }; | 
 | 105 |  | 
 | 106 | static struct platform_device amlm5900_device_nor = { | 
 | 107 | 	.name		= "physmap-flash", | 
 | 108 | 	.id		= 0, | 
 | 109 | 	.dev = { | 
 | 110 | 			.platform_data = &amlm5900_flash_data, | 
 | 111 | 		}, | 
 | 112 | 	.num_resources	= 1, | 
 | 113 | 	.resource	= &amlm5900_nor_resource, | 
 | 114 | }; | 
 | 115 | #endif | 
 | 116 |  | 
 | 117 | static struct map_desc amlm5900_iodesc[] __initdata = { | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 118 | }; | 
 | 119 |  | 
 | 120 | #define UCON S3C2410_UCON_DEFAULT | 
 | 121 | #define ULCON S3C2410_LCON_CS8 | S3C2410_LCON_PNONE | S3C2410_LCON_STOPB | 
 | 122 | #define UFCON S3C2410_UFCON_RXTRIG8 | S3C2410_UFCON_FIFOMODE | 
 | 123 |  | 
 | 124 | static struct s3c2410_uartcfg amlm5900_uartcfgs[] = { | 
 | 125 | 	[0] = { | 
 | 126 | 		.hwport	     = 0, | 
 | 127 | 		.flags	     = 0, | 
 | 128 | 		.ucon	     = UCON, | 
 | 129 | 		.ulcon	     = ULCON, | 
 | 130 | 		.ufcon	     = UFCON, | 
 | 131 | 	}, | 
 | 132 | 	[1] = { | 
 | 133 | 		.hwport	     = 1, | 
 | 134 | 		.flags	     = 0, | 
 | 135 | 		.ucon	     = UCON, | 
 | 136 | 		.ulcon	     = ULCON, | 
 | 137 | 		.ufcon	     = UFCON, | 
 | 138 | 	}, | 
 | 139 | 	[2] = { | 
 | 140 | 		.hwport	     = 2, | 
 | 141 | 		.flags	     = 0, | 
 | 142 | 		.ucon	     = UCON, | 
 | 143 | 		.ulcon	     = ULCON, | 
 | 144 | 		.ufcon	     = UFCON, | 
 | 145 | 	} | 
 | 146 | }; | 
 | 147 |  | 
 | 148 |  | 
 | 149 | static struct platform_device *amlm5900_devices[] __initdata = { | 
 | 150 | #ifdef CONFIG_FB_S3C2410 | 
 | 151 | 	&s3c_device_lcd, | 
 | 152 | #endif | 
 | 153 | 	&s3c_device_adc, | 
 | 154 | 	&s3c_device_wdt, | 
| Ben Dooks | 3e1b776 | 2008-10-31 16:14:40 +0000 | [diff] [blame] | 155 | 	&s3c_device_i2c0, | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 156 | 	&s3c_device_usb, | 
 | 157 |  	&s3c_device_rtc, | 
 | 158 | 	&s3c_device_usbgadget, | 
 | 159 |         &s3c_device_sdi, | 
 | 160 | #ifdef CONFIG_MTD_PARTITIONS | 
 | 161 | 	&amlm5900_device_nor, | 
 | 162 | #endif | 
 | 163 | }; | 
 | 164 |  | 
| Ben Dooks | e078761 | 2007-05-28 18:57:31 +0100 | [diff] [blame] | 165 | static void __init amlm5900_map_io(void) | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 166 | { | 
 | 167 | 	s3c24xx_init_io(amlm5900_iodesc, ARRAY_SIZE(amlm5900_iodesc)); | 
 | 168 | 	s3c24xx_init_clocks(0); | 
 | 169 | 	s3c24xx_init_uarts(amlm5900_uartcfgs, ARRAY_SIZE(amlm5900_uartcfgs)); | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 170 | } | 
 | 171 |  | 
 | 172 | #ifdef CONFIG_FB_S3C2410 | 
| Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 173 | static struct s3c2410fb_display __initdata amlm5900_lcd_info = { | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 174 | 	.width		= 160, | 
 | 175 | 	.height		= 160, | 
 | 176 |  | 
| Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 177 | 	.type		= S3C2410_LCDCON1_STN4, | 
 | 178 |  | 
| Krzysztof Helt | 6981669 | 2007-10-16 01:29:06 -0700 | [diff] [blame] | 179 | 	.pixclock	= 680000, /* HCLK = 100MHz */ | 
| Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 180 | 	.xres		= 160, | 
 | 181 | 	.yres		= 160, | 
 | 182 | 	.bpp		= 4, | 
| Krzysztof Helt | 1f41153 | 2007-10-16 01:28:57 -0700 | [diff] [blame] | 183 | 	.left_margin	= 1 << (4 + 3), | 
 | 184 | 	.right_margin	= 8 << 3, | 
| Krzysztof Helt | 93d11f5 | 2007-10-16 01:29:00 -0700 | [diff] [blame] | 185 | 	.hsync_len	= 48, | 
| Krzysztof Helt | 5f20f69 | 2007-10-16 01:28:59 -0700 | [diff] [blame] | 186 | 	.upper_margin	= 0, | 
 | 187 | 	.lower_margin	= 0, | 
| Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 188 |  | 
| Krzysztof Helt | f28ef57 | 2007-10-16 01:28:58 -0700 | [diff] [blame] | 189 | 	.lcdcon5	= 0x00000001, | 
| Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 190 | }; | 
 | 191 |  | 
 | 192 | static struct s3c2410fb_mach_info __initdata amlm5900_fb_info = { | 
 | 193 |  | 
 | 194 | 	.displays = &amlm5900_lcd_info, | 
 | 195 | 	.num_displays = 1, | 
 | 196 | 	.default_display = 0, | 
 | 197 |  | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 198 | 	.gpccon =	0xaaaaaaaa, | 
 | 199 | 	.gpccon_mask =	0xffffffff, | 
 | 200 | 	.gpcup =	0x0000ffff, | 
 | 201 | 	.gpcup_mask =	0xffffffff, | 
 | 202 |  | 
 | 203 | 	.gpdcon =	0xaaaaaaaa, | 
 | 204 | 	.gpdcon_mask =	0xffffffff, | 
 | 205 | 	.gpdup =	0x0000ffff, | 
 | 206 | 	.gpdup_mask =	0xffffffff, | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 207 | }; | 
 | 208 | #endif | 
 | 209 |  | 
| David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 210 | static irqreturn_t | 
| Linus Torvalds | 0cd61b6 | 2006-10-06 10:53:39 -0700 | [diff] [blame] | 211 | amlm5900_wake_interrupt(int irq, void *ignored) | 
| David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 212 | { | 
 | 213 | 	return IRQ_HANDLED; | 
 | 214 | } | 
 | 215 |  | 
 | 216 | static void amlm5900_init_pm(void) | 
 | 217 | { | 
 | 218 | 	int ret = 0; | 
 | 219 |  | 
 | 220 | 	ret = request_irq(IRQ_EINT9, &amlm5900_wake_interrupt, | 
 | 221 | 				IRQF_TRIGGER_RISING | IRQF_SHARED, | 
 | 222 | 				"amlm5900_wakeup", &amlm5900_wake_interrupt); | 
 | 223 | 	if (ret != 0) { | 
 | 224 | 		printk(KERN_ERR "AML-M5900: no wakeup irq, %d?\n", ret); | 
 | 225 | 	} else { | 
 | 226 | 		enable_irq_wake(IRQ_EINT9); | 
 | 227 | 		/* configure the suspend/resume status pin */ | 
| Ben Dooks | 070276d | 2009-05-17 22:32:23 +0100 | [diff] [blame] | 228 | 		s3c2410_gpio_cfgpin(S3C2410_GPF(2), S3C2410_GPIO_OUTPUT); | 
 | 229 | 		s3c2410_gpio_pullup(S3C2410_GPF(2), 0); | 
| David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 230 | 	} | 
 | 231 | } | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 232 | static void __init amlm5900_init(void) | 
 | 233 | { | 
| David Anders | 26f9081 | 2006-09-26 17:46:00 +0100 | [diff] [blame] | 234 | 	amlm5900_init_pm(); | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 235 | #ifdef CONFIG_FB_S3C2410 | 
| Krzysztof Helt | 09fe75f | 2007-10-16 01:28:56 -0700 | [diff] [blame] | 236 | 	s3c24xx_fb_set_platdata(&amlm5900_fb_info); | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 237 | #endif | 
| Ben Dooks | 3e1b776 | 2008-10-31 16:14:40 +0000 | [diff] [blame] | 238 | 	s3c_i2c0_set_platdata(NULL); | 
| Ben Dooks | 57e5171 | 2007-04-20 11:19:16 +0100 | [diff] [blame] | 239 | 	platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices)); | 
| David Anders | da56c94 | 2006-09-21 22:57:12 +0100 | [diff] [blame] | 240 | } | 
 | 241 |  | 
 | 242 | MACHINE_START(AML_M5900, "AML_M5900") | 
 | 243 | 	.phys_io	= S3C2410_PA_UART, | 
 | 244 | 	.io_pg_offst	= (((u32)S3C24XX_VA_UART) >> 18) & 0xfffc, | 
 | 245 | 	.boot_params	= S3C2410_SDRAM_PA + 0x100, | 
 | 246 | 	.map_io		= amlm5900_map_io, | 
 | 247 | 	.init_irq	= s3c24xx_init_irq, | 
 | 248 | 	.init_machine	= amlm5900_init, | 
 | 249 | 	.timer		= &s3c24xx_timer, | 
 | 250 | MACHINE_END |