From patchwork Fri Feb 3 19:09:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Antonov X-Patchwork-Id: 1737208 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=OLEkxpVq; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P7lZh5LCLz23h0 for ; Sat, 4 Feb 2023 06:09:30 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 510B785FBD; Fri, 3 Feb 2023 20:09:25 +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="OLEkxpVq"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B6A7185F90; Fri, 3 Feb 2023 20:09:22 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) (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 2023C85F90 for ; Fri, 3 Feb 2023 20:09:20 +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=saproj@gmail.com Received: by mail-ej1-x635.google.com with SMTP id ud5so18045095ejc.4 for ; Fri, 03 Feb 2023 11:09:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Y3rnmGxNmowsuRspbI4wzKXm8J7tHl7zjKhPKZDAn3g=; b=OLEkxpVqxqr6NGzJLPaYePHiZLK74smHC8ZKqi74nAgIZ+i67hGhnQnJt56RA5ce4D qPb/rTTrt9jKgmBOXnw8YMktUYfVJ7/m87ZspJmHfPzaooEJHB9DD0UsTl+ZH9JyYxAd 9AnvS+NbNThxtFfHQgWY2uuRWLaWAcBuF6uCxwev4oHpFdXxlpImTdAJfVAKfXE3iioy qc3uQyAk1Or8qLwfeermszuiprB1F9mRO2T1t5t47W0DWHRthR2VV/atLdhVtXz0K56U 6GkaZq1kanM5PM9OfV24w4S4dPPJujpuBqQDqYsgn2bJpi3isE1Lq3U8Uq/m3Ro36tHw SNlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Y3rnmGxNmowsuRspbI4wzKXm8J7tHl7zjKhPKZDAn3g=; b=S/3YXrcuuaQHypDI608iZlqlqtnXmoO6fj3Qp0VhZsktIvYIVZedV7mIVdRYcQiieH GRDZobKOksVqPe7jLxwp3GxcGGyrut7EL3rh286QuWMb+7mz4y8IKVtKeSuKT5RJ5ueH YqiT7k1q9WeAXTZbh7ISyHYg0PbRRPJhLjLiD3bb3L9DssqHK2k9BLrfOXbO5vl4zIGc NmMszYCNqZ7g5gbUQYRU1hZVURJU6rVr4xBGFieJbjkml/3QV98ahzW+zBQyHK9bzmPJ OgaptkHwTRrPJZFnKp8kGc+7zO0dGahEJOa3hl78jx6Fq46Ions2lJkcSxuDlR9EKI4Z ucww== X-Gm-Message-State: AO0yUKUVuogx+GfLAudXtPlvQ4jQ7oCQ/E5ajcAIJ4Sy8fpFErMjYDRo EwLcDflgafVnRWEwfmEY2kJ+olmOYYI= X-Google-Smtp-Source: AK7set8zMB6xS0+OIdyxrV30gG7SBtVqyD0Iu/Cz8uf9w/gWKUyhrl/E2wlaT//jfE8SymX358jFVA== X-Received: by 2002:a17:907:6d15:b0:872:b1d7:8028 with SMTP id sa21-20020a1709076d1500b00872b1d78028mr15893220ejc.3.1675451359618; Fri, 03 Feb 2023 11:09:19 -0800 (PST) Received: from saproj-Latitude-5501.yandex.net ([2a02:6b8:0:40c:d7f7:41cb:f2:d80c]) by smtp.gmail.com with ESMTPSA id y14-20020a170906448e00b008787becf3a8sm1753762ejo.79.2023.02.03.11.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:09:19 -0800 (PST) From: Sergei Antonov To: u-boot@lists.denx.de, rfried.dev@gmail.com, joe.hershberger@ni.com Cc: Sergei Antonov Subject: [PATCH v3 1/3] net: ftmac100: change driver name from nds32_mac to ftmac100 Date: Fri, 3 Feb 2023 22:09:02 +0300 Message-Id: <20230203190904.2448780-1-saproj@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean So it will be named similarly to the related ftgmac100 driver. The old name 'nds32_mac' is not referred to anywhere in U-Boot. Signed-off-by: Sergei Antonov Reviewed-by: Ramon Fried Reviewed-by: Rick Chen --- v2 -> v3: no change v1 -> v2: no change drivers/net/ftmac100.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index f710c271c64b..7c89d7f67b8d 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -348,7 +348,7 @@ static const struct udevice_id ftmac100_ids[] = { }; U_BOOT_DRIVER(ftmac100) = { - .name = "nds32_mac", + .name = "ftmac100", .id = UCLASS_ETH, .of_match = ftmac100_ids, .bind = ftmac100_bind, From patchwork Fri Feb 3 19:09:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Antonov X-Patchwork-Id: 1737209 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=T+TOfNmT; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P7lZt4LBGz23h0 for ; Sat, 4 Feb 2023 06:09:42 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BA9E6856F4; Fri, 3 Feb 2023 20:09:34 +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="T+TOfNmT"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E19A585F93; Fri, 3 Feb 2023 20:09:27 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) (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 BADC685F91 for ; Fri, 3 Feb 2023 20:09:24 +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=saproj@gmail.com Received: by mail-ej1-x62f.google.com with SMTP id lu11so18063234ejb.3 for ; Fri, 03 Feb 2023 11:09:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RO9UhRzE/auOW0eZkRNnKUbxSCRZc/FQFUorVQ9Mfgg=; b=T+TOfNmTLew2sNTbpBX2r3s63elpJKbqXhiCKcFvIu5CnnUy1TeSR/uE9BiyA5sApI RM5B7y+PK882OptdXxT6Os1BD+dDXZi+gjEGYYFmT7FSRCRSlmcrDEXss0f/+RBqOvmX enhOWOZyBLU+33Q10/2yH0uRXuQ0OQkAvT0o09uyGBD8bpJrLpLm/luDXGwrkTUr3m0c pGF9XkvsI+oT1Ef6I+zdSFoECkTzf9THQ98CVYQ1hgXxZnJVFNoNqRVA1LstG65IJ48f 0V6IFmqAUcnGCd+uSpBuirfC4TLHjrPPu4flvNCGbQiB8XMkeuJoJppD34YdUWuzv4Xb KuDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RO9UhRzE/auOW0eZkRNnKUbxSCRZc/FQFUorVQ9Mfgg=; b=gRXLLHi+QRAC6BexY4nRBNpKoMZmslXCqc98lWdLIvbTHtZ/iMg+Sj8x3qIHyc4p2b O5zApxno9321XqYlonbgvVr0XMmGsFi/ZleZseXGD0pKtLzC1HIy6g7700Voz623x3gV KxRHHPLdnmiHinWax8wLoY5VVPhDXYxhA+KdWHxO2K12grJeCJNz90Jmsqnnb5qCU5Xq Gu1wTYlQq3EokSmvHxl4cZhQrZg4ro1irNet11Vy+e36AyuaIiec6xGe6AeR5armjdCq 6SKGwYFM1tRI58Jc9CZe0PQ+94HLrpZEdzJiMC7AOfibPdckIMypQoJbRBkYERsWk4VB wljg== X-Gm-Message-State: AO0yUKU+bAGtMmWZgDcXovV4S5TM2MQuf7NvroYAFwRVYSiqnFR9cKo8 hPArZH5dp6lv5mTf1VyTYO2M/zfDkSA= X-Google-Smtp-Source: AK7set/X17ejb0AcKZhN/KYAsLvmVxy8CMe6V3JHpSRh+0iFYMPkAbOmTN4sB5moHlFjhT3bPMM9dA== X-Received: by 2002:a17:907:6d96:b0:88d:ba89:183c with SMTP id sb22-20020a1709076d9600b0088dba89183cmr7748638ejc.13.1675451364299; Fri, 03 Feb 2023 11:09:24 -0800 (PST) Received: from saproj-Latitude-5501.yandex.net ([2a02:6b8:0:40c:d7f7:41cb:f2:d80c]) by smtp.gmail.com with ESMTPSA id y14-20020a170906448e00b008787becf3a8sm1753762ejo.79.2023.02.03.11.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:09:24 -0800 (PST) From: Sergei Antonov To: u-boot@lists.denx.de, rfried.dev@gmail.com, joe.hershberger@ni.com Cc: Sergei Antonov Subject: [PATCH v3 2/3] net: ftmac100: simplify priv->iobase casting Date: Fri, 3 Feb 2023 22:09:03 +0300 Message-Id: <20230203190904.2448780-2-saproj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203190904.2448780-1-saproj@gmail.com> References: <20230203190904.2448780-1-saproj@gmail.com> MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean Replace 'phys_addr_t iobase' with 'struct ftmac100 *ftmac100' in struct ftmac100_data. It allows to remove casting in a number of places. Since priv->iobase is phys_addr_t, use phys_to_virt() to make a pointer from it. Signed-off-by: Sergei Antonov Reviewed-by: Rick Chen --- v2 -> v3: Fix the following warning by using phys_to_virt() to get a pointer from phys_addr_t. (ae350_rv32) drivers/net/ftmac100.c:317:26: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast] (ae350_rv32) 317 | priv->ftmac100 = (struct ftmac100 *)pdata->iobase; v1 -> v2: no change drivers/net/ftmac100.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index 7c89d7f67b8d..e7b9d88ea9cd 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -28,7 +28,7 @@ struct ftmac100_data { struct ftmac100_rxdes rxdes[PKTBUFSRX]; int rx_index; const char *name; - phys_addr_t iobase; + struct ftmac100 *ftmac100; }; /* @@ -36,7 +36,7 @@ struct ftmac100_data { */ static void ftmac100_reset(struct ftmac100_data *priv) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; debug ("%s()\n", __func__); @@ -57,7 +57,7 @@ static void ftmac100_reset(struct ftmac100_data *priv) static void ftmac100_set_mac(struct ftmac100_data *priv , const unsigned char *mac) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; unsigned int maddr = mac[0] << 8 | mac[1]; unsigned int laddr = mac[2] << 24 | mac[3] << 16 | mac[4] << 8 | mac[5]; @@ -72,7 +72,7 @@ static void ftmac100_set_mac(struct ftmac100_data *priv , */ static void _ftmac100_halt(struct ftmac100_data *priv) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; debug ("%s()\n", __func__); writel (0, &ftmac100->maccr); } @@ -82,7 +82,7 @@ static void _ftmac100_halt(struct ftmac100_data *priv) */ static int _ftmac100_init(struct ftmac100_data *priv, unsigned char enetaddr[6]) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; struct ftmac100_txdes *txdes = priv->txdes; struct ftmac100_rxdes *rxdes = priv->rxdes; unsigned int maccr; @@ -187,7 +187,7 @@ static int __ftmac100_recv(struct ftmac100_data *priv) */ static int _ftmac100_send(struct ftmac100_data *priv, void *packet, int length) { - struct ftmac100 *ftmac100 = (struct ftmac100 *)(uintptr_t)priv->iobase; + struct ftmac100 *ftmac100 = priv->ftmac100; struct ftmac100_txdes *curr_des = priv->txdes; ulong start; @@ -314,7 +314,7 @@ static int ftmac100_of_to_plat(struct udevice *dev) struct eth_pdata *pdata = dev_get_plat(dev); const char *mac; pdata->iobase = dev_read_addr(dev); - priv->iobase = pdata->iobase; + priv->ftmac100 = phys_to_virt(pdata->iobase); mac = dtbmacaddr(0); if (mac) memcpy(pdata->enetaddr , mac , 6); From patchwork Fri Feb 3 19:09:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergei Antonov X-Patchwork-Id: 1737210 X-Patchwork-Delegate: rfried.dev@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.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=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=foqjgjmP; dkim-atps=neutral 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 ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P7lb91Bhgz23h0 for ; Sat, 4 Feb 2023 06:09:57 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E712D85FCA; Fri, 3 Feb 2023 20:09:37 +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="foqjgjmP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 20F6985F91; Fri, 3 Feb 2023 20:09:29 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) (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 3F26085FC2 for ; Fri, 3 Feb 2023 20:09:26 +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=saproj@gmail.com Received: by mail-ej1-x632.google.com with SMTP id dr8so17940187ejc.12 for ; Fri, 03 Feb 2023 11:09:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/kNG36ExOiZNKmJUOlbycUxdYfRNc7uP2HWScUbgsXA=; b=foqjgjmPLFa6fJBCukdjRU4yPwrkMFA9x48Ha6/zBl5UYBWJZ2kqQn+CEALZYb1IKR YepZhHuRMvc/bTs5AxE3Hx00w9oJPt/M0WfprjlTdPG3seL5q8SSZrX4fUfh4vEYb31z mkfxBGOUP0rXWlue3ou7314i7+qP8xT3wMFS00aB9H1yo89235EsB18CrhRn7udiVUKb 9SgjkDAqORnFrDbQwWziEcp6eVyo2joodFkMwuCAC922vsIhqszx8j9sA8OtaMnObLYM 5Qqd+IzrCrVZjg8YItjRB7Ix8u4ZzB+i+BaogGHHYamUR4ZosHD/VLWZwut1dO9FmWzk AosA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/kNG36ExOiZNKmJUOlbycUxdYfRNc7uP2HWScUbgsXA=; b=OGtUPpn/xWPkSmZS5RAJGznG03KOAfftgEgyDtGF+wUea5JIP3hvgtNHpk1pG4Kokf zXon66W0HXlp9AnhaBYGGH/KxHmgDJcnKje69Os28T51l/C2OjwNT0x+kMqHltvlFIkM J/+4Np9kCZKEZICV5hJceUYnNxlyiGSxiedZBpU6KuJfbMmQzI286u4iw4YeG7Mzntxw 9Fi7XgW03501WSzHwRct+pvraaIz/c2AtSdjwzJ0usWEyAHbUB493ckucYIz6yEUMrYx XV+4+1jFOleZ1iCcCmFMaFbPBcBiVaRF9a2DzoTU/RbukoAL6epTeer6az41QmsGafJI KDiQ== X-Gm-Message-State: AO0yUKV51/me5oZSwi0Ew7UwRKDWXIBeENcVsB2PqXM95uKJfRKzXwLY Avt5s+G+D2Ycj0nEJ4hrVIn0KOSs5Pc= X-Google-Smtp-Source: AK7set8HVx43D/ykhXHzRNooZlEhREX4I/WJ3HGLNw2O+2Z1HvCCYiN22rDlBGRrdOCiB6XPFNJq/w== X-Received: by 2002:a17:907:990b:b0:87b:dac1:bbe6 with SMTP id ka11-20020a170907990b00b0087bdac1bbe6mr12074867ejc.36.1675451365889; Fri, 03 Feb 2023 11:09:25 -0800 (PST) Received: from saproj-Latitude-5501.yandex.net ([2a02:6b8:0:40c:d7f7:41cb:f2:d80c]) by smtp.gmail.com with ESMTPSA id y14-20020a170906448e00b008787becf3a8sm1753762ejo.79.2023.02.03.11.09.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Feb 2023 11:09:25 -0800 (PST) From: Sergei Antonov To: u-boot@lists.denx.de, rfried.dev@gmail.com, joe.hershberger@ni.com Cc: Sergei Antonov Subject: [PATCH v3 3/3] net: ftmac100: add mii read and write callbacks Date: Fri, 3 Feb 2023 22:09:04 +0300 Message-Id: <20230203190904.2448780-3-saproj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230203190904.2448780-1-saproj@gmail.com> References: <20230203190904.2448780-1-saproj@gmail.com> MIME-Version: 1.0 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.6 at phobos.denx.de X-Virus-Status: Clean Register mii_bus with read and write callbacks to allow the 'mii' command to work. Use a timeout of 10 ms to wait for the R/W operations to complete. Signed-off-by: Sergei Antonov Reviewed-by: Rick Chen Tested-by: Rick Chen --- v2 -> v3: no change v1 -> v2: * fix a typo in the description * add a dependency from MII to Kconfig drivers/net/Kconfig | 1 + drivers/net/ftmac100.c | 103 +++++++++++++++++++++++++++++++++++++++++ drivers/net/ftmac100.h | 9 ++++ 3 files changed, 113 insertions(+) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 62d2c03849af..6006cfc82d50 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -406,6 +406,7 @@ config FSL_FM_10GEC_REGULAR_NOTATION config FTMAC100 bool "Ftmac100 Ethernet Support" + select MII help This MAC is present in Andestech SoCs. diff --git a/drivers/net/ftmac100.c b/drivers/net/ftmac100.c index e7b9d88ea9cd..fae3adc3de34 100644 --- a/drivers/net/ftmac100.c +++ b/drivers/net/ftmac100.c @@ -12,9 +12,13 @@ #include #include #include +#include +#include +#include #include #include #include +#include #include "ftmac100.h" #include @@ -23,12 +27,16 @@ DECLARE_GLOBAL_DATA_PTR; #define ETH_ZLEN 60 +/* Timeout for a mdio read/write operation */ +#define FTMAC100_MDIO_TIMEOUT_USEC 10000 + struct ftmac100_data { struct ftmac100_txdes txdes[1]; struct ftmac100_rxdes rxdes[PKTBUFSRX]; int rx_index; const char *name; struct ftmac100 *ftmac100; + struct mii_dev *bus; }; /* @@ -322,10 +330,104 @@ static int ftmac100_of_to_plat(struct udevice *dev) return 0; } +/* + * struct mii_bus functions + */ +static int ftmac100_mdio_read(struct mii_dev *bus, int addr, int devad, + int reg) +{ + struct ftmac100_data *priv = bus->priv; + struct ftmac100 *ftmac100 = priv->ftmac100; + int phycr = FTMAC100_PHYCR_PHYAD(addr) | + FTMAC100_PHYCR_REGAD(reg) | + FTMAC100_PHYCR_MIIRD; + int ret; + + writel(phycr, &ftmac100->phycr); + + ret = readl_poll_timeout(&ftmac100->phycr, phycr, + !(phycr & FTMAC100_PHYCR_MIIRD), + FTMAC100_MDIO_TIMEOUT_USEC); + if (ret) + pr_err("%s: mdio read failed (addr=0x%x reg=0x%x)\n", + bus->name, addr, reg); + else + ret = phycr & FTMAC100_PHYCR_MIIRDATA; + + return ret; +} + +static int ftmac100_mdio_write(struct mii_dev *bus, int addr, int devad, + int reg, u16 value) +{ + struct ftmac100_data *priv = bus->priv; + struct ftmac100 *ftmac100 = priv->ftmac100; + int phycr = FTMAC100_PHYCR_PHYAD(addr) | + FTMAC100_PHYCR_REGAD(reg) | + FTMAC100_PHYCR_MIIWR; + int ret; + + writel(value, &ftmac100->phywdata); + writel(phycr, &ftmac100->phycr); + + ret = readl_poll_timeout(&ftmac100->phycr, phycr, + !(phycr & FTMAC100_PHYCR_MIIWR), + FTMAC100_MDIO_TIMEOUT_USEC); + if (ret) + pr_err("%s: mdio write failed (addr=0x%x reg=0x%x)\n", + bus->name, addr, reg); + + return ret; +} + +static int ftmac100_mdio_init(struct udevice *dev) +{ + struct ftmac100_data *priv = dev_get_priv(dev); + struct mii_dev *bus; + int ret; + + bus = mdio_alloc(); + if (!bus) + return -ENOMEM; + + bus->read = ftmac100_mdio_read; + bus->write = ftmac100_mdio_write; + bus->priv = priv; + + ret = mdio_register_seq(bus, dev_seq(dev)); + if (ret) { + mdio_free(bus); + return ret; + } + + priv->bus = bus; + + return 0; +} + static int ftmac100_probe(struct udevice *dev) { struct ftmac100_data *priv = dev_get_priv(dev); priv->name = dev->name; + int ret = 0; + + ret = ftmac100_mdio_init(dev); + if (ret) { + dev_err(dev, "Failed to initialize mdiobus: %d\n", ret); + goto out; + } + +out: + return ret; +} + +static int ftmac100_remove(struct udevice *dev) +{ + struct ftmac100_data *priv = dev_get_priv(dev); + + mdio_unregister(priv->bus); + mdio_free(priv->bus); + return 0; } @@ -354,6 +456,7 @@ U_BOOT_DRIVER(ftmac100) = { .bind = ftmac100_bind, .of_to_plat = ftmac100_of_to_plat, .probe = ftmac100_probe, + .remove = ftmac100_remove, .ops = &ftmac100_ops, .priv_auto = sizeof(struct ftmac100_data), .plat_auto = sizeof(struct eth_pdata), diff --git a/drivers/net/ftmac100.h b/drivers/net/ftmac100.h index 75a49f628a69..21d339f835bf 100644 --- a/drivers/net/ftmac100.h +++ b/drivers/net/ftmac100.h @@ -92,6 +92,15 @@ struct ftmac100 { #define FTMAC100_MACCR_RX_MULTIPKT (1 << 16) #define FTMAC100_MACCR_RX_BROADPKT (1 << 17) +/* + * PHY control register + */ +#define FTMAC100_PHYCR_MIIRDATA 0xffff +#define FTMAC100_PHYCR_PHYAD(x) (((x) & 0x1f) << 16) +#define FTMAC100_PHYCR_REGAD(x) (((x) & 0x1f) << 21) +#define FTMAC100_PHYCR_MIIWR BIT(27) +#define FTMAC100_PHYCR_MIIRD BIT(26) + /* * Transmit descriptor, aligned to 16 bytes */