From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 06367C433F5 for ; Fri, 25 Feb 2022 20:33:10 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 55A5B836D2; Fri, 25 Feb 2022 21:33:08 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.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=gmail.com header.i=@gmail.com header.b="CvN37PCW"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9BC87800C2; Fri, 25 Feb 2022 21:33:05 +0100 (CET) Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) (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 40141838B9 for ; Fri, 25 Feb 2022 21:33:01 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=aford173@gmail.com Received: by mail-il1-x12c.google.com with SMTP id w4so5227903ilj.5 for ; Fri, 25 Feb 2022 12:33:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=4ZokPBHm+QmawFGQPqTM1kDFp1Ab8MGR6pw9C6kuO0c=; b=CvN37PCW+3/Ys6J8xvBOS+prDtWkMBT0YMF8uYKAfzzw7hI2+z1x0RMd23Ek4NtpFC La3nblrNyqKkXCABnVYVwVoBDpgCpI7L9FCzwGJnJyDgriN9d+vOxZBwzYIeQIbJFH1C PHzAXyk8omWYvCBGBEmVMrr8+eQH/K9tVQB8tUHgcSjVDXg34a4ebgYlFiYffTby8owk 682sy8dwkhlHT6YZA6C/E6FwqVP3W/Tgic+4SfD7m8qecQHq4ExPgCftXWqV6htkbg7d T/5hzdFzI9MJnzSEtj3Wyaa7UbljTnsrSzHMktNsozT/t+MYdgIP9VnlJwMqhZk6Oza8 ieTQ== 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=4ZokPBHm+QmawFGQPqTM1kDFp1Ab8MGR6pw9C6kuO0c=; b=CAdKJjZ4PnefYk4C4Z/v7FI3VL+k06Q8XaMwT/F8BV0k7phGwnXNIXzg//jbQbpDXE fSiS7IUbzW4lCOWwi6froFfdY4/MfIexnYZ1C7di4/ILsoUT+0HLtQBSkWxbuay6aUQF SyGPG40DiZ2rNFghhKPDMrtmFD2zoFIzcgCafPG6MMmVgLLxUIZKHKu1nx0OYOKIh/8G 8O3foFwngyHEZ9Z7nuyM1NTRf0lKgpyH6dXzJ+DJPCoGHtOCYUePqidfms3ICXDWuMzV Mvb+AhKJ2FR/KbmxEIYu3d/Aoyn5XuyPx5d2GY1tQbutiuafe0dT7RLJvSSWLK3EE+/9 S2hw== X-Gm-Message-State: AOAM530cFKYeI8wJa1GLMhqgZliOuFLLYo39FynY5wZ7P3oKU1bFmd2s +6VWmeSZhtpEldEq1aQC0g5qnqgV4lQo3g== X-Google-Smtp-Source: ABdhPJzP3wuWuixzCUxQzRLkO78ACpEKJ23Y/BU9Xo3vSyCA6J/j586BmEkvpCqAjJJ/Dlsw1k32Sg== X-Received: by 2002:a05:6e02:1788:b0:2c2:461a:61fb with SMTP id y8-20020a056e02178800b002c2461a61fbmr7513993ilu.74.1645821179223; Fri, 25 Feb 2022 12:32:59 -0800 (PST) Received: from aford-IdeaCentre-A730.lan ([2601:448:8400:9e8:5b80:a4b8:a089:497a]) by smtp.gmail.com with ESMTPSA id h124-20020a6bb782000000b00641955d3baesm2155813iof.18.2022.02.25.12.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 12:32:58 -0800 (PST) From: Adam Ford To: u-boot@lists.denx.de Cc: marex@denx.de, aford@beaconembedded.com, cstevens@beaconembedded.com, Adam Ford , Joe Hershberger , Ramon Fried Subject: [PATCH V3 1/2] net: ravb: Add tx/rx delay flag checks and support for rgmii-rxid Date: Fri, 25 Feb 2022 14:32:52 -0600 Message-Id: <20220225203253.526207-1-aford173@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.5 at phobos.denx.de X-Virus-Status: Clean Some boards like the Beacon RZ/G2 SOM use either flags for tx-internal-delay-ps, rx-internal-delay-ps or rgmii-rxid. In Linux the APSR_RDM flag is set when either rx-internal-delay-ps is set or the mode is rgmii-rxid, and the APSR_TDM is set when tx-internal-delay-ps is found or rgmii-txid is set, and both are set if rgmii-id is set. The ravb driver in U-Boot driver was missing rgmii-rxid support, so add that support in a similar fashion to what is done in Linux. Signed-off-by: Adam Ford --- V3: Re-order the checks for rx/tx-internal-delay-ps so the rx comes before the tx. V2: Add boolean for explit delays which skips the rgmii mode check if explicit delays are set. This more closely matches the behavior in Linux. Also add the same comments for the delays to match the comments found in Linux. diff --git a/drivers/net/ravb.c b/drivers/net/ravb.c index 1d1118c341..4078d33bb5 100644 --- a/drivers/net/ravb.c +++ b/drivers/net/ravb.c @@ -52,6 +52,7 @@ #define CSR_OPS 0x0000000F #define CSR_OPS_CONFIG BIT(1) +#define APSR_RDM BIT(13) #define APSR_TDM BIT(14) #define TCCR_TSRQ0 BIT(0) @@ -376,6 +377,9 @@ static int ravb_dmac_init(struct udevice *dev) struct ravb_priv *eth = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_plat(dev); int ret = 0; + int mode = 0; + unsigned int delay; + bool explicit_delay = false; /* Set CONFIG mode */ ret = ravb_reset(dev); @@ -402,9 +406,33 @@ static int ravb_dmac_init(struct udevice *dev) (rmobile_get_cpu_type() == RMOBILE_CPU_TYPE_R8A77995)) return 0; - if ((pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID) || - (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID)) - writel(APSR_TDM, eth->iobase + RAVB_REG_APSR); + if (!dev_read_u32(dev, "rx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 1800, according to DT bindings */ + if (delay) { + mode |= APSR_RDM; + explicit_delay = true; + } + } + + if (!dev_read_u32(dev, "tx-internal-delay-ps", &delay)) { + /* Valid values are 0 and 2000, according to DT bindings */ + if (delay) { + mode |= APSR_TDM; + explicit_delay = true; + } + } + + if (!explicit_delay) { + if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_RXID) + mode |= APSR_RDM; + + if (pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_ID || + pdata->phy_interface == PHY_INTERFACE_MODE_RGMII_TXID) + mode |= APSR_TDM; + } + + writel(mode, eth->iobase + RAVB_REG_APSR); return 0; } -- 2.34.1