From patchwork Wed Aug 4 13:06:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Riesch X-Patchwork-Id: 12418703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39B58C4338F for ; Wed, 4 Aug 2021 13:07:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id ED5F16052B for ; Wed, 4 Aug 2021 13:07:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org ED5F16052B Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=wolfvision.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9EXygV42KF9LvVfUJMah/d0k35K/+i+WGvJQDQ2A82c=; b=nsiN3vjNOQrq6A Efb93RL7rwlJuYZzaz+2y1sb3xM051yxMShDfPYOUuAtnNOX4tml9onjQ+AW5W0nV1LJ3fljrSKWX Y+vpMdEsNqd0RRo4lUGV5XE2oxWommp52a5ai2mirjTSQawS1tGGEagY5Rmjf/KVqQMi18C6XcqnT 3bVsY90pFziM1sP6+TVWksi1n0BCPZJy+tVaONooko01pLBitU/zK+rX5JtzMn7F/xA5Bzc6Rb2bo sk+QBNheLfx0AGnRaCzqkkQDxoAAJRUmtI/5jwUDByUKQhwB03SRGbXdyy4psTYs0+nq/Ox7q1TcQ SnUdN3Ynj6lFFjhdVz1w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBGcC-0065B9-22; Wed, 04 Aug 2021 13:07:20 +0000 Received: from mail-am6eur05on2083.outbound.protection.outlook.com ([40.107.22.83] helo=EUR05-AM6-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBGbf-0064ze-4p; Wed, 04 Aug 2021 13:06:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tj3TLTk+A+khWyc8qts9NfwXx62oOyFkvhv1Ckqavwe2Jgg0D8jLKX/Z13zY7Dzy+JaCl7wfeTqVRcUHKHtjFd621LVepOZSQjwPXOb/bZRpO1n1pdJvzRCbYS5QgiY/NtR7gf3PSjNAqSryDgpql3ysZlN6TkddR938Vt/CuSQANlsTGp8N191LnD+GgBaSt2KkKU4XVozn9I82FwXbOGDFmE9JnIashPnYFWpBYBFY0kMoFzfKdIJUlYgAzE4orWfX/XmESvhji/WaK/o3zpL6NoyOCih4hKvDPkGYbI1OhjvkPPGaSnbE1UL4P1hXhwQ3QbMmyf5hcvs3WFQIqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T3SrhTEWB6RsTJABTHRL98bEpe62oMj/f0PP0YasWqo=; b=Ah2cGhuf6GZEnKqLRILXvMYqBfM0+yllLiyz0zuGdOOVDyVE3ioFPgVsz7PiW7fS0oR6UPNYBr3TNTV9tMQw4KQ2dST1QImUqaWHwwuzXhHPQ1BMEYl+Sf89X/zeZq6W/P9NStMwBzcQm1i17/Pyvp2xgXXWVdsVXh3TrAi5xkoKImKo7A40yNMnP1tPqgVF49e+fFm305mS14MaIgQ5H8uNa4r5zOWW7taVW0Clz3jhyATEHjh0KNMldMtM+ZZXuAOPwOquajSFdQT64tYiuxlS4ugAotP3E83G24nzz1lT7U7XXkOCViW626sqRiZvZLeMxAnDdr7ZFDWXPDV++w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=wolfvision.net; dmarc=pass action=none header.from=wolfvision.net; dkim=pass header.d=wolfvision.net; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wolfvision.net; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T3SrhTEWB6RsTJABTHRL98bEpe62oMj/f0PP0YasWqo=; b=KYpkK7parughIT1xcpWiA9Zl0jGykxQe2EahZVj0P7rPXGfiznImbJsOaFFdvwjtQESGqVuYOPnQsIXdRjFwOkbHf3idgHvfMqjqOm7ydAPixpZFnEWptXhW0VDGOI/Nu6WmAtr7PuWyi3XpnXpx9ZIgRXYIoAwnEweyRLMJZuQ= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=wolfvision.net; Received: from DBBPR08MB4523.eurprd08.prod.outlook.com (2603:10a6:10:c8::19) by DB8PR08MB5401.eurprd08.prod.outlook.com (2603:10a6:10:f9::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.21; Wed, 4 Aug 2021 13:06:44 +0000 Received: from DBBPR08MB4523.eurprd08.prod.outlook.com ([fe80::ade3:93e2:735c:c10b]) by DBBPR08MB4523.eurprd08.prod.outlook.com ([fe80::ade3:93e2:735c:c10b%7]) with mapi id 15.20.4394.016; Wed, 4 Aug 2021 13:06:44 +0000 From: Michael Riesch To: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Rob Herring , Heiko Stuebner , Liang Chen , Peter Geis , Sascha Hauer , Michael Riesch , Simon Xue , Jianqun Xu , "Rafael J . Wysocki" , Lee Jones , Ulf Hansson , Zhang Changzhong , Johan Jonker Subject: [PATCH v2 1/7] soc: rockchip: io-domain: add rk3568 support Date: Wed, 4 Aug 2021 15:06:19 +0200 Message-Id: <20210804130625.15449-2-michael.riesch@wolfvision.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210804130625.15449-1-michael.riesch@wolfvision.net> References: <20210804130625.15449-1-michael.riesch@wolfvision.net> X-ClientProxiedBy: AM4PR0202CA0012.eurprd02.prod.outlook.com (2603:10a6:200:89::22) To DBBPR08MB4523.eurprd08.prod.outlook.com (2603:10a6:10:c8::19) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from carlos.wolfvision-at.intra (91.118.163.37) by AM4PR0202CA0012.eurprd02.prod.outlook.com (2603:10a6:200:89::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Wed, 4 Aug 2021 13:06:43 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f26376e5-0020-46fe-1113-08d95748b57f X-MS-TrafficTypeDiagnostic: DB8PR08MB5401: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uspHaZluyfk2F4BJgrs3rHWtgBSL5qis+au49pRRqSMcXZZ4ZBt/PvMfJ0ogPXMQa1Pj6T3dkLV2Y4qgT5BWfUe0BXe9kkgT3B8XlAV4OA3dyGObqrLrzm5Z59YwDb2/ScST8iJqac8WSlxcTnO2PSwoDNiuhoSP+4LIclC9LR1BOEb7DLbEZG6OBiDj+LW/WNrUyK/uoJXStL0nsEagPXs2N7PN0tp5LjjwnFXybEYzRaeZIxB5g/BXZM0lCeY27uuATRKnS4C4Hy0IRVenTPVpVFX+wXs9y+WmWfffD1vLV7GpnU0rzkneIVvcXWokxn5rIYNx0GrQT1+Q3jcDHs8p55hxUb+ePOyy00Bh4HV1QmAfJbCRy8cLe7ZeBut1mc+lHitMg3AB27PuZeGeLrMFGlm3kCkw1gwYzTzzldR6WPIddDq47UQlV1Zm4De1FlVxVg7I6qIBJ2owH4G0UVXuxbsbcfjN8QiNjDOlWwXVfNOzFkgDufg462b+uyVmIPaqIUJHScZiYjckPboniKQPO5q5lIbQqEOOT1NlK7emxlEeA07UxGqjszeUby1qJO65OF9eJT/xHLY+Jf6x7ggdodJkMhF92IvHoi1NyF6rhfbuJM+Qys21NAmnxueNjI7lNSeYlkvpaDA3kt5CQM2l+wStnCsTCQ/OvBM4hnmfWAgDXzVUabYOjyrmkj1WLGaGZTEWKiMxSZIu4uqtUA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR08MB4523.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(376002)(39840400004)(396003)(366004)(346002)(136003)(8676002)(186003)(956004)(1076003)(7416002)(478600001)(2616005)(2906002)(66556008)(8936002)(66476007)(66946007)(52116002)(6666004)(83380400001)(54906003)(36756003)(38350700002)(5660300002)(44832011)(316002)(6512007)(38100700002)(26005)(86362001)(6486002)(4326008)(6506007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1U984eUh/OXHDJSNFO4JlVHIDL3VdjElmXpOUNqz3SEUPIo8VdEI14xyTJO+xU0FgZyC+VqgsUMRvCpYxZF32AIWYHdxpO/4Jm1lafDSl7ToCuVmf+I0jdLNb819ZAz8k8yi5/TCYef3LN963EZ1J3X4Dt0BPOUAZuHSq132ZHCvHAawll4DlmmT1ySC5D/sP++qx/KrflVDOpzHeUSYSlbhcHxq9C+Bbp7UluHePjHY/nQ7C/UXm28ChTXLDvOpv4NEWPq+LmF+JlF3f+HN8OKYfAE6x9eEeiGXOJiXcIswr+/AxCEyZC8XdqEz8oT+PzhGmtvqvyDSFGNSRpceubapNPSAwuO81uN/EA96anNCfH37GlMz8sF+hKq5S4/jPNFP2XRTQb0JcSFv1CWd4Lc9A1MHLvENIIcA/Ew6AVYnLAbMWn7gA0BQsH0NTPufT4NgkDF5JGkbTklv72fwD+608j/JC3U2zx7ptwhqPWz7vCLeZmm76P2cVtnO+OhINqPZ6W17GkM/3jWTCwqGPqXPKvWnVbXQHukzLILWkmGIyExfugeCgwf20XgrV1+6U+9JapTejPrSNGkONiaFl+HfL2kN4US56Yq40Xy25EcTncNS60tJA2uZvGz2AFsnBpKwBZjZErFwfE6TuaJNiKDqEV5Ar5H7IqBdyZnPXCaeXl8zw1xa4SPT+znxZ9f90ECkKlrNZZ37tDd0QpNRHOfNglNdrPSHFiMKhsGjXYgUzUKkbqsW7Sg444J7z0BUM8tMOyELeJY/u85LS0g/Tft32barRLvUUr+ZaoO6fQlDgqOLXm/wVQkrBOhgxKHZL3CGDWaEaDsAEmpNLK4acYv0GjViAT7jpUXdfC/0e8Ji3QZQu/KiZiAlFVbsGDlJa9vFvbkRVsGav3e3z3s2a7wR3Ag9FPSfyQ8I6OjvuzBLJUDrfKfsjp+yDGsZvyL7lfYd7qoqoo4KQtma+M2J/K7zVKAziXiQn9vznrNfXKoImqd5ApBOZ3TXVcgNQ7dZt+WpiIWp+H41HYz3aYjJT3apZ1dkT5Q6cAWHCG3l4Tb/Fd8cHL7mFf/+LHCdGYiVXkFkcHeaQZDNiTaRoYc2whGdDOR5Nhmj33hiznP7/PA6J8yrbzKqE+hytEv6MKILKj9KA6QucuWMu3oB3QAGFXrOUPeO0f14FZ/enuLVVysaSf05nu8ewI0z+JY7w2XNLv5xsEAMavOTfKOIn8VEZhmM2N5jxP8XZ3t26eV5wYnukyAcutpFZ4pDbZBqJzsGS38GoguUxKOsbEpaqZDkmSYj02cWZShcyoOveAZi98oRiw7GkZAYCitNwkpbOg97 X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: f26376e5-0020-46fe-1113-08d95748b57f X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB4523.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Aug 2021 13:06:44.4910 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e94ec9da-9183-471e-83b3-51baa8eb804f X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: P1auCVnimmzs6JGPXuFkP0IQCIY5FGnINEThmLBhAm+ckdgUlw/O07mRQux/+8aBgCbxGKCYwSk0L6esr1mvbIgG/Bxj/+/yHMtVZ1fsnu8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5401 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210804_060647_270598_8F6EF582 X-CRM114-Status: GOOD ( 20.80 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org From: Jianqun Xu The io-domain registers on RK3568 SoCs have three separated bits to enable/disable the 1.8v/2.5v/3.3v power. This patch make the write to be a operation, allow rk3568 uses a private register set function. Since the 2.5v is not used on RK3568, so the driver only set 1.8v [enable] + 3.3v [disable] for 1.8v mode 1.8v [disable] + 3.3v [enable] for 3.3v mode There is not register order requirement which has been cleared by our IC team. Signed-off-by: Jianqun Xu --- drivers/soc/rockchip/io-domain.c | 88 +++++++++++++++++++++++++++++--- 1 file changed, 80 insertions(+), 8 deletions(-) diff --git a/drivers/soc/rockchip/io-domain.c b/drivers/soc/rockchip/io-domain.c index cf8182fc3642..13c446fd33a9 100644 --- a/drivers/soc/rockchip/io-domain.c +++ b/drivers/soc/rockchip/io-domain.c @@ -51,13 +51,11 @@ #define RK3399_PMUGRF_CON0_VSEL BIT(8) #define RK3399_PMUGRF_VSEL_SUPPLY_NUM 9 -struct rockchip_iodomain; +#define RK3568_PMU_GRF_IO_VSEL0 (0x0140) +#define RK3568_PMU_GRF_IO_VSEL1 (0x0144) +#define RK3568_PMU_GRF_IO_VSEL2 (0x0148) -struct rockchip_iodomain_soc_data { - int grf_offset; - const char *supply_names[MAX_SUPPLIES]; - void (*init)(struct rockchip_iodomain *iod); -}; +struct rockchip_iodomain; struct rockchip_iodomain_supply { struct rockchip_iodomain *iod; @@ -66,13 +64,62 @@ struct rockchip_iodomain_supply { int idx; }; +struct rockchip_iodomain_soc_data { + int grf_offset; + const char *supply_names[MAX_SUPPLIES]; + void (*init)(struct rockchip_iodomain *iod); + int (*write)(struct rockchip_iodomain_supply *supply, int uV); +}; + struct rockchip_iodomain { struct device *dev; struct regmap *grf; const struct rockchip_iodomain_soc_data *soc_data; struct rockchip_iodomain_supply supplies[MAX_SUPPLIES]; + int (*write)(struct rockchip_iodomain_supply *supply, int uV); }; +static int rk3568_iodomain_write(struct rockchip_iodomain_supply *supply, int uV) +{ + struct rockchip_iodomain *iod = supply->iod; + u32 is_3v3 = uV > MAX_VOLTAGE_1_8; + u32 val0, val1; + int b; + + switch (supply->idx) { + case 0: /* pmuio1 */ + break; + case 1: /* pmuio2 */ + b = supply->idx; + val0 = BIT(16 + b) | (is_3v3 ? 0 : BIT(b)); + b = supply->idx + 4; + val1 = BIT(16 + b) | (is_3v3 ? BIT(b) : 0); + + regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL2, val0); + regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL2, val1); + break; + case 3: /* vccio2 */ + break; + case 2: /* vccio1 */ + case 4: /* vccio3 */ + case 5: /* vccio4 */ + case 6: /* vccio5 */ + case 7: /* vccio6 */ + case 8: /* vccio7 */ + b = supply->idx - 1; + val0 = BIT(16 + b) | (is_3v3 ? 0 : BIT(b)); + val1 = BIT(16 + b) | (is_3v3 ? BIT(b) : 0); + + regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL0, val0); + regmap_write(iod->grf, RK3568_PMU_GRF_IO_VSEL1, val1); + break; + default: + return -EINVAL; + }; + + return 0; +} + static int rockchip_iodomain_write(struct rockchip_iodomain_supply *supply, int uV) { @@ -136,7 +183,7 @@ static int rockchip_iodomain_notify(struct notifier_block *nb, return NOTIFY_BAD; } - ret = rockchip_iodomain_write(supply, uV); + ret = supply->iod->write(supply, uV); if (ret && event == REGULATOR_EVENT_PRE_VOLTAGE_CHANGE) return NOTIFY_BAD; @@ -398,6 +445,22 @@ static const struct rockchip_iodomain_soc_data soc_data_rk3399_pmu = { .init = rk3399_pmu_iodomain_init, }; +static const struct rockchip_iodomain_soc_data soc_data_rk3568_pmu = { + .grf_offset = 0x140, + .supply_names = { + "pmuio1", + "pmuio2", + "vccio1", + "vccio2", + "vccio3", + "vccio4", + "vccio5", + "vccio6", + "vccio7", + }, + .write = rk3568_iodomain_write, +}; + static const struct rockchip_iodomain_soc_data soc_data_rv1108 = { .grf_offset = 0x404, .supply_names = { @@ -469,6 +532,10 @@ static const struct of_device_id rockchip_iodomain_match[] = { .compatible = "rockchip,rk3399-pmu-io-voltage-domain", .data = &soc_data_rk3399_pmu }, + { + .compatible = "rockchip,rk3568-pmu-io-voltage-domain", + .data = &soc_data_rk3568_pmu + }, { .compatible = "rockchip,rv1108-io-voltage-domain", .data = &soc_data_rv1108 @@ -502,6 +569,11 @@ static int rockchip_iodomain_probe(struct platform_device *pdev) match = of_match_node(rockchip_iodomain_match, np); iod->soc_data = match->data; + if (iod->soc_data->write) + iod->write = iod->soc_data->write; + else + iod->write = rockchip_iodomain_write; + parent = pdev->dev.parent; if (parent && parent->of_node) { iod->grf = syscon_node_to_regmap(parent->of_node); @@ -562,7 +634,7 @@ static int rockchip_iodomain_probe(struct platform_device *pdev) supply->reg = reg; supply->nb.notifier_call = rockchip_iodomain_notify; - ret = rockchip_iodomain_write(supply, uV); + ret = iod->write(supply, uV); if (ret) { supply->reg = NULL; goto unreg_notify;