[U-Boot] [PATCH u-boot-marvell v2 00/12] Updates for Turris Mox

This is second version of updates for Turris Mox. The first version was sent three months ago, on 16th May. Sorry :). It would be great if this got to 2018.09 release, but I will understand if it does not.
I changed the first patch, "phy: marvell: Support changing SERDES map in board file", according to Stefan's suggestions.
The other patches have changed, since I have reworked the system of how U-Boot tells kernel about the different Mox modules.
Previously the board code created a variable module_topology, which then was used by boot script to load correct device tree. There were many device trees, one for each correct module topology.
Now there is only one device tree, and U-Boot patches the device tree in ft_board_setup, according to which modules are connected.
Patch 2 adds code to peripheral clocks, so that their parents/rates can be changed.
Patch 3 fixes watchdog setup.
Patch 4 adds fixup for U-Boot's device tree according to module topology (enables PCIe node if PCIe device is connected).
Patches 5 and 10 add configs to defcofnig.
Patch 6 is cosmetic.
Patch 7 adds comphy_update_map which updates SERDES lane 1 speed according to module topology.
Patch 8 adds check for module topology, if it is correct and so on, then adds configuration of switch modules via SPI and finally some fancy switch LED blinking.
Patch 9 adds the code which patches Linux's device tree according to module topology.
Patch 11 changes the Mox's U-Boot device tree.
Patch 12 creates a new config variable to support 1 GB RAM version of Mox (and adds a -u-boot.dtsi to support the change).
Marek

This adds a weak definition of comphy_update_map to comphy_core, which does nothing. If this function is defined elsewhere, for example in board file, the board file can change some parameters of SERDES configuration.
This is needed on Turris Mox, where the SERDES speed on lane 1 has to be set differently when SFP module is connected and when Topaz Switch module is connected.
This is a temporary solution. When the comphy driver for armada-3720 will be added to the kernel, the comphy driver in u-boot shall also be updated and this should be done differently then.
Signed-off-by: Marek Behun marek.behun@nic.cz --- MAINTAINERS | 3 ++- drivers/phy/marvell/comphy_a3700.h | 2 +- drivers/phy/marvell/comphy_core.c | 12 +++++++++++- drivers/phy/marvell/{comphy.h => comphy_core.h} | 16 ++++------------ drivers/phy/marvell/comphy_cp110.c | 2 +- drivers/phy/marvell/comphy_mux.c | 2 +- include/mvebu/comphy.h | 22 ++++++++++++++++++++++ 7 files changed, 42 insertions(+), 17 deletions(-) rename drivers/phy/marvell/{comphy.h => comphy_core.h} (96%) create mode 100644 include/mvebu/comphy.h
diff --git a/MAINTAINERS b/MAINTAINERS index 8f237128b2..1893090b8f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -139,7 +139,7 @@ S: Maintained F: arch/arm/cpu/armv8/hisilicon F: arch/arm/include/asm/arch-hi6220/
-ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X +ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X ARMADA-37XX M: Prafulla Wadaskar prafulla@marvell.com M: Luka Perkov luka.perkov@sartura.hr M: Stefan Roese sr@denx.de @@ -148,6 +148,7 @@ T: git git://git.denx.de/u-boot-marvell.git F: arch/arm/mach-kirkwood/ F: arch/arm/mach-mvebu/ F: drivers/ata/ahci_mvebu.c +F: drivers/phy/marvell/
ARM MARVELL PXA M: Marek Vasut marex@denx.de diff --git a/drivers/phy/marvell/comphy_a3700.h b/drivers/phy/marvell/comphy_a3700.h index a14767d809..b0941ffb37 100644 --- a/drivers/phy/marvell/comphy_a3700.h +++ b/drivers/phy/marvell/comphy_a3700.h @@ -6,7 +6,7 @@ #ifndef _COMPHY_A3700_H_ #define _COMPHY_A3700_H_
-#include "comphy.h" +#include "comphy_core.h" #include "comphy_hpipe.h"
#define MVEBU_REG(offs) \ diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index c6e2cc8897..9c24692629 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -11,7 +11,7 @@ #include <linux/errno.h> #include <asm/io.h>
-#include "comphy.h" +#include "comphy_core.h"
#define COMPHY_MAX_CHIP 4
@@ -66,6 +66,11 @@ void comphy_print(struct chip_serdes_phy_config *chip_cfg, } }
+__weak int comphy_update_map(struct comphy_map *serdes_map, int count) +{ + return 0; +} + static int comphy_probe(struct udevice *dev) { const void *blob = gd->fdt_blob; @@ -76,6 +81,7 @@ static int comphy_probe(struct udevice *dev) int lane; int last_idx = 0; static int current_idx; + int res;
/* Save base addresses for later use */ chip_cfg->comphy_base_addr = (void *)devfdt_get_addr_index(dev, 0); @@ -143,6 +149,10 @@ static int comphy_probe(struct udevice *dev) lane++; }
+ res = comphy_update_map(comphy_map_data, chip_cfg->comphy_lanes_count); + if (res < 0) + return res; + /* Save CP index for MultiCP devices (A8K) */ chip_cfg->cp_index = current_idx++; /* PHY power UP sequence */ diff --git a/drivers/phy/marvell/comphy.h b/drivers/phy/marvell/comphy_core.h similarity index 96% rename from drivers/phy/marvell/comphy.h rename to drivers/phy/marvell/comphy_core.h index b588ae41f0..12ab921d24 100644 --- a/drivers/phy/marvell/comphy.h +++ b/drivers/phy/marvell/comphy_core.h @@ -3,11 +3,11 @@ * Copyright (C) 2015-2016 Marvell International Ltd. */
-#ifndef _COMPHY_H_ -#define _COMPHY_H_ +#ifndef _COMPHY_CORE_H_ +#define _COMPHY_CORE_H_
-#include <dt-bindings/comphy/comphy_data.h> #include <fdtdec.h> +#include <mvebu/comphy.h>
#if defined(DEBUG) #define debug_enter() printf("----> Enter %s\n", __func__); @@ -80,14 +80,6 @@ struct comphy_mux_data { struct comphy_mux_options mux_values[MAX_LANE_OPTIONS]; };
-struct comphy_map { - u32 type; - u32 speed; - u32 invert; - bool clk_src; - bool end_point; -}; - struct chip_serdes_phy_config { struct comphy_mux_data *mux_data; int (*ptr_comphy_chip_init)(struct chip_serdes_phy_config *, @@ -183,5 +175,5 @@ void comphy_pcie_config_detect(u32 comphy_max_count, struct comphy_map *serdes_map); void comphy_pcie_unit_general_config(u32 pex_index);
-#endif /* _COMPHY_H_ */ +#endif /* _COMPHY_CORE_H_ */
diff --git a/drivers/phy/marvell/comphy_cp110.c b/drivers/phy/marvell/comphy_cp110.c index b0d5d5ca26..6a60da3df0 100644 --- a/drivers/phy/marvell/comphy_cp110.c +++ b/drivers/phy/marvell/comphy_cp110.c @@ -9,7 +9,7 @@ #include <asm/arch/cpu.h> #include <asm/arch/soc.h>
-#include "comphy.h" +#include "comphy_core.h" #include "comphy_hpipe.h" #include "sata.h" #include "utmi_phy.h" diff --git a/drivers/phy/marvell/comphy_mux.c b/drivers/phy/marvell/comphy_mux.c index 1f757d8e04..c67ba99762 100644 --- a/drivers/phy/marvell/comphy_mux.c +++ b/drivers/phy/marvell/comphy_mux.c @@ -6,7 +6,7 @@ #include <common.h> #include <asm/io.h>
-#include "comphy.h" +#include "comphy_core.h" #include "comphy_hpipe.h"
/* diff --git a/include/mvebu/comphy.h b/include/mvebu/comphy.h new file mode 100644 index 0000000000..cde7a022af --- /dev/null +++ b/include/mvebu/comphy.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) 2015-2016 Marvell International Ltd. + */ + +#ifndef _MVEBU_COMPHY_H_ +#define _MVEBU_COMPHY_H_ + +#include <dt-bindings/comphy/comphy_data.h> + +struct comphy_map { + u32 type; + u32 speed; + u32 invert; + bool clk_src; + bool end_point; +}; + +int comphy_update_map(struct comphy_map *serdes_map, int count); + +#endif /* _MVEBU_COMPHY_H_ */ +

On 17.08.2018 12:58, Marek Behún wrote:
This adds a weak definition of comphy_update_map to comphy_core, which does nothing. If this function is defined elsewhere, for example in board file, the board file can change some parameters of SERDES configuration.
This is needed on Turris Mox, where the SERDES speed on lane 1 has to be set differently when SFP module is connected and when Topaz Switch module is connected.
This is a temporary solution. When the comphy driver for armada-3720 will be added to the kernel, the comphy driver in u-boot shall also be updated and this should be done differently then.
Signed-off-by: Marek Behun marek.behun@nic.cz
MAINTAINERS | 3 ++- drivers/phy/marvell/comphy_a3700.h | 2 +- drivers/phy/marvell/comphy_core.c | 12 +++++++++++- drivers/phy/marvell/{comphy.h => comphy_core.h} | 16 ++++------------ drivers/phy/marvell/comphy_cp110.c | 2 +- drivers/phy/marvell/comphy_mux.c | 2 +- include/mvebu/comphy.h | 22 ++++++++++++++++++++++ 7 files changed, 42 insertions(+), 17 deletions(-) rename drivers/phy/marvell/{comphy.h => comphy_core.h} (96%) create mode 100644 include/mvebu/comphy.h
diff --git a/MAINTAINERS b/MAINTAINERS index 8f237128b2..1893090b8f 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -139,7 +139,7 @@ S: Maintained F: arch/arm/cpu/armv8/hisilicon F: arch/arm/include/asm/arch-hi6220/
-ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X +ARM MARVELL KIRKWOOD ARMADA-XP ARMADA-38X ARMADA-37XX M: Prafulla Wadaskar prafulla@marvell.com M: Luka Perkov luka.perkov@sartura.hr M: Stefan Roese sr@denx.de @@ -148,6 +148,7 @@ T: git git://git.denx.de/u-boot-marvell.git F: arch/arm/mach-kirkwood/ F: arch/arm/mach-mvebu/ F: drivers/ata/ahci_mvebu.c +F: drivers/phy/marvell/
ARM MARVELL PXA M: Marek Vasut marex@denx.de diff --git a/drivers/phy/marvell/comphy_a3700.h b/drivers/phy/marvell/comphy_a3700.h index a14767d809..b0941ffb37 100644 --- a/drivers/phy/marvell/comphy_a3700.h +++ b/drivers/phy/marvell/comphy_a3700.h @@ -6,7 +6,7 @@ #ifndef _COMPHY_A3700_H_ #define _COMPHY_A3700_H_
-#include "comphy.h" +#include "comphy_core.h" #include "comphy_hpipe.h"
#define MVEBU_REG(offs) \ diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index c6e2cc8897..9c24692629 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -11,7 +11,7 @@ #include <linux/errno.h> #include <asm/io.h>
-#include "comphy.h" +#include "comphy_core.h"
#define COMPHY_MAX_CHIP 4
@@ -66,6 +66,11 @@ void comphy_print(struct chip_serdes_phy_config *chip_cfg, } }
+__weak int comphy_update_map(struct comphy_map *serdes_map, int count) +{
- return 0;
+}
- static int comphy_probe(struct udevice *dev) { const void *blob = gd->fdt_blob;
@@ -76,6 +81,7 @@ static int comphy_probe(struct udevice *dev) int lane; int last_idx = 0; static int current_idx;
int res;
/* Save base addresses for later use */ chip_cfg->comphy_base_addr = (void *)devfdt_get_addr_index(dev, 0);
@@ -143,6 +149,10 @@ static int comphy_probe(struct udevice *dev) lane++; }
- res = comphy_update_map(comphy_map_data, chip_cfg->comphy_lanes_count);
- if (res < 0)
return res;
- /* Save CP index for MultiCP devices (A8K) */ chip_cfg->cp_index = current_idx++; /* PHY power UP sequence */
diff --git a/drivers/phy/marvell/comphy.h b/drivers/phy/marvell/comphy_core.h similarity index 96% rename from drivers/phy/marvell/comphy.h rename to drivers/phy/marvell/comphy_core.h index b588ae41f0..12ab921d24 100644 --- a/drivers/phy/marvell/comphy.h +++ b/drivers/phy/marvell/comphy_core.h @@ -3,11 +3,11 @@
- Copyright (C) 2015-2016 Marvell International Ltd.
*/
-#ifndef _COMPHY_H_ -#define _COMPHY_H_ +#ifndef _COMPHY_CORE_H_ +#define _COMPHY_CORE_H_
-#include <dt-bindings/comphy/comphy_data.h> #include <fdtdec.h> +#include <mvebu/comphy.h>
#if defined(DEBUG) #define debug_enter() printf("----> Enter %s\n", __func__); @@ -80,14 +80,6 @@ struct comphy_mux_data { struct comphy_mux_options mux_values[MAX_LANE_OPTIONS]; };
-struct comphy_map {
- u32 type;
- u32 speed;
- u32 invert;
- bool clk_src;
- bool end_point;
-};
- struct chip_serdes_phy_config { struct comphy_mux_data *mux_data; int (*ptr_comphy_chip_init)(struct chip_serdes_phy_config *,
@@ -183,5 +175,5 @@ void comphy_pcie_config_detect(u32 comphy_max_count, struct comphy_map *serdes_map); void comphy_pcie_unit_general_config(u32 pex_index);
-#endif /* _COMPHY_H_ */ +#endif /* _COMPHY_CORE_H_ */
diff --git a/drivers/phy/marvell/comphy_cp110.c b/drivers/phy/marvell/comphy_cp110.c index b0d5d5ca26..6a60da3df0 100644 --- a/drivers/phy/marvell/comphy_cp110.c +++ b/drivers/phy/marvell/comphy_cp110.c @@ -9,7 +9,7 @@ #include <asm/arch/cpu.h> #include <asm/arch/soc.h>
-#include "comphy.h" +#include "comphy_core.h" #include "comphy_hpipe.h" #include "sata.h" #include "utmi_phy.h" diff --git a/drivers/phy/marvell/comphy_mux.c b/drivers/phy/marvell/comphy_mux.c index 1f757d8e04..c67ba99762 100644 --- a/drivers/phy/marvell/comphy_mux.c +++ b/drivers/phy/marvell/comphy_mux.c @@ -6,7 +6,7 @@ #include <common.h> #include <asm/io.h>
-#include "comphy.h" +#include "comphy_core.h" #include "comphy_hpipe.h"
/* diff --git a/include/mvebu/comphy.h b/include/mvebu/comphy.h new file mode 100644 index 0000000000..cde7a022af --- /dev/null +++ b/include/mvebu/comphy.h @@ -0,0 +1,22 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/*
- Copyright (C) 2015-2016 Marvell International Ltd.
- */
+#ifndef _MVEBU_COMPHY_H_ +#define _MVEBU_COMPHY_H_
+#include <dt-bindings/comphy/comphy_data.h>
+struct comphy_map {
- u32 type;
- u32 speed;
- u32 invert;
- bool clk_src;
- bool end_point;
+};
+int comphy_update_map(struct comphy_map *serdes_map, int count);
+#endif /* _MVEBU_COMPHY_H_ */
Applied to u-boot-marvell/master
Thanks, Stefan

Add support for changing clock rate and parent clock for Armada 37xx peripheral clocks.
Only clocks which can be disabled (.can_gate is true) can have parent or rate changed.
This is needed so that Turris Mox can change SPI clock in device tree.
Signed-off-by: Marek Behun marek.behun@nic.cz --- drivers/clk/mvebu/armada-37xx-periph.c | 130 ++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c index 902a6cc9ef..b1a35968e1 100644 --- a/drivers/clk/mvebu/armada-37xx-periph.c +++ b/drivers/clk/mvebu/armada-37xx-periph.c @@ -224,11 +224,21 @@ static const struct clk_periph clks_sb[] = { { }, };
-static inline int get_mux(struct a37xx_periphclk *priv, int shift) +static int get_mux(struct a37xx_periphclk *priv, int shift) { return (readl(priv->reg + TBG_SEL) >> shift) & 3; }
+static void set_mux(struct a37xx_periphclk *priv, int shift, int val) +{ + u32 reg; + + reg = readl(priv->reg + TBG_SEL); + reg &= ~(3 << shift); + reg |= (val & 3) << shift; + writel(reg, priv->reg + TBG_SEL); +} + static ulong periph_clk_get_rate(struct a37xx_periphclk *priv, int id);
static ulong get_parent_rate(struct a37xx_periphclk *priv, int id) @@ -277,6 +287,17 @@ static ulong get_div(struct a37xx_periphclk *priv, return 0; }
+static void set_div_val(struct a37xx_periphclk *priv, + const struct clk_periph *clk, int idx, int val) +{ + u32 reg; + + reg = readl(priv->reg + clk->div_reg_off[idx]); + reg &= ~(clk->div_mask[idx] << clk->div_shift[idx]); + reg |= (val & clk->div_mask[idx]) << clk->div_shift[idx]; + writel(reg, priv->reg + clk->div_reg_off[idx]); +} + static ulong periph_clk_get_rate(struct a37xx_periphclk *priv, int id) { const struct clk_periph *clk = &priv->clks[id]; @@ -337,6 +358,111 @@ static int armada_37xx_periph_clk_disable(struct clk *clk) return periph_clk_enable(clk, 0); }
+#define diff(a, b) abs((long)(a) - (long)(b)) + +static ulong find_best_div(const struct clk_div_table *t0, + const struct clk_div_table *t1, ulong parent_rate, + ulong req_rate, int *v0, int *v1) +{ + const struct clk_div_table *i, *j; + ulong rate, best_rate = 0; + + for (i = t0; i && i->div; ++i) { + for (j = t1; j && j->div; ++j) { + rate = DIV_ROUND_UP(parent_rate, i->div * j->div); + + if (!best_rate || + diff(rate, req_rate) < diff(best_rate, req_rate)) { + best_rate = rate; + *v0 = i->val; + *v1 = j->val; + } + } + } + + return best_rate; +} + +static ulong armada_37xx_periph_clk_set_rate(struct clk *clk, ulong req_rate) +{ + struct a37xx_periphclk *priv = dev_get_priv(clk->dev); + const struct clk_periph *periph_clk = &priv->clks[clk->id]; + ulong rate, old_rate, parent_rate; + int div_val0 = 0, div_val1 = 0; + const struct clk_div_table *t1; + static const struct clk_div_table empty_table[2] = { + { 1, 0 }, + { 0, 0 } + }; + + if (clk->id > priv->count) + return -EINVAL; + + old_rate = periph_clk_get_rate(priv, clk->id); + if (old_rate == -EINVAL) + return -EINVAL; + + if (old_rate == req_rate) + return old_rate; + + if (!periph_clk->can_gate || !periph_clk->dividers) + return -ENOTSUPP; + + parent_rate = get_parent_rate(priv, clk->id); + if (parent_rate == -EINVAL) + return -EINVAL; + + t1 = empty_table; + if (periph_clk->dividers > 1) + t1 = periph_clk->div_table[1]; + + rate = find_best_div(periph_clk->div_table[0], t1, parent_rate, + req_rate, &div_val0, &div_val1); + + periph_clk_enable(clk, 0); + + set_div_val(priv, periph_clk, 0, div_val0); + if (periph_clk->dividers > 1) + set_div_val(priv, periph_clk, 1, div_val1); + + periph_clk_enable(clk, 1); + + return rate; +} + +static int armada_37xx_periph_clk_set_parent(struct clk *clk, + struct clk *parent) +{ + struct a37xx_periphclk *priv = dev_get_priv(clk->dev); + const struct clk_periph *periph_clk = &priv->clks[clk->id]; + struct clk check_parent; + int ret; + + /* We also check if parent is our TBG clock */ + if (clk->id > priv->count || parent->id >= MAX_TBG_PARENTS) + return -EINVAL; + + if (!periph_clk->can_mux || !periph_clk->can_gate) + return -ENOTSUPP; + + ret = clk_get_by_index(clk->dev, 0, &check_parent); + if (ret < 0) + return ret; + + if (parent->dev != check_parent.dev) + ret = -EINVAL; + + clk_free(&check_parent); + if (ret < 0) + return ret; + + periph_clk_enable(clk, 0); + set_mux(priv, periph_clk->mux_shift, parent->id); + periph_clk_enable(clk, 1); + + return 0; +} + #if defined(CONFIG_CMD_CLK) && defined(CONFIG_CLK_ARMADA_3720) static int armada_37xx_periph_clk_dump(struct udevice *dev) { @@ -473,6 +599,8 @@ static int armada_37xx_periph_clk_probe(struct udevice *dev)
static const struct clk_ops armada_37xx_periph_clk_ops = { .get_rate = armada_37xx_periph_clk_get_rate, + .set_rate = armada_37xx_periph_clk_set_rate, + .set_parent = armada_37xx_periph_clk_set_parent, .enable = armada_37xx_periph_clk_enable, .disable = armada_37xx_periph_clk_disable, };

On 17.08.2018 12:58, Marek Behún wrote:
Add support for changing clock rate and parent clock for Armada 37xx peripheral clocks.
Only clocks which can be disabled (.can_gate is true) can have parent or rate changed.
This is needed so that Turris Mox can change SPI clock in device tree.
Signed-off-by: Marek Behun marek.behun@nic.cz
drivers/clk/mvebu/armada-37xx-periph.c | 130 ++++++++++++++++++++++++++++++++- 1 file changed, 129 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/mvebu/armada-37xx-periph.c b/drivers/clk/mvebu/armada-37xx-periph.c index 902a6cc9ef..b1a35968e1 100644 --- a/drivers/clk/mvebu/armada-37xx-periph.c +++ b/drivers/clk/mvebu/armada-37xx-periph.c @@ -224,11 +224,21 @@ static const struct clk_periph clks_sb[] = { { }, };
-static inline int get_mux(struct a37xx_periphclk *priv, int shift) +static int get_mux(struct a37xx_periphclk *priv, int shift) { return (readl(priv->reg + TBG_SEL) >> shift) & 3; }
+static void set_mux(struct a37xx_periphclk *priv, int shift, int val) +{
- u32 reg;
- reg = readl(priv->reg + TBG_SEL);
- reg &= ~(3 << shift);
- reg |= (val & 3) << shift;
- writel(reg, priv->reg + TBG_SEL);
+}
static ulong periph_clk_get_rate(struct a37xx_periphclk *priv, int id);
static ulong get_parent_rate(struct a37xx_periphclk *priv, int id)
@@ -277,6 +287,17 @@ static ulong get_div(struct a37xx_periphclk *priv, return 0; }
+static void set_div_val(struct a37xx_periphclk *priv,
const struct clk_periph *clk, int idx, int val)
+{
- u32 reg;
- reg = readl(priv->reg + clk->div_reg_off[idx]);
- reg &= ~(clk->div_mask[idx] << clk->div_shift[idx]);
- reg |= (val & clk->div_mask[idx]) << clk->div_shift[idx];
- writel(reg, priv->reg + clk->div_reg_off[idx]);
+}
- static ulong periph_clk_get_rate(struct a37xx_periphclk *priv, int id) { const struct clk_periph *clk = &priv->clks[id];
@@ -337,6 +358,111 @@ static int armada_37xx_periph_clk_disable(struct clk *clk) return periph_clk_enable(clk, 0); }
+#define diff(a, b) abs((long)(a) - (long)(b))
+static ulong find_best_div(const struct clk_div_table *t0,
const struct clk_div_table *t1, ulong parent_rate,
ulong req_rate, int *v0, int *v1)
+{
- const struct clk_div_table *i, *j;
- ulong rate, best_rate = 0;
- for (i = t0; i && i->div; ++i) {
for (j = t1; j && j->div; ++j) {
rate = DIV_ROUND_UP(parent_rate, i->div * j->div);
if (!best_rate ||
diff(rate, req_rate) < diff(best_rate, req_rate)) {
best_rate = rate;
*v0 = i->val;
*v1 = j->val;
}
}
- }
- return best_rate;
+}
+static ulong armada_37xx_periph_clk_set_rate(struct clk *clk, ulong req_rate) +{
- struct a37xx_periphclk *priv = dev_get_priv(clk->dev);
- const struct clk_periph *periph_clk = &priv->clks[clk->id];
- ulong rate, old_rate, parent_rate;
- int div_val0 = 0, div_val1 = 0;
- const struct clk_div_table *t1;
- static const struct clk_div_table empty_table[2] = {
{ 1, 0 },
{ 0, 0 }
- };
- if (clk->id > priv->count)
return -EINVAL;
- old_rate = periph_clk_get_rate(priv, clk->id);
- if (old_rate == -EINVAL)
return -EINVAL;
- if (old_rate == req_rate)
return old_rate;
- if (!periph_clk->can_gate || !periph_clk->dividers)
return -ENOTSUPP;
- parent_rate = get_parent_rate(priv, clk->id);
- if (parent_rate == -EINVAL)
return -EINVAL;
- t1 = empty_table;
- if (periph_clk->dividers > 1)
t1 = periph_clk->div_table[1];
- rate = find_best_div(periph_clk->div_table[0], t1, parent_rate,
req_rate, &div_val0, &div_val1);
- periph_clk_enable(clk, 0);
- set_div_val(priv, periph_clk, 0, div_val0);
- if (periph_clk->dividers > 1)
set_div_val(priv, periph_clk, 1, div_val1);
- periph_clk_enable(clk, 1);
- return rate;
+}
+static int armada_37xx_periph_clk_set_parent(struct clk *clk,
struct clk *parent)
+{
- struct a37xx_periphclk *priv = dev_get_priv(clk->dev);
- const struct clk_periph *periph_clk = &priv->clks[clk->id];
- struct clk check_parent;
- int ret;
- /* We also check if parent is our TBG clock */
- if (clk->id > priv->count || parent->id >= MAX_TBG_PARENTS)
return -EINVAL;
- if (!periph_clk->can_mux || !periph_clk->can_gate)
return -ENOTSUPP;
- ret = clk_get_by_index(clk->dev, 0, &check_parent);
- if (ret < 0)
return ret;
- if (parent->dev != check_parent.dev)
ret = -EINVAL;
- clk_free(&check_parent);
- if (ret < 0)
return ret;
- periph_clk_enable(clk, 0);
- set_mux(priv, periph_clk->mux_shift, parent->id);
- periph_clk_enable(clk, 1);
- return 0;
+}
- #if defined(CONFIG_CMD_CLK) && defined(CONFIG_CLK_ARMADA_3720) static int armada_37xx_periph_clk_dump(struct udevice *dev) {
@@ -473,6 +599,8 @@ static int armada_37xx_periph_clk_probe(struct udevice *dev)
static const struct clk_ops armada_37xx_periph_clk_ops = { .get_rate = armada_37xx_periph_clk_get_rate,
- .set_rate = armada_37xx_periph_clk_set_rate,
- .set_parent = armada_37xx_periph_clk_set_parent, .enable = armada_37xx_periph_clk_enable, .disable = armada_37xx_periph_clk_disable, };
Applied to u-boot-marvell/master
Thanks, Stefan

The macro name CONFIG_WDT_ARMADA_3720 is called CONFIG_WDT_ARMADA_37XX instead. Fix this so that watchdog really is enabled in board_init.
Signed-off-by: Marek Behun marek.behun@nic.cz --- board/CZ.NIC/turris_mox/turris_mox.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 130d4c606d..b6a0ca4626 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -9,13 +9,13 @@ #include <spi.h> #include <linux/string.h>
-#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX #include <wdt.h> #endif
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX static struct udevice *watchdog_dev;
void watchdog_reset(void) @@ -41,7 +41,7 @@ int board_init(void) /* address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
-#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { printf("Cannot find Armada 3720 watchdog!\n"); } else {

On 17.08.2018 12:58, Marek Behún wrote:
The macro name CONFIG_WDT_ARMADA_3720 is called CONFIG_WDT_ARMADA_37XX instead. Fix this so that watchdog really is enabled in board_init.
Signed-off-by: Marek Behun marek.behun@nic.cz
board/CZ.NIC/turris_mox/turris_mox.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 130d4c606d..b6a0ca4626 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -9,13 +9,13 @@ #include <spi.h> #include <linux/string.h>
-#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX #include <wdt.h> #endif
DECLARE_GLOBAL_DATA_PTR;
-#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX static struct udevice *watchdog_dev;
void watchdog_reset(void) @@ -41,7 +41,7 @@ int board_init(void) /* address of boot parameters */ gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
-#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX if (uclass_get_device(UCLASS_WDT, 0, &watchdog_dev)) { printf("Cannot find Armada 3720 watchdog!\n"); } else {
Applied to u-boot-marvell/master
Thanks, Stefan

If PCIe Mox module is connected we want to have PCIe node enabled in U-Boot's device tree.
Signed-off-by: Marek Behun marek.behun@nic.cz --- arch/arm/dts/armada-3720-turris-mox.dts | 7 +++ board/CZ.NIC/turris_mox/turris_mox.c | 80 +++++++++++++++++++++++++++++++++ configs/turris_mox_defconfig | 1 + 3 files changed, 88 insertions(+)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index bef100afce..a817f20920 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -130,3 +130,10 @@ vbus-supply = <®_usb3_vbus>; status = "okay"; }; + +&pcie0 { + pinctrl-names = "default"; + pinctrl-0 = <&pcie_pins>; + reset-gpio = <&gpiosb 3 GPIO_ACTIVE_HIGH>; + status = "disabled"; +}; diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index b6a0ca4626..42f55b7915 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -4,17 +4,97 @@ */
#include <common.h> +#include <asm/io.h> #include <dm.h> #include <clk.h> #include <spi.h> #include <linux/string.h> +#include <linux/libfdt.h> +#include <fdt_support.h>
#ifdef CONFIG_WDT_ARMADA_37XX #include <wdt.h> #endif
+#define MAX_MOX_MODULES 10 + +#define MOX_MODULE_SFP 0x1 +#define MOX_MODULE_PCI 0x2 +#define MOX_MODULE_TOPAZ 0x3 +#define MOX_MODULE_PERIDOT 0x4 +#define MOX_MODULE_USB3 0x5 +#define MOX_MODULE_PASSPCI 0x6 + +#define ARMADA_37XX_NB_GPIO_SEL 0xd0013830 +#define ARMADA_37XX_SPI_CTRL 0xd0010600 +#define ARMADA_37XX_SPI_CFG 0xd0010604 +#define ARMADA_37XX_SPI_DOUT 0xd0010608 +#define ARMADA_37XX_SPI_DIN 0xd001060c + +#define PCIE_PATH "/soc/pcie@d0070000" + DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_OF_BOARD_FIXUP) +int board_fix_fdt(void *blob) +{ + u8 topology[MAX_MOX_MODULES]; + int i, size, node; + bool enable; + + /* + * SPI driver is not loaded in driver model yet, but we have to find out + * if pcie should be enabled in U-Boot's device tree. Therefore we have + * to read SPI by reading/writing SPI registers directly + */ + + writel(0x563fa, ARMADA_37XX_NB_GPIO_SEL); + writel(0x10df, ARMADA_37XX_SPI_CFG); + writel(0x2005b, ARMADA_37XX_SPI_CTRL); + + while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2)) + udelay(1); + + for (i = 0; i < MAX_MOX_MODULES; ++i) { + writel(0x0, ARMADA_37XX_SPI_DOUT); + + while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2)) + udelay(1); + + topology[i] = readl(ARMADA_37XX_SPI_DIN) & 0xff; + if (topology[i] == 0xff) + break; + } + + size = i; + + writel(0x5b, ARMADA_37XX_SPI_CTRL); + + if (size > 1 && (topology[1] == MOX_MODULE_PCI || + topology[1] == MOX_MODULE_USB3 || + topology[1] == MOX_MODULE_PASSPCI)) + enable = true; + else + enable = false; + + node = fdt_path_offset(blob, PCIE_PATH); + + if (node < 0) { + printf("Cannot find PCIe node in U-Boot's device tree!\n"); + return 0; + } + + if (fdt_setprop_string(blob, node, "status", + enable ? "okay" : "disabled") < 0) { + printf("Cannot %s PCIe in U-Boot's device tree!\n", + enable ? "enable" : "disable"); + return 0; + } + + return 0; +} +#endif + #ifdef CONFIG_WDT_ARMADA_37XX static struct udevice *watchdog_dev;
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index de9aedc764..47ab914ce9 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_ARCH_EARLY_INIT_R=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y

If PCIe Mox module is connected we want to have PCIe node enabled in U-Boot's device tree.
Signed-off-by: Marek Behun marek.behun@nic.cz --- arch/arm/dts/armada-3720-turris-mox.dts | 7 +++ board/CZ.NIC/turris_mox/turris_mox.c | 82 +++++++++++++++++++++++++++++++++ configs/turris_mox_defconfig | 1 + 3 files changed, 90 insertions(+)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index bef100afce..a817f20920 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -130,3 +130,10 @@ vbus-supply = <®_usb3_vbus>; status = "okay"; }; + +&pcie0 { + pinctrl-names = "default"; + pinctrl-0 = <&pcie_pins>; + reset-gpio = <&gpiosb 3 GPIO_ACTIVE_HIGH>; + status = "disabled"; +}; diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index b6a0ca4626..c4622a49c2 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -4,17 +4,99 @@ */
#include <common.h> +#include <asm/io.h> #include <dm.h> #include <clk.h> #include <spi.h> #include <linux/string.h> +#include <linux/libfdt.h> +#include <fdt_support.h>
#ifdef CONFIG_WDT_ARMADA_37XX #include <wdt.h> #endif
+#define MAX_MOX_MODULES 10 + +#define MOX_MODULE_SFP 0x1 +#define MOX_MODULE_PCI 0x2 +#define MOX_MODULE_TOPAZ 0x3 +#define MOX_MODULE_PERIDOT 0x4 +#define MOX_MODULE_USB3 0x5 +#define MOX_MODULE_PASSPCI 0x6 + +#define ARMADA_37XX_NB_GPIO_SEL 0xd0013830 +#define ARMADA_37XX_SPI_CTRL 0xd0010600 +#define ARMADA_37XX_SPI_CFG 0xd0010604 +#define ARMADA_37XX_SPI_DOUT 0xd0010608 +#define ARMADA_37XX_SPI_DIN 0xd001060c + +#define PCIE_PATH "/soc/pcie@d0070000" + DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_OF_BOARD_FIXUP) +int board_fix_fdt(void *blob) +{ + u8 topology[MAX_MOX_MODULES]; + int i, size, node; + bool enable; + + /* + * SPI driver is not loaded in driver model yet, but we have to find out + * if pcie should be enabled in U-Boot's device tree. Therefore we have + * to read SPI by reading/writing SPI registers directly + */ + + writel(0x563fa, ARMADA_37XX_NB_GPIO_SEL); + writel(0x10df, ARMADA_37XX_SPI_CFG); + writel(0x2005b, ARMADA_37XX_SPI_CTRL); + + while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2)) + udelay(1); + + for (i = 0; i < MAX_MOX_MODULES; ++i) { + writel(0x0, ARMADA_37XX_SPI_DOUT); + + while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2)) + udelay(1); + + topology[i] = readl(ARMADA_37XX_SPI_DIN) & 0xff; + if (topology[i] == 0xff) + break; + + topology[i] &= 0xf; + } + + size = i; + + writel(0x5b, ARMADA_37XX_SPI_CTRL); + + if (size > 1 && (topology[1] == MOX_MODULE_PCI || + topology[1] == MOX_MODULE_USB3 || + topology[1] == MOX_MODULE_PASSPCI)) + enable = true; + else + enable = false; + + node = fdt_path_offset(blob, PCIE_PATH); + + if (node < 0) { + printf("Cannot find PCIe node in U-Boot's device tree!\n"); + return 0; + } + + if (fdt_setprop_string(blob, node, "status", + enable ? "okay" : "disabled") < 0) { + printf("Cannot %s PCIe in U-Boot's device tree!\n", + enable ? "enable" : "disable"); + return 0; + } + + return 0; +} +#endif + #ifdef CONFIG_WDT_ARMADA_37XX static struct udevice *watchdog_dev;
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index de9aedc764..47ab914ce9 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_ARCH_EARLY_INIT_R=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y

On 21.08.2018 12:22, Marek Behún wrote:
If PCIe Mox module is connected we want to have PCIe node enabled in U-Boot's device tree.
Signed-off-by: Marek Behun marek.behun@nic.cz
arch/arm/dts/armada-3720-turris-mox.dts | 7 +++ board/CZ.NIC/turris_mox/turris_mox.c | 82 +++++++++++++++++++++++++++++++++ configs/turris_mox_defconfig | 1 + 3 files changed, 90 insertions(+)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index bef100afce..a817f20920 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -130,3 +130,10 @@ vbus-supply = <®_usb3_vbus>; status = "okay"; };
+&pcie0 {
- pinctrl-names = "default";
- pinctrl-0 = <&pcie_pins>;
- reset-gpio = <&gpiosb 3 GPIO_ACTIVE_HIGH>;
- status = "disabled";
+}; diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index b6a0ca4626..c4622a49c2 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -4,17 +4,99 @@ */
#include <common.h> +#include <asm/io.h> #include <dm.h> #include <clk.h> #include <spi.h> #include <linux/string.h> +#include <linux/libfdt.h> +#include <fdt_support.h>
#ifdef CONFIG_WDT_ARMADA_37XX #include <wdt.h> #endif
+#define MAX_MOX_MODULES 10
+#define MOX_MODULE_SFP 0x1 +#define MOX_MODULE_PCI 0x2 +#define MOX_MODULE_TOPAZ 0x3 +#define MOX_MODULE_PERIDOT 0x4 +#define MOX_MODULE_USB3 0x5 +#define MOX_MODULE_PASSPCI 0x6
+#define ARMADA_37XX_NB_GPIO_SEL 0xd0013830 +#define ARMADA_37XX_SPI_CTRL 0xd0010600 +#define ARMADA_37XX_SPI_CFG 0xd0010604 +#define ARMADA_37XX_SPI_DOUT 0xd0010608 +#define ARMADA_37XX_SPI_DIN 0xd001060c
+#define PCIE_PATH "/soc/pcie@d0070000"
- DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_OF_BOARD_FIXUP) +int board_fix_fdt(void *blob) +{
- u8 topology[MAX_MOX_MODULES];
- int i, size, node;
- bool enable;
- /*
* SPI driver is not loaded in driver model yet, but we have to find out
* if pcie should be enabled in U-Boot's device tree. Therefore we have
* to read SPI by reading/writing SPI registers directly
*/
- writel(0x563fa, ARMADA_37XX_NB_GPIO_SEL);
- writel(0x10df, ARMADA_37XX_SPI_CFG);
- writel(0x2005b, ARMADA_37XX_SPI_CTRL);
- while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2))
udelay(1);
- for (i = 0; i < MAX_MOX_MODULES; ++i) {
writel(0x0, ARMADA_37XX_SPI_DOUT);
while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2))
udelay(1);
topology[i] = readl(ARMADA_37XX_SPI_DIN) & 0xff;
if (topology[i] == 0xff)
break;
topology[i] &= 0xf;
- }
- size = i;
- writel(0x5b, ARMADA_37XX_SPI_CTRL);
- if (size > 1 && (topology[1] == MOX_MODULE_PCI ||
topology[1] == MOX_MODULE_USB3 ||
topology[1] == MOX_MODULE_PASSPCI))
enable = true;
- else
enable = false;
- node = fdt_path_offset(blob, PCIE_PATH);
- if (node < 0) {
printf("Cannot find PCIe node in U-Boot's device tree!\n");
return 0;
- }
- if (fdt_setprop_string(blob, node, "status",
enable ? "okay" : "disabled") < 0) {
printf("Cannot %s PCIe in U-Boot's device tree!\n",
enable ? "enable" : "disable");
return 0;
- }
- return 0;
+} +#endif
- #ifdef CONFIG_WDT_ARMADA_37XX static struct udevice *watchdog_dev;
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index de9aedc764..47ab914ce9 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_ARCH_EARLY_INIT_R=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y
Applied to u-boot-marvell/master
Thanks, Stefan

On 17.08.2018 12:58, Marek Behún wrote:
If PCIe Mox module is connected we want to have PCIe node enabled in U-Boot's device tree.
Signed-off-by: Marek Behun marek.behun@nic.cz
arch/arm/dts/armada-3720-turris-mox.dts | 7 +++ board/CZ.NIC/turris_mox/turris_mox.c | 80 +++++++++++++++++++++++++++++++++ configs/turris_mox_defconfig | 1 + 3 files changed, 88 insertions(+)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index bef100afce..a817f20920 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -130,3 +130,10 @@ vbus-supply = <®_usb3_vbus>; status = "okay"; };
+&pcie0 {
- pinctrl-names = "default";
- pinctrl-0 = <&pcie_pins>;
- reset-gpio = <&gpiosb 3 GPIO_ACTIVE_HIGH>;
- status = "disabled";
+}; diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index b6a0ca4626..42f55b7915 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -4,17 +4,97 @@ */
#include <common.h> +#include <asm/io.h> #include <dm.h> #include <clk.h> #include <spi.h> #include <linux/string.h> +#include <linux/libfdt.h> +#include <fdt_support.h>
#ifdef CONFIG_WDT_ARMADA_37XX #include <wdt.h> #endif
+#define MAX_MOX_MODULES 10
+#define MOX_MODULE_SFP 0x1 +#define MOX_MODULE_PCI 0x2 +#define MOX_MODULE_TOPAZ 0x3 +#define MOX_MODULE_PERIDOT 0x4 +#define MOX_MODULE_USB3 0x5 +#define MOX_MODULE_PASSPCI 0x6
+#define ARMADA_37XX_NB_GPIO_SEL 0xd0013830 +#define ARMADA_37XX_SPI_CTRL 0xd0010600 +#define ARMADA_37XX_SPI_CFG 0xd0010604 +#define ARMADA_37XX_SPI_DOUT 0xd0010608 +#define ARMADA_37XX_SPI_DIN 0xd001060c
+#define PCIE_PATH "/soc/pcie@d0070000"
- DECLARE_GLOBAL_DATA_PTR;
+#if defined(CONFIG_OF_BOARD_FIXUP) +int board_fix_fdt(void *blob) +{
- u8 topology[MAX_MOX_MODULES];
- int i, size, node;
- bool enable;
- /*
* SPI driver is not loaded in driver model yet, but we have to find out
* if pcie should be enabled in U-Boot's device tree. Therefore we have
* to read SPI by reading/writing SPI registers directly
*/
- writel(0x563fa, ARMADA_37XX_NB_GPIO_SEL);
- writel(0x10df, ARMADA_37XX_SPI_CFG);
- writel(0x2005b, ARMADA_37XX_SPI_CTRL);
- while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2))
udelay(1);
- for (i = 0; i < MAX_MOX_MODULES; ++i) {
writel(0x0, ARMADA_37XX_SPI_DOUT);
while (!(readl(ARMADA_37XX_SPI_CTRL) & 0x2))
udelay(1);
topology[i] = readl(ARMADA_37XX_SPI_DIN) & 0xff;
if (topology[i] == 0xff)
break;
- }
- size = i;
- writel(0x5b, ARMADA_37XX_SPI_CTRL);
- if (size > 1 && (topology[1] == MOX_MODULE_PCI ||
topology[1] == MOX_MODULE_USB3 ||
topology[1] == MOX_MODULE_PASSPCI))
enable = true;
- else
enable = false;
- node = fdt_path_offset(blob, PCIE_PATH);
- if (node < 0) {
printf("Cannot find PCIe node in U-Boot's device tree!\n");
return 0;
- }
- if (fdt_setprop_string(blob, node, "status",
enable ? "okay" : "disabled") < 0) {
printf("Cannot %s PCIe in U-Boot's device tree!\n",
enable ? "enable" : "disable");
return 0;
- }
- return 0;
+} +#endif
- #ifdef CONFIG_WDT_ARMADA_37XX static struct udevice *watchdog_dev;
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index de9aedc764..47ab914ce9 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -13,6 +13,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_CPUINFO is not set # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_ARCH_EARLY_INIT_R=y +CONFIG_OF_BOARD_FIXUP=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y
Applied to u-boot-marvell/master
Thanks, Stefan

Enable the pci-aardvark driver in defconfig for Turris Mox and also enable the pci command.
Signed-off-by: Marek Behun marek.behun@nic.cz --- configs/turris_mox_defconfig | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index 47ab914ce9..1dd6826dbc 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -18,6 +18,7 @@ CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y @@ -51,6 +52,10 @@ CONFIG_MVEBU_COMPHY_SUPPORT=y CONFIG_PINCTRL=y CONFIG_PINCTRL_ARMADA_37XX=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCI_AARDVARK=y +# CONFIG_PCI_PNP is not set # CONFIG_SPL_SERIAL_PRESENT is not set CONFIG_DEBUG_MVEBU_A3700_UART=y CONFIG_DEBUG_UART_SHIFT=2

On 17.08.2018 12:58, Marek Behún wrote:
Enable the pci-aardvark driver in defconfig for Turris Mox and also enable the pci command.
Signed-off-by: Marek Behun marek.behun@nic.cz
configs/turris_mox_defconfig | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index 47ab914ce9..1dd6826dbc 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -18,6 +18,7 @@ CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y +CONFIG_CMD_PCI=y CONFIG_CMD_SF=y CONFIG_CMD_SPI=y CONFIG_CMD_USB=y @@ -51,6 +52,10 @@ CONFIG_MVEBU_COMPHY_SUPPORT=y CONFIG_PINCTRL=y CONFIG_PINCTRL_ARMADA_37XX=y CONFIG_DM_REGULATOR_FIXED=y +CONFIG_PCI=y +CONFIG_DM_PCI=y +CONFIG_PCI_AARDVARK=y +# CONFIG_PCI_PNP is not set # CONFIG_SPL_SERIAL_PRESENT is not set CONFIG_DEBUG_MVEBU_A3700_UART=y CONFIG_DEBUG_UART_SHIFT=2
Applied to u-boot-marvell/master
Thanks, Stefan

Restructure the board initialization source. Remove the module_topology environment variable since it won't be needed.
Signed-off-by: Marek Behun marek.behun@nic.cz --- board/CZ.NIC/turris_mox/turris_mox.c | 153 ++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 47 deletions(-)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 42f55b7915..4a3e78c5d6 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -33,6 +33,12 @@
#define PCIE_PATH "/soc/pcie@d0070000"
+typedef enum { + MOX_UNKNOWN, + MOX_EMMC, + MOX_SD +} mox_version_t; + DECLARE_GLOBAL_DATA_PTR;
#if defined(CONFIG_OF_BOARD_FIXUP) @@ -133,17 +139,15 @@ int board_init(void) return 0; }
-int last_stage_init(void) +static int mox_do_spi(u8 *in, u8 *out, size_t size) { struct spi_slave *slave; struct udevice *dev; - u8 din[10], dout[10]; - int ret, i; - size_t len = 0; - char module_topology[128]; + int ret;
- ret = spi_get_bus_and_cs(0, 1, 20000000, SPI_CPHA, "spi_generic_drv", - "mox-modules@1", &dev, &slave); + ret = spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL, + "spi_generic_drv", "moxtet@1", &dev, + &slave); if (ret) goto fail;
@@ -151,57 +155,112 @@ int last_stage_init(void) if (ret) goto fail_free;
- memset(din, 0, 10); - memset(dout, 0, 10); + ret = spi_xfer(slave, size * 8, out, in, SPI_XFER_ONCE); + + spi_release_bus(slave); +fail_free: + spi_free_slave(slave); +fail: + return ret; +}
- ret = spi_xfer(slave, 80, dout, din, SPI_XFER_ONCE); +static int mox_get_topology(const u8 **ptopology, int *psize, + mox_version_t *pversion) +{ + static mox_version_t mox_version; + static u8 topology[MAX_MOX_MODULES - 1]; + static int size; + u8 din[MAX_MOX_MODULES], dout[MAX_MOX_MODULES]; + int ret, i; + + if (size) { + if (ptopology) + *ptopology = topology; + if (psize) + *psize = size; + if (pversion) + *pversion = mox_version; + return 0; + } + + memset(din, 0, MAX_MOX_MODULES); + memset(dout, 0, MAX_MOX_MODULES); + + ret = mox_do_spi(din, dout, MAX_MOX_MODULES); if (ret) - goto fail_release; + return ret; + + switch (din[0]) { + case 0x00: + mox_version = MOX_EMMC; + break; + case 0x10: + mox_version = MOX_SD; + break; + case 0xff: + mox_version = MOX_UNKNOWN; + break; + default: + return -ENODEV; + } + + for (i = 1; i < MAX_MOX_MODULES && din[i] != 0xff; ++i) + topology[i - 1] = din[i] & 0xf; + size = i - 1; + + if (ptopology) + *ptopology = topology; + if (psize) + *psize = size; + if (pversion) + *pversion = mox_version; + + return 0; +}
- if (din[0] != 0x00 && din[0] != 0xff) - goto fail_release; +int last_stage_init(void) +{ + int ret, i; + const u8 *topology; + int module_count; + mox_version_t version; + + ret = mox_get_topology(&topology, &module_count, &version); + if (ret) { + printf("Cannot read module topology!\n"); + return 0; + }
+ printf("Found Turris Mox %s version\n", version == MOX_SD ? "SD" : + version == MOX_EMMC ? "eMMC" : + "unknown"); printf("Module Topology:\n"); - for (i = 1; i < 10 && din[i] != 0xff; ++i) { - u8 mid = din[i] & 0xf; - size_t mlen; - const char *mname = ""; - - switch (mid) { - case 0x1: - mname = "sfp-"; - printf("% 4i: SFP Module\n", i); + for (i = 0; i < module_count; ++i) { + switch (topology[i]) { + case MOX_MODULE_SFP: + printf("% 4i: SFP Module\n", i + 1); + break; + case MOX_MODULE_PCI: + printf("% 4i: Mini-PCIe Module\n", i + 1); + break; + case MOX_MODULE_TOPAZ: + printf("% 4i: Topaz Switch Module (4-port)\n", i + 1); break; - case 0x2: - mname = "pci-"; - printf("% 4i: Mini-PCIe Module\n", i); + case MOX_MODULE_PERIDOT: + printf("% 4i: Peridot Switch Module (8-port)\n", i + 1); break; - case 0x3: - mname = "topaz-"; - printf("% 4i: Topaz Switch Module\n", i); + case MOX_MODULE_USB3: + printf("% 4i: USB 3.0 Module (4 ports)\n", i + 1); + break; + case MOX_MODULE_PASSPCI: + printf("% 4i: Passthrough Mini-PCIe Module\n", i + 1); break; default: - printf("% 4i: unknown (ID %i)\n", i, mid); - } - - mlen = strlen(mname); - if (len + mlen < sizeof(module_topology)) { - strcpy(module_topology + len, mname); - len += mlen; + printf("% 4i: unknown (ID %i)\n", i + 1, topology[i]); } } - printf("\n"); - - module_topology[len > 0 ? len - 1 : 0] = '\0';
- env_set("module_topology", module_topology); + printf("\n");
-fail_release: - spi_release_bus(slave); -fail_free: - spi_free_slave(slave); -fail: - if (ret) - printf("Cannot read module topology!\n"); - return ret; + return 0; }

On 17.08.2018 12:58, Marek Behún wrote:
Restructure the board initialization source. Remove the module_topology environment variable since it won't be needed.
Signed-off-by: Marek Behun marek.behun@nic.cz
board/CZ.NIC/turris_mox/turris_mox.c | 153 ++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 47 deletions(-)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 42f55b7915..4a3e78c5d6 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -33,6 +33,12 @@
#define PCIE_PATH "/soc/pcie@d0070000"
+typedef enum {
- MOX_UNKNOWN,
- MOX_EMMC,
- MOX_SD
+} mox_version_t;
DECLARE_GLOBAL_DATA_PTR;
#if defined(CONFIG_OF_BOARD_FIXUP)
@@ -133,17 +139,15 @@ int board_init(void) return 0; }
-int last_stage_init(void) +static int mox_do_spi(u8 *in, u8 *out, size_t size) { struct spi_slave *slave; struct udevice *dev;
- u8 din[10], dout[10];
- int ret, i;
- size_t len = 0;
- char module_topology[128];
- int ret;
- ret = spi_get_bus_and_cs(0, 1, 20000000, SPI_CPHA, "spi_generic_drv",
"mox-modules@1", &dev, &slave);
- ret = spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL,
"spi_generic_drv", "moxtet@1", &dev,
if (ret) goto fail;&slave);
@@ -151,57 +155,112 @@ int last_stage_init(void) if (ret) goto fail_free;
- memset(din, 0, 10);
- memset(dout, 0, 10);
- ret = spi_xfer(slave, size * 8, out, in, SPI_XFER_ONCE);
- spi_release_bus(slave);
+fail_free:
- spi_free_slave(slave);
+fail:
- return ret;
+}
- ret = spi_xfer(slave, 80, dout, din, SPI_XFER_ONCE);
+static int mox_get_topology(const u8 **ptopology, int *psize,
mox_version_t *pversion)
+{
- static mox_version_t mox_version;
- static u8 topology[MAX_MOX_MODULES - 1];
- static int size;
- u8 din[MAX_MOX_MODULES], dout[MAX_MOX_MODULES];
- int ret, i;
- if (size) {
if (ptopology)
*ptopology = topology;
if (psize)
*psize = size;
if (pversion)
*pversion = mox_version;
return 0;
- }
- memset(din, 0, MAX_MOX_MODULES);
- memset(dout, 0, MAX_MOX_MODULES);
- ret = mox_do_spi(din, dout, MAX_MOX_MODULES); if (ret)
goto fail_release;
return ret;
- switch (din[0]) {
- case 0x00:
mox_version = MOX_EMMC;
break;
- case 0x10:
mox_version = MOX_SD;
break;
- case 0xff:
mox_version = MOX_UNKNOWN;
break;
- default:
return -ENODEV;
- }
- for (i = 1; i < MAX_MOX_MODULES && din[i] != 0xff; ++i)
topology[i - 1] = din[i] & 0xf;
- size = i - 1;
- if (ptopology)
*ptopology = topology;
- if (psize)
*psize = size;
- if (pversion)
*pversion = mox_version;
- return 0;
+}
- if (din[0] != 0x00 && din[0] != 0xff)
goto fail_release;
+int last_stage_init(void) +{
int ret, i;
const u8 *topology;
int module_count;
mox_version_t version;
ret = mox_get_topology(&topology, &module_count, &version);
if (ret) {
printf("Cannot read module topology!\n");
return 0;
}
printf("Found Turris Mox %s version\n", version == MOX_SD ? "SD" :
version == MOX_EMMC ? "eMMC" :
"unknown");
printf("Module Topology:\n");
- for (i = 1; i < 10 && din[i] != 0xff; ++i) {
u8 mid = din[i] & 0xf;
size_t mlen;
const char *mname = "";
switch (mid) {
case 0x1:
mname = "sfp-";
printf("% 4i: SFP Module\n", i);
- for (i = 0; i < module_count; ++i) {
switch (topology[i]) {
case MOX_MODULE_SFP:
printf("% 4i: SFP Module\n", i + 1);
break;
case MOX_MODULE_PCI:
printf("% 4i: Mini-PCIe Module\n", i + 1);
break;
case MOX_MODULE_TOPAZ:
printf("% 4i: Topaz Switch Module (4-port)\n", i + 1); break;
case 0x2:
mname = "pci-";
printf("% 4i: Mini-PCIe Module\n", i);
case MOX_MODULE_PERIDOT:
printf("% 4i: Peridot Switch Module (8-port)\n", i + 1); break;
case 0x3:
mname = "topaz-";
printf("% 4i: Topaz Switch Module\n", i);
case MOX_MODULE_USB3:
printf("% 4i: USB 3.0 Module (4 ports)\n", i + 1);
break;
case MOX_MODULE_PASSPCI:
default:printf("% 4i: Passthrough Mini-PCIe Module\n", i + 1); break;
printf("% 4i: unknown (ID %i)\n", i, mid);
}
mlen = strlen(mname);
if (len + mlen < sizeof(module_topology)) {
strcpy(module_topology + len, mname);
len += mlen;
} }printf("% 4i: unknown (ID %i)\n", i + 1, topology[i]);
printf("\n");
module_topology[len > 0 ? len - 1 : 0] = '\0';
env_set("module_topology", module_topology);
- printf("\n");
-fail_release:
- spi_release_bus(slave);
-fail_free:
- spi_free_slave(slave);
-fail:
- if (ret)
printf("Cannot read module topology!\n");
- return ret;
- return 0; }
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Thanks, Stefan

Hi Marek,
On 19.09.18 14:22, Stefan Roese wrote:
On 17.08.2018 12:58, Marek Behún wrote:
Restructure the board initialization source. Remove the module_topology environment variable since it won't be needed.
Signed-off-by: Marek Behun marek.behun@nic.cz
board/CZ.NIC/turris_mox/turris_mox.c | 153 ++++++++++++++++++++++++----------- 1 file changed, 106 insertions(+), 47 deletions(-)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 42f55b7915..4a3e78c5d6 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -33,6 +33,12 @@
#define PCIE_PATH "/soc/pcie@d0070000"
+typedef enum {
- MOX_UNKNOWN,
- MOX_EMMC,
- MOX_SD
+} mox_version_t;
DECLARE_GLOBAL_DATA_PTR;
#if defined(CONFIG_OF_BOARD_FIXUP)
@@ -133,17 +139,15 @@ int board_init(void) return 0; }
-int last_stage_init(void) +static int mox_do_spi(u8 *in, u8 *out, size_t size) { struct spi_slave *slave; struct udevice *dev;
- u8 din[10], dout[10];
- int ret, i;
- size_t len = 0;
- char module_topology[128];
- int ret;
- ret = spi_get_bus_and_cs(0, 1, 20000000, SPI_CPHA, "spi_generic_drv",
"mox-modules@1", &dev, &slave);
- ret = spi_get_bus_and_cs(0, 1, 1000000, SPI_CPHA | SPI_CPOL,
"spi_generic_drv", "moxtet@1", &dev,
if (ret) goto fail;&slave);
@@ -151,57 +155,112 @@ int last_stage_init(void) if (ret) goto fail_free;
- memset(din, 0, 10);
- memset(dout, 0, 10);
- ret = spi_xfer(slave, size * 8, out, in, SPI_XFER_ONCE);
- spi_release_bus(slave);
+fail_free:
- spi_free_slave(slave);
+fail:
- return ret;
+}
- ret = spi_xfer(slave, 80, dout, din, SPI_XFER_ONCE);
+static int mox_get_topology(const u8 **ptopology, int *psize,
mox_version_t *pversion)
+{
- static mox_version_t mox_version;
- static u8 topology[MAX_MOX_MODULES - 1];
- static int size;
- u8 din[MAX_MOX_MODULES], dout[MAX_MOX_MODULES];
- int ret, i;
- if (size) {
if (ptopology)
*ptopology = topology;
if (psize)
*psize = size;
if (pversion)
*pversion = mox_version;
return 0;
- }
- memset(din, 0, MAX_MOX_MODULES);
- memset(dout, 0, MAX_MOX_MODULES);
- ret = mox_do_spi(din, dout, MAX_MOX_MODULES); if (ret)
goto fail_release;
return ret;
- switch (din[0]) {
- case 0x00:
mox_version = MOX_EMMC;
break;
- case 0x10:
mox_version = MOX_SD;
break;
- case 0xff:
mox_version = MOX_UNKNOWN;
break;
- default:
return -ENODEV;
- }
- for (i = 1; i < MAX_MOX_MODULES && din[i] != 0xff; ++i)
topology[i - 1] = din[i] & 0xf;
- size = i - 1;
- if (ptopology)
*ptopology = topology;
- if (psize)
*psize = size;
- if (pversion)
*pversion = mox_version;
- return 0;
+}
- if (din[0] != 0x00 && din[0] != 0xff)
goto fail_release;
+int last_stage_init(void) +{
int ret, i;
const u8 *topology;
int module_count;
mox_version_t version;
ret = mox_get_topology(&topology, &module_count, &version);
if (ret) {
printf("Cannot read module topology!\n");
return 0;
}
printf("Found Turris Mox %s version\n", version == MOX_SD ? "SD" :
version == MOX_EMMC ? "eMMC" :
"unknown");
printf("Module Topology:\n");
- for (i = 1; i < 10 && din[i] != 0xff; ++i) {
u8 mid = din[i] & 0xf;
size_t mlen;
const char *mname = "";
switch (mid) {
case 0x1:
mname = "sfp-";
printf("% 4i: SFP Module\n", i);
- for (i = 0; i < module_count; ++i) {
switch (topology[i]) {
case MOX_MODULE_SFP:
printf("% 4i: SFP Module\n", i + 1);
break;
case MOX_MODULE_PCI:
printf("% 4i: Mini-PCIe Module\n", i + 1);
break;
case MOX_MODULE_TOPAZ:
printf("% 4i: Topaz Switch Module (4-port)\n", i + 1); break;
case 0x2:
mname = "pci-";
printf("% 4i: Mini-PCIe Module\n", i);
case MOX_MODULE_PERIDOT:
printf("% 4i: Peridot Switch Module (8-port)\n", i + 1); break;
case 0x3:
mname = "topaz-";
printf("% 4i: Topaz Switch Module\n", i);
case MOX_MODULE_USB3:
printf("% 4i: USB 3.0 Module (4 ports)\n", i + 1);
break;
case MOX_MODULE_PASSPCI:
printf("% 4i: Passthrough Mini-PCIe Module\n", i + 1); break; default:
printf("% 4i: unknown (ID %i)\n", i, mid);
}
mlen = strlen(mname);
if (len + mlen < sizeof(module_topology)) {
strcpy(module_topology + len, mname);
len += mlen;
}printf("% 4i: unknown (ID %i)\n", i + 1, topology[i]); }
printf("\n");
module_topology[len > 0 ? len - 1 : 0] = '\0';
env_set("module_topology", module_topology);
- printf("\n");
-fail_release:
- spi_release_bus(slave);
-fail_free:
- spi_free_slave(slave);
-fail:
- if (ret)
printf("Cannot read module topology!\n");
- return ret;
- return 0; }
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Any updates on this? Please rebase the still missing patches from this series on top of latest mainline.
Thanks, Stefan

Any updates on this? Please rebase the still missing patches from this series on top of latest mainline.
Thanks, Stefan
Hi Stefan, I am (almost regularly) rebasing new patches on top of mainline in this repository https://gitlab.labs.nic.cz/turris/mox-u-boot I did not sent the patches yet because I don't know if my model of kernel devicetree patching will be accepter in kernel. That is: I want to push a complete device-tree for Mox with nodes for all modules to kernel, but with nodes for different modules disabled. The code in u-boot shall then enable the nodes for devices which are enumerated in u-boot. I don't yet know if such a device-tree will be accepted in kernel though.
Marek

Hi Marek,
On 20.11.18 12:24, Marek Behun wrote:
Any updates on this? Please rebase the still missing patches from this series on top of latest mainline.
Thanks, Stefan
Hi Stefan, I am (almost regularly) rebasing new patches on top of mainline in this repository https://gitlab.labs.nic.cz/turris/mox-u-boot I did not sent the patches yet because I don't know if my model of kernel devicetree patching will be accepter in kernel. That is: I want to push a complete device-tree for Mox with nodes for all modules to kernel, but with nodes for different modules disabled. The code in u-boot shall then enable the nodes for devices which are enumerated in u-boot. I don't yet know if such a device-tree will be accepted in kernel though.
That's a perfect understandable reasoning and makes sense. So its perhaps best if we remove the pending patches from the patchwork queue for now. And you will submit fresh patches, once such a decision has been made.
Okay?
Thanks, Stefan

On Tue, 20 Nov 2018 12:27:48 +0100 Stefan Roese sr@denx.de wrote:
Hi Marek,
On 20.11.18 12:24, Marek Behun wrote:
Any updates on this? Please rebase the still missing patches from this series on top of latest mainline.
Thanks, Stefan
Hi Stefan, I am (almost regularly) rebasing new patches on top of mainline in this repository https://gitlab.labs.nic.cz/turris/mox-u-boot I did not sent the patches yet because I don't know if my model of kernel devicetree patching will be accepter in kernel. That is: I want to push a complete device-tree for Mox with nodes for all modules to kernel, but with nodes for different modules disabled. The code in u-boot shall then enable the nodes for devices which are enumerated in u-boot. I don't yet know if such a device-tree will be accepted in kernel though.
That's a perfect understandable reasoning and makes sense. So its perhaps best if we remove the pending patches from the patchwork queue for now. And you will submit fresh patches, once such a decision has been made.
Okay?
Hi, I can send patches which won't be affected by this, though, like the one that fixes A3720 watchdog implementation to be kernel compliant. I am going to rebase and send them, ok? Marek
Thanks, Stefan

On 20.11.18 12:40, Marek Behun wrote:
On Tue, 20 Nov 2018 12:27:48 +0100 Stefan Roese sr@denx.de wrote:
Hi Marek,
On 20.11.18 12:24, Marek Behun wrote:
Any updates on this? Please rebase the still missing patches from this series on top of latest mainline.
Thanks, Stefan
Hi Stefan, I am (almost regularly) rebasing new patches on top of mainline in this repository https://gitlab.labs.nic.cz/turris/mox-u-boot I did not sent the patches yet because I don't know if my model of kernel devicetree patching will be accepter in kernel. That is: I want to push a complete device-tree for Mox with nodes for all modules to kernel, but with nodes for different modules disabled. The code in u-boot shall then enable the nodes for devices which are enumerated in u-boot. I don't yet know if such a device-tree will be accepted in kernel though.
That's a perfect understandable reasoning and makes sense. So its perhaps best if we remove the pending patches from the patchwork queue for now. And you will submit fresh patches, once such a decision has been made.
Okay?
Hi, I can send patches which won't be affected by this, though, like the one that fixes A3720 watchdog implementation to be kernel compliant. I am going to rebase and send them, ok?
Sure, go ahead.
Thanks, Stefan

When SFP module is connected directly to CPU module we want the SGMII lane speed at 1.25 Gbps.
Signed-off-by: Marek Behun marek.behun@nic.cz --- board/CZ.NIC/turris_mox/turris_mox.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 4a3e78c5d6..224179434b 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -8,6 +8,7 @@ #include <dm.h> #include <clk.h> #include <spi.h> +#include <mvebu/comphy.h> #include <linux/string.h> #include <linux/libfdt.h> #include <fdt_support.h> @@ -218,6 +219,38 @@ static int mox_get_topology(const u8 **ptopology, int *psize, return 0; }
+int comphy_update_map(struct comphy_map *serdes_map, int count) +{ + int ret, i, size, sfpindex = -1, swindex = -1; + const u8 *topology; + + ret = mox_get_topology(&topology, &size, NULL); + if (ret) + return ret; + + for (i = 0; i < size; ++i) { + if (topology[i] == MOX_MODULE_SFP && sfpindex == -1) + sfpindex = i; + else if ((topology[i] == MOX_MODULE_TOPAZ || + topology[i] == MOX_MODULE_PERIDOT) && + swindex == -1) + swindex = i; + } + + if (sfpindex >= 0 && swindex >= 0) { + if (sfpindex < swindex) + serdes_map[0].speed = PHY_SPEED_1_25G; + else + serdes_map[0].speed = PHY_SPEED_3_125G; + } else if (sfpindex >= 0) { + serdes_map[0].speed = PHY_SPEED_1_25G; + } else if (swindex >= 0) { + serdes_map[0].speed = PHY_SPEED_3_125G; + } + + return 0; +} + int last_stage_init(void) { int ret, i;

On 17.08.2018 12:58, Marek Behún wrote:
When SFP module is connected directly to CPU module we want the SGMII lane speed at 1.25 Gbps.
Signed-off-by: Marek Behun marek.behun@nic.cz
board/CZ.NIC/turris_mox/turris_mox.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 4a3e78c5d6..224179434b 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -8,6 +8,7 @@ #include <dm.h> #include <clk.h> #include <spi.h> +#include <mvebu/comphy.h> #include <linux/string.h> #include <linux/libfdt.h> #include <fdt_support.h> @@ -218,6 +219,38 @@ static int mox_get_topology(const u8 **ptopology, int *psize, return 0; }
+int comphy_update_map(struct comphy_map *serdes_map, int count) +{
- int ret, i, size, sfpindex = -1, swindex = -1;
- const u8 *topology;
- ret = mox_get_topology(&topology, &size, NULL);
- if (ret)
return ret;
- for (i = 0; i < size; ++i) {
if (topology[i] == MOX_MODULE_SFP && sfpindex == -1)
sfpindex = i;
else if ((topology[i] == MOX_MODULE_TOPAZ ||
topology[i] == MOX_MODULE_PERIDOT) &&
swindex == -1)
swindex = i;
- }
- if (sfpindex >= 0 && swindex >= 0) {
if (sfpindex < swindex)
serdes_map[0].speed = PHY_SPEED_1_25G;
else
serdes_map[0].speed = PHY_SPEED_3_125G;
- } else if (sfpindex >= 0) {
serdes_map[0].speed = PHY_SPEED_1_25G;
- } else if (swindex >= 0) {
serdes_map[0].speed = PHY_SPEED_3_125G;
- }
- return 0;
+}
- int last_stage_init(void) { int ret, i;
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Thanks, Stefan

Check if Mox modules are connected in supported mode, then configure the MDIO addresses of switch modules.
Signed-off-by: Marek Behun marek.behun@nic.cz --- arch/arm/dts/armada-3720-turris-mox.dts | 11 ++ board/CZ.NIC/turris_mox/turris_mox.c | 235 +++++++++++++++++++++++++++++++- 2 files changed, 245 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index a817f20920..05904387d2 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -114,6 +114,17 @@ spi-max-frequency = <20000000>; m25p,fast-read; }; + + moxtet@1 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "cznic,moxtet"; + reg = <1>; + devrst-gpio = <&gpiosb 2 GPIO_ACTIVE_LOW>; + spi-max-frequency = <1000000>; + spi-cpol; + spi-cpha; + }; };
&uart0 { diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 224179434b..21a3e63864 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -4,11 +4,13 @@ */
#include <common.h> +#include <asm/gpio.h> #include <asm/io.h> #include <dm.h> #include <clk.h> #include <spi.h> #include <mvebu/comphy.h> +#include <miiphy.h> #include <linux/string.h> #include <linux/libfdt.h> #include <fdt_support.h> @@ -251,12 +253,131 @@ int comphy_update_map(struct comphy_map *serdes_map, int count) return 0; }
+#define SW_SMI_CMD_R(d, r) (0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) +#define SW_SMI_CMD_W(d, r) (0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) + +static int sw_multi_read(struct mii_dev *bus, int sw, int dev, int reg) +{ + bus->write(bus, sw, 0, 0, SW_SMI_CMD_R(dev, reg)); + mdelay(5); + return bus->read(bus, sw, 0, 1); +} + +static void sw_multi_write(struct mii_dev *bus, int sw, int dev, int reg, + u16 val) +{ + bus->write(bus, sw, 0, 1, val); + bus->write(bus, sw, 0, 0, SW_SMI_CMD_W(dev, reg)); + mdelay(5); +} + +static int sw_scratch_read(struct mii_dev *bus, int sw, int reg) +{ + sw_multi_write(bus, sw, 0x1c, 0x1a, (reg & 0x7f) << 8); + return sw_multi_read(bus, sw, 0x1c, 0x1a) & 0xff; +} + +static void sw_led_write(struct mii_dev *bus, int sw, int port, int reg, + u16 val) +{ + sw_multi_write(bus, sw, port, 0x16, 0x8000 | ((reg & 7) << 12) + | (val & 0x7ff)); +} + +static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz) +{ + int i, p; + struct { + int port; + u16 val; + int wait; + } regs[] = { + { 2, 0xef, 1 }, { 2, 0xfe, 1 }, { 2, 0x33, 0 }, + { 4, 0xef, 1 }, { 4, 0xfe, 1 }, { 4, 0x33, 0 }, + { 3, 0xfe, 1 }, { 3, 0xef, 1 }, { 3, 0x33, 0 }, + { 1, 0xfe, 1 }, { 1, 0xef, 1 }, { 1, 0x33, 0 } + }; + + for (i = 0; i < 12; ++i) { + for (p = 0; p < peridot; ++p) { + sw_led_write(bus, 0x10 + p, regs[i].port, 0, + regs[i].val); + sw_led_write(bus, 0x10 + p, regs[i].port + 4, 0, + regs[i].val); + } + if (topaz) { + sw_led_write(bus, 0x2, 0x10 + regs[i].port, 0, + regs[i].val); + } + + if (regs[i].wait) + mdelay(75); + } +} + +static void check_switch_address(struct mii_dev *bus, int addr) +{ + if (sw_scratch_read(bus, addr, 0x70) >> 3 != addr) + printf("Check of switch MDIO address failed for 0x%02x\n", + addr); +} + +static int sfp, pci, topaz, peridot, usb, passpci; +static int sfp_pos, peridot_pos[3]; +static int module_count; + +static int configure_peridots(void) +{ + int node, i, ret; + struct gpio_desc gpio = {}; + u8 dout[MAX_MOX_MODULES]; + + node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "cznic,moxtet"); + if (node < 0) { + printf("Cannot find Moxtet bus device node!\n"); + return -1; + } + + gpio_request_by_name_nodev(offset_to_ofnode(node), "devrst-gpio", 0, + &gpio, GPIOD_IS_OUT); + + if (!dm_gpio_is_valid(&gpio)) { + printf("Cannot find reset GPIO for Moxtet bus!\n"); + return -1; + } + + memset(dout, 0, MAX_MOX_MODULES); + + /* set addresses of Peridot modules */ + for (i = 0; i < peridot; ++i) + dout[module_count - peridot_pos[i]] = (~i) & 3; + + /* + * if there is a SFP module connected to the last Peridot module, set + * the P10_SMODE to 1 for the Peridot module + */ + if (sfp) + dout[module_count - peridot_pos[i - 1]] |= 1 << 3; + + dm_gpio_set_value(&gpio, 1); + mdelay(10); + + ret = mox_do_spi(NULL, dout, module_count + 1); + + mdelay(10); + dm_gpio_set_value(&gpio, 0); + + mdelay(50); + + return ret; +} + int last_stage_init(void) { int ret, i; const u8 *topology; - int module_count; mox_version_t version; + struct mii_dev *bus;
ret = mox_get_topology(&topology, &module_count, &version); if (ret) { @@ -293,6 +414,118 @@ int last_stage_init(void) } }
+ /* now check if modules are connected in supported mode */ + + for (i = 0; i < module_count; ++i) { + switch (topology[i]) { + case MOX_MODULE_SFP: + if (sfp) { + printf("Error: Only one SFP module is " + "supported!\n"); + } else if (topaz) { + printf("Error: SFP module cannot be connected " + "after Topaz Switch module!\n"); + } else { + sfp_pos = i; + ++sfp; + } + break; + case MOX_MODULE_PCI: + if (pci) { + printf("Error: Only one Mini-PCIe module is " + "supported!\n"); + } else if (usb) { + printf("Error: Mini-PCIe module cannot come " + "after USB 3.0 module!\n"); + } else if (i && (i != 1 || !passpci)) { + printf("Error: Mini-PCIe module should be the " + "first connected module or come right " + "after Passthrough Mini-PCIe module!\n"); + } else { + ++pci; + } + break; + case MOX_MODULE_TOPAZ: + if (topaz) { + printf("Error: Only one Topaz module is " + "supported!\n"); + } else if (peridot >= 3) { + printf("Error: At most two Peridot modules " + "can come before Topaz module!\n"); + } else { + ++topaz; + } + break; + case MOX_MODULE_PERIDOT: + if (sfp || topaz) { + printf("Error: Peridot module must come before " + "SFP or Topaz module!\n"); + } else if (peridot >= 3) { + printf("Error: At most three Peridot modules " + "are supported!\n"); + } else { + peridot_pos[peridot] = i; + ++peridot; + } + break; + case MOX_MODULE_USB3: + if (pci) { + printf("Error: USB 3.0 module cannot come " + "after Mini-PCIe module!\n"); + } else if (usb) { + printf("Error: Only one USB 3.0 module is " + "supported!\n"); + } else if (i && (i != 1 || !passpci)) { + printf("Error: USB 3.0 module should be the " + "first connected module or come right " + "after Passthrough Mini-PCIe module!\n"); + } else { + ++usb; + } + break; + case MOX_MODULE_PASSPCI: + if (passpci) { + printf("Error: Only one Passthrough Mini-PCIe " + "module is supported!\n"); + } else if (i != 0) { + printf("Error: Passthrough Mini-PCIe module " + "should be the first connected " + "module!\n"); + } else { + ++passpci; + } + } + } + + /* now configure modules */ + + if (peridot > 0) { + if (configure_peridots() < 0) { + printf("Cannot configure Peridot modules!\n"); + peridot = 0; + } + } + + if (peridot || topaz) { + /* + * now check if the addresses are set by reading Scratch & Misc + * register 0x70 of Peridot (and potentially Topaz) modules + */ + + bus = miiphy_get_dev_by_name("neta@30000"); + if (!bus) { + printf("Cannot get MDIO bus device!\n"); + } else { + for (i = 0; i < peridot; ++i) + check_switch_address(bus, 0x10 + i); + + if (topaz) + check_switch_address(bus, 0x2); + + sw_blink_leds(bus, peridot, topaz); + } + } + printf("\n");
return 0;

On 17.08.2018 12:58, Marek Behún wrote:
Check if Mox modules are connected in supported mode, then configure the MDIO addresses of switch modules.
Signed-off-by: Marek Behun marek.behun@nic.cz
arch/arm/dts/armada-3720-turris-mox.dts | 11 ++ board/CZ.NIC/turris_mox/turris_mox.c | 235 +++++++++++++++++++++++++++++++- 2 files changed, 245 insertions(+), 1 deletion(-)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index a817f20920..05904387d2 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -114,6 +114,17 @@ spi-max-frequency = <20000000>; m25p,fast-read; };
moxtet@1 {
#address-cells = <1>;
#size-cells = <0>;
compatible = "cznic,moxtet";
reg = <1>;
devrst-gpio = <&gpiosb 2 GPIO_ACTIVE_LOW>;
spi-max-frequency = <1000000>;
spi-cpol;
spi-cpha;
}; };
&uart0 {
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 224179434b..21a3e63864 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -4,11 +4,13 @@ */
#include <common.h> +#include <asm/gpio.h> #include <asm/io.h> #include <dm.h> #include <clk.h> #include <spi.h> #include <mvebu/comphy.h> +#include <miiphy.h> #include <linux/string.h> #include <linux/libfdt.h> #include <fdt_support.h> @@ -251,12 +253,131 @@ int comphy_update_map(struct comphy_map *serdes_map, int count) return 0; }
+#define SW_SMI_CMD_R(d, r) (0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) +#define SW_SMI_CMD_W(d, r) (0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f))
+static int sw_multi_read(struct mii_dev *bus, int sw, int dev, int reg) +{
- bus->write(bus, sw, 0, 0, SW_SMI_CMD_R(dev, reg));
- mdelay(5);
- return bus->read(bus, sw, 0, 1);
+}
+static void sw_multi_write(struct mii_dev *bus, int sw, int dev, int reg,
u16 val)
+{
- bus->write(bus, sw, 0, 1, val);
- bus->write(bus, sw, 0, 0, SW_SMI_CMD_W(dev, reg));
- mdelay(5);
+}
+static int sw_scratch_read(struct mii_dev *bus, int sw, int reg) +{
- sw_multi_write(bus, sw, 0x1c, 0x1a, (reg & 0x7f) << 8);
- return sw_multi_read(bus, sw, 0x1c, 0x1a) & 0xff;
+}
+static void sw_led_write(struct mii_dev *bus, int sw, int port, int reg,
u16 val)
+{
- sw_multi_write(bus, sw, port, 0x16, 0x8000 | ((reg & 7) << 12)
| (val & 0x7ff));
+}
+static void sw_blink_leds(struct mii_dev *bus, int peridot, int topaz) +{
- int i, p;
- struct {
int port;
u16 val;
int wait;
- } regs[] = {
{ 2, 0xef, 1 }, { 2, 0xfe, 1 }, { 2, 0x33, 0 },
{ 4, 0xef, 1 }, { 4, 0xfe, 1 }, { 4, 0x33, 0 },
{ 3, 0xfe, 1 }, { 3, 0xef, 1 }, { 3, 0x33, 0 },
{ 1, 0xfe, 1 }, { 1, 0xef, 1 }, { 1, 0x33, 0 }
- };
- for (i = 0; i < 12; ++i) {
for (p = 0; p < peridot; ++p) {
sw_led_write(bus, 0x10 + p, regs[i].port, 0,
regs[i].val);
sw_led_write(bus, 0x10 + p, regs[i].port + 4, 0,
regs[i].val);
}
if (topaz) {
sw_led_write(bus, 0x2, 0x10 + regs[i].port, 0,
regs[i].val);
}
if (regs[i].wait)
mdelay(75);
- }
+}
+static void check_switch_address(struct mii_dev *bus, int addr) +{
- if (sw_scratch_read(bus, addr, 0x70) >> 3 != addr)
printf("Check of switch MDIO address failed for 0x%02x\n",
addr);
+}
+static int sfp, pci, topaz, peridot, usb, passpci; +static int sfp_pos, peridot_pos[3]; +static int module_count;
+static int configure_peridots(void) +{
- int node, i, ret;
- struct gpio_desc gpio = {};
- u8 dout[MAX_MOX_MODULES];
- node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "cznic,moxtet");
- if (node < 0) {
printf("Cannot find Moxtet bus device node!\n");
return -1;
- }
- gpio_request_by_name_nodev(offset_to_ofnode(node), "devrst-gpio", 0,
&gpio, GPIOD_IS_OUT);
- if (!dm_gpio_is_valid(&gpio)) {
printf("Cannot find reset GPIO for Moxtet bus!\n");
return -1;
- }
- memset(dout, 0, MAX_MOX_MODULES);
- /* set addresses of Peridot modules */
- for (i = 0; i < peridot; ++i)
dout[module_count - peridot_pos[i]] = (~i) & 3;
- /*
* if there is a SFP module connected to the last Peridot module, set
* the P10_SMODE to 1 for the Peridot module
*/
- if (sfp)
dout[module_count - peridot_pos[i - 1]] |= 1 << 3;
- dm_gpio_set_value(&gpio, 1);
- mdelay(10);
- ret = mox_do_spi(NULL, dout, module_count + 1);
- mdelay(10);
- dm_gpio_set_value(&gpio, 0);
- mdelay(50);
- return ret;
+}
- int last_stage_init(void) { int ret, i; const u8 *topology;
- int module_count; mox_version_t version;
struct mii_dev *bus;
ret = mox_get_topology(&topology, &module_count, &version); if (ret) {
@@ -293,6 +414,118 @@ int last_stage_init(void) } }
/* now check if modules are connected in supported mode */
for (i = 0; i < module_count; ++i) {
switch (topology[i]) {
case MOX_MODULE_SFP:
if (sfp) {
printf("Error: Only one SFP module is "
"supported!\n");
} else if (topaz) {
printf("Error: SFP module cannot be connected "
"after Topaz Switch module!\n");
} else {
sfp_pos = i;
++sfp;
}
break;
case MOX_MODULE_PCI:
if (pci) {
printf("Error: Only one Mini-PCIe module is "
"supported!\n");
} else if (usb) {
printf("Error: Mini-PCIe module cannot come "
"after USB 3.0 module!\n");
} else if (i && (i != 1 || !passpci)) {
printf("Error: Mini-PCIe module should be the "
"first connected module or come right "
"after Passthrough Mini-PCIe module!\n");
} else {
++pci;
}
break;
case MOX_MODULE_TOPAZ:
if (topaz) {
printf("Error: Only one Topaz module is "
"supported!\n");
} else if (peridot >= 3) {
printf("Error: At most two Peridot modules "
"can come before Topaz module!\n");
} else {
++topaz;
}
break;
case MOX_MODULE_PERIDOT:
if (sfp || topaz) {
printf("Error: Peridot module must come before "
"SFP or Topaz module!\n");
} else if (peridot >= 3) {
printf("Error: At most three Peridot modules "
"are supported!\n");
} else {
peridot_pos[peridot] = i;
++peridot;
}
break;
case MOX_MODULE_USB3:
if (pci) {
printf("Error: USB 3.0 module cannot come "
"after Mini-PCIe module!\n");
} else if (usb) {
printf("Error: Only one USB 3.0 module is "
"supported!\n");
} else if (i && (i != 1 || !passpci)) {
printf("Error: USB 3.0 module should be the "
"first connected module or come right "
"after Passthrough Mini-PCIe module!\n");
} else {
++usb;
}
break;
case MOX_MODULE_PASSPCI:
if (passpci) {
printf("Error: Only one Passthrough Mini-PCIe "
"module is supported!\n");
} else if (i != 0) {
printf("Error: Passthrough Mini-PCIe module "
"should be the first connected "
"module!\n");
} else {
++passpci;
}
}
}
/* now configure modules */
if (peridot > 0) {
if (configure_peridots() < 0) {
printf("Cannot configure Peridot modules!\n");
peridot = 0;
}
}
if (peridot || topaz) {
/*
* now check if the addresses are set by reading Scratch & Misc
* register 0x70 of Peridot (and potentially Topaz) modules
*/
bus = miiphy_get_dev_by_name("neta@30000");
if (!bus) {
printf("Cannot get MDIO bus device!\n");
} else {
for (i = 0; i < peridot; ++i)
check_switch_address(bus, 0x10 + i);
if (topaz)
check_switch_address(bus, 0x2);
sw_blink_leds(bus, peridot, topaz);
}
}
printf("\n");
return 0;
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Thanks, Stefan

Patch Linux's device tree according to which Mox modules are connected. Linux's device tree is supposed to have some nodes already preprogrammed. If user wants to use different device tree, they should disable CONFIG_OF_BOARD_SETUP in U-Boot's config, so that the boot command does not fail.
Signed-off-by: Marek Behun marek.behun@nic.cz --- board/CZ.NIC/turris_mox/turris_mox.c | 222 +++++++++++++++++++++++++++++++++++ configs/turris_mox_defconfig | 1 + 2 files changed, 223 insertions(+)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 21a3e63864..3361579d7c 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -3,6 +3,7 @@ * Copyright (C) 2018 Marek Behun marek.behun@nic.cz */
+#include <stdarg.h> #include <common.h> #include <asm/gpio.h> #include <asm/io.h> @@ -34,7 +35,11 @@ #define ARMADA_37XX_SPI_DOUT 0xd0010608 #define ARMADA_37XX_SPI_DIN 0xd001060c
+#define ETH1_PATH "/soc/internal-regs@d0000000/ethernet@40000" +#define MDIO_PATH "/soc/internal-regs@d0000000/mdio@32004" +#define MOXTET_SFP_PATH "/soc/internal-regs@d0000000/spi@10600/moxtet@1/moxtet-sfp@0" #define PCIE_PATH "/soc/pcie@d0070000" +#define SFP_PATH "/sfp"
typedef enum { MOX_UNKNOWN, @@ -530,3 +535,220 @@ int last_stage_init(void)
return 0; } + +#if defined(CONFIG_OF_BOARD_SETUP) + +static int vnode_by_path(void *blob, const char *fmt, va_list ap) +{ + char path[128]; + + vsprintf(path, fmt, ap); + return fdt_path_offset(blob, path); +} + +static int node_by_path(void *blob, const char *fmt, ...) +{ + va_list ap; + int res; + + va_start(ap, fmt); + res = vnode_by_path(blob, fmt, ap); + va_end(ap); + + return res; +} + +static int phandle_by_path(void *blob, const char *fmt, ...) +{ + va_list ap; + int node, phandle, res; + + va_start(ap, fmt); + node = vnode_by_path(blob, fmt, ap); + va_end(ap); + + if (node < 0) + return node; + + phandle = fdt_get_phandle(blob, node); + if (phandle > 0) + return phandle; + + phandle = fdt_get_max_phandle(blob); + if (phandle < 0) + return phandle; + + phandle += 1; + + res = fdt_setprop_u32(blob, node, "linux,phandle", phandle); + if (res < 0) + return res; + + res = fdt_setprop_u32(blob, node, "phandle", phandle); + if (res < 0) + return res; + + return phandle; +} + +static int enable_by_path(void *blob, const char *fmt, ...) +{ + va_list ap; + int node; + + va_start(ap, fmt); + node = vnode_by_path(blob, fmt, ap); + va_end(ap); + + if (node < 0) + return node; + + return fdt_setprop_string(blob, node, "status", "okay"); +} + +static bool is_topaz(int id) +{ + return topaz && id == peridot + topaz - 1; +} + +static int switch_addr(int id) +{ + return is_topaz(id) ? 0x2 : 0x10 + id; +} + +static int setup_switch(void *blob, int id) +{ + int res, addr, i, node, phandle; + + addr = switch_addr(id); + + /* first enable the switch by setting status = "okay" */ + res = enable_by_path(blob, MDIO_PATH "/switch%i@%x", id, addr); + if (res < 0) + return res; + + /* + * now if there are more switches or a SFP module coming after, + * enable corresponding ports + */ + if (id < peridot + topaz - 1) + res = enable_by_path(blob, + MDIO_PATH "/switch%i@%x/ports/port@a", + id, addr); + else if (id == peridot - 1 && !topaz && sfp) + res = enable_by_path(blob, + MDIO_PATH "/switch%i@%x/ports/port-sfp@a", + id, addr); + else + res = 0; + if (res < 0) + return res; + + if (id >= peridot + topaz - 1) + return 0; + + /* finally change link property if needed */ + node = node_by_path(blob, MDIO_PATH "/switch%i@%x/ports/port@a", id, + addr); + if (node < 0) + return node; + + for (i = id + 1; i < peridot + topaz; ++i) { + phandle = phandle_by_path(blob, + MDIO_PATH "/switch%i@%x/ports/port@%x", + i, switch_addr(i), + is_topaz(i) ? 5 : 9); + if (phandle < 0) + return phandle; + + if (i == id + 1) + res = fdt_setprop_u32(blob, node, "link", phandle); + else + res = fdt_appendprop_u32(blob, node, "link", phandle); + if (res < 0) + return res; + } + + return 0; +} + +int ft_board_setup(void *blob, bd_t *bd) +{ + int node, phandle, res; + + if (pci || usb) { + node = fdt_path_offset(blob, PCIE_PATH); + if (node < 0) + return node; + + res = fdt_setprop_string(blob, node, "status", "okay"); + if (res < 0) + return res; + } + + if (peridot || topaz) { + int i; + + res = enable_by_path(blob, ETH1_PATH); + if (res < 0) + return res; + + for (i = 0; i < peridot + topaz; ++i) { + res = setup_switch(blob, i); + if (res < 0) + return res; + } + } + + if (sfp) { + res = enable_by_path(blob, SFP_PATH); + if (res < 0) + return res; + + if (!peridot) { + phandle = phandle_by_path(blob, SFP_PATH); + if (phandle < 0) + return res; + + node = node_by_path(blob, ETH1_PATH); + if (node < 0) + return node; + + res = fdt_setprop_u32(blob, node, "sfp", phandle); + if (res < 0) + return res; + + res = fdt_setprop_string(blob, node, "phy-mode", + "sgmii"); + if (res < 0) + return res; + } + + res = enable_by_path(blob, MOXTET_SFP_PATH); + if (res < 0) + return res; + + if (sfp_pos) { + char newname[16]; + + /* moxtet-sfp is on non-zero position, change default */ + node = node_by_path(blob, MOXTET_SFP_PATH); + if (node < 0) + return node; + + res = fdt_setprop_u32(blob, node, "reg", sfp_pos); + if (res < 0) + return res; + + sprintf(newname, "moxtet-sfp@%x", sfp_pos); + + res = fdt_set_name(blob, node, newname); + if (res < 0) + return res; + } + } + + return 0; +} + +#endif diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index 1dd6826dbc..fb4192df56 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -14,6 +14,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_ARCH_EARLY_INIT_R=y CONFIG_OF_BOARD_FIXUP=y +CONFIG_OF_BOARD_SETUP=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y

On 17.08.2018 12:58, Marek Behún wrote:
Patch Linux's device tree according to which Mox modules are connected. Linux's device tree is supposed to have some nodes already preprogrammed. If user wants to use different device tree, they should disable CONFIG_OF_BOARD_SETUP in U-Boot's config, so that the boot command does not fail.
Signed-off-by: Marek Behun marek.behun@nic.cz
board/CZ.NIC/turris_mox/turris_mox.c | 222 +++++++++++++++++++++++++++++++++++ configs/turris_mox_defconfig | 1 + 2 files changed, 223 insertions(+)
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 21a3e63864..3361579d7c 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -3,6 +3,7 @@
- Copyright (C) 2018 Marek Behun marek.behun@nic.cz
*/
+#include <stdarg.h> #include <common.h> #include <asm/gpio.h> #include <asm/io.h> @@ -34,7 +35,11 @@ #define ARMADA_37XX_SPI_DOUT 0xd0010608 #define ARMADA_37XX_SPI_DIN 0xd001060c
+#define ETH1_PATH "/soc/internal-regs@d0000000/ethernet@40000" +#define MDIO_PATH "/soc/internal-regs@d0000000/mdio@32004" +#define MOXTET_SFP_PATH "/soc/internal-regs@d0000000/spi@10600/moxtet@1/moxtet-sfp@0" #define PCIE_PATH "/soc/pcie@d0070000" +#define SFP_PATH "/sfp"
typedef enum { MOX_UNKNOWN, @@ -530,3 +535,220 @@ int last_stage_init(void)
return 0; }
+#if defined(CONFIG_OF_BOARD_SETUP)
+static int vnode_by_path(void *blob, const char *fmt, va_list ap) +{
- char path[128];
- vsprintf(path, fmt, ap);
- return fdt_path_offset(blob, path);
+}
+static int node_by_path(void *blob, const char *fmt, ...) +{
- va_list ap;
- int res;
- va_start(ap, fmt);
- res = vnode_by_path(blob, fmt, ap);
- va_end(ap);
- return res;
+}
+static int phandle_by_path(void *blob, const char *fmt, ...) +{
- va_list ap;
- int node, phandle, res;
- va_start(ap, fmt);
- node = vnode_by_path(blob, fmt, ap);
- va_end(ap);
- if (node < 0)
return node;
- phandle = fdt_get_phandle(blob, node);
- if (phandle > 0)
return phandle;
- phandle = fdt_get_max_phandle(blob);
- if (phandle < 0)
return phandle;
- phandle += 1;
- res = fdt_setprop_u32(blob, node, "linux,phandle", phandle);
- if (res < 0)
return res;
- res = fdt_setprop_u32(blob, node, "phandle", phandle);
- if (res < 0)
return res;
- return phandle;
+}
+static int enable_by_path(void *blob, const char *fmt, ...) +{
- va_list ap;
- int node;
- va_start(ap, fmt);
- node = vnode_by_path(blob, fmt, ap);
- va_end(ap);
- if (node < 0)
return node;
- return fdt_setprop_string(blob, node, "status", "okay");
+}
+static bool is_topaz(int id) +{
- return topaz && id == peridot + topaz - 1;
+}
+static int switch_addr(int id) +{
- return is_topaz(id) ? 0x2 : 0x10 + id;
+}
+static int setup_switch(void *blob, int id) +{
- int res, addr, i, node, phandle;
- addr = switch_addr(id);
- /* first enable the switch by setting status = "okay" */
- res = enable_by_path(blob, MDIO_PATH "/switch%i@%x", id, addr);
- if (res < 0)
return res;
- /*
* now if there are more switches or a SFP module coming after,
* enable corresponding ports
*/
- if (id < peridot + topaz - 1)
res = enable_by_path(blob,
MDIO_PATH "/switch%i@%x/ports/port@a",
id, addr);
- else if (id == peridot - 1 && !topaz && sfp)
res = enable_by_path(blob,
MDIO_PATH "/switch%i@%x/ports/port-sfp@a",
id, addr);
- else
res = 0;
- if (res < 0)
return res;
- if (id >= peridot + topaz - 1)
return 0;
- /* finally change link property if needed */
- node = node_by_path(blob, MDIO_PATH "/switch%i@%x/ports/port@a", id,
addr);
- if (node < 0)
return node;
- for (i = id + 1; i < peridot + topaz; ++i) {
phandle = phandle_by_path(blob,
MDIO_PATH "/switch%i@%x/ports/port@%x",
i, switch_addr(i),
is_topaz(i) ? 5 : 9);
if (phandle < 0)
return phandle;
if (i == id + 1)
res = fdt_setprop_u32(blob, node, "link", phandle);
else
res = fdt_appendprop_u32(blob, node, "link", phandle);
if (res < 0)
return res;
- }
- return 0;
+}
+int ft_board_setup(void *blob, bd_t *bd) +{
- int node, phandle, res;
- if (pci || usb) {
node = fdt_path_offset(blob, PCIE_PATH);
if (node < 0)
return node;
res = fdt_setprop_string(blob, node, "status", "okay");
if (res < 0)
return res;
- }
- if (peridot || topaz) {
int i;
res = enable_by_path(blob, ETH1_PATH);
if (res < 0)
return res;
for (i = 0; i < peridot + topaz; ++i) {
res = setup_switch(blob, i);
if (res < 0)
return res;
}
- }
- if (sfp) {
res = enable_by_path(blob, SFP_PATH);
if (res < 0)
return res;
if (!peridot) {
phandle = phandle_by_path(blob, SFP_PATH);
if (phandle < 0)
return res;
node = node_by_path(blob, ETH1_PATH);
if (node < 0)
return node;
res = fdt_setprop_u32(blob, node, "sfp", phandle);
if (res < 0)
return res;
res = fdt_setprop_string(blob, node, "phy-mode",
"sgmii");
if (res < 0)
return res;
}
res = enable_by_path(blob, MOXTET_SFP_PATH);
if (res < 0)
return res;
if (sfp_pos) {
char newname[16];
/* moxtet-sfp is on non-zero position, change default */
node = node_by_path(blob, MOXTET_SFP_PATH);
if (node < 0)
return node;
res = fdt_setprop_u32(blob, node, "reg", sfp_pos);
if (res < 0)
return res;
sprintf(newname, "moxtet-sfp@%x", sfp_pos);
res = fdt_set_name(blob, node, newname);
if (res < 0)
return res;
}
- }
- return 0;
+}
+#endif diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index 1dd6826dbc..fb4192df56 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -14,6 +14,7 @@ CONFIG_SYS_CONSOLE_INFO_QUIET=y # CONFIG_DISPLAY_BOARDINFO is not set CONFIG_ARCH_EARLY_INIT_R=y CONFIG_OF_BOARD_FIXUP=y +CONFIG_OF_BOARD_SETUP=y CONFIG_CMD_CLK=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Thanks, Stefan

This can be used to detect whether the button is pressed or light LEDs.
Signed-off-by: Marek Behun marek.behun@nic.cz --- configs/turris_mox_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index fb4192df56..cc28a1fe95 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -16,6 +16,7 @@ CONFIG_ARCH_EARLY_INIT_R=y CONFIG_OF_BOARD_FIXUP=y CONFIG_OF_BOARD_SETUP=y CONFIG_CMD_CLK=y +CONFIG_CMD_GPIO=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y

On 17.08.2018 12:59, Marek Behún wrote:
This can be used to detect whether the button is pressed or light LEDs.
Signed-off-by: Marek Behun marek.behun@nic.cz
configs/turris_mox_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index fb4192df56..cc28a1fe95 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -16,6 +16,7 @@ CONFIG_ARCH_EARLY_INIT_R=y CONFIG_OF_BOARD_FIXUP=y CONFIG_OF_BOARD_SETUP=y CONFIG_CMD_CLK=y +CONFIG_CMD_GPIO=y # CONFIG_CMD_FLASH is not set CONFIG_CMD_I2C=y CONFIG_CMD_MMC=y
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Thanks, Stefan

Remove smi_pins definition since it is already in armada-37xx.dtsi. Add assigned-clocks definitions to spi0.
Signed-off-by: Marek Behun marek.behun@nic.cz --- arch/arm/dts/armada-3720-turris-mox.dts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index 05904387d2..9c96dd39a9 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -94,17 +94,13 @@ }; };
-&pinctrl_sb { - smi_pins: smi-pins { - groups = "smi"; - function = "smi"; - }; -}; - &spi0 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi_cs1_pins>; + assigned-clocks = <&nb_periph_clk 7>; + assigned-clock-parents = <&tbg 1>; + assigned-clock-rates = <20000000>;
spi-flash@0 { #address-cells = <1>;

On 17.08.2018 12:59, Marek Behún wrote:
Remove smi_pins definition since it is already in armada-37xx.dtsi. Add assigned-clocks definitions to spi0.
Signed-off-by: Marek Behun marek.behun@nic.cz
arch/arm/dts/armada-3720-turris-mox.dts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
diff --git a/arch/arm/dts/armada-3720-turris-mox.dts b/arch/arm/dts/armada-3720-turris-mox.dts index 05904387d2..9c96dd39a9 100644 --- a/arch/arm/dts/armada-3720-turris-mox.dts +++ b/arch/arm/dts/armada-3720-turris-mox.dts @@ -94,17 +94,13 @@ }; };
-&pinctrl_sb {
- smi_pins: smi-pins {
groups = "smi";
function = "smi";
- };
-};
- &spi0 { status = "okay"; pinctrl-names = "default"; pinctrl-0 = <&spi_cs1_pins>;
assigned-clocks = <&nb_periph_clk 7>;
assigned-clock-parents = <&tbg 1>;
assigned-clock-rates = <20000000>;
spi-flash@0 { #address-cells = <1>;
Applied to u-boot-marvell/master
Thanks, Stefan

Add configuration variables to differentiate between the 512 MB and 1 GB versions of Turris Mox and change the RAM size in U-Boot's device tree accordingly.
Signed-off-by: Marek Behun marek.behun@nic.cz --- MAINTAINERS | 7 +++++++ arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi | 16 ++++++++++++++++ arch/arm/mach-mvebu/Kconfig | 15 +++++++++++++++ configs/turris_mox_defconfig | 1 + 4 files changed, 39 insertions(+) create mode 100644 arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
diff --git a/MAINTAINERS b/MAINTAINERS index 1893090b8f..1a55d80c13 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -360,6 +360,13 @@ S: Maintained T: git git://git.denx.de/u-boot-coldfire.git F: arch/m68k/
+CZ.NIC TURRIS +M: Marek Behun marek.behun@nic.cz +S: Maintained +F: arch/arm/dts/armada-3720-turris-mox.dts +F: arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi +F: board/CZ.NIC/ + DFU M: Lukasz Majewski lukma@denx.de S: Maintained diff --git a/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi new file mode 100644 index 0000000000..122f5c8ae1 --- /dev/null +++ b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ or X11 +/* + * 2018 by Marek Behun marek.behun@nic.cz + */ + +#include <config.h> + +/ { + memory { +#ifdef CONFIG_TARGET_TURRIS_MOX_1GB + reg = <0x00000000 0x00000000 0x00000000 0x40000000>; +#else + reg = <0x00000000 0x00000000 0x00000000 0x20000000>; +#endif + }; +}; diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index d1f71338ac..3e88b3757b 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -198,6 +198,21 @@ config MVEBU_SPL_BOOT_DEVICE_UART
endchoice
+if TARGET_TURRIS_MOX + +choice + prompt "Turris Mox RAM size" + +config TARGET_TURRIS_MOX_512MB + bool "512 MB" + +config TARGET_TURRIS_MOX_1GB + bool "1 GB" + +endchoice + +endif + config MVEBU_EFUSE bool "Enable eFuse support" default n diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index cc28a1fe95..2bcbdd8133 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -3,6 +3,7 @@ CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_TURRIS_MOX=y +CONFIG_TARGET_TURRIS_MOX_512MB=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=25804800 CONFIG_DEFAULT_DEVICE_TREE="armada-3720-turris-mox"

On 17.08.2018 12:59, Marek Behún wrote:
Add configuration variables to differentiate between the 512 MB and 1 GB versions of Turris Mox and change the RAM size in U-Boot's device tree accordingly.
Signed-off-by: Marek Behun marek.behun@nic.cz
MAINTAINERS | 7 +++++++ arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi | 16 ++++++++++++++++ arch/arm/mach-mvebu/Kconfig | 15 +++++++++++++++ configs/turris_mox_defconfig | 1 + 4 files changed, 39 insertions(+) create mode 100644 arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi
diff --git a/MAINTAINERS b/MAINTAINERS index 1893090b8f..1a55d80c13 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -360,6 +360,13 @@ S: Maintained T: git git://git.denx.de/u-boot-coldfire.git F: arch/m68k/
+CZ.NIC TURRIS +M: Marek Behun marek.behun@nic.cz +S: Maintained +F: arch/arm/dts/armada-3720-turris-mox.dts +F: arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi +F: board/CZ.NIC/
- DFU M: Lukasz Majewski lukma@denx.de S: Maintained
diff --git a/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi new file mode 100644 index 0000000000..122f5c8ae1 --- /dev/null +++ b/arch/arm/dts/armada-3720-turris-mox-u-boot.dtsi @@ -0,0 +1,16 @@ +// SPDX-License-Identifier: GPL-2.0+ or X11 +/*
- 2018 by Marek Behun marek.behun@nic.cz
- */
+#include <config.h>
+/ {
- memory {
+#ifdef CONFIG_TARGET_TURRIS_MOX_1GB
reg = <0x00000000 0x00000000 0x00000000 0x40000000>;
+#else
reg = <0x00000000 0x00000000 0x00000000 0x20000000>;
+#endif
- };
+}; diff --git a/arch/arm/mach-mvebu/Kconfig b/arch/arm/mach-mvebu/Kconfig index d1f71338ac..3e88b3757b 100644 --- a/arch/arm/mach-mvebu/Kconfig +++ b/arch/arm/mach-mvebu/Kconfig @@ -198,6 +198,21 @@ config MVEBU_SPL_BOOT_DEVICE_UART
endchoice
+if TARGET_TURRIS_MOX
+choice
- prompt "Turris Mox RAM size"
+config TARGET_TURRIS_MOX_512MB
- bool "512 MB"
+config TARGET_TURRIS_MOX_1GB
- bool "1 GB"
+endchoice
+endif
- config MVEBU_EFUSE bool "Enable eFuse support" default n
diff --git a/configs/turris_mox_defconfig b/configs/turris_mox_defconfig index cc28a1fe95..2bcbdd8133 100644 --- a/configs/turris_mox_defconfig +++ b/configs/turris_mox_defconfig @@ -3,6 +3,7 @@ CONFIG_ARCH_MVEBU=y CONFIG_SYS_TEXT_BASE=0x00000000 CONFIG_SYS_MALLOC_F_LEN=0x2000 CONFIG_TARGET_TURRIS_MOX=y +CONFIG_TARGET_TURRIS_MOX_512MB=y CONFIG_DEBUG_UART_BASE=0xd0012000 CONFIG_DEBUG_UART_CLOCK=25804800 CONFIG_DEFAULT_DEVICE_TREE="armada-3720-turris-mox"
This patch does not apply currently. I'm skipping it from this series for now. I'm currently pushing my Marvell branch upstream and would like to get the first batch of patches accepted. After Tom has pulled these patches, please rebase on top of this new master.
Thanks, Stefan

Hi Marek,
On 17.08.2018 12:58, Marek Behún wrote:
This is second version of updates for Turris Mox. The first version was sent three months ago, on 16th May. Sorry :). It would be great if this got to 2018.09 release, but I will understand if it does not.
I'm afraid, but this will have to wait for the next merge window. We're at RC2 and I'll be leaving for one week vacation tomorrow. I'll try to review the patches later then.
Thanks, Stefan
participants (3)
-
Marek Behun
-
Marek Behún
-
Stefan Roese