From patchwork Fri Feb 16 15:21:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Xiwen via B4 Relay X-Patchwork-Id: 202208 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:c619:b0:108:e6aa:91d0 with SMTP id hn25csp599446dyb; Fri, 16 Feb 2024 07:43:25 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV+jmSgcdPwrjwcsmH6ypu767udq1vExYVqlKwobqNyUOEuoExTwBSB9hunqlUF8WUEkp+wLk+sjyF0bIEo3tbx3pFPyw== X-Google-Smtp-Source: AGHT+IE+g1th4UcyhQWFZ9FG4oIlcX5vbg8s6N4X6Sjkojib5hqDNzxzhrxxnwkSLYDLs6fyXcu9 X-Received: by 2002:a17:906:f20d:b0:a3d:2637:b713 with SMTP id gt13-20020a170906f20d00b00a3d2637b713mr4315689ejb.54.1708098205657; Fri, 16 Feb 2024 07:43:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708098205; cv=pass; d=google.com; s=arc-20160816; b=C7aAWDF4UJ2M3UP58rWd/F08lKZRsY9BRkK2a8CMtlQOsTJrRYoTIxTXc/BWLCt4Q8 jjcXH+0p1fuWdyHP3cgKbe+cMXeVbzLuafCcsoU6GD+TpgzOo/gZTjvnXq9WU1pmPDT2 2/hswh/PnlJeEYW765jPygZtu8bFXPtmU1ZzVx9UgAz1MjtVjGzDeDDUREG0NYlJZhDt 1rg7vxvu3p5VfumZOMGC7SWMKZncN83GOO5j2XKvI3yYz7lSSthvhMxyCvU9KwZLsEhH ch0X4ppkjncbAsL60cSvLlqwRiQuEfscTNP5ngKnyiz2GvN6IJJv9TNo59Rpw0bULiR6 utsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=reply-to:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:subject:date:from:dkim-signature; bh=xnfFG1IcfV8ofAasZcI2+aKrB59CIk23xjg3Vu9U3Wk=; fh=/wRwIHgmVsrLW9sRFYxTGxZ4FeMBZ7dOboqO3KP8JJ0=; b=F9stwroQocPevu24IwnYtex8rr5wndLSthp3V/knnThoziiz7aeEbpfXgTCPxrqoi6 KBFopQFfKrije6yruv3JoSPEdlPrlfeK9JW6xgRC0bVloewWKD12dcq3EWHoiivnW7y1 Qs93TB0enwTcQm5/auq5sBegr4E2KhWF7eMIvoIkZ4D7eelxmRUHs1tXsxMlRdAp7Hq4 bjgG82jCqPXmE/a08AiuHySf6w6DzSkEVRciSXcRFhJX6zbBzjKigpIKQYdCcaZag7SZ N3+03v0SsIk7fSUyg7qgdRBtguhROcHs0SKMhhnQ94fntGs9TW2wsSLD5jJwuo7nZATs 4MjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MYUmG14Y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68864-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68864-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gb33-20020a170907962100b00a3d8f34187dsi48489ejc.166.2024.02.16.07.43.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 07:43:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-68864-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MYUmG14Y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-68864-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-68864-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 5FF981F26D6B for ; Fri, 16 Feb 2024 15:32:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CDF7A132C0E; Fri, 16 Feb 2024 15:21:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MYUmG14Y" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C314512F590; Fri, 16 Feb 2024 15:21:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096887; cv=none; b=Y/XHDAx2ON+Pe7l39jAeiWygHppEoTWx0k3i9sD7YH1UCY8g9PjXDJYcZJsu4RvIhGxYMItaQW+J1qY+LNa/beikXX++OHrvm7FEwOhrvZnhlv+MevRRtziWAWVuvHSIkCAmCN22xN2sZp36n1OuyX4hmvkQW+6hqv2FQGxkybI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708096887; c=relaxed/simple; bh=VZRY9XMcrLAgmTWhll1wn7de+3/sRUO6L2Lrel3FpI4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gPqKCXtV40olTZSb5PnjFldVGf5q04UpzVa8Yp0MzjeHs9jRrRa8ejeYGzq4xTKJkktSifLSShtNg20J5digjRqtnTYx+WaHypmv30y3tfU7sHogTPucfPXuK6Abz0HuH5l3XVgHhKZYu0UDjfHyF/2Uy5Q8oYcVjK+YUIQMbhI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MYUmG14Y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPS id 6FAF9C43399; Fri, 16 Feb 2024 15:21:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708096887; bh=VZRY9XMcrLAgmTWhll1wn7de+3/sRUO6L2Lrel3FpI4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=MYUmG14Y6GAR7dXeLLMyO/HceOQZTMXcdhkW2OLPis21rUNEunHY1VX/sfoEyQKGt /GBdMNvLiaomKDwHrA+o6jfiJw4eRVCkY7s9EQ9S/Sp5DVRq6jC8PRbeSwbBBdwZpl MjMvtr5EMjIy8005XVToeJwH/MpFyoQ1tmz5Fn/Dbp2UElV6dfjZBjqEyj1XyGcwqQ HaoOqwkaObYZjBL1rJHLCmPE045/5JUT9XTQ/5Zl/C+btb15kresMHFWFAq3wa+0Bb gMmIU74Ie0gmEdLyNrka4Dv3sWwDn/f0FSJMsX7Ord0u0MiA79XHAhc3FB3GIDc4z6 bg2r6ydx+kupA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4F61FC48BF6; Fri, 16 Feb 2024 15:21:27 +0000 (UTC) From: Yang Xiwen via B4 Relay Date: Fri, 16 Feb 2024 23:21:03 +0800 Subject: [PATCH RFC 3/4] phy: hisi-inno-usb2: add support for direct MMIO Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240216-inno-phy-v1-3-1ab912f0533f@outlook.com> References: <20240216-inno-phy-v1-0-1ab912f0533f@outlook.com> In-Reply-To: <20240216-inno-phy-v1-0-1ab912f0533f@outlook.com> To: Vinod Koul , Kishon Vijay Abraham I , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jiancheng Xue , Pengcheng Li , Shawn Guo Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Kishon Vijay Abraham I , David Yang , Yang Xiwen X-Mailer: b4 0.12.4 X-Developer-Signature: v=1; a=ed25519-sha256; t=1708096886; l=3548; i=forbidden405@outlook.com; s=20230724; h=from:subject:message-id; bh=vlXiKqsLZeXsfy+2X2tFbKV08QHZormBiBHhDir/Zg8=; b=PvrXOIVdC8a36f4CWMQWiDK4swW9T8EN05s/5LxcRoeUztInX+RUWn2ky2HoAJtxOFlS6uM64 yd2w5HpwpGgAkRRgHzbqCMWE3hQipcLwTE0595hdjY5aZZupxZNjCY0 X-Developer-Key: i=forbidden405@outlook.com; a=ed25519; pk=qOD5jhp891/Xzc+H/PZ8LWVSWE3O/XCQnAg+5vdU2IU= X-Endpoint-Received: by B4 Relay for forbidden405@outlook.com/20230724 with auth_id=67 X-Original-From: Yang Xiwen Reply-To: X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791070783955761614 X-GMAIL-MSGID: 1791070783955761614 From: Yang Xiwen This method of resgiter access is used by Hi3798MV200. For other models, of_iomap() returns 0 due to insufficient length. So they are unaffected. Signed-off-by: Yang Xiwen --- drivers/phy/hisilicon/phy-hisi-inno-usb2.c | 53 +++++++++++++++++++----------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c index b7e740eb4752..12a158fb749c 100644 --- a/drivers/phy/hisilicon/phy-hisi-inno-usb2.c +++ b/drivers/phy/hisilicon/phy-hisi-inno-usb2.c @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -43,6 +44,7 @@ #define PHY_CLK_ENABLE BIT(2) struct hisi_inno_phy_port { + void __iomem *base; struct reset_control *utmi_rst; struct hisi_inno_phy_priv *priv; }; @@ -62,26 +64,31 @@ static void hisi_inno_phy_write_reg(struct hisi_inno_phy_priv *priv, u32 val; u32 value; - if (priv->type == PHY_TYPE_0) - val = (data & PHY_TEST_DATA) | - ((addr << PHY_TEST_ADDR_OFFSET) & PHY0_TEST_ADDR) | - ((port << PHY0_TEST_PORT_OFFSET) & PHY0_TEST_PORT) | - PHY0_TEST_WREN | PHY0_TEST_RST; - else - val = (data & PHY_TEST_DATA) | - ((addr << PHY_TEST_ADDR_OFFSET) & PHY1_TEST_ADDR) | - ((port << PHY1_TEST_PORT_OFFSET) & PHY1_TEST_PORT) | - PHY1_TEST_WREN | PHY1_TEST_RST; - writel(val, reg); - - value = val; - if (priv->type == PHY_TYPE_0) - value |= PHY0_TEST_CLK; - else - value |= PHY1_TEST_CLK; - writel(value, reg); - - writel(val, reg); + if (priv->ports[port].base) + // stride is 4 + writel(data, (u32 *)priv->ports[port].base + addr); + else { + if (priv->type == PHY_TYPE_0) + val = (data & PHY_TEST_DATA) | + ((addr << PHY_TEST_ADDR_OFFSET) & PHY0_TEST_ADDR) | + ((port << PHY0_TEST_PORT_OFFSET) & PHY0_TEST_PORT) | + PHY0_TEST_WREN | PHY0_TEST_RST; + else + val = (data & PHY_TEST_DATA) | + ((addr << PHY_TEST_ADDR_OFFSET) & PHY1_TEST_ADDR) | + ((port << PHY1_TEST_PORT_OFFSET) & PHY1_TEST_PORT) | + PHY1_TEST_WREN | PHY1_TEST_RST; + writel(val, reg); + + value = val; + if (priv->type == PHY_TYPE_0) + value |= PHY0_TEST_CLK; + else + value |= PHY1_TEST_CLK; + writel(value, reg); + + writel(val, reg); + } } static void hisi_inno_phy_setup(struct hisi_inno_phy_priv *priv) @@ -167,6 +174,7 @@ static int hisi_inno_phy_probe(struct platform_device *pdev) for_each_child_of_node(np, child) { struct reset_control *rst; struct phy *phy; + void __iomem *base; rst = of_reset_control_get_exclusive(child, NULL); if (IS_ERR(rst)) { @@ -174,7 +182,10 @@ static int hisi_inno_phy_probe(struct platform_device *pdev) return PTR_ERR(rst); } + base = of_iomap(child, 0); + priv->ports[i].utmi_rst = rst; + priv->ports[i].base = base; priv->ports[i].priv = priv; phy = devm_phy_create(dev, child, &hisi_inno_phy_ops); @@ -205,6 +216,8 @@ static const struct of_device_id hisi_inno_phy_of_match[] = { .data = (void *) PHY_TYPE_0 }, { .compatible = "hisilicon,hi3798mv100-usb2-phy", .data = (void *) PHY_TYPE_1 }, + { .compatible = "hisilicon,hi3798mv200-usb2-phy", + .data = (void *) PHY_TYPE_0 }, { }, }; MODULE_DEVICE_TABLE(of, hisi_inno_phy_of_match);