Skip to contentSkip to conversation

MIPS generic kernels, SEAD-3 & Boston support

PATCH Superseded Paul Burton 5 participants 42 messages Aug 26, 2016 – Dec 25, 2017

Subsystems (8)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover MIPS generic kernels, SEAD-3 & Boston support

This series introduces some infrastructure for building generic kernels which will run on multiple boards depending upon the device tree provided to them by the bootloader. It converts SEAD-3 to make use of this, and adds support for the MIPS Boston development platform.

The Boston support can be tested in QEMU with this patchset applied:

https://lists.gnu.org/archive/html/qemu-devel/2016-08/msg03419.html

To do so, configure the kernel for the generic 64r6el_defconfig & run QEMU like so:

  $ make ARCH=mips 64r6el_defconfig
  $ make ARCH=mips CROSS_COMPILE=my-toolchain-
  $ qemu-system-mips64el -M boston \
      -kernel arch/mips/boot/vmlinux.gz.itb \
      serial stdio

The same kernel binary will also boot on a SEAD-3 if using a bootloader capable of loading the FIT image format (ie. U-Boot). These 2 boards form the starting point for the generic kernels, with Ci20 & Ci40 able to be added easily. Malta will require further work, but I've got most peripherals converted to probe using device tree as a starting point & will submit that separately.

This series applies atop v4.8-rc3 with my "MIPS: SEAD3 device tree conversion" series applied first.

Paul Burton (26):
MIPS: PCI: Support for CONFIG_PCI_DOMAINS_GENERIC
MIPS: PCI: Make pcibios_set_cache_line_size an initcall
MIPS: PCI: Inline pcibios_assign_all_busses
MIPS: PCI: Split pci.c into pci.c & pci-legacy.c
MIPS: PCI: Introduce CONFIG_PCI_DRIVERS_LEGACY
MIPS: PCI: Support generic drivers
MIPS: Sanitise coherentio semantics
MIPS: dma-default: Don't check hw_coherentio if device is non-coherent
MIPS: Support per-device DMA coherence
MIPS: Print CM error reports upon bus errors
dt-bindings: Document mti,mips-cpc binding
MIPS: CPC: Provide a default mips_cpc_default_phys_base
dt-bindings: Document mti,mips-cdmm binding
MIPS: CDMM: Allow CDMM base address to be specified via DT
irqchip: mips-cpu: Replace magic 0x100 with IE_SW0
irqchip: mips-cpu: Prepare for non-legacy IRQ domains
irqchip: mips-cpu: Introduce IPI IRQ domain support
MIPS: smp-mt: Use CPU interrupt controller IPI IRQ domain support
MIPS: Stengthen IPI IRQ domain sanity check
MIPS: Adjust MIPS64 CAC_BASE to reflect Config.K0
MIPS: Support generating Flattened Image Trees (.itb)
MIPS: generic: Introduce generic DT-based board support
MIPS: generic: Convert SEAD-3 to a generic board
dt-bindings: Document img,boston-clock binding
clk: boston: Add a driver for MIPS Boston board clocks
MIPS: generic: Support MIPS Boston development boards

 .../devicetree/bindings/clock/img,boston-clock.txt |  27 ++
 .../devicetree/bindings/misc/mti,mips-cdmm.txt     |   8 +
 .../devicetree/bindings/misc/mti,mips-cpc.txt      |   8 +
 arch/mips/Kbuild.platforms                         |   2 +-
 arch/mips/Kconfig                                  | 104 ++++---
 arch/mips/Makefile                                 |  72 ++++-
 arch/mips/alchemy/common/setup.c                   |   6 +-
 arch/mips/boot/Makefile                            |  66 +++++
 arch/mips/boot/dts/Makefile                        |   1 +
 arch/mips/boot/dts/img/Makefile                    |   7 +
 arch/mips/boot/dts/img/boston.dts                  | 230 ++++++++++++++++
 arch/mips/boot/dts/mti/Makefile                    |   2 +-
 arch/mips/boot/dts/mti/sead3.dts                   |   1 +
 arch/mips/configs/generic/32r1.config              |   2 +
 arch/mips/configs/generic/32r2.config              |   3 +
 arch/mips/configs/generic/32r6.config              |   2 +
 arch/mips/configs/generic/64r1.config              |   1 +
 arch/mips/configs/generic/64r2.config              |   2 +
 arch/mips/configs/generic/64r6.config              |   1 +
 arch/mips/configs/generic/board-boston.config      |  46 ++++
 arch/mips/configs/generic/board-sead-3.config      |  32 +++
 arch/mips/configs/generic/eb.config                |   1 +
 arch/mips/configs/generic/el.config                |   1 +
 arch/mips/configs/generic/micro32r2.config         |   4 +
 arch/mips/configs/generic_defconfig                |   2 +
 arch/mips/configs/sead3_defconfig                  | 129 ---------
 arch/mips/configs/sead3micro_defconfig             | 122 ---------
 arch/mips/generic/Kconfig                          |  27 ++
 arch/mips/generic/Makefile                         |  15 +
 arch/mips/generic/Platform                         |  14 +
 .../sead3-dtshim.c => generic/board-sead3.c}       | 106 +++++++-
 arch/mips/generic/init.c                           | 174 ++++++++++++
 arch/mips/generic/irq.c                            |  64 +++++
 arch/mips/generic/proc.c                           |  29 ++
 arch/mips/generic/vmlinux.its.S                    |  56 ++++
 arch/mips/include/asm/addrspace.h                  |   3 +-
 arch/mips/include/asm/device.h                     |   5 +
 arch/mips/include/asm/dma-coherence.h              |  16 +-
 arch/mips/include/asm/dma-mapping.h                |  10 +
 arch/mips/include/asm/mach-generic/dma-coherence.h |  14 +-
 arch/mips/include/asm/mach-generic/spaces.h        |   8 +-
 arch/mips/include/asm/mach-ip27/spaces.h           |   1 +
 .../include/asm/mach-sead3/cpu-feature-overrides.h |  72 -----
 arch/mips/include/asm/mach-sead3/irq.h             |   9 -
 .../include/asm/mach-sead3/kernel-entry-init.h     |  21 --
 arch/mips/include/asm/mach-sead3/sead3-dtshim.h    |  29 --
 arch/mips/include/asm/mach-sead3/war.h             |  24 --
 arch/mips/include/asm/machine.h                    |  63 +++++
 arch/mips/include/asm/pci.h                        |  57 +++-
 arch/mips/kernel/mips-cpc.c                        |  18 ++
 arch/mips/kernel/smp-mt.c                          |  49 +---
 arch/mips/kernel/smp.c                             |  20 +-
 arch/mips/kernel/traps.c                           |   3 +
 arch/mips/lantiq/irq.c                             |  52 ----
 arch/mips/lib/iomap-pci.c                          |   4 +
 arch/mips/mm/c-r4k.c                               |   7 +-
 arch/mips/mm/dma-default.c                         |  16 +-
 arch/mips/mti-malta/malta-int.c                    |  90 +-----
 arch/mips/mti-malta/malta-setup.c                  |  10 +-
 arch/mips/mti-sead3/Makefile                       |  15 -
 arch/mips/mti-sead3/Platform                       |   7 -
 arch/mips/mti-sead3/sead3-init.c                   | 100 -------
 arch/mips/mti-sead3/sead3-int.c                    |  23 --
 arch/mips/mti-sead3/sead3-setup.c                  |  39 ---
 arch/mips/mti-sead3/sead3-time.c                   |  91 -------
 arch/mips/pci/Makefile                             |   2 +
 arch/mips/pci/pci-alchemy.c                        |   3 +-
 arch/mips/pci/pci-generic.c                        |  52 ++++
 arch/mips/pci/pci-legacy.c                         | 302 +++++++++++++++++++++
 arch/mips/pci/pci.c                                | 296 +-------------------
 drivers/bus/mips_cdmm.c                            |  13 +
 drivers/clk/Kconfig                                |   9 +
 drivers/clk/Makefile                               |   1 +
 drivers/clk/clk-boston.c                           | 131 +++++++++
 drivers/irqchip/Kconfig                            |   2 +
 drivers/irqchip/irq-mips-cpu.c                     | 149 ++++++++--
 include/dt-bindings/clock/boston-clock.h           |  13 +
 77 files changed, 1937 insertions(+), 1279 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/img,boston-clock.txt
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt
 create mode 100644 arch/mips/boot/dts/img/Makefile
 create mode 100644 arch/mips/boot/dts/img/boston.dts
 create mode 100644 arch/mips/configs/generic/32r1.config
 create mode 100644 arch/mips/configs/generic/32r2.config
 create mode 100644 arch/mips/configs/generic/32r6.config
 create mode 100644 arch/mips/configs/generic/64r1.config
 create mode 100644 arch/mips/configs/generic/64r2.config
 create mode 100644 arch/mips/configs/generic/64r6.config
 create mode 100644 arch/mips/configs/generic/board-boston.config
 create mode 100644 arch/mips/configs/generic/board-sead-3.config
 create mode 100644 arch/mips/configs/generic/eb.config
 create mode 100644 arch/mips/configs/generic/el.config
 create mode 100644 arch/mips/configs/generic/micro32r2.config
 create mode 100644 arch/mips/configs/generic_defconfig
 delete mode 100644 arch/mips/configs/sead3_defconfig
 delete mode 100644 arch/mips/configs/sead3micro_defconfig
 create mode 100644 arch/mips/generic/Kconfig
 create mode 100644 arch/mips/generic/Makefile
 create mode 100644 arch/mips/generic/Platform
 rename arch/mips/{mti-sead3/sead3-dtshim.c => generic/board-sead3.c} (72%)
 create mode 100644 arch/mips/generic/init.c
 create mode 100644 arch/mips/generic/irq.c
 create mode 100644 arch/mips/generic/proc.c
 create mode 100644 arch/mips/generic/vmlinux.its.S
 delete mode 100644 arch/mips/include/asm/mach-sead3/cpu-feature-overrides.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/irq.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/kernel-entry-init.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/sead3-dtshim.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/war.h
 create mode 100644 arch/mips/include/asm/machine.h
 delete mode 100644 arch/mips/mti-sead3/Makefile
 delete mode 100644 arch/mips/mti-sead3/Platform
 delete mode 100644 arch/mips/mti-sead3/sead3-init.c
 delete mode 100644 arch/mips/mti-sead3/sead3-int.c
 delete mode 100644 arch/mips/mti-sead3/sead3-setup.c
 delete mode 100644 arch/mips/mti-sead3/sead3-time.c
 create mode 100644 arch/mips/pci/pci-generic.c
 create mode 100644 arch/mips/pci/pci-legacy.c
 create mode 100644 drivers/clk/clk-boston.c
 create mode 100644 include/dt-bindings/clock/boston-clock.h
Signature · 1 line
2.9.3
#1 lore raw

PATCH 1/26 MIPS: PCI: Support for CONFIG_PCI_DOMAINS_GENERIC

Introduce support for CONFIG_PCI_DOMAINS_GENERIC, allowing for platforms to make use of generic PCI domains instead of the MIPS-specific implementation. The set_pci_need_domain_info function is introduced to abstract away the removed need_domain_info field in struct pci_controller, and pcibios_scanbus is adjusted to use the pci_domain_nr accessor instead of directly accessing the index field.

---

 arch/mips/Kconfig           |  3 +++
 arch/mips/include/asm/pci.h | 21 ++++++++++++++++++++-
 arch/mips/pci/pci.c         |  4 ++--
 3 files changed, 25 insertions(+), 3 deletions(-)
arch/mips/Kconfig +3 -0
index 45bbddf..88c0c0d 100644
@@ -2980,6 +2980,9 @@ config HT_PCI
 config PCI_DOMAINS
 	bool
 
+config PCI_DOMAINS_GENERIC
+	bool
+
 source "drivers/pci/Kconfig"
 
 #
arch/mips/include/asm/pci.h +20 -1
index 547e113..0564692 100644
@@ -39,10 +39,12 @@ struct pci_controller {
 	struct resource *busn_resource;
 	unsigned long busn_offset;
 
+#ifndef CONFIG_PCI_DOMAINS_GENERIC
 	unsigned int index;
 	/* For compatibility with current (as of July 2003) pciutils
 	   and XFree86. Eventually will be removed. */
 	unsigned int need_domain_info;
+#endif
 
 	/* Optional access methods for reading/writing the bus number
 	   of the PCI controller */
@@ -101,7 +103,18 @@ struct pci_dev;
  */
 #define PCI_DMA_BUS_IS_PHYS     (1)
 
-#ifdef CONFIG_PCI_DOMAINS
+#ifdef CONFIG_PCI_DOMAINS_GENERIC
+static inline int pci_proc_domain(struct pci_bus *bus)
+{
+	return pci_domain_nr(bus);
+}
+
+static inline void set_pci_need_domain_info(struct pci_controller *hose,
+					    int need_domain_info)
+{
+	/* nothing to do */
+}
+#elif defined(CONFIG_PCI_DOMAINS)
 #define pci_domain_nr(bus) ((struct pci_controller *)(bus)->sysdata)->index
 
 static inline int pci_proc_domain(struct pci_bus *bus)
@@ -109,6 +122,12 @@ static inline int pci_proc_domain(struct pci_bus *bus)
 	struct pci_controller *hose = bus->sysdata;
 	return hose->need_domain_info;
 }
+
+static inline void set_pci_need_domain_info(struct pci_controller *hose,
+					    int need_domain_info)
+{
+	hose->need_domain_info = need_domain_info;
+}
 #endif /* CONFIG_PCI_DOMAINS */
 
 #endif /* __KERNEL__ */
arch/mips/pci/pci.c +2 -2
index 644ae96..5207c04 100644
@@ -95,8 +95,8 @@ static void pcibios_scanbus(struct pci_controller *hose)
 				&resources);
 	hose->bus = bus;
 
-	need_domain_info = need_domain_info || hose->index;
-	hose->need_domain_info = need_domain_info;
+	need_domain_info = need_domain_info || pci_domain_nr(bus);
+	set_pci_need_domain_info(hose, need_domain_info);
 
 	if (!bus) {
 		pci_free_resource_list(&resources);
Signature · 1 line
2.9.3
#2 lore raw

PATCH 2/26 MIPS: PCI: Make pcibios_set_cache_line_size an initcall

In reply to Paul Burton

In preparation for allowing configurations in which pcibios_init is not included, make pcibios_set_cache_line_size an initcall. arch_initcall is used such that it runs before the pcibios_init subsys_initcall for platforms that continue to use it.

---

 arch/mips/pci/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/pci/pci.c +3 -3
index 5207c04..30320a4 100644
@@ -220,7 +220,7 @@ out:
 	       "Skipping PCI bus scan due to resource conflict\n");
 }
 
-static void __init pcibios_set_cache_line_size(void)
+static int __init pcibios_set_cache_line_size(void)
 {
 	struct cpuinfo_mips *c = &current_cpu_data;
 	unsigned int lsize;
@@ -238,14 +238,14 @@ static void __init pcibios_set_cache_line_size(void)
 	pci_dfl_cache_line_size = lsize >> 2;
 
 	pr_debug("PCI: pci_cache_line_size set to %d bytes\n", lsize);
+	return 0;
 }
+arch_initcall(pcibios_set_cache_line_size);
 
 static int __init pcibios_init(void)
 {
 	struct pci_controller *hose;
 
-	pcibios_set_cache_line_size();
-
 	/* Scan all of the recorded PCI controllers.  */
 	list_for_each_entry(hose, &controllers, list)
 		pcibios_scanbus(hose);
Signature · 1 line
2.9.3
#3 lore raw

PATCH 3/26 MIPS: PCI: Inline pcibios_assign_all_busses

In reply to Paul Burton

The MIPS implementation of pcibios_assign_all_busses trivially returns
1. Implement it as a static function in asm/pci.h such that the compiler can inline it & optimise out never-taken paths.

---

 arch/mips/include/asm/pci.h | 6 ++++--
 arch/mips/pci/pci.c         | 5 -----
 2 files changed, 4 insertions(+), 7 deletions(-)
arch/mips/include/asm/pci.h +4 -2
index 0564692..acc651e 100644
@@ -66,8 +66,10 @@ extern int pcibios_map_irq(const struct pci_dev *dev, u8 slot, u8 pin);
 /* 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 */
-
-extern unsigned int pcibios_assign_all_busses(void);
+static inline unsigned int pcibios_assign_all_busses(void)
+{
+	return 1;
+}
 
 extern unsigned long PCIBIOS_MIN_IO;
 extern unsigned long PCIBIOS_MIN_MEM;
arch/mips/pci/pci.c +0 -5
index 30320a4..8cc6ea4 100644
@@ -297,11 +297,6 @@ static int pcibios_enable_resources(struct pci_dev *dev, int mask)
 	return 0;
 }
 
-unsigned int pcibios_assign_all_busses(void)
-{
-	return 1;
-}
-
 int pcibios_enable_device(struct pci_dev *dev, int mask)
 {
 	int err;
Signature · 1 line
2.9.3
#4 lore raw

PATCH 4/26 MIPS: PCI: Split pci.c into pci.c & pci-legacy.c

In reply to Paul Burton

Split out the parts of pci.c that are used by existing systems with MIPS-style PCI drivers but that will not be used by systems with more generic PCI drivers such as pcie-xilinx. This is done in preparation for allowing configurations where the code moved to pci-legacy.c is not built.

---

 arch/mips/pci/Makefile     |   1 +
 arch/mips/pci/pci-legacy.c | 302 +++++++++++++++++++++++++++++++++++++++++++++
 arch/mips/pci/pci.c        | 287 +-----------------------------------------
 3 files changed, 306 insertions(+), 284 deletions(-)
 create mode 100644 arch/mips/pci/pci-legacy.c
arch/mips/pci/Makefile +1 -0
index 139ad1d..5666637 100644
@@ -3,6 +3,7 @@
 #
 
 obj-y				+= pci.o
+obj-y				+= pci-legacy.o
 
 #
 # PCI bus host bridge specific code
arch/mips/pci/pci-legacy.c new file +302 -0

302 lines not on this page · raw message

arch/mips/pci/pci.c +3 -284

304 lines not on this page · raw message

Signature · 1 line
2.9.3
#5 lore raw

PATCH 5/26 MIPS: PCI: Introduce CONFIG_PCI_DRIVERS_LEGACY

In reply to Paul Burton

Introduce 2 Kconfig symbols, CONFIG_PCI_DRIVERS_GENERIC & CONFIG_PCI_DRIVERS_LEGACY, which indicate whether the system should be built to for PCI drivers using the MIPS-specific struct pci_controller API (hereafter "legacy" drivers) or more generic drivers using only functionality provided by the PCI core (hereafter "generic" drivers).

The Kconfig entries are created such that platforms have to select CONFIG_PCI_DRIVERS_GENERIC if they wish to use it - that is, the default is CONFIG_PCI_DRIVERS_LEGACY so that existing platforms need no modification.

The functions declared in pci.h are rearranged with those provided only by pci-legacy.c being guarded by an #ifdef CONFIG_PCI_DRIVERS_LEGACY to ensure they are only used in configurations where they are implemented.

---

 arch/mips/Kconfig           |  8 ++++++-
 arch/mips/include/asm/pci.h | 54 ++++++++++++++++++++++++++-------------------
 arch/mips/lib/iomap-pci.c   |  4 ++++
 arch/mips/pci/Makefile      |  2 +-
 4 files changed, 43 insertions(+), 25 deletions(-)
arch/mips/Kconfig +7 -1
index 88c0c0d..45c7895 100644
@@ -2959,7 +2959,6 @@ config PCI
 	bool "Support for PCI controller"
 	depends on HW_HAS_PCI
 	select PCI_DOMAINS
-	select NO_GENERIC_PCI_IOPORT_MAP
 	help
 	  Find out whether you have a PCI motherboard. PCI is the name of a
 	  bus system, i.e. the way the CPU talks to the other stuff inside
@@ -2983,6 +2982,13 @@ config PCI_DOMAINS
 config PCI_DOMAINS_GENERIC
 	bool
 
+config PCI_DRIVERS_GENERIC
+	bool
+
+config PCI_DRIVERS_LEGACY
+	def_bool !PCI_DRIVERS_GENERIC
+	select NO_GENERIC_PCI_IOPORT_MAP
+
 source "drivers/pci/Kconfig"
 
 #
arch/mips/include/asm/pci.h +31 -23

82 lines not on this page · raw message

arch/mips/lib/iomap-pci.c +4 -0
index fd35daa..9cf279d 100644
@@ -10,6 +10,8 @@
 #include <linux/module.h>
 #include <asm/io.h>
 
+#ifdef CONFIG_PCI_DRIVERS_LEGACY
+
 void __iomem *__pci_ioport_map(struct pci_dev *dev,
 			       unsigned long port, unsigned int nr)
 {
@@ -40,6 +42,8 @@ void __iomem *__pci_ioport_map(struct pci_dev *dev,
 	return (void __iomem *) (ctrl->io_map_base + port);
 }
 
+#endif /* CONFIG_PCI_DRIVERS_LEGACY */
+
 void pci_iounmap(struct pci_dev *dev, void __iomem * addr)
 {
 	iounmap(addr);
arch/mips/pci/Makefile +1 -1
index 5666637..8478210 100644
@@ -3,7 +3,7 @@
 #
 
 obj-y				+= pci.o
-obj-y				+= pci-legacy.o
+obj-$(CONFIG_PCI_DRIVERS_LEGACY)+= pci-legacy.o
 
 #
 # PCI bus host bridge specific code
Signature · 1 line
2.9.3
#6 lore raw

PATCH 6/26 MIPS: PCI: Support generic drivers

In reply to Paul Burton

Introduce support for PCI drivers using only functionality provided generically by the PCI subsystem, by adding the minimum arch-provided functions required.

The driver this has been developed for & tested with the xilinx-pcie on a MIPS Boston development board.

---

 arch/mips/Kconfig           |  1 +
 arch/mips/pci/Makefile      |  1 +
 arch/mips/pci/pci-generic.c | 52 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 54 insertions(+)
 create mode 100644 arch/mips/pci/pci-generic.c
arch/mips/Kconfig +1 -0
index 45c7895..6c5133f 100644
@@ -2983,6 +2983,7 @@ config PCI_DOMAINS_GENERIC
 	bool
 
 config PCI_DRIVERS_GENERIC
+	select PCI_DOMAINS_GENERIC if PCI_DOMAINS
 	bool
 
 config PCI_DRIVERS_LEGACY
arch/mips/pci/Makefile +1 -0
index 8478210..4b82148 100644
@@ -4,6 +4,7 @@
 
 obj-y				+= pci.o
 obj-$(CONFIG_PCI_DRIVERS_LEGACY)+= pci-legacy.o
+obj-$(CONFIG_PCI_DRIVERS_GENERIC)+= pci-generic.o
 
 #
 # PCI bus host bridge specific code
arch/mips/pci/pci-generic.c new file +52 -0

52 lines not on this page · raw message

Signature · 1 line
2.9.3
#7 lore raw

PATCH 7/26 MIPS: Sanitise coherentio semantics

In reply to Paul Burton

The coherentio variable has previously been used as a boolean value, indicating whether the user specified that coherent I/O should be enabled or disabled. It failed to take into account the case where the user does not specify any preference, in which case it makes sense that we should default to coherent I/O if the hardware supports it (hw_coherentio is non-zero).

Introduce an enum to clarify the 3 different values of coherentio & use it throughout the code, modifying plat_device_is_coherent() & r4k_cache_init() to take into account the default case.

---

 arch/mips/alchemy/common/setup.c                   |  6 +++---
 arch/mips/include/asm/dma-coherence.h              | 12 +++++++++---
 arch/mips/include/asm/mach-generic/dma-coherence.h | 10 +++++++++-
 arch/mips/mm/c-r4k.c                               |  3 ++-
 arch/mips/mm/dma-default.c                         |  7 ++++---
 arch/mips/mti-malta/malta-setup.c                  |  4 ++--
 arch/mips/pci/pci-alchemy.c                        |  3 ++-
 7 files changed, 31 insertions(+), 14 deletions(-)
arch/mips/alchemy/common/setup.c +3 -3
index 2902138..7faaa6d 100644
@@ -48,17 +48,17 @@ void __init plat_mem_setup(void)
 		clear_c0_config(1 << 19); /* Clear Config[OD] */
 
 	hw_coherentio = 0;
-	coherentio = 1;
+	coherentio = IO_COHERENCE_ENABLED;
 	switch (alchemy_get_cputype()) {
 	case ALCHEMY_CPU_AU1000:
 	case ALCHEMY_CPU_AU1500:
 	case ALCHEMY_CPU_AU1100:
-		coherentio = 0;
+		coherentio = IO_COHERENCE_DISABLED;
 		break;
 	case ALCHEMY_CPU_AU1200:
 		/* Au1200 AB USB does not support coherent memory */
 		if (0 == (read_c0_prid() & PRID_REV_MASK))
-			coherentio = 0;
+			coherentio = IO_COHERENCE_DISABLED;
 		break;
 	}
 
arch/mips/include/asm/dma-coherence.h +9 -3
index bc5e85d..4fbce79 100644
@@ -9,14 +9,20 @@
 #ifndef __ASM_DMA_COHERENCE_H
 #define __ASM_DMA_COHERENCE_H
 
+enum coherent_io_user_state {
+	IO_COHERENCE_DEFAULT,
+	IO_COHERENCE_ENABLED,
+	IO_COHERENCE_DISABLED,
+};
+
 #ifdef CONFIG_DMA_MAYBE_COHERENT
-extern int coherentio;
+extern enum coherent_io_user_state coherentio;
 extern int hw_coherentio;
 #else
 #ifdef CONFIG_DMA_COHERENT
-#define coherentio	1
+#define coherentio	IO_COHERENCE_ENABLED
 #else
-#define coherentio	0
+#define coherentio	IO_COHERENCE_DISABLED
 #endif
 #define hw_coherentio	0
 #endif /* CONFIG_DMA_MAYBE_COHERENT */
arch/mips/include/asm/mach-generic/dma-coherence.h +9 -1
index 0f8a354..8484f82 100644
@@ -49,7 +49,15 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)
 
 static inline int plat_device_is_coherent(struct device *dev)
 {
-	return coherentio;
+	switch (coherentio) {
+	default:
+	case IO_COHERENCE_DEFAULT:
+		return hw_coherentio;
+	case IO_COHERENCE_ENABLED:
+		return 1;
+	case IO_COHERENCE_DISABLED:
+		return 0;
+	}
 }
 
 #ifndef plat_post_dma_flush
arch/mips/mm/c-r4k.c +2 -1
index cd72805..c48deab 100644
@@ -1917,7 +1917,8 @@ void r4k_cache_init(void)
 	local_flush_icache_range	= local_r4k_flush_icache_range;
 
 #if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_DMA_MAYBE_COHERENT)
-	if (coherentio) {
+	if ((coherentio == IO_COHERENCE_ENABLED) ||
+	    ((coherentio == IO_COHERENCE_DEFAULT) && hw_coherentio)) {
 		_dma_cache_wback_inv	= (void *)cache_noop;
 		_dma_cache_wback	= (void *)cache_noop;
 		_dma_cache_inv		= (void *)cache_noop;
arch/mips/mm/dma-default.c +4 -3
index b2eadd6..a9c1e94 100644
@@ -25,13 +25,14 @@
 #include <dma-coherence.h>
 
 #ifdef CONFIG_DMA_MAYBE_COHERENT
-int coherentio = 0;	/* User defined DMA coherency from command line. */
+/* User defined DMA coherency from command line. */
+enum coherent_io_user_state coherentio = IO_COHERENCE_DEFAULT;
 EXPORT_SYMBOL_GPL(coherentio);
 int hw_coherentio = 0;	/* Actual hardware supported DMA coherency setting. */
 
 static int __init setcoherentio(char *str)
 {
-	coherentio = 1;
+	coherentio = IO_COHERENCE_ENABLED;
 	pr_info("Hardware DMA cache coherency (command line)\n");
 	return 0;
 }
@@ -39,7 +40,7 @@ early_param("coherentio", setcoherentio);
 
 static int __init setnocoherentio(char *str)
 {
-	coherentio = 0;
+	coherentio = IO_COHERENCE_DISABLED;
 	pr_info("Software DMA cache coherency (command line)\n");
 	return 0;
 }
arch/mips/mti-malta/malta-setup.c +2 -2
index ec5b216..d7d151f 100644
@@ -148,12 +148,12 @@ static void __init plat_setup_iocoherency(void)
 	 * coherency instead.
 	 */
 	if (plat_enable_iocoherency()) {
-		if (coherentio == 0)
+		if (coherentio == IO_COHERENCE_DISABLED)
 			pr_info("Hardware DMA cache coherency disabled\n");
 		else
 			pr_info("Hardware DMA cache coherency enabled\n");
 	} else {
-		if (coherentio == 1)
+		if (coherentio == IO_COHERENCE_ENABLED)
 			pr_info("Hardware DMA cache coherency unsupported, but enabled from command line!\n");
 		else
 			pr_info("Software DMA cache coherency enabled\n");
arch/mips/pci/pci-alchemy.c +2 -1
index c8994c1..e99ca77 100644
@@ -429,7 +429,8 @@ static int alchemy_pci_probe(struct platform_device *pdev)
 
 	/* Au1500 revisions older than AD have borked coherent PCI */
 	if ((alchemy_get_cputype() == ALCHEMY_CPU_AU1500) &&
-	    (read_c0_prid() < 0x01030202) && !coherentio) {
+	    (read_c0_prid() < 0x01030202) &&
+	    (coherentio == IO_COHERENCE_DISABLED)) {
 		val = __raw_readl(ctx->regs + PCI_REG_CONFIG);
 		val |= PCI_CONFIG_NC;
 		__raw_writel(val, ctx->regs + PCI_REG_CONFIG);
Signature · 1 line
2.9.3
#8 lore raw

PATCH 8/26 MIPS: dma-default: Don't check hw_coherentio if device is non-coherent

In reply to Paul Burton

There are no cases where plat_device_is_coherent() will return zero whilst hw_coherentio is non-zero, and acting any differently in such a case doesn't make much sense - if a device is non-coherent with the CPU caches then access to memory "coherent" with DMA must be uncached. Clean up the nonsensical case.

---

 arch/mips/mm/dma-default.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
arch/mips/mm/dma-default.c +3 -4
index a9c1e94..6540355 100644
@@ -161,8 +161,7 @@ static void *mips_dma_alloc_coherent(struct device *dev, size_t size,
 	*dma_handle = plat_map_dma_mem(dev, ret, size);
 	if (!plat_device_is_coherent(dev)) {
 		dma_cache_wback_inv((unsigned long) ret, size);
-		if (!hw_coherentio)
-			ret = UNCAC_ADDR(ret);
+		ret = UNCAC_ADDR(ret);
 	}
 
 	return ret;
@@ -190,7 +189,7 @@ static void mips_dma_free_coherent(struct device *dev, size_t size, void *vaddr,
 
 	plat_unmap_dma_mem(dev, dma_handle, size, DMA_BIDIRECTIONAL);
 
-	if (!plat_device_is_coherent(dev) && !hw_coherentio)
+	if (!plat_device_is_coherent(dev))
 		addr = CAC_ADDR(addr);
 
 	page = virt_to_page((void *) addr);
@@ -210,7 +209,7 @@ static int mips_dma_mmap(struct device *dev, struct vm_area_struct *vma,
 	unsigned long pfn;
 	int ret = -ENXIO;
 
-	if (!plat_device_is_coherent(dev) && !hw_coherentio)
+	if (!plat_device_is_coherent(dev))
 		addr = CAC_ADDR(addr);
 
 	pfn = page_to_pfn(virt_to_page((void *)addr));
Signature · 1 line
2.9.3
#9 lore raw

PATCH 9/26 MIPS: Support per-device DMA coherence

In reply to Paul Burton

On some MIPS systems, a subset of devices may have DMA coherent with CPU caches. For example in systems including a MIPS I/O Coherence Unit (IOCU), some devices may be connected to that IOCU whilst others are not.

Prior to this patch, we have a plat_device_is_coherent() function but no implementation which does anything besides return a global true or false, optionally chosen at runtime. For devices such as those described above this is insufficient.

Fix this by tracking DMA coherence on a per-device basis with a dma_coherent field in struct dev_archdata. Setting this from arch_setup_dma_ops() takes care of devices which set the dma-coherent property via device tree, and any PCI devices beneath a bridge described in DT, automatically.

---

 arch/mips/Kconfig                                  |  4 ++++
 arch/mips/include/asm/device.h                     |  5 +++++
 arch/mips/include/asm/dma-coherence.h              |  4 +++-
 arch/mips/include/asm/dma-mapping.h                | 10 ++++++++++
 arch/mips/include/asm/mach-generic/dma-coherence.h |  4 ++++
 arch/mips/mm/c-r4k.c                               |  4 ++++
 arch/mips/mm/dma-default.c                         |  2 +-
 7 files changed, 31 insertions(+), 2 deletions(-)
arch/mips/Kconfig +4 -0
index 6c5133f..49eb902 100644
@@ -1097,6 +1097,10 @@ config DMA_MAYBE_COHERENT
 	select DMA_NONCOHERENT
 	bool
 
+config DMA_PERDEV_COHERENT
+	bool
+	select DMA_MAYBE_COHERENT
+
 config DMA_COHERENT
 	bool
 
arch/mips/include/asm/device.h +5 -0
index c94fafb..21c2082 100644
@@ -11,6 +11,11 @@ struct dma_map_ops;
 struct dev_archdata {
 	/* DMA operations on that device */
 	struct dma_map_ops *dma_ops;
+
+#ifdef CONFIG_DMA_PERDEV_COHERENT
+	/* Non-zero if DMA is coherent with CPU caches */
+	bool dma_coherent;
+#endif
 };
 
 struct pdev_archdata {
arch/mips/include/asm/dma-coherence.h +3 -1
index 4fbce79..72d0eab 100644
@@ -15,7 +15,9 @@ enum coherent_io_user_state {
 	IO_COHERENCE_DISABLED,
 };
 
-#ifdef CONFIG_DMA_MAYBE_COHERENT
+#if defined(CONFIG_DMA_PERDEV_COHERENT)
+/* Don't provide (hw_)coherentio to avoid misuse */
+#elif defined(CONFIG_DMA_MAYBE_COHERENT)
 extern enum coherent_io_user_state coherentio;
 extern int hw_coherentio;
 #else
arch/mips/include/asm/dma-mapping.h +10 -0
index 12fa79e..7aa71b9 100644
@@ -32,4 +32,14 @@ static inline void dma_mark_clean(void *addr, size_t size) {}
 extern void dma_cache_sync(struct device *dev, void *vaddr, size_t size,
 	       enum dma_data_direction direction);
 
+#define arch_setup_dma_ops arch_setup_dma_ops
+static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
+				      u64 size, const struct iommu_ops *iommu,
+				      bool coherent)
+{
+#ifdef CONFIG_DMA_PERDEV_COHERENT
+	dev->archdata.dma_coherent = coherent;
+#endif
+}
+
 #endif /* _ASM_DMA_MAPPING_H */
arch/mips/include/asm/mach-generic/dma-coherence.h +4 -0
index 8484f82..61addb1 100644
@@ -49,6 +49,9 @@ static inline int plat_dma_supported(struct device *dev, u64 mask)
 
 static inline int plat_device_is_coherent(struct device *dev)
 {
+#ifdef CONFIG_DMA_PERDEV_COHERENT
+	return dev->archdata.dma_coherent;
+#else
 	switch (coherentio) {
 	default:
 	case IO_COHERENCE_DEFAULT:
@@ -58,6 +61,7 @@ static inline int plat_device_is_coherent(struct device *dev)
 	case IO_COHERENCE_DISABLED:
 		return 0;
 	}
+#endif
 }
 
 #ifndef plat_post_dma_flush
arch/mips/mm/c-r4k.c +4 -0
index c48deab..7529096 100644
@@ -1917,8 +1917,12 @@ void r4k_cache_init(void)
 	local_flush_icache_range	= local_r4k_flush_icache_range;
 
 #if defined(CONFIG_DMA_NONCOHERENT) || defined(CONFIG_DMA_MAYBE_COHERENT)
+# if defined(CONFIG_DMA_PERDEV_COHERENT)
+	if (0) {
+# else
 	if ((coherentio == IO_COHERENCE_ENABLED) ||
 	    ((coherentio == IO_COHERENCE_DEFAULT) && hw_coherentio)) {
+# endif
 		_dma_cache_wback_inv	= (void *)cache_noop;
 		_dma_cache_wback	= (void *)cache_noop;
 		_dma_cache_inv		= (void *)cache_noop;
arch/mips/mm/dma-default.c +1 -1
index 6540355..9f51ee8 100644
@@ -24,7 +24,7 @@
 
 #include <dma-coherence.h>
 
-#ifdef CONFIG_DMA_MAYBE_COHERENT
+#if defined(CONFIG_DMA_MAYBE_COHERENT) && !defined(CONFIG_DMA_PERDEV_COHERENT)
 /* User defined DMA coherency from command line. */
 enum coherent_io_user_state coherentio = IO_COHERENCE_DEFAULT;
 EXPORT_SYMBOL_GPL(coherentio);
Signature · 1 line
2.9.3
#10 lore raw

PATCH 10/26 MIPS: Print CM error reports upon bus errors

In reply to Paul Burton

If a bus error occurs on a system with a MIPS Coherence Manager (CM) then the CM may hold useful diagnostic information. Printing this out has so far been left up to boards, with the requirement that they register a board_be_handler function & call mips_cm_error_decode() from there.

In order to avoid boards other than Malta needing to duplicate this code, call mips_cm_error_decode() automatically if the board registers no board_be_handler, and remove the Malta implementation of that.

This patch results in no functional change, but removes a further piece of platform-specific code.

---

 arch/mips/kernel/traps.c          |  3 +++
 arch/mips/mti-malta/malta-int.c   | 15 ---------------
 arch/mips/mti-malta/malta-setup.c |  6 ------
 3 files changed, 3 insertions(+), 21 deletions(-)
arch/mips/kernel/traps.c +3 -0
index 3de85be..e2c571d 100644
@@ -48,6 +48,7 @@
 #include <asm/fpu.h>
 #include <asm/fpu_emulator.h>
 #include <asm/idle.h>
+#include <asm/mips-cm.h>
 #include <asm/mips-r2-to-r6-emul.h>
 #include <asm/mipsregs.h>
 #include <asm/mipsmtregs.h>
@@ -444,6 +445,8 @@ asmlinkage void do_be(struct pt_regs *regs)
 
 	if (board_be_handler)
 		action = board_be_handler(regs, fixup != NULL);
+	else
+		mips_cm_error_report();
 
 	switch (action) {
 	case MIPS_BE_DISCARD:
arch/mips/mti-malta/malta-int.c +0 -15
index c6a6c7a..548130d 100644
@@ -376,18 +376,3 @@ void __init arch_init_irq(void)
 	setup_irq(i8259_irq, &i8259irq);
 	setup_irq(corehi_irq, &corehi_irqaction);
 }
-
-void malta_be_init(void)
-{
-	/* Could change CM error mask register. */
-}
-
-int malta_be_handler(struct pt_regs *regs, int is_fixup)
-{
-	/* This duplicates the handling in do_be which seems wrong */
-	int retval = is_fixup ? MIPS_BE_FIXUP : MIPS_BE_FATAL;
-
-	mips_cm_error_report();
-
-	return retval;
-}
arch/mips/mti-malta/malta-setup.c +0 -6
index d7d151f..2f25930 100644
@@ -39,9 +39,6 @@
 #include <linux/console.h>
 #endif
 
-extern void malta_be_init(void);
-extern int malta_be_handler(struct pt_regs *regs, int is_fixup);
-
 static struct resource standard_io_resources[] = {
 	{
 		.name = "dma1",
@@ -295,7 +292,4 @@ void __init plat_mem_setup(void)
 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
 	screen_info_setup();
 #endif
-
-	board_be_init = malta_be_init;
-	board_be_handler = malta_be_handler;
 }
Signature · 1 line
2.9.3
#11 lore raw

PATCH 11/26 dt-bindings: Document mti,mips-cpc binding

In reply to Paul Burton

Document a binding for the MIPS Cluster Power Controller (CPC) which simply allows the device tree to specify where the CPC registers should be mapped.

---

 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt
Documentation/devicetree/bindings/misc/mti,mips-cpc.txt new file +8 -0
new file mode 100644
index 0000000..92eb08f
@@ -0,0 +1,8 @@
+Binding for MIPS Cluster Power Controller (CPC).
+
+This binding allows a system to specify where the CPC registers should be
+mapped using device tree.
+
+Required properties:
+compatible : Should be "mti,mips-cpc".
+regs: Should describe the address & size of the CPC register region.
Signature · 1 line
2.9.3
maintainer
#12 lore raw

Re: [PATCH 11/26] dt-bindings: Document mti,mips-cpc binding

Quoted 8 lines · Paul Burton

Document a binding for the MIPS Cluster Power Controller (CPC) which simply allows the device tree to specify where the CPC registers should be mapped.

---

 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt | 8 ++++++++

This is for power domains, right? Move to bindings/power.

Quoted 9 lines
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt
Documentation/devicetree/bindings/misc/mti,mips-cpc.txt new file +0 -0
new file mode 100644
index 0000000..92eb08f

Documentation/devicetree/bindings/misc/mti,mips-cpc.txt line 8

Quoted 8 lines
Documentation/devicetree/bindings/misc/mti,mips-cpc.txt new file +8 -0
@@ -0,0 +1,8 @@
+Binding for MIPS Cluster Power Controller (CPC).
+
+This binding allows a system to specify where the CPC registers should be
+mapped using device tree.
+
+Required properties:
+compatible : Should be "mti,mips-cpc".
+regs: Should describe the address & size of the CPC register region.

Also needs #power-domain-cells property.

Quoted 3 lines
Signature · 1 line
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw

Re: [PATCH 11/26] dt-bindings: Document mti,mips-cpc binding

Quoted 11 lines · Rob Herring
Quoted 8 lines · Paul Burton

Document a binding for the MIPS Cluster Power Controller (CPC) which simply allows the device tree to specify where the CPC registers should be mapped.

---

 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt | 8 ++++++++

This is for power domains, right? Move to bindings/power.

Hi Rob,

Well, sort of. The CPC controls the power domains for CPU cores & the MIPS Coherency Manager within a CPU cluster. That is, it's the block of hardware that we send commands to power up or down CPUs to. It's not something that makes use of the kernel's power domain infrastructure, it's essentially only involved in SMP startup, hotplug or cpuidle low power states.

This binding is purely about assigning some address space for the CPC register interface, which can be mapped anywhere at runtime. Besides knowing where to place the registers there's currently nothing else we'd need to describe in DT.

If you still think bindings/power/ is the best place for it given that, I'll move it.

Quoted 4 lines
Quoted 4 lines
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cpc.txt
Quoted 16 lines
Quoted 6 lines
Documentation/devicetree/bindings/misc/mti,mips-cpc.txt new file +0 -0
new file mode 100644
index 0000000..92eb08f

Documentation/devicetree/bindings/misc/mti,mips-cpc.txt line 8

Quoted 8 lines
Documentation/devicetree/bindings/misc/mti,mips-cpc.txt new file +8 -0
@@ -0,0 +1,8 @@
+Binding for MIPS Cluster Power Controller (CPC).
+
+This binding allows a system to specify where the CPC registers should be
+mapped using device tree.
+
+Required properties:
+compatible : Should be "mti,mips-cpc".
+regs: Should describe the address & size of the CPC register region.

Also needs #power-domain-cells property.

As above, this doesn't make use of power domain infrastructure or anything like it so I don't think that's correct.

Thanks,
Paul

Quoted 4 lines
Quoted 4 lines
Signature · 2 lines
-- 
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#14 lore raw

PATCH 12/26 MIPS: CPC: Provide a default mips_cpc_default_phys_base

In reply to Paul Burton

Provide a weak default implementation of mips_cpc_default_phys_base which reads the base address of the CPC from the device tree if possible, and failing that returns the existing physical address of the CPC as read from CPC base address GCR. This allows for platforms to make use of the CPC without requiring platform code.

---

 arch/mips/kernel/mips-cpc.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/mips/kernel/mips-cpc.c +18 -0
index 566b8d2..b188787 100644
@@ -9,6 +9,8 @@
  */
 
 #include <linux/errno.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/percpu.h>
 #include <linux/spinlock.h>
 
@@ -21,6 +23,22 @@ static DEFINE_PER_CPU_ALIGNED(spinlock_t, cpc_core_lock);
 
 static DEFINE_PER_CPU_ALIGNED(unsigned long, cpc_core_lock_flags);
 
+__weak phys_addr_t mips_cpc_default_phys_base(void)
+{
+	struct device_node *cpc_node;
+	struct resource res;
+	int err;
+
+	cpc_node = of_find_compatible_node(of_root, NULL, "mti,mips-cpc");
+	if (cpc_node) {
+		err = of_address_to_resource(cpc_node, 0, &res);
+		if (!err)
+			return res.start;
+	}
+
+	return read_gcr_cpc_base() & CM_GCR_CPC_BASE_CPCBASE_MSK;
+}
+
 /**
  * mips_cpc_phys_base - retrieve the physical base address of the CPC
  *
Signature · 1 line
2.9.3
#15 lore raw

PATCH 13/26 dt-bindings: Document mti,mips-cdmm binding

In reply to Paul Burton

Document a binding for the MIPS Common Device Memory Map (CDMM) which simply allows the device tree to specify where the CDMM registers should be mapped.

---

 Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt | 8 ++++++++
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt
Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt new file +8 -0
new file mode 100644
index 0000000..5b0fc40
@@ -0,0 +1,8 @@
+Binding for MIPS Common Device Memory Map (CDMM) bus.
+
+This binding allows a system to specify where the CDMM registers should be
+mapped using device tree.
+
+Required properties:
+compatible : Should be "mti,mips-cdmm".
+regs: Should describe the address & size of the CDMM register region.
Signature · 1 line
2.9.3
maintainer
#16 lore raw

Re: [PATCH 13/26] dt-bindings: Document mti,mips-cdmm binding

Quoted 8 lines · Paul Burton

Document a binding for the MIPS Common Device Memory Map (CDMM) which simply allows the device tree to specify where the CDMM registers should be mapped.

---

 Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt | 8 ++++++++

Try to find another location for these. Perhaps bindings/bus/? Even bindings/mips/ would be better.

Quoted 20 lines
 1 file changed, 8 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt
Documentation/devicetree/bindings/misc/mti,mips-cdmm.txt new file +8 -0
new file mode 100644
index 0000000..5b0fc40
@@ -0,0 +1,8 @@
+Binding for MIPS Common Device Memory Map (CDMM) bus.
+
+This binding allows a system to specify where the CDMM registers should be
+mapped using device tree.
+
+Required properties:
+compatible : Should be "mti,mips-cdmm".
+regs: Should describe the address & size of the CDMM register region.
Signature · 1 line
2.9.3
#17 lore raw

PATCH 14/26 MIPS: CDMM: Allow CDMM base address to be specified via DT

In reply to Paul Burton

Allow systems to specify the base address for the CDMM using device tree. This removes the need for it to be specified by platform specific code, preparing for generic kernels which can run without any.

---

 drivers/bus/mips_cdmm.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/bus/mips_cdmm.c +13 -0
index cad49bc..311ce54 100644
@@ -13,6 +13,8 @@
 #include <linux/cpu.h>
 #include <linux/cpumask.h>
 #include <linux/io.h>
+#include <linux/of.h>
+#include <linux/of_address.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/smp.h>
@@ -340,6 +342,17 @@ static phys_addr_t mips_cdmm_cur_base(void)
  */
 phys_addr_t __weak mips_cdmm_phys_base(void)
 {
+	struct device_node *cdmm_node;
+	struct resource res;
+	int err;
+
+	cdmm_node = of_find_compatible_node(of_root, NULL, "mti,mips-cdmm");
+	if (cdmm_node) {
+		err = of_address_to_resource(cdmm_node, 0, &res);
+		if (!err)
+			return res.start;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.9.3
#18 lore raw

PATCH 15/26 irqchip: mips-cpu: Replace magic 0x100 with IE_SW0

In reply to Paul Burton

Replace use of the magic number 0x100 (ie. bit 8) with the more explanatory IE_SW0 (ie. interrupt enable for software interrupt 0) or C_SW0 (ie. cause bit for software interrupt 0) as appropriate.

---

 drivers/irqchip/irq-mips-cpu.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/irqchip/irq-mips-cpu.c +4 -4
index 8c504f5..e6b4136 100644
@@ -41,13 +41,13 @@
 
 static inline void unmask_mips_irq(struct irq_data *d)
 {
-	set_c0_status(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
+	set_c0_status(IE_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
 	irq_enable_hazard();
 }
 
 static inline void mask_mips_irq(struct irq_data *d)
 {
-	clear_c0_status(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
+	clear_c0_status(IE_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
 	irq_disable_hazard();
 }
 
@@ -70,7 +70,7 @@ static unsigned int mips_mt_cpu_irq_startup(struct irq_data *d)
 {
 	unsigned int vpflags = dvpe();
 
-	clear_c0_cause(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
+	clear_c0_cause(C_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
 	evpe(vpflags);
 	unmask_mips_irq(d);
 	return 0;
@@ -83,7 +83,7 @@ static unsigned int mips_mt_cpu_irq_startup(struct irq_data *d)
 static void mips_mt_cpu_irq_ack(struct irq_data *d)
 {
 	unsigned int vpflags = dvpe();
-	clear_c0_cause(0x100 << (d->irq - MIPS_CPU_IRQ_BASE));
+	clear_c0_cause(C_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
 	evpe(vpflags);
 	mask_mips_irq(d);
 }
Signature · 1 line
2.9.3
#19 lore raw

PATCH 16/26 irqchip: mips-cpu: Prepare for non-legacy IRQ domains

In reply to Paul Burton

The various struct irq_chip callbacks in the MIPS CPU interrupt controller driver have been calculating the hardware interrupt number by subtracting MIPS_CPU_IRQ_BASE from the virq number. This presumes a linear mapping beginning from MIPS_CPU_IRQ_BASE, and this will not hold once an IPI IRQ domain is introduced. Switch to using the hwirq field of struct irq_data which already contains the hardware interrupt number instead of attempting to calculate it.

Similarly, plat_irq_dispatch calculated the virq number by adding MIPS_CPU_IRQ_BASE to the hardware interrupt number. Ready this for the introduction of an IPI IRQ domain by instead using irq_linear_revmap.

---

 drivers/irqchip/irq-mips-cpu.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)
drivers/irqchip/irq-mips-cpu.c +13 -10
index e6b4136..338de92 100644
@@ -39,15 +39,17 @@
 #include <asm/mipsmtregs.h>
 #include <asm/setup.h>
 
+static struct irq_domain *irq_domain;
+
 static inline void unmask_mips_irq(struct irq_data *d)
 {
-	set_c0_status(IE_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
+	set_c0_status(IE_SW0 << d->hwirq);
 	irq_enable_hazard();
 }
 
 static inline void mask_mips_irq(struct irq_data *d)
 {
-	clear_c0_status(IE_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
+	clear_c0_status(IE_SW0 << d->hwirq);
 	irq_disable_hazard();
 }
 
@@ -70,7 +72,7 @@ static unsigned int mips_mt_cpu_irq_startup(struct irq_data *d)
 {
 	unsigned int vpflags = dvpe();
 
-	clear_c0_cause(C_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
+	clear_c0_cause(C_SW0 << d->hwirq);
 	evpe(vpflags);
 	unmask_mips_irq(d);
 	return 0;
@@ -83,7 +85,7 @@ static unsigned int mips_mt_cpu_irq_startup(struct irq_data *d)
 static void mips_mt_cpu_irq_ack(struct irq_data *d)
 {
 	unsigned int vpflags = dvpe();
-	clear_c0_cause(C_SW0 << (d->irq - MIPS_CPU_IRQ_BASE));
+	clear_c0_cause(C_SW0 << d->hwirq);
 	evpe(vpflags);
 	mask_mips_irq(d);
 }
@@ -103,6 +105,7 @@ static struct irq_chip mips_mt_cpu_irq_controller = {
 asmlinkage void __weak plat_irq_dispatch(void)
 {
 	unsigned long pending = read_c0_cause() & read_c0_status() & ST0_IM;
+	unsigned int virq;
 	int irq;
 
 	if (!pending) {
@@ -113,7 +116,8 @@ asmlinkage void __weak plat_irq_dispatch(void)
 	pending >>= CAUSEB_IP;
 	while (pending) {
 		irq = fls(pending) - 1;
-		do_IRQ(MIPS_CPU_IRQ_BASE + irq);
+		virq = irq_linear_revmap(irq_domain, irq);
+		do_IRQ(virq);
 		pending &= ~BIT(irq);
 	}
 }
@@ -145,15 +149,14 @@ static const struct irq_domain_ops mips_cpu_intc_irq_domain_ops = {
 
 static void __init __mips_cpu_irq_init(struct device_node *of_node)
 {
-	struct irq_domain *domain;
-
 	/* Mask interrupts. */
 	clear_c0_status(ST0_IM);
 	clear_c0_cause(CAUSEF_IP);
 
-	domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, 0,
-				       &mips_cpu_intc_irq_domain_ops, NULL);
-	if (!domain)
+	irq_domain = irq_domain_add_legacy(of_node, 8, MIPS_CPU_IRQ_BASE, 0,
+					   &mips_cpu_intc_irq_domain_ops,
+					   NULL);
+	if (!irq_domain)
 		panic("Failed to add irqdomain for MIPS CPU");
 }
 
Signature · 1 line
2.9.3
#20 lore raw

PATCH 17/26 irqchip: mips-cpu: Introduce IPI IRQ domain support

In reply to Paul Burton

Introduce support for registering an IPI IRQ domain suitable for use by systems using the MIPS MT (multithreading) ASE within a single core. This will allow for such systems to be supported generically, without the current kludge of IPI code split between the MIPS arch & the malta board support code.

---

 drivers/irqchip/Kconfig        |   2 +
 drivers/irqchip/irq-mips-cpu.c | 128 ++++++++++++++++++++++++++++++++++++++---
 2 files changed, 122 insertions(+), 8 deletions(-)
drivers/irqchip/Kconfig +2 -0
index 7f87289..8af8704 100644
@@ -127,7 +127,9 @@ config IMGPDC_IRQ
 config IRQ_MIPS_CPU
 	bool
 	select GENERIC_IRQ_CHIP
+	select GENERIC_IRQ_IPI if SYS_SUPPORTS_MULTITHREADING
 	select IRQ_DOMAIN
+	select IRQ_DOMAIN_HIERARCHY if GENERIC_IRQ_IPI
 
 config CLPS711X_IRQCHIP
 	bool
drivers/irqchip/irq-mips-cpu.c +120 -8

172 lines not on this page · raw message

Signature · 1 line
2.9.3
#21 lore raw

PATCH 18/26 MIPS: smp-mt: Use CPU interrupt controller IPI IRQ domain support

In reply to Paul Burton

Remove the smp-mt IPI code that supported single-core multithreaded systems and instead make use of the IPI IRQ domain support provided by the MIPS CPU interrupt controller driver. This removes some less than nice code, the horrible split between arch & board code and the duplication that led to within board code.

The lantiq portion of this patch has only been compile tested. Malta has been tested & is functional.

---

 arch/mips/kernel/smp-mt.c       | 49 +++------------------------
 arch/mips/lantiq/irq.c          | 52 ----------------------------
 arch/mips/mti-malta/malta-int.c | 75 ++---------------------------------------
 3 files changed, 7 insertions(+), 169 deletions(-)
arch/mips/kernel/smp-mt.c +4 -45
index 4f9570a..fd3ce15 100644
@@ -82,6 +82,8 @@ static unsigned int __init smvp_vpe_init(unsigned int tc, unsigned int mvpconf0,
 	if (tc != 0)
 		smvp_copy_vpe_config();
 
+	cpu_data[ncpu].vpe_id = tc;
+
 	return ncpu;
 }
 
@@ -113,49 +115,6 @@ static void __init smvp_tc_init(unsigned int tc, unsigned int mvpconf0)
 	write_tc_c0_tchalt(TCHALT_H);
 }
 
-static void vsmp_send_ipi_single(int cpu, unsigned int action)
-{
-	int i;
-	unsigned long flags;
-	int vpflags;
-
-#ifdef CONFIG_MIPS_GIC
-	if (gic_present) {
-		mips_smp_send_ipi_single(cpu, action);
-		return;
-	}
-#endif
-	local_irq_save(flags);
-
-	vpflags = dvpe();	/* can't access the other CPU's registers whilst MVPE enabled */
-
-	switch (action) {
-	case SMP_CALL_FUNCTION:
-		i = C_SW1;
-		break;
-
-	case SMP_RESCHEDULE_YOURSELF:
-	default:
-		i = C_SW0;
-		break;
-	}
-
-	/* 1:1 mapping of vpe and tc... */
-	settc(cpu);
-	write_vpe_c0_cause(read_vpe_c0_cause() | i);
-	evpe(vpflags);
-
-	local_irq_restore(flags);
-}
-
-static void vsmp_send_ipi_mask(const struct cpumask *mask, unsigned int action)
-{
-	unsigned int i;
-
-	for_each_cpu(i, mask)
-		vsmp_send_ipi_single(i, action);
-}
-
 static void vsmp_init_secondary(void)
 {
 #ifdef CONFIG_MIPS_GIC
@@ -280,8 +239,8 @@ static void __init vsmp_prepare_cpus(unsigned int max_cpus)
 }
 
 struct plat_smp_ops vsmp_smp_ops = {
-	.send_ipi_single	= vsmp_send_ipi_single,
-	.send_ipi_mask		= vsmp_send_ipi_mask,
+	.send_ipi_single	= mips_smp_send_ipi_single,
+	.send_ipi_mask		= mips_smp_send_ipi_mask,
 	.init_secondary		= vsmp_init_secondary,
 	.smp_finish		= vsmp_smp_finish,
 	.boot_secondary		= vsmp_boot_secondary,
arch/mips/lantiq/irq.c +0 -52

64 lines not on this page · raw message

arch/mips/mti-malta/malta-int.c +3 -72

94 lines not on this page · raw message

Signature · 1 line
2.9.3
#22 lore raw

PATCH 19/26 MIPS: Stengthen IPI IRQ domain sanity check

In reply to Paul Burton

Commit fbde2d7d8290 ("MIPS: Add generic SMP IPI support") introduced a sanity check that an IPI IRQ domain can be found during boot, in order to ensure that IPIs are able to be set up in systems using such domains. However it was added at a point where systems may have used an IPI IRQ domain in some situations but not others, and we could not know which were the case until runtime, so commit 578bffc82ec5 ("MIPS: Don't BUG_ON when no IPI domain is found") made that check simply skip IPI init if no domain were found in order to fix the boot for systems such as QEMU Malta.

We now use IPI IRQ domains for the MIPS CPU interrupt controller, which means systems which make use of IPI IRQ domains will always do so when running on multiple CPUs. As a result we now strengthen the sanity check to ensure that an IPI IRQ domain is found when multiple CPUs are present in the system.

---

 arch/mips/kernel/smp.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)
arch/mips/kernel/smp.c +12 -8
index f95f094..0155e85 100644
@@ -257,16 +257,20 @@ static int __init mips_smp_ipi_init(void)
 		ipidomain = irq_find_matching_host(NULL, DOMAIN_BUS_IPI);
 
 	/*
-	 * There are systems which only use IPI domains some of the time,
-	 * depending upon configuration we don't know until runtime. An
-	 * example is Malta where we may compile in support for GIC & the
-	 * MT ASE, but run on a system which has multiple VPEs in a single
-	 * core and doesn't include a GIC. Until all IPI implementations
-	 * have been converted to use IPI domains the best we can do here
-	 * is to return & hope some other code sets up the IPIs.
+	 * There are systems which use IPI IRQ domains, but only have one
+	 * registered when some runtime condition is met. For example a Malta
+	 * kernel may include support for GIC & CPU interrupt controller IPI
+	 * IRQ domains, but if run on a system with no GIC & no MT ASE then
+	 * neither will be supported or registered.
+	 *
+	 * We only have a problem if we're actually using multiple CPUs so fail
+	 * loudly if that is the case. Otherwise simply return, skipping IPI
+	 * setup, if we're running with only a single CPU.
 	 */
-	if (!ipidomain)
+	if (!ipidomain) {
+		BUG_ON(num_present_cpus() > 1);
 		return 0;
+	}
 
 	call_virq = irq_reserve_ipi(ipidomain, cpu_possible_mask);
 	BUG_ON(!call_virq);
Signature · 1 line
2.9.3
#23 lore raw

PATCH 20/26 MIPS: Adjust MIPS64 CAC_BASE to reflect Config.K0

In reply to Paul Burton

On MIPS64 we define the default CAC_BASE as one of the xkphys regions of the virtual address space. Since the CCA is encoded in bits 61:59 of xkphys addresses, fixing CAC_BASE to any particular one prevents us from dynamically changing the CCA as we do for MIPS32 where CAC_BASE is placed within kseg0. In order to make the kernel more generic, drop the current kludge that gives CAC_BASE CCA=3 if CONFIG_DMA_NONCOHERENT is selected (disregarding CONFIG_DMA_MAYBE_COHERENT) & CCA=5 (which is not standardised by the architecture) otherwise. Instead read Config.K0 and generate the appropriate offset into xkphys, presuming that either the bootloader or early kernel code will have configured Config.K0 appropriately. This seems like the best option for a generic implementation.

The ip27 spaces.h is adjusted to set its former value of CAC_BASE, since it's the only user of CAC_BASE from assembly (in its smp_slave_setup macro). This allows the generic case to focus solely on C code without breaking ip27.

---

 arch/mips/include/asm/addrspace.h           | 3 +--
 arch/mips/include/asm/mach-generic/spaces.h | 8 +++-----
 arch/mips/include/asm/mach-ip27/spaces.h    | 1 +
 3 files changed, 5 insertions(+), 7 deletions(-)
arch/mips/include/asm/addrspace.h +1 -2
index c5b04e7..4856adc 100644
@@ -126,8 +126,7 @@
 #define PHYS_TO_XKSEG_UNCACHED(p)	PHYS_TO_XKPHYS(K_CALG_UNCACHED, (p))
 #define PHYS_TO_XKSEG_CACHED(p)		PHYS_TO_XKPHYS(K_CALG_COH_SHAREABLE, (p))
 #define XKPHYS_TO_PHYS(p)		((p) & TO_PHYS_MASK)
-#define PHYS_TO_XKPHYS(cm, a)		(_CONST64_(0x8000000000000000) | \
-					 (_CONST64_(cm) << 59) | (a))
+#define PHYS_TO_XKPHYS(cm, a)		(XKPHYS | (_ACAST64_(cm) << 59) | (a))
 
 /*
  * The ultimate limited of the 64-bit MIPS architecture:  2 bits for selecting
arch/mips/include/asm/mach-generic/spaces.h +3 -5
index afc96ec..952b0fd 100644
@@ -12,6 +12,8 @@
 
 #include <linux/const.h>
 
+#include <asm/mipsregs.h>
+
 /*
  * This gives the physical RAM offset.
  */
@@ -52,11 +54,7 @@
 #ifdef CONFIG_64BIT
 
 #ifndef CAC_BASE
-#ifdef CONFIG_DMA_NONCOHERENT
-#define CAC_BASE		_AC(0x9800000000000000, UL)
-#else
-#define CAC_BASE		_AC(0xa800000000000000, UL)
-#endif
+#define CAC_BASE	PHYS_TO_XKPHYS(read_c0_config() & CONF_CM_CMASK, 0)
 #endif
 
 #ifndef IO_BASE
arch/mips/include/asm/mach-ip27/spaces.h +1 -0
index b18802a..4775a11 100644
@@ -19,6 +19,7 @@
 #define IO_BASE			0x9200000000000000
 #define MSPEC_BASE		0x9400000000000000
 #define UNCAC_BASE		0x9600000000000000
+#define CAC_BASE		0xa800000000000000
 
 #define TO_MSPEC(x)		(MSPEC_BASE | ((x) & TO_PHYS_MASK))
 #define TO_HSPEC(x)		(HSPEC_BASE | ((x) & TO_PHYS_MASK))
Signature · 1 line
2.9.3
#24 lore raw

PATCH 21/26 MIPS: Support generating Flattened Image Trees (.itb)

In reply to Paul Burton

Add support for generating kernel images in the Flattened Image Tree (.itb) format as supported by U-Boot. This format is essentially a Flattened Device Tree binary containing images (kernels, DTBs, ramdisks) and configurations which link those images together. The big advantages of FIT images over the uImage format are:

- We can include FDTs in the kernel image in a way that the bootloader can extract it & manipulate it before providing it to the kernel. Thus we can ship FDTs as part of the kernel giving us the advantages of being able to develop & maintain the DT within the kernel tree, but also have the benefits of the bootloader being able to manipulate the FDT. Example uses for this would be to inject the kernel command line into the chosen node, or to fill in the correct memory size.

- We can include multiple configurations in a single kernel image. This means that a single FIT image can, given appropriate bootloaders, be booted on different boards with the bootloader selecting an appropriate configuration & providing the correct FDT to the kernel.

- We can support a multitude of hashes over the data.

---

 arch/mips/Makefile      |  8 ++++++-
 arch/mips/boot/Makefile | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+), 1 deletion(-)
arch/mips/Makefile +7 -1
index efd7a9d..d968ec0 100644
@@ -266,7 +266,8 @@ KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
 KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
 
 bootvars-y	= VMLINUX_LOAD_ADDRESS=$(load-y) \
-		  VMLINUX_ENTRY_ADDRESS=$(entry-y)
+		  VMLINUX_ENTRY_ADDRESS=$(entry-y) \
+		  PLATFORM=$(platform-y)
 
 LDFLAGS			+= -m $(ld-emul)
 
@@ -306,6 +307,11 @@ boot-y			+= uImage.gz
 boot-y			+= uImage.lzma
 boot-y			+= uImage.lzo
 endif
+boot-y			+= vmlinux.itb
+boot-y			+= vmlinux.gz.itb
+boot-y			+= vmlinux.bz2.itb
+boot-y			+= vmlinux.lzma.itb
+boot-y			+= vmlinux.lzo.itb
 
 # compressed boot image targets (arch/mips/boot/compressed/)
 bootz-y			:= vmlinuz
arch/mips/boot/Makefile +57 -0

60 lines not on this page · raw message

Signature · 1 line
2.9.3
#25 lore raw

PATCH 22/26 MIPS: generic: Introduce generic DT-based board support

In reply to Paul Burton

Introduce a "generic" platform, which aims to be board-agnostic by making use of device trees passed by the boot protocol defined in the MIPS UHI (Universal Hosting Interface) specification. Provision is made for supporting boards which use a legacy boot protocol that can't be changed, but adding support for such boards or any others is left to followon patches.

Right now the built kernels expect to be loaded to 0x80100000, ie. in kseg0. This is fine for the vast majority of MIPS platforms, but nevertheless it would be good to remove this limitation in the future by mapping the kernel via the TLB such that it can be loaded anywhere & map itself appropriately.

Configuration is handled by dynamically generating configs using scripts/kconfig/merge_config.sh, somewhat similar to the way powerpc makes use of it. This allows for variations upon the configuration, eg. differing architecture revisions or subsets of driver support for differing boards, to be handled without having a large number of defconfig files.

---

 arch/mips/Kbuild.platforms                 |   1 +
 arch/mips/Kconfig                          |  51 +++++++++
 arch/mips/Makefile                         |  51 +++++++++
 arch/mips/boot/Makefile                    |  11 +-
 arch/mips/configs/generic/32r1.config      |   2 +
 arch/mips/configs/generic/32r2.config      |   3 +
 arch/mips/configs/generic/32r6.config      |   2 +
 arch/mips/configs/generic/64r1.config      |   1 +
 arch/mips/configs/generic/64r2.config      |   2 +
 arch/mips/configs/generic/64r6.config      |   1 +
 arch/mips/configs/generic/eb.config        |   1 +
 arch/mips/configs/generic/el.config        |   1 +
 arch/mips/configs/generic/micro32r2.config |   4 +
 arch/mips/configs/generic_defconfig        |   2 +
 arch/mips/generic/Kconfig                  |  12 ++
 arch/mips/generic/Makefile                 |  13 +++
 arch/mips/generic/Platform                 |  14 +++
 arch/mips/generic/init.c                   | 174 +++++++++++++++++++++++++++++
 arch/mips/generic/irq.c                    |  64 +++++++++++
 arch/mips/generic/proc.c                   |  29 +++++
 arch/mips/generic/vmlinux.its.S            |  31 +++++
 arch/mips/include/asm/machine.h            |  63 +++++++++++
 22 files changed, 532 insertions(+), 1 deletion(-)
 create mode 100644 arch/mips/configs/generic/32r1.config
 create mode 100644 arch/mips/configs/generic/32r2.config
 create mode 100644 arch/mips/configs/generic/32r6.config
 create mode 100644 arch/mips/configs/generic/64r1.config
 create mode 100644 arch/mips/configs/generic/64r2.config
 create mode 100644 arch/mips/configs/generic/64r6.config
 create mode 100644 arch/mips/configs/generic/eb.config
 create mode 100644 arch/mips/configs/generic/el.config
 create mode 100644 arch/mips/configs/generic/micro32r2.config
 create mode 100644 arch/mips/configs/generic_defconfig
 create mode 100644 arch/mips/generic/Kconfig
 create mode 100644 arch/mips/generic/Makefile
 create mode 100644 arch/mips/generic/Platform
 create mode 100644 arch/mips/generic/init.c
 create mode 100644 arch/mips/generic/irq.c
 create mode 100644 arch/mips/generic/proc.c
 create mode 100644 arch/mips/generic/vmlinux.its.S
 create mode 100644 arch/mips/include/asm/machine.h
arch/mips/Kbuild.platforms +1 -0
index c5cd63a..9c1e8f9 100644
@@ -11,6 +11,7 @@ platforms += cavium-octeon
 platforms += cobalt
 platforms += dec
 platforms += emma
+platforms += generic
 platforms += jazz
 platforms += jz4740
 platforms += lantiq
arch/mips/Kconfig +51 -0

63 lines not on this page · raw message

arch/mips/Makefile +51 -0

61 lines not on this page · raw message

arch/mips/boot/Makefile +10 -1
index ed65663..2728a9a 100644
@@ -111,13 +111,22 @@ targets += vmlinux.bz2.itb
 targets += vmlinux.lzma.itb
 targets += vmlinux.lzo.itb
 
+ifeq ($(ADDR_BITS),32)
+	itb_addr_cells = 1
+endif
+ifeq ($(ADDR_BITS),64)
+	itb_addr_cells = 2
+endif
+
 quiet_cmd_cpp_its_S = ITS     $@
       cmd_cpp_its_S = $(CPP) $(cpp_flags) -P -C -o $@ $< \
 		        -DKERNEL_NAME="\"Linux $(KERNELRELEASE)\"" \
 			-DVMLINUX_BINARY="\"$(3)\"" \
 			-DVMLINUX_COMPRESSION="\"$(2)\"" \
 			-DVMLINUX_LOAD_ADDRESS=$(VMLINUX_LOAD_ADDRESS) \
-			-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS)
+			-DVMLINUX_ENTRY_ADDRESS=$(VMLINUX_ENTRY_ADDRESS) \
+			-DADDR_BITS=$(ADDR_BITS) \
+			-DADDR_CELLS=$(itb_addr_cells)
 
 $(obj)/vmlinux.its: $(srctree)/arch/mips/$(PLATFORM)/vmlinux.its.S FORCE
 	$(call if_changed_dep,cpp_its_S,none,vmlinux.bin)
arch/mips/configs/generic/32r1.config new file +2 -0
new file mode 100644
index 0000000..a11cd87
@@ -0,0 +1,2 @@
+CONFIG_CPU_MIPS32_R1=y
+CONFIG_HIGHMEM=y
arch/mips/configs/generic/32r2.config new file +3 -0
new file mode 100644
index 0000000..9570672
@@ -0,0 +1,3 @@
+CONFIG_CPU_MIPS32_R2=y
+CONFIG_MIPS_O32_FP64_SUPPORT=y
+CONFIG_HIGHMEM=y
arch/mips/configs/generic/32r6.config new file +2 -0
new file mode 100644
index 0000000..ca606e7
@@ -0,0 +1,2 @@
+CONFIG_CPU_MIPS32_R6=y
+CONFIG_HIGHMEM=y
arch/mips/configs/generic/64r1.config new file +1 -0
new file mode 100644
index 0000000..96ac0d7
@@ -0,0 +1 @@
+CONFIG_CPU_MIPS64_R1=y
arch/mips/configs/generic/64r2.config new file +2 -0
new file mode 100644
index 0000000..fa9cab0
@@ -0,0 +1,2 @@
+CONFIG_CPU_MIPS64_R2=y
+CONFIG_MIPS_O32_FP64_SUPPORT=y
arch/mips/configs/generic/64r6.config new file +1 -0
new file mode 100644
index 0000000..51a9ebb
@@ -0,0 +1 @@
+CONFIG_CPU_MIPS64_R6=y
arch/mips/configs/generic/eb.config new file +1 -0
new file mode 100644
index 0000000..c5cdc99
@@ -0,0 +1 @@
+CONFIG_CPU_BIG_ENDIAN=y
arch/mips/configs/generic/el.config new file +1 -0
new file mode 100644
index 0000000..ee43fdb
@@ -0,0 +1 @@
+CONFIG_CPU_LITTLE_ENDIAN=y
arch/mips/configs/generic/micro32r2.config new file +4 -0
new file mode 100644
index 0000000..b701fe7
@@ -0,0 +1,4 @@
+CONFIG_CPU_MIPS32_R2=y
+CONFIG_CPU_MICROMIPS=y
+CONFIG_MIPS_O32_FP64_SUPPORT=y
+CONFIG_HIGHMEM=y
arch/mips/configs/generic_defconfig new file +2 -0
new file mode 100644
index 0000000..419d263
@@ -0,0 +1,2 @@
+CONFIG_MIPS=y
+CONFIG_MIPS_GENERIC=y
arch/mips/generic/Kconfig new file +12 -0
new file mode 100644
index 0000000..baddb06
@@ -0,0 +1,12 @@
+if MIPS_GENERIC
+
+config LEGACY_BOARDS
+	bool
+	help
+	  Select this from your board if the board must use a legacy, non-UHI,
+	  boot protocol. This will cause the kernel to scan through the list of
+	  supported machines calling their detect functions in turn if the
+	  kernel is booted without being provided with an FDT via the UHI
+	  boot protocol.
+
+endif
arch/mips/generic/Makefile new file +13 -0
new file mode 100644
index 0000000..26e6420
@@ -0,0 +1,13 @@
+#
+# Copyright (C) 2016 Imagination Technologies
+# Author: Paul Burton <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation;  either version 2 of the  License, or (at your
+# option) any later version.
+#
+
+obj-y += init.o
+obj-y += irq.o
+obj-y += proc.o
arch/mips/generic/Platform new file +14 -0
new file mode 100644
index 0000000..9a30d69
@@ -0,0 +1,14 @@
+#
+# Copyright (C) 2016 Imagination Technologies
+# Author: Paul Burton <[email protected]>
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation;  either version 2 of the  License, or (at your
+# option) any later version.
+#
+
+platform-$(CONFIG_MIPS_GENERIC)	+= generic/
+cflags-$(CONFIG_MIPS_GENERIC)	+= -I$(srctree)/arch/mips/include/asm/mach-generic
+load-$(CONFIG_MIPS_GENERIC)	+= 0xffffffff80100000
+all-$(CONFIG_MIPS_GENERIC)	:= vmlinux.gz.itb
arch/mips/generic/init.c new file +174 -0

174 lines not on this page · raw message

arch/mips/generic/irq.c new file +64 -0

64 lines not on this page · raw message

arch/mips/generic/proc.c new file +29 -0
new file mode 100644
index 0000000..42b3325
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ * Author: Paul Burton <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation;  either version 2 of the  License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/of.h>
+
+#include <asm/bootinfo.h>
+
+const char *get_system_type(void)
+{
+	const char *str;
+	int err;
+
+	err = of_property_read_string(of_root, "model", &str);
+	if (!err)
+		return str;
+
+	err = of_property_read_string_index(of_root, "compatible", 0, &str);
+	if (!err)
+		return str;
+
+	return "Unknown";
+}
arch/mips/generic/vmlinux.its.S new file +31 -0
new file mode 100644
index 0000000..f67fbf1
@@ -0,0 +1,31 @@
+/dts-v1/;
+
+/ {
+	description = KERNEL_NAME;
+	#address-cells = <ADDR_CELLS>;
+
+	images {
+		kernel@0 {
+			description = KERNEL_NAME;
+			data = /incbin/(VMLINUX_BINARY);
+			type = "kernel";
+			arch = "mips";
+			os = "linux";
+			compression = VMLINUX_COMPRESSION;
+			load = /bits/ ADDR_BITS <VMLINUX_LOAD_ADDRESS>;
+			entry = /bits/ ADDR_BITS <VMLINUX_ENTRY_ADDRESS>;
+			hash@0 {
+				algo = "sha1";
+			};
+		};
+	};
+
+	configurations {
+		default = "conf@default";
+
+		conf@default {
+			description = "Generic Linux kernel";
+			kernel = "kernel@0";
+		};
+	};
+};
arch/mips/include/asm/machine.h new file +63 -0

63 lines not on this page · raw message

Signature · 1 line
2.9.3
#26 lore raw

Re: [22/26] MIPS: generic: Introduce generic DT-based board support

Quoted 13 lines · Paul Burton

Introduce a "generic" platform, which aims to be board-agnostic by making use of device trees passed by the boot protocol defined in the MIPS UHI (Universal Hosting Interface) specification. Provision is made for supporting boards which use a legacy boot protocol that can't be changed, but adding support for such boards or any others is left to followon patches.

Right now the built kernels expect to be loaded to 0x80100000, ie. in kseg0. This is fine for the vast majority of MIPS platforms, but nevertheless it would be good to remove this limitation in the future by mapping the kernel via the TLB such that it can be loaded anywhere & map itself appropriately.

Quoted 8 lines

Configuration is handled by dynamically generating configs using scripts/kconfig/merge_config.sh, somewhat similar to the way powerpc makes use of it. This allows for variations upon the configuration, eg. differing architecture revisions or subsets of driver support for differing boards, to be handled without having a large number of defconfig files.

Guess it is known that this patch causes failures when building "allmodconfig" on test systems such as 0day; it was reported by 0day some two months ago. nevertheless, the patch found its way into mainline without fix. Does anyone care, or should I simply disable "allmodconfig" test builds for mips ?

Guenter

#27 lore raw

Re: [22/26] MIPS: generic: Introduce generic DT-based board support

Quoted 21 lines · Guenter Roeck
Quoted 20 lines · Paul Burton

Introduce a "generic" platform, which aims to be board-agnostic by making use of device trees passed by the boot protocol defined in the MIPS UHI (Universal Hosting Interface) specification. Provision is made for supporting boards which use a legacy boot protocol that can't be changed, but adding support for such boards or any others is left to followon patches.

Right now the built kernels expect to be loaded to 0x80100000, ie. in kseg0. This is fine for the vast majority of MIPS platforms, but nevertheless it would be good to remove this limitation in the future by mapping the kernel via the TLB such that it can be loaded anywhere & map itself appropriately.

Configuration is handled by dynamically generating configs using scripts/kconfig/merge_config.sh, somewhat similar to the way powerpc makes use of it. This allows for variations upon the configuration, eg. differing architecture revisions or subsets of driver support for differing boards, to be handled without having a large number of defconfig files.

Quoted 7 lines
Quoted 1 line

Guess it is known that this patch causes failures when building "allmodconfig" on test systems such as 0day; it was reported by 0day some two months ago. nevertheless, the patch found its way into mainline without fix. Does anyone care, or should I simply disable "allmodconfig" test builds for mips ?

Hi Guenter,

I can't find any emails from 0day in relation to this patch (I've also dug about on the kbuild-all archives without success). Could you link to or quote the build failure you're referring to.

Thanks
James

#28 lore raw

Re: [22/26] MIPS: generic: Introduce generic DT-based board support

Quoted 30 lines · James Hogan
Quoted 21 lines · Guenter Roeck
Quoted 20 lines · Paul Burton

Introduce a "generic" platform, which aims to be board-agnostic by making use of device trees passed by the boot protocol defined in the MIPS UHI (Universal Hosting Interface) specification. Provision is made for supporting boards which use a legacy boot protocol that can't be changed, but adding support for such boards or any others is left to followon patches.

Right now the built kernels expect to be loaded to 0x80100000, ie. in kseg0. This is fine for the vast majority of MIPS platforms, but nevertheless it would be good to remove this limitation in the future by mapping the kernel via the TLB such that it can be loaded anywhere & map itself appropriately.

Configuration is handled by dynamically generating configs using scripts/kconfig/merge_config.sh, somewhat similar to the way powerpc makes use of it. This allows for variations upon the configuration, eg. differing architecture revisions or subsets of driver support for differing boards, to be handled without having a large number of defconfig files.

Quoted 7 lines
Quoted 1 line

Guess it is known that this patch causes failures when building "allmodconfig" on test systems such as 0day; it was reported by 0day some two months ago. nevertheless, the patch found its way into mainline without fix. Does anyone care, or should I simply disable "allmodconfig" test builds for mips ?

Quoted 9 lines

Hi Guenter,

I can't find any emails from 0day in relation to this patch (I've also dug about on the kbuild-all archives without success). Could you link to or quote the build failure you're referring to.

Thanks
James

It was much older than two months, actually.

https://lkml.org/lkml/2016/12/15/33

Guenter

#29 lore raw

PATCH 1/1 MIPS: Fix CPS SMP NS16550 UART defaults

From: James Hogan <[email protected]>

The MIPS_CPS_NS16550_BASE and MIPS_CPS_NS16550_SHIFT options have no defaults for non-Malta platforms which select SYS_SUPPORTS_MIPS_CPS (i.e. the pistachio and generic platforms). This is problematic for automated allyesconfig and allmodconfig builds based on these platforms, since make silentoldconfig tries to ask the user for values, and especially since v4.15 where the default platform was switched to generic.

Default these options to 0 and arrange for MIPS_CPS_NS16550 to be no when using that default base address, so that the option only has an effect when the default is provided (i.e. Malta) or when a value is provided by the user.

Fixes 609cf6f2291a ("MIPS: CPS: Early debug using an ns16550-compatible UART")
Cc Ralf Baechle <[email protected]>
Cc Guenter Roeck <[email protected]>

---
Guenter: I'm guessing this is the problem you're referring to.

---
 arch/mips/Kconfig.debug | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
arch/mips/Kconfig.debug +10 -4
index 464af5e025d6..0749c3724543 100644
@@ -124,30 +124,36 @@ config SCACHE_DEBUGFS
 
 	  If unsure, say N.
 
-menuconfig MIPS_CPS_NS16550
+menuconfig MIPS_CPS_NS16550_BOOL
 	bool "CPS SMP NS16550 UART output"
 	depends on MIPS_CPS
 	help
 	  Output debug information via an ns16550 compatible UART if exceptions
 	  occur early in the boot process of a secondary core.
 
-if MIPS_CPS_NS16550
+if MIPS_CPS_NS16550_BOOL
+
+config MIPS_CPS_NS16550
+	def_bool MIPS_CPS_NS16550_BASE != 0
 
 config MIPS_CPS_NS16550_BASE
 	hex "UART Base Address"
 	default 0x1b0003f8 if MIPS_MALTA
+	default 0
 	help
 	  The base address of the ns16550 compatible UART on which to output
 	  debug information from the early stages of core startup.
 
+	  This is only used if non-zero.
+
 config MIPS_CPS_NS16550_SHIFT
 	int "UART Register Shift"
-	default 0 if MIPS_MALTA
+	default 0
 	help
 	  The number of bits to shift ns16550 register indices by in order to
 	  form their addresses. That is, log base 2 of the span between
 	  adjacent ns16550 registers in the system.
 
-endif # MIPS_CPS_NS16550
+endif # MIPS_CPS_NS16550_BOOL
 
 endmenu
Signature · 1 line
2.14.1
Tested-by on v1 1/1
#30 lore raw

Re: [PATCH] MIPS: Fix CPS SMP NS16550 UART defaults

Quoted 15 lines · James Hogan

From: James Hogan <[email protected]>

The MIPS_CPS_NS16550_BASE and MIPS_CPS_NS16550_SHIFT options have no defaults for non-Malta platforms which select SYS_SUPPORTS_MIPS_CPS (i.e. the pistachio and generic platforms). This is problematic for automated allyesconfig and allmodconfig builds based on these platforms, since make silentoldconfig tries to ask the user for values, and especially since v4.15 where the default platform was switched to generic.

Default these options to 0 and arrange for MIPS_CPS_NS16550 to be no when using that default base address, so that the option only has an effect when the default is provided (i.e. Malta) or when a value is provided by the user.

Quoted 8 lines
Fixes 609cf6f2291a ("MIPS: CPS: Early debug using an ns16550-compatible UART")
Cc Ralf Baechle <[email protected]>
Cc Guenter Roeck <[email protected]>

---
Guenter: I'm guessing this is the problem you're referring to.

Yes.

mips:allmodconfig still fails to build with this patch applied, but elsewhere.

In file included from /opt/buildbot/slave/hwmon-testing/build/include/linux/bcma/bcma.h:10:0,
from /opt/buildbot/slave/hwmon-testing/build/drivers/bcma/bcma_private.h:9,
from /opt/buildbot/slave/hwmon-testing/build/drivers/bcma/main.c:8:
/opt/buildbot/slave/hwmon-testing/build/include/linux/bcma/bcma_driver_pci.h:218:24: error: field 'pci_controller' has incomplete type

Guenter

#31 lore raw

Re: MIPS: Fix CPS SMP NS16550 UART defaults

In reply to James Hogan
Quoted 15 lines · James Hogan

From: James Hogan <[email protected]>

The MIPS_CPS_NS16550_BASE and MIPS_CPS_NS16550_SHIFT options have no defaults for non-Malta platforms which select SYS_SUPPORTS_MIPS_CPS (i.e. the pistachio and generic platforms). This is problematic for automated allyesconfig and allmodconfig builds based on these platforms, since make silentoldconfig tries to ask the user for values, and especially since v4.15 where the default platform was switched to generic.

Default these options to 0 and arrange for MIPS_CPS_NS16550 to be no when using that default base address, so that the option only has an effect when the default is provided (i.e. Malta) or when a value is provided by the user.

Quoted 7 lines
Fixes 609cf6f2291a ("MIPS: CPS: Early debug using an ns16550-compatible UART")
Cc Ralf Baechle <[email protected]>
Cc Guenter Roeck <[email protected]>

Still not applied, mips builds still broken both in mainline and -next (and worse in -next). Doesn't 0day report all this breakage automatically ?

Guenter

Quoted 51 lines

---
Guenter: I'm guessing this is the problem you're referring to.

---
 arch/mips/Kconfig.debug | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
arch/mips/Kconfig.debug +10 -4
index 464af5e025d6..0749c3724543 100644
@@ -124,30 +124,36 @@ config SCACHE_DEBUGFS
 
 	  If unsure, say N.
 
-menuconfig MIPS_CPS_NS16550
+menuconfig MIPS_CPS_NS16550_BOOL
 	bool "CPS SMP NS16550 UART output"
 	depends on MIPS_CPS
 	help
 	  Output debug information via an ns16550 compatible UART if exceptions
 	  occur early in the boot process of a secondary core.
 
-if MIPS_CPS_NS16550
+if MIPS_CPS_NS16550_BOOL
+
+config MIPS_CPS_NS16550
+	def_bool MIPS_CPS_NS16550_BASE != 0
 
 config MIPS_CPS_NS16550_BASE
 	hex "UART Base Address"
 	default 0x1b0003f8 if MIPS_MALTA
+	default 0
 	help
 	  The base address of the ns16550 compatible UART on which to output
 	  debug information from the early stages of core startup.
 
+	  This is only used if non-zero.
+
 config MIPS_CPS_NS16550_SHIFT
 	int "UART Register Shift"
-	default 0 if MIPS_MALTA
+	default 0
 	help
 	  The number of bits to shift ns16550 register indices by in order to
 	  form their addresses. That is, log base 2 of the span between
 	  adjacent ns16550 registers in the system.
 
-endif # MIPS_CPS_NS16550
+endif # MIPS_CPS_NS16550_BOOL
 
 endmenu
#32 lore raw

PATCH 23/26 MIPS: generic: Convert SEAD-3 to a generic board

In reply to Paul Burton

Convert the MIPS SEAD-3 board support to be a generic board, supported by generic kernels.

Because the SEAD-3 boot protocol was defined long ago and we don't want to force a switch to the UHI protocol, SEAD-3 is added as a legacy board which is detected by reading the REVISION register. This may technically not be a valid memory read & future work will include attempting to handle that gracefully. In practice since SEAD-3 is the only legacy board supported by the generic kernel so far the read will only happen on SEAD-3 boards, and even once Malta is converted the same REVISION register exists there too. Other boards such as Boston, Ci20 & Ci40 will use the UHI boot protocol & thus not run any of the legacy board detect functions.

---

 arch/mips/Kbuild.platforms                         |   1 -
 arch/mips/Kconfig                                  |  37 +-----
 arch/mips/Makefile                                 |  13 +++
 arch/mips/boot/dts/mti/Makefile                    |   2 +-
 arch/mips/boot/dts/mti/sead3.dts                   |   1 +
 arch/mips/configs/generic/board-sead-3.config      |  32 +++++
 arch/mips/configs/sead3_defconfig                  | 129 ---------------------
 arch/mips/configs/sead3micro_defconfig             | 122 -------------------
 arch/mips/generic/Kconfig                          |   7 ++
 arch/mips/generic/Makefile                         |   2 +
 .../sead3-dtshim.c => generic/board-sead3.c}       | 106 +++++++++++++++--
 .../include/asm/mach-sead3/cpu-feature-overrides.h |  72 ------------
 arch/mips/include/asm/mach-sead3/irq.h             |   9 --
 .../include/asm/mach-sead3/kernel-entry-init.h     |  21 ----
 arch/mips/include/asm/mach-sead3/sead3-dtshim.h    |  29 -----
 arch/mips/include/asm/mach-sead3/war.h             |  24 ----
 arch/mips/mti-sead3/Makefile                       |  15 ---
 arch/mips/mti-sead3/Platform                       |   7 --
 arch/mips/mti-sead3/sead3-init.c                   | 100 ----------------
 arch/mips/mti-sead3/sead3-int.c                    |  23 ----
 arch/mips/mti-sead3/sead3-setup.c                  |  39 -------
 arch/mips/mti-sead3/sead3-time.c                   |  91 ---------------
 22 files changed, 152 insertions(+), 730 deletions(-)
 create mode 100644 arch/mips/configs/generic/board-sead-3.config
 delete mode 100644 arch/mips/configs/sead3_defconfig
 delete mode 100644 arch/mips/configs/sead3micro_defconfig
 rename arch/mips/{mti-sead3/sead3-dtshim.c => generic/board-sead3.c} (72%)
 delete mode 100644 arch/mips/include/asm/mach-sead3/cpu-feature-overrides.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/irq.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/kernel-entry-init.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/sead3-dtshim.h
 delete mode 100644 arch/mips/include/asm/mach-sead3/war.h
 delete mode 100644 arch/mips/mti-sead3/Makefile
 delete mode 100644 arch/mips/mti-sead3/Platform
 delete mode 100644 arch/mips/mti-sead3/sead3-init.c
 delete mode 100644 arch/mips/mti-sead3/sead3-int.c
 delete mode 100644 arch/mips/mti-sead3/sead3-setup.c
 delete mode 100644 arch/mips/mti-sead3/sead3-time.c
arch/mips/Kbuild.platforms +0 -1
index 9c1e8f9..f5f1bdb 100644
@@ -19,7 +19,6 @@ platforms += lasat
 platforms += loongson32
 platforms += loongson64
 platforms += mti-malta
-platforms += mti-sead3
 platforms += netlogic
 platforms += paravirt
 platforms += pic32
arch/mips/Kconfig +1 -36
index 2884d80..a2b6dd1 100644
@@ -543,41 +543,6 @@ config MACH_PIC32
 	  Microchip PIC32 is a family of general-purpose 32 bit MIPS core
 	  microcontrollers.
 
-config MIPS_SEAD3
-	bool "MIPS SEAD3 board"
-	select BOOT_ELF32
-	select BOOT_RAW
-	select BUILTIN_DTB
-	select CEVT_R4K
-	select CSRC_R4K
-	select CLKSRC_MIPS_GIC
-	select COMMON_CLK
-	select CPU_MIPSR2_IRQ_VI
-	select CPU_MIPSR2_IRQ_EI
-	select DMA_NONCOHERENT
-	select IRQ_MIPS_CPU
-	select MIPS_GIC
-	select LIBFDT
-	select MIPS_MSC
-	select SYS_HAS_CPU_MIPS32_R1
-	select SYS_HAS_CPU_MIPS32_R2
-	select SYS_HAS_CPU_MIPS32_R6
-	select SYS_HAS_CPU_MIPS64_R1
-	select SYS_SUPPORTS_32BIT_KERNEL
-	select SYS_SUPPORTS_64BIT_KERNEL
-	select SYS_SUPPORTS_BIG_ENDIAN
-	select SYS_SUPPORTS_LITTLE_ENDIAN
-	select SYS_SUPPORTS_SMARTMIPS
-	select SYS_SUPPORTS_MICROMIPS
-	select SYS_SUPPORTS_MIPS16
-	select SYS_SUPPORTS_RELOCATABLE
-	select USB_EHCI_BIG_ENDIAN_DESC
-	select USB_EHCI_BIG_ENDIAN_MMIO
-	select USE_OF
-	help
-	  This enables support for the MIPS Technologies SEAD3 evaluation
-	  board.
-
 config NEC_MARKEINS
 	bool "NEC EMMA2RH Mark-eins board"
 	select SOC_EMMA2RH
@@ -2960,7 +2925,7 @@ endchoice
 choice
 	prompt "Kernel command line type" if !CMDLINE_OVERRIDE
 	default MIPS_CMDLINE_FROM_DTB if USE_OF && !ATH79 && !MACH_INGENIC && \
-					 !MIPS_MALTA && !MIPS_SEAD3 && \
+					 !MIPS_MALTA && \
 					 !CAVIUM_OCTEON_SOC
 	default MIPS_CMDLINE_FROM_BOOTLOADER
 
arch/mips/Makefile +13 -0
index 1add1e7..5e0eba3 100644
@@ -487,3 +487,16 @@ $(generic_defconfigs):
 		-m -O $(objtree) $(srctree)/arch/$(ARCH)/configs/generic_defconfig $^ \
 		$(foreach board,$(BOARDS),$(generic_config_dir)/board-$(board).config)
 	$(Q)$(MAKE) olddefconfig
+
+#
+# Legacy defconfig compatibility - these targets used to be real defconfigs but
+# now that the boards have been converted to use the generic kernel they are
+# wrappers around the generic rules above.
+#
+.PHONY: sead3_defconfig
+sead3_defconfig:
+	$(Q)$(MAKE) 32r2el_defconfig BOARDS=sead-3
+
+.PHONY: sead3micro_defconfig
+sead3micro_defconfig:
+	$(Q)$(MAKE) micro32r2el_defconfig BOARDS=sead-3
arch/mips/boot/dts/mti/Makefile +1 -1
index 144d776..fcabd69 100644
@@ -1,5 +1,5 @@
 dtb-$(CONFIG_MIPS_MALTA)	+= malta.dtb
-dtb-$(CONFIG_MIPS_SEAD3)	+= sead3.dtb
+dtb-$(CONFIG_LEGACY_BOARD_SEAD3)	+= sead3.dtb
 
 obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
 
arch/mips/boot/dts/mti/sead3.dts +1 -0
index 2579ca5..b112879 100644
@@ -10,6 +10,7 @@
 	#address-cells = <1>;
 	#size-cells = <1>;
 	compatible = "mti,sead-3";
+	model = "MIPS SEAD-3";
 	interrupt-parent = <&gic>;
 
 	chosen {
arch/mips/configs/generic/board-sead-3.config new file +32 -0
new file mode 100644
index 0000000..3b5e1ac
@@ -0,0 +1,32 @@
+CONFIG_LEGACY_BOARD_SEAD3=y
+
+CONFIG_AUXDISPLAY=y
+CONFIG_IMG_ASCII_LCD=y
+
+CONFIG_NEW_LEDS=y
+CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_SYSCON=y
+
+CONFIG_MMC=y
+CONFIG_MMC_SPI=y
+
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_CFI=y
+CONFIG_MTD_CFI_INTELEXT=y
+CONFIG_MTD_OF_PARTS=y
+CONFIG_MTD_PHYSMAP=y
+CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_GLUEBI=y
+
+CONFIG_NETDEVICES=y
+CONFIG_SMSC911X=y
+CONFIG_SMSC_PHY=y
+
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+
+CONFIG_USB=y
+CONFIG_USB_EHCI_HCD=y
arch/mips/configs/sead3_defconfig deleted +0 -129

129 lines not on this page · raw message

arch/mips/configs/sead3micro_defconfig deleted +0 -122

122 lines not on this page · raw message

arch/mips/generic/Kconfig +7 -0
index baddb06..a606b3f 100644
@@ -9,4 +9,11 @@ config LEGACY_BOARDS
 	  kernel is booted without being provided with an FDT via the UHI
 	  boot protocol.
 
+config LEGACY_BOARD_SEAD3
+	bool "Support MIPS SEAD-3 boards"
+	select LEGACY_BOARDS
+	help
+	  Enable this to include support for booting on MIPS SEAD-3 FPGA-based
+	  development boards, which boot using a legacy boot protocol.
+
 endif
arch/mips/generic/Makefile +2 -0
index 26e6420..7c66494 100644
@@ -11,3 +11,5 @@
 obj-y += init.o
 obj-y += irq.o
 obj-y += proc.o
+
+obj-$(CONFIG_LEGACY_BOARD_SEAD3)	+= board-sead3.o
arch/mips/generic/board-sead3.c renamed from arch/mips/mti-sead3/sead3-dtshim.c +95 -11

164 lines not on this page · raw message

arch/mips/include/asm/mach-sead3/cpu-feature-overrides.h deleted +0 -72

72 lines not on this page · raw message

arch/mips/include/asm/mach-sead3/irq.h deleted +0 -9
deleted file mode 100644
index 5d154cf..0000000
@@ -1,9 +0,0 @@
-#ifndef __ASM_MACH_MIPS_IRQ_H
-#define __ASM_MACH_MIPS_IRQ_H
-
-#define NR_IRQS 256
-
-
-#include_next <irq.h>
-
-#endif /* __ASM_MACH_MIPS_IRQ_H */
arch/mips/include/asm/mach-sead3/kernel-entry-init.h deleted +0 -21
deleted file mode 100644
index 6cccd4d..0000000
@@ -1,21 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Chris Dearman ([email protected])
- * Copyright (C) 2007 Mips Technologies, Inc.
- */
-#ifndef __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H
-#define __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H
-
-	.macro	kernel_entry_setup
-	.endm
-
-/*
- * Do SMP slave processor setup necessary before we can safely execute C code.
- */
-	.macro	smp_slave_setup
-	.endm
-
-#endif /* __ASM_MACH_MIPS_KERNEL_ENTRY_INIT_H */
arch/mips/include/asm/mach-sead3/sead3-dtshim.h deleted +0 -29
deleted file mode 100644
index f5d7d9c..0000000
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2016 Imagination Technologies
- * Author: Paul Burton <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- */
-
-#ifndef __MIPS_SEAD3_DTSHIM_H__
-#define __MIPS_SEAD3_DTSHIM_H__
-
-#include <linux/init.h>
-
-#ifdef CONFIG_MIPS_SEAD3
-
-extern void __init *sead3_dt_shim(void *fdt);
-
-#else /* !CONFIG_MIPS_SEAD3 */
-
-static inline void *sead3_dt_shim(void *fdt)
-{
-	return fdt;
-}
-
-#endif /* !CONFIG_MIPS_SEAD3 */
-
-#endif /* __MIPS_SEAD3_DTSHIM_H__ */
arch/mips/include/asm/mach-sead3/war.h deleted +0 -24
deleted file mode 100644
index d068fc4..0000000
@@ -1,24 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2002, 2004, 2007 by Ralf Baechle <ralf-6z/[email protected]>
- */
-#ifndef __ASM_MIPS_MACH_MIPS_WAR_H
-#define __ASM_MIPS_MACH_MIPS_WAR_H
-
-#define R4600_V1_INDEX_ICACHEOP_WAR	0
-#define R4600_V1_HIT_CACHEOP_WAR	0
-#define R4600_V2_HIT_CACHEOP_WAR	0
-#define R5432_CP0_INTERRUPT_WAR		0
-#define BCM1250_M3_WAR			0
-#define SIBYTE_1956_WAR			0
-#define MIPS4K_ICACHE_REFILL_WAR	1
-#define MIPS_CACHE_SYNC_WAR		1
-#define TX49XX_ICACHE_INDEX_INV_WAR	0
-#define ICACHE_REFILLS_WORKAROUND_WAR	1
-#define R10000_LLSC_WAR			0
-#define MIPS34K_MISSED_ITLB_WAR		0
-
-#endif /* __ASM_MIPS_MACH_MIPS_WAR_H */
arch/mips/mti-sead3/Makefile deleted +0 -15
deleted file mode 100644
index 1674b9c..0000000
@@ -1,15 +0,0 @@
-#
-# Carsten Langgaard, [email protected]
-# Copyright (C) 1999,2000 MIPS Technologies, Inc.  All rights reserved.
-#
-# Copyright (C) 2008 Wind River Systems, Inc.
-#   written by Ralf Baechle <ralf-6z/[email protected]>
-#
-# Copyright (C) 2012 MIPS Technoligies, Inc.  All rights reserved.
-# Steven J. Hill <[email protected]>
-#
-obj-y := sead3-dtshim.o
-obj-y += sead3-init.o
-obj-y += sead3-int.o
-obj-y += sead3-setup.o
-obj-y += sead3-time.o
arch/mips/mti-sead3/Platform deleted +0 -7
deleted file mode 100644
index 3870924..0000000
@@ -1,7 +0,0 @@
-#
-# MIPS SEAD-3 board
-#
-platform-$(CONFIG_MIPS_SEAD3)	+= mti-sead3/
-cflags-$(CONFIG_MIPS_SEAD3)	+= -I$(srctree)/arch/mips/include/asm/mach-sead3
-load-$(CONFIG_MIPS_SEAD3)	+= 0xffffffff80100000
-all-$(CONFIG_MIPS_SEAD3)	:= $(COMPRESSION_FNAME).srec
arch/mips/mti-sead3/sead3-init.c deleted +0 -100

100 lines not on this page · raw message

arch/mips/mti-sead3/sead3-int.c deleted +0 -23
deleted file mode 100644
index 2e6b732..0000000
@@ -1,23 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
- */
-#include <linux/init.h>
-#include <linux/irqchip.h>
-#include <linux/irqchip/mips-gic.h>
-
-#include <asm/cpu-info.h>
-#include <asm/irq.h>
-
-void __init arch_init_irq(void)
-{
-	irqchip_init();
-
-	pr_info("GIC: %spresent\n", (gic_present) ? "" : "not ");
-	pr_info("EIC: %s\n",
-		(current_cpu_data.options & MIPS_CPU_VEIC) ?  "on" : "off");
-}
-
arch/mips/mti-sead3/sead3-setup.c deleted +0 -39
deleted file mode 100644
index c915e54..0000000
@@ -1,39 +0,0 @@
-/*
- * This file is subject to the terms and conditions of the GNU General Public
- * License.  See the file "COPYING" in the main directory of this archive
- * for more details.
- *
- * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
- * Copyright (C) 2013 Imagination Technologies Ltd.
- */
-#include <linux/init.h>
-#include <linux/libfdt.h>
-#include <linux/of_fdt.h>
-
-#include <asm/prom.h>
-
-#include <asm/mach-sead3/sead3-dtshim.h>
-#include <asm/mips-boards/generic.h>
-
-const char *get_system_type(void)
-{
-	return "MIPS SEAD3";
-}
-
-void __init *plat_get_fdt(void)
-{
-	return (void *)__dtb_start;
-}
-
-void __init plat_mem_setup(void)
-{
-	void *fdt = plat_get_fdt();
-
-	fdt = sead3_dt_shim(fdt);
-	__dt_setup_arch(fdt);
-}
-
-void __init device_tree_init(void)
-{
-	unflatten_and_copy_device_tree();
-}
arch/mips/mti-sead3/sead3-time.c deleted +0 -91

91 lines not on this page · raw message

Signature · 6 lines
2.9.3

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#33 lore raw

PATCH 24/26 dt-bindings: Document img,boston-clock binding

In reply to Paul Burton

Add device tree binding documentation for the clocks provided by the MIPS Boston development board from Imagination Technologies, and a header file describing the available clocks for use by device trees & driver.

---

 .../devicetree/bindings/clock/img,boston-clock.txt | 27 ++++++++++++++++++++++
 include/dt-bindings/clock/boston-clock.h           | 13 +++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/img,boston-clock.txt
 create mode 100644 include/dt-bindings/clock/boston-clock.h
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +27 -0
new file mode 100644
index 0000000..c01ea60
@@ -0,0 +1,27 @@
+Binding for Imagination Technologies MIPS Boston clock sources.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : Should be "img,boston-clock".
+- #clock-cells : Should be set to 1.
+  Values available for clock consumers can be found in the header file:
+    <dt-bindings/clock/boston-clock.h>
+- regmap : Phandle to the Boston platform register system controller.
+  This should contain a phandle to the system controller node covering the
+  platform registers provided by the Boston board.
+
+Example:
+
+	clk_boston: clock {
+		compatible = "img,boston-clock";
+		#clock-cells = <1>;
+		regmap = <&plat_regs>;
+	};
+
+	uart0: uart@17ffe000 {
+		/* ... */
+		clocks = <&clk_boston BOSTON_CLK_SYS>;
+	};
include/dt-bindings/clock/boston-clock.h new file +13 -0
new file mode 100644
index 0000000..25f9cd2
@@ -0,0 +1,13 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef __DT_BINDINGS_CLOCK_BOSTON_CLOCK_H__
+#define __DT_BINDINGS_CLOCK_BOSTON_CLOCK_H__
+
+#define BOSTON_CLK_SYS 0
+#define BOSTON_CLK_CPU 1
+
+#endif /* __DT_BINDINGS_CLOCK_BOSTON_CLOCK_H__ */
Signature · 1 line
2.9.3
#34 lore raw

Re: [PATCH 24/26] dt-bindings: Document img,boston-clock binding

Quoted 17 lines · Paul Burton
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +11 -0
new file mode 100644
index 0000000..c01ea60
@@ -0,0 +1,27 @@
+Binding for Imagination Technologies MIPS Boston clock sources.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : Should be "img,boston-clock".
+- #clock-cells : Should be set to 1.
+  Values available for clock consumers can be found in the header file:
+    <dt-bindings/clock/boston-clock.h>

Documentation/devicetree/bindings/clock/img,boston-clock.txt line 21

Quoted 10 lines
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +10 -0
+- regmap : Phandle to the Boston platform register system controller.
+  This should contain a phandle to the system controller node covering the
+  platform registers provided by the Boston board.
+
+Example:
+
+	clk_boston: clock {
+		compatible = "img,boston-clock";
+		#clock-cells = <1>;
+		regmap = <&plat_regs>;

Isn't syscon more standard than regmap as the property name? Is there a binding for the plat_regs device? Is there any reason the clks can't be populated in that syscon driver?

Quoted 6 lines
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +6 -0
+	};
+
+	uart0: uart@17ffe000 {
+		/* ... */
+		clocks = <&clk_boston BOSTON_CLK_SYS>;
+	};
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#35 lore raw

Re: [PATCH 24/26] dt-bindings: Document img,boston-clock binding

Quoted 24 lines · Stephen Boyd
Quoted 23 lines · Paul Burton
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +17 -0
new file mode 100644
index 0000000..c01ea60
@@ -0,0 +1,27 @@
+Binding for Imagination Technologies MIPS Boston clock sources.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : Should be "img,boston-clock".
+- #clock-cells : Should be set to 1.
+  Values available for clock consumers can be found in the header file:
+    <dt-bindings/clock/boston-clock.h>
+- regmap : Phandle to the Boston platform register system controller.
+  This should contain a phandle to the system controller node covering the
+  platform registers provided by the Boston board.
+
+Example:
+
Quoted 8 lines

Documentation/devicetree/bindings/clock/img,boston-clock.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +4 -0
+	clk_boston: clock {
+		compatible = "img,boston-clock";
+		#clock-cells = <1>;
+		regmap = <&plat_regs>;

Isn't syscon more standard than regmap as the property name? Is there a binding for the plat_regs device? Is there any reason the clks can't be populated in that syscon driver?

Hi Stephen,

The plat_regs device doesn't have a custom driver, it simply makes use of the generic "syscon" driver which can provide a regmap.

It would be possible to register the clocks from a register for the plat_regs device, but I don't think it would make much sense. The platform registers in question are essentially just a convenient place where various bits of information about the system are exposed, including the clock frequencies but also other bits & pieces like connectivity of PCIe controllers or I/O coherence units, the RTL revision of the CPU or the wrapper RTL that runs on this FPGA-based board, a register that allows for resetting the board, etc. It's not a single piece of hardware, more a dumping ground for miscellanea. So in my opinion using the syscon approach works best here, and drivers for well defined pieces of hardware or functionality can reference that syscon to retrieve the regmap.

As for whether "syscon" is a more standard property name than "regmap", both seem to be used based on a grep of Documentation/devicetree/bindings/. I believe I picked up use of "regmap" from the generic syscon-poweroff & syscon-reboot drivers, which both use "regmap" as a property name.

Thanks,
Paul

Quoted 8 lines
Quoted 7 lines
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +6 -0
+	};
+
+	uart0: uart@17ffe000 {
+		/* ... */
+		clocks = <&clk_boston BOSTON_CLK_SYS>;
+	};
maintainer
#36 lore raw

Re: [PATCH 24/26] dt-bindings: Document img,boston-clock binding

Quoted 39 lines · Paul Burton
Quoted 24 lines · Stephen Boyd
Quoted 23 lines · Paul Burton
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +17 -0
new file mode 100644
index 0000000..c01ea60
@@ -0,0 +1,27 @@
+Binding for Imagination Technologies MIPS Boston clock sources.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : Should be "img,boston-clock".
+- #clock-cells : Should be set to 1.
+  Values available for clock consumers can be found in the header file:
+    <dt-bindings/clock/boston-clock.h>
+- regmap : Phandle to the Boston platform register system controller.
+  This should contain a phandle to the system controller node covering the
+  platform registers provided by the Boston board.
+
+Example:
+
Quoted 8 lines

Documentation/devicetree/bindings/clock/img,boston-clock.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +4 -0
+	clk_boston: clock {
+		compatible = "img,boston-clock";
+		#clock-cells = <1>;
+		regmap = <&plat_regs>;

Isn't syscon more standard than regmap as the property name? Is there a binding for the plat_regs device? Is there any reason the clks can't be populated in that syscon driver?

Hi Stephen,

The plat_regs device doesn't have a custom driver, it simply makes use of the generic "syscon" driver which can provide a regmap.

Quoted 12 lines

It would be possible to register the clocks from a register for the plat_regs device, but I don't think it would make much sense. The platform registers in question are essentially just a convenient place where various bits of information about the system are exposed, including the clock frequencies but also other bits & pieces like connectivity of PCIe controllers or I/O coherence units, the RTL revision of the CPU or the wrapper RTL that runs on this FPGA-based board, a register that allows for resetting the board, etc. It's not a single piece of hardware, more a dumping ground for miscellanea. So in my opinion using the syscon approach works best here, and drivers for well defined pieces of hardware or functionality can reference that syscon to retrieve the regmap.

That is all quite common for any SoC. Whether it's 2 nodes or 2 drivers are independent questions. You can easily have 1 node and 2 drivers. The decision factor is really how many registers we're dealing with. We don't want to end up with a node per register or register field. That's too fine grained.

Quoted 5 lines

As for whether "syscon" is a more standard property name than "regmap", both seem to be used based on a grep of Documentation/devicetree/bindings/. I believe I picked up use of "regmap" from the generic syscon-poweroff & syscon-reboot drivers, which both use "regmap" as a property name.

syscon is much more common.

Avoid the phandle altogether and make this a child node.

Rob

#37 lore raw

Re: [PATCH 24/26] dt-bindings: Document img,boston-clock binding

Quoted 53 lines · Rob Herring
Quoted 39 lines · Paul Burton
Quoted 24 lines · Stephen Boyd
Quoted 23 lines · Paul Burton
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +17 -0
new file mode 100644
index 0000000..c01ea60
@@ -0,0 +1,27 @@
+Binding for Imagination Technologies MIPS Boston clock sources.
+
+This binding uses the common clock binding[1].
+
+[1] Documentation/devicetree/bindings/clock/clock-bindings.txt
+
+Required properties:
+- compatible : Should be "img,boston-clock".
+- #clock-cells : Should be set to 1.
+  Values available for clock consumers can be found in the header file:
+    <dt-bindings/clock/boston-clock.h>
+- regmap : Phandle to the Boston platform register system controller.
+  This should contain a phandle to the system controller node covering the
+  platform registers provided by the Boston board.
+
+Example:
+
Quoted 8 lines

Documentation/devicetree/bindings/clock/img,boston-clock.txt line 21

Quoted 4 lines
Documentation/devicetree/bindings/clock/img,boston-clock.txt new file +4 -0
+	clk_boston: clock {
+		compatible = "img,boston-clock";
+		#clock-cells = <1>;
+		regmap = <&plat_regs>;

Isn't syscon more standard than regmap as the property name? Is there a binding for the plat_regs device? Is there any reason the clks can't be populated in that syscon driver?

Hi Stephen,

The plat_regs device doesn't have a custom driver, it simply makes use of the generic "syscon" driver which can provide a regmap.

Quoted 12 lines

It would be possible to register the clocks from a register for the plat_regs device, but I don't think it would make much sense. The platform registers in question are essentially just a convenient place where various bits of information about the system are exposed, including the clock frequencies but also other bits & pieces like connectivity of PCIe controllers or I/O coherence units, the RTL revision of the CPU or the wrapper RTL that runs on this FPGA-based board, a register that allows for resetting the board, etc. It's not a single piece of hardware, more a dumping ground for miscellanea. So in my opinion using the syscon approach works best here, and drivers for well defined pieces of hardware or functionality can reference that syscon to retrieve the regmap.

Quoted 5 lines

That is all quite common for any SoC. Whether it's 2 nodes or 2 drivers are independent questions. You can easily have 1 node and 2 drivers. The decision factor is really how many registers we're dealing with. We don't want to end up with a node per register or register field. That's too fine grained.

Absolutely, I don't think we disagree there.

Quoted 9 lines
Quoted 5 lines

As for whether "syscon" is a more standard property name than "regmap", both seem to be used based on a grep of Documentation/devicetree/bindings/. I believe I picked up use of "regmap" from the generic syscon-poweroff & syscon-reboot drivers, which both use "regmap" as a property name.

syscon is much more common.

Avoid the phandle altogether and make this a child node.

I could do that, but it would feel rather odd to describe the clock hardware as a child of a bunch of miscellaneous registers that happen to expose some information about those clocks. Is that really what you prefer? I think as-is the DT is a better description of the hardware.

Thanks,
Paul

Quoted 3 lines

Rob

#38 lore raw

PATCH 25/26 clk: boston: Add a driver for MIPS Boston board clocks

In reply to Paul Burton

Add a driver for the clocks provided by the MIPS Boston board from Imagination Technologies. 2 clocks are provided - the system clock & the CPU clock - and each is a simple fixed rate clock whose frequency can be determined by reading a register provided by the board.

---

 drivers/clk/Kconfig      |   9 ++++
 drivers/clk/Makefile     |   1 +
 drivers/clk/clk-boston.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 141 insertions(+)
 create mode 100644 drivers/clk/clk-boston.c
drivers/clk/Kconfig +9 -0
index e2d9bd7..2680343 100644
@@ -208,6 +208,15 @@ config COMMON_CLK_OXNAS
 	---help---
 	  Support for the OXNAS SoC Family clocks.
 
+config COMMON_CLK_BOSTON
+	bool "Clock driver for MIPS Boston boards"
+	select MFD_SYSCON
+	---help---
+	  Enable this to support the system & CPU clocks on the MIPS Boston
+	  development board from Imagination Technologies. These are simple
+	  fixed rate clocks whose rate is determined by reading a platform
+	  provided register.
+
 source "drivers/clk/bcm/Kconfig"
 source "drivers/clk/hisilicon/Kconfig"
 source "drivers/clk/meson/Kconfig"
drivers/clk/Makefile +1 -0
index 3b6f9cf..3b78e515 100644
@@ -20,6 +20,7 @@ endif
 obj-$(CONFIG_MACH_ASM9260)		+= clk-asm9260.o
 obj-$(CONFIG_COMMON_CLK_AXI_CLKGEN)	+= clk-axi-clkgen.o
 obj-$(CONFIG_ARCH_AXXIA)		+= clk-axm5516.o
+obj-$(CONFIG_COMMON_CLK_BOSTON)		+= clk-boston.o
 obj-$(CONFIG_COMMON_CLK_CDCE706)	+= clk-cdce706.o
 obj-$(CONFIG_COMMON_CLK_CDCE925)	+= clk-cdce925.o
 obj-$(CONFIG_ARCH_CLPS711X)		+= clk-clps711x.o
drivers/clk/clk-boston.c new file +131 -0

131 lines not on this page · raw message

Signature · 1 line
2.9.3
#39 lore raw

Re: [PATCH 25/26] clk: boston: Add a driver for MIPS Boston board clocks

Quoted 4 lines · Paul Burton
 drivers/clk/Kconfig      |   9 ++++
 drivers/clk/Makefile     |   1 +
 drivers/clk/clk-boston.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++

Maybe a vendor subdirectory is appropriate? imgtec?

drivers/clk/clk-boston.c line 34

Quoted 8 lines
drivers/clk/clk-boston.c new file +8 -0
+
+struct clk_boston_state {
+	struct clk *clk[BOSTON_CLK_COUNT];
+	struct clk_boston clk_boston[BOSTON_CLK_COUNT];
+	struct clk_onecell_data onecell_data[BOSTON_CLK_COUNT];
+};
+
+static const char *clk_names[BOSTON_CLK_COUNT] = {

const char * const?

Quoted 6 lines
drivers/clk/clk-boston.c new file +6 -0
+	[BOSTON_CLK_SYS] = "sys",
+	[BOSTON_CLK_CPU] = "cpu",
+};
+
+#define BOSTON_PLAT_MMCMDIV		0x30
+# define BOSTON_PLAT_MMCMDIV_CLK0DIV	(0xff << 0)

drivers/clk/clk-boston.c line 50

Quoted 10 lines
drivers/clk/clk-boston.c new file +10 -0
+# define BOSTON_PLAT_MMCMDIV_INPUT	(0xff << 8)
+# define BOSTON_PLAT_MMCMDIV_MUL	(0xff << 16)
+# define BOSTON_PLAT_MMCMDIV_CLK1DIV	(0xff << 24)
+
+static struct clk_boston *to_clk_boston(struct clk_hw *hw)
+{
+	return container_of(hw, struct clk_boston, hw);
+}
+
+static uint32_t ext_field(uint32_t val, uint32_t mask)

Please use u32 instead of uint32_t in drivers.

drivers/clk/clk-boston.c line 60

Quoted 10 lines
drivers/clk/clk-boston.c new file +10 -0
+{
+	return (val & mask) >> (ffs(mask) - 1);
+}
+
+static unsigned long clk_boston_recalc_rate(struct clk_hw *hw,
+					    unsigned long parent_rate)
+{
+	struct clk_boston *state = to_clk_boston(hw);
+	uint32_t in_rate, mul, div;
+	uint mmcmdiv;

unsigned int?

drivers/clk/clk-boston.c line 67

Quoted 7 lines
drivers/clk/clk-boston.c new file +7 -0
+	int err;
+
+	err = regmap_read(state->regmap, BOSTON_PLAT_MMCMDIV, &mmcmdiv);
+	if (err)
+		return 0;
+
+	in_rate = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_INPUT);

This sounds like a parent rate? Should there be another clk created for that so that parent_rate in this function is useful?

drivers/clk/clk-boston.c line 75

Quoted 8 lines
drivers/clk/clk-boston.c new file +8 -0
+	mul = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_MUL);
+
+	switch (state->id) {
+	case BOSTON_CLK_SYS:
+		div = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_CLK0DIV);
+		break;
+	case BOSTON_CLK_CPU:
+		div = ext_field(mmcmdiv, BOSTON_PLAT_MMCMDIV_CLK1DIV);

Why not put the CLK0DIV or CLK1DIV offset in state->id instead? That way this function just read in_rate, mul, and div and then does the math?

drivers/clk/clk-boston.c line 81

Quoted 6 lines
drivers/clk/clk-boston.c new file +6 -0
+		break;
+	default:
+		return 0;
+	}
+
+	return (in_rate * mul * 1000000) / div;

Is this always fixed at boot? It may be easier to populate fixed rate clks during probe with the rate calculated there. Then there aren't any clk_ops to implement.

Quoted 16 lines
drivers/clk/clk-boston.c new file +16 -0
+}
+
+static const struct clk_ops clk_boston_ops = {
+	.recalc_rate = clk_boston_recalc_rate,
+};
+
+static void __init clk_boston_setup(struct device_node *np)
+{
+	struct clk_boston_state *state;
+	struct clk_init_data init;
+	struct regmap *regmap;
+	int i, err;
+
+	state = kzalloc(sizeof(*state), GFP_KERNEL);
+	if (!state)
+		return;

drivers/clk/clk-boston.c line 107

Quoted 10 lines
drivers/clk/clk-boston.c new file +10 -0
+
+	regmap = syscon_regmap_lookup_by_phandle(np, "regmap");
+	if (IS_ERR(regmap)) {
+		pr_err("failed to find regmap\n");
+		return;
+	}
+
+	for (i = 0; i < BOSTON_CLK_COUNT; i++) {
+		memset(&init, 0, sizeof(init));
+		init.flags = CLK_IS_BASIC;

Please drop this flag unless you really need it for something. As far as I know CLK_IS_BASIC is just for OMAP code.

drivers/clk/clk-boston.c line 115

Quoted 8 lines
drivers/clk/clk-boston.c new file +8 -0
+		init.name = clk_names[i];
+		init.ops = &clk_boston_ops;
+
+		state->clk_boston[i].hw.init = &init;
+		state->clk_boston[i].id = i;
+		state->clk_boston[i].regmap = regmap;
+
+		state->clk[i] = clk_register(NULL, &state->clk_boston[i].hw);

Please use clk_hw_register() instead.

drivers/clk/clk-boston.c line 127

Quoted 12 lines
drivers/clk/clk-boston.c new file +12 -0
+		if (IS_ERR(state->clk[i])) {
+			pr_err("failed to register clock: %ld\n",
+			       PTR_ERR(state->clk[i]));
+			return;
+		}
+	}
+
+	state->onecell_data->clks = state->clk;
+	state->onecell_data->clk_num = BOSTON_CLK_COUNT;
+
+	err = of_clk_add_provider(np, of_clk_src_onecell_get,
+				  state->onecell_data);

Please use of_clk_add_hw_provider() instead.

drivers/clk/clk-boston.c line 131

Quoted 4 lines
drivers/clk/clk-boston.c new file +4 -0
+	if (err)
+		pr_err("failed to add DT provider: %d\n", err);
+}
+CLK_OF_DECLARE(clk_boston, "img,boston-clock", clk_boston_setup);

Please make this into a platform driver.

Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
#40 lore raw

Re: [PATCH 25/26] clk: boston: Add a driver for MIPS Boston board clocks

Quoted 6 lines · Stephen Boyd

drivers/clk/clk-boston.c line 131

Quoted 4 lines
drivers/clk/clk-boston.c new file +4 -0
+	if (err)
+		pr_err("failed to add DT provider: %d\n", err);
+}
+CLK_OF_DECLARE(clk_boston, "img,boston-clock", clk_boston_setup);

Please make this into a platform driver.

Hi Stephen,

The problem with this would be that we need to obtain the CPU clock rate fairly early during boot in order to set up the clocksource & delay loop etc. Using CLK_OF_DECLARE allows for that but if this were a platform driver my understanding is that the clocks wouldn't become available until some point later in boot. If I'm wrong & there's a way to avoid that please let me know.

Also: why? If CLK_OF_DECLARE isn't liked, shouldn't that be documented somewhere (ideally next to the declaration of CLK_OF_DECLARE in include/linux/clk-provider.h)?

Thanks,
Paul

#41 lore raw

PATCH 26/26 MIPS: generic: Support MIPS Boston development boards

In reply to Paul Burton

Add support for the MIPS Boston development board to generic kernels, which essentially amounts to:

- Adding the device tree source for the MIPS Boston board.

- Adding a Kconfig fragment which enables the appropriate drivers for the MIPS Boston board.

With these changes in place generic kernels will support the board by default, and kernels with only the drivers needed for Boston enabled can be configured by setting BOARDS=boston during configuration. For example:

  $ make ARCH=mips 64r6el_defconfig BOARDS=boston

---

 arch/mips/boot/dts/Makefile                   |   1 +
 arch/mips/boot/dts/img/Makefile               |   7 +
 arch/mips/boot/dts/img/boston.dts             | 230 ++++++++++++++++++++++++++
 arch/mips/configs/generic/board-boston.config |  46 ++++++
 arch/mips/generic/Kconfig                     |   8 +
 arch/mips/generic/vmlinux.its.S               |  25 +++
 6 files changed, 317 insertions(+)
 create mode 100644 arch/mips/boot/dts/img/Makefile
 create mode 100644 arch/mips/boot/dts/img/boston.dts
 create mode 100644 arch/mips/configs/generic/board-boston.config
arch/mips/boot/dts/Makefile +1 -0
index fc7a0a9..b9db492 100644
@@ -1,5 +1,6 @@
 dts-dirs	+= brcm
 dts-dirs	+= cavium-octeon
+dts-dirs	+= img
 dts-dirs	+= ingenic
 dts-dirs	+= lantiq
 dts-dirs	+= mti
arch/mips/boot/dts/img/Makefile new file +7 -0
new file mode 100644
index 0000000..ae119d3
@@ -0,0 +1,7 @@
+dtb-$(CONFIG_FIT_IMAGE_FDT_BOSTON)	+= boston.dtb
+
+# Force kbuild to make empty built-in.o if necessary
+obj-					+= dummy.o
+
+always					:= $(dtb-y)
+clean-files				:= *.dtb *.dtb.S
arch/mips/boot/dts/img/boston.dts new file +230 -0

230 lines not on this page · raw message

arch/mips/configs/generic/board-boston.config new file +46 -0

46 lines not on this page · raw message

arch/mips/generic/Kconfig +8 -0
index a606b3f..16eb939 100644
@@ -16,4 +16,12 @@ config LEGACY_BOARD_SEAD3
 	  Enable this to include support for booting on MIPS SEAD-3 FPGA-based
 	  development boards, which boot using a legacy boot protocol.
 
+config FIT_IMAGE_FDT_BOSTON
+	bool "Include FDT for MIPS Boston boards"
+	help
+	  Enable this to include the FDT for the MIPS Boston development board
+	  from Imagination Technologies in the FIT kernel image. You should
+	  enable this if you wish to boot on a MIPS Boston board, as it is
+	  expected by the bootloader.
+
 endif
arch/mips/generic/vmlinux.its.S +25 -0
index f67fbf1..3390e2f 100644
@@ -29,3 +29,28 @@
 		};
 	};
 };
+
+#ifdef CONFIG_FIT_IMAGE_FDT_BOSTON
+/ {
+	images {
+		fdt@boston {
+			description = "img,boston Device Tree";
+			data = /incbin/("boot/dts/img/boston.dtb");
+			type = "flat_dt";
+			arch = "mips";
+			compression = "none";
+			hash@0 {
+				algo = "sha1";
+			};
+		};
+	};
+
+	configurations {
+		conf@boston {
+			description = "Boston Linux kernel";
+			kernel = "kernel@0";
+			fdt = "fdt@boston";
+		};
+	};
+};
+#endif /* CONFIG_FIT_IMAGE_FDT_BOSTON */
Signature · 1 line
2.9.3