From nobody Sun Feb 8 22:49:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 519DBEB64D7 for ; Tue, 20 Jun 2023 11:41:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232110AbjFTLlD (ORCPT ); Tue, 20 Jun 2023 07:41:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbjFTLk7 (ORCPT ); Tue, 20 Jun 2023 07:40:59 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF654A1 for ; Tue, 20 Jun 2023 04:40:58 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-4f85966b0f2so5369591e87.3 for ; Tue, 20 Jun 2023 04:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1687261257; x=1689853257; 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=ZNFZpEh4/cl7s83JmJ5khDQ6aml5OmK6AW+M363aFjU=; b=biDDrOKTzHLYitPYod0RIO44Z1JCB7Vq+G/s+gIYRJ2XB3b8jr5tsk0/Ye8+Kzh0LE Eh+8lJrPZvu97GzuuyWh78xXH1gh8GVwXM9ymXeSG3xrnPYwkR20MrEBXlcBtDrp2gUD pmxc6LeLO/SoMTCZtrJz2gDxUEYFN7NpO4t9Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687261257; x=1689853257; 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=ZNFZpEh4/cl7s83JmJ5khDQ6aml5OmK6AW+M363aFjU=; b=bmH+bsOE1f2i8p55AqRn9/w7xdPWgByvGIUACAhccJ41WVNTU/tNH9n3nD461VjAey c8imF1x6uASA+ML6otHxHPSKL4KGwcOOCCO6tZWASBzwdK4dGJTzALDIcNiAdD6ykqxN 4QBoULWEZl4yoTHOnOWNZAtsDXXGDfq6vQzvrwe/xyvAAUGvwEnwG2dCwPhjEWbWaYZy Zus40OeaIL2V6vRVrmeCHrvGmrlbC7hQV/UAE50fim6mZkKJhAh9DEIZR0qyzdmGhtkv 4vGbRsvgjSS2whLVAXXP8UF2pr0QwSP4LT2W2E+LdGv6Zs3CuyMeN4+sAIZgP6gS6vdv EdcA== X-Gm-Message-State: AC+VfDy7ev67MsaD4+BfqO/VXWgbH7R/8p3Fw4PpFLfOmCbsh1k1yfRy 8cOVkD9sN8Jhz2YIALPZHg1tZvuyNjmP30lxhh37ig== X-Google-Smtp-Source: ACHHUZ7q/79IAx2fL0zq/CrCtVLiuxKFTR+X1CC55xo2T25ZTgPLBk21UNhluCFwBxX9meKQmLwfHg== X-Received: by 2002:a05:6512:3284:b0:4f8:692a:6492 with SMTP id p4-20020a056512328400b004f8692a6492mr4413487lfe.32.1687261256749; Tue, 20 Jun 2023 04:40:56 -0700 (PDT) Received: from localhost.localdomain ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id d12-20020ac2544c000000b004f84162e08bsm329879lfn.185.2023.06.20.04.40.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:40:56 -0700 (PDT) From: Rasmus Villemoes To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Rasmus Villemoes , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 1/3] net: dsa: microchip: simplify ksz_prmw8() Date: Tue, 20 Jun 2023 13:38:52 +0200 Message-Id: <20230620113855.733526-2-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230620113855.733526-1-linux@rasmusvillemoes.dk> References: <20230620113855.733526-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Implement ksz_prmw8() in terms of ksz_rmw8(), just as all the other ksz_pX are implemented in terms of ksz_X. No functional change. Signed-off-by: Rasmus Villemoes Acked-by: Arun Ramadoss Reviewed-by: Simon Horman --- drivers/net/dsa/microchip/ksz_common.h | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index a66b56857ec6..2453c43c48a5 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -578,17 +578,8 @@ static inline int ksz_pwrite32(struct ksz_device *dev,= int port, int offset, static inline int ksz_prmw8(struct ksz_device *dev, int port, int offset, u8 mask, u8 val) { - int ret; - - ret =3D regmap_update_bits(ksz_regmap_8(dev), - dev->dev_ops->get_port_addr(port, offset), - mask, val); - if (ret) - dev_err(dev->dev, "can't rmw 8bit reg 0x%x: %pe\n", - dev->dev_ops->get_port_addr(port, offset), - ERR_PTR(ret)); - - return ret; + return ksz_rmw8(dev, dev->dev_ops->get_port_addr(port, offset), + mask, val); } =20 static inline void ksz_regmap_lock(void *__mtx) --=20 2.37.2 From nobody Sun Feb 8 22:49:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 51935EB64D7 for ; Tue, 20 Jun 2023 11:41:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232712AbjFTLlJ (ORCPT ); Tue, 20 Jun 2023 07:41:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231995AbjFTLlD (ORCPT ); Tue, 20 Jun 2023 07:41:03 -0400 Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8CBEA1 for ; Tue, 20 Jun 2023 04:41:00 -0700 (PDT) Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-4f8777caaa1so1646136e87.3 for ; Tue, 20 Jun 2023 04:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1687261258; x=1689853258; 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=JJfdnRF9Vl6raSksJddU5E+UCkdBzgf8ixFIV7tG5Fw=; b=aCHgr6eVSbF0sSWS5KVz9OjzuyyOGXqeZUBI0EscRJLFniU0QgYOewzKkCo2rbRrx8 ijBX2GBsdGtOaWilHopc/qpeNyp6ZgmM/8dFQPmUE3Rtvzj+9l9NhwhMAB6dax5F+hTu 6kahIyVtuf4p69CJYbUfyrXFSVXC4gFGziL6A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687261258; x=1689853258; 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=JJfdnRF9Vl6raSksJddU5E+UCkdBzgf8ixFIV7tG5Fw=; b=HhmYlYih86WmQLY47qVOoUUF5OhCWj0grRVy1XLaj+Nkl6RNoiygjoBhVEfevSXiHL VEnI0yxZcR4FhbV3ywxJzbyzhrRBrup3LkBI+NVRF9Eua192LOr2qq1cplwN/ucIJhZ3 zOJGieTDsBaYoTXW7o6DoVXTo66F9V2kvPXlLj0HUEGs6rEC6Z70Ag9UvcDgzEVoU7Sq gMkBCdvVYv+KWwx+jqbmEx29mGR51ErhsSVjPP8VM4IbBaiV5BAPX87iIa/N+D9oX3Ng DnpXAK4PARJ8XwlVPdiKpDImewGZe/qc511t75mfbRGs1bdTyPnYgBqZ1WCgPlNjvzt+ Q8oA== X-Gm-Message-State: AC+VfDzS7eopl4GOYFkvJmyEVGyn+sGiT8+ss8qpnAibNql/XT1hI5c+ Fe7coeIJIcqWGrhW5Tuk3AasGA== X-Google-Smtp-Source: ACHHUZ6aWAoO8+VPVomym/NUP8XMNnTvJPPQS+D3kdspQ2LETykVC5sXLHUYealrRYHrLzJsXjIZxA== X-Received: by 2002:a19:8c14:0:b0:4f8:7333:d1fd with SMTP id o20-20020a198c14000000b004f87333d1fdmr3097994lfd.34.1687261257806; Tue, 20 Jun 2023 04:40:57 -0700 (PDT) Received: from localhost.localdomain ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id d12-20020ac2544c000000b004f84162e08bsm329879lfn.185.2023.06.20.04.40.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:40:57 -0700 (PDT) From: Rasmus Villemoes To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Rasmus Villemoes , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 2/3] net: dsa: microchip: add ksz_prmw32() helper Date: Tue, 20 Jun 2023 13:38:53 +0200 Message-Id: <20230620113855.733526-3-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230620113855.733526-1-linux@rasmusvillemoes.dk> References: <20230620113855.733526-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This will be used in a subsequent patch fixing an errata for writes to certain PHY registers. Signed-off-by: Rasmus Villemoes Acked-by: Arun Ramadoss Reviewed-by: Simon Horman --- drivers/net/dsa/microchip/ksz_common.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/net/dsa/microchip/ksz_common.h b/drivers/net/dsa/micro= chip/ksz_common.h index 2453c43c48a5..28444e5924f9 100644 --- a/drivers/net/dsa/microchip/ksz_common.h +++ b/drivers/net/dsa/microchip/ksz_common.h @@ -582,6 +582,13 @@ static inline int ksz_prmw8(struct ksz_device *dev, in= t port, int offset, mask, val); } =20 +static inline int ksz_prmw32(struct ksz_device *dev, int port, int offset, + u32 mask, u32 val) +{ + return ksz_rmw32(dev, dev->dev_ops->get_port_addr(port, offset), + mask, val); +} + static inline void ksz_regmap_lock(void *__mtx) { struct mutex *mtx =3D __mtx; --=20 2.37.2 From nobody Sun Feb 8 22:49:13 2026 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED77BEB64D8 for ; Tue, 20 Jun 2023 11:41:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231951AbjFTLlL (ORCPT ); Tue, 20 Jun 2023 07:41:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229933AbjFTLlD (ORCPT ); Tue, 20 Jun 2023 07:41:03 -0400 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3DE4DE71 for ; Tue, 20 Jun 2023 04:41:01 -0700 (PDT) Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-4f4b2bc1565so5979835e87.2 for ; Tue, 20 Jun 2023 04:41:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; t=1687261259; x=1689853259; 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=rc0VF9QAKItzIoQIN+TGeSbpZSwD884ZJlY6XLWEwnQ=; b=OSo/IOjpcTOvWjExcqsUbvuVyXnARS++fI0WVy3bVnpKwZGoSPB4IrOxk/VnscG8BF FfeSlGKun5ERhfnpb5CLB13pbyP1lWPKhVHkcU8hsfjhGbLJJtwZAFIiMr/anJHqRSP1 +eIcUHFwHvqjxUsQOzyIPT2Qmnbt5eDVXiQBE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687261259; x=1689853259; 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=rc0VF9QAKItzIoQIN+TGeSbpZSwD884ZJlY6XLWEwnQ=; b=dRAGp31KW0QsnNOcvgb/iGkxWhFynsVxRhWtrrvLdq/FdqBUnwIxVV8TNaDnCr7wOm wW+K6mOtUTXAvzJ5PwhWLGHQw52F0plp3+GdViPxjJGoc3ufyp8uFqL98yc5WM/6ztlr pISE/gm/x1AZ55EYDns04q1k4XqN9X175IETpQ89f4Qzvr1U1IN5thTh8HnyEQ9np15F IxLGoudOnCYkxAQXgNcP13H5IOd1oqMOgFsLdSCSnbFYxvua5bhWDvCbxbimTJ/cMUwA dsjdTjrvoMgn7zcLTgCnWa2oQduXSg+XqjqJRq46aSnjPAwLugtcPwKoZL32I1Z67IU6 J69A== X-Gm-Message-State: AC+VfDyzCt4yvO/LTyBFIN6oX3s+T3GNRe/egGUmmPQHrW1TiX8/OWW2 CKNI6oqdY2Iy5Y0dj2RwFtiKEg== X-Google-Smtp-Source: ACHHUZ7vTB7KJs+ED1EvGxXyIkcZbS3zd6TkV0QsQM3gGOpK8DiScTUsVPoFeq/WVfuUiSUwiOZvhQ== X-Received: by 2002:ac2:5b12:0:b0:4f3:dd96:bf55 with SMTP id v18-20020ac25b12000000b004f3dd96bf55mr7093121lfn.11.1687261258951; Tue, 20 Jun 2023 04:40:58 -0700 (PDT) Received: from localhost.localdomain ([87.54.42.112]) by smtp.gmail.com with ESMTPSA id d12-20020ac2544c000000b004f84162e08bsm329879lfn.185.2023.06.20.04.40.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jun 2023 04:40:58 -0700 (PDT) From: Rasmus Villemoes To: Woojung Huh , UNGLinuxDriver@microchip.com, Andrew Lunn , Florian Fainelli , Vladimir Oltean , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Rasmus Villemoes , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next 3/3] net: dsa: microchip: fix writes to phy registers >= 0x10 Date: Tue, 20 Jun 2023 13:38:54 +0200 Message-Id: <20230620113855.733526-4-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20230620113855.733526-1-linux@rasmusvillemoes.dk> References: <20230620113855.733526-1-linux@rasmusvillemoes.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" According to the errata sheets for ksz9477 and ksz9567, writes to the PHY registers 0x10-0x1f (i.e. those located at addresses 0xN120 to 0xN13f) must be done as a 32 bit write to the 4-byte aligned address containing the register, hence requires a RMW in order not to change the adjacent PHY register. Signed-off-by: Rasmus Villemoes Reviewed-by: Andrew Lunn Reviewed-by: Simon Horman --- drivers/net/dsa/microchip/ksz9477.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchi= p/ksz9477.c index fc5157a10af5..83b7f2d5c1ea 100644 --- a/drivers/net/dsa/microchip/ksz9477.c +++ b/drivers/net/dsa/microchip/ksz9477.c @@ -329,11 +329,27 @@ int ksz9477_r_phy(struct ksz_device *dev, u16 addr, u= 16 reg, u16 *data) =20 int ksz9477_w_phy(struct ksz_device *dev, u16 addr, u16 reg, u16 val) { + u32 mask, val32; + /* No real PHY after this. */ if (!dev->info->internal_phy[addr]) return 0; =20 - return ksz_pwrite16(dev, addr, 0x100 + (reg << 1), val); + if (reg < 0x10) + return ksz_pwrite16(dev, addr, 0x100 + (reg << 1), val); + + /* Errata: When using SPI, I2C, or in-band register access, + * writes to certain PHY registers should be performed as + * 32-bit writes instead of 16-bit writes. + */ + val32 =3D val; + mask =3D 0xffff; + if ((reg & 1) =3D=3D 0) { + val32 <<=3D 16; + mask <<=3D 16; + } + reg &=3D ~1; + return ksz_prmw32(dev, addr, 0x100 + (reg << 1), mask, val32); } =20 void ksz9477_cfg_port_member(struct ksz_device *dev, int port, u8 member) --=20 2.37.2