mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120
@ 2016-10-04 19:13 Uwe Kleine-König
  2016-10-04 19:13 ` [PATCH 2/2] ARM: mvebu: document some general mvebu stuff and the rn2120 board Uwe Kleine-König
  2016-10-07  9:07 ` [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120 Sascha Hauer
  0 siblings, 2 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2016-10-04 19:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 arch/arm/boards/Makefile                    |  1 +
 arch/arm/boards/netgear-rn2120/Makefile     |  2 +
 arch/arm/boards/netgear-rn2120/board.c      | 88 +++++++++++++++++++++++++++++
 arch/arm/boards/netgear-rn2120/kwbimage.cfg |  7 +++
 arch/arm/boards/netgear-rn2120/lowlevel.c   | 41 ++++++++++++++
 arch/arm/dts/Makefile                       |  1 +
 arch/arm/dts/armada-xp-rn2120-bb.dts        | 11 ++++
 arch/arm/mach-mvebu/Kconfig                 |  4 ++
 images/Makefile.mvebu                       |  8 +++
 9 files changed, 163 insertions(+)
 create mode 100644 arch/arm/boards/netgear-rn2120/Makefile
 create mode 100644 arch/arm/boards/netgear-rn2120/board.c
 create mode 100644 arch/arm/boards/netgear-rn2120/kwbimage.cfg
 create mode 100644 arch/arm/boards/netgear-rn2120/lowlevel.c
 create mode 100644 arch/arm/dts/armada-xp-rn2120-bb.dts

diff --git a/arch/arm/boards/Makefile b/arch/arm/boards/Makefile
index 35b636f0cfbb..8f24fd13aa7b 100644
--- a/arch/arm/boards/Makefile
+++ b/arch/arm/boards/Makefile
@@ -72,6 +72,7 @@ obj-$(CONFIG_MACH_MX28EVK)			+= freescale-mx28-evk/
 obj-$(CONFIG_MACH_MX31MOBOARD)			+= mx31moboard/
 obj-$(CONFIG_MACH_NESO)				+= guf-neso/
 obj-$(CONFIG_MACH_NETGEAR_RN104)		+= netgear-rn104/
+obj-$(CONFIG_MACH_NETGEAR_RN2120)		+= netgear-rn2120/
 obj-$(CONFIG_MACH_NOMADIK_8815NHK)		+= nhk8815/
 obj-$(CONFIG_MACH_NVIDIA_BEAVER)		+= nvidia-beaver/
 obj-$(CONFIG_MACH_NVIDIA_JETSON)		+= nvidia-jetson-tk1/
diff --git a/arch/arm/boards/netgear-rn2120/Makefile b/arch/arm/boards/netgear-rn2120/Makefile
new file mode 100644
index 000000000000..01c7a259e9a5
--- /dev/null
+++ b/arch/arm/boards/netgear-rn2120/Makefile
@@ -0,0 +1,2 @@
+obj-y += board.o
+lwl-y += lowlevel.o
diff --git a/arch/arm/boards/netgear-rn2120/board.c b/arch/arm/boards/netgear-rn2120/board.c
new file mode 100644
index 000000000000..caf106af50d6
--- /dev/null
+++ b/arch/arm/boards/netgear-rn2120/board.c
@@ -0,0 +1,88 @@
+#include <clock.h>
+#include <init.h>
+#include <of.h>
+#include <gpio.h>
+#include <printk.h>
+#include <linux/kernel.h>
+#include <asm/armlinux.h>
+#include <generated/mach-types.h>
+
+static int rn2120_init(void)
+{
+	/*
+	 * This is the machine type that the kernel shipped by Netgear is using.
+	 * It's wrong but a given fact.
+	 */
+	armlinux_set_architecture(MACH_TYPE_ARMADA_XP_DB);
+
+	return 0;
+}
+device_initcall(rn2120_init);
+
+struct hdpower {
+	unsigned gpio_detect;
+	unsigned gpio_power;
+	unsigned gpio_led;
+};
+
+/*
+ * It would be nice to have this abstracted in the device tree, but currently
+ * this isn't the case.
+ */
+static struct hdpower rn2120_hdpower[] = {
+	{
+		/* sata 1 */
+		.gpio_detect = 32,
+		.gpio_power = 24,
+		.gpio_led = 31,
+	}, {
+		/* sata 2 */
+		.gpio_detect = 33,
+		.gpio_power = 25,
+		.gpio_led = 40,
+	}, {
+		/* sata 3 */
+		.gpio_detect = 34,
+		.gpio_power = 26,
+		.gpio_led = 44,
+	}, {
+		/* sata 4 */
+		.gpio_detect = 35,
+		.gpio_power = 28,
+		.gpio_led = 47,
+	},
+};
+
+static int rn2120_hddetect(void)
+{
+	int i;
+
+	if (!of_machine_is_compatible("netgear,readynas-2120"))
+		return 0;
+
+	for (i = 0; i < ARRAY_SIZE(rn2120_hdpower); ++i) {
+		int ret;
+		ret = gpio_direction_input(rn2120_hdpower[i].gpio_detect);
+		if (ret) {
+			pr_err("Failure to detect hd%d (%d)\n", i, ret);
+			continue;
+		}
+
+		ret = gpio_get_value(rn2120_hdpower[i].gpio_detect);
+		if (ret) {
+			/* no disk present */
+			gpio_direction_output(rn2120_hdpower[i].gpio_power, 0);
+		} else {
+			pr_info("Detected presence of disk #%d\n", i + 1);
+			/* make a pause after powering up 2 disks */
+			if (i && !(i & 1)) {
+				pr_info("Delay power up\n");
+				mdelay(7000);
+			}
+
+			gpio_direction_output(rn2120_hdpower[i].gpio_power, 1);
+		}
+	}
+	return 0;
+}
+device_initcall(rn2120_hddetect);
diff --git a/arch/arm/boards/netgear-rn2120/kwbimage.cfg b/arch/arm/boards/netgear-rn2120/kwbimage.cfg
new file mode 100644
index 000000000000..a6f0aa6d3dc3
--- /dev/null
+++ b/arch/arm/boards/netgear-rn2120/kwbimage.cfg
@@ -0,0 +1,7 @@
+VERSION 1
+BOOT_FROM nand
+DESTADDR 00000000
+EXECADDR 00000000
+NAND_BLKSZ 00020000
+NAND_BADBLK_LOCATION 01
+BINARY binary.0 0000005b 00000068
diff --git a/arch/arm/boards/netgear-rn2120/lowlevel.c b/arch/arm/boards/netgear-rn2120/lowlevel.c
new file mode 100644
index 000000000000..29c8b43c4467
--- /dev/null
+++ b/arch/arm/boards/netgear-rn2120/lowlevel.c
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2015 Pengutronix, Uwe Kleine-König <kernel@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, as published by the Free Software Foundation.
+ *
+ * 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 <common.h>
+#include <asm/barebox-arm.h>
+#include <asm/barebox-arm-head.h>
+#include <asm/io.h>
+#include <mach/lowlevel.h>
+
+extern char __dtb_armada_xp_rn2120_bb_start[];
+
+ENTRY_FUNCTION(start_netgear_rn2120, r0, r1, r2)
+{
+	void *fdt;
+
+	arm_cpu_lowlevel_init();
+
+	/*
+	 * This is necessary to allow the machine to draw more power. Probably
+	 * connected to a TI TPS65251. Without this resetting a phy makes the
+	 * SoC reset.
+	 * This is effectively gpio_direction_output(42, 1);
+	 */
+	writel((1 << 10) | readl((void *)0xd0018140), (void *)0xd0018140);
+	writel(~(1 << 10) & readl((void *)0xd0018144), (void *)0xd0018144);
+
+	fdt = __dtb_armada_xp_rn2120_bb_start -
+		get_runtime_offset();
+
+	mvebu_barebox_entry(fdt);
+}
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 09bf68ea2be7..0bc5c9542d3f 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -29,6 +29,7 @@ pbl-dtb-$(CONFIG_MACH_GW_VENTANA) += imx6q-gw54xx.dtb.o
 pbl-dtb-$(CONFIG_MACH_LENOVO_IX4_300D) += armada-xp-lenovo-ix4-300d-bb.dtb.o
 pbl-dtb-$(CONFIG_MACH_MARVELL_ARMADA_XP_GP) += armada-xp-gp-bb.dtb.o
 pbl-dtb-$(CONFIG_MACH_NETGEAR_RN104) += armada-370-rn104-bb.dtb.o
+pbl-dtb-$(CONFIG_MACH_NETGEAR_RN2120) += armada-xp-rn2120-bb.dtb.o
 pbl-dtb-$(CONFIG_MACH_NITROGEN6) += imx6q-nitrogen6x.dtb.o imx6dl-nitrogen6x.dtb.o imx6qp-nitrogen6_max.dtb.o
 pbl-dtb-$(CONFIG_MACH_NVIDIA_BEAVER) += tegra30-beaver.dtb.o
 pbl-dtb-$(CONFIG_MACH_NVIDIA_JETSON) += tegra124-jetson-tk1.dtb.o
diff --git a/arch/arm/dts/armada-xp-rn2120-bb.dts b/arch/arm/dts/armada-xp-rn2120-bb.dts
new file mode 100644
index 000000000000..969136b336fc
--- /dev/null
+++ b/arch/arm/dts/armada-xp-rn2120-bb.dts
@@ -0,0 +1,11 @@
+/*
+ * Barebox specific DT overlay for Netgear ReadyNAS 2120
+ */
+
+#include "arm/armada-xp-netgear-rn2120.dts"
+
+/ {
+	chosen {
+		stdout-path = "/soc/internal-regs/serial@12000";
+	};
+};
diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig
index 79fcc8d3ac36..148b4f6d4cb3 100644
--- a/arch/arm/mach-mvebu/Kconfig
+++ b/arch/arm/mach-mvebu/Kconfig
@@ -55,6 +55,10 @@ config MACH_MARVELL_ARMADA_XP_GP
 	bool "Marvell Armada XP GP"
 	select ARCH_ARMADA_XP
 
+config MACH_NETGEAR_RN2120
+	bool "Netgear ReadyNAS 2120"
+	select ARCH_ARMADA_XP
+
 config MACH_PLATHOME_OPENBLOCKS_AX3
 	bool "PlatHome OpenBlocks AX3"
 	select ARCH_ARMADA_XP
diff --git a/images/Makefile.mvebu b/images/Makefile.mvebu
index 195f48d47073..6286c93e3d8e 100644
--- a/images/Makefile.mvebu
+++ b/images/Makefile.mvebu
@@ -57,6 +57,14 @@ image-$(CONFIG_MACH_MARVELL_ARMADA_XP_GP) += barebox-marvell-armada-xp-gp.img
 image-$(CONFIG_MACH_MARVELL_ARMADA_XP_GP) += barebox-marvell-armada-xp-gp-uart.img
 image-$(CONFIG_MACH_MARVELL_ARMADA_XP_GP) += barebox-marvell-armada-xp-gp-2nd.img
 
+NETGEAR_RN2120_KWBOPTS = ${KWBOPTS} -i $(board)/netgear-rn2120/kwbimage.cfg
+OPTS_start_netgear_rn2120.pblx.kwbimg = $(NETGEAR_RN2120_KWBOPTS)
+FILE_barebox-netgear-rn2120.img	= start_netgear_rn2120.pblx.kwbimg
+FILE_barebox-netgear-rn2120-2nd.img = start_netgear_rn2120.pblx
+pblx-$(CONFIG_MACH_NETGEAR_RN2120) += start_netgear_rn2120
+image-$(CONFIG_MACH_NETGEAR_RN2120) += barebox-netgear-rn2120.img
+image-$(CONFIG_MACH_NETGEAR_RN2120) += barebox-netgear-rn2120-2nd.img
+
 PLATHOME_OPENBLOCKS_AX3_KWBOPTS = ${KWBOPTS} -i $(board)/plathome-openblocks-ax3/kwbimage.cfg
 OPTS_start_plathome_openblocks_ax3.pblx.kwbimg = $(PLATHOME_OPENBLOCKS_AX3_KWBOPTS)
 OPTS_start_plathome_openblocks_ax3.pblx.kwbuartimg = -m uart $(PLATHOME_OPENBLOCKS_AX3_KWBOPTS)
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/2] ARM: mvebu: document some general mvebu stuff and the rn2120 board
  2016-10-04 19:13 [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120 Uwe Kleine-König
@ 2016-10-04 19:13 ` Uwe Kleine-König
  2016-10-07  9:07 ` [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120 Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Uwe Kleine-König @ 2016-10-04 19:13 UTC (permalink / raw)
  To: barebox

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
---
 Documentation/boards/mvebu.rst                     | 50 ++++++++++++++++++++++
 .../boards/mvebu/Netgear-ReadyNAS-2120.rst         | 19 ++++++++
 2 files changed, 69 insertions(+)
 create mode 100644 Documentation/boards/mvebu.rst
 create mode 100644 Documentation/boards/mvebu/Netgear-ReadyNAS-2120.rst

diff --git a/Documentation/boards/mvebu.rst b/Documentation/boards/mvebu.rst
new file mode 100644
index 000000000000..b4f8e6043dac
--- /dev/null
+++ b/Documentation/boards/mvebu.rst
@@ -0,0 +1,50 @@
+Marvell Embedded Business Unit (mvebu)
+======================================
+
+Move of the Register Window
+---------------------------
+
+When an mvebu SoC comes up the internal registers are mapped at 0xd0000000 in
+the address space. To make it possible to have more than 3.25 GiB of continuous
+RAM in Linux this window is moved to 0xf1000000.
+Unfortunately the register to configure the location of the registers is located
+in this window, so there is no way to determine the location afterwards.
+
+RAM initialisation
+------------------
+
+Traditionally the RAM initialisation happens with a binary blob that have to be
+extracted from the vendor U-Boot::
+
+  scripts/kwbimage -x -i /dev/mtdblock0 -o .
+
+This creates among others a file "binary.0" that has to be put into the board
+directory. For license reasons this is usually not included in the barebox
+repository.
+
+Note that in the meantime U-Boot has open source code to do the RAM
+initialisation that could be taken.
+
+Booting second stage
+--------------------
+
+This is currently not possible because barebox assumes the registers are mapped
+at 0xd0000000 as is the case when the boot ROM gives control to the bootloader.
+
+Booting from UART
+-----------------
+
+The mvebu SoCs support booting from UART. For this there is a tool available in
+barebox called kwboot.
+
+mvebu boards
+------------
+
+Not all supported boards have a description here.
+
+.. toctree::
+  :glob:
+  :numbered:
+  :maxdepth: 1
+
+  mvebu/*
diff --git a/Documentation/boards/mvebu/Netgear-ReadyNAS-2120.rst b/Documentation/boards/mvebu/Netgear-ReadyNAS-2120.rst
new file mode 100644
index 000000000000..5bee03af9d38
--- /dev/null
+++ b/Documentation/boards/mvebu/Netgear-ReadyNAS-2120.rst
@@ -0,0 +1,19 @@
+Netgear ReadyNAS 2120
+=====================
+
+This is a rack mountable 4 bay NAS using an Armada XP dual-core processor.
+
+UART booting
+------------
+
+The first UART hides behind a sticker on 4 pins.
+
+The machine seems to do two resets at power on which makes UART booting hard. A
+trick to work around this is::
+
+  scripts/kwboot -d /dev/ttyUSB0; kwboot -b images/barebox-netgear-rn2120.img -t /dev/ttyUSB0
+
+This way the first window in which the CPU accepts the magic string is taken by
+the first invokation which blocks until the second reset happens. The second
+window is then hit with the image to boot. This is not 100% reliable but works
+most of the time.
-- 
2.9.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120
  2016-10-04 19:13 [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120 Uwe Kleine-König
  2016-10-04 19:13 ` [PATCH 2/2] ARM: mvebu: document some general mvebu stuff and the rn2120 board Uwe Kleine-König
@ 2016-10-07  9:07 ` Sascha Hauer
  1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2016-10-07  9:07 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: barebox

On Tue, Oct 04, 2016 at 09:13:05PM +0200, Uwe Kleine-König wrote:
> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
> ---
>  arch/arm/boards/Makefile                    |  1 +
>  arch/arm/boards/netgear-rn2120/Makefile     |  2 +
>  arch/arm/boards/netgear-rn2120/board.c      | 88 +++++++++++++++++++++++++++++
>  arch/arm/boards/netgear-rn2120/kwbimage.cfg |  7 +++
>  arch/arm/boards/netgear-rn2120/lowlevel.c   | 41 ++++++++++++++
>  arch/arm/dts/Makefile                       |  1 +
>  arch/arm/dts/armada-xp-rn2120-bb.dts        | 11 ++++
>  arch/arm/mach-mvebu/Kconfig                 |  4 ++
>  images/Makefile.mvebu                       |  8 +++
>  9 files changed, 163 insertions(+)
>  create mode 100644 arch/arm/boards/netgear-rn2120/Makefile
>  create mode 100644 arch/arm/boards/netgear-rn2120/board.c
>  create mode 100644 arch/arm/boards/netgear-rn2120/kwbimage.cfg
>  create mode 100644 arch/arm/boards/netgear-rn2120/lowlevel.c
>  create mode 100644 arch/arm/dts/armada-xp-rn2120-bb.dts

Applied, thanks

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2016-10-07  9:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-04 19:13 [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120 Uwe Kleine-König
2016-10-04 19:13 ` [PATCH 2/2] ARM: mvebu: document some general mvebu stuff and the rn2120 board Uwe Kleine-König
2016-10-07  9:07 ` [PATCH 1/2] ARM: mvebu: add support for Netgear RN2120 Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox