mips: add <asm-generic/io.h> including

With the adding, some default ioremap_xx methods defined in
asm-generic/io.h can be used. E.g the default ioremap_uc() returning
NULL.

We also massaged various headers to avoid nested includes.

Signed-off-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com>
[jiaxun.yang@flygoat.com: Massage more headers, fix ioport defines]
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: linux-mips@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
This commit is contained in:
Jiaxun Yang 2023-09-21 19:04:22 +08:00 committed by Arnd Bergmann
parent b85ea95d08
commit 4bfb53e7d3
6 changed files with 75 additions and 35 deletions

View file

@ -13,7 +13,6 @@
#define _ASM_IO_H #define _ASM_IO_H
#include <linux/compiler.h> #include <linux/compiler.h>
#include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/irqflags.h> #include <linux/irqflags.h>
@ -25,7 +24,6 @@
#include <asm/cpu-features.h> #include <asm/cpu-features.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/pgtable-bits.h> #include <asm/pgtable-bits.h>
#include <asm/processor.h>
#include <asm/string.h> #include <asm/string.h>
#include <mangle-port.h> #include <mangle-port.h>
@ -41,6 +39,11 @@
# define __raw_ioswabq(a, x) (x) # define __raw_ioswabq(a, x) (x)
# define ____raw_ioswabq(a, x) (x) # define ____raw_ioswabq(a, x) (x)
# define _ioswabb ioswabb
# define _ioswabw ioswabw
# define _ioswabl ioswabl
# define _ioswabq ioswabq
# define __relaxed_ioswabb ioswabb # define __relaxed_ioswabb ioswabb
# define __relaxed_ioswabw ioswabw # define __relaxed_ioswabw ioswabw
# define __relaxed_ioswabl ioswabl # define __relaxed_ioswabl ioswabl
@ -126,6 +129,7 @@ static inline phys_addr_t virt_to_phys(const volatile void *x)
* almost all conceivable cases a device driver should not be using * almost all conceivable cases a device driver should not be using
* this function * this function
*/ */
#define phys_to_virt phys_to_virt
static inline void * phys_to_virt(unsigned long address) static inline void * phys_to_virt(unsigned long address)
{ {
return __va(address); return __va(address);
@ -296,9 +300,9 @@ static inline type pfx##read##bwlq(const volatile void __iomem *mem) \
return pfx##ioswab##bwlq(__mem, __val); \ return pfx##ioswab##bwlq(__mem, __val); \
} }
#define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, barrier, relax, p) \ #define __BUILD_IOPORT_SINGLE(pfx, bwlq, type, barrier, relax) \
\ \
static inline void pfx##out##bwlq##p(type val, unsigned long port) \ static inline void pfx##out##bwlq(type val, unsigned long port) \
{ \ { \
volatile type *__addr; \ volatile type *__addr; \
type __val; \ type __val; \
@ -318,7 +322,7 @@ static inline void pfx##out##bwlq##p(type val, unsigned long port) \
*__addr = __val; \ *__addr = __val; \
} \ } \
\ \
static inline type pfx##in##bwlq##p(unsigned long port) \ static inline type pfx##in##bwlq(unsigned long port) \
{ \ { \
volatile type *__addr; \ volatile type *__addr; \
type __val; \ type __val; \
@ -360,11 +364,10 @@ __BUILD_MEMORY_PFX(__mem_, q, u64, 0)
#endif #endif
#define __BUILD_IOPORT_PFX(bus, bwlq, type) \ #define __BUILD_IOPORT_PFX(bus, bwlq, type) \
__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0,) \ __BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0)
__BUILD_IOPORT_SINGLE(bus, bwlq, type, 1, 0, _p)
#define BUILDIO_IOPORT(bwlq, type) \ #define BUILDIO_IOPORT(bwlq, type) \
__BUILD_IOPORT_PFX(, bwlq, type) \ __BUILD_IOPORT_PFX(_, bwlq, type) \
__BUILD_IOPORT_PFX(__mem_, bwlq, type) __BUILD_IOPORT_PFX(__mem_, bwlq, type)
BUILDIO_IOPORT(b, u8) BUILDIO_IOPORT(b, u8)
@ -412,14 +415,6 @@ __BUILDIO(q, u64)
#define writeq_be(val, addr) \ #define writeq_be(val, addr) \
__raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr)) __raw_writeq(cpu_to_be64((val)), (__force unsigned *)(addr))
/*
* Some code tests for these symbols
*/
#ifdef CONFIG_64BIT
#define readq readq
#define writeq writeq
#endif
#define __BUILD_MEMORY_STRING(bwlq, type) \ #define __BUILD_MEMORY_STRING(bwlq, type) \
\ \
static inline void writes##bwlq(volatile void __iomem *mem, \ static inline void writes##bwlq(volatile void __iomem *mem, \
@ -480,18 +475,6 @@ BUILDSTRING(l, u32)
BUILDSTRING(q, u64) BUILDSTRING(q, u64)
#endif #endif
static inline void memset_io(volatile void __iomem *addr, unsigned char val, int count)
{
memset((void __force *) addr, val, count);
}
static inline void memcpy_fromio(void *dst, const volatile void __iomem *src, int count)
{
memcpy(dst, (void __force *) src, count);
}
static inline void memcpy_toio(volatile void __iomem *dst, const void *src, int count)
{
memcpy((void __force *) dst, src, count);
}
/* /*
* The caches on some architectures aren't dma-coherent and have need to * The caches on some architectures aren't dma-coherent and have need to
@ -548,6 +531,61 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
#define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v)) #define csr_out32(v, a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST) = (v))
#define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST)) #define csr_in32(a) (*(volatile u32 *)((unsigned long)(a) + __CSR_32_ADJUST))
#define __raw_readb __raw_readb
#define __raw_readw __raw_readw
#define __raw_readl __raw_readl
#ifdef CONFIG_64BIT
#define __raw_readq __raw_readq
#endif
#define __raw_writeb __raw_writeb
#define __raw_writew __raw_writew
#define __raw_writel __raw_writel
#ifdef CONFIG_64BIT
#define __raw_writeq __raw_writeq
#endif
#define readb readb
#define readw readw
#define readl readl
#ifdef CONFIG_64BIT
#define readq readq
#endif
#define writeb writeb
#define writew writew
#define writel writel
#ifdef CONFIG_64BIT
#define writeq writeq
#endif
#define readsb readsb
#define readsw readsw
#define readsl readsl
#ifdef CONFIG_64BIT
#define readsq readsq
#endif
#define writesb writesb
#define writesw writesw
#define writesl writesl
#ifdef CONFIG_64BIT
#define writesq writesq
#endif
#define _inb _inb
#define _inw _inw
#define _inl _inl
#define insb insb
#define insw insw
#define insl insl
#define _outb _outb
#define _outw _outw
#define _outl _outl
#define outsb outsb
#define outsw outsw
#define outsl outsl
/* /*
* Convert a physical pointer to a virtual kernel pointer for /dev/mem * Convert a physical pointer to a virtual kernel pointer for /dev/mem
* access * access
@ -557,4 +595,6 @@ extern void (*_dma_cache_inv)(unsigned long start, unsigned long size);
void __ioread64_copy(void *to, const void __iomem *from, size_t count); void __ioread64_copy(void *to, const void __iomem *from, size_t count);
#include <asm-generic/io.h>
#endif /* _ASM_IO_H */ #endif /* _ASM_IO_H */

View file

@ -2,9 +2,9 @@
#ifndef _ASM_MMIOWB_H #ifndef _ASM_MMIOWB_H
#define _ASM_MMIOWB_H #define _ASM_MMIOWB_H
#include <asm/io.h> #include <asm/barrier.h>
#define mmiowb() iobarrier_w() #define mmiowb() wmb()
#include <asm-generic/mmiowb.h> #include <asm-generic/mmiowb.h>

View file

@ -13,8 +13,6 @@
#include <linux/errno.h> #include <linux/errno.h>
#include <asm/mips-cps.h>
#ifdef CONFIG_SMP #ifdef CONFIG_SMP
#include <linux/cpumask.h> #include <linux/cpumask.h>

View file

@ -11,13 +11,11 @@
#ifndef __ASM_SMP_H #ifndef __ASM_SMP_H
#define __ASM_SMP_H #define __ASM_SMP_H
#include <linux/bitops.h> #include <linux/compiler.h>
#include <linux/linkage.h> #include <linux/linkage.h>
#include <linux/smp.h>
#include <linux/threads.h> #include <linux/threads.h>
#include <linux/cpumask.h> #include <linux/cpumask.h>
#include <linux/atomic.h>
#include <asm/smp-ops.h> #include <asm/smp-ops.h>
extern int smp_num_siblings; extern int smp_num_siblings;

View file

@ -42,6 +42,7 @@
#include <asm/sections.h> #include <asm/sections.h>
#include <asm/setup.h> #include <asm/setup.h>
#include <asm/smp-ops.h> #include <asm/smp-ops.h>
#include <asm/mips-cps.h>
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/fw/fw.h> #include <asm/fw/fw.h>

View file

@ -7,6 +7,9 @@
* Copyright (C) 1999, 2000, 04 Ralf Baechle (ralf@linux-mips.org) * Copyright (C) 1999, 2000, 04 Ralf Baechle (ralf@linux-mips.org)
* Copyright (C) 1999, 2000 Silicon Graphics, Inc. * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
*/ */
#include <linux/io.h>
#include <asm/sn/addrs.h> #include <asm/sn/addrs.h>
#include <asm/sn/types.h> #include <asm/sn/types.h>
#include <asm/sn/klconfig.h> #include <asm/sn/klconfig.h>