From patchwork Thu Aug 5 12:01:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Riesch X-Patchwork-Id: 12421065 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 70360C4338F for ; Thu, 5 Aug 2021 12:04:40 +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 307E26113E for ; Thu, 5 Aug 2021 12:04:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 307E26113E 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=pghXADEFND8RvGRxHqcRBSOSkhjCtJUpIX2uIWgbrlk=; b=XRIBfq6ceQNhwO vAyXmrqLeMFosvXtlXdy+70bzVBOHCuo7oAzoLKZ2+tzvKZixH1YEWrdqDf2BDxvzr+b2viqcW725 p9hbsENWmAYYzmupO7wIAA7k+7OJgZrgq5d8Ibchex7BtZwBeUofrMy7JnlQj5LBxWpOHpIA/mDSW OfXhWToFEVShSYjHFeItKsianwXa3sFEJRql25opunc3GgCZIC4L87pKnnl75vf8Gicoi/YKfbixv Cdjt/Jtij3GQOFyWOtcboFTpJX8cb5sKtr0xpjh+5rj+E9+Msn9y0wedh54EaKHAtXEiZJWqnSpfQ vTtlkYJhKR70JZcoQN2A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBc4Y-009Kjb-0E; Thu, 05 Aug 2021 12:02:02 +0000 Received: from mail-db8eur05on2078.outbound.protection.outlook.com ([40.107.20.78] helo=EUR05-DB8-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mBc43-009KVj-Ng; Thu, 05 Aug 2021 12:01:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CDY+nUGfMhkVIGXsu4Vaw7c9ztewz4ZDOpQK/v3+4azY1E7csznX1NV7scJrPSXlH04lc/E2ZLtWxUX1xvXRg7gjR9jmpenr/uAFR76EldNHsTiB7xV7pMa4ASDbZ+t7RqqGY0trEYa1PiCFk9qPZj7/H9ExfJFuWTbPWCk24t5+uF1V4X6bWOrQA2JiE24gm1Fu8Vzsv/uuMSK+SH075LKlehpmIJZ7fKQs1ruOMjvuA0CyalnKCpbe3gIr6X+5VM4Fk8nvmC2VOJ+Z8gQODcTDcyTnYrSfzbxS61qxU19oMJ/RQ9TbnJjI8UWNBTTXjOpAEYfqKDhOosLY+7hgcA== 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=1VhqnL0+9ZAb95pJ1bIoH40UmTJ/ugiOMIB+fbj/Oso=; b=MUFYixeV88XDoWmalmASZdwW7ee/+mJH3V0fG5dRqX/0KGm7CzB6mUGD2N9+zjSJcr6BmzxuPv/WKO+68eBAXcIqCwS8nLJ9GkqaEL6By2TmCHsnTlWPVfn2SIG334Dz6CGu0zJYrR78fA/C/zG4ELE64qkwKs4v0m2b9M3MwX9R7PxviiiEBNEnQuOZ+fPb4cCK5ABVQc19iG2Rmntq5rd23czxwgZkr/RJus2dof2PVFWArltYpPn4BVUQ6bfRyZO8tGRVUmYgAKuU1fISs1xRb1zkdb+Y9VXVZG5ppjZ2H2+Rba0IY7qFIGm6IdkYKMev+w2+zYazZK/6v3dp5w== 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=1VhqnL0+9ZAb95pJ1bIoH40UmTJ/ugiOMIB+fbj/Oso=; b=vMuW+HT93lxvMmEkX+KWnxlcmtItriGLO1J4V7ZBwIjeo80RY2l6OM05QKSaiHDsLm6INd6j02thwOKphC2YCyhycb7oDlEU6p6ZmyANC2geso6xm9Nmtlcamja2O64lraI26OgEQbT/jHPb7ETBJzHMzc+oCMVg+ErFe6Drglo= 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 DB8PR08MB5419.eurprd08.prod.outlook.com (2603:10a6:10:118::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15; Thu, 5 Aug 2021 12:01:25 +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; Thu, 5 Aug 2021 12:01:25 +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 , Tobias Schramm , Johan Jonker Subject: [PATCH v3 2/7] soc: rockchip: io-domain: add rk3568 support Date: Thu, 5 Aug 2021 14:01:02 +0200 Message-Id: <20210805120107.27007-3-michael.riesch@wolfvision.net> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210805120107.27007-1-michael.riesch@wolfvision.net> References: <20210805120107.27007-1-michael.riesch@wolfvision.net> X-ClientProxiedBy: VI1PR04CA0099.eurprd04.prod.outlook.com (2603:10a6:803:64::34) 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 VI1PR04CA0099.eurprd04.prod.outlook.com (2603:10a6:803:64::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.17 via Frontend Transport; Thu, 5 Aug 2021 12:01:24 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 495dda20-17e0-4d34-62b2-08d95808c006 X-MS-TrafficTypeDiagnostic: DB8PR08MB5419: 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: i+wHIKnJVS8gE+RFPTpFGGI4PfLuBYoU+uhS7s2yM8QwZstIuKcIKDeDAyl2hILl69+oTt6bqlugaiG15DbrczQLNNIcCPCkryZ4n9cBPDpsV/mFmZlIGXtg6F4v9pH8pSm5Y08QF7/AqgmaZxsbCMt5HGUaeDtfe56KmjYcNsQED6USRchgvs8JyKUx6KWYwglgUB5sT02dybQEBWaoBddXTsHJHtjzY1pcaDhPJ6smsfRod+x9y1HoUXVlYSqfjzcc5To74pW6KlsO4rxFoQgyeWxh5yuG5jjfxop6g1IEJiNUgcmT5VGsg5bbw+pVahUZQdEQvmIJTLTskxh9uJlLSgs6i5/So2IoRKOHEaeKIpqunuZtPHg1tq8rAqcZnTKvGsj04vhQzXc7yxyXscLi9YO44TlAIPaUs4sJlApyJW5AmqAysosM44q8hJ0z1AEz6nbmnDjlGiNgC6+mQkIcQUQLF9vz/gmzjGwwSecznfVBTstSlzHMEv+IXoWxkn/DOgMSLjPL9Xa/bPVZZ1ZBXePzYHnPvOW6qqyZowcFhe89mBB8PFGDTgwYpskxwfExgPfhu3XFNR0oARP/EXX2Gho/orLFymGbiin7W3utD4ybx/v9Zb8W0BNDI2qkRZHOycOw0sY1xpu0oE4HiA3KpZ4+Tj7CunYK8M6H+3M6p2kLKkEzOGr1yoQgcBpEJVLfekN/dm74pnM/vwl2dA== 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)(136003)(366004)(39840400004)(396003)(376002)(346002)(6512007)(8936002)(66946007)(38100700002)(7416002)(66476007)(6486002)(66556008)(52116002)(1076003)(2906002)(8676002)(4326008)(54906003)(478600001)(44832011)(316002)(36756003)(38350700002)(83380400001)(2616005)(6666004)(186003)(6506007)(956004)(86362001)(26005)(5660300002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: I25f8wcwoB9/GbX7TDRx/B6taWAlpN6pJ+MPxlTWoNCkZP31z4TTGirOiIZzQ90ymZHpRAZzbAJZRQwEqBYWVfsJhTPSkUCapFhNeGwIiV8KtFZI+Zdg2wiHeAAM1JnmRLvR2wbteFNsJjyqQgF+LCS+sXaIhWnomgspJ1iOBCqNGIkfy4z1aMPgZRR/Mb4a0XOxB97Qmc8sLqTsHbhy+4n1Bgxl+fLl5vrbnaf5fl7Y3Qm9FQUK1uzS8Om0bKpI1DseX/r5DP3zkHwLdzlppj+Du8V9MAe8CDIOdIXYxDqbU0y2pd1mlgG5bOywepUTjLJykL5L2xgkRzbGGzdlFUOSE0XLI1W/MWlkGHV8qaNOhOK1yXanj/gtx4ktbJri+gzy/im6yeFwn/s8SgCG8tMaAWTKIEe7Gahk0rB0ubMypclC7LNiAHXfNuXqFD6WR82r30FrrNM93Js9XCAPlYh8+OryHiqFw8G2Mk22WeJ5waOJV3jZ31TN7ntawLHhJTCStpJyqeEkMlleFYFD3rYexs5RLbYaiUFmTGcpmpBMrRrrUVKu91hxuGjEZbyBU3vnM1PbYjleHABZnaZp9U9jbO39b0YspcDcVD/bvAVZhw6Vo+6kx2j5y1j0+yiOVERJ4enF+TxzRG2za/9vR67durg3aEOsoqH/3BTlM4pHyc5H3I/S6s9uEwxUKWZFVbGUwiaFeMlbNlY5w655nyI5eUuqVUN0Y8W28PJD9st+7K0l0pKVwvSHJcG25IoEG/QPKx0a+4Ynqo6GYvyNQXv43IvqyoYmDsw7aAZgFJm3JE1ttBUTGuRmUTzce9dmlcztCMlqcLPFlS+V1ab6Zq1y++6gMg+aWuvsOlnb7Liz1I0nG7ADFrl+kFZSC3E/7y00nAJbpKLQLQrtXKDTQ2HsTwRm387jJTiij7onTzrDZThM5g2Twz0O2rz2FJ8/sv+ugzc3WaNRSLOQHtUqCNdLIsVu7p5CTx/dG42hS7/2zUlICqBXZanns+jU3OcGdYskanToNhzBRo42UFI0ppELhl7kLzIf3nva2X3/Z1FSUYtOcMPBHQn5YBl6SL/SA9dq+Hf7Vr7NtwG8psan9WDTTZvXMgh0FEl6RTXZYFbjZPI84K4uCZaCP6y5JA41FqYZqFeyzvCRvo7ZYv9ovKq/vSp2mEjWWBDolZFAnAnbUwAkY/p2/9TzOi0KeDS4XjwSZCKCyMFQEZ/uFOi/WPs56HsOwig/LasR+Iuf0r/6M5cQa6xdUzxiIddsupYKWystEiB3rECLq/MZKistZvfzC9Ye0Be0oh9RjejETaYsTfYSTRd8QbvdDC51ZrSi X-OriginatorOrg: wolfvision.net X-MS-Exchange-CrossTenant-Network-Message-Id: 495dda20-17e0-4d34-62b2-08d95808c006 X-MS-Exchange-CrossTenant-AuthSource: DBBPR08MB4523.eurprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2021 12:01:25.5461 (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: 6cE14FpC7Bo0W4mknNn5mMUO3rRsoXbLdQ9g56Ro7wcdlQtVrjYISGIBITAi125VS7vkGYnkOmrbVT2PSMs/SB+A845MKd1rB6xWjjGUXr8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5419 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210805_050131_814353_40E1D9FB X-CRM114-Status: GOOD ( 19.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=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 Tested-by: Peter Geis --- 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;