Skip to contentSkip to conversation

MIPS: ath79: Add OF support and DTS for TL-WR1043ND

PATCH In review Alban Bedel 5 participants 22 messages May 30, 2015 – Jun 22, 2015

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

v4 cover MIPS: ath79: Add OF support and DTS for TL-WR1043ND

This series add OF bindings and code support for the interrupt controllers, clocks and GPIOs. However it was only tested on a TL-WR1043ND with an AR9132, others SoCs are untested, and a few are not supported at all.

Most code changes base on the previous bug fix series:
[PATCH v2 0/5] MIPS: ath79: Various small fix to prepare OF support

The requested patch to move the GPIO driver to drivers/gpio is ready and will follow once it is clearer if this serie get merged.

ChangeLog:
v2: * Fixed the OF bindings and DTS to use ePAPR standardized names
* Fixed the typos in the OF bindings
* Added an ngpios property to the GPIO binding and driver
* Removed all the soc_is_xxx() calls out of the GPIO driver probe()
* Updated the DTS patches to the new directory structure and merged both in one. Having 3 patches to add Makefile, SoC dtsi and board DTS seemed a bit overkill.
* Moved the patch to use the common clk API to the bug fix serie to keep this one cleaner.

v3: * Moved the builtin DTB menu to the patch adding the TL-WR1043ND DTS
* Made the builtin DTB menu optional
* Fixed more typos
* Really fixed the DDR controller binding example to use ePAPR names
* Fixed the qca9550 compatible string in the PLL bindings and driver
* Fixed the example in the GPIO controller binding
* Moved the new vendor entry to the correct place

v4: * Added the missing Signed-off-by on patch 08
* Whitspace fix in the GPIO controller binding
* Always build the DTB to improve testing coverage
* Added the SPI controller and flash to the DTS as the binding for the SPI controller has been accepted in the SPI tree

Alban Bedel (12):
devicetree: Add bindings for the SoC of the ATH79 family
MIPS: ath79: Add basic device tree support
devicetree: Add bindings for the ATH79 DDR controllers
devicetree: Add bindings for the ATH79 interrupt controllers
devicetree: Add bindings for the ATH79 MISC interrupt controllers
MIPS: ath79: Add OF support to the IRQ controllers
devicetree: Add bindings for the ATH79 PLL controllers
MIPS: ath79: Add OF support to the clocks
devicetree: Add bindings for the ATH79 GPIO controllers
MIPS: ath79: Add OF support to the GPIO driver
of: Add vendor prefix for TP-Link Technologies Co. Ltd
MIPS: Add basic support for the TL-WR1043ND version 1

 .../devicetree/bindings/clock/qca,ath79-pll.txt    |  33 +++++
 .../devicetree/bindings/gpio/gpio-ath79.txt        |  38 ++++++
 .../interrupt-controller/qca,ath79-cpu-intc.txt    |  44 +++++++
 .../interrupt-controller/qca,ath79-misc-intc.txt   |  30 +++++
 .../memory-controllers/ath79-ddr-controller.txt    |  35 ++++++
 .../devicetree/bindings/mips/ath79-soc.txt         |  21 ++++
 .../devicetree/bindings/vendor-prefixes.txt        |   1 +
 arch/mips/Kconfig                                  |   1 +
 arch/mips/ath79/Kconfig                            |  12 ++
 arch/mips/ath79/clock.c                            |  63 +++++++---
 arch/mips/ath79/dev-common.c                       |  51 ++++++++
 arch/mips/ath79/gpio.c                             |  79 ++++++++----
 arch/mips/ath79/irq.c                              |  87 +++++++++++++-
 arch/mips/ath79/machtypes.h                        |   1 +
 arch/mips/ath79/setup.c                            |  27 ++++-
 arch/mips/boot/dts/Makefile                        |   1 +
 arch/mips/boot/dts/qca/Makefile                    |  11 ++
 arch/mips/boot/dts/qca/ar9132.dtsi                 | 133 +++++++++++++++++++++
 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts   | 112 +++++++++++++++++
 include/linux/platform_data/gpio-ath79.h           |  19 +++
 20 files changed, 756 insertions(+), 43 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/clock/qca,ath79-pll.txt
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-ath79.txt
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/qca,ath79-cpu-intc.txt
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/qca,ath79-misc-intc.txt
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt
 create mode 100644 Documentation/devicetree/bindings/mips/ath79-soc.txt
 create mode 100644 arch/mips/boot/dts/qca/Makefile
 create mode 100644 arch/mips/boot/dts/qca/ar9132.dtsi
 create mode 100644 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts
 create mode 100644 include/linux/platform_data/gpio-ath79.h
Signature · 1 line
2.0.0
#1 lore raw

PATCH v4 1/12 devicetree: Add bindings for the SoC of the ATH79 family

---
 .../devicetree/bindings/mips/ath79-soc.txt          | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/ath79-soc.txt
Documentation/devicetree/bindings/mips/ath79-soc.txt new file +21 -0
new file mode 100644
index 0000000..88a12a4
@@ -0,0 +1,21 @@
+Binding for Qualcomm Atheros AR7xxx/AR9XXX SoC
+
+Each device tree must specify a compatible value for the AR SoC
+it uses in the compatible property of the root node. The compatible
+value must be one of the following values:
+
+- qca,ar7130
+- qca,ar7141
+- qca,ar7161
+- qca,ar7240
+- qca,ar7241
+- qca,ar7242
+- qca,ar9130
+- qca,ar9132
+- qca,ar9330
+- qca,ar9331
+- qca,ar9341
+- qca,ar9342
+- qca,ar9344
+- qca,qca9556
+- qca,qca9558
Signature · 6 lines
2.0.0

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

PATCH v4 2/12 MIPS: ath79: Add basic device tree support

In reply to Alban Bedel

Add the bare minimum to load a device tree.

---
v3: * Removed the empty Builtin devicetree menu

---
 arch/mips/Kconfig           |  1 +
 arch/mips/ath79/machtypes.h |  1 +
 arch/mips/ath79/setup.c     | 27 ++++++++++++++++++++++++++-
 3 files changed, 28 insertions(+), 1 deletion(-)
arch/mips/Kconfig +1 -0
index 874bbaf..772312d 100644
@@ -133,6 +133,7 @@ config ATH79
 	select SYS_SUPPORTS_BIG_ENDIAN
 	select SYS_SUPPORTS_MIPS16
 	select SYS_SUPPORTS_ZBOOT
+	select USE_OF
 	help
 	  Support for the Atheros AR71XX/AR724X/AR913X SoCs.
 
arch/mips/ath79/machtypes.h +1 -0
index 2625405..a13db3d 100644
@@ -15,6 +15,7 @@
 #include <asm/mips_machine.h>
 
 enum ath79_mach_type {
+	ATH79_MACH_GENERIC_OF = -1,	/* Device tree board */
 	ATH79_MACH_GENERIC = 0,
 	ATH79_MACH_AP121,		/* Atheros AP121 reference board */
 	ATH79_MACH_AP136_010,		/* Atheros AP136-010 reference board */
arch/mips/ath79/setup.c +26 -1
index 74f1af7..01a644f 100644
@@ -17,12 +17,16 @@
 #include <linux/bootmem.h>
 #include <linux/err.h>
 #include <linux/clk.h>
+#include <linux/of_platform.h>
+#include <linux/of_fdt.h>
 
 #include <asm/bootinfo.h>
 #include <asm/idle.h>
 #include <asm/time.h>		/* for mips_hpt_frequency */
 #include <asm/reboot.h>		/* for _machine_{restart,halt} */
 #include <asm/mips_machine.h>
+#include <asm/prom.h>
+#include <asm/fw/fw.h>
 
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
@@ -194,8 +198,19 @@ unsigned int get_c0_compare_int(void)
 
 void __init plat_mem_setup(void)
 {
+	unsigned long fdt_start;
+
 	set_io_port_base(KSEG1);
 
+	/* Get the position of the FDT passed by the bootloader */
+	fdt_start = fw_getenvl("fdt_start");
+	if (fdt_start)
+		__dt_setup_arch((void *)KSEG0ADDR(fdt_start));
+#ifdef CONFIG_BUILTIN_DTB
+	else
+		__dt_setup_arch(__dtb_start);
+#endif
+
 	ath79_reset_base = ioremap_nocache(AR71XX_RESET_BASE,
 					   AR71XX_RESET_SIZE);
 	ath79_pll_base = ioremap_nocache(AR71XX_PLL_BASE,
@@ -203,7 +218,8 @@ void __init plat_mem_setup(void)
 	ath79_ddr_ctrl_init();
 
 	ath79_detect_sys_type();
-	detect_memory_region(0, ATH79_MEM_SIZE_MIN, ATH79_MEM_SIZE_MAX);
+	if (mips_machtype != ATH79_MACH_GENERIC_OF)
+		detect_memory_region(0, ATH79_MEM_SIZE_MIN, ATH79_MEM_SIZE_MAX);
 
 	_machine_restart = ath79_restart;
 	_machine_halt = ath79_halt;
@@ -235,6 +251,10 @@ void __init plat_time_init(void)
 
 static int __init ath79_setup(void)
 {
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+	if  (mips_machtype == ATH79_MACH_GENERIC_OF)
+		return 0;
+
 	ath79_gpio_init();
 	ath79_register_uart();
 	ath79_register_wdt();
@@ -246,6 +266,11 @@ static int __init ath79_setup(void)
 
 arch_initcall(ath79_setup);
 
+void __init device_tree_init(void)
+{
+	unflatten_and_copy_device_tree();
+}
+
 static void __init ath79_generic_init(void)
 {
 	/* Nothing to do */
Signature · 6 lines
2.0.0

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

PATCH v4 3/12 devicetree: Add bindings for the ATH79 DDR controllers

In reply to Alban Bedel

The DDR controller of the ARxxx and AR9xxx families provides an interface to flush the FIFO between various devices and the DDR. This is mainly used by the IRQ controller to flush the FIFO before running the interrupt handler of such devices.

---
v2: * Fix the node names to respect ePAPR
v3: * Fix some typos
* Really fix the node names this time

---
 .../memory-controllers/ath79-ddr-controller.txt    | 35 ++++++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt
Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt new file +35 -0
new file mode 100644
index 0000000..efe35a06
@@ -0,0 +1,35 @@
+Binding for Qualcomm  Atheros AR7xxx/AR9xxx DDR controller
+
+The DDR controller of the ARxxx and AR9xxx families provides an interface
+to flush the FIFO between various devices and the DDR. This is mainly used
+by the IRQ controller to flush the FIFO before running the interrupt handler
+of such devices.
+
+Required properties:
+
+- compatible: has to be "qca,<soc-type>-ddr-controller",
+  "qca,[ar7100|ar7240]-ddr-controller" as fallback.
+  On SoC with PCI support "qca,ar7100-ddr-controller" should be used as
+  fallback, otherwise "qca,ar7240-ddr-controller" should be used.
+- reg: Base address and size of the controllers memory area
+- #qca,ddr-wb-channel-cells: has to be 1, the index of the write buffer
+  channel
+
+Example:
+
+	ddr_ctrl: memory-controller@18000000 {
+		compatible = "qca,ar9132-ddr-controller",
+				"qca,ar7240-ddr-controller";
+		reg = <0x18000000 0x100>;
+
+		#qca,ddr-wb-channel-cells = <1>;
+	};
+
+	...
+
+	interrupt-controller {
+		...
+		qca,ddr-wb-channel-interrupts = <2>, <3>, <4>, <5>;
+		qca,ddr-wb-channels = <&ddr_ctrl 3>, <&ddr_ctrl 2>,
+					<&ddr_ctrl 0>, <&ddr_ctrl 1>;
+	};
Signature · 6 lines
2.0.0

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

Re: [PATCH v4 03/12] devicetree: Add bindings for the ATH79 DDR controllers

Hello.

Quoted 21 lines · Alban Bedel

The DDR controller of the ARxxx and AR9xxx families provides an interface to flush the FIFO between various devices and the DDR. This is mainly used by the IRQ controller to flush the FIFO before running the interrupt handler of such devices.

---
v2: * Fix the node names to respect ePAPR
v3: * Fix some typos
* Really fix the node names this time

---
  .../memory-controllers/ath79-ddr-controller.txt    | 35 ++++++++++++++++++++++
  1 file changed, 35 insertions(+)

create mode 100644 Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt

Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt new file +0 -0
new file mode 100644
index 0000000..efe35a06

Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt line 3

Quoted 3 lines
Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt new file +3 -0
@@ -0,0 +1,35 @@
+Binding for Qualcomm  Atheros AR7xxx/AR9xxx DDR controller
+
+The DDR controller of the ARxxx and AR9xxx families provides an interface

s/ARxxx/AR7xxx/.

Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt line 14

Quoted 11 lines
Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt new file +11 -0
+to flush the FIFO between various devices and the DDR. This is mainly used
+by the IRQ controller to flush the FIFO before running the interrupt handler
+of such devices.
+
+Required properties:
+
+- compatible: has to be "qca,<soc-type>-ddr-controller",
+  "qca,[ar7100|ar7240]-ddr-controller" as fallback.
+  On SoC with PCI support "qca,ar7100-ddr-controller" should be used as
+  fallback, otherwise "qca,ar7240-ddr-controller" should be used.
+- reg: Base address and size of the controllers memory area

Controller's.

Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt line 16

Quoted 2 lines
Documentation/devicetree/bindings/memory-controllers/ath79-ddr-controller.txt new file +2 -0
+- #qca,ddr-wb-channel-cells: has to be 1, the index of the write buffer
+  channel

Hm, index? The expectation for such props is the # of cells.

WBR, Sergei

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

#5 lore raw

PATCH v4 4/12 devicetree: Add bindings for the ATH79 interrupt controllers

In reply to Alban Bedel

---
v2: * Fixed the node names to respect ePAPR
* Removed the unneeded @0 on the node name

---
 .../interrupt-controller/qca,ath79-cpu-intc.txt    | 44 ++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/qca,ath79-cpu-intc.txt
Documentation/devicetree/bindings/interrupt-controller/qca,ath79-cpu-intc.txt new file +44 -0
new file mode 100644
index 0000000..aabce78
@@ -0,0 +1,44 @@
+Binding for Qualcomm Atheros AR7xxx/AR9XXX CPU interrupt controller
+
+On most SoC the IRQ controller need to flush the DDR FIFO before running
+the interrupt handler of some devices. This is configured using the
+qca,ddr-wb-channels and qca,ddr-wb-channel-interrupts properties.
+
+Required Properties:
+
+- compatible: has to be "qca,<soctype>-cpu-intc", "qca,ar7100-cpu-intc"
+  as fallback
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode interrupt
+		     source, should be 1 for intc
+
+Please refer to interrupts.txt in this directory for details of the common
+Interrupt Controllers bindings used by client devices.
+
+Optional Properties:
+
+- qca,ddr-wb-channel-interrupts: List of the interrupts needing a write
+  buffer flush
+- qca,ddr-wb-channels: List of phandles to the write buffer channels for
+  each interrupt. If qca,ddr-wb-channel-interrupts is not present the interrupt
+  default to the entry's index.
+
+Example:
+
+	interrupt-controller {
+		compatible = "qca,ar9132-cpu-intc", "qca,ar7100-cpu-intc";
+
+		interrupt-controller;
+		#interrupt-cells = <1>;
+
+		qca,ddr-wb-channel-interrupts = <2>, <3>, <4>, <5>;
+		qca,ddr-wb-channels = <&ddr_ctrl 3>, <&ddr_ctrl 2>,
+					<&ddr_ctrl 0>, <&ddr_ctrl 1>;
+	};
+
+	...
+
+	ddr_ctrl: memory-controller@18000000 {
+		...
+		#qca,ddr-wb-channel-cells = <1>;
+	};
Signature · 6 lines
2.0.0

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

PATCH v4 5/12 devicetree: Add bindings for the ATH79 MISC interrupt controllers

In reply to Alban Bedel

---
v2: * Fixed the node names to respect ePAPR

---
 .../interrupt-controller/qca,ath79-misc-intc.txt   | 30 ++++++++++++++++++++++
 1 file changed, 30 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/interrupt-controller/qca,ath79-misc-intc.txt
Documentation/devicetree/bindings/interrupt-controller/qca,ath79-misc-intc.txt new file +30 -0
new file mode 100644
index 0000000..391717a
@@ -0,0 +1,30 @@
+Binding for Qualcomm Atheros AR7xxx/AR9XXX MISC interrupt controller
+
+The MISC interrupt controller is a secondary controller for lower priority
+interrupt.
+
+Required Properties:
+- compatible: has to be "qca,<soctype>-cpu-intc", "qca,ar7100-misc-intc"
+  as fallback
+- reg: Base address and size of the controllers memory area
+- interrupt-parent: phandle of the parent interrupt controller.
+- interrupts: Interrupt specifier for the controllers interrupt.
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode interrupt
+		     source, should be 1
+
+Please refer to interrupts.txt in this directory for details of the common
+Interrupt Controllers bindings used by client devices.
+
+Example:
+
+	interrupt-controller@18060010 {
+		compatible = "qca,ar9132-misc-intc", qca,ar7100-misc-intc";
+		reg = <0x18060010 0x4>;
+
+		interrupt-parent = <&cpuintc>;
+		interrupts = <6>;
+
+		interrupt-controller;
+		#interrupt-cells = <1>;
+	};
Signature · 6 lines
2.0.0

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

Re: [PATCH v4 05/12] devicetree: Add bindings for the ATH79 MISC interrupt controllers

2015-05-31 2:52 GMT+03:00 Alban Bedel <[email protected]>:

Documentation/devicetree/bindings/interrupt-controller/qca,ath79-misc-intc.txt line 22

Quoted 5 lines
Documentation/devicetree/bindings/interrupt-controller/qca,ath79-misc-intc.txt new file +5 -0
+
+Example:
+
+       interrupt-controller@18060010 {
+               compatible = "qca,ar9132-misc-intc", qca,ar7100-misc-intc";

Sorry for meticulousness, but seems you missed a quote :)

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

PATCH v4 6/12 MIPS: ath79: Add OF support to the IRQ controllers

In reply to Alban Bedel

Add OF support for the CPU and MISC interrupt controllers of most supported ATH79 devices.

---
 arch/mips/ath79/irq.c | 87 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 86 insertions(+), 1 deletion(-)
arch/mips/ath79/irq.c +86 -1
index 2c3991a..afb0096 100644
@@ -15,7 +15,9 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
-#include <linux/irq.h>
+#include <linux/irqchip.h>
+#include <linux/of_irq.h>
+#include "../../../drivers/irqchip/irqchip.h"
 
 #include <asm/irq_cpu.h>
 #include <asm/mipsregs.h>
@@ -23,6 +25,7 @@
 #include <asm/mach-ath79/ath79.h>
 #include <asm/mach-ath79/ar71xx_regs.h>
 #include "common.h"
+#include "machtypes.h"
 
 static void ath79_misc_irq_handler(unsigned int irq, struct irq_desc *desc)
 {
@@ -268,8 +271,90 @@ asmlinkage void plat_irq_dispatch(void)
 	}
 }
 
+#ifdef CONFIG_IRQCHIP
+static int misc_map(struct irq_domain *d, unsigned int irq, irq_hw_number_t hw)
+{
+	irq_set_chip_and_handler(irq, &ath79_misc_irq_chip, handle_level_irq);
+	return 0;
+}
+
+static const struct irq_domain_ops misc_irq_domain_ops = {
+	.xlate = irq_domain_xlate_onecell,
+	.map = misc_map,
+};
+
+static int __init ath79_misc_intc_of_init(
+	struct device_node *node, struct device_node *parent)
+{
+	void __iomem *base = ath79_reset_base;
+	struct irq_domain *domain;
+	int irq;
+
+	irq = irq_of_parse_and_map(node, 0);
+	if (!irq)
+		panic("Failed to get MISC IRQ");
+
+	domain = irq_domain_add_legacy(node, ATH79_MISC_IRQ_COUNT,
+			ATH79_MISC_IRQ_BASE, 0, &misc_irq_domain_ops, NULL);
+	if (!domain)
+		panic("Failed to add MISC irqdomain");
+
+	/* Disable and clear all interrupts */
+	__raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_ENABLE);
+	__raw_writel(0, base + AR71XX_RESET_REG_MISC_INT_STATUS);
+
+
+	irq_set_chained_handler(irq, ath79_misc_irq_handler);
+
+	return 0;
+}
+IRQCHIP_DECLARE(ath79_misc_intc, "qca,ar7100-misc-intc",
+		ath79_misc_intc_of_init);
+
+static int __init ar79_cpu_intc_of_init(
+	struct device_node *node, struct device_node *parent)
+{
+	int err, i, count;
+
+	/* Fill the irq_wb_chan table */
+	count = of_count_phandle_with_args(
+		node, "qca,ddr-wb-channels", "#qca,ddr-wb-channel-cells");
+
+	for (i = 0; i < count; i++) {
+		struct of_phandle_args args;
+		u32 irq = i;
+
+		of_property_read_u32_index(
+			node, "qca,ddr-wb-channel-interrupts", i, &irq);
+		if (irq >= ARRAY_SIZE(irq_wb_chan))
+			continue;
+
+		err = of_parse_phandle_with_args(
+			node, "qca,ddr-wb-channels",
+			"#qca,ddr-wb-channel-cells",
+			i, &args);
+		if (err)
+			return err;
+
+		irq_wb_chan[irq] = args.args[0];
+		pr_info("IRQ: Set flush channel of IRQ%d to %d\n",
+			irq, args.args[0]);
+	}
+
+	return mips_cpu_irq_of_init(node, parent);
+}
+IRQCHIP_DECLARE(ar79_cpu_intc, "qca,ar7100-cpu-intc",
+		ar79_cpu_intc_of_init);
+
+#endif
+
 void __init arch_init_irq(void)
 {
+	if (mips_machtype == ATH79_MACH_GENERIC_OF) {
+		irqchip_init();
+		return;
+	}
+
 	if (soc_is_ar71xx() || soc_is_ar724x() ||
 	    soc_is_ar913x() || soc_is_ar933x()) {
 		irq_wb_chan[2] = 3;
Signature · 6 lines
2.0.0

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

PATCH v4 7/12 devicetree: Add bindings for the ATH79 PLL controllers

In reply to Alban Bedel

---
v2: * Fixed the node names to respect ePAPR
* Fixed the missing 's' in 'fallbacks' and the 'clocks' property
v3: * Fix the compatible string for qca9550

---
 .../devicetree/bindings/clock/qca,ath79-pll.txt    | 33 ++++++++++++++++++++++
 1 file changed, 33 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/clock/qca,ath79-pll.txt
Documentation/devicetree/bindings/clock/qca,ath79-pll.txt new file +33 -0
new file mode 100644
index 0000000..e0fc2c1
@@ -0,0 +1,33 @@
+Binding for Qualcomm Atheros AR7xxx/AR9XXX PLL controller
+
+The PPL controller provides the 3 main clocks of the SoC: CPU, DDR and AHB.
+
+Required Properties:
+- compatible: has to be "qca,<soctype>-cpu-intc" and one of the following
+  fallbacks:
+  - "qca,ar7100-pll"
+  - "qca,ar7240-pll"
+  - "qca,ar9130-pll"
+  - "qca,ar9330-pll"
+  - "qca,ar9340-pll"
+  - "qca,qca9550-pll"
+- reg: Base address and size of the controllers memory area
+- clock-names: Name of the input clock, has to be "ref"
+- clocks: phandle of the external reference clock
+- #clock-cells: has to be one
+
+Optional properties:
+- clock-output-names: should be "cpu", "ddr", "ahb"
+
+Example:
+
+	memory-controller@18050000 {
+		compatible = "qca,ar9132-ppl", "qca,ar9130-pll";
+		reg = <0x18050000 0x20>;
+
+		clock-names = "ref";
+		clocks = <&extosc>;
+
+		#clock-cells = <1>;
+		clock-output-names = "cpu", "ddr", "ahb";
+	};
Signature · 6 lines
2.0.0

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

PATCH v4 8/12 MIPS: ath79: Add OF support to the clocks

In reply to Alban Bedel

Allow using the SoC clocks in the device tree.

---
v3: * Fix the compatible string for qca9550
v4: * Added missing Signed-off-by

---
 arch/mips/ath79/clock.c | 63 ++++++++++++++++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 19 deletions(-)
arch/mips/ath79/clock.c +44 -19
index 1fcb691..eb5117c 100644
@@ -29,7 +29,14 @@
 #define AR724X_BASE_FREQ	5000000
 #define AR913X_BASE_FREQ	5000000
 
-static void __init ath79_add_sys_clkdev(const char *id, unsigned long rate)
+static struct clk *clks[3];
+static struct clk_onecell_data clk_data = {
+	.clks = clks,
+	.clk_num = ARRAY_SIZE(clks),
+};
+
+static struct clk *__init ath79_add_sys_clkdev(
+	const char *id, unsigned long rate)
 {
 	struct clk *clk;
 	int err;
@@ -41,6 +48,8 @@ static void __init ath79_add_sys_clkdev(const char *id, unsigned long rate)
 	err = clk_register_clkdev(clk, id, NULL);
 	if (err)
 		panic("unable to register %s clock device", id);
+
+	return clk;
 }
 
 static void __init ar71xx_clocks_init(void)
@@ -70,9 +79,9 @@ static void __init ar71xx_clocks_init(void)
 	ahb_rate = cpu_rate / div;
 
 	ath79_add_sys_clkdev("ref", ref_rate);
-	ath79_add_sys_clkdev("cpu", cpu_rate);
-	ath79_add_sys_clkdev("ddr", ddr_rate);
-	ath79_add_sys_clkdev("ahb", ahb_rate);
+	clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
+	clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
+	clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
 
 	clk_add_alias("wdt", NULL, "ahb", NULL);
 	clk_add_alias("uart", NULL, "ahb", NULL);
@@ -106,9 +115,9 @@ static void __init ar724x_clocks_init(void)
 	ahb_rate = cpu_rate / div;
 
 	ath79_add_sys_clkdev("ref", ref_rate);
-	ath79_add_sys_clkdev("cpu", cpu_rate);
-	ath79_add_sys_clkdev("ddr", ddr_rate);
-	ath79_add_sys_clkdev("ahb", ahb_rate);
+	clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
+	clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
+	clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
 
 	clk_add_alias("wdt", NULL, "ahb", NULL);
 	clk_add_alias("uart", NULL, "ahb", NULL);
@@ -139,9 +148,9 @@ static void __init ar913x_clocks_init(void)
 	ahb_rate = cpu_rate / div;
 
 	ath79_add_sys_clkdev("ref", ref_rate);
-	ath79_add_sys_clkdev("cpu", cpu_rate);
-	ath79_add_sys_clkdev("ddr", ddr_rate);
-	ath79_add_sys_clkdev("ahb", ahb_rate);
+	clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
+	clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
+	clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
 
 	clk_add_alias("wdt", NULL, "ahb", NULL);
 	clk_add_alias("uart", NULL, "ahb", NULL);
@@ -201,9 +210,9 @@ static void __init ar933x_clocks_init(void)
 	}
 
 	ath79_add_sys_clkdev("ref", ref_rate);
-	ath79_add_sys_clkdev("cpu", cpu_rate);
-	ath79_add_sys_clkdev("ddr", ddr_rate);
-	ath79_add_sys_clkdev("ahb", ahb_rate);
+	clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
+	clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
+	clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
 
 	clk_add_alias("wdt", NULL, "ahb", NULL);
 	clk_add_alias("uart", NULL, "ref", NULL);
@@ -335,9 +344,9 @@ static void __init ar934x_clocks_init(void)
 		ahb_rate = cpu_pll / (postdiv + 1);
 
 	ath79_add_sys_clkdev("ref", ref_rate);
-	ath79_add_sys_clkdev("cpu", cpu_rate);
-	ath79_add_sys_clkdev("ddr", ddr_rate);
-	ath79_add_sys_clkdev("ahb", ahb_rate);
+	clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
+	clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
+	clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
 
 	clk_add_alias("wdt", NULL, "ref", NULL);
 	clk_add_alias("uart", NULL, "ref", NULL);
@@ -422,9 +431,9 @@ static void __init qca955x_clocks_init(void)
 		ahb_rate = cpu_pll / (postdiv + 1);
 
 	ath79_add_sys_clkdev("ref", ref_rate);
-	ath79_add_sys_clkdev("cpu", cpu_rate);
-	ath79_add_sys_clkdev("ddr", ddr_rate);
-	ath79_add_sys_clkdev("ahb", ahb_rate);
+	clks[0] = ath79_add_sys_clkdev("cpu", cpu_rate);
+	clks[1] = ath79_add_sys_clkdev("ddr", ddr_rate);
+	clks[2] = ath79_add_sys_clkdev("ahb", ahb_rate);
 
 	clk_add_alias("wdt", NULL, "ref", NULL);
 	clk_add_alias("uart", NULL, "ref", NULL);
@@ -446,6 +455,8 @@ void __init ath79_clocks_init(void)
 		qca955x_clocks_init();
 	else
 		BUG();
+
+	of_clk_init(NULL);
 }
 
 unsigned long __init
@@ -463,3 +474,17 @@ ath79_get_sys_clk_rate(const char *id)
 
 	return rate;
 }
+
+#ifdef CONFIG_OF
+static void __init ath79_clocks_init_dt(struct device_node *np)
+{
+	of_clk_add_provider(np, of_clk_src_onecell_get, &clk_data);
+}
+
+CLK_OF_DECLARE(ar7100, "qca,ar7100-pll", ath79_clocks_init_dt);
+CLK_OF_DECLARE(ar7240, "qca,ar7240-pll", ath79_clocks_init_dt);
+CLK_OF_DECLARE(ar9130, "qca,ar9130-pll", ath79_clocks_init_dt);
+CLK_OF_DECLARE(ar9330, "qca,ar9330-pll", ath79_clocks_init_dt);
+CLK_OF_DECLARE(ar9340, "qca,ar9340-pll", ath79_clocks_init_dt);
+CLK_OF_DECLARE(ar9550, "qca,qca9550-pll", ath79_clocks_init_dt);
+#endif
Signature · 1 line
2.0.0
#11 lore raw

PATCH v4 9/12 devicetree: Add bindings for the ATH79 GPIO controllers

In reply to Alban Bedel

These bindings support the GPIO controllers found on the Qualcomm Atheros AR7xxx/AR9XXX SoC.

---
v2: * Add the ngpios property to have fewer fallbacks and simpler code
v3: * Fix missing 's' typo
* Fix the example to be valid with the binding
v4: * Fix the double space in the title

---
 .../devicetree/bindings/gpio/gpio-ath79.txt        | 38 ++++++++++++++++++++++
 1 file changed, 38 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/gpio/gpio-ath79.txt
Documentation/devicetree/bindings/gpio/gpio-ath79.txt new file +38 -0
new file mode 100644
index 0000000..c522851
@@ -0,0 +1,38 @@
+Binding for Qualcomm Atheros AR7xxx/AR9xxx GPIO controller
+
+Required properties:
+- compatible: has to be "qca,<soctype>-gpio" and one of the following
+  fallbacks:
+  - "qca,ar7100-gpio"
+  - "qca,ar9340-gpio"
+- reg: Base address and size of the controllers memory area
+- gpio-controller : Marks the device node as a GPIO controller.
+- #gpio-cells : Should be two. The first cell is the pin number and the
+  second cell is used to specify optional parameters.
+- ngpios: Should be set to the number of GPIOs available on the SoC.
+
+Optional properties:
+- interrupt-parent: phandle of the parent interrupt controller.
+- interrupts: Interrupt specifier for the controllers interrupt.
+- interrupt-controller : Identifies the node as an interrupt controller
+- #interrupt-cells : Specifies the number of cells needed to encode interrupt
+		     source, should be 2
+
+Please refer to interrupts.txt in this directory for details of the common
+Interrupt Controllers bindings used by client devices.
+
+Example:
+
+	gpio@18040000 {
+		compatible = "qca,ar9132-gpio", "qca,ar7100-gpio";
+		reg = <0x18040000 0x30>;
+		interrupts = <2>;
+
+		ngpios = <22>;
+
+		gpio-controller;
+		#gpio-cells = <2>;
+
+		interrupt-controller;
+		#interrupt-cells = <2>;
+	};
Signature · 6 lines
2.0.0

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

PATCH v4 10/12 MIPS: ath79: Add OF support to the GPIO driver

In reply to Alban Bedel

Replace the simple GPIO chip registration by a platform driver and make ath79_gpio_init() just register the device.

---
v2: * Added an 'ngpios' property instead of the many matches
* Use a platform data struct to store the device config on non-DT boards. It make for a cleaner separation of the config and driver code.

---
 arch/mips/ath79/dev-common.c             | 51 +++++++++++++++++++++
 arch/mips/ath79/gpio.c                   | 79 +++++++++++++++++++++++---------
 include/linux/platform_data/gpio-ath79.h | 19 ++++++++
 3 files changed, 127 insertions(+), 22 deletions(-)
 create mode 100644 include/linux/platform_data/gpio-ath79.h
arch/mips/ath79/dev-common.c +51 -0
index 516225d..9d0172a 100644
@@ -14,6 +14,7 @@
 #include <linux/kernel.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
+#include <linux/platform_data/gpio-ath79.h>
 #include <linux/serial_8250.h>
 #include <linux/clk.h>
 #include <linux/err.h>
@@ -106,3 +107,53 @@ void __init ath79_register_wdt(void)
 
 	platform_device_register_simple("ath79-wdt", -1, &res, 1);
 }
+
+static struct ath79_gpio_platform_data ath79_gpio_pdata;
+
+static struct resource ath79_gpio_resources[] = {
+	{
+		.flags = IORESOURCE_MEM,
+		.start = AR71XX_GPIO_BASE,
+		.end = AR71XX_GPIO_BASE + AR71XX_GPIO_SIZE - 1,
+	},
+	{
+		.start	= ATH79_MISC_IRQ(2),
+		.end	= ATH79_MISC_IRQ(2),
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device ath79_gpio_device = {
+	.name		= "ath79-gpio",
+	.id		= -1,
+	.resource	= ath79_gpio_resources,
+	.num_resources	= ARRAY_SIZE(ath79_gpio_resources),
+	.dev = {
+		.platform_data	= &ath79_gpio_pdata
+	},
+};
+
+void __init ath79_gpio_init(void)
+{
+	if (soc_is_ar71xx()) {
+		ath79_gpio_pdata.ngpios = AR71XX_GPIO_COUNT;
+	} else if (soc_is_ar7240()) {
+		ath79_gpio_pdata.ngpios = AR7240_GPIO_COUNT;
+	} else if (soc_is_ar7241() || soc_is_ar7242()) {
+		ath79_gpio_pdata.ngpios = AR7241_GPIO_COUNT;
+	} else if (soc_is_ar913x()) {
+		ath79_gpio_pdata.ngpios = AR913X_GPIO_COUNT;
+	} else if (soc_is_ar933x()) {
+		ath79_gpio_pdata.ngpios = AR933X_GPIO_COUNT;
+	} else if (soc_is_ar934x()) {
+		ath79_gpio_pdata.ngpios = AR934X_GPIO_COUNT;
+		ath79_gpio_pdata.oe_inverted = 1;
+	} else if (soc_is_qca955x()) {
+		ath79_gpio_pdata.ngpios = QCA955X_GPIO_COUNT;
+		ath79_gpio_pdata.oe_inverted = 1;
+	} else {
+		BUG();
+	}
+
+	platform_device_register(&ath79_gpio_device);
+}
arch/mips/ath79/gpio.c +57 -22

109 lines not on this page · raw message

include/linux/platform_data/gpio-ath79.h new file +19 -0
new file mode 100644
index 0000000..88b0db7
@@ -0,0 +1,19 @@
+/*
+ *  Atheros AR7XXX/AR9XXX GPIO controller platform data
+ *
+ * Copyright (C) 2015 Alban Bedel <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __LINUX_PLATFORM_DATA_GPIO_ATH79_H
+#define __LINUX_PLATFORM_DATA_GPIO_ATH79_H
+
+struct ath79_gpio_platform_data {
+	unsigned ngpios;
+	bool oe_inverted;
+};
+
+#endif
Signature · 6 lines
2.0.0

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

PATCH v4 11/12 of: Add vendor prefix for TP-Link Technologies Co. Ltd

In reply to Alban Bedel

---
v3: * Put the new entry at the right place

---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/vendor-prefixes.txt +1 -0
index 8033919..606e110 100644
@@ -195,6 +195,7 @@ tlm	Trusted Logic Mobility
 toradex	Toradex AG
 toshiba	Toshiba Corporation
 toumaz	Toumaz
+tplink	TP-LINK Technologies Co., Ltd.
 truly	Truly Semiconductors Limited
 usi	Universal Scientific Industrial Co., Ltd.
 v3	V3 Semiconductor
Signature · 6 lines
2.0.0

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

PATCH v4 12/12 MIPS: Add basic support for the TL-WR1043ND version 1

In reply to Alban Bedel

Add a DTS for TL-WR1043ND version 1 and allow to have it built in the kernel to circumvent the broken u-boot found on these boards. Currently only the UART, LEDs and buttons are supported.

---
v2: * Rebased for the new vendor directory structure
* Merged the 2 separate patch for SoC dtsi and board DTS in a single one
* Fixed the node names to use ePAPR standardized names
v3: * Moved adding the Kconfig Builtin devicetree menu to this patch
* Set the Kconfig builtin DTB menu as optional, removed config DTB_ATH79_NONE and slightly improved the menu name and help message.
v4: * Always build the DTB to improve testing coverage
* Added the SPI controller as the binding has been accepted in the SPI tree.

---
 arch/mips/ath79/Kconfig                          |  12 ++
 arch/mips/boot/dts/Makefile                      |   1 +
 arch/mips/boot/dts/qca/Makefile                  |  11 ++
 arch/mips/boot/dts/qca/ar9132.dtsi               | 133 +++++++++++++++++++++++
 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts | 112 +++++++++++++++++++
 5 files changed, 269 insertions(+)
 create mode 100644 arch/mips/boot/dts/qca/Makefile
 create mode 100644 arch/mips/boot/dts/qca/ar9132.dtsi
 create mode 100644 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts
arch/mips/ath79/Kconfig +12 -0
index dfc6020..13c04cf 100644
@@ -71,6 +71,18 @@ config ATH79_MACH_UBNT_XM
 	  Say 'Y' here if you want your kernel to support the
 	  Ubiquiti Networks XM (rev 1.0) board.
 
+choice
+	prompt "Build a DTB in the kernel"
+	optional
+	help
+	  Select a devicetree that should be built into the kernel.
+
+	config DTB_TL_WR1043ND_V1
+		bool "TL-WR1043ND Version 1"
+		select BUILTIN_DTB
+		select SOC_AR913X
+endchoice
+
 endmenu
 
 config SOC_AR71XX
arch/mips/boot/dts/Makefile +1 -0
index 5d95e4b..9975485 100644
@@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
 dts-dirs	+= lantiq
 dts-dirs	+= mti
 dts-dirs	+= netlogic
+dts-dirs	+= qca
 dts-dirs	+= ralink
 
 obj-y		:= $(addsuffix /, $(dts-dirs))
arch/mips/boot/dts/qca/Makefile new file +11 -0
new file mode 100644
index 0000000..2d61455d
@@ -0,0 +1,11 @@
+# All DTBs
+dtb-$(CONFIG_ATH79)			+= ar9132_tl_wr1043nd_v1.dtb
+
+# Select a DTB to build in the kernel
+obj-$(CONFIG_DTB_TL_WR1043ND_V1)	+= ar9132_tl_wr1043nd_v1.dtb.o
+
+# Force kbuild to make empty built-in.o if necessary
+obj-				+= dummy.o
+
+always				:= $(dtb-y)
+clean-files			:= *.dtb *.dtb.S
arch/mips/boot/dts/qca/ar9132.dtsi new file +133 -0

133 lines not on this page · raw message

arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts new file +112 -0

112 lines not on this page · raw message

Signature · 6 lines
2.0.0

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

Re: [PATCH v4 12/12] MIPS: Add basic support for the TL-WR1043ND version 1

Quoted 36 lines · On Sun, 31 May 2015 02:18:26 +0200 Alban Bedel <[email protected]> wrote:

Add a DTS for TL-WR1043ND version 1 and allow to have it built in the kernel to circumvent the broken u-boot found on these boards. Currently only the UART, LEDs and buttons are supported.

arch/mips/boot/dts/qca/ar9132.dtsi new file +25 -0
 
 
+++ b/arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts
@@ -0,0 +1,112 @@
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "ar9132.dtsi"
+
+/ {
+	compatible = "tplink,tl-wr1043nd-v1", "qca,ar9132";
+	model = "TP-Link TL-WR1043ND Version 1";
+
+	alias {
+		serial0 = "/ahb/apb/uart@18020000";
+	};
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x2000000>;
+	};
+
+	extosc: oscillator {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <40000000>;

arch/mips/boot/dts/qca/ar9132.dtsi line 34

Quoted 10 lines
arch/mips/boot/dts/qca/ar9132.dtsi new file +10 -0
+	};
+
+	ahb {
+		apb {
+			uart@18020000 {
+				status = "okay";
+			};
+
+			pll-controller@18050000 {
+				clocks = <&extosc>;

IMHO AR9132 SoC can't work without external oscilator.

Can we just move basic extosc declaration to SoC dt file (ar9132.dtsi)? So board dt file ar9132_tl_wr1043nd_v1.dts will contain only oscilator clock frequency value.

E.g.

ar9132.dtsi:
============

	extosc: oscillator {
		compatible = "fixed-clock";
		#clock-cells = <0>;
		clock-frequency = <40000000>;
	};
...
	ahb {
		apb {

...

			pll-controller@18050000 {
...
				clocks = <&extosc>;

...

ar9132_tl_wr1043nd_v1.dts:
==========================

...

	&extosc {
		clock-frequency = <40000000>;
	};

--
Best regards,
  Antony Pavlov

author
#16 lore raw

Re: [PATCH v4 12/12] MIPS: Add basic support for the TL-WR1043ND version 1

Quoted 5 lines · On Mon, 8 Jun 2015 13:17:58 +0300 Antony Pavlov <[email protected]> wrote:

IMHO AR9132 SoC can't work without external oscilator.

Can we just move basic extosc declaration to SoC dt file (ar9132.dtsi)? So board dt file ar9132_tl_wr1043nd_v1.dts will contain only oscilator clock frequency value.

I would prefer to keep the split between the files in sync with the hardware. I understand that most simple board designs use a fixed oscillator, but that might not always be the case.

Alban

#17 lore raw

Re: [PATCH v4 12/12] MIPS: Add basic support for the TL-WR1043ND version 1

Quoted 5 lines · On Wed, 10 Jun 2015 23:58:11 +0200 Alban <[email protected]> wrote:
Quoted 2 lines · On Mon, 8 Jun 2015 13:17:58 +0300 Antony Pavlov <[email protected]> wrote:

IMHO AR9132 SoC can't work without external oscilator.

Quoted 8 lines
Quoted 3 lines

Can we just move basic extosc declaration to SoC dt file (ar9132.dtsi)? So board dt file ar9132_tl_wr1043nd_v1.dts will contain only oscilator clock frequency value.

I would prefer to keep the split between the files in sync with the hardware. I understand that most simple board designs use a fixed oscillator, but that might not always be the case.

The AR9132 SoC __always__ use one external oscilator. So it's reasonable to have the first mention of extosc in ar9132.dtsi not in a board file. This description style is always sync with hardware.
On the other hand pll-controller is always part of the SoC not a part of a board. So pll-controller on extosc dependency have to go to SoC dts file not to a board file. In your dts description pll-controller is a part of a dts board file.

It looks like my previous device tree structure proposal contains a small error (extra clock-frequency field in ar9132.dtsi). I have fixed it. Please comment it.

ar9132.dtsi:
============

	extosc: oscillator {
		compatible = "fixed-clock";
		#clock-cells = <0>;
	};
...
	ahb {
		apb {

...

			pll-controller@18050000 {
...
				clocks = <&extosc>;

...

ar9132_tl_wr1043nd_v1.dts:
==========================

...

	&extosc {
		clock-frequency = <40000000>;
	};
Signature · 3 lines
-- 
Best regards,
  Antony Pavlov
author
#18 lore raw

Re: [PATCH v4 12/12] MIPS: Add basic support for the TL-WR1043ND version 1

Quoted 12 lines · On Mon, 15 Jun 2015 10:42:13 +0300 Antony Pavlov…
Quoted 9 lines · On Wed, 10 Jun 2015 23:58:11 +0200 Alban <[email protected]>…
Quoted 5 lines · On Mon, 8 Jun 2015 13:17:58 +0300 Antony Pavlov…

IMHO AR9132 SoC can't work without external oscilator.

Can we just move basic extosc declaration to SoC dt file (ar9132.dtsi)? So board dt file ar9132_tl_wr1043nd_v1.dts will contain only oscilator clock frequency value.

Quoted 6 lines
Quoted 4 lines

I would prefer to keep the split between the files in sync with the hardware. I understand that most simple board designs use a fixed oscillator, but that might not always be the case.

The AR9132 SoC __always__ use one external oscilator.

Yes, but what I don't like is to impose the clock source being a fixed-oscillator. What if the board use a clock from another component that need to be represented in the DT as something else than a fixed-oscillator?

Quoted 3 lines

So it's reasonable to have the first mention of extosc in ar9132.dtsi not in a board file. This description style is always sync with hardware.

In your proposal it wouldn't as the AR9132 doesn't have a fixed-oscillator on chip. So boards using another type of clock would still have that fixed-oscillator hanging around.

Quoted 4 lines

On the other hand pll-controller is always part
of the SoC not a part of a board. So pll-controller on extosc dependency have to go to SoC dts file not to a board file. In your dts description pll-controller is a part of a dts board file.

The PLL controller shows up in the board DTS as the connection between the SoC and the other components on boards has to be represented. We could use a label and reference it in the board file but that is the same in the end.

But that's not really the point, more important is the fact that DTS don't allow to delete nodes. This mean that DTSI should really not start to define more than is strictly needed.

Alban
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in

#19 lore raw

Re: [PATCH v4 12/12] MIPS: Add basic support for the TL-WR1043ND version 1

Quoted 20 lines · On Sat, 20 Jun 2015 12:51:37 +0200 Alban <[email protected]> wrote:
Quoted 17 lines · On Mon, 15 Jun 2015 10:42:13 +0300 Antony Pavlov <[email protected]>…
Quoted 13 lines · On Wed, 10 Jun 2015 23:58:11 +0200 Alban <[email protected]> wrote:
Quoted 5 lines · On Mon, 8 Jun 2015 13:17:58 +0300 Antony Pavlov <[email protected]> wrote:

IMHO AR9132 SoC can't work without external oscilator.

Can we just move basic extosc declaration to SoC dt file (ar9132.dtsi)? So board dt file ar9132_tl_wr1043nd_v1.dts will contain only oscilator clock frequency value.

I would prefer to keep the split between the files in sync with the hardware. I understand that most simple board designs use a fixed oscillator, but that might not always be the case.

Quoted 6 lines
Quoted 1 line

The AR9132 SoC __always__ use one external oscilator.

Yes, but what I don't like is to impose the clock source being a fixed-oscillator. What if the board use a clock from another component that need to be represented in the DT as something else than a fixed-oscillator?

The absolute majority of the ar9132-based boards has fixed-oscillator (Actually I suppose all of them has fixed oscillator).

If some board has different clock source then we can completely alter extosc node in the board dts file. (But I have some doubts in existence of such board.)

--
Best regards,
  Antony Pavlov

#20 lore raw

Re: [PATCH v4 12/12] MIPS: Add basic support for the TL-WR1043ND version 1

In reply to Alban Bedel
Quoted 196 lines · On Sun, 31 May 2015 02:18:26 +0200 Alban Bedel <[email protected]> wrote:

Add a DTS for TL-WR1043ND version 1 and allow to have it built in the kernel to circumvent the broken u-boot found on these boards. Currently only the UART, LEDs and buttons are supported.

---
v2: * Rebased for the new vendor directory structure
* Merged the 2 separate patch for SoC dtsi and board DTS in a single one
* Fixed the node names to use ePAPR standardized names
v3: * Moved adding the Kconfig Builtin devicetree menu to this patch
* Set the Kconfig builtin DTB menu as optional, removed config DTB_ATH79_NONE and slightly improved the menu name and help message.
v4: * Always build the DTB to improve testing coverage
* Added the SPI controller as the binding has been accepted in the SPI tree.

---
 arch/mips/ath79/Kconfig                          |  12 ++
 arch/mips/boot/dts/Makefile                      |   1 +
 arch/mips/boot/dts/qca/Makefile                  |  11 ++
 arch/mips/boot/dts/qca/ar9132.dtsi               | 133 +++++++++++++++++++++++
 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts | 112 +++++++++++++++++++
 5 files changed, 269 insertions(+)
 create mode 100644 arch/mips/boot/dts/qca/Makefile
 create mode 100644 arch/mips/boot/dts/qca/ar9132.dtsi
 create mode 100644 arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts
arch/mips/ath79/Kconfig +12 -0
index dfc6020..13c04cf 100644
@@ -71,6 +71,18 @@ config ATH79_MACH_UBNT_XM
 	  Say 'Y' here if you want your kernel to support the
 	  Ubiquiti Networks XM (rev 1.0) board.
 
+choice
+	prompt "Build a DTB in the kernel"
+	optional
+	help
+	  Select a devicetree that should be built into the kernel.
+
+	config DTB_TL_WR1043ND_V1
+		bool "TL-WR1043ND Version 1"
+		select BUILTIN_DTB
+		select SOC_AR913X
+endchoice
+
 endmenu
 
 config SOC_AR71XX
arch/mips/boot/dts/Makefile +1 -0
index 5d95e4b..9975485 100644
@@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
 dts-dirs	+= lantiq
 dts-dirs	+= mti
 dts-dirs	+= netlogic
+dts-dirs	+= qca
 dts-dirs	+= ralink
 
 obj-y		:= $(addsuffix /, $(dts-dirs))
arch/mips/boot/dts/qca/Makefile new file +11 -0
new file mode 100644
index 0000000..2d61455d
@@ -0,0 +1,11 @@
+# All DTBs
+dtb-$(CONFIG_ATH79)			+= ar9132_tl_wr1043nd_v1.dtb
+
+# Select a DTB to build in the kernel
+obj-$(CONFIG_DTB_TL_WR1043ND_V1)	+= ar9132_tl_wr1043nd_v1.dtb.o
+
+# Force kbuild to make empty built-in.o if necessary
+obj-				+= dummy.o
+
+always				:= $(dtb-y)
+clean-files			:= *.dtb *.dtb.S
arch/mips/boot/dts/qca/ar9132.dtsi new file +110 -0
new file mode 100644
index 0000000..4759cff
@@ -0,0 +1,133 @@
+/ {
+	compatible = "qca,ar9132";
+
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "mips,mips24Kc";
+			reg = <0>;
+		};
+	};
+
+	cpuintc: interrupt-controller {
+		compatible = "qca,ar9132-cpu-intc", "qca,ar7100-cpu-intc";
+
+		interrupt-controller;
+		#interrupt-cells = <1>;
+
+		qca,ddr-wb-channel-interrupts = <2>, <3>, <4>, <5>;
+		qca,ddr-wb-channels = <&ddr_ctrl 3>, <&ddr_ctrl 2>,
+					<&ddr_ctrl 0>, <&ddr_ctrl 1>;
+	};
+
+	ahb {
+		compatible = "simple-bus";
+		ranges;
+
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		interrupt-parent = <&cpuintc>;
+
+		apb {
+			compatible = "simple-bus";
+			ranges;
+
+			#address-cells = <1>;
+			#size-cells = <1>;
+
+			interrupt-parent = <&miscintc>;
+
+			ddr_ctrl: memory-controller@18000000 {
+				compatible = "qca,ar9132-ddr-controller",
+						"qca,ar7240-ddr-controller";
+				reg = <0x18000000 0x100>;
+
+				#qca,ddr-wb-channel-cells = <1>;
+			};
+
+			uart@18020000 {
+				compatible = "ns8250";
+				reg = <0x18020000 0x20>;
+				interrupts = <3>;
+
+				clocks = <&pll 2>;
+				clock-names = "uart";
+
+				reg-io-width = <4>;
+				reg-shift = <2>;
+				no-loopback-test;
+
+				status = "disabled";
+			};
+
+			gpio: gpio@18040000 {
+				compatible = "qca,ar9132-gpio",
+						"qca,ar7100-gpio";
+				reg = <0x18040000 0x30>;
+				interrupts = <2>;
+
+				ngpios = <22>;
+
+				gpio-controller;
+				#gpio-cells = <2>;
+
+				interrupt-controller;
+				#interrupt-cells = <2>;
+			};
+
+			pll: pll-controller@18050000 {
+				compatible = "qca,ar9132-ppl",
+						"qca,ar9130-pll";
+				reg = <0x18050000 0x20>;
+
+				clock-names = "ref";
+				/* The board must provides the ref clock */
+
+				#clock-cells = <1>;
+				clock-output-names = "cpu", "ddr", "ahb";
+			};
+
+			wdt@18060008 {
+				compatible = "qca,ar7130-wdt";
+				reg = <0x18060008 0x8>;
+
+				interrupts = <4>;
+
+				clocks = <&pll 2>;
+				clock-names = "wdt";
+			};
+
+			miscintc: interrupt-controller@18060010 {
+				compatible = "qca,ar9132-misc-intc",
+					   "qca,ar7100-misc-intc";
+				reg = <0x18060010 0x4>;

arch/mips/boot/dts/qca/ar9132.dtsi line 120

Quoted 10 lines
arch/mips/boot/dts/qca/ar9132.dtsi new file +10 -0
+
+				interrupt-parent = <&cpuintc>;
+				interrupts = <6>;
+
+				interrupt-controller;
+				#interrupt-cells = <1>;
+			};
+		};
+
+		spi@1f000000 {

Could we add an alias here? E.g.

		spi: spi@1f000000 {

So we can use the alias in the board dts file with zero indent. E.g

&spi {
	status = "okay";
	num-cs = <1>;

	flash@0 {

...

Just the same change can be used with uart@18020000.

Quoted 122 lines
arch/mips/boot/dts/qca/ar9132_tl_wr1043nd_v1.dts new file +112 -0
new file mode 100644
index 0000000..003015a
@@ -0,0 +1,112 @@
+/dts-v1/;
+
+#include <dt-bindings/gpio/gpio.h>
+#include <dt-bindings/input/input.h>
+
+#include "ar9132.dtsi"
+
+/ {
+	compatible = "tplink,tl-wr1043nd-v1", "qca,ar9132";
+	model = "TP-Link TL-WR1043ND Version 1";
+
+	alias {
+		serial0 = "/ahb/apb/uart@18020000";
+	};
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x2000000>;
+	};
+
+	extosc: oscillator {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <40000000>;
+	};
+
+	ahb {
+		apb {
+			uart@18020000 {
+				status = "okay";
+			};
+
+			pll-controller@18050000 {
+				clocks = <&extosc>;
+			};
+		};
+
+		spi@1f000000 {
+			status = "okay";
+			num-cs = <1>;
+
+			flash@0 {
+				#address-cells = <1>;
+				#size-cells = <1>;
+				compatible = "s25sl064a";
+				reg = <0>;
+				spi-max-frequency = <25000000>;
+
+				partition@0 {
+					label = "u-boot";
+					reg = <0x000000 0x020000>;
+				};
+
+				partition@1 {
+					label = "firmware";
+					reg = <0x020000 0x7D0000>;
+				};
+
+				partition@2 {
+					label = "art";
+					reg = <0x7F0000 0x010000>;
+					read-only;
+				};
+			};
+		};
+	};
+
+	gpio-keys {
+		compatible = "gpio-keys-polled";
+		#address-cells = <1>;
+		#size-cells = <0>;
+
+		poll-interval = <20>;
+		button@0 {
+			label = "reset";
+			linux,code = <KEY_RESTART>;
+			gpios = <&gpio 3 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+
+		button@1 {
+			label = "qss";
+			linux,code = <KEY_WPS_BUTTON>;
+			gpios = <&gpio 7 GPIO_ACTIVE_LOW>;
+			debounce-interval = <60>;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+		led@0 {
+			label = "tp-link:green:usb";
+			gpios = <&gpio 1 GPIO_ACTIVE_LOW>;
+		};
+
+		led@1 {
+			label = "tp-link:green:system";
+			gpios = <&gpio 2 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "heartbeat";
+		};
+
+		led@2 {
+			label = "tp-link:green:qss";
+			gpios = <&gpio 5 GPIO_ACTIVE_HIGH>;
+		};
+
+		led@3 {
+			label = "tp-link:green:wlan";
+			gpios = <&gpio 9 GPIO_ACTIVE_LOW>;
+		};
+	};
+};
Signature · 1 line
2.0.0
Signature · 3 lines
-- 
Best regards,
  Antony Pavlov