From patchwork Fri Dec 1 00:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 172185 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp776379vqy; Thu, 30 Nov 2023 16:16:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IELeukQZLcumZXt2SxeoBTMe4GnYfGuxgtnURzz0UavRqAEoxcj9Yeo8EF3aa3A9oudH/6N X-Received: by 2002:a17:90a:1910:b0:281:d55:6fe8 with SMTP id 16-20020a17090a191000b002810d556fe8mr19501743pjg.24.1701389760998; Thu, 30 Nov 2023 16:16:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701389760; cv=none; d=google.com; s=arc-20160816; b=rAzDaCOyC8UMiGLBHzmPIzsyX8oCcWpolGCrstH8/fXtdUBn6nl4utCPKJzWWUjWwx HMGVpo/8TaW9FNcc2svFcTwg0RhILF7z+NdZ+Kvh9RIDmwIIw6l4F/Kz1Yj/OaGZMkb3 Q5EDd6BQKUkCIgkBmKH4xafpZeqxdFsjpJ0BWBXxpwYTYiuZhQp7Oxj2UbqRiGbE5DNq ld2CMlqV1yogYMIDnNbz7F+SrwQeKQamKLk0ZvsiwNRuvexIqL2n4ZPvTu5HxAASHzoC GMUX3J9KMPsJ9Wi4GiW9Tzd9do+ipvJhFTp7WGCjNq7etmeVQoxK+2EK166fB5LPgrkG RZSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=i12Gu+wY1CypxJPzomZzPt1KEPWiDTFBh+rmjVLvo38=; fh=utmrxdkgikAlLxVfQI1kldUG+rNjhrLN+3fAlOYj01s=; b=fxKa52+Zk4NQAT16HxzDqNBYOvx3Na7hOmB0M+5R4EWgdx0T5jliMkUU6vqrxQwIR3 m2gIiawSfyqffJKYPiRq6dP8PnzaxtxTS+5JsgtK8erzDQ4z7U0HUX/boW9WxBfq70ka cm1N4iYE6UpXR2qqvZBiScLWXVs7rGQ6l1YR2uGuE9gdZjeAMa4xXakoRmLX1VCnr6k1 C9kqFZiOwU0pUpEXDCprDE4BS859f0yVGwblMJdq0ROBm8YXHDYcYfqBM3U5X5CSxP+H VIBwD9PenD21sZjX3L/fqXnBt6j0G146eDRVCU0h5z7ZUt1E0RuYeFLntTY729+E+0Qs 7bQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bT3b7giL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id sm15-20020a17090b2e4f00b002839aba9d89si2580902pjb.25.2023.11.30.16.16.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 16:16:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bT3b7giL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id F32AC8061B46; Thu, 30 Nov 2023 16:15:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377525AbjLAAPb (ORCPT + 99 others); Thu, 30 Nov 2023 19:15:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48988 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377466AbjLAAPJ (ORCPT ); Thu, 30 Nov 2023 19:15:09 -0500 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDCB11981; Thu, 30 Nov 2023 16:15:01 -0800 (PST) Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-333308c3683so131198f8f.3; Thu, 30 Nov 2023 16:15:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701389700; x=1701994500; darn=vger.kernel.org; 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=i12Gu+wY1CypxJPzomZzPt1KEPWiDTFBh+rmjVLvo38=; b=bT3b7giLwZKBWt200a+53yO984RsbHnFC4N+s2Eh/tR+xviHSbC57cZ8OpuXZ1wSA+ 8KaIx4BQqTdiCUitQciHfXc6wkBy0r5w17lyXU0gmMA+dJGyfG1gH7sNDjZMN5fP8/MN /iDLd9IFMIBFGuVkRXzHdsiMeCRidRMYnqtzTMTTKKgcX9UmEx4VfV7zKPWSmAO8nBtB BUQADlN/MJ1hXzFZjhWgwIvaI8uOplQGm41WbCqzmrxUl/BWmLJEAitVkvaJn2IYNjHZ RpczfCwPLSbhxjqfacSDti9RrLPy+zIlo4N16fcKcfcD/kAGUBAjFCNXMX1LZsCt9dZt 82IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701389700; x=1701994500; 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=i12Gu+wY1CypxJPzomZzPt1KEPWiDTFBh+rmjVLvo38=; b=ms8h2pSwWFQl0uEahISUe4CZnYW1lYgxjnrc+/MbdiVeakJ5ySFafbMibhCiGvzbqi WMwkA1mvX4hUDtRCYKha0sNxH8a8xuDSZpumuWzi9au6sQ/eEpgIKBeu13lqvLnzW6/T L8bwgMDmqn/QBGoFny1W7il1FJPehos7yNcyv4yTveNpwOnaOliEskwAUhNeQ5XYJppk ZIH8LZ0aMav6h6xXqNRTcM0aIe6OB4zY5Gqi51Kyu6CwMWZBQL1JITSWpRcgarFZFpHW iZ+6JUrWxaPocwBXPkMblso6HdRr+T2LOAgRRWIq4ZyceWY+wNgK+9gfe/fmZ4vtr4L4 c1xg== X-Gm-Message-State: AOJu0YxEej46lcIpM7V1S3aturIn1eWnJd3NIrqel7lOKU+a9uvdI4F/ M7GzUD7d64GYPz368f3zL40= X-Received: by 2002:a5d:484b:0:b0:333:1a1c:50f5 with SMTP id n11-20020a5d484b000000b003331a1c50f5mr135853wrs.62.1701389699724; Thu, 30 Nov 2023 16:14:59 -0800 (PST) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id g16-20020a05600c4ed000b0040b47c53610sm3535457wmq.14.2023.11.30.16.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 16:14:59 -0800 (PST) From: Christian Marangi To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [net-next PATCH v2 11/12] net: phy: at803x: move at8035 specific DT parse to dedicated probe Date: Fri, 1 Dec 2023 01:14:21 +0100 Message-Id: <20231201001423.20989-12-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20231201001423.20989-1-ansuelsmth@gmail.com> References: <20231201001423.20989-1-ansuelsmth@gmail.com> MIME-Version: 1.0 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, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Thu, 30 Nov 2023 16:15:41 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784036469621882454 X-GMAIL-MSGID: 1784036469621882454 Move at8035 specific DT parse for clock out frequency to dedicated probe to make at803x probe function more generic. This is to tidy code and no behaviour change are intended. Detection logic is changed, we check if the clk 25m mask is set and if it's not zero, we assume the qca,clk-out-frequency property is set. The property is checked in the generic at803x_parse_dt called by at803x_probe. Signed-off-by: Christian Marangi Reviewed-by: Andrew Lunn --- drivers/net/phy/at803x.c | 60 +++++++++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 19 deletions(-) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 73d1a5e29202..27dc0a9ca076 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -638,23 +638,6 @@ static int at803x_parse_dt(struct phy_device *phydev) priv->clk_25m_reg |= FIELD_PREP(AT803X_CLK_OUT_MASK, sel); priv->clk_25m_mask |= AT803X_CLK_OUT_MASK; - - /* Fixup for the AR8030/AR8035. This chip has another mask and - * doesn't support the DSP reference. Eg. the lowest bit of the - * mask. The upper two bits select the same frequencies. Mask - * the lowest bit here. - * - * Warning: - * There was no datasheet for the AR8030 available so this is - * just a guess. But the AR8035 is listed as pin compatible - * to the AR8030 so there might be a good chance it works on - * the AR8030 too. - */ - if (phydev->drv->phy_id == ATH8030_PHY_ID || - phydev->drv->phy_id == ATH8035_PHY_ID) { - priv->clk_25m_reg &= AT8035_CLK_OUT_MASK; - priv->clk_25m_mask &= AT8035_CLK_OUT_MASK; - } } ret = of_property_read_u32(node, "qca,clk-out-strength", &strength); @@ -1637,6 +1620,45 @@ static int at8031_config_intr(struct phy_device *phydev) return at803x_config_intr(phydev); } +static int at8035_parse_dt(struct phy_device *phydev) +{ + struct at803x_priv *priv = phydev->priv; + + /* Mask is set by the generic at803x_parse_dt + * if property is set. Assume property is set + * with the mask not zero. + */ + if (priv->clk_25m_mask) { + /* Fixup for the AR8030/AR8035. This chip has another mask and + * doesn't support the DSP reference. Eg. the lowest bit of the + * mask. The upper two bits select the same frequencies. Mask + * the lowest bit here. + * + * Warning: + * There was no datasheet for the AR8030 available so this is + * just a guess. But the AR8035 is listed as pin compatible + * to the AR8030 so there might be a good chance it works on + * the AR8030 too. + */ + priv->clk_25m_reg &= AT8035_CLK_OUT_MASK; + priv->clk_25m_mask &= AT8035_CLK_OUT_MASK; + } + + return 0; +} + +/* AR8030 and AR8035 shared the same special mask for clk_25m */ +static int at8035_probe(struct phy_device *phydev) +{ + int ret; + + ret = at803x_probe(phydev); + if (ret) + return ret; + + return at8035_parse_dt(phydev); +} + static int qca83xx_config_init(struct phy_device *phydev) { u8 switch_revision; @@ -2109,7 +2131,7 @@ static struct phy_driver at803x_driver[] = { PHY_ID_MATCH_EXACT(ATH8035_PHY_ID), .name = "Qualcomm Atheros AR8035", .flags = PHY_POLL_CABLE_TEST, - .probe = at803x_probe, + .probe = at8035_probe, .config_aneg = at803x_config_aneg, .config_init = at803x_config_init, .soft_reset = genphy_soft_reset, @@ -2130,7 +2152,7 @@ static struct phy_driver at803x_driver[] = { .phy_id = ATH8030_PHY_ID, .name = "Qualcomm Atheros AR8030", .phy_id_mask = AT8030_PHY_ID_MASK, - .probe = at803x_probe, + .probe = at8035_probe, .config_init = at803x_config_init, .link_change_notify = at803x_link_change_notify, .set_wol = at803x_set_wol,