diff mbox series

[v4,10/37] sh: Common PCI framework support

Message ID 65b5ddcbecfa05088b3889d0815588012dc816da.1699856600.git.ysato@users.sourceforge.jp (mailing list archive)
State New, archived
Headers show
Series Device Tree support for SH7751 based board | expand

Commit Message

Yoshinori Sato Nov. 14, 2023, 8 a.m. UTC
When CONFIG_OF=y, a common PCI framework is used.
The new driver also needs to reference PCI headers, so move the
necessary header files to a public location rather than a private one.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 arch/sh/include/asm/io.h                      | 40 +++++++++++++------
 .../sh/{drivers/pci => include/asm}/pci-sh4.h |  7 ++--
 .../{drivers/pci => include/asm}/pci-sh7751.h |  0
 .../{drivers/pci => include/asm}/pci-sh7780.h |  0
 arch/sh/include/asm/pci.h                     |  4 ++
 5 files changed, 36 insertions(+), 15 deletions(-)
 rename arch/sh/{drivers/pci => include/asm}/pci-sh4.h (99%)
 rename arch/sh/{drivers/pci => include/asm}/pci-sh7751.h (100%)
 rename arch/sh/{drivers/pci => include/asm}/pci-sh7780.h (100%)

Comments

Arnd Bergmann Nov. 14, 2023, 1:03 p.m. UTC | #1
On Tue, Nov 14, 2023, at 03:00, Yoshinori Sato wrote:
> When CONFIG_OF=y, a common PCI framework is used.
> The new driver also needs to reference PCI headers, so move the
> necessary header files to a public location rather than a private one.
>
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> ---
>  arch/sh/include/asm/io.h                      | 40 +++++++++++++------
>  .../sh/{drivers/pci => include/asm}/pci-sh4.h |  7 ++--
>  .../{drivers/pci => include/asm}/pci-sh7751.h |  0
>  .../{drivers/pci => include/asm}/pci-sh7780.h |  0
>  arch/sh/include/asm/pci.h                     |  4 ++

I think ideally the PCI host driver should be moved to
drivers/pci/controller, but I'm not sure if that solves
your problem here. There should normally be no need to
put driver specific headers into a global location.
 
>  #define IO_SPACE_LIMIT 0xffffffff

The IO_SPACE_LIMIT is wrong here, as most of the address space
is not actually reserved for port I/O. Usually you want just
64KB here, but you can also make this PIO_MASK I think.

> +#ifdef __KERNEL__
> +#define PCI_IOBASE	((void __iomem *)0xfe240000UL)
> +
> +#define HAVE_ARCH_PIO_SIZE
> +#define PIO_OFFSET	0xfe240000UL
> +#define PIO_MASK	0x3ffffUL
> +#define PIO_RESERVED	0x40000UL
> +#endif /* __KERNEL__ */

As far as I understand the generic iomap code, this does
not work because PIO_OFFSET has to be smaller than
PIO_RESERVED. Once you remove the GENERIC_IOMAP hack, it
should no longer matter.

      Arnd
diff mbox series

Patch

diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index ac521f287fa5..ef9b774dd4c8 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -150,6 +150,7 @@  __BUILD_MEMORY_STRING(__raw_, q, u64)
  */
 #undef CONF_SLOWDOWN_IO
 
+#ifndef CONFIG_GENERIC_IOMAP
 /*
  * On SuperH I/O ports are memory mapped, so we access them using normal
  * load/store instructions. sh_io_port_base is the virtual address to
@@ -163,11 +164,7 @@  static inline void __set_io_port_base(unsigned long pbase)
 	barrier();
 }
 
-#ifdef CONFIG_GENERIC_IOMAP
-#define __ioport_map ioport_map
-#else
 extern void __iomem *__ioport_map(unsigned long addr, unsigned int size);
-#endif
 
 #ifdef CONF_SLOWDOWN_IO
 #define SLOW_DOWN_IO __raw_readw(sh_io_port_base)
@@ -239,12 +236,6 @@  __BUILD_IOPORT_STRING(w, u16)
 __BUILD_IOPORT_STRING(l, u32)
 __BUILD_IOPORT_STRING(q, u64)
 
-#else /* !CONFIG_HAS_IOPORT_MAP */
-
-#include <asm/io_noioport.h>
-
-#endif
-
 #define inb(addr)      inb(addr)
 #define inw(addr)      inw(addr)
 #define inl(addr)      inl(addr)
@@ -265,6 +256,21 @@  __BUILD_IOPORT_STRING(q, u64)
 #define outsb outsb
 #define outsw outsw
 #define outsl outsl
+#else /* !CONFIG_GENERIC_IOMAP */
+#define __ioport_map ioport_map
+#endif
+
+#else /* !CONFIG_HAS_IOPORT_MAP */
+
+#define insb insb
+#define insw insw
+#define insl insl
+#define outsb outsb
+#define outsw outsw
+#define outsl outsl
+#include <asm/io_noioport.h>
+
+#endif
 
 #define IO_SPACE_LIMIT 0xffffffff
 
@@ -311,10 +317,20 @@  unsigned long long poke_real_address_q(unsigned long long addr,
 #define xlate_dev_mem_ptr(p)	__va(p)
 #define unxlate_dev_mem_ptr(p, v) do { } while (0)
 
-#include <asm-generic/io.h>
-
 #define ARCH_HAS_VALID_PHYS_ADDR_RANGE
 int valid_phys_addr_range(phys_addr_t addr, size_t size);
 int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);
 
+
+#ifdef __KERNEL__
+#define PCI_IOBASE	((void __iomem *)0xfe240000UL)
+
+#define HAVE_ARCH_PIO_SIZE
+#define PIO_OFFSET	0xfe240000UL
+#define PIO_MASK	0x3ffffUL
+#define PIO_RESERVED	0x40000UL
+#endif /* __KERNEL__ */
+
+#include <asm-generic/io.h>
+
 #endif /* __ASM_SH_IO_H */
diff --git a/arch/sh/drivers/pci/pci-sh4.h b/arch/sh/include/asm/pci-sh4.h
similarity index 99%
rename from arch/sh/drivers/pci/pci-sh4.h
rename to arch/sh/include/asm/pci-sh4.h
index 1543c50b6503..26a75841fbe2 100644
--- a/arch/sh/drivers/pci/pci-sh4.h
+++ b/arch/sh/include/asm/pci-sh4.h
@@ -5,9 +5,9 @@ 
 #if defined(CONFIG_CPU_SUBTYPE_SH7780) || \
     defined(CONFIG_CPU_SUBTYPE_SH7785) || \
     defined(CONFIG_CPU_SUBTYPE_SH7763)
-#include "pci-sh7780.h"
+#include <asm/pci-sh7780.h>
 #else
-#include "pci-sh7751.h"
+#include <asm/pci-sh7751.h>
 #endif
 
 #include <asm/io.h>
@@ -153,6 +153,7 @@ 
   #define SH4_PCIPDTR_PB0	  0x000000001	/* Port 0 Enable */
 #define SH4_PCIPDR		0x220		/* Port IO Data Register */
 
+#ifndef CONFIG_PCI_HOST_COMMON
 /* arch/sh/kernel/drivers/pci/ops-sh4.c */
 extern struct pci_ops sh4_pci_ops;
 int pci_fixup_pcic(struct pci_channel *chan);
@@ -178,5 +179,5 @@  static inline unsigned long pci_read_reg(struct pci_channel *chan,
 {
 	return __raw_readl(chan->reg_base + reg);
 }
-
+#endif
 #endif /* __PCI_SH4_H */
diff --git a/arch/sh/drivers/pci/pci-sh7751.h b/arch/sh/include/asm/pci-sh7751.h
similarity index 100%
rename from arch/sh/drivers/pci/pci-sh7751.h
rename to arch/sh/include/asm/pci-sh7751.h
diff --git a/arch/sh/drivers/pci/pci-sh7780.h b/arch/sh/include/asm/pci-sh7780.h
similarity index 100%
rename from arch/sh/drivers/pci/pci-sh7780.h
rename to arch/sh/include/asm/pci-sh7780.h
diff --git a/arch/sh/include/asm/pci.h b/arch/sh/include/asm/pci.h
index 54c30126ea17..92b3bd604319 100644
--- a/arch/sh/include/asm/pci.h
+++ b/arch/sh/include/asm/pci.h
@@ -2,6 +2,7 @@ 
 #ifndef __ASM_SH_PCI_H
 #define __ASM_SH_PCI_H
 
+#ifndef CONFIG_SH_DEVICE_TREE
 /* Can be used to override the logic in pci_scan_bus for skipping
    already-configured bus numbers - to be used for buggy BIOSes
    or architectures with incomplete PCI setup by the loader */
@@ -88,4 +89,7 @@  static inline int pci_proc_domain(struct pci_bus *bus)
 	return hose->need_domain_info;
 }
 
+#else /* CONFIG_SH_DEVICE_TREE */
+#include <asm-generic/pci.h>
+#endif
 #endif /* __ASM_SH_PCI_H */