From patchwork Fri Oct 29 14:08:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amjad Ouled-Ameur X-Patchwork-Id: 1548038 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.a=rsa-sha256 header.s=20210112 header.b=h2Zf5nC9; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4Hgkmr3Vfbz9sRK for ; Sat, 30 Oct 2021 01:08:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2180C835AF; Fri, 29 Oct 2021 16:08:38 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=baylibre-com.20210112.gappssmtp.com header.i=@baylibre-com.20210112.gappssmtp.com header.b="h2Zf5nC9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A9F848342C; Fri, 29 Oct 2021 16:08:35 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 9DDB7835B0 for ; Fri, 29 Oct 2021 16:08:31 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aouledameur@baylibre.com Received: by mail-wr1-x432.google.com with SMTP id k7so16272405wrd.13 for ; Fri, 29 Oct 2021 07:08:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nn+p65jqiWjkWXfIqdBeapZEMg7/m9utyj670goUHCc=; b=h2Zf5nC9zKkRhr6D/hxhgvL5hNbF31OlA3jmeEkY648Zfk9uKQjRk5Gt7dLY5+iz0P m7WOvK7HLaWY6xTa+qhDUwI6nVpoD0vw97hQFBv9B44s/rJ2MNLclj2LFKf8aXW00Jlz 5FKvvd2XZNv0aEaZk22ylOPoO3fD1W+DeWnrxebFIzalY2fKg4GLONT+S1ux/DmX29mx BPVeB2Kq0DCA4vmpKC/Wuq+M7qAqcQ6AsD5217QorlVX48GzTyJRvf1A7Iem3SBv3fh8 qDBMswVyWArnOQjLbu02mvCVwRrhA+q/zTazw5XnpYTma93hs/FDrH1HhYg48SeissaU S8rg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nn+p65jqiWjkWXfIqdBeapZEMg7/m9utyj670goUHCc=; b=gQdPx3+uUISkMnEBTNYcQdnTa6A+/WbwOIWME2hvPlPbw59rWUXRXiu9GQ+7kZtCJw 3iEV7IHGeCzCE2pZbVctQ0xan+9tor26+gHGXggRs5SstS5eAm1bPBhwdb46tRdekqXr UJ/xroawC9FqaPAAgqEIWbnrEDqS+HVUYp62QthcriSm5v29orLF8JBYY/xqqvW7rS79 LUi9tVnaMX/ZPiLSlYGRFSj2Jquc9TtYAUkWgnFvzClxKVtjqc4JACu9AzTQswcpKatY t2YSE1IN7M0fobwdH1tutjj5Gj1wB5Z97AEsQp5cZEadwEGQmvwXlgJyCNZEGLIguIrl fHBw== X-Gm-Message-State: AOAM532apYIjJOXWImvGnBM+sfbjUp0jUHHfj96KMCPSlGX269nLmQh/ Ifutxz01fD/cx3FWt2wDJ4dpd+QWwN4Bhw== X-Google-Smtp-Source: ABdhPJz9MmjaofbQwPEw2r8dfCFODmsiLjW1mQICTYwA8QRjtHPcZgKf5YNBZ4qD9m1FD3UQXqJhqQ== X-Received: by 2002:adf:e10a:: with SMTP id t10mr14547906wrz.384.1635516508767; Fri, 29 Oct 2021 07:08:28 -0700 (PDT) Received: from localhost.localdomain (203.247.120.78.rev.sfr.net. [78.120.247.203]) by smtp.googlemail.com with ESMTPSA id a26sm5079782wmm.46.2021.10.29.07.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 07:08:28 -0700 (PDT) From: Amjad Ouled-Ameur To: u-boot@lists.denx.de Cc: Amjad Ouled-Ameur , Roger Quadros , Heiko Schocher , Igor Opaniuk , Kory Maincent , Lokesh Vutla , Priyanka Jain , Rick Chen , Sean Anderson , Simon Glass , Tom Rini , khilman@baylibre.com Subject: [PATCH] board: ti: am335x: Choose CPSW or PRUSS configuration based on jumper setting Date: Fri, 29 Oct 2021 16:08:17 +0200 Message-Id: <20211029140817.85307-1-aouledameur@baylibre.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean The am335x-ice-v2 board's Ethernet ports can be configured in 'MII' or 'RMII' mode to be connected to 'PRUSS' or 'CPSW' Ethernet subsystems. This patch sets the environment variable 'ice_mii' to 'mii' or 'rmii' accordingly. Based on that we choose the appropriate board devicetree i.e. 'am335x-ice-v2.dtb' or 'am335x-ice-v2-prueth.dtb'. Since there are 2 Ethernet ports with 2 modes, there can be 4 configurations but for now we consider both ports in different modes to be an invalid configuration and prevent boot in that case. Signed-off-by: Roger Quadros [Amjad: use overlay instead of using new am335x-ice-v2-prueth.dtb] Signed-off-by: Amjad Ouled-Ameur Reviewed-by: Tom Rini --- This depends on the currently in-review patch [0]. [0]: 20211022155526.54368-1-aouledameur@baylibre.com board/ti/am335x/board.c | 17 +++++++++++++++++ include/configs/am335x_evm.h | 5 ++++- include/configs/ti_armv7_common.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/board/ti/am335x/board.c b/board/ti/am335x/board.c index e8555de9c937..b50e7a0fa466 100644 --- a/board/ti/am335x/board.c +++ b/board/ti/am335x/board.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -691,6 +692,8 @@ done: } #endif +static bool prueth_is_mii = true; + /* * Basic board specific setup. Pinmux has been handled already. */ @@ -710,6 +713,8 @@ int board_init(void) if (board_is_icev2()) { int rv; u32 reg; + bool eth0_is_mii = true; + bool eth1_is_mii = true; REQUEST_AND_SET_GPIO(GPIO_PR1_MII_CTRL); /* Make J19 status available on GPIO1_26 */ @@ -740,6 +745,7 @@ int board_init(void) writel(reg, GPIO0_IRQSTATUS1); /* clear irq */ /* RMII mode */ printf("ETH0, CPSW\n"); + eth0_is_mii = false; } else { /* MII mode */ printf("ETH0, PRU\n"); @@ -752,12 +758,21 @@ int board_init(void) /* RMII mode */ printf("ETH1, CPSW\n"); gpio_set_value(GPIO_MUX_MII_CTRL, 1); + eth1_is_mii = false; } else { /* MII mode */ printf("ETH1, PRU\n"); cdce913_data.pdiv2 = 4; /* 25MHz PHY clk */ } + if (eth0_is_mii != eth1_is_mii) { + printf("Unsupported Ethernet port configuration\n"); + printf("Both ports must be set as RMII or MII\n"); + hang(); + } + + prueth_is_mii = eth0_is_mii; + /* disable rising edge IRQs */ reg = readl(GPIO0_RISINGDETECT) & ~BIT(11); writel(reg, GPIO0_RISINGDETECT); @@ -852,6 +867,8 @@ int board_late_init(void) if (is_valid_ethaddr(mac_addr)) eth_env_set_enetaddr("eth1addr", mac_addr); } + + env_set("ice_mii", prueth_is_mii ? "mii" : "rmii"); #endif if (!env_get("serial#")) { diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h index 7fb1b3a3e3fa..0f340806efc9 100644 --- a/include/configs/am335x_evm.h +++ b/include/configs/am335x_evm.h @@ -143,7 +143,10 @@ "if test $board_name = A335X_SK; then " \ "setenv fdtfile am335x-evmsk.dtb; fi; " \ "if test $board_name = A335_ICE; then " \ - "setenv fdtfile am335x-icev2.dtb; fi; " \ + "setenv fdtfile am335x-icev2.dtb; " \ + "if test $ice_mii = mii; then " \ + "setenv pxe_label_override Pruss; fi;" \ + "fi; " \ "if test $fdtfile = undefined; then " \ "echo WARNING: Could not determine device tree to use; fi; \0" \ "init_console=" \ diff --git a/include/configs/ti_armv7_common.h b/include/configs/ti_armv7_common.h index fa48cd2818ce..797e1211980d 100644 --- a/include/configs/ti_armv7_common.h +++ b/include/configs/ti_armv7_common.h @@ -37,6 +37,7 @@ "fdtaddr=0x88000000\0" \ "dtboaddr=0x89000000\0" \ "fdt_addr_r=0x88000000\0" \ + "fdtoverlay_addr_r=0x89000000\0" \ "rdaddr=0x88080000\0" \ "ramdisk_addr_r=0x88080000\0" \ "scriptaddr=0x80000000\0" \