From 9d4f13e531b4722fe40cc8e28c02a495bdd49267 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 3 Jan 2006 17:28:33 +0000 Subject: [ARM] Make kernel link address depend on PAGE_OFFSET We are coding the kernel link address into the makefiles, which is invisibly dependent on PAGE_OFFSET. If PAGE_OFFSET is changed, the makefiles also need to be changed. Make adjustments such that the makefiles encode just the offset from PAGE_OFFSET for the kernel link address, and use PAGE_OFFSET in the linker scripts directly. Signed-off-by: Russell King diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 81bd219..afaf3a1 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -8,7 +8,7 @@ # Copyright (C) 1995-2001 by Russell King LDFLAGS_vmlinux :=-p --no-undefined -X -CPPFLAGS_vmlinux.lds = -DKERNEL_RAM_ADDR=$(TEXTADDR) +CPPFLAGS_vmlinux.lds = -DTEXT_OFFSET=$(TEXT_OFFSET) OBJCOPYFLAGS :=-O binary -R .note -R .comment -S GZFLAGS :=-9 #CFLAGS +=-pipe @@ -65,7 +65,7 @@ CHECKFLAGS += -D__arm__ #Default value head-y := arch/arm/kernel/head.o arch/arm/kernel/init_task.o -textaddr-y := 0xC0008000 +textofs-y := 0x00008000 machine-$(CONFIG_ARCH_RPC) := rpc machine-$(CONFIG_ARCH_EBSA110) := ebsa110 @@ -73,22 +73,20 @@ textaddr-y := 0xC0008000 incdir-$(CONFIG_ARCH_CLPS7500) := cl7500 machine-$(CONFIG_FOOTBRIDGE) := footbridge incdir-$(CONFIG_FOOTBRIDGE) := ebsa285 -textaddr-$(CONFIG_ARCH_CO285) := 0x60008000 machine-$(CONFIG_ARCH_CO285) := footbridge incdir-$(CONFIG_ARCH_CO285) := ebsa285 machine-$(CONFIG_ARCH_SHARK) := shark machine-$(CONFIG_ARCH_SA1100) := sa1100 ifeq ($(CONFIG_ARCH_SA1100),y) # SA1111 DMA bug: we don't want the kernel to live in precious DMA-able memory -textaddr-$(CONFIG_SA1111) := 0xc0208000 + textofs-$(CONFIG_SA1111) := 0x00208000 endif machine-$(CONFIG_ARCH_PXA) := pxa machine-$(CONFIG_ARCH_L7200) := l7200 machine-$(CONFIG_ARCH_INTEGRATOR) := integrator machine-$(CONFIG_ARCH_CAMELOT) := epxa10db -textaddr-$(CONFIG_ARCH_CLPS711X) := 0xc0028000 + textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000 machine-$(CONFIG_ARCH_CLPS711X) := clps711x -textaddr-$(CONFIG_ARCH_FORTUNET) := 0xc0008000 machine-$(CONFIG_ARCH_IOP3XX) := iop3xx machine-$(CONFIG_ARCH_IXP4XX) := ixp4xx machine-$(CONFIG_ARCH_IXP2000) := ixp2000 @@ -110,7 +108,8 @@ CFLAGS_3c589_cs.o :=-DISA_SIXTEEN_BIT_PERIPHERAL export CFLAGS_3c589_cs.o endif -TEXTADDR := $(textaddr-y) +# The byte offset of the kernel image in RAM from the start of RAM. +TEXT_OFFSET := $(textofs-y) ifeq ($(incdir-y),) incdir-y := $(machine-y) @@ -123,7 +122,7 @@ else MACHINE := endif -export TEXTADDR GZFLAGS +export TEXT_OFFSET GZFLAGS # Do we have FASTFPE? FASTFPE :=arch/arm/fastfpe diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile index 937a353..a174d63 100644 --- a/arch/arm/boot/Makefile +++ b/arch/arm/boot/Makefile @@ -15,7 +15,7 @@ include $(srctree)/$(MACHINE)/Makefile.boot endif # Note: the following conditions must always be true: -# ZRELADDR == virt_to_phys(TEXTADDR) +# ZRELADDR == virt_to_phys(PAGE_OFFSET + TEXT_OFFSET) # PARAMS_PHYS must be within 4MB of ZRELADDR # INITRD_PHYS must be in RAM ZRELADDR := $(zreladdr-y) diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index c11169b..25b14c3 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -2,7 +2,7 @@ # Makefile for the linux kernel. # -AFLAGS_head.o := -DKERNEL_RAM_ADDR=$(TEXTADDR) +AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) # Object file lists. diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index d7d69fd7..1e985f2 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -33,6 +33,8 @@ #define MACHINFO_PGOFFIO 12 #define MACHINFO_NAME 16 +#define KERNEL_RAM_ADDR (PAGE_OFFSET + TEXT_OFFSET) + /* * swapper_pg_dir is the virtual address of the initial page table. * We place the page tables 16K below KERNEL_RAM_ADDR. Therefore, we must diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 9a47770..2b254e8 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -17,15 +17,13 @@ jiffies = jiffies_64; jiffies = jiffies_64 + 4; #endif +SECTIONS +{ #ifdef CONFIG_XIP_KERNEL -#define TEXTADDR XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR) + . = XIP_VIRT_ADDR(CONFIG_XIP_PHYS_ADDR); #else -#define TEXTADDR KERNEL_RAM_ADDR + . = PAGE_OFFSET + TEXT_OFFSET; #endif - -SECTIONS -{ - . = TEXTADDR; .init : { /* Init code and data */ _stext = .; _sinittext = .; @@ -104,7 +102,7 @@ SECTIONS #ifdef CONFIG_XIP_KERNEL __data_loc = ALIGN(4); /* location in binary */ - . = KERNEL_RAM_ADDR; + . = PAGE_OFFSET + TEXT_OFFSET; #else . = ALIGN(THREAD_SIZE); __data_loc = .; -- cgit v0.10.2 From 78ff18a412da24a4b79c6a97000ef5e467e813da Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 3 Jan 2006 17:39:34 +0000 Subject: [ARM] Cleanup ARM includes arch/arm/kernel/entry-armv.S has contained a comment suggesting that asm/hardware.h and asm/arch/irqs.h should be moved into the asm/arch/entry-macro.S include. So move the includes to these two files as required. Add missing includes (asm/hardware.h, asm/io.h) to asm/arch/system.h includes which use those facilities, and remove asm/io.h from kernel/process.c. Remove other unnecessary includes from arch/arm/kernel, arch/arm/mm and arch/arm/mach-footbridge. Signed-off-by: Russell King diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 2b78838..8d6381c 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c @@ -12,8 +12,6 @@ * DMA facilities. */ #include -#include -#include #include #include #include diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S index 2a8d27e..a52baed 100644 --- a/arch/arm/kernel/entry-armv.S +++ b/arch/arm/kernel/entry-armv.S @@ -18,8 +18,6 @@ #include #include #include -#include /* should be moved into entry-macro.S */ -#include /* should be moved into entry-macro.S */ #include #include "entry-header.S" diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c index 30494aa..54a21bd 100644 --- a/arch/arm/kernel/process.c +++ b/arch/arm/kernel/process.c @@ -28,10 +28,9 @@ #include #include -#include -#include #include #include +#include #include #include diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 8577416..2cab741a 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -26,8 +26,6 @@ #include #include -#include -#include #include #include #include diff --git a/arch/arm/kernel/time.c b/arch/arm/kernel/time.c index fc47291..d7d932c 100644 --- a/arch/arm/kernel/time.c +++ b/arch/arm/kernel/time.c @@ -29,9 +29,6 @@ #include #include -#include -#include -#include #include #include #include diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c index 45e9ea6..c9fe6f5 100644 --- a/arch/arm/kernel/traps.c +++ b/arch/arm/kernel/traps.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/arch/arm/mach-footbridge/dma.c b/arch/arm/mach-footbridge/dma.c index a6b1396..7a54578 100644 --- a/arch/arm/mach-footbridge/dma.c +++ b/arch/arm/mach-footbridge/dma.c @@ -15,6 +15,7 @@ #include #include +#include #include #include diff --git a/arch/arm/mm/consistent.c b/arch/arm/mm/consistent.c index dbfe9e8..0513ed1 100644 --- a/arch/arm/mm/consistent.c +++ b/arch/arm/mm/consistent.c @@ -19,7 +19,6 @@ #include #include -#include #include #define CONSISTENT_BASE (0xffc00000) diff --git a/arch/arm/mm/discontig.c b/arch/arm/mm/discontig.c index 0d097bb..1e56021 100644 --- a/arch/arm/mm/discontig.c +++ b/arch/arm/mm/discontig.c @@ -9,10 +9,8 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ - #include -#include -#include +#include #include #if MAX_NUMNODES != 4 && MAX_NUMNODES != 16 diff --git a/arch/arm/mm/mm-armv.c b/arch/arm/mm/mm-armv.c index 9e50127..d0245a3 100644 --- a/arch/arm/mm/mm-armv.c +++ b/arch/arm/mm/mm-armv.c @@ -19,7 +19,6 @@ #include #include -#include #include #include diff --git a/include/asm-arm/arch-cl7500/entry-macro.S b/include/asm-arm/arch-cl7500/entry-macro.S index 686f413..c9e5395 100644 --- a/include/asm-arm/arch-cl7500/entry-macro.S +++ b/include/asm-arm/arch-cl7500/entry-macro.S @@ -1,3 +1,3 @@ - +#include #include diff --git a/include/asm-arm/arch-clps711x/entry-macro.S b/include/asm-arm/arch-clps711x/entry-macro.S index b31079a..21f6ee4 100644 --- a/include/asm-arm/arch-clps711x/entry-macro.S +++ b/include/asm-arm/arch-clps711x/entry-macro.S @@ -7,6 +7,7 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include #include .macro disable_fiq diff --git a/include/asm-arm/arch-clps711x/system.h b/include/asm-arm/arch-clps711x/system.h index 2ab981f..11e1491 100644 --- a/include/asm-arm/arch-clps711x/system.h +++ b/include/asm-arm/arch-clps711x/system.h @@ -20,7 +20,9 @@ #ifndef __ASM_ARCH_SYSTEM_H #define __ASM_ARCH_SYSTEM_H +#include #include +#include static inline void arch_idle(void) { diff --git a/include/asm-arm/arch-ebsa285/entry-macro.S b/include/asm-arm/arch-ebsa285/entry-macro.S index db5729f..cf10ac9 100644 --- a/include/asm-arm/arch-ebsa285/entry-macro.S +++ b/include/asm-arm/arch-ebsa285/entry-macro.S @@ -7,6 +7,8 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include +#include #include .macro disable_fiq diff --git a/include/asm-arm/arch-imx/entry-macro.S b/include/asm-arm/arch-imx/entry-macro.S index b40ea7c..3b9ef69 100644 --- a/include/asm-arm/arch-imx/entry-macro.S +++ b/include/asm-arm/arch-imx/entry-macro.S @@ -7,6 +7,8 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include + .macro disable_fiq .endm #define AITC_NIVECSR 0x40 diff --git a/include/asm-arm/arch-integrator/entry-macro.S b/include/asm-arm/arch-integrator/entry-macro.S index 44f7ee6..69838d0 100644 --- a/include/asm-arm/arch-integrator/entry-macro.S +++ b/include/asm-arm/arch-integrator/entry-macro.S @@ -7,6 +7,8 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include +#include .macro disable_fiq .endm diff --git a/include/asm-arm/arch-iop3xx/entry-macro.S b/include/asm-arm/arch-iop3xx/entry-macro.S index e2ce7f5..926668c 100644 --- a/include/asm-arm/arch-iop3xx/entry-macro.S +++ b/include/asm-arm/arch-iop3xx/entry-macro.S @@ -7,6 +7,7 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include #if defined(CONFIG_ARCH_IOP321) .macro disable_fiq diff --git a/include/asm-arm/arch-ixp2000/entry-macro.S b/include/asm-arm/arch-ixp2000/entry-macro.S index e3a4e41..16e1e61 100644 --- a/include/asm-arm/arch-ixp2000/entry-macro.S +++ b/include/asm-arm/arch-ixp2000/entry-macro.S @@ -7,6 +7,7 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include .macro disable_fiq .endm diff --git a/include/asm-arm/arch-ixp4xx/entry-macro.S b/include/asm-arm/arch-ixp4xx/entry-macro.S index 323b0bc..27e1241 100644 --- a/include/asm-arm/arch-ixp4xx/entry-macro.S +++ b/include/asm-arm/arch-ixp4xx/entry-macro.S @@ -7,6 +7,7 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include .macro disable_fiq .endm diff --git a/include/asm-arm/arch-l7200/system.h b/include/asm-arm/arch-l7200/system.h index cb4ff29..18825cf 100644 --- a/include/asm-arm/arch-l7200/system.h +++ b/include/asm-arm/arch-l7200/system.h @@ -12,6 +12,8 @@ #ifndef __ASM_ARCH_SYSTEM_H #define __ASM_ARCH_SYSTEM_H +#include + static inline void arch_idle(void) { *(unsigned long *)(IO_BASE + 0x50004) = 1; /* idle mode */ diff --git a/include/asm-arm/arch-lh7a40x/entry-macro.S b/include/asm-arm/arch-lh7a40x/entry-macro.S index 865f396..a2f67c0 100644 --- a/include/asm-arm/arch-lh7a40x/entry-macro.S +++ b/include/asm-arm/arch-lh7a40x/entry-macro.S @@ -7,6 +7,8 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include +#include # if defined (CONFIG_ARCH_LH7A400) && defined (CONFIG_ARCH_LH7A404) # error "LH7A400 and LH7A404 are mutually exclusive" diff --git a/include/asm-arm/arch-omap/entry-macro.S b/include/asm-arm/arch-omap/entry-macro.S index f8814a8..0ffb118 100644 --- a/include/asm-arm/arch-omap/entry-macro.S +++ b/include/asm-arm/arch-omap/entry-macro.S @@ -7,6 +7,8 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include +#include #if defined(CONFIG_ARCH_OMAP1) diff --git a/include/asm-arm/arch-pxa/entry-macro.S b/include/asm-arm/arch-pxa/entry-macro.S index 2abfc8b..4985e33 100644 --- a/include/asm-arm/arch-pxa/entry-macro.S +++ b/include/asm-arm/arch-pxa/entry-macro.S @@ -7,6 +7,8 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ +#include +#include .macro disable_fiq .endm diff --git a/include/asm-arm/arch-realview/entry-macro.S b/include/asm-arm/arch-realview/entry-macro.S index 6288fad..1a6eec8 100644 --- a/include/asm-arm/arch-realview/entry-macro.S +++ b/include/asm-arm/arch-realview/entry-macro.S @@ -7,7 +7,7 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ - +#include #include .macro disable_fiq diff --git a/include/asm-arm/arch-rpc/entry-macro.S b/include/asm-arm/arch-rpc/entry-macro.S index 686f413..c9e5395 100644 --- a/include/asm-arm/arch-rpc/entry-macro.S +++ b/include/asm-arm/arch-rpc/entry-macro.S @@ -1,3 +1,3 @@ - +#include #include diff --git a/include/asm-arm/arch-s3c2410/entry-macro.S b/include/asm-arm/arch-s3c2410/entry-macro.S index b7d4d7f..cc06b1b 100644 --- a/include/asm-arm/arch-s3c2410/entry-macro.S +++ b/include/asm-arm/arch-s3c2410/entry-macro.S @@ -10,6 +10,8 @@ * Modifications: * 10-Mar-2005 LCVR Changed S3C2410_VA to S3C24XX_VA */ +#include +#include .macro get_irqnr_and_base, irqnr, irqstat, base, tmp diff --git a/include/asm-arm/arch-versatile/entry-macro.S b/include/asm-arm/arch-versatile/entry-macro.S index 90e4e97..58f0d71 100644 --- a/include/asm-arm/arch-versatile/entry-macro.S +++ b/include/asm-arm/arch-versatile/entry-macro.S @@ -7,7 +7,9 @@ * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ - .macro disable_fiq +#include + + .macro disable_fiq .endm .macro get_irqnr_and_base, irqnr, irqstat, base, tmp diff --git a/include/asm-arm/cacheflush.h b/include/asm-arm/cacheflush.h index e81baff..09e19a7 100644 --- a/include/asm-arm/cacheflush.h +++ b/include/asm-arm/cacheflush.h @@ -14,7 +14,6 @@ #include #include -#include #include #include -- cgit v0.10.2 From f47fc0ac7ead5ed91a11fcabfad6ee44c17ee934 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 3 Jan 2006 18:34:20 +0000 Subject: [ARM] Add additional documentation to the clock source framework It seems that there's some confusion over how the clock source framework should be used. Add some additional comments to explain the ambiguous areas. Signed-off-by: Russell King diff --git a/include/asm-arm/hardware/clock.h b/include/asm-arm/hardware/clock.h index 19da861..5c56894 100644 --- a/include/asm-arm/hardware/clock.h +++ b/include/asm-arm/hardware/clock.h @@ -33,6 +33,8 @@ struct clk; * uses @dev and @id to determine the clock consumer, and thereby * the clock producer. (IOW, @id may be identical strings, but * clk_get may return different clock producers depending on @dev.) + * + * Drivers must assume that the clock source is not enabled. */ struct clk *clk_get(struct device *dev, const char *id); @@ -49,6 +51,14 @@ int clk_enable(struct clk *clk); /** * clk_disable - inform the system when the clock source is no longer required. * @clk: clock source + * + * Inform the system that a clock source is no longer required by + * a driver and may be shut down. + * + * Implementation detail: if the clock source is shared between + * multiple drivers, clk_enable() calls must be balanced by the + * same number of clk_disable() calls for the clock source to be + * disabled. */ void clk_disable(struct clk *clk); @@ -76,6 +86,10 @@ unsigned long clk_get_rate(struct clk *clk); /** * clk_put - "free" the clock source * @clk: clock source + * + * Note: drivers must ensure that all clk_enable calls made on this + * clock source are balanced by clk_disable calls prior to calling + * this function. */ void clk_put(struct clk *clk); -- cgit v0.10.2 From a8d3584a2df28827094f6338cde1303c467bc1f0 Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 3 Jan 2006 18:41:37 +0000 Subject: [ARM] Remove clk_use()/clk_unuse() It seems that clk_use() and clk_unuse() are additional complexity which isn't required anymore. Remove them from the clock framework to avoid the additional confusion which they cause, and update all ARM machine types except for OMAP. Signed-off-by: Russell King diff --git a/arch/arm/mach-aaec2000/clock.c b/arch/arm/mach-aaec2000/clock.c index 0340ddc..8282083 100644 --- a/arch/arm/mach-aaec2000/clock.c +++ b/arch/arm/mach-aaec2000/clock.c @@ -58,17 +58,6 @@ void clk_disable(struct clk *clk) } EXPORT_SYMBOL(clk_disable); -int clk_use(struct clk *clk) -{ - return 0; -} -EXPORT_SYMBOL(clk_use); - -void clk_unuse(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_unuse); - unsigned long clk_get_rate(struct clk *clk) { return clk->rate; diff --git a/arch/arm/mach-integrator/clock.c b/arch/arm/mach-integrator/clock.c index 73c3606..bbfe46c 100644 --- a/arch/arm/mach-integrator/clock.c +++ b/arch/arm/mach-integrator/clock.c @@ -58,17 +58,6 @@ void clk_disable(struct clk *clk) } EXPORT_SYMBOL(clk_disable); -int clk_use(struct clk *clk) -{ - return 0; -} -EXPORT_SYMBOL(clk_use); - -void clk_unuse(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_unuse); - unsigned long clk_get_rate(struct clk *clk) { return clk->rate; diff --git a/arch/arm/mach-realview/clock.c b/arch/arm/mach-realview/clock.c index 002635c..331e1b4 100644 --- a/arch/arm/mach-realview/clock.c +++ b/arch/arm/mach-realview/clock.c @@ -57,17 +57,6 @@ void clk_disable(struct clk *clk) } EXPORT_SYMBOL(clk_disable); -int clk_use(struct clk *clk) -{ - return 0; -} -EXPORT_SYMBOL(clk_use); - -void clk_unuse(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_unuse); - unsigned long clk_get_rate(struct clk *clk) { return clk->rate; diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c index 82e8253..77f321f 100644 --- a/arch/arm/mach-s3c2410/clock.c +++ b/arch/arm/mach-s3c2410/clock.c @@ -151,18 +151,6 @@ void clk_disable(struct clk *clk) } -int clk_use(struct clk *clk) -{ - atomic_inc(&clk->used); - return 0; -} - - -void clk_unuse(struct clk *clk) -{ - atomic_dec(&clk->used); -} - unsigned long clk_get_rate(struct clk *clk) { if (IS_ERR(clk)) @@ -196,8 +184,6 @@ EXPORT_SYMBOL(clk_get); EXPORT_SYMBOL(clk_put); EXPORT_SYMBOL(clk_enable); EXPORT_SYMBOL(clk_disable); -EXPORT_SYMBOL(clk_use); -EXPORT_SYMBOL(clk_unuse); EXPORT_SYMBOL(clk_get_rate); EXPORT_SYMBOL(clk_round_rate); EXPORT_SYMBOL(clk_set_rate); @@ -370,7 +356,6 @@ static struct clk init_clocks[] = { int s3c24xx_register_clock(struct clk *clk) { clk->owner = THIS_MODULE; - atomic_set(&clk->used, 0); if (clk->enable == NULL) clk->enable = clk_null_enable; diff --git a/arch/arm/mach-s3c2410/clock.h b/arch/arm/mach-s3c2410/clock.h index 7953b6f..177d5c8 100644 --- a/arch/arm/mach-s3c2410/clock.h +++ b/arch/arm/mach-s3c2410/clock.h @@ -16,7 +16,6 @@ struct clk { struct clk *parent; const char *name; int id; - atomic_t used; unsigned long rate; unsigned long ctrlbit; int (*enable)(struct clk *, int enable); diff --git a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c index 8a00e3c..9acda44 100644 --- a/arch/arm/mach-s3c2410/time.c +++ b/arch/arm/mach-s3c2410/time.c @@ -191,7 +191,6 @@ static void s3c2410_timer_setup (void) if (IS_ERR(clk)) panic("failed to get clock for system timer"); - clk_use(clk); clk_enable(clk); pclk = clk_get_rate(clk); diff --git a/arch/arm/mach-versatile/clock.c b/arch/arm/mach-versatile/clock.c index b96a2ea..ada3142 100644 --- a/arch/arm/mach-versatile/clock.c +++ b/arch/arm/mach-versatile/clock.c @@ -58,17 +58,6 @@ void clk_disable(struct clk *clk) } EXPORT_SYMBOL(clk_disable); -int clk_use(struct clk *clk) -{ - return 0; -} -EXPORT_SYMBOL(clk_use); - -void clk_unuse(struct clk *clk) -{ -} -EXPORT_SYMBOL(clk_unuse); - unsigned long clk_get_rate(struct clk *clk) { return clk->rate; diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index eb667da..621e8a9 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -397,7 +397,6 @@ static int s3c2410wdt_probe(struct platform_device *pdev) return -ENOENT; } - clk_use(wdt_clock); clk_enable(wdt_clock); /* see if we can actually set the requested timer margin, and if @@ -444,7 +443,6 @@ static int s3c2410wdt_remove(struct platform_device *dev) if (wdt_clock != NULL) { clk_disable(wdt_clock); - clk_unuse(wdt_clock); clk_put(wdt_clock); wdt_clock = NULL; } diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 58cfd31..2a2f86d 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -738,7 +738,6 @@ static void s3c24xx_i2c_free(struct s3c24xx_i2c *i2c) { if (i2c->clk != NULL && !IS_ERR(i2c->clk)) { clk_disable(i2c->clk); - clk_unuse(i2c->clk); clk_put(i2c->clk); i2c->clk = NULL; } @@ -778,7 +777,6 @@ static int s3c24xx_i2c_probe(struct platform_device *pdev) dev_dbg(&pdev->dev, "clock source %p\n", i2c->clk); - clk_use(i2c->clk); clk_enable(i2c->clk); /* map the registers */ diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index 9b1ab5e..d847ed5 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -72,13 +72,9 @@ static int amba_kmi_open(struct serio *io) unsigned int divisor; int ret; - ret = clk_use(kmi->clk); - if (ret) - goto out; - ret = clk_enable(kmi->clk); if (ret) - goto clk_unuse; + goto out; divisor = clk_get_rate(kmi->clk) / 8000000 - 1; writeb(divisor, KMICLKDIV); @@ -97,8 +93,6 @@ static int amba_kmi_open(struct serio *io) clk_disable: clk_disable(kmi->clk); - clk_unuse: - clk_unuse(kmi->clk); out: return ret; } @@ -111,7 +105,6 @@ static void amba_kmi_close(struct serio *io) free_irq(kmi->irq, kmi); clk_disable(kmi->clk); - clk_unuse(kmi->clk); } static int amba_kmi_probe(struct amba_device *dev, void *id) diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 166c9b0..31b0b6d 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -479,13 +479,9 @@ static int mmci_probe(struct amba_device *dev, void *id) goto host_free; } - ret = clk_use(host->clk); - if (ret) - goto clk_free; - ret = clk_enable(host->clk); if (ret) - goto clk_unuse; + goto clk_free; host->plat = plat; host->mclk = clk_get_rate(host->clk); @@ -558,8 +554,6 @@ static int mmci_probe(struct amba_device *dev, void *id) iounmap(host->base); clk_disable: clk_disable(host->clk); - clk_unuse: - clk_unuse(host->clk); clk_free: clk_put(host->clk); host_free: @@ -594,7 +588,6 @@ static int mmci_remove(struct amba_device *dev) iounmap(host->base); clk_disable(host->clk); - clk_unuse(host->clk); clk_put(host->clk); mmc_free_host(mmc); diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index d209214..b796a9a 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -460,7 +460,6 @@ static int s3c2410_nand_remove(struct platform_device *pdev) if (info->clk != NULL && !IS_ERR(info->clk)) { clk_disable(info->clk); - clk_unuse(info->clk); clk_put(info->clk); } @@ -598,7 +597,6 @@ static int s3c24xx_nand_probe(struct platform_device *pdev, int is_s3c2440) goto exit_error; } - clk_use(info->clk); clk_enable(info->clk); /* allocate and map the resource */ diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index d84476e..531b0e4 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -761,10 +761,6 @@ static int pl011_probe(struct amba_device *dev, void *id) goto unmap; } - ret = clk_use(uap->clk); - if (ret) - goto putclk; - uap->port.dev = &dev->dev; uap->port.mapbase = dev->res.start; uap->port.membase = base; @@ -782,8 +778,6 @@ static int pl011_probe(struct amba_device *dev, void *id) if (ret) { amba_set_drvdata(dev, NULL); amba_ports[i] = NULL; - clk_unuse(uap->clk); - putclk: clk_put(uap->clk); unmap: iounmap(base); @@ -808,7 +802,6 @@ static int pl011_remove(struct amba_device *dev) amba_ports[i] = NULL; iounmap(uap->port.membase); - clk_unuse(uap->clk); clk_put(uap->clk); kfree(uap); return 0; diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index 47681c4..eb47f5b 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c @@ -782,11 +782,9 @@ static void s3c24xx_serial_set_termios(struct uart_port *port, if (ourport->baudclk != NULL && !IS_ERR(ourport->baudclk)) { clk_disable(ourport->baudclk); - clk_unuse(ourport->baudclk); ourport->baudclk = NULL; } - clk_use(clk); clk_enable(clk); ourport->clksrc = clksrc; @@ -1077,9 +1075,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport, ourport->clk = clk_get(&platdev->dev, "uart"); - if (ourport->clk != NULL && !IS_ERR(ourport->clk)) - clk_use(ourport->clk); - dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n", port->mapbase, port->membase, port->irq, port->uartclk); diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index 35cc940..add198a 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -363,7 +363,6 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver, goto err1; } - clk_use(clk); s3c2410_start_hc(dev, hcd); hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); @@ -384,7 +383,6 @@ int usb_hcd_s3c2410_probe (const struct hc_driver *driver, err2: s3c2410_stop_hc(dev); iounmap(hcd->regs); - clk_unuse(clk); clk_put(clk); err1: diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index a3c2c45..69421c8 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -346,10 +346,6 @@ static int clcdfb_register(struct clcd_fb *fb) goto out; } - ret = clk_use(fb->clk); - if (ret) - goto free_clk; - fb->fb.fix.mmio_start = fb->dev->res.start; fb->fb.fix.mmio_len = SZ_4K; @@ -357,7 +353,7 @@ static int clcdfb_register(struct clcd_fb *fb) if (!fb->regs) { printk(KERN_ERR "CLCD: unable to remap registers\n"); ret = -ENOMEM; - goto unuse_clk; + goto free_clk; } fb->fb.fbops = &clcdfb_ops; @@ -427,8 +423,6 @@ static int clcdfb_register(struct clcd_fb *fb) printk(KERN_ERR "CLCD: cannot register framebuffer (%d)\n", ret); iounmap(fb->regs); - unuse_clk: - clk_unuse(fb->clk); free_clk: clk_put(fb->clk); out: @@ -489,7 +483,6 @@ static int clcdfb_remove(struct amba_device *dev) clcdfb_disable(fb); unregister_framebuffer(&fb->fb); iounmap(fb->regs); - clk_unuse(fb->clk); clk_put(fb->clk); fb->board->remove(fb); diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index ce6e749..d9c08cc 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c @@ -746,7 +746,6 @@ int __init s3c2410fb_probe(struct platform_device *pdev) goto release_irq; } - clk_use(info->clk); clk_enable(info->clk); dprintk("got and enabled clock\n"); @@ -783,7 +782,6 @@ free_video_memory: s3c2410fb_unmap_video_memory(info); release_clock: clk_disable(info->clk); - clk_unuse(info->clk); clk_put(info->clk); release_irq: free_irq(irq,info); @@ -828,7 +826,6 @@ static int s3c2410fb_remove(struct platform_device *pdev) if (info->clk) { clk_disable(info->clk); - clk_unuse(info->clk); clk_put(info->clk); info->clk = NULL; } diff --git a/include/asm-arm/hardware/clock.h b/include/asm-arm/hardware/clock.h index 5c56894..69f3321 100644 --- a/include/asm-arm/hardware/clock.h +++ b/include/asm-arm/hardware/clock.h @@ -63,20 +63,6 @@ int clk_enable(struct clk *clk); void clk_disable(struct clk *clk); /** - * clk_use - increment the use count - * @clk: clock source - * - * Returns success (0) or negative errno. - */ -int clk_use(struct clk *clk); - -/** - * clk_unuse - decrement the use count - * @clk: clock source - */ -void clk_unuse(struct clk *clk); - -/** * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. * This is only valid once the clock source has been enabled. * @clk: clock source -- cgit v0.10.2 From 109a9378807cb9093a88fbf9707420de97601e14 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 14:06:31 +0000 Subject: [ARM] Remove unused dma.c files CLPS711x, EPXA10DB and Integrator contained a dma.c file which has never been built. Remove these redundant files. Signed-off-by: Russell King diff --git a/arch/arm/mach-clps711x/dma.c b/arch/arm/mach-clps711x/dma.c deleted file mode 100644 index af5a4de..0000000 --- a/arch/arm/mach-clps711x/dma.c +++ /dev/null @@ -1,27 +0,0 @@ -/* - * linux/arch/arm/mach-clps711x/dma.c - * - * Copyright (C) 2000 Deep Blue Solutions Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include - -#include -#include - -void __init arch_dma_init(dma_t *dma) -{ -} diff --git a/arch/arm/mach-epxa10db/dma.c b/arch/arm/mach-epxa10db/dma.c deleted file mode 100644 index 0151e9f..0000000 --- a/arch/arm/mach-epxa10db/dma.c +++ /dev/null @@ -1,28 +0,0 @@ -/* - * linux/arch/arm/mach-epxa10db/dma.c - * - * Copyright (C) 1999 ARM Limited - * Copyright (C) 2000 Deep Blue Solutions Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include - -#include -#include - -void __init arch_dma_init(dma_t *dma) -{ -} diff --git a/arch/arm/mach-integrator/dma.c b/arch/arm/mach-integrator/dma.c deleted file mode 100644 index aae6f23..0000000 --- a/arch/arm/mach-integrator/dma.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - * linux/arch/arm/mach-integrator/dma.c - * - * Copyright (C) 1999 ARM Limited - * Copyright (C) 2000 Deep Blue Solutions Ltd - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#include -#include -#include - -#include -#include -#include -#include -#include - -#include - -void __init arch_dma_init(dma_t *dma) -{ -} -- cgit v0.10.2 From 333c9624b728a9e83b741ea75836aa114ec35272 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 14:41:29 +0000 Subject: [ARM] Move ISA DMA bus_to_virt() out of set_dma_addr() Allow the compiler to optimise the bus_to_virt(virt_to_bus()) transformation in the ARM ISA DMA interface. Signed-off-by: Russell King diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 8d6381c..3aedada 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c @@ -131,7 +131,7 @@ void set_dma_sg (dmach_t channel, struct scatterlist *sg, int nr_sg) * * Copy address to the structure, and set the invalid bit */ -void set_dma_addr (dmach_t channel, unsigned long physaddr) +void __set_dma_addr (dmach_t channel, void *addr) { dma_t *dma = dma_chan + channel; @@ -141,7 +141,7 @@ void set_dma_addr (dmach_t channel, unsigned long physaddr) dma->sg = &dma->buf; dma->sgcount = 1; - dma->buf.__address = bus_to_virt(physaddr); + dma->buf.__address = addr; dma->using_sg = 0; dma->invalid = 1; } @@ -278,7 +278,7 @@ GLOBAL_ALIAS(get_dma_list, get_dma_residue); GLOBAL_ALIAS(set_dma_mode, get_dma_residue); GLOBAL_ALIAS(set_dma_page, get_dma_residue); GLOBAL_ALIAS(set_dma_count, get_dma_residue); -GLOBAL_ALIAS(set_dma_addr, get_dma_residue); +GLOBAL_ALIAS(__set_dma_addr, get_dma_residue); GLOBAL_ALIAS(set_dma_sg, get_dma_residue); GLOBAL_ALIAS(set_dma_speed, get_dma_residue); GLOBAL_ALIAS(init_dma, get_dma_residue); @@ -289,7 +289,7 @@ EXPORT_SYMBOL(request_dma); EXPORT_SYMBOL(free_dma); EXPORT_SYMBOL(enable_dma); EXPORT_SYMBOL(disable_dma); -EXPORT_SYMBOL(set_dma_addr); +EXPORT_SYMBOL(__set_dma_addr); EXPORT_SYMBOL(set_dma_count); EXPORT_SYMBOL(set_dma_mode); EXPORT_SYMBOL(set_dma_page); diff --git a/include/asm-arm/dma.h b/include/asm-arm/dma.h index ef41df43a..1c7087f 100644 --- a/include/asm-arm/dma.h +++ b/include/asm-arm/dma.h @@ -91,7 +91,9 @@ extern void set_dma_sg(dmach_t channel, struct scatterlist *sg, int nr_sg); * especially since some DMA architectures don't update the * DMA address immediately, but defer it to the enable_dma(). */ -extern void set_dma_addr(dmach_t channel, unsigned long physaddr); +extern void __set_dma_addr(dmach_t channel, void *addr); +#define set_dma_addr(channel, addr) \ + __set_dma_addr(channel, bus_to_virt(addr)) /* Set the DMA byte count for this channel * -- cgit v0.10.2 From 7cdad482974792419cfe4b0affca689170116f49 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:08:30 +0000 Subject: [ARM] Remove '__address' from scatterlist and convert to DMA API The old __address element in struct scatterlist remained from older kernels because the ARM DMA emulation code made use of it. Move this field into struct dma_struct, and convert DMA emulation code to setup a SG entry as required. Also, convert DMA emulation code to use the new DMA API rather than the PCI DMA API. Signed-off-by: Russell King diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c index e9a3630..0353276 100644 --- a/arch/arm/kernel/dma-isa.c +++ b/arch/arm/kernel/dma-isa.c @@ -18,7 +18,7 @@ */ #include #include -#include +#include #include #include @@ -65,37 +65,41 @@ static void isa_enable_dma(dmach_t channel, dma_t *dma) { if (dma->invalid) { unsigned long address, length; - unsigned int mode, direction; + unsigned int mode; + enum dma_data_direction direction; mode = channel & 3; switch (dma->dma_mode & DMA_MODE_MASK) { case DMA_MODE_READ: mode |= ISA_DMA_MODE_READ; - direction = PCI_DMA_FROMDEVICE; + direction = DMA_FROM_DEVICE; break; case DMA_MODE_WRITE: mode |= ISA_DMA_MODE_WRITE; - direction = PCI_DMA_TODEVICE; + direction = DMA_TO_DEVICE; break; case DMA_MODE_CASCADE: mode |= ISA_DMA_MODE_CASCADE; - direction = PCI_DMA_BIDIRECTIONAL; + direction = DMA_BIDIRECTIONAL; break; default: - direction = PCI_DMA_NONE; + direction = DMA_NONE; break; } - if (!dma->using_sg) { + if (!dma->sg) { /* * Cope with ISA-style drivers which expect cache * coherence. */ - dma->buf.dma_address = pci_map_single(NULL, - dma->buf.__address, dma->buf.length, + dma->sg = &dma->buf; + dma->sgcount = 1; + dma->buf.length = dma->count; + dma->buf.dma_address = dma_map_single(NULL, + dma->addr, dma->count, direction); } diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 3aedada..913fd94 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c @@ -123,7 +123,6 @@ void set_dma_sg (dmach_t channel, struct scatterlist *sg, int nr_sg) dma->sg = sg; dma->sgcount = nr_sg; - dma->using_sg = 1; dma->invalid = 1; } @@ -139,10 +138,8 @@ void __set_dma_addr (dmach_t channel, void *addr) printk(KERN_ERR "dma%d: altering DMA address while " "DMA active\n", channel); - dma->sg = &dma->buf; - dma->sgcount = 1; - dma->buf.__address = addr; - dma->using_sg = 0; + dma->sg = NULL; + dma->addr = addr; dma->invalid = 1; } @@ -158,10 +155,8 @@ void set_dma_count (dmach_t channel, unsigned long count) printk(KERN_ERR "dma%d: altering DMA count while " "DMA active\n", channel); - dma->sg = &dma->buf; - dma->sgcount = 1; - dma->buf.length = count; - dma->using_sg = 0; + dma->sg = NULL; + dma->count = count; dma->invalid = 1; } diff --git a/arch/arm/mach-rpc/dma.c b/arch/arm/mach-rpc/dma.c index bc07474..bd86ffb 100644 --- a/arch/arm/mach-rpc/dma.c +++ b/arch/arm/mach-rpc/dma.c @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -148,11 +148,14 @@ static void iomd_enable_dma(dmach_t channel, dma_t *dma) * Cope with ISA-style drivers which expect cache * coherence. */ - if (!dma->using_sg) { - dma->buf.dma_address = pci_map_single(NULL, - dma->buf.__address, dma->buf.length, + if (!dma->sg) { + dma->sg = &dma->buf; + dma->sgcount = 1; + dma->buf.length = dma->count; + dma->buf.dma_address = dma_map_single(NULL, + dma->addr, dma->count, dma->dma_mode == DMA_MODE_READ ? - PCI_DMA_FROMDEVICE : PCI_DMA_TODEVICE); + DMA_FROM_DEVICE : DMA_TO_DEVICE); } iomd_writeb(DMA_CR_C, dma_base + CR); @@ -239,7 +242,7 @@ static void floppy_enable_dma(dmach_t channel, dma_t *dma) unsigned int fiqhandler_length; struct pt_regs regs; - if (dma->using_sg) + if (dma->sg) BUG(); if (dma->dma_mode == DMA_MODE_READ) { @@ -252,8 +255,8 @@ static void floppy_enable_dma(dmach_t channel, dma_t *dma) fiqhandler_length = &floppy_fiqout_end - &floppy_fiqout_start; } - regs.ARM_r9 = dma->buf.length; - regs.ARM_r10 = (unsigned long)dma->buf.__address; + regs.ARM_r9 = dma->count; + regs.ARM_r10 = (unsigned long)dma->addr; regs.ARM_fp = (unsigned long)FLOPPYDMA_BASE; if (claim_fiq(&fh)) { diff --git a/include/asm-arm/mach/dma.h b/include/asm-arm/mach/dma.h index 31bf716..e7c4a20 100644 --- a/include/asm-arm/mach/dma.h +++ b/include/asm-arm/mach/dma.h @@ -25,13 +25,15 @@ struct dma_ops { }; struct dma_struct { + void *addr; /* single DMA address */ + unsigned long count; /* single DMA size */ struct scatterlist buf; /* single DMA */ int sgcount; /* number of DMA SG */ struct scatterlist *sg; /* DMA Scatter-Gather List */ unsigned int active:1; /* Transfer active */ unsigned int invalid:1; /* Address/Count changed */ - unsigned int using_sg:1; /* using scatter list? */ + dmamode_t dma_mode; /* DMA mode */ int speed; /* DMA speed */ diff --git a/include/asm-arm/scatterlist.h b/include/asm-arm/scatterlist.h index 83b876f..de2f65e 100644 --- a/include/asm-arm/scatterlist.h +++ b/include/asm-arm/scatterlist.h @@ -9,7 +9,6 @@ struct scatterlist { unsigned int offset; /* buffer offset */ dma_addr_t dma_address; /* dma address */ unsigned int length; /* length */ - char *__address; /* for set_dma_addr */ }; /* -- cgit v0.10.2 From 6842b9299272a9471a7e94e046b953f6ffe3db9d Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:17:08 +0000 Subject: [ARM] Use core_initcall() to initialise ARM DMA There's no need to have DMA initialised at the same time as interrupts. Move it to a core_initcall(). Signed-off-by: Russell King diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 913fd94..3b325ef 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c @@ -248,11 +248,14 @@ int get_dma_residue(dmach_t channel) return ret; } -void __init init_dma(void) +static int __init init_dma(void) { arch_dma_init(dma_chan); + return 0; } +core_initcall(init_dma); + #else int request_dma(dmach_t channel, const char *device_id) @@ -276,7 +279,6 @@ GLOBAL_ALIAS(set_dma_count, get_dma_residue); GLOBAL_ALIAS(__set_dma_addr, get_dma_residue); GLOBAL_ALIAS(set_dma_sg, get_dma_residue); GLOBAL_ALIAS(set_dma_speed, get_dma_residue); -GLOBAL_ALIAS(init_dma, get_dma_residue); #endif diff --git a/arch/arm/kernel/irq.c b/arch/arm/kernel/irq.c index d7099db..869c466 100644 --- a/arch/arm/kernel/irq.c +++ b/arch/arm/kernel/irq.c @@ -1027,7 +1027,6 @@ void __init init_irq_proc(void) void __init init_IRQ(void) { struct irqdesc *desc; - extern void init_dma(void); int irq; #ifdef CONFIG_SMP @@ -1041,7 +1040,6 @@ void __init init_IRQ(void) } init_arch_irq(); - init_dma(); } static int __init noirqdebug_setup(char *str) -- cgit v0.10.2 From d4c6fc9976dd70a27abc988ddbd6a746c1dba0a7 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:30:48 +0000 Subject: [ARM] Move common definition of MAX_DMA_ADDRESS to asm/dma.h Signed-off-by: Russell King diff --git a/include/asm-arm/arch-aaec2000/dma.h b/include/asm-arm/arch-aaec2000/dma.h index 28c890b..c42212c 100644 --- a/include/asm-arm/arch-aaec2000/dma.h +++ b/include/asm-arm/arch-aaec2000/dma.h @@ -11,7 +11,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff #define MAX_DMA_CHANNELS 0 #endif diff --git a/include/asm-arm/arch-clps711x/dma.h b/include/asm-arm/arch-clps711x/dma.h index 3c4c5c8..c35f87d 100644 --- a/include/asm-arm/arch-clps711x/dma.h +++ b/include/asm-arm/arch-clps711x/dma.h @@ -20,8 +20,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff - #define MAX_DMA_CHANNELS 0 #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-ebsa110/dma.h b/include/asm-arm/arch-ebsa110/dma.h index d491776..f1add13 100644 --- a/include/asm-arm/arch-ebsa110/dma.h +++ b/include/asm-arm/arch-ebsa110/dma.h @@ -12,7 +12,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff #define MAX_DMA_CHANNELS 0 #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-ebsa285/dma.h b/include/asm-arm/arch-ebsa285/dma.h index c43046e..0259ad4 100644 --- a/include/asm-arm/arch-ebsa285/dma.h +++ b/include/asm-arm/arch-ebsa285/dma.h @@ -10,11 +10,6 @@ #define __ASM_ARCH_DMA_H /* - * This is the maximum DMA address that can be DMAd to. - */ -#define MAX_DMA_ADDRESS 0xffffffff - -/* * The 21285 has two internal DMA channels; we call these 8 and 9. * On CATS hardware we have an additional eight ISA dma channels * numbered 0..7. diff --git a/include/asm-arm/arch-epxa10db/dma.h b/include/asm-arm/arch-epxa10db/dma.h index 5d97734..6e13e6b 100644 --- a/include/asm-arm/arch-epxa10db/dma.h +++ b/include/asm-arm/arch-epxa10db/dma.h @@ -20,8 +20,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff - #define MAX_DMA_CHANNELS 0 #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-imx/dma.h b/include/asm-arm/arch-imx/dma.h index dbdc017..0b8f39a 100644 --- a/include/asm-arm/arch-imx/dma.h +++ b/include/asm-arm/arch-imx/dma.h @@ -20,8 +20,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff - #define MAX_DMA_CHANNELS 0 /* diff --git a/include/asm-arm/arch-integrator/dma.h b/include/asm-arm/arch-integrator/dma.h index 7171792..6f934f6 100644 --- a/include/asm-arm/arch-integrator/dma.h +++ b/include/asm-arm/arch-integrator/dma.h @@ -20,8 +20,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff - #define MAX_DMA_CHANNELS 0 #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-iop3xx/dma.h b/include/asm-arm/arch-iop3xx/dma.h index 797f9e6..58ec24d 100644 --- a/include/asm-arm/arch-iop3xx/dma.h +++ b/include/asm-arm/arch-iop3xx/dma.h @@ -11,6 +11,4 @@ #ifndef _IOP3XX_DMA_H_P #define _IOP3XX_DMA_H_P -#define MAX_DMA_ADDRESS 0xffffffff - #endif /* _ASM_ARCH_DMA_H_P */ diff --git a/include/asm-arm/arch-ixp2000/dma.h b/include/asm-arm/arch-ixp2000/dma.h index 0fb3568..3af3825 100644 --- a/include/asm-arm/arch-ixp2000/dma.h +++ b/include/asm-arm/arch-ixp2000/dma.h @@ -10,8 +10,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff - /* No DMA */ #define MAX_DMA_CHANNELS 0 diff --git a/include/asm-arm/arch-lh7a40x/dma.h b/include/asm-arm/arch-lh7a40x/dma.h index 5797f01..18f1368 100644 --- a/include/asm-arm/arch-lh7a40x/dma.h +++ b/include/asm-arm/arch-lh7a40x/dma.h @@ -11,7 +11,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff #define MAX_DMA_CHANNELS 0 /* All DMA is internal to CPU */ #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-omap/dma.h b/include/asm-arm/arch-omap/dma.h index ccbcb58..40c0454 100644 --- a/include/asm-arm/arch-omap/dma.h +++ b/include/asm-arm/arch-omap/dma.h @@ -21,7 +21,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff #define MAX_DMA_CHANNELS 0 /* Hardware registers for omap1 */ diff --git a/include/asm-arm/arch-pxa/dma.h b/include/asm-arm/arch-pxa/dma.h index 56db3d4..7402bda 100644 --- a/include/asm-arm/arch-pxa/dma.h +++ b/include/asm-arm/arch-pxa/dma.h @@ -12,8 +12,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff - /* No DMA as the rest of the world see it */ #define MAX_DMA_CHANNELS 0 diff --git a/include/asm-arm/arch-realview/dma.h b/include/asm-arm/arch-realview/dma.h index 744491a..d595cc9 100644 --- a/include/asm-arm/arch-realview/dma.h +++ b/include/asm-arm/arch-realview/dma.h @@ -21,7 +21,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff #define MAX_DMA_CHANNELS 0 #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-sa1100/dma.h b/include/asm-arm/arch-sa1100/dma.h index 3d60ed9..a79c2d3 100644 --- a/include/asm-arm/arch-sa1100/dma.h +++ b/include/asm-arm/arch-sa1100/dma.h @@ -15,12 +15,6 @@ /* - * This is the maximum DMA address that can be DMAd to. - */ -#define MAX_DMA_ADDRESS 0xffffffff - - -/* * The regular generic DMA interface is inappropriate for the * SA1100 DMA model. None of the SA1100 specific drivers using * DMA are portable anyway so it's pointless to try to twist the diff --git a/include/asm-arm/arch-versatile/dma.h b/include/asm-arm/arch-versatile/dma.h index dcc8ac2..94b3fc5 100644 --- a/include/asm-arm/arch-versatile/dma.h +++ b/include/asm-arm/arch-versatile/dma.h @@ -21,7 +21,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_ADDRESS 0xffffffff #define MAX_DMA_CHANNELS 0 #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/dma.h b/include/asm-arm/dma.h index 1c7087f..49c01e2 100644 --- a/include/asm-arm/dma.h +++ b/include/asm-arm/dma.h @@ -10,6 +10,13 @@ typedef unsigned int dmach_t; #include /* + * This is the maximum virtual address which can be DMA'd from. + */ +#ifndef MAX_DMA_ADDRESS +#define MAX_DMA_ADDRESS 0xffffffff +#endif + +/* * DMA modes */ typedef unsigned int dmamode_t; -- cgit v0.10.2 From 065909b91581cf2438d901a7811a82af3476bdab Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:44:16 +0000 Subject: [ARM] Refine selection of ISA_DMA_API and generic dma.c code ISA_DMA_API tells the rest of the kernel if the ISA DMA API is available. Select this symbol only on machine types which make use of the ISA DMA API. Make building of arch/arm/kernel/dma.c depend on this symbol - if a machine does not support the ISA DMA API, it's pointless building this file. Signed-off-by: Russell King diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 4b15f5f..cb41310 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -154,6 +154,7 @@ config ARCH_RPC select FIQ select TIMER_ACORN select ARCH_MAY_HAVE_PC_FDC + select ISA_DMA_API help On the Acorn Risc-PC, Linux can support the internal IDE disk and CD-ROM interface, serial and parallel port, and the floppy drive. @@ -206,6 +207,7 @@ config ARCH_IMX config ARCH_H720X bool "Hynix-HMS720x-based" + select ISA_DMA_API help This enables support for systems based on the Hynix HMS720x @@ -290,12 +292,14 @@ config ISA (MCA) or VESA. ISA is an older system, now being displaced by PCI; newer boards don't support it. If you have ISA, say Y, otherwise N. +# Select ISA DMA controller support config ISA_DMA bool + select ISA_DMA_API +# Select ISA DMA interface config ISA_DMA_API bool - default y config PCI bool "PCI support" if ARCH_INTEGRATOR_AP || ARCH_VERSATILE_PB diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 25b14c3..de94b0f 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile @@ -6,11 +6,12 @@ AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) # Object file lists. -obj-y := compat.o dma.o entry-armv.o entry-common.o irq.o \ +obj-y := compat.o entry-armv.o entry-common.o irq.o \ process.o ptrace.o semaphore.o setup.o signal.o sys_arm.o \ time.o traps.o obj-$(CONFIG_APM) += apm.o +obj-$(CONFIG_ISA_DMA_API) += dma.o obj-$(CONFIG_ARCH_ACORN) += ecard.o obj-$(CONFIG_FOOTBRIDGE) += isa.o obj-$(CONFIG_FIQ) += fiq.o -- cgit v0.10.2 From 95ba9fb06be4a8714c98df6097eab1808c72fa98 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:51:51 +0000 Subject: [ARM] Remove definition of MAX_DMA_CHANNELS to zero Since we now only build arch/arm/kernel/dma.c on machine types which set ISA_DMA_API, we don't need to define MAX_DMA_CHANNELS to 0 to indicate this - this definition becomes superfluous. Remove it. Signed-off-by: Russell King diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 3b325ef..62c8966 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c @@ -22,8 +22,6 @@ DEFINE_SPINLOCK(dma_spin_lock); -#if MAX_DMA_CHANNELS > 0 - static dma_t dma_chan[MAX_DMA_CHANNELS]; /* @@ -256,32 +254,6 @@ static int __init init_dma(void) core_initcall(init_dma); -#else - -int request_dma(dmach_t channel, const char *device_id) -{ - return -EINVAL; -} - -int get_dma_residue(dmach_t channel) -{ - return 0; -} - -#define GLOBAL_ALIAS(_a,_b) asm (".set " #_a "," #_b "; .globl " #_a) -GLOBAL_ALIAS(disable_dma, get_dma_residue); -GLOBAL_ALIAS(enable_dma, get_dma_residue); -GLOBAL_ALIAS(free_dma, get_dma_residue); -GLOBAL_ALIAS(get_dma_list, get_dma_residue); -GLOBAL_ALIAS(set_dma_mode, get_dma_residue); -GLOBAL_ALIAS(set_dma_page, get_dma_residue); -GLOBAL_ALIAS(set_dma_count, get_dma_residue); -GLOBAL_ALIAS(__set_dma_addr, get_dma_residue); -GLOBAL_ALIAS(set_dma_sg, get_dma_residue); -GLOBAL_ALIAS(set_dma_speed, get_dma_residue); - -#endif - EXPORT_SYMBOL(request_dma); EXPORT_SYMBOL(free_dma); EXPORT_SYMBOL(enable_dma); diff --git a/include/asm-arm/arch-aaec2000/dma.h b/include/asm-arm/arch-aaec2000/dma.h index c42212c..e100b1e 100644 --- a/include/asm-arm/arch-aaec2000/dma.h +++ b/include/asm-arm/arch-aaec2000/dma.h @@ -7,10 +7,3 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ - -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif diff --git a/include/asm-arm/arch-cl7500/dma.h b/include/asm-arm/arch-cl7500/dma.h index 1d6a882..591ed25 100644 --- a/include/asm-arm/arch-cl7500/dma.h +++ b/include/asm-arm/arch-cl7500/dma.h @@ -15,7 +15,6 @@ * bytes of RAM. */ #define MAX_DMA_ADDRESS 0xd0000000 -#define MAX_DMA_CHANNELS 0 #define DMA_S0 0 diff --git a/include/asm-arm/arch-clps711x/dma.h b/include/asm-arm/arch-clps711x/dma.h index c35f87d..6109979 100644 --- a/include/asm-arm/arch-clps711x/dma.h +++ b/include/asm-arm/arch-clps711x/dma.h @@ -17,10 +17,3 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ - diff --git a/include/asm-arm/arch-ebsa110/dma.h b/include/asm-arm/arch-ebsa110/dma.h index f1add13..c52f9e2a 100644 --- a/include/asm-arm/arch-ebsa110/dma.h +++ b/include/asm-arm/arch-ebsa110/dma.h @@ -9,10 +9,3 @@ * * EBSA110 DMA definitions */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ - diff --git a/include/asm-arm/arch-epxa10db/dma.h b/include/asm-arm/arch-epxa10db/dma.h index 6e13e6b..de20ec8 100644 --- a/include/asm-arm/arch-epxa10db/dma.h +++ b/include/asm-arm/arch-epxa10db/dma.h @@ -17,10 +17,3 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ - diff --git a/include/asm-arm/arch-imx/dma.h b/include/asm-arm/arch-imx/dma.h index 0b8f39a..b45fa36 100644 --- a/include/asm-arm/arch-imx/dma.h +++ b/include/asm-arm/arch-imx/dma.h @@ -20,8 +20,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_CHANNELS 0 - /* * DMA registration */ diff --git a/include/asm-arm/arch-integrator/dma.h b/include/asm-arm/arch-integrator/dma.h index 6f934f6..83fd6bb 100644 --- a/include/asm-arm/arch-integrator/dma.h +++ b/include/asm-arm/arch-integrator/dma.h @@ -17,10 +17,3 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ - diff --git a/include/asm-arm/arch-iop3xx/dma.h b/include/asm-arm/arch-iop3xx/dma.h index 58ec24d..1e808db 100644 --- a/include/asm-arm/arch-iop3xx/dma.h +++ b/include/asm-arm/arch-iop3xx/dma.h @@ -7,8 +7,3 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ - -#ifndef _IOP3XX_DMA_H_P -#define _IOP3XX_DMA_H_P - -#endif /* _ASM_ARCH_DMA_H_P */ diff --git a/include/asm-arm/arch-ixp2000/dma.h b/include/asm-arm/arch-ixp2000/dma.h index 3af3825..548d8dc 100644 --- a/include/asm-arm/arch-ixp2000/dma.h +++ b/include/asm-arm/arch-ixp2000/dma.h @@ -7,10 +7,3 @@ * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -/* No DMA */ -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-ixp4xx/dma.h b/include/asm-arm/arch-ixp4xx/dma.h index 312065d..b1a071e 100644 --- a/include/asm-arm/arch-ixp4xx/dma.h +++ b/include/asm-arm/arch-ixp4xx/dma.h @@ -20,7 +20,4 @@ #define MAX_DMA_ADDRESS (PAGE_OFFSET + SZ_64M) -/* No DMA */ -#define MAX_DMA_CHANNELS 0 - #endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-l7200/dma.h b/include/asm-arm/arch-l7200/dma.h index 6595b38..4c7eca6 100644 --- a/include/asm-arm/arch-l7200/dma.h +++ b/include/asm-arm/arch-l7200/dma.h @@ -17,7 +17,6 @@ * bytes of RAM. */ #define MAX_DMA_ADDRESS 0xd0000000 -#define MAX_DMA_CHANNELS 0 #define DMA_S0 0 diff --git a/include/asm-arm/arch-lh7a40x/dma.h b/include/asm-arm/arch-lh7a40x/dma.h index 18f1368..15492e3 100644 --- a/include/asm-arm/arch-lh7a40x/dma.h +++ b/include/asm-arm/arch-lh7a40x/dma.h @@ -7,10 +7,3 @@ * version 2 as published by the Free Software Foundation. * */ - -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 /* All DMA is internal to CPU */ - -#endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-omap/dma.h b/include/asm-arm/arch-omap/dma.h index 40c0454..d4e73ef 100644 --- a/include/asm-arm/arch-omap/dma.h +++ b/include/asm-arm/arch-omap/dma.h @@ -21,8 +21,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -#define MAX_DMA_CHANNELS 0 - /* Hardware registers for omap1 */ #define OMAP_DMA_BASE (0xfffed800) #define OMAP_DMA_GCR (OMAP_DMA_BASE + 0x400) diff --git a/include/asm-arm/arch-pxa/dma.h b/include/asm-arm/arch-pxa/dma.h index 7402bda..3e88a2a 100644 --- a/include/asm-arm/arch-pxa/dma.h +++ b/include/asm-arm/arch-pxa/dma.h @@ -12,9 +12,6 @@ #ifndef __ASM_ARCH_DMA_H #define __ASM_ARCH_DMA_H -/* No DMA as the rest of the world see it */ -#define MAX_DMA_CHANNELS 0 - /* * Descriptor structure for PXA's DMA engine * Note: this structure must always be aligned to a 16-byte boundary. diff --git a/include/asm-arm/arch-realview/dma.h b/include/asm-arm/arch-realview/dma.h index d595cc9..8342e3f 100644 --- a/include/asm-arm/arch-realview/dma.h +++ b/include/asm-arm/arch-realview/dma.h @@ -18,9 +18,3 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ diff --git a/include/asm-arm/arch-s3c2410/dma.h b/include/asm-arm/arch-s3c2410/dma.h index e830a40..b011e14 100644 --- a/include/asm-arm/arch-s3c2410/dma.h +++ b/include/asm-arm/arch-s3c2410/dma.h @@ -31,14 +31,6 @@ #define MAX_DMA_TRANSFER_SIZE 0x100000 /* Data Unit is half word */ -/* according to the samsung port, we cannot use the regular - * dma channels... we must therefore provide our own interface - * for DMA, and allow our drivers to use that. - */ - -#define MAX_DMA_CHANNELS 0 - - /* we have 4 dma channels */ #define S3C2410_DMA_CHANNELS (4) diff --git a/include/asm-arm/arch-sa1100/dma.h b/include/asm-arm/arch-sa1100/dma.h index a79c2d3..02575d7 100644 --- a/include/asm-arm/arch-sa1100/dma.h +++ b/include/asm-arm/arch-sa1100/dma.h @@ -15,14 +15,6 @@ /* - * The regular generic DMA interface is inappropriate for the - * SA1100 DMA model. None of the SA1100 specific drivers using - * DMA are portable anyway so it's pointless to try to twist the - * regular DMA API to accommodate them. - */ -#define MAX_DMA_CHANNELS 0 - -/* * The SA1100 has six internal DMA channels. */ #define SA1100_DMA_CHANNELS 6 diff --git a/include/asm-arm/arch-versatile/dma.h b/include/asm-arm/arch-versatile/dma.h index 94b3fc5..6425773 100644 --- a/include/asm-arm/arch-versatile/dma.h +++ b/include/asm-arm/arch-versatile/dma.h @@ -18,9 +18,3 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef __ASM_ARCH_DMA_H -#define __ASM_ARCH_DMA_H - -#define MAX_DMA_CHANNELS 0 - -#endif /* _ASM_ARCH_DMA_H */ -- cgit v0.10.2 From d7b4a75677f8f2a559b0c55a550b364e79a8d302 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:52:45 +0000 Subject: [ARM] Move DMA exports to be next to each function Signed-off-by: Russell King diff --git a/arch/arm/kernel/dma.c b/arch/arm/kernel/dma.c index 62c8966..5a0f4bc 100644 --- a/arch/arm/kernel/dma.c +++ b/arch/arm/kernel/dma.c @@ -21,6 +21,7 @@ #include DEFINE_SPINLOCK(dma_spin_lock); +EXPORT_SYMBOL(dma_spin_lock); static dma_t dma_chan[MAX_DMA_CHANNELS]; @@ -77,6 +78,7 @@ bad_dma: busy: return -EBUSY; } +EXPORT_SYMBOL(request_dma); /* * Free DMA channel @@ -108,6 +110,7 @@ void free_dma(dmach_t channel) bad_dma: printk(KERN_ERR "dma: trying to free DMA%d\n", channel); } +EXPORT_SYMBOL(free_dma); /* Set DMA Scatter-Gather list */ @@ -123,6 +126,7 @@ void set_dma_sg (dmach_t channel, struct scatterlist *sg, int nr_sg) dma->sgcount = nr_sg; dma->invalid = 1; } +EXPORT_SYMBOL(set_dma_sg); /* Set DMA address * @@ -140,6 +144,7 @@ void __set_dma_addr (dmach_t channel, void *addr) dma->addr = addr; dma->invalid = 1; } +EXPORT_SYMBOL(__set_dma_addr); /* Set DMA byte count * @@ -157,6 +162,7 @@ void set_dma_count (dmach_t channel, unsigned long count) dma->count = count; dma->invalid = 1; } +EXPORT_SYMBOL(set_dma_count); /* Set DMA direction mode */ @@ -171,6 +177,7 @@ void set_dma_mode (dmach_t channel, dmamode_t mode) dma->dma_mode = mode; dma->invalid = 1; } +EXPORT_SYMBOL(set_dma_mode); /* Enable DMA channel */ @@ -191,6 +198,7 @@ free_dma: printk(KERN_ERR "dma%d: trying to enable free DMA\n", channel); BUG(); } +EXPORT_SYMBOL(enable_dma); /* Disable DMA channel */ @@ -211,6 +219,7 @@ free_dma: printk(KERN_ERR "dma%d: trying to disable free DMA\n", channel); BUG(); } +EXPORT_SYMBOL(disable_dma); /* * Is the specified DMA channel active? @@ -224,6 +233,7 @@ void set_dma_page(dmach_t channel, char pagenr) { printk(KERN_ERR "dma%d: trying to set_dma_page\n", channel); } +EXPORT_SYMBOL(set_dma_page); void set_dma_speed(dmach_t channel, int cycle_ns) { @@ -234,6 +244,7 @@ void set_dma_speed(dmach_t channel, int cycle_ns) ret = dma->d_ops->setspeed(channel, dma, cycle_ns); dma->speed = ret; } +EXPORT_SYMBOL(set_dma_speed); int get_dma_residue(dmach_t channel) { @@ -245,6 +256,7 @@ int get_dma_residue(dmach_t channel) return ret; } +EXPORT_SYMBOL(get_dma_residue); static int __init init_dma(void) { @@ -253,17 +265,3 @@ static int __init init_dma(void) } core_initcall(init_dma); - -EXPORT_SYMBOL(request_dma); -EXPORT_SYMBOL(free_dma); -EXPORT_SYMBOL(enable_dma); -EXPORT_SYMBOL(disable_dma); -EXPORT_SYMBOL(__set_dma_addr); -EXPORT_SYMBOL(set_dma_count); -EXPORT_SYMBOL(set_dma_mode); -EXPORT_SYMBOL(set_dma_page); -EXPORT_SYMBOL(get_dma_residue); -EXPORT_SYMBOL(set_dma_sg); -EXPORT_SYMBOL(set_dma_speed); - -EXPORT_SYMBOL(dma_spin_lock); -- cgit v0.10.2 From b3a962455b106a1677f91c754e5315753c3d44c3 Mon Sep 17 00:00:00 2001 From: Russell King Date: Wed, 4 Jan 2006 15:55:41 +0000 Subject: [ARM] Remove SA1100 PM prepare/finish ops These are empty, unnecessary functions, so remove them. Signed-off-by: Russell King diff --git a/arch/arm/mach-sa1100/pm.c b/arch/arm/mach-sa1100/pm.c index 59c7964..786c853 100644 --- a/arch/arm/mach-sa1100/pm.c +++ b/arch/arm/mach-sa1100/pm.c @@ -135,29 +135,11 @@ unsigned long sleep_phys_sp(void *sp) } /* - * Called after processes are frozen, but before we shut down devices. - */ -static int sa11x0_pm_prepare(suspend_state_t state) -{ - return 0; -} - -/* - * Called after devices are re-setup, but before processes are thawed. - */ -static int sa11x0_pm_finish(suspend_state_t state) -{ - return 0; -} - -/* * Set to PM_DISK_FIRMWARE so we can quickly veto suspend-to-disk. */ static struct pm_ops sa11x0_pm_ops = { .pm_disk_mode = PM_DISK_FIRMWARE, - .prepare = sa11x0_pm_prepare, .enter = sa11x0_pm_enter, - .finish = sa11x0_pm_finish, }; static int __init sa11x0_pm_init(void) -- cgit v0.10.2 From f7e8bbb8207c17afbd716e7e5fc785b78fa08571 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Wed, 4 Jan 2006 17:17:10 +0000 Subject: [ARM] 3192/1: Remove gpio_isr_line_clear() API from IXP4xx Patch from Deepak Saxena Other than interrupt masking purposes, this API is only used when configuring interrupt lines and this patch moves that functionality directly into the ixp4xx_set_irq_type() implementation as board level PCI code should not need to worry about those details. Signed-off-by: Deepak Saxena Signed-off-by: Russell King diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index f3c687c..9f33cb2 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c @@ -142,6 +142,8 @@ static int ixp4xx_set_irq_type(unsigned int irq, unsigned int type) *int_reg &= ~(IXP4XX_GPIO_STYLE_CLEAR << (line * IXP4XX_GPIO_STYLE_SIZE)); + *IXP4XX_GPIO_GPISR = (1 << line); + /* Set the new style */ *int_reg |= (int_style << (line * IXP4XX_GPIO_STYLE_SIZE)); @@ -169,7 +171,7 @@ static void ixp4xx_irq_ack(unsigned int irq) int line = (irq < 32) ? irq2gpio[irq] : -1; if (line >= 0) - gpio_line_isr_clear(line); + *IXP4XX_GPIO_GPISR = (1 << line); } /* diff --git a/arch/arm/mach-ixp4xx/coyote-pci.c b/arch/arm/mach-ixp4xx/coyote-pci.c index 60de8a9..e6b7fcd 100644 --- a/arch/arm/mach-ixp4xx/coyote-pci.c +++ b/arch/arm/mach-ixp4xx/coyote-pci.c @@ -33,9 +33,6 @@ void __init coyote_pci_preinit(void) set_irq_type(IRQ_COYOTE_PCI_SLOT0, IRQT_LOW); set_irq_type(IRQ_COYOTE_PCI_SLOT1, IRQT_LOW); - gpio_line_isr_clear(COYOTE_PCI_SLOT0_PIN); - gpio_line_isr_clear(COYOTE_PCI_SLOT1_PIN); - ixp4xx_pci_preinit(); } diff --git a/arch/arm/mach-ixp4xx/ixdp425-pci.c b/arch/arm/mach-ixp4xx/ixdp425-pci.c index f9a1d3e..da415d5 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-pci.c +++ b/arch/arm/mach-ixp4xx/ixdp425-pci.c @@ -32,11 +32,6 @@ void __init ixdp425_pci_preinit(void) set_irq_type(IRQ_IXDP425_PCI_INTC, IRQT_LOW); set_irq_type(IRQ_IXDP425_PCI_INTD, IRQT_LOW); - gpio_line_isr_clear(IXDP425_PCI_INTA_PIN); - gpio_line_isr_clear(IXDP425_PCI_INTB_PIN); - gpio_line_isr_clear(IXDP425_PCI_INTC_PIN); - gpio_line_isr_clear(IXDP425_PCI_INTD_PIN); - ixp4xx_pci_preinit(); } diff --git a/arch/arm/mach-ixp4xx/ixdpg425-pci.c b/arch/arm/mach-ixp4xx/ixdpg425-pci.c index fe5e766..526fb61 100644 --- a/arch/arm/mach-ixp4xx/ixdpg425-pci.c +++ b/arch/arm/mach-ixp4xx/ixdpg425-pci.c @@ -32,9 +32,6 @@ void __init ixdpg425_pci_preinit(void) set_irq_type(IRQ_IXP4XX_GPIO6, IRQT_LOW); set_irq_type(IRQ_IXP4XX_GPIO7, IRQT_LOW); - gpio_line_isr_clear(6); - gpio_line_isr_clear(7); - ixp4xx_pci_preinit(); } diff --git a/arch/arm/mach-ixp4xx/nslu2-pci.c b/arch/arm/mach-ixp4xx/nslu2-pci.c index a575f2e..ece8604 100644 --- a/arch/arm/mach-ixp4xx/nslu2-pci.c +++ b/arch/arm/mach-ixp4xx/nslu2-pci.c @@ -28,14 +28,6 @@ void __init nslu2_pci_preinit(void) set_irq_type(IRQ_NSLU2_PCI_INTB, IRQT_LOW); set_irq_type(IRQ_NSLU2_PCI_INTC, IRQT_LOW); - gpio_line_isr_clear(NSLU2_PCI_INTA_PIN); - gpio_line_isr_clear(NSLU2_PCI_INTB_PIN); - gpio_line_isr_clear(NSLU2_PCI_INTC_PIN); - - /* INTD is not configured as GPIO is used - * for the power input button. - */ - ixp4xx_pci_preinit(); } diff --git a/arch/arm/mach-ixp4xx/nslu2-power.c b/arch/arm/mach-ixp4xx/nslu2-power.c index 18fbc8c..b0ad9e9 100644 --- a/arch/arm/mach-ixp4xx/nslu2-power.c +++ b/arch/arm/mach-ixp4xx/nslu2-power.c @@ -54,9 +54,6 @@ static int __init nslu2_power_init(void) set_irq_type(NSLU2_RB_IRQ, IRQT_LOW); set_irq_type(NSLU2_PB_IRQ, IRQT_HIGH); - gpio_line_isr_clear(NSLU2_RB_GPIO); - gpio_line_isr_clear(NSLU2_PB_GPIO); - if (request_irq(NSLU2_RB_IRQ, &nslu2_reset_handler, SA_INTERRUPT, "NSLU2 reset button", NULL) < 0) { diff --git a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h index f14ed63..6b77ed2 100644 --- a/include/asm-arm/arch-ixp4xx/platform.h +++ b/include/asm-arm/arch-ixp4xx/platform.h @@ -112,10 +112,5 @@ static inline void gpio_line_set(u8 line, int value) *IXP4XX_GPIO_GPOUTR &= ~(1 << line); } -static inline void gpio_line_isr_clear(u8 line) -{ - *IXP4XX_GPIO_GPISR = (1 << line); -} - #endif // __ASSEMBLY__ -- cgit v0.10.2 From 3145d8a6cc83ee15adf18f598873e53a54cd1841 Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Wed, 4 Jan 2006 17:17:11 +0000 Subject: [ARM] 3215/1: Iomega NAS 100d (MACH_NAS100D) machine support Patch from Rod Whitby This patch adds support for a new arm/ixp4xx machine - the Iomega NAS 100d network attached storage product. The NAS100D is a consumer device containing a 266MHz Intel IXP420 processor, 16MB of flash, 64MB of RAM, a 160Gb internal IDE hard disk, and 802.11b/g wireless on an Atheros mini-PCI card. Work on porting the latest 2.6.x kernel to this device is being done by the NSLU2-Linux project (the same team who maintains the port to the Linksys NSLU2 device). In particular, the majority of this patch was authored by Alessandro Zummo, based on the work done for MACH_NSLU2 support by the NSLU2-Linux core team of developers. MACH_NAS100D (as implemented by this patch) can be enabled in jumbo ixp4xx kernels without any affect on the other machines supported by that kernel. This patch applies cleanly against 2.6.15-rc7 and should be trivial to apply to later kernel versions. It does not depend upon any other patches. Modified files (and number of lines inserted): arch/arm/mach-ixp4xx/Kconfig | 8 arch/arm/mach-ixp4xx/Makefile | 1 include/asm-arm/arch-ixp4xx/hardware.h | 1 include/asm-arm/arch-ixp4xx/irqs.h | 9 include/asm-arm/arch-ixp4xx/nas100d.h | 75 arch/arm/mach-ixp4xx/nas100d-pci.c | 77 arch/arm/mach-ixp4xx/nas100d-power.c | 69 arch/arm/mach-ixp4xx/nas100d-setup.c | 133 -- Rod Whitby (NSLU2-Linux project lead) Signed-off-by: Rod Whitby Signed-off-by: Alessandro Zummo Signed-off-by: Russell King diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig index 3852858..daadc78 100644 --- a/arch/arm/mach-ixp4xx/Kconfig +++ b/arch/arm/mach-ixp4xx/Kconfig @@ -71,6 +71,14 @@ config ARCH_PRPMC1100 PrPCM1100 Processor Mezanine Module. For more information on this platform, see . +config MACH_NAS100D + bool + prompt "NAS100D" + help + Say 'Y' here if you want your kernel to support Iomega's + NAS 100d device. For more information on this platform, + see http://www.nslu2-linux.org/wiki/NAS100d/HomePage + # # Avila and IXDP share the same source for now. Will change in future # diff --git a/arch/arm/mach-ixp4xx/Makefile b/arch/arm/mach-ixp4xx/Makefile index 7a15629..0471044 100644 --- a/arch/arm/mach-ixp4xx/Makefile +++ b/arch/arm/mach-ixp4xx/Makefile @@ -9,4 +9,5 @@ obj-$(CONFIG_MACH_IXDPG425) += ixdpg425-pci.o coyote-setup.o obj-$(CONFIG_ARCH_ADI_COYOTE) += coyote-pci.o coyote-setup.o obj-$(CONFIG_MACH_GTWX5715) += gtwx5715-pci.o gtwx5715-setup.o obj-$(CONFIG_MACH_NSLU2) += nslu2-pci.o nslu2-setup.o nslu2-power.o +obj-$(CONFIG_MACH_NAS100D) += nas100d-pci.o nas100d-setup.o nas100d-power.o diff --git a/arch/arm/mach-ixp4xx/nas100d-pci.c b/arch/arm/mach-ixp4xx/nas100d-pci.c new file mode 100644 index 0000000..9bd0294 --- /dev/null +++ b/arch/arm/mach-ixp4xx/nas100d-pci.c @@ -0,0 +1,77 @@ +/* + * arch/arm/mach-ixp4xx/nas100d-pci.c + * + * NAS 100d board-level PCI initialization + * + * based on ixdp425-pci.c: + * Copyright (C) 2002 Intel Corporation. + * Copyright (C) 2003-2004 MontaVista Software, Inc. + * + * Maintainer: http://www.nslu2-linux.org/ + * + * 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 +#include +#include + +#include +#include + +void __init nas100d_pci_preinit(void) +{ + set_irq_type(IRQ_NAS100D_PCI_INTA, IRQT_LOW); + set_irq_type(IRQ_NAS100D_PCI_INTB, IRQT_LOW); + set_irq_type(IRQ_NAS100D_PCI_INTC, IRQT_LOW); + set_irq_type(IRQ_NAS100D_PCI_INTD, IRQT_LOW); + set_irq_type(IRQ_NAS100D_PCI_INTE, IRQT_LOW); + + gpio_line_isr_clear(NAS100D_PCI_INTA_PIN); + gpio_line_isr_clear(NAS100D_PCI_INTB_PIN); + gpio_line_isr_clear(NAS100D_PCI_INTC_PIN); + gpio_line_isr_clear(NAS100D_PCI_INTD_PIN); + gpio_line_isr_clear(NAS100D_PCI_INTE_PIN); + + ixp4xx_pci_preinit(); +} + +static int __init nas100d_map_irq(struct pci_dev *dev, u8 slot, u8 pin) +{ + static int pci_irq_table[NAS100D_PCI_MAX_DEV][NAS100D_PCI_IRQ_LINES] = + { + { IRQ_NAS100D_PCI_INTA, -1, -1 }, + { IRQ_NAS100D_PCI_INTB, -1, -1 }, + { IRQ_NAS100D_PCI_INTC, IRQ_NAS100D_PCI_INTD, IRQ_NAS100D_PCI_INTE }, + }; + + int irq = -1; + + if (slot >= 1 && slot <= NAS100D_PCI_MAX_DEV && + pin >= 1 && pin <= NAS100D_PCI_IRQ_LINES) + irq = pci_irq_table[slot-1][pin-1]; + + return irq; +} + +struct hw_pci __initdata nas100d_pci = { + .nr_controllers = 1, + .preinit = nas100d_pci_preinit, + .swizzle = pci_std_swizzle, + .setup = ixp4xx_setup, + .scan = ixp4xx_scan_bus, + .map_irq = nas100d_map_irq, +}; + +int __init nas100d_pci_init(void) +{ + if (machine_is_nas100d()) + pci_common_init(&nas100d_pci); + + return 0; +} + +subsys_initcall(nas100d_pci_init); diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c new file mode 100644 index 0000000..c74a190 --- /dev/null +++ b/arch/arm/mach-ixp4xx/nas100d-power.c @@ -0,0 +1,69 @@ +/* + * arch/arm/mach-ixp4xx/nas100d-power.c + * + * NAS 100d Power/Reset driver + * + * Copyright (C) 2005 Tower Technologies + * + * based on nas100d-io.c + * Copyright (C) 2004 Karen Spearel + * + * Author: Alessandro Zummo + * Maintainers: http://www.nslu2-linux.org/ + * + * 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 +#include +#include + +#include + +extern void ctrl_alt_del(void); + +static irqreturn_t nas100d_reset_handler(int irq, void *dev_id, struct pt_regs *regs) +{ + /* Signal init to do the ctrlaltdel action, this will bypass init if + * it hasn't started and do a kernel_restart. + */ + ctrl_alt_del(); + + return IRQ_HANDLED; +} + +static int __init nas100d_power_init(void) +{ + if (!(machine_is_nas100d())) + return 0; + + set_irq_type(NAS100D_RB_IRQ, IRQT_LOW); + + gpio_line_isr_clear(NAS100D_RB_GPIO); + + if (request_irq(NAS100D_RB_IRQ, &nas100d_reset_handler, + SA_INTERRUPT, "NAS100D reset button", NULL) < 0) { + + printk(KERN_DEBUG "Reset Button IRQ %d not available\n", + NAS100D_RB_IRQ); + + return -EIO; + } + + return 0; +} + +static void __exit nas100d_power_exit(void) +{ + free_irq(NAS100D_RB_IRQ, NULL); +} + +module_init(nas100d_power_init); +module_exit(nas100d_power_exit); + +MODULE_AUTHOR("Alessandro Zummo "); +MODULE_DESCRIPTION("NAS100D Power/Reset driver"); +MODULE_LICENSE("GPL"); diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c new file mode 100644 index 0000000..bde9648 --- /dev/null +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c @@ -0,0 +1,133 @@ +/* + * arch/arm/mach-ixp4xx/nas100d-setup.c + * + * NAS 100d board-setup + * + * based ixdp425-setup.c: + * Copyright (C) 2003-2004 MontaVista Software, Inc. + * + * Author: Alessandro Zummo + * Author: Rod Whitby + * Maintainers: http://www.nslu2-linux.org/ + * + */ + +#include +#include +#include + +#include +#include +#include + +static struct flash_platform_data nas100d_flash_data = { + .map_name = "cfi_probe", + .width = 2, +}; + +static struct resource nas100d_flash_resource = { + .start = NAS100D_FLASH_BASE, + .end = NAS100D_FLASH_BASE + NAS100D_FLASH_SIZE, + .flags = IORESOURCE_MEM, +}; + +static struct platform_device nas100d_flash = { + .name = "IXP4XX-Flash", + .id = 0, + .dev.platform_data = &nas100d_flash_data, + .num_resources = 1, + .resource = &nas100d_flash_resource, +}; + +static struct ixp4xx_i2c_pins nas100d_i2c_gpio_pins = { + .sda_pin = NAS100D_SDA_PIN, + .scl_pin = NAS100D_SCL_PIN, +}; + +static struct platform_device nas100d_i2c_controller = { + .name = "IXP4XX-I2C", + .id = 0, + .dev.platform_data = &nas100d_i2c_gpio_pins, + .num_resources = 0, +}; + +static struct resource nas100d_uart_resources[] = { + { + .start = IXP4XX_UART1_BASE_PHYS, + .end = IXP4XX_UART1_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + }, + { + .start = IXP4XX_UART2_BASE_PHYS, + .end = IXP4XX_UART2_BASE_PHYS + 0x0fff, + .flags = IORESOURCE_MEM, + } +}; + +static struct plat_serial8250_port nas100d_uart_data[] = { + { + .mapbase = IXP4XX_UART1_BASE_PHYS, + .membase = (char *)IXP4XX_UART1_BASE_VIRT + REG_OFFSET, + .irq = IRQ_IXP4XX_UART1, + .flags = UPF_BOOT_AUTOCONF, + .iotype = UPIO_MEM, + .regshift = 2, + .uartclk = IXP4XX_UART_XTAL, + }, + { + .mapbase = IXP4XX_UART2_BASE_PHYS, + .membase = (char *)IXP4XX_UART2_BASE_VIRT + REG_OFFSET, + .irq = IRQ_IXP4XX_UART2, + .flags = UPF_BOOT_AUTOCONF, + .iotype = UPIO_MEM, + .regshift = 2, + .uartclk = IXP4XX_UART_XTAL, + }, + { } +}; + +static struct platform_device nas100d_uart = { + .name = "serial8250", + .id = PLAT8250_DEV_PLATFORM, + .dev.platform_data = nas100d_uart_data, + .num_resources = 2, + .resource = nas100d_uart_resources, +}; + +static struct platform_device *nas100d_devices[] __initdata = { + &nas100d_i2c_controller, + &nas100d_flash, + &nas100d_uart, +}; + +static void nas100d_power_off(void) +{ + /* This causes the box to drop the power and go dead. */ + + /* enable the pwr cntl gpio */ + gpio_line_config(NAS100D_PO_GPIO, IXP4XX_GPIO_OUT); + + /* do the deed */ + gpio_line_set(NAS100D_PO_GPIO, IXP4XX_GPIO_HIGH); +} + +static void __init nas100d_init(void) +{ + ixp4xx_sys_init(); + + pm_power_off = nas100d_power_off; + + platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); +} + +MACHINE_START(NAS100D, "Iomega NAS 100d") + /* Maintainer: www.nslu2-linux.org */ + .phys_ram = PHYS_OFFSET, + .phys_io = IXP4XX_PERIPHERAL_BASE_PHYS, + .io_pg_offst = ((IXP4XX_PERIPHERAL_BASE_VIRT) >> 18) & 0xFFFC, + .boot_params = 0x00000100, + .map_io = ixp4xx_map_io, + .init_irq = ixp4xx_init_irq, + .timer = &ixp4xx_timer, + .init_machine = nas100d_init, +MACHINE_END diff --git a/include/asm-arm/arch-ixp4xx/hardware.h b/include/asm-arm/arch-ixp4xx/hardware.h index cfb413c..6acb69c 100644 --- a/include/asm-arm/arch-ixp4xx/hardware.h +++ b/include/asm-arm/arch-ixp4xx/hardware.h @@ -45,5 +45,6 @@ extern unsigned int processor_id; #include "coyote.h" #include "prpmc1100.h" #include "nslu2.h" +#include "nas100d.h" #endif /* _ASM_ARCH_HARDWARE_H */ diff --git a/include/asm-arm/arch-ixp4xx/irqs.h b/include/asm-arm/arch-ixp4xx/irqs.h index 2cf4930..f24b763 100644 --- a/include/asm-arm/arch-ixp4xx/irqs.h +++ b/include/asm-arm/arch-ixp4xx/irqs.h @@ -100,4 +100,13 @@ #define IRQ_NSLU2_PCI_INTB IRQ_IXP4XX_GPIO10 #define IRQ_NSLU2_PCI_INTC IRQ_IXP4XX_GPIO9 +/* + * NAS100D board IRQs + */ +#define IRQ_NAS100D_PCI_INTA IRQ_IXP4XX_GPIO11 +#define IRQ_NAS100D_PCI_INTB IRQ_IXP4XX_GPIO10 +#define IRQ_NAS100D_PCI_INTC IRQ_IXP4XX_GPIO9 +#define IRQ_NAS100D_PCI_INTD IRQ_IXP4XX_GPIO8 +#define IRQ_NAS100D_PCI_INTE IRQ_IXP4XX_GPIO7 + #endif diff --git a/include/asm-arm/arch-ixp4xx/nas100d.h b/include/asm-arm/arch-ixp4xx/nas100d.h new file mode 100644 index 0000000..ce7a86a --- /dev/null +++ b/include/asm-arm/arch-ixp4xx/nas100d.h @@ -0,0 +1,75 @@ +/* + * include/asm-arm/arch-ixp4xx/nas100d.h + * + * NAS100D platform specific definitions + * + * Copyright (c) 2005 Tower Technologies + * + * Author: Alessandro Zummo + * + * based on ixdp425.h: + * Copyright 2004 (c) MontaVista, Software, Inc. + * + * This file is licensed under the terms of the GNU General Public + * License version 2. This program is licensed "as is" without any + * warranty of any kind, whether express or implied. + */ + +#ifndef __ASM_ARCH_HARDWARE_H__ +#error "Do not include this directly, instead #include " +#endif + +#define NAS100D_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS +#define NAS100D_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE + +#define NAS100D_SDA_PIN 6 +#define NAS100D_SCL_PIN 5 + +/* + * NAS100D PCI IRQs + */ +#define NAS100D_PCI_MAX_DEV 3 +#define NAS100D_PCI_IRQ_LINES 3 + + +/* PCI controller GPIO to IRQ pin mappings */ +#define NAS100D_PCI_INTA_PIN 11 +#define NAS100D_PCI_INTB_PIN 10 +#define NAS100D_PCI_INTC_PIN 9 +#define NAS100D_PCI_INTD_PIN 8 +#define NAS100D_PCI_INTE_PIN 7 + +/* GPIO */ + +#define NAS100D_GPIO0 0 +#define NAS100D_GPIO1 1 +#define NAS100D_GPIO2 2 +#define NAS100D_GPIO3 3 +#define NAS100D_GPIO4 4 +#define NAS100D_GPIO5 5 +#define NAS100D_GPIO6 6 +#define NAS100D_GPIO7 7 +#define NAS100D_GPIO8 8 +#define NAS100D_GPIO9 9 +#define NAS100D_GPIO10 10 +#define NAS100D_GPIO11 11 +#define NAS100D_GPIO12 12 +#define NAS100D_GPIO13 13 +#define NAS100D_GPIO14 14 +#define NAS100D_GPIO15 15 + + +/* Buttons */ + +#define NAS100D_PB_GPIO NAS100D_GPIO14 +#define NAS100D_RB_GPIO NAS100D_GPIO4 +#define NAS100D_PO_GPIO NAS100D_GPIO12 /* power off */ + +#define NAS100D_PB_IRQ IRQ_IXP4XX_GPIO14 +#define NAS100D_RB_IRQ IRQ_IXP4XX_GPIO4 + +/* +#define NAS100D_PB_BM (1L << NAS100D_PB_GPIO) +#define NAS100D_PO_BM (1L << NAS100D_PO_GPIO) +#define NAS100D_RB_BM (1L << NAS100D_RB_GPIO) +*/ -- cgit v0.10.2 From 8d27e6992bc6a7ca7eaa1d29fb1a8d6cb6022c45 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Wed, 4 Jan 2006 17:17:12 +0000 Subject: [ARM] 3220/1: Remove gpio_isr_line_clear() from NAS 100d Patch from Deepak Saxena This patch removes referneces to gpio_isr_line_clear() from the NAS 100d platform implementation. Depends on 3192/1 and 3215/1 Signed-off-by: Deepak Saxena Signed-off-by: Russell King diff --git a/arch/arm/mach-ixp4xx/nas100d-pci.c b/arch/arm/mach-ixp4xx/nas100d-pci.c index 9bd0294..26b7c00 100644 --- a/arch/arm/mach-ixp4xx/nas100d-pci.c +++ b/arch/arm/mach-ixp4xx/nas100d-pci.c @@ -30,12 +30,6 @@ void __init nas100d_pci_preinit(void) set_irq_type(IRQ_NAS100D_PCI_INTD, IRQT_LOW); set_irq_type(IRQ_NAS100D_PCI_INTE, IRQT_LOW); - gpio_line_isr_clear(NAS100D_PCI_INTA_PIN); - gpio_line_isr_clear(NAS100D_PCI_INTB_PIN); - gpio_line_isr_clear(NAS100D_PCI_INTC_PIN); - gpio_line_isr_clear(NAS100D_PCI_INTD_PIN); - gpio_line_isr_clear(NAS100D_PCI_INTE_PIN); - ixp4xx_pci_preinit(); } diff --git a/arch/arm/mach-ixp4xx/nas100d-power.c b/arch/arm/mach-ixp4xx/nas100d-power.c index c74a190..2bec69b 100644 --- a/arch/arm/mach-ixp4xx/nas100d-power.c +++ b/arch/arm/mach-ixp4xx/nas100d-power.c @@ -42,8 +42,6 @@ static int __init nas100d_power_init(void) set_irq_type(NAS100D_RB_IRQ, IRQT_LOW); - gpio_line_isr_clear(NAS100D_RB_GPIO); - if (request_irq(NAS100D_RB_IRQ, &nas100d_reset_handler, SA_INTERRUPT, "NAS100D reset button", NULL) < 0) { -- cgit v0.10.2 From 313cbb5519405966e3e65fca86c0305ab24f2a3b Mon Sep 17 00:00:00 2001 From: Rod Whitby Date: Wed, 4 Jan 2006 17:17:13 +0000 Subject: [ARM] 3218/1: PAGE_SHIFT undeclared in arch-ixp4xx/memory.h (adjust_zones moved out of line) Patch from Rod Whitby PAGE_SHIFT is undeclared in include/asm-arm/arch-ixp4xx/memory.h, identified by the following kernel compilation error: CC [M] sound/core/memory.o In file included from include/asm/memory.h:27, from include/asm/io.h:28, from sound/core/memory.c:24: include/asm/arch/memory.h: In function `__arch_adjust_zones': include/asm/arch/memory.h:28: error: `PAGE_SHIFT' undeclared (first use in this function) This patch replaces my previous attempt at fixing this problem (Patch 3214/1) and is based on the following feedback: Russell King wrote: > The error you see came up on SA1100. The best solution was to move > the __arch_adjust_zones() function out of line. I suggest ixp4xx > does the same. I have moved the function out of line into arch/arm/mach-ixp4xx/common-pci.c as suggested. Signed-off-by: Rod Whitby Signed-off-by: Deepak Saxena Signed-off-by: Russell King diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c index 9795da2..6e3462e 100644 --- a/arch/arm/mach-ixp4xx/common-pci.c +++ b/arch/arm/mach-ixp4xx/common-pci.c @@ -341,6 +341,29 @@ int dma_needs_bounce(struct device *dev, dma_addr_t dma_addr, size_t size) return (dev->bus == &pci_bus_type ) && ((dma_addr + size) >= SZ_64M); } +/* + * Only first 64MB of memory can be accessed via PCI. + * We use GFP_DMA to allocate safe buffers to do map/unmap. + * This is really ugly and we need a better way of specifying + * DMA-capable regions of memory. + */ +void __init ixp4xx_adjust_zones(int node, unsigned long *zone_size, + unsigned long *zhole_size) +{ + unsigned int sz = SZ_64M >> PAGE_SHIFT; + + /* + * Only adjust if > 64M on current system + */ + if (node || (zone_size[0] <= sz)) + return; + + zone_size[1] = zone_size[0] - sz; + zone_size[0] = sz; + zhole_size[1] = zhole_size[0]; + zhole_size[0] = 0; +} + void __init ixp4xx_pci_preinit(void) { unsigned long processor_id; diff --git a/include/asm-arm/arch-ixp4xx/memory.h b/include/asm-arm/arch-ixp4xx/memory.h index e024d0a..ee211d2 100644 --- a/include/asm-arm/arch-ixp4xx/memory.h +++ b/include/asm-arm/arch-ixp4xx/memory.h @@ -16,31 +16,10 @@ #ifndef __ASSEMBLY__ -/* - * Only first 64MB of memory can be accessed via PCI. - * We use GFP_DMA to allocate safe buffers to do map/unmap. - * This is really ugly and we need a better way of specifying - * DMA-capable regions of memory. - */ -static inline void __arch_adjust_zones(int node, unsigned long *zone_size, - unsigned long *zhole_size) -{ - unsigned int sz = SZ_64M >> PAGE_SHIFT; - - /* - * Only adjust if > 64M on current system - */ - if (node || (zone_size[0] <= sz)) - return; - - zone_size[1] = zone_size[0] - sz; - zone_size[0] = sz; - zhole_size[1] = zhole_size[0]; - zhole_size[0] = 0; -} +void ixp4xx_adjust_zones(int node, unsigned long *size, unsigned long *holes); #define arch_adjust_zones(node, size, holes) \ - __arch_adjust_zones(node, size, holes) + ixp4xx_adjust_zones(node, size, holes) #define ISA_DMA_THRESHOLD (SZ_64M - 1) -- cgit v0.10.2 From b1ad3a57d39001af413414c34feb5cd41d0f7917 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Wed, 4 Jan 2006 17:17:14 +0000 Subject: [ARM] 3221/1: Update IXP4xx defconfig Patch from Deepak Saxena Add NAS 100d to machine build list and update to new 2.6.15 options. Signed-off-by: Deepak Saxena --- Signed-off-by: Russell King diff --git a/arch/arm/configs/ixp4xx_defconfig b/arch/arm/configs/ixp4xx_defconfig index f74c926..613afab 100644 --- a/arch/arm/configs/ixp4xx_defconfig +++ b/arch/arm/configs/ixp4xx_defconfig @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit -# Linux kernel version: 2.6.14-rc1-git5 -# Tue Sep 20 17:26:28 2005 +# Linux kernel version: 2.6.15 +# Tue Jan 3 03:20:40 2006 # CONFIG_ARM=y CONFIG_MMU=y @@ -33,6 +33,7 @@ CONFIG_SYSCTL=y CONFIG_KOBJECT_UEVENT=y # CONFIG_IKCONFIG is not set CONFIG_INITRAMFS_SOURCE="" +CONFIG_CC_OPTIMIZE_FOR_SIZE=y CONFIG_EMBEDDED=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_ALL is not set @@ -42,7 +43,6 @@ CONFIG_BUG=y CONFIG_BASE_FULL=y CONFIG_FUTEX=y CONFIG_EPOLL=y -CONFIG_CC_OPTIMIZE_FOR_SIZE=y CONFIG_SHMEM=y CONFIG_CC_ALIGN_FUNCTIONS=0 CONFIG_CC_ALIGN_LABELS=0 @@ -62,6 +62,23 @@ CONFIG_MODVERSIONS=y CONFIG_KMOD=y # +# Block layer +# + +# +# IO Schedulers +# +CONFIG_IOSCHED_NOOP=y +CONFIG_IOSCHED_AS=y +CONFIG_IOSCHED_DEADLINE=y +CONFIG_IOSCHED_CFQ=y +CONFIG_DEFAULT_AS=y +# CONFIG_DEFAULT_DEADLINE is not set +# CONFIG_DEFAULT_CFQ is not set +# CONFIG_DEFAULT_NOOP is not set +CONFIG_DEFAULT_IOSCHED="anticipatory" + +# # System Type # # CONFIG_ARCH_CLPS7500 is not set @@ -83,6 +100,7 @@ CONFIG_ARCH_IXP4XX=y # CONFIG_ARCH_LH7A40X is not set # CONFIG_ARCH_OMAP is not set # CONFIG_ARCH_VERSATILE is not set +# CONFIG_ARCH_REALVIEW is not set # CONFIG_ARCH_IMX is not set # CONFIG_ARCH_H720X is not set # CONFIG_ARCH_AAEC2000 is not set @@ -102,6 +120,7 @@ CONFIG_MACH_IXDPG425=y CONFIG_MACH_IXDP465=y CONFIG_ARCH_IXCDP1100=y CONFIG_ARCH_PRPMC1100=y +CONFIG_MACH_NAS100D=y CONFIG_ARCH_IXDP4XX=y CONFIG_CPU_IXP46X=y # CONFIG_MACH_GTWX5715 is not set @@ -155,6 +174,7 @@ CONFIG_FLATMEM_MANUAL=y CONFIG_FLATMEM=y CONFIG_FLAT_NODE_MEM_MAP=y # CONFIG_SPARSEMEM_STATIC is not set +CONFIG_SPLIT_PTLOCK_CPUS=4096 CONFIG_ALIGNMENT_TRAP=y # @@ -173,6 +193,7 @@ CONFIG_CMDLINE="console=ttyS0,115200 ip=bootp root=/dev/nfs" # At least one emulation must be selected # CONFIG_FPE_NWFPE=y +# CONFIG_FPE_NWFPE_XP is not set # CONFIG_FPE_FASTFPE is not set # @@ -187,6 +208,8 @@ CONFIG_BINFMT_ELF=y # Power management options # CONFIG_PM=y +CONFIG_PM_LEGACY=y +# CONFIG_PM_DEBUG is not set CONFIG_APM=y # @@ -271,6 +294,10 @@ CONFIG_IP_VS_SH=m CONFIG_NETFILTER=y # CONFIG_NETFILTER_DEBUG is not set CONFIG_BRIDGE_NETFILTER=y + +# +# Core Netfilter Configuration +# # CONFIG_NETFILTER_NETLINK is not set # @@ -286,6 +313,7 @@ CONFIG_IP_NF_IRC=m # CONFIG_IP_NF_NETBIOS_NS is not set # CONFIG_IP_NF_TFTP is not set # CONFIG_IP_NF_AMANDA is not set +# CONFIG_IP_NF_PPTP is not set CONFIG_IP_NF_QUEUE=m CONFIG_IP_NF_IPTABLES=m CONFIG_IP_NF_MATCH_LIMIT=m @@ -319,6 +347,7 @@ CONFIG_IP_NF_TARGET_REJECT=m CONFIG_IP_NF_TARGET_LOG=m CONFIG_IP_NF_TARGET_ULOG=m CONFIG_IP_NF_TARGET_TCPMSS=m +# CONFIG_IP_NF_TARGET_NFQUEUE is not set CONFIG_IP_NF_NAT=m CONFIG_IP_NF_NAT_NEEDED=y CONFIG_IP_NF_TARGET_MASQUERADE=m @@ -380,10 +409,18 @@ CONFIG_ECONET=m CONFIG_ECONET_AUNUDP=y CONFIG_ECONET_NATIVE=y CONFIG_WAN_ROUTER=m + +# +# QoS and/or fair queueing +# CONFIG_NET_SCHED=y CONFIG_NET_SCH_CLK_JIFFIES=y # CONFIG_NET_SCH_CLK_GETTIMEOFDAY is not set # CONFIG_NET_SCH_CLK_CPU is not set + +# +# Queueing/Scheduling +# CONFIG_NET_SCH_CBQ=m CONFIG_NET_SCH_HTB=m # CONFIG_NET_SCH_HFSC is not set @@ -397,8 +434,10 @@ CONFIG_NET_SCH_GRED=m CONFIG_NET_SCH_DSMARK=m # CONFIG_NET_SCH_NETEM is not set CONFIG_NET_SCH_INGRESS=m -CONFIG_NET_QOS=y -CONFIG_NET_ESTIMATOR=y + +# +# Classification +# CONFIG_NET_CLS=y # CONFIG_NET_CLS_BASIC is not set CONFIG_NET_CLS_TCINDEX=m @@ -407,13 +446,14 @@ CONFIG_NET_CLS_ROUTE=y CONFIG_NET_CLS_FW=m CONFIG_NET_CLS_U32=m # CONFIG_CLS_U32_PERF is not set -# CONFIG_NET_CLS_IND is not set # CONFIG_CLS_U32_MARK is not set CONFIG_NET_CLS_RSVP=m CONFIG_NET_CLS_RSVP6=m # CONFIG_NET_EMATCH is not set # CONFIG_NET_CLS_ACT is not set CONFIG_NET_CLS_POLICE=y +# CONFIG_NET_CLS_IND is not set +CONFIG_NET_ESTIMATOR=y # # Network testing @@ -437,6 +477,11 @@ CONFIG_PREVENT_FIRMWARE_BUILD=y # CONFIG_DEBUG_DRIVER is not set # +# Connector - unified userspace <-> kernelspace linker +# +# CONFIG_CONNECTOR is not set + +# # Memory Technology Devices (MTD) # CONFIG_MTD=y @@ -458,6 +503,7 @@ CONFIG_MTD_BLOCK=y # CONFIG_FTL is not set # CONFIG_NFTL is not set # CONFIG_INFTL is not set +# CONFIG_RFD_FTL is not set # # RAM/ROM/Flash chip drivers @@ -492,7 +538,6 @@ CONFIG_MTD_COMPLEX_MAPPINGS=y # CONFIG_MTD_PHYSMAP is not set # CONFIG_MTD_ARM_INTEGRATOR is not set CONFIG_MTD_IXP4XX=y -# CONFIG_MTD_EDB7312 is not set # CONFIG_MTD_PCI is not set # CONFIG_MTD_PLATRAM is not set @@ -523,6 +568,11 @@ CONFIG_MTD_NAND_IDS=m # CONFIG_MTD_NAND_NANDSIM is not set # +# OneNAND Flash Device Drivers +# +# CONFIG_MTD_ONENAND is not set + +# # Parallel port support # # CONFIG_PARPORT is not set @@ -548,14 +598,6 @@ CONFIG_BLK_DEV_RAM_COUNT=16 CONFIG_BLK_DEV_RAM_SIZE=8192 CONFIG_BLK_DEV_INITRD=y # CONFIG_CDROM_PKTCDVD is not set - -# -# IO Schedulers -# -CONFIG_IOSCHED_NOOP=y -CONFIG_IOSCHED_AS=y -CONFIG_IOSCHED_DEADLINE=y -CONFIG_IOSCHED_CFQ=y # CONFIG_ATA_OVER_ETH is not set # @@ -668,6 +710,7 @@ CONFIG_NET_ETHERNET=y CONFIG_MII=y # CONFIG_HAPPYMEAL is not set # CONFIG_SUNGEM is not set +# CONFIG_CASSINI is not set # CONFIG_NET_VENDOR_3COM is not set # CONFIG_SMC91X is not set # CONFIG_DM9000 is not set @@ -739,6 +782,7 @@ CONFIG_NET_RADIO=y # # Wireless 802.11b ISA/PCI cards support # +# CONFIG_AIRO is not set CONFIG_HERMES=y # CONFIG_PLX_HERMES is not set # CONFIG_TMD_HERMES is not set @@ -782,6 +826,7 @@ CONFIG_WAN_ROUTER_DRIVERS=y # # ATM drivers # +# CONFIG_ATM_DUMMY is not set CONFIG_ATM_TCP=m # CONFIG_ATM_LANAI is not set # CONFIG_ATM_ENI is not set @@ -902,6 +947,7 @@ CONFIG_IXP4XX_WATCHDOG=y # TPM devices # # CONFIG_TCG_TPM is not set +# CONFIG_TELCLOCK is not set # # I2C support @@ -954,6 +1000,7 @@ CONFIG_SENSORS_EEPROM=y # CONFIG_SENSORS_PCF8591 is not set # CONFIG_SENSORS_RTC8564 is not set # CONFIG_SENSORS_MAX6875 is not set +# CONFIG_RTC_X1205_I2C is not set # CONFIG_I2C_DEBUG_CORE is not set # CONFIG_I2C_DEBUG_ALGO is not set # CONFIG_I2C_DEBUG_BUS is not set @@ -1036,6 +1083,10 @@ CONFIG_USB_ARCH_HAS_OHCI=y # CONFIG_USB is not set # +# NOTE: USB_STORAGE enables SCSI, and 'SCSI disk support' +# + +# # USB Gadget Support # # CONFIG_USB_GADGET is not set @@ -1110,6 +1161,7 @@ CONFIG_RAMFS=y CONFIG_JFFS2_FS=y CONFIG_JFFS2_FS_DEBUG=0 CONFIG_JFFS2_FS_WRITEBUFFER=y +# CONFIG_JFFS2_SUMMARY is not set # CONFIG_JFFS2_COMPRESSION_OPTIONS is not set CONFIG_JFFS2_ZLIB=y CONFIG_JFFS2_RTIME=y @@ -1190,7 +1242,9 @@ CONFIG_DETECT_SOFTLOCKUP=y CONFIG_DEBUG_BUGVERBOSE=y # CONFIG_DEBUG_INFO is not set # CONFIG_DEBUG_FS is not set +# CONFIG_DEBUG_VM is not set CONFIG_FRAME_POINTER=y +# CONFIG_RCU_TORTURE_TEST is not set # CONFIG_DEBUG_USER is not set # CONFIG_DEBUG_WAITQ is not set CONFIG_DEBUG_ERRORS=y -- cgit v0.10.2 From b721243a6700b2ecc11f7b920d3d5d6718c5d148 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 4 Jan 2006 17:17:15 +0000 Subject: [ARM] 3223/1: remove ixdp2x01 cs89x0 hack Patch from Lennert Buytenhek Remove the ixdp2x01 cs89x0 hack from ixp2000's io implementation. Since the cs89x0 driver has been made properly aware of the odd way the cs89x0 is hooked up on the ixdp2x01, we don't need this hack anymore. Signed-off-by: Lennert Buytenhek Signed-off-by: Deepak Saxena Signed-off-by: Russell King diff --git a/include/asm-arm/arch-ixp2000/io.h b/include/asm-arm/arch-ixp2000/io.h index 7fbcdf9..c0ff2c6 100644 --- a/include/asm-arm/arch-ixp2000/io.h +++ b/include/asm-arm/arch-ixp2000/io.h @@ -131,102 +131,4 @@ #endif -#ifdef CONFIG_ARCH_IXDP2X01 -/* - * This is an ugly hack but the CS8900 on the 2x01's does not sit in any sort - * of "I/O space" and is just direct mapped into a 32-bit-only addressable - * bus. The address space for this bus is such that we can't really easily - * make it contiguous to the PCI I/O address range, and it also does not - * need swapping like PCI addresses do (IXDP2x01 is a BE platform). - * B/C of this we can't use the standard in/out functions and need to - * runtime check if the incoming address is a PCI address or for - * the CS89x0. - */ -#undef inw -#undef outw -#undef insw -#undef outsw - -#include - -static inline void insw(u32 ptr, void *buf, int length) -{ - register volatile u32 *port = (volatile u32 *)ptr; - - /* - * Is this cycle meant for the CS8900? - */ - if ((machine_is_ixdp2401() || machine_is_ixdp2801()) && - (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) && - ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) { - u8 *buf8 = (u8*)buf; - register u32 tmp32; - - do { - tmp32 = *port; - *buf8++ = (u8)tmp32; - *buf8++ = (u8)(tmp32 >> 8); - } while(--length); - - return; - } - - __raw_readsw(alignw(___io(ptr)),buf,length); -} - -static inline void outsw(u32 ptr, void *buf, int length) -{ - register volatile u32 *port = (volatile u32 *)ptr; - - /* - * Is this cycle meant for the CS8900? - */ - if ((machine_is_ixdp2401() || machine_is_ixdp2801()) && - (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) && - ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) { - register u32 tmp32; - u8 *buf8 = (u8*)buf; - do { - tmp32 = *buf8++; - tmp32 |= (*buf8++) << 8; - *port = tmp32; - } while(--length); - return; - } - - __raw_writesw(alignw(___io(ptr)),buf,length); -} - - -static inline u16 inw(u32 ptr) -{ - register volatile u32 *port = (volatile u32 *)ptr; - - /* - * Is this cycle meant for the CS8900? - */ - if ((machine_is_ixdp2401() || machine_is_ixdp2801()) && - (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) && - ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) { - return (u16)(*port); - } - - return __raw_readw(alignw(___io(ptr))); -} - -static inline void outw(u16 value, u32 ptr) -{ - register volatile u32 *port = (volatile u32 *)ptr; - - if ((machine_is_ixdp2401() || machine_is_ixdp2801()) && - (((u32)port >= (u32)IXDP2X01_CS8900_VIRT_BASE) && - ((u32)port <= (u32)IXDP2X01_CS8900_VIRT_END))) { - *port = value; - return; - } - - __raw_writew((value),alignw(___io(ptr))); -} -#endif /* IXDP2x01 */ - #endif -- cgit v0.10.2 From 7a94283a7e8cd8a4ea29bf2cfedba511c706b0b4 Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 4 Jan 2006 17:17:16 +0000 Subject: [ARM] 3224/1: add masked thread interrupt status registers for ixp2000 Patch from Lennert Buytenhek In its interrupt handler, the (NAPI) ixp2000 netdev driver needs to use the masked thread interrupt status register (instead of the raw one) to prevent scheduling polling when polling is already running when a TXdone interrupt comes in. The definitions for the masked status registers were not in yet, so this patch adds them. Signed-off-by: Lennert Buytenhek Signed-off-by: Russell King diff --git a/include/asm-arm/arch-ixp2000/ixp2000-regs.h b/include/asm-arm/arch-ixp2000/ixp2000-regs.h index fc5ac6a..8cf70ff 100644 --- a/include/asm-arm/arch-ixp2000/ixp2000-regs.h +++ b/include/asm-arm/arch-ixp2000/ixp2000-regs.h @@ -156,6 +156,14 @@ #define IXP2000_IRQ_THD_RAW_STATUS_B_1 IXP2000_INTCTL_REG(0x84) #define IXP2000_IRQ_THD_RAW_STATUS_B_2 IXP2000_INTCTL_REG(0x88) #define IXP2000_IRQ_THD_RAW_STATUS_B_3 IXP2000_INTCTL_REG(0x8c) +#define IXP2000_IRQ_THD_STATUS_A_0 IXP2000_INTCTL_REG(0xe0) +#define IXP2000_IRQ_THD_STATUS_A_1 IXP2000_INTCTL_REG(0xe4) +#define IXP2000_IRQ_THD_STATUS_A_2 IXP2000_INTCTL_REG(0xe8) +#define IXP2000_IRQ_THD_STATUS_A_3 IXP2000_INTCTL_REG(0xec) +#define IXP2000_IRQ_THD_STATUS_B_0 IXP2000_INTCTL_REG(0x100) +#define IXP2000_IRQ_THD_STATUS_B_1 IXP2000_INTCTL_REG(0x104) +#define IXP2000_IRQ_THD_STATUS_B_2 IXP2000_INTCTL_REG(0x108) +#define IXP2000_IRQ_THD_STATUS_B_3 IXP2000_INTCTL_REG(0x10c) #define IXP2000_IRQ_THD_ENABLE_SET_A_0 IXP2000_INTCTL_REG(0x160) #define IXP2000_IRQ_THD_ENABLE_SET_A_1 IXP2000_INTCTL_REG(0x164) #define IXP2000_IRQ_THD_ENABLE_SET_A_2 IXP2000_INTCTL_REG(0x168) -- cgit v0.10.2 From 4c70b926c91ba9c1ce3dc92d418f8e4670c8f16d Mon Sep 17 00:00:00 2001 From: Lennert Buytenhek Date: Wed, 4 Jan 2006 17:17:17 +0000 Subject: [ARM] 3225/1: add symbolic names for enp2611 gpio interrupts Patch from Lennert Buytenhek Add symbolic names for the five ixp2400 GPIO lines on the enp2611 that are used as interrupts. Signed-off-by: Lennert Buytenhek Signed-off-by: Russell King diff --git a/include/asm-arm/arch-ixp2000/enp2611.h b/include/asm-arm/arch-ixp2000/enp2611.h index 95128d9..42f3c28 100644 --- a/include/asm-arm/arch-ixp2000/enp2611.h +++ b/include/asm-arm/arch-ixp2000/enp2611.h @@ -36,5 +36,11 @@ #define ENP2611_GPIO_SCL 7 #define ENP2611_GPIO_SDA 6 +#define IRQ_ENP2611_THERMAL IRQ_IXP2000_GPIO4 +#define IRQ_ENP2611_OPTION_BOARD IRQ_IXP2000_GPIO3 +#define IRQ_ENP2611_CALEB IRQ_IXP2000_GPIO2 +#define IRQ_ENP2611_PM3386_1 IRQ_IXP2000_GPIO1 +#define IRQ_ENP2611_PM3386_0 IRQ_IXP2000_GPIO0 + #endif -- cgit v0.10.2 From 3125c68d70e3433c21234431a9df9e7336efa29f Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 20:44:52 +0000 Subject: [ARM] 3227/1: Spitz: Add pxa27x OHCI platform specific code Patch from Richard Purdie Add platform code to enable the ohci device on the pxa27x based Sharp Zaurus Cxx00 devices. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 2df1b56..5d34abc 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -335,6 +336,35 @@ static struct pxamci_platform_data spitz_mci_platform_data = { /* + * USB Host (OHCI) + */ +static int spitz_ohci_init(struct device *dev) +{ + /* Only Port 2 is connected */ + pxa_gpio_mode(SPITZ_GPIO_USB_CONNECT | GPIO_IN); + pxa_gpio_mode(SPITZ_GPIO_USB_HOST | GPIO_OUT); + pxa_gpio_mode(SPITZ_GPIO_USB_DEVICE | GPIO_IN); + + /* Setup USB Port 2 Output Control Register */ + UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; + + GPSR(SPITZ_GPIO_USB_HOST) = GPIO_bit(SPITZ_GPIO_USB_HOST); + + UHCHR = (UHCHR) & + ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); + + UHCRHDA |= UHCRHDA_NOCP; + + return 0; +} + +static struct pxaohci_platform_data spitz_ohci_platform_data = { + .port_mode = PMM_NPS_MODE, + .init = spitz_ohci_init, +}; + + +/* * Irda */ static void spitz_irda_transceiver_mode(struct device *dev, int mode) @@ -411,6 +441,7 @@ static void __init common_init(void) platform_add_devices(devices, ARRAY_SIZE(devices)); pxa_set_mci_info(&spitz_mci_platform_data); + pxa_set_ohci_info(&spitz_ohci_platform_data); pxa_set_ficp_info(&spitz_ficp_platform_data); set_pxa_fb_parent(&spitzssp_device.dev); set_pxa_fb_info(&spitz_pxafb_info); -- cgit v0.10.2 From b7557de41a04346cb545d4dda7088760cb96e713 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 20:44:55 +0000 Subject: [ARM] 3228/1: SharpSL: Move PM code to arch/arm/common Patch from Richard Purdie This patch moves a large chunk of the sharpsl_pm driver to arch/arm/common so that it can be reused on other devices such as the SL-5500 (collie). It also abstracts some functions from the core into the machine and platform specific parts of the driver to aid reuse. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig index 666ba39..d7509c7 100644 --- a/arch/arm/common/Kconfig +++ b/arch/arm/common/Kconfig @@ -23,5 +23,8 @@ config SHARP_LOCOMO config SHARP_PARAM bool +config SHARPSL_PM + bool + config SHARP_SCOOP bool diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index a878865..2685051 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile @@ -13,4 +13,5 @@ obj-$(CONFIG_DMABOUNCE) += dmabounce.o obj-$(CONFIG_TIMER_ACORN) += time-acorn.o obj-$(CONFIG_SHARP_LOCOMO) += locomo.o obj-$(CONFIG_SHARP_PARAM) += sharpsl_param.o +obj-$(CONFIG_SHARPSL_PM) += sharpsl_pm.o obj-$(CONFIG_SHARP_SCOOP) += scoop.o diff --git a/arch/arm/common/sharpsl_pm.c b/arch/arm/common/sharpsl_pm.c new file mode 100644 index 0000000..978d32e --- /dev/null +++ b/arch/arm/common/sharpsl_pm.c @@ -0,0 +1,839 @@ +/* + * Battery and Power Management code for the Sharp SL-C7xx and SL-Cxx00 + * series of PDAs + * + * Copyright (c) 2004-2005 Richard Purdie + * + * Based on code written by Sharp for 2.4 kernels + * + * 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. + * + */ + +#undef DEBUG + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Constants + */ +#define SHARPSL_CHARGE_ON_TIME_INTERVAL (msecs_to_jiffies(1*60*1000)) /* 1 min */ +#define SHARPSL_CHARGE_FINISH_TIME (msecs_to_jiffies(10*60*1000)) /* 10 min */ +#define SHARPSL_BATCHK_TIME (msecs_to_jiffies(15*1000)) /* 15 sec */ +#define SHARPSL_BATCHK_TIME_SUSPEND (60*10) /* 10 min */ +#define SHARPSL_WAIT_CO_TIME 15 /* 15 sec */ +#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */ +#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */ +#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */ +#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN 10 /* 10 msec */ +#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */ +#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */ +#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */ + +#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ +#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ +#define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */ +#define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */ +#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ +#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ + +/* + * Prototypes + */ +static int sharpsl_off_charge_battery(void); +static int sharpsl_check_battery_temp(void); +static int sharpsl_check_battery_voltage(void); +static int sharpsl_ac_check(void); +static int sharpsl_fatal_check(void); +static int sharpsl_average_value(int ad); +static void sharpsl_average_clear(void); +static void sharpsl_charge_toggle(void *private_); +static void sharpsl_battery_thread(void *private_); + + +/* + * Variables + */ +struct sharpsl_pm_status sharpsl_pm; +DECLARE_WORK(toggle_charger, sharpsl_charge_toggle, NULL); +DECLARE_WORK(sharpsl_bat, sharpsl_battery_thread, NULL); + + +static int get_percentage(int voltage) +{ + int i = sharpsl_pm.machinfo->bat_levels - 1; + struct battery_thresh *thresh; + + if (sharpsl_pm.charge_mode == CHRG_ON) + thresh=sharpsl_pm.machinfo->bat_levels_acin; + else + thresh=sharpsl_pm.machinfo->bat_levels_noac; + + while (i > 0 && (voltage > thresh[i].voltage)) + i--; + + return thresh[i].percentage; +} + +static int get_apm_status(int voltage) +{ + int low_thresh, high_thresh; + + if (sharpsl_pm.charge_mode == CHRG_ON) { + high_thresh = sharpsl_pm.machinfo->status_high_acin; + low_thresh = sharpsl_pm.machinfo->status_low_acin; + } else { + high_thresh = sharpsl_pm.machinfo->status_high_noac; + low_thresh = sharpsl_pm.machinfo->status_low_noac; + } + + if (voltage >= high_thresh) + return APM_BATTERY_STATUS_HIGH; + if (voltage >= low_thresh) + return APM_BATTERY_STATUS_LOW; + return APM_BATTERY_STATUS_CRITICAL; +} + +void sharpsl_battery_kick(void) +{ + schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(125)); +} +EXPORT_SYMBOL(sharpsl_battery_kick); + + +static void sharpsl_battery_thread(void *private_) +{ + int voltage, percent, apm_status, i = 0; + + if (!sharpsl_pm.machinfo) + return; + + sharpsl_pm.battstat.ac_status = (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN) ? APM_AC_ONLINE : APM_AC_OFFLINE); + + /* Corgi cannot confirm when battery fully charged so periodically kick! */ + if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON) + && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL)) + schedule_work(&toggle_charger); + + while(1) { + voltage = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT); + + if (voltage > 0) break; + if (i++ > 5) { + voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage; + dev_warn(sharpsl_pm.dev, "Warning: Cannot read main battery!\n"); + break; + } + } + + voltage = sharpsl_average_value(voltage); + apm_status = get_apm_status(voltage); + percent = get_percentage(voltage); + + /* At low battery voltages, the voltage has a tendency to start + creeping back up so we try to avoid this here */ + if ((sharpsl_pm.battstat.ac_status == APM_AC_ONLINE) || (apm_status == APM_BATTERY_STATUS_HIGH) || percent <= sharpsl_pm.battstat.mainbat_percent) { + sharpsl_pm.battstat.mainbat_voltage = voltage; + sharpsl_pm.battstat.mainbat_status = apm_status; + sharpsl_pm.battstat.mainbat_percent = percent; + } + + dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %d\n", voltage, + sharpsl_pm.battstat.mainbat_status, sharpsl_pm.battstat.mainbat_percent, jiffies); + + /* If battery is low. limit backlight intensity to save power. */ + if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE) + && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) || + (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) { + if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) { + corgibl_limit_intensity(1); + sharpsl_pm.flags |= SHARPSL_BL_LIMIT; + } + } else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) { + corgibl_limit_intensity(0); + sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT; + } + + /* Suspend if critical battery level */ + if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE) + && (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL) + && !(sharpsl_pm.flags & SHARPSL_APM_QUEUED)) { + sharpsl_pm.flags |= SHARPSL_APM_QUEUED; + dev_err(sharpsl_pm.dev, "Fatal Off\n"); + apm_queue_event(APM_CRITICAL_SUSPEND); + } + + schedule_delayed_work(&sharpsl_bat, SHARPSL_BATCHK_TIME); +} + +void sharpsl_pm_led(int val) +{ + if (val == SHARPSL_LED_ERROR) { + dev_err(sharpsl_pm.dev, "Charging Error!\n"); + } else if (val == SHARPSL_LED_ON) { + dev_dbg(sharpsl_pm.dev, "Charge LED On\n"); + + } else { + dev_dbg(sharpsl_pm.dev, "Charge LED Off\n"); + + } +} + +static void sharpsl_charge_on(void) +{ + dev_dbg(sharpsl_pm.dev, "Turning Charger On\n"); + + sharpsl_pm.full_count = 0; + sharpsl_pm.charge_mode = CHRG_ON; + schedule_delayed_work(&toggle_charger, msecs_to_jiffies(250)); + schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(500)); +} + +static void sharpsl_charge_off(void) +{ + dev_dbg(sharpsl_pm.dev, "Turning Charger Off\n"); + + sharpsl_pm.machinfo->charge(0); + sharpsl_pm_led(SHARPSL_LED_OFF); + sharpsl_pm.charge_mode = CHRG_OFF; + + schedule_work(&sharpsl_bat); +} + +static void sharpsl_charge_error(void) +{ + sharpsl_pm_led(SHARPSL_LED_ERROR); + sharpsl_pm.machinfo->charge(0); + sharpsl_pm.charge_mode = CHRG_ERROR; +} + +static void sharpsl_charge_toggle(void *private_) +{ + dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies); + + if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) { + sharpsl_charge_off(); + return; + } else if ((sharpsl_check_battery_temp() < 0) || (sharpsl_ac_check() < 0)) { + sharpsl_charge_error(); + return; + } + + sharpsl_pm_led(SHARPSL_LED_ON); + sharpsl_pm.machinfo->charge(0); + mdelay(SHARPSL_CHARGE_WAIT_TIME); + sharpsl_pm.machinfo->charge(1); + + sharpsl_pm.charge_start_time = jiffies; +} + +static void sharpsl_ac_timer(unsigned long data) +{ + int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN); + + dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin); + + sharpsl_average_clear(); + if (acin && (sharpsl_pm.charge_mode != CHRG_ON)) + sharpsl_charge_on(); + else if (sharpsl_pm.charge_mode == CHRG_ON) + sharpsl_charge_off(); + + schedule_work(&sharpsl_bat); +} + + +irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp) +{ + /* Delay the event slightly to debounce */ + /* Must be a smaller delay than the chrg_full_isr below */ + mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250)); + + return IRQ_HANDLED; +} + +static void sharpsl_chrg_full_timer(unsigned long data) +{ + dev_dbg(sharpsl_pm.dev, "Charge Full at time: %lx\n", jiffies); + + sharpsl_pm.full_count++; + + if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) { + dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n"); + if (sharpsl_pm.charge_mode == CHRG_ON) + sharpsl_charge_off(); + } else if (sharpsl_pm.full_count < 2) { + dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n"); + schedule_work(&toggle_charger); + } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) { + dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n"); + schedule_work(&toggle_charger); + } else { + sharpsl_charge_off(); + sharpsl_pm.charge_mode = CHRG_DONE; + dev_dbg(sharpsl_pm.dev, "Charge Full: Charging Finished\n"); + } +} + +/* Charging Finished Interrupt (Not present on Corgi) */ +/* Can trigger at the same time as an AC staus change so + delay until after that has been processed */ +irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp) +{ + if (sharpsl_pm.flags & SHARPSL_SUSPENDED) + return IRQ_HANDLED; + + /* delay until after any ac interrupt */ + mod_timer(&sharpsl_pm.chrg_full_timer, jiffies + msecs_to_jiffies(500)); + + return IRQ_HANDLED; +} + +irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp) +{ + int is_fatal = 0; + + if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) { + dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n"); + is_fatal = 1; + } + + if (!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_FATAL)) { + dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n"); + is_fatal = 1; + } + + if (!(sharpsl_pm.flags & SHARPSL_APM_QUEUED) && is_fatal) { + sharpsl_pm.flags |= SHARPSL_APM_QUEUED; + apm_queue_event(APM_CRITICAL_SUSPEND); + } + + return IRQ_HANDLED; +} + +/* + * Maintain an average of the last 10 readings + */ +#define SHARPSL_CNV_VALUE_NUM 10 +static int sharpsl_ad_index; + +static void sharpsl_average_clear(void) +{ + sharpsl_ad_index = 0; +} + +static int sharpsl_average_value(int ad) +{ + int i, ad_val = 0; + static int sharpsl_ad[SHARPSL_CNV_VALUE_NUM+1]; + + if (sharpsl_pm.battstat.mainbat_status != APM_BATTERY_STATUS_HIGH) { + sharpsl_ad_index = 0; + return ad; + } + + sharpsl_ad[sharpsl_ad_index] = ad; + sharpsl_ad_index++; + if (sharpsl_ad_index >= SHARPSL_CNV_VALUE_NUM) { + for (i=0; i < (SHARPSL_CNV_VALUE_NUM-1); i++) + sharpsl_ad[i] = sharpsl_ad[i+1]; + sharpsl_ad_index = SHARPSL_CNV_VALUE_NUM - 1; + } + for (i=0; i < sharpsl_ad_index; i++) + ad_val += sharpsl_ad[i]; + + return (ad_val / sharpsl_ad_index); +} + +/* + * Take an array of 5 integers, remove the maximum and minimum values + * and return the average. + */ +static int get_select_val(int *val) +{ + int i, j, k, temp, sum = 0; + + /* Find MAX val */ + temp = val[0]; + j=0; + for (i=1; i<5; i++) { + if (temp < val[i]) { + temp = val[i]; + j = i; + } + } + + /* Find MIN val */ + temp = val[4]; + k=4; + for (i=3; i>=0; i--) { + if (temp > val[i]) { + temp = val[i]; + k = i; + } + } + + for (i=0; i<5; i++) + if (i != j && i != k ) + sum += val[i]; + + dev_dbg(sharpsl_pm.dev, "Average: %d from values: %d, %d, %d, %d, %d\n", sum/3, val[0], val[1], val[2], val[3], val[4]); + + return (sum/3); +} + +static int sharpsl_check_battery_temp(void) +{ + int val, i, buff[5]; + + /* Check battery temperature */ + for (i=0; i<5; i++) { + mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP); + sharpsl_pm.machinfo->measure_temp(1); + mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP); + buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_TEMP); + sharpsl_pm.machinfo->measure_temp(0); + } + + val = get_select_val(buff); + + dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val); + if (val > SHARPSL_CHARGE_ON_TEMP) + return -1; + + return 0; +} + +static int sharpsl_check_battery_voltage(void) +{ + int val, i, buff[5]; + + /* disable charge, enable discharge */ + sharpsl_pm.machinfo->charge(0); + sharpsl_pm.machinfo->discharge(1); + mdelay(SHARPSL_WAIT_DISCHARGE_ON); + + if (sharpsl_pm.machinfo->discharge1) + sharpsl_pm.machinfo->discharge1(1); + + /* Check battery voltage */ + for (i=0; i<5; i++) { + buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT); + mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); + } + + if (sharpsl_pm.machinfo->discharge1) + sharpsl_pm.machinfo->discharge1(0); + + sharpsl_pm.machinfo->discharge(0); + + val = get_select_val(buff); + dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val); + + if (val < SHARPSL_CHARGE_ON_VOLT) + return -1; + + return 0; +} + +static int sharpsl_ac_check(void) +{ + int temp, i, buff[5]; + + for (i=0; i<5; i++) { + buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_ACIN_VOLT); + mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN); + } + + temp = get_select_val(buff); + dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp); + + if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) { + dev_err(sharpsl_pm.dev, "Error: AC check failed.\n"); + return -1; + } + + return 0; +} + +#ifdef CONFIG_PM +static int sharpsl_pm_suspend(struct platform_device *pdev, pm_message_t state) +{ + sharpsl_pm.flags |= SHARPSL_SUSPENDED; + flush_scheduled_work(); + + if (sharpsl_pm.charge_mode == CHRG_ON) + sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; + else + sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG; + + return 0; +} + +static int sharpsl_pm_resume(struct platform_device *pdev) +{ + /* Clear the reset source indicators as they break the bootloader upon reboot */ + RCSR = 0x0f; + sharpsl_average_clear(); + sharpsl_pm.flags &= ~SHARPSL_APM_QUEUED; + sharpsl_pm.flags &= ~SHARPSL_SUSPENDED; + + return 0; +} + +static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state) +{ + dev_dbg(sharpsl_pm.dev, "Time is: %08x\n",RCNR); + + dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG); + /* not charging and AC-IN! */ + + if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN))) { + dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n"); + sharpsl_pm.charge_mode = CHRG_OFF; + sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG; + sharpsl_off_charge_battery(); + } + + sharpsl_pm.machinfo->presuspend(); + + PEDR = 0xffffffff; /* clear it */ + + sharpsl_pm.flags &= ~SHARPSL_ALARM_ACTIVE; + if ((sharpsl_pm.charge_mode == CHRG_ON) && ((alarm_enable && ((alarm_time - RCNR) > (SHARPSL_BATCHK_TIME_SUSPEND + 30))) || !alarm_enable)) { + RTSR &= RTSR_ALE; + RTAR = RCNR + SHARPSL_BATCHK_TIME_SUSPEND; + dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n",RTAR); + sharpsl_pm.flags |= SHARPSL_ALARM_ACTIVE; + } else if (alarm_enable) { + RTSR &= RTSR_ALE; + RTAR = alarm_time; + dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n",RTAR); + } else { + dev_dbg(sharpsl_pm.dev, "No alarms set.\n"); + } + + pxa_pm_enter(state); + + sharpsl_pm.machinfo->postsuspend(); + + dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",PEDR); +} + +static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state) +{ + if (!sharpsl_pm.machinfo->should_wakeup(!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE) && alarm_enable) ) + { + if (!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE)) { + dev_dbg(sharpsl_pm.dev, "No user triggered wakeup events and not charging. Strange. Suspend.\n"); + corgi_goto_sleep(alarm_time, alarm_enable, state); + return 1; + } + if(sharpsl_off_charge_battery()) { + dev_dbg(sharpsl_pm.dev, "Charging. Suspend...\n"); + corgi_goto_sleep(alarm_time, alarm_enable, state); + return 1; + } + dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n"); + } + + if ((!sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_LOCK)) || (sharpsl_fatal_check() < 0) ) + { + dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n"); + corgi_goto_sleep(alarm_time, alarm_enable, state); + return 1; + } + + return 0; +} + +static int corgi_pxa_pm_enter(suspend_state_t state) +{ + unsigned long alarm_time = RTAR; + unsigned int alarm_status = ((RTSR & RTSR_ALE) != 0); + + dev_dbg(sharpsl_pm.dev, "SharpSL suspending for first time.\n"); + + corgi_goto_sleep(alarm_time, alarm_status, state); + + while (corgi_enter_suspend(alarm_time,alarm_status,state)) + {} + + dev_dbg(sharpsl_pm.dev, "SharpSL resuming...\n"); + + return 0; +} +#endif + + +/* + * Check for fatal battery errors + * Fatal returns -1 + */ +static int sharpsl_fatal_check(void) +{ + int buff[5], temp, i, acin; + + dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n"); + + /* Check AC-Adapter */ + acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN); + + if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) { + sharpsl_pm.machinfo->charge(0); + udelay(100); + sharpsl_pm.machinfo->discharge(1); /* enable discharge */ + mdelay(SHARPSL_WAIT_DISCHARGE_ON); + } + + if (sharpsl_pm.machinfo->discharge1) + sharpsl_pm.machinfo->discharge1(1); + + /* Check battery : check inserting battery ? */ + for (i=0; i<5; i++) { + buff[i] = sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT); + mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); + } + + if (sharpsl_pm.machinfo->discharge1) + sharpsl_pm.machinfo->discharge1(0); + + if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) { + udelay(100); + sharpsl_pm.machinfo->charge(1); + sharpsl_pm.machinfo->discharge(0); + } + + temp = get_select_val(buff); + dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_pm.machinfo->read_devdata(SHARPSL_BATT_VOLT)); + + if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) || + (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT))) + return -1; + return 0; +} + +static int sharpsl_off_charge_error(void) +{ + dev_err(sharpsl_pm.dev, "Offline Charger: Error occured.\n"); + sharpsl_pm.machinfo->charge(0); + sharpsl_pm_led(SHARPSL_LED_ERROR); + sharpsl_pm.charge_mode = CHRG_ERROR; + return 1; +} + +/* + * Charging Control while suspended + * Return 1 - go straight to sleep + * Return 0 - sleep or wakeup depending on other factors + */ +static int sharpsl_off_charge_battery(void) +{ + int time; + + dev_dbg(sharpsl_pm.dev, "Charge Mode: %d\n", sharpsl_pm.charge_mode); + + if (sharpsl_pm.charge_mode == CHRG_OFF) { + dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n"); + + /* AC Check */ + if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery_temp() < 0)) + return sharpsl_off_charge_error(); + + /* Start Charging */ + sharpsl_pm_led(SHARPSL_LED_ON); + sharpsl_pm.machinfo->charge(0); + mdelay(SHARPSL_CHARGE_WAIT_TIME); + sharpsl_pm.machinfo->charge(1); + + sharpsl_pm.charge_mode = CHRG_ON; + sharpsl_pm.full_count = 0; + + return 1; + } else if (sharpsl_pm.charge_mode != CHRG_ON) { + return 1; + } + + if (sharpsl_pm.full_count == 0) { + int time; + + dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n"); + + if ((sharpsl_check_battery_temp() < 0) || (sharpsl_check_battery_voltage() < 0)) + return sharpsl_off_charge_error(); + + sharpsl_pm.machinfo->charge(0); + mdelay(SHARPSL_CHARGE_WAIT_TIME); + sharpsl_pm.machinfo->charge(1); + sharpsl_pm.charge_mode = CHRG_ON; + + mdelay(SHARPSL_CHARGE_CO_CHECK_TIME); + + time = RCNR; + while(1) { + /* Check if any wakeup event had occured */ + if (sharpsl_pm.machinfo->charger_wakeup() != 0) + return 0; + /* Check for timeout */ + if ((RCNR - time) > SHARPSL_WAIT_CO_TIME) + return 1; + if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL)) { + dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n"); + sharpsl_pm.full_count++; + sharpsl_pm.machinfo->charge(0); + mdelay(SHARPSL_CHARGE_WAIT_TIME); + sharpsl_pm.machinfo->charge(1); + return 1; + } + } + } + + dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 3\n"); + + mdelay(SHARPSL_CHARGE_CO_CHECK_TIME); + + time = RCNR; + while(1) { + /* Check if any wakeup event had occured */ + if (sharpsl_pm.machinfo->charger_wakeup() != 0) + return 0; + /* Check for timeout */ + if ((RCNR-time) > SHARPSL_WAIT_CO_TIME) { + if (sharpsl_pm.full_count > SHARPSL_CHARGE_RETRY_CNT) { + dev_dbg(sharpsl_pm.dev, "Offline Charger: Not charged sufficiently. Retrying.\n"); + sharpsl_pm.full_count = 0; + } + sharpsl_pm.full_count++; + return 1; + } + if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_CHRGFULL)) { + dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n"); + sharpsl_pm_led(SHARPSL_LED_OFF); + sharpsl_pm.machinfo->charge(0); + sharpsl_pm.charge_mode = CHRG_DONE; + return 1; + } + } +} + + +static ssize_t battery_percentage_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_percent); +} + +static ssize_t battery_voltage_show(struct device *dev, struct device_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_voltage); +} + +static DEVICE_ATTR(battery_percentage, 0444, battery_percentage_show, NULL); +static DEVICE_ATTR(battery_voltage, 0444, battery_voltage_show, NULL); + +extern void (*apm_get_power_status)(struct apm_power_info *); + +static void sharpsl_apm_get_power_status(struct apm_power_info *info) +{ + info->ac_line_status = sharpsl_pm.battstat.ac_status; + + if (sharpsl_pm.charge_mode == CHRG_ON) + info->battery_status = APM_BATTERY_STATUS_CHARGING; + else + info->battery_status = sharpsl_pm.battstat.mainbat_status; + + info->battery_flag = (1 << info->battery_status); + info->battery_life = sharpsl_pm.battstat.mainbat_percent; +} + +static struct pm_ops sharpsl_pm_ops = { + .pm_disk_mode = PM_DISK_FIRMWARE, + .prepare = pxa_pm_prepare, + .enter = corgi_pxa_pm_enter, + .finish = pxa_pm_finish, +}; + +static int __init sharpsl_pm_probe(struct platform_device *pdev) +{ + if (!pdev->dev.platform_data) + return -EINVAL; + + sharpsl_pm.dev = &pdev->dev; + sharpsl_pm.machinfo = pdev->dev.platform_data; + sharpsl_pm.charge_mode = CHRG_OFF; + sharpsl_pm.flags = 0; + + init_timer(&sharpsl_pm.ac_timer); + sharpsl_pm.ac_timer.function = sharpsl_ac_timer; + + init_timer(&sharpsl_pm.chrg_full_timer); + sharpsl_pm.chrg_full_timer.function = sharpsl_chrg_full_timer; + + sharpsl_pm.machinfo->init(); + + device_create_file(&pdev->dev, &dev_attr_battery_percentage); + device_create_file(&pdev->dev, &dev_attr_battery_voltage); + + apm_get_power_status = sharpsl_apm_get_power_status; + + pm_set_ops(&sharpsl_pm_ops); + + mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250)); + + return 0; +} + +static int sharpsl_pm_remove(struct platform_device *pdev) +{ + pm_set_ops(NULL); + + device_remove_file(&pdev->dev, &dev_attr_battery_percentage); + device_remove_file(&pdev->dev, &dev_attr_battery_voltage); + + sharpsl_pm.machinfo->exit(); + + del_timer_sync(&sharpsl_pm.chrg_full_timer); + del_timer_sync(&sharpsl_pm.ac_timer); + + return 0; +} + +static struct platform_driver sharpsl_pm_driver = { + .probe = sharpsl_pm_probe, + .remove = sharpsl_pm_remove, + .suspend = sharpsl_pm_suspend, + .resume = sharpsl_pm_resume, + .driver = { + .name = "sharpsl-pm", + }, +}; + +static int __devinit sharpsl_pm_init(void) +{ + return platform_driver_register(&sharpsl_pm_driver); +} + +static void sharpsl_pm_exit(void) +{ + platform_driver_unregister(&sharpsl_pm_driver); +} + +late_initcall(sharpsl_pm_init); +module_exit(sharpsl_pm_exit); diff --git a/arch/arm/mach-pxa/Kconfig b/arch/arm/mach-pxa/Kconfig index 2a58499..c1d77f5 100644 --- a/arch/arm/mach-pxa/Kconfig +++ b/arch/arm/mach-pxa/Kconfig @@ -112,12 +112,14 @@ config IWMMXT config PXA_SHARP_C7xx bool select PXA_SSP + select SHARPSL_PM help Enable support for all Sharp C7xx models config PXA_SHARP_Cxx00 bool select PXA_SSP + select SHARPSL_PM help Enable common support for Sharp Cxx00 models diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c index 599be14..de8b240 100644 --- a/arch/arm/mach-pxa/corgi_pm.c +++ b/arch/arm/mach-pxa/corgi_pm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -33,19 +34,7 @@ static void corgi_charger_init(void) pxa_gpio_mode(CORGI_GPIO_CHRG_ON | GPIO_OUT); pxa_gpio_mode(CORGI_GPIO_CHRG_UKN | GPIO_OUT); pxa_gpio_mode(CORGI_GPIO_KEY_INT | GPIO_IN); -} - -static void corgi_charge_led(int val) -{ - if (val == SHARPSL_LED_ERROR) { - dev_dbg(sharpsl_pm.dev, "Charge LED Error\n"); - } else if (val == SHARPSL_LED_ON) { - dev_dbg(sharpsl_pm.dev, "Charge LED On\n"); - GPSR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); - } else { - dev_dbg(sharpsl_pm.dev, "Charge LED Off\n"); - GPCR0 = GPIO_bit(CORGI_GPIO_LED_ORANGE); - } + sharpsl_pm_pxa_init(); } static void corgi_measure_temp(int on) @@ -138,15 +127,15 @@ static int corgi_should_wakeup(unsigned int resume_on_alarm) dev_dbg(sharpsl_pm.dev, "GPLR0 = %x,%x\n", GPLR0, PEDR); if ((PEDR & GPIO_bit(CORGI_GPIO_AC_IN))) { - if (STATUS_AC_IN()) { + if (sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN)) { /* charge on */ dev_dbg(sharpsl_pm.dev, "ac insert\n"); sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; } else { /* charge off */ dev_dbg(sharpsl_pm.dev, "ac remove\n"); - CHARGE_LED_OFF(); - CHARGE_OFF(); + sharpsl_pm_led(SHARPSL_LED_OFF); + sharpsl_pm.machinfo->charge(0); sharpsl_pm.charge_mode = CHRG_OFF; } } @@ -172,23 +161,39 @@ static unsigned long corgi_charger_wakeup(void) return ~GPLR0 & ( GPIO_bit(CORGI_GPIO_AC_IN) | GPIO_bit(CORGI_GPIO_KEY_INT) | GPIO_bit(CORGI_GPIO_WAKEUP) ); } -static int corgi_acin_status(void) +unsigned long corgipm_read_devdata(int type) { - return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0); + switch(type) { + case SHARPSL_STATUS_ACIN: + return ((GPLR(CORGI_GPIO_AC_IN) & GPIO_bit(CORGI_GPIO_AC_IN)) != 0); + case SHARPSL_STATUS_LOCK: + return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock); + case SHARPSL_STATUS_CHRGFULL: + return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull); + case SHARPSL_STATUS_FATAL: + return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal); + case SHARPSL_ACIN_VOLT: + return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT); + case SHARPSL_BATT_TEMP: + return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP); + case SHARPSL_BATT_VOLT: + default: + return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT); + } } static struct sharpsl_charger_machinfo corgi_pm_machinfo = { .init = corgi_charger_init, + .exit = sharpsl_pm_pxa_remove, .gpio_batlock = CORGI_GPIO_BAT_COVER, .gpio_acin = CORGI_GPIO_AC_IN, .gpio_batfull = CORGI_GPIO_CHRG_FULL, - .status_acin = corgi_acin_status, .discharge = corgi_discharge, .charge = corgi_charge, - .chargeled = corgi_charge_led, .measure_temp = corgi_measure_temp, .presuspend = corgi_presuspend, .postsuspend = corgi_postsuspend, + .read_devdata = corgipm_read_devdata, .charger_wakeup = corgi_charger_wakeup, .should_wakeup = corgi_should_wakeup, .bat_levels = 40, diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h index b0c40a1..92b7930 100644 --- a/arch/arm/mach-pxa/sharpsl.h +++ b/arch/arm/mach-pxa/sharpsl.h @@ -1,7 +1,16 @@ /* - * SharpSL SSP Driver + * Copyright (c) 2004-2005 Richard Purdie + * + * 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. + * */ + +/* + * SharpSL SSP Driver + */ struct corgissp_machinfo { int port; int cs_lcdcon; @@ -14,18 +23,18 @@ struct corgissp_machinfo { void corgi_ssp_set_machinfo(struct corgissp_machinfo *machinfo); + /* * SharpSL Backlight */ - void corgi_bl_set_intensity(int intensity); void spitz_bl_set_intensity(int intensity); void akita_bl_set_intensity(int intensity); + /* * SharpSL Touchscreen Driver */ - unsigned long corgi_get_hsync_len(void); unsigned long spitz_get_hsync_len(void); void corgi_put_hsync(void); @@ -33,89 +42,22 @@ void spitz_put_hsync(void); void corgi_wait_hsync(void); void spitz_wait_hsync(void); + /* * SharpSL Battery/PM Driver */ -struct sharpsl_charger_machinfo { - void (*init)(void); - int gpio_acin; - int gpio_batfull; - int gpio_batlock; - int gpio_fatal; - int (*status_acin)(void); - void (*discharge)(int); - void (*discharge1)(int); - void (*charge)(int); - void (*chargeled)(int); - void (*measure_temp)(int); - void (*presuspend)(void); - void (*postsuspend)(void); - unsigned long (*charger_wakeup)(void); - int (*should_wakeup)(unsigned int resume_on_alarm); - int bat_levels; - struct battery_thresh *bat_levels_noac; - struct battery_thresh *bat_levels_acin; - int status_high_acin; - int status_low_acin; - int status_high_noac; - int status_low_noac; -}; - -struct battery_thresh { - int voltage; - int percentage; -}; - -struct battery_stat { - int ac_status; /* APM AC Present/Not Present */ - int mainbat_status; /* APM Main Battery Status */ - int mainbat_percent; /* Main Battery Percentage Charge */ - int mainbat_voltage; /* Main Battery Voltage */ -}; - -struct sharpsl_pm_status { - struct device *dev; - struct timer_list ac_timer; - struct timer_list chrg_full_timer; - - int charge_mode; -#define CHRG_ERROR (-1) -#define CHRG_OFF (0) -#define CHRG_ON (1) -#define CHRG_DONE (2) - - unsigned int flags; -#define SHARPSL_SUSPENDED (1 << 0) /* Device is Suspended */ -#define SHARPSL_ALARM_ACTIVE (1 << 1) /* Alarm is for charging event (not user) */ -#define SHARPSL_BL_LIMIT (1 << 2) /* Backlight Intensity Limited */ -#define SHARPSL_APM_QUEUED (1 << 3) /* APM Event Queued */ -#define SHARPSL_DO_OFFLINE_CHRG (1 << 4) /* Trigger the offline charger */ +#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x)) - int full_count; - unsigned long charge_start_time; - struct sharpsl_charger_machinfo *machinfo; - struct battery_stat battstat; -}; +/* MAX1111 Channel Definitions */ +#define MAX1111_BATT_VOLT 4u +#define MAX1111_BATT_TEMP 2u +#define MAX1111_ACIN_VOLT 6u -extern struct sharpsl_pm_status sharpsl_pm; extern struct battery_thresh spitz_battery_levels_acin[]; extern struct battery_thresh spitz_battery_levels_noac[]; +void sharpsl_pm_pxa_init(void); +void sharpsl_pm_pxa_remove(void); +int sharpsl_pm_pxa_read_max1111(int channel); -#define READ_GPIO_BIT(x) (GPLR(x) & GPIO_bit(x)) - -#define SHARPSL_LED_ERROR 2 -#define SHARPSL_LED_ON 1 -#define SHARPSL_LED_OFF 0 -#define CHARGE_ON() sharpsl_pm.machinfo->charge(1) -#define CHARGE_OFF() sharpsl_pm.machinfo->charge(0) -#define CHARGE_LED_ON() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ON) -#define CHARGE_LED_OFF() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_OFF) -#define CHARGE_LED_ERR() sharpsl_pm.machinfo->chargeled(SHARPSL_LED_ERROR) -#define DISCHARGE_ON() sharpsl_pm.machinfo->discharge(1) -#define DISCHARGE_OFF() sharpsl_pm.machinfo->discharge(0) -#define STATUS_AC_IN() sharpsl_pm.machinfo->status_acin() -#define STATUS_BATT_LOCKED() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock) -#define STATUS_CHRG_FULL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull) -#define STATUS_FATAL() READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal) diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c index c10be00..f6fefb1 100644 --- a/arch/arm/mach-pxa/sharpsl_pm.c +++ b/arch/arm/mach-pxa/sharpsl_pm.c @@ -15,48 +15,21 @@ #undef DEBUG #include -#include #include #include -#include -#include #include #include #include -#include #include #include #include - #include #include #include +#include #include "sharpsl.h" -/* - * Constants - */ -#define SHARPSL_CHARGE_ON_TIME_INTERVAL (msecs_to_jiffies(1*60*1000)) /* 1 min */ -#define SHARPSL_CHARGE_FINISH_TIME (msecs_to_jiffies(10*60*1000)) /* 10 min */ -#define SHARPSL_BATCHK_TIME (msecs_to_jiffies(15*1000)) /* 15 sec */ -#define SHARPSL_BATCHK_TIME_SUSPEND (60*10) /* 10 min */ -#define SHARPSL_WAIT_CO_TIME 15 /* 15 sec */ -#define SHARPSL_WAIT_DISCHARGE_ON 100 /* 100 msec */ -#define SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP 10 /* 10 msec */ -#define SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT 10 /* 10 msec */ -#define SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN 10 /* 10 msec */ -#define SHARPSL_CHARGE_WAIT_TIME 15 /* 15 msec */ -#define SHARPSL_CHARGE_CO_CHECK_TIME 5 /* 5 msec */ -#define SHARPSL_CHARGE_RETRY_CNT 1 /* eqv. 10 min */ - -#define SHARPSL_CHARGE_ON_VOLT 0x99 /* 2.9V */ -#define SHARPSL_CHARGE_ON_TEMP 0xe0 /* 2.9V */ -#define SHARPSL_CHARGE_ON_ACIN_HIGH 0x9b /* 6V */ -#define SHARPSL_CHARGE_ON_ACIN_LOW 0x34 /* 2V */ -#define SHARPSL_FATAL_ACIN_VOLT 182 /* 3.45V */ -#define SHARPSL_FATAL_NOACIN_VOLT 170 /* 3.40V */ - struct battery_thresh spitz_battery_levels_acin[] = { { 213, 100}, { 212, 98}, @@ -151,763 +124,17 @@ struct battery_thresh spitz_battery_levels_noac[] = { #define MAXCTRL_SEL_SH 4 #define MAXCTRL_STR 1u << 7 -/* MAX1111 Channel Definitions */ -#define BATT_AD 4u -#define BATT_THM 2u -#define JK_VAD 6u - - -/* - * Prototypes - */ -static int sharpsl_read_main_battery(void); -static int sharpsl_off_charge_battery(void); -static int sharpsl_check_battery_temp(void); -static int sharpsl_check_battery_voltage(void); -static int sharpsl_ac_check(void); -static int sharpsl_fatal_check(void); -static int sharpsl_average_value(int ad); -static void sharpsl_average_clear(void); -static void sharpsl_charge_toggle(void *private_); -static void sharpsl_battery_thread(void *private_); - - -/* - * Variables - */ -struct sharpsl_pm_status sharpsl_pm; -DECLARE_WORK(toggle_charger, sharpsl_charge_toggle, NULL); -DECLARE_WORK(sharpsl_bat, sharpsl_battery_thread, NULL); - - -static int get_percentage(int voltage) -{ - int i = sharpsl_pm.machinfo->bat_levels - 1; - struct battery_thresh *thresh; - - if (sharpsl_pm.charge_mode == CHRG_ON) - thresh=sharpsl_pm.machinfo->bat_levels_acin; - else - thresh=sharpsl_pm.machinfo->bat_levels_noac; - - while (i > 0 && (voltage > thresh[i].voltage)) - i--; - - return thresh[i].percentage; -} - -static int get_apm_status(int voltage) -{ - int low_thresh, high_thresh; - - if (sharpsl_pm.charge_mode == CHRG_ON) { - high_thresh = sharpsl_pm.machinfo->status_high_acin; - low_thresh = sharpsl_pm.machinfo->status_low_acin; - } else { - high_thresh = sharpsl_pm.machinfo->status_high_noac; - low_thresh = sharpsl_pm.machinfo->status_low_noac; - } - - if (voltage >= high_thresh) - return APM_BATTERY_STATUS_HIGH; - if (voltage >= low_thresh) - return APM_BATTERY_STATUS_LOW; - return APM_BATTERY_STATUS_CRITICAL; -} - -void sharpsl_battery_kick(void) -{ - schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(125)); -} -EXPORT_SYMBOL(sharpsl_battery_kick); - - -static void sharpsl_battery_thread(void *private_) -{ - int voltage, percent, apm_status, i = 0; - - if (!sharpsl_pm.machinfo) - return; - - sharpsl_pm.battstat.ac_status = (STATUS_AC_IN() ? APM_AC_ONLINE : APM_AC_OFFLINE); - - /* Corgi cannot confirm when battery fully charged so periodically kick! */ - if (machine_is_corgi() && (sharpsl_pm.charge_mode == CHRG_ON) - && time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_ON_TIME_INTERVAL)) - schedule_work(&toggle_charger); - - while(1) { - voltage = sharpsl_read_main_battery(); - if (voltage > 0) break; - if (i++ > 5) { - voltage = sharpsl_pm.machinfo->bat_levels_noac[0].voltage; - dev_warn(sharpsl_pm.dev, "Warning: Cannot read main battery!\n"); - break; - } - } - - voltage = sharpsl_average_value(voltage); - apm_status = get_apm_status(voltage); - percent = get_percentage(voltage); - - /* At low battery voltages, the voltage has a tendency to start - creeping back up so we try to avoid this here */ - if ((sharpsl_pm.battstat.ac_status == APM_AC_ONLINE) || (apm_status == APM_BATTERY_STATUS_HIGH) || percent <= sharpsl_pm.battstat.mainbat_percent) { - sharpsl_pm.battstat.mainbat_voltage = voltage; - sharpsl_pm.battstat.mainbat_status = apm_status; - sharpsl_pm.battstat.mainbat_percent = percent; - } - - dev_dbg(sharpsl_pm.dev, "Battery: voltage: %d, status: %d, percentage: %d, time: %d\n", voltage, - sharpsl_pm.battstat.mainbat_status, sharpsl_pm.battstat.mainbat_percent, jiffies); - - /* If battery is low. limit backlight intensity to save power. */ - if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE) - && ((sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_LOW) || - (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL))) { - if (!(sharpsl_pm.flags & SHARPSL_BL_LIMIT)) { - corgibl_limit_intensity(1); - sharpsl_pm.flags |= SHARPSL_BL_LIMIT; - } - } else if (sharpsl_pm.flags & SHARPSL_BL_LIMIT) { - corgibl_limit_intensity(0); - sharpsl_pm.flags &= ~SHARPSL_BL_LIMIT; - } - - /* Suspend if critical battery level */ - if ((sharpsl_pm.battstat.ac_status != APM_AC_ONLINE) - && (sharpsl_pm.battstat.mainbat_status == APM_BATTERY_STATUS_CRITICAL) - && !(sharpsl_pm.flags & SHARPSL_APM_QUEUED)) { - sharpsl_pm.flags |= SHARPSL_APM_QUEUED; - dev_err(sharpsl_pm.dev, "Fatal Off\n"); - apm_queue_event(APM_CRITICAL_SUSPEND); - } - - schedule_delayed_work(&sharpsl_bat, SHARPSL_BATCHK_TIME); -} - -static void sharpsl_charge_on(void) -{ - dev_dbg(sharpsl_pm.dev, "Turning Charger On\n"); - - sharpsl_pm.full_count = 0; - sharpsl_pm.charge_mode = CHRG_ON; - schedule_delayed_work(&toggle_charger, msecs_to_jiffies(250)); - schedule_delayed_work(&sharpsl_bat, msecs_to_jiffies(500)); -} - -static void sharpsl_charge_off(void) -{ - dev_dbg(sharpsl_pm.dev, "Turning Charger Off\n"); - - CHARGE_OFF(); - CHARGE_LED_OFF(); - sharpsl_pm.charge_mode = CHRG_OFF; - - schedule_work(&sharpsl_bat); -} - -static void sharpsl_charge_error(void) -{ - CHARGE_LED_ERR(); - CHARGE_OFF(); - sharpsl_pm.charge_mode = CHRG_ERROR; -} - -static void sharpsl_charge_toggle(void *private_) -{ - dev_dbg(sharpsl_pm.dev, "Toogling Charger at time: %lx\n", jiffies); - - if (STATUS_AC_IN() == 0) { - sharpsl_charge_off(); - return; - } else if ((sharpsl_check_battery_temp() < 0) || (sharpsl_ac_check() < 0)) { - sharpsl_charge_error(); - return; - } - - CHARGE_LED_ON(); - CHARGE_OFF(); - mdelay(SHARPSL_CHARGE_WAIT_TIME); - CHARGE_ON(); - - sharpsl_pm.charge_start_time = jiffies; -} - -static void sharpsl_ac_timer(unsigned long data) -{ - int acin = STATUS_AC_IN(); - - dev_dbg(sharpsl_pm.dev, "AC Status: %d\n",acin); - - sharpsl_average_clear(); - if (acin && (sharpsl_pm.charge_mode != CHRG_ON)) - sharpsl_charge_on(); - else if (sharpsl_pm.charge_mode == CHRG_ON) - sharpsl_charge_off(); - - schedule_work(&sharpsl_bat); -} - - -static irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp) -{ - /* Delay the event slightly to debounce */ - /* Must be a smaller delay than the chrg_full_isr below */ - mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250)); - - return IRQ_HANDLED; -} - -static void sharpsl_chrg_full_timer(unsigned long data) -{ - dev_dbg(sharpsl_pm.dev, "Charge Full at time: %lx\n", jiffies); - - sharpsl_pm.full_count++; - - if (STATUS_AC_IN() == 0) { - dev_dbg(sharpsl_pm.dev, "Charge Full: AC removed - stop charging!\n"); - if (sharpsl_pm.charge_mode == CHRG_ON) - sharpsl_charge_off(); - } else if (sharpsl_pm.full_count < 2) { - dev_dbg(sharpsl_pm.dev, "Charge Full: Count too low\n"); - schedule_work(&toggle_charger); - } else if (time_after(jiffies, sharpsl_pm.charge_start_time + SHARPSL_CHARGE_FINISH_TIME)) { - dev_dbg(sharpsl_pm.dev, "Charge Full: Interrupt generated too slowly - retry.\n"); - schedule_work(&toggle_charger); - } else { - sharpsl_charge_off(); - sharpsl_pm.charge_mode = CHRG_DONE; - dev_dbg(sharpsl_pm.dev, "Charge Full: Charging Finished\n"); - } -} - -/* Charging Finished Interrupt (Not present on Corgi) */ -/* Can trigger at the same time as an AC staus change so - delay until after that has been processed */ -static irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp) -{ - if (sharpsl_pm.flags & SHARPSL_SUSPENDED) - return IRQ_HANDLED; - - /* delay until after any ac interrupt */ - mod_timer(&sharpsl_pm.chrg_full_timer, jiffies + msecs_to_jiffies(500)); - - return IRQ_HANDLED; -} - -static irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp) -{ - int is_fatal = 0; - - if (STATUS_BATT_LOCKED() == 0) { - dev_err(sharpsl_pm.dev, "Battery now Unlocked! Suspending.\n"); - is_fatal = 1; - } - - if (sharpsl_pm.machinfo->gpio_fatal && (STATUS_FATAL() == 0)) { - dev_err(sharpsl_pm.dev, "Fatal Batt Error! Suspending.\n"); - is_fatal = 1; - } - - if (!(sharpsl_pm.flags & SHARPSL_APM_QUEUED) && is_fatal) { - sharpsl_pm.flags |= SHARPSL_APM_QUEUED; - apm_queue_event(APM_CRITICAL_SUSPEND); - } - - return IRQ_HANDLED; -} - -/* - * Maintain an average of the last 10 readings - */ -#define SHARPSL_CNV_VALUE_NUM 10 -static int sharpsl_ad_index; - -static void sharpsl_average_clear(void) -{ - sharpsl_ad_index = 0; -} - -static int sharpsl_average_value(int ad) -{ - int i, ad_val = 0; - static int sharpsl_ad[SHARPSL_CNV_VALUE_NUM+1]; - - if (sharpsl_pm.battstat.mainbat_status != APM_BATTERY_STATUS_HIGH) { - sharpsl_ad_index = 0; - return ad; - } - - sharpsl_ad[sharpsl_ad_index] = ad; - sharpsl_ad_index++; - if (sharpsl_ad_index >= SHARPSL_CNV_VALUE_NUM) { - for (i=0; i < (SHARPSL_CNV_VALUE_NUM-1); i++) - sharpsl_ad[i] = sharpsl_ad[i+1]; - sharpsl_ad_index = SHARPSL_CNV_VALUE_NUM - 1; - } - for (i=0; i < sharpsl_ad_index; i++) - ad_val += sharpsl_ad[i]; - - return (ad_val / sharpsl_ad_index); -} - - /* * Read MAX1111 ADC */ -static int read_max1111(int channel) +int sharpsl_pm_pxa_read_max1111(int channel) { return corgi_ssp_max1111_get((channel << MAXCTRL_SEL_SH) | MAXCTRL_PD0 | MAXCTRL_PD1 | MAXCTRL_SGL | MAXCTRL_UNI | MAXCTRL_STR); } -static int sharpsl_read_main_battery(void) -{ - return read_max1111(BATT_AD); -} - -static int sharpsl_read_temp(void) +void sharpsl_pm_pxa_init(void) { - int temp; - - sharpsl_pm.machinfo->measure_temp(1); - - mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP); - temp = read_max1111(BATT_THM); - - sharpsl_pm.machinfo->measure_temp(0); - - return temp; -} - -static int sharpsl_read_acin(void) -{ - return read_max1111(JK_VAD); -} - -/* - * Take an array of 5 integers, remove the maximum and minimum values - * and return the average. - */ -static int get_select_val(int *val) -{ - int i, j, k, temp, sum = 0; - - /* Find MAX val */ - temp = val[0]; - j=0; - for (i=1; i<5; i++) { - if (temp < val[i]) { - temp = val[i]; - j = i; - } - } - - /* Find MIN val */ - temp = val[4]; - k=4; - for (i=3; i>=0; i--) { - if (temp > val[i]) { - temp = val[i]; - k = i; - } - } - - for (i=0; i<5; i++) - if (i != j && i != k ) - sum += val[i]; - - dev_dbg(sharpsl_pm.dev, "Average: %d from values: %d, %d, %d, %d, %d\n", sum/3, val[0], val[1], val[2], val[3], val[4]); - - return (sum/3); -} - -static int sharpsl_check_battery_temp(void) -{ - int val, i, buff[5]; - - /* Check battery temperature */ - for (i=0; i<5; i++) { - mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_TEMP); - buff[i] = sharpsl_read_temp(); - } - - val = get_select_val(buff); - - dev_dbg(sharpsl_pm.dev, "Temperature: %d\n", val); - if (val > SHARPSL_CHARGE_ON_TEMP) - return -1; - - return 0; -} - -static int sharpsl_check_battery_voltage(void) -{ - int val, i, buff[5]; - - /* disable charge, enable discharge */ - CHARGE_OFF(); - DISCHARGE_ON(); - mdelay(SHARPSL_WAIT_DISCHARGE_ON); - - if (sharpsl_pm.machinfo->discharge1) - sharpsl_pm.machinfo->discharge1(1); - - /* Check battery voltage */ - for (i=0; i<5; i++) { - buff[i] = sharpsl_read_main_battery(); - mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); - } - - if (sharpsl_pm.machinfo->discharge1) - sharpsl_pm.machinfo->discharge1(0); - - DISCHARGE_OFF(); - - val = get_select_val(buff); - dev_dbg(sharpsl_pm.dev, "Battery Voltage: %d\n", val); - - if (val < SHARPSL_CHARGE_ON_VOLT) - return -1; - - return 0; -} - -static int sharpsl_ac_check(void) -{ - int temp, i, buff[5]; - - for (i=0; i<5; i++) { - buff[i] = sharpsl_read_acin(); - mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_ACIN); - } - - temp = get_select_val(buff); - dev_dbg(sharpsl_pm.dev, "AC Voltage: %d\n",temp); - - if ((temp > SHARPSL_CHARGE_ON_ACIN_HIGH) || (temp < SHARPSL_CHARGE_ON_ACIN_LOW)) { - dev_err(sharpsl_pm.dev, "Error: AC check failed.\n"); - return -1; - } - - return 0; -} - -#ifdef CONFIG_PM -static int sharpsl_pm_suspend(struct platform_device *pdev, pm_message_t state) -{ - sharpsl_pm.flags |= SHARPSL_SUSPENDED; - flush_scheduled_work(); - - if (sharpsl_pm.charge_mode == CHRG_ON) - sharpsl_pm.flags |= SHARPSL_DO_OFFLINE_CHRG; - else - sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG; - - return 0; -} - -static int sharpsl_pm_resume(struct platform_device *pdev) -{ - /* Clear the reset source indicators as they break the bootloader upon reboot */ - RCSR = 0x0f; - sharpsl_average_clear(); - sharpsl_pm.flags &= ~SHARPSL_APM_QUEUED; - sharpsl_pm.flags &= ~SHARPSL_SUSPENDED; - - return 0; -} - -static void corgi_goto_sleep(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state) -{ - dev_dbg(sharpsl_pm.dev, "Time is: %08x\n",RCNR); - - dev_dbg(sharpsl_pm.dev, "Offline Charge Activate = %d\n",sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG); - /* not charging and AC-IN! */ - - if ((sharpsl_pm.flags & SHARPSL_DO_OFFLINE_CHRG) && (STATUS_AC_IN() != 0)) { - dev_dbg(sharpsl_pm.dev, "Activating Offline Charger...\n"); - sharpsl_pm.charge_mode = CHRG_OFF; - sharpsl_pm.flags &= ~SHARPSL_DO_OFFLINE_CHRG; - sharpsl_off_charge_battery(); - } - - sharpsl_pm.machinfo->presuspend(); - - PEDR = 0xffffffff; /* clear it */ - - sharpsl_pm.flags &= ~SHARPSL_ALARM_ACTIVE; - if ((sharpsl_pm.charge_mode == CHRG_ON) && ((alarm_enable && ((alarm_time - RCNR) > (SHARPSL_BATCHK_TIME_SUSPEND + 30))) || !alarm_enable)) { - RTSR &= RTSR_ALE; - RTAR = RCNR + SHARPSL_BATCHK_TIME_SUSPEND; - dev_dbg(sharpsl_pm.dev, "Charging alarm at: %08x\n",RTAR); - sharpsl_pm.flags |= SHARPSL_ALARM_ACTIVE; - } else if (alarm_enable) { - RTSR &= RTSR_ALE; - RTAR = alarm_time; - dev_dbg(sharpsl_pm.dev, "User alarm at: %08x\n",RTAR); - } else { - dev_dbg(sharpsl_pm.dev, "No alarms set.\n"); - } - - pxa_pm_enter(state); - - sharpsl_pm.machinfo->postsuspend(); - - dev_dbg(sharpsl_pm.dev, "Corgi woken up from suspend: %08x\n",PEDR); -} - -static int corgi_enter_suspend(unsigned long alarm_time, unsigned int alarm_enable, suspend_state_t state) -{ - if (!sharpsl_pm.machinfo->should_wakeup(!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE) && alarm_enable) ) - { - if (!(sharpsl_pm.flags & SHARPSL_ALARM_ACTIVE)) { - dev_dbg(sharpsl_pm.dev, "No user triggered wakeup events and not charging. Strange. Suspend.\n"); - corgi_goto_sleep(alarm_time, alarm_enable, state); - return 1; - } - if(sharpsl_off_charge_battery()) { - dev_dbg(sharpsl_pm.dev, "Charging. Suspend...\n"); - corgi_goto_sleep(alarm_time, alarm_enable, state); - return 1; - } - dev_dbg(sharpsl_pm.dev, "User triggered wakeup in offline charger.\n"); - } - - if ((STATUS_BATT_LOCKED() == 0) || (sharpsl_fatal_check() < 0) ) - { - dev_err(sharpsl_pm.dev, "Fatal condition. Suspend.\n"); - corgi_goto_sleep(alarm_time, alarm_enable, state); - return 1; - } - - return 0; -} - -static int corgi_pxa_pm_enter(suspend_state_t state) -{ - unsigned long alarm_time = RTAR; - unsigned int alarm_status = ((RTSR & RTSR_ALE) != 0); - - dev_dbg(sharpsl_pm.dev, "SharpSL suspending for first time.\n"); - - corgi_goto_sleep(alarm_time, alarm_status, state); - - while (corgi_enter_suspend(alarm_time,alarm_status,state)) - {} - - dev_dbg(sharpsl_pm.dev, "SharpSL resuming...\n"); - - return 0; -} -#endif - - -/* - * Check for fatal battery errors - * Fatal returns -1 - */ -static int sharpsl_fatal_check(void) -{ - int buff[5], temp, i, acin; - - dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check entered\n"); - - /* Check AC-Adapter */ - acin = STATUS_AC_IN(); - - if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) { - CHARGE_OFF(); - udelay(100); - DISCHARGE_ON(); /* enable discharge */ - mdelay(SHARPSL_WAIT_DISCHARGE_ON); - } - - if (sharpsl_pm.machinfo->discharge1) - sharpsl_pm.machinfo->discharge1(1); - - /* Check battery : check inserting battery ? */ - for (i=0; i<5; i++) { - buff[i] = sharpsl_read_main_battery(); - mdelay(SHARPSL_CHECK_BATTERY_WAIT_TIME_VOLT); - } - - if (sharpsl_pm.machinfo->discharge1) - sharpsl_pm.machinfo->discharge1(0); - - if (acin && (sharpsl_pm.charge_mode == CHRG_ON)) { - udelay(100); - CHARGE_ON(); - DISCHARGE_OFF(); - } - - temp = get_select_val(buff); - dev_dbg(sharpsl_pm.dev, "sharpsl_fatal_check: acin: %d, discharge voltage: %d, no discharge: %d\n", acin, temp, sharpsl_read_main_battery()); - - if ((acin && (temp < SHARPSL_FATAL_ACIN_VOLT)) || - (!acin && (temp < SHARPSL_FATAL_NOACIN_VOLT))) - return -1; - return 0; -} - -static int sharpsl_off_charge_error(void) -{ - dev_err(sharpsl_pm.dev, "Offline Charger: Error occured.\n"); - CHARGE_OFF(); - CHARGE_LED_ERR(); - sharpsl_pm.charge_mode = CHRG_ERROR; - return 1; -} - -/* - * Charging Control while suspended - * Return 1 - go straight to sleep - * Return 0 - sleep or wakeup depending on other factors - */ -static int sharpsl_off_charge_battery(void) -{ - int time; - - dev_dbg(sharpsl_pm.dev, "Charge Mode: %d\n", sharpsl_pm.charge_mode); - - if (sharpsl_pm.charge_mode == CHRG_OFF) { - dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 1\n"); - - /* AC Check */ - if ((sharpsl_ac_check() < 0) || (sharpsl_check_battery_temp() < 0)) - return sharpsl_off_charge_error(); - - /* Start Charging */ - CHARGE_LED_ON(); - CHARGE_OFF(); - mdelay(SHARPSL_CHARGE_WAIT_TIME); - CHARGE_ON(); - - sharpsl_pm.charge_mode = CHRG_ON; - sharpsl_pm.full_count = 0; - - return 1; - } else if (sharpsl_pm.charge_mode != CHRG_ON) { - return 1; - } - - if (sharpsl_pm.full_count == 0) { - int time; - - dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 2\n"); - - if ((sharpsl_check_battery_temp() < 0) || (sharpsl_check_battery_voltage() < 0)) - return sharpsl_off_charge_error(); - - CHARGE_OFF(); - mdelay(SHARPSL_CHARGE_WAIT_TIME); - CHARGE_ON(); - sharpsl_pm.charge_mode = CHRG_ON; - - mdelay(SHARPSL_CHARGE_CO_CHECK_TIME); - - time = RCNR; - while(1) { - /* Check if any wakeup event had occured */ - if (sharpsl_pm.machinfo->charger_wakeup() != 0) - return 0; - /* Check for timeout */ - if ((RCNR - time) > SHARPSL_WAIT_CO_TIME) - return 1; - if (STATUS_CHRG_FULL()) { - dev_dbg(sharpsl_pm.dev, "Offline Charger: Charge full occured. Retrying to check\n"); - sharpsl_pm.full_count++; - CHARGE_OFF(); - mdelay(SHARPSL_CHARGE_WAIT_TIME); - CHARGE_ON(); - return 1; - } - } - } - - dev_dbg(sharpsl_pm.dev, "Offline Charger: Step 3\n"); - - mdelay(SHARPSL_CHARGE_CO_CHECK_TIME); - - time = RCNR; - while(1) { - /* Check if any wakeup event had occured */ - if (sharpsl_pm.machinfo->charger_wakeup() != 0) - return 0; - /* Check for timeout */ - if ((RCNR-time) > SHARPSL_WAIT_CO_TIME) { - if (sharpsl_pm.full_count > SHARPSL_CHARGE_RETRY_CNT) { - dev_dbg(sharpsl_pm.dev, "Offline Charger: Not charged sufficiently. Retrying.\n"); - sharpsl_pm.full_count = 0; - } - sharpsl_pm.full_count++; - return 1; - } - if (STATUS_CHRG_FULL()) { - dev_dbg(sharpsl_pm.dev, "Offline Charger: Charging complete.\n"); - CHARGE_LED_OFF(); - CHARGE_OFF(); - sharpsl_pm.charge_mode = CHRG_DONE; - return 1; - } - } -} - - -static ssize_t battery_percentage_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_percent); -} - -static ssize_t battery_voltage_show(struct device *dev, struct device_attribute *attr, char *buf) -{ - return sprintf(buf, "%d\n",sharpsl_pm.battstat.mainbat_voltage); -} - -static DEVICE_ATTR(battery_percentage, 0444, battery_percentage_show, NULL); -static DEVICE_ATTR(battery_voltage, 0444, battery_voltage_show, NULL); - -extern void (*apm_get_power_status)(struct apm_power_info *); - -static void sharpsl_apm_get_power_status(struct apm_power_info *info) -{ - info->ac_line_status = sharpsl_pm.battstat.ac_status; - - if (sharpsl_pm.charge_mode == CHRG_ON) - info->battery_status = APM_BATTERY_STATUS_CHARGING; - else - info->battery_status = sharpsl_pm.battstat.mainbat_status; - - info->battery_flag = (1 << info->battery_status); - info->battery_life = sharpsl_pm.battstat.mainbat_percent; -} - -static struct pm_ops sharpsl_pm_ops = { - .pm_disk_mode = PM_DISK_FIRMWARE, - .prepare = pxa_pm_prepare, - .enter = corgi_pxa_pm_enter, - .finish = pxa_pm_finish, -}; - -static int __init sharpsl_pm_probe(struct platform_device *pdev) -{ - if (!pdev->dev.platform_data) - return -EINVAL; - - sharpsl_pm.dev = &pdev->dev; - sharpsl_pm.machinfo = pdev->dev.platform_data; - sharpsl_pm.charge_mode = CHRG_OFF; - sharpsl_pm.flags = 0; - - sharpsl_pm.machinfo->init(); - - init_timer(&sharpsl_pm.ac_timer); - sharpsl_pm.ac_timer.function = sharpsl_ac_timer; - - init_timer(&sharpsl_pm.chrg_full_timer); - sharpsl_pm.chrg_full_timer.function = sharpsl_chrg_full_timer; - pxa_gpio_mode(sharpsl_pm.machinfo->gpio_acin | GPIO_IN); pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batfull | GPIO_IN); pxa_gpio_mode(sharpsl_pm.machinfo->gpio_batlock | GPIO_IN); @@ -938,26 +165,10 @@ static int __init sharpsl_pm_probe(struct platform_device *pdev) } else set_irq_type(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull),IRQT_RISING); } - - device_create_file(&pdev->dev, &dev_attr_battery_percentage); - device_create_file(&pdev->dev, &dev_attr_battery_voltage); - - apm_get_power_status = sharpsl_apm_get_power_status; - - pm_set_ops(&sharpsl_pm_ops); - - mod_timer(&sharpsl_pm.ac_timer, jiffies + msecs_to_jiffies(250)); - - return 0; } -static int sharpsl_pm_remove(struct platform_device *pdev) +void sharpsl_pm_pxa_remove(void) { - pm_set_ops(NULL); - - device_remove_file(&pdev->dev, &dev_attr_battery_percentage); - device_remove_file(&pdev->dev, &dev_attr_battery_voltage); - free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_acin), sharpsl_ac_isr); free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batlock), sharpsl_fatal_isr); @@ -966,32 +177,4 @@ static int sharpsl_pm_remove(struct platform_device *pdev) if (!machine_is_corgi()) free_irq(IRQ_GPIO(sharpsl_pm.machinfo->gpio_batfull), sharpsl_chrg_full_isr); - - del_timer_sync(&sharpsl_pm.chrg_full_timer); - del_timer_sync(&sharpsl_pm.ac_timer); - - return 0; } - -static struct platform_driver sharpsl_pm_driver = { - .probe = sharpsl_pm_probe, - .remove = sharpsl_pm_remove, - .suspend = sharpsl_pm_suspend, - .resume = sharpsl_pm_resume, - .driver = { - .name = "sharpsl-pm", - }, -}; - -static int __devinit sharpsl_pm_init(void) -{ - return platform_driver_register(&sharpsl_pm_driver); -} - -static void sharpsl_pm_exit(void) -{ - platform_driver_unregister(&sharpsl_pm_driver); -} - -late_initcall(sharpsl_pm_init); -module_exit(sharpsl_pm_exit); diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c index 3ce7486d..76a5c26 100644 --- a/arch/arm/mach-pxa/spitz_pm.c +++ b/arch/arm/mach-pxa/spitz_pm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -33,19 +34,7 @@ static void spitz_charger_init(void) { pxa_gpio_mode(SPITZ_GPIO_KEY_INT | GPIO_IN); pxa_gpio_mode(SPITZ_GPIO_SYNC | GPIO_IN); -} - -static void spitz_charge_led(int val) -{ - if (val == SHARPSL_LED_ERROR) { - dev_dbg(sharpsl_pm.dev, "Charge LED Error\n"); - } else if (val == SHARPSL_LED_ON) { - dev_dbg(sharpsl_pm.dev, "Charge LED On\n"); - set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE); - } else { - dev_dbg(sharpsl_pm.dev, "Charge LED Off\n"); - reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_LED_ORANGE); - } + sharpsl_pm_pxa_init(); } static void spitz_measure_temp(int on) @@ -92,7 +81,7 @@ static void spitz_discharge1(int on) static void spitz_presuspend(void) { - spitz_last_ac_status = STATUS_AC_IN(); + spitz_last_ac_status = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN); /* GPIO Sleep Register */ PGSR0 = 0x00144018; @@ -138,7 +127,7 @@ static void spitz_postsuspend(void) static int spitz_should_wakeup(unsigned int resume_on_alarm) { int is_resume = 0; - int acin = STATUS_AC_IN(); + int acin = sharpsl_pm.machinfo->read_devdata(SHARPSL_STATUS_ACIN); if (spitz_last_ac_status != acin) { if (acin) { @@ -148,8 +137,8 @@ static int spitz_should_wakeup(unsigned int resume_on_alarm) } else { /* charge off */ dev_dbg(sharpsl_pm.dev, "AC Removed\n"); - CHARGE_LED_OFF(); - CHARGE_OFF(); + sharpsl_pm_led(SHARPSL_LED_OFF); + sharpsl_pm.machinfo->charge(0); sharpsl_pm.charge_mode = CHRG_OFF; } spitz_last_ac_status = acin; @@ -175,25 +164,41 @@ static unsigned long spitz_charger_wakeup(void) return (~GPLR0 & GPIO_bit(SPITZ_GPIO_KEY_INT)) | (GPLR0 & GPIO_bit(SPITZ_GPIO_SYNC)); } -static int spitz_acin_status(void) +unsigned long spitzpm_read_devdata(int type) { - return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0); + switch(type) { + case SHARPSL_STATUS_ACIN: + return (((~GPLR(SPITZ_GPIO_AC_IN)) & GPIO_bit(SPITZ_GPIO_AC_IN)) != 0); + case SHARPSL_STATUS_LOCK: + return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batlock); + case SHARPSL_STATUS_CHRGFULL: + return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_batfull); + case SHARPSL_STATUS_FATAL: + return READ_GPIO_BIT(sharpsl_pm.machinfo->gpio_fatal); + case SHARPSL_ACIN_VOLT: + return sharpsl_pm_pxa_read_max1111(MAX1111_ACIN_VOLT); + case SHARPSL_BATT_TEMP: + return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_TEMP); + case SHARPSL_BATT_VOLT: + default: + return sharpsl_pm_pxa_read_max1111(MAX1111_BATT_VOLT); + } } struct sharpsl_charger_machinfo spitz_pm_machinfo = { .init = spitz_charger_init, + .exit = sharpsl_pm_pxa_remove, .gpio_batlock = SPITZ_GPIO_BAT_COVER, .gpio_acin = SPITZ_GPIO_AC_IN, .gpio_batfull = SPITZ_GPIO_CHRG_FULL, .gpio_fatal = SPITZ_GPIO_FATAL_BAT, - .status_acin = spitz_acin_status, .discharge = spitz_discharge, .discharge1 = spitz_discharge1, .charge = spitz_charge, - .chargeled = spitz_charge_led, .measure_temp = spitz_measure_temp, .presuspend = spitz_presuspend, .postsuspend = spitz_postsuspend, + .read_devdata = spitzpm_read_devdata, .charger_wakeup = spitz_charger_wakeup, .should_wakeup = spitz_should_wakeup, .bat_levels = 40, diff --git a/drivers/video/backlight/corgi_bl.c b/drivers/video/backlight/corgi_bl.c index 6a219b2..d0aaf45 100644 --- a/drivers/video/backlight/corgi_bl.c +++ b/drivers/video/backlight/corgi_bl.c @@ -20,6 +20,7 @@ #include #include +#include #define CORGI_DEFAULT_INTENSITY 0x1f #define CORGI_LIMIT_MASK 0x0b diff --git a/include/asm-arm/hardware/sharpsl_pm.h b/include/asm-arm/hardware/sharpsl_pm.h new file mode 100644 index 0000000..36983e5 --- /dev/null +++ b/include/asm-arm/hardware/sharpsl_pm.h @@ -0,0 +1,94 @@ +/* + * SharpSL Battery/PM Driver + * + * Copyright (c) 2004-2005 Richard Purdie + * + * 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 + +struct sharpsl_charger_machinfo { + void (*init)(void); + void (*exit)(void); + int gpio_acin; + int gpio_batfull; + int gpio_batlock; + int gpio_fatal; + void (*discharge)(int); + void (*discharge1)(int); + void (*charge)(int); + void (*measure_temp)(int); + void (*presuspend)(void); + void (*postsuspend)(void); + unsigned long (*read_devdata)(int); +#define SHARPSL_BATT_VOLT 1 +#define SHARPSL_BATT_TEMP 2 +#define SHARPSL_ACIN_VOLT 3 +#define SHARPSL_STATUS_ACIN 4 +#define SHARPSL_STATUS_LOCK 5 +#define SHARPSL_STATUS_CHRGFULL 6 +#define SHARPSL_STATUS_FATAL 7 + unsigned long (*charger_wakeup)(void); + int (*should_wakeup)(unsigned int resume_on_alarm); + int bat_levels; + struct battery_thresh *bat_levels_noac; + struct battery_thresh *bat_levels_acin; + int status_high_acin; + int status_low_acin; + int status_high_noac; + int status_low_noac; +}; + +struct battery_thresh { + int voltage; + int percentage; +}; + +struct battery_stat { + int ac_status; /* APM AC Present/Not Present */ + int mainbat_status; /* APM Main Battery Status */ + int mainbat_percent; /* Main Battery Percentage Charge */ + int mainbat_voltage; /* Main Battery Voltage */ +}; + +struct sharpsl_pm_status { + struct device *dev; + struct timer_list ac_timer; + struct timer_list chrg_full_timer; + + int charge_mode; +#define CHRG_ERROR (-1) +#define CHRG_OFF (0) +#define CHRG_ON (1) +#define CHRG_DONE (2) + + unsigned int flags; +#define SHARPSL_SUSPENDED (1 << 0) /* Device is Suspended */ +#define SHARPSL_ALARM_ACTIVE (1 << 1) /* Alarm is for charging event (not user) */ +#define SHARPSL_BL_LIMIT (1 << 2) /* Backlight Intensity Limited */ +#define SHARPSL_APM_QUEUED (1 << 3) /* APM Event Queued */ +#define SHARPSL_DO_OFFLINE_CHRG (1 << 4) /* Trigger the offline charger */ + + int full_count; + unsigned long charge_start_time; + struct sharpsl_charger_machinfo *machinfo; + struct battery_stat battstat; +}; + +extern struct sharpsl_pm_status sharpsl_pm; + + +#define SHARPSL_LED_ERROR 2 +#define SHARPSL_LED_ON 1 +#define SHARPSL_LED_OFF 0 + +void sharpsl_battery_kick(void); +void sharpsl_pm_led(int val); +irqreturn_t sharpsl_ac_isr(int irq, void *dev_id, struct pt_regs *fp); +irqreturn_t sharpsl_chrg_full_isr(int irq, void *dev_id, struct pt_regs *fp); +irqreturn_t sharpsl_fatal_isr(int irq, void *dev_id, struct pt_regs *fp); + -- cgit v0.10.2 From 53b7c2b243bd31f857dddabd9339f2dd6ae3fb67 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 20:44:55 +0000 Subject: [ARM] 3229/1: Remove uneeded ARM apm dependency on PM_LEGACY Patch from Richard Purdie ARM doesn't use ACPI so ARM's apm implementation has no need to depend on PM_LEGACY. This patch removes that dependency. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index cb41310..16a5d52 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -660,7 +660,6 @@ source "kernel/power/Kconfig" config APM tristate "Advanced Power Management Emulation" - depends on PM_LEGACY ---help--- APM is a BIOS specification for saving power using several different techniques. This is mostly useful for battery powered laptops with diff --git a/arch/arm/kernel/apm.c b/arch/arm/kernel/apm.c index a2843be..b9df1b7 100644 --- a/arch/arm/kernel/apm.c +++ b/arch/arm/kernel/apm.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -81,6 +80,7 @@ struct apm_user { */ static int suspends_pending; static int apm_disabled; +static int arm_apm_active; static DECLARE_WAIT_QUEUE_HEAD(apm_waitqueue); static DECLARE_WAIT_QUEUE_HEAD(apm_suspend_waitqueue); @@ -477,9 +477,9 @@ static int kapmd(void *arg) apm_event_t event; wait_event_interruptible(kapmd_wait, - !queue_empty(&kapmd_queue) || !pm_active); + !queue_empty(&kapmd_queue) || !arm_apm_active); - if (!pm_active) + if (!arm_apm_active) break; spin_lock_irq(&kapmd_queue_lock); @@ -522,16 +522,11 @@ static int __init apm_init(void) return -ENODEV; } - if (PM_IS_ACTIVE()) { - printk(KERN_NOTICE "apm: overridden by ACPI.\n"); - return -EINVAL; - } - - pm_active = 1; + arm_apm_active = 1; ret = kernel_thread(kapmd, NULL, CLONE_KERNEL); if (ret < 0) { - pm_active = 0; + arm_apm_active = 0; return ret; } @@ -543,7 +538,7 @@ static int __init apm_init(void) if (ret != 0) { remove_proc_entry("apm", NULL); - pm_active = 0; + arm_apm_active = 0; wake_up(&kapmd_wait); wait_for_completion(&kapmd_exit); } @@ -556,7 +551,7 @@ static void __exit apm_exit(void) misc_deregister(&apm_device); remove_proc_entry("apm", NULL); - pm_active = 0; + arm_apm_active = 0; wake_up(&kapmd_wait); wait_for_completion(&kapmd_exit); } -- cgit v0.10.2 From 945b957972844881002ab4f68534581f4427a30b Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Thu, 5 Jan 2006 20:44:57 +0000 Subject: [ARM] 3230/1: Sharp Scoop: Fix Shared Power Control Issues Patch from Richard Purdie The SL-Cxx00 devices have a power control register in SCOOP that is shared by both CF and MMC/SD card slots. The CF reset code was resetting this register leading to various lockups as the MMC power was suddenly lost. This patch handles the CPR register in a more sensitive manner. It also removes some unneeded collie specific calls as the reset code handles this. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/common/scoop.c b/arch/arm/common/scoop.c index 0c3cbd9..b6de43e 100644 --- a/arch/arm/common/scoop.c +++ b/arch/arm/common/scoop.c @@ -33,7 +33,6 @@ void reset_scoop(struct device *dev) SCOOP_REG(sdev->base,SCOOP_MCR) = 0x0100; // 00 SCOOP_REG(sdev->base,SCOOP_CDR) = 0x0000; // 04 - SCOOP_REG(sdev->base,SCOOP_CPR) = 0x0000; // 0C SCOOP_REG(sdev->base,SCOOP_CCR) = 0x0000; // 10 SCOOP_REG(sdev->base,SCOOP_IMR) = 0x0000; // 18 SCOOP_REG(sdev->base,SCOOP_IRM) = 0x00FF; // 14 @@ -154,6 +153,7 @@ int __init scoop_probe(struct platform_device *pdev) SCOOP_REG(devptr->base, SCOOP_MCR) = 0x0140; reset_scoop(&pdev->dev); + SCOOP_REG(devptr->base, SCOOP_CPR) = 0x0000; SCOOP_REG(devptr->base, SCOOP_GPCR) = inf->io_dir & 0xffff; SCOOP_REG(devptr->base, SCOOP_GPWR) = inf->io_out & 0xffff; diff --git a/arch/arm/mach-pxa/spitz.c b/arch/arm/mach-pxa/spitz.c index 5d34abc..f2007db 100644 --- a/arch/arm/mach-pxa/spitz.c +++ b/arch/arm/mach-pxa/spitz.c @@ -127,10 +127,12 @@ static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) cpr &= ~0x0002; if (device == SPITZ_PWR_SD) cpr &= ~0x0004; - write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); if (!(cpr & 0x0002) && !(cpr & 0x0004)) { + write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); mdelay(1); reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); + } else { + write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); } } } diff --git a/drivers/pcmcia/pxa2xx_sharpsl.c b/drivers/pcmcia/pxa2xx_sharpsl.c index 56c5883..4fbd995 100644 --- a/drivers/pcmcia/pxa2xx_sharpsl.c +++ b/drivers/pcmcia/pxa2xx_sharpsl.c @@ -36,9 +36,18 @@ struct scoop_pcmcia_config *platform_scoop_config; #define SCOOP_DEV platform_scoop_config->devs -static void sharpsl_pcmcia_init_reset(struct scoop_pcmcia_dev *scoopdev) +static void sharpsl_pcmcia_init_reset(struct soc_pcmcia_socket *skt) { + struct scoop_pcmcia_dev *scoopdev = &SCOOP_DEV[skt->nr]; + reset_scoop(scoopdev->dev); + + /* Shared power controls need to be handled carefully */ + if (platform_scoop_config->power_ctrl) + platform_scoop_config->power_ctrl(scoopdev->dev, 0x0000, skt->nr); + else + write_scoop_reg(scoopdev->dev, SCOOP_CPR, 0x0000); + scoopdev->keep_vs = NO_KEEP_VS; scoopdev->keep_rd = 0; } @@ -208,26 +217,17 @@ static int sharpsl_pcmcia_configure_socket(struct soc_pcmcia_socket *skt, static void sharpsl_pcmcia_socket_init(struct soc_pcmcia_socket *skt) { - sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]); + sharpsl_pcmcia_init_reset(skt); /* Enable interrupt */ write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_IMR, 0x00C0); write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_MCR, 0x0101); SCOOP_DEV[skt->nr].keep_vs = NO_KEEP_VS; - - if (machine_is_collie()) - /* We need to disable SS_OUTPUT_ENA here. */ - write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080); } static void sharpsl_pcmcia_socket_suspend(struct soc_pcmcia_socket *skt) { - /* CF_BUS_OFF */ - sharpsl_pcmcia_init_reset(&SCOOP_DEV[skt->nr]); - - if (machine_is_collie()) - /* We need to disable SS_OUTPUT_ENA here. */ - write_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR, read_scoop_reg(SCOOP_DEV[skt->nr].dev, SCOOP_CPR) & ~0x0080); + sharpsl_pcmcia_init_reset(skt); } static struct pcmcia_low_level sharpsl_pcmcia_ops = { -- cgit v0.10.2 From 6a2273d6fc627d28a4de9beadf77ae6636b1e5d0 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 5 Jan 2006 20:44:58 +0000 Subject: [ARM] 3231/1: mx1ads board support cleanup Patch from Sascha Hauer - remove unnecessary mappings - rename mx1ads_device to cs89x0_device, because that's what it is - fix io/irq resource for cs89x0 device Signed-off-by: Sascha Hauer Signed-off-by: Russell King diff --git a/arch/arm/mach-imx/mx1ads.c b/arch/arm/mach-imx/mx1ads.c index 708e1b3..c9e0cd8 100644 --- a/arch/arm/mach-imx/mx1ads.c +++ b/arch/arm/mach-imx/mx1ads.c @@ -29,27 +29,27 @@ #include "generic.h" #include -static struct resource mx1ads_resources[] = { +static struct resource cs89x0_resources[] = { [0] = { - .start = IMX_CS4_VIRT, - .end = IMX_CS4_VIRT + 16, + .start = IMX_CS4_PHYS + 0x300, + .end = IMX_CS4_PHYS + 0x300 + 16, .flags = IORESOURCE_MEM, }, [1] = { - .start = 13, - .end = 13, + .start = IRQ_GPIOC(17), + .end = IRQ_GPIOC(17), .flags = IORESOURCE_IRQ, }, }; -static struct platform_device mx1ads_device = { - .name = "mx1ads", - .num_resources = ARRAY_SIZE(mx1ads_resources), - .resource = mx1ads_resources, +static struct platform_device cs89x0_device = { + .name = "cirrus-cs89x0", + .num_resources = ARRAY_SIZE(cs89x0_resources), + .resource = cs89x0_resources, }; static struct platform_device *devices[] __initdata = { - &mx1ads_device, + &cs89x0_device, }; static void __init @@ -61,45 +61,10 @@ mx1ads_init(void) platform_add_devices(devices, ARRAY_SIZE(devices)); } -static struct map_desc mx1ads_io_desc[] __initdata = { - { - .virtual = IMX_CS0_VIRT, - .pfn = __phys_to_pfn(IMX_CS0_PHYS), - .length = IMX_CS0_SIZE, - .type = MT_DEVICE - }, { - .virtual = IMX_CS1_VIRT, - .pfn = __phys_to_pfn(IMX_CS1_PHYS), - .length = IMX_CS1_SIZE, - .type = MT_DEVICE - }, { - .virtual = IMX_CS2_VIRT, - .pfn = __phys_to_pfn(IMX_CS2_PHYS), - .length = IMX_CS2_SIZE, - .type = MT_DEVICE - }, { - .virtual = IMX_CS3_VIRT, - .pfn = __phys_to_pfn(IMX_CS3_PHYS), - .length = IMX_CS3_SIZE, - .type = MT_DEVICE - }, { - .virtual = IMX_CS4_VIRT, - .pfn = __phys_to_pfn(IMX_CS4_PHYS), - .length = IMX_CS4_SIZE, - .type = MT_DEVICE - }, { - .virtual = IMX_CS5_VIRT, - .pfn = __phys_to_pfn(IMX_CS5_PHYS), - .length = IMX_CS5_SIZE, - .type = MT_DEVICE - } -}; - static void __init mx1ads_map_io(void) { imx_map_io(); - iotable_init(mx1ads_io_desc, ARRAY_SIZE(mx1ads_io_desc)); } MACHINE_START(MX1ADS, "Motorola MX1ADS") -- cgit v0.10.2 From 2b9ac7c15c0c5c9d6057b9e297dabaebd208ffe8 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 5 Jan 2006 20:53:02 +0000 Subject: [ARM] 3217/1: iop331 uarts as platform devices Patch from Dan Williams Convert old-style serial devices to platform devices so that printk's are visible during the boot process. Signed-off-by: Dan Williams Signed-off-by: Deepak Saxena Signed-off-by: Russell King diff --git a/arch/arm/mach-iop3xx/iop331-setup.c b/arch/arm/mach-iop3xx/iop331-setup.c index 53f6061..e6ea1cb 100644 --- a/arch/arm/mach-iop3xx/iop331-setup.c +++ b/arch/arm/mach-iop3xx/iop331-setup.c @@ -18,7 +18,7 @@ #include #include #include -#include +#include #include #include @@ -50,32 +50,74 @@ static struct map_desc iop331_std_desc[] __initdata = { } }; -static struct uart_port iop331_serial_ports[] = { - { - .membase = (char*)(IOP331_UART0_VIRT), - .mapbase = (IOP331_UART0_PHYS), - .irq = IRQ_IOP331_UART0, - .flags = UPF_SKIP_TEST, - .iotype = UPIO_MEM, - .regshift = 2, - .uartclk = IOP331_UART_XTAL, - .line = 0, - .type = PORT_XSCALE, - .fifosize = 32 - } , { - .membase = (char*)(IOP331_UART1_VIRT), - .mapbase = (IOP331_UART1_PHYS), - .irq = IRQ_IOP331_UART1, - .flags = UPF_SKIP_TEST, - .iotype = UPIO_MEM, - .regshift = 2, - .uartclk = IOP331_UART_XTAL, - .line = 1, - .type = PORT_XSCALE, - .fifosize = 32 +static struct resource iop33x_uart0_resources[] = { + [0] = { + .start = IOP331_UART0_PHYS, + .end = IOP331_UART0_PHYS + 0x3f, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_IOP331_UART0, + .end = IRQ_IOP331_UART0, + .flags = IORESOURCE_IRQ + } +}; + +static struct resource iop33x_uart1_resources[] = { + [0] = { + .start = IOP331_UART1_PHYS, + .end = IOP331_UART1_PHYS + 0x3f, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_IOP331_UART1, + .end = IRQ_IOP331_UART1, + .flags = IORESOURCE_IRQ } }; +static struct plat_serial8250_port iop33x_uart0_data[] = { + { + .membase = (char*)(IOP331_UART0_VIRT), + .mapbase = (IOP331_UART0_PHYS), + .irq = IRQ_IOP331_UART0, + .uartclk = IOP331_UART_XTAL, + .regshift = 2, + .iotype = UPIO_MEM, + .flags = UPF_SKIP_TEST, + }, + { }, +}; + +static struct plat_serial8250_port iop33x_uart1_data[] = { + { + .membase = (char*)(IOP331_UART1_VIRT), + .mapbase = (IOP331_UART1_PHYS), + .irq = IRQ_IOP331_UART1, + .uartclk = IOP331_UART_XTAL, + .regshift = 2, + .iotype = UPIO_MEM, + .flags = UPF_SKIP_TEST, + }, + { }, +}; + +static struct platform_device iop33x_uart0 = { + .name = "serial8250", + .id = 0, + .dev.platform_data = iop33x_uart0_data, + .num_resources = 2, + .resource = iop33x_uart0_resources, +}; + +static struct platform_device iop33x_uart1 = { + .name = "serial8250", + .id = 1, + .dev.platform_data = iop33x_uart1_data, + .num_resources = 2, + .resource = iop33x_uart1_resources, +}; + static struct resource iop33x_i2c_0_resources[] = { [0] = { .start = 0xfffff680, @@ -117,6 +159,8 @@ static struct platform_device iop33x_i2c_1_controller = { }; static struct platform_device *iop33x_devices[] __initdata = { + &iop33x_uart0, + &iop33x_uart1, &iop33x_i2c_0_controller, &iop33x_i2c_1_controller }; @@ -133,8 +177,6 @@ void __init iop33x_init(void) void __init iop331_map_io(void) { iotable_init(iop331_std_desc, ARRAY_SIZE(iop331_std_desc)); - early_serial_setup(&iop331_serial_ports[0]); - early_serial_setup(&iop331_serial_ports[1]); } #ifdef CONFIG_ARCH_IOP331 -- cgit v0.10.2 From 54e269ead6e672325866037b0617a72edd1396b9 Mon Sep 17 00:00:00 2001 From: Deepak Saxena Date: Thu, 5 Jan 2006 20:59:29 +0000 Subject: [ARM] 3226/1: IXP4xx runtime expansion bus window size configuration Patch from Deepak Saxena The expansion bus on the IXP46x NPU can be configured for either 32MiB or 16MiB windows and changing the configuration causes the base address for each chip select for each region to change. Because of this, we cannot hardcode the physical base as we currently do. This patch checks the expansion bus configuration registers at runtime to determine the appropriate window size. Note that this requires that the bootloader already configured the device sizes appropriately, but I feel that is valid assumption to make as the bootloader must configure and access the flash window, the output display (LCD, LEDs, etc) window, and other expansion bus devices. Signed-off-by: Deepak Saxena Signed-off-by: Russell King diff --git a/arch/arm/mach-ixp4xx/common.c b/arch/arm/mach-ixp4xx/common.c index 9f33cb2..6b39369 100644 --- a/arch/arm/mach-ixp4xx/common.c +++ b/arch/arm/mach-ixp4xx/common.c @@ -332,11 +332,27 @@ static struct platform_device *ixp46x_devices[] __initdata = { &ixp46x_i2c_controller }; +unsigned long ixp4xx_exp_bus_size; + void __init ixp4xx_sys_init(void) { + ixp4xx_exp_bus_size = SZ_16M; + if (cpu_is_ixp46x()) { + int region; + platform_add_devices(ixp46x_devices, ARRAY_SIZE(ixp46x_devices)); + + for (region = 0; region < 7; region++) { + if((*(IXP4XX_EXP_REG(0x4 * region)) & 0x200)) { + ixp4xx_exp_bus_size = SZ_32M; + break; + } + } } + + printk("IXP4xx: Using %uMiB expansion bus window size\n", + ixp4xx_exp_bus_size >> 20); } diff --git a/arch/arm/mach-ixp4xx/coyote-setup.c b/arch/arm/mach-ixp4xx/coyote-setup.c index 050c927..679594a 100644 --- a/arch/arm/mach-ixp4xx/coyote-setup.c +++ b/arch/arm/mach-ixp4xx/coyote-setup.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -30,8 +31,6 @@ static struct flash_platform_data coyote_flash_data = { }; static struct resource coyote_flash_resource = { - .start = COYOTE_FLASH_BASE, - .end = COYOTE_FLASH_BASE + COYOTE_FLASH_SIZE - 1, .flags = IORESOURCE_MEM, }; @@ -81,6 +80,11 @@ static struct platform_device *coyote_devices[] __initdata = { static void __init coyote_init(void) { + ixp4xx_sys_init(); + + coyote_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); + coyote_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_32M - 1; + *IXP4XX_EXP_CS0 |= IXP4XX_FLASH_WRITABLE; *IXP4XX_EXP_CS1 = *IXP4XX_EXP_CS0; @@ -91,8 +95,6 @@ static void __init coyote_init(void) coyote_uart_data[0].irq = IRQ_IXP4XX_UART1; } - - ixp4xx_sys_init(); platform_add_devices(coyote_devices, ARRAY_SIZE(coyote_devices)); } diff --git a/arch/arm/mach-ixp4xx/gtwx5715-setup.c b/arch/arm/mach-ixp4xx/gtwx5715-setup.c index 29a6d02..0386704 100644 --- a/arch/arm/mach-ixp4xx/gtwx5715-setup.c +++ b/arch/arm/mach-ixp4xx/gtwx5715-setup.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -106,11 +107,9 @@ static struct flash_platform_data gtwx5715_flash_data = { .width = 2, }; -static struct resource gtwx5715_flash_resource = { - .start = GTWX5715_FLASH_BASE, - .end = GTWX5715_FLASH_BASE + GTWX5715_FLASH_SIZE - 1, +static struct gtw5715_flash_resource = { .flags = IORESOURCE_MEM, -}; +} static struct platform_device gtwx5715_flash = { .name = "IXP4XX-Flash", @@ -129,6 +128,14 @@ static struct platform_device *gtwx5715_devices[] __initdata = { static void __init gtwx5715_init(void) { + ixp4xx_sys_init(); + + if (!flash_resource) + printk(KERN_ERR "Could not allocate flash resource\n"); + + gtwx5715_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); + gtwx5715_flash_resource.end = IXP4XX_EXP_BUS_BASE(0) + SZ_8M - 1; + platform_add_devices(gtwx5715_devices, ARRAY_SIZE(gtwx5715_devices)); } diff --git a/arch/arm/mach-ixp4xx/ixdp425-setup.c b/arch/arm/mach-ixp4xx/ixdp425-setup.c index 3a22d84e..c2e105c 100644 --- a/arch/arm/mach-ixp4xx/ixdp425-setup.c +++ b/arch/arm/mach-ixp4xx/ixdp425-setup.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -30,8 +31,6 @@ static struct flash_platform_data ixdp425_flash_data = { }; static struct resource ixdp425_flash_resource = { - .start = IXDP425_FLASH_BASE, - .end = IXDP425_FLASH_BASE + IXDP425_FLASH_SIZE - 1, .flags = IORESOURCE_MEM, }; @@ -108,17 +107,13 @@ static struct platform_device *ixdp425_devices[] __initdata = { &ixdp425_uart }; - static void __init ixdp425_init(void) { ixp4xx_sys_init(); - /* - * IXP465 has 32MB window - */ - if (machine_is_ixdp465()) { - ixdp425_flash_resource.end += IXDP425_FLASH_SIZE; - } + ixdp425_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); + ixdp425_flash_resource.end = + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; platform_add_devices(ixdp425_devices, ARRAY_SIZE(ixdp425_devices)); } diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index bde9648..49998a8 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c @@ -26,8 +26,6 @@ static struct flash_platform_data nas100d_flash_data = { }; static struct resource nas100d_flash_resource = { - .start = NAS100D_FLASH_BASE, - .end = NAS100D_FLASH_BASE + NAS100D_FLASH_SIZE, .flags = IORESOURCE_MEM, }; @@ -115,6 +113,10 @@ static void __init nas100d_init(void) { ixp4xx_sys_init(); + nas100d_flash_resource.start = IXP4XX_EXP_BUS_BASE(0); + nas100d_flash_resource.end = + IXP4XX_EXP_BUS_BASE(0) + ixp4xx_exp_bus_size - 1; + pm_power_off = nas100d_power_off; platform_add_devices(nas100d_devices, ARRAY_SIZE(nas100d_devices)); diff --git a/include/asm-arm/arch-ixp4xx/coyote.h b/include/asm-arm/arch-ixp4xx/coyote.h index dd0c2d2..7ac9ba2 100644 --- a/include/asm-arm/arch-ixp4xx/coyote.h +++ b/include/asm-arm/arch-ixp4xx/coyote.h @@ -16,9 +16,6 @@ #error "Do not include this directly, instead #include " #endif -#define COYOTE_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS -#define COYOTE_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE * 2 - /* PCI controller GPIO to IRQ pin mappings */ #define COYOTE_PCI_SLOT0_PIN 6 #define COYOTE_PCI_SLOT1_PIN 11 @@ -26,7 +23,7 @@ #define COYOTE_PCI_SLOT0_DEVID 14 #define COYOTE_PCI_SLOT1_DEVID 15 -#define COYOTE_IDE_BASE_PHYS IXP4XX_EXP_BUS_CS3_BASE_PHYS +#define COYOTE_IDE_BASE_PHYS IXP4XX_EXP_BUS_BASE(3) #define COYOTE_IDE_BASE_VIRT 0xFFFE1000 #define COYOTE_IDE_REGION_SIZE 0x1000 diff --git a/include/asm-arm/arch-ixp4xx/gtwx5715.h b/include/asm-arm/arch-ixp4xx/gtwx5715.h index fc460af..c3069d6 100644 --- a/include/asm-arm/arch-ixp4xx/gtwx5715.h +++ b/include/asm-arm/arch-ixp4xx/gtwx5715.h @@ -57,10 +57,6 @@ #define GTWX5715_GPIO13_IRQ IRQ_IXP4XX_SW_INT1 #define GTWX5715_GPIO14_IRQ IRQ_IXP4XX_SW_INT2 - -#define GTWX5715_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS -#define GTWX5715_FLASH_SIZE (0x00800000) - /* PCI controller GPIO to IRQ pin mappings INTA INTB diff --git a/include/asm-arm/arch-ixp4xx/ixdp425.h b/include/asm-arm/arch-ixp4xx/ixdp425.h index 7d21bf9..3d3820d 100644 --- a/include/asm-arm/arch-ixp4xx/ixdp425.h +++ b/include/asm-arm/arch-ixp4xx/ixdp425.h @@ -16,9 +16,6 @@ #error "Do not include this directly, instead #include " #endif -#define IXDP425_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS -#define IXDP425_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE - #define IXDP425_SDA_PIN 7 #define IXDP425_SCL_PIN 6 diff --git a/include/asm-arm/arch-ixp4xx/nas100d.h b/include/asm-arm/arch-ixp4xx/nas100d.h index ce7a86a..51ac018 100644 --- a/include/asm-arm/arch-ixp4xx/nas100d.h +++ b/include/asm-arm/arch-ixp4xx/nas100d.h @@ -19,9 +19,6 @@ #error "Do not include this directly, instead #include " #endif -#define NAS100D_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS -#define NAS100D_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE - #define NAS100D_SDA_PIN 6 #define NAS100D_SCL_PIN 5 diff --git a/include/asm-arm/arch-ixp4xx/nslu2.h b/include/asm-arm/arch-ixp4xx/nslu2.h index b8b347a..4281838 100644 --- a/include/asm-arm/arch-ixp4xx/nslu2.h +++ b/include/asm-arm/arch-ixp4xx/nslu2.h @@ -18,9 +18,6 @@ #error "Do not include this directly, instead #include " #endif -#define NSLU2_FLASH_BASE IXP4XX_EXP_BUS_CS0_BASE_PHYS -#define NSLU2_FLASH_SIZE IXP4XX_EXP_BUS_CSX_REGION_SIZE - #define NSLU2_SDA_PIN 7 #define NSLU2_SCL_PIN 6 diff --git a/include/asm-arm/arch-ixp4xx/platform.h b/include/asm-arm/arch-ixp4xx/platform.h index 6b77ed2..daf9790 100644 --- a/include/asm-arm/arch-ixp4xx/platform.h +++ b/include/asm-arm/arch-ixp4xx/platform.h @@ -26,16 +26,17 @@ */ #define IXP4XX_EXP_BUS_BASE_PHYS (0x50000000) -#define IXP4XX_EXP_BUS_CSX_REGION_SIZE (0x01000000) - -#define IXP4XX_EXP_BUS_CS0_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x00000000) -#define IXP4XX_EXP_BUS_CS1_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x01000000) -#define IXP4XX_EXP_BUS_CS2_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x02000000) -#define IXP4XX_EXP_BUS_CS3_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x03000000) -#define IXP4XX_EXP_BUS_CS4_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x04000000) -#define IXP4XX_EXP_BUS_CS5_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x05000000) -#define IXP4XX_EXP_BUS_CS6_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x06000000) -#define IXP4XX_EXP_BUS_CS7_BASE_PHYS (IXP4XX_EXP_BUS_BASE_PHYS + 0x07000000) +/* + * The expansion bus on the IXP4xx can be configured for either 16 or + * 32MB windows and the CS offset for each region changes based on the + * current configuration. This means that we cannot simply hardcode + * each offset. ixp4xx_sys_init() looks at the expansion bus configuration + * as setup by the bootloader to determine our window size. + */ +extern unsigned long ixp4xx_exp_bus_size; + +#define IXP4XX_EXP_BUS_BASE(region)\ + (IXP4XX_EXP_BUS_BASE_PHYS + ((region) * ixp4xx_exp_bus_size)) #define IXP4XX_FLASH_WRITABLE (0x2) #define IXP4XX_FLASH_DEFAULT (0xbcd23c40) -- cgit v0.10.2 From 5b2e98cdf3a6ac6c57de6a2156c673d4b0262684 Mon Sep 17 00:00:00 2001 From: Jared Hulbert Date: Thu, 5 Jan 2006 21:12:26 +0000 Subject: [ARM] 3206/1: Modifications to the bus arbiter controller for the Intel PXA27x Patch from Jared Hulbert The following patch changes the bus arbiter controller settings for the Intel PXA27x Application Processor Family. Up to 5% better video performance. It parks the bus on the core while not in use and sets the arbitration for other bus items. The patch only applies changes to the Intel Mainstone development platform. This patch is not compatible with preproduction Intel PXA27x silicon. This patch is based on the Intel Linux Preview Kit released to the public on 25 Feb. 2005 found at ftp://ftp.arm.linux.org.uk/pub/linux/arm/people/xscale/mainstone/02-25-2005/. Signed-off-by: Justin A Treon Signed-off-by: Jared Hulbert Signed-off-by: Nicolas Pitre Signed-off-by: Russell King diff --git a/arch/arm/mach-pxa/mainstone.c b/arch/arm/mach-pxa/mainstone.c index 07892f4..fe74043 100644 --- a/arch/arm/mach-pxa/mainstone.c +++ b/arch/arm/mach-pxa/mainstone.c @@ -407,6 +407,12 @@ static void __init mainstone_init(void) printk(KERN_NOTICE "Mainstone configured to boot from %s\n", mst_flash_data[0].name); + /* system bus arbiter setting + * - Core_Park + * - LCD_wt:DMA_wt:CORE_Wt = 2:3:4 + */ + ARB_CNTRL = ARB_CORE_PARK | 0x234; + /* * On Mainstone, we route AC97_SYSCLK via GPIO45 to * the audio daughter card diff --git a/include/asm-arm/arch-pxa/pxa-regs.h b/include/asm-arm/arch-pxa/pxa-regs.h index a75a247..dae138b 100644 --- a/include/asm-arm/arch-pxa/pxa-regs.h +++ b/include/asm-arm/arch-pxa/pxa-regs.h @@ -2042,6 +2042,18 @@ #ifdef CONFIG_PXA27x +#define ARB_CNTRL __REG(0x48000048) /* Arbiter Control Register */ + +#define ARB_DMA_SLV_PARK (1<<31) /* Be parked with DMA slave when idle */ +#define ARB_CI_PARK (1<<30) /* Be parked with Camera Interface when idle */ +#define ARB_EX_MEM_PARK (1<<29) /* Be parked with external MEMC when idle */ +#define ARB_INT_MEM_PARK (1<<28) /* Be parked with internal MEMC when idle */ +#define ARB_USB_PARK (1<<27) /* Be parked with USB when idle */ +#define ARB_LCD_PARK (1<<26) /* Be parked with LCD when idle */ +#define ARB_DMA_PARK (1<<25) /* Be parked with DMA when idle */ +#define ARB_CORE_PARK (1<<24) /* Be parked with core when idle */ +#define ARB_LOCK_FLAG (1<<23) /* Only Locking masters gain access to the bus */ + /* * Keypad */ -- cgit v0.10.2 From f99c89297cd6995ccad6394c87383941c2570fe9 Mon Sep 17 00:00:00 2001 From: Pavel Pisa Date: Sat, 7 Jan 2006 10:44:32 +0000 Subject: [ARM] 3232/1: i.MX Frame Buffer undeclared "dev" variable fix Patch from Pavel Pisa Correction of the code broken by update whole-tree platform devices update. Signed-off-by: Pavel Pisa Signed-off-by: Sascha Hauer Signed-off-by: Russell King diff --git a/drivers/video/imxfb.c b/drivers/video/imxfb.c index 5924cc2..1718baa 100644 --- a/drivers/video/imxfb.c +++ b/drivers/video/imxfb.c @@ -554,7 +554,7 @@ static int __init imxfb_probe(struct platform_device *pdev) inf = pdev->dev.platform_data; if(!inf) { - dev_err(dev,"No platform_data available\n"); + dev_err(&pdev->dev,"No platform_data available\n"); return -ENOMEM; } @@ -579,7 +579,7 @@ static int __init imxfb_probe(struct platform_device *pdev) if (!inf->fixed_screen_cpu) { ret = imxfb_map_video_memory(info); if (ret) { - dev_err(dev, "Failed to allocate video RAM: %d\n", ret); + dev_err(&pdev->dev, "Failed to allocate video RAM: %d\n", ret); ret = -ENOMEM; goto failed_map; } @@ -608,7 +608,7 @@ static int __init imxfb_probe(struct platform_device *pdev) imxfb_set_par(info); ret = register_framebuffer(info); if (ret < 0) { - dev_err(dev, "failed to register framebuffer\n"); + dev_err(&pdev->dev, "failed to register framebuffer\n"); goto failed_register; } -- cgit v0.10.2 From 2c041f4b9be5cecbd0a042ecd9122a9db6f50416 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Sat, 7 Jan 2006 11:12:26 +0000 Subject: [ARM] 3235/1: SharpSL PM: Fix a gcc4 build error Patch from Richard Purdie Fix a gcc4 build error (incomplete element type) in the pxa SharpSL PM code. Signed-off-by: Richard Purdie Signed-off-by: Russell King diff --git a/arch/arm/mach-pxa/corgi_pm.c b/arch/arm/mach-pxa/corgi_pm.c index de8b240..7a1ab73 100644 --- a/arch/arm/mach-pxa/corgi_pm.c +++ b/arch/arm/mach-pxa/corgi_pm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include diff --git a/arch/arm/mach-pxa/sharpsl.h b/arch/arm/mach-pxa/sharpsl.h index 92b7930..da4769c 100644 --- a/arch/arm/mach-pxa/sharpsl.h +++ b/arch/arm/mach-pxa/sharpsl.h @@ -7,6 +7,7 @@ * */ +#include /* * SharpSL SSP Driver diff --git a/arch/arm/mach-pxa/sharpsl_pm.c b/arch/arm/mach-pxa/sharpsl_pm.c index f6fefb1..6d402b2 100644 --- a/arch/arm/mach-pxa/sharpsl_pm.c +++ b/arch/arm/mach-pxa/sharpsl_pm.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "sharpsl.h" struct battery_thresh spitz_battery_levels_acin[] = { diff --git a/arch/arm/mach-pxa/spitz_pm.c b/arch/arm/mach-pxa/spitz_pm.c index 76a5c26..5e5bdc8 100644 --- a/arch/arm/mach-pxa/spitz_pm.c +++ b/arch/arm/mach-pxa/spitz_pm.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include -- cgit v0.10.2 From 6351610d6906aacbf9176cbdd045dd3876eec4c0 Mon Sep 17 00:00:00 2001 From: Andre McCurdy Date: Sat, 7 Jan 2006 11:39:20 +0000 Subject: [ARM] 3239/1: Add ARM optimised swab32 Patch from Andre McCurdy Replaces generic swab32 routine with a more ARM friendly version. Reduces kernel text size by approx 1200 bytes when compiled with 3.4.4 and approx 2400 bytes with 4.0.2 Probably some performance benefit as well. Signed-off-by: Andre McCurdy Signed-off-by: Russell King diff --git a/include/asm-arm/byteorder.h b/include/asm-arm/byteorder.h index d648a19..af42f44 100644 --- a/include/asm-arm/byteorder.h +++ b/include/asm-arm/byteorder.h @@ -15,9 +15,22 @@ #ifndef __ASM_ARM_BYTEORDER_H #define __ASM_ARM_BYTEORDER_H - #include +static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) +{ + __u32 t; + + t = x ^ ((x << 16) | (x >> 16)); /* eor r1,r0,r0,ror #16 */ + x = (x << 24) | (x >> 8); /* mov r0,r0,ror #8 */ + t &= ~0x00FF0000; /* bic r1,r1,#0x00FF0000 */ + x ^= (t >> 8); /* eor r0,r0,r1,lsr #8 */ + + return x; +} + +#define __arch__swab32(x) ___arch__swab32(x) + #if !defined(__STRICT_ANSI__) || defined(__KERNEL__) # define __BYTEORDER_HAS_U64__ # define __SWAB_64_THRU_32__ -- cgit v0.10.2 From a62c80e559809e6c7851ec04d30575e85ad6f6ed Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 13:52:45 +0000 Subject: [ARM] Move AMBA include files to include/linux/amba/ Since the ARM AMBA bus is used on MIPS as well as ARM, we need to make the bus available for other architectures to use. Move the AMBA include files from include/asm-arm/hardware/ to include/linux/amba/ Signed-off-by: Russell King diff --git a/arch/arm/common/amba.c b/arch/arm/common/amba.c index e101311..2bb0ce8 100644 --- a/arch/arm/common/amba.c +++ b/arch/arm/common/amba.c @@ -12,10 +12,10 @@ #include #include #include +#include #include #include -#include #include #define to_amba_device(d) container_of(d, struct amba_device, dev) diff --git a/arch/arm/mach-aaec2000/core.c b/arch/arm/mach-aaec2000/core.c index 4e706d9..dce4815 100644 --- a/arch/arm/mach-aaec2000/core.c +++ b/arch/arm/mach-aaec2000/core.c @@ -20,11 +20,11 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/arch/arm/mach-aaec2000/core.h b/arch/arm/mach-aaec2000/core.h index daefc0e..b6029a9 100644 --- a/arch/arm/mach-aaec2000/core.h +++ b/arch/arm/mach-aaec2000/core.h @@ -9,7 +9,7 @@ * */ -#include +#include struct sys_timer; diff --git a/arch/arm/mach-integrator/core.c b/arch/arm/mach-integrator/core.c index dacbf50..20071a2 100644 --- a/arch/arm/mach-integrator/core.c +++ b/arch/arm/mach-integrator/core.c @@ -15,11 +15,11 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/arch/arm/mach-integrator/impd1.c b/arch/arm/mach-integrator/impd1.c index a4bafee..a85d471 100644 --- a/arch/arm/mach-integrator/impd1.c +++ b/arch/arm/mach-integrator/impd1.c @@ -18,11 +18,11 @@ #include #include #include +#include +#include #include #include -#include -#include #include #include #include diff --git a/arch/arm/mach-integrator/integrator_ap.c b/arch/arm/mach-integrator/integrator_ap.c index 4c0f7c65..3afedeb 100644 --- a/arch/arm/mach-integrator/integrator_ap.c +++ b/arch/arm/mach-integrator/integrator_ap.c @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -32,8 +34,6 @@ #include #include /* HZ */ #include -#include -#include #include diff --git a/arch/arm/mach-integrator/integrator_cp.c b/arch/arm/mach-integrator/integrator_cp.c index 93f7ccb..16cf248 100644 --- a/arch/arm/mach-integrator/integrator_cp.c +++ b/arch/arm/mach-integrator/integrator_cp.c @@ -16,15 +16,15 @@ #include #include #include +#include +#include +#include #include #include #include #include #include -#include -#include -#include #include #include diff --git a/arch/arm/mach-integrator/time.c b/arch/arm/mach-integrator/time.c index 1a844ca..9f46aae 100644 --- a/arch/arm/mach-integrator/time.c +++ b/arch/arm/mach-integrator/time.c @@ -14,8 +14,8 @@ #include #include #include +#include -#include #include #include #include diff --git a/arch/arm/mach-realview/core.c b/arch/arm/mach-realview/core.c index af6580f..4a222f5 100644 --- a/arch/arm/mach-realview/core.c +++ b/arch/arm/mach-realview/core.c @@ -24,14 +24,14 @@ #include #include #include +#include +#include #include #include #include #include #include -#include -#include #include #include diff --git a/arch/arm/mach-realview/core.h b/arch/arm/mach-realview/core.h index c06e604..93e86d9 100644 --- a/arch/arm/mach-realview/core.h +++ b/arch/arm/mach-realview/core.h @@ -22,7 +22,8 @@ #ifndef __ASM_ARCH_REALVIEW_H #define __ASM_ARCH_REALVIEW_H -#include +#include + #include #include diff --git a/arch/arm/mach-realview/realview_eb.c b/arch/arm/mach-realview/realview_eb.c index 7dc3250..112f759 100644 --- a/arch/arm/mach-realview/realview_eb.c +++ b/arch/arm/mach-realview/realview_eb.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include #include diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index a1ca466..9002374 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c @@ -25,14 +25,14 @@ #include #include #include +#include +#include #include #include #include #include #include -#include -#include #include #include diff --git a/arch/arm/mach-versatile/core.h b/arch/arm/mach-versatile/core.h index 588c206..afcaa85 100644 --- a/arch/arm/mach-versatile/core.h +++ b/arch/arm/mach-versatile/core.h @@ -22,7 +22,7 @@ #ifndef __ASM_ARCH_VERSATILE_H #define __ASM_ARCH_VERSATILE_H -#include +#include extern void __init versatile_init(void); extern void __init versatile_init_irq(void); diff --git a/arch/arm/mach-versatile/versatile_ab.c b/arch/arm/mach-versatile/versatile_ab.c index 8b0b3be..e74c8a2 100644 --- a/arch/arm/mach-versatile/versatile_ab.c +++ b/arch/arm/mach-versatile/versatile_ab.c @@ -23,12 +23,12 @@ #include #include #include +#include #include #include #include #include -#include #include diff --git a/arch/arm/mach-versatile/versatile_pb.c b/arch/arm/mach-versatile/versatile_pb.c index 7c3078c..22d5ca0 100644 --- a/arch/arm/mach-versatile/versatile_pb.c +++ b/arch/arm/mach-versatile/versatile_pb.c @@ -23,12 +23,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index d847ed5..cbab5d2 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -19,11 +19,11 @@ #include #include #include +#include +#include #include #include -#include -#include #include #define KMI_BASE (kmi->base) diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 31b0b6d..57375bc 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -19,12 +19,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include diff --git a/drivers/serial/amba-pl010.c b/drivers/serial/amba-pl010.c index ddd0307..48f6e87 100644 --- a/drivers/serial/amba-pl010.c +++ b/drivers/serial/amba-pl010.c @@ -47,12 +47,12 @@ #include #include #include +#include +#include #include #include #include -#include -#include #define UART_NR 2 diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 531b0e4..4ae4dff 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -47,12 +47,12 @@ #include #include #include +#include +#include #include #include -#include #include -#include #define UART_NR 14 diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 69421c8..3358a14 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -21,13 +21,12 @@ #include #include #include +#include +#include #include -#include #include -#include - #define to_clcd(info) container_of(info, struct clcd_fb, fb) /* This is limited to 16 characters when displayed by X startup */ diff --git a/include/asm-arm/arch-integrator/debug-macro.S b/include/asm-arm/arch-integrator/debug-macro.S index 484a1aa..031d309 100644 --- a/include/asm-arm/arch-integrator/debug-macro.S +++ b/include/asm-arm/arch-integrator/debug-macro.S @@ -11,7 +11,7 @@ * */ -#include +#include .macro addruart,rx mrc p15, 0, \rx, c1, c0 diff --git a/include/asm-arm/arch-realview/debug-macro.S b/include/asm-arm/arch-realview/debug-macro.S index ed28bd0..017ad99 100644 --- a/include/asm-arm/arch-realview/debug-macro.S +++ b/include/asm-arm/arch-realview/debug-macro.S @@ -11,7 +11,7 @@ * */ -#include +#include .macro addruart,rx mrc p15, 0, \rx, c1, c0 diff --git a/include/asm-arm/arch-versatile/debug-macro.S b/include/asm-arm/arch-versatile/debug-macro.S index 89e38ac..ef61671 100644 --- a/include/asm-arm/arch-versatile/debug-macro.S +++ b/include/asm-arm/arch-versatile/debug-macro.S @@ -11,7 +11,7 @@ * */ -#include +#include .macro addruart,rx mrc p15, 0, \rx, c1, c0 diff --git a/include/asm-arm/hardware/amba.h b/include/asm-arm/hardware/amba.h deleted file mode 100644 index 51e6e54..0000000 --- a/include/asm-arm/hardware/amba.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - * linux/include/asm-arm/hardware/amba.h - * - * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. - * - * 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. - */ -#ifndef ASMARM_AMBA_H -#define ASMARM_AMBA_H - -#define AMBA_NR_IRQS 2 - -struct amba_device { - struct device dev; - struct resource res; - u64 dma_mask; - unsigned int periphid; - unsigned int irq[AMBA_NR_IRQS]; -}; - -struct amba_id { - unsigned int id; - unsigned int mask; - void *data; -}; - -struct amba_driver { - struct device_driver drv; - int (*probe)(struct amba_device *, void *); - int (*remove)(struct amba_device *); - void (*shutdown)(struct amba_device *); - int (*suspend)(struct amba_device *, pm_message_t); - int (*resume)(struct amba_device *); - struct amba_id *id_table; -}; - -#define amba_get_drvdata(d) dev_get_drvdata(&d->dev) -#define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p) - -int amba_driver_register(struct amba_driver *); -void amba_driver_unregister(struct amba_driver *); -int amba_device_register(struct amba_device *, struct resource *); -void amba_device_unregister(struct amba_device *); -struct amba_device *amba_find_device(const char *, struct device *, unsigned int, unsigned int); -int amba_request_regions(struct amba_device *, const char *); -void amba_release_regions(struct amba_device *); - -#define amba_config(d) (((d)->periphid >> 24) & 0xff) -#define amba_rev(d) (((d)->periphid >> 20) & 0x0f) -#define amba_manf(d) (((d)->periphid >> 12) & 0xff) -#define amba_part(d) ((d)->periphid & 0xfff) - -#endif diff --git a/include/asm-arm/hardware/amba_clcd.h b/include/asm-arm/hardware/amba_clcd.h deleted file mode 100644 index 6b8d73d..0000000 --- a/include/asm-arm/hardware/amba_clcd.h +++ /dev/null @@ -1,271 +0,0 @@ -/* - * linux/include/asm-arm/hardware/amba_clcd.h -- Integrator LCD panel. - * - * David A Rusling - * - * Copyright (C) 2001 ARM Limited - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of this archive - * for more details. - */ -#include -#include - -/* - * CLCD Controller Internal Register addresses - */ -#define CLCD_TIM0 0x00000000 -#define CLCD_TIM1 0x00000004 -#define CLCD_TIM2 0x00000008 -#define CLCD_TIM3 0x0000000c -#define CLCD_UBAS 0x00000010 -#define CLCD_LBAS 0x00000014 - -#if !defined(CONFIG_ARCH_VERSATILE) && !defined(CONFIG_ARCH_REALVIEW) -#define CLCD_IENB 0x00000018 -#define CLCD_CNTL 0x0000001c -#else -/* - * Someone rearranged these two registers on the Versatile - * platform... - */ -#define CLCD_IENB 0x0000001c -#define CLCD_CNTL 0x00000018 -#endif - -#define CLCD_STAT 0x00000020 -#define CLCD_INTR 0x00000024 -#define CLCD_UCUR 0x00000028 -#define CLCD_LCUR 0x0000002C -#define CLCD_PALL 0x00000200 -#define CLCD_PALETTE 0x00000200 - -#define TIM2_CLKSEL (1 << 5) -#define TIM2_IVS (1 << 11) -#define TIM2_IHS (1 << 12) -#define TIM2_IPC (1 << 13) -#define TIM2_IOE (1 << 14) -#define TIM2_BCD (1 << 26) - -#define CNTL_LCDEN (1 << 0) -#define CNTL_LCDBPP1 (0 << 1) -#define CNTL_LCDBPP2 (1 << 1) -#define CNTL_LCDBPP4 (2 << 1) -#define CNTL_LCDBPP8 (3 << 1) -#define CNTL_LCDBPP16 (4 << 1) -#define CNTL_LCDBPP24 (5 << 1) -#define CNTL_LCDBW (1 << 4) -#define CNTL_LCDTFT (1 << 5) -#define CNTL_LCDMONO8 (1 << 6) -#define CNTL_LCDDUAL (1 << 7) -#define CNTL_BGR (1 << 8) -#define CNTL_BEBO (1 << 9) -#define CNTL_BEPO (1 << 10) -#define CNTL_LCDPWR (1 << 11) -#define CNTL_LCDVCOMP(x) ((x) << 12) -#define CNTL_LDMAFIFOTIME (1 << 15) -#define CNTL_WATERMARK (1 << 16) - -struct clcd_panel { - struct fb_videomode mode; - signed short width; /* width in mm */ - signed short height; /* height in mm */ - u32 tim2; - u32 tim3; - u32 cntl; - unsigned int bpp:8, - fixedtimings:1, - grayscale:1; - unsigned int connector; -}; - -struct clcd_regs { - u32 tim0; - u32 tim1; - u32 tim2; - u32 tim3; - u32 cntl; - unsigned long pixclock; -}; - -struct clcd_fb; - -/* - * the board-type specific routines - */ -struct clcd_board { - const char *name; - - /* - * Optional. Check whether the var structure is acceptable - * for this display. - */ - int (*check)(struct clcd_fb *fb, struct fb_var_screeninfo *var); - - /* - * Compulsary. Decode fb->fb.var into regs->*. In the case of - * fixed timing, set regs->* to the register values required. - */ - void (*decode)(struct clcd_fb *fb, struct clcd_regs *regs); - - /* - * Optional. Disable any extra display hardware. - */ - void (*disable)(struct clcd_fb *); - - /* - * Optional. Enable any extra display hardware. - */ - void (*enable)(struct clcd_fb *); - - /* - * Setup platform specific parts of CLCD driver - */ - int (*setup)(struct clcd_fb *); - - /* - * mmap the framebuffer memory - */ - int (*mmap)(struct clcd_fb *, struct vm_area_struct *); - - /* - * Remove platform specific parts of CLCD driver - */ - void (*remove)(struct clcd_fb *); -}; - -struct amba_device; -struct clk; - -/* this data structure describes each frame buffer device we find */ -struct clcd_fb { - struct fb_info fb; - struct amba_device *dev; - struct clk *clk; - struct clcd_panel *panel; - struct clcd_board *board; - void *board_data; - void __iomem *regs; - u32 clcd_cntl; - u32 cmap[16]; -}; - -static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs) -{ - u32 val, cpl; - - /* - * Program the CLCD controller registers and start the CLCD - */ - val = ((fb->fb.var.xres / 16) - 1) << 2; - val |= (fb->fb.var.hsync_len - 1) << 8; - val |= (fb->fb.var.right_margin - 1) << 16; - val |= (fb->fb.var.left_margin - 1) << 24; - regs->tim0 = val; - - val = fb->fb.var.yres; - if (fb->panel->cntl & CNTL_LCDDUAL) - val /= 2; - val -= 1; - val |= (fb->fb.var.vsync_len - 1) << 10; - val |= fb->fb.var.lower_margin << 16; - val |= fb->fb.var.upper_margin << 24; - regs->tim1 = val; - - val = fb->panel->tim2; - val |= fb->fb.var.sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS; - val |= fb->fb.var.sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS; - - cpl = fb->fb.var.xres_virtual; - if (fb->panel->cntl & CNTL_LCDTFT) /* TFT */ - /* / 1 */; - else if (!fb->fb.var.grayscale) /* STN color */ - cpl = cpl * 8 / 3; - else if (fb->panel->cntl & CNTL_LCDMONO8) /* STN monochrome, 8bit */ - cpl /= 8; - else /* STN monochrome, 4bit */ - cpl /= 4; - - regs->tim2 = val | ((cpl - 1) << 16); - - regs->tim3 = fb->panel->tim3; - - val = fb->panel->cntl; - if (fb->fb.var.grayscale) - val |= CNTL_LCDBW; - - switch (fb->fb.var.bits_per_pixel) { - case 1: - val |= CNTL_LCDBPP1; - break; - case 2: - val |= CNTL_LCDBPP2; - break; - case 4: - val |= CNTL_LCDBPP4; - break; - case 8: - val |= CNTL_LCDBPP8; - break; - case 16: - val |= CNTL_LCDBPP16; - break; - case 32: - val |= CNTL_LCDBPP24; - break; - } - - regs->cntl = val; - regs->pixclock = fb->fb.var.pixclock; -} - -static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) -{ - var->xres_virtual = var->xres = (var->xres + 15) & ~15; - var->yres_virtual = var->yres = (var->yres + 1) & ~1; - -#define CHECK(e,l,h) (var->e < l || var->e > h) - if (CHECK(right_margin, (5+1), 256) || /* back porch */ - CHECK(left_margin, (5+1), 256) || /* front porch */ - CHECK(hsync_len, (5+1), 256) || - var->xres > 4096 || - var->lower_margin > 255 || /* back porch */ - var->upper_margin > 255 || /* front porch */ - var->vsync_len > 32 || - var->yres > 1024) - return -EINVAL; -#undef CHECK - - /* single panel mode: PCD = max(PCD, 1) */ - /* dual panel mode: PCD = max(PCD, 5) */ - - /* - * You can't change the grayscale setting, and - * we can only do non-interlaced video. - */ - if (var->grayscale != fb->fb.var.grayscale || - (var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) - return -EINVAL; - -#define CHECK(e) (var->e != fb->fb.var.e) - if (fb->panel->fixedtimings && - (CHECK(xres) || - CHECK(yres) || - CHECK(bits_per_pixel) || - CHECK(pixclock) || - CHECK(left_margin) || - CHECK(right_margin) || - CHECK(upper_margin) || - CHECK(lower_margin) || - CHECK(hsync_len) || - CHECK(vsync_len) || - CHECK(sync))) - return -EINVAL; -#undef CHECK - - var->nonstd = 0; - var->accel_flags = 0; - - return 0; -} diff --git a/include/asm-arm/hardware/amba_kmi.h b/include/asm-arm/hardware/amba_kmi.h deleted file mode 100644 index a39e5be..0000000 --- a/include/asm-arm/hardware/amba_kmi.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * linux/include/asm-arm/hardware/amba_kmi.h - * - * Internal header file for AMBA KMI ports - * - * Copyright (C) 2000 Deep Blue Solutions Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * --------------------------------------------------------------------------- - * From ARM PrimeCell(tm) PS2 Keyboard/Mouse Interface (PL050) Technical - * Reference Manual - ARM DDI 0143B - see http://www.arm.com/ - * --------------------------------------------------------------------------- - */ -#ifndef ASM_ARM_HARDWARE_AMBA_KMI_H -#define ASM_ARM_HARDWARE_AMBA_KMI_H - -/* - * KMI control register: - * KMICR_TYPE 0 = PS2/AT mode, 1 = No line control bit mode - * KMICR_RXINTREN 1 = enable RX interrupts - * KMICR_TXINTREN 1 = enable TX interrupts - * KMICR_EN 1 = enable KMI - * KMICR_FD 1 = force KMI data low - * KMICR_FC 1 = force KMI clock low - */ -#define KMICR (KMI_BASE + 0x00) -#define KMICR_TYPE (1 << 5) -#define KMICR_RXINTREN (1 << 4) -#define KMICR_TXINTREN (1 << 3) -#define KMICR_EN (1 << 2) -#define KMICR_FD (1 << 1) -#define KMICR_FC (1 << 0) - -/* - * KMI status register: - * KMISTAT_TXEMPTY 1 = transmitter register empty - * KMISTAT_TXBUSY 1 = currently sending data - * KMISTAT_RXFULL 1 = receiver register ready to be read - * KMISTAT_RXBUSY 1 = currently receiving data - * KMISTAT_RXPARITY parity of last databyte received - * KMISTAT_IC current level of KMI clock input - * KMISTAT_ID current level of KMI data input - */ -#define KMISTAT (KMI_BASE + 0x04) -#define KMISTAT_TXEMPTY (1 << 6) -#define KMISTAT_TXBUSY (1 << 5) -#define KMISTAT_RXFULL (1 << 4) -#define KMISTAT_RXBUSY (1 << 3) -#define KMISTAT_RXPARITY (1 << 2) -#define KMISTAT_IC (1 << 1) -#define KMISTAT_ID (1 << 0) - -/* - * KMI data register - */ -#define KMIDATA (KMI_BASE + 0x08) - -/* - * KMI clock divisor: to generate 8MHz internal clock - * div = (ref / 8MHz) - 1; 0 <= div <= 15 - */ -#define KMICLKDIV (KMI_BASE + 0x0c) - -/* - * KMI interrupt register: - * KMIIR_TXINTR 1 = transmit interrupt asserted - * KMIIR_RXINTR 1 = receive interrupt asserted - */ -#define KMIIR (KMI_BASE + 0x10) -#define KMIIR_TXINTR (1 << 1) -#define KMIIR_RXINTR (1 << 0) - -/* - * The size of the KMI primecell - */ -#define KMI_SIZE (0x100) - -#endif diff --git a/include/asm-arm/hardware/amba_serial.h b/include/asm-arm/hardware/amba_serial.h deleted file mode 100644 index dc726ff..0000000 --- a/include/asm-arm/hardware/amba_serial.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * linux/include/asm-arm/hardware/serial_amba.h - * - * Internal header file for AMBA serial ports - * - * Copyright (C) ARM Limited - * Copyright (C) 2000 Deep Blue Solutions Ltd. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef ASM_ARM_HARDWARE_SERIAL_AMBA_H -#define ASM_ARM_HARDWARE_SERIAL_AMBA_H - -/* ------------------------------------------------------------------------------- - * From AMBA UART (PL010) Block Specification - * ------------------------------------------------------------------------------- - * UART Register Offsets. - */ -#define UART01x_DR 0x00 /* Data read or written from the interface. */ -#define UART01x_RSR 0x04 /* Receive status register (Read). */ -#define UART01x_ECR 0x04 /* Error clear register (Write). */ -#define UART010_LCRH 0x08 /* Line control register, high byte. */ -#define UART010_LCRM 0x0C /* Line control register, middle byte. */ -#define UART010_LCRL 0x10 /* Line control register, low byte. */ -#define UART010_CR 0x14 /* Control register. */ -#define UART01x_FR 0x18 /* Flag register (Read only). */ -#define UART010_IIR 0x1C /* Interrupt indentification register (Read). */ -#define UART010_ICR 0x1C /* Interrupt clear register (Write). */ -#define UART01x_ILPR 0x20 /* IrDA low power counter register. */ -#define UART011_IBRD 0x24 /* Integer baud rate divisor register. */ -#define UART011_FBRD 0x28 /* Fractional baud rate divisor register. */ -#define UART011_LCRH 0x2c /* Line control register. */ -#define UART011_CR 0x30 /* Control register. */ -#define UART011_IFLS 0x34 /* Interrupt fifo level select. */ -#define UART011_IMSC 0x38 /* Interrupt mask. */ -#define UART011_RIS 0x3c /* Raw interrupt status. */ -#define UART011_MIS 0x40 /* Masked interrupt status. */ -#define UART011_ICR 0x44 /* Interrupt clear register. */ -#define UART011_DMACR 0x48 /* DMA control register. */ - -#define UART011_DR_OE (1 << 11) -#define UART011_DR_BE (1 << 10) -#define UART011_DR_PE (1 << 9) -#define UART011_DR_FE (1 << 8) - -#define UART01x_RSR_OE 0x08 -#define UART01x_RSR_BE 0x04 -#define UART01x_RSR_PE 0x02 -#define UART01x_RSR_FE 0x01 - -#define UART011_FR_RI 0x100 -#define UART011_FR_TXFE 0x080 -#define UART011_FR_RXFF 0x040 -#define UART01x_FR_TXFF 0x020 -#define UART01x_FR_RXFE 0x010 -#define UART01x_FR_BUSY 0x008 -#define UART01x_FR_DCD 0x004 -#define UART01x_FR_DSR 0x002 -#define UART01x_FR_CTS 0x001 -#define UART01x_FR_TMSK (UART01x_FR_TXFF + UART01x_FR_BUSY) - -#define UART011_CR_CTSEN 0x8000 /* CTS hardware flow control */ -#define UART011_CR_RTSEN 0x4000 /* RTS hardware flow control */ -#define UART011_CR_OUT2 0x2000 /* OUT2 */ -#define UART011_CR_OUT1 0x1000 /* OUT1 */ -#define UART011_CR_RTS 0x0800 /* RTS */ -#define UART011_CR_DTR 0x0400 /* DTR */ -#define UART011_CR_RXE 0x0200 /* receive enable */ -#define UART011_CR_TXE 0x0100 /* transmit enable */ -#define UART011_CR_LBE 0x0080 /* loopback enable */ -#define UART010_CR_RTIE 0x0040 -#define UART010_CR_TIE 0x0020 -#define UART010_CR_RIE 0x0010 -#define UART010_CR_MSIE 0x0008 -#define UART01x_CR_IIRLP 0x0004 /* SIR low power mode */ -#define UART01x_CR_SIREN 0x0002 /* SIR enable */ -#define UART01x_CR_UARTEN 0x0001 /* UART enable */ - -#define UART011_LCRH_SPS 0x80 -#define UART01x_LCRH_WLEN_8 0x60 -#define UART01x_LCRH_WLEN_7 0x40 -#define UART01x_LCRH_WLEN_6 0x20 -#define UART01x_LCRH_WLEN_5 0x00 -#define UART01x_LCRH_FEN 0x10 -#define UART01x_LCRH_STP2 0x08 -#define UART01x_LCRH_EPS 0x04 -#define UART01x_LCRH_PEN 0x02 -#define UART01x_LCRH_BRK 0x01 - -#define UART010_IIR_RTIS 0x08 -#define UART010_IIR_TIS 0x04 -#define UART010_IIR_RIS 0x02 -#define UART010_IIR_MIS 0x01 - -#define UART011_IFLS_RX1_8 (0 << 3) -#define UART011_IFLS_RX2_8 (1 << 3) -#define UART011_IFLS_RX4_8 (2 << 3) -#define UART011_IFLS_RX6_8 (3 << 3) -#define UART011_IFLS_RX7_8 (4 << 3) -#define UART011_IFLS_TX1_8 (0 << 0) -#define UART011_IFLS_TX2_8 (1 << 0) -#define UART011_IFLS_TX4_8 (2 << 0) -#define UART011_IFLS_TX6_8 (3 << 0) -#define UART011_IFLS_TX7_8 (4 << 0) - -#define UART011_OEIM (1 << 10) /* overrun error interrupt mask */ -#define UART011_BEIM (1 << 9) /* break error interrupt mask */ -#define UART011_PEIM (1 << 8) /* parity error interrupt mask */ -#define UART011_FEIM (1 << 7) /* framing error interrupt mask */ -#define UART011_RTIM (1 << 6) /* receive timeout interrupt mask */ -#define UART011_TXIM (1 << 5) /* transmit interrupt mask */ -#define UART011_RXIM (1 << 4) /* receive interrupt mask */ -#define UART011_DSRMIM (1 << 3) /* DSR interrupt mask */ -#define UART011_DCDMIM (1 << 2) /* DCD interrupt mask */ -#define UART011_CTSMIM (1 << 1) /* CTS interrupt mask */ -#define UART011_RIMIM (1 << 0) /* RI interrupt mask */ - -#define UART011_OEIS (1 << 10) /* overrun error interrupt status */ -#define UART011_BEIS (1 << 9) /* break error interrupt status */ -#define UART011_PEIS (1 << 8) /* parity error interrupt status */ -#define UART011_FEIS (1 << 7) /* framing error interrupt status */ -#define UART011_RTIS (1 << 6) /* receive timeout interrupt status */ -#define UART011_TXIS (1 << 5) /* transmit interrupt status */ -#define UART011_RXIS (1 << 4) /* receive interrupt status */ -#define UART011_DSRMIS (1 << 3) /* DSR interrupt status */ -#define UART011_DCDMIS (1 << 2) /* DCD interrupt status */ -#define UART011_CTSMIS (1 << 1) /* CTS interrupt status */ -#define UART011_RIMIS (1 << 0) /* RI interrupt status */ - -#define UART011_OEIC (1 << 10) /* overrun error interrupt clear */ -#define UART011_BEIC (1 << 9) /* break error interrupt clear */ -#define UART011_PEIC (1 << 8) /* parity error interrupt clear */ -#define UART011_FEIC (1 << 7) /* framing error interrupt clear */ -#define UART011_RTIC (1 << 6) /* receive timeout interrupt clear */ -#define UART011_TXIC (1 << 5) /* transmit interrupt clear */ -#define UART011_RXIC (1 << 4) /* receive interrupt clear */ -#define UART011_DSRMIC (1 << 3) /* DSR interrupt clear */ -#define UART011_DCDMIC (1 << 2) /* DCD interrupt clear */ -#define UART011_CTSMIC (1 << 1) /* CTS interrupt clear */ -#define UART011_RIMIC (1 << 0) /* RI interrupt clear */ - -#define UART011_DMAONERR (1 << 2) /* disable dma on error */ -#define UART011_TXDMAE (1 << 1) /* enable transmit dma */ -#define UART011_RXDMAE (1 << 0) /* enable receive dma */ - -#define UART01x_RSR_ANY (UART01x_RSR_OE|UART01x_RSR_BE|UART01x_RSR_PE|UART01x_RSR_FE) -#define UART01x_FR_MODEM_ANY (UART01x_FR_DCD|UART01x_FR_DSR|UART01x_FR_CTS) - -#endif diff --git a/include/linux/amba/bus.h b/include/linux/amba/bus.h new file mode 100644 index 0000000..51e6e54 --- /dev/null +++ b/include/linux/amba/bus.h @@ -0,0 +1,55 @@ +/* + * linux/include/asm-arm/hardware/amba.h + * + * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. + * + * 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. + */ +#ifndef ASMARM_AMBA_H +#define ASMARM_AMBA_H + +#define AMBA_NR_IRQS 2 + +struct amba_device { + struct device dev; + struct resource res; + u64 dma_mask; + unsigned int periphid; + unsigned int irq[AMBA_NR_IRQS]; +}; + +struct amba_id { + unsigned int id; + unsigned int mask; + void *data; +}; + +struct amba_driver { + struct device_driver drv; + int (*probe)(struct amba_device *, void *); + int (*remove)(struct amba_device *); + void (*shutdown)(struct amba_device *); + int (*suspend)(struct amba_device *, pm_message_t); + int (*resume)(struct amba_device *); + struct amba_id *id_table; +}; + +#define amba_get_drvdata(d) dev_get_drvdata(&d->dev) +#define amba_set_drvdata(d,p) dev_set_drvdata(&d->dev, p) + +int amba_driver_register(struct amba_driver *); +void amba_driver_unregister(struct amba_driver *); +int amba_device_register(struct amba_device *, struct resource *); +void amba_device_unregister(struct amba_device *); +struct amba_device *amba_find_device(const char *, struct device *, unsigned int, unsigned int); +int amba_request_regions(struct amba_device *, const char *); +void amba_release_regions(struct amba_device *); + +#define amba_config(d) (((d)->periphid >> 24) & 0xff) +#define amba_rev(d) (((d)->periphid >> 20) & 0x0f) +#define amba_manf(d) (((d)->periphid >> 12) & 0xff) +#define amba_part(d) ((d)->periphid & 0xfff) + +#endif diff --git a/include/linux/amba/clcd.h b/include/linux/amba/clcd.h new file mode 100644 index 0000000..6b8d73d --- /dev/null +++ b/include/linux/amba/clcd.h @@ -0,0 +1,271 @@ +/* + * linux/include/asm-arm/hardware/amba_clcd.h -- Integrator LCD panel. + * + * David A Rusling + * + * Copyright (C) 2001 ARM Limited + * + * This file is subject to the terms and conditions of the GNU General Public + * License. See the file COPYING in the main directory of this archive + * for more details. + */ +#include +#include + +/* + * CLCD Controller Internal Register addresses + */ +#define CLCD_TIM0 0x00000000 +#define CLCD_TIM1 0x00000004 +#define CLCD_TIM2 0x00000008 +#define CLCD_TIM3 0x0000000c +#define CLCD_UBAS 0x00000010 +#define CLCD_LBAS 0x00000014 + +#if !defined(CONFIG_ARCH_VERSATILE) && !defined(CONFIG_ARCH_REALVIEW) +#define CLCD_IENB 0x00000018 +#define CLCD_CNTL 0x0000001c +#else +/* + * Someone rearranged these two registers on the Versatile + * platform... + */ +#define CLCD_IENB 0x0000001c +#define CLCD_CNTL 0x00000018 +#endif + +#define CLCD_STAT 0x00000020 +#define CLCD_INTR 0x00000024 +#define CLCD_UCUR 0x00000028 +#define CLCD_LCUR 0x0000002C +#define CLCD_PALL 0x00000200 +#define CLCD_PALETTE 0x00000200 + +#define TIM2_CLKSEL (1 << 5) +#define TIM2_IVS (1 << 11) +#define TIM2_IHS (1 << 12) +#define TIM2_IPC (1 << 13) +#define TIM2_IOE (1 << 14) +#define TIM2_BCD (1 << 26) + +#define CNTL_LCDEN (1 << 0) +#define CNTL_LCDBPP1 (0 << 1) +#define CNTL_LCDBPP2 (1 << 1) +#define CNTL_LCDBPP4 (2 << 1) +#define CNTL_LCDBPP8 (3 << 1) +#define CNTL_LCDBPP16 (4 << 1) +#define CNTL_LCDBPP24 (5 << 1) +#define CNTL_LCDBW (1 << 4) +#define CNTL_LCDTFT (1 << 5) +#define CNTL_LCDMONO8 (1 << 6) +#define CNTL_LCDDUAL (1 << 7) +#define CNTL_BGR (1 << 8) +#define CNTL_BEBO (1 << 9) +#define CNTL_BEPO (1 << 10) +#define CNTL_LCDPWR (1 << 11) +#define CNTL_LCDVCOMP(x) ((x) << 12) +#define CNTL_LDMAFIFOTIME (1 << 15) +#define CNTL_WATERMARK (1 << 16) + +struct clcd_panel { + struct fb_videomode mode; + signed short width; /* width in mm */ + signed short height; /* height in mm */ + u32 tim2; + u32 tim3; + u32 cntl; + unsigned int bpp:8, + fixedtimings:1, + grayscale:1; + unsigned int connector; +}; + +struct clcd_regs { + u32 tim0; + u32 tim1; + u32 tim2; + u32 tim3; + u32 cntl; + unsigned long pixclock; +}; + +struct clcd_fb; + +/* + * the board-type specific routines + */ +struct clcd_board { + const char *name; + + /* + * Optional. Check whether the var structure is acceptable + * for this display. + */ + int (*check)(struct clcd_fb *fb, struct fb_var_screeninfo *var); + + /* + * Compulsary. Decode fb->fb.var into regs->*. In the case of + * fixed timing, set regs->* to the register values required. + */ + void (*decode)(struct clcd_fb *fb, struct clcd_regs *regs); + + /* + * Optional. Disable any extra display hardware. + */ + void (*disable)(struct clcd_fb *); + + /* + * Optional. Enable any extra display hardware. + */ + void (*enable)(struct clcd_fb *); + + /* + * Setup platform specific parts of CLCD driver + */ + int (*setup)(struct clcd_fb *); + + /* + * mmap the framebuffer memory + */ + int (*mmap)(struct clcd_fb *, struct vm_area_struct *); + + /* + * Remove platform specific parts of CLCD driver + */ + void (*remove)(struct clcd_fb *); +}; + +struct amba_device; +struct clk; + +/* this data structure describes each frame buffer device we find */ +struct clcd_fb { + struct fb_info fb; + struct amba_device *dev; + struct clk *clk; + struct clcd_panel *panel; + struct clcd_board *board; + void *board_data; + void __iomem *regs; + u32 clcd_cntl; + u32 cmap[16]; +}; + +static inline void clcdfb_decode(struct clcd_fb *fb, struct clcd_regs *regs) +{ + u32 val, cpl; + + /* + * Program the CLCD controller registers and start the CLCD + */ + val = ((fb->fb.var.xres / 16) - 1) << 2; + val |= (fb->fb.var.hsync_len - 1) << 8; + val |= (fb->fb.var.right_margin - 1) << 16; + val |= (fb->fb.var.left_margin - 1) << 24; + regs->tim0 = val; + + val = fb->fb.var.yres; + if (fb->panel->cntl & CNTL_LCDDUAL) + val /= 2; + val -= 1; + val |= (fb->fb.var.vsync_len - 1) << 10; + val |= fb->fb.var.lower_margin << 16; + val |= fb->fb.var.upper_margin << 24; + regs->tim1 = val; + + val = fb->panel->tim2; + val |= fb->fb.var.sync & FB_SYNC_HOR_HIGH_ACT ? 0 : TIM2_IHS; + val |= fb->fb.var.sync & FB_SYNC_VERT_HIGH_ACT ? 0 : TIM2_IVS; + + cpl = fb->fb.var.xres_virtual; + if (fb->panel->cntl & CNTL_LCDTFT) /* TFT */ + /* / 1 */; + else if (!fb->fb.var.grayscale) /* STN color */ + cpl = cpl * 8 / 3; + else if (fb->panel->cntl & CNTL_LCDMONO8) /* STN monochrome, 8bit */ + cpl /= 8; + else /* STN monochrome, 4bit */ + cpl /= 4; + + regs->tim2 = val | ((cpl - 1) << 16); + + regs->tim3 = fb->panel->tim3; + + val = fb->panel->cntl; + if (fb->fb.var.grayscale) + val |= CNTL_LCDBW; + + switch (fb->fb.var.bits_per_pixel) { + case 1: + val |= CNTL_LCDBPP1; + break; + case 2: + val |= CNTL_LCDBPP2; + break; + case 4: + val |= CNTL_LCDBPP4; + break; + case 8: + val |= CNTL_LCDBPP8; + break; + case 16: + val |= CNTL_LCDBPP16; + break; + case 32: + val |= CNTL_LCDBPP24; + break; + } + + regs->cntl = val; + regs->pixclock = fb->fb.var.pixclock; +} + +static inline int clcdfb_check(struct clcd_fb *fb, struct fb_var_screeninfo *var) +{ + var->xres_virtual = var->xres = (var->xres + 15) & ~15; + var->yres_virtual = var->yres = (var->yres + 1) & ~1; + +#define CHECK(e,l,h) (var->e < l || var->e > h) + if (CHECK(right_margin, (5+1), 256) || /* back porch */ + CHECK(left_margin, (5+1), 256) || /* front porch */ + CHECK(hsync_len, (5+1), 256) || + var->xres > 4096 || + var->lower_margin > 255 || /* back porch */ + var->upper_margin > 255 || /* front porch */ + var->vsync_len > 32 || + var->yres > 1024) + return -EINVAL; +#undef CHECK + + /* single panel mode: PCD = max(PCD, 1) */ + /* dual panel mode: PCD = max(PCD, 5) */ + + /* + * You can't change the grayscale setting, and + * we can only do non-interlaced video. + */ + if (var->grayscale != fb->fb.var.grayscale || + (var->vmode & FB_VMODE_MASK) != FB_VMODE_NONINTERLACED) + return -EINVAL; + +#define CHECK(e) (var->e != fb->fb.var.e) + if (fb->panel->fixedtimings && + (CHECK(xres) || + CHECK(yres) || + CHECK(bits_per_pixel) || + CHECK(pixclock) || + CHECK(left_margin) || + CHECK(right_margin) || + CHECK(upper_margin) || + CHECK(lower_margin) || + CHECK(hsync_len) || + CHECK(vsync_len) || + CHECK(sync))) + return -EINVAL; +#undef CHECK + + var->nonstd = 0; + var->accel_flags = 0; + + return 0; +} diff --git a/include/linux/amba/kmi.h b/include/linux/amba/kmi.h new file mode 100644 index 0000000..a39e5be --- /dev/null +++ b/include/linux/amba/kmi.h @@ -0,0 +1,92 @@ +/* + * linux/include/asm-arm/hardware/amba_kmi.h + * + * Internal header file for AMBA KMI ports + * + * Copyright (C) 2000 Deep Blue Solutions Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * + * --------------------------------------------------------------------------- + * From ARM PrimeCell(tm) PS2 Keyboard/Mouse Interface (PL050) Technical + * Reference Manual - ARM DDI 0143B - see http://www.arm.com/ + * --------------------------------------------------------------------------- + */ +#ifndef ASM_ARM_HARDWARE_AMBA_KMI_H +#define ASM_ARM_HARDWARE_AMBA_KMI_H + +/* + * KMI control register: + * KMICR_TYPE 0 = PS2/AT mode, 1 = No line control bit mode + * KMICR_RXINTREN 1 = enable RX interrupts + * KMICR_TXINTREN 1 = enable TX interrupts + * KMICR_EN 1 = enable KMI + * KMICR_FD 1 = force KMI data low + * KMICR_FC 1 = force KMI clock low + */ +#define KMICR (KMI_BASE + 0x00) +#define KMICR_TYPE (1 << 5) +#define KMICR_RXINTREN (1 << 4) +#define KMICR_TXINTREN (1 << 3) +#define KMICR_EN (1 << 2) +#define KMICR_FD (1 << 1) +#define KMICR_FC (1 << 0) + +/* + * KMI status register: + * KMISTAT_TXEMPTY 1 = transmitter register empty + * KMISTAT_TXBUSY 1 = currently sending data + * KMISTAT_RXFULL 1 = receiver register ready to be read + * KMISTAT_RXBUSY 1 = currently receiving data + * KMISTAT_RXPARITY parity of last databyte received + * KMISTAT_IC current level of KMI clock input + * KMISTAT_ID current level of KMI data input + */ +#define KMISTAT (KMI_BASE + 0x04) +#define KMISTAT_TXEMPTY (1 << 6) +#define KMISTAT_TXBUSY (1 << 5) +#define KMISTAT_RXFULL (1 << 4) +#define KMISTAT_RXBUSY (1 << 3) +#define KMISTAT_RXPARITY (1 << 2) +#define KMISTAT_IC (1 << 1) +#define KMISTAT_ID (1 << 0) + +/* + * KMI data register + */ +#define KMIDATA (KMI_BASE + 0x08) + +/* + * KMI clock divisor: to generate 8MHz internal clock + * div = (ref / 8MHz) - 1; 0 <= div <= 15 + */ +#define KMICLKDIV (KMI_BASE + 0x0c) + +/* + * KMI interrupt register: + * KMIIR_TXINTR 1 = transmit interrupt asserted + * KMIIR_RXINTR 1 = receive interrupt asserted + */ +#define KMIIR (KMI_BASE + 0x10) +#define KMIIR_TXINTR (1 << 1) +#define KMIIR_RXINTR (1 << 0) + +/* + * The size of the KMI primecell + */ +#define KMI_SIZE (0x100) + +#endif diff --git a/include/linux/amba/serial.h b/include/linux/amba/serial.h new file mode 100644 index 0000000..dc726ff --- /dev/null +++ b/include/linux/amba/serial.h @@ -0,0 +1,161 @@ +/* + * linux/include/asm-arm/hardware/serial_amba.h + * + * Internal header file for AMBA serial ports + * + * Copyright (C) ARM Limited + * Copyright (C) 2000 Deep Blue Solutions Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef ASM_ARM_HARDWARE_SERIAL_AMBA_H +#define ASM_ARM_HARDWARE_SERIAL_AMBA_H + +/* ------------------------------------------------------------------------------- + * From AMBA UART (PL010) Block Specification + * ------------------------------------------------------------------------------- + * UART Register Offsets. + */ +#define UART01x_DR 0x00 /* Data read or written from the interface. */ +#define UART01x_RSR 0x04 /* Receive status register (Read). */ +#define UART01x_ECR 0x04 /* Error clear register (Write). */ +#define UART010_LCRH 0x08 /* Line control register, high byte. */ +#define UART010_LCRM 0x0C /* Line control register, middle byte. */ +#define UART010_LCRL 0x10 /* Line control register, low byte. */ +#define UART010_CR 0x14 /* Control register. */ +#define UART01x_FR 0x18 /* Flag register (Read only). */ +#define UART010_IIR 0x1C /* Interrupt indentification register (Read). */ +#define UART010_ICR 0x1C /* Interrupt clear register (Write). */ +#define UART01x_ILPR 0x20 /* IrDA low power counter register. */ +#define UART011_IBRD 0x24 /* Integer baud rate divisor register. */ +#define UART011_FBRD 0x28 /* Fractional baud rate divisor register. */ +#define UART011_LCRH 0x2c /* Line control register. */ +#define UART011_CR 0x30 /* Control register. */ +#define UART011_IFLS 0x34 /* Interrupt fifo level select. */ +#define UART011_IMSC 0x38 /* Interrupt mask. */ +#define UART011_RIS 0x3c /* Raw interrupt status. */ +#define UART011_MIS 0x40 /* Masked interrupt status. */ +#define UART011_ICR 0x44 /* Interrupt clear register. */ +#define UART011_DMACR 0x48 /* DMA control register. */ + +#define UART011_DR_OE (1 << 11) +#define UART011_DR_BE (1 << 10) +#define UART011_DR_PE (1 << 9) +#define UART011_DR_FE (1 << 8) + +#define UART01x_RSR_OE 0x08 +#define UART01x_RSR_BE 0x04 +#define UART01x_RSR_PE 0x02 +#define UART01x_RSR_FE 0x01 + +#define UART011_FR_RI 0x100 +#define UART011_FR_TXFE 0x080 +#define UART011_FR_RXFF 0x040 +#define UART01x_FR_TXFF 0x020 +#define UART01x_FR_RXFE 0x010 +#define UART01x_FR_BUSY 0x008 +#define UART01x_FR_DCD 0x004 +#define UART01x_FR_DSR 0x002 +#define UART01x_FR_CTS 0x001 +#define UART01x_FR_TMSK (UART01x_FR_TXFF + UART01x_FR_BUSY) + +#define UART011_CR_CTSEN 0x8000 /* CTS hardware flow control */ +#define UART011_CR_RTSEN 0x4000 /* RTS hardware flow control */ +#define UART011_CR_OUT2 0x2000 /* OUT2 */ +#define UART011_CR_OUT1 0x1000 /* OUT1 */ +#define UART011_CR_RTS 0x0800 /* RTS */ +#define UART011_CR_DTR 0x0400 /* DTR */ +#define UART011_CR_RXE 0x0200 /* receive enable */ +#define UART011_CR_TXE 0x0100 /* transmit enable */ +#define UART011_CR_LBE 0x0080 /* loopback enable */ +#define UART010_CR_RTIE 0x0040 +#define UART010_CR_TIE 0x0020 +#define UART010_CR_RIE 0x0010 +#define UART010_CR_MSIE 0x0008 +#define UART01x_CR_IIRLP 0x0004 /* SIR low power mode */ +#define UART01x_CR_SIREN 0x0002 /* SIR enable */ +#define UART01x_CR_UARTEN 0x0001 /* UART enable */ + +#define UART011_LCRH_SPS 0x80 +#define UART01x_LCRH_WLEN_8 0x60 +#define UART01x_LCRH_WLEN_7 0x40 +#define UART01x_LCRH_WLEN_6 0x20 +#define UART01x_LCRH_WLEN_5 0x00 +#define UART01x_LCRH_FEN 0x10 +#define UART01x_LCRH_STP2 0x08 +#define UART01x_LCRH_EPS 0x04 +#define UART01x_LCRH_PEN 0x02 +#define UART01x_LCRH_BRK 0x01 + +#define UART010_IIR_RTIS 0x08 +#define UART010_IIR_TIS 0x04 +#define UART010_IIR_RIS 0x02 +#define UART010_IIR_MIS 0x01 + +#define UART011_IFLS_RX1_8 (0 << 3) +#define UART011_IFLS_RX2_8 (1 << 3) +#define UART011_IFLS_RX4_8 (2 << 3) +#define UART011_IFLS_RX6_8 (3 << 3) +#define UART011_IFLS_RX7_8 (4 << 3) +#define UART011_IFLS_TX1_8 (0 << 0) +#define UART011_IFLS_TX2_8 (1 << 0) +#define UART011_IFLS_TX4_8 (2 << 0) +#define UART011_IFLS_TX6_8 (3 << 0) +#define UART011_IFLS_TX7_8 (4 << 0) + +#define UART011_OEIM (1 << 10) /* overrun error interrupt mask */ +#define UART011_BEIM (1 << 9) /* break error interrupt mask */ +#define UART011_PEIM (1 << 8) /* parity error interrupt mask */ +#define UART011_FEIM (1 << 7) /* framing error interrupt mask */ +#define UART011_RTIM (1 << 6) /* receive timeout interrupt mask */ +#define UART011_TXIM (1 << 5) /* transmit interrupt mask */ +#define UART011_RXIM (1 << 4) /* receive interrupt mask */ +#define UART011_DSRMIM (1 << 3) /* DSR interrupt mask */ +#define UART011_DCDMIM (1 << 2) /* DCD interrupt mask */ +#define UART011_CTSMIM (1 << 1) /* CTS interrupt mask */ +#define UART011_RIMIM (1 << 0) /* RI interrupt mask */ + +#define UART011_OEIS (1 << 10) /* overrun error interrupt status */ +#define UART011_BEIS (1 << 9) /* break error interrupt status */ +#define UART011_PEIS (1 << 8) /* parity error interrupt status */ +#define UART011_FEIS (1 << 7) /* framing error interrupt status */ +#define UART011_RTIS (1 << 6) /* receive timeout interrupt status */ +#define UART011_TXIS (1 << 5) /* transmit interrupt status */ +#define UART011_RXIS (1 << 4) /* receive interrupt status */ +#define UART011_DSRMIS (1 << 3) /* DSR interrupt status */ +#define UART011_DCDMIS (1 << 2) /* DCD interrupt status */ +#define UART011_CTSMIS (1 << 1) /* CTS interrupt status */ +#define UART011_RIMIS (1 << 0) /* RI interrupt status */ + +#define UART011_OEIC (1 << 10) /* overrun error interrupt clear */ +#define UART011_BEIC (1 << 9) /* break error interrupt clear */ +#define UART011_PEIC (1 << 8) /* parity error interrupt clear */ +#define UART011_FEIC (1 << 7) /* framing error interrupt clear */ +#define UART011_RTIC (1 << 6) /* receive timeout interrupt clear */ +#define UART011_TXIC (1 << 5) /* transmit interrupt clear */ +#define UART011_RXIC (1 << 4) /* receive interrupt clear */ +#define UART011_DSRMIC (1 << 3) /* DSR interrupt clear */ +#define UART011_DCDMIC (1 << 2) /* DCD interrupt clear */ +#define UART011_CTSMIC (1 << 1) /* CTS interrupt clear */ +#define UART011_RIMIC (1 << 0) /* RI interrupt clear */ + +#define UART011_DMAONERR (1 << 2) /* disable dma on error */ +#define UART011_TXDMAE (1 << 1) /* enable transmit dma */ +#define UART011_RXDMAE (1 << 0) /* enable receive dma */ + +#define UART01x_RSR_ANY (UART01x_RSR_OE|UART01x_RSR_BE|UART01x_RSR_PE|UART01x_RSR_FE) +#define UART01x_FR_MODEM_ANY (UART01x_FR_DCD|UART01x_FR_DSR|UART01x_FR_CTS) + +#endif diff --git a/sound/arm/aaci.c b/sound/arm/aaci.c index 559ead6..5b6cae5 100644 --- a/sound/arm/aaci.c +++ b/sound/arm/aaci.c @@ -17,11 +17,11 @@ #include #include #include +#include #include #include #include -#include #include #include -- cgit v0.10.2 From de1d815fccee1f4766a7e56054ab0ec3f6f3a7db Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 14:54:15 +0000 Subject: [ARM] Move AMBA bus code to drivers/amba/ Make the AMBA bus code visible to other architectures. Signed-off-by: Russell King diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile index 2685051..ec8d17c 100644 --- a/arch/arm/common/Makefile +++ b/arch/arm/common/Makefile @@ -3,7 +3,6 @@ # obj-y += rtctime.o -obj-$(CONFIG_ARM_AMBA) += amba.o obj-$(CONFIG_ARM_GIC) += gic.o obj-$(CONFIG_ICST525) += icst525.o obj-$(CONFIG_ICST307) += icst307.o diff --git a/arch/arm/common/amba.c b/arch/arm/common/amba.c deleted file mode 100644 index 1bbdd16..0000000 --- a/arch/arm/common/amba.c +++ /dev/null @@ -1,359 +0,0 @@ -/* - * linux/arch/arm/common/amba.c - * - * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. - * - * 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 -#include -#include -#include -#include -#include - -#include -#include -#include - -#define to_amba_device(d) container_of(d, struct amba_device, dev) -#define to_amba_driver(d) container_of(d, struct amba_driver, drv) - -static struct amba_id * -amba_lookup(struct amba_id *table, struct amba_device *dev) -{ - int ret = 0; - - while (table->mask) { - ret = (dev->periphid & table->mask) == table->id; - if (ret) - break; - table++; - } - - return ret ? table : NULL; -} - -static int amba_match(struct device *dev, struct device_driver *drv) -{ - struct amba_device *pcdev = to_amba_device(dev); - struct amba_driver *pcdrv = to_amba_driver(drv); - - return amba_lookup(pcdrv->id_table, pcdev) != NULL; -} - -#ifdef CONFIG_HOTPLUG -static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) -{ - struct amba_device *pcdev = to_amba_device(dev); - - if (nr_env < 2) - return -ENOMEM; - - snprintf(buf, bufsz, "AMBA_ID=%08x", pcdev->periphid); - *envp++ = buf; - *envp++ = NULL; - return 0; -} -#else -#define amba_uevent NULL -#endif - -static int amba_suspend(struct device *dev, pm_message_t state) -{ - struct amba_driver *drv = to_amba_driver(dev->driver); - int ret = 0; - - if (dev->driver && drv->suspend) - ret = drv->suspend(to_amba_device(dev), state); - return ret; -} - -static int amba_resume(struct device *dev) -{ - struct amba_driver *drv = to_amba_driver(dev->driver); - int ret = 0; - - if (dev->driver && drv->resume) - ret = drv->resume(to_amba_device(dev)); - return ret; -} - -/* - * Primecells are part of the Advanced Microcontroller Bus Architecture, - * so we call the bus "amba". - */ -static struct bus_type amba_bustype = { - .name = "amba", - .match = amba_match, - .uevent = amba_uevent, - .suspend = amba_suspend, - .resume = amba_resume, -}; - -static int __init amba_init(void) -{ - return bus_register(&amba_bustype); -} - -postcore_initcall(amba_init); - -/* - * These are the device model conversion veneers; they convert the - * device model structures to our more specific structures. - */ -static int amba_probe(struct device *dev) -{ - struct amba_device *pcdev = to_amba_device(dev); - struct amba_driver *pcdrv = to_amba_driver(dev->driver); - struct amba_id *id; - - id = amba_lookup(pcdrv->id_table, pcdev); - - return pcdrv->probe(pcdev, id); -} - -static int amba_remove(struct device *dev) -{ - struct amba_driver *drv = to_amba_driver(dev->driver); - return drv->remove(to_amba_device(dev)); -} - -static void amba_shutdown(struct device *dev) -{ - struct amba_driver *drv = to_amba_driver(dev->driver); - drv->shutdown(to_amba_device(dev)); -} - -/** - * amba_driver_register - register an AMBA device driver - * @drv: amba device driver structure - * - * Register an AMBA device driver with the Linux device model - * core. If devices pre-exist, the drivers probe function will - * be called. - */ -int amba_driver_register(struct amba_driver *drv) -{ - drv->drv.bus = &amba_bustype; - -#define SETFN(fn) if (drv->fn) drv->drv.fn = amba_##fn - SETFN(probe); - SETFN(remove); - SETFN(shutdown); - - return driver_register(&drv->drv); -} - -/** - * amba_driver_unregister - remove an AMBA device driver - * @drv: AMBA device driver structure to remove - * - * Unregister an AMBA device driver from the Linux device - * model. The device model will call the drivers remove function - * for each device the device driver is currently handling. - */ -void amba_driver_unregister(struct amba_driver *drv) -{ - driver_unregister(&drv->drv); -} - - -static void amba_device_release(struct device *dev) -{ - struct amba_device *d = to_amba_device(dev); - - if (d->res.parent) - release_resource(&d->res); - kfree(d); -} - -#define amba_attr(name,fmt,arg...) \ -static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf) \ -{ \ - struct amba_device *dev = to_amba_device(_dev); \ - return sprintf(buf, fmt, arg); \ -} \ -static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) - -amba_attr(id, "%08x\n", dev->periphid); -amba_attr(irq0, "%u\n", dev->irq[0]); -amba_attr(irq1, "%u\n", dev->irq[1]); -amba_attr(resource, "\t%08lx\t%08lx\t%08lx\n", - dev->res.start, dev->res.end, dev->res.flags); - -/** - * amba_device_register - register an AMBA device - * @dev: AMBA device to register - * @parent: parent memory resource - * - * Setup the AMBA device, reading the cell ID if present. - * Claim the resource, and register the AMBA device with - * the Linux device manager. - */ -int amba_device_register(struct amba_device *dev, struct resource *parent) -{ - u32 pid, cid; - void __iomem *tmp; - int i, ret; - - dev->dev.release = amba_device_release; - dev->dev.bus = &amba_bustype; - dev->dev.dma_mask = &dev->dma_mask; - dev->res.name = dev->dev.bus_id; - - if (!dev->dev.coherent_dma_mask && dev->dma_mask) - dev_warn(&dev->dev, "coherent dma mask is unset\n"); - - ret = request_resource(parent, &dev->res); - if (ret == 0) { - tmp = ioremap(dev->res.start, SZ_4K); - if (!tmp) { - ret = -ENOMEM; - goto out; - } - - for (pid = 0, i = 0; i < 4; i++) - pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8); - for (cid = 0, i = 0; i < 4; i++) - cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8); - - iounmap(tmp); - - if (cid == 0xb105f00d) - dev->periphid = pid; - - if (dev->periphid) - ret = device_register(&dev->dev); - else - ret = -ENODEV; - - if (ret == 0) { - device_create_file(&dev->dev, &dev_attr_id); - if (dev->irq[0] != NO_IRQ) - device_create_file(&dev->dev, &dev_attr_irq0); - if (dev->irq[1] != NO_IRQ) - device_create_file(&dev->dev, &dev_attr_irq1); - device_create_file(&dev->dev, &dev_attr_resource); - } else { - out: - release_resource(&dev->res); - } - } - return ret; -} - -/** - * amba_device_unregister - unregister an AMBA device - * @dev: AMBA device to remove - * - * Remove the specified AMBA device from the Linux device - * manager. All files associated with this object will be - * destroyed, and device drivers notified that the device has - * been removed. The AMBA device's resources including - * the amba_device structure will be freed once all - * references to it have been dropped. - */ -void amba_device_unregister(struct amba_device *dev) -{ - device_unregister(&dev->dev); -} - - -struct find_data { - struct amba_device *dev; - struct device *parent; - const char *busid; - unsigned int id; - unsigned int mask; -}; - -static int amba_find_match(struct device *dev, void *data) -{ - struct find_data *d = data; - struct amba_device *pcdev = to_amba_device(dev); - int r; - - r = (pcdev->periphid & d->mask) == d->id; - if (d->parent) - r &= d->parent == dev->parent; - if (d->busid) - r &= strcmp(dev->bus_id, d->busid) == 0; - - if (r) { - get_device(dev); - d->dev = pcdev; - } - - return r; -} - -/** - * amba_find_device - locate an AMBA device given a bus id - * @busid: bus id for device (or NULL) - * @parent: parent device (or NULL) - * @id: peripheral ID (or 0) - * @mask: peripheral ID mask (or 0) - * - * Return the AMBA device corresponding to the supplied parameters. - * If no device matches, returns NULL. - * - * NOTE: When a valid device is found, its refcount is - * incremented, and must be decremented before the returned - * reference. - */ -struct amba_device * -amba_find_device(const char *busid, struct device *parent, unsigned int id, - unsigned int mask) -{ - struct find_data data; - - data.dev = NULL; - data.parent = parent; - data.busid = busid; - data.id = id; - data.mask = mask; - - bus_for_each_dev(&amba_bustype, NULL, &data, amba_find_match); - - return data.dev; -} - -/** - * amba_request_regions - request all mem regions associated with device - * @dev: amba_device structure for device - * @name: name, or NULL to use driver name - */ -int amba_request_regions(struct amba_device *dev, const char *name) -{ - int ret = 0; - - if (!name) - name = dev->dev.driver->name; - - if (!request_mem_region(dev->res.start, SZ_4K, name)) - ret = -EBUSY; - - return ret; -} - -/** - * amba_release_regions - release mem regions assoicated with device - * @dev: amba_device structure for device - * - * Release regions claimed by a successful call to amba_request_regions. - */ -void amba_release_regions(struct amba_device *dev) -{ - release_mem_region(dev->res.start, SZ_4K); -} - -EXPORT_SYMBOL(amba_driver_register); -EXPORT_SYMBOL(amba_driver_unregister); -EXPORT_SYMBOL(amba_device_register); -EXPORT_SYMBOL(amba_device_unregister); -EXPORT_SYMBOL(amba_find_device); -EXPORT_SYMBOL(amba_request_regions); -EXPORT_SYMBOL(amba_release_regions); diff --git a/drivers/Makefile b/drivers/Makefile index ea410b6..7fc3f0f 100644 --- a/drivers/Makefile +++ b/drivers/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_ACPI) += acpi/ # PnP must come after ACPI since it will eventually need to check if acpi # was used and do nothing if so obj-$(CONFIG_PNP) += pnp/ +obj-$(CONFIG_ARM_AMBA) += amba/ # char/ comes before serial/ etc so that the VT console is the boot-time # default. diff --git a/drivers/amba/Makefile b/drivers/amba/Makefile new file mode 100644 index 0000000..40fe740 --- /dev/null +++ b/drivers/amba/Makefile @@ -0,0 +1,2 @@ +obj-y += bus.o + diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c new file mode 100644 index 0000000..1bbdd16 --- /dev/null +++ b/drivers/amba/bus.c @@ -0,0 +1,359 @@ +/* + * linux/arch/arm/common/amba.c + * + * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved. + * + * 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 +#include +#include +#include +#include +#include + +#include +#include +#include + +#define to_amba_device(d) container_of(d, struct amba_device, dev) +#define to_amba_driver(d) container_of(d, struct amba_driver, drv) + +static struct amba_id * +amba_lookup(struct amba_id *table, struct amba_device *dev) +{ + int ret = 0; + + while (table->mask) { + ret = (dev->periphid & table->mask) == table->id; + if (ret) + break; + table++; + } + + return ret ? table : NULL; +} + +static int amba_match(struct device *dev, struct device_driver *drv) +{ + struct amba_device *pcdev = to_amba_device(dev); + struct amba_driver *pcdrv = to_amba_driver(drv); + + return amba_lookup(pcdrv->id_table, pcdev) != NULL; +} + +#ifdef CONFIG_HOTPLUG +static int amba_uevent(struct device *dev, char **envp, int nr_env, char *buf, int bufsz) +{ + struct amba_device *pcdev = to_amba_device(dev); + + if (nr_env < 2) + return -ENOMEM; + + snprintf(buf, bufsz, "AMBA_ID=%08x", pcdev->periphid); + *envp++ = buf; + *envp++ = NULL; + return 0; +} +#else +#define amba_uevent NULL +#endif + +static int amba_suspend(struct device *dev, pm_message_t state) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + int ret = 0; + + if (dev->driver && drv->suspend) + ret = drv->suspend(to_amba_device(dev), state); + return ret; +} + +static int amba_resume(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + int ret = 0; + + if (dev->driver && drv->resume) + ret = drv->resume(to_amba_device(dev)); + return ret; +} + +/* + * Primecells are part of the Advanced Microcontroller Bus Architecture, + * so we call the bus "amba". + */ +static struct bus_type amba_bustype = { + .name = "amba", + .match = amba_match, + .uevent = amba_uevent, + .suspend = amba_suspend, + .resume = amba_resume, +}; + +static int __init amba_init(void) +{ + return bus_register(&amba_bustype); +} + +postcore_initcall(amba_init); + +/* + * These are the device model conversion veneers; they convert the + * device model structures to our more specific structures. + */ +static int amba_probe(struct device *dev) +{ + struct amba_device *pcdev = to_amba_device(dev); + struct amba_driver *pcdrv = to_amba_driver(dev->driver); + struct amba_id *id; + + id = amba_lookup(pcdrv->id_table, pcdev); + + return pcdrv->probe(pcdev, id); +} + +static int amba_remove(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + return drv->remove(to_amba_device(dev)); +} + +static void amba_shutdown(struct device *dev) +{ + struct amba_driver *drv = to_amba_driver(dev->driver); + drv->shutdown(to_amba_device(dev)); +} + +/** + * amba_driver_register - register an AMBA device driver + * @drv: amba device driver structure + * + * Register an AMBA device driver with the Linux device model + * core. If devices pre-exist, the drivers probe function will + * be called. + */ +int amba_driver_register(struct amba_driver *drv) +{ + drv->drv.bus = &amba_bustype; + +#define SETFN(fn) if (drv->fn) drv->drv.fn = amba_##fn + SETFN(probe); + SETFN(remove); + SETFN(shutdown); + + return driver_register(&drv->drv); +} + +/** + * amba_driver_unregister - remove an AMBA device driver + * @drv: AMBA device driver structure to remove + * + * Unregister an AMBA device driver from the Linux device + * model. The device model will call the drivers remove function + * for each device the device driver is currently handling. + */ +void amba_driver_unregister(struct amba_driver *drv) +{ + driver_unregister(&drv->drv); +} + + +static void amba_device_release(struct device *dev) +{ + struct amba_device *d = to_amba_device(dev); + + if (d->res.parent) + release_resource(&d->res); + kfree(d); +} + +#define amba_attr(name,fmt,arg...) \ +static ssize_t show_##name(struct device *_dev, struct device_attribute *attr, char *buf) \ +{ \ + struct amba_device *dev = to_amba_device(_dev); \ + return sprintf(buf, fmt, arg); \ +} \ +static DEVICE_ATTR(name, S_IRUGO, show_##name, NULL) + +amba_attr(id, "%08x\n", dev->periphid); +amba_attr(irq0, "%u\n", dev->irq[0]); +amba_attr(irq1, "%u\n", dev->irq[1]); +amba_attr(resource, "\t%08lx\t%08lx\t%08lx\n", + dev->res.start, dev->res.end, dev->res.flags); + +/** + * amba_device_register - register an AMBA device + * @dev: AMBA device to register + * @parent: parent memory resource + * + * Setup the AMBA device, reading the cell ID if present. + * Claim the resource, and register the AMBA device with + * the Linux device manager. + */ +int amba_device_register(struct amba_device *dev, struct resource *parent) +{ + u32 pid, cid; + void __iomem *tmp; + int i, ret; + + dev->dev.release = amba_device_release; + dev->dev.bus = &amba_bustype; + dev->dev.dma_mask = &dev->dma_mask; + dev->res.name = dev->dev.bus_id; + + if (!dev->dev.coherent_dma_mask && dev->dma_mask) + dev_warn(&dev->dev, "coherent dma mask is unset\n"); + + ret = request_resource(parent, &dev->res); + if (ret == 0) { + tmp = ioremap(dev->res.start, SZ_4K); + if (!tmp) { + ret = -ENOMEM; + goto out; + } + + for (pid = 0, i = 0; i < 4; i++) + pid |= (readl(tmp + 0xfe0 + 4 * i) & 255) << (i * 8); + for (cid = 0, i = 0; i < 4; i++) + cid |= (readl(tmp + 0xff0 + 4 * i) & 255) << (i * 8); + + iounmap(tmp); + + if (cid == 0xb105f00d) + dev->periphid = pid; + + if (dev->periphid) + ret = device_register(&dev->dev); + else + ret = -ENODEV; + + if (ret == 0) { + device_create_file(&dev->dev, &dev_attr_id); + if (dev->irq[0] != NO_IRQ) + device_create_file(&dev->dev, &dev_attr_irq0); + if (dev->irq[1] != NO_IRQ) + device_create_file(&dev->dev, &dev_attr_irq1); + device_create_file(&dev->dev, &dev_attr_resource); + } else { + out: + release_resource(&dev->res); + } + } + return ret; +} + +/** + * amba_device_unregister - unregister an AMBA device + * @dev: AMBA device to remove + * + * Remove the specified AMBA device from the Linux device + * manager. All files associated with this object will be + * destroyed, and device drivers notified that the device has + * been removed. The AMBA device's resources including + * the amba_device structure will be freed once all + * references to it have been dropped. + */ +void amba_device_unregister(struct amba_device *dev) +{ + device_unregister(&dev->dev); +} + + +struct find_data { + struct amba_device *dev; + struct device *parent; + const char *busid; + unsigned int id; + unsigned int mask; +}; + +static int amba_find_match(struct device *dev, void *data) +{ + struct find_data *d = data; + struct amba_device *pcdev = to_amba_device(dev); + int r; + + r = (pcdev->periphid & d->mask) == d->id; + if (d->parent) + r &= d->parent == dev->parent; + if (d->busid) + r &= strcmp(dev->bus_id, d->busid) == 0; + + if (r) { + get_device(dev); + d->dev = pcdev; + } + + return r; +} + +/** + * amba_find_device - locate an AMBA device given a bus id + * @busid: bus id for device (or NULL) + * @parent: parent device (or NULL) + * @id: peripheral ID (or 0) + * @mask: peripheral ID mask (or 0) + * + * Return the AMBA device corresponding to the supplied parameters. + * If no device matches, returns NULL. + * + * NOTE: When a valid device is found, its refcount is + * incremented, and must be decremented before the returned + * reference. + */ +struct amba_device * +amba_find_device(const char *busid, struct device *parent, unsigned int id, + unsigned int mask) +{ + struct find_data data; + + data.dev = NULL; + data.parent = parent; + data.busid = busid; + data.id = id; + data.mask = mask; + + bus_for_each_dev(&amba_bustype, NULL, &data, amba_find_match); + + return data.dev; +} + +/** + * amba_request_regions - request all mem regions associated with device + * @dev: amba_device structure for device + * @name: name, or NULL to use driver name + */ +int amba_request_regions(struct amba_device *dev, const char *name) +{ + int ret = 0; + + if (!name) + name = dev->dev.driver->name; + + if (!request_mem_region(dev->res.start, SZ_4K, name)) + ret = -EBUSY; + + return ret; +} + +/** + * amba_release_regions - release mem regions assoicated with device + * @dev: amba_device structure for device + * + * Release regions claimed by a successful call to amba_request_regions. + */ +void amba_release_regions(struct amba_device *dev) +{ + release_mem_region(dev->res.start, SZ_4K); +} + +EXPORT_SYMBOL(amba_driver_register); +EXPORT_SYMBOL(amba_driver_unregister); +EXPORT_SYMBOL(amba_device_register); +EXPORT_SYMBOL(amba_device_unregister); +EXPORT_SYMBOL(amba_find_device); +EXPORT_SYMBOL(amba_request_regions); +EXPORT_SYMBOL(amba_release_regions); -- cgit v0.10.2 From f8ce25476d5f12ffa29b885e49c38cd95053437e Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 16:15:52 +0000 Subject: [ARM] Move asm/hardware/clock.h to linux/clk.h This is needs to be visible to other architectures using the AMBA bus and peripherals. Signed-off-by: Russell King diff --git a/arch/arm/mach-aaec2000/clock.c b/arch/arm/mach-aaec2000/clock.c index 8282083..1c84c60 100644 --- a/arch/arm/mach-aaec2000/clock.c +++ b/arch/arm/mach-aaec2000/clock.c @@ -15,9 +15,9 @@ #include #include #include +#include #include -#include #include "clock.h" diff --git a/arch/arm/mach-integrator/clock.c b/arch/arm/mach-integrator/clock.c index bbfe46c..40684e0 100644 --- a/arch/arm/mach-integrator/clock.c +++ b/arch/arm/mach-integrator/clock.c @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include #include #include "clock.h" diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c index 540b20d..5c975eb 100644 --- a/arch/arm/mach-omap1/board-palmte.c +++ b/arch/arm/mach-omap1/board-palmte.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include static void __init omap_generic_init_irq(void) { diff --git a/arch/arm/mach-omap1/clock.c b/arch/arm/mach-omap1/clock.c index 4277eee..9d862f8 100644 --- a/arch/arm/mach-omap1/clock.c +++ b/arch/arm/mach-omap1/clock.c @@ -16,9 +16,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/arch/arm/mach-omap1/serial.c b/arch/arm/mach-omap1/serial.c index 6810cfb..fcfb81d 100644 --- a/arch/arm/mach-omap1/serial.c +++ b/arch/arm/mach-omap1/serial.c @@ -17,10 +17,10 @@ #include #include #include +#include #include #include -#include #include #include diff --git a/arch/arm/mach-omap2/clock.c b/arch/arm/mach-omap2/clock.c index 85818d9..5407b95 100644 --- a/arch/arm/mach-omap2/clock.c +++ b/arch/arm/mach-omap2/clock.c @@ -22,10 +22,10 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/arch/arm/mach-omap2/serial.c b/arch/arm/mach-omap2/serial.c index f4df04f..e1bd46a 100644 --- a/arch/arm/mach-omap2/serial.c +++ b/arch/arm/mach-omap2/serial.c @@ -16,9 +16,9 @@ #include #include #include +#include #include -#include #include #include diff --git a/arch/arm/mach-omap2/timer-gp.c b/arch/arm/mach-omap2/timer-gp.c index 9ec1144..23d36b1 100644 --- a/arch/arm/mach-omap2/timer-gp.c +++ b/arch/arm/mach-omap2/timer-gp.c @@ -21,10 +21,11 @@ #include #include #include +#include + #include #include #include -#include #define OMAP2_GP_TIMER1_BASE 0x48028000 #define OMAP2_GP_TIMER2_BASE 0x4802a000 diff --git a/arch/arm/mach-realview/clock.c b/arch/arm/mach-realview/clock.c index 331e1b4..ec3f7e7 100644 --- a/arch/arm/mach-realview/clock.c +++ b/arch/arm/mach-realview/clock.c @@ -13,9 +13,9 @@ #include #include #include +#include #include -#include #include #include "clock.h" diff --git a/arch/arm/mach-s3c2410/clock.c b/arch/arm/mach-s3c2410/clock.c index 77f321f..5830ae3 100644 --- a/arch/arm/mach-s3c2410/clock.c +++ b/arch/arm/mach-s3c2410/clock.c @@ -34,16 +34,15 @@ #include #include #include - #include #include +#include #include #include #include #include -#include #include #include "clock.h" diff --git a/arch/arm/mach-s3c2410/s3c2440-clock.c b/arch/arm/mach-s3c2410/s3c2440-clock.c index c67e097..b557a2b 100644 --- a/arch/arm/mach-s3c2410/s3c2440-clock.c +++ b/arch/arm/mach-s3c2410/s3c2440-clock.c @@ -29,16 +29,15 @@ #include #include #include - #include #include +#include #include #include #include #include -#include #include #include "clock.h" diff --git a/arch/arm/mach-s3c2410/s3c2440.c b/arch/arm/mach-s3c2410/s3c2440.c index 4d63e71..b7fe6d9 100644 --- a/arch/arm/mach-s3c2410/s3c2440.c +++ b/arch/arm/mach-s3c2410/s3c2440.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -36,7 +37,6 @@ #include #include #include -#include #include #include diff --git a/arch/arm/mach-s3c2410/time.c b/arch/arm/mach-s3c2410/time.c index 9acda44..10a2976 100644 --- a/arch/arm/mach-s3c2410/time.c +++ b/arch/arm/mach-s3c2410/time.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include "clock.h" #include "cpu.h" diff --git a/arch/arm/mach-versatile/clock.c b/arch/arm/mach-versatile/clock.c index ada3142..dcf1001 100644 --- a/arch/arm/mach-versatile/clock.c +++ b/arch/arm/mach-versatile/clock.c @@ -14,9 +14,9 @@ #include #include #include +#include #include -#include #include #include "clock.h" diff --git a/arch/arm/plat-omap/clock.c b/arch/arm/plat-omap/clock.c index 7ce39b9..84fd656 100644 --- a/arch/arm/plat-omap/clock.c +++ b/arch/arm/plat-omap/clock.c @@ -19,10 +19,10 @@ #include #include #include +#include #include #include -#include #include diff --git a/arch/arm/plat-omap/common.c b/arch/arm/plat-omap/common.c index ccdb4526..adffc5a 100644 --- a/arch/arm/plat-omap/common.c +++ b/arch/arm/plat-omap/common.c @@ -18,12 +18,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include diff --git a/arch/arm/plat-omap/cpu-omap.c b/arch/arm/plat-omap/cpu-omap.c index fd894bb..98edc9f 100644 --- a/arch/arm/plat-omap/cpu-omap.c +++ b/arch/arm/plat-omap/cpu-omap.c @@ -19,13 +19,12 @@ #include #include #include +#include #include #include #include -#include - /* TODO: Add support for SDRAM timing changes */ int omap_verify_speed(struct cpufreq_policy *policy) diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c index 76f721d..ca3681a 100644 --- a/arch/arm/plat-omap/gpio.c +++ b/arch/arm/plat-omap/gpio.c @@ -19,9 +19,9 @@ #include #include #include +#include #include -#include #include #include #include diff --git a/arch/arm/plat-omap/mcbsp.c b/arch/arm/plat-omap/mcbsp.c index ea9475c..be0e0f3 100644 --- a/arch/arm/plat-omap/mcbsp.c +++ b/arch/arm/plat-omap/mcbsp.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -30,8 +31,6 @@ #include #include -#include - #ifdef CONFIG_MCBSP_DEBUG #define DBG(x...) printk(x) #else diff --git a/arch/arm/plat-omap/ocpi.c b/arch/arm/plat-omap/ocpi.c index b861482..e40fcc8 100644 --- a/arch/arm/plat-omap/ocpi.c +++ b/arch/arm/plat-omap/ocpi.c @@ -31,9 +31,9 @@ #include #include #include +#include #include -#include #include #define OCPI_BASE 0xfffec320 diff --git a/drivers/char/s3c2410-rtc.c b/drivers/char/s3c2410-rtc.c index 3df7a57..2e30865 100644 --- a/drivers/char/s3c2410-rtc.c +++ b/drivers/char/s3c2410-rtc.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,6 @@ #include -#include #include /* need this for the RTC_AF definitions */ diff --git a/drivers/char/watchdog/s3c2410_wdt.c b/drivers/char/watchdog/s3c2410_wdt.c index 621e8a9..9dc5473 100644 --- a/drivers/char/watchdog/s3c2410_wdt.c +++ b/drivers/char/watchdog/s3c2410_wdt.c @@ -46,12 +46,12 @@ #include #include #include +#include #include #include #include -#include #undef S3C24XX_VA_WATCHDOG #define S3C24XX_VA_WATCHDOG (0) diff --git a/drivers/i2c/busses/i2c-s3c2410.c b/drivers/i2c/busses/i2c-s3c2410.c index 2a2f86d..f7d40f8 100644 --- a/drivers/i2c/busses/i2c-s3c2410.c +++ b/drivers/i2c/busses/i2c-s3c2410.c @@ -34,12 +34,12 @@ #include #include #include +#include #include #include #include -#include #include #include #include diff --git a/drivers/input/serio/ambakmi.c b/drivers/input/serio/ambakmi.c index cbab5d2..3df5eed 100644 --- a/drivers/input/serio/ambakmi.c +++ b/drivers/input/serio/ambakmi.c @@ -21,10 +21,10 @@ #include #include #include +#include #include #include -#include #define KMI_BASE (kmi->base) diff --git a/drivers/mmc/mmci.c b/drivers/mmc/mmci.c index 57375bc..a0cd916 100644 --- a/drivers/mmc/mmci.c +++ b/drivers/mmc/mmci.c @@ -20,12 +20,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include "mmci.h" diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index b796a9a..5b55599 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -53,6 +53,7 @@ #include #include #include +#include #include #include @@ -60,7 +61,6 @@ #include #include -#include #include #include diff --git a/drivers/serial/amba-pl011.c b/drivers/serial/amba-pl011.c index 4ae4dff..1296705 100644 --- a/drivers/serial/amba-pl011.c +++ b/drivers/serial/amba-pl011.c @@ -49,10 +49,10 @@ #include #include #include +#include #include #include -#include #define UART_NR 14 diff --git a/drivers/serial/s3c2410.c b/drivers/serial/s3c2410.c index eb47f5b..fe83ce6 100644 --- a/drivers/serial/s3c2410.c +++ b/drivers/serial/s3c2410.c @@ -72,12 +72,12 @@ #include #include #include +#include #include #include #include -#include #include #include diff --git a/drivers/usb/host/ohci-omap.c b/drivers/usb/host/ohci-omap.c index c9e29d8..3785b3f 100644 --- a/drivers/usb/host/ohci-omap.c +++ b/drivers/usb/host/ohci-omap.c @@ -17,6 +17,7 @@ #include /* SA_INTERRUPT */ #include #include +#include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include /* OMAP-1510 OHCI has its own MMU for DMA */ diff --git a/drivers/usb/host/ohci-s3c2410.c b/drivers/usb/host/ohci-s3c2410.c index add198a..372527a 100644 --- a/drivers/usb/host/ohci-s3c2410.c +++ b/drivers/usb/host/ohci-s3c2410.c @@ -20,9 +20,9 @@ */ #include +#include #include -#include #include #define valid_port(idx) ((idx) == 1 || (idx) == 2) diff --git a/drivers/video/amba-clcd.c b/drivers/video/amba-clcd.c index 3358a14..0da4083 100644 --- a/drivers/video/amba-clcd.c +++ b/drivers/video/amba-clcd.c @@ -23,9 +23,9 @@ #include #include #include +#include #include -#include #define to_clcd(info) container_of(info, struct clcd_fb, fb) diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index d9c08cc..fe99d17 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c @@ -87,6 +87,7 @@ #include #include #include +#include #include #include @@ -96,7 +97,6 @@ #include #include #include -#include #ifdef CONFIG_PM #include diff --git a/include/asm-arm/arch-omap/system.h b/include/asm-arm/arch-omap/system.h index 9af415d..6724a81 100644 --- a/include/asm-arm/arch-omap/system.h +++ b/include/asm-arm/arch-omap/system.h @@ -5,8 +5,9 @@ #ifndef __ASM_ARCH_SYSTEM_H #define __ASM_ARCH_SYSTEM_H #include +#include + #include -#include #include #include diff --git a/include/asm-arm/hardware/clock.h b/include/asm-arm/hardware/clock.h deleted file mode 100644 index 69f3321..0000000 --- a/include/asm-arm/hardware/clock.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * linux/include/asm-arm/hardware/clock.h - * - * Copyright (C) 2004 ARM Limited. - * Written by Deep Blue Solutions Limited. - * - * 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. - */ -#ifndef ASMARM_CLOCK_H -#define ASMARM_CLOCK_H - -struct device; - -/* - * The base API. - */ - - -/* - * struct clk - an machine class defined object / cookie. - */ -struct clk; - -/** - * clk_get - lookup and obtain a reference to a clock producer. - * @dev: device for clock "consumer" - * @id: clock comsumer ID - * - * Returns a struct clk corresponding to the clock producer, or - * valid IS_ERR() condition containing errno. The implementation - * uses @dev and @id to determine the clock consumer, and thereby - * the clock producer. (IOW, @id may be identical strings, but - * clk_get may return different clock producers depending on @dev.) - * - * Drivers must assume that the clock source is not enabled. - */ -struct clk *clk_get(struct device *dev, const char *id); - -/** - * clk_enable - inform the system when the clock source should be running. - * @clk: clock source - * - * If the clock can not be enabled/disabled, this should return success. - * - * Returns success (0) or negative errno. - */ -int clk_enable(struct clk *clk); - -/** - * clk_disable - inform the system when the clock source is no longer required. - * @clk: clock source - * - * Inform the system that a clock source is no longer required by - * a driver and may be shut down. - * - * Implementation detail: if the clock source is shared between - * multiple drivers, clk_enable() calls must be balanced by the - * same number of clk_disable() calls for the clock source to be - * disabled. - */ -void clk_disable(struct clk *clk); - -/** - * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. - * This is only valid once the clock source has been enabled. - * @clk: clock source - */ -unsigned long clk_get_rate(struct clk *clk); - -/** - * clk_put - "free" the clock source - * @clk: clock source - * - * Note: drivers must ensure that all clk_enable calls made on this - * clock source are balanced by clk_disable calls prior to calling - * this function. - */ -void clk_put(struct clk *clk); - - -/* - * The remaining APIs are optional for machine class support. - */ - - -/** - * clk_round_rate - adjust a rate to the exact rate a clock can provide - * @clk: clock source - * @rate: desired clock rate in Hz - * - * Returns rounded clock rate in Hz, or negative errno. - */ -long clk_round_rate(struct clk *clk, unsigned long rate); - -/** - * clk_set_rate - set the clock rate for a clock source - * @clk: clock source - * @rate: desired clock rate in Hz - * - * Returns success (0) or negative errno. - */ -int clk_set_rate(struct clk *clk, unsigned long rate); - -/** - * clk_set_parent - set the parent clock source for this clock - * @clk: clock source - * @parent: parent clock source - * - * Returns success (0) or negative errno. - */ -int clk_set_parent(struct clk *clk, struct clk *parent); - -/** - * clk_get_parent - get the parent clock source for this clock - * @clk: clock source - * - * Returns struct clk corresponding to parent clock source, or - * valid IS_ERR() condition containing errno. - */ -struct clk *clk_get_parent(struct clk *clk); - -#endif diff --git a/include/linux/clk.h b/include/linux/clk.h new file mode 100644 index 0000000..12848f8 --- /dev/null +++ b/include/linux/clk.h @@ -0,0 +1,124 @@ +/* + * linux/include/linux/clk.h + * + * Copyright (C) 2004 ARM Limited. + * Written by Deep Blue Solutions Limited. + * + * 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. + */ +#ifndef ASMARM_CLOCK_H +#define ASMARM_CLOCK_H + +struct device; + +/* + * The base API. + */ + + +/* + * struct clk - an machine class defined object / cookie. + */ +struct clk; + +/** + * clk_get - lookup and obtain a reference to a clock producer. + * @dev: device for clock "consumer" + * @id: clock comsumer ID + * + * Returns a struct clk corresponding to the clock producer, or + * valid IS_ERR() condition containing errno. The implementation + * uses @dev and @id to determine the clock consumer, and thereby + * the clock producer. (IOW, @id may be identical strings, but + * clk_get may return different clock producers depending on @dev.) + * + * Drivers must assume that the clock source is not enabled. + */ +struct clk *clk_get(struct device *dev, const char *id); + +/** + * clk_enable - inform the system when the clock source should be running. + * @clk: clock source + * + * If the clock can not be enabled/disabled, this should return success. + * + * Returns success (0) or negative errno. + */ +int clk_enable(struct clk *clk); + +/** + * clk_disable - inform the system when the clock source is no longer required. + * @clk: clock source + * + * Inform the system that a clock source is no longer required by + * a driver and may be shut down. + * + * Implementation detail: if the clock source is shared between + * multiple drivers, clk_enable() calls must be balanced by the + * same number of clk_disable() calls for the clock source to be + * disabled. + */ +void clk_disable(struct clk *clk); + +/** + * clk_get_rate - obtain the current clock rate (in Hz) for a clock source. + * This is only valid once the clock source has been enabled. + * @clk: clock source + */ +unsigned long clk_get_rate(struct clk *clk); + +/** + * clk_put - "free" the clock source + * @clk: clock source + * + * Note: drivers must ensure that all clk_enable calls made on this + * clock source are balanced by clk_disable calls prior to calling + * this function. + */ +void clk_put(struct clk *clk); + + +/* + * The remaining APIs are optional for machine class support. + */ + + +/** + * clk_round_rate - adjust a rate to the exact rate a clock can provide + * @clk: clock source + * @rate: desired clock rate in Hz + * + * Returns rounded clock rate in Hz, or negative errno. + */ +long clk_round_rate(struct clk *clk, unsigned long rate); + +/** + * clk_set_rate - set the clock rate for a clock source + * @clk: clock source + * @rate: desired clock rate in Hz + * + * Returns success (0) or negative errno. + */ +int clk_set_rate(struct clk *clk, unsigned long rate); + +/** + * clk_set_parent - set the parent clock source for this clock + * @clk: clock source + * @parent: parent clock source + * + * Returns success (0) or negative errno. + */ +int clk_set_parent(struct clk *clk, struct clk *parent); + +/** + * clk_get_parent - get the parent clock source for this clock + * @clk: clock source + * + * Returns struct clk corresponding to parent clock source, or + * valid IS_ERR() condition containing errno. + */ +struct clk *clk_get_parent(struct clk *clk); + +#endif -- cgit v0.10.2 From fe5dd7c73d328b255286b6b65ca19dd34447f709 Mon Sep 17 00:00:00 2001 From: Russell King Date: Sat, 7 Jan 2006 16:55:50 +0000 Subject: [ARM] byteorder.h needs linux/compiler.h Signed-off-by: Russell King diff --git a/include/asm-arm/byteorder.h b/include/asm-arm/byteorder.h index af42f44..741f5bc 100644 --- a/include/asm-arm/byteorder.h +++ b/include/asm-arm/byteorder.h @@ -15,6 +15,7 @@ #ifndef __ASM_ARM_BYTEORDER_H #define __ASM_ARM_BYTEORDER_H +#include #include static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) -- cgit v0.10.2