diff mbox series

[RESEND,RFC,03/12] sh: SH4 OF support.

Message ID 4a138cf1ff14ff6166a66851db7476096fa3f009.1693444193.git.ysato@users.sourceforge.jp (mailing list archive)
State New, archived
Headers show
Series DeviceTree support for SH7751 based boards. | expand

Commit Message

Yoshinori Sato Aug. 31, 2023, 1:11 a.m. UTC
- switch generic framework in clock / PCI.

Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
---
 arch/sh/drivers/Makefile        |  2 ++
 arch/sh/include/asm/io.h        | 10 ++++++++++
 arch/sh/include/asm/pci.h       |  4 ++++
 arch/sh/kernel/cpu/Makefile     |  8 ++++++--
 arch/sh/kernel/cpu/clock.c      |  3 ++-
 arch/sh/kernel/cpu/sh4/Makefile |  2 ++
 6 files changed, 26 insertions(+), 3 deletions(-)

Comments

Geert Uytterhoeven Sept. 1, 2023, 12:26 p.m. UTC | #1
Hi Sato-san,

Thanks for your patch!

On Thu, Aug 31, 2023 at 5:22 AM Yoshinori Sato
<ysato@users.sourceforge.jp> wrote:
> - switch generic framework in clock / PCI.

... and much more.
Please split in separate patches.

> --- a/arch/sh/kernel/cpu/clock.c
> +++ b/arch/sh/kernel/cpu/clock.c
> @@ -14,12 +14,13 @@
>  #include <linux/kernel.h>
>  #include <linux/init.h>
>  #include <linux/clk.h>
> +#include <linux/of.h>
>  #include <asm/clock.h>
>  #include <asm/machvec.h>
>
>  int __init clk_init(void)
>  {
> -       int ret;
> +       int ret = 0;
>
>  #ifndef CONFIG_COMMON_CLK
>         ret = arch_clk_init();

Perhaps make this whole function depend on CONFIG_COMMON_CLK,
and call sh_of_clk_init() (or of_clk_init()) directly() from time_init()?

> @@ -15,6 +15,7 @@ perf-$(CONFIG_CPU_SUBTYPE_SH7750)     := perf_event.o
>  perf-$(CONFIG_CPU_SUBTYPE_SH7750S)     := perf_event.o
>  perf-$(CONFIG_CPU_SUBTYPE_SH7091)      := perf_event.o
>
> +ifndef CONFIG_OF

CONFIG_SH_DEVICE_TREE

>  # CPU subtype setup
>  obj-$(CONFIG_CPU_SUBTYPE_SH7750)       += setup-sh7750.o
>  obj-$(CONFIG_CPU_SUBTYPE_SH7750R)      += setup-sh7750.o

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
Geert Uytterhoeven Sept. 13, 2023, 12:23 p.m. UTC | #2
Hi Sato-san,

On Thu, Aug 31, 2023 at 5:22 AM Yoshinori Sato
<ysato@users.sourceforge.jp> wrote:
> - switch generic framework in clock / PCI.
>
> Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>

> --- a/arch/sh/include/asm/io.h
> +++ b/arch/sh/include/asm/io.h
> @@ -292,4 +292,14 @@ static inline void iounmap(volatile void __iomem *addr) { }
>  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     0xfe240000UL
> +
> +#define HAVE_ARCH_PIO_SIZE
> +#define PIO_OFFSET     PCI_IOBASE
> +#define PIO_MASK       0x3ffffUL
> +#define PIO_RESERVED   0x40000UL
> +#endif /* __KERNEL__ */
> +

Since commit b94692e84dccf12d ("sh: add <asm-generic/io.h> including")
in v6.6-rc1, the new definitions must be inserted higher up, before
the inclusion of <asm-generic/io.h>, to avoid:

    arch/sh/include/asm/io.h:322: warning: "PCI_IOBASE" redefined
      322 | #define PCI_IOBASE      0xfe240000UL
          |
    include/asm-generic/io.h:527: note: this is the location of the
previous definition

>  #endif /* __ASM_SH_IO_H */

Gr{oetje,eeting}s,

                        Geert
Yoshinori Sato Sept. 15, 2023, 9:21 a.m. UTC | #3
On Wed, 13 Sep 2023 21:23:14 +0900,
Geert Uytterhoeven wrote:
> 
> Hi Sato-san,
> 
> On Thu, Aug 31, 2023 at 5:22 AM Yoshinori Sato
> <ysato@users.sourceforge.jp> wrote:
> > - switch generic framework in clock / PCI.
> >
> > Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
> 
> > --- a/arch/sh/include/asm/io.h
> > +++ b/arch/sh/include/asm/io.h
> > @@ -292,4 +292,14 @@ static inline void iounmap(volatile void __iomem *addr) { }
> >  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     0xfe240000UL
> > +
> > +#define HAVE_ARCH_PIO_SIZE
> > +#define PIO_OFFSET     PCI_IOBASE
> > +#define PIO_MASK       0x3ffffUL
> > +#define PIO_RESERVED   0x40000UL
> > +#endif /* __KERNEL__ */
> > +
> 
> Since commit b94692e84dccf12d ("sh: add <asm-generic/io.h> including")
> in v6.6-rc1, the new definitions must be inserted higher up, before
> the inclusion of <asm-generic/io.h>, to avoid:
> 
>     arch/sh/include/asm/io.h:322: warning: "PCI_IOBASE" redefined
>       322 | #define PCI_IOBASE      0xfe240000UL
>           |
>     include/asm-generic/io.h:527: note: this is the location of the
> previous definition
> 
> >  #endif /* __ASM_SH_IO_H */

OK.
This has been fixed in the v2 patch.

> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> -- 
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds
diff mbox series

Patch

diff --git a/arch/sh/drivers/Makefile b/arch/sh/drivers/Makefile
index 56b0acace6e7..eacbcefb26b2 100644
--- a/arch/sh/drivers/Makefile
+++ b/arch/sh/drivers/Makefile
@@ -5,7 +5,9 @@ 
 
 obj-y		+= dma/ platform_early.o
 
+ifndef CONFIG_SH_DEVICE_TREE
 obj-$(CONFIG_PCI)		+= pci/
+endif
 obj-$(CONFIG_SUPERHYWAY)	+= superhyway/
 obj-$(CONFIG_PUSH_SWITCH)	+= push-switch.o
 obj-$(CONFIG_HEARTBEAT)		+= heartbeat.o
diff --git a/arch/sh/include/asm/io.h b/arch/sh/include/asm/io.h
index d8f3537ef57f..d14adf034780 100644
--- a/arch/sh/include/asm/io.h
+++ b/arch/sh/include/asm/io.h
@@ -292,4 +292,14 @@  static inline void iounmap(volatile void __iomem *addr) { }
 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	0xfe240000UL
+
+#define HAVE_ARCH_PIO_SIZE
+#define PIO_OFFSET	PCI_IOBASE
+#define PIO_MASK	0x3ffffUL
+#define PIO_RESERVED	0x40000UL
+#endif /* __KERNEL__ */
+
 #endif /* __ASM_SH_IO_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 */
diff --git a/arch/sh/kernel/cpu/Makefile b/arch/sh/kernel/cpu/Makefile
index 46118236bf04..e462a9552c92 100644
--- a/arch/sh/kernel/cpu/Makefile
+++ b/arch/sh/kernel/cpu/Makefile
@@ -16,6 +16,10 @@  obj-$(CONFIG_ARCH_SHMOBILE)	+= shmobile/
 # Common interfaces.
 
 obj-$(CONFIG_SH_ADC)		+= adc.o
+ifndef CONFIG_COMMON_CLK
 obj-$(CONFIG_SH_CLK_CPG_LEGACY)	+= clock-cpg.o
-
-obj-y	+= irq/ init.o clock.o fpu.o pfc.o proc.o
+endif
+ifndef CONFIG_GENERIC_IRQ_CHIP
+obj-y	+= irq/
+endif
+obj-y	+= init.o clock.o fpu.o pfc.o proc.o
diff --git a/arch/sh/kernel/cpu/clock.c b/arch/sh/kernel/cpu/clock.c
index 6fb34410d630..e6c75d4ba7e1 100644
--- a/arch/sh/kernel/cpu/clock.c
+++ b/arch/sh/kernel/cpu/clock.c
@@ -14,12 +14,13 @@ 
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/clk.h>
+#include <linux/of.h>
 #include <asm/clock.h>
 #include <asm/machvec.h>
 
 int __init clk_init(void)
 {
-	int ret;
+	int ret = 0;
 
 #ifndef CONFIG_COMMON_CLK
 	ret = arch_clk_init();
diff --git a/arch/sh/kernel/cpu/sh4/Makefile b/arch/sh/kernel/cpu/sh4/Makefile
index 00c16331e07e..1e196c320b96 100644
--- a/arch/sh/kernel/cpu/sh4/Makefile
+++ b/arch/sh/kernel/cpu/sh4/Makefile
@@ -15,6 +15,7 @@  perf-$(CONFIG_CPU_SUBTYPE_SH7750)	:= perf_event.o
 perf-$(CONFIG_CPU_SUBTYPE_SH7750S)	:= perf_event.o
 perf-$(CONFIG_CPU_SUBTYPE_SH7091)	:= perf_event.o
 
+ifndef CONFIG_OF
 # CPU subtype setup
 obj-$(CONFIG_CPU_SUBTYPE_SH7750)	+= setup-sh7750.o
 obj-$(CONFIG_CPU_SUBTYPE_SH7750R)	+= setup-sh7750.o
@@ -32,6 +33,7 @@  endif
 
 # Additional clocks by subtype
 clock-$(CONFIG_CPU_SUBTYPE_SH4_202)	+= clock-sh4-202.o
+endif
 
 obj-y					+= $(clock-y)
 obj-$(CONFIG_PERF_EVENTS)		+= $(perf-y)