[U-Boot] [PATCH 1/4] ARM: tegra: add SoC-level hook for board_late_init()

From: Stephen Warren swarren@nvidia.com
Extend the Tegra186 implementation of board_late_init() to call a per-SoC "hook" function. This will allow SoC-specific (rather than Tegra-wide) functionality to be implemented without the core Tegra code needing to be aware of the details. While board186.c is currently only used for Tegra186, it should be applicable to any other future SoC, and perhaps its simple design could be back-ported to older SoCs in the future too.
Signed-off-by: Stephen Warren swarren@nvidia.com --- This series logically relies on the DWC EQOS driver series that I just sent in order for the device to actually work. However, the code should compile and even run (albeit without yet enabling Ethernet) even without both series applied. So, the two series don't need to be applied in any particular order, nor in the same branch.
arch/arm/mach-tegra/board186.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/arch/arm/mach-tegra/board186.c b/arch/arm/mach-tegra/board186.c index 1b9799fd80c2..38261e421cc1 100644 --- a/arch/arm/mach-tegra/board186.c +++ b/arch/arm/mach-tegra/board186.c @@ -26,11 +26,16 @@ int board_init(void) return tegra_board_init(); }
-int board_late_init(void) +__weak int tegra_soc_board_init_late(void) { return 0; }
+int board_late_init(void) +{ + return tegra_soc_board_init_late(); +} + void pad_init_mmc(struct mmc_host *host) { }

From: Stephen Warren swarren@nvidia.com
On Tegra186, the bootloader which runs before U-Boot passes the Ethernet MAC address to U-Boot using device tree. Extract this value and write it to the environment, so that the Ethernet uclass picks it up and uses it for the built-in Ethernet device.
Signed-off-by: Stephen Warren swarren@nvidia.com --- arch/arm/mach-tegra/tegra186/Makefile | 1 + arch/arm/mach-tegra/tegra186/nvtboot_board.c | 54 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 arch/arm/mach-tegra/tegra186/nvtboot_board.c
diff --git a/arch/arm/mach-tegra/tegra186/Makefile b/arch/arm/mach-tegra/tegra186/Makefile index 033d6005fb44..26bc462930c1 100644 --- a/arch/arm/mach-tegra/tegra186/Makefile +++ b/arch/arm/mach-tegra/tegra186/Makefile @@ -3,5 +3,6 @@ # SPDX-License-Identifier: GPL-2.0
obj-y += ../board186.o +obj-y += nvtboot_board.o obj-y += nvtboot_ll.o obj-y += nvtboot_mem.o diff --git a/arch/arm/mach-tegra/tegra186/nvtboot_board.c b/arch/arm/mach-tegra/tegra186/nvtboot_board.c new file mode 100644 index 000000000000..1d78346f9843 --- /dev/null +++ b/arch/arm/mach-tegra/tegra186/nvtboot_board.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2016, NVIDIA CORPORATION. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <fdt_support.h> +#include <fdtdec.h> +#include <asm/arch/tegra.h> + +extern unsigned long nvtboot_boot_x0; + +/* + * Attempt to use /chosen/nvidia,ether-mac in the nvtboot DTB to U-Boot's + * ethaddr environment variable if possible. + */ +static int set_ethaddr_from_nvtboot(void) +{ + const void *nvtboot_blob = (void *)nvtboot_boot_x0; + int ret, node, len; + const u32 *prop; + + /* Already a valid address in the environment? If so, keep it */ + if (getenv("ethaddr")) + return 0; + + node = fdt_path_offset(nvtboot_blob, "/chosen"); + if (node < 0) { + printf("Can't find /chosen node in nvtboot DTB\n"); + return node; + } + prop = fdt_getprop(nvtboot_blob, node, "nvidia,ether-mac", &len); + if (!prop) { + printf("Can't find nvidia,ether-mac property in nvtboot DTB\n"); + return -ENOENT; + } + + ret = setenv("ethaddr", (void *)prop); + if (ret) { + printf("Failed to set ethaddr from nvtboot DTB: %d\n", ret); + return ret; + } + + return 0; +} + +int tegra_soc_board_init_late(void) +{ + /* Ignore errors here; not all cases care about Ethernet addresses */ + set_ethaddr_from_nvtboot(); + + return 0; +}

On 12 September 2016 at 11:51, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
On Tegra186, the bootloader which runs before U-Boot passes the Ethernet MAC address to U-Boot using device tree. Extract this value and write it to the environment, so that the Ethernet uclass picks it up and uses it for the built-in Ethernet device.
Signed-off-by: Stephen Warren swarren@nvidia.com
arch/arm/mach-tegra/tegra186/Makefile | 1 + arch/arm/mach-tegra/tegra186/nvtboot_board.c | 54 ++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 arch/arm/mach-tegra/tegra186/nvtboot_board.c
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Sep 12, 2016 at 12:51 PM, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
On Tegra186, the bootloader which runs before U-Boot passes the Ethernet MAC address to U-Boot using device tree. Extract this value and write it to the environment, so that the Ethernet uclass picks it up and uses it for the built-in Ethernet device.
Signed-off-by: Stephen Warren swarren@nvidia.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


From: Stephen Warren swarren@nvidia.com
Tegra186 includes a Synopsys DWC EQoS (Ethernet) device. Add this to the Tegra186 SoC DT so that boards can make use of it.
Signed-off-by: Stephen Warren swarren@nvidia.com --- arch/arm/dts/tegra186.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/arch/arm/dts/tegra186.dtsi b/arch/arm/dts/tegra186.dtsi index f878b6532510..dd9e3b869de7 100644 --- a/arch/arm/dts/tegra186.dtsi +++ b/arch/arm/dts/tegra186.dtsi @@ -31,6 +31,26 @@ #interrupt-cells = <2>; };
+ ethernet@2490000 { + compatible = "nvidia,tegra186-eqos", "snps,dwc-qos-ethernet-4.10"; + reg = <0x0 0x02490000 0x0 0x10000>; + interrupts = <GIC_SPI 194 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&bpmp TEGRA186_CLK_AXI_CBB>, + <&bpmp TEGRA186_CLK_EQOS_AXI>, + <&bpmp TEGRA186_CLK_EQOS_RX>, + <&bpmp TEGRA186_CLK_EQOS_PTP_REF>, + <&bpmp TEGRA186_CLK_EQOS_TX>; + clock-names = "slave_bus", + "master_bus", + "rx", + "ptp_ref", + "tx"; + resets = <&bpmp TEGRA186_RESET_EQOS>; + reset-names = "eqos"; + phy-mode = "rgmii"; + status = "disabled"; + }; + uarta: serial@3100000 { compatible = "nvidia,tegra186-uart", "nvidia,tegra20-uart"; reg = <0x0 0x03100000 0x0 0x10000>;

On 12 September 2016 at 11:51, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
Tegra186 includes a Synopsys DWC EQoS (Ethernet) device. Add this to the Tegra186 SoC DT so that boards can make use of it.
Signed-off-by: Stephen Warren swarren@nvidia.com
arch/arm/dts/tegra186.dtsi | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Sep 12, 2016 at 12:51 PM, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
Tegra186 includes a Synopsys DWC EQoS (Ethernet) device. Add this to the Tegra186 SoC DT so that boards can make use of it.
Signed-off-by: Stephen Warren swarren@nvidia.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


From: Stephen Warren swarren@nvidia.com
Enable the Ethernet device in DT, provide board-specific configuration, and enable the driver in Kconfig.
Signed-off-by: Stephen Warren swarren@nvidia.com --- arch/arm/dts/tegra186-p2771-0000.dtsi | 5 +++++ configs/p2771-0000-000_defconfig | 1 + configs/p2771-0000-500_defconfig | 1 + 3 files changed, 7 insertions(+)
diff --git a/arch/arm/dts/tegra186-p2771-0000.dtsi b/arch/arm/dts/tegra186-p2771-0000.dtsi index d867674fd04e..41ef64479a99 100644 --- a/arch/arm/dts/tegra186-p2771-0000.dtsi +++ b/arch/arm/dts/tegra186-p2771-0000.dtsi @@ -25,6 +25,11 @@ reg = <0x0 0x80000000 0x0 0x60000000>; };
+ ethernet@2490000 { + status = "okay"; + phy-reset-gpios = <&gpio_main TEGRA_MAIN_GPIO(M, 4) GPIO_ACTIVE_LOW>; + }; + i2c@3160000 { status = "okay"; }; diff --git a/configs/p2771-0000-000_defconfig b/configs/p2771-0000-000_defconfig index 4c4606a71ae7..339c29270279 100644 --- a/configs/p2771-0000-000_defconfig +++ b/configs/p2771-0000-000_defconfig @@ -26,6 +26,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_TEGRA186_BPMP_I2C=y +CONFIG_DWC_ETH_QOS=y CONFIG_E1000=y CONFIG_RTL8169=y CONFIG_PCI_TEGRA=y diff --git a/configs/p2771-0000-500_defconfig b/configs/p2771-0000-500_defconfig index b32df1cb0cf7..f9836aea42be 100644 --- a/configs/p2771-0000-500_defconfig +++ b/configs/p2771-0000-500_defconfig @@ -26,6 +26,7 @@ CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y CONFIG_TEGRA186_BPMP_I2C=y +CONFIG_DWC_ETH_QOS=y CONFIG_E1000=y CONFIG_RTL8169=y CONFIG_PCI_TEGRA=y

On 12 September 2016 at 11:51, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
Enable the Ethernet device in DT, provide board-specific configuration, and enable the driver in Kconfig.
Signed-off-by: Stephen Warren swarren@nvidia.com
arch/arm/dts/tegra186-p2771-0000.dtsi | 5 +++++ configs/p2771-0000-000_defconfig | 1 + configs/p2771-0000-500_defconfig | 1 + 3 files changed, 7 insertions(+)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Sep 12, 2016 at 12:51 PM, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
Enable the Ethernet device in DT, provide board-specific configuration, and enable the driver in Kconfig.
Signed-off-by: Stephen Warren swarren@nvidia.com
Acked-by: Joe Hershberger joe.hershberger@ni.com


On 12 September 2016 at 11:51, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
Extend the Tegra186 implementation of board_late_init() to call a per-SoC "hook" function. This will allow SoC-specific (rather than Tegra-wide) functionality to be implemented without the core Tegra code needing to be aware of the details. While board186.c is currently only used for Tegra186, it should be applicable to any other future SoC, and perhaps its simple design could be back-ported to older SoCs in the future too.
Signed-off-by: Stephen Warren swarren@nvidia.com
This series logically relies on the DWC EQOS driver series that I just sent in order for the device to actually work. However, the code should compile and even run (albeit without yet enabling Ethernet) even without both series applied. So, the two series don't need to be applied in any particular order, nor in the same branch.
arch/arm/mach-tegra/board186.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, Sep 12, 2016 at 12:51 PM, Stephen Warren swarren@wwwdotorg.org wrote:
From: Stephen Warren swarren@nvidia.com
Extend the Tegra186 implementation of board_late_init() to call a per-SoC "hook" function. This will allow SoC-specific (rather than Tegra-wide) functionality to be implemented without the core Tegra code needing to be aware of the details. While board186.c is currently only used for Tegra186, it should be applicable to any other future SoC, and perhaps its simple design could be back-ported to older SoCs in the future too.
Signed-off-by: Stephen Warren swarren@nvidia.com
Acked-by: Joe Hershberger joe.hershberger@ni.com

participants (4)
-
Joe Hershberger
-
Joe Hershberger
-
Simon Glass
-
Stephen Warren