From patchwork Fri Aug 17 10:58:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958768 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="QCwvqc6N"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sKz52vVRz9s4c for ; Fri, 17 Aug 2018 21:02:09 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id DA3D7C21DFD; Fri, 17 Aug 2018 11:01:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id E8DA8C21DB5; Fri, 17 Aug 2018 11:01:18 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 74CB5C21D56; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 0F994C21D65 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 9E4F76093E; Fri, 17 Aug 2018 13:01:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503675; bh=bBBL2IZkQgJp2BR7v1BubifLxo57S30n8cs+l6+hwKw=; h=From:To:Date; b=QCwvqc6NRccPLUpeZlFCP7e4df8sHqtAWxTfHpPvD71aA/PZR6XMBsMONDrbJD5s8 SpJ4ALPiSVX3CvUS7AnwSA1i4zd/gZLLLSiQnRiMEYjeUotBtFLXMNOKLYmwq7E+AO HRG48oGk5J2LXfxRQCO1hfbyimnBnLXVkPoF4bOQ= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:51 +0200 Message-Id: <20180817105902.10692-2-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 01/12] phy: marvell: Support changing SERDES map in board file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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 M: Luka Perkov M: Stefan Roese @@ -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 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 #include -#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 #include +#include #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 #include -#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 #include -#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 + +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_ */ + From patchwork Fri Aug 17 10:58:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958769 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="GUT4zWrv"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL1F4cHWz9s4c for ; Fri, 17 Aug 2018 21:04:01 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 36A1DC21DCA; Fri, 17 Aug 2018 11:02:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D3635C21DEC; Fri, 17 Aug 2018 11:01:19 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D54B6C21DB3; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 2D8CDC21D72 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id AA69F60BE1; Fri, 17 Aug 2018 13:01:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503675; bh=zwI6l9uf+4naX2kVqO7KvQUqa74kVP7UAWCDCxOm2FM=; h=From:To:Date; b=GUT4zWrv34XdNJyfiyQgDi6YpLGEwlrVJHVhy8ur8nnDaKZmUiub56lxthAGytp2E ptczNrf6aelttF3JZdSGdXA82sL2kD6F3+zhAWhLUZapEerwCtKbQBgR7mSrk14t9c rzRXmFdSpVeWdJphZoJs5NrUCGSUbCZfK4/zu7jE= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:52 +0200 Message-Id: <20180817105902.10692-3-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 02/12] clk: armada-37xx-periph: Support changing clock parent and rate X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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, }; From patchwork Fri Aug 17 10:58:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958771 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="fiq79O38"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL2h42wSz9s8k for ; Fri, 17 Aug 2018 21:05:16 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 13BB4C21DCA; Fri, 17 Aug 2018 11:02:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 93942C21DF8; Fri, 17 Aug 2018 11:01:20 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E64EDC21D83; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 4B1CBC21D83 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id DCE1760D81; Fri, 17 Aug 2018 13:01:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503675; bh=ydBhsHuuD23PWTI90nj44OrR8rnPBTwJVww34QWLGa8=; h=From:To:Date; b=fiq79O38Q7KjdRi2UWK+0lfCsst6pRLUDevPU/JicqbP7irYpas8kDsq1fuTQVE82 8a9H9M9jHuf8fBvsYOaktHccfLXhDF8ZBVI5lOMyk/DwbzeIpb+R/WScs2iUwTzRW0 vQ6BCplpaEd5UyvOP5NUav4qeJpTDyHZ/o5WCQQI= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:53 +0200 Message-Id: <20180817105902.10692-4-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 03/12] board: turris_mox: Fix watchdog macro name X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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 #include -#ifdef CONFIG_WDT_ARMADA_3720 +#ifdef CONFIG_WDT_ARMADA_37XX #include #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 { From patchwork Fri Aug 17 10:58:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958770 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="wrqADlye"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL1T4hS3z9s4c for ; Fri, 17 Aug 2018 21:04:13 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 482AFC21DB5; Fri, 17 Aug 2018 11:02:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 59555C21D8A; Fri, 17 Aug 2018 11:01:21 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 02679C21D8A; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 58B6FC21D8A for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id EE6C960D93; Fri, 17 Aug 2018 13:01:15 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=/RKkZ5f0fWMdUfCShwjt8ENgM7W9DPcYl96LBezFmSc=; h=From:To:Date; b=wrqADlyeOggIFJv+depwstA8puAac4C5mY4uAXTXIzLxtErIgxawnt/LM6vxyv/Tu hYo1jSQqAe99pNyY7Tyv7mklqwodzmsGhd2KtcsoqBIDQQmpdgIeCLhjbXrrqLqC6w c4IQO4bLogeyzUE8fbzgBs2lj35qfxMlx9Z0eT74= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:54 +0200 Message-Id: <20180817105902.10692-5-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 04/12] board: turris_mox: Fixup U-Boot's device tree if PCIe connected X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" If PCIe Mox module is connected we want to have PCIe node enabled in U-Boot's device tree. Signed-off-by: Marek Behun --- 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 +#include #include #include #include #include +#include +#include #ifdef CONFIG_WDT_ARMADA_37XX #include #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 From patchwork Fri Aug 17 10:58:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958777 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="pcQMIVUO"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL7c3grwz9s4c for ; Fri, 17 Aug 2018 21:09:32 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 32170C21E0D; Fri, 17 Aug 2018 11:04:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DC2FAC21E73; Fri, 17 Aug 2018 11:01:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7F2ADC21D65; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 7C8EAC21D65 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 11C80612ED; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=5pCMjVsS7trgGLzMT4jHFUazaKyVtaTzWgzINu0iwoU=; h=From:To:Date; b=pcQMIVUOTDbleMutLVOvK5lpCc25wHkohxUppblD4QqU//4L3bGYsVZY1Xjr+8yl9 IGnV43HtDqS2HDH49CZi+r/DtVBQTyJo4HJBulCTVmfSS4Qqzl+ebe9mpW5X4kkR3v K8jUJL7E6um3G+1jgmERGX/6j5gFf5HKg9dhdIv8= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:55 +0200 Message-Id: <20180817105902.10692-6-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 05/12] board: turris_mox: Enable PCI in defconfig X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Enable the pci-aardvark driver in defconfig for Turris Mox and also enable the pci command. Signed-off-by: Marek Behun --- 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 From patchwork Fri Aug 17 10:58:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958778 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="Pt0a1stz"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL7v0Y91z9s4c for ; Fri, 17 Aug 2018 21:09:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 21CE9C21E0F; Fri, 17 Aug 2018 11:05:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 8A20AC21E88; Fri, 17 Aug 2018 11:01:28 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A8C3CC21D56; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 86677C21DA1 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 2C8CA62279; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=FO441L9Ku1r964pvv6EMChQc7goZLtfEKqp4ukK64fw=; h=From:To:Date; b=Pt0a1stziIduDBUFttw+v4hscHGnfDomLUz2fFDFaPj9VTt/PK5oq9Wt1p3s+9Ga/ FkwURHZc0Ov2lPrveLy4d4SKzlaOafoBQzvcFCOXkr2WxXdLYRMb8P+2NymCoaVkzN zB6YfFT7vVQ4G0+PMPZ5AdWfxGnNwx9Ky/ZdLMxs= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:56 +0200 Message-Id: <20180817105902.10692-7-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 06/12] board: turris_mox: Cosmetic restructurization X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Restructure the board initialization source. Remove the module_topology environment variable since it won't be needed. Signed-off-by: Marek Behun --- 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; } From patchwork Fri Aug 17 10:58:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958775 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="t/0M6L0U"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL4p2MV2z9s8f for ; Fri, 17 Aug 2018 21:07:06 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E2A1FC21DE8; Fri, 17 Aug 2018 11:03:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id DBF2FC21DB3; Fri, 17 Aug 2018 11:01:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 47F89C21D72; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 930D5C21D8E for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 43501622DD; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=vWa34HJJXhdau2L6utdQXMKyTnHq9wIqE+GKZ7BSamk=; h=From:To:Date; b=t/0M6L0U5f+hIVfpO/GG1NBy+4RkcM/FdIXVHC84CVdsIEEz3wE3UdVcX5TR5MWXv Wkw1R4b7y6WXO1PVMUkTQj7Ul/ze3x//nROI9iZzJ3Bj1tf0Zr+Ezmmvf9czMbvWCu q2JY8rlBk8ClRcBgYiArlV0URLxd+aWr0mZtoDMk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:57 +0200 Message-Id: <20180817105902.10692-8-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 07/12] board: turris_mox: Change SERDES map depending on module topology X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" When SFP module is connected directly to CPU module we want the SGMII lane speed at 1.25 Gbps. Signed-off-by: Marek Behun --- 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 #include #include +#include #include #include #include @@ -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; From patchwork Fri Aug 17 10:58:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958776 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="P4L8qwCx"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL6Q1lTTz9s4c for ; Fri, 17 Aug 2018 21:08:30 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id F2D23C21E1B; Fri, 17 Aug 2018 11:04:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 05541C21E62; Fri, 17 Aug 2018 11:01:26 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 6A75BC21D56; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 9B662C21DA2 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 4DF25623DA; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=PASONX+YTmbMx09HSIKj1uVXt0w1niZD3Ft6rQhAEF0=; h=From:To:Date; b=P4L8qwCx395FGRbLR3II5TGeuxSgzQSAvaXfy1LjOoHq6SPezLx/aYAVSTQ60lF7E IUWZ0Py92eaQzNYLL0PztViLhnM53jlH06xugJqet8uVmzrD2P3u6B6H1sOrPWoYo+ nnXlacJD7nPpWm6MpsoLIkuFjvb371bBtbhLFD78= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:58 +0200 Message-Id: <20180817105902.10692-9-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 08/12] board: turris_mox: Check and configure modules X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Check if Mox modules are connected in supported mode, then configure the MDIO addresses of switch modules. Signed-off-by: Marek Behun --- 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 +#include #include #include #include #include #include +#include #include #include #include @@ -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; From patchwork Fri Aug 17 10:58:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958774 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="V7gbsT6g"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL4V07PPz9s4c for ; Fri, 17 Aug 2018 21:06:49 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id B5886C21DAF; Fri, 17 Aug 2018 11:03:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 18FE9C21E4E; Fri, 17 Aug 2018 11:01:25 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 5618CC21D83; Fri, 17 Aug 2018 11:01:17 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id B1722C21D56 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 5885A62705; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=evEIrJgQsq7zeFX7hhc15/cgqjBo3Ad0Db4iFcwZg/o=; h=From:To:Date; b=V7gbsT6gBAAlcV5ckjYG3q/BZbGA23u1rqxsz4gLfqA12e3HH2sZZZLBOn0HPrI6z RW7v13DhJ7QFpRTg7i4RvC8UH9gJES71OCrxHk63LzlZ1P9q8X9h38/UGTqDZ3saNr 3jcb0CKyvOa1xYcP0PEjHb+lZIe1nR/ZZ26FuT/o= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:58:59 +0200 Message-Id: <20180817105902.10692-10-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 09/12] board: turris_mox: Setup Linux's device tree before boot X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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 */ +#include #include #include #include @@ -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 From patchwork Fri Aug 17 10:59:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958779 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="LfoYA0ty"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL861dsPz9s4c for ; Fri, 17 Aug 2018 21:09:58 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id E4E1BC21DDC; Fri, 17 Aug 2018 11:04:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id BCF76C21D83; Fri, 17 Aug 2018 11:01:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 91F59C21D72; Fri, 17 Aug 2018 11:01:17 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id BFFEFC21DA6 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 6E50862750; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=3/ASj30uVHzxUezZ4HmD8pa7zkI5bC2Mr++Knwzody0=; h=From:To:Date; b=LfoYA0tyE5529Vq8+UURLLStcbiLChSWNNUKz3/aHLEWqaflyh2qMyw3ahpcktdxA yiSCTvDAJPWXii7bp3UdkM/CyA0IwQL+hRD/KSxlHNiU8LjZCJYvQtq/1/pN0RTAk2 YfbIFFw9LNeug54swmE8QC5kJoKOcF9USuHGpOYU= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:59:00 +0200 Message-Id: <20180817105902.10692-11-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 10/12] board: turris_mox: Add gpio command to defconfig X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This can be used to detect whether the button is pressed or light LEDs. Signed-off-by: Marek Behun --- 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 From patchwork Fri Aug 17 10:59:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958772 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="CZ3UoDIy"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL324Tsjz9s4c for ; Fri, 17 Aug 2018 21:05:34 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 51051C21DFA; Fri, 17 Aug 2018 11:03:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2F786C21D56; Fri, 17 Aug 2018 11:01:23 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 3DA07C21D65; Fri, 17 Aug 2018 11:01:17 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id D1906C21DAF for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 7EEB662B40; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=cG/R5RwrBtZhTKR/ey0SVjuMuab+LZAIdOVQ3dbmBaw=; h=From:To:Date; b=CZ3UoDIyGQb9FdPIHuuCECLsLPRUQKECJWfAt+nESdJBTWmhac2yL3XjR1+M8t509 BHqQ7N5r8oTjCJ3ihLr+rfq5872rehvqopV4EiBPnURf/wRlQzm9+mLkaJQPYnJ8Rx HMv8LcFBzPngmPm+9lZowH0QUfCdqz1KhYiCgxhk= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:59:01 +0200 Message-Id: <20180817105902.10692-12-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 11/12] arch/arm/dts: Update Turris Mox device tree X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Remove smi_pins definition since it is already in armada-37xx.dtsi. Add assigned-clocks definitions to spi0. Signed-off-by: Marek Behun --- 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>; From patchwork Fri Aug 17 10:59:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 958773 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=nic.cz Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="apLrB0g/"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 41sL3N1Gmjz9s4c for ; Fri, 17 Aug 2018 21:05:52 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id D7B13C21DF8; Fri, 17 Aug 2018 11:03:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2A048C21E1B; Fri, 17 Aug 2018 11:01:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 20D70C21D56; Fri, 17 Aug 2018 11:01:17 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id E3956C21D72 for ; Fri, 17 Aug 2018 11:01:16 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:cac7:3539:7f1f:463]) by mail.nic.cz (Postfix) with ESMTP id 8EF3E6088B; Fri, 17 Aug 2018 13:01:16 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1534503676; bh=cAECX25zoK4HieehOVaAQRUo7V3j4bNdYH8hPaB1SZs=; h=From:To:Date; b=apLrB0g/CFoecCmLg1p35j2R/FIERoNCjg7puEF0MqPc/7DLWjZ2qhrnP3tF9Yrik TKD9RSJ/XATqRcN22nrHfV4d33w2K5RFch4OEH4q1KJLoZWAOgRN4HHhODpv0AKnku VFunmeGFcY/6pQwaINXT2B2BAeGbziORDyQbTsOc= From: =?utf-8?q?Marek_Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 17 Aug 2018 12:59:02 +0200 Message-Id: <20180817105902.10692-13-marek.behun@nic.cz> X-Mailer: git-send-email 2.16.4 In-Reply-To: <20180817105902.10692-1-marek.behun@nic.cz> References: <20180817105902.10692-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Stefan Roese Subject: [U-Boot] [PATCH u-boot-marvell v2 12/12] arch/arm/mvebu: Support 1 GB version of Turris Mox X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 --- 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 +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 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 + */ + +#include + +/ { + 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"