From patchwork Mon Dec 25 08:44:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 183156 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp295309dyb; Mon, 25 Dec 2023 00:45:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOohVzh8oRLek7cVZtdeMgaVEjoTO9gHkbApf017UUbNgE+2w97edkprP1OFyYHHJ0/ElL X-Received: by 2002:a05:6a20:9708:b0:189:c46d:9790 with SMTP id hr8-20020a056a20970800b00189c46d9790mr5568008pzc.30.1703493954635; Mon, 25 Dec 2023 00:45:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703493954; cv=none; d=google.com; s=arc-20160816; b=R96FlCRDNRVXzGK8EEO5WKqzxodrmODgmTZyA94aJchgmmKZHqM+N86gtceFITkV23 N+LMhR4uDFimCV9l6NXDwblKUqfXWTzhGjr+UasYNcwXU3dIror35f78pwVgIWFx4WQa zaFoP/7Rg03MsehF6XuaP/pRVbBWJZJo6viurblTcjiiLF3HHDfm7RcnzLwmT2GTjdDu Bhp6vQX0qpJL1Px1QgbONp+zQ5HtIvPugiwmFE0vQTCHS/taun3e7D3zlI6eyUcekX34 aNGKIlpe2Ob2C6F44kLObs99CylIFoQ4hokiVKBwa5eLxOuq3HIKdbAcfqulez9WpTDm RlkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FFW+RKQFRS3hNZWC4B1zbsHCDFZ2KKuoWG+X51zxpU8=; fh=+g5tGayWdOm7NVf+9R7F5Bp+AAhjebsKXKT3IUU1ti0=; b=FRQFNeKJStLd5eD8K6hvr5NFq0YVg+Y0Qe+SwnQnokO51ZIE7tsReu/0EB13tm486l iAKMhKTjegn+K4lpmmqSy4dolILelbF266XWtueqEkNX/WEs42U6tkAvlRrOilPP+8hE wdxbLkJ01s97zcdu2wKkw+lojE80sazTYoizwG+oBK/FF7fJC6AwS1o4+8ghE/GqTp0J +IN+lukS56XzEmFEopkqPO/5gX8XGJcXE97lLJ2y409IktApkIFlsAd0P05rOueXmSK2 nog5nI700BGmUpD4q16dljmZLk/s3lp9iQNFSaOZBzvqxx8oV2JI1TAvMkBgVuM905XC dkIA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R1o5uZ72; spf=pass (google.com: domain of linux-kernel+bounces-10957-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o16-20020a17090ac71000b0028bbbd1228esi7770010pjt.145.2023.12.25.00.45.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 00:45:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10957-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=R1o5uZ72; spf=pass (google.com: domain of linux-kernel+bounces-10957-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10957-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 35B9AB2118C for ; Mon, 25 Dec 2023 08:45:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4DB40101C1; Mon, 25 Dec 2023 08:45:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="R1o5uZ72" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4A756CA7A; Mon, 25 Dec 2023 08:45:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BP7A3II019837; Mon, 25 Dec 2023 08:44:47 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=FFW+RKQFRS3hNZWC4B1zbsHCDFZ2KKuoWG+X51zxpU8=; b=R1 o5uZ72Yx+TD33LivsZtncTRKRn5FyBJXVyGIiT0gzw8R4wKl9EUGILvXVmN2ETHp fLzeWEq9LYzzmI5N4uASSxiEie1MNxkPFgMRNGxn1dOgviazM14LtcSp3rwvBxWK UJus/JxXoHy9QxSAFSl8jQ133cEP9zYfriSTLnP3VKg6zVu5SQQ3rOhEkF497N/h 6dRrhIJtXOHQMPjMCupJKLuoxYKxhb1eYoAaZi+DkE3mmghx/5GF3zixvtwqIFjE 6+fVhu89C+Uc6c4/trYLwNgq6shNAEAfyOgonXti3L2u/cLzUUOBcDBjAsnUDYzA uZ2Riv18yifi6XE1Pw7g== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v5mwr3fc6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:44:47 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BP8ikZI025490 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:44:46 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; Mon, 25 Dec 2023 00:44:41 -0800 From: Luo Jie To: , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v4 1/5] net: mdio: ipq4019: move eth_ldo_rdy before MDIO bus register Date: Mon, 25 Dec 2023 16:44:20 +0800 Message-ID: <20231225084424.30986-2-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231225084424.30986-1-quic_luoj@quicinc.com> References: <20231225084424.30986-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: jg7JjeldXH8xeTi_Hr6Pn8KZS3S8PW8F X-Proofpoint-ORIG-GUID: jg7JjeldXH8xeTi_Hr6Pn8KZS3S8PW8F 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 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312250066 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786242877325353454 X-GMAIL-MSGID: 1786242877325353454 The ethernet LDO provides the clock for the ethernet PHY that is connected with PCS, each LDO enables the clock output to each PCS, after the clock output enablement, the PHY GPIO reset can take effect. For the PHY taking the MDIO bus level GPIO reset, the ethernet LDO should be enabled before the MDIO bus register. For example, the qca8084 PHY takes the MDIO bus level GPIO reset for quad PHYs, there is another reason for qca8084 PHY using MDIO bus level GPIO reset instead of PHY level GPIO reset as below. The work sequence of qca8084: 1. enable ethernet LDO. 2. GPIO reset on quad PHYs. 3. register clock provider based on MDIO device of qca8084. 4. PHY probe function called for initializing common clocks. 5. PHY capabilities acquirement. If qca8084 takes PHY level GPIO reset in the step 4, the clock provider of qca8084 can't be registered correctly, since the clock parent(reading the current qca8084 hardware registers in step 3) of the registered clocks is deserted after GPIO reset. There are two PCS(UNIPHY) supported in SOC side on ipq5332, and three PCS(UNIPHY) supported on ipq9574. Signed-off-by: Luo Jie --- drivers/net/mdio/mdio-ipq4019.c | 51 +++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c index abd8b508ec16..5273864fabb3 100644 --- a/drivers/net/mdio/mdio-ipq4019.c +++ b/drivers/net/mdio/mdio-ipq4019.c @@ -37,9 +37,12 @@ #define IPQ_PHY_SET_DELAY_US 100000 +/* Maximum SOC PCS(uniphy) number on IPQ platform */ +#define ETH_LDO_RDY_CNT 3 + struct ipq4019_mdio_data { - void __iomem *membase; - void __iomem *eth_ldo_rdy; + void __iomem *membase; + void __iomem *eth_ldo_rdy[ETH_LDO_RDY_CNT]; struct clk *mdio_clk; }; @@ -206,19 +209,8 @@ static int ipq4019_mdio_write_c22(struct mii_bus *bus, int mii_id, int regnum, static int ipq_mdio_reset(struct mii_bus *bus) { struct ipq4019_mdio_data *priv = bus->priv; - u32 val; int ret; - /* To indicate CMN_PLL that ethernet_ldo has been ready if platform resource 1 - * is specified in the device tree. - */ - if (priv->eth_ldo_rdy) { - val = readl(priv->eth_ldo_rdy); - val |= BIT(0); - writel(val, priv->eth_ldo_rdy); - fsleep(IPQ_PHY_SET_DELAY_US); - } - /* Configure MDIO clock source frequency if clock is specified in the device tree */ ret = clk_set_rate(priv->mdio_clk, IPQ_MDIO_CLK_RATE); if (ret) @@ -236,7 +228,7 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) struct ipq4019_mdio_data *priv; struct mii_bus *bus; struct resource *res; - int ret; + int ret, index; bus = devm_mdiobus_alloc_size(&pdev->dev, sizeof(*priv)); if (!bus) @@ -252,11 +244,32 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) if (IS_ERR(priv->mdio_clk)) return PTR_ERR(priv->mdio_clk); - /* The platform resource is provided on the chipset IPQ5018 */ - /* This resource is optional */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - if (res) - priv->eth_ldo_rdy = devm_ioremap_resource(&pdev->dev, res); + /* These platform resources are provided on the chipset IPQ5018 or + * IPQ5332. + */ + /* This resource are optional */ + for (index = 0; index < ETH_LDO_RDY_CNT; index++) { + res = platform_get_resource(pdev, IORESOURCE_MEM, index + 1); + if (res) { + priv->eth_ldo_rdy[index] = devm_ioremap(&pdev->dev, + res->start, + resource_size(res)); + + /* The ethernet LDO enable is necessary to reset PHY + * by GPIO, some PHY(such as qca8084) GPIO reset uses + * the MDIO level reset, so this function should be + * called before the MDIO bus register. + */ + if (priv->eth_ldo_rdy[index]) { + u32 val; + + val = readl(priv->eth_ldo_rdy[index]); + val |= BIT(0); + writel(val, priv->eth_ldo_rdy[index]); + fsleep(IPQ_PHY_SET_DELAY_US); + } + } + } bus->name = "ipq4019_mdio"; bus->read = ipq4019_mdio_read_c22; From patchwork Mon Dec 25 08:44:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 183157 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp295435dyb; Mon, 25 Dec 2023 00:46:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFzlcNG0xj9s4vk0pBx3keX/2/eAucFrwsutTSCGxoVUnhfL/OOdyhF3f4E9ERfy9utfl/3 X-Received: by 2002:a0d:ff41:0:b0:5e8:2919:e65d with SMTP id p62-20020a0dff41000000b005e82919e65dmr3503140ywf.81.1703493980648; Mon, 25 Dec 2023 00:46:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703493980; cv=none; d=google.com; s=arc-20160816; b=YR62wLQ5wAEWNgDPyIuki9HoCcFOng5rPBRLRXvHRfVhzBZO0RihtlAsQYxgzofgO9 WQiesj/ON3RqRBHeJ4mcJr3FRvefRw0gweOoKtPokIp8/fN8IdYE9m1OVs0JNc1JReDt hEp/h89X9v9rTp4ctizccWG8+gJmceJn+J3VWy4ruXKVIphp7VX0KxvD7833pPjVFWdy MKpHNGRRepSAzhtBOSuGf9exmkWEMmnFlfVQw2lWRy/CM7DWlepvnwrqStv8v/a75nyT mu6/DYDRSLBRNu5rv7jqSsTpPrg/tPbYVuLDPcW8TytpxGUuUTFoRR51pC4G1oim14A4 VOMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=mlYzy+wSb4NOhKpWT5m2fOWnkyhlsBAyvm+KXUCzv5Y=; fh=+g5tGayWdOm7NVf+9R7F5Bp+AAhjebsKXKT3IUU1ti0=; b=NBQZlmO89gsJ5ECXvT3sYdawsLtkiagsaXMcqUq5+0DGre8wJfKPywoVtirogF2vAm PZrhjBiEY0Jarx9SyYS91IFmRX8Gh9XeyMPCkQKzjxrzhh//T9MJcKQe+mQvnMUzchw4 FNZ6HD+b7/ddZwGM8lMwjjs+CKOiyrfw2tG82RNp6mGytZAIs+F+r2X/JO1Z9Jqeqlnf Kn3CUh4eJ+SIGi01YVYAHLqJaQuWnRE14KrpIwOuDoy+StAJDxij+5/K8nx2XvmR+Siu ddjeb64M5HaaodhzoR9boNxsHJ3StPlHVMA370Rr2R5X57SUxuqed0qArkG/R/l7yl1q TvQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IXk3PMJP; spf=pass (google.com: domain of linux-kernel+bounces-10958-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10958-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id o16-20020a17090ac71000b0028bbbd1228esi7770010pjt.145.2023.12.25.00.46.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 00:46:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10958-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=IXk3PMJP; spf=pass (google.com: domain of linux-kernel+bounces-10958-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10958-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 45EBCB21184 for ; Mon, 25 Dec 2023 08:46:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23F0910973; Mon, 25 Dec 2023 08:45:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="IXk3PMJP" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E6D4E573; Mon, 25 Dec 2023 08:45:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BP7J6kG000493; Mon, 25 Dec 2023 08:44:52 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=mlYzy+wSb4NOhKpWT5m2fOWnkyhlsBAyvm+KXUCzv5Y=; b=IX k3PMJPQtX7mjz3tca/8PdWoEeIAEMS5FcRV6YadLuqaei82d+3t0aM2a6nXc5kau 8Pc670AO9JIu9z7qgNyJXXQMngl52RqDDP7LDMTEX4Ye15RLHJuJaEEQVh6aKOsg TWNFccUf3y0EMXUg5VyX4QbYhCnJRdO5anYA4mUvPbsjNM9cNeulrbN4AP8LVCRp e7KP+n5mSZabKiDk6Th5WSF8yBQa5JLVwXGZ8YlwuJZVD7EB25ZfK7aDZBMMRVND 0WBFKGlOdPHm5zhb75tTy8NzYw12wi2CZycsGqccfmxx4KmCXKJfTUtArzRW9Z4T +3FiRfhRVumbNUBECI/A== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v5mwr3fc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:44:51 +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 3BP8ioIY020290 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:44:50 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; Mon, 25 Dec 2023 00:44:46 -0800 From: Luo Jie To: , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v4 2/5] net: mdio: ipq4019: enable the SoC uniphy clocks for ipq5332 platform Date: Mon, 25 Dec 2023 16:44:21 +0800 Message-ID: <20231225084424.30986-3-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231225084424.30986-1-quic_luoj@quicinc.com> References: <20231225084424.30986-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: fx7OJgkIH94Uen1RapvFHDvKCoS6UkK2 X-Proofpoint-ORIG-GUID: fx7OJgkIH94Uen1RapvFHDvKCoS6UkK2 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 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312250066 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786242904022562418 X-GMAIL-MSGID: 1786242904022562418 On the platform ipq5332, the related SoC uniphy GCC clocks need to be enabled for making the MDIO slave devices accessible. These UNIPHY clocks are from the SoC platform GCC clock provider, which are enabled for the connected PHY devices working. Signed-off-by: Luo Jie --- drivers/net/mdio/mdio-ipq4019.c | 75 ++++++++++++++++++++++++++++----- 1 file changed, 64 insertions(+), 11 deletions(-) diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c index 5273864fabb3..e24b0e688b10 100644 --- a/drivers/net/mdio/mdio-ipq4019.c +++ b/drivers/net/mdio/mdio-ipq4019.c @@ -35,15 +35,36 @@ /* MDIO clock source frequency is fixed to 100M */ #define IPQ_MDIO_CLK_RATE 100000000 +/* SoC UNIPHY fixed clock */ +#define IPQ_UNIPHY_AHB_CLK_RATE 100000000 +#define IPQ_UNIPHY_SYS_CLK_RATE 24000000 + #define IPQ_PHY_SET_DELAY_US 100000 /* Maximum SOC PCS(uniphy) number on IPQ platform */ #define ETH_LDO_RDY_CNT 3 +enum mdio_clk_id { + MDIO_CLK_MDIO_AHB, + MDIO_CLK_UNIPHY0_AHB, + MDIO_CLK_UNIPHY0_SYS, + MDIO_CLK_UNIPHY1_AHB, + MDIO_CLK_UNIPHY1_SYS, + MDIO_CLK_CNT +}; + struct ipq4019_mdio_data { void __iomem *membase; void __iomem *eth_ldo_rdy[ETH_LDO_RDY_CNT]; - struct clk *mdio_clk; + struct clk *clk[MDIO_CLK_CNT]; +}; + +static const char *const mdio_clk_name[] = { + "gcc_mdio_ahb_clk", + "uniphy0_ahb", + "uniphy0_sys", + "uniphy1_ahb", + "uniphy1_sys" }; static int ipq4019_mdio_wait_busy(struct mii_bus *bus) @@ -209,14 +230,43 @@ static int ipq4019_mdio_write_c22(struct mii_bus *bus, int mii_id, int regnum, static int ipq_mdio_reset(struct mii_bus *bus) { struct ipq4019_mdio_data *priv = bus->priv; - int ret; + unsigned long rate; + int ret, index; - /* Configure MDIO clock source frequency if clock is specified in the device tree */ - ret = clk_set_rate(priv->mdio_clk, IPQ_MDIO_CLK_RATE); - if (ret) - return ret; + /* For the platform ipq5332, there are two SoC uniphies available + * for connecting with ethernet PHY, the SoC uniphy gcc clock + * should be enabled for resetting the connected device such + * as qca8386 switch, qca8081 PHY or other PHYs effectively. + * + * Configure MDIO/UNIPHY clock source frequency if clock instance + * is specified in the device tree. + */ + for (index = MDIO_CLK_MDIO_AHB; index < MDIO_CLK_CNT; index++) { + switch (index) { + case MDIO_CLK_MDIO_AHB: + rate = IPQ_MDIO_CLK_RATE; + break; + case MDIO_CLK_UNIPHY0_AHB: + case MDIO_CLK_UNIPHY1_AHB: + rate = IPQ_UNIPHY_AHB_CLK_RATE; + break; + case MDIO_CLK_UNIPHY0_SYS: + case MDIO_CLK_UNIPHY1_SYS: + rate = IPQ_UNIPHY_SYS_CLK_RATE; + break; + default: + break; + } + + ret = clk_set_rate(priv->clk[index], rate); + if (ret) + return ret; + + ret = clk_prepare_enable(priv->clk[index]); + if (ret) + return ret; + } - ret = clk_prepare_enable(priv->mdio_clk); if (ret == 0) mdelay(10); @@ -240,10 +290,6 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) if (IS_ERR(priv->membase)) return PTR_ERR(priv->membase); - priv->mdio_clk = devm_clk_get_optional(&pdev->dev, "gcc_mdio_ahb_clk"); - if (IS_ERR(priv->mdio_clk)) - return PTR_ERR(priv->mdio_clk); - /* These platform resources are provided on the chipset IPQ5018 or * IPQ5332. */ @@ -271,6 +317,13 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) } } + for (index = 0; index < MDIO_CLK_CNT; index++) { + priv->clk[index] = devm_clk_get_optional(&pdev->dev, + mdio_clk_name[index]); + if (IS_ERR(priv->clk[index])) + return PTR_ERR(priv->clk[index]); + } + bus->name = "ipq4019_mdio"; bus->read = ipq4019_mdio_read_c22; bus->write = ipq4019_mdio_write_c22; From patchwork Mon Dec 25 08:44:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 183158 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp295557dyb; Mon, 25 Dec 2023 00:46:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IFg2ZZx6LoLbHnjpZLCeYUWXzt5NQYkBZN5mrSke9Fk7Gl2Ke4EC3sHkyTcBq9NiBBp1Cua X-Received: by 2002:aca:121a:0:b0:3ba:3cee:cf50 with SMTP id 26-20020aca121a000000b003ba3ceecf50mr4568666ois.111.1703494007197; Mon, 25 Dec 2023 00:46:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703494007; cv=none; d=google.com; s=arc-20160816; b=xzvkKd3Oqcq3Z/I3b44iT89glk3FO+5ybTz9lS655jUYzTKLyab6z2ViwYSicwZ2xW 0ewLcFLdhaPAeS7G7rItP5eOsGGIckL0+8/vmP6ht+y95grfNlg4lDK+IvI0WOGbZFbE XiboWuJBLROYCnMaUTvm33Om/02Skr/nEQc35cq6CmCW3LaeeJOOWSt63UaEMkD55LAp umSwwDhl6LHVGZeGAe870VZRYwljY7BrvWMj6RbDZqxDQpi5RcpravvoS6ylL6NnhLum JYYyXbA7SF+QAVNUTHuxcD1ArpffoYvSJXRzwb3Y+ppgoCiVAH2+nlhkN5X7q/8rTA5o PmmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=XRiz7Dj2lwKbsNvmLwEtwS/An8GjKcSc1OuBpac68TE=; fh=+g5tGayWdOm7NVf+9R7F5Bp+AAhjebsKXKT3IUU1ti0=; b=NOJLSXj6Wg4JGYUwNjLXkLZTYEQrZSBEixjg1Lq6JHFkReXYLz+Ewv30lk0uX6M+El yrx/2K1kKR+pSYs+OGM98zwO0aJFIoeXDO3OsbPTNMc8oY9kkLkuPyU3cMTsQrF18m9B +1CZHm61exvPQ+T+Sz+sZFgZ9MUG4yZO7jBNIrQEbEddQeQpyFZwrkWEMuhUkHcBcFe3 u9fVO1nJ64y7qGWswXAmP7r0q2EcavaaejDZQY1FIjgOlyZBw0pdkhgNQQEOKeSmod+7 ahu+jgBmTmGlGrp4HYReGI1bBoUBZP1Xzt+wxD9+Nod+8BCkNp6FEo7EA95Y+916ho11 z7MA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XtG1c2gY; spf=pass (google.com: domain of linux-kernel+bounces-10959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10959-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id t5-20020a17090ad14500b0028c1c339f5fsi4515991pjw.35.2023.12.25.00.46.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 00:46:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=XtG1c2gY; spf=pass (google.com: domain of linux-kernel+bounces-10959-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10959-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 022D8B21281 for ; Mon, 25 Dec 2023 08:46:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6225A10A2D; Mon, 25 Dec 2023 08:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="XtG1c2gY" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B438185A; Mon, 25 Dec 2023 08:45:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BP6n4X5002523; Mon, 25 Dec 2023 08:44:56 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=XRiz7Dj2lwKbsNvmLwEtwS/An8GjKcSc1OuBpac68TE=; b=Xt G1c2gYSkeP9y2ycV+bFkFB5DT3NpWtiqIYUPQhvO8Kw4HKjgflztyKKnbNu0pT6+ Xvsq81eTK7Hu7B5+1fonOIPsBEsu7VLbGejTKm+yClWaNvIGPKOSB4qgPdOZpW3N Yy5RS+4Z/XgIv1TlDBpCpSaFlGt5rV+0prRnQ9VDQ6SZVbm2V/MPfwHVZu/Im3pT j0TwwJ14VKnVqfMG6q4J6+BaWToaB63zpYB1l+FqcJ3M2+8v5Vf0iO4OOGVPdR8Z M0gxhuIG3NLPormfmbtcT/i4p7qcHVGPeVrmqcdYghACe/32EK5uHBWUCfWW+zUq CRaK4gy4dav03mzZdpcA== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v5qs5k9gy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:44:56 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BP8it5A025535 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:44:55 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; Mon, 25 Dec 2023 00:44:50 -0800 From: Luo Jie To: , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v4 3/5] net: mdio: ipq4019: configure CMN PLL clock for ipq5332 Date: Mon, 25 Dec 2023 16:44:22 +0800 Message-ID: <20231225084424.30986-4-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231225084424.30986-1-quic_luoj@quicinc.com> References: <20231225084424.30986-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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: Btyxz-feKik-IrlyUuEczTzCqHcLPh4a X-Proofpoint-GUID: Btyxz-feKik-IrlyUuEczTzCqHcLPh4a 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_01,2023-12-07_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 clxscore=1015 adultscore=0 mlxlogscore=999 mlxscore=0 priorityscore=1501 bulkscore=0 impostorscore=0 suspectscore=0 malwarescore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312250066 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786242931822395378 X-GMAIL-MSGID: 1786242931822395378 The reference clock of CMN PLL block is selectable, the internal 48MHZ is used by default. The output clock of CMN PLL block is for providing the clock source of ethernet device(such as qca8084), there are 1 * 25MHZ and 3 * 50MHZ output clocks available for the ethernet devices. Signed-off-by: Luo Jie --- drivers/net/mdio/mdio-ipq4019.c | 129 +++++++++++++++++++++++++++++++- 1 file changed, 128 insertions(+), 1 deletion(-) diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c index e24b0e688b10..e4862ac02026 100644 --- a/drivers/net/mdio/mdio-ipq4019.c +++ b/drivers/net/mdio/mdio-ipq4019.c @@ -44,6 +44,17 @@ /* Maximum SOC PCS(uniphy) number on IPQ platform */ #define ETH_LDO_RDY_CNT 3 +#define CMN_PLL_REFERENCE_SOURCE_SEL 0x28 +#define CMN_PLL_REFCLK_SOURCE_DIV GENMASK(9, 8) + +#define CMN_PLL_REFERENCE_CLOCK 0x784 +#define CMN_PLL_REFCLK_EXTERNAL BIT(9) +#define CMN_PLL_REFCLK_DIV GENMASK(8, 4) +#define CMN_PLL_REFCLK_INDEX GENMASK(3, 0) + +#define CMN_PLL_POWER_ON_AND_RESET 0x780 +#define CMN_ANA_EN_SW_RSTN BIT(6) + enum mdio_clk_id { MDIO_CLK_MDIO_AHB, MDIO_CLK_UNIPHY0_AHB, @@ -55,6 +66,7 @@ enum mdio_clk_id { struct ipq4019_mdio_data { void __iomem *membase; + void __iomem *cmn_membase; void __iomem *eth_ldo_rdy[ETH_LDO_RDY_CNT]; struct clk *clk[MDIO_CLK_CNT]; }; @@ -227,12 +239,116 @@ static int ipq4019_mdio_write_c22(struct mii_bus *bus, int mii_id, int regnum, return 0; } +/* For the CMN PLL block, the reference clock can be configured according to + * the device tree property "qcom,cmn-ref-clock-frequency", the internal 48MHZ + * is used by default. + * + * The output clock of CMN PLL block is provided to the ethernet devices, + * threre are 4 CMN PLL output clocks (1*25MHZ + 3*50MHZ) enabled by default. + * + * Such as the output 50M clock for the qca8084 ethernet PHY. + */ +static int ipq_cmn_clock_config(struct mii_bus *bus) +{ + struct ipq4019_mdio_data *priv; + u32 reg_val, src_sel, ref_clk; + int ret; + + priv = bus->priv; + if (priv->cmn_membase) { + reg_val = readl(priv->cmn_membase + CMN_PLL_REFERENCE_CLOCK); + + /* Select reference clock source of CMN PLL block, which can + * be from wifi module or the external xtal. + * + * If absent, the wifi internal 48MHz is used as the reference + * clock source of CMN PLL block, if the 48MHZ is specified, + * which means the xtal 48MHZ is selected. + */ + ret = of_property_read_u32(bus->parent->of_node, + "qcom,cmn-ref-clock-frequency", + &ref_clk); + if (!ret) { + switch (ref_clk) { + case 25000000: + reg_val &= ~(CMN_PLL_REFCLK_EXTERNAL | + CMN_PLL_REFCLK_INDEX); + reg_val |= (CMN_PLL_REFCLK_EXTERNAL | + FIELD_PREP(CMN_PLL_REFCLK_INDEX, 3)); + break; + case 31250000: + reg_val &= ~(CMN_PLL_REFCLK_EXTERNAL | + CMN_PLL_REFCLK_INDEX); + reg_val |= (CMN_PLL_REFCLK_EXTERNAL | + FIELD_PREP(CMN_PLL_REFCLK_INDEX, 4)); + break; + case 40000000: + reg_val &= ~(CMN_PLL_REFCLK_EXTERNAL | + CMN_PLL_REFCLK_INDEX); + reg_val |= (CMN_PLL_REFCLK_EXTERNAL | + FIELD_PREP(CMN_PLL_REFCLK_INDEX, 6)); + break; + case 48000000: + reg_val &= ~(CMN_PLL_REFCLK_EXTERNAL | + CMN_PLL_REFCLK_INDEX); + reg_val |= (CMN_PLL_REFCLK_EXTERNAL | + FIELD_PREP(CMN_PLL_REFCLK_INDEX, 7)); + break; + case 50000000: + reg_val &= ~(CMN_PLL_REFCLK_EXTERNAL | + CMN_PLL_REFCLK_INDEX); + reg_val |= (CMN_PLL_REFCLK_EXTERNAL | + FIELD_PREP(CMN_PLL_REFCLK_INDEX, 8)); + break; + case 96000000: + src_sel = readl(priv->cmn_membase + + CMN_PLL_REFERENCE_SOURCE_SEL); + src_sel &= ~CMN_PLL_REFCLK_SOURCE_DIV; + src_sel |= FIELD_PREP(CMN_PLL_REFCLK_SOURCE_DIV, 0); + writel(src_sel, priv->cmn_membase + + CMN_PLL_REFERENCE_SOURCE_SEL); + + reg_val &= ~CMN_PLL_REFCLK_DIV; + reg_val |= FIELD_PREP(CMN_PLL_REFCLK_DIV, 2); + break; + default: + return -EINVAL; + } + } else if (ret == -EINVAL) { + /* the internal 48MHZ is selected by default. */ + reg_val &= ~(CMN_PLL_REFCLK_EXTERNAL | CMN_PLL_REFCLK_INDEX); + reg_val |= FIELD_PREP(CMN_PLL_REFCLK_INDEX, 7); + } else { + return ret; + } + + writel(reg_val, priv->cmn_membase + CMN_PLL_REFERENCE_CLOCK); + + /* assert CMN PLL */ + reg_val = readl(priv->cmn_membase + CMN_PLL_POWER_ON_AND_RESET); + reg_val &= ~CMN_ANA_EN_SW_RSTN; + writel(reg_val, priv->cmn_membase); + fsleep(IPQ_PHY_SET_DELAY_US); + + /* deassert CMN PLL */ + reg_val |= CMN_ANA_EN_SW_RSTN; + writel(reg_val, priv->cmn_membase + CMN_PLL_POWER_ON_AND_RESET); + fsleep(IPQ_PHY_SET_DELAY_US); + } + + return 0; +} + static int ipq_mdio_reset(struct mii_bus *bus) { struct ipq4019_mdio_data *priv = bus->priv; unsigned long rate; int ret, index; + ret = ipq_cmn_clock_config(bus); + if (ret) + return ret; + /* For the platform ipq5332, there are two SoC uniphies available * for connecting with ethernet PHY, the SoC uniphy gcc clock * should be enabled for resetting the connected device such @@ -296,7 +412,7 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) /* This resource are optional */ for (index = 0; index < ETH_LDO_RDY_CNT; index++) { res = platform_get_resource(pdev, IORESOURCE_MEM, index + 1); - if (res) { + if (res && strcmp(res->name, "cmn_blk")) { priv->eth_ldo_rdy[index] = devm_ioremap(&pdev->dev, res->start, resource_size(res)); @@ -317,6 +433,17 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) } } + /* The CMN block resource is for providing clock source to ethernet, + * which can be optionally configured on the platform ipq9574 and + * ipq5332. + */ + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "cmn_blk"); + if (res) { + priv->cmn_membase = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(priv->cmn_membase)) + return PTR_ERR(priv->cmn_membase); + } + for (index = 0; index < MDIO_CLK_CNT; index++) { priv->clk[index] = devm_clk_get_optional(&pdev->dev, mdio_clk_name[index]); From patchwork Mon Dec 25 08:44:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 183159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp295604dyb; Mon, 25 Dec 2023 00:46:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IEno+fng6Ji9msntDIZl1GeqnR6T+WoXOG4QS9TPjqwVAgJk77f1h1QME3zImK2C12BlPen X-Received: by 2002:a05:6808:ec4:b0:3bb:66da:a305 with SMTP id q4-20020a0568080ec400b003bb66daa305mr6283542oiv.96.1703494012609; Mon, 25 Dec 2023 00:46:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703494012; cv=none; d=google.com; s=arc-20160816; b=BANXuWtZ1SjmSLALaTtfNxkxg8xIlSzo3TF0gmNvl+ghNTdV44U/IbcMnXy3GKUJpI 0RU5WN1qISGm8EEPIu/VrlTEM75nbd50OIWWBC2tBCopBQI18x08D0KL2PL9i9lwhbzV AOHoxL+VGYmLNuIBiAI146byxdoMJdDshIZQp4piox62DCXVg2K51/Z0PR6+499UrL8i OB5wfsxmh6sX/FKB0EhjasWOBTRX5oAnwdxO5ad2GHTrA3Q+aDTwA+CA52pFR24OgaZR 7ol/udVNpTJMn/YLfWggko/91v09Xr3bGa1KW1BJuGx9l8KJDLqJObA1ZpywQ6jVzE+8 sPfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ds+dFd1j8HAKO33AZwKlWd1wIYwsCZ2yGMitqsnFuuk=; fh=+g5tGayWdOm7NVf+9R7F5Bp+AAhjebsKXKT3IUU1ti0=; b=L6HYfcVs00N41Pk/+Kbh20byEcF3DLtYTkIj3vKHyGvv7AqJurpnKYIkzxurjkkrK6 u4wLurdONTOYs6Ssfrbpr7/saiqz43evcYZ498QGg34nPHJlUgfm8B5bRklcfUedUUuO f/fVlTuNcTOLX6PwqPczWqEcfJ+SjykZoKBHteJaU/S8mpZR8zA9ZrkmOJeLaAMn1ukL hv4xR7HHVlyH7sP1vhnAwaeEU/3j4nbhUJmPrKiiWTGASI4D/hxc5xNXFxJG8L8drIZm uRPs0p/fUmIIlItptz0YmvH94KOzZKXu90IZQvX8zLmonMVa3aw/5xSwVy3biD6sbnh7 uGuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cyMf34YJ; spf=pass (google.com: domain of linux-kernel+bounces-10960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10960-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fb23-20020a056a002d9700b006d9b044f15csi2591627pfb.258.2023.12.25.00.46.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 00:46:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=cyMf34YJ; spf=pass (google.com: domain of linux-kernel+bounces-10960-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10960-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 59E65281C89 for ; Mon, 25 Dec 2023 08:46:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CCBED11723; Mon, 25 Dec 2023 08:45:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="cyMf34YJ" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D221210A35; Mon, 25 Dec 2023 08:45:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BP8JdrJ021745; Mon, 25 Dec 2023 08:45:02 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=ds+dFd1j8HAKO33AZwKlWd1wIYwsCZ2yGMitqsnFuuk=; b=cy Mf34YJhJsDlX7tAjKR1XQisrqbajzzs0HFV5aY9BnDH2nATaYG1oDyiPcIzaRzRs IHjZO+Mt8GNghhwdjU17QOc4NWIK1VzLC9EQfCg3aQbO5TZxI7PlvjZ8wMVKAwr1 fuBUjzW42ZL+nwUPWznA+jMV+vFacvvohK/J404lhhRIp96pJE9CsANgd2lbli5+ PMMp5NrAyNw+UMjpoBM6rXCuaPMSyAHA+S0U179PXZfdwIHHmWIzsbw+H6+dK0Om bt5ULRNsYoD6cknWTaqILGGsRUjJpjWjBmyxYmsamx3lpA7u8eM89y/qzPFKZUqS wt/VMYNE7uDufal24VIg== Received: from nalasppmta03.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v5pvnk9nx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:45:02 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA03.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BP8j169025554 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:45:01 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; Mon, 25 Dec 2023 00:44:55 -0800 From: Luo Jie To: , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v4 4/5] net: mdio: ipq4019: support MDIO clock frequency divider Date: Mon, 25 Dec 2023 16:44:23 +0800 Message-ID: <20231225084424.30986-5-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231225084424.30986-1-quic_luoj@quicinc.com> References: <20231225084424.30986-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: 6bd7DwKBOwW7_LqaIPgczliB5npCw0vG X-Proofpoint-ORIG-GUID: 6bd7DwKBOwW7_LqaIPgczliB5npCw0vG 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 bulkscore=0 adultscore=0 phishscore=0 mlxscore=0 mlxlogscore=999 spamscore=0 impostorscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 clxscore=1015 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312250066 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786242937667195536 X-GMAIL-MSGID: 1786242937667195536 The MDIO clock frequency can be divided according to the MDIO control register value. The MDIO system clock is fixed to 100MHZ, the working frequency is 100MHZ/(divider + 1), the divider value is from the bit[7:0] of control register 0x40. Signed-off-by: Luo Jie --- drivers/net/mdio/mdio-ipq4019.c | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/net/mdio/mdio-ipq4019.c b/drivers/net/mdio/mdio-ipq4019.c index e4862ac02026..fd41dd7ff9cb 100644 --- a/drivers/net/mdio/mdio-ipq4019.c +++ b/drivers/net/mdio/mdio-ipq4019.c @@ -29,6 +29,9 @@ /* 0 = Clause 22, 1 = Clause 45 */ #define MDIO_MODE_C45 BIT(8) +/* MDC frequency is SYS_CLK/(MDIO_CLK_DIV + 1), SYS_CLK is 100MHz */ +#define MDIO_CLK_DIV_MASK GENMASK(7, 0) + #define IPQ4019_MDIO_TIMEOUT 10000 #define IPQ4019_MDIO_SLEEP 10 @@ -69,6 +72,7 @@ struct ipq4019_mdio_data { void __iomem *cmn_membase; void __iomem *eth_ldo_rdy[ETH_LDO_RDY_CNT]; struct clk *clk[MDIO_CLK_CNT]; + int clk_div; }; static const char *const mdio_clk_name[] = { @@ -102,6 +106,7 @@ static int ipq4019_mdio_read_c45(struct mii_bus *bus, int mii_id, int mmd, data = readl(priv->membase + MDIO_MODE_REG); data |= MDIO_MODE_C45; + data |= FIELD_PREP(MDIO_CLK_DIV_MASK, priv->clk_div); writel(data, priv->membase + MDIO_MODE_REG); @@ -143,6 +148,7 @@ static int ipq4019_mdio_read_c22(struct mii_bus *bus, int mii_id, int regnum) data = readl(priv->membase + MDIO_MODE_REG); data &= ~MDIO_MODE_C45; + data |= FIELD_PREP(MDIO_CLK_DIV_MASK, priv->clk_div); writel(data, priv->membase + MDIO_MODE_REG); @@ -175,6 +181,7 @@ static int ipq4019_mdio_write_c45(struct mii_bus *bus, int mii_id, int mmd, data = readl(priv->membase + MDIO_MODE_REG); data |= MDIO_MODE_C45; + data |= FIELD_PREP(MDIO_CLK_DIV_MASK, priv->clk_div); writel(data, priv->membase + MDIO_MODE_REG); @@ -218,6 +225,7 @@ static int ipq4019_mdio_write_c22(struct mii_bus *bus, int mii_id, int regnum, data = readl(priv->membase + MDIO_MODE_REG); data &= ~MDIO_MODE_C45; + data |= FIELD_PREP(MDIO_CLK_DIV_MASK, priv->clk_div); writel(data, priv->membase + MDIO_MODE_REG); @@ -389,6 +397,39 @@ static int ipq_mdio_reset(struct mii_bus *bus) return ret; } +static int ipq_mdio_clk_set(struct platform_device *pdev, int *clk_div) +{ + int freq; + + /* Keep the MDIO clock divider as the hardware default value 0xff if + * the MDIO property "clock-frequency" is not specified. + */ + if (of_property_read_u32(pdev->dev.of_node, "clock-frequency", &freq)) { + *clk_div = 0xff; + return 0; + } + + /* MDC frequency is SYS_CLK/(MDIO_CLK_DIV + 1), SYS_CLK is fixed + * to 100MHz, the MDIO_CLK_DIV can be only configured the valid + * values, other values cause malfunction. + */ + switch (freq) { + case 390625: + case 781250: + case 1562500: + case 3125000: + case 6250000: + case 12500000: + *clk_div = DIV_ROUND_UP(IPQ_MDIO_CLK_RATE, freq) - 1; + break; + default: + dev_err(&pdev->dev, "Invalid clock frequency %dHZ\n", freq); + return -EINVAL; + } + + return 0; +} + static int ipq4019_mdio_probe(struct platform_device *pdev) { struct ipq4019_mdio_data *priv; @@ -451,6 +492,10 @@ static int ipq4019_mdio_probe(struct platform_device *pdev) return PTR_ERR(priv->clk[index]); } + ret = ipq_mdio_clk_set(pdev, &priv->clk_div); + if (ret) + return ret; + bus->name = "ipq4019_mdio"; bus->read = ipq4019_mdio_read_c22; bus->write = ipq4019_mdio_write_c22; From patchwork Mon Dec 25 08:44:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Luo X-Patchwork-Id: 183160 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp295858dyb; Mon, 25 Dec 2023 00:47:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsKKBzQk44nIhFhN1jkPfMkGopl+9BfzR0lq78Bi0mgVAHgzpB/0g2xxWra/ceSjlsd/0z X-Received: by 2002:a17:906:10cd:b0:a23:74e3:90da with SMTP id v13-20020a17090610cd00b00a2374e390damr1610910ejv.137.1703494067426; Mon, 25 Dec 2023 00:47:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703494067; cv=none; d=google.com; s=arc-20160816; b=MP947yNEXHb0fuKQlPav4G6+j7kbkc9ECT3lh9pYzwljkcJOkDcPdRdod6SQdYuVtV 8ujsFitaB4R3Ntdn+KmMdf/iFH1EPflGJiaQbPR1R57TdSXbWBs0upXQqSp2e5ek/F9l UwsQhUPm80zGoTUdMwmEglUxTMjBC+aSzlQIMwdxJfryFX8+9nPOn+YhATU20nt/Vs7O awdW9v/PcLTxdysYhanDm5kHxwKOZpW228wbcFkd3m8u0JRqQMV/xzk3nF4UiDLbqtIe WhC0zC1mdQz5SbYS/5uBCTxLKP4qe9n9KznOxdpWrO4ObABhXJsPRwAevHRlPnlzyXJ+ vcnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=VRfK9RWMLCh9Ms22Qc54Qyf+Loo5sc4QpXd0wUmTPtY=; fh=+g5tGayWdOm7NVf+9R7F5Bp+AAhjebsKXKT3IUU1ti0=; b=GuSdRm+CZ5U4eskv/xRKQ9GawcrjTqUoI0JsI/PFSeZwNxA2BCao/fwgzLoppwugNY Y6LVA1GQeWtXgR5Nf8G332qk6Mq/2PPZsXyv7zxTQrhlcJoTHGpibxT7rB4I0QdW4gcZ gmOFpr5MfrSBsLkFl0wxuXbeNxPFrGxHvIVBwJ4BuQ4rkxy36GOGhaNH7qsnVjOcFrIx ZZZzWenXeXQ7X7Biode7geRuPhvoBEEeZRJurtmWacFCCzmIDwiJTPaob3TXRJcTaNhg VXbh0uaNM3jq2UyRFEQibouwz4TsMVFugcrh07J2esgmnxHoy2CF6lUFo5tWBOw+CYau JJ+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mfBmgumo; spf=pass (google.com: domain of linux-kernel+bounces-10961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ka24-20020a170907921800b00a26aaa4a258si3436025ejb.275.2023.12.25.00.47.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Dec 2023 00:47:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-10961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=mfBmgumo; spf=pass (google.com: domain of linux-kernel+bounces-10961-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-10961-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DBE0C1F21298 for ; Mon, 25 Dec 2023 08:47:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B10D6883D; Mon, 25 Dec 2023 08:47:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="mfBmgumo" X-Original-To: linux-kernel@vger.kernel.org Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B78461C2E; Mon, 25 Dec 2023 08:47:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Received: from pps.filterd (m0279873.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.24/8.17.1.24) with ESMTP id 3BP8c0Ef011114; Mon, 25 Dec 2023 08:47:08 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=VRfK9RWMLCh9Ms22Qc54Qyf+Loo5sc4QpXd0wUmTPtY=; b=mf BmgumoRyOX/MFxHnUp8eOPEAHjLoNQxatFgbMc0eldoIoebehUUwHMC88IBKmPYi YXhgDjNrNLt0bxF8/WLQojRm1CHBFhLGM1zAXnDZTwc42dP8Om05etR3gst1IRug XFnUtNGDJtkgCk7dywFY2olvxWVjLwq67IiNq1X6zv42itppLim/CCE7f6iSrnRE e3QEbLcTl1Xew97+iRGrsVdLKZdnTHwoypox4dTyqSxay23qYsvI4hJtETLoB5bj f7+e6hjUjcP82cWWo6o3rrK8SR7t/cN5MFUSc4xI9RAj5DALQJlMVGC8pGV/CtKb 91wGqflwsRk8vUCWsZtA== Received: from nalasppmta01.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3v5mwr3fg8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:47:08 +0000 (GMT) Received: from nalasex01c.na.qualcomm.com (nalasex01c.na.qualcomm.com [10.47.97.35]) by NALASPPMTA01.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 3BP8j6rE014182 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 25 Dec 2023 08:47:06 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; Mon, 25 Dec 2023 00:45:00 -0800 From: Luo Jie To: , , , , , , , , , , , , , CC: , , , , Subject: [PATCH v4 5/5] dt-bindings: net: ipq4019-mdio: Document ipq5332 platform Date: Mon, 25 Dec 2023 16:44:24 +0800 Message-ID: <20231225084424.30986-6-quic_luoj@quicinc.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231225084424.30986-1-quic_luoj@quicinc.com> References: <20231225084424.30986-1-quic_luoj@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) 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-GUID: Nb0T21WSm4ZUuz0kvuUOKZMZXXcoqUq2 X-Proofpoint-ORIG-GUID: Nb0T21WSm4ZUuz0kvuUOKZMZXXcoqUq2 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 clxscore=1015 lowpriorityscore=0 bulkscore=0 malwarescore=0 impostorscore=0 adultscore=0 phishscore=0 mlxscore=0 spamscore=0 priorityscore=1501 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2311290000 definitions=main-2312250066 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1786242995017101396 X-GMAIL-MSGID: 1786242995017101396 Update the yaml file for the new DTS properties. 1. qcom,cmn-ref-clock-frequency for the CMN PLL source clock select. 2. clock-frequency for MDIO clock frequency config. 3. add uniphy AHB & SYS GCC clocks. Signed-off-by: Luo Jie --- .../bindings/net/qcom,ipq4019-mdio.yaml | 141 +++++++++++++++++- 1 file changed, 136 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml index 3407e909e8a7..205500cb1fd1 100644 --- a/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml +++ b/Documentation/devicetree/bindings/net/qcom,ipq4019-mdio.yaml @@ -18,8 +18,10 @@ properties: - items: - enum: + - qcom,ipq5332-mdio - qcom,ipq6018-mdio - qcom,ipq8074-mdio + - qcom,ipq9574-mdio - const: qcom,ipq4019-mdio "#address-cells": @@ -30,19 +32,76 @@ properties: reg: minItems: 1 - maxItems: 2 - description: - the first Address and length of the register set for the MDIO controller. - the second Address and length of the register for ethernet LDO, this second - address range is only required by the platform IPQ50xx. + maxItems: 5 + description: | + The first address and length of the register set for the MDIO controller, + the optional second address and length of the register is for CMN block, + the optional third, fourth and fifth address and length of the register + for Ethernet LDO, the optional Ethernet LDO address range is required by + the platform IPQ50xx/IPQ5332. + + reg-names: + minItems: 1 + items: + - const: mdio + - const: cmn_blk + - const: eth_ldo1 + - const: eth_ldo2 + - const: eth_ldo3 clocks: + minItems: 1 items: - description: MDIO clock source frequency fixed to 100MHZ + - description: UNIPHY0 AHB clock source frequency fixed to 100MHZ + - description: UNIPHY1 AHB clock source frequency fixed to 100MHZ + - description: UNIPHY0 SYS clock source frequency fixed to 24MHZ + - description: UNIPHY1 SYS clock source frequency fixed to 24MHZ clock-names: + minItems: 1 items: - const: gcc_mdio_ahb_clk + - const: uniphy0_ahb + - const: uniphy1_ahb + - const: uniphy0_sys + - const: uniphy1_sys + + qcom,cmn-ref-clock-frequency: + $ref: /schemas/types.yaml#/definitions/uint32 + enum: + - 25000000 + - 31250000 + - 40000000 + - 48000000 + - 50000000 + - 96000000 + default: 48000000 + description: | + The reference clock source of CMN PLL block is selectable, the + reference clock source can be from wifi module or the external + xtal, the reference clock frequency 48MHZ can be from internal + wifi or the external xtal, if absent, the internal 48MHZ is used, + if the 48MHZ is specified, which means the external 48Mhz is used. + + clock-frequency: + enum: + - 390625 + - 781250 + - 1562500 + - 3125000 + - 6250000 + - 12500000 + default: 390625 + description: | + The MDIO bus clock that must be output by the MDIO bus hardware, + only the listed frequencies above can be supported, other frequency + will cause malfunction. If absent, the default hardware value 0xff + is used, which means the default MDIO clock frequency 390625HZ, The + MDIO clock frequency is MDIO_SYS_CLK/(MDIO_CLK_DIV + 1), the SoC + MDIO_SYS_CLK is fixed to 100MHZ, the MDIO_CLK_DIV is from MDIO control + register, there is higher clock frequency requirement on the normal + working case where the MDIO slave devices support high clock frequency. required: - compatible @@ -59,8 +118,10 @@ allOf: contains: enum: - qcom,ipq5018-mdio + - qcom,ipq5332-mdio - qcom,ipq6018-mdio - qcom,ipq8074-mdio + - qcom,ipq9574-mdio then: required: - clocks @@ -70,6 +131,20 @@ allOf: clocks: false clock-names: false + - if: + properties: + compatible: + contains: + enum: + - qcom,ipq5332-mdio + then: + properties: + clocks: + minItems: 5 + maxItems: 5 + reg-names: + minItems: 4 + unevaluatedProperties: false examples: @@ -100,3 +175,59 @@ examples: reg = <4>; }; }; + + - | + #include + #include + + mdio@90000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "qcom,ipq5332-mdio", + "qcom,ipq4019-mdio"; + + reg = <0x90000 0x64>, + <0x9b000 0x800>, + <0x7a00610 0x4>, + <0x7a10610 0x4>; + + reg-names = "mdio", + "cmn_blk", + "eth_ldo1", + "eth_ldo2"; + + clocks = <&gcc GCC_MDIO_AHB_CLK>, + <&gcc GCC_UNIPHY0_AHB_CLK>, + <&gcc GCC_UNIPHY1_AHB_CLK>, + <&gcc GCC_UNIPHY0_SYS_CLK>, + <&gcc GCC_UNIPHY1_SYS_CLK>; + + clock-names = "gcc_mdio_ahb_clk", + "uniphy0_ahb", + "uniphy1_ahb", + "uniphy0_sys", + "uniphy1_sys"; + + clock-frequency = <6250000>; + reset-gpios = <&tlmm 51 GPIO_ACTIVE_LOW>; + + qca8kphy0: ethernet-phy@1 { + compatible = "ethernet-phy-id004d.d180"; + reg = <1>; + }; + + qca8kphy1: ethernet-phy@2 { + compatible = "ethernet-phy-id004d.d180"; + reg = <2>; + }; + + qca8kphy2: ethernet-phy@3 { + compatible = "ethernet-phy-id004d.d180"; + reg = <3>; + }; + + qca8kphy3: ethernet-phy@4 { + compatible = "ethernet-phy-id004d.d180"; + reg = <4>; + }; + };