Received: by 2002:ab2:1c04:0:b0:1f7:53ba:1ebe with SMTP id f4csp87800lqg; Fri, 26 Apr 2024 09:27:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWYs00Vz1ChPZNc56y1+9ysKy1XUizqCpZx3QqYQDQgCulHl9V7+T0hzyH8RvcX8XmnwLzUM+XbWRxY4fb6pHXf7EQmF8TWIS6GryXIOg== X-Google-Smtp-Source: AGHT+IFGxwcP9py1jYm9RxQVOVqwUEpGKQpcKDuDhBPy4CVJWaiBydNjBnEOuEPJ43fx9WzjnBzf X-Received: by 2002:a05:6a00:84cc:b0:6f3:e6ac:1a3f with SMTP id gl12-20020a056a0084cc00b006f3e6ac1a3fmr901542pfb.11.1714148840397; Fri, 26 Apr 2024 09:27:20 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714148840; cv=pass; d=google.com; s=arc-20160816; b=zNde98ZaG5wVmTWf98MKz7TXKIPIcJIo56NvWRpFb4d3ZCUUhZ72VkRUBeA1YsGC3V 9Foo6IhyXyigpi7TBKbPaUa6vJRe0V1zTK6Yketi/hGB3vni30LltblQ7UCC4F9WIU5A FPA74Xvw7JXjP7uPAB3DvochELz72LENK3E2UT4GUP9TnMK+N63gE1R3tjGhHimVeK+j iPMxd+ihWfprLisAUNHRWOPjZN0VL3j9IRA6P+QWqR8mH8XKpU4jWzqqNHVX9pFSi03c gboMRXGpIaTA5q7vCTmw2aHr+HhSM5Ssis3b0Bssb9c+rRJHPtz5JJDEYzsz80yKy0RD yYKg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=dLpoxPvvgiNhLq6wWoquSG/kLA+2IkGrgHtcMPVbqTg=; fh=MZgvy/AmeHE5/588XAg1mUij55f12DiWyocFDxS19BU=; b=eO8raYZJMBXzHVoVl5V4CkSSGm8Ofnf3ivDc/cO3xONpi5VjCEKd25RnPA8jIhzfLB b9bOirIVMh5Q8r+y2kho7B2NI1DMzJtXmhtHTgTg0fgJjIYN2ApgmrDbKyVAgD0kY/QS a3WqQuIDIjMaQMVJ1/Sl9uJ0Zwwhps8qX8pu6AjY9J2CYsAvnTz7tijlytu/AH3FM0Vr jRFzhg3V2EoaqxzZu8crjpa+uSoK4bvGsFyfBP5MhE+DkuUE2fSMXVCkJ287SjMcQd9f 7x/hz+dr/EiGHJnlIYAA9URBi0Ainfbe/dwNx7Vb6H8HUCVYol5Z4ercdO0fFX7QLiy7 mPgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=F7Byt8J4; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-kernel+bounces-160350-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id gk9-20020a056a00848900b006ecfdfb8281si14952572pfb.237.2024.04.26.09.27.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Apr 2024 09:27:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-160350-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@denx.de header.s=phobos-20191101 header.b=F7Byt8J4; arc=pass (i=1 spf=pass spfdomain=denx.de dkim=pass dkdomain=denx.de dmarc=pass fromdomain=denx.de); spf=pass (google.com: domain of linux-kernel+bounces-160350-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-160350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=denx.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3D664B27BD7 for ; Fri, 26 Apr 2024 16:02:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B710614D2BC; Fri, 26 Apr 2024 16:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b="F7Byt8J4" 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.subspace.kernel.org (Postfix) with ESMTPS id 71065157463; Fri, 26 Apr 2024 16:00:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=85.214.62.61 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714147262; cv=none; b=hCoFxeO5mRBE7HieDriLrI5l23l4vZHpRwF8sEL8/R6UtE/+uE+7tLAimrFAkEr/i7v3mvrcT+yHRn5UlQ0uKndKrUouIXCIBh0HV1oYAuzEh5Z6SJayZoi0FASY1x4HKIjoReUj43jZS62xRep9KxPXZ2+scftINFVWnzfIEIs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714147262; c=relaxed/simple; bh=uulYlAkCUz11COWeZOP+CzKbGlqVCgeSXf4Xrw39bQg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=rCtjNqSPBG7nxl2u8kQJms9rha1WwbmZ6tacZ2Zx176ORTmvLyzjR4mbbaJQdgHFSbUZ88uBBEFnDG30789fqBHgwFM6JdjX98P4Gx7eQe2MOwUv9S5UfqzZyJYha6AUG7Pp7eMrRgifcpkzfsoVPuBs11VB5444GMxq0u3lA/Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de; spf=pass smtp.mailfrom=denx.de; dkim=pass (2048-bit key) header.d=denx.de header.i=@denx.de header.b=F7Byt8J4; arc=none smtp.client-ip=85.214.62.61 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=denx.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=denx.de Received: from [127.0.0.1] (p578adb1c.dip0.t-ipconnect.de [87.138.219.28]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id 37FCC884F3; Fri, 26 Apr 2024 18:00:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1714147250; bh=dLpoxPvvgiNhLq6wWoquSG/kLA+2IkGrgHtcMPVbqTg=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=F7Byt8J41Nr3+ZuOu+e1nlotRJfZKjoMWnH9uY/GvbLcAwtiQHyUxRzAPgoIq23rl 9NSY1IuO/1boW/8uMSl3ZaxFLmhB/lixjFmp6YUJxuGI06fKzQE2+v4pAKt9BmcGhL k5gO/9+czmd5py0AjXJBdYvhQTBtHInv7dxMsmbxGVcnoW0t8GV/O5hFEp+5r8i2Qq wOkhW80/CgojCeuewAaqVl0i0qmmxP2Nr9v2xh1iawpBamunc4ZThBN6UuH/zTFVFJ b/Fpo/URooZLlUBh9J6yN32sdCVrx3EOO1XBBLoH18vMe5lWLA0/Z+4W+zSQrgCTTU CyyQ/RJ3oToQQ== Message-ID: <56f2d023-82d5-4910-8c4e-68e9d62bd1fe@denx.de> Date: Fri, 26 Apr 2024 16:53:50 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 03/11] net: stmmac: dwmac-stm32: rework glue to simplify management To: Christophe Roullier , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Maxime Coquelin , Alexandre Torgue , Richard Cochran , Jose Abreu , Liam Girdwood , Mark Brown Cc: netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <20240426125707.585269-1-christophe.roullier@foss.st.com> <20240426125707.585269-4-christophe.roullier@foss.st.com> Content-Language: en-US From: Marek Vasut In-Reply-To: <20240426125707.585269-4-christophe.roullier@foss.st.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean On 4/26/24 2:56 PM, Christophe Roullier wrote: > Change glue to be more generic and manage easily next stm32 products. > The goal of this commit is to have one stm32mp1_set_mode function which > can manage different STM32 SOC. SOC can have different SYSCFG register > bitfields. so in pmcsetr we defined the bitfields corresponding to the SOC. > > Signed-off-by: Christophe Roullier > --- > .../net/ethernet/stmicro/stmmac/dwmac-stm32.c | 76 +++++++++++++------ > 1 file changed, 51 insertions(+), 25 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > index c92dfc4ecf57..68a02de25ac7 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-stm32.c > @@ -23,10 +23,6 @@ > > #define SYSCFG_MCU_ETH_MASK BIT(23) > #define SYSCFG_MP1_ETH_MASK GENMASK(23, 16) > -#define SYSCFG_PMCCLRR_OFFSET 0x40 > - > -#define SYSCFG_PMCR_ETH_CLK_SEL BIT(16) > -#define SYSCFG_PMCR_ETH_REF_CLK_SEL BIT(17) > > /* CLOCK feed to PHY*/ > #define ETH_CK_F_25M 25000000 > @@ -46,9 +42,6 @@ > * RMII | 1 | 0 | 0 | n/a | > *------------------------------------------ > */ > -#define SYSCFG_PMCR_ETH_SEL_MII BIT(20) > -#define SYSCFG_PMCR_ETH_SEL_RGMII BIT(21) > -#define SYSCFG_PMCR_ETH_SEL_RMII BIT(23) > #define SYSCFG_PMCR_ETH_SEL_GMII 0 > #define SYSCFG_MCU_ETH_SEL_MII 0 > #define SYSCFG_MCU_ETH_SEL_RMII 1 > @@ -90,19 +83,33 @@ struct stm32_dwmac { > int eth_ref_clk_sel_reg; > int irq_pwr_wakeup; > u32 mode_reg; /* MAC glue-logic mode register */ > + u32 mode_mask; > struct regmap *regmap; > u32 speed; > const struct stm32_ops *ops; > struct device *dev; > }; > > +struct stm32_syscfg_pmcsetr { > + u32 eth1_clk_sel; > + u32 eth1_ref_clk_sel; > + u32 eth1_selmii; > + u32 eth1_sel_rgmii; > + u32 eth1_sel_rmii; > + u32 eth2_clk_sel; > + u32 eth2_ref_clk_sel; > + u32 eth2_sel_rgmii; > + u32 eth2_sel_rmii; > +}; [...] > @@ -487,8 +502,19 @@ static struct stm32_ops stm32mp1_dwmac_data = { > .suspend = stm32mp1_suspend, > .resume = stm32mp1_resume, > .parse_data = stm32mp1_parse_data, > - .syscfg_eth_mask = SYSCFG_MP1_ETH_MASK, > - .clk_rx_enable_in_suspend = true > + .clk_rx_enable_in_suspend = true, > + .syscfg_clr_off = 0x44, > + .pmcsetr = { > + .eth1_clk_sel = BIT(16), > + .eth1_ref_clk_sel = BIT(17), > + .eth1_selmii = BIT(20), > + .eth1_sel_rgmii = BIT(21), > + .eth1_sel_rmii = BIT(23), > + .eth2_clk_sel = 0, > + .eth2_ref_clk_sel = 0, > + .eth2_sel_rgmii = 0, > + .eth2_sel_rmii = 0 > + } > }; Is this structure really necessary ? It seems the MP15 single ethernet config bitfield is at offset 16. MP13 has two bitfields, one at offset 16, the other at offset 24 . All you need to do is figure out which of the two MACs you are configuring, and then shift the bitfield mask by 16 or 24, since the bits are at the same offset for both bitfields. See the matching upstream U-Boot commit for how this shift can be done: a440d19c6c91 ("net: dwc_eth_qos: Add DT parsing for STM32MP13xx platform")