* [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2
@ 2014-12-23 21:13 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 1/5] dtc: Use quotes to include header files Chris Packham
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Chris Packham @ 2014-12-23 21:13 UTC (permalink / raw)
To: linux-arm-kernel
Here's my updated series for Marvell's reference board. I had hoped to
send this before 3.19-rc1 but I missed by a few days.
The new 1/5 patch was sent to the devicetree ML. So far not much
feedback. 2/5 depends on it so I've included it in the series. It would
be possible to remove the dependency by using the CFLAGS_boardv7.o
trick and if/when the dtc change is accepted it could be cleaned up
along with the others.
I haven't had any (recent) feedback on patches 3-5, understandable this
time of year. These are unchanged since v1[1].
The more information I get out of Marvell the more I'm starting to see
this thing as a parallel development to the Armada-XP as opposed to a
direct descendent. In particular because the integrated packet processor
shares some clock sources with the CPU block there is a new "DFX" (no
idea what that stands for) block that replaces a lot of the SaR and
clocking registers from the Armada.
I'll probably have to create new clock drivers instead of using
armada-xp-cpu-clock. No problem for the driver itself but the device
tree becomes problematic. I can't use armada-xp-.dtsi because it already
uses the "cpuclk:" label which I can't re-define with a new node. There
are a couple of options. One is to split the common peripherals out into
individual .dtsi files (see arch/powerpc/boot/dts/fsl) which may not be
a bad thing since some of these are common to kirkwood/orion also.
Another approach might be to move the labeling to the final .dts files
which would allow us to pick which potential clocksource/driver gets
the label "cpuclk:"
Thanks,
Chris
--
[1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/309765.html
Chris Packham (5):
dtc: Use quotes to include header files
ARM: mvebu: use dt_fixup to provide fallback for enable-method
clk: mvebu: armada-xp: Support for 98DX4251
ARM: mvebu: Initial support for rd-dxbc2
ARM: mvebu: Custom smp_ops for 98DX4251
.../devicetree/bindings/clock/mvebu-core-clock.txt | 4 +
arch/arm/boot/dts/rd-dxbc2.dts | 118 +++++++++++++++++++++
arch/arm/mach-mvebu/Makefile | 1 +
arch/arm/mach-mvebu/board-v7.c | 42 +++++++-
arch/arm/mach-mvebu/common.h | 2 +
arch/arm/mach-mvebu/mvebu-soc-id.h | 3 +
arch/arm/mach-mvebu/platsmp.c | 28 +++++
arch/arm/mach-mvebu/pmsu-98dx4251.c | 68 ++++++++++++
drivers/clk/mvebu/armada-xp.c | 35 ++++++
scripts/dtc/libfdt/libfdt.h | 4 +-
10 files changed, 302 insertions(+), 3 deletions(-)
create mode 100644 arch/arm/boot/dts/rd-dxbc2.dts
create mode 100644 arch/arm/mach-mvebu/pmsu-98dx4251.c
--
2.2.0.rc0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 1/5] dtc: Use quotes to include header files
2014-12-23 21:13 [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2 Chris Packham
@ 2014-12-23 21:13 ` Chris Packham
2014-12-28 2:08 ` Rob Herring
2014-12-23 21:13 ` [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method Chris Packham
` (3 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Chris Packham @ 2014-12-23 21:13 UTC (permalink / raw)
To: linux-arm-kernel
Currently in arch and driver code that needs early access to the
flattened device tree it is necessary to add specific CFLAGS so that
when scripts/dtc/libfdt/libfdt.h is included the C preprocessor is able
to locate the libfdt versions of libfdt_env.h and fdt.h without
generating an error.
We already provide an alternative linux-specific
version of libfdt_env.h and directly include scripts/dtc/libfdt/fdt.h
so the inclusion by scripts/dtc/libfdt/libfdt.h is a no-op thanks to the
inclusion guards.
By using quotes in scripts/dtc/libfdt/libfdt.h it picks up fdt.h and
libfdt_env.h from the source directory without needing to add CFLAGS for
the sources that happen to include linux/libfdt.h.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
For the files that include linux/libfdt.h we currently also have to
specify additional CFLAGS to satisfy the CPP.
$ git grep '<linux/libfdt.h>'
arch/mips/cavium-octeon/octeon-platform.c:#include <linux/libfdt.h>
arch/mips/cavium-octeon/setup.c:#include <linux/libfdt.h>
arch/mips/mti-sead3/sead3-setup.c:#include <linux/libfdt.h>
arch/powerpc/kernel/prom.c:#include <linux/libfdt.h>
drivers/firmware/efi/libstub/fdt.c:#include <linux/libfdt.h>
drivers/of/fdt.c:#include <linux/libfdt.h>
drivers/of/fdt_address.c:#include <linux/libfdt.h>
$ git grep -e '-I.*dtc/libfdt'
arch/mips/cavium-octeon/Makefile:CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt
arch/mips/cavium-octeon/Makefile:CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
arch/mips/mti-sead3/Makefile:CFLAGS_sead3-setup.o = -I$(src)/../../../scripts/dtc/libfdt
arch/powerpc/kernel/Makefile:CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt
drivers/firmware/efi/libstub/Makefile:CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
drivers/of/Makefile:CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
drivers/of/Makefile:CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
lib/Makefile: $(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
Simply by switching to using quotes we can avoid having this extra step.
scripts/dtc/libfdt/libfdt.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
index 73f4975..ea1ddcd 100644
--- a/scripts/dtc/libfdt/libfdt.h
+++ b/scripts/dtc/libfdt/libfdt.h
@@ -51,8 +51,8 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <libfdt_env.h>
-#include <fdt.h>
+#include "libfdt_env.h"
+#include "fdt.h"
#define FDT_FIRST_SUPPORTED_VERSION 0x10
#define FDT_LAST_SUPPORTED_VERSION 0x11
--
2.2.0.rc0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method
2014-12-23 21:13 [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 1/5] dtc: Use quotes to include header files Chris Packham
@ 2014-12-23 21:13 ` Chris Packham
2014-12-28 2:53 ` Rob Herring
2014-12-23 21:13 ` [RFC/PATCHv2 3/5] clk: mvebu: armada-xp: Support for 98DX4251 Chris Packham
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Chris Packham @ 2014-12-23 21:13 UTC (permalink / raw)
To: linux-arm-kernel
When the device tree doesn't define an enable-method insert a property
into the flattened device tree. arm_dt_init_cpu_maps() will then parse
this an set smp_ops appropriately. Now that we have this fallback it is
no longer necessary to set .smp in the DT_MACHINE definition.
Additionally Armada 370, which is a single core device, no longer has any
smp operations defined.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
As Arnd and Maxime suggested this replaces the unconditional setting of
smp_ops[1] with a fixup that inserts an appropriate property in the
device-tree if needed. It turned out not to be terribly tricky to
implement that checked each possible CPU node. One assumption I've made
is that the cpu nodes are numbered contiguously but that seems to be
reasonable.
[1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/309766.html
arch/arm/mach-mvebu/board-v7.c | 42 +++++++++++++++++++++++++++++++++++++++++-
1 file changed, 41 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
index d0d39f1..08eb6a9 100644
--- a/arch/arm/mach-mvebu/board-v7.c
+++ b/arch/arm/mach-mvebu/board-v7.c
@@ -17,6 +17,8 @@
#include <linux/clk-provider.h>
#include <linux/of_address.h>
#include <linux/of_platform.h>
+#include <linux/of_fdt.h>
+#include <linux/libfdt.h>
#include <linux/io.h>
#include <linux/clocksource.h>
#include <linux/dma-mapping.h>
@@ -198,6 +200,44 @@ static void __init mvebu_dt_init(void)
of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
}
+static void __init armada_370_xp_dt_fixup(void)
+{
+ int offset, node;
+ int i, len;
+ void *prop;
+ char buffer[20];
+ unsigned long root = of_get_flat_dt_root();
+
+ if (!IS_ENABLED(CONFIG_SMP) ||
+ !of_flat_dt_is_compatible(root, "marvell,armadaxp"))
+ return;
+
+ offset = fdt_path_offset(initial_boot_params, "/cpus");
+ if (offset < 0)
+ return;
+
+ prop = fdt_getprop(initial_boot_params, offset, "enable-method", &len);
+ if (prop)
+ return;
+
+ for (i = 0; i < NR_CPUS; i++) {
+ snprintf(buffer, sizeof(buffer), "cpu@%d", i);
+ node = fdt_subnode_offset(initial_boot_params, offset, buffer);
+ if (node < 0)
+ break;
+ prop = fdt_getprop(initial_boot_params, node,
+ "enable-method", &len);
+ if (prop)
+ return;
+ }
+
+ pr_info("No enable-method defined. "
+ "Falling back to \"marvell,armada-xp-smp\"\n");
+
+ fdt_setprop(initial_boot_params, offset, "enable-method",
+ "marvell,armada-xp-smp", sizeof("marvell,armada-xp-smp"));
+}
+
static const char * const armada_370_xp_dt_compat[] = {
"marvell,armada-370-xp",
NULL,
@@ -206,11 +246,11 @@ static const char * const armada_370_xp_dt_compat[] = {
DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)")
.l2c_aux_val = 0,
.l2c_aux_mask = ~0,
- .smp = smp_ops(armada_xp_smp_ops),
.init_machine = mvebu_dt_init,
.init_irq = mvebu_init_irq,
.restart = mvebu_restart,
.dt_compat = armada_370_xp_dt_compat,
+ .dt_fixup = armada_370_xp_dt_fixup,
MACHINE_END
static const char * const armada_375_dt_compat[] = {
--
2.2.0.rc0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 3/5] clk: mvebu: armada-xp: Support for 98DX4251
2014-12-23 21:13 [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 1/5] dtc: Use quotes to include header files Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method Chris Packham
@ 2014-12-23 21:13 ` Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 4/5] ARM: mvebu: Initial support for rd-dxbc2 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 5/5] ARM: mvebu: Custom smp_ops for 98DX4251 Chris Packham
4 siblings, 0 replies; 10+ messages in thread
From: Chris Packham @ 2014-12-23 21:13 UTC (permalink / raw)
To: linux-arm-kernel
The 98DX4251 is one of a range of packet processors with integrated CPUs
based on armada-xp. One difference is that the TCLK frequency is fixed
at 200MHz as opposed to the fixed 250MHz used on armada-xp. Additionally
the clock-gating options are a subset of what's available on the
armada-xp.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
As per Thomas' and Andrews comments I've made this specific to the
98DX4251 and separated out the gating definitions. It should be good for
other variants of what Marvell call "MSYS" but I don't have access to
any to test with.
v1: http://lists.infradead.org/pipermail/linux-arm-kernel/2014-November/304387.html
.../devicetree/bindings/clock/mvebu-core-clock.txt | 4 +++
drivers/clk/mvebu/armada-xp.c | 35 ++++++++++++++++++++++
2 files changed, 39 insertions(+)
diff --git a/Documentation/devicetree/bindings/clock/mvebu-core-clock.txt b/Documentation/devicetree/bindings/clock/mvebu-core-clock.txt
index dc5ea5b..503849e 100644
--- a/Documentation/devicetree/bindings/clock/mvebu-core-clock.txt
+++ b/Documentation/devicetree/bindings/clock/mvebu-core-clock.txt
@@ -34,6 +34,9 @@ The following is a list of provided IDs and clock names on Orion5x:
1 = cpuclk (CPU0 clock)
2 = ddrclk (DDR controller clock derived from CPU0 clock)
+The following is a list of provided IDs and clock names on MV98DX4251:
+ 0 = tclk (Internal Bus clock)
+
Required properties:
- compatible : shall be one of the following:
"marvell,armada-370-core-clock" - For Armada 370 SoC core clocks
@@ -46,6 +49,7 @@ Required properties:
"marvell,mv88f5182-core-clock" - for Orion MV88F5182 SoC
"marvell,mv88f5281-core-clock" - for Orion MV88F5281 SoC
"marvell,mv88f6183-core-clock" - for Orion MV88F6183 SoC
+ "marvell,mv98dx4251-core-clock" - for MV98DX4251 SoC
- reg : shall be the register address of the Sample-At-Reset (SAR) register
- #clock-cells : from common clock binding; shall be set to 1
diff --git a/drivers/clk/mvebu/armada-xp.c b/drivers/clk/mvebu/armada-xp.c
index b309431..eb17817 100644
--- a/drivers/clk/mvebu/armada-xp.c
+++ b/drivers/clk/mvebu/armada-xp.c
@@ -52,6 +52,12 @@ static u32 __init axp_get_tclk_freq(void __iomem *sar)
return 250000000;
}
+/* MV98DX4251 TCLK frequency is fixed to 200MHz */
+static u32 __init mv98dx4251_get_tclk_freq(void __iomem *sar)
+{
+ return 200000000;
+}
+
static const u32 axp_cpu_freqs[] __initconst = {
1000000000,
1066000000,
@@ -158,6 +164,14 @@ static const struct coreclk_soc_desc axp_coreclks = {
.num_ratios = ARRAY_SIZE(axp_coreclk_ratios),
};
+static const struct coreclk_soc_desc mv98dx4251_coreclks = {
+ .get_tclk_freq = mv98dx4251_get_tclk_freq,
+ .get_cpu_freq = axp_get_cpu_freq,
+ .get_clk_ratio = axp_get_clk_ratio,
+ .ratios = axp_coreclk_ratios,
+ .num_ratios = ARRAY_SIZE(axp_coreclk_ratios),
+};
+
/*
* Clock Gating Control
*/
@@ -195,6 +209,15 @@ static const struct clk_gating_soc_desc axp_gating_desc[] __initconst = {
{ }
};
+static const struct clk_gating_soc_desc mv98dx4251_gating_desc[] __initconst = {
+ { "ge1", NULL, 3, 0 },
+ { "ge0", NULL, 4, 0 },
+ { "pex00", NULL, 5, 0 },
+ { "sdio", NULL, 17, 0 },
+ { "xor0", NULL, 22, 0 },
+ { }
+};
+
static void __init axp_clk_init(struct device_node *np)
{
struct device_node *cgnp =
@@ -206,3 +229,15 @@ static void __init axp_clk_init(struct device_node *np)
mvebu_clk_gating_setup(cgnp, axp_gating_desc);
}
CLK_OF_DECLARE(axp_clk, "marvell,armada-xp-core-clock", axp_clk_init);
+
+static void __init mv98dx4251_clk_init(struct device_node *np)
+{
+ struct device_node *cgnp =
+ of_find_compatible_node(NULL, NULL, "marvell,armada-xp-gating-clock");
+
+ mvebu_coreclk_setup(np, &mv98dx4251_coreclks);
+
+ if (cgnp)
+ mvebu_clk_gating_setup(cgnp, mv98dx4251_gating_desc);
+}
+CLK_OF_DECLARE(mv98dx4251_clk, "marvell,mv98dx4251-core-clock", mv98dx4251_clk_init);
--
2.2.0.rc0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 4/5] ARM: mvebu: Initial support for rd-dxbc2
2014-12-23 21:13 [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2 Chris Packham
` (2 preceding siblings ...)
2014-12-23 21:13 ` [RFC/PATCHv2 3/5] clk: mvebu: armada-xp: Support for 98DX4251 Chris Packham
@ 2014-12-23 21:13 ` Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 5/5] ARM: mvebu: Custom smp_ops for 98DX4251 Chris Packham
4 siblings, 0 replies; 10+ messages in thread
From: Chris Packham @ 2014-12-23 21:13 UTC (permalink / raw)
To: linux-arm-kernel
The 98DX4251 Control and Management subsystem is a feature reduction
derivative of the ARMADA XP with some functional changes.
The following table highlights differences between the
ARMADA XP MV78230 and the Control and Management subsystem. There is a
complete table in the "Control and Management Subsystem Functional
Specification" .
Feature Bobcat2 MV78230
------- ------- -------
CPU Core (ARMv7 compliant Dual CPU @ up Dual CPU @ up
with FPU) to 800 MHz to 1.6 GHz
L2 Cache 2MB 1MB
PCIe 1 x1 1 x4 or 4 x1
1 x1
XOR DMA 2 Channels 4 Channels
SPI interface 1 Port 2 Ports
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
I'm not sure how much of a blurb people want about the new platform. I'd
just be repeating what's in Marvell's datasheets anyway.
I deliberately left the copyright notice in rd-dxbc2.dts since it was
created by copying armada-xp-db.dts. And I don't think anything I did is
worth asserting a different copyright. At the moment the mvebu-soc-id.h
definition is not strictly needed for anything but hopefully Marvell
will come to the party and add the other SoCs.
arch/arm/boot/dts/rd-dxbc2.dts | 109 +++++++++++++++++++++++++++++++++++++
arch/arm/mach-mvebu/mvebu-soc-id.h | 3 +
2 files changed, 112 insertions(+)
create mode 100644 arch/arm/boot/dts/rd-dxbc2.dts
diff --git a/arch/arm/boot/dts/rd-dxbc2.dts b/arch/arm/boot/dts/rd-dxbc2.dts
new file mode 100644
index 0000000..97a72d4
--- /dev/null
+++ b/arch/arm/boot/dts/rd-dxbc2.dts
@@ -0,0 +1,109 @@
+/*
+ * Device Tree file for RD-DXBC2 board
+ *
+ * Copyright (C) 2012-2014 Marvell
+ *
+ * Lior Amsalem <alior@marvell.com>
+ * Gregory CLEMENT <gregory.clement@free-electrons.com>
+ * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2. This program is licensed "as is" without any
+ * warranty of any kind, whether express or implied.
+ *
+ * Note: this Device Tree assumes that the bootloader has remapped the
+ * internal registers to 0xf1000000 (instead of the default
+ * 0xd0000000). The 0xf1000000 is the default used by the recent,
+ * DT-capable, U-Boot bootloaders provided by Marvell. Some earlier
+ * boards were delivered with an older version of the bootloader that
+ * left internal registers mapped at 0xd0000000. If you are in this
+ * situation, you should either update your bootloader (preferred
+ * solution) or the below Device Tree should be adjusted.
+ */
+
+/dts-v1/;
+#include "armada-xp-mv78260.dtsi"
+
+/ {
+ model = "Marvell Bobcat2 Evaluation Board";
+ compatible = "marvell,axp-db", "marvell,armadaxp-mv78260", "marvell,armadaxp", "marvell,armada-370-xp";
+
+ chosen {
+ bootargs = "console=ttyS0,115200 earlyprintk";
+ };
+
+ memory {
+ device_type = "memory";
+ reg = <0 0x00000000 0 0x20000000>; /* 512 MB */
+ };
+
+ soc {
+ ranges = <MBUS_ID(0xf0, 0x01) 0 0 0xf1000000 0x100000
+ MBUS_ID(0x01, 0x1d) 0 0 0xfff00000 0x100000
+ MBUS_ID(0x01, 0x2f) 0 0 0xf0000000 0x1000000>;
+
+ devbus-bootcs {
+ status = "okay";
+
+ /* Device Bus parameters are required */
+
+ /* Read parameters */
+ devbus,bus-width = <16>;
+ devbus,turn-off-ps = <60000>;
+ devbus,badr-skew-ps = <0>;
+ devbus,acc-first-ps = <124000>;
+ devbus,acc-next-ps = <248000>;
+ devbus,rd-setup-ps = <0>;
+ devbus,rd-hold-ps = <0>;
+
+ /* Write parameters */
+ devbus,sync-enable = <0>;
+ devbus,wr-high-ps = <60000>;
+ devbus,wr-low-ps = <60000>;
+ devbus,ale-wr-ps = <60000>;
+ };
+
+ internal-regs {
+ serial at 12000 {
+ status = "okay";
+ };
+ serial at 12100 {
+ status = "okay";
+ };
+
+ coreclk: mvebu-sar at 18230 {
+ compatible = "marvell,mv98dx4251-core-clock";
+ };
+
+ i2c at 11000 {
+ compatible = "marvell,mv64xxx-i2c";
+ clock-frequency = <400000>;
+ status = "okay";
+ };
+
+ mvsdio at d4000 {
+ pinctrl-0 = <&sdio_pins>;
+ pinctrl-names = "default";
+ status = "okay";
+ /* No CD or WP GPIOs */
+ broken-cd;
+ };
+
+ spi0: spi at 10600 {
+ status = "okay";
+
+ spi-flash at 0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ compatible = "m25p64";
+ reg = <0>; /* Chip select 0 */
+ spi-max-frequency = <20000000>;
+ };
+ };
+
+ xor at f0900 {
+ status = "disabled";
+ };
+ };
+ };
+};
diff --git a/arch/arm/mach-mvebu/mvebu-soc-id.h b/arch/arm/mach-mvebu/mvebu-soc-id.h
index c16bb68..98a9dca 100644
--- a/arch/arm/mach-mvebu/mvebu-soc-id.h
+++ b/arch/arm/mach-mvebu/mvebu-soc-id.h
@@ -24,6 +24,9 @@
#define ARMADA_375_Z1_REV 0x0
#define ARMADA_375_A0_REV 0x3
+/* Packet Processors with integrated CPU */
+#define MV98DX4251 0xFC00
+
#ifdef CONFIG_ARCH_MVEBU
int mvebu_get_soc_id(u32 *dev, u32 *rev);
#else
--
2.2.0.rc0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 5/5] ARM: mvebu: Custom smp_ops for 98DX4251
2014-12-23 21:13 [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2 Chris Packham
` (3 preceding siblings ...)
2014-12-23 21:13 ` [RFC/PATCHv2 4/5] ARM: mvebu: Initial support for rd-dxbc2 Chris Packham
@ 2014-12-23 21:13 ` Chris Packham
4 siblings, 0 replies; 10+ messages in thread
From: Chris Packham @ 2014-12-23 21:13 UTC (permalink / raw)
To: linux-arm-kernel
Compared to the armada-xp the 98DX4251 uses different registers to set
the boot address for the secondary CPU. This seems to contradict the
datasheet which lists the same PMSU registers. This could be an error in
the datasheet since it is likely to reproduce much of the armada-xp
information. Or it could be an artifact of the early silicon revision
being used.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
I wasn't sure about the name "pmsu-98dx4251" originally I called this
"msys" but following previous conversations on the subject I've opted to
go with something specific to the chip I'm dealing with. I could fold
this into pmsu.c so it was alongside mvebu_pmsu_set_cpu_boot_addr if
people think that would be better.
arch/arm/boot/dts/rd-dxbc2.dts | 9 +++++
arch/arm/mach-mvebu/Makefile | 1 +
arch/arm/mach-mvebu/common.h | 2 ++
arch/arm/mach-mvebu/platsmp.c | 28 +++++++++++++++
arch/arm/mach-mvebu/pmsu-98dx4251.c | 68 +++++++++++++++++++++++++++++++++++++
5 files changed, 108 insertions(+)
create mode 100644 arch/arm/mach-mvebu/pmsu-98dx4251.c
diff --git a/arch/arm/boot/dts/rd-dxbc2.dts b/arch/arm/boot/dts/rd-dxbc2.dts
index 97a72d4..5763c4f 100644
--- a/arch/arm/boot/dts/rd-dxbc2.dts
+++ b/arch/arm/boot/dts/rd-dxbc2.dts
@@ -28,6 +28,10 @@
model = "Marvell Bobcat2 Evaluation Board";
compatible = "marvell,axp-db", "marvell,armadaxp-mv78260", "marvell,armadaxp", "marvell,armada-370-xp";
+ cpus {
+ enable-method = "marvell,98dx4251-smp";
+ };
+
chosen {
bootargs = "console=ttyS0,115200 earlyprintk";
};
@@ -104,6 +108,11 @@
xor at f0900 {
status = "disabled";
};
+
+ resume at 20980 {
+ compatible = "marvell,98dx4251-resume-ctrl";
+ reg = <0x20980 0x10>;
+ };
};
};
};
diff --git a/arch/arm/mach-mvebu/Makefile b/arch/arm/mach-mvebu/Makefile
index e24136b..866822e 100644
--- a/arch/arm/mach-mvebu/Makefile
+++ b/arch/arm/mach-mvebu/Makefile
@@ -8,6 +8,7 @@ obj-$(CONFIG_MACH_MVEBU_ANY) += system-controller.o mvebu-soc-id.o
ifeq ($(CONFIG_MACH_MVEBU_V7),y)
obj-y += cpu-reset.o board-v7.o coherency.o coherency_ll.o pmsu.o pmsu_ll.o
+obj-y += pmsu-98dx4251.o
obj-$(CONFIG_SMP) += platsmp.o headsmp.o platsmp-a9.o headsmp-a9.o
endif
diff --git a/arch/arm/mach-mvebu/common.h b/arch/arm/mach-mvebu/common.h
index 3ccb40c..5064ac5 100644
--- a/arch/arm/mach-mvebu/common.h
+++ b/arch/arm/mach-mvebu/common.h
@@ -25,4 +25,6 @@ int mvebu_system_controller_get_soc_id(u32 *dev, u32 *rev);
void __iomem *mvebu_get_scu_base(void);
+void mv98dx4251_resume_set_cpu_boot_addr(int hw_cpu, void *boot_addr);
+
#endif
diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
index 895dc37..2a2ed65d 100644
--- a/arch/arm/mach-mvebu/platsmp.c
+++ b/arch/arm/mach-mvebu/platsmp.c
@@ -180,5 +180,33 @@ struct smp_operations armada_xp_smp_ops __initdata = {
#endif
};
+static int mv98dx4251_boot_secondary(unsigned int cpu, struct task_struct *idle)
+{
+ int ret, hw_cpu;
+
+ pr_info("Booting CPU %d\n", cpu);
+
+ hw_cpu = cpu_logical_map(cpu);
+ mv98dx4251_resume_set_cpu_boot_addr(hw_cpu, armada_xp_secondary_startup);
+ ret = mvebu_cpu_reset_deassert(hw_cpu);
+ if (ret) {
+ pr_warn("unable to boot CPU: %d\n", ret);
+ return ret;
+ }
+
+ return 0;
+}
+
+struct smp_operations mv98dx4251_smp_ops __initdata = {
+ .smp_init_cpus = armada_xp_smp_init_cpus,
+ .smp_prepare_cpus = armada_xp_smp_prepare_cpus,
+ .smp_boot_secondary = mv98dx4251_boot_secondary,
+#ifdef CONFIG_HOTPLUG_CPU
+ .cpu_die = armada_xp_cpu_die,
+#endif
+};
+
CPU_METHOD_OF_DECLARE(armada_xp_smp, "marvell,armada-xp-smp",
&armada_xp_smp_ops);
+CPU_METHOD_OF_DECLARE(mv98dx4251_smp, "marvell,98dx4251-smp",
+ &mv98dx4251_smp_ops);
diff --git a/arch/arm/mach-mvebu/pmsu-98dx4251.c b/arch/arm/mach-mvebu/pmsu-98dx4251.c
new file mode 100644
index 0000000..e4d3ad46
--- /dev/null
+++ b/arch/arm/mach-mvebu/pmsu-98dx4251.c
@@ -0,0 +1,68 @@
+/**
+ * CPU resume support for 98DX4521 internal CPU (a.k.a. MSYS).
+ */
+
+#define pr_fmt(fmt) "mv98dx4251-resume: " fmt
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/of_address.h>
+#include <linux/io.h>
+#include "common.h"
+
+static void __iomem *mv98dx4251_resume_base;
+#define MV98DX4251_CPU_RESUME_CTRL_OFFSET 0x08
+#define MV98DX4251_CPU_RESUME_ADDR_OFFSET 0x04
+
+static struct of_device_id of_mv98dx4251_resume_table[] = {
+ {.compatible = "marvell,98dx4251-resume-ctrl",},
+ { /* end of list */ },
+};
+
+void mv98dx4251_resume_set_cpu_boot_addr(int hw_cpu, void *boot_addr)
+{
+ WARN_ON(hw_cpu != 1);
+
+ writel(0, mv98dx4251_resume_base + MV98DX4251_CPU_RESUME_CTRL_OFFSET);
+ writel(virt_to_phys(boot_addr), mv98dx4251_resume_base +
+ MV98DX4251_CPU_RESUME_ADDR_OFFSET);
+}
+
+static int __init mv98dx4251_resume_init(void)
+{
+ struct device_node *np;
+ struct resource res;
+ int ret = 0;
+
+ np = of_find_matching_node(NULL, of_mv98dx4251_resume_table);
+ if (!np)
+ return 0;
+
+ pr_info("Initializing 98DX4521 Resume\n");
+
+ if (of_address_to_resource(np, 0, &res)) {
+ pr_err("unable to get resource\n");
+ ret = -ENOENT;
+ goto out;
+ }
+
+ if (!request_mem_region(res.start, resource_size(&res), np->full_name)) {
+ pr_err("unable to request region\n");
+ ret = -EBUSY;
+ goto out;
+ }
+
+ mv98dx4251_resume_base = ioremap(res.start, resource_size(&res));
+ if (!mv98dx4251_resume_base) {
+ pr_err("unable to map registers\n");
+ release_mem_region(res.start, resource_size(&res));
+ ret = -ENOMEM;
+ goto out;
+ }
+
+out:
+ of_node_put(np);
+ return ret;
+}
+
+early_initcall(mv98dx4251_resume_init);
--
2.2.0.rc0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 1/5] dtc: Use quotes to include header files
2014-12-23 21:13 ` [RFC/PATCHv2 1/5] dtc: Use quotes to include header files Chris Packham
@ 2014-12-28 2:08 ` Rob Herring
2015-01-02 21:21 ` Chris Packham
0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2014-12-28 2:08 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Dec 23, 2014 at 3:13 PM, Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
> Currently in arch and driver code that needs early access to the
> flattened device tree it is necessary to add specific CFLAGS so that
> when scripts/dtc/libfdt/libfdt.h is included the C preprocessor is able
> to locate the libfdt versions of libfdt_env.h and fdt.h without
> generating an error.
>
> We already provide an alternative linux-specific
> version of libfdt_env.h and directly include scripts/dtc/libfdt/fdt.h
> so the inclusion by scripts/dtc/libfdt/libfdt.h is a no-op thanks to the
> inclusion guards.
>
> By using quotes in scripts/dtc/libfdt/libfdt.h it picks up fdt.h and
> libfdt_env.h from the source directory without needing to add CFLAGS for
> the sources that happen to include linux/libfdt.h.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> For the files that include linux/libfdt.h we currently also have to
> specify additional CFLAGS to satisfy the CPP.
>
> $ git grep '<linux/libfdt.h>'
> arch/mips/cavium-octeon/octeon-platform.c:#include <linux/libfdt.h>
> arch/mips/cavium-octeon/setup.c:#include <linux/libfdt.h>
> arch/mips/mti-sead3/sead3-setup.c:#include <linux/libfdt.h>
> arch/powerpc/kernel/prom.c:#include <linux/libfdt.h>
> drivers/firmware/efi/libstub/fdt.c:#include <linux/libfdt.h>
> drivers/of/fdt.c:#include <linux/libfdt.h>
> drivers/of/fdt_address.c:#include <linux/libfdt.h>
>
> $ git grep -e '-I.*dtc/libfdt'
> arch/mips/cavium-octeon/Makefile:CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt
> arch/mips/cavium-octeon/Makefile:CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
> arch/mips/mti-sead3/Makefile:CFLAGS_sead3-setup.o = -I$(src)/../../../scripts/dtc/libfdt
> arch/powerpc/kernel/Makefile:CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt
> drivers/firmware/efi/libstub/Makefile:CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
> drivers/of/Makefile:CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
> drivers/of/Makefile:CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
> lib/Makefile: $(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
>
> Simply by switching to using quotes we can avoid having this extra step.
Nice, but I would like to see all of these CFLAGS removed as well.
> scripts/dtc/libfdt/libfdt.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
This is an import of dtc/libfdt and patches to it should be sent
upstream and to devicetree-compiler list.
Rob
> diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
> index 73f4975..ea1ddcd 100644
> --- a/scripts/dtc/libfdt/libfdt.h
> +++ b/scripts/dtc/libfdt/libfdt.h
> @@ -51,8 +51,8 @@
> * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> */
>
> -#include <libfdt_env.h>
> -#include <fdt.h>
> +#include "libfdt_env.h"
> +#include "fdt.h"
>
> #define FDT_FIRST_SUPPORTED_VERSION 0x10
> #define FDT_LAST_SUPPORTED_VERSION 0x11
> --
> 2.2.0.rc0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method
2014-12-23 21:13 ` [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method Chris Packham
@ 2014-12-28 2:53 ` Rob Herring
2015-01-02 21:51 ` Chris Packham
0 siblings, 1 reply; 10+ messages in thread
From: Rob Herring @ 2014-12-28 2:53 UTC (permalink / raw)
To: linux-arm-kernel
On Tue, Dec 23, 2014 at 3:13 PM, Chris Packham
<chris.packham@alliedtelesis.co.nz> wrote:
> When the device tree doesn't define an enable-method insert a property
> into the flattened device tree. arm_dt_init_cpu_maps() will then parse
> this an set smp_ops appropriately. Now that we have this fallback it is
> no longer necessary to set .smp in the DT_MACHINE definition.
> Additionally Armada 370, which is a single core device, no longer has any
> smp operations defined.
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
> ---
> As Arnd and Maxime suggested this replaces the unconditional setting of
> smp_ops[1] with a fixup that inserts an appropriate property in the
> device-tree if needed. It turned out not to be terribly tricky to
> implement that checked each possible CPU node. One assumption I've made
> is that the cpu nodes are numbered contiguously but that seems to be
> reasonable.
In general, that's not a good assumption, but may be okay for Armada.
> [1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/309766.html
I'm not really convinced this is better than a 1-line function...
>
> arch/arm/mach-mvebu/board-v7.c | 42 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 41 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
> index d0d39f1..08eb6a9 100644
> --- a/arch/arm/mach-mvebu/board-v7.c
> +++ b/arch/arm/mach-mvebu/board-v7.c
> @@ -17,6 +17,8 @@
> #include <linux/clk-provider.h>
> #include <linux/of_address.h>
> #include <linux/of_platform.h>
> +#include <linux/of_fdt.h>
> +#include <linux/libfdt.h>
> #include <linux/io.h>
> #include <linux/clocksource.h>
> #include <linux/dma-mapping.h>
> @@ -198,6 +200,44 @@ static void __init mvebu_dt_init(void)
> of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
> }
>
> +static void __init armada_370_xp_dt_fixup(void)
> +{
> + int offset, node;
> + int i, len;
> + void *prop;
> + char buffer[20];
> + unsigned long root = of_get_flat_dt_root();
> +
> + if (!IS_ENABLED(CONFIG_SMP) ||
This doesn't need to be conditional on SMP. You should fixup the DT
independent of kernel options.
> + !of_flat_dt_is_compatible(root, "marvell,armadaxp"))
> + return;
> +
> + offset = fdt_path_offset(initial_boot_params, "/cpus");
> + if (offset < 0)
> + return;
> +
> + prop = fdt_getprop(initial_boot_params, offset, "enable-method", &len);
> + if (prop)
> + return;
> +
> + for (i = 0; i < NR_CPUS; i++) {
> + snprintf(buffer, sizeof(buffer), "cpu@%d", i);
> + node = fdt_subnode_offset(initial_boot_params, offset, buffer);
You can use fdt_node_offset_by_compatible with the cpu compatible
string here instead.
> + if (node < 0)
> + break;
> + prop = fdt_getprop(initial_boot_params, node,
> + "enable-method", &len);
Do you really need to search thru all of the nodes? enable-method
should either be present on all or none.
> + if (prop)
> + return;
> + }
> +
> + pr_info("No enable-method defined. "
> + "Falling back to \"marvell,armada-xp-smp\"\n");
> +
> + fdt_setprop(initial_boot_params, offset, "enable-method",
> + "marvell,armada-xp-smp", sizeof("marvell,armada-xp-smp"));
Use fdt_setprop_string here.
enable-method is supposed to be a per cpu property. The Marvell berlin
binding is wrong here and should not be copied.
Rob
> +}
> +
> static const char * const armada_370_xp_dt_compat[] = {
> "marvell,armada-370-xp",
> NULL,
> @@ -206,11 +246,11 @@ static const char * const armada_370_xp_dt_compat[] = {
> DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)")
> .l2c_aux_val = 0,
> .l2c_aux_mask = ~0,
> - .smp = smp_ops(armada_xp_smp_ops),
> .init_machine = mvebu_dt_init,
> .init_irq = mvebu_init_irq,
> .restart = mvebu_restart,
> .dt_compat = armada_370_xp_dt_compat,
> + .dt_fixup = armada_370_xp_dt_fixup,
> MACHINE_END
>
> static const char * const armada_375_dt_compat[] = {
> --
> 2.2.0.rc0
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 1/5] dtc: Use quotes to include header files
2014-12-28 2:08 ` Rob Herring
@ 2015-01-02 21:21 ` Chris Packham
0 siblings, 0 replies; 10+ messages in thread
From: Chris Packham @ 2015-01-02 21:21 UTC (permalink / raw)
To: linux-arm-kernel
Hi Rob,
On Sat, 27 Dec 2014, Rob Herring wrote:
> On Tue, Dec 23, 2014 at 3:13 PM, Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
>> Currently in arch and driver code that needs early access to the
>> flattened device tree it is necessary to add specific CFLAGS so that
>> when scripts/dtc/libfdt/libfdt.h is included the C preprocessor is able
>> to locate the libfdt versions of libfdt_env.h and fdt.h without
>> generating an error.
>>
>> We already provide an alternative linux-specific
>> version of libfdt_env.h and directly include scripts/dtc/libfdt/fdt.h
>> so the inclusion by scripts/dtc/libfdt/libfdt.h is a no-op thanks to the
>> inclusion guards.
>>
>> By using quotes in scripts/dtc/libfdt/libfdt.h it picks up fdt.h and
>> libfdt_env.h from the source directory without needing to add CFLAGS for
>> the sources that happen to include linux/libfdt.h.
>>
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>> ---
>> For the files that include linux/libfdt.h we currently also have to
>> specify additional CFLAGS to satisfy the CPP.
>>
>> $ git grep '<linux/libfdt.h>'
>> arch/mips/cavium-octeon/octeon-platform.c:#include <linux/libfdt.h>
>> arch/mips/cavium-octeon/setup.c:#include <linux/libfdt.h>
>> arch/mips/mti-sead3/sead3-setup.c:#include <linux/libfdt.h>
>> arch/powerpc/kernel/prom.c:#include <linux/libfdt.h>
>> drivers/firmware/efi/libstub/fdt.c:#include <linux/libfdt.h>
>> drivers/of/fdt.c:#include <linux/libfdt.h>
>> drivers/of/fdt_address.c:#include <linux/libfdt.h>
>>
>> $ git grep -e '-I.*dtc/libfdt'
>> arch/mips/cavium-octeon/Makefile:CFLAGS_octeon-platform.o = -I$(src)/../../../scripts/dtc/libfdt
>> arch/mips/cavium-octeon/Makefile:CFLAGS_setup.o = -I$(src)/../../../scripts/dtc/libfdt
>> arch/mips/mti-sead3/Makefile:CFLAGS_sead3-setup.o = -I$(src)/../../../scripts/dtc/libfdt
>> arch/powerpc/kernel/Makefile:CFLAGS_prom.o = -I$(src)/../../../scripts/dtc/libfdt
>> drivers/firmware/efi/libstub/Makefile:CFLAGS_fdt.o += -I$(srctree)/scripts/dtc/libfdt/
>> drivers/of/Makefile:CFLAGS_fdt.o = -I$(src)/../../scripts/dtc/libfdt
>> drivers/of/Makefile:CFLAGS_fdt_address.o = -I$(src)/../../scripts/dtc/libfdt
>> lib/Makefile: $(eval CFLAGS_$(file) = -I$(src)/../scripts/dtc/libfdt))
>>
>> Simply by switching to using quotes we can avoid having this extra step.
>
> Nice, but I would like to see all of these CFLAGS removed as well.
>
If/when this is accepted I'll send a follow up patch removing these. Given
the comment below about getting the patch in the upstream dtc repository
it make take some time for it to be accepted there and then sync'd with
the kernel source.
>> scripts/dtc/libfdt/libfdt.h | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> This is an import of dtc/libfdt and patches to it should be sent
> upstream and to devicetree-compiler list.
Have done so now.
>
> Rob
>
>> diff --git a/scripts/dtc/libfdt/libfdt.h b/scripts/dtc/libfdt/libfdt.h
>> index 73f4975..ea1ddcd 100644
>> --- a/scripts/dtc/libfdt/libfdt.h
>> +++ b/scripts/dtc/libfdt/libfdt.h
>> @@ -51,8 +51,8 @@
>> * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
>> */
>>
>> -#include <libfdt_env.h>
>> -#include <fdt.h>
>> +#include "libfdt_env.h"
>> +#include "fdt.h"
>>
>> #define FDT_FIRST_SUPPORTED_VERSION 0x10
>> #define FDT_LAST_SUPPORTED_VERSION 0x11
>> --
>> 2.2.0.rc0
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method
2014-12-28 2:53 ` Rob Herring
@ 2015-01-02 21:51 ` Chris Packham
0 siblings, 0 replies; 10+ messages in thread
From: Chris Packham @ 2015-01-02 21:51 UTC (permalink / raw)
To: linux-arm-kernel
Hi Rob,
On Sat, 27 Dec 2014, Rob Herring wrote:
> On Tue, Dec 23, 2014 at 3:13 PM, Chris Packham
> <chris.packham@alliedtelesis.co.nz> wrote:
>> When the device tree doesn't define an enable-method insert a property
>> into the flattened device tree. arm_dt_init_cpu_maps() will then parse
>> this an set smp_ops appropriately. Now that we have this fallback it is
>> no longer necessary to set .smp in the DT_MACHINE definition.
>> Additionally Armada 370, which is a single core device, no longer has any
>> smp operations defined.
>>
>> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
>> ---
>> As Arnd and Maxime suggested this replaces the unconditional setting of
>> smp_ops[1] with a fixup that inserts an appropriate property in the
>> device-tree if needed. It turned out not to be terribly tricky to
>> implement that checked each possible CPU node. One assumption I've made
>> is that the cpu nodes are numbered contiguously but that seems to be
>> reasonable.
>
> In general, that's not a good assumption, but may be okay for Armada.
>
I guess that should read "reasonable for Armada". This is a Armada
specific fixup so I think that's OK. Still it wouldn't hurt to remove the
break and just iterate from 0 to NR_CPUS.
>> [1] - http://lists.infradead.org/pipermail/linux-arm-kernel/2014-December/309766.html
>
> I'm not really convinced this is better than a 1-line function...
>
Arnd, Maxime care to comment? I'm good either way. One justification was
that we were using a function called "dt_fixup" to do something other than
maniplulate the device tree. We could add a new function pointer for this
but I think I'm a bit too much of a newbie to start adding new
machine_desc functions and modifying core code.
>>
>> arch/arm/mach-mvebu/board-v7.c | 42 +++++++++++++++++++++++++++++++++++++++++-
>> 1 file changed, 41 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/arm/mach-mvebu/board-v7.c b/arch/arm/mach-mvebu/board-v7.c
>> index d0d39f1..08eb6a9 100644
>> --- a/arch/arm/mach-mvebu/board-v7.c
>> +++ b/arch/arm/mach-mvebu/board-v7.c
>> @@ -17,6 +17,8 @@
>> #include <linux/clk-provider.h>
>> #include <linux/of_address.h>
>> #include <linux/of_platform.h>
>> +#include <linux/of_fdt.h>
>> +#include <linux/libfdt.h>
>> #include <linux/io.h>
>> #include <linux/clocksource.h>
>> #include <linux/dma-mapping.h>
>> @@ -198,6 +200,44 @@ static void __init mvebu_dt_init(void)
>> of_platform_populate(NULL, of_default_bus_match_table, NULL, NULL);
>> }
>>
>> +static void __init armada_370_xp_dt_fixup(void)
>> +{
>> + int offset, node;
>> + int i, len;
>> + void *prop;
>> + char buffer[20];
>> + unsigned long root = of_get_flat_dt_root();
>> +
>> + if (!IS_ENABLED(CONFIG_SMP) ||
>
> This doesn't need to be conditional on SMP. You should fixup the DT
> independent of kernel options.
>
Will remove in the next round.
>> + !of_flat_dt_is_compatible(root, "marvell,armadaxp"))
>> + return;
>> +
>> + offset = fdt_path_offset(initial_boot_params, "/cpus");
>> + if (offset < 0)
>> + return;
>> +
>> + prop = fdt_getprop(initial_boot_params, offset, "enable-method", &len);
>> + if (prop)
>> + return;
>> +
>> + for (i = 0; i < NR_CPUS; i++) {
>> + snprintf(buffer, sizeof(buffer), "cpu@%d", i);
>> + node = fdt_subnode_offset(initial_boot_params, offset, buffer);
>
> You can use fdt_node_offset_by_compatible with the cpu compatible
> string here instead.
>
I'll look into that for the next version. Will
fdt_node_offset_by_compatible() allow me to iterate through all nodes with
that compatible string?
>> + if (node < 0)
>> + break;
>> + prop = fdt_getprop(initial_boot_params, node,
>> + "enable-method", &len);
>
> Do you really need to search thru all of the nodes? enable-method
> should either be present on all or none.
>
I'm following what arm_dt_init_cpu_maps does. I agree that these days a
valid device tree should have this set for every cpu node but we're trying
to be compaitble with older dtbs.
>> + if (prop)
>> + return;
>> + }
>> +
>> + pr_info("No enable-method defined. "
>> + "Falling back to \"marvell,armada-xp-smp\"\n");
>> +
>> + fdt_setprop(initial_boot_params, offset, "enable-method",
>> + "marvell,armada-xp-smp", sizeof("marvell,armada-xp-smp"));
>
> Use fdt_setprop_string here.
Will do in the next round.
>
> enable-method is supposed to be a per cpu property. The Marvell berlin
> binding is wrong here and should not be copied.
>
Are you suggesting that I set the enable-method on the individual CPU
nodes instead of /cpus? That would be easy enough to do and
arm_dt_init_cpu_maps would do the right thing.
One consideration is a device-tree with an enable-method on /cpu at 2 but not
on /cpu at 1. The existing code would handle this, after this proposed change
we'd set the enable-method on /cpu at 1 negating the effect of it being set
on /cpu at 2. This is a pretty contrived example, I'm not sure that such a
device tree exists. We probably do need to handle the case of the
enable-method being set on /cpus and not the individual nodes.
> Rob
>
>> +}
>> +
>> static const char * const armada_370_xp_dt_compat[] = {
>> "marvell,armada-370-xp",
>> NULL,
>> @@ -206,11 +246,11 @@ static const char * const armada_370_xp_dt_compat[] = {
>> DT_MACHINE_START(ARMADA_370_XP_DT, "Marvell Armada 370/XP (Device Tree)")
>> .l2c_aux_val = 0,
>> .l2c_aux_mask = ~0,
>> - .smp = smp_ops(armada_xp_smp_ops),
>> .init_machine = mvebu_dt_init,
>> .init_irq = mvebu_init_irq,
>> .restart = mvebu_restart,
>> .dt_compat = armada_370_xp_dt_compat,
>> + .dt_fixup = armada_370_xp_dt_fixup,
>> MACHINE_END
>>
>> static const char * const armada_375_dt_compat[] = {
>> --
>> 2.2.0.rc0
>>
>>
>> _______________________________________________
>> linux-arm-kernel mailing list
>> linux-arm-kernel at lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2015-01-02 21:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-23 21:13 [RFC/PATCHv2 0/5] Add support for Marvell's RD-DXBC2 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 1/5] dtc: Use quotes to include header files Chris Packham
2014-12-28 2:08 ` Rob Herring
2015-01-02 21:21 ` Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 2/5] ARM: mvebu: use dt_fixup to provide fallback for enable-method Chris Packham
2014-12-28 2:53 ` Rob Herring
2015-01-02 21:51 ` Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 3/5] clk: mvebu: armada-xp: Support for 98DX4251 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 4/5] ARM: mvebu: Initial support for rd-dxbc2 Chris Packham
2014-12-23 21:13 ` [RFC/PATCHv2 5/5] ARM: mvebu: Custom smp_ops for 98DX4251 Chris Packham
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).