Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2624238pxb; Sun, 17 Oct 2021 20:49:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyuX9wtrv/F4edE/6rVuj+wqQRGvMbsj0TK75tqBq6T3zGd3F1OoPjNicaHFDPJS7JBUERa X-Received: by 2002:a63:9844:: with SMTP id l4mr5744388pgo.271.1634528992967; Sun, 17 Oct 2021 20:49:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634528992; cv=none; d=google.com; s=arc-20160816; b=hqpfGd5223IqmMh6WFutU4iOEr2AXTS/6YKglRXloj9ZzMObfil7SVoM55fIYOdzbb XASuCbCjm6FcXPhYZsH7kcqql2U5na1P8CR3kdEq43QlMYT+axT6m6YlPHuDeNB6Aj7J gqmjb/lo3glDUTzp754BWnWd311vwm/oDBwBnEqvr7AxEfOJjp2DC9VdhIllW3abaNgJ 8MLDwRlwRhuG0MqpZEMt6Bam9vvgKfRi+cGCpy1UqB0+vcRulzJXrsr9lw9Rozw7TJcb o6yml7r2w5qOkVO5puDh1vEzIXSxhKrZvcwgvH8Dl/SqJdE7YO3Kt8Wyzjbeu3a3UFM+ pVyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dmarc-filter:sender:dkim-signature; bh=Q9DZvtxDGzLpBOD6j5tV0IXipemu2GoK9zXf2dy1XGk=; b=ajC3kc+S2iu9CI6mY0sk8iLgJGEykzIN9i4cKrRZSmMQQ1Z8FdDa/cyzgSWDT73jNa e5CW4+/1MgDO/030cV9M0oCbFMufjaxMAscdsI/Jtg8rf5IhgeqnIj8WFExVSR188bRp 9LJM8bJ9SWPTpKvcMxD66qnblM38pG7J/2SkGM4WR+4oOys0Gxx4Zy5qs6jhssmpFFc+ 5FXr2GXksso6mDKr4Qpg+hbq/xlNUyG6pxpJHHewH1pc35xsbLdiQoGQHKvSSyIVfY08 A9qysdzWDPwoslqMMblfmK+0BxMhV6wJnAAIo8/UBdiC/30DyrrX9tiLEgw+M2Q0gcry 30Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=FCNDg5w7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j21si11151454pll.84.2021.10.17.20.49.40; Sun, 17 Oct 2021 20:49:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=FCNDg5w7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232562AbhJRDhd (ORCPT + 99 others); Sun, 17 Oct 2021 23:37:33 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:23692 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232474AbhJRDg4 (ORCPT ); Sun, 17 Oct 2021 23:36:56 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634528086; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=Q9DZvtxDGzLpBOD6j5tV0IXipemu2GoK9zXf2dy1XGk=; b=FCNDg5w7Me/GQrrTGDrazV8gT8aRm4cbsx4SaN7I5DcA80QKm3bMr7DpIAK41MjqcLfq2JMK 4TdFSqMbk5DfeB0mUqpWdjQGoLC6HbyDlcarBX664i9vWPODhxBMS6/R//VSlMQjX7co9zBh gLyfTG1pzOk5epzcSLhfXbIP3Bk= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-east-1.postgun.com with SMTP id 616ceb3dab9da96e64621af9 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 18 Oct 2021 03:34:21 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 7A943C43637; Mon, 18 Oct 2021 03:34:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from akronite-sh-dev02.qualcomm.com (unknown [180.166.53.21]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: luoj) by smtp.codeaurora.org (Postfix) with ESMTPSA id 70A5DC43617; Mon, 18 Oct 2021 03:34:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 70A5DC43617 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org From: Luo Jie To: andrew@lunn.ch, hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sricharan@codeaurora.org, Luo Jie Subject: [PATCH v3 11/13] net: phy: add qca8081 soft_reset and enable master/slave seed Date: Mon, 18 Oct 2021 11:33:31 +0800 Message-Id: <20211018033333.17677-12-luoj@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211018033333.17677-1-luoj@codeaurora.org> References: <20211018033333.17677-1-luoj@codeaurora.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org qca8081 phy is a single port phy, configure phy the lower seed value to make it linked as slave mode easier. Signed-off-by: Luo Jie --- drivers/net/phy/at803x.c | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index 8ab2084b9614..5d007f89e9d3 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -214,6 +214,12 @@ #define QCA808X_PHY_MMD3_DEBUG_6 0xa011 #define QCA808X_MMD3_DEBUG_6_VALUE 0x5f85 +/* master/slave seed config */ +#define QCA808X_PHY_DEBUG_LOCAL_SEED 9 +#define QCA808X_MASTER_SLAVE_SEED_ENABLE BIT(1) +#define QCA808X_MASTER_SLAVE_SEED_CFG GENMASK(12, 2) +#define QCA808X_MASTER_SLAVE_SEED_RANGE 0x32 + MODULE_DESCRIPTION("Qualcomm Atheros AR803x and QCA808X PHY driver"); MODULE_AUTHOR("Matus Ujhelyi"); MODULE_LICENSE("GPL"); @@ -1471,6 +1477,25 @@ static int qca808x_phy_fast_retrain_config(struct phy_device *phydev) return 0; } +static int qca808x_phy_ms_random_seed_set(struct phy_device *phydev) +{ + u16 seed_value = (prandom_u32() % QCA808X_MASTER_SLAVE_SEED_RANGE) << 2; + + return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, + QCA808X_MASTER_SLAVE_SEED_CFG, seed_value); +} + +static int qca808x_phy_ms_seed_enable(struct phy_device *phydev, bool enable) +{ + u16 seed_enable = 0; + + if (enable) + seed_enable = QCA808X_MASTER_SLAVE_SEED_ENABLE; + + return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, + QCA808X_MASTER_SLAVE_SEED_ENABLE, seed_enable); +} + static int qca808x_config_init(struct phy_device *phydev) { int ret; @@ -1492,6 +1517,16 @@ static int qca808x_config_init(struct phy_device *phydev) if (ret) return ret; + /* Configure lower ramdom seed to make phy linked as slave mode */ + ret = qca808x_phy_ms_random_seed_set(phydev); + if (ret) + return ret; + + /* Enable seed */ + ret = qca808x_phy_ms_seed_enable(phydev, true); + if (ret) + return ret; + /* Configure adc threshold as 100mv for the link 10M */ return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_ADC_THRESHOLD, QCA808X_ADC_THRESHOLD_MASK, QCA808X_ADC_THRESHOLD_100MV); @@ -1524,6 +1559,17 @@ static int qca808x_read_status(struct phy_device *phydev) return 0; } +static int qca808x_soft_reset(struct phy_device *phydev) +{ + int ret; + + ret = genphy_soft_reset(phydev); + if (ret < 0) + return ret; + + return qca808x_phy_ms_seed_enable(phydev, true); +} + static struct phy_driver at803x_driver[] = { { /* Qualcomm Atheros AR8035 */ @@ -1649,6 +1695,7 @@ static struct phy_driver at803x_driver[] = { .resume = genphy_resume, .read_status = qca808x_read_status, .config_init = qca808x_config_init, + .soft_reset = qca808x_soft_reset, }, }; module_phy_driver(at803x_driver); -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project