linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] MIPS: NI 169445 board support
@ 2016-12-02 15:42 Nathan Sullivan
  2016-12-02 16:21 ` Zubair Lutfullah Kakakhel
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Nathan Sullivan @ 2016-12-02 15:42 UTC (permalink / raw)
  To: ralf, mark.rutland, robh+dt
  Cc: linux-mips, devicetree, linux-kernel, Nathan Sullivan

Support the National Instruments 169445 board.

Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
---
"gpio: mmio: add support for NI 169445 NAND GPIO" and 
"devicetree: add vendor prefix for National Instruments" are required for the
NAND on this board to work.

 Documentation/devicetree/bindings/mips/ni.txt |   7 ++
 arch/mips/Kbuild.platforms                    |   1 +
 arch/mips/Kconfig                             |  26 ++++++
 arch/mips/boot/dts/Makefile                   |   1 +
 arch/mips/boot/dts/ni/169445.dts              |  99 +++++++++++++++++++++
 arch/mips/boot/dts/ni/Makefile                |   9 ++
 arch/mips/configs/ni169445_defconfig          | 120 ++++++++++++++++++++++++++
 arch/mips/ni169445/169445-console.c           |  38 ++++++++
 arch/mips/ni169445/169445-init.c              |  39 +++++++++
 arch/mips/ni169445/169445-int.c               |  34 ++++++++
 arch/mips/ni169445/169445-setup.c             |  58 +++++++++++++
 arch/mips/ni169445/169445-time.c              |  35 ++++++++
 arch/mips/ni169445/Makefile                   |   9 ++
 arch/mips/ni169445/Platform                   |   6 ++
 14 files changed, 482 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
 create mode 100644 arch/mips/boot/dts/ni/169445.dts
 create mode 100644 arch/mips/boot/dts/ni/Makefile
 create mode 100644 arch/mips/configs/ni169445_defconfig
 create mode 100644 arch/mips/ni169445/169445-console.c
 create mode 100644 arch/mips/ni169445/169445-init.c
 create mode 100644 arch/mips/ni169445/169445-int.c
 create mode 100644 arch/mips/ni169445/169445-setup.c
 create mode 100644 arch/mips/ni169445/169445-time.c
 create mode 100644 arch/mips/ni169445/Makefile
 create mode 100644 arch/mips/ni169445/Platform

diff --git a/Documentation/devicetree/bindings/mips/ni.txt b/Documentation/devicetree/bindings/mips/ni.txt
new file mode 100644
index 0000000..722bf2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/ni.txt
@@ -0,0 +1,7 @@
+National Instruments MIPS platforms
+
+required root node properties:
+	- compatible: must be "ni,169445"
+
+CPU Nodes
+	- compatible: must be "mti,mips14KEc"
diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
index f5f1bdb..f2d7b5c 100644
--- a/arch/mips/Kbuild.platforms
+++ b/arch/mips/Kbuild.platforms
@@ -20,6 +20,7 @@ platforms += loongson32
 platforms += loongson64
 platforms += mti-malta
 platforms += netlogic
+platforms += ni169445
 platforms += paravirt
 platforms += pic32
 platforms += pistachio
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index b3c5bde..d24d11f 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -574,6 +574,32 @@ config NXP_STB225
 	help
 	 Support for NXP Semiconductors STB225 Development Board.
 
+config NI_169445
+	bool "NI 169445 board"
+	select ARCH_WANT_OPTIONAL_GPIOLIB
+	select BOOT_ELF32
+	select BOOT_RAW
+	select BUILTIN_DTB
+	select CEVT_R4K
+	select CSRC_R4K
+	select CPU_MIPSR2_IRQ_VI
+	select CPU_MIPSR2_IRQ_EI
+	select DMA_NONCOHERENT
+	select IRQ_MIPS_CPU
+	select LIBFDT
+	select MIPS_MSC
+	select SYS_HAS_CPU_MIPS32_R1
+	select SYS_HAS_CPU_MIPS32_R2
+	select SYS_HAS_EARLY_PRINTK
+	select SYS_SUPPORTS_32BIT_KERNEL
+	select SYS_SUPPORTS_LITTLE_ENDIAN
+	select USE_OF
+	select COMMON_CLK
+	help
+	  This enables support for the National Instruments 169445A
+	  board.
+
+
 config PMC_MSP
 	bool "PMC-Sierra MSP chipsets"
 	select CEVT_R4K
diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
index fc7a0a9..65a0ad8 100644
--- a/arch/mips/boot/dts/Makefile
+++ b/arch/mips/boot/dts/Makefile
@@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
 dts-dirs	+= ingenic
 dts-dirs	+= lantiq
 dts-dirs	+= mti
+dts-dirs	+= ni
 dts-dirs	+= netlogic
 dts-dirs	+= pic32
 dts-dirs	+= qca
diff --git a/arch/mips/boot/dts/ni/169445.dts b/arch/mips/boot/dts/ni/169445.dts
new file mode 100644
index 0000000..a2b49f9
--- /dev/null
+++ b/arch/mips/boot/dts/ni/169445.dts
@@ -0,0 +1,99 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "ni,169445";
+
+	cpus {
+		mips-hpt-frequency = <25000000>;
+
+		cpu@0 {
+			compatible = "mti,mips14KEc";
+		};
+	};
+
+	memory {
+		device_type = "memory";
+		reg = <0x0 0x08000000>;
+	};
+
+	clocks {
+		baseclk: baseclock {
+			compatible = "fixed-clock";
+			#clock-cells = <0>;
+			clock-frequency = <50000000>;
+		};
+	};
+
+	cpu_intc: cpu_intc {
+		#address-cells = <0>;
+		compatible = "mti,cpu-interrupt-controller";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+	};
+
+	ahb@0 {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges;
+
+		gpio1: nand-gpio-out@1f300010 {
+			compatible = "ni,169445-nand-gpio";
+			reg = <0x1f300010 0x4>;
+			reg-names = "dat";
+			gpio-controller;
+			#gpio-cells = <2>;
+			ngpios = <5>;
+		};
+
+		gpio2: nand-gpio-in@1f300014 {
+			compatible = "ni,169445-nand-gpio";
+			reg = <0x1f300014 0x4>;
+			reg-names = "dat";
+			gpio-controller;
+			#gpio-cells = <2>;
+			ngpios = <1>;
+		};
+
+		nand@1f300000 {
+			compatible = "gpio-control-nand";
+			nand-on-flash-bbt;
+			nand-ecc-mode = "soft_bch";
+			nand-ecc-step-size = <512>;
+			nand-ecc-strength = <4>;
+			reg = <0x1f300000 4>;
+			gpios = <&gpio2 0 0>, /* rdy */
+				<&gpio1 1 0>, /* nce */
+				<&gpio1 2 0>, /* ale */
+				<&gpio1 3 0>, /* cle */
+				<&gpio1 4 0>; /* nwp */
+		};
+
+		serial@1f380000 {
+			compatible = "ns16550a";
+			reg = <0x1f380000 0x1000>;
+			interrupt-parent = <&cpu_intc>;
+			interrupts = <6>;
+			clocks = <&baseclk>;
+			reg-shift = <0>;
+		};
+
+		ethernet@1f340000 {
+			compatible = "snps,dwc-qos-ethernet-4.10";
+			interrupt-parent = <&cpu_intc>;
+			interrupts = <5>;
+			reg = <0x1f340000 0x2000>;
+			clock-names = "apb_pclk", "phy_ref_clk";
+			clocks = <&baseclk>, <&baseclk>;
+
+			phy-mode = "rgmii";
+
+			fixed-link {
+				speed = <1000>;
+				full-duplex;
+			};
+		};
+	};
+};
diff --git a/arch/mips/boot/dts/ni/Makefile b/arch/mips/boot/dts/ni/Makefile
new file mode 100644
index 0000000..5291c18
--- /dev/null
+++ b/arch/mips/boot/dts/ni/Makefile
@@ -0,0 +1,9 @@
+dtb-$(CONFIG_NI_169445)		+= 169445.dtb
+
+obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
+
+# Force kbuild to make empty built-in.o if necessary
+obj-				+= dummy.o
+
+always				:= $(dtb-y)
+clean-files			:= *.dtb *.dtb.S
diff --git a/arch/mips/configs/ni169445_defconfig b/arch/mips/configs/ni169445_defconfig
new file mode 100644
index 0000000..e5a34df
--- /dev/null
+++ b/arch/mips/configs/ni169445_defconfig
@@ -0,0 +1,120 @@
+CONFIG_NI_169445=y
+CONFIG_CPU_MIPS32_R2=y
+CONFIG_HZ_100=y
+CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y
+# CONFIG_SWAP is not set
+CONFIG_SYSVIPC=y
+CONFIG_HZ_PERIODIC=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IKCONFIG=y
+CONFIG_IKCONFIG_PROC=y
+CONFIG_LOG_BUF_SHIFT=15
+CONFIG_BLK_DEV_INITRD=y
+# CONFIG_RD_GZIP is not set
+# CONFIG_RD_LZMA is not set
+# CONFIG_RD_XZ is not set
+# CONFIG_RD_LZO is not set
+# CONFIG_RD_LZ4 is not set
+# CONFIG_SHMEM is not set
+CONFIG_EMBEDDED=y
+CONFIG_SLAB=y
+CONFIG_PROFILING=y
+# CONFIG_LBDAF is not set
+# CONFIG_BLK_DEV_BSG is not set
+# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
+# CONFIG_SUSPEND is not set
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+# CONFIG_INET_DIAG is not set
+# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
+CONFIG_NETFILTER=y
+CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
+CONFIG_IP_NF_IPTABLES=y
+CONFIG_IP_NF_FILTER=y
+CONFIG_IP6_NF_IPTABLES=y
+CONFIG_IP6_NF_FILTER=y
+# CONFIG_WIRELESS is not set
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_MTD=y
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK_RO=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_ECC_BCH=y
+CONFIG_MTD_NAND_GPIO=y
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BLOCK=y
+CONFIG_NETDEVICES=y
+# CONFIG_NET_VENDOR_AMAZON is not set
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_CADENCE is not set
+# CONFIG_NET_VENDOR_BROADCOM is not set
+# CONFIG_NET_VENDOR_EZCHIP is not set
+# CONFIG_NET_VENDOR_INTEL is not set
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_NETRONOME is not set
+# CONFIG_NET_VENDOR_QUALCOMM is not set
+# CONFIG_NET_VENDOR_RENESAS is not set
+# CONFIG_NET_VENDOR_ROCKER is not set
+# CONFIG_NET_VENDOR_SAMSUNG is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+CONFIG_SYNOPSYS_DWC_ETH_QOS=y
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+# CONFIG_NET_VENDOR_XILINX is not set
+# CONFIG_WLAN is not set
+# CONFIG_INPUT_MOUSEDEV is not set
+# CONFIG_INPUT_KEYBOARD is not set
+# CONFIG_INPUT_MOUSE is not set
+# CONFIG_SERIO is not set
+# CONFIG_CONSOLE_TRANSLATIONS is not set
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_LEGACY_PTY_COUNT=32
+CONFIG_SERIAL_8250=y
+# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
+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_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+# CONFIG_HWMON is not set
+# CONFIG_VGA_CONSOLE is not set
+# CONFIG_HID is not set
+# CONFIG_USB_SUPPORT is not set
+# CONFIG_MIPS_PLATFORM_DEVICES is not set
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_UBIFS_FS=y
+CONFIG_UBIFS_FS_ADVANCED_COMPR=y
+# CONFIG_UBIFS_FS_ZLIB is not set
+CONFIG_SQUASHFS=y
+# CONFIG_SQUASHFS_ZLIB is not set
+CONFIG_SQUASHFS_LZO=y
+CONFIG_SQUASHFS_XZ=y
+# CONFIG_NETWORK_FILESYSTEMS is not set
+# CONFIG_FTRACE is not set
+CONFIG_CRYPTO_CBC=y
+CONFIG_CRYPTO_ECB=y
+CONFIG_CRYPTO_CRC32C=y
+CONFIG_CRYPTO_ARC4=y
+# CONFIG_CRYPTO_HW is not set
+# CONFIG_XZ_DEC_X86 is not set
+# CONFIG_XZ_DEC_POWERPC is not set
+# CONFIG_XZ_DEC_IA64 is not set
+# CONFIG_XZ_DEC_ARM is not set
+# CONFIG_XZ_DEC_ARMTHUMB is not set
+# CONFIG_XZ_DEC_SPARC is not set
diff --git a/arch/mips/ni169445/169445-console.c b/arch/mips/ni169445/169445-console.c
new file mode 100644
index 0000000..f07e48b
--- /dev/null
+++ b/arch/mips/ni169445/169445-console.c
@@ -0,0 +1,38 @@
+/*  Copyright 2016 National Instruments Corporation
+ *
+ *  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.
+ */
+#include <linux/init.h>
+#include <linux/console.h>
+#include <linux/serial_reg.h>
+#include <linux/io.h>
+
+#define NI_UART0_REGS_BASE	((unsigned char __iomem *)0xbf380000)
+
+static inline unsigned char serial_in(int offset)
+{
+	return __raw_readb(NI_UART0_REGS_BASE + offset);
+}
+
+static inline void serial_out(int offset, char value)
+{
+	__raw_writeb(value, NI_UART0_REGS_BASE + offset);
+}
+
+int prom_putchar(char c)
+{
+	while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0)
+		;
+
+	serial_out(UART_TX, c);
+
+	return 1;
+}
diff --git a/arch/mips/ni169445/169445-init.c b/arch/mips/ni169445/169445-init.c
new file mode 100644
index 0000000..5c7ff5e
--- /dev/null
+++ b/arch/mips/ni169445/169445-init.c
@@ -0,0 +1,39 @@
+/*  Copyright 2016 National Instruments Corporation
+ *
+ *  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.
+ */
+#include <linux/init.h>
+#include <linux/initrd.h>
+#include <linux/io.h>
+
+#include <asm/bootinfo.h>
+#include <asm/cacheflush.h>
+#include <asm/traps.h>
+#include <asm/mips-boards/generic.h>
+#include <asm/fw/fw.h>
+
+void __init prom_init(void)
+{
+	fw_init_cmdline();
+
+#ifdef CONFIG_BLK_DEV_INITRD
+	/* Read the initrd address from the firmware environment */
+	initrd_start = fw_getenvl("initrd_start");
+	if (initrd_start) {
+		initrd_start = KSEG0ADDR(initrd_start);
+		initrd_end = initrd_start + fw_getenvl("initrd_size");
+	}
+#endif
+}
+
+void __init prom_free_prom_memory(void)
+{
+}
diff --git a/arch/mips/ni169445/169445-int.c b/arch/mips/ni169445/169445-int.c
new file mode 100644
index 0000000..83caf79
--- /dev/null
+++ b/arch/mips/ni169445/169445-int.c
@@ -0,0 +1,34 @@
+/*  Copyright 2016 National Instruments Corporation
+ *
+ *  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.
+ */
+#include <linux/init.h>
+#include <linux/irq.h>
+#include <linux/of_irq.h>
+#include <linux/irqchip/mips-gic.h>
+#include <linux/io.h>
+
+#include <asm/irq_cpu.h>
+#include <asm/setup.h>
+
+static const struct of_device_id of_irq_ids[] __initconst = {
+	{
+		.compatible = "mti,cpu-interrupt-controller",
+		.data = mips_cpu_irq_of_init
+	},
+	{},
+};
+
+void __init arch_init_irq(void)
+{
+	of_irq_init(of_irq_ids);
+}
+
diff --git a/arch/mips/ni169445/169445-setup.c b/arch/mips/ni169445/169445-setup.c
new file mode 100644
index 0000000..80a5c91
--- /dev/null
+++ b/arch/mips/ni169445/169445-setup.c
@@ -0,0 +1,58 @@
+/*  Copyright 2016 National Instruments Corporation
+ *
+ *  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.
+ */
+#include <linux/init.h>
+#include <linux/clk-provider.h>
+#include <linux/libfdt.h>
+#include <linux/of_platform.h>
+#include <linux/of_fdt.h>
+
+#include <asm/prom.h>
+#include <asm/fw/fw.h>
+
+#include <asm/mips-boards/generic.h>
+
+const char *get_system_type(void)
+{
+	return "NI 169445 FPGA";
+}
+
+void __init plat_mem_setup(void)
+{
+	/*
+	 * Load the builtin devicetree. This causes the chosen node to be
+	 * parsed resulting in our memory appearing
+	 */
+	__dt_setup_arch(__dtb_start);
+}
+
+void __init device_tree_init(void)
+{
+	if (!initial_boot_params)
+		return;
+
+	unflatten_and_copy_device_tree();
+}
+
+static int __init customize_machine(void)
+{
+	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
+	return 0;
+}
+arch_initcall(customize_machine);
+
+static int __init plat_dev_init(void)
+{
+	of_clk_init(NULL);
+	return 0;
+}
+device_initcall(plat_dev_init);
diff --git a/arch/mips/ni169445/169445-time.c b/arch/mips/ni169445/169445-time.c
new file mode 100644
index 0000000..3d2499e
--- /dev/null
+++ b/arch/mips/ni169445/169445-time.c
@@ -0,0 +1,35 @@
+/*  Copyright 2016 National Instruments Corporation
+ *
+ *  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.
+ */
+
+#include <linux/init.h>
+#include <linux/of.h>
+
+#include <asm/time.h>
+
+void __init plat_time_init(void)
+{
+	struct device_node *np;
+	u32 freq;
+
+	np = of_find_node_by_name(NULL, "cpus");
+	if (!np)
+		panic("missing 'cpus' DT node");
+	if (of_property_read_u32(np, "mips-hpt-frequency", &freq) < 0)
+		panic("missing 'mips-hpt-frequency' property");
+	of_node_put(np);
+
+	mips_hpt_frequency = freq;
+
+	/* IRQs will not work until the timer has been set at least once */
+	write_c0_count(0);
+}
diff --git a/arch/mips/ni169445/Makefile b/arch/mips/ni169445/Makefile
new file mode 100644
index 0000000..f3a0c8c
--- /dev/null
+++ b/arch/mips/ni169445/Makefile
@@ -0,0 +1,9 @@
+#
+#
+obj-y				:= 169445-init.o \
+				   169445-int.o 169445-setup.o \
+				   169445-time.o
+
+obj-$(CONFIG_EARLY_PRINTK)	+= 169445-console.o
+
+CFLAGS_169445-setup.o = -I$(src)/../../../scripts/dtc/libfdt
diff --git a/arch/mips/ni169445/Platform b/arch/mips/ni169445/Platform
new file mode 100644
index 0000000..9380312
--- /dev/null
+++ b/arch/mips/ni169445/Platform
@@ -0,0 +1,6 @@
+#
+# National Instruments 169445 FPGA board
+#
+platform-$(CONFIG_NI_169445)	+= ni169445/
+load-$(CONFIG_NI_169445)	+= 0xffffffff80002000
+all-$(CONFIG_NI_169445)		:= $(COMPRESSION_FNAME).srec
-- 
2.1.4

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-02 15:42 [PATCH] MIPS: NI 169445 board support Nathan Sullivan
@ 2016-12-02 16:21 ` Zubair Lutfullah Kakakhel
  2016-12-02 17:30   ` Nathan Sullivan
  2016-12-09 21:18 ` Rob Herring
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 14+ messages in thread
From: Zubair Lutfullah Kakakhel @ 2016-12-02 16:21 UTC (permalink / raw)
  To: Nathan Sullivan, ralf, mark.rutland, robh+dt
  Cc: linux-mips, devicetree, linux-kernel

Hi,

On 12/02/2016 03:42 PM, Nathan Sullivan wrote:
> Support the National Instruments 169445 board.

Interesting patch.

But do you happen to have a link to a description of the board?
I couldn't find anything with a quick search.
Perhaps the public name is something else?

Thanks,
ZubairLK

>
> Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
> ---
> "gpio: mmio: add support for NI 169445 NAND GPIO" and
> "devicetree: add vendor prefix for National Instruments" are required for the
> NAND on this board to work.
>
>  Documentation/devicetree/bindings/mips/ni.txt |   7 ++
>  arch/mips/Kbuild.platforms                    |   1 +
>  arch/mips/Kconfig                             |  26 ++++++
>  arch/mips/boot/dts/Makefile                   |   1 +
>  arch/mips/boot/dts/ni/169445.dts              |  99 +++++++++++++++++++++
>  arch/mips/boot/dts/ni/Makefile                |   9 ++
>  arch/mips/configs/ni169445_defconfig          | 120 ++++++++++++++++++++++++++
>  arch/mips/ni169445/169445-console.c           |  38 ++++++++
>  arch/mips/ni169445/169445-init.c              |  39 +++++++++
>  arch/mips/ni169445/169445-int.c               |  34 ++++++++
>  arch/mips/ni169445/169445-setup.c             |  58 +++++++++++++
>  arch/mips/ni169445/169445-time.c              |  35 ++++++++
>  arch/mips/ni169445/Makefile                   |   9 ++
>  arch/mips/ni169445/Platform                   |   6 ++
>  14 files changed, 482 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
>  create mode 100644 arch/mips/boot/dts/ni/169445.dts
>  create mode 100644 arch/mips/boot/dts/ni/Makefile
>  create mode 100644 arch/mips/configs/ni169445_defconfig
>  create mode 100644 arch/mips/ni169445/169445-console.c
>  create mode 100644 arch/mips/ni169445/169445-init.c
>  create mode 100644 arch/mips/ni169445/169445-int.c
>  create mode 100644 arch/mips/ni169445/169445-setup.c
>  create mode 100644 arch/mips/ni169445/169445-time.c
>  create mode 100644 arch/mips/ni169445/Makefile
>  create mode 100644 arch/mips/ni169445/Platform
>
> diff --git a/Documentation/devicetree/bindings/mips/ni.txt b/Documentation/devicetree/bindings/mips/ni.txt
> new file mode 100644
> index 0000000..722bf2d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mips/ni.txt
> @@ -0,0 +1,7 @@
> +National Instruments MIPS platforms
> +
> +required root node properties:
> +	- compatible: must be "ni,169445"
> +
> +CPU Nodes
> +	- compatible: must be "mti,mips14KEc"
> diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
> index f5f1bdb..f2d7b5c 100644
> --- a/arch/mips/Kbuild.platforms
> +++ b/arch/mips/Kbuild.platforms
> @@ -20,6 +20,7 @@ platforms += loongson32
>  platforms += loongson64
>  platforms += mti-malta
>  platforms += netlogic
> +platforms += ni169445
>  platforms += paravirt
>  platforms += pic32
>  platforms += pistachio
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index b3c5bde..d24d11f 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -574,6 +574,32 @@ config NXP_STB225
>  	help
>  	 Support for NXP Semiconductors STB225 Development Board.
>
> +config NI_169445
> +	bool "NI 169445 board"
> +	select ARCH_WANT_OPTIONAL_GPIOLIB
> +	select BOOT_ELF32
> +	select BOOT_RAW
> +	select BUILTIN_DTB
> +	select CEVT_R4K
> +	select CSRC_R4K
> +	select CPU_MIPSR2_IRQ_VI
> +	select CPU_MIPSR2_IRQ_EI
> +	select DMA_NONCOHERENT
> +	select IRQ_MIPS_CPU
> +	select LIBFDT
> +	select MIPS_MSC
> +	select SYS_HAS_CPU_MIPS32_R1
> +	select SYS_HAS_CPU_MIPS32_R2
> +	select SYS_HAS_EARLY_PRINTK
> +	select SYS_SUPPORTS_32BIT_KERNEL
> +	select SYS_SUPPORTS_LITTLE_ENDIAN
> +	select USE_OF
> +	select COMMON_CLK
> +	help
> +	  This enables support for the National Instruments 169445A
> +	  board.
> +
> +
>  config PMC_MSP
>  	bool "PMC-Sierra MSP chipsets"
>  	select CEVT_R4K
> diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
> index fc7a0a9..65a0ad8 100644
> --- a/arch/mips/boot/dts/Makefile
> +++ b/arch/mips/boot/dts/Makefile
> @@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
>  dts-dirs	+= ingenic
>  dts-dirs	+= lantiq
>  dts-dirs	+= mti
> +dts-dirs	+= ni
>  dts-dirs	+= netlogic
>  dts-dirs	+= pic32
>  dts-dirs	+= qca
> diff --git a/arch/mips/boot/dts/ni/169445.dts b/arch/mips/boot/dts/ni/169445.dts
> new file mode 100644
> index 0000000..a2b49f9
> --- /dev/null
> +++ b/arch/mips/boot/dts/ni/169445.dts
> @@ -0,0 +1,99 @@
> +/dts-v1/;
> +
> +/ {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +	compatible = "ni,169445";
> +
> +	cpus {
> +		mips-hpt-frequency = <25000000>;
> +
> +		cpu@0 {
> +			compatible = "mti,mips14KEc";
> +		};
> +	};
> +
> +	memory {
> +		device_type = "memory";
> +		reg = <0x0 0x08000000>;
> +	};
> +
> +	clocks {
> +		baseclk: baseclock {
> +			compatible = "fixed-clock";
> +			#clock-cells = <0>;
> +			clock-frequency = <50000000>;
> +		};
> +	};
> +
> +	cpu_intc: cpu_intc {
> +		#address-cells = <0>;
> +		compatible = "mti,cpu-interrupt-controller";
> +		interrupt-controller;
> +		#interrupt-cells = <1>;
> +	};
> +
> +	ahb@0 {
> +		compatible = "simple-bus";
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		ranges;
> +
> +		gpio1: nand-gpio-out@1f300010 {
> +			compatible = "ni,169445-nand-gpio";
> +			reg = <0x1f300010 0x4>;
> +			reg-names = "dat";
> +			gpio-controller;
> +			#gpio-cells = <2>;
> +			ngpios = <5>;
> +		};
> +
> +		gpio2: nand-gpio-in@1f300014 {
> +			compatible = "ni,169445-nand-gpio";
> +			reg = <0x1f300014 0x4>;
> +			reg-names = "dat";
> +			gpio-controller;
> +			#gpio-cells = <2>;
> +			ngpios = <1>;
> +		};
> +
> +		nand@1f300000 {
> +			compatible = "gpio-control-nand";
> +			nand-on-flash-bbt;
> +			nand-ecc-mode = "soft_bch";
> +			nand-ecc-step-size = <512>;
> +			nand-ecc-strength = <4>;
> +			reg = <0x1f300000 4>;
> +			gpios = <&gpio2 0 0>, /* rdy */
> +				<&gpio1 1 0>, /* nce */
> +				<&gpio1 2 0>, /* ale */
> +				<&gpio1 3 0>, /* cle */
> +				<&gpio1 4 0>; /* nwp */
> +		};
> +
> +		serial@1f380000 {
> +			compatible = "ns16550a";
> +			reg = <0x1f380000 0x1000>;
> +			interrupt-parent = <&cpu_intc>;
> +			interrupts = <6>;
> +			clocks = <&baseclk>;
> +			reg-shift = <0>;
> +		};
> +
> +		ethernet@1f340000 {
> +			compatible = "snps,dwc-qos-ethernet-4.10";
> +			interrupt-parent = <&cpu_intc>;
> +			interrupts = <5>;
> +			reg = <0x1f340000 0x2000>;
> +			clock-names = "apb_pclk", "phy_ref_clk";
> +			clocks = <&baseclk>, <&baseclk>;
> +
> +			phy-mode = "rgmii";
> +
> +			fixed-link {
> +				speed = <1000>;
> +				full-duplex;
> +			};
> +		};
> +	};
> +};
> diff --git a/arch/mips/boot/dts/ni/Makefile b/arch/mips/boot/dts/ni/Makefile
> new file mode 100644
> index 0000000..5291c18
> --- /dev/null
> +++ b/arch/mips/boot/dts/ni/Makefile
> @@ -0,0 +1,9 @@
> +dtb-$(CONFIG_NI_169445)		+= 169445.dtb
> +
> +obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
> +
> +# Force kbuild to make empty built-in.o if necessary
> +obj-				+= dummy.o
> +
> +always				:= $(dtb-y)
> +clean-files			:= *.dtb *.dtb.S
> diff --git a/arch/mips/configs/ni169445_defconfig b/arch/mips/configs/ni169445_defconfig
> new file mode 100644
> index 0000000..e5a34df
> --- /dev/null
> +++ b/arch/mips/configs/ni169445_defconfig
> @@ -0,0 +1,120 @@
> +CONFIG_NI_169445=y
> +CONFIG_CPU_MIPS32_R2=y
> +CONFIG_HZ_100=y
> +CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y
> +# CONFIG_SWAP is not set
> +CONFIG_SYSVIPC=y
> +CONFIG_HZ_PERIODIC=y
> +CONFIG_NO_HZ=y
> +CONFIG_HIGH_RES_TIMERS=y
> +CONFIG_IKCONFIG=y
> +CONFIG_IKCONFIG_PROC=y
> +CONFIG_LOG_BUF_SHIFT=15
> +CONFIG_BLK_DEV_INITRD=y
> +# CONFIG_RD_GZIP is not set
> +# CONFIG_RD_LZMA is not set
> +# CONFIG_RD_XZ is not set
> +# CONFIG_RD_LZO is not set
> +# CONFIG_RD_LZ4 is not set
> +# CONFIG_SHMEM is not set
> +CONFIG_EMBEDDED=y
> +CONFIG_SLAB=y
> +CONFIG_PROFILING=y
> +# CONFIG_LBDAF is not set
> +# CONFIG_BLK_DEV_BSG is not set
> +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
> +# CONFIG_SUSPEND is not set
> +CONFIG_NET=y
> +CONFIG_PACKET=y
> +CONFIG_UNIX=y
> +CONFIG_INET=y
> +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
> +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
> +# CONFIG_INET_XFRM_MODE_BEET is not set
> +# CONFIG_INET_DIAG is not set
> +# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
> +# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
> +CONFIG_NETFILTER=y
> +CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
> +CONFIG_IP_NF_IPTABLES=y
> +CONFIG_IP_NF_FILTER=y
> +CONFIG_IP6_NF_IPTABLES=y
> +CONFIG_IP6_NF_FILTER=y
> +# CONFIG_WIRELESS is not set
> +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
> +CONFIG_DEVTMPFS=y
> +CONFIG_DEVTMPFS_MOUNT=y
> +CONFIG_MTD=y
> +CONFIG_MTD_CMDLINE_PARTS=y
> +CONFIG_MTD_BLOCK_RO=y
> +CONFIG_MTD_NAND=y
> +CONFIG_MTD_NAND_ECC_BCH=y
> +CONFIG_MTD_NAND_GPIO=y
> +CONFIG_MTD_UBI=y
> +CONFIG_MTD_UBI_BLOCK=y
> +CONFIG_NETDEVICES=y
> +# CONFIG_NET_VENDOR_AMAZON is not set
> +# CONFIG_NET_VENDOR_ARC is not set
> +# CONFIG_NET_CADENCE is not set
> +# CONFIG_NET_VENDOR_BROADCOM is not set
> +# CONFIG_NET_VENDOR_EZCHIP is not set
> +# CONFIG_NET_VENDOR_INTEL is not set
> +# CONFIG_NET_VENDOR_MARVELL is not set
> +# CONFIG_NET_VENDOR_MICREL is not set
> +# CONFIG_NET_VENDOR_NATSEMI is not set
> +# CONFIG_NET_VENDOR_NETRONOME is not set
> +# CONFIG_NET_VENDOR_QUALCOMM is not set
> +# CONFIG_NET_VENDOR_RENESAS is not set
> +# CONFIG_NET_VENDOR_ROCKER is not set
> +# CONFIG_NET_VENDOR_SAMSUNG is not set
> +# CONFIG_NET_VENDOR_SEEQ is not set
> +# CONFIG_NET_VENDOR_SMSC is not set
> +# CONFIG_NET_VENDOR_STMICRO is not set
> +CONFIG_SYNOPSYS_DWC_ETH_QOS=y
> +# CONFIG_NET_VENDOR_VIA is not set
> +# CONFIG_NET_VENDOR_WIZNET is not set
> +# CONFIG_NET_VENDOR_XILINX is not set
> +# CONFIG_WLAN is not set
> +# CONFIG_INPUT_MOUSEDEV is not set
> +# CONFIG_INPUT_KEYBOARD is not set
> +# CONFIG_INPUT_MOUSE is not set
> +# CONFIG_SERIO is not set
> +# CONFIG_CONSOLE_TRANSLATIONS is not set
> +CONFIG_VT_HW_CONSOLE_BINDING=y
> +CONFIG_LEGACY_PTY_COUNT=32
> +CONFIG_SERIAL_8250=y
> +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
> +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_GPIOLIB=y
> +CONFIG_GPIO_SYSFS=y
> +CONFIG_GPIO_GENERIC_PLATFORM=y
> +# CONFIG_HWMON is not set
> +# CONFIG_VGA_CONSOLE is not set
> +# CONFIG_HID is not set
> +# CONFIG_USB_SUPPORT is not set
> +# CONFIG_MIPS_PLATFORM_DEVICES is not set
> +# CONFIG_IOMMU_SUPPORT is not set
> +CONFIG_UBIFS_FS=y
> +CONFIG_UBIFS_FS_ADVANCED_COMPR=y
> +# CONFIG_UBIFS_FS_ZLIB is not set
> +CONFIG_SQUASHFS=y
> +# CONFIG_SQUASHFS_ZLIB is not set
> +CONFIG_SQUASHFS_LZO=y
> +CONFIG_SQUASHFS_XZ=y
> +# CONFIG_NETWORK_FILESYSTEMS is not set
> +# CONFIG_FTRACE is not set
> +CONFIG_CRYPTO_CBC=y
> +CONFIG_CRYPTO_ECB=y
> +CONFIG_CRYPTO_CRC32C=y
> +CONFIG_CRYPTO_ARC4=y
> +# CONFIG_CRYPTO_HW is not set
> +# CONFIG_XZ_DEC_X86 is not set
> +# CONFIG_XZ_DEC_POWERPC is not set
> +# CONFIG_XZ_DEC_IA64 is not set
> +# CONFIG_XZ_DEC_ARM is not set
> +# CONFIG_XZ_DEC_ARMTHUMB is not set
> +# CONFIG_XZ_DEC_SPARC is not set
> diff --git a/arch/mips/ni169445/169445-console.c b/arch/mips/ni169445/169445-console.c
> new file mode 100644
> index 0000000..f07e48b
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-console.c
> @@ -0,0 +1,38 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/console.h>
> +#include <linux/serial_reg.h>
> +#include <linux/io.h>
> +
> +#define NI_UART0_REGS_BASE	((unsigned char __iomem *)0xbf380000)
> +
> +static inline unsigned char serial_in(int offset)
> +{
> +	return __raw_readb(NI_UART0_REGS_BASE + offset);
> +}
> +
> +static inline void serial_out(int offset, char value)
> +{
> +	__raw_writeb(value, NI_UART0_REGS_BASE + offset);
> +}
> +
> +int prom_putchar(char c)
> +{
> +	while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0)
> +		;
> +
> +	serial_out(UART_TX, c);
> +
> +	return 1;
> +}
> diff --git a/arch/mips/ni169445/169445-init.c b/arch/mips/ni169445/169445-init.c
> new file mode 100644
> index 0000000..5c7ff5e
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-init.c
> @@ -0,0 +1,39 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/initrd.h>
> +#include <linux/io.h>
> +
> +#include <asm/bootinfo.h>
> +#include <asm/cacheflush.h>
> +#include <asm/traps.h>
> +#include <asm/mips-boards/generic.h>
> +#include <asm/fw/fw.h>
> +
> +void __init prom_init(void)
> +{
> +	fw_init_cmdline();
> +
> +#ifdef CONFIG_BLK_DEV_INITRD
> +	/* Read the initrd address from the firmware environment */
> +	initrd_start = fw_getenvl("initrd_start");
> +	if (initrd_start) {
> +		initrd_start = KSEG0ADDR(initrd_start);
> +		initrd_end = initrd_start + fw_getenvl("initrd_size");
> +	}
> +#endif
> +}
> +
> +void __init prom_free_prom_memory(void)
> +{
> +}
> diff --git a/arch/mips/ni169445/169445-int.c b/arch/mips/ni169445/169445-int.c
> new file mode 100644
> index 0000000..83caf79
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-int.c
> @@ -0,0 +1,34 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/irq.h>
> +#include <linux/of_irq.h>
> +#include <linux/irqchip/mips-gic.h>
> +#include <linux/io.h>
> +
> +#include <asm/irq_cpu.h>
> +#include <asm/setup.h>
> +
> +static const struct of_device_id of_irq_ids[] __initconst = {
> +	{
> +		.compatible = "mti,cpu-interrupt-controller",
> +		.data = mips_cpu_irq_of_init
> +	},
> +	{},
> +};
> +
> +void __init arch_init_irq(void)
> +{
> +	of_irq_init(of_irq_ids);
> +}
> +
> diff --git a/arch/mips/ni169445/169445-setup.c b/arch/mips/ni169445/169445-setup.c
> new file mode 100644
> index 0000000..80a5c91
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-setup.c
> @@ -0,0 +1,58 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/clk-provider.h>
> +#include <linux/libfdt.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_fdt.h>
> +
> +#include <asm/prom.h>
> +#include <asm/fw/fw.h>
> +
> +#include <asm/mips-boards/generic.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "NI 169445 FPGA";
> +}
> +
> +void __init plat_mem_setup(void)
> +{
> +	/*
> +	 * Load the builtin devicetree. This causes the chosen node to be
> +	 * parsed resulting in our memory appearing
> +	 */
> +	__dt_setup_arch(__dtb_start);
> +}
> +
> +void __init device_tree_init(void)
> +{
> +	if (!initial_boot_params)
> +		return;
> +
> +	unflatten_and_copy_device_tree();
> +}
> +
> +static int __init customize_machine(void)
> +{
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +	return 0;
> +}
> +arch_initcall(customize_machine);
> +
> +static int __init plat_dev_init(void)
> +{
> +	of_clk_init(NULL);
> +	return 0;
> +}
> +device_initcall(plat_dev_init);
> diff --git a/arch/mips/ni169445/169445-time.c b/arch/mips/ni169445/169445-time.c
> new file mode 100644
> index 0000000..3d2499e
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-time.c
> @@ -0,0 +1,35 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/of.h>
> +
> +#include <asm/time.h>
> +
> +void __init plat_time_init(void)
> +{
> +	struct device_node *np;
> +	u32 freq;
> +
> +	np = of_find_node_by_name(NULL, "cpus");
> +	if (!np)
> +		panic("missing 'cpus' DT node");
> +	if (of_property_read_u32(np, "mips-hpt-frequency", &freq) < 0)
> +		panic("missing 'mips-hpt-frequency' property");
> +	of_node_put(np);
> +
> +	mips_hpt_frequency = freq;
> +
> +	/* IRQs will not work until the timer has been set at least once */
> +	write_c0_count(0);
> +}
> diff --git a/arch/mips/ni169445/Makefile b/arch/mips/ni169445/Makefile
> new file mode 100644
> index 0000000..f3a0c8c
> --- /dev/null
> +++ b/arch/mips/ni169445/Makefile
> @@ -0,0 +1,9 @@
> +#
> +#
> +obj-y				:= 169445-init.o \
> +				   169445-int.o 169445-setup.o \
> +				   169445-time.o
> +
> +obj-$(CONFIG_EARLY_PRINTK)	+= 169445-console.o
> +
> +CFLAGS_169445-setup.o = -I$(src)/../../../scripts/dtc/libfdt
> diff --git a/arch/mips/ni169445/Platform b/arch/mips/ni169445/Platform
> new file mode 100644
> index 0000000..9380312
> --- /dev/null
> +++ b/arch/mips/ni169445/Platform
> @@ -0,0 +1,6 @@
> +#
> +# National Instruments 169445 FPGA board
> +#
> +platform-$(CONFIG_NI_169445)	+= ni169445/
> +load-$(CONFIG_NI_169445)	+= 0xffffffff80002000
> +all-$(CONFIG_NI_169445)		:= $(COMPRESSION_FNAME).srec
>

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-02 16:21 ` Zubair Lutfullah Kakakhel
@ 2016-12-02 17:30   ` Nathan Sullivan
  0 siblings, 0 replies; 14+ messages in thread
From: Nathan Sullivan @ 2016-12-02 17:30 UTC (permalink / raw)
  To: Zubair Lutfullah Kakakhel
  Cc: ralf, mark.rutland, robh+dt, linux-mips, devicetree, linux-kernel

On Fri, Dec 02, 2016 at 04:21:59PM +0000, Zubair Lutfullah Kakakhel wrote:
> Hi,
> 
> On 12/02/2016 03:42 PM, Nathan Sullivan wrote:
> >Support the National Instruments 169445 board.
> 
> Interesting patch.
> 
> But do you happen to have a link to a description of the board?
> I couldn't find anything with a quick search.
> Perhaps the public name is something else?
> 
> Thanks,
> ZubairLK

This patch is for a pre-release board we have not made public yet.  It's a
straightforward MIPS system that will be used for networking, and we'd like to
get Linux support in place ahead of release.

Thanks,
Nathan

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-02 15:42 [PATCH] MIPS: NI 169445 board support Nathan Sullivan
  2016-12-02 16:21 ` Zubair Lutfullah Kakakhel
@ 2016-12-09 21:18 ` Rob Herring
  2016-12-14 16:32   ` Nathan Sullivan
  2016-12-13 18:40 ` Paul Burton
       [not found] ` <20161220163434.GA15962@linux-mips.org>
  3 siblings, 1 reply; 14+ messages in thread
From: Rob Herring @ 2016-12-09 21:18 UTC (permalink / raw)
  To: Nathan Sullivan; +Cc: ralf, mark.rutland, linux-mips, devicetree, linux-kernel

On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
> Support the National Instruments 169445 board.
> 
> Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
> ---
> "gpio: mmio: add support for NI 169445 NAND GPIO" and 
> "devicetree: add vendor prefix for National Instruments" are required for the
> NAND on this board to work.

These should have been a series, but I already applied the first one.

> 
>  Documentation/devicetree/bindings/mips/ni.txt |   7 ++
>  arch/mips/Kbuild.platforms                    |   1 +
>  arch/mips/Kconfig                             |  26 ++++++
>  arch/mips/boot/dts/Makefile                   |   1 +
>  arch/mips/boot/dts/ni/169445.dts              |  99 +++++++++++++++++++++
>  arch/mips/boot/dts/ni/Makefile                |   9 ++
>  arch/mips/configs/ni169445_defconfig          | 120 ++++++++++++++++++++++++++
>  arch/mips/ni169445/169445-console.c           |  38 ++++++++
>  arch/mips/ni169445/169445-init.c              |  39 +++++++++
>  arch/mips/ni169445/169445-int.c               |  34 ++++++++
>  arch/mips/ni169445/169445-setup.c             |  58 +++++++++++++
>  arch/mips/ni169445/169445-time.c              |  35 ++++++++
>  arch/mips/ni169445/Makefile                   |   9 ++
>  arch/mips/ni169445/Platform                   |   6 ++
>  14 files changed, 482 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
>  create mode 100644 arch/mips/boot/dts/ni/169445.dts
>  create mode 100644 arch/mips/boot/dts/ni/Makefile
>  create mode 100644 arch/mips/configs/ni169445_defconfig
>  create mode 100644 arch/mips/ni169445/169445-console.c
>  create mode 100644 arch/mips/ni169445/169445-init.c
>  create mode 100644 arch/mips/ni169445/169445-int.c
>  create mode 100644 arch/mips/ni169445/169445-setup.c
>  create mode 100644 arch/mips/ni169445/169445-time.c
>  create mode 100644 arch/mips/ni169445/Makefile
>  create mode 100644 arch/mips/ni169445/Platform
> 
> diff --git a/Documentation/devicetree/bindings/mips/ni.txt b/Documentation/devicetree/bindings/mips/ni.txt
> new file mode 100644
> index 0000000..722bf2d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mips/ni.txt
> @@ -0,0 +1,7 @@
> +National Instruments MIPS platforms
> +
> +required root node properties:
> +	- compatible: must be "ni,169445"
> +
> +CPU Nodes
> +	- compatible: must be "mti,mips14KEc"
> diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
> index f5f1bdb..f2d7b5c 100644
> --- a/arch/mips/Kbuild.platforms
> +++ b/arch/mips/Kbuild.platforms
> @@ -20,6 +20,7 @@ platforms += loongson32
>  platforms += loongson64
>  platforms += mti-malta
>  platforms += netlogic
> +platforms += ni169445
>  platforms += paravirt
>  platforms += pic32
>  platforms += pistachio
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index b3c5bde..d24d11f 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -574,6 +574,32 @@ config NXP_STB225
>  	help
>  	 Support for NXP Semiconductors STB225 Development Board.
>  
> +config NI_169445
> +	bool "NI 169445 board"
> +	select ARCH_WANT_OPTIONAL_GPIOLIB
> +	select BOOT_ELF32
> +	select BOOT_RAW
> +	select BUILTIN_DTB
> +	select CEVT_R4K
> +	select CSRC_R4K
> +	select CPU_MIPSR2_IRQ_VI
> +	select CPU_MIPSR2_IRQ_EI
> +	select DMA_NONCOHERENT
> +	select IRQ_MIPS_CPU
> +	select LIBFDT
> +	select MIPS_MSC
> +	select SYS_HAS_CPU_MIPS32_R1
> +	select SYS_HAS_CPU_MIPS32_R2
> +	select SYS_HAS_EARLY_PRINTK
> +	select SYS_SUPPORTS_32BIT_KERNEL
> +	select SYS_SUPPORTS_LITTLE_ENDIAN
> +	select USE_OF
> +	select COMMON_CLK
> +	help
> +	  This enables support for the National Instruments 169445A
> +	  board.
> +
> +
>  config PMC_MSP
>  	bool "PMC-Sierra MSP chipsets"
>  	select CEVT_R4K
> diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
> index fc7a0a9..65a0ad8 100644
> --- a/arch/mips/boot/dts/Makefile
> +++ b/arch/mips/boot/dts/Makefile
> @@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
>  dts-dirs	+= ingenic
>  dts-dirs	+= lantiq
>  dts-dirs	+= mti
> +dts-dirs	+= ni
>  dts-dirs	+= netlogic
>  dts-dirs	+= pic32
>  dts-dirs	+= qca
> diff --git a/arch/mips/boot/dts/ni/169445.dts b/arch/mips/boot/dts/ni/169445.dts
> new file mode 100644
> index 0000000..a2b49f9
> --- /dev/null
> +++ b/arch/mips/boot/dts/ni/169445.dts
> @@ -0,0 +1,99 @@
> +/dts-v1/;
> +
> +/ {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +	compatible = "ni,169445";
> +
> +	cpus {
> +		mips-hpt-frequency = <25000000>;
> +
> +		cpu@0 {
> +			compatible = "mti,mips14KEc";
> +		};
> +	};
> +
> +	memory {

memory@0

> +		device_type = "memory";
> +		reg = <0x0 0x08000000>;
> +	};
> +
> +	clocks {
> +		baseclk: baseclock {
> +			compatible = "fixed-clock";
> +			#clock-cells = <0>;
> +			clock-frequency = <50000000>;
> +		};
> +	};
> +
> +	cpu_intc: cpu_intc {
> +		#address-cells = <0>;
> +		compatible = "mti,cpu-interrupt-controller";
> +		interrupt-controller;
> +		#interrupt-cells = <1>;
> +	};
> +
> +	ahb@0 {
> +		compatible = "simple-bus";
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		ranges;

If everything is under 0x1f3xxxxx, then add in the ranges here (and the 
unit address).

> +
> +		gpio1: nand-gpio-out@1f300010 {

As in the binding example: gpio-controller@...

> +			compatible = "ni,169445-nand-gpio";
> +			reg = <0x1f300010 0x4>;
> +			reg-names = "dat";
> +			gpio-controller;
> +			#gpio-cells = <2>;
> +			ngpios = <5>;
> +		};
> +
> +		gpio2: nand-gpio-in@1f300014 {

ditto

> +			compatible = "ni,169445-nand-gpio";
> +			reg = <0x1f300014 0x4>;
> +			reg-names = "dat";
> +			gpio-controller;
> +			#gpio-cells = <2>;
> +			ngpios = <1>;
> +		};
> +
> +		nand@1f300000 {
> +			compatible = "gpio-control-nand";
> +			nand-on-flash-bbt;
> +			nand-ecc-mode = "soft_bch";
> +			nand-ecc-step-size = <512>;
> +			nand-ecc-strength = <4>;
> +			reg = <0x1f300000 4>;
> +			gpios = <&gpio2 0 0>, /* rdy */
> +				<&gpio1 1 0>, /* nce */
> +				<&gpio1 2 0>, /* ale */
> +				<&gpio1 3 0>, /* cle */
> +				<&gpio1 4 0>; /* nwp */
> +		};
> +
> +		serial@1f380000 {
> +			compatible = "ns16550a";
> +			reg = <0x1f380000 0x1000>;
> +			interrupt-parent = <&cpu_intc>;
> +			interrupts = <6>;
> +			clocks = <&baseclk>;
> +			reg-shift = <0>;
> +		};
> +
> +		ethernet@1f340000 {
> +			compatible = "snps,dwc-qos-ethernet-4.10";
> +			interrupt-parent = <&cpu_intc>;
> +			interrupts = <5>;
> +			reg = <0x1f340000 0x2000>;
> +			clock-names = "apb_pclk", "phy_ref_clk";
> +			clocks = <&baseclk>, <&baseclk>;
> +
> +			phy-mode = "rgmii";
> +
> +			fixed-link {
> +				speed = <1000>;
> +				full-duplex;
> +			};
> +		};
> +	};
> +};

[...]

> diff --git a/arch/mips/ni169445/169445-setup.c b/arch/mips/ni169445/169445-setup.c
> new file mode 100644
> index 0000000..80a5c91
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-setup.c
> @@ -0,0 +1,58 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/clk-provider.h>
> +#include <linux/libfdt.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_fdt.h>
> +
> +#include <asm/prom.h>
> +#include <asm/fw/fw.h>
> +
> +#include <asm/mips-boards/generic.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "NI 169445 FPGA";

Perhaps this should come from model property. There's a patch in flight 
to add a function to get machine name.

> +}
> +
> +void __init plat_mem_setup(void)
> +{
> +	/*
> +	 * Load the builtin devicetree. This causes the chosen node to be
> +	 * parsed resulting in our memory appearing
> +	 */
> +	__dt_setup_arch(__dtb_start);
> +}
> +
> +void __init device_tree_init(void)
> +{
> +	if (!initial_boot_params)
> +		return;
> +
> +	unflatten_and_copy_device_tree();
> +}
> +
> +static int __init customize_machine(void)
> +{
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);

This should happen by default now.

> +	return 0;
> +}
> +arch_initcall(customize_machine);

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-02 15:42 [PATCH] MIPS: NI 169445 board support Nathan Sullivan
  2016-12-02 16:21 ` Zubair Lutfullah Kakakhel
  2016-12-09 21:18 ` Rob Herring
@ 2016-12-13 18:40 ` Paul Burton
  2016-12-13 18:56   ` Nathan Sullivan
       [not found] ` <20161220163434.GA15962@linux-mips.org>
  3 siblings, 1 reply; 14+ messages in thread
From: Paul Burton @ 2016-12-13 18:40 UTC (permalink / raw)
  To: Nathan Sullivan
  Cc: linux-mips, ralf, mark.rutland, robh+dt, devicetree, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 20363 bytes --]

Hi Nathan,

On Friday, 2 December 2016 09:42:09 GMT Nathan Sullivan wrote:
> Support the National Instruments 169445 board.
> 
> Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
> ---
> "gpio: mmio: add support for NI 169445 NAND GPIO" and
> "devicetree: add vendor prefix for National Instruments" are required for
> the NAND on this board to work.
> 
>  Documentation/devicetree/bindings/mips/ni.txt |   7 ++
>  arch/mips/Kbuild.platforms                    |   1 +
>  arch/mips/Kconfig                             |  26 ++++++
>  arch/mips/boot/dts/Makefile                   |   1 +
>  arch/mips/boot/dts/ni/169445.dts              |  99 +++++++++++++++++++++
>  arch/mips/boot/dts/ni/Makefile                |   9 ++
>  arch/mips/configs/ni169445_defconfig          | 120 ++++++++++++++++++++++++++
>  arch/mips/ni169445/169445-console.c           |  38 ++++++++
>  arch/mips/ni169445/169445-init.c              |  39 +++++++++
>  arch/mips/ni169445/169445-int.c               |  34 ++++++++
>  arch/mips/ni169445/169445-setup.c             |  58 +++++++++++++
>  arch/mips/ni169445/169445-time.c              |  35 ++++++++
>  arch/mips/ni169445/Makefile                   |   9 ++
>  arch/mips/ni169445/Platform                   |   6 ++
>  14 files changed, 482 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
>  create mode 100644 arch/mips/boot/dts/ni/169445.dts
>  create mode 100644 arch/mips/boot/dts/ni/Makefile
>  create mode 100644 arch/mips/configs/ni169445_defconfig
>  create mode 100644 arch/mips/ni169445/169445-console.c
>  create mode 100644 arch/mips/ni169445/169445-init.c
>  create mode 100644 arch/mips/ni169445/169445-int.c
>  create mode 100644 arch/mips/ni169445/169445-setup.c
>  create mode 100644 arch/mips/ni169445/169445-time.c
>  create mode 100644 arch/mips/ni169445/Makefile
>  create mode 100644 arch/mips/ni169445/Platform
> 
> diff --git a/Documentation/devicetree/bindings/mips/ni.txt
> b/Documentation/devicetree/bindings/mips/ni.txt new file mode 100644
> index 0000000..722bf2d
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mips/ni.txt
> @@ -0,0 +1,7 @@
> +National Instruments MIPS platforms
> +
> +required root node properties:
> +	- compatible: must be "ni,169445"
> +
> +CPU Nodes
> +	- compatible: must be "mti,mips14KEc"

This doesn't describe anything else you rely on, like the
mips-hpt-frequency property which you panic without.

> diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
> index f5f1bdb..f2d7b5c 100644
> --- a/arch/mips/Kbuild.platforms
> +++ b/arch/mips/Kbuild.platforms
> @@ -20,6 +20,7 @@ platforms += loongson32
>  platforms += loongson64
>  platforms += mti-malta
>  platforms += netlogic
> +platforms += ni169445
>  platforms += paravirt
>  platforms += pic32
>  platforms += pistachio
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index b3c5bde..d24d11f 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -574,6 +574,32 @@ config NXP_STB225
>  	help
>  	 Support for NXP Semiconductors STB225 Development Board.
> 
> +config NI_169445
> +	bool "NI 169445 board"
> +	select ARCH_WANT_OPTIONAL_GPIOLIB
> +	select BOOT_ELF32
> +	select BOOT_RAW
> +	select BUILTIN_DTB
> +	select CEVT_R4K
> +	select CSRC_R4K
> +	select CPU_MIPSR2_IRQ_VI
> +	select CPU_MIPSR2_IRQ_EI
> +	select DMA_NONCOHERENT
> +	select IRQ_MIPS_CPU
> +	select LIBFDT
> +	select MIPS_MSC
> +	select SYS_HAS_CPU_MIPS32_R1
> +	select SYS_HAS_CPU_MIPS32_R2
> +	select SYS_HAS_EARLY_PRINTK
> +	select SYS_SUPPORTS_32BIT_KERNEL
> +	select SYS_SUPPORTS_LITTLE_ENDIAN
> +	select USE_OF
> +	select COMMON_CLK
> +	help
> +	  This enables support for the National Instruments 169445A
> +	  board.
> +
> +
>  config PMC_MSP
>  	bool "PMC-Sierra MSP chipsets"
>  	select CEVT_R4K
> diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
> index fc7a0a9..65a0ad8 100644
> --- a/arch/mips/boot/dts/Makefile
> +++ b/arch/mips/boot/dts/Makefile
> @@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
>  dts-dirs	+= ingenic
>  dts-dirs	+= lantiq
>  dts-dirs	+= mti
> +dts-dirs	+= ni
>  dts-dirs	+= netlogic
>  dts-dirs	+= pic32
>  dts-dirs	+= qca
> diff --git a/arch/mips/boot/dts/ni/169445.dts
> b/arch/mips/boot/dts/ni/169445.dts new file mode 100644
> index 0000000..a2b49f9
> --- /dev/null
> +++ b/arch/mips/boot/dts/ni/169445.dts
> @@ -0,0 +1,99 @@
> +/dts-v1/;
> +
> +/ {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +	compatible = "ni,169445";
> +
> +	cpus {
> +		mips-hpt-frequency = <25000000>;
> +
> +		cpu@0 {
> +			compatible = "mti,mips14KEc";
> +		};
> +	};
> +
> +	memory {
> +		device_type = "memory";
> +		reg = <0x0 0x08000000>;
> +	};
> +
> +	clocks {
> +		baseclk: baseclock {
> +			compatible = "fixed-clock";
> +			#clock-cells = <0>;
> +			clock-frequency = <50000000>;
> +		};
> +	};
> +
> +	cpu_intc: cpu_intc {
> +		#address-cells = <0>;
> +		compatible = "mti,cpu-interrupt-controller";
> +		interrupt-controller;
> +		#interrupt-cells = <1>;
> +	};
> +
> +	ahb@0 {
> +		compatible = "simple-bus";
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		ranges;
> +
> +		gpio1: nand-gpio-out@1f300010 {
> +			compatible = "ni,169445-nand-gpio";
> +			reg = <0x1f300010 0x4>;
> +			reg-names = "dat";
> +			gpio-controller;
> +			#gpio-cells = <2>;
> +			ngpios = <5>;
> +		};
> +
> +		gpio2: nand-gpio-in@1f300014 {
> +			compatible = "ni,169445-nand-gpio";
> +			reg = <0x1f300014 0x4>;
> +			reg-names = "dat";
> +			gpio-controller;
> +			#gpio-cells = <2>;
> +			ngpios = <1>;
> +		};
> +
> +		nand@1f300000 {
> +			compatible = "gpio-control-nand";
> +			nand-on-flash-bbt;
> +			nand-ecc-mode = "soft_bch";
> +			nand-ecc-step-size = <512>;
> +			nand-ecc-strength = <4>;
> +			reg = <0x1f300000 4>;
> +			gpios = <&gpio2 0 0>, /* rdy */
> +				<&gpio1 1 0>, /* nce */
> +				<&gpio1 2 0>, /* ale */
> +				<&gpio1 3 0>, /* cle */
> +				<&gpio1 4 0>; /* nwp */
> +		};
> +
> +		serial@1f380000 {
> +			compatible = "ns16550a";
> +			reg = <0x1f380000 0x1000>;
> +			interrupt-parent = <&cpu_intc>;
> +			interrupts = <6>;
> +			clocks = <&baseclk>;
> +			reg-shift = <0>;
> +		};
> +
> +		ethernet@1f340000 {
> +			compatible = "snps,dwc-qos-ethernet-4.10";
> +			interrupt-parent = <&cpu_intc>;
> +			interrupts = <5>;
> +			reg = <0x1f340000 0x2000>;
> +			clock-names = "apb_pclk", "phy_ref_clk";
> +			clocks = <&baseclk>, <&baseclk>;
> +
> +			phy-mode = "rgmii";
> +
> +			fixed-link {
> +				speed = <1000>;
> +				full-duplex;
> +			};
> +		};
> +	};
> +};
> diff --git a/arch/mips/boot/dts/ni/Makefile b/arch/mips/boot/dts/ni/Makefile
> new file mode 100644
> index 0000000..5291c18
> --- /dev/null
> +++ b/arch/mips/boot/dts/ni/Makefile
> @@ -0,0 +1,9 @@
> +dtb-$(CONFIG_NI_169445)		+= 169445.dtb
> +
> +obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
> +
> +# Force kbuild to make empty built-in.o if necessary
> +obj-				+= dummy.o
> +
> +always				:= $(dtb-y)
> +clean-files			:= *.dtb *.dtb.S
> diff --git a/arch/mips/configs/ni169445_defconfig
> b/arch/mips/configs/ni169445_defconfig new file mode 100644
> index 0000000..e5a34df
> --- /dev/null
> +++ b/arch/mips/configs/ni169445_defconfig
> @@ -0,0 +1,120 @@
> +CONFIG_NI_169445=y
> +CONFIG_CPU_MIPS32_R2=y
> +CONFIG_HZ_100=y
> +CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y
> +# CONFIG_SWAP is not set
> +CONFIG_SYSVIPC=y
> +CONFIG_HZ_PERIODIC=y
> +CONFIG_NO_HZ=y
> +CONFIG_HIGH_RES_TIMERS=y
> +CONFIG_IKCONFIG=y
> +CONFIG_IKCONFIG_PROC=y
> +CONFIG_LOG_BUF_SHIFT=15
> +CONFIG_BLK_DEV_INITRD=y
> +# CONFIG_RD_GZIP is not set
> +# CONFIG_RD_LZMA is not set
> +# CONFIG_RD_XZ is not set
> +# CONFIG_RD_LZO is not set
> +# CONFIG_RD_LZ4 is not set
> +# CONFIG_SHMEM is not set
> +CONFIG_EMBEDDED=y
> +CONFIG_SLAB=y
> +CONFIG_PROFILING=y
> +# CONFIG_LBDAF is not set
> +# CONFIG_BLK_DEV_BSG is not set
> +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
> +# CONFIG_SUSPEND is not set
> +CONFIG_NET=y
> +CONFIG_PACKET=y
> +CONFIG_UNIX=y
> +CONFIG_INET=y
> +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
> +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
> +# CONFIG_INET_XFRM_MODE_BEET is not set
> +# CONFIG_INET_DIAG is not set
> +# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
> +# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
> +CONFIG_NETFILTER=y
> +CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
> +CONFIG_IP_NF_IPTABLES=y
> +CONFIG_IP_NF_FILTER=y
> +CONFIG_IP6_NF_IPTABLES=y
> +CONFIG_IP6_NF_FILTER=y
> +# CONFIG_WIRELESS is not set
> +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
> +CONFIG_DEVTMPFS=y
> +CONFIG_DEVTMPFS_MOUNT=y
> +CONFIG_MTD=y
> +CONFIG_MTD_CMDLINE_PARTS=y
> +CONFIG_MTD_BLOCK_RO=y
> +CONFIG_MTD_NAND=y
> +CONFIG_MTD_NAND_ECC_BCH=y
> +CONFIG_MTD_NAND_GPIO=y
> +CONFIG_MTD_UBI=y
> +CONFIG_MTD_UBI_BLOCK=y
> +CONFIG_NETDEVICES=y
> +# CONFIG_NET_VENDOR_AMAZON is not set
> +# CONFIG_NET_VENDOR_ARC is not set
> +# CONFIG_NET_CADENCE is not set
> +# CONFIG_NET_VENDOR_BROADCOM is not set
> +# CONFIG_NET_VENDOR_EZCHIP is not set
> +# CONFIG_NET_VENDOR_INTEL is not set
> +# CONFIG_NET_VENDOR_MARVELL is not set
> +# CONFIG_NET_VENDOR_MICREL is not set
> +# CONFIG_NET_VENDOR_NATSEMI is not set
> +# CONFIG_NET_VENDOR_NETRONOME is not set
> +# CONFIG_NET_VENDOR_QUALCOMM is not set
> +# CONFIG_NET_VENDOR_RENESAS is not set
> +# CONFIG_NET_VENDOR_ROCKER is not set
> +# CONFIG_NET_VENDOR_SAMSUNG is not set
> +# CONFIG_NET_VENDOR_SEEQ is not set
> +# CONFIG_NET_VENDOR_SMSC is not set
> +# CONFIG_NET_VENDOR_STMICRO is not set
> +CONFIG_SYNOPSYS_DWC_ETH_QOS=y
> +# CONFIG_NET_VENDOR_VIA is not set
> +# CONFIG_NET_VENDOR_WIZNET is not set
> +# CONFIG_NET_VENDOR_XILINX is not set
> +# CONFIG_WLAN is not set
> +# CONFIG_INPUT_MOUSEDEV is not set
> +# CONFIG_INPUT_KEYBOARD is not set
> +# CONFIG_INPUT_MOUSE is not set
> +# CONFIG_SERIO is not set
> +# CONFIG_CONSOLE_TRANSLATIONS is not set
> +CONFIG_VT_HW_CONSOLE_BINDING=y
> +CONFIG_LEGACY_PTY_COUNT=32
> +CONFIG_SERIAL_8250=y
> +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
> +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_GPIOLIB=y
> +CONFIG_GPIO_SYSFS=y
> +CONFIG_GPIO_GENERIC_PLATFORM=y
> +# CONFIG_HWMON is not set
> +# CONFIG_VGA_CONSOLE is not set
> +# CONFIG_HID is not set
> +# CONFIG_USB_SUPPORT is not set
> +# CONFIG_MIPS_PLATFORM_DEVICES is not set
> +# CONFIG_IOMMU_SUPPORT is not set
> +CONFIG_UBIFS_FS=y
> +CONFIG_UBIFS_FS_ADVANCED_COMPR=y
> +# CONFIG_UBIFS_FS_ZLIB is not set
> +CONFIG_SQUASHFS=y
> +# CONFIG_SQUASHFS_ZLIB is not set
> +CONFIG_SQUASHFS_LZO=y
> +CONFIG_SQUASHFS_XZ=y
> +# CONFIG_NETWORK_FILESYSTEMS is not set
> +# CONFIG_FTRACE is not set
> +CONFIG_CRYPTO_CBC=y
> +CONFIG_CRYPTO_ECB=y
> +CONFIG_CRYPTO_CRC32C=y
> +CONFIG_CRYPTO_ARC4=y
> +# CONFIG_CRYPTO_HW is not set
> +# CONFIG_XZ_DEC_X86 is not set
> +# CONFIG_XZ_DEC_POWERPC is not set
> +# CONFIG_XZ_DEC_IA64 is not set
> +# CONFIG_XZ_DEC_ARM is not set
> +# CONFIG_XZ_DEC_ARMTHUMB is not set
> +# CONFIG_XZ_DEC_SPARC is not set
> diff --git a/arch/mips/ni169445/169445-console.c
> b/arch/mips/ni169445/169445-console.c new file mode 100644
> index 0000000..f07e48b
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-console.c
> @@ -0,0 +1,38 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/console.h>
> +#include <linux/serial_reg.h>
> +#include <linux/io.h>
> +
> +#define NI_UART0_REGS_BASE	((unsigned char __iomem *)0xbf380000)
> +
> +static inline unsigned char serial_in(int offset)
> +{
> +	return __raw_readb(NI_UART0_REGS_BASE + offset);
> +}
> +
> +static inline void serial_out(int offset, char value)
> +{
> +	__raw_writeb(value, NI_UART0_REGS_BASE + offset);
> +}
> +
> +int prom_putchar(char c)
> +{
> +	while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0)
> +		;
> +
> +	serial_out(UART_TX, c);
> +
> +	return 1;
> +}

Could you use the generic 16550 earlycon support? (see CONFIG_SERIAL_8250_CONSOLE)

> diff --git a/arch/mips/ni169445/169445-init.c
> b/arch/mips/ni169445/169445-init.c new file mode 100644
> index 0000000..5c7ff5e
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-init.c
> @@ -0,0 +1,39 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/initrd.h>
> +#include <linux/io.h>
> +
> +#include <asm/bootinfo.h>
> +#include <asm/cacheflush.h>
> +#include <asm/traps.h>
> +#include <asm/mips-boards/generic.h>
> +#include <asm/fw/fw.h>
> +
> +void __init prom_init(void)
> +{
> +	fw_init_cmdline();
> +
> +#ifdef CONFIG_BLK_DEV_INITRD
> +	/* Read the initrd address from the firmware environment */
> +	initrd_start = fw_getenvl("initrd_start");
> +	if (initrd_start) {
> +		initrd_start = KSEG0ADDR(initrd_start);
> +		initrd_end = initrd_start + fw_getenvl("initrd_size");
> +	}
> +#endif
> +}
> +
> +void __init prom_free_prom_memory(void)
> +{
> +}
> diff --git a/arch/mips/ni169445/169445-int.c
> b/arch/mips/ni169445/169445-int.c new file mode 100644
> index 0000000..83caf79
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-int.c
> @@ -0,0 +1,34 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/irq.h>
> +#include <linux/of_irq.h>
> +#include <linux/irqchip/mips-gic.h>
> +#include <linux/io.h>
> +
> +#include <asm/irq_cpu.h>
> +#include <asm/setup.h>
> +
> +static const struct of_device_id of_irq_ids[] __initconst = {
> +	{
> +		.compatible = "mti,cpu-interrupt-controller",
> +		.data = mips_cpu_irq_of_init
> +	},
> +	{},
> +};
> +
> +void __init arch_init_irq(void)
> +{
> +	of_irq_init(of_irq_ids);
> +}

The CPU interrupt controller driver already does an IRQCHIP_DECLARE to
provide its compatible string, so can you just use irqchip_init()?

> +
> diff --git a/arch/mips/ni169445/169445-setup.c
> b/arch/mips/ni169445/169445-setup.c new file mode 100644
> index 0000000..80a5c91
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-setup.c
> @@ -0,0 +1,58 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +#include <linux/init.h>
> +#include <linux/clk-provider.h>
> +#include <linux/libfdt.h>
> +#include <linux/of_platform.h>
> +#include <linux/of_fdt.h>
> +
> +#include <asm/prom.h>
> +#include <asm/fw/fw.h>
> +
> +#include <asm/mips-boards/generic.h>
> +
> +const char *get_system_type(void)
> +{
> +	return "NI 169445 FPGA";
> +}
> +
> +void __init plat_mem_setup(void)
> +{
> +	/*
> +	 * Load the builtin devicetree. This causes the chosen node to be
> +	 * parsed resulting in our memory appearing
> +	 */
> +	__dt_setup_arch(__dtb_start);
> +}
> +
> +void __init device_tree_init(void)
> +{
> +	if (!initial_boot_params)
> +		return;
> +
> +	unflatten_and_copy_device_tree();
> +}
> +
> +static int __init customize_machine(void)
> +{
> +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> +	return 0;
> +}
> +arch_initcall(customize_machine);
> +
> +static int __init plat_dev_init(void)
> +{
> +	of_clk_init(NULL);
> +	return 0;
> +}
> +device_initcall(plat_dev_init);
> diff --git a/arch/mips/ni169445/169445-time.c
> b/arch/mips/ni169445/169445-time.c new file mode 100644
> index 0000000..3d2499e
> --- /dev/null
> +++ b/arch/mips/ni169445/169445-time.c
> @@ -0,0 +1,35 @@
> +/*  Copyright 2016 National Instruments Corporation
> + *
> + *  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.
> + */
> +
> +#include <linux/init.h>
> +#include <linux/of.h>
> +
> +#include <asm/time.h>
> +
> +void __init plat_time_init(void)
> +{
> +	struct device_node *np;
> +	u32 freq;
> +
> +	np = of_find_node_by_name(NULL, "cpus");
> +	if (!np)
> +		panic("missing 'cpus' DT node");
> +	if (of_property_read_u32(np, "mips-hpt-frequency", &freq) < 0)
> +		panic("missing 'mips-hpt-frequency' property");

I think "clock-frequency" would be more standard, and the kernel would
then just halve it to find the frequency at which the cop0 count register
increments.

> +	of_node_put(np);
> +
> +	mips_hpt_frequency = freq;
> +
> +	/* IRQs will not work until the timer has been set at least once */
> +	write_c0_count(0);

Really? Do you have any details of this, it sounds weird. Do you mean
only the cop0 compare interrupt won't work until count is set? If so (and
that sounds strange in itself) perhaps r4k_clockevent_init() ought to do
this rather than some platform/board code.

> +}
> diff --git a/arch/mips/ni169445/Makefile b/arch/mips/ni169445/Makefile
> new file mode 100644
> index 0000000..f3a0c8c
> --- /dev/null
> +++ b/arch/mips/ni169445/Makefile
> @@ -0,0 +1,9 @@
> +#
> +#
> +obj-y				:= 169445-init.o \
> +				   169445-int.o 169445-setup.o \
> +				   169445-time.o
> +
> +obj-$(CONFIG_EARLY_PRINTK)	+= 169445-console.o
> +
> +CFLAGS_169445-setup.o = -I$(src)/../../../scripts/dtc/libfdt
> diff --git a/arch/mips/ni169445/Platform b/arch/mips/ni169445/Platform
> new file mode 100644
> index 0000000..9380312
> --- /dev/null
> +++ b/arch/mips/ni169445/Platform
> @@ -0,0 +1,6 @@
> +#
> +# National Instruments 169445 FPGA board
> +#
> +platform-$(CONFIG_NI_169445)	+= ni169445/
> +load-$(CONFIG_NI_169445)	+= 0xffffffff80002000
> +all-$(CONFIG_NI_169445)		:= $(COMPRESSION_FNAME).srec

Could all this platform/board code be scrapped in favour of adding your
system to the generic platform? There's some documentation over here
which I hope to get in-tree soon:

https://paulburton.eu/kernel-docs/mips/generic-platform.html

You can also see some further examples of systems converted to the
generic platform which I hope to get into mainline over the next few
cycles over here:

https://git.linux-mips.org/cgit/linux-mti.git/log/

But the core of the generic platform is already there & ought to be
usable for a system like this.

Thanks,
    Paul

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-13 18:40 ` Paul Burton
@ 2016-12-13 18:56   ` Nathan Sullivan
  0 siblings, 0 replies; 14+ messages in thread
From: Nathan Sullivan @ 2016-12-13 18:56 UTC (permalink / raw)
  To: Paul Burton
  Cc: linux-mips, ralf, mark.rutland, robh+dt, devicetree, linux-kernel

On Tue, Dec 13, 2016 at 06:40:31PM +0000, Paul Burton wrote:
> Hi Nathan,
> 
> On Friday, 2 December 2016 09:42:09 GMT Nathan Sullivan wrote:
> > Support the National Instruments 169445 board.
> > 
> > Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
> > ---
> > "gpio: mmio: add support for NI 169445 NAND GPIO" and
> > "devicetree: add vendor prefix for National Instruments" are required for
> > the NAND on this board to work.
> > 
> >  Documentation/devicetree/bindings/mips/ni.txt |   7 ++
> >  arch/mips/Kbuild.platforms                    |   1 +
> >  arch/mips/Kconfig                             |  26 ++++++
> >  arch/mips/boot/dts/Makefile                   |   1 +
> >  arch/mips/boot/dts/ni/169445.dts              |  99 +++++++++++++++++++++
> >  arch/mips/boot/dts/ni/Makefile                |   9 ++
> >  arch/mips/configs/ni169445_defconfig          | 120 ++++++++++++++++++++++++++
> >  arch/mips/ni169445/169445-console.c           |  38 ++++++++
> >  arch/mips/ni169445/169445-init.c              |  39 +++++++++
> >  arch/mips/ni169445/169445-int.c               |  34 ++++++++
> >  arch/mips/ni169445/169445-setup.c             |  58 +++++++++++++
> >  arch/mips/ni169445/169445-time.c              |  35 ++++++++
> >  arch/mips/ni169445/Makefile                   |   9 ++
> >  arch/mips/ni169445/Platform                   |   6 ++
> >  14 files changed, 482 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
> >  create mode 100644 arch/mips/boot/dts/ni/169445.dts
> >  create mode 100644 arch/mips/boot/dts/ni/Makefile
> >  create mode 100644 arch/mips/configs/ni169445_defconfig
> >  create mode 100644 arch/mips/ni169445/169445-console.c
> >  create mode 100644 arch/mips/ni169445/169445-init.c
> >  create mode 100644 arch/mips/ni169445/169445-int.c
> >  create mode 100644 arch/mips/ni169445/169445-setup.c
> >  create mode 100644 arch/mips/ni169445/169445-time.c
> >  create mode 100644 arch/mips/ni169445/Makefile
> >  create mode 100644 arch/mips/ni169445/Platform
> > 
> > diff --git a/Documentation/devicetree/bindings/mips/ni.txt
> > b/Documentation/devicetree/bindings/mips/ni.txt new file mode 100644
> > index 0000000..722bf2d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mips/ni.txt
> > @@ -0,0 +1,7 @@
> > +National Instruments MIPS platforms
> > +
> > +required root node properties:
> > +	- compatible: must be "ni,169445"
> > +
> > +CPU Nodes
> > +	- compatible: must be "mti,mips14KEc"
> 
> This doesn't describe anything else you rely on, like the
> mips-hpt-frequency property which you panic without.
> 
> > diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
> > index f5f1bdb..f2d7b5c 100644
> > --- a/arch/mips/Kbuild.platforms
> > +++ b/arch/mips/Kbuild.platforms
> > @@ -20,6 +20,7 @@ platforms += loongson32
> >  platforms += loongson64
> >  platforms += mti-malta
> >  platforms += netlogic
> > +platforms += ni169445
> >  platforms += paravirt
> >  platforms += pic32
> >  platforms += pistachio
> > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > index b3c5bde..d24d11f 100644
> > --- a/arch/mips/Kconfig
> > +++ b/arch/mips/Kconfig
> > @@ -574,6 +574,32 @@ config NXP_STB225
> >  	help
> >  	 Support for NXP Semiconductors STB225 Development Board.
> > 
> > +config NI_169445
> > +	bool "NI 169445 board"
> > +	select ARCH_WANT_OPTIONAL_GPIOLIB
> > +	select BOOT_ELF32
> > +	select BOOT_RAW
> > +	select BUILTIN_DTB
> > +	select CEVT_R4K
> > +	select CSRC_R4K
> > +	select CPU_MIPSR2_IRQ_VI
> > +	select CPU_MIPSR2_IRQ_EI
> > +	select DMA_NONCOHERENT
> > +	select IRQ_MIPS_CPU
> > +	select LIBFDT
> > +	select MIPS_MSC
> > +	select SYS_HAS_CPU_MIPS32_R1
> > +	select SYS_HAS_CPU_MIPS32_R2
> > +	select SYS_HAS_EARLY_PRINTK
> > +	select SYS_SUPPORTS_32BIT_KERNEL
> > +	select SYS_SUPPORTS_LITTLE_ENDIAN
> > +	select USE_OF
> > +	select COMMON_CLK
> > +	help
> > +	  This enables support for the National Instruments 169445A
> > +	  board.
> > +
> > +
> >  config PMC_MSP
> >  	bool "PMC-Sierra MSP chipsets"
> >  	select CEVT_R4K
> > diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
> > index fc7a0a9..65a0ad8 100644
> > --- a/arch/mips/boot/dts/Makefile
> > +++ b/arch/mips/boot/dts/Makefile
> > @@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
> >  dts-dirs	+= ingenic
> >  dts-dirs	+= lantiq
> >  dts-dirs	+= mti
> > +dts-dirs	+= ni
> >  dts-dirs	+= netlogic
> >  dts-dirs	+= pic32
> >  dts-dirs	+= qca
> > diff --git a/arch/mips/boot/dts/ni/169445.dts
> > b/arch/mips/boot/dts/ni/169445.dts new file mode 100644
> > index 0000000..a2b49f9
> > --- /dev/null
> > +++ b/arch/mips/boot/dts/ni/169445.dts
> > @@ -0,0 +1,99 @@
> > +/dts-v1/;
> > +
> > +/ {
> > +	#address-cells = <1>;
> > +	#size-cells = <1>;
> > +	compatible = "ni,169445";
> > +
> > +	cpus {
> > +		mips-hpt-frequency = <25000000>;
> > +
> > +		cpu@0 {
> > +			compatible = "mti,mips14KEc";
> > +		};
> > +	};
> > +
> > +	memory {
> > +		device_type = "memory";
> > +		reg = <0x0 0x08000000>;
> > +	};
> > +
> > +	clocks {
> > +		baseclk: baseclock {
> > +			compatible = "fixed-clock";
> > +			#clock-cells = <0>;
> > +			clock-frequency = <50000000>;
> > +		};
> > +	};
> > +
> > +	cpu_intc: cpu_intc {
> > +		#address-cells = <0>;
> > +		compatible = "mti,cpu-interrupt-controller";
> > +		interrupt-controller;
> > +		#interrupt-cells = <1>;
> > +	};
> > +
> > +	ahb@0 {
> > +		compatible = "simple-bus";
> > +		#address-cells = <1>;
> > +		#size-cells = <1>;
> > +		ranges;
> > +
> > +		gpio1: nand-gpio-out@1f300010 {
> > +			compatible = "ni,169445-nand-gpio";
> > +			reg = <0x1f300010 0x4>;
> > +			reg-names = "dat";
> > +			gpio-controller;
> > +			#gpio-cells = <2>;
> > +			ngpios = <5>;
> > +		};
> > +
> > +		gpio2: nand-gpio-in@1f300014 {
> > +			compatible = "ni,169445-nand-gpio";
> > +			reg = <0x1f300014 0x4>;
> > +			reg-names = "dat";
> > +			gpio-controller;
> > +			#gpio-cells = <2>;
> > +			ngpios = <1>;
> > +		};
> > +
> > +		nand@1f300000 {
> > +			compatible = "gpio-control-nand";
> > +			nand-on-flash-bbt;
> > +			nand-ecc-mode = "soft_bch";
> > +			nand-ecc-step-size = <512>;
> > +			nand-ecc-strength = <4>;
> > +			reg = <0x1f300000 4>;
> > +			gpios = <&gpio2 0 0>, /* rdy */
> > +				<&gpio1 1 0>, /* nce */
> > +				<&gpio1 2 0>, /* ale */
> > +				<&gpio1 3 0>, /* cle */
> > +				<&gpio1 4 0>; /* nwp */
> > +		};
> > +
> > +		serial@1f380000 {
> > +			compatible = "ns16550a";
> > +			reg = <0x1f380000 0x1000>;
> > +			interrupt-parent = <&cpu_intc>;
> > +			interrupts = <6>;
> > +			clocks = <&baseclk>;
> > +			reg-shift = <0>;
> > +		};
> > +
> > +		ethernet@1f340000 {
> > +			compatible = "snps,dwc-qos-ethernet-4.10";
> > +			interrupt-parent = <&cpu_intc>;
> > +			interrupts = <5>;
> > +			reg = <0x1f340000 0x2000>;
> > +			clock-names = "apb_pclk", "phy_ref_clk";
> > +			clocks = <&baseclk>, <&baseclk>;
> > +
> > +			phy-mode = "rgmii";
> > +
> > +			fixed-link {
> > +				speed = <1000>;
> > +				full-duplex;
> > +			};
> > +		};
> > +	};
> > +};
> > diff --git a/arch/mips/boot/dts/ni/Makefile b/arch/mips/boot/dts/ni/Makefile
> > new file mode 100644
> > index 0000000..5291c18
> > --- /dev/null
> > +++ b/arch/mips/boot/dts/ni/Makefile
> > @@ -0,0 +1,9 @@
> > +dtb-$(CONFIG_NI_169445)		+= 169445.dtb
> > +
> > +obj-y				+= $(patsubst %.dtb, %.dtb.o, $(dtb-y))
> > +
> > +# Force kbuild to make empty built-in.o if necessary
> > +obj-				+= dummy.o
> > +
> > +always				:= $(dtb-y)
> > +clean-files			:= *.dtb *.dtb.S
> > diff --git a/arch/mips/configs/ni169445_defconfig
> > b/arch/mips/configs/ni169445_defconfig new file mode 100644
> > index 0000000..e5a34df
> > --- /dev/null
> > +++ b/arch/mips/configs/ni169445_defconfig
> > @@ -0,0 +1,120 @@
> > +CONFIG_NI_169445=y
> > +CONFIG_CPU_MIPS32_R2=y
> > +CONFIG_HZ_100=y
> > +CONFIG_MIPS_CMDLINE_FROM_BOOTLOADER=y
> > +# CONFIG_SWAP is not set
> > +CONFIG_SYSVIPC=y
> > +CONFIG_HZ_PERIODIC=y
> > +CONFIG_NO_HZ=y
> > +CONFIG_HIGH_RES_TIMERS=y
> > +CONFIG_IKCONFIG=y
> > +CONFIG_IKCONFIG_PROC=y
> > +CONFIG_LOG_BUF_SHIFT=15
> > +CONFIG_BLK_DEV_INITRD=y
> > +# CONFIG_RD_GZIP is not set
> > +# CONFIG_RD_LZMA is not set
> > +# CONFIG_RD_XZ is not set
> > +# CONFIG_RD_LZO is not set
> > +# CONFIG_RD_LZ4 is not set
> > +# CONFIG_SHMEM is not set
> > +CONFIG_EMBEDDED=y
> > +CONFIG_SLAB=y
> > +CONFIG_PROFILING=y
> > +# CONFIG_LBDAF is not set
> > +# CONFIG_BLK_DEV_BSG is not set
> > +# CONFIG_CORE_DUMP_DEFAULT_ELF_HEADERS is not set
> > +# CONFIG_SUSPEND is not set
> > +CONFIG_NET=y
> > +CONFIG_PACKET=y
> > +CONFIG_UNIX=y
> > +CONFIG_INET=y
> > +# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
> > +# CONFIG_INET_XFRM_MODE_TUNNEL is not set
> > +# CONFIG_INET_XFRM_MODE_BEET is not set
> > +# CONFIG_INET_DIAG is not set
> > +# CONFIG_INET6_XFRM_MODE_TRANSPORT is not set
> > +# CONFIG_INET6_XFRM_MODE_TUNNEL is not set
> > +CONFIG_NETFILTER=y
> > +CONFIG_NETFILTER_XT_MATCH_MULTIPORT=y
> > +CONFIG_IP_NF_IPTABLES=y
> > +CONFIG_IP_NF_FILTER=y
> > +CONFIG_IP6_NF_IPTABLES=y
> > +CONFIG_IP6_NF_FILTER=y
> > +# CONFIG_WIRELESS is not set
> > +CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
> > +CONFIG_DEVTMPFS=y
> > +CONFIG_DEVTMPFS_MOUNT=y
> > +CONFIG_MTD=y
> > +CONFIG_MTD_CMDLINE_PARTS=y
> > +CONFIG_MTD_BLOCK_RO=y
> > +CONFIG_MTD_NAND=y
> > +CONFIG_MTD_NAND_ECC_BCH=y
> > +CONFIG_MTD_NAND_GPIO=y
> > +CONFIG_MTD_UBI=y
> > +CONFIG_MTD_UBI_BLOCK=y
> > +CONFIG_NETDEVICES=y
> > +# CONFIG_NET_VENDOR_AMAZON is not set
> > +# CONFIG_NET_VENDOR_ARC is not set
> > +# CONFIG_NET_CADENCE is not set
> > +# CONFIG_NET_VENDOR_BROADCOM is not set
> > +# CONFIG_NET_VENDOR_EZCHIP is not set
> > +# CONFIG_NET_VENDOR_INTEL is not set
> > +# CONFIG_NET_VENDOR_MARVELL is not set
> > +# CONFIG_NET_VENDOR_MICREL is not set
> > +# CONFIG_NET_VENDOR_NATSEMI is not set
> > +# CONFIG_NET_VENDOR_NETRONOME is not set
> > +# CONFIG_NET_VENDOR_QUALCOMM is not set
> > +# CONFIG_NET_VENDOR_RENESAS is not set
> > +# CONFIG_NET_VENDOR_ROCKER is not set
> > +# CONFIG_NET_VENDOR_SAMSUNG is not set
> > +# CONFIG_NET_VENDOR_SEEQ is not set
> > +# CONFIG_NET_VENDOR_SMSC is not set
> > +# CONFIG_NET_VENDOR_STMICRO is not set
> > +CONFIG_SYNOPSYS_DWC_ETH_QOS=y
> > +# CONFIG_NET_VENDOR_VIA is not set
> > +# CONFIG_NET_VENDOR_WIZNET is not set
> > +# CONFIG_NET_VENDOR_XILINX is not set
> > +# CONFIG_WLAN is not set
> > +# CONFIG_INPUT_MOUSEDEV is not set
> > +# CONFIG_INPUT_KEYBOARD is not set
> > +# CONFIG_INPUT_MOUSE is not set
> > +# CONFIG_SERIO is not set
> > +# CONFIG_CONSOLE_TRANSLATIONS is not set
> > +CONFIG_VT_HW_CONSOLE_BINDING=y
> > +CONFIG_LEGACY_PTY_COUNT=32
> > +CONFIG_SERIAL_8250=y
> > +# CONFIG_SERIAL_8250_DEPRECATED_OPTIONS is not set
> > +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_GPIOLIB=y
> > +CONFIG_GPIO_SYSFS=y
> > +CONFIG_GPIO_GENERIC_PLATFORM=y
> > +# CONFIG_HWMON is not set
> > +# CONFIG_VGA_CONSOLE is not set
> > +# CONFIG_HID is not set
> > +# CONFIG_USB_SUPPORT is not set
> > +# CONFIG_MIPS_PLATFORM_DEVICES is not set
> > +# CONFIG_IOMMU_SUPPORT is not set
> > +CONFIG_UBIFS_FS=y
> > +CONFIG_UBIFS_FS_ADVANCED_COMPR=y
> > +# CONFIG_UBIFS_FS_ZLIB is not set
> > +CONFIG_SQUASHFS=y
> > +# CONFIG_SQUASHFS_ZLIB is not set
> > +CONFIG_SQUASHFS_LZO=y
> > +CONFIG_SQUASHFS_XZ=y
> > +# CONFIG_NETWORK_FILESYSTEMS is not set
> > +# CONFIG_FTRACE is not set
> > +CONFIG_CRYPTO_CBC=y
> > +CONFIG_CRYPTO_ECB=y
> > +CONFIG_CRYPTO_CRC32C=y
> > +CONFIG_CRYPTO_ARC4=y
> > +# CONFIG_CRYPTO_HW is not set
> > +# CONFIG_XZ_DEC_X86 is not set
> > +# CONFIG_XZ_DEC_POWERPC is not set
> > +# CONFIG_XZ_DEC_IA64 is not set
> > +# CONFIG_XZ_DEC_ARM is not set
> > +# CONFIG_XZ_DEC_ARMTHUMB is not set
> > +# CONFIG_XZ_DEC_SPARC is not set
> > diff --git a/arch/mips/ni169445/169445-console.c
> > b/arch/mips/ni169445/169445-console.c new file mode 100644
> > index 0000000..f07e48b
> > --- /dev/null
> > +++ b/arch/mips/ni169445/169445-console.c
> > @@ -0,0 +1,38 @@
> > +/*  Copyright 2016 National Instruments Corporation
> > + *
> > + *  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.
> > + */
> > +#include <linux/init.h>
> > +#include <linux/console.h>
> > +#include <linux/serial_reg.h>
> > +#include <linux/io.h>
> > +
> > +#define NI_UART0_REGS_BASE	((unsigned char __iomem *)0xbf380000)
> > +
> > +static inline unsigned char serial_in(int offset)
> > +{
> > +	return __raw_readb(NI_UART0_REGS_BASE + offset);
> > +}
> > +
> > +static inline void serial_out(int offset, char value)
> > +{
> > +	__raw_writeb(value, NI_UART0_REGS_BASE + offset);
> > +}
> > +
> > +int prom_putchar(char c)
> > +{
> > +	while ((serial_in(UART_LSR) & UART_LSR_THRE) == 0)
> > +		;
> > +
> > +	serial_out(UART_TX, c);
> > +
> > +	return 1;
> > +}
> 
> Could you use the generic 16550 earlycon support? (see CONFIG_SERIAL_8250_CONSOLE)
> 
> > diff --git a/arch/mips/ni169445/169445-init.c
> > b/arch/mips/ni169445/169445-init.c new file mode 100644
> > index 0000000..5c7ff5e
> > --- /dev/null
> > +++ b/arch/mips/ni169445/169445-init.c
> > @@ -0,0 +1,39 @@
> > +/*  Copyright 2016 National Instruments Corporation
> > + *
> > + *  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.
> > + */
> > +#include <linux/init.h>
> > +#include <linux/initrd.h>
> > +#include <linux/io.h>
> > +
> > +#include <asm/bootinfo.h>
> > +#include <asm/cacheflush.h>
> > +#include <asm/traps.h>
> > +#include <asm/mips-boards/generic.h>
> > +#include <asm/fw/fw.h>
> > +
> > +void __init prom_init(void)
> > +{
> > +	fw_init_cmdline();
> > +
> > +#ifdef CONFIG_BLK_DEV_INITRD
> > +	/* Read the initrd address from the firmware environment */
> > +	initrd_start = fw_getenvl("initrd_start");
> > +	if (initrd_start) {
> > +		initrd_start = KSEG0ADDR(initrd_start);
> > +		initrd_end = initrd_start + fw_getenvl("initrd_size");
> > +	}
> > +#endif
> > +}
> > +
> > +void __init prom_free_prom_memory(void)
> > +{
> > +}
> > diff --git a/arch/mips/ni169445/169445-int.c
> > b/arch/mips/ni169445/169445-int.c new file mode 100644
> > index 0000000..83caf79
> > --- /dev/null
> > +++ b/arch/mips/ni169445/169445-int.c
> > @@ -0,0 +1,34 @@
> > +/*  Copyright 2016 National Instruments Corporation
> > + *
> > + *  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.
> > + */
> > +#include <linux/init.h>
> > +#include <linux/irq.h>
> > +#include <linux/of_irq.h>
> > +#include <linux/irqchip/mips-gic.h>
> > +#include <linux/io.h>
> > +
> > +#include <asm/irq_cpu.h>
> > +#include <asm/setup.h>
> > +
> > +static const struct of_device_id of_irq_ids[] __initconst = {
> > +	{
> > +		.compatible = "mti,cpu-interrupt-controller",
> > +		.data = mips_cpu_irq_of_init
> > +	},
> > +	{},
> > +};
> > +
> > +void __init arch_init_irq(void)
> > +{
> > +	of_irq_init(of_irq_ids);
> > +}
> 
> The CPU interrupt controller driver already does an IRQCHIP_DECLARE to
> provide its compatible string, so can you just use irqchip_init()?
> 
> > +
> > diff --git a/arch/mips/ni169445/169445-setup.c
> > b/arch/mips/ni169445/169445-setup.c new file mode 100644
> > index 0000000..80a5c91
> > --- /dev/null
> > +++ b/arch/mips/ni169445/169445-setup.c
> > @@ -0,0 +1,58 @@
> > +/*  Copyright 2016 National Instruments Corporation
> > + *
> > + *  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.
> > + */
> > +#include <linux/init.h>
> > +#include <linux/clk-provider.h>
> > +#include <linux/libfdt.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/of_fdt.h>
> > +
> > +#include <asm/prom.h>
> > +#include <asm/fw/fw.h>
> > +
> > +#include <asm/mips-boards/generic.h>
> > +
> > +const char *get_system_type(void)
> > +{
> > +	return "NI 169445 FPGA";
> > +}
> > +
> > +void __init plat_mem_setup(void)
> > +{
> > +	/*
> > +	 * Load the builtin devicetree. This causes the chosen node to be
> > +	 * parsed resulting in our memory appearing
> > +	 */
> > +	__dt_setup_arch(__dtb_start);
> > +}
> > +
> > +void __init device_tree_init(void)
> > +{
> > +	if (!initial_boot_params)
> > +		return;
> > +
> > +	unflatten_and_copy_device_tree();
> > +}
> > +
> > +static int __init customize_machine(void)
> > +{
> > +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> > +	return 0;
> > +}
> > +arch_initcall(customize_machine);
> > +
> > +static int __init plat_dev_init(void)
> > +{
> > +	of_clk_init(NULL);
> > +	return 0;
> > +}
> > +device_initcall(plat_dev_init);
> > diff --git a/arch/mips/ni169445/169445-time.c
> > b/arch/mips/ni169445/169445-time.c new file mode 100644
> > index 0000000..3d2499e
> > --- /dev/null
> > +++ b/arch/mips/ni169445/169445-time.c
> > @@ -0,0 +1,35 @@
> > +/*  Copyright 2016 National Instruments Corporation
> > + *
> > + *  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.
> > + */
> > +
> > +#include <linux/init.h>
> > +#include <linux/of.h>
> > +
> > +#include <asm/time.h>
> > +
> > +void __init plat_time_init(void)
> > +{
> > +	struct device_node *np;
> > +	u32 freq;
> > +
> > +	np = of_find_node_by_name(NULL, "cpus");
> > +	if (!np)
> > +		panic("missing 'cpus' DT node");
> > +	if (of_property_read_u32(np, "mips-hpt-frequency", &freq) < 0)
> > +		panic("missing 'mips-hpt-frequency' property");
> 
> I think "clock-frequency" would be more standard, and the kernel would
> then just halve it to find the frequency at which the cop0 count register
> increments.
> 
> > +	of_node_put(np);
> > +
> > +	mips_hpt_frequency = freq;
> > +
> > +	/* IRQs will not work until the timer has been set at least once */
> > +	write_c0_count(0);
> 
> Really? Do you have any details of this, it sounds weird. Do you mean
> only the cop0 compare interrupt won't work until count is set? If so (and
> that sounds strange in itself) perhaps r4k_clockevent_init() ought to do
> this rather than some platform/board code.
> 

Yes, the cop0 interrupt doesn't fire until you write count once.  U-boot does
this in its MIPS timer code, and our hardware team confirmed this is the case.
I added this line before we started booting with U-boot, so it is probably fine
without it now.

> > +}
> > diff --git a/arch/mips/ni169445/Makefile b/arch/mips/ni169445/Makefile
> > new file mode 100644
> > index 0000000..f3a0c8c
> > --- /dev/null
> > +++ b/arch/mips/ni169445/Makefile
> > @@ -0,0 +1,9 @@
> > +#
> > +#
> > +obj-y				:= 169445-init.o \
> > +				   169445-int.o 169445-setup.o \
> > +				   169445-time.o
> > +
> > +obj-$(CONFIG_EARLY_PRINTK)	+= 169445-console.o
> > +
> > +CFLAGS_169445-setup.o = -I$(src)/../../../scripts/dtc/libfdt
> > diff --git a/arch/mips/ni169445/Platform b/arch/mips/ni169445/Platform
> > new file mode 100644
> > index 0000000..9380312
> > --- /dev/null
> > +++ b/arch/mips/ni169445/Platform
> > @@ -0,0 +1,6 @@
> > +#
> > +# National Instruments 169445 FPGA board
> > +#
> > +platform-$(CONFIG_NI_169445)	+= ni169445/
> > +load-$(CONFIG_NI_169445)	+= 0xffffffff80002000
> > +all-$(CONFIG_NI_169445)		:= $(COMPRESSION_FNAME).srec
> 
> Could all this platform/board code be scrapped in favour of adding your
> system to the generic platform? There's some documentation over here
> which I hope to get in-tree soon:
> 
> https://paulburton.eu/kernel-docs/mips/generic-platform.html
> 
> You can also see some further examples of systems converted to the
> generic platform which I hope to get into mainline over the next few
> cycles over here:
> 
> https://git.linux-mips.org/cgit/linux-mti.git/log/
> 
> But the core of the generic platform is already there & ought to be
> usable for a system like this.
> 
> Thanks,
>     Paul

I think so, we aren't very different from the simpler MTI boards.  I was under
the mistaken impression that MIPS didn't have a generic platform like ARM, but
I'll give this a try along with the other changes you suggested now that I
know about it.

 Thanks,
     Nathan

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-09 21:18 ` Rob Herring
@ 2016-12-14 16:32   ` Nathan Sullivan
  2016-12-14 16:48     ` Rob Herring
  0 siblings, 1 reply; 14+ messages in thread
From: Nathan Sullivan @ 2016-12-14 16:32 UTC (permalink / raw)
  To: Rob Herring; +Cc: ralf, mark.rutland, linux-mips, devicetree, linux-kernel

On Fri, Dec 09, 2016 at 03:18:28PM -0600, Rob Herring wrote:
> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
> > Support the National Instruments 169445 board.
> > 
> > Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
> > ---
> > "gpio: mmio: add support for NI 169445 NAND GPIO" and 
> > "devicetree: add vendor prefix for National Instruments" are required for the
> > NAND on this board to work.
> 
> These should have been a series, but I already applied the first one.
> 
> > 
> >  Documentation/devicetree/bindings/mips/ni.txt |   7 ++
> >  arch/mips/Kbuild.platforms                    |   1 +
> >  arch/mips/Kconfig                             |  26 ++++++
> >  arch/mips/boot/dts/Makefile                   |   1 +
> >  arch/mips/boot/dts/ni/169445.dts              |  99 +++++++++++++++++++++
> >  arch/mips/boot/dts/ni/Makefile                |   9 ++
> >  arch/mips/configs/ni169445_defconfig          | 120 ++++++++++++++++++++++++++
> >  arch/mips/ni169445/169445-console.c           |  38 ++++++++
> >  arch/mips/ni169445/169445-init.c              |  39 +++++++++
> >  arch/mips/ni169445/169445-int.c               |  34 ++++++++
> >  arch/mips/ni169445/169445-setup.c             |  58 +++++++++++++
> >  arch/mips/ni169445/169445-time.c              |  35 ++++++++
> >  arch/mips/ni169445/Makefile                   |   9 ++
> >  arch/mips/ni169445/Platform                   |   6 ++
> >  14 files changed, 482 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
> >  create mode 100644 arch/mips/boot/dts/ni/169445.dts
> >  create mode 100644 arch/mips/boot/dts/ni/Makefile
> >  create mode 100644 arch/mips/configs/ni169445_defconfig
> >  create mode 100644 arch/mips/ni169445/169445-console.c
> >  create mode 100644 arch/mips/ni169445/169445-init.c
> >  create mode 100644 arch/mips/ni169445/169445-int.c
> >  create mode 100644 arch/mips/ni169445/169445-setup.c
> >  create mode 100644 arch/mips/ni169445/169445-time.c
> >  create mode 100644 arch/mips/ni169445/Makefile
> >  create mode 100644 arch/mips/ni169445/Platform
> > 
> > diff --git a/Documentation/devicetree/bindings/mips/ni.txt b/Documentation/devicetree/bindings/mips/ni.txt
> > new file mode 100644
> > index 0000000..722bf2d
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mips/ni.txt
> > @@ -0,0 +1,7 @@
> > +National Instruments MIPS platforms
> > +
> > +required root node properties:
> > +	- compatible: must be "ni,169445"
> > +
> > +CPU Nodes
> > +	- compatible: must be "mti,mips14KEc"
> > diff --git a/arch/mips/Kbuild.platforms b/arch/mips/Kbuild.platforms
> > index f5f1bdb..f2d7b5c 100644
> > --- a/arch/mips/Kbuild.platforms
> > +++ b/arch/mips/Kbuild.platforms
> > @@ -20,6 +20,7 @@ platforms += loongson32
> >  platforms += loongson64
> >  platforms += mti-malta
> >  platforms += netlogic
> > +platforms += ni169445
> >  platforms += paravirt
> >  platforms += pic32
> >  platforms += pistachio
> > diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> > index b3c5bde..d24d11f 100644
> > --- a/arch/mips/Kconfig
> > +++ b/arch/mips/Kconfig
> > @@ -574,6 +574,32 @@ config NXP_STB225
> >  	help
> >  	 Support for NXP Semiconductors STB225 Development Board.
> >  
> > +config NI_169445
> > +	bool "NI 169445 board"
> > +	select ARCH_WANT_OPTIONAL_GPIOLIB
> > +	select BOOT_ELF32
> > +	select BOOT_RAW
> > +	select BUILTIN_DTB
> > +	select CEVT_R4K
> > +	select CSRC_R4K
> > +	select CPU_MIPSR2_IRQ_VI
> > +	select CPU_MIPSR2_IRQ_EI
> > +	select DMA_NONCOHERENT
> > +	select IRQ_MIPS_CPU
> > +	select LIBFDT
> > +	select MIPS_MSC
> > +	select SYS_HAS_CPU_MIPS32_R1
> > +	select SYS_HAS_CPU_MIPS32_R2
> > +	select SYS_HAS_EARLY_PRINTK
> > +	select SYS_SUPPORTS_32BIT_KERNEL
> > +	select SYS_SUPPORTS_LITTLE_ENDIAN
> > +	select USE_OF
> > +	select COMMON_CLK
> > +	help
> > +	  This enables support for the National Instruments 169445A
> > +	  board.
> > +
> > +
> >  config PMC_MSP
> >  	bool "PMC-Sierra MSP chipsets"
> >  	select CEVT_R4K
> > diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
> > index fc7a0a9..65a0ad8 100644
> > --- a/arch/mips/boot/dts/Makefile
> > +++ b/arch/mips/boot/dts/Makefile
> > @@ -3,6 +3,7 @@ dts-dirs	+= cavium-octeon
> >  dts-dirs	+= ingenic
> >  dts-dirs	+= lantiq
> >  dts-dirs	+= mti
> > +dts-dirs	+= ni
> >  dts-dirs	+= netlogic
> >  dts-dirs	+= pic32
> >  dts-dirs	+= qca
> > diff --git a/arch/mips/boot/dts/ni/169445.dts b/arch/mips/boot/dts/ni/169445.dts
> > new file mode 100644
> > index 0000000..a2b49f9
> > --- /dev/null
> > +++ b/arch/mips/boot/dts/ni/169445.dts
> > @@ -0,0 +1,99 @@
> > +/dts-v1/;
> > +
> > +/ {
> > +	#address-cells = <1>;
> > +	#size-cells = <1>;
> > +	compatible = "ni,169445";
> > +
> > +	cpus {
> > +		mips-hpt-frequency = <25000000>;
> > +
> > +		cpu@0 {
> > +			compatible = "mti,mips14KEc";
> > +		};
> > +	};
> > +
> > +	memory {
> 
> memory@0
> 
> > +		device_type = "memory";
> > +		reg = <0x0 0x08000000>;
> > +	};
> > +
> > +	clocks {
> > +		baseclk: baseclock {
> > +			compatible = "fixed-clock";
> > +			#clock-cells = <0>;
> > +			clock-frequency = <50000000>;
> > +		};
> > +	};
> > +
> > +	cpu_intc: cpu_intc {
> > +		#address-cells = <0>;
> > +		compatible = "mti,cpu-interrupt-controller";
> > +		interrupt-controller;
> > +		#interrupt-cells = <1>;
> > +	};
> > +
> > +	ahb@0 {
> > +		compatible = "simple-bus";
> > +		#address-cells = <1>;
> > +		#size-cells = <1>;
> > +		ranges;
> 
> If everything is under 0x1f3xxxxx, then add in the ranges here (and the 
> unit address).
> 

I noticed that some systems call out their axi/ahb busses, some do not.  Would
you prefer that I remove the bus entirely?

> > +
> > +		gpio1: nand-gpio-out@1f300010 {
> 
> As in the binding example: gpio-controller@...
> 
> > +			compatible = "ni,169445-nand-gpio";
> > +			reg = <0x1f300010 0x4>;
> > +			reg-names = "dat";
> > +			gpio-controller;
> > +			#gpio-cells = <2>;
> > +			ngpios = <5>;
> > +		};
> > +
> > +		gpio2: nand-gpio-in@1f300014 {
> 
> ditto
> 
> > +			compatible = "ni,169445-nand-gpio";
> > +			reg = <0x1f300014 0x4>;
> > +			reg-names = "dat";
> > +			gpio-controller;
> > +			#gpio-cells = <2>;
> > +			ngpios = <1>;
> > +		};
> > +
> > +		nand@1f300000 {
> > +			compatible = "gpio-control-nand";
> > +			nand-on-flash-bbt;
> > +			nand-ecc-mode = "soft_bch";
> > +			nand-ecc-step-size = <512>;
> > +			nand-ecc-strength = <4>;
> > +			reg = <0x1f300000 4>;
> > +			gpios = <&gpio2 0 0>, /* rdy */
> > +				<&gpio1 1 0>, /* nce */
> > +				<&gpio1 2 0>, /* ale */
> > +				<&gpio1 3 0>, /* cle */
> > +				<&gpio1 4 0>; /* nwp */
> > +		};
> > +
> > +		serial@1f380000 {
> > +			compatible = "ns16550a";
> > +			reg = <0x1f380000 0x1000>;
> > +			interrupt-parent = <&cpu_intc>;
> > +			interrupts = <6>;
> > +			clocks = <&baseclk>;
> > +			reg-shift = <0>;
> > +		};
> > +
> > +		ethernet@1f340000 {
> > +			compatible = "snps,dwc-qos-ethernet-4.10";
> > +			interrupt-parent = <&cpu_intc>;
> > +			interrupts = <5>;
> > +			reg = <0x1f340000 0x2000>;
> > +			clock-names = "apb_pclk", "phy_ref_clk";
> > +			clocks = <&baseclk>, <&baseclk>;
> > +
> > +			phy-mode = "rgmii";
> > +
> > +			fixed-link {
> > +				speed = <1000>;
> > +				full-duplex;
> > +			};
> > +		};
> > +	};
> > +};
> 
> [...]
> 
> > diff --git a/arch/mips/ni169445/169445-setup.c b/arch/mips/ni169445/169445-setup.c
> > new file mode 100644
> > index 0000000..80a5c91
> > --- /dev/null
> > +++ b/arch/mips/ni169445/169445-setup.c
> > @@ -0,0 +1,58 @@
> > +/*  Copyright 2016 National Instruments Corporation
> > + *
> > + *  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.
> > + */
> > +#include <linux/init.h>
> > +#include <linux/clk-provider.h>
> > +#include <linux/libfdt.h>
> > +#include <linux/of_platform.h>
> > +#include <linux/of_fdt.h>
> > +
> > +#include <asm/prom.h>
> > +#include <asm/fw/fw.h>
> > +
> > +#include <asm/mips-boards/generic.h>
> > +
> > +const char *get_system_type(void)
> > +{
> > +	return "NI 169445 FPGA";
> 
> Perhaps this should come from model property. There's a patch in flight 
> to add a function to get machine name.
> 
> > +}
> > +
> > +void __init plat_mem_setup(void)
> > +{
> > +	/*
> > +	 * Load the builtin devicetree. This causes the chosen node to be
> > +	 * parsed resulting in our memory appearing
> > +	 */
> > +	__dt_setup_arch(__dtb_start);
> > +}
> > +
> > +void __init device_tree_init(void)
> > +{
> > +	if (!initial_boot_params)
> > +		return;
> > +
> > +	unflatten_and_copy_device_tree();
> > +}
> > +
> > +static int __init customize_machine(void)
> > +{
> > +	of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> 
> This should happen by default now.
> 
> > +	return 0;
> > +}
> > +arch_initcall(customize_machine);

Thank you for the feedback.
	Nathan

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

* Re: [PATCH] MIPS: NI 169445 board support
  2016-12-14 16:32   ` Nathan Sullivan
@ 2016-12-14 16:48     ` Rob Herring
  0 siblings, 0 replies; 14+ messages in thread
From: Rob Herring @ 2016-12-14 16:48 UTC (permalink / raw)
  To: Nathan Sullivan
  Cc: Ralf Baechle, Mark Rutland, Linux-MIPS, devicetree, linux-kernel

On Wed, Dec 14, 2016 at 10:32 AM, Nathan Sullivan
<nathan.sullivan@ni.com> wrote:
> On Fri, Dec 09, 2016 at 03:18:28PM -0600, Rob Herring wrote:
>> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
>> > Support the National Instruments 169445 board.
>> >
>> > Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
>> > ---
>> > "gpio: mmio: add support for NI 169445 NAND GPIO" and
>> > "devicetree: add vendor prefix for National Instruments" are required for the
>> > NAND on this board to work.

>> > +   ahb@0 {
>> > +           compatible = "simple-bus";
>> > +           #address-cells = <1>;
>> > +           #size-cells = <1>;
>> > +           ranges;
>>
>> If everything is under 0x1f3xxxxx, then add in the ranges here (and the
>> unit address).
>>
>
> I noticed that some systems call out their axi/ahb busses, some do not.  Would
> you prefer that I remove the bus entirely?

Definitely not. IMO, not having a bus node is an error.

Rob

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

* Re: [PATCH] MIPS: NI 169445 board support
       [not found] ` <20161220163434.GA15962@linux-mips.org>
@ 2017-01-04 16:38   ` Nathan Sullivan
  2017-01-05 18:28     ` Niklas Cassel
  0 siblings, 1 reply; 14+ messages in thread
From: Nathan Sullivan @ 2017-01-04 16:38 UTC (permalink / raw)
  To: Ralf Baechle, linux-mips; +Cc: davem, netdev, linux-kernel

On Tue, Dec 20, 2016 at 05:34:34PM +0100, Ralf Baechle wrote:
> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
> > Date:   Fri, 2 Dec 2016 09:42:09 -0600
> > From: Nathan Sullivan <nathan.sullivan@ni.com>
> > To: ralf@linux-mips.org, mark.rutland@arm.com, robh+dt@kernel.org
> > CC: linux-mips@linux-mips.org, devicetree@vger.kernel.org,
> >  linux-kernel@vger.kernel.org, Nathan Sullivan <nathan.sullivan@ni.com>
> > Subject: [PATCH] MIPS: NI 169445 board support
> > Content-Type: text/plain
> > 
> > Support the National Instruments 169445 board.
> 
> Nathan,
> 
> I assume you're going to repost the changes Rob asked for in
> https://patchwork.linux-mips.org/patch/14641/#26924 and resubmit?
> 
> Thanks,
> 
>   Ralf

Hmm, I found the issue with the generic MIPS config and dwc_eth_qos.  The NIC
driver attempts to cache align a descriptor ring using the ___cacheline_aligned
attribute on the descriptor struct, in combination with a "skip" feature in
hardware.  However, the skip feature only has a three bit field, and the generic
MIPS config selects MIPS_L1_CACHE_SHIFT_7.  So, the line size is 128, and with a
64-bit bus, that means the NIC descriptor skip field would need to be set to
14 to align the 16-byte descriptors...

I guess it makes sense for a generic MIPS kernel to align everything for 128 byte
cache lines, and for me to fix the dwc_eth_qos driver to handle cases where the
line size is too big for the hardware skip feature, right?

Thanks,

   Nathan

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

* Re: Re: [PATCH] MIPS: NI 169445 board support
  2017-01-04 16:38   ` Nathan Sullivan
@ 2017-01-05 18:28     ` Niklas Cassel
  2017-01-05 18:33       ` Joao Pinto
  0 siblings, 1 reply; 14+ messages in thread
From: Niklas Cassel @ 2017-01-05 18:28 UTC (permalink / raw)
  To: Nathan Sullivan, Ralf Baechle, linux-mips
  Cc: davem, netdev, linux-kernel, Lars Persson, Joao Pinto

On 01/04/2017 05:38 PM, Nathan Sullivan wrote:
> On Tue, Dec 20, 2016 at 05:34:34PM +0100, Ralf Baechle wrote:
>> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
>>> Date:   Fri, 2 Dec 2016 09:42:09 -0600
>>> From: Nathan Sullivan <nathan.sullivan@ni.com>
>>> To: ralf@linux-mips.org, mark.rutland@arm.com, robh+dt@kernel.org
>>> CC: linux-mips@linux-mips.org, devicetree@vger.kernel.org,
>>>  linux-kernel@vger.kernel.org, Nathan Sullivan <nathan.sullivan@ni.com>
>>> Subject: [PATCH] MIPS: NI 169445 board support
>>> Content-Type: text/plain
>>>
>>> Support the National Instruments 169445 board.
>> Nathan,
>>
>> I assume you're going to repost the changes Rob asked for in
>> https://patchwork.linux-mips.org/patch/14641/#26924 and resubmit?
>>
>> Thanks,
>>
>>   Ralf
> Hmm, I found the issue with the generic MIPS config and dwc_eth_qos.  The NIC
> driver attempts to cache align a descriptor ring using the ___cacheline_aligned
> attribute on the descriptor struct, in combination with a "skip" feature in
> hardware.  However, the skip feature only has a three bit field, and the generic
> MIPS config selects MIPS_L1_CACHE_SHIFT_7.  So, the line size is 128, and with a
> 64-bit bus, that means the NIC descriptor skip field would need to be set to
> 14 to align the 16-byte descriptors...
>
> I guess it makes sense for a generic MIPS kernel to align everything for 128 byte
> cache lines, and for me to fix the dwc_eth_qos driver to handle cases where the
> line size is too big for the hardware skip feature, right?

I don't know if you've been following the discussion regarding
dwc_eth_qos on netdev, but Joao Pinto from Synopsys is
planning on removing the driver (since the stmmac driver
now supports the same version of the IP, together with older
versions of the IP).

Since device tree bindings are treated as an ABI,
Joao has implemented a glue layer for stmmac that parses
the dwc_eth_qos binding, but uses stmmac under the hood.

You can use any of the bindings, but since the dwc_eth_qos
binding will be marked as deprecated, you might want to
consider moving to the stmmac binding.

>
> Thanks,
>
>    Nathan
>
>

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

* Re: [PATCH] MIPS: NI 169445 board support
  2017-01-05 18:28     ` Niklas Cassel
@ 2017-01-05 18:33       ` Joao Pinto
  2017-01-05 18:44         ` Nathan Sullivan
  0 siblings, 1 reply; 14+ messages in thread
From: Joao Pinto @ 2017-01-05 18:33 UTC (permalink / raw)
  To: Niklas Cassel, Nathan Sullivan, Ralf Baechle, linux-mips
  Cc: davem, netdev, linux-kernel, Lars Persson, Joao Pinto

Hi,

Às 6:28 PM de 1/5/2017, Niklas Cassel escreveu:
> On 01/04/2017 05:38 PM, Nathan Sullivan wrote:
>> On Tue, Dec 20, 2016 at 05:34:34PM +0100, Ralf Baechle wrote:
>>> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
>>>> Date:   Fri, 2 Dec 2016 09:42:09 -0600
>>>> From: Nathan Sullivan <nathan.sullivan@ni.com>
>>>> To: ralf@linux-mips.org, mark.rutland@arm.com, robh+dt@kernel.org
>>>> CC: linux-mips@linux-mips.org, devicetree@vger.kernel.org,
>>>>  linux-kernel@vger.kernel.org, Nathan Sullivan <nathan.sullivan@ni.com>
>>>> Subject: [PATCH] MIPS: NI 169445 board support
>>>> Content-Type: text/plain
>>>>
>>>> Support the National Instruments 169445 board.
>>> Nathan,
>>>
>>> I assume you're going to repost the changes Rob asked for in
>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__patchwork.linux-2Dmips.org_patch_14641_-2326924&d=DgICaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=5p7f9dIkvVVK4UFHimMpezq5NwIJfUpd08c-Zk4_c6c&s=_JwSwe4VFYtxV1tcYt6Z8r4hJX0xfoGhCixygUxlg5s&e=  and resubmit?
>>>
>>> Thanks,
>>>
>>>   Ralf
>> Hmm, I found the issue with the generic MIPS config and dwc_eth_qos.  The NIC
>> driver attempts to cache align a descriptor ring using the ___cacheline_aligned
>> attribute on the descriptor struct, in combination with a "skip" feature in
>> hardware.  However, the skip feature only has a three bit field, and the generic
>> MIPS config selects MIPS_L1_CACHE_SHIFT_7.  So, the line size is 128, and with a
>> 64-bit bus, that means the NIC descriptor skip field would need to be set to
>> 14 to align the 16-byte descriptors...
>>
>> I guess it makes sense for a generic MIPS kernel to align everything for 128 byte
>> cache lines, and for me to fix the dwc_eth_qos driver to handle cases where the
>> line size is too big for the hardware skip feature, right?
> 
> I don't know if you've been following the discussion regarding
> dwc_eth_qos on netdev, but Joao Pinto from Synopsys is
> planning on removing the driver (since the stmmac driver
> now supports the same version of the IP, together with older
> versions of the IP).
> 
> Since device tree bindings are treated as an ABI,
> Joao has implemented a glue layer for stmmac that parses
> the dwc_eth_qos binding, but uses stmmac under the hood.
> 
> You can use any of the bindings, but since the dwc_eth_qos
> binding will be marked as deprecated, you might want to
> consider moving to the stmmac binding.

A patch set to port dwc_eth_qos to stmmac is at this moment under review:

http://patchwork.ozlabs.org/patch/711428/
http://patchwork.ozlabs.org/patch/711438/
http://patchwork.ozlabs.org/patch/711439/

Niklas has tested it and it works well, so after the patches are upstreamed the
dwc_eth_qos will be removed as agreed with Lars.

Thanks.

> 
>>
>> Thanks,
>>
>>    Nathan
>>
>>
> 

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

* Re: [PATCH] MIPS: NI 169445 board support
  2017-01-05 18:33       ` Joao Pinto
@ 2017-01-05 18:44         ` Nathan Sullivan
  2017-01-05 18:45           ` Joao Pinto
  0 siblings, 1 reply; 14+ messages in thread
From: Nathan Sullivan @ 2017-01-05 18:44 UTC (permalink / raw)
  To: Joao Pinto
  Cc: Niklas Cassel, Ralf Baechle, linux-mips, davem, netdev,
	linux-kernel, Lars Persson

On Thu, Jan 05, 2017 at 06:33:53PM +0000, Joao Pinto wrote:
> Hi,
> 
> Às 6:28 PM de 1/5/2017, Niklas Cassel escreveu:
> > On 01/04/2017 05:38 PM, Nathan Sullivan wrote:
> >> On Tue, Dec 20, 2016 at 05:34:34PM +0100, Ralf Baechle wrote:
> >>> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
> >>>> Date:   Fri, 2 Dec 2016 09:42:09 -0600
> >>>> From: Nathan Sullivan <nathan.sullivan@ni.com>
> >>>> To: ralf@linux-mips.org, mark.rutland@arm.com, robh+dt@kernel.org
> >>>> CC: linux-mips@linux-mips.org, devicetree@vger.kernel.org,
> >>>>  linux-kernel@vger.kernel.org, Nathan Sullivan <nathan.sullivan@ni.com>
> >>>> Subject: [PATCH] MIPS: NI 169445 board support
> >>>> Content-Type: text/plain
> >>>>
> >>>> Support the National Instruments 169445 board.
> >>> Nathan,
> >>>
> >>> I assume you're going to repost the changes Rob asked for in
> >>> https://urldefense.proofpoint.com/v2/url?u=https-3A__patchwork.linux-2Dmips.org_patch_14641_-2326924&d=DgICaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=5p7f9dIkvVVK4UFHimMpezq5NwIJfUpd08c-Zk4_c6c&s=_JwSwe4VFYtxV1tcYt6Z8r4hJX0xfoGhCixygUxlg5s&e=  and resubmit?
> >>>
> >>> Thanks,
> >>>
> >>>   Ralf
> >> Hmm, I found the issue with the generic MIPS config and dwc_eth_qos.  The NIC
> >> driver attempts to cache align a descriptor ring using the ___cacheline_aligned
> >> attribute on the descriptor struct, in combination with a "skip" feature in
> >> hardware.  However, the skip feature only has a three bit field, and the generic
> >> MIPS config selects MIPS_L1_CACHE_SHIFT_7.  So, the line size is 128, and with a
> >> 64-bit bus, that means the NIC descriptor skip field would need to be set to
> >> 14 to align the 16-byte descriptors...
> >>
> >> I guess it makes sense for a generic MIPS kernel to align everything for 128 byte
> >> cache lines, and for me to fix the dwc_eth_qos driver to handle cases where the
> >> line size is too big for the hardware skip feature, right?
> > 
> > I don't know if you've been following the discussion regarding
> > dwc_eth_qos on netdev, but Joao Pinto from Synopsys is
> > planning on removing the driver (since the stmmac driver
> > now supports the same version of the IP, together with older
> > versions of the IP).
> > 
> > Since device tree bindings are treated as an ABI,
> > Joao has implemented a glue layer for stmmac that parses
> > the dwc_eth_qos binding, but uses stmmac under the hood.
> > 
> > You can use any of the bindings, but since the dwc_eth_qos
> > binding will be marked as deprecated, you might want to
> > consider moving to the stmmac binding.
> 
> A patch set to port dwc_eth_qos to stmmac is at this moment under review:
> 
> http://patchwork.ozlabs.org/patch/711428/
> http://patchwork.ozlabs.org/patch/711438/
> http://patchwork.ozlabs.org/patch/711439/
> 
> Niklas has tested it and it works well, so after the patches are upstreamed the
> dwc_eth_qos will be removed as agreed with Lars.
> 
> Thanks.
>

Thanks for the heads up, I'll wait, adjust my bindings and retest then.

   Nathan

> > 
> >>
> >> Thanks,
> >>
> >>    Nathan
> >>
> >>
> > 
> 

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

* Re: [PATCH] MIPS: NI 169445 board support
  2017-01-05 18:44         ` Nathan Sullivan
@ 2017-01-05 18:45           ` Joao Pinto
  0 siblings, 0 replies; 14+ messages in thread
From: Joao Pinto @ 2017-01-05 18:45 UTC (permalink / raw)
  To: Nathan Sullivan, Joao Pinto
  Cc: Niklas Cassel, Ralf Baechle, linux-mips, davem, netdev,
	linux-kernel, Lars Persson

Às 6:44 PM de 1/5/2017, Nathan Sullivan escreveu:
> On Thu, Jan 05, 2017 at 06:33:53PM +0000, Joao Pinto wrote:
>> Hi,
>>
>> Às 6:28 PM de 1/5/2017, Niklas Cassel escreveu:
>>> On 01/04/2017 05:38 PM, Nathan Sullivan wrote:
>>>> On Tue, Dec 20, 2016 at 05:34:34PM +0100, Ralf Baechle wrote:
>>>>> On Fri, Dec 02, 2016 at 09:42:09AM -0600, Nathan Sullivan wrote:
>>>>>> Date:   Fri, 2 Dec 2016 09:42:09 -0600
>>>>>> From: Nathan Sullivan <nathan.sullivan@ni.com>
>>>>>> To: ralf@linux-mips.org, mark.rutland@arm.com, robh+dt@kernel.org
>>>>>> CC: linux-mips@linux-mips.org, devicetree@vger.kernel.org,
>>>>>>  linux-kernel@vger.kernel.org, Nathan Sullivan <nathan.sullivan@ni.com>
>>>>>> Subject: [PATCH] MIPS: NI 169445 board support
>>>>>> Content-Type: text/plain
>>>>>>
>>>>>> Support the National Instruments 169445 board.
>>>>> Nathan,
>>>>>
>>>>> I assume you're going to repost the changes Rob asked for in
>>>>> https://urldefense.proofpoint.com/v2/url?u=https-3A__patchwork.linux-2Dmips.org_patch_14641_-2326924&d=DgICaQ&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=5p7f9dIkvVVK4UFHimMpezq5NwIJfUpd08c-Zk4_c6c&s=_JwSwe4VFYtxV1tcYt6Z8r4hJX0xfoGhCixygUxlg5s&e=  and resubmit?
>>>>>
>>>>> Thanks,
>>>>>
>>>>>   Ralf
>>>> Hmm, I found the issue with the generic MIPS config and dwc_eth_qos.  The NIC
>>>> driver attempts to cache align a descriptor ring using the ___cacheline_aligned
>>>> attribute on the descriptor struct, in combination with a "skip" feature in
>>>> hardware.  However, the skip feature only has a three bit field, and the generic
>>>> MIPS config selects MIPS_L1_CACHE_SHIFT_7.  So, the line size is 128, and with a
>>>> 64-bit bus, that means the NIC descriptor skip field would need to be set to
>>>> 14 to align the 16-byte descriptors...
>>>>
>>>> I guess it makes sense for a generic MIPS kernel to align everything for 128 byte
>>>> cache lines, and for me to fix the dwc_eth_qos driver to handle cases where the
>>>> line size is too big for the hardware skip feature, right?
>>>
>>> I don't know if you've been following the discussion regarding
>>> dwc_eth_qos on netdev, but Joao Pinto from Synopsys is
>>> planning on removing the driver (since the stmmac driver
>>> now supports the same version of the IP, together with older
>>> versions of the IP).
>>>
>>> Since device tree bindings are treated as an ABI,
>>> Joao has implemented a glue layer for stmmac that parses
>>> the dwc_eth_qos binding, but uses stmmac under the hood.
>>>
>>> You can use any of the bindings, but since the dwc_eth_qos
>>> binding will be marked as deprecated, you might want to
>>> consider moving to the stmmac binding.
>>
>> A patch set to port dwc_eth_qos to stmmac is at this moment under review:
>>
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__patchwork.ozlabs.org_patch_711428_&d=DgIDAw&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=E0wkLvWGNBx49Zdq7Jw5toxfcwI9r7MBBbcTea28AL0&s=P71GK8K8tyGjenB4tDVyKfCuZF9cZiFBBpdeX8PQtEM&e= 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__patchwork.ozlabs.org_patch_711438_&d=DgIDAw&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=E0wkLvWGNBx49Zdq7Jw5toxfcwI9r7MBBbcTea28AL0&s=fj787JEefx7cddQAe7g604tMtvDlVzYj3kQKy80Gym0&e= 
>> https://urldefense.proofpoint.com/v2/url?u=http-3A__patchwork.ozlabs.org_patch_711439_&d=DgIDAw&c=DPL6_X_6JkXFx7AXWqB0tg&r=s2fO0hii0OGNOv9qQy_HRXy-xAJUD1NNoEcc3io_kx0&m=E0wkLvWGNBx49Zdq7Jw5toxfcwI9r7MBBbcTea28AL0&s=Cyy9ySM6LNgkQ07OsIYE8KnD1h1DruhCKLxH6W3_1VY&e= 
>>
>> Niklas has tested it and it works well, so after the patches are upstreamed the
>> dwc_eth_qos will be removed as agreed with Lars.
>>
>> Thanks.
>>
> 
> Thanks for the heads up, I'll wait, adjust my bindings and retest then.

Great! Thanks!

> 
>    Nathan
> 
>>>
>>>>
>>>> Thanks,
>>>>
>>>>    Nathan
>>>>
>>>>
>>>
>>

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

* [PATCH] MIPS: NI 169445 board support
  2017-07-14 17:16 RESEND PATCH v5 Nathan Sullivan
@ 2017-07-14 17:16 ` Nathan Sullivan
  0 siblings, 0 replies; 14+ messages in thread
From: Nathan Sullivan @ 2017-07-14 17:16 UTC (permalink / raw)
  To: ralf, robh+dt; +Cc: devicetree, linux-mips, linux-kernel, Nathan Sullivan

Support the National Instruments 169445 board.

Signed-off-by: Nathan Sullivan <nathan.sullivan@ni.com>
---
 Documentation/devicetree/bindings/mips/ni.txt   |   7 ++
 MAINTAINERS                                     |   8 ++
 arch/mips/boot/dts/Makefile                     |   1 +
 arch/mips/boot/dts/ni/169445.dts                | 100 ++++++++++++++++++++++++
 arch/mips/boot/dts/ni/Makefile                  |   7 ++
 arch/mips/configs/generic/board-ni169445.config |  27 +++++++
 arch/mips/generic/Kconfig                       |   6 ++
 arch/mips/generic/vmlinux.its.S                 |  25 ++++++
 8 files changed, 181 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mips/ni.txt
 create mode 100644 arch/mips/boot/dts/ni/169445.dts
 create mode 100644 arch/mips/boot/dts/ni/Makefile
 create mode 100644 arch/mips/configs/generic/board-ni169445.config

diff --git a/Documentation/devicetree/bindings/mips/ni.txt b/Documentation/devicetree/bindings/mips/ni.txt
new file mode 100644
index 0000000..722bf2d
--- /dev/null
+++ b/Documentation/devicetree/bindings/mips/ni.txt
@@ -0,0 +1,7 @@
+National Instruments MIPS platforms
+
+required root node properties:
+	- compatible: must be "ni,169445"
+
+CPU Nodes
+	- compatible: must be "mti,mips14KEc"
diff --git a/MAINTAINERS b/MAINTAINERS
index 7d9bd4a..73fa2e0 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9294,6 +9294,14 @@ F:	include/linux/sunrpc/
 F:	include/uapi/linux/nfs*
 F:	include/uapi/linux/sunrpc/
 
+NI169445 MIPS ARCHITECTURE
+M:	Nathan Sullivan <nathan.sullivan@ni.com>
+L:	linux-mips@linux-mips.org
+S:	Maintained
+F:	arch/mips/boot/dts/ni/
+F:	arch/mips/configs/generic/board-ni169445.config
+F:	Documentation/devicetree/bindings/mips/ni.txt
+
 NILFS2 FILESYSTEM
 M:	Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
 L:	linux-nilfs@vger.kernel.org
diff --git a/arch/mips/boot/dts/Makefile b/arch/mips/boot/dts/Makefile
index b9db492..27b0f37 100644
--- a/arch/mips/boot/dts/Makefile
+++ b/arch/mips/boot/dts/Makefile
@@ -4,6 +4,7 @@ dts-dirs	+= img
 dts-dirs	+= ingenic
 dts-dirs	+= lantiq
 dts-dirs	+= mti
+dts-dirs	+= ni
 dts-dirs	+= netlogic
 dts-dirs	+= pic32
 dts-dirs	+= qca
diff --git a/arch/mips/boot/dts/ni/169445.dts b/arch/mips/boot/dts/ni/169445.dts
new file mode 100644
index 0000000..6a20036
--- /dev/null
+++ b/arch/mips/boot/dts/ni/169445.dts
@@ -0,0 +1,100 @@
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "ni,169445";
+
+	cpus {
+		#address-cells = <1>;
+		#size-cells = <0>;
+		cpu@0 {
+			device_type = "cpu";
+			compatible = "mti,mips14KEc";
+			clocks = <&baseclk>;
+			reg = <0>;
+		};
+	};
+
+	memory@0 {
+		device_type = "memory";
+		reg = <0x0 0x10000000>;
+	};
+
+	baseclk: baseclock {
+		compatible = "fixed-clock";
+		#clock-cells = <0>;
+		clock-frequency = <50000000>;
+	};
+
+	cpu_intc: interrupt-controller {
+		#address-cells = <0>;
+		compatible = "mti,cpu-interrupt-controller";
+		interrupt-controller;
+		#interrupt-cells = <1>;
+	};
+
+	ahb@1f300000 {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+		ranges = <0x0 0x1f300000 0x80FFF>;
+
+		gpio1: gpio@1f300010 {
+			compatible = "ni,169445-nand-gpio";
+			reg = <0x10 0x4>;
+			reg-names = "dat";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
+
+		gpio2: gpio@1f300014 {
+			compatible = "ni,169445-nand-gpio";
+			reg = <0x14 0x4>;
+			reg-names = "dat";
+			gpio-controller;
+			#gpio-cells = <2>;
+			no-output;
+		};
+
+		nand@1f300000 {
+			compatible = "gpio-control-nand";
+			nand-on-flash-bbt;
+			nand-ecc-mode = "soft_bch";
+			nand-ecc-step-size = <512>;
+			nand-ecc-strength = <4>;
+			reg = <0x0 4>;
+			gpios = <&gpio2 0 0>, /* rdy */
+				<&gpio1 1 0>, /* nce */
+				<&gpio1 2 0>, /* ale */
+				<&gpio1 3 0>, /* cle */
+				<&gpio1 4 0>; /* nwp */
+		};
+
+		serial@1f380000 {
+			compatible = "ns16550a";
+			reg = <0x80000 0x1000>;
+			interrupt-parent = <&cpu_intc>;
+			interrupts = <6>;
+			clocks = <&baseclk>;
+			reg-shift = <0>;
+		};
+
+		ethernet@1f340000 {
+			compatible = "snps,dwmac-4.10a";
+			interrupt-parent = <&cpu_intc>;
+			interrupts = <5>;
+			interrupt-names = "macirq";
+			reg = <0x40000 0x2000>;
+			clock-names = "stmmaceth", "pclk";
+			clocks = <&baseclk>, <&baseclk>;
+
+			phy-mode = "rgmii";
+
+			fixed-link {
+				speed = <1000>;
+				full-duplex;
+			};
+		};
+	};
+};
diff --git a/arch/mips/boot/dts/ni/Makefile b/arch/mips/boot/dts/ni/Makefile
new file mode 100644
index 0000000..66cfdff
--- /dev/null
+++ b/arch/mips/boot/dts/ni/Makefile
@@ -0,0 +1,7 @@
+dtb-$(CONFIG_FIT_IMAGE_FDT_NI169445)	+= 169445.dtb
+
+# Force kbuild to make empty built-in.o if necessary
+obj-					+= dummy.o
+
+always					:= $(dtb-y)
+clean-files				:= *.dtb *.dtb.S
diff --git a/arch/mips/configs/generic/board-ni169445.config b/arch/mips/configs/generic/board-ni169445.config
new file mode 100644
index 0000000..0bae1f8
--- /dev/null
+++ b/arch/mips/configs/generic/board-ni169445.config
@@ -0,0 +1,27 @@
+CONFIG_FIT_IMAGE_FDT_NI169445=y
+
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_OF_PLATFORM=y
+
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_GPIO_GENERIC_PLATFORM=y
+
+CONFIG_MTD=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_CMDLINE_PARTS=y
+
+CONFIG_MTD_NAND_ECC=y
+CONFIG_MTD_NAND_ECC_BCH=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_GPIO=y
+CONFIG_MTD_NAND_IDS=y
+
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_BLOCK=y
+
+CONFIG_NETDEVICES=y
+CONFIG_STMMAC_ETH=y
+CONFIG_STMMAC_PLATFORM=y
+CONFIG_DWMAC_GENERIC=y
diff --git a/arch/mips/generic/Kconfig b/arch/mips/generic/Kconfig
index a606b3f..fbf0813 100644
--- a/arch/mips/generic/Kconfig
+++ b/arch/mips/generic/Kconfig
@@ -16,4 +16,10 @@ config LEGACY_BOARD_SEAD3
 	  Enable this to include support for booting on MIPS SEAD-3 FPGA-based
 	  development boards, which boot using a legacy boot protocol.
 
+config FIT_IMAGE_FDT_NI169445
+	bool "Include FDT for NI 169445"
+	help
+	  Enable this to include the FDT for the 169445 platform from
+	  National Instruments in the FIT kernel image.
+
 endif
diff --git a/arch/mips/generic/vmlinux.its.S b/arch/mips/generic/vmlinux.its.S
index f67fbf1..de851f7 100644
--- a/arch/mips/generic/vmlinux.its.S
+++ b/arch/mips/generic/vmlinux.its.S
@@ -29,3 +29,28 @@
 		};
 	};
 };
+
+#ifdef CONFIG_FIT_IMAGE_FDT_NI169445
+/ {
+	images {
+		fdt@ni169445 {
+			description = "NI 169445 device tree";
+			data = /incbin/("boot/dts/ni/169445.dtb");
+			type = "flat_dt";
+			arch = "mips";
+			compression = "none";
+			hash@0 {
+				algo = "sha1";
+			};
+		};
+	};
+
+	configurations {
+		conf@ni169445 {
+			description = "NI 169445 Linux Kernel";
+			kernel = "kernel@0";
+			fdt = "fdt@ni169445";
+		};
+	};
+};
+#endif
-- 
2.1.4

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

end of thread, other threads:[~2017-07-14 17:18 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-02 15:42 [PATCH] MIPS: NI 169445 board support Nathan Sullivan
2016-12-02 16:21 ` Zubair Lutfullah Kakakhel
2016-12-02 17:30   ` Nathan Sullivan
2016-12-09 21:18 ` Rob Herring
2016-12-14 16:32   ` Nathan Sullivan
2016-12-14 16:48     ` Rob Herring
2016-12-13 18:40 ` Paul Burton
2016-12-13 18:56   ` Nathan Sullivan
     [not found] ` <20161220163434.GA15962@linux-mips.org>
2017-01-04 16:38   ` Nathan Sullivan
2017-01-05 18:28     ` Niklas Cassel
2017-01-05 18:33       ` Joao Pinto
2017-01-05 18:44         ` Nathan Sullivan
2017-01-05 18:45           ` Joao Pinto
2017-07-14 17:16 RESEND PATCH v5 Nathan Sullivan
2017-07-14 17:16 ` [PATCH] MIPS: NI 169445 board support Nathan Sullivan

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).