Skip to content

Commit

Permalink
davinci: add arch_ioremap() which uses existing static mappings
Browse files Browse the repository at this point in the history
Add arch-specific ioremap() which uses any existing static mappings in
place of doing a new mapping.  From now on, drivers should always use
ioremap() instead of IO_ADDRESS().

In addition, remove the davinci_[read|write]* macros in favor of using
ioremap.

Signed-off-by: Kevin Hilman <khilman@deeprootsystems.com>
  • Loading branch information
Kevin Hilman committed Apr 23, 2009
1 parent c5b736d commit f5c122d
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 98 deletions.
4 changes: 3 additions & 1 deletion arch/arm/mach-davinci/board-evm.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#include <mach/common.h>
#include <mach/i2c.h>

#define DAVINCI_CFC_ATA_BASE 0x01C66000
#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE 0x02000000

/* other misc. init functions */
void __init davinci_psc_init(void);
void __init davinci_irq_init(void);
Expand Down Expand Up @@ -422,7 +425,6 @@ static __init void davinci_evm_init(void)

static __init void davinci_evm_irq_init(void)
{
davinci_init_common_hw();
davinci_irq_init();
}

Expand Down
2 changes: 2 additions & 0 deletions arch/arm/mach-davinci/devices.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <mach/i2c.h>
#include <mach/irqs.h>

#define DAVINCI_I2C_BASE 0x01C21000

static struct resource i2c_resources[] = {
{
.start = DAVINCI_I2C_BASE,
Expand Down
6 changes: 3 additions & 3 deletions arch/arm/mach-davinci/id.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/init.h>
#include <linux/io.h>

#define JTAG_ID_BASE 0x01c40028
#define JTAG_ID_BASE IO_ADDRESS(0x01c40028)

static unsigned int davinci_revision;

Expand Down Expand Up @@ -58,7 +58,7 @@ static u16 __init davinci_get_part_no(void)
{
u32 dev_id, part_no;

dev_id = davinci_readl(JTAG_ID_BASE);
dev_id = __raw_readl(JTAG_ID_BASE);

part_no = ((dev_id >> 12) & 0xffff);

Expand All @@ -72,7 +72,7 @@ static u8 __init davinci_get_variant(void)
{
u32 variant;

variant = davinci_readl(JTAG_ID_BASE);
variant = __raw_readl(JTAG_ID_BASE);

variant = (variant >> 28) & 0xf;

Expand Down
4 changes: 3 additions & 1 deletion arch/arm/mach-davinci/include/mach/gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@

#include <linux/io.h>
#include <asm-generic/gpio.h>
#include <mach/hardware.h>

#include <mach/irqs.h>

#define DAVINCI_GPIO_BASE 0x01C67000

/*
* basic gpio routines
*
Expand Down
51 changes: 13 additions & 38 deletions arch/arm/mach-davinci/include/mach/hardware.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/*
* Common hardware definitions
* Hardware definitions common to all DaVinci family processors
*
* Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
* Author: Kevin Hilman, Deep Root Systems, LLC
*
* 2007 (c) MontaVista Software, Inc. This file is licensed under
* 2007 (c) Deep Root Systems, LLC. 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.
Expand All @@ -12,41 +12,16 @@
#define __ASM_ARCH_HARDWARE_H

/*
* Base register addresses
* Before you add anything to ths file:
*
* This header is for defines common to ALL DaVinci family chips.
* Anything that is chip specific should go in <chipname>.h,
* and the chip/board init code should then explicitly include
* <chipname>.h
*/
#define DAVINCI_DMA_3PCC_BASE (0x01C00000)
#define DAVINCI_DMA_3PTC0_BASE (0x01C10000)
#define DAVINCI_DMA_3PTC1_BASE (0x01C10400)
#define DAVINCI_I2C_BASE (0x01C21000)
#define DAVINCI_PWM0_BASE (0x01C22000)
#define DAVINCI_PWM1_BASE (0x01C22400)
#define DAVINCI_PWM2_BASE (0x01C22800)
#define DAVINCI_SYSTEM_MODULE_BASE (0x01C40000)
#define DAVINCI_PLL_CNTRL0_BASE (0x01C40800)
#define DAVINCI_PLL_CNTRL1_BASE (0x01C40C00)
#define DAVINCI_PWR_SLEEP_CNTRL_BASE (0x01C41000)
#define DAVINCI_SYSTEM_DFT_BASE (0x01C42000)
#define DAVINCI_IEEE1394_BASE (0x01C60000)
#define DAVINCI_USB_OTG_BASE (0x01C64000)
#define DAVINCI_CFC_ATA_BASE (0x01C66000)
#define DAVINCI_SPI_BASE (0x01C66800)
#define DAVINCI_GPIO_BASE (0x01C67000)
#define DAVINCI_UHPI_BASE (0x01C67800)
#define DAVINCI_VPSS_REGS_BASE (0x01C70000)
#define DAVINCI_EMAC_CNTRL_REGS_BASE (0x01C80000)
#define DAVINCI_EMAC_WRAPPER_CNTRL_REGS_BASE (0x01C81000)
#define DAVINCI_EMAC_WRAPPER_RAM_BASE (0x01C82000)
#define DAVINCI_MDIO_CNTRL_REGS_BASE (0x01C84000)
#define DAVINCI_IMCOP_BASE (0x01CC0000)
#define DAVINCI_ASYNC_EMIF_CNTRL_BASE (0x01E00000)
#define DAVINCI_VLYNQ_BASE (0x01E01000)
#define DAVINCI_MCBSP_BASE (0x01E02000)
#define DAVINCI_MMC_SD_BASE (0x01E10000)
#define DAVINCI_MS_BASE (0x01E20000)
#define DAVINCI_ASYNC_EMIF_DATA_CE0_BASE (0x02000000)
#define DAVINCI_ASYNC_EMIF_DATA_CE1_BASE (0x04000000)
#define DAVINCI_ASYNC_EMIF_DATA_CE2_BASE (0x06000000)
#define DAVINCI_ASYNC_EMIF_DATA_CE3_BASE (0x08000000)
#define DAVINCI_VLYNQ_REMOTE_BASE (0x0C000000)
#define DAVINCI_SYSTEM_MODULE_BASE 0x01C40000

/* System control register offsets */
#define DM64XX_VDD3P3V_PWDN 0x48

#endif /* __ASM_ARCH_HARDWARE_H */
20 changes: 5 additions & 15 deletions arch/arm/mach-davinci/include/mach/io.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,12 @@
#else
#define IOMEM(x) ((void __force __iomem *)(x))

/*
* Functions to access the DaVinci IO region
*
* NOTE: - Use davinci_read/write[bwl] for physical register addresses
* - Use __raw_read/write[bwl]() for virtual register addresses
* - Use IO_ADDRESS(phys_addr) to convert registers to virtual addresses
* - DO NOT use hardcoded virtual addresses to allow changing the
* IO address space again if needed
*/
#define davinci_readb(a) __raw_readb(IO_ADDRESS(a))
#define davinci_readw(a) __raw_readw(IO_ADDRESS(a))
#define davinci_readl(a) __raw_readl(IO_ADDRESS(a))
#define __arch_ioremap(p, s, t) davinci_ioremap(p, s, t)
#define __arch_iounmap(v) davinci_iounmap(v)

#define davinci_writeb(v, a) __raw_writeb(v, IO_ADDRESS(a))
#define davinci_writew(v, a) __raw_writew(v, IO_ADDRESS(a))
#define davinci_writel(v, a) __raw_writel(v, IO_ADDRESS(a))
void __iomem *davinci_ioremap(unsigned long phys, size_t size,
unsigned int type);
void davinci_iounmap(volatile void __iomem *addr);

#endif /* __ASSEMBLER__ */
#endif /* __ASM_ARCH_IO_H */
22 changes: 21 additions & 1 deletion arch/arm/mach-davinci/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ void __init davinci_map_common_io(void)
davinci_check_revision();
}

void __init davinci_init_common_hw(void)
#define BETWEEN(p, st, sz) ((p) >= (st) && (p) < ((st) + (sz)))
#define XLATE(p, pst, vst) ((void __iomem *)((p) - (pst) + (vst)))

/*
* Intercept ioremap() requests for addresses in our fixed mapping regions.
*/
void __iomem *davinci_ioremap(unsigned long p, size_t size, unsigned int type)
{
if (BETWEEN(p, IO_PHYS, IO_SIZE))
return XLATE(p, IO_PHYS, IO_VIRT);

return __arm_ioremap(p, size, type);
}
EXPORT_SYMBOL(davinci_ioremap);

void davinci_iounmap(volatile void __iomem *addr)
{
unsigned long virt = (unsigned long)addr;

if (virt >= VMALLOC_START && virt < VMALLOC_END)
__iounmap(addr);
}
EXPORT_SYMBOL(davinci_iounmap);
6 changes: 4 additions & 2 deletions arch/arm/mach-davinci/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,16 @@
#define IRQ_INTPRI0_REG_OFFSET 0x0030
#define IRQ_INTPRI7_REG_OFFSET 0x004C

#define INTC_BASE IO_ADDRESS(DAVINCI_ARM_INTC_BASE)

static inline unsigned int davinci_irq_readl(int offset)
{
return davinci_readl(DAVINCI_ARM_INTC_BASE + offset);
return __raw_readl(INTC_BASE + offset);
}

static inline void davinci_irq_writel(unsigned long value, int offset)
{
davinci_writel(value, DAVINCI_ARM_INTC_BASE + offset);
__raw_writel(value, INTC_BASE + offset);
}

/* Disable interrupt */
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/mach-davinci/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ static DEFINE_SPINLOCK(mux_lock);

void davinci_mux_peripheral(unsigned int mux, unsigned int enable)
{
void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE);
u32 pinmux, muxreg = PINMUX0;

if (mux >= DAVINCI_MUX_LEVEL2) {
Expand All @@ -31,11 +32,11 @@ void davinci_mux_peripheral(unsigned int mux, unsigned int enable)
}

spin_lock(&mux_lock);
pinmux = davinci_readl(DAVINCI_SYSTEM_MODULE_BASE + muxreg);
pinmux = __raw_readl(base + muxreg);
if (enable)
pinmux |= (1 << mux);
else
pinmux &= ~(1 << mux);
davinci_writel(pinmux, DAVINCI_SYSTEM_MODULE_BASE + muxreg);
__raw_writel(pinmux, base + muxreg);
spin_unlock(&mux_lock);
}
2 changes: 2 additions & 0 deletions arch/arm/mach-davinci/psc.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <mach/psc.h>
#include <mach/mux.h>

#define DAVINCI_PWR_SLEEP_CNTRL_BASE 0x01C41000

/* PSC register offsets */
#define EPCPR 0x070
#define PTCMD 0x120
Expand Down
Loading

0 comments on commit f5c122d

Please sign in to comment.