Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5870619rdb; Thu, 14 Dec 2023 01:50:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IE5StOnZ80pd+Syku3vWq3AuShtWaRwOME88HKi9js17eHmCbNXygpA1KmJBIgX/myVeqxn X-Received: by 2002:a17:903:704:b0:1d3:3a00:d8de with SMTP id kk4-20020a170903070400b001d33a00d8demr3879396plb.30.1702547431914; Thu, 14 Dec 2023 01:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702547431; cv=none; d=google.com; s=arc-20160816; b=MkkxddjodCcU+7TQtz84ZeTS8eErvtlt2tJ536zGunZntQq8Jgy5pxh8xMgWizGTuU 2IBCudG9sh6rl53pz9Z4pPVjZldFMbnJjk8Yyzi9rdKz8LNTYwEOaH+XbA1uhOGv7pWo zsHcf9fHpTBaMsyDrkLcp52Zyw9X59Vv3wIGXn1igruk+S1JpdMoOz576CQWCv1DIdD3 uIpMOUGdRkH4yLcbOi0Cu3RebCWHr/dF/+U5/LwpYezJyUssEGGvuXbIlQbiVbZcD1qh PySPPpLAHtT6Xf9bdDw6iUC5XEMtqsELk4PC0KdrJFhFxET5tcf4eRwTOUxNvbhyZRKF gD6A== 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=s+ow7T+OuUMlBNecjU0aO/QVMPc5Mr6UNh605j+9AnI=; fh=/GuWXIFJTb2Z3LVYajHwooJWphp6NrpriHhj5GHcik0=; b=p0vBfIC9Z+oPCsjWrOHf0Ul6U9fc+BpZofs/ucywrKEKip021gqW3uLH10iu2x0Kzt QYqAe2QcW/KXOVYnz6nsb/H+vqUcJ+J8ZJuER9Ie6+49CAdeMiDNcHSvz6Hy/D6xmntJ 9p4+917JIp+2Yvb7A8JUiSwwaGsbBoxmwe2b4GHuxQboxokTcYG48QqujvUDJKTLiJp5 +hXkt3UxDVrfVvOY90upkehFSMql4FC8POq2L9yuc9HesWFvJwcqocazbUyFv0oV1ZAr o7DSFV/yIUjHWUX0Kh/TOjkFSTNztS6FaXClKGBZD0bkhnPflpFx8gvh4N/qb5Ot5O79 b2ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gXzbEMq0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id ju6-20020a170903428600b001d0b3c280f9si1703541plb.501.2023.12.14.01.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 01:50:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=gXzbEMq0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0C2C08325D33; Thu, 14 Dec 2023 01:50:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1443666AbjLNJuI (ORCPT + 99 others); Thu, 14 Dec 2023 04:50:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1443561AbjLNJtr (ORCPT ); Thu, 14 Dec 2023 04:49:47 -0500 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D84CB171D; Thu, 14 Dec 2023 01:49:27 -0800 (PST) Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BE8SjSS011003; Thu, 14 Dec 2023 09:49:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:content-type; s= qcppdkim1; bh=s+ow7T+OuUMlBNecjU0aO/QVMPc5Mr6UNh605j+9AnI=; b=gX zbEMq0+xr6UQdvcCfF+ylpw3PCRuDMXNdPWeA4AuWQclAzduepNc8oqPcRtsTmIc ohHCMvN8dKg6KuMMMvz+x3T2CCyZFIc0tAYfwHNoW/Y6qGsR6I2MNgze97PJ2M0z +bmZc//4V8e+ahazTfpgJibrBQQi7brWPk3n9x/yL0arnuJTty3tyYXIoPO7pidD 5xDGWlYEQCg7aGG8DQDzRpmTjzHChtmkJZxlsIaZgdGqvk4Pl0BoEVoIo/IxX3PP 0/CWRp+1KsMXYB0yL98fWh1nuPM5UY1q2HhzBhNZs9tMRsaqmGa3QWVMBU1Nlgw+ X346Bs6botVzTRXCZArA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3uyp0p92w3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 09:49:13 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BE9nCep008859 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 14 Dec 2023 09:49:12 GMT Received: from akronite-sh-dev02.qualcomm.com (10.80.80.8) by nalasex01c.na.qualcomm.com (10.47.97.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.40; Thu, 14 Dec 2023 01:49:08 -0800 From: Luo Jie To: , , , , , , , , , , , , CC: , , , Subject: [PATCH v7 10/14] net: phy: at803x: parse qca8084 clocks and resets Date: Thu, 14 Dec 2023 17:48:09 +0800 Message-ID: <20231214094813.24690-11-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231214094813.24690-1-quic_luoj@quicinc.com> References: <20231214094813.24690-1-quic_luoj@quicinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nalasex01c.na.qualcomm.com (10.47.97.35) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: p5TAOuoHTDqpWvnniRSjaspXoQ2u5gLa X-Proofpoint-GUID: p5TAOuoHTDqpWvnniRSjaspXoQ2u5gLa X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-12-09_02,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 phishscore=0 impostorscore=0 clxscore=1015 malwarescore=0 lowpriorityscore=0 adultscore=0 bulkscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312140065 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email 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 (howler.vger.email [0.0.0.0]); Thu, 14 Dec 2023 01:50:26 -0800 (PST) These clock and reset IDs are needed to bring up qca8084, after the initializations with these clocks and resets, the PHY function can be accessed correctly such as reading the capabilities of PHY. Signed-off-by: Luo Jie --- drivers/net/phy/at803x.c | 89 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index a00c5950683c..6a7a7111ff68 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -21,6 +21,8 @@ #include #include #include +#include +#include #define AT803X_SPECIFIC_FUNCTION_CONTROL 0x10 #define AT803X_SFC_ASSERT_CRS BIT(11) @@ -337,6 +339,31 @@ static struct at803x_hw_stat at803x_hw_stats[] = { { "eee_wake_errors", 0x16, GENMASK(15, 0), MMD}, }; +enum { + SRDS0_SYS_CLK, + SRDS1_SYS_CLK, + GEPHY0_SYS_CLK, + GEPHY1_SYS_CLK, + GEPHY2_SYS_CLK, + GEPHY3_SYS_CLK, + QCA8084_CLK_CNT +}; + +enum { + SRDS0_SYS_RESET, + SRDS1_SYS_RESET, + GEPHY0_SYS_RESET, + GEPHY1_SYS_RESET, + GEPHY2_SYS_RESET, + GEPHY3_SYS_RESET, + GEPHY0_RESET, + GEPHY1_RESET, + GEPHY2_RESET, + GEPHY3_RESET, + GEPHY_DSP_RESET, + QCA8084_RESET_CNT, +}; + struct at803x_priv { int flags; u16 clk_25m_reg; @@ -348,6 +375,8 @@ struct at803x_priv { struct regulator_dev *vddio_rdev; struct regulator_dev *vddh_rdev; u64 stats[ARRAY_SIZE(at803x_hw_stats)]; + struct clk *clk[QCA8084_CLK_CNT]; + struct reset_control *reset[QCA8084_RESET_CNT]; }; struct at803x_context { @@ -359,6 +388,29 @@ struct at803x_context { u16 led_control; }; +static const char *const qca8084_clock_name[QCA8084_CLK_CNT] = { + "srds0_sys", + "srds1_sys", + "gephy0_sys", + "gephy1_sys", + "gephy2_sys", + "gephy3_sys", +}; + +static const char *const qca8084_reset_name[QCA8084_RESET_CNT] = { + "srds0_sys", + "srds1_sys", + "gephy0_sys", + "gephy1_sys", + "gephy2_sys", + "gephy3_sys", + "gephy0_soft", + "gephy1_soft", + "gephy2_soft", + "gephy3_soft", + "gephy_dsp", +}; + static int at803x_debug_reg_write(struct phy_device *phydev, u16 reg, u16 data) { int ret; @@ -1007,8 +1059,45 @@ static int qca8084_parse_and_set_phyaddr(struct phy_device *phydev) FIELD_PREP(QCA8084_PCS_ADDR2_MASK, addr[6])); } +static int qca8084_parse_dt(struct phy_device *phydev) +{ + struct at803x_priv *priv; + int i; + + priv = phydev->priv; + for (i = 0; i < QCA8084_CLK_CNT; i++) { + priv->clk[i] = devm_clk_get_optional(&phydev->mdio.dev, + qca8084_clock_name[i]); + if (IS_ERR(priv->clk[i])) { + phydev_err(phydev, "failed to get the clock ID %s!\n", + qca8084_clock_name[i]); + + return PTR_ERR(priv->clk[i]); + } + } + + for (i = 0; i < QCA8084_RESET_CNT; i++) { + priv->reset[i] = devm_reset_control_get_optional_exclusive(&phydev->mdio.dev, + qca8084_reset_name[i]); + if (IS_ERR(priv->reset[i])) { + phydev_err(phydev, "failed to get the reset ID %s!\n", + qca8084_reset_name[i]); + + return PTR_ERR(priv->reset[i]); + } + } + + return 0; +} + static int qca8084_probe(struct phy_device *phydev) { + int ret; + + ret = qca8084_parse_dt(phydev); + if (ret) + return ret; + return qca8084_parse_and_set_phyaddr(phydev); } -- 2.42.0