Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2350856pxb; Fri, 22 Oct 2021 20:29:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyb4FTtJ+Rgk4yVYXtXyQ2f3XX1wi7JC+ZV3mbvWQRPozE5R8B+SInk7a2+AZEol7virzqj X-Received: by 2002:a17:906:af68:: with SMTP id os8mr1140066ejb.405.1634959760580; Fri, 22 Oct 2021 20:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634959760; cv=none; d=google.com; s=arc-20160816; b=LwQkABFTEEfNAgDY8tG8xC/Q1Ryt/O6sf4kiJqHO4ui8pvNAGe7rDNmwyTu9I1GpXM KKj/IjNDqyBLvb+Ex/BjfHgpRGK4uu4dOXhk2TpJtF88JaHXUytF7cVZVjJr8HVywF6C rpKfKwfmbgVrn/ImzWAMA92HZjudUqeN0XSK+y8kCRujmU06yQzhKWVvDrRagtHmMmc8 OScrv/DM1rO6tivmQgdnChrBMV/hlVzsUw4SEzb7wQiF6YiTdHDV+405J5we9MTi9TcE Wu51qivrpoWd6t33EJVyEyMiotP3H+pj7cLMJ04l++02Bi8E/PSY4TGxNBxEqfeNNAQ3 zX+w== 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=VvWNLqPUD/ffsqcY9IXsMuvidL/zUK3rPrlUhC0hWyU=; b=MwS1+pvdYqQX9ACev22GCMwJ1RYx2H51OO07u0JDPogJh0MiB/F4tCiFknOipCpCi2 c585HC/t4yCa2Zc9XJ0TKy34GnM3xhfMxGS9wj4Ob/QLXICHqtn7KkT2HwHc1bdHzTtP 5/OKHaChUOyUNz6wp3jzWDmjUSrMvve/dJ3AiOBWgfY45MWKDMrZyNjLYJktzDxxv+9g JHKZ4+Wb0lEWTBr7SLwrbDr3ihGs2aVI9vxoSQhmepGckebIcZJic3/DJkA9fM/axX4M ro4K32/S8N7b4zXibkrk0dZq8T/8ypUP3ocfw6iUq+IAxTXGTxdhxXLs927uWg0XSB84 warg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=wdZziIpl; 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 e7si6139472ejs.467.2021.10.22.20.28.33; Fri, 22 Oct 2021 20:29:20 -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=wdZziIpl; 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 S231760AbhJWD16 (ORCPT + 99 others); Fri, 22 Oct 2021 23:27:58 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:48469 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231772AbhJWD1T (ORCPT ); Fri, 22 Oct 2021 23:27:19 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1634959501; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=VvWNLqPUD/ffsqcY9IXsMuvidL/zUK3rPrlUhC0hWyU=; b=wdZziIpl4gBHqRC9YXDQed/LGzO3eF1zDDLyUCnNga4/Rn8Mvcd3/V5AyCdxR6wljolUEgq5 XMI7fKqoCt3LmvWBtJwMKYVgyl5CoS5klEFLbql74cefromPFU6Mz/J3Jz+KN5P4aDznDgl/ g/iVZmQqp/nsVh1MCIjJQ2en7TA= 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-n07.prod.us-east-1.postgun.com with SMTP id 6173808cb03398c06ca18235 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sat, 23 Oct 2021 03:25:00 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E4B84C4361B; Sat, 23 Oct 2021 03:24:59 +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 92B32C4338F; Sat, 23 Oct 2021 03:24:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 92B32C4338F 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 v5 12/14] net: phy: add qca8081 soft_reset and enable master/slave seed Date: Sat, 23 Oct 2021 11:24:10 +0800 Message-Id: <20211023032412.30479-13-luoj@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211023032412.30479-1-luoj@codeaurora.org> References: <20211023032412.30479-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 | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index da710523b7c4..1418db4f2091 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -223,6 +223,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"); @@ -1569,6 +1575,26 @@ 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); + + return at803x_debug_reg_mask(phydev, QCA808X_PHY_DEBUG_LOCAL_SEED, + QCA808X_MASTER_SLAVE_SEED_CFG, + FIELD_PREP(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; @@ -1590,6 +1616,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); @@ -1622,6 +1658,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 */ @@ -1797,6 +1844,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