| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 | 
							- /*
 
-  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
 
-  *		http://www.samsung.com
 
-  *
 
-  * Copyright 2008 Openmoko, Inc.
 
-  * Copyright 2008 Simtec Electronics
 
-  *	Ben Dooks <ben@simtec.co.uk>
 
-  *	http://armlinux.simtec.co.uk/
 
-  *
 
-  * Common Codes for S3C64XX machines
 
-  *
 
-  * This program is free software; you can redistribute it and/or modify
 
-  * it under the terms of the GNU General Public License version 2 as
 
-  * published by the Free Software Foundation.
 
-  */
 
- #include <linux/kernel.h>
 
- #include <linux/init.h>
 
- #include <linux/module.h>
 
- #include <linux/interrupt.h>
 
- #include <linux/ioport.h>
 
- #include <linux/serial_core.h>
 
- #include <linux/platform_device.h>
 
- #include <linux/io.h>
 
- #include <linux/dma-mapping.h>
 
- #include <linux/irq.h>
 
- #include <linux/gpio.h>
 
- #include <asm/mach/arch.h>
 
- #include <asm/mach/map.h>
 
- #include <asm/hardware/vic.h>
 
- #include <asm/system_misc.h>
 
- #include <mach/map.h>
 
- #include <mach/hardware.h>
 
- #include <mach/regs-gpio.h>
 
- #include <plat/cpu.h>
 
- #include <plat/clock.h>
 
- #include <plat/devs.h>
 
- #include <plat/pm.h>
 
- #include <plat/gpio-cfg.h>
 
- #include <plat/irq-uart.h>
 
- #include <plat/irq-vic-timer.h>
 
- #include <plat/regs-irqtype.h>
 
- #include <plat/regs-serial.h>
 
- #include <plat/watchdog-reset.h>
 
- #include "common.h"
 
- /* uart registration process */
 
- static void __init s3c64xx_init_uarts(struct s3c2410_uartcfg *cfg, int no)
 
- {
 
- 	s3c24xx_init_uartdevs("s3c6400-uart", s3c64xx_uart_resources, cfg, no);
 
- }
 
- /* table of supported CPUs */
 
- static const char name_s3c6400[] = "S3C6400";
 
- static const char name_s3c6410[] = "S3C6410";
 
- static struct cpu_table cpu_ids[] __initdata = {
 
- 	{
 
- 		.idcode		= S3C6400_CPU_ID,
 
- 		.idmask		= S3C64XX_CPU_MASK,
 
- 		.map_io		= s3c6400_map_io,
 
- 		.init_clocks	= s3c6400_init_clocks,
 
- 		.init_uarts	= s3c64xx_init_uarts,
 
- 		.init		= s3c6400_init,
 
- 		.name		= name_s3c6400,
 
- 	}, {
 
- 		.idcode		= S3C6410_CPU_ID,
 
- 		.idmask		= S3C64XX_CPU_MASK,
 
- 		.map_io		= s3c6410_map_io,
 
- 		.init_clocks	= s3c6410_init_clocks,
 
- 		.init_uarts	= s3c64xx_init_uarts,
 
- 		.init		= s3c6410_init,
 
- 		.name		= name_s3c6410,
 
- 	},
 
- };
 
- /* minimal IO mapping */
 
- /* see notes on uart map in arch/arm/mach-s3c64xx/include/mach/debug-macro.S */
 
- #define UART_OFFS (S3C_PA_UART & 0xfffff)
 
- static struct map_desc s3c_iodesc[] __initdata = {
 
- 	{
 
- 		.virtual	= (unsigned long)S3C_VA_SYS,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_SYSCON),
 
- 		.length		= SZ_4K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)S3C_VA_MEM,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_SROM),
 
- 		.length		= SZ_4K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)(S3C_VA_UART + UART_OFFS),
 
- 		.pfn		= __phys_to_pfn(S3C_PA_UART),
 
- 		.length		= SZ_4K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)VA_VIC0,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_VIC0),
 
- 		.length		= SZ_16K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)VA_VIC1,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_VIC1),
 
- 		.length		= SZ_16K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)S3C_VA_TIMER,
 
- 		.pfn		= __phys_to_pfn(S3C_PA_TIMER),
 
- 		.length		= SZ_16K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)S3C64XX_VA_GPIO,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_GPIO),
 
- 		.length		= SZ_4K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)S3C64XX_VA_MODEM,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_MODEM),
 
- 		.length		= SZ_4K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)S3C_VA_WATCHDOG,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_WATCHDOG),
 
- 		.length		= SZ_4K,
 
- 		.type		= MT_DEVICE,
 
- 	}, {
 
- 		.virtual	= (unsigned long)S3C_VA_USB_HSPHY,
 
- 		.pfn		= __phys_to_pfn(S3C64XX_PA_USB_HSPHY),
 
- 		.length		= SZ_1K,
 
- 		.type		= MT_DEVICE,
 
- 	},
 
- };
 
- static struct bus_type s3c64xx_subsys = {
 
- 	.name		= "s3c64xx-core",
 
- 	.dev_name	= "s3c64xx-core",
 
- };
 
- static struct device s3c64xx_dev = {
 
- 	.bus	= &s3c64xx_subsys,
 
- };
 
- /* read cpu identification code */
 
- void __init s3c64xx_init_io(struct map_desc *mach_desc, int size)
 
- {
 
- 	/* initialise the io descriptors we need for initialisation */
 
- 	iotable_init(s3c_iodesc, ARRAY_SIZE(s3c_iodesc));
 
- 	iotable_init(mach_desc, size);
 
- 	/* detect cpu id */
 
- 	s3c64xx_init_cpu();
 
- 	s3c_init_cpu(samsung_cpu_id, cpu_ids, ARRAY_SIZE(cpu_ids));
 
- }
 
- static __init int s3c64xx_dev_init(void)
 
- {
 
- 	subsys_system_register(&s3c64xx_subsys, NULL);
 
- 	return device_register(&s3c64xx_dev);
 
- }
 
- core_initcall(s3c64xx_dev_init);
 
- /*
 
-  * setup the sources the vic should advertise resume
 
-  * for, even though it is not doing the wake
 
-  * (set_irq_wake needs to be valid)
 
-  */
 
- #define IRQ_VIC0_RESUME (1 << (IRQ_RTC_TIC - IRQ_VIC0_BASE))
 
- #define IRQ_VIC1_RESUME (1 << (IRQ_RTC_ALARM - IRQ_VIC1_BASE) |	\
 
- 			 1 << (IRQ_PENDN - IRQ_VIC1_BASE) |	\
 
- 			 1 << (IRQ_HSMMC0 - IRQ_VIC1_BASE) |	\
 
- 			 1 << (IRQ_HSMMC1 - IRQ_VIC1_BASE) |	\
 
- 			 1 << (IRQ_HSMMC2 - IRQ_VIC1_BASE))
 
- void __init s3c64xx_init_irq(u32 vic0_valid, u32 vic1_valid)
 
- {
 
- 	printk(KERN_DEBUG "%s: initialising interrupts\n", __func__);
 
- 	/* initialise the pair of VICs */
 
- 	vic_init(VA_VIC0, IRQ_VIC0_BASE, vic0_valid, IRQ_VIC0_RESUME);
 
- 	vic_init(VA_VIC1, IRQ_VIC1_BASE, vic1_valid, IRQ_VIC1_RESUME);
 
- 	/* add the timer sub-irqs */
 
- 	s3c_init_vic_timer_irq(5, IRQ_TIMER0);
 
- }
 
- #define eint_offset(irq)	((irq) - IRQ_EINT(0))
 
- #define eint_irq_to_bit(irq)	((u32)(1 << eint_offset(irq)))
 
- static inline void s3c_irq_eint_mask(struct irq_data *data)
 
- {
 
- 	u32 mask;
 
- 	mask = __raw_readl(S3C64XX_EINT0MASK);
 
- 	mask |= (u32)data->chip_data;
 
- 	__raw_writel(mask, S3C64XX_EINT0MASK);
 
- }
 
- static void s3c_irq_eint_unmask(struct irq_data *data)
 
- {
 
- 	u32 mask;
 
- 	mask = __raw_readl(S3C64XX_EINT0MASK);
 
- 	mask &= ~((u32)data->chip_data);
 
- 	__raw_writel(mask, S3C64XX_EINT0MASK);
 
- }
 
- static inline void s3c_irq_eint_ack(struct irq_data *data)
 
- {
 
- 	__raw_writel((u32)data->chip_data, S3C64XX_EINT0PEND);
 
- }
 
 
  |