Commit e19d4ebc authored by Arnd Bergmann's avatar Arnd Bergmann
Browse files

alpha: add full ioread64/iowrite64 implementation



The previous patch introduced ioread64/iowrite64 declarations, but
this means we no longer get the io-64-nonatomic variant, and
run into a long error when someone actually wants to use these:

ERROR: modpost: "ioread64" [drivers/net/ethernet/freescale/enetc/fsl-enetc.ko] undefined!

Add the (hopefully) correct implementation for each machine type,
based on the 32-bit accessor. Since the 32-bit return type does
not work for ioread64(), change the internal implementation to use
the correct width consistently, but leave the external interface
to match the asm-generic/iomap.h header that uses 32-bit or 64-bit
return values.

Reported-by: default avatarGuenter Roeck <linux@roeck-us.net>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Fixes: 7e772dad ("alpha: Use generic <asm-generic/io.h>")
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
parent 28a679ea
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -384,7 +384,7 @@ struct el_apecs_procdata
		}						\
	} while (0)

__EXTERN_INLINE unsigned int apecs_ioread8(const void __iomem *xaddr)
__EXTERN_INLINE u8 apecs_ioread8(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	unsigned long result, base_and_type;
@@ -420,7 +420,7 @@ __EXTERN_INLINE void apecs_iowrite8(u8 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + base_and_type) = w;
}

__EXTERN_INLINE unsigned int apecs_ioread16(const void __iomem *xaddr)
__EXTERN_INLINE u16 apecs_ioread16(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	unsigned long result, base_and_type;
@@ -456,7 +456,7 @@ __EXTERN_INLINE void apecs_iowrite16(u16 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + base_and_type) = w;
}

__EXTERN_INLINE unsigned int apecs_ioread32(const void __iomem *xaddr)
__EXTERN_INLINE u32 apecs_ioread32(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < APECS_DENSE_MEM)
@@ -472,6 +472,22 @@ __EXTERN_INLINE void apecs_iowrite32(u32 b, void __iomem *xaddr)
	*(vuip)addr = b;
}

__EXTERN_INLINE u64 apecs_ioread64(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < APECS_DENSE_MEM)
		addr = ((addr - APECS_IO) << 5) + APECS_IO + 0x18;
	return *(vulp)addr;
}

__EXTERN_INLINE void apecs_iowrite64(u64 b, void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < APECS_DENSE_MEM)
		addr = ((addr - APECS_IO) << 5) + APECS_IO + 0x18;
	*(vulp)addr = b;
}

__EXTERN_INLINE void __iomem *apecs_ioportmap(unsigned long addr)
{
	return (void __iomem *)(addr + APECS_IO);
+19 −3
Original line number Diff line number Diff line
@@ -342,7 +342,7 @@ struct el_CIA_sysdata_mcheck {
#define vuip	volatile unsigned int __force *
#define vulp	volatile unsigned long __force *

__EXTERN_INLINE unsigned int cia_ioread8(const void __iomem *xaddr)
__EXTERN_INLINE u8 cia_ioread8(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	unsigned long result, base_and_type;
@@ -374,7 +374,7 @@ __EXTERN_INLINE void cia_iowrite8(u8 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + base_and_type) = w;
}

__EXTERN_INLINE unsigned int cia_ioread16(const void __iomem *xaddr)
__EXTERN_INLINE u16 cia_ioread16(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	unsigned long result, base_and_type;
@@ -404,7 +404,7 @@ __EXTERN_INLINE void cia_iowrite16(u16 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + base_and_type) = w;
}

__EXTERN_INLINE unsigned int cia_ioread32(const void __iomem *xaddr)
__EXTERN_INLINE u32 cia_ioread32(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < CIA_DENSE_MEM)
@@ -420,6 +420,22 @@ __EXTERN_INLINE void cia_iowrite32(u32 b, void __iomem *xaddr)
	*(vuip)addr = b;
}

__EXTERN_INLINE u64 cia_ioread64(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < CIA_DENSE_MEM)
		addr = ((addr - CIA_IO) << 5) + CIA_IO + 0x18;
	return *(vulp)addr;
}

__EXTERN_INLINE void cia_iowrite64(u64 b, void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < CIA_DENSE_MEM)
		addr = ((addr - CIA_IO) << 5) + CIA_IO + 0x18;
	*(vulp)addr = b;
}

__EXTERN_INLINE void __iomem *cia_ioportmap(unsigned long addr)
{
	return (void __iomem *)(addr + CIA_IO);
+19 −3
Original line number Diff line number Diff line
@@ -230,7 +230,7 @@ union el_lca {
	} while (0)


__EXTERN_INLINE unsigned int lca_ioread8(const void __iomem *xaddr)
__EXTERN_INLINE u8 lca_ioread8(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	unsigned long result, base_and_type;
@@ -266,7 +266,7 @@ __EXTERN_INLINE void lca_iowrite8(u8 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + base_and_type) = w;
}

__EXTERN_INLINE unsigned int lca_ioread16(const void __iomem *xaddr)
__EXTERN_INLINE u16 lca_ioread16(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	unsigned long result, base_and_type;
@@ -302,7 +302,7 @@ __EXTERN_INLINE void lca_iowrite16(u16 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + base_and_type) = w;
}

__EXTERN_INLINE unsigned int lca_ioread32(const void __iomem *xaddr)
__EXTERN_INLINE u32 lca_ioread32(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < LCA_DENSE_MEM)
@@ -318,6 +318,22 @@ __EXTERN_INLINE void lca_iowrite32(u32 b, void __iomem *xaddr)
	*(vuip)addr = b;
}

__EXTERN_INLINE u64 lca_ioread64(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < LCA_DENSE_MEM)
		addr = ((addr - LCA_IO) << 5) + LCA_IO + 0x18;
	return *(vulp)addr;
}

__EXTERN_INLINE void lca_iowrite64(u64 b, void __iomem *xaddr)
{
	unsigned long addr = (unsigned long) xaddr;
	if (addr < LCA_DENSE_MEM)
		addr = ((addr - LCA_IO) << 5) + LCA_IO + 0x18;
	*(vulp)addr = b;
}

__EXTERN_INLINE void __iomem *lca_ioportmap(unsigned long addr)
{
	return (void __iomem *)(addr + LCA_IO);
+2 −2
Original line number Diff line number Diff line
@@ -332,10 +332,10 @@ struct io7 {
#define vucp	volatile unsigned char __force *
#define vusp	volatile unsigned short __force *

extern unsigned int marvel_ioread8(const void __iomem *);
extern u8 marvel_ioread8(const void __iomem *);
extern void marvel_iowrite8(u8 b, void __iomem *);

__EXTERN_INLINE unsigned int marvel_ioread16(const void __iomem *addr)
__EXTERN_INLINE u16 marvel_ioread16(const void __iomem *addr)
{
	return __kernel_ldwu(*(vusp)addr);
}
+25 −3
Original line number Diff line number Diff line
@@ -248,6 +248,7 @@ struct el_MCPCIA_uncorrected_frame_mcheck {

#define vip	volatile int __force *
#define vuip	volatile unsigned int __force *
#define vulp	volatile unsigned long __force *

#ifndef MCPCIA_ONE_HAE_WINDOW
#define MCPCIA_FROB_MMIO						\
@@ -267,7 +268,7 @@ extern inline int __mcpcia_is_mmio(unsigned long addr)
	return (addr & 0x80000000UL) == 0;
}

__EXTERN_INLINE unsigned int mcpcia_ioread8(const void __iomem *xaddr)
__EXTERN_INLINE u8 mcpcia_ioread8(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
	unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
@@ -291,7 +292,7 @@ __EXTERN_INLINE void mcpcia_iowrite8(u8 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + hose + 0x00) = w;
}

__EXTERN_INLINE unsigned int mcpcia_ioread16(const void __iomem *xaddr)
__EXTERN_INLINE u16 mcpcia_ioread16(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long)xaddr & MCPCIA_MEM_MASK;
	unsigned long hose = (unsigned long)xaddr & ~MCPCIA_MEM_MASK;
@@ -315,7 +316,7 @@ __EXTERN_INLINE void mcpcia_iowrite16(u16 b, void __iomem *xaddr)
	*(vuip) ((addr << 5) + hose + 0x08) = w;
}

__EXTERN_INLINE unsigned int mcpcia_ioread32(const void __iomem *xaddr)
__EXTERN_INLINE u32 mcpcia_ioread32(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long)xaddr;

@@ -335,6 +336,26 @@ __EXTERN_INLINE void mcpcia_iowrite32(u32 b, void __iomem *xaddr)
	*(vuip)addr = b;
}

__EXTERN_INLINE u64 mcpcia_ioread64(const void __iomem *xaddr)
{
	unsigned long addr = (unsigned long)xaddr;

	if (!__mcpcia_is_mmio(addr))
		addr = ((addr & 0xffff) << 5) + (addr & ~0xfffful) + 0x18;

	return *(vulp)addr;
}

__EXTERN_INLINE void mcpcia_iowrite64(u64 b, void __iomem *xaddr)
{
	unsigned long addr = (unsigned long)xaddr;

	if (!__mcpcia_is_mmio(addr))
		addr = ((addr & 0xffff) << 5) + (addr & ~0xfffful) + 0x18;

	*(vulp)addr = b;
}


__EXTERN_INLINE void __iomem *mcpcia_ioportmap(unsigned long addr)
{
@@ -362,6 +383,7 @@ __EXTERN_INLINE int mcpcia_is_mmio(const volatile void __iomem *xaddr)

#undef vip
#undef vuip
#undef vulp

#undef __IO_PREFIX
#define __IO_PREFIX		mcpcia
Loading