From patchwork Thu Dec 14 09:48:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 178620 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3b04:b0:fb:cd0c:d3e with SMTP id c4csp8427073dys; Thu, 14 Dec 2023 01:50:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IHJMjz2vNsPUyKgJPULVtEA7DW7kfqDWb3PXaCgVgxMiv4f/N9XnHJmuJ9fMTj7iXibwM2P X-Received: by 2002:a05:6a00:3097:b0:6d0:d43f:1907 with SMTP id bh23-20020a056a00309700b006d0d43f1907mr2128734pfb.21.1702547421484; Thu, 14 Dec 2023 01:50:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702547421; cv=none; d=google.com; s=arc-20160816; b=q1CAuxfDE6wUAAEK+c1mXhwvUL6qnCeTGla5IMEMSuiO5JXP7fu3YrkQWp1I2i2D+4 hTiTk2beLzOo5Z5PmhKCE3vNVTZIXm3Yv9oOpDrlArJ88/BLOM2Tmnj1B+cF70V+KwhK 4D2TWT2pTNu9pE8MDQQTXBXlzdYOWukCzkUCW+6pB6q46wtygrtnu6DPD2ni/gxpPBHS kFAExeHiNhjfuh7gV2UJL7+GQs06U1UpByUqNzdJb0fX1XWVeapCme1O/msq3rphwZvQ poSEQBy1tFK1yT7GtmLZS4VaY2enfkxgYdsE4R40L1jE57MHaYZo/ji0BqLsT0atQUDk nLpQ== 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 Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id s6-20020a62e706000000b006cd853221easi10894054pfh.362.2023.12.14.01.50.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 01:50:21 -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 1457E8325D3D; Thu, 14 Dec 2023 01:50:17 -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 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:17 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1785250364765080591 X-GMAIL-MSGID: 1785250364765080591 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); }