linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/19] MIPS: SEAD3 device tree conversion
@ 2016-08-26 14:17 Paul Burton
  2016-08-26 14:17 ` [PATCH v2 01/19] MIPS: SEAD3: Split obj-y entries across lines Paul Burton
                   ` (18 more replies)
  0 siblings, 19 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Ondrej Zary, linux-fbdev, Alan Stern, Kefeng Wang,
	Jacek Anaszewski, Guenter Roeck,
	Jean-Christophe Plagniol-Villard, Rob Herring,
	Geert Uytterhoeven, Geert Uytterhoeven, linux-leds,
	Richard Purdie, Maciej W. Rozycki, Tomi Valkeinen,
	Greg Kroah-Hartman, Andrew Morton, devicetree, Rob Herring,
	Ezequiel Garcia, Simon Horman, Matt Redfearn,
	Miguel Ojeda Sandonis, Robert Jarzmik, linux-usb, Arnd Bergmann,
	linux-kernel, David S. Miller, Mark Rutland,
	Mauro Carvalho Chehab

Although the SEAD3 board has already made some minimal use of device
tree, until now most peripherals have been left probed by platform code.

This series converts all SEAD3 peripherals to instead be probed from
device tree. The amount of platform code is significantly reduced
leaving SEAD3 primed & ready for a wider task of genericising the
kernel.

Applies atop v4.8-rc3.

Paul Burton (19):
  MIPS: SEAD3: Split obj-y entries across lines
  MIPS: SEAD3: Probe interrupt controllers using DT
  MIPS: SEAD3: Probe UARTs using DT
  MIPS: SEAD3: Use generic ns16550a earlycon support
  MIPS: SEAD3: Probe ethernet controller using DT
  MIPS: SEAD3: Probe EHCI controller using DT
  usb: host: ehci-sead3: Remove SEAD-3 EHCI code
  SEAD3: Probe parallel flash via DT
  MIPS: SEAD3: Use register-bit-led driver via DT for LEDs
  leds: Remove SEAD3 driver
  MIPS: SEAD3: Reset via generic syscon-reboot driver & DT
  MIPS: SEAD3: Use generic restart-poweroff driver
  MIPS: SEAD3: Parse memsize in DT shim
  MIPS: SEAD3: Drop use of cobalt fbdev driver
  fbdev: cobalt_lcdfb: Drop SEAD3 support
  dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs
  auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays
  MIPS: SEAD3: Use img-ascii-lcd driver
  MIPS: SEAD3: Remove custom read_persistent_clock

 .../bindings/auxdisplay/img-ascii-lcd.txt          |  17 +
 MAINTAINERS                                        |   6 +
 arch/mips/Kconfig                                  |   1 -
 arch/mips/boot/dts/mti/sead3.dts                   | 237 +++++++++++
 arch/mips/configs/sead3_defconfig                  |   8 +
 arch/mips/include/asm/mach-sead3/sead3-dtshim.h    |  29 ++
 arch/mips/include/asm/mips-boards/sead3int.h       |  32 --
 arch/mips/mti-sead3/Makefile                       |  10 +-
 arch/mips/mti-sead3/sead3-console.c                |  46 ---
 arch/mips/mti-sead3/sead3-display.c                |  77 ----
 arch/mips/mti-sead3/sead3-dtshim.c                 | 292 ++++++++++++++
 arch/mips/mti-sead3/sead3-init.c                   |  52 ---
 arch/mips/mti-sead3/sead3-int.c                    |  27 +-
 arch/mips/mti-sead3/sead3-lcd.c                    |  43 --
 arch/mips/mti-sead3/sead3-platform.c               | 223 -----------
 arch/mips/mti-sead3/sead3-reset.c                  |  40 --
 arch/mips/mti-sead3/sead3-setup.c                  |  77 +---
 arch/mips/mti-sead3/sead3-time.c                   |   8 -
 drivers/auxdisplay/Kconfig                         |   9 +
 drivers/auxdisplay/Makefile                        |   1 +
 drivers/auxdisplay/img-ascii-lcd.c                 | 443 +++++++++++++++++++++
 drivers/leds/Kconfig                               |  10 -
 drivers/leds/Makefile                              |   1 -
 drivers/leds/leds-sead3.c                          |  78 ----
 drivers/usb/host/ehci-hcd.c                        |   5 -
 drivers/usb/host/ehci-sead3.c                      | 185 ---------
 drivers/video/fbdev/Kconfig                        |   2 +-
 drivers/video/fbdev/cobalt_lcdfb.c                 |  42 --
 28 files changed, 1056 insertions(+), 945 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt
 create mode 100644 arch/mips/include/asm/mach-sead3/sead3-dtshim.h
 delete mode 100644 arch/mips/include/asm/mips-boards/sead3int.h
 delete mode 100644 arch/mips/mti-sead3/sead3-console.c
 delete mode 100644 arch/mips/mti-sead3/sead3-display.c
 create mode 100644 arch/mips/mti-sead3/sead3-dtshim.c
 delete mode 100644 arch/mips/mti-sead3/sead3-lcd.c
 delete mode 100644 arch/mips/mti-sead3/sead3-platform.c
 delete mode 100644 arch/mips/mti-sead3/sead3-reset.c
 create mode 100644 drivers/auxdisplay/img-ascii-lcd.c
 delete mode 100644 drivers/leds/leds-sead3.c
 delete mode 100644 drivers/usb/host/ehci-sead3.c

-- 
2.9.3

^ permalink raw reply	[flat|nested] 25+ messages in thread

* [PATCH v2 01/19] MIPS: SEAD3: Split obj-y entries across lines
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 02/19] MIPS: SEAD3: Probe interrupt controllers using DT Paul Burton
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, Jacek Anaszewski, linux-kernel

Split the obj-y entries for SEAD3 onto a line each, so that they're more
independent & can be modified more clearly by later commits.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/mti-sead3/Makefile | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index 7a584e0..8b03cfb 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -8,8 +8,13 @@
 # Copyright (C) 2012 MIPS Technoligies, Inc.  All rights reserved.
 # Steven J. Hill <sjhill@mips.com>
 #
-obj-y				:= sead3-lcd.o sead3-display.o sead3-init.o \
-				   sead3-int.o sead3-platform.o sead3-reset.o \
-				   sead3-setup.o sead3-time.o
+obj-y := sead3-lcd.o
+obj-y += sead3-display.o
+obj-y += sead3-init.o
+obj-y += sead3-int.o
+obj-y += sead3-platform.o
+obj-y += sead3-reset.o
+obj-y += sead3-setup.o
+obj-y += sead3-time.o
 
 obj-$(CONFIG_EARLY_PRINTK)	+= sead3-console.o
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 02/19] MIPS: SEAD3: Probe interrupt controllers using DT
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
  2016-08-26 14:17 ` [PATCH v2 01/19] MIPS: SEAD3: Split obj-y entries across lines Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 03/19] MIPS: SEAD3: Probe UARTs " Paul Burton
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Matt Redfearn, devicetree, Kefeng Wang,
	Jacek Anaszewski, linux-kernel, Rob Herring, Mark Rutland

Probe the CPU interrupt controller & optional Global Interrupt
Controller (GIC) using devicetree rather than platform code. Because the
bootloader on SEAD3 does not provide a device tree to the kernel & the
device tree is always built in, we patch out the GIC node during boot if
we detect that a GIC is not present in the system.

The appropriate IRQ domain is discovered by platform code setting up
device IRQ numbers temporarily. It will be removed by further patches
which move the devices towards being probed via device tree.

No behavioural change is intended by this patch.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- #include <linux/errno.h>, thanks kbuild test robot!
- Add missing semicolon, thanks kbuild test robot!

 arch/mips/boot/dts/mti/sead3.dts                | 31 +++++++++
 arch/mips/include/asm/mach-sead3/sead3-dtshim.h | 29 ++++++++
 arch/mips/include/asm/mips-boards/sead3int.h    |  5 --
 arch/mips/mti-sead3/Makefile                    |  1 +
 arch/mips/mti-sead3/sead3-dtshim.c              | 92 +++++++++++++++++++++++++
 arch/mips/mti-sead3/sead3-int.c                 | 27 ++------
 arch/mips/mti-sead3/sead3-platform.c            | 43 +++++++++---
 arch/mips/mti-sead3/sead3-setup.c               | 13 ++--
 8 files changed, 197 insertions(+), 44 deletions(-)
 create mode 100644 arch/mips/include/asm/mach-sead3/sead3-dtshim.h
 create mode 100644 arch/mips/mti-sead3/sead3-dtshim.c

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index e4b317d..051b3a9 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -4,10 +4,13 @@
 /memreserve/ 0x00001000 0x000ef000;	// ROM data
 /memreserve/ 0x000f0000 0x004cc000;	// reserved
 
+#include <dt-bindings/interrupt-controller/mips-gic.h>
+
 / {
 	#address-cells = <1>;
 	#size-cells = <1>;
 	compatible = "mti,sead-3";
+	interrupt-parent = <&gic>;
 
 	cpus {
 		cpu@0 {
@@ -19,4 +22,32 @@
 		device_type = "memory";
 		reg = <0x0 0x08000000>;
 	};
+
+	cpu_intc: interrupt-controller {
+		compatible = "mti,cpu-interrupt-controller";
+
+		interrupt-controller;
+		#interrupt-cells = <1>;
+	};
+
+	gic: interrupt-controller@1b1c0000 {
+		compatible = "mti,gic";
+		reg = <0x1b1c0000 0x20000>;
+
+		interrupt-controller;
+		#interrupt-cells = <3>;
+
+		/*
+		 * Declare the interrupt-parent even though the mti,gic
+		 * binding doesn't require it, such that the kernel can
+		 * figure out that cpu_intc is the root interrupt
+		 * controller & should be probed first.
+		 */
+		interrupt-parent = <&cpu_intc>;
+
+		timer {
+			compatible = "mti,gic-timer";
+			interrupts = <GIC_LOCAL 1 IRQ_TYPE_NONE>;
+		};
+	};
 };
diff --git a/arch/mips/include/asm/mach-sead3/sead3-dtshim.h b/arch/mips/include/asm/mach-sead3/sead3-dtshim.h
new file mode 100644
index 0000000..f5d7d9c
--- /dev/null
+++ b/arch/mips/include/asm/mach-sead3/sead3-dtshim.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * 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__ */
diff --git a/arch/mips/include/asm/mips-boards/sead3int.h b/arch/mips/include/asm/mips-boards/sead3int.h
index 8932c7d..bd85da3 100644
--- a/arch/mips/include/asm/mips-boards/sead3int.h
+++ b/arch/mips/include/asm/mips-boards/sead3int.h
@@ -12,12 +12,7 @@
 
 #include <linux/irqchip/mips-gic.h>
 
-/* SEAD-3 GIC address space definitions. */
-#define GIC_BASE_ADDR		0x1b1c0000
-#define GIC_ADDRSPACE_SZ	(128 * 1024)
-
 /* CPU interrupt offsets */
-#define CPU_INT_GIC		2
 #define CPU_INT_EHCI		2
 #define CPU_INT_UART0		4
 #define CPU_INT_UART1		4
diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index 8b03cfb..aad67aa 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -10,6 +10,7 @@
 #
 obj-y := sead3-lcd.o
 obj-y += sead3-display.o
+obj-y += sead3-dtshim.o
 obj-y += sead3-init.o
 obj-y += sead3-int.o
 obj-y += sead3-platform.o
diff --git a/arch/mips/mti-sead3/sead3-dtshim.c b/arch/mips/mti-sead3/sead3-dtshim.c
new file mode 100644
index 0000000..3283a7e
--- /dev/null
+++ b/arch/mips/mti-sead3/sead3-dtshim.c
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * 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.
+ */
+
+#define pr_fmt(fmt) "sead3-dtshim: " fmt
+
+#include <linux/errno.h>
+#include <linux/libfdt.h>
+#include <linux/printk.h>
+
+#include <asm/io.h>
+
+#define SEAD_CONFIG			CKSEG1ADDR(0x1b100110)
+#define SEAD_CONFIG_GIC_PRESENT		BIT(1)
+
+static unsigned char fdt_buf[16 << 10] __initdata;
+
+static int remove_gic(void *fdt)
+{
+	int gic_off, cpu_off, err;
+	uint32_t cfg, cpu_phandle;
+
+	/* leave the GIC node intact if a GIC is present */
+	cfg = __raw_readl((uint32_t *)SEAD_CONFIG);
+	if (cfg & SEAD_CONFIG_GIC_PRESENT)
+		return 0;
+
+	gic_off = fdt_node_offset_by_compatible(fdt, -1, "mti,gic");
+	if (gic_off < 0) {
+		pr_err("unable to find DT GIC node: %d\n", gic_off);
+		return gic_off;
+	}
+
+	err = fdt_nop_node(fdt, gic_off);
+	if (err) {
+		pr_err("unable to nop GIC node\n");
+		return err;
+	}
+
+	cpu_off = fdt_node_offset_by_compatible(fdt, -1,
+			"mti,cpu-interrupt-controller");
+	if (cpu_off < 0) {
+		pr_err("unable to find CPU intc node: %d\n", cpu_off);
+		return cpu_off;
+	}
+
+	cpu_phandle = fdt_get_phandle(fdt, cpu_off);
+	if (!cpu_phandle) {
+		pr_err("unable to get CPU intc phandle\n");
+		return -EINVAL;
+	}
+
+	err = fdt_setprop_u32(fdt, 0, "interrupt-parent", cpu_phandle);
+	if (err) {
+		pr_err("unable to set root interrupt-parent: %d\n", err);
+		return err;
+	}
+
+	return 0;
+}
+
+void __init *sead3_dt_shim(void *fdt)
+{
+	int err;
+
+	if (fdt_check_header(fdt))
+		panic("Corrupt DT");
+
+	/* if this isn't SEAD3, leave the DT alone */
+	if (fdt_node_check_compatible(fdt, 0, "mti,sead-3"))
+		return fdt;
+
+	err = fdt_open_into(fdt, fdt_buf, sizeof(fdt_buf));
+	if (err)
+		panic("Unable to open FDT: %d", err);
+
+	err = remove_gic(fdt_buf);
+	if (err)
+		panic("Unable to patch FDT: %d", err);
+
+	err = fdt_pack(fdt_buf);
+	if (err)
+		panic("Unable to pack FDT: %d\n", err);
+
+	return fdt_buf;
+}
diff --git a/arch/mips/mti-sead3/sead3-int.c b/arch/mips/mti-sead3/sead3-int.c
index e31e17f..2e6b732 100644
--- a/arch/mips/mti-sead3/sead3-int.c
+++ b/arch/mips/mti-sead3/sead3-int.c
@@ -6,37 +6,18 @@
  * Copyright (C) 2012 MIPS Technologies, Inc.  All rights reserved.
  */
 #include <linux/init.h>
-#include <linux/irq.h>
+#include <linux/irqchip.h>
 #include <linux/irqchip/mips-gic.h>
-#include <linux/io.h>
 
-#include <asm/irq_cpu.h>
-#include <asm/setup.h>
-
-#include <asm/mips-boards/sead3int.h>
-
-#define SEAD_CONFIG_GIC_PRESENT_SHF	1
-#define SEAD_CONFIG_GIC_PRESENT_MSK	(1 << SEAD_CONFIG_GIC_PRESENT_SHF)
-#define SEAD_CONFIG_BASE		0x1b100110
-#define SEAD_CONFIG_SIZE		4
-
-static void __iomem *sead3_config_reg;
+#include <asm/cpu-info.h>
+#include <asm/irq.h>
 
 void __init arch_init_irq(void)
 {
-	if (!cpu_has_veic)
-		mips_cpu_irq_init();
+	irqchip_init();
 
-	sead3_config_reg = ioremap_nocache(SEAD_CONFIG_BASE, SEAD_CONFIG_SIZE);
-	gic_present = (__raw_readl(sead3_config_reg) &
-		       SEAD_CONFIG_GIC_PRESENT_MSK) >>
-		SEAD_CONFIG_GIC_PRESENT_SHF;
 	pr_info("GIC: %spresent\n", (gic_present) ? "" : "not ");
 	pr_info("EIC: %s\n",
 		(current_cpu_data.options & MIPS_CPU_VEIC) ?  "on" : "off");
-
-	if (gic_present)
-		gic_init(GIC_BASE_ADDR, GIC_ADDRSPACE_SZ, CPU_INT_GIC,
-			 MIPS_GIC_IRQ_BASE);
 }
 
diff --git a/arch/mips/mti-sead3/sead3-platform.c b/arch/mips/mti-sead3/sead3-platform.c
index 73b73ef..d6be029 100644
--- a/arch/mips/mti-sead3/sead3-platform.c
+++ b/arch/mips/mti-sead3/sead3-platform.c
@@ -9,8 +9,10 @@
 #include <linux/init.h>
 #include <linux/irq.h>
 #include <linux/irqchip/mips-gic.h>
+#include <linux/irqdomain.h>
 #include <linux/leds.h>
 #include <linux/mtd/physmap.h>
+#include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/serial_8250.h>
 #include <linux/smsc911x.h>
@@ -204,16 +206,41 @@ static struct platform_device *sead3_platform_devices[] __initdata = {
 
 static int __init sead3_platforms_device_init(void)
 {
+	const char *intc_compat;
+	struct device_node *node;
+	struct irq_domain *irqd;
+
+	if (gic_present)
+		intc_compat = "mti,gic";
+	else
+		intc_compat = "mti,cpu-interrupt-controller";
+
+	node = of_find_compatible_node(NULL, NULL, intc_compat);
+	if (!node) {
+		pr_err("unable to find interrupt controller DT node\n");
+		return -ENODEV;
+	}
+
+	irqd = irq_find_host(node);
+	if (!irqd) {
+		pr_err("unable to find interrupt controller IRQ domain\n");
+		return -ENODEV;
+	}
+
 	if (gic_present) {
-		uart8250_data[0].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART0;
-		uart8250_data[1].irq = MIPS_GIC_IRQ_BASE + GIC_INT_UART1;
-		ehci_resources[1].start = MIPS_GIC_IRQ_BASE + GIC_INT_EHCI;
-		sead3_net_resources[1].start = MIPS_GIC_IRQ_BASE + GIC_INT_NET;
+		uart8250_data[0].irq = irq_create_mapping(irqd, GIC_INT_UART0);
+		uart8250_data[1].irq = irq_create_mapping(irqd, GIC_INT_UART1);
+		ehci_resources[1].start =
+			irq_create_mapping(irqd, GIC_INT_EHCI);
+		sead3_net_resources[1].start =
+			irq_create_mapping(irqd, GIC_INT_NET);
 	} else {
-		uart8250_data[0].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART0;
-		uart8250_data[1].irq = MIPS_CPU_IRQ_BASE + CPU_INT_UART1;
-		ehci_resources[1].start = MIPS_CPU_IRQ_BASE + CPU_INT_EHCI;
-		sead3_net_resources[1].start = MIPS_CPU_IRQ_BASE + CPU_INT_NET;
+		uart8250_data[0].irq = irq_create_mapping(irqd, CPU_INT_UART0);
+		uart8250_data[1].irq = irq_create_mapping(irqd, CPU_INT_UART1);
+		ehci_resources[1].start =
+			irq_create_mapping(irqd, CPU_INT_EHCI);
+		sead3_net_resources[1].start =
+			irq_create_mapping(irqd, CPU_INT_NET);
 	}
 
 	return platform_add_devices(sead3_platform_devices,
diff --git a/arch/mips/mti-sead3/sead3-setup.c b/arch/mips/mti-sead3/sead3-setup.c
index edfcaf0..c4fc0c6 100644
--- a/arch/mips/mti-sead3/sead3-setup.c
+++ b/arch/mips/mti-sead3/sead3-setup.c
@@ -13,6 +13,7 @@
 #include <asm/prom.h>
 #include <asm/fw/fw.h>
 
+#include <asm/mach-sead3/sead3-dtshim.h>
 #include <asm/mips-boards/generic.h>
 
 const char *get_system_type(void)
@@ -89,20 +90,16 @@ void __init *plat_get_fdt(void)
 
 void __init plat_mem_setup(void)
 {
+	void *fdt = plat_get_fdt();
+
 	/* allow command line/bootloader env to override memory size in DT */
 	parse_memsize_param();
 
-	/*
-	 * Load the builtin devicetree. This causes the chosen node to be
-	 * parsed resulting in our memory appearing
-	 */
-	__dt_setup_arch(__dtb_start);
+	fdt = sead3_dt_shim(fdt);
+	__dt_setup_arch(fdt);
 }
 
 void __init device_tree_init(void)
 {
-	if (!initial_boot_params)
-		return;
-
 	unflatten_and_copy_device_tree();
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 03/19] MIPS: SEAD3: Probe UARTs using DT
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
  2016-08-26 14:17 ` [PATCH v2 01/19] MIPS: SEAD3: Split obj-y entries across lines Paul Burton
  2016-08-26 14:17 ` [PATCH v2 02/19] MIPS: SEAD3: Probe interrupt controllers using DT Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 04/19] MIPS: SEAD3: Use generic ns16550a earlycon support Paul Burton
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, linux-kernel, Rob Herring, Mark Rutland

Probe the UARTs on SEAD3 boards using device tree rather than platform
code, in order to reduce the amount of the latter. This requires that
CONFIG_SERIAL_OF_PLATFORM be enabled, so enable it in sead3_defconfig.
The SEAD3 DT shim code is extended to read bootloader environment
variables to determine the appropriate UART & mode for kernel console
output & set the stdout-path property of the chosen node accordingly.

In contrast to the old platform code, which appears to have only ever
set "console=ttyS0,38400n8r" with the code in console_config never
having an effect, this will honor the "yamontty" environment variable to
select between the 2 UARTs on the board and then check the "modetty0" or
"modetty1" variable as appropriate to determine the UART configuration.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- #include <asm/fw/fw.h>, thanks kbuild test robot!

 arch/mips/boot/dts/mti/sead3.dts             |  37 ++++++++++
 arch/mips/configs/sead3_defconfig            |   2 +
 arch/mips/include/asm/mips-boards/sead3int.h |   4 -
 arch/mips/mti-sead3/sead3-dtshim.c           | 105 ++++++++++++++++++++++++++-
 arch/mips/mti-sead3/sead3-init.c             |  46 ------------
 arch/mips/mti-sead3/sead3-platform.c         |  30 --------
 6 files changed, 143 insertions(+), 81 deletions(-)

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 051b3a9..3f681c5 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -12,6 +12,15 @@
 	compatible = "mti,sead-3";
 	interrupt-parent = <&gic>;
 
+	chosen {
+		stdout-path = "uart1:115200";
+	};
+
+	aliases {
+		uart0 = &uart0;
+		uart1 = &uart1;
+	};
+
 	cpus {
 		cpu@0 {
 			compatible = "mti,mips14KEc", "mti,mips14Kc";
@@ -50,4 +59,32 @@
 			interrupts = <GIC_LOCAL 1 IRQ_TYPE_NONE>;
 		};
 	};
+
+	/* UART connected to FTDI & miniUSB socket */
+	uart0: uart@1f000900 {
+		compatible = "ns16550a";
+		reg = <0x1f000900 0x20>;
+		reg-io-width = <4>;
+		reg-shift = <2>;
+
+		clock-frequency = <14745600>;
+
+		interrupts = <3>; /* GIC 3 or CPU 4 */
+
+		no-loopback-test;
+	};
+
+	/* UART connected to RS232 socket */
+	uart1: uart@1f000800 {
+		compatible = "ns16550a";
+		reg = <0x1f000800 0x20>;
+		reg-io-width = <4>;
+		reg-shift = <2>;
+
+		clock-frequency = <14745600>;
+
+		interrupts = <2>; /* GIC 2 or CPU 4 */
+
+		no-loopback-test;
+	};
 };
diff --git a/arch/mips/configs/sead3_defconfig b/arch/mips/configs/sead3_defconfig
index dae9354..deb48fb 100644
--- a/arch/mips/configs/sead3_defconfig
+++ b/arch/mips/configs/sead3_defconfig
@@ -39,6 +39,7 @@ CONFIG_MTD_CFI_INTELEXT=y
 CONFIG_MTD_PHYSMAP=y
 CONFIG_MTD_UBI=y
 CONFIG_MTD_UBI_GLUEBI=y
+CONFIG_OF=y
 CONFIG_BLK_DEV_LOOP=y
 CONFIG_BLK_DEV_CRYPTOLOOP=m
 CONFIG_SCSI=y
@@ -70,6 +71,7 @@ CONFIG_SERIAL_8250=y
 CONFIG_SERIAL_8250_CONSOLE=y
 CONFIG_SERIAL_8250_NR_UARTS=2
 CONFIG_SERIAL_8250_RUNTIME_UARTS=2
+CONFIG_SERIAL_OF_PLATFORM=y
 # CONFIG_HW_RANDOM is not set
 CONFIG_I2C=y
 # CONFIG_I2C_COMPAT is not set
diff --git a/arch/mips/include/asm/mips-boards/sead3int.h b/arch/mips/include/asm/mips-boards/sead3int.h
index bd85da3..3a5e079 100644
--- a/arch/mips/include/asm/mips-boards/sead3int.h
+++ b/arch/mips/include/asm/mips-boards/sead3int.h
@@ -14,14 +14,10 @@
 
 /* CPU interrupt offsets */
 #define CPU_INT_EHCI		2
-#define CPU_INT_UART0		4
-#define CPU_INT_UART1		4
 #define CPU_INT_NET		6
 
 /* GIC interrupt offsets */
 #define GIC_INT_NET		GIC_SHARED_TO_HWIRQ(0)
-#define GIC_INT_UART1		GIC_SHARED_TO_HWIRQ(2)
-#define GIC_INT_UART0		GIC_SHARED_TO_HWIRQ(3)
 #define GIC_INT_EHCI		GIC_SHARED_TO_HWIRQ(5)
 
 #endif /* !(_MIPS_SEAD3INT_H) */
diff --git a/arch/mips/mti-sead3/sead3-dtshim.c b/arch/mips/mti-sead3/sead3-dtshim.c
index 3283a7e..b462f65 100644
--- a/arch/mips/mti-sead3/sead3-dtshim.c
+++ b/arch/mips/mti-sead3/sead3-dtshim.c
@@ -14,6 +14,7 @@
 #include <linux/libfdt.h>
 #include <linux/printk.h>
 
+#include <asm/fw/fw.h>
 #include <asm/io.h>
 
 #define SEAD_CONFIG			CKSEG1ADDR(0x1b100110)
@@ -23,7 +24,8 @@ static unsigned char fdt_buf[16 << 10] __initdata;
 
 static int remove_gic(void *fdt)
 {
-	int gic_off, cpu_off, err;
+	const unsigned int cpu_uart_int = 4;
+	int gic_off, cpu_off, uart_off, err;
 	uint32_t cfg, cpu_phandle;
 
 	/* leave the GIC node intact if a GIC is present */
@@ -62,6 +64,103 @@ static int remove_gic(void *fdt)
 		return err;
 	}
 
+	uart_off = fdt_node_offset_by_compatible(fdt, -1, "ns16550a");
+	while (uart_off >= 0) {
+		err = fdt_setprop_u32(fdt, uart_off, "interrupts",
+				      cpu_uart_int);
+		if (err) {
+			pr_err("unable to set UART interrupts property: %d\n",
+			       err);
+			return err;
+		}
+
+		uart_off = fdt_node_offset_by_compatible(fdt, uart_off,
+							 "ns16550a");
+	}
+	if (uart_off != -FDT_ERR_NOTFOUND) {
+		pr_err("error searching for UART DT node: %d\n", uart_off);
+		return uart_off;
+	}
+
+	return 0;
+}
+
+static int serial_config(void *fdt)
+{
+	const char *yamontty, *mode_var;
+	char mode_var_name[9], path[18], parity;
+	unsigned int uart, baud, stop_bits;
+	bool hw_flow;
+	int chosen_off, err;
+
+	yamontty = fw_getenv("yamontty");
+	if (!yamontty || !strcmp(yamontty, "tty0")) {
+		uart = 0;
+	} else if (!strcmp(yamontty, "tty1")) {
+		uart = 1;
+	} else {
+		pr_warn("yamontty environment variable '%s' invalid\n",
+			yamontty);
+		uart = 0;
+	}
+
+	baud = stop_bits = 0;
+	parity = 0;
+	hw_flow = false;
+
+	snprintf(mode_var_name, sizeof(mode_var_name), "modetty%u", uart);
+	mode_var = fw_getenv(mode_var_name);
+	if (mode_var) {
+		while (mode_var[0] >= '0' && mode_var[0] <= '9') {
+			baud *= 10;
+			baud += mode_var[0] - '0';
+			mode_var++;
+		}
+		if (mode_var[0] == ',')
+			mode_var++;
+		if (mode_var[0])
+			parity = mode_var[0];
+		if (mode_var[0] == ',')
+			mode_var++;
+		if (mode_var[0])
+			stop_bits = mode_var[0] - '0';
+		if (mode_var[0] == ',')
+			mode_var++;
+		if (!strcmp(mode_var, "hw"))
+			hw_flow = true;
+	}
+
+	if (!baud)
+		baud = 38400;
+
+	if (parity != 'e' && parity != 'n' && parity != 'o')
+		parity = 'n';
+
+	if (stop_bits != 7 && stop_bits != 8)
+		stop_bits = 8;
+
+	WARN_ON(snprintf(path, sizeof(path), "uart%u:%u%c%u%s",
+			 uart, baud, parity, stop_bits,
+			 hw_flow ? "r" : "") >= sizeof(path));
+
+	/* find or add chosen node */
+	chosen_off = fdt_path_offset(fdt, "/chosen");
+	if (chosen_off == -FDT_ERR_NOTFOUND)
+		chosen_off = fdt_path_offset(fdt, "/chosen@0");
+	if (chosen_off == -FDT_ERR_NOTFOUND)
+		chosen_off = fdt_add_subnode(fdt, 0, "chosen");
+	if (chosen_off < 0) {
+		pr_err("Unable to find or add DT chosen node: %d\n",
+		       chosen_off);
+		return chosen_off;
+	}
+
+	err = fdt_setprop_string(fdt, chosen_off, "stdout-path", path);
+	if (err) {
+		pr_err("Unable to set stdout-path property: %d\n", err);
+		return err;
+	}
+
 	return 0;
 }
 
@@ -84,6 +183,10 @@ void __init *sead3_dt_shim(void *fdt)
 	if (err)
 		panic("Unable to patch FDT: %d", err);
 
+	err = serial_config(fdt_buf);
+	if (err)
+		panic("Unable to patch FDT: %d", err);
+
 	err = fdt_pack(fdt_buf);
 	if (err)
 		panic("Unable to pack FDT: %d\n", err);
diff --git a/arch/mips/mti-sead3/sead3-init.c b/arch/mips/mti-sead3/sead3-init.c
index 3572ea3..e81f5b7 100644
--- a/arch/mips/mti-sead3/sead3-init.c
+++ b/arch/mips/mti-sead3/sead3-init.c
@@ -17,47 +17,6 @@
 extern char except_vec_nmi;
 extern char except_vec_ejtag_debug;
 
-#ifdef CONFIG_SERIAL_8250_CONSOLE
-static void __init console_config(void)
-{
-	char console_string[40];
-	int baud = 0;
-	char parity = '\0', bits = '\0', flow = '\0';
-	char *s;
-
-	if ((strstr(fw_getcmdline(), "console=")) == NULL) {
-		s = fw_getenv("modetty0");
-		if (s) {
-			while (*s >= '0' && *s <= '9')
-				baud = baud*10 + *s++ - '0';
-			if (*s == ',')
-				s++;
-			if (*s)
-				parity = *s++;
-			if (*s == ',')
-				s++;
-			if (*s)
-				bits = *s++;
-			if (*s == ',')
-				s++;
-			if (*s == 'h')
-				flow = 'r';
-		}
-		if (baud == 0)
-			baud = 38400;
-		if (parity != 'n' && parity != 'o' && parity != 'e')
-			parity = 'n';
-		if (bits != '7' && bits != '8')
-			bits = '8';
-		if (flow == '\0')
-			flow = 'r';
-		sprintf(console_string, " console=ttyS0,%d%c%c%c", baud,
-			parity, bits, flow);
-		strcat(fw_getcmdline(), console_string);
-	}
-}
-#endif
-
 static void __init mips_nmi_setup(void)
 {
 	void *base;
@@ -140,11 +99,6 @@ void __init prom_init(void)
 	else if ((strstr(fw_getcmdline(), "console=ttyS1")) != NULL)
 		fw_init_early_console(1);
 #endif
-#ifdef CONFIG_SERIAL_8250_CONSOLE
-	if ((strstr(fw_getcmdline(), "console=")) == NULL)
-		strcat(fw_getcmdline(), " console=ttyS0,38400n8r");
-	console_config();
-#endif
 }
 
 void __init prom_free_prom_memory(void)
diff --git a/arch/mips/mti-sead3/sead3-platform.c b/arch/mips/mti-sead3/sead3-platform.c
index d6be029..538a6f8 100644
--- a/arch/mips/mti-sead3/sead3-platform.c
+++ b/arch/mips/mti-sead3/sead3-platform.c
@@ -14,35 +14,10 @@
 #include <linux/mtd/physmap.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
-#include <linux/serial_8250.h>
 #include <linux/smsc911x.h>
 
 #include <asm/mips-boards/sead3int.h>
 
-#define UART(base)							\
-{									\
-	.mapbase	= base,						\
-	.irq		= -1,						\
-	.uartclk	= 14745600,					\
-	.iotype		= UPIO_MEM32,					\
-	.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | UPF_IOREMAP, \
-	.regshift	= 2,						\
-}
-
-static struct plat_serial8250_port uart8250_data[] = {
-	UART(0x1f000900),   /* ttyS0 = USB   */
-	UART(0x1f000800),   /* ttyS1 = RS232 */
-	{ },
-};
-
-static struct platform_device uart8250_device = {
-	.name			= "serial8250",
-	.id			= PLAT8250_DEV_PLATFORM2,
-	.dev			= {
-		.platform_data	= uart8250_data,
-	},
-};
-
 static struct smsc911x_platform_config sead3_smsc911x_data = {
 	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
 	.irq_type	= SMSC911X_IRQ_TYPE_PUSH_PULL,
@@ -195,7 +170,6 @@ static struct platform_device ehci_device = {
 };
 
 static struct platform_device *sead3_platform_devices[] __initdata = {
-	&uart8250_device,
 	&sead3_flash,
 	&pled_device,
 	&fled_device,
@@ -228,15 +202,11 @@ static int __init sead3_platforms_device_init(void)
 	}
 
 	if (gic_present) {
-		uart8250_data[0].irq = irq_create_mapping(irqd, GIC_INT_UART0);
-		uart8250_data[1].irq = irq_create_mapping(irqd, GIC_INT_UART1);
 		ehci_resources[1].start =
 			irq_create_mapping(irqd, GIC_INT_EHCI);
 		sead3_net_resources[1].start =
 			irq_create_mapping(irqd, GIC_INT_NET);
 	} else {
-		uart8250_data[0].irq = irq_create_mapping(irqd, CPU_INT_UART0);
-		uart8250_data[1].irq = irq_create_mapping(irqd, CPU_INT_UART1);
 		ehci_resources[1].start =
 			irq_create_mapping(irqd, CPU_INT_EHCI);
 		sead3_net_resources[1].start =
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 04/19] MIPS: SEAD3: Use generic ns16550a earlycon support
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (2 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 03/19] MIPS: SEAD3: Probe UARTs " Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 05/19] MIPS: SEAD3: Probe ethernet controller using DT Paul Burton
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, Jacek Anaszewski, linux-kernel

Stop selecting SYS_HAS_EARLY_PRINTK & remove the custom support for
early output to the ns16550a UARTs, instead relying upon generic
ns16550a earlycon support. This reduces the amount of platform code
required for SEAD3 without losing any functionality.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/Kconfig                   |  1 -
 arch/mips/configs/sead3_defconfig   |  2 ++
 arch/mips/mti-sead3/Makefile        |  2 --
 arch/mips/mti-sead3/sead3-console.c | 46 -------------------------------------
 arch/mips/mti-sead3/sead3-init.c    |  6 -----
 5 files changed, 2 insertions(+), 55 deletions(-)
 delete mode 100644 arch/mips/mti-sead3/sead3-console.c

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index 2638856..45bbddf 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -513,7 +513,6 @@ config MIPS_SEAD3
 	select SYS_HAS_CPU_MIPS32_R2
 	select SYS_HAS_CPU_MIPS32_R6
 	select SYS_HAS_CPU_MIPS64_R1
-	select SYS_HAS_EARLY_PRINTK
 	select SYS_SUPPORTS_32BIT_KERNEL
 	select SYS_SUPPORTS_64BIT_KERNEL
 	select SYS_SUPPORTS_BIG_ENDIAN
diff --git a/arch/mips/configs/sead3_defconfig b/arch/mips/configs/sead3_defconfig
index deb48fb..23cce81 100644
--- a/arch/mips/configs/sead3_defconfig
+++ b/arch/mips/configs/sead3_defconfig
@@ -15,6 +15,8 @@ CONFIG_PROFILING=y
 CONFIG_OPROFILE=y
 CONFIG_MODULES=y
 # CONFIG_BLK_DEV_BSG is not set
+CONFIG_CMDLINE_BOOL=y
+CONFIG_CMDLINE="earlycon"
 # CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
 CONFIG_NET=y
 CONFIG_PACKET=y
diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index aad67aa..a58b6d9 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -17,5 +17,3 @@ obj-y += sead3-platform.o
 obj-y += sead3-reset.o
 obj-y += sead3-setup.o
 obj-y += sead3-time.o
-
-obj-$(CONFIG_EARLY_PRINTK)	+= sead3-console.o
diff --git a/arch/mips/mti-sead3/sead3-console.c b/arch/mips/mti-sead3/sead3-console.c
deleted file mode 100644
index 031f47d..0000000
--- a/arch/mips/mti-sead3/sead3-console.c
+++ /dev/null
@@ -1,46 +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/console.h>
-#include <linux/serial_reg.h>
-#include <linux/io.h>
-
-#define SEAD_UART1_REGS_BASE	0xbf000800   /* ttyS1 = DB9 port */
-#define SEAD_UART0_REGS_BASE	0xbf000900   /* ttyS0 = USB port   */
-#define PORT(base_addr, offset) ((unsigned int __iomem *)(base_addr+(offset)*4))
-
-static char console_port = 1;
-
-static inline unsigned int serial_in(int offset, unsigned int base_addr)
-{
-	return __raw_readl(PORT(base_addr, offset)) & 0xff;
-}
-
-static inline void serial_out(int offset, int value, unsigned int base_addr)
-{
-	__raw_writel(value, PORT(base_addr, offset));
-}
-
-void __init fw_init_early_console(char port)
-{
-	console_port = port;
-}
-
-int prom_putchar(char c)
-{
-	unsigned int base_addr;
-
-	base_addr = console_port ? SEAD_UART1_REGS_BASE : SEAD_UART0_REGS_BASE;
-
-	while ((serial_in(UART_LSR, base_addr) & UART_LSR_THRE) == 0)
-		;
-
-	serial_out(UART_TX, c, base_addr);
-
-	return 1;
-}
diff --git a/arch/mips/mti-sead3/sead3-init.c b/arch/mips/mti-sead3/sead3-init.c
index e81f5b7..50f3fcb 100644
--- a/arch/mips/mti-sead3/sead3-init.c
+++ b/arch/mips/mti-sead3/sead3-init.c
@@ -93,12 +93,6 @@ void __init prom_init(void)
 	board_ejtag_handler_setup = mips_ejtag_setup;
 
 	fw_init_cmdline();
-#ifdef CONFIG_EARLY_PRINTK
-	if ((strstr(fw_getcmdline(), "console=ttyS0")) != NULL)
-		fw_init_early_console(0);
-	else if ((strstr(fw_getcmdline(), "console=ttyS1")) != NULL)
-		fw_init_early_console(1);
-#endif
 }
 
 void __init prom_free_prom_memory(void)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 05/19] MIPS: SEAD3: Probe ethernet controller using DT
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (3 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 04/19] MIPS: SEAD3: Use generic ns16550a earlycon support Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 06/19] MIPS: SEAD3: Probe EHCI " Paul Burton
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, linux-kernel, Rob Herring, Mark Rutland

Probe the smsc911x ethernet controller using device tree rather than
platform code, reducing the amount of the latter.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/boot/dts/mti/sead3.dts             | 12 ++++++++++
 arch/mips/include/asm/mips-boards/sead3int.h |  2 --
 arch/mips/mti-sead3/sead3-dtshim.c           | 15 ++++++++++++-
 arch/mips/mti-sead3/sead3-platform.c         | 33 ----------------------------
 4 files changed, 26 insertions(+), 36 deletions(-)

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 3f681c5..29ed194 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -87,4 +87,16 @@
 
 		no-loopback-test;
 	};
+
+	eth@1f010000 {
+		compatible = "smsc,lan9115";
+		reg = <0x1f010000 0x10000>;
+		reg-io-width = <4>;
+
+		interrupts = <0>; /* GIC 0 or CPU 6 */
+
+		phy-mode = "mii";
+		smsc,irq-push-pull;
+		smsc,save-mac-address;
+	};
 };
diff --git a/arch/mips/include/asm/mips-boards/sead3int.h b/arch/mips/include/asm/mips-boards/sead3int.h
index 3a5e079..7fdb9d4 100644
--- a/arch/mips/include/asm/mips-boards/sead3int.h
+++ b/arch/mips/include/asm/mips-boards/sead3int.h
@@ -14,10 +14,8 @@
 
 /* CPU interrupt offsets */
 #define CPU_INT_EHCI		2
-#define CPU_INT_NET		6
 
 /* GIC interrupt offsets */
-#define GIC_INT_NET		GIC_SHARED_TO_HWIRQ(0)
 #define GIC_INT_EHCI		GIC_SHARED_TO_HWIRQ(5)
 
 #endif /* !(_MIPS_SEAD3INT_H) */
diff --git a/arch/mips/mti-sead3/sead3-dtshim.c b/arch/mips/mti-sead3/sead3-dtshim.c
index b462f65..279d8d4 100644
--- a/arch/mips/mti-sead3/sead3-dtshim.c
+++ b/arch/mips/mti-sead3/sead3-dtshim.c
@@ -25,7 +25,8 @@ static unsigned char fdt_buf[16 << 10] __initdata;
 static int remove_gic(void *fdt)
 {
 	const unsigned int cpu_uart_int = 4;
-	int gic_off, cpu_off, uart_off, err;
+	const unsigned int cpu_eth_int = 6;
+	int gic_off, cpu_off, uart_off, eth_off, err;
 	uint32_t cfg, cpu_phandle;
 
 	/* leave the GIC node intact if a GIC is present */
@@ -82,6 +83,18 @@ static int remove_gic(void *fdt)
 		return uart_off;
 	}
 
+	eth_off = fdt_node_offset_by_compatible(fdt, -1, "smsc,lan9115");
+	if (eth_off < 0) {
+		pr_err("unable to find ethernet DT node: %d\n", eth_off);
+		return eth_off;
+	}
+
+	err = fdt_setprop_u32(fdt, eth_off, "interrupts", cpu_eth_int);
+	if (err) {
+		pr_err("unable to set ethernet interrupts property: %d\n", err);
+		return err;
+	}
+
 	return 0;
 }
 
diff --git a/arch/mips/mti-sead3/sead3-platform.c b/arch/mips/mti-sead3/sead3-platform.c
index 538a6f8..9f9e914 100644
--- a/arch/mips/mti-sead3/sead3-platform.c
+++ b/arch/mips/mti-sead3/sead3-platform.c
@@ -14,37 +14,9 @@
 #include <linux/mtd/physmap.h>
 #include <linux/of.h>
 #include <linux/platform_device.h>
-#include <linux/smsc911x.h>
 
 #include <asm/mips-boards/sead3int.h>
 
-static struct smsc911x_platform_config sead3_smsc911x_data = {
-	.irq_polarity	= SMSC911X_IRQ_POLARITY_ACTIVE_LOW,
-	.irq_type	= SMSC911X_IRQ_TYPE_PUSH_PULL,
-	.flags		= SMSC911X_USE_32BIT | SMSC911X_SAVE_MAC_ADDRESS,
-	.phy_interface	= PHY_INTERFACE_MODE_MII,
-};
-
-static struct resource sead3_net_resources[] = {
-	{
-		.start			= 0x1f010000,
-		.end			= 0x1f01ffff,
-		.flags			= IORESOURCE_MEM
-	}, {
-		.flags			= IORESOURCE_IRQ
-	}
-};
-
-static struct platform_device sead3_net_device = {
-	.name			= "smsc911x",
-	.id			= 0,
-	.dev			= {
-		.platform_data	= &sead3_smsc911x_data,
-	},
-	.num_resources		= ARRAY_SIZE(sead3_net_resources),
-	.resource		= sead3_net_resources
-};
-
 static struct mtd_partition sead3_mtd_partitions[] = {
 	{
 		.name =		"User FS",
@@ -175,7 +147,6 @@ static struct platform_device *sead3_platform_devices[] __initdata = {
 	&fled_device,
 	&sead3_led_device,
 	&ehci_device,
-	&sead3_net_device,
 };
 
 static int __init sead3_platforms_device_init(void)
@@ -204,13 +175,9 @@ static int __init sead3_platforms_device_init(void)
 	if (gic_present) {
 		ehci_resources[1].start =
 			irq_create_mapping(irqd, GIC_INT_EHCI);
-		sead3_net_resources[1].start =
-			irq_create_mapping(irqd, GIC_INT_NET);
 	} else {
 		ehci_resources[1].start =
 			irq_create_mapping(irqd, CPU_INT_EHCI);
-		sead3_net_resources[1].start =
-			irq_create_mapping(irqd, CPU_INT_NET);
 	}
 
 	return platform_add_devices(sead3_platform_devices,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 06/19] MIPS: SEAD3: Probe EHCI controller using DT
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (4 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 05/19] MIPS: SEAD3: Probe ethernet controller using DT Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 07/19] usb: host: ehci-sead3: Remove SEAD-3 EHCI code Paul Burton
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, linux-kernel, Rob Herring, Mark Rutland

Probe the SEAD3 EHCI controller using the generic-ehci driver & device
tree rather than platform code, in order to reduce the amount of the
latter.

Now that no devices probed from platform code require interrupts, remove
the retrieval of the IRQ domain & sead3int.h.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- Use generic-ehci, dropping SEAD-3 specific driver code

 arch/mips/boot/dts/mti/sead3.dts             |  9 +++++
 arch/mips/include/asm/mips-boards/sead3int.h | 21 ----------
 arch/mips/mti-sead3/sead3-dtshim.c           | 15 ++++++-
 arch/mips/mti-sead3/sead3-platform.c         | 59 ----------------------------
 4 files changed, 23 insertions(+), 81 deletions(-)
 delete mode 100644 arch/mips/include/asm/mips-boards/sead3int.h

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 29ed194..49f57c2 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -60,6 +60,15 @@
 		};
 	};
 
+	ehci@1b200000 {
+		compatible = "generic-ehci";
+		reg = <0x1b200000 0x1000>;
+
+		interrupts = <0>; /* GIC 0 or CPU 6 */
+
+		has-transaction-translator;
+	};
+
 	/* UART connected to FTDI & miniUSB socket */
 	uart0: uart@1f000900 {
 		compatible = "ns16550a";
diff --git a/arch/mips/include/asm/mips-boards/sead3int.h b/arch/mips/include/asm/mips-boards/sead3int.h
deleted file mode 100644
index 7fdb9d4..0000000
--- a/arch/mips/include/asm/mips-boards/sead3int.h
+++ /dev/null
@@ -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.
- *
- * Copyright (C) 2000,2012 MIPS Technologies, Inc.  All rights reserved.
- *	Douglas Leung <douglas@mips.com>
- *	Steven J. Hill <sjhill@mips.com>
- */
-#ifndef _MIPS_SEAD3INT_H
-#define _MIPS_SEAD3INT_H
-
-#include <linux/irqchip/mips-gic.h>
-
-/* CPU interrupt offsets */
-#define CPU_INT_EHCI		2
-
-/* GIC interrupt offsets */
-#define GIC_INT_EHCI		GIC_SHARED_TO_HWIRQ(5)
-
-#endif /* !(_MIPS_SEAD3INT_H) */
diff --git a/arch/mips/mti-sead3/sead3-dtshim.c b/arch/mips/mti-sead3/sead3-dtshim.c
index 279d8d4..6e32ceb 100644
--- a/arch/mips/mti-sead3/sead3-dtshim.c
+++ b/arch/mips/mti-sead3/sead3-dtshim.c
@@ -24,9 +24,10 @@ static unsigned char fdt_buf[16 << 10] __initdata;
 
 static int remove_gic(void *fdt)
 {
+	const unsigned int cpu_ehci_int = 2;
 	const unsigned int cpu_uart_int = 4;
 	const unsigned int cpu_eth_int = 6;
-	int gic_off, cpu_off, uart_off, eth_off, err;
+	int gic_off, cpu_off, uart_off, eth_off, ehci_off, err;
 	uint32_t cfg, cpu_phandle;
 
 	/* leave the GIC node intact if a GIC is present */
@@ -95,6 +96,18 @@ static int remove_gic(void *fdt)
 		return err;
 	}
 
+	ehci_off = fdt_node_offset_by_compatible(fdt, -1, "mti,sead3-ehci");
+	if (ehci_off < 0) {
+		pr_err("unable to find EHCI DT node: %d\n", ehci_off);
+		return ehci_off;
+	}
+
+	err = fdt_setprop_u32(fdt, ehci_off, "interrupts", cpu_ehci_int);
+	if (err) {
+		pr_err("unable to set EHCI interrupts property: %d\n", err);
+		return err;
+	}
+
 	return 0;
 }
 
diff --git a/arch/mips/mti-sead3/sead3-platform.c b/arch/mips/mti-sead3/sead3-platform.c
index 9f9e914..21047b5 100644
--- a/arch/mips/mti-sead3/sead3-platform.c
+++ b/arch/mips/mti-sead3/sead3-platform.c
@@ -7,16 +7,10 @@
  */
 #include <linux/dma-mapping.h>
 #include <linux/init.h>
-#include <linux/irq.h>
-#include <linux/irqchip/mips-gic.h>
-#include <linux/irqdomain.h>
 #include <linux/leds.h>
 #include <linux/mtd/physmap.h>
-#include <linux/of.h>
 #include <linux/platform_device.h>
 
-#include <asm/mips-boards/sead3int.h>
-
 static struct mtd_partition sead3_mtd_partitions[] = {
 	{
 		.name =		"User FS",
@@ -118,68 +112,15 @@ static struct platform_device sead3_led_device = {
         .id     = -1,
 };
 
-static struct resource ehci_resources[] = {
-	{
-		.start			= 0x1b200000,
-		.end			= 0x1b200fff,
-		.flags			= IORESOURCE_MEM
-	}, {
-		.flags			= IORESOURCE_IRQ
-	}
-};
-
-static u64 sead3_usbdev_dma_mask = DMA_BIT_MASK(32);
-
-static struct platform_device ehci_device = {
-	.name		= "sead3-ehci",
-	.id		= 0,
-	.dev		= {
-		.dma_mask		= &sead3_usbdev_dma_mask,
-		.coherent_dma_mask	= DMA_BIT_MASK(32)
-	},
-	.num_resources	= ARRAY_SIZE(ehci_resources),
-	.resource	= ehci_resources
-};
-
 static struct platform_device *sead3_platform_devices[] __initdata = {
 	&sead3_flash,
 	&pled_device,
 	&fled_device,
 	&sead3_led_device,
-	&ehci_device,
 };
 
 static int __init sead3_platforms_device_init(void)
 {
-	const char *intc_compat;
-	struct device_node *node;
-	struct irq_domain *irqd;
-
-	if (gic_present)
-		intc_compat = "mti,gic";
-	else
-		intc_compat = "mti,cpu-interrupt-controller";
-
-	node = of_find_compatible_node(NULL, NULL, intc_compat);
-	if (!node) {
-		pr_err("unable to find interrupt controller DT node\n");
-		return -ENODEV;
-	}
-
-	irqd = irq_find_host(node);
-	if (!irqd) {
-		pr_err("unable to find interrupt controller IRQ domain\n");
-		return -ENODEV;
-	}
-
-	if (gic_present) {
-		ehci_resources[1].start =
-			irq_create_mapping(irqd, GIC_INT_EHCI);
-	} else {
-		ehci_resources[1].start =
-			irq_create_mapping(irqd, CPU_INT_EHCI);
-	}
-
 	return platform_add_devices(sead3_platform_devices,
 				    ARRAY_SIZE(sead3_platform_devices));
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 07/19] usb: host: ehci-sead3: Remove SEAD-3 EHCI code
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (5 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 06/19] MIPS: SEAD3: Probe EHCI " Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 15:55   ` Alan Stern
  2016-08-26 14:17 ` [PATCH v2 08/19] SEAD3: Probe parallel flash via DT Paul Burton
                   ` (11 subsequent siblings)
  18 siblings, 1 reply; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Greg Kroah-Hartman, Alan Stern, linux-kernel, linux-usb

The SEAD-3 board is now probing its EHCI controller using the generic
EHCI driver & its generic-ehci device tree binding. Remove the unused
SEAD-3 specific EHCI code.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- New patch, removing SEAD-3 EHCI code instead of extending it

 drivers/usb/host/ehci-hcd.c   |   5 --
 drivers/usb/host/ehci-sead3.c | 185 ------------------------------------------
 2 files changed, 190 deletions(-)
 delete mode 100644 drivers/usb/host/ehci-sead3.c

diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 1e5f529..0630648 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1308,11 +1308,6 @@ MODULE_LICENSE ("GPL");
 #define        PLATFORM_DRIVER         ehci_mv_driver
 #endif
 
-#ifdef CONFIG_MIPS_SEAD3
-#include "ehci-sead3.c"
-#define	PLATFORM_DRIVER		ehci_hcd_sead3_driver
-#endif
-
 static int __init ehci_hcd_init(void)
 {
 	int retval = 0;
diff --git a/drivers/usb/host/ehci-sead3.c b/drivers/usb/host/ehci-sead3.c
deleted file mode 100644
index 3d86cc2..0000000
--- a/drivers/usb/host/ehci-sead3.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * MIPS CI13320A EHCI Host Controller driver
- * Based on "ehci-au1xxx.c" by K.Boge <karsten.boge@amd.com>
- *
- * Copyright (C) 2012 MIPS Technologies, Inc.
- *
- * 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.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-
-#include <linux/err.h>
-#include <linux/platform_device.h>
-
-static int ehci_sead3_setup(struct usb_hcd *hcd)
-{
-	int ret;
-	struct ehci_hcd *ehci = hcd_to_ehci(hcd);
-
-	ehci->caps = hcd->regs + 0x100;
-
-#ifdef __BIG_ENDIAN
-	ehci->big_endian_mmio = 1;
-	ehci->big_endian_desc = 1;
-#endif
-
-	ret = ehci_setup(hcd);
-	if (ret)
-		return ret;
-
-	ehci->need_io_watchdog = 0;
-
-	/* Set burst length to 16 words. */
-	ehci_writel(ehci, 0x1010, &ehci->regs->reserved1[1]);
-
-	return ret;
-}
-
-const struct hc_driver ehci_sead3_hc_driver = {
-	.description		= hcd_name,
-	.product_desc		= "SEAD-3 EHCI",
-	.hcd_priv_size		= sizeof(struct ehci_hcd),
-
-	/*
-	 * generic hardware linkage
-	 */
-	.irq			= ehci_irq,
-	.flags			= HCD_MEMORY | HCD_USB2 | HCD_BH,
-
-	/*
-	 * basic lifecycle operations
-	 *
-	 */
-	.reset			= ehci_sead3_setup,
-	.start			= ehci_run,
-	.stop			= ehci_stop,
-	.shutdown		= ehci_shutdown,
-
-	/*
-	 * managing i/o requests and associated device resources
-	 */
-	.urb_enqueue		= ehci_urb_enqueue,
-	.urb_dequeue		= ehci_urb_dequeue,
-	.endpoint_disable	= ehci_endpoint_disable,
-	.endpoint_reset		= ehci_endpoint_reset,
-
-	/*
-	 * scheduling support
-	 */
-	.get_frame_number	= ehci_get_frame,
-
-	/*
-	 * root hub support
-	 */
-	.hub_status_data	= ehci_hub_status_data,
-	.hub_control		= ehci_hub_control,
-	.bus_suspend		= ehci_bus_suspend,
-	.bus_resume		= ehci_bus_resume,
-	.relinquish_port	= ehci_relinquish_port,
-	.port_handed_over	= ehci_port_handed_over,
-
-	.clear_tt_buffer_complete	= ehci_clear_tt_buffer_complete,
-};
-
-static int ehci_hcd_sead3_drv_probe(struct platform_device *pdev)
-{
-	struct usb_hcd *hcd;
-	struct resource *res;
-	int ret;
-
-	if (usb_disabled())
-		return -ENODEV;
-
-	if (pdev->resource[1].flags != IORESOURCE_IRQ) {
-		pr_debug("resource[1] is not IORESOURCE_IRQ");
-		return -ENOMEM;
-	}
-	hcd = usb_create_hcd(&ehci_sead3_hc_driver, &pdev->dev, "SEAD-3");
-	if (!hcd)
-		return -ENOMEM;
-
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	hcd->regs = devm_ioremap_resource(&pdev->dev, res);
-	if (IS_ERR(hcd->regs)) {
-		ret = PTR_ERR(hcd->regs);
-		goto err1;
-	}
-	hcd->rsrc_start = res->start;
-	hcd->rsrc_len = resource_size(res);
-
-	/* Root hub has integrated TT. */
-	hcd->has_tt = 1;
-
-	ret = usb_add_hcd(hcd, pdev->resource[1].start,
-			  IRQF_SHARED);
-	if (ret == 0) {
-		platform_set_drvdata(pdev, hcd);
-		device_wakeup_enable(hcd->self.controller);
-		return ret;
-	}
-
-err1:
-	usb_put_hcd(hcd);
-	return ret;
-}
-
-static int ehci_hcd_sead3_drv_remove(struct platform_device *pdev)
-{
-	struct usb_hcd *hcd = platform_get_drvdata(pdev);
-
-	usb_remove_hcd(hcd);
-	usb_put_hcd(hcd);
-
-	return 0;
-}
-
-#ifdef CONFIG_PM
-static int ehci_hcd_sead3_drv_suspend(struct device *dev)
-{
-	struct usb_hcd *hcd = dev_get_drvdata(dev);
-	bool do_wakeup = device_may_wakeup(dev);
-
-	return ehci_suspend(hcd, do_wakeup);
-}
-
-static int ehci_hcd_sead3_drv_resume(struct device *dev)
-{
-	struct usb_hcd *hcd = dev_get_drvdata(dev);
-
-	ehci_resume(hcd, false);
-	return 0;
-}
-
-static const struct dev_pm_ops sead3_ehci_pmops = {
-	.suspend	= ehci_hcd_sead3_drv_suspend,
-	.resume		= ehci_hcd_sead3_drv_resume,
-};
-
-#define SEAD3_EHCI_PMOPS (&sead3_ehci_pmops)
-
-#else
-#define SEAD3_EHCI_PMOPS NULL
-#endif
-
-static struct platform_driver ehci_hcd_sead3_driver = {
-	.probe		= ehci_hcd_sead3_drv_probe,
-	.remove		= ehci_hcd_sead3_drv_remove,
-	.shutdown	= usb_hcd_platform_shutdown,
-	.driver = {
-		.name	= "sead3-ehci",
-		.pm	= SEAD3_EHCI_PMOPS,
-	}
-};
-
-MODULE_ALIAS("platform:sead3-ehci");
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 08/19] SEAD3: Probe parallel flash via DT
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (6 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 07/19] usb: host: ehci-sead3: Remove SEAD-3 EHCI code Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 09/19] MIPS: SEAD3: Use register-bit-led driver via DT for LEDs Paul Burton
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, linux-kernel, Rob Herring, Mark Rutland

Probe the system parallel flash using device tree rather than platform
code, in order to reduce the amount of the latter.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- Provide bank-width
- Move partitions beneath partitions node
- s/pflash/flash/

 arch/mips/boot/dts/mti/sead3.dts     | 24 +++++++++++++++++++++++
 arch/mips/mti-sead3/sead3-platform.c | 37 ------------------------------------
 2 files changed, 24 insertions(+), 37 deletions(-)

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 49f57c2..8844cc0 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -69,6 +69,30 @@
 		has-transaction-translator;
 	};
 
+	flash@1c000000 {
+		compatible = "intel,28f128j3", "cfi-flash";
+		reg = <0x1c000000 0x2000000>;
+		#address-cells = <1>;
+		#size-cells = <1>;
+		bank-width = <4>;
+
+		partitions {
+			compatible = "fixed-partitions";
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			user-fs@0 {
+				label = "User FS";
+				reg = <0x0 0x1fc0000>;
+			};
+
+			board-config@3e0000 {
+				label = "Board Config";
+				reg = <0x1fc0000 0x40000>;
+			};
+		};
+	};
+
 	/* UART connected to FTDI & miniUSB socket */
 	uart0: uart@1f000900 {
 		compatible = "ns16550a";
diff --git a/arch/mips/mti-sead3/sead3-platform.c b/arch/mips/mti-sead3/sead3-platform.c
index 21047b5..5c1f42a 100644
--- a/arch/mips/mti-sead3/sead3-platform.c
+++ b/arch/mips/mti-sead3/sead3-platform.c
@@ -8,44 +8,8 @@
 #include <linux/dma-mapping.h>
 #include <linux/init.h>
 #include <linux/leds.h>
-#include <linux/mtd/physmap.h>
 #include <linux/platform_device.h>
 
-static struct mtd_partition sead3_mtd_partitions[] = {
-	{
-		.name =		"User FS",
-		.offset =	0x00000000,
-		.size =		0x01fc0000,
-	}, {
-		.name =		"Board Config",
-		.offset =	0x01fc0000,
-		.size =		0x00040000,
-		.mask_flags =	MTD_WRITEABLE
-	},
-};
-
-static struct physmap_flash_data sead3_flash_data = {
-	.width		= 4,
-	.nr_parts	= ARRAY_SIZE(sead3_mtd_partitions),
-	.parts		= sead3_mtd_partitions
-};
-
-static struct resource sead3_flash_resource = {
-	.start		= 0x1c000000,
-	.end		= 0x1dffffff,
-	.flags		= IORESOURCE_MEM
-};
-
-static struct platform_device sead3_flash = {
-	.name		= "physmap-flash",
-	.id		= 0,
-	.dev		= {
-		.platform_data	= &sead3_flash_data,
-	},
-	.num_resources	= 1,
-	.resource	= &sead3_flash_resource,
-};
-
 #define LEDFLAGS(bits, shift)		\
 	((bits << 8) | (shift << 8))
 
@@ -113,7 +77,6 @@ static struct platform_device sead3_led_device = {
 };
 
 static struct platform_device *sead3_platform_devices[] __initdata = {
-	&sead3_flash,
 	&pled_device,
 	&fled_device,
 	&sead3_led_device,
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 09/19] MIPS: SEAD3: Use register-bit-led driver via DT for LEDs
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (7 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 08/19] SEAD3: Probe parallel flash via DT Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 10/19] leds: Remove SEAD3 driver Paul Burton
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, Jacek Anaszewski, linux-kernel,
	Rob Herring, Mark Rutland

Probe a driver for the PLED & FLED LEDs found on the SEAD3 board using
the register-bit-led driver via device tree, rather than a custom driver
via platform code. Enable support for the register-bit-led driver & its
prerequisite syscon in sead3_defconfig.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/boot/dts/mti/sead3.dts     | 103 +++++++++++++++++++++++++++++++++++
 arch/mips/configs/sead3_defconfig    |   2 +
 arch/mips/mti-sead3/Makefile         |   1 -
 arch/mips/mti-sead3/sead3-platform.c |  91 -------------------------------
 4 files changed, 105 insertions(+), 92 deletions(-)
 delete mode 100644 arch/mips/mti-sead3/sead3-platform.c

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 8844cc0..0159450 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -93,6 +93,109 @@
 		};
 	};
 
+	system-controller@1f000200 {
+		compatible = "mti,sead3-cpld", "syscon", "simple-mfd";
+		reg = <0x1f000200 0x300>;
+
+		led@10.0 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x1>;
+			label = "pled0";
+		};
+		led@10.1 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x2>;
+			label = "pled1";
+		};
+		led@10.2 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x4>;
+			label = "pled2";
+		};
+		led@10.3 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x8>;
+			label = "pled3";
+		};
+		led@10.4 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x10>;
+			label = "pled4";
+		};
+		led@10.5 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x20>;
+			label = "pled5";
+		};
+		led@10.6 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x40>;
+			label = "pled6";
+		};
+		led@10.7 {
+			compatible = "register-bit-led";
+			offset = <0x10>;
+			mask = <0x80>;
+			label = "pled7";
+		};
+
+		led@18.0 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x1>;
+			label = "fled0";
+		};
+		led@18.1 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x2>;
+			label = "fled1";
+		};
+		led@18.2 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x4>;
+			label = "fled2";
+		};
+		led@18.3 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x8>;
+			label = "fled3";
+		};
+		led@18.4 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x10>;
+			label = "fled4";
+		};
+		led@18.5 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x20>;
+			label = "fled5";
+		};
+		led@18.6 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x40>;
+			label = "fled6";
+		};
+		led@18.7 {
+			compatible = "register-bit-led";
+			offset = <0x18>;
+			mask = <0x80>;
+			label = "fled7";
+		};
+	};
+
 	/* UART connected to FTDI & miniUSB socket */
 	uart0: uart@1f000900 {
 		compatible = "ns16550a";
diff --git a/arch/mips/configs/sead3_defconfig b/arch/mips/configs/sead3_defconfig
index 23cce81..e1c6582 100644
--- a/arch/mips/configs/sead3_defconfig
+++ b/arch/mips/configs/sead3_defconfig
@@ -81,6 +81,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_HELPER_AUTO is not set
 CONFIG_SPI=y
 CONFIG_SENSORS_ADT7475=y
+CONFIG_MFD_SYSCON=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
@@ -95,6 +96,7 @@ CONFIG_MMC_DEBUG=y
 CONFIG_MMC_SPI=y
 CONFIG_NEW_LEDS=y
 CONFIG_LEDS_CLASS=y
+CONFIG_LEDS_SYSCON=y
 CONFIG_LEDS_TRIGGERS=y
 CONFIG_LEDS_TRIGGER_HEARTBEAT=y
 CONFIG_RTC_CLASS=y
diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index a58b6d9..04ea002 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -13,7 +13,6 @@ obj-y += sead3-display.o
 obj-y += sead3-dtshim.o
 obj-y += sead3-init.o
 obj-y += sead3-int.o
-obj-y += sead3-platform.o
 obj-y += sead3-reset.o
 obj-y += sead3-setup.o
 obj-y += sead3-time.o
diff --git a/arch/mips/mti-sead3/sead3-platform.c b/arch/mips/mti-sead3/sead3-platform.c
deleted file mode 100644
index 5c1f42a..0000000
--- a/arch/mips/mti-sead3/sead3-platform.c
+++ /dev/null
@@ -1,91 +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/dma-mapping.h>
-#include <linux/init.h>
-#include <linux/leds.h>
-#include <linux/platform_device.h>
-
-#define LEDFLAGS(bits, shift)		\
-	((bits << 8) | (shift << 8))
-
-#define LEDBITS(id, shift, bits)	\
-	.name = id #shift,		\
-	.flags = LEDFLAGS(bits, shift)
-
-static struct led_info led_data_info[] = {
-	{ LEDBITS("bit", 0, 1) },
-	{ LEDBITS("bit", 1, 1) },
-	{ LEDBITS("bit", 2, 1) },
-	{ LEDBITS("bit", 3, 1) },
-	{ LEDBITS("bit", 4, 1) },
-	{ LEDBITS("bit", 5, 1) },
-	{ LEDBITS("bit", 6, 1) },
-	{ LEDBITS("bit", 7, 1) },
-	{ LEDBITS("all", 0, 8) },
-};
-
-static struct led_platform_data led_data = {
-	.num_leds	= ARRAY_SIZE(led_data_info),
-	.leds		= led_data_info
-};
-
-static struct resource pled_resources[] = {
-	{
-		.start	= 0x1f000210,
-		.end	= 0x1f000217,
-		.flags	= IORESOURCE_MEM
-	}
-};
-
-static struct platform_device pled_device = {
-	.name			= "sead3::pled",
-	.id			= 0,
-	.dev			= {
-		.platform_data	= &led_data,
-	},
-	.num_resources		= ARRAY_SIZE(pled_resources),
-	.resource		= pled_resources
-};
-
-
-static struct resource fled_resources[] = {
-	{
-		.start			= 0x1f000218,
-		.end			= 0x1f00021f,
-		.flags			= IORESOURCE_MEM
-	}
-};
-
-static struct platform_device fled_device = {
-	.name			= "sead3::fled",
-	.id			= 0,
-	.dev			= {
-		.platform_data	= &led_data,
-	},
-	.num_resources		= ARRAY_SIZE(fled_resources),
-	.resource		= fled_resources
-};
-
-static struct platform_device sead3_led_device = {
-        .name   = "sead3-led",
-        .id     = -1,
-};
-
-static struct platform_device *sead3_platform_devices[] __initdata = {
-	&pled_device,
-	&fled_device,
-	&sead3_led_device,
-};
-
-static int __init sead3_platforms_device_init(void)
-{
-	return platform_add_devices(sead3_platform_devices,
-				    ARRAY_SIZE(sead3_platform_devices));
-}
-
-device_initcall(sead3_platforms_device_init);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 10/19] leds: Remove SEAD3 driver
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (8 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 09/19] MIPS: SEAD3: Use register-bit-led driver via DT for LEDs Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-29  8:55   ` Jacek Anaszewski
  2016-08-26 14:17 ` [PATCH v2 11/19] MIPS: SEAD3: Reset via generic syscon-reboot driver & DT Paul Burton
                   ` (8 subsequent siblings)
  18 siblings, 1 reply; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Jacek Anaszewski, Richard Purdie, linux-leds, linux-kernel

SEAD3 is now using the generic syscon & regmap based register-bit-led
driver, so remove the unused custom SEAD3 LED driver.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 drivers/leds/Kconfig      | 10 ------
 drivers/leds/Makefile     |  1 -
 drivers/leds/leds-sead3.c | 78 -----------------------------------------------
 3 files changed, 89 deletions(-)
 delete mode 100644 drivers/leds/leds-sead3.c

diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
index 9dcc9b1..025de7e 100644
--- a/drivers/leds/Kconfig
+++ b/drivers/leds/Kconfig
@@ -574,16 +574,6 @@ config LEDS_KTD2692
 
 	  Say Y to enable this driver.
 
-config LEDS_SEAD3
-	tristate "LED support for the MIPS SEAD 3 board"
-	depends on LEDS_CLASS && MIPS_SEAD3
-	help
-	  Say Y here to include support for the FLED and PLED LEDs on SEAD3 eval
-	  boards.
-
-	  This driver can also be built as a module. If so the module
-	  will be called leds-sead3.
-
 config LEDS_IS31FL32XX
 	tristate "LED support for ISSI IS31FL32XX I2C LED controller family"
 	depends on LEDS_CLASS && I2C && OF
diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
index 0684c86..da594cf 100644
--- a/drivers/leds/Makefile
+++ b/drivers/leds/Makefile
@@ -66,7 +66,6 @@ obj-$(CONFIG_LEDS_VERSATILE)		+= leds-versatile.o
 obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.o
 obj-$(CONFIG_LEDS_KTD2692)		+= leds-ktd2692.o
 obj-$(CONFIG_LEDS_POWERNV)		+= leds-powernv.o
-obj-$(CONFIG_LEDS_SEAD3)		+= leds-sead3.o
 obj-$(CONFIG_LEDS_IS31FL32XX)		+= leds-is31fl32xx.o
 
 # LED SPI Drivers
diff --git a/drivers/leds/leds-sead3.c b/drivers/leds/leds-sead3.c
deleted file mode 100644
index eb97a32..0000000
--- a/drivers/leds/leds-sead3.c
+++ /dev/null
@@ -1,78 +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) 2015 Imagination Technologies, Inc.
- */
-#include <linux/kernel.h>
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/platform_device.h>
-#include <linux/leds.h>
-#include <linux/err.h>
-#include <linux/io.h>
-
-#include <asm/mips-boards/sead3-addr.h>
-
-static void sead3_pled_set(struct led_classdev *led_cdev,
-		enum led_brightness value)
-{
-	writel(value, (void __iomem *)SEAD3_CPLD_P_LED);
-}
-
-static void sead3_fled_set(struct led_classdev *led_cdev,
-		enum led_brightness value)
-{
-	writel(value, (void __iomem *)SEAD3_CPLD_F_LED);
-}
-
-static struct led_classdev sead3_pled = {
-	.name		= "sead3::pled",
-	.brightness_set = sead3_pled_set,
-	.flags		= LED_CORE_SUSPENDRESUME,
-};
-
-static struct led_classdev sead3_fled = {
-	.name		= "sead3::fled",
-	.brightness_set = sead3_fled_set,
-	.flags		= LED_CORE_SUSPENDRESUME,
-};
-
-static int sead3_led_probe(struct platform_device *pdev)
-{
-	int ret;
-
-	ret = led_classdev_register(&pdev->dev, &sead3_pled);
-	if (ret < 0)
-		return ret;
-
-	ret = led_classdev_register(&pdev->dev, &sead3_fled);
-	if (ret < 0)
-		led_classdev_unregister(&sead3_pled);
-
-	return ret;
-}
-
-static int sead3_led_remove(struct platform_device *pdev)
-{
-	led_classdev_unregister(&sead3_pled);
-	led_classdev_unregister(&sead3_fled);
-
-	return 0;
-}
-
-static struct platform_driver sead3_led_driver = {
-	.probe		= sead3_led_probe,
-	.remove		= sead3_led_remove,
-	.driver		= {
-		.name		= "sead3-led",
-	},
-};
-
-module_platform_driver(sead3_led_driver);
-
-MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
-MODULE_DESCRIPTION("SEAD3 LED driver");
-MODULE_LICENSE("GPL");
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 11/19] MIPS: SEAD3: Reset via generic syscon-reboot driver & DT
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (9 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 10/19] leds: Remove SEAD3 driver Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 12/19] MIPS: SEAD3: Use generic restart-poweroff driver Paul Burton
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, linux-kernel, Rob Herring, Mark Rutland

Remove the SEAD3 implementation of _machine_restart & instead make use
of the generic syscon-reboot driver probed via device tree.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/boot/dts/mti/sead3.dts  | 12 ++++++++++++
 arch/mips/configs/sead3_defconfig |  3 ++-
 arch/mips/mti-sead3/sead3-reset.c |  9 ---------
 3 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 0159450..047ff7a 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -93,6 +93,18 @@
 		};
 	};
 
+	fpga_regs: system-controller@1f000000 {
+		compatible = "mti,sead3-fpga", "syscon", "simple-mfd";
+		reg = <0x1f000000 0x200>;
+
+		reboot {
+			compatible = "syscon-reboot";
+			regmap = <&fpga_regs>;
+			offset = <0x50>;
+			mask = <0x4d>;
+		};
+	};
+
 	system-controller@1f000200 {
 		compatible = "mti,sead3-cpld", "syscon", "simple-mfd";
 		reg = <0x1f000200 0x300>;
diff --git a/arch/mips/configs/sead3_defconfig b/arch/mips/configs/sead3_defconfig
index e1c6582..055af30 100644
--- a/arch/mips/configs/sead3_defconfig
+++ b/arch/mips/configs/sead3_defconfig
@@ -80,8 +80,9 @@ CONFIG_I2C=y
 CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_HELPER_AUTO is not set
 CONFIG_SPI=y
+CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_SYSCON=y
 CONFIG_SENSORS_ADT7475=y
-CONFIG_MFD_SYSCON=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
 CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
diff --git a/arch/mips/mti-sead3/sead3-reset.c b/arch/mips/mti-sead3/sead3-reset.c
index e6fb244..8f548f0 100644
--- a/arch/mips/mti-sead3/sead3-reset.c
+++ b/arch/mips/mti-sead3/sead3-reset.c
@@ -13,14 +13,6 @@
 #define SOFTRES_REG	0x1f000050
 #define GORESET		0x4d
 
-static void mips_machine_restart(char *command)
-{
-	unsigned int __iomem *softres_reg =
-		ioremap(SOFTRES_REG, sizeof(unsigned int));
-
-	__raw_writel(GORESET, softres_reg);
-}
-
 static void mips_machine_halt(void)
 {
 	unsigned int __iomem *softres_reg =
@@ -31,7 +23,6 @@ static void mips_machine_halt(void)
 
 static int __init mips_reboot_setup(void)
 {
-	_machine_restart = mips_machine_restart;
 	_machine_halt = mips_machine_halt;
 	pm_power_off = mips_machine_halt;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 12/19] MIPS: SEAD3: Use generic restart-poweroff driver
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (10 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 11/19] MIPS: SEAD3: Reset via generic syscon-reboot driver & DT Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 13/19] MIPS: SEAD3: Parse memsize in DT shim Paul Burton
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, Jacek Anaszewski, linux-kernel,
	Rob Herring, Mark Rutland

Remove the custom platform code to restart when instructed to power off,
instead relying upon the generic restart-poweroff driver probed via DT
to do the same thing.

Remove also the halt implementation, which is incorrect. The generic
MIPS version will hang the system as halt should.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/boot/dts/mti/sead3.dts  |  4 ++++
 arch/mips/configs/sead3_defconfig |  1 +
 arch/mips/mti-sead3/Makefile      |  1 -
 arch/mips/mti-sead3/sead3-reset.c | 31 -------------------------------
 4 files changed, 5 insertions(+), 32 deletions(-)
 delete mode 100644 arch/mips/mti-sead3/sead3-reset.c

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 047ff7a..32a5ab9 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -103,6 +103,10 @@
 			offset = <0x50>;
 			mask = <0x4d>;
 		};
+
+		poweroff {
+			compatible = "restart-poweroff";
+		};
 	};
 
 	system-controller@1f000200 {
diff --git a/arch/mips/configs/sead3_defconfig b/arch/mips/configs/sead3_defconfig
index 055af30..ab4c465 100644
--- a/arch/mips/configs/sead3_defconfig
+++ b/arch/mips/configs/sead3_defconfig
@@ -81,6 +81,7 @@ CONFIG_I2C_CHARDEV=y
 # CONFIG_I2C_HELPER_AUTO is not set
 CONFIG_SPI=y
 CONFIG_POWER_RESET=y
+CONFIG_POWER_RESET_RESTART=y
 CONFIG_POWER_RESET_SYSCON=y
 CONFIG_SENSORS_ADT7475=y
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index 04ea002..ad722c8 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -13,6 +13,5 @@ obj-y += sead3-display.o
 obj-y += sead3-dtshim.o
 obj-y += sead3-init.o
 obj-y += sead3-int.o
-obj-y += sead3-reset.o
 obj-y += sead3-setup.o
 obj-y += sead3-time.o
diff --git a/arch/mips/mti-sead3/sead3-reset.c b/arch/mips/mti-sead3/sead3-reset.c
deleted file mode 100644
index 8f548f0..0000000
--- a/arch/mips/mti-sead3/sead3-reset.c
+++ /dev/null
@@ -1,31 +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/io.h>
-#include <linux/pm.h>
-
-#include <asm/reboot.h>
-
-#define SOFTRES_REG	0x1f000050
-#define GORESET		0x4d
-
-static void mips_machine_halt(void)
-{
-	unsigned int __iomem *softres_reg =
-		ioremap(SOFTRES_REG, sizeof(unsigned int));
-
-	__raw_writel(GORESET, softres_reg);
-}
-
-static int __init mips_reboot_setup(void)
-{
-	_machine_halt = mips_machine_halt;
-	pm_power_off = mips_machine_halt;
-
-	return 0;
-}
-arch_initcall(mips_reboot_setup);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 13/19] MIPS: SEAD3: Parse memsize in DT shim
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (11 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 12/19] MIPS: SEAD3: Use generic restart-poweroff driver Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 14/19] MIPS: SEAD3: Drop use of cobalt fbdev driver Paul Burton
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Matt Redfearn, Rob Herring, Kefeng Wang, linux-kernel

Parse the memsize argument provided by the bootloader in the DT shim
code, allowing the user to override it on the command line. This places
all of the DT manipulation code into sead3-dtshim.c.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/mti-sead3/sead3-dtshim.c | 71 ++++++++++++++++++++++++++++++++++++++
 arch/mips/mti-sead3/sead3-setup.c  | 66 -----------------------------------
 2 files changed, 71 insertions(+), 66 deletions(-)

diff --git a/arch/mips/mti-sead3/sead3-dtshim.c b/arch/mips/mti-sead3/sead3-dtshim.c
index 6e32ceb..d6b0708 100644
--- a/arch/mips/mti-sead3/sead3-dtshim.c
+++ b/arch/mips/mti-sead3/sead3-dtshim.c
@@ -22,6 +22,73 @@
 
 static unsigned char fdt_buf[16 << 10] __initdata;
 
+static int append_memory(void *fdt)
+{
+	unsigned long phys_memsize, memsize;
+	__be32 mem_array[2];
+	int err, mem_off;
+	char *var;
+
+	/* find memory size from the bootloader environment */
+	var = fw_getenv("memsize");
+	if (var) {
+		err = kstrtoul(var, 0, &phys_memsize);
+		if (err) {
+			pr_err("Failed to read memsize env variable '%s'\n",
+			       var);
+			return -EINVAL;
+		}
+	} else {
+		pr_warn("The bootloader didn't provide memsize: defaulting to 32MB\n");
+		phys_memsize = 32 << 20;
+	}
+
+	/* default to using all available RAM */
+	memsize = phys_memsize;
+
+	/* allow the user to override the usable memory */
+	var = strstr(arcs_cmdline, "memsize=");
+	if (var)
+		memsize = memparse(var + strlen("memsize="), NULL);
+
+	/* if the user says there's more RAM than we thought, believe them */
+	phys_memsize = max_t(unsigned long, phys_memsize, memsize);
+
+	/* find or add a memory node */
+	mem_off = fdt_path_offset(fdt, "/memory");
+	if (mem_off == -FDT_ERR_NOTFOUND)
+		mem_off = fdt_add_subnode(fdt, 0, "memory");
+	if (mem_off < 0) {
+		pr_err("Unable to find or add memory DT node: %d\n", mem_off);
+		return mem_off;
+	}
+
+	err = fdt_setprop_string(fdt, mem_off, "device_type", "memory");
+	if (err) {
+		pr_err("Unable to set memory node device_type: %d\n", err);
+		return err;
+	}
+
+	mem_array[0] = 0;
+	mem_array[1] = cpu_to_be32(phys_memsize);
+	err = fdt_setprop(fdt, mem_off, "reg", mem_array, sizeof(mem_array));
+	if (err) {
+		pr_err("Unable to set memory regs property: %d\n", err);
+		return err;
+	}
+
+	mem_array[0] = 0;
+	mem_array[1] = cpu_to_be32(memsize);
+	err = fdt_setprop(fdt, mem_off, "linux,usable-memory",
+			  mem_array, sizeof(mem_array));
+	if (err) {
+		pr_err("Unable to set linux,usable-memory property: %d\n", err);
+		return err;
+	}
+
+	return 0;
+}
+
 static int remove_gic(void *fdt)
 {
 	const unsigned int cpu_ehci_int = 2;
@@ -205,6 +272,10 @@ void __init *sead3_dt_shim(void *fdt)
 	if (err)
 		panic("Unable to open FDT: %d", err);
 
+	err = append_memory(fdt_buf);
+	if (err)
+		panic("Unable to patch FDT: %d", err);
+
 	err = remove_gic(fdt_buf);
 	if (err)
 		panic("Unable to patch FDT: %d", err);
diff --git a/arch/mips/mti-sead3/sead3-setup.c b/arch/mips/mti-sead3/sead3-setup.c
index c4fc0c6..c915e54 100644
--- a/arch/mips/mti-sead3/sead3-setup.c
+++ b/arch/mips/mti-sead3/sead3-setup.c
@@ -11,7 +11,6 @@
 #include <linux/of_fdt.h>
 
 #include <asm/prom.h>
-#include <asm/fw/fw.h>
 
 #include <asm/mach-sead3/sead3-dtshim.h>
 #include <asm/mips-boards/generic.h>
@@ -21,68 +20,6 @@ const char *get_system_type(void)
 	return "MIPS SEAD3";
 }
 
-static uint32_t get_memsize_from_cmdline(void)
-{
-	int memsize = 0;
-	char *p = arcs_cmdline;
-	char *s = "memsize=";
-
-	p = strstr(p, s);
-	if (p) {
-		p += strlen(s);
-		memsize = memparse(p, NULL);
-	}
-
-	return memsize;
-}
-
-static uint32_t get_memsize_from_env(void)
-{
-	int memsize = 0;
-	char *p;
-
-	p = fw_getenv("memsize");
-	if (p)
-		memsize = memparse(p, NULL);
-
-	return memsize;
-}
-
-static uint32_t get_memsize(void)
-{
-	uint32_t memsize;
-
-	memsize = get_memsize_from_cmdline();
-	if (memsize)
-		return memsize;
-
-	return get_memsize_from_env();
-}
-
-static void __init parse_memsize_param(void)
-{
-	int offset;
-	const uint64_t *prop_value;
-	int prop_len;
-	uint32_t memsize = get_memsize();
-
-	if (!memsize)
-		return;
-
-	offset = fdt_path_offset(__dtb_start, "/memory");
-	if (offset > 0) {
-		uint64_t new_value;
-		/*
-		 * reg contains 2 32-bits BE values, offset and size. We just
-		 * want to replace the size value without affecting the offset
-		 */
-		prop_value = fdt_getprop(__dtb_start, offset, "reg", &prop_len);
-		new_value = be64_to_cpu(*prop_value);
-		new_value =  (new_value & ~0xffffffffllu) | memsize;
-		fdt_setprop_inplace_u64(__dtb_start, offset, "reg", new_value);
-	}
-}
-
 void __init *plat_get_fdt(void)
 {
 	return (void *)__dtb_start;
@@ -92,9 +29,6 @@ void __init plat_mem_setup(void)
 {
 	void *fdt = plat_get_fdt();
 
-	/* allow command line/bootloader env to override memory size in DT */
-	parse_memsize_param();
-
 	fdt = sead3_dt_shim(fdt);
 	__dt_setup_arch(fdt);
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 14/19] MIPS: SEAD3: Drop use of cobalt fbdev driver
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (12 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 13/19] MIPS: SEAD3: Parse memsize in DT shim Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 15/19] fbdev: cobalt_lcdfb: Drop SEAD3 support Paul Burton
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, Jacek Anaszewski, linux-kernel

The 2 line * 16 character LCD display on the SEAD3 board has no real use
as a framebuffer device. It's far too small to produce any meaningful
output if used as the kernel console, SEAD3 is a development board that
will essentially always have a far more useful UART connection & the
code in sead3-display.c will overwrite whatever's on the display every
second anyway. Remove this unused code.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/mti-sead3/Makefile    |  3 +--
 arch/mips/mti-sead3/sead3-lcd.c | 43 -----------------------------------------
 2 files changed, 1 insertion(+), 45 deletions(-)
 delete mode 100644 arch/mips/mti-sead3/sead3-lcd.c

diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index ad722c8..cb6d620 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -8,8 +8,7 @@
 # Copyright (C) 2012 MIPS Technoligies, Inc.  All rights reserved.
 # Steven J. Hill <sjhill@mips.com>
 #
-obj-y := sead3-lcd.o
-obj-y += sead3-display.o
+obj-y := sead3-display.o
 obj-y += sead3-dtshim.o
 obj-y += sead3-init.o
 obj-y += sead3-int.o
diff --git a/arch/mips/mti-sead3/sead3-lcd.c b/arch/mips/mti-sead3/sead3-lcd.c
deleted file mode 100644
index 10b10ed2..0000000
--- a/arch/mips/mti-sead3/sead3-lcd.c
+++ /dev/null
@@ -1,43 +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/platform_device.h>
-
-static struct resource __initdata sead3_lcd_resource = {
-		.start	= 0x1f000400,
-		.end	= 0x1f00041f,
-		.flags	= IORESOURCE_MEM,
-};
-
-static __init int sead3_lcd_add(void)
-{
-	struct platform_device *pdev;
-	int retval;
-
-	/* SEAD-3 and Cobalt platforms use same display type. */
-	pdev = platform_device_alloc("cobalt-lcd", -1);
-	if (!pdev)
-		return -ENOMEM;
-
-	retval = platform_device_add_resources(pdev, &sead3_lcd_resource, 1);
-	if (retval)
-		goto err_free_device;
-
-	retval = platform_device_add(pdev);
-	if (retval)
-		goto err_free_device;
-
-	return 0;
-
-err_free_device:
-	platform_device_put(pdev);
-
-	return retval;
-}
-
-device_initcall(sead3_lcd_add);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 15/19] fbdev: cobalt_lcdfb: Drop SEAD3 support
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (13 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 14/19] MIPS: SEAD3: Drop use of cobalt fbdev driver Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 16/19] dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs Paul Burton
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Ondrej Zary, linux-fbdev, Arnd Bergmann,
	Robert Jarzmik, Maciej W. Rozycki, Ezequiel Garcia, linux-kernel,
	Tomi Valkeinen, Jean-Christophe Plagniol-Villard,
	Geert Uytterhoeven, Simon Horman

The SEAD3 board no longer uses the cobalt_lcdfb driver, so remove the
SEAD3-specific code from it.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Acked-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
---

Changes in v2: None

 drivers/video/fbdev/Kconfig        |  2 +-
 drivers/video/fbdev/cobalt_lcdfb.c | 42 --------------------------------------
 2 files changed, 1 insertion(+), 43 deletions(-)

diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig
index 88b008f..914bfb2 100644
--- a/drivers/video/fbdev/Kconfig
+++ b/drivers/video/fbdev/Kconfig
@@ -2183,7 +2183,7 @@ config FB_GOLDFISH
 
 config FB_COBALT
 	tristate "Cobalt server LCD frame buffer support"
-	depends on FB && (MIPS_COBALT || MIPS_SEAD3)
+	depends on FB && MIPS_COBALT
 
 config FB_SH7760
 	bool "SH7760/SH7763/SH7720/SH7721 LCDC support"
diff --git a/drivers/video/fbdev/cobalt_lcdfb.c b/drivers/video/fbdev/cobalt_lcdfb.c
index 07675d6..2d3b691 100644
--- a/drivers/video/fbdev/cobalt_lcdfb.c
+++ b/drivers/video/fbdev/cobalt_lcdfb.c
@@ -63,7 +63,6 @@
 #define LCD_CUR_POS(x)		((x) & LCD_CUR_POS_MASK)
 #define LCD_TEXT_POS(x)		((x) | LCD_TEXT_MODE)
 
-#ifdef CONFIG_MIPS_COBALT
 static inline void lcd_write_control(struct fb_info *info, u8 control)
 {
 	writel((u32)control << 24, info->screen_base);
@@ -83,47 +82,6 @@ static inline u8 lcd_read_data(struct fb_info *info)
 {
 	return readl(info->screen_base + LCD_DATA_REG_OFFSET) >> 24;
 }
-#else
-
-#define LCD_CTL			0x00
-#define LCD_DATA		0x08
-#define CPLD_STATUS		0x10
-#define CPLD_DATA		0x18
-
-static inline void cpld_wait(struct fb_info *info)
-{
-	do {
-	} while (readl(info->screen_base + CPLD_STATUS) & 1);
-}
-
-static inline void lcd_write_control(struct fb_info *info, u8 control)
-{
-	cpld_wait(info);
-	writel(control, info->screen_base + LCD_CTL);
-}
-
-static inline u8 lcd_read_control(struct fb_info *info)
-{
-	cpld_wait(info);
-	readl(info->screen_base + LCD_CTL);
-	cpld_wait(info);
-	return readl(info->screen_base + CPLD_DATA) & 0xff;
-}
-
-static inline void lcd_write_data(struct fb_info *info, u8 data)
-{
-	cpld_wait(info);
-	writel(data, info->screen_base + LCD_DATA);
-}
-
-static inline u8 lcd_read_data(struct fb_info *info)
-{
-	cpld_wait(info);
-	readl(info->screen_base + LCD_DATA);
-	cpld_wait(info);
-	return readl(info->screen_base + CPLD_DATA) & 0xff;
-}
-#endif
 
 static int lcd_busy_wait(struct fb_info *info)
 {
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 16/19] dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (14 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 15/19] fbdev: cobalt_lcdfb: Drop SEAD3 support Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-31 16:18   ` Rob Herring
  2016-08-26 14:17 ` [PATCH v2 17/19] auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays Paul Burton
                   ` (2 subsequent siblings)
  18 siblings, 1 reply; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Mauro Carvalho Chehab, devicetree, Guenter Roeck,
	linux-kernel, David S. Miller, Greg Kroah-Hartman, Rob Herring,
	Geert Uytterhoeven, Mark Rutland, Andrew Morton

Add documentation for a devicetree binding for the simple ASCII LCD
displays found on development boards such as the MIPS Boston, MIPS Malta
& MIPS SEAD3 from Imagination Technologies.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- Fix filename & path in MAINTAINERS

 .../devicetree/bindings/auxdisplay/img-ascii-lcd.txt    | 17 +++++++++++++++++
 MAINTAINERS                                             |  5 +++++
 2 files changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt

diff --git a/Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt b/Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt
new file mode 100644
index 0000000..b69bb68
--- /dev/null
+++ b/Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt
@@ -0,0 +1,17 @@
+Binding for ASCII LCD displays on Imagination Technologies boards
+
+Required properties:
+- compatible : should be one of:
+    "img,boston-lcd"
+    "mti,malta-lcd"
+    "mti,sead3-lcd"
+
+Required properties for "img,boston-lcd":
+- reg : memory region locating the device registers
+
+Required properties for "mti,malta-lcd" or "mti,sead3-lcd":
+- regmap: phandle of the system controller containing the LCD registers
+- offset: offset in bytes to the LCD registers within the system controller
+
+The layout of the registers & properties of the display are determined
+from the compatible string, making this binding somewhat trivial.
diff --git a/MAINTAINERS b/MAINTAINERS
index 0bbe4b1..f7a68b1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5953,6 +5953,11 @@ M:	Stanislaw Gruszka <stf_xl@wp.pl>
 S:	Maintained
 F:	drivers/usb/atm/ueagle-atm.c
 
+IMGTEC ASCII LCD DRIVER
+M:	Paul Burton <paul.burton@imgtec.com>
+S:	Maintained
+F:	Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt
+
 INA209 HARDWARE MONITOR DRIVER
 M:	Guenter Roeck <linux@roeck-us.net>
 L:	linux-hwmon@vger.kernel.org
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 17/19] auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (15 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 16/19] dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-09-27 18:52   ` Ralf Baechle
  2016-08-26 14:17 ` [PATCH v2 18/19] MIPS: SEAD3: Use img-ascii-lcd driver Paul Burton
  2016-08-26 14:17 ` [PATCH v2 19/19] MIPS: SEAD3: Remove custom read_persistent_clock Paul Burton
  18 siblings, 1 reply; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, Mauro Carvalho Chehab, Miguel Ojeda Sandonis,
	linux-kernel, Guenter Roeck, David S. Miller, Greg Kroah-Hartman,
	Geert Uytterhoeven, Andrew Morton

Add a driver for simple ASCII LCD displays found on the MIPS Boston,
Malta & SEAD3 development boards. The Boston display is an independent
memory mapped device with a simple memory mapped 8 byte register space
containing the 8 ASCII characters to display. The Malta display is
exposed as part of the Malta board registers, and provides 8 registers
each of which corresponds to one of the ASCII characters to display. The
SEAD3 display is slightly more complex, exposing an interface to an
S6A0069 LCD controller via registers provided by the boards CPLD.
However although the displays differ in their register interface, we
require similar functionality on each board so abstracting away the
differences within a single driver allows us to share a significant
amount of code & ensure consistent behaviour.

The driver displays the Linux kernel version as the default message, but
allows the message to be changed via a character device. Messages longer
then the number of characters that the display can show will scroll.

This provides different behaviour to the existing LCD display code for
the MIPS Malta or MIPS SEAD3 platforms in the following ways:

  - The default string to display is not "LINUX ON MALTA" or "LINUX ON
    SEAD3" but "Linux" followed by the version number of the kernel
    (UTS_RELEASE).

  - Since that string tends to be significantly longer it scrolls twice
    as fast, moving every 500ms rather than every 1s.

  - The LCD won't be updated until the driver is probed, so it doesn't
    provide the early "LINUX" string.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2:
- Fix filename in MAINTAINERS

 MAINTAINERS                        |   1 +
 drivers/auxdisplay/Kconfig         |   9 +
 drivers/auxdisplay/Makefile        |   1 +
 drivers/auxdisplay/img-ascii-lcd.c | 443 +++++++++++++++++++++++++++++++++++++
 4 files changed, 454 insertions(+)
 create mode 100644 drivers/auxdisplay/img-ascii-lcd.c

diff --git a/MAINTAINERS b/MAINTAINERS
index f7a68b1..39bda4e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -5957,6 +5957,7 @@ IMGTEC ASCII LCD DRIVER
 M:	Paul Burton <paul.burton@imgtec.com>
 S:	Maintained
 F:	Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt
+F:	drivers/auxdisplay/img-ascii-lcd.c
 
 INA209 HARDWARE MONITOR DRIVER
 M:	Guenter Roeck <linux@roeck-us.net>
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index c07e725..10e1b9e 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -119,4 +119,13 @@ config CFAG12864B_RATE
 	  If you compile this as a module, you can still override this
 	  value using the module parameters.
 
+config IMG_ASCII_LCD
+	tristate "Imagination Technologies ASCII LCD Display"
+	default y if MIPS_MALTA || MIPS_SEAD3
+	select SYSCON
+	help
+	  Enable this to support the simple ASCII LCD displays found on
+	  development boards such as the MIPS Boston, MIPS Malta & MIPS SEAD3
+	  from Imagination Technologies.
+
 endif # AUXDISPLAY
diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile
index 8a8936a..3127175 100644
--- a/drivers/auxdisplay/Makefile
+++ b/drivers/auxdisplay/Makefile
@@ -4,3 +4,4 @@
 
 obj-$(CONFIG_KS0108)		+= ks0108.o
 obj-$(CONFIG_CFAG12864B)	+= cfag12864b.o cfag12864bfb.o
+obj-$(CONFIG_IMG_ASCII_LCD)	+= img-ascii-lcd.o
diff --git a/drivers/auxdisplay/img-ascii-lcd.c b/drivers/auxdisplay/img-ascii-lcd.c
new file mode 100644
index 0000000..bf43b5d
--- /dev/null
+++ b/drivers/auxdisplay/img-ascii-lcd.c
@@ -0,0 +1,443 @@
+/*
+ * Copyright (C) 2016 Imagination Technologies
+ * Author: Paul Burton <paul.burton@imgtec.com>
+ *
+ * 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 <generated/utsrelease.h>
+#include <linux/kernel.h>
+#include <linux/io.h>
+#include <linux/mfd/syscon.h>
+#include <linux/module.h>
+#include <linux/of_address.h>
+#include <linux/of_platform.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/slab.h>
+#include <linux/sysfs.h>
+
+struct img_ascii_lcd_ctx;
+
+/**
+ * struct img_ascii_lcd_config - Configuration information about an LCD model
+ * @num_chars: the number of characters the LCD can display
+ * @external_regmap: true if registers are in a system controller, else false
+ * @update: function called to update the LCD
+ */
+struct img_ascii_lcd_config {
+	unsigned int num_chars;
+	bool external_regmap;
+	void (*update)(struct img_ascii_lcd_ctx *ctx);
+};
+
+/**
+ * struct img_ascii_lcd_ctx - Private data structure
+ * @pdev: the ASCII LCD platform device
+ * @base: the base address of the LCD registers
+ * @regmap: the regmap through which LCD registers are accessed
+ * @offset: the offset within regmap to the start of the LCD registers
+ * @cfg: pointer to the LCD model configuration
+ * @message: the full message to display or scroll on the LCD
+ * @message_len: the length of the @message string
+ * @scroll_pos: index of the first character of @message currently displayed
+ * @scroll_rate: scroll interval in jiffies
+ * @timer: timer used to implement scrolling
+ * @curr: the string currently displayed on the LCD
+ */
+struct img_ascii_lcd_ctx {
+	struct platform_device *pdev;
+	union {
+		void __iomem *base;
+		struct regmap *regmap;
+	};
+	u32 offset;
+	const struct img_ascii_lcd_config *cfg;
+	char *message;
+	unsigned int message_len;
+	unsigned int scroll_pos;
+	unsigned int scroll_rate;
+	struct timer_list timer;
+	char curr[] __aligned(8);
+};
+
+/*
+ * MIPS Boston development board
+ */
+
+static void boston_update(struct img_ascii_lcd_ctx *ctx)
+{
+	ulong val;
+
+#if BITS_PER_LONG == 64
+	val = *((u64 *)&ctx->curr[0]);
+	__raw_writeq(val, ctx->base);
+#elif BITS_PER_LONG == 32
+	val = *((u32 *)&ctx->curr[0]);
+	__raw_writel(val, ctx->base);
+	val = *((u32 *)&ctx->curr[4]);
+	__raw_writel(val, ctx->base + 4);
+#else
+# error Not 32 or 64 bit
+#endif
+}
+
+static struct img_ascii_lcd_config boston_config = {
+	.num_chars = 8,
+	.update = boston_update,
+};
+
+/*
+ * MIPS Malta development board
+ */
+
+static void malta_update(struct img_ascii_lcd_ctx *ctx)
+{
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < ctx->cfg->num_chars; i++) {
+		err = regmap_write(ctx->regmap,
+				   ctx->offset + (i * 8), ctx->curr[i]);
+		if (err)
+			break;
+	}
+
+	if (unlikely(err))
+		pr_err_ratelimited("Failed to update LCD display: %d\n", err);
+}
+
+static struct img_ascii_lcd_config malta_config = {
+	.num_chars = 8,
+	.external_regmap = true,
+	.update = malta_update,
+};
+
+/*
+ * MIPS SEAD3 development board
+ */
+
+enum {
+	SEAD3_REG_LCD_CTRL		= 0x00,
+#define SEAD3_REG_LCD_CTRL_SETDRAM	BIT(7)
+	SEAD3_REG_LCD_DATA		= 0x08,
+	SEAD3_REG_CPLD_STATUS		= 0x10,
+#define SEAD3_REG_CPLD_STATUS_BUSY	BIT(0)
+	SEAD3_REG_CPLD_DATA		= 0x18,
+#define SEAD3_REG_CPLD_DATA_BUSY	BIT(7)
+};
+
+static int sead3_wait_sm_idle(struct img_ascii_lcd_ctx *ctx)
+{
+	unsigned int status;
+	int err;
+
+	do {
+		err = regmap_read(ctx->regmap,
+				  ctx->offset + SEAD3_REG_CPLD_STATUS,
+				  &status);
+		if (err)
+			return err;
+	} while (status & SEAD3_REG_CPLD_STATUS_BUSY);
+
+	return 0;
+
+}
+
+static int sead3_wait_lcd_idle(struct img_ascii_lcd_ctx *ctx)
+{
+	unsigned int cpld_data;
+	int err;
+
+	err = sead3_wait_sm_idle(ctx);
+	if (err)
+		return err;
+
+	do {
+		err = regmap_read(ctx->regmap,
+				  ctx->offset + SEAD3_REG_LCD_CTRL,
+				  &cpld_data);
+		if (err)
+			return err;
+
+		err = sead3_wait_sm_idle(ctx);
+		if (err)
+			return err;
+
+		err = regmap_read(ctx->regmap,
+				  ctx->offset + SEAD3_REG_CPLD_DATA,
+				  &cpld_data);
+		if (err)
+			return err;
+	} while (cpld_data & SEAD3_REG_CPLD_DATA_BUSY);
+
+	return 0;
+}
+
+static void sead3_update(struct img_ascii_lcd_ctx *ctx)
+{
+	unsigned int i;
+	int err;
+
+	for (i = 0; i < ctx->cfg->num_chars; i++) {
+		err = sead3_wait_lcd_idle(ctx);
+		if (err)
+			break;
+
+		err = regmap_write(ctx->regmap,
+				   ctx->offset + SEAD3_REG_LCD_CTRL,
+				   SEAD3_REG_LCD_CTRL_SETDRAM | i);
+		if (err)
+			break;
+
+		err = sead3_wait_lcd_idle(ctx);
+		if (err)
+			break;
+
+		err = regmap_write(ctx->regmap,
+				   ctx->offset + SEAD3_REG_LCD_DATA,
+				   ctx->curr[i]);
+		if (err)
+			break;
+	}
+
+	if (unlikely(err))
+		pr_err_ratelimited("Failed to update LCD display: %d\n", err);
+}
+
+static struct img_ascii_lcd_config sead3_config = {
+	.num_chars = 16,
+	.external_regmap = true,
+	.update = sead3_update,
+};
+
+static const struct of_device_id img_ascii_lcd_matches[] = {
+	{ .compatible = "img,boston-lcd", .data = &boston_config },
+	{ .compatible = "mti,malta-lcd", .data = &malta_config },
+	{ .compatible = "mti,sead3-lcd", .data = &sead3_config },
+};
+
+/**
+ * img_ascii_lcd_scroll() - scroll the display by a character
+ * @arg: really a pointer to the private data structure
+ *
+ * Scroll the current message along the LCD by one character, rearming the
+ * timer if required.
+ */
+static void img_ascii_lcd_scroll(unsigned long arg)
+{
+	struct img_ascii_lcd_ctx *ctx = (struct img_ascii_lcd_ctx *)arg;
+	unsigned int i, ch = ctx->scroll_pos;
+	unsigned int num_chars = ctx->cfg->num_chars;
+
+	/* update the current message string */
+	for (i = 0; i < num_chars;) {
+		/* copy as many characters from the string as possible */
+		for (; i < num_chars && ch < ctx->message_len; i++, ch++)
+			ctx->curr[i] = ctx->message[ch];
+
+		/* wrap around to the start of the string */
+		ch = 0;
+	}
+
+	/* update the LCD */
+	ctx->cfg->update(ctx);
+
+	/* move on to the next character */
+	ctx->scroll_pos++;
+	ctx->scroll_pos %= ctx->message_len;
+
+	/* rearm the timer */
+	if (ctx->message_len > ctx->cfg->num_chars)
+		mod_timer(&ctx->timer, jiffies + ctx->scroll_rate);
+}
+
+/**
+ * img_ascii_lcd_display() - set the message to be displayed
+ * @ctx: pointer to the private data structure
+ * @msg: the message to display
+ * @count: length of msg, or -1
+ *
+ * Display a new message @msg on the LCD. @msg can be longer than the number of
+ * characters the LCD can display, in which case it will begin scrolling across
+ * the LCD display.
+ *
+ * Return: 0 on success, -ENOMEM on memory allocation failure
+ */
+static int img_ascii_lcd_display(struct img_ascii_lcd_ctx *ctx,
+			     const char *msg, ssize_t count)
+{
+	char *new_msg;
+
+	/* stop the scroll timer */
+	del_timer_sync(&ctx->timer);
+
+	if (count == -1)
+		count = strlen(msg);
+
+	/* if the string ends with a newline, trim it */
+	if (msg[count - 1] == '\n')
+		count--;
+
+	new_msg = devm_kmalloc(&ctx->pdev->dev, count + 1, GFP_KERNEL);
+	if (!new_msg)
+		return -ENOMEM;
+
+	memcpy(new_msg, msg, count);
+	new_msg[count] = 0;
+
+	if (ctx->message)
+		devm_kfree(&ctx->pdev->dev, ctx->message);
+
+	ctx->message = new_msg;
+	ctx->message_len = count;
+	ctx->scroll_pos = 0;
+
+	/* update the LCD */
+	img_ascii_lcd_scroll((unsigned long)ctx);
+
+	return 0;
+}
+
+/**
+ * message_show() - read message via sysfs
+ * @dev: the LCD device
+ * @attr: the LCD message attribute
+ * @buf: the buffer to read the message into
+ *
+ * Read the current message being displayed or scrolled across the LCD display
+ * into @buf, for reads from sysfs.
+ *
+ * Return: the number of characters written to @buf
+ */
+static ssize_t message_show(struct device *dev, struct device_attribute *attr,
+			    char *buf)
+{
+	struct img_ascii_lcd_ctx *ctx = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%s\n", ctx->message);
+}
+
+/**
+ * message_store() - write a new message via sysfs
+ * @dev: the LCD device
+ * @attr: the LCD message attribute
+ * @buf: the buffer containing the new message
+ * @count: the size of the message in @buf
+ *
+ * Write a new message to display or scroll across the LCD display from sysfs.
+ *
+ * Return: the size of the message on success, else -ERRNO
+ */
+static ssize_t message_store(struct device *dev, struct device_attribute *attr,
+			     const char *buf, size_t count)
+{
+	struct img_ascii_lcd_ctx *ctx = dev_get_drvdata(dev);
+	int err;
+
+	err = img_ascii_lcd_display(ctx, buf, count);
+	return err ?: count;
+}
+
+static DEVICE_ATTR_RW(message);
+
+/**
+ * img_ascii_lcd_probe() - probe an LCD display device
+ * @pdev: the LCD platform device
+ *
+ * Probe an LCD display device, ensuring that we have the required resources in
+ * order to access the LCD & setting up private data as well as sysfs files.
+ *
+ * Return: 0 on success, else -ERRNO
+ */
+static int img_ascii_lcd_probe(struct platform_device *pdev)
+{
+	const struct of_device_id *match;
+	const struct img_ascii_lcd_config *cfg;
+	struct img_ascii_lcd_ctx *ctx;
+	struct resource *res;
+	int err;
+
+	match = of_match_device(img_ascii_lcd_matches, &pdev->dev);
+	if (!match)
+		return -ENODEV;
+
+	cfg = match->data;
+	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx) + cfg->num_chars,
+			   GFP_KERNEL);
+	if (!ctx)
+		return -ENOMEM;
+
+	if (cfg->external_regmap) {
+		ctx->regmap = syscon_node_to_regmap(pdev->dev.parent->of_node);
+		if (IS_ERR(ctx->regmap))
+			return PTR_ERR(ctx->regmap);
+
+		if (of_property_read_u32(pdev->dev.of_node, "offset",
+					 &ctx->offset))
+			return -EINVAL;
+	} else {
+		res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+		ctx->base = devm_ioremap_resource(&pdev->dev, res);
+		if (IS_ERR(ctx->base))
+			return PTR_ERR(ctx->base);
+	}
+
+	ctx->pdev = pdev;
+	ctx->cfg = cfg;
+	ctx->message = NULL;
+	ctx->scroll_pos = 0;
+	ctx->scroll_rate = HZ / 2;
+
+	/* initialise a timer for scrolling the message */
+	init_timer(&ctx->timer);
+	ctx->timer.function = img_ascii_lcd_scroll;
+	ctx->timer.data = (unsigned long)ctx;
+
+	platform_set_drvdata(pdev, ctx);
+
+	/* display a default message */
+	err = img_ascii_lcd_display(ctx, "Linux " UTS_RELEASE "       ", -1);
+	if (err)
+		goto out_del_timer;
+
+	err = device_create_file(&pdev->dev, &dev_attr_message);
+	if (err)
+		goto out_del_timer;
+
+	return 0;
+out_del_timer:
+	del_timer_sync(&ctx->timer);
+	return err;
+}
+
+/**
+ * img_ascii_lcd_remove() - remove an LCD display device
+ * @pdev: the LCD platform device
+ *
+ * Remove an LCD display device, freeing private resources & ensuring that the
+ * driver stops using the LCD display registers.
+ *
+ * Return: 0
+ */
+static int img_ascii_lcd_remove(struct platform_device *pdev)
+{
+	struct img_ascii_lcd_ctx *ctx = platform_get_drvdata(pdev);
+
+	device_remove_file(&pdev->dev, &dev_attr_message);
+	del_timer_sync(&ctx->timer);
+	return 0;
+}
+
+static struct platform_driver img_ascii_lcd_driver = {
+	.driver = {
+		.name		= "img-ascii-lcd",
+		.of_match_table	= img_ascii_lcd_matches,
+	},
+	.probe	= img_ascii_lcd_probe,
+	.remove	= img_ascii_lcd_remove,
+};
+module_platform_driver(img_ascii_lcd_driver);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 18/19] MIPS: SEAD3: Use img-ascii-lcd driver
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (16 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 17/19] auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  2016-08-26 14:17 ` [PATCH v2 19/19] MIPS: SEAD3: Remove custom read_persistent_clock Paul Burton
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle
  Cc: Paul Burton, devicetree, Jacek Anaszewski, linux-kernel,
	Rob Herring, Mark Rutland

Probe the img-ascii-lcd driver using device tree in order to display a
message on the SEAD3 board's LCD display, and remove the platform code
that was formerly performing this function. This removes more platform
code and moves SEAD3 further towards being entirely DT-based.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2: None

 arch/mips/boot/dts/mti/sead3.dts    |  5 +++
 arch/mips/mti-sead3/Makefile        |  3 +-
 arch/mips/mti-sead3/sead3-display.c | 77 -------------------------------------
 arch/mips/mti-sead3/sead3-time.c    |  2 -
 4 files changed, 6 insertions(+), 81 deletions(-)
 delete mode 100644 arch/mips/mti-sead3/sead3-display.c

diff --git a/arch/mips/boot/dts/mti/sead3.dts b/arch/mips/boot/dts/mti/sead3.dts
index 32a5ab9..2579ca5 100644
--- a/arch/mips/boot/dts/mti/sead3.dts
+++ b/arch/mips/boot/dts/mti/sead3.dts
@@ -210,6 +210,11 @@
 			mask = <0x80>;
 			label = "fled7";
 		};
+
+		lcd@200 {
+			compatible = "mti,sead3-lcd";
+			offset = <0x200>;
+		};
 	};
 
 	/* UART connected to FTDI & miniUSB socket */
diff --git a/arch/mips/mti-sead3/Makefile b/arch/mips/mti-sead3/Makefile
index cb6d620..1674b9c 100644
--- a/arch/mips/mti-sead3/Makefile
+++ b/arch/mips/mti-sead3/Makefile
@@ -8,8 +8,7 @@
 # Copyright (C) 2012 MIPS Technoligies, Inc.  All rights reserved.
 # Steven J. Hill <sjhill@mips.com>
 #
-obj-y := sead3-display.o
-obj-y += sead3-dtshim.o
+obj-y := sead3-dtshim.o
 obj-y += sead3-init.o
 obj-y += sead3-int.o
 obj-y += sead3-setup.o
diff --git a/arch/mips/mti-sead3/sead3-display.c b/arch/mips/mti-sead3/sead3-display.c
deleted file mode 100644
index 9487599..0000000
--- a/arch/mips/mti-sead3/sead3-display.c
+++ /dev/null
@@ -1,77 +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/timer.h>
-#include <linux/io.h>
-#include <asm/mips-boards/generic.h>
-
-static unsigned int display_count;
-static unsigned int max_display_count;
-
-#define LCD_DISPLAY_POS_BASE		0x1f000400
-#define DISPLAY_LCDINSTRUCTION		(0*2)
-#define DISPLAY_LCDDATA			(1*2)
-#define DISPLAY_CPLDSTATUS		(2*2)
-#define DISPLAY_CPLDDATA		(3*2)
-#define LCD_SETDDRAM			0x80
-#define LCD_IR_BF			0x80
-
-const char display_string[] = "		      LINUX ON SEAD3		   ";
-
-static void scroll_display_message(unsigned long data);
-static DEFINE_TIMER(mips_scroll_timer, scroll_display_message, HZ, 0);
-
-static void lcd_wait(unsigned int __iomem *display)
-{
-	/* Wait for CPLD state machine to become idle. */
-	do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);
-
-	do {
-		__raw_readl(display + DISPLAY_LCDINSTRUCTION);
-
-		/* Wait for CPLD state machine to become idle. */
-		do { } while (__raw_readl(display + DISPLAY_CPLDSTATUS) & 1);
-	} while (__raw_readl(display + DISPLAY_CPLDDATA) & LCD_IR_BF);
-}
-
-void mips_display_message(const char *str)
-{
-	static unsigned int __iomem *display;
-	char ch;
-	int i;
-
-	if (unlikely(display == NULL))
-		display = ioremap_nocache(LCD_DISPLAY_POS_BASE,
-			(8 * sizeof(int)));
-
-	for (i = 0; i < 16; i++) {
-		if (*str)
-			ch = *str++;
-		else
-			ch = ' ';
-		lcd_wait(display);
-		__raw_writel((LCD_SETDDRAM | i),
-			(display + DISPLAY_LCDINSTRUCTION));
-		lcd_wait(display);
-		__raw_writel(ch, display + DISPLAY_LCDDATA);
-	}
-}
-
-static void scroll_display_message(unsigned long data)
-{
-	mips_display_message(&display_string[display_count++]);
-	if (display_count == max_display_count)
-		display_count = 0;
-	mod_timer(&mips_scroll_timer, jiffies + HZ);
-}
-
-void mips_scroll_message(void)
-{
-	del_timer_sync(&mips_scroll_timer);
-	max_display_count = strlen(display_string) + 1 - 16;
-	mod_timer(&mips_scroll_timer, jiffies + 1);
-}
diff --git a/arch/mips/mti-sead3/sead3-time.c b/arch/mips/mti-sead3/sead3-time.c
index a120b7a..10b0bf3 100644
--- a/arch/mips/mti-sead3/sead3-time.c
+++ b/arch/mips/mti-sead3/sead3-time.c
@@ -94,6 +94,4 @@ void __init plat_time_init(void)
 
 	pr_debug("CPU frequency %d.%02d MHz\n", (est_freq / 1000000),
 		(est_freq % 1000000) * 100 / 1000000);
-
-	mips_scroll_message();
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* [PATCH v2 19/19] MIPS: SEAD3: Remove custom read_persistent_clock
  2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
                   ` (17 preceding siblings ...)
  2016-08-26 14:17 ` [PATCH v2 18/19] MIPS: SEAD3: Use img-ascii-lcd driver Paul Burton
@ 2016-08-26 14:17 ` Paul Burton
  18 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-26 14:17 UTC (permalink / raw)
  To: linux-mips, Ralf Baechle; +Cc: Paul Burton, linux-kernel

The SEAD3 board defines a custom implementation of read_persistent_clock
which does exactly the same dummy operation as the generic weak version.
Remove the not really implemented custom version.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>

---

Changes in v2: None

 arch/mips/mti-sead3/sead3-time.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/mips/mti-sead3/sead3-time.c b/arch/mips/mti-sead3/sead3-time.c
index 10b0bf3..71feb51 100644
--- a/arch/mips/mti-sead3/sead3-time.c
+++ b/arch/mips/mti-sead3/sead3-time.c
@@ -63,12 +63,6 @@ static unsigned int __init estimate_cpu_frequency(void)
 	return freq ;
 }
 
-void read_persistent_clock(struct timespec *ts)
-{
-	ts->tv_sec = 0;
-	ts->tv_nsec = 0;
-}
-
 int get_c0_perfcount_int(void)
 {
 	if (gic_present)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 07/19] usb: host: ehci-sead3: Remove SEAD-3 EHCI code
  2016-08-26 14:17 ` [PATCH v2 07/19] usb: host: ehci-sead3: Remove SEAD-3 EHCI code Paul Burton
@ 2016-08-26 15:55   ` Alan Stern
  0 siblings, 0 replies; 25+ messages in thread
From: Alan Stern @ 2016-08-26 15:55 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Ralf Baechle, Greg Kroah-Hartman, linux-kernel, linux-usb

On Fri, 26 Aug 2016, Paul Burton wrote:

> The SEAD-3 board is now probing its EHCI controller using the generic
> EHCI driver & its generic-ehci device tree binding. Remove the unused
> SEAD-3 specific EHCI code.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> 
> ---
> 
> Changes in v2:
> - New patch, removing SEAD-3 EHCI code instead of extending it
> 
>  drivers/usb/host/ehci-hcd.c   |   5 --
>  drivers/usb/host/ehci-sead3.c | 185 ------------------------------------------
>  2 files changed, 190 deletions(-)
>  delete mode 100644 drivers/usb/host/ehci-sead3.c

Acked-by: Alan Stern <stern@rowland.harvard.edu>

I hardly ever object to getting rid of code...  :-)

Alan Stern

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 10/19] leds: Remove SEAD3 driver
  2016-08-26 14:17 ` [PATCH v2 10/19] leds: Remove SEAD3 driver Paul Burton
@ 2016-08-29  8:55   ` Jacek Anaszewski
  2016-08-30 14:42     ` Paul Burton
  0 siblings, 1 reply; 25+ messages in thread
From: Jacek Anaszewski @ 2016-08-29  8:55 UTC (permalink / raw)
  To: Paul Burton, linux-mips, Ralf Baechle
  Cc: Richard Purdie, linux-leds, linux-kernel

Hi Paul,

On 08/26/2016 04:17 PM, Paul Burton wrote:
> SEAD3 is now using the generic syscon & regmap based register-bit-led
> driver, so remove the unused custom SEAD3 LED driver.
>
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> ---
>
> Changes in v2: None
>
>  drivers/leds/Kconfig      | 10 ------
>  drivers/leds/Makefile     |  1 -
>  drivers/leds/leds-sead3.c | 78 -----------------------------------------------
>  3 files changed, 89 deletions(-)
>  delete mode 100644 drivers/leds/leds-sead3.c
>
> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
> index 9dcc9b1..025de7e 100644
> --- a/drivers/leds/Kconfig
> +++ b/drivers/leds/Kconfig
> @@ -574,16 +574,6 @@ config LEDS_KTD2692
>
>  	  Say Y to enable this driver.
>
> -config LEDS_SEAD3
> -	tristate "LED support for the MIPS SEAD 3 board"
> -	depends on LEDS_CLASS && MIPS_SEAD3
> -	help
> -	  Say Y here to include support for the FLED and PLED LEDs on SEAD3 eval
> -	  boards.
> -
> -	  This driver can also be built as a module. If so the module
> -	  will be called leds-sead3.
> -
>  config LEDS_IS31FL32XX
>  	tristate "LED support for ISSI IS31FL32XX I2C LED controller family"
>  	depends on LEDS_CLASS && I2C && OF
> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
> index 0684c86..da594cf 100644
> --- a/drivers/leds/Makefile
> +++ b/drivers/leds/Makefile
> @@ -66,7 +66,6 @@ obj-$(CONFIG_LEDS_VERSATILE)		+= leds-versatile.o
>  obj-$(CONFIG_LEDS_MENF21BMC)		+= leds-menf21bmc.o
>  obj-$(CONFIG_LEDS_KTD2692)		+= leds-ktd2692.o
>  obj-$(CONFIG_LEDS_POWERNV)		+= leds-powernv.o
> -obj-$(CONFIG_LEDS_SEAD3)		+= leds-sead3.o
>  obj-$(CONFIG_LEDS_IS31FL32XX)		+= leds-is31fl32xx.o
>
>  # LED SPI Drivers
> diff --git a/drivers/leds/leds-sead3.c b/drivers/leds/leds-sead3.c
> deleted file mode 100644
> index eb97a32..0000000
> --- a/drivers/leds/leds-sead3.c
> +++ /dev/null
> @@ -1,78 +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) 2015 Imagination Technologies, Inc.
> - */
> -#include <linux/kernel.h>
> -#include <linux/module.h>
> -#include <linux/init.h>
> -#include <linux/platform_device.h>
> -#include <linux/leds.h>
> -#include <linux/err.h>
> -#include <linux/io.h>
> -
> -#include <asm/mips-boards/sead3-addr.h>
> -
> -static void sead3_pled_set(struct led_classdev *led_cdev,
> -		enum led_brightness value)
> -{
> -	writel(value, (void __iomem *)SEAD3_CPLD_P_LED);
> -}
> -
> -static void sead3_fled_set(struct led_classdev *led_cdev,
> -		enum led_brightness value)
> -{
> -	writel(value, (void __iomem *)SEAD3_CPLD_F_LED);
> -}
> -
> -static struct led_classdev sead3_pled = {
> -	.name		= "sead3::pled",
> -	.brightness_set = sead3_pled_set,
> -	.flags		= LED_CORE_SUSPENDRESUME,
> -};
> -
> -static struct led_classdev sead3_fled = {
> -	.name		= "sead3::fled",
> -	.brightness_set = sead3_fled_set,
> -	.flags		= LED_CORE_SUSPENDRESUME,
> -};
> -
> -static int sead3_led_probe(struct platform_device *pdev)
> -{
> -	int ret;
> -
> -	ret = led_classdev_register(&pdev->dev, &sead3_pled);
> -	if (ret < 0)
> -		return ret;
> -
> -	ret = led_classdev_register(&pdev->dev, &sead3_fled);
> -	if (ret < 0)
> -		led_classdev_unregister(&sead3_pled);
> -
> -	return ret;
> -}
> -
> -static int sead3_led_remove(struct platform_device *pdev)
> -{
> -	led_classdev_unregister(&sead3_pled);
> -	led_classdev_unregister(&sead3_fled);
> -
> -	return 0;
> -}
> -
> -static struct platform_driver sead3_led_driver = {
> -	.probe		= sead3_led_probe,
> -	.remove		= sead3_led_remove,
> -	.driver		= {
> -		.name		= "sead3-led",
> -	},
> -};
> -
> -module_platform_driver(sead3_led_driver);
> -
> -MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
> -MODULE_DESCRIPTION("SEAD3 LED driver");
> -MODULE_LICENSE("GPL");
>

Currently the patch doesn't apply cleanly on the linux-leds.git,
for-next branch, due to the fresh changes in the surrounding code in
the drivers/leds/Makefile and Kconfig. Does this patch depend on
the previous patches in this series, or I can take it now and apply
to the LEDs git?

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 10/19] leds: Remove SEAD3 driver
  2016-08-29  8:55   ` Jacek Anaszewski
@ 2016-08-30 14:42     ` Paul Burton
  0 siblings, 0 replies; 25+ messages in thread
From: Paul Burton @ 2016-08-30 14:42 UTC (permalink / raw)
  To: Jacek Anaszewski, Ralf Baechle
  Cc: linux-mips, Richard Purdie, linux-leds, linux-kernel

On 29/08/16 09:55, Jacek Anaszewski wrote:
> Hi Paul,
> 
> On 08/26/2016 04:17 PM, Paul Burton wrote:
>> SEAD3 is now using the generic syscon & regmap based register-bit-led
>> driver, so remove the unused custom SEAD3 LED driver.
>>
>> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
>> ---
>>
>> Changes in v2: None
>>
>>  drivers/leds/Kconfig      | 10 ------
>>  drivers/leds/Makefile     |  1 -
>>  drivers/leds/leds-sead3.c | 78 -----------------------------------------------
>>  3 files changed, 89 deletions(-)
>>  delete mode 100644 drivers/leds/leds-sead3.c
>>
>> diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig
>> index 9dcc9b1..025de7e 100644
>> --- a/drivers/leds/Kconfig
>> +++ b/drivers/leds/Kconfig
>> @@ -574,16 +574,6 @@ config LEDS_KTD2692
>>
>>        Say Y to enable this driver.
>>
>> -config LEDS_SEAD3
>> -    tristate "LED support for the MIPS SEAD 3 board"
>> -    depends on LEDS_CLASS && MIPS_SEAD3
>> -    help
>> -      Say Y here to include support for the FLED and PLED LEDs on SEAD3 eval
>> -      boards.
>> -
>> -      This driver can also be built as a module. If so the module
>> -      will be called leds-sead3.
>> -
>>  config LEDS_IS31FL32XX
>>      tristate "LED support for ISSI IS31FL32XX I2C LED controller family"
>>      depends on LEDS_CLASS && I2C && OF
>> diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile
>> index 0684c86..da594cf 100644
>> --- a/drivers/leds/Makefile
>> +++ b/drivers/leds/Makefile
>> @@ -66,7 +66,6 @@ obj-$(CONFIG_LEDS_VERSATILE)        += leds-versatile.o
>>  obj-$(CONFIG_LEDS_MENF21BMC)        += leds-menf21bmc.o
>>  obj-$(CONFIG_LEDS_KTD2692)        += leds-ktd2692.o
>>  obj-$(CONFIG_LEDS_POWERNV)        += leds-powernv.o
>> -obj-$(CONFIG_LEDS_SEAD3)        += leds-sead3.o
>>  obj-$(CONFIG_LEDS_IS31FL32XX)        += leds-is31fl32xx.o
>>
>>  # LED SPI Drivers
>> diff --git a/drivers/leds/leds-sead3.c b/drivers/leds/leds-sead3.c
>> deleted file mode 100644
>> index eb97a32..0000000
>> --- a/drivers/leds/leds-sead3.c
>> +++ /dev/null
>> @@ -1,78 +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) 2015 Imagination Technologies, Inc.
>> - */
>> -#include <linux/kernel.h>
>> -#include <linux/module.h>
>> -#include <linux/init.h>
>> -#include <linux/platform_device.h>
>> -#include <linux/leds.h>
>> -#include <linux/err.h>
>> -#include <linux/io.h>
>> -
>> -#include <asm/mips-boards/sead3-addr.h>
>> -
>> -static void sead3_pled_set(struct led_classdev *led_cdev,
>> -        enum led_brightness value)
>> -{
>> -    writel(value, (void __iomem *)SEAD3_CPLD_P_LED);
>> -}
>> -
>> -static void sead3_fled_set(struct led_classdev *led_cdev,
>> -        enum led_brightness value)
>> -{
>> -    writel(value, (void __iomem *)SEAD3_CPLD_F_LED);
>> -}
>> -
>> -static struct led_classdev sead3_pled = {
>> -    .name        = "sead3::pled",
>> -    .brightness_set = sead3_pled_set,
>> -    .flags        = LED_CORE_SUSPENDRESUME,
>> -};
>> -
>> -static struct led_classdev sead3_fled = {
>> -    .name        = "sead3::fled",
>> -    .brightness_set = sead3_fled_set,
>> -    .flags        = LED_CORE_SUSPENDRESUME,
>> -};
>> -
>> -static int sead3_led_probe(struct platform_device *pdev)
>> -{
>> -    int ret;
>> -
>> -    ret = led_classdev_register(&pdev->dev, &sead3_pled);
>> -    if (ret < 0)
>> -        return ret;
>> -
>> -    ret = led_classdev_register(&pdev->dev, &sead3_fled);
>> -    if (ret < 0)
>> -        led_classdev_unregister(&sead3_pled);
>> -
>> -    return ret;
>> -}
>> -
>> -static int sead3_led_remove(struct platform_device *pdev)
>> -{
>> -    led_classdev_unregister(&sead3_pled);
>> -    led_classdev_unregister(&sead3_fled);
>> -
>> -    return 0;
>> -}
>> -
>> -static struct platform_driver sead3_led_driver = {
>> -    .probe        = sead3_led_probe,
>> -    .remove        = sead3_led_remove,
>> -    .driver        = {
>> -        .name        = "sead3-led",
>> -    },
>> -};
>> -
>> -module_platform_driver(sead3_led_driver);
>> -
>> -MODULE_AUTHOR("Kristian Kielhofner <kris@krisk.org>");
>> -MODULE_DESCRIPTION("SEAD3 LED driver");
>> -MODULE_LICENSE("GPL");
>>
> 
> Currently the patch doesn't apply cleanly on the linux-leds.git,
> for-next branch, due to the fresh changes in the surrounding code in
> the drivers/leds/Makefile and Kconfig. Does this patch depend on
> the previous patches in this series, or I can take it now and apply
> to the LEDs git?

Hi Jacek,

Ideally the patches to the SEAD-3 board code & DT would go in first such
that the board switches to the register-bit-led driver before this
custom driver is removed. Otherwise we'll lose support for the LEDs in
between you applying this patch & Ralf applying the rest.

Having said that I doubt anyone actually uses the SEAD-3 LEDs so I don't
mind so much if you & Ralf decide that's the easiest path forwards.

Thanks,
    Paul

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 16/19] dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs
  2016-08-26 14:17 ` [PATCH v2 16/19] dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs Paul Burton
@ 2016-08-31 16:18   ` Rob Herring
  0 siblings, 0 replies; 25+ messages in thread
From: Rob Herring @ 2016-08-31 16:18 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Ralf Baechle, Mauro Carvalho Chehab, devicetree,
	Guenter Roeck, linux-kernel, David S. Miller, Greg Kroah-Hartman,
	Geert Uytterhoeven, Mark Rutland, Andrew Morton

On Fri, Aug 26, 2016 at 03:17:48PM +0100, Paul Burton wrote:
> Add documentation for a devicetree binding for the simple ASCII LCD
> displays found on development boards such as the MIPS Boston, MIPS Malta
> & MIPS SEAD3 from Imagination Technologies.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>
> 
> ---
> 
> Changes in v2:
> - Fix filename & path in MAINTAINERS
> 
>  .../devicetree/bindings/auxdisplay/img-ascii-lcd.txt    | 17 +++++++++++++++++
>  MAINTAINERS                                             |  5 +++++
>  2 files changed, 22 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/auxdisplay/img-ascii-lcd.txt

Acked-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 25+ messages in thread

* Re: [PATCH v2 17/19] auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays
  2016-08-26 14:17 ` [PATCH v2 17/19] auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays Paul Burton
@ 2016-09-27 18:52   ` Ralf Baechle
  0 siblings, 0 replies; 25+ messages in thread
From: Ralf Baechle @ 2016-09-27 18:52 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, Mauro Carvalho Chehab, Miguel Ojeda Sandonis,
	linux-kernel, Guenter Roeck, David S. Miller, Greg Kroah-Hartman,
	Geert Uytterhoeven, Andrew Morton

On Fri, Aug 26, 2016 at 03:17:49PM +0100, Paul Burton wrote:

> Add a driver for simple ASCII LCD displays found on the MIPS Boston,
> Malta & SEAD3 development boards. The Boston display is an independent
> memory mapped device with a simple memory mapped 8 byte register space
> containing the 8 ASCII characters to display. The Malta display is
> exposed as part of the Malta board registers, and provides 8 registers
> each of which corresponds to one of the ASCII characters to display. The
> SEAD3 display is slightly more complex, exposing an interface to an
> S6A0069 LCD controller via registers provided by the boards CPLD.
> However although the displays differ in their register interface, we
> require similar functionality on each board so abstracting away the
> differences within a single driver allows us to share a significant
> amount of code & ensure consistent behaviour.
> 
> The driver displays the Linux kernel version as the default message, but
> allows the message to be changed via a character device. Messages longer
> then the number of characters that the display can show will scroll.
> 
> This provides different behaviour to the existing LCD display code for
> the MIPS Malta or MIPS SEAD3 platforms in the following ways:
> 
>   - The default string to display is not "LINUX ON MALTA" or "LINUX ON
>     SEAD3" but "Linux" followed by the version number of the kernel
>     (UTS_RELEASE).
> 
>   - Since that string tends to be significantly longer it scrolls twice
>     as fast, moving every 500ms rather than every 1s.
> 
>   - The LCD won't be updated until the driver is probed, so it doesn't
>     provide the early "LINUX" string.

Right now parts 15..18 of this series are stalled due to the lack of an
ack for this patch.

Miguel?

  Ralf

^ permalink raw reply	[flat|nested] 25+ messages in thread

end of thread, other threads:[~2016-09-27 18:52 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-26 14:17 [PATCH v2 00/19] MIPS: SEAD3 device tree conversion Paul Burton
2016-08-26 14:17 ` [PATCH v2 01/19] MIPS: SEAD3: Split obj-y entries across lines Paul Burton
2016-08-26 14:17 ` [PATCH v2 02/19] MIPS: SEAD3: Probe interrupt controllers using DT Paul Burton
2016-08-26 14:17 ` [PATCH v2 03/19] MIPS: SEAD3: Probe UARTs " Paul Burton
2016-08-26 14:17 ` [PATCH v2 04/19] MIPS: SEAD3: Use generic ns16550a earlycon support Paul Burton
2016-08-26 14:17 ` [PATCH v2 05/19] MIPS: SEAD3: Probe ethernet controller using DT Paul Burton
2016-08-26 14:17 ` [PATCH v2 06/19] MIPS: SEAD3: Probe EHCI " Paul Burton
2016-08-26 14:17 ` [PATCH v2 07/19] usb: host: ehci-sead3: Remove SEAD-3 EHCI code Paul Burton
2016-08-26 15:55   ` Alan Stern
2016-08-26 14:17 ` [PATCH v2 08/19] SEAD3: Probe parallel flash via DT Paul Burton
2016-08-26 14:17 ` [PATCH v2 09/19] MIPS: SEAD3: Use register-bit-led driver via DT for LEDs Paul Burton
2016-08-26 14:17 ` [PATCH v2 10/19] leds: Remove SEAD3 driver Paul Burton
2016-08-29  8:55   ` Jacek Anaszewski
2016-08-30 14:42     ` Paul Burton
2016-08-26 14:17 ` [PATCH v2 11/19] MIPS: SEAD3: Reset via generic syscon-reboot driver & DT Paul Burton
2016-08-26 14:17 ` [PATCH v2 12/19] MIPS: SEAD3: Use generic restart-poweroff driver Paul Burton
2016-08-26 14:17 ` [PATCH v2 13/19] MIPS: SEAD3: Parse memsize in DT shim Paul Burton
2016-08-26 14:17 ` [PATCH v2 14/19] MIPS: SEAD3: Drop use of cobalt fbdev driver Paul Burton
2016-08-26 14:17 ` [PATCH v2 15/19] fbdev: cobalt_lcdfb: Drop SEAD3 support Paul Burton
2016-08-26 14:17 ` [PATCH v2 16/19] dt-bindings: img-ascii-lcd: Document a binding for simple ASCII LCDs Paul Burton
2016-08-31 16:18   ` Rob Herring
2016-08-26 14:17 ` [PATCH v2 17/19] auxdisplay: img-ascii-lcd: driver for simple ASCII LCD displays Paul Burton
2016-09-27 18:52   ` Ralf Baechle
2016-08-26 14:17 ` [PATCH v2 18/19] MIPS: SEAD3: Use img-ascii-lcd driver Paul Burton
2016-08-26 14:17 ` [PATCH v2 19/19] MIPS: SEAD3: Remove custom read_persistent_clock Paul Burton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).