Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3417218pxb; Sun, 24 Oct 2021 01:31:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkmDYYK5/O3hCGLYpDjyRhOVULdSHpxaRZRdB9UYQOOcKSN3OFNq1c/9NH+KI1+YblodUg X-Received: by 2002:a17:907:7d94:: with SMTP id oz20mr13348447ejc.98.1635064300453; Sun, 24 Oct 2021 01:31:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635064300; cv=none; d=google.com; s=arc-20160816; b=b2W/5XG7XGUclFZ3VtyCCdUWDxysVuA8Po+cf36mCkd22LEChnzwO6WD3X63JpMrE8 avnGC1n6sfSzqDfk80TzBMMpzfV0qGUhdHCh86jEGr4nGD2z/LxxBOQIKFrKdTXLzTT5 7x7evh1CaZINmiZ1E8Mna2DCm/tLE6Uf20k5zLmgXhHS6ewJLaZsNSR2MVOXrXnGk2wM Nf2V83c8/lf7dzrTUM3qjUOxyRbnATeIKokLrU3dIqql3n1c3uuYR0Q7DAJZEhOD/F+D 5Q/NP+smKAdLXFejdC2iRcagd28NZRTzFw7CzquSe8bUCk7F2MvO9hC2HjfnQQotFJk1 AQAw== 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=YVpmYCO6qpmUD0exmZ4Uccgy3uvlAAl3MPxNs7cZONF4G3eAX/1fnGPhg+J7MrHnxO xKmpvpmejYU2CnFUMUdpPogMWif5ewfHRAOzhIGPqW9w3Ijaz3meYr9VWnCBLdQJGnit aC5gog5oorTPl1BPUo4dv5u9A2dKvxR3f7zVr4QVtILncNMwbOXYF6snxCpXVbrcpsKe ZZtvm8igaSsFejxoC9Qt5qRpkfbccKnk4mzYiinf6vjpdtGe19qQn4cB+K6IxrVGVk3f X9X2y+5TtTVd4cQSRj8xWzP559WbZsvXtTidMj6XGPQgRkcyWW3tTV6fP7aFzd/xUnkW eOuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=Xjdoz08D; 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 cw2si31849221ejc.730.2021.10.24.01.31.16; Sun, 24 Oct 2021 01:31:40 -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=Xjdoz08D; 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 S231869AbhJXIbN (ORCPT + 99 others); Sun, 24 Oct 2021 04:31:13 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:28246 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231807AbhJXIas (ORCPT ); Sun, 24 Oct 2021 04:30:48 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1635064108; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=VvWNLqPUD/ffsqcY9IXsMuvidL/zUK3rPrlUhC0hWyU=; b=Xjdoz08De90xMMM7QfZ1ji115KUf1tyfROFnspb1fRYeUhDaH6b2khwb0BpvUottSRCYpgE2 2szDmj1qZfSmHassgKWXOoiTfUziAKEtKk9Pv6rpz0C5okvuhk26/Ztz3Wb6erLO8ElwUtCC b3jr5ygnXEVXsmLhePBNakN/clI= X-Mailgun-Sending-Ip: 198.61.254.9 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-n01.prod.us-west-2.postgun.com with SMTP id 61751922321f240051d4bfef (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 24 Oct 2021 08:28:18 GMT Sender: luoj=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id DC75EC4361A; Sun, 24 Oct 2021 08:28:17 +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, URIBL_BLOCKED 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 EC9C1C4338F; Sun, 24 Oct 2021 08:28:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org EC9C1C4338F 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 v7 12/14] net: phy: add qca8081 soft_reset and enable master/slave seed Date: Sun, 24 Oct 2021 16:27:36 +0800 Message-Id: <20211024082738.849-13-luoj@codeaurora.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211024082738.849-1-luoj@codeaurora.org> References: <20211024082738.849-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