Message ID | 20230531065724.3671795-3-joy.zou@nxp.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2682929vqr; Tue, 30 May 2023 23:58:49 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7TljdWCGLHS5oto600XsXpK9BUItdysvQ4dKWN+gzUKDFf1AIiJdy/stwWNo52CkVjpnUb X-Received: by 2002:a05:6a20:a127:b0:10b:a9ca:97ca with SMTP id q39-20020a056a20a12700b0010ba9ca97camr5880356pzk.51.1685516328892; Tue, 30 May 2023 23:58:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1685516328; cv=pass; d=google.com; s=arc-20160816; b=fdlcUjf35BL2EKtrTWUC7Jt0yaVzV1dYd2SEIC/0wi0W1d2sC307CHtZXnzOoW6ofc ZGz2AefEQ7JA5W/Zu9gtd506WP09SaqgObjiC2IJCZy/L90NpTTlx2+VOnKjUv0hrCAB Rtl5HYiL6mm2G+jiWj/KL/KgAFmyDs0wRjYf5tRPVTf7tC2nI3QOZ6cRd28z4fdwIGOU +f1bJGKeL6RoHTDUxvzrGLaFSeop/rr+1TkmkwJsYcsQZj7j2ClBQFwBG3wnGVNrYNZN PAeMcYN4pwxgaN1aNkeb7oNbNK9DZ0KQ0Mls5WgxmjdXPPIqrkmLwIz7ZVXvXOsH0VFH B8Og== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qbeiposDPchdDHX1hgYIIbLynUXmwdHraPh+/lGK5C8=; b=IZa8Zo9WtNSdAhMCS/vClPCWmrdhyRzCkZYZwUwyHDG/s7UqcQiznFsUchao9zamCC Vgq/THT+PmK6uduQOVcw6RVfDCyG13WUzJidRbR7JN7m9G1Hy9SnZceFTMN12IrUdrAe 1vV14MlpPdoD5/dIslDZEo3G8Yl8W2jYaLCBOnLR0VYBBCkG5ItJcsvmeWUI9i0dfVKu 8l480piluW6OeKjtRh8t9VBczpqJzeCKfWW8uK9virr6g3lqWGGOdi6UtVsAwsw4lleA l5YY7Fk8yjnkn/E1rANjBszB/woqgsxvw8GOA8yuoVD5QwmU6d7LA/h4hwN/wxdfDLbj sSOg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=fhQV8XxS; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ot17-20020a17090b3b5100b002569554346esi471627pjb.168.2023.05.30.23.58.34; Tue, 30 May 2023 23:58:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=fhQV8XxS; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234417AbjEaGx3 (ORCPT <rfc822;callmefire3@gmail.com> + 99 others); Wed, 31 May 2023 02:53:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234443AbjEaGxZ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 31 May 2023 02:53:25 -0400 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9375E183; Tue, 30 May 2023 23:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BTUlPR3UyP8dbnc25zSvxo1ujugHzslJ8qRVPNmR1WeMVa++CuPjAbLO/ETaQdfLxN/ZmAoEOaqpHr6mbrOyb+mq+csVCThISx3CSdTAGT6zy4KcN2hNrciasUtBCf7aJ33o2fv9O2Hbc2NR5dgYdklKmf7nl/odLSrQKhP//cfr7L91AOyq6qNvrR4T9EEIvPN5WptIhfVpst132oe7voV760DuTS/wLEzGzShMFSvCeEhB3F2+mwrMxp1IbTLFRiK+FTKaCRkh2bURMr3+dH6OxbFCdpOnxch4VsRcsYWsbrK2mYXKNmvP7GydXfXTxZjIdcC6Gq8dCz9swGYMfw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qbeiposDPchdDHX1hgYIIbLynUXmwdHraPh+/lGK5C8=; b=Gen8Tu8n5bW3MclsHJ42UGSv6Gq8cnQq8pBd4W4WloHeAgmaCYB94aO5eE6hAX+mc+NujOL7jWVnLsSvk3eToD79dPNq12cC1UXrenVNonoF42xae8lpr8TvMHII0jY0BU/X4xJkKiElWEMQAxmzV8LXdnc5SATy/+F0Wmd11QGDX/I557FYV6+nSp7i2qGc+rIG4f54gX2DGXbnkAqdTXVPaW/OFBlBhCt+vioxEVzlY0VK5K7yuKAII1fxKCc/KLTuy35rsCH5BqvPOeG0TcLTsqxTlVfC0hWJiiYewFAcmmbb+kIa5lAgSnIZhKpBPhJ4RTrO8mb3LOL7YxoMyw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qbeiposDPchdDHX1hgYIIbLynUXmwdHraPh+/lGK5C8=; b=fhQV8XxSwvshPxivmarKXolX9E5NhThiK58k3OSPz4gFnmqo1Ccr5807ZxgDSonDSXmHXP0gz7Xt6VUWzBWC4PiqDfChvUEQSnoh16gMVdoyMLpZBYkVJUuR82oV+aJlXozq04mm2QhE751pPorO38Acs9RgWIFKFA19YxQzo4Q= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM6PR04MB5925.eurprd04.prod.outlook.com (2603:10a6:20b:ab::19) by AM0PR04MB6771.eurprd04.prod.outlook.com (2603:10a6:208:18d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Wed, 31 May 2023 06:53:15 +0000 Received: from AM6PR04MB5925.eurprd04.prod.outlook.com ([fe80::1a8e:7e33:7f24:d77c]) by AM6PR04MB5925.eurprd04.prod.outlook.com ([fe80::1a8e:7e33:7f24:d77c%5]) with mapi id 15.20.6433.022; Wed, 31 May 2023 06:53:15 +0000 From: Joy Zou <joy.zou@nxp.com> To: ping.bai@nxp.com, lgirdwood@gmail.com, broonie@kernel.org, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, shawnguo@kernel.org, s.hauer@pengutronix.de Cc: kernel@pengutronix.de, festevam@gmail.com, linux-imx@nxp.com, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 2/3] regulator: pca9450: add pca9451a support Date: Wed, 31 May 2023 14:57:23 +0800 Message-Id: <20230531065724.3671795-3-joy.zou@nxp.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230531065724.3671795-1-joy.zou@nxp.com> References: <20230531065724.3671795-1-joy.zou@nxp.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SI2PR02CA0011.apcprd02.prod.outlook.com (2603:1096:4:194::20) To AM6PR04MB5925.eurprd04.prod.outlook.com (2603:10a6:20b:ab::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM6PR04MB5925:EE_|AM0PR04MB6771:EE_ X-MS-Office365-Filtering-Correlation-Id: f173be87-6516-462b-ff91-08db61a3b54f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: t9PItByObyrLIxGnMjC3zUFDZYvhOMHsugi5/nStok/DQznapQNNVUftR/npxS6gjpX755jhyHdafCod+xWYxBBlp3UVCMNjAjfIKglrI4L/qanpJoy3Gq1zhA6PQ8m7aldrmkAa7kXs/8jrebnIjZXlor5AGAu/UYbkqctsaObeo5xloum4xvRJLlUcOJ1W6QOlhskSEqkSm00bR1zWwC1pSs9x4cQFyUb4XVopEIOe0TVcuKJXWXZxg4tCn0fL7GHRVgsuZ9TPV1AFY/qYxoMmdi7nf29WusBSaX3RPGqDrvlJbqDfBisQyI1Fm+Yk/Wed+IDGuooqBn9kEsEgKcWBfaW32YIRpUQL8n3s8SOqe0Nase7lHbzFKE2aodGGKIUIcGAHWHa4mneLMjTi185rDEmQKLuapJv1zrtUZ17j9IVWj5DJZXwt2l82+XJiTOBKTH/VxOXH2uC167Q7uz5GjEkmiDQLzY36Jo4VIP4bsdmO/B1Bl6dvYqQ6A+stQxoLcyvEGvFy/dXbNA+fcgP1O/bqi3oIIJXuzTUYzuljwCPBWtPAEbUxPE6z82PcNQODb1b5MijTUlLIpxRhfbC1G8P7WABIIJN9dc9Ma85+rBqeyS0QyGxhi/Ojq3qW X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM6PR04MB5925.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(366004)(396003)(376002)(451199021)(26005)(1076003)(38350700002)(38100700002)(41300700001)(52116002)(6666004)(6486002)(83380400001)(186003)(6512007)(6506007)(2616005)(478600001)(8676002)(4326008)(66476007)(66946007)(316002)(5660300002)(8936002)(86362001)(44832011)(7416002)(30864003)(66556008)(2906002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ET9Oh1h4g4TvYrktV8Swcfp5LvCCeFbOYfqfSDOzqglghrmWdmjMDkG1bCWQqpteTNL+pGxZkhCNINSuRIxZ3d7/0QljdgVI0CQ9v3qCYhPrTV5KQU1fLR7g7LnqozzbdZg6YsVkGC/CAXCFAkcEMKd7sUc/IC72a2SDGzihKm9exJm1+neTsKMLoagXuesuBj1ttWKtZqDhvF/jSIF79s7A5ulpWUAMmdsud7jHXqZLR8tyLxEoqEA6vd+P9SAn9z+PJuqVJl6gXHhU/fn+Tc43F4s/ZnoK3XritZln/SQ9fET8piiANePkPuqJC5zsobAnCjYE4ba3vkjPlXZyauHThF0UatjwzRMlZ+XVCxTuKEGjyz4rmCYnU1SyeuEQZlIDKEKTJPepJViJnD0PrTPWQYjzWjljPkTpl9PVdCgBxKi9KcYAm12+Hp17E6b1SRL1R8lJm8iOaY4x2aBlBgeTqY7jBmWHxDRsls+f0zGgIAYCNYBWKKBTQlQnUvvPPjGJtACX5OnxVqjsR+/uK73ZjxqqymvYn8a0vte0Wfw8xmM9yEnpkblHsPA75ThFnrPxDGbWJtz/a+jDUsQumKUsRGyTKdPRyw5TE7PaArBsKV4JB/CmxctJCMsdEAKsFaoVOlMk/aB++XVSbte2POID++lIKUi0LpGS0P2qCM8Fl9/e9zJJQkVHC6eHq0i3JuU9A5Mt4l+f5GFq55ZKfJjqWlXl3lsigZK2ZFXerF50SaaaboJAIDc9CJnG6KrTy95dP1aVBZipcLZNBQKLzImeYK0tjG2S13237sIVmcGmWTDBwDKZ0B44Bac53KBJjEyWJz9Q0AZ2juthwycUCaDMr69Bivwkv0SmGd+OeJbI2I2SpwVy6snMC35w+yZmPbcm/cToAELUtH7mw/JbE9ujqEkD0mlaBNp3ccTaTo0b7+fcd5ibmxbo4PtO35N9wiarH7Xu/m14+hXWxZa6yX2NB4cU9EsSCJMcUgVP430h9k1LDw8ZgRLlm2GUkoq7O5jMnZUwAIPWZKtj81XLrD5174LbrTRJH16kKi/3mpS93l+Qhfx1iZ+eNaxgJU3TIsaS6hzoRcXPSlpftuCCjNzbFOXfoCt5otH29NU8s8FY4eXYy8yNqJ0ky/hs0JUYjXVE0UnTI3rCbeJfwnzXLuoWAw1K0j3o6UteEsgEmfTYRCR7tURc4ETZ4j6yUjlIzRuPjGvZeiYJXKtwUpQE1xy/a/E1PeYqYfAGpPqWZ17dHVnzI/Pc2NG5V7R+YyUSnHyLW8bsZrKyzNUFuurmtx7dYrzhG+4OTodCR+OOi25J143dmNMeNMr+WHXQtYsodyTrSi0I+AXKIq7d2ammeH9wADPZrQn6hxOedEY800jJ4Nkp/x3CI1cE5ZbZYiCKiA0mkci4IPFKIrEtFAebx6iV+1TaFvN0Sn3i2Th0ryj9DGYFGzdy3sktbtczODgxi+h1ZD6fmwIpruKVqvDFmMPrmpuS5HXnCwR3BCl79rM7pXqb451N+nGrZ9N8S32Q6m6ytJ9sTDkFk50/IiNZXsAZ5aSf/WFrm7CKey/D/NXUtb7pNwkwZyoXXp3Ucdtm X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f173be87-6516-462b-ff91-08db61a3b54f X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB5925.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2023 06:53:15.5028 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kpeX21F7Q3vYEft+dX6kZe3rKS7hGZikMMslJ0lET3JJHoK2epAMv/RO7Vnzo0dU X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB6771 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767391969997464167?= X-GMAIL-MSGID: =?utf-8?q?1767391969997464167?= |
Series |
add pmic pca9451a support
|
|
Commit Message
Joy Zou
May 31, 2023, 6:57 a.m. UTC
Adding support for pmic pca9451a.
This patch support old and new pmic pca9451a. The new pmic trimed BUCK1.
The default value of Toff_Deb is used to distinguish the old and new pmic.
Signed-off-by: Joy Zou <joy.zou@nxp.com>
---
drivers/regulator/pca9450-regulator.c | 262 ++++++++++++++++++++++++--
include/linux/regulator/pca9450.h | 2 +
2 files changed, 252 insertions(+), 12 deletions(-)
Comments
Hi, Am Mittwoch, 31. Mai 2023, 08:57:23 CEST schrieb Joy Zou: > Adding support for pmic pca9451a. > > This patch support old and new pmic pca9451a. The new pmic trimed BUCK1. > The default value of Toff_Deb is used to distinguish the old and new pmic. > > Signed-off-by: Joy Zou <joy.zou@nxp.com> > --- > drivers/regulator/pca9450-regulator.c | 262 ++++++++++++++++++++++++-- > include/linux/regulator/pca9450.h | 2 + > 2 files changed, 252 insertions(+), 12 deletions(-) > > diff --git a/drivers/regulator/pca9450-regulator.c > b/drivers/regulator/pca9450-regulator.c index 91bfb7e026c9..654aa4fbe494 > 100644 > --- a/drivers/regulator/pca9450-regulator.c > +++ b/drivers/regulator/pca9450-regulator.c > @@ -104,7 +104,15 @@ static const struct regulator_ops > pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) > */ > static const struct linear_range pca9450_dvs_buck_volts[] = { > - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > +}; > + > +/* > + * BUCK1/3 > + * 0.65 to 2.2375V (12.5mV step) Reading this comment, it seems the same distinction needs to be done for BUCK3 as well, no? > + */ > +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { > + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), > }; > > /* > @@ -663,6 +671,207 @@ static const struct pca9450_regulator_desc > pca9450bc_regulators[] = { }, > }; > > +static const struct pca9450_regulator_desc pca9451a_regulators[] = { > + { > + .desc = { > + .name = "buck1", > + .of_match = of_match_ptr("BUCK1"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_BUCK1, > + .ops = &pca9450_dvs_buck_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > + .linear_ranges = pca9450_dvs_buck_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_dvs_buck_volts), > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > + .vsel_mask = BUCK1OUT_DVS0_MASK, > + .enable_reg = PCA9450_REG_BUCK1CTRL, > + .enable_mask = BUCK1_ENMODE_MASK, > + .enable_val = BUCK_ENMODE_ONREQ, > + .ramp_mask = BUCK1_RAMP_MASK, > + .ramp_delay_table = pca9450_dvs_buck_ramp_table, > + .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > + .owner = THIS_MODULE, > + .of_parse_cb = pca9450_set_dvs_levels, > + }, > + .dvs = { > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > + .run_mask = BUCK1OUT_DVS0_MASK, > + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, > + .standby_mask = BUCK1OUT_DVS1_MASK, > + }, > + }, > + { > + .desc = { > + .name = "buck1_trim", > + .of_match = of_match_ptr("BUCK1"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_BUCK1, > + .ops = &pca9450_dvs_buck_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > + .linear_ranges = pca9450_trim_dvs_buck_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_trim_dvs_buck_volts), > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > + .vsel_mask = BUCK1OUT_DVS0_MASK, > + .enable_reg = PCA9450_REG_BUCK1CTRL, > + .enable_mask = BUCK1_ENMODE_MASK, > + .enable_val = BUCK_ENMODE_ONREQ, > + .ramp_mask = BUCK1_RAMP_MASK, > + .ramp_delay_table = pca9450_dvs_buck_ramp_table, > + .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > + .owner = THIS_MODULE, > + .of_parse_cb = pca9450_set_dvs_levels, > + }, > + .dvs = { > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > + .run_mask = BUCK1OUT_DVS0_MASK, > + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, > + .standby_mask = BUCK1OUT_DVS1_MASK, > + }, > + }, > + { > + .desc = { > + .name = "buck2", > + .of_match = of_match_ptr("BUCK2"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_BUCK2, > + .ops = &pca9450_dvs_buck_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_BUCK2_VOLTAGE_NUM, > + .linear_ranges = pca9450_dvs_buck_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_dvs_buck_volts), > + .vsel_reg = PCA9450_REG_BUCK2OUT_DVS0, > + .vsel_mask = BUCK2OUT_DVS0_MASK, > + .enable_reg = PCA9450_REG_BUCK2CTRL, > + .enable_mask = BUCK2_ENMODE_MASK, > + .enable_val = BUCK_ENMODE_ONREQ_STBYREQ, > + .ramp_mask = BUCK2_RAMP_MASK, > + .ramp_delay_table = pca9450_dvs_buck_ramp_table, > + .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > + .owner = THIS_MODULE, > + .of_parse_cb = pca9450_set_dvs_levels, > + }, > + .dvs = { > + .run_reg = PCA9450_REG_BUCK2OUT_DVS0, > + .run_mask = BUCK2OUT_DVS0_MASK, > + .standby_reg = PCA9450_REG_BUCK2OUT_DVS1, > + .standby_mask = BUCK2OUT_DVS1_MASK, > + }, > + }, > + { > + .desc = { > + .name = "buck4", > + .of_match = of_match_ptr("BUCK4"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_BUCK4, > + .ops = &pca9450_buck_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_BUCK4_VOLTAGE_NUM, > + .linear_ranges = pca9450_buck_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_buck_volts), > + .vsel_reg = PCA9450_REG_BUCK4OUT, > + .vsel_mask = BUCK4OUT_MASK, > + .enable_reg = PCA9450_REG_BUCK4CTRL, > + .enable_mask = BUCK4_ENMODE_MASK, > + .enable_val = BUCK_ENMODE_ONREQ, > + .owner = THIS_MODULE, > + }, > + }, > + { > + .desc = { > + .name = "buck5", > + .of_match = of_match_ptr("BUCK5"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_BUCK5, > + .ops = &pca9450_buck_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_BUCK5_VOLTAGE_NUM, > + .linear_ranges = pca9450_buck_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_buck_volts), > + .vsel_reg = PCA9450_REG_BUCK5OUT, > + .vsel_mask = BUCK5OUT_MASK, > + .enable_reg = PCA9450_REG_BUCK5CTRL, > + .enable_mask = BUCK5_ENMODE_MASK, > + .enable_val = BUCK_ENMODE_ONREQ, > + .owner = THIS_MODULE, > + }, > + }, > + { > + .desc = { > + .name = "buck6", > + .of_match = of_match_ptr("BUCK6"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_BUCK6, > + .ops = &pca9450_buck_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_BUCK6_VOLTAGE_NUM, > + .linear_ranges = pca9450_buck_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_buck_volts), > + .vsel_reg = PCA9450_REG_BUCK6OUT, > + .vsel_mask = BUCK6OUT_MASK, > + .enable_reg = PCA9450_REG_BUCK6CTRL, > + .enable_mask = BUCK6_ENMODE_MASK, > + .enable_val = BUCK_ENMODE_ONREQ, > + .owner = THIS_MODULE, > + }, > + }, > + { > + .desc = { > + .name = "ldo1", > + .of_match = of_match_ptr("LDO1"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_LDO1, > + .ops = &pca9450_ldo_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_LDO1_VOLTAGE_NUM, > + .linear_ranges = pca9450_ldo1_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo1_volts), > + .vsel_reg = PCA9450_REG_LDO1CTRL, > + .vsel_mask = LDO1OUT_MASK, > + .enable_reg = PCA9450_REG_LDO1CTRL, > + .enable_mask = LDO1_EN_MASK, > + .owner = THIS_MODULE, > + }, > + }, > + { > + .desc = { > + .name = "ldo4", > + .of_match = of_match_ptr("LDO4"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_LDO4, > + .ops = &pca9450_ldo_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_LDO4_VOLTAGE_NUM, > + .linear_ranges = pca9450_ldo34_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo34_volts), > + .vsel_reg = PCA9450_REG_LDO4CTRL, > + .vsel_mask = LDO4OUT_MASK, > + .enable_reg = PCA9450_REG_LDO4CTRL, > + .enable_mask = LDO4_EN_MASK, > + .owner = THIS_MODULE, > + }, > + }, > + { > + .desc = { > + .name = "ldo5", > + .of_match = of_match_ptr("LDO5"), > + .regulators_node = of_match_ptr("regulators"), > + .id = PCA9450_LDO5, > + .ops = &pca9450_ldo_regulator_ops, > + .type = REGULATOR_VOLTAGE, > + .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, > + .linear_ranges = pca9450_ldo5_volts, > + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo5_volts), > + .vsel_reg = PCA9450_REG_LDO5CTRL_H, > + .vsel_mask = LDO5HOUT_MASK, > + .enable_reg = PCA9450_REG_LDO5CTRL_H, > + .enable_mask = LDO5H_EN_MASK, > + .owner = THIS_MODULE, > + }, > + }, > +}; > + > static irqreturn_t pca9450_irq_handler(int irq, void *data) > { > struct pca9450 *pca9450 = data; > @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > const struct pca9450_regulator_desc *regulator_desc; > struct regulator_config config = { }; > struct pca9450 *pca9450; > - unsigned int device_id, i; > + unsigned int device_id, i, val; > unsigned int reset_ctrl; > + bool pmic_trim = false; > int ret; > > if (!i2c->irq) { > @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > if (!pca9450) > return -ENOMEM; > > + pca9450->regmap = devm_regmap_init_i2c(i2c, > + &pca9450_regmap_config); > + if (IS_ERR(pca9450->regmap)) { > + dev_err(&i2c->dev, "regmap initialization failed\n"); > + return PTR_ERR(pca9450->regmap); > + } > + > + ret = regmap_read(pca9450->regmap, PCA9450_REG_PWRCTRL, &val); > + if (ret) { > + dev_err(&i2c->dev, "Read device id error\n"); > + return ret; > + } > + > + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) > + pmic_trim = true; PCA9450_REG_PWRCTRL is a read/write register. How is it possible to detect a chip revision using a bit which can be changed by software e.g. bootloader? Despite that this bit sets debounce time for PMIC_ON_REQ, how is this related to BUCK1 voltage range? > + > switch (type) { > case PCA9450_TYPE_PCA9450A: > regulator_desc = pca9450a_regulators; > @@ -730,6 +956,10 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > regulator_desc = pca9450bc_regulators; > pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); > break; > + case PCA9450_TYPE_PCA9451A: > + regulator_desc = pca9451a_regulators; > + pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); > + break; > default: > dev_err(&i2c->dev, "Unknown device type"); > return -EINVAL; > @@ -741,13 +971,6 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > dev_set_drvdata(&i2c->dev, pca9450); > > - pca9450->regmap = devm_regmap_init_i2c(i2c, > - &pca9450_regmap_config); > - if (IS_ERR(pca9450->regmap)) { > - dev_err(&i2c->dev, "regmap initialization failed\n"); > - return PTR_ERR(pca9450->regmap); > - } > - > ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, &device_id); > if (ret) { > dev_err(&i2c->dev, "Read device id error\n"); > @@ -756,7 +979,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > /* Check your board and dts for match the right pmic */ > if (((device_id >> 4) != 0x1 && type == PCA9450_TYPE_PCA9450A) || > - ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC)) { > + ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC) || > + ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9451A)) { > dev_err(&i2c->dev, "Device id(%x) mismatched\n", > device_id >> 4); > return -EINVAL; > @@ -767,7 +991,16 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > struct regulator_dev *rdev; > const struct pca9450_regulator_desc *r; > > - r = ®ulator_desc[i]; > + if (type == PCA9450_TYPE_PCA9451A && > + !strcmp((®ulator_desc[i])->desc.name, "buck1") && pmic_trim) { > + r = ®ulator_desc[i + 1]; > + i = i + 1; > + } else if (type == PCA9450_TYPE_PCA9451A && > + !strcmp((®ulator_desc[i])->desc.name, "buck1")) { > + r = ®ulator_desc[i]; > + i = i + 1; I would put this in a single 'type == PCA9450_TYPE_PCA9451A' branch, to indicate that only PCA9451A needs some kind of special handling. > + } else > + r = ®ulator_desc[i]; > desc = &r->desc; > > config.regmap = pca9450->regmap; > @@ -847,7 +1080,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > } > > dev_info(&i2c->dev, "%s probed.\n", > - type == PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc"); > + type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > + (type == PCA9450_TYPE_PCA9451A ? "pca9451a" : "pca9450bc")); > > return 0; > } > @@ -865,6 +1099,10 @@ static const struct of_device_id pca9450_of_match[] = > { .compatible = "nxp,pca9450c", > .data = (void *)PCA9450_TYPE_PCA9450BC, > }, > + { > + .compatible = "nxp,pca9451a", > + .data = (void *)PCA9450_TYPE_PCA9451A, > + }, > { } > }; > MODULE_DEVICE_TABLE(of, pca9450_of_match); > diff --git a/include/linux/regulator/pca9450.h > b/include/linux/regulator/pca9450.h index 3c01c2bf84f5..5dd79f52165a 100644 > --- a/include/linux/regulator/pca9450.h > +++ b/include/linux/regulator/pca9450.h > @@ -9,6 +9,7 @@ > enum pca9450_chip_type { > PCA9450_TYPE_PCA9450A = 0, > PCA9450_TYPE_PCA9450BC, > + PCA9450_TYPE_PCA9451A, > PCA9450_TYPE_AMOUNT, > }; > > @@ -93,6 +94,7 @@ enum { > PCA9450_MAX_REGISTER = 0x2F, > }; > > +#define PCA9450_REG_PWRCTRL_TOFF_DEB BIT(5) Newline here please. Best regards, Alexander > /* PCA9450 BUCK ENMODE bits */ > #define BUCK_ENMODE_OFF 0x00 > #define BUCK_ENMODE_ONREQ 0x01
> -----Original Message----- > From: Alexander Stein <alexander.stein@ew.tq-group.com> > Sent: 2023年5月31日 19:35 > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > broonie@kernel.org; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > linux-arm-kernel@lists.infradead.org > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Joy Zou > <joy.zou@nxp.com> > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a support > > Caution: This is an external email. Please take care when clicking links or > opening attachments. When in doubt, report the message using the 'Report > this email' button > > > Hi, > > Am Mittwoch, 31. Mai 2023, 08:57:23 CEST schrieb Joy Zou: > > Adding support for pmic pca9451a. > > > > This patch support old and new pmic pca9451a. The new pmic trimed > BUCK1. > > The default value of Toff_Deb is used to distinguish the old and new pmic. > > > > Signed-off-by: Joy Zou <joy.zou@nxp.com> > > --- > > drivers/regulator/pca9450-regulator.c | 262 > ++++++++++++++++++++++++-- > > include/linux/regulator/pca9450.h | 2 + > > 2 files changed, 252 insertions(+), 12 deletions(-) > > > > diff --git a/drivers/regulator/pca9450-regulator.c > > b/drivers/regulator/pca9450-regulator.c index > > 91bfb7e026c9..654aa4fbe494 > > 100644 > > --- a/drivers/regulator/pca9450-regulator.c > > +++ b/drivers/regulator/pca9450-regulator.c > > @@ -104,7 +104,15 @@ static const struct regulator_ops > > pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) > > */ > > static const struct linear_range pca9450_dvs_buck_volts[] = { > > - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > > + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), }; > > + > > +/* > > + * BUCK1/3 > > + * 0.65 to 2.2375V (12.5mV step) > > Reading this comment, it seems the same distinction needs to be done for > BUCK3 as well, no? Sorry for the late reply! The BUCK1 and BUCK3 are dual phase, so don't need to be done for BUCK3. > > > + */ > > +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { > > + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), > > }; > > > > /* > > @@ -663,6 +671,207 @@ static const struct pca9450_regulator_desc > > pca9450bc_regulators[] = { }, }; > > > > +static const struct pca9450_regulator_desc pca9451a_regulators[] = { > > + { > > + .desc = { > > + .name = "buck1", > > + .of_match = of_match_ptr("BUCK1"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_BUCK1, > > + .ops = &pca9450_dvs_buck_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > > + .linear_ranges = pca9450_dvs_buck_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_dvs_buck_volts), > > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > > + .vsel_mask = BUCK1OUT_DVS0_MASK, > > + .enable_reg = PCA9450_REG_BUCK1CTRL, > > + .enable_mask = BUCK1_ENMODE_MASK, > > + .enable_val = BUCK_ENMODE_ONREQ, > > + .ramp_mask = BUCK1_RAMP_MASK, > > + .ramp_delay_table = > pca9450_dvs_buck_ramp_table, > > + .n_ramp_values = > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > + .owner = THIS_MODULE, > > + .of_parse_cb = pca9450_set_dvs_levels, > > + }, > > + .dvs = { > > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > > + .run_mask = BUCK1OUT_DVS0_MASK, > > + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, > > + .standby_mask = BUCK1OUT_DVS1_MASK, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "buck1_trim", > > + .of_match = of_match_ptr("BUCK1"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_BUCK1, > > + .ops = &pca9450_dvs_buck_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > > + .linear_ranges = pca9450_trim_dvs_buck_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_trim_dvs_buck_volts), > > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > > + .vsel_mask = BUCK1OUT_DVS0_MASK, > > + .enable_reg = PCA9450_REG_BUCK1CTRL, > > + .enable_mask = BUCK1_ENMODE_MASK, > > + .enable_val = BUCK_ENMODE_ONREQ, > > + .ramp_mask = BUCK1_RAMP_MASK, > > + .ramp_delay_table = > pca9450_dvs_buck_ramp_table, > > + .n_ramp_values = > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > + .owner = THIS_MODULE, > > + .of_parse_cb = pca9450_set_dvs_levels, > > + }, > > + .dvs = { > > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > > + .run_mask = BUCK1OUT_DVS0_MASK, > > + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, > > + .standby_mask = BUCK1OUT_DVS1_MASK, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "buck2", > > + .of_match = of_match_ptr("BUCK2"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_BUCK2, > > + .ops = &pca9450_dvs_buck_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_BUCK2_VOLTAGE_NUM, > > + .linear_ranges = pca9450_dvs_buck_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_dvs_buck_volts), > > + .vsel_reg = PCA9450_REG_BUCK2OUT_DVS0, > > + .vsel_mask = BUCK2OUT_DVS0_MASK, > > + .enable_reg = PCA9450_REG_BUCK2CTRL, > > + .enable_mask = BUCK2_ENMODE_MASK, > > + .enable_val = BUCK_ENMODE_ONREQ_STBYREQ, > > + .ramp_mask = BUCK2_RAMP_MASK, > > + .ramp_delay_table = > pca9450_dvs_buck_ramp_table, > > + .n_ramp_values = > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > + .owner = THIS_MODULE, > > + .of_parse_cb = pca9450_set_dvs_levels, > > + }, > > + .dvs = { > > + .run_reg = PCA9450_REG_BUCK2OUT_DVS0, > > + .run_mask = BUCK2OUT_DVS0_MASK, > > + .standby_reg = PCA9450_REG_BUCK2OUT_DVS1, > > + .standby_mask = BUCK2OUT_DVS1_MASK, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "buck4", > > + .of_match = of_match_ptr("BUCK4"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_BUCK4, > > + .ops = &pca9450_buck_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_BUCK4_VOLTAGE_NUM, > > + .linear_ranges = pca9450_buck_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_buck_volts), > > + .vsel_reg = PCA9450_REG_BUCK4OUT, > > + .vsel_mask = BUCK4OUT_MASK, > > + .enable_reg = PCA9450_REG_BUCK4CTRL, > > + .enable_mask = BUCK4_ENMODE_MASK, > > + .enable_val = BUCK_ENMODE_ONREQ, > > + .owner = THIS_MODULE, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "buck5", > > + .of_match = of_match_ptr("BUCK5"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_BUCK5, > > + .ops = &pca9450_buck_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_BUCK5_VOLTAGE_NUM, > > + .linear_ranges = pca9450_buck_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_buck_volts), > > + .vsel_reg = PCA9450_REG_BUCK5OUT, > > + .vsel_mask = BUCK5OUT_MASK, > > + .enable_reg = PCA9450_REG_BUCK5CTRL, > > + .enable_mask = BUCK5_ENMODE_MASK, > > + .enable_val = BUCK_ENMODE_ONREQ, > > + .owner = THIS_MODULE, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "buck6", > > + .of_match = of_match_ptr("BUCK6"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_BUCK6, > > + .ops = &pca9450_buck_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_BUCK6_VOLTAGE_NUM, > > + .linear_ranges = pca9450_buck_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_buck_volts), > > + .vsel_reg = PCA9450_REG_BUCK6OUT, > > + .vsel_mask = BUCK6OUT_MASK, > > + .enable_reg = PCA9450_REG_BUCK6CTRL, > > + .enable_mask = BUCK6_ENMODE_MASK, > > + .enable_val = BUCK_ENMODE_ONREQ, > > + .owner = THIS_MODULE, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "ldo1", > > + .of_match = of_match_ptr("LDO1"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_LDO1, > > + .ops = &pca9450_ldo_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_LDO1_VOLTAGE_NUM, > > + .linear_ranges = pca9450_ldo1_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_ldo1_volts), > > + .vsel_reg = PCA9450_REG_LDO1CTRL, > > + .vsel_mask = LDO1OUT_MASK, > > + .enable_reg = PCA9450_REG_LDO1CTRL, > > + .enable_mask = LDO1_EN_MASK, > > + .owner = THIS_MODULE, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "ldo4", > > + .of_match = of_match_ptr("LDO4"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_LDO4, > > + .ops = &pca9450_ldo_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_LDO4_VOLTAGE_NUM, > > + .linear_ranges = pca9450_ldo34_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_ldo34_volts), > > + .vsel_reg = PCA9450_REG_LDO4CTRL, > > + .vsel_mask = LDO4OUT_MASK, > > + .enable_reg = PCA9450_REG_LDO4CTRL, > > + .enable_mask = LDO4_EN_MASK, > > + .owner = THIS_MODULE, > > + }, > > + }, > > + { > > + .desc = { > > + .name = "ldo5", > > + .of_match = of_match_ptr("LDO5"), > > + .regulators_node = of_match_ptr("regulators"), > > + .id = PCA9450_LDO5, > > + .ops = &pca9450_ldo_regulator_ops, > > + .type = REGULATOR_VOLTAGE, > > + .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, > > + .linear_ranges = pca9450_ldo5_volts, > > + .n_linear_ranges = > ARRAY_SIZE(pca9450_ldo5_volts), > > + .vsel_reg = PCA9450_REG_LDO5CTRL_H, > > + .vsel_mask = LDO5HOUT_MASK, > > + .enable_reg = PCA9450_REG_LDO5CTRL_H, > > + .enable_mask = LDO5H_EN_MASK, > > + .owner = THIS_MODULE, > > + }, > > + }, > > +}; > > + > > static irqreturn_t pca9450_irq_handler(int irq, void *data) { > > struct pca9450 *pca9450 = data; > > @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > const struct pca9450_regulator_desc *regulator_desc; > > struct regulator_config config = { }; > > struct pca9450 *pca9450; > > - unsigned int device_id, i; > > + unsigned int device_id, i, val; > > unsigned int reset_ctrl; > > + bool pmic_trim = false; > > int ret; > > > > if (!i2c->irq) { > > @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > if (!pca9450) > > return -ENOMEM; > > > > + pca9450->regmap = devm_regmap_init_i2c(i2c, > > + > &pca9450_regmap_config); > > + if (IS_ERR(pca9450->regmap)) { > > + dev_err(&i2c->dev, "regmap initialization failed\n"); > > + return PTR_ERR(pca9450->regmap); > > + } > > + > > + ret = regmap_read(pca9450->regmap, PCA9450_REG_PWRCTRL, > &val); > > + if (ret) { > > + dev_err(&i2c->dev, "Read device id error\n"); > > + return ret; > > + } > > + > > + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) > > + pmic_trim = true; > > PCA9450_REG_PWRCTRL is a read/write register. How is it possible to detect a > chip revision using a bit which can be changed by software e.g. bootloader? > Despite that this bit sets debounce time for PMIC_ON_REQ, how is this related > to BUCK1 voltage range? There are old and new two kind PMIC pca9451a. This bit sets debounce time in PCA9450_REG_PWRCTRL was set different value by hardware in order to only distinguish the old and new PMIC. This bit isn't related to the BUCK1 voltage range. If the pmic_trim is true that means it's new pca9451a. > > > + > > switch (type) { > > case PCA9450_TYPE_PCA9450A: > > regulator_desc = pca9450a_regulators; @@ -730,6 +956,10 > > @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > regulator_desc = pca9450bc_regulators; > > pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); > > break; > > + case PCA9450_TYPE_PCA9451A: > > + regulator_desc = pca9451a_regulators; > > + pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); > > + break; > > default: > > dev_err(&i2c->dev, "Unknown device type"); > > return -EINVAL; > > @@ -741,13 +971,6 @@ static int pca9450_i2c_probe(struct i2c_client > > *i2c) > > > > dev_set_drvdata(&i2c->dev, pca9450); > > > > - pca9450->regmap = devm_regmap_init_i2c(i2c, > > - > &pca9450_regmap_config); > > - if (IS_ERR(pca9450->regmap)) { > > - dev_err(&i2c->dev, "regmap initialization failed\n"); > > - return PTR_ERR(pca9450->regmap); > > - } > > - > > ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, > &device_id); > > if (ret) { > > dev_err(&i2c->dev, "Read device id error\n"); @@ -756,7 > > +979,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > /* Check your board and dts for match the right pmic */ > > if (((device_id >> 4) != 0x1 && type == PCA9450_TYPE_PCA9450A) || > > - ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC)) > { > > + ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC) > || > > + ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9451A)) > > + { > > dev_err(&i2c->dev, "Device id(%x) mismatched\n", > > device_id >> 4); > > return -EINVAL; > > @@ -767,7 +991,16 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > struct regulator_dev *rdev; > > const struct pca9450_regulator_desc *r; > > > > - r = ®ulator_desc[i]; > > + if (type == PCA9450_TYPE_PCA9451A && > > + !strcmp((®ulator_desc[i])->desc.name, "buck1") && > pmic_trim) { > > + r = ®ulator_desc[i + 1]; > > + i = i + 1; > > + } else if (type == PCA9450_TYPE_PCA9451A && > > + !strcmp((®ulator_desc[i])->desc.name, > "buck1")) { > > + r = ®ulator_desc[i]; > > + i = i + 1; > > I would put this in a single 'type == PCA9450_TYPE_PCA9451A' branch, to > indicate that only PCA9451A needs some kind of special handling. Yes, this makes the logic clearer. I will change in next version. > > > + } else > > + r = ®ulator_desc[i]; > > desc = &r->desc; > > > > config.regmap = pca9450->regmap; @@ -847,7 +1080,8 > @@ > > static int pca9450_i2c_probe(struct i2c_client *i2c) > > } > > > > dev_info(&i2c->dev, "%s probed.\n", > > - type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > "pca9450bc"); > > + type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > > + (type == PCA9450_TYPE_PCA9451A ? "pca9451a" : > "pca9450bc")); > > > > return 0; > > } > > @@ -865,6 +1099,10 @@ static const struct of_device_id > > pca9450_of_match[] = { .compatible = "nxp,pca9450c", > > .data = (void *)PCA9450_TYPE_PCA9450BC, > > }, > > + { > > + .compatible = "nxp,pca9451a", > > + .data = (void *)PCA9450_TYPE_PCA9451A, > > + }, > > { } > > }; > > MODULE_DEVICE_TABLE(of, pca9450_of_match); diff --git > > a/include/linux/regulator/pca9450.h > > b/include/linux/regulator/pca9450.h index 3c01c2bf84f5..5dd79f52165a > > 100644 > > --- a/include/linux/regulator/pca9450.h > > +++ b/include/linux/regulator/pca9450.h > > @@ -9,6 +9,7 @@ > > enum pca9450_chip_type { > > PCA9450_TYPE_PCA9450A = 0, > > PCA9450_TYPE_PCA9450BC, > > + PCA9450_TYPE_PCA9451A, > > PCA9450_TYPE_AMOUNT, > > }; > > > > @@ -93,6 +94,7 @@ enum { > > PCA9450_MAX_REGISTER = 0x2F, > > }; > > > > +#define PCA9450_REG_PWRCTRL_TOFF_DEB BIT(5) > > Newline here please. Ok, will modify it. Thank you very much for your comments and efforts. BR Joy Zou > > Best regards, > Alexander > > > /* PCA9450 BUCK ENMODE bits */ > > #define BUCK_ENMODE_OFF 0x00 > > #define BUCK_ENMODE_ONREQ 0x01 > > > -- > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany > Amtsgericht München, HRB 105018 > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider > http://www.tq-/ > group.com%2F&data=05%7C01%7Cjoy.zou%40nxp.com%7C1ecbe75c432d464 > cb45f08db61cb08bc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 > C638211296883052738%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% > 7C&sdata=mz7vtBiDvAxY9FO7tTZO3oPBA8zvYS6f8hLgAwrU8uk%3D&reserved > =0 >
Hello, Am Mittwoch, 5. Juli 2023, 08:50:24 CEST schrieb Joy Zou: > > > -----Original Message----- > > From: Alexander Stein <alexander.stein@ew.tq-group.com> > > Sent: 2023年5月31日 19:35 > > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > > broonie@kernel.org; robh+dt@kernel.org; > > krzysztof.kozlowski+dt@linaro.org; > > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > > linux-arm-kernel@lists.infradead.org > > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; Joy > > Zou <joy.zou@nxp.com> > > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > support > > > > > > > > Caution: This is an external email. Please take care when clicking links > > or opening attachments. When in doubt, report the message using the > > 'Report this email' button > > > > > > > > > > Hi, > > > > > > > > Am Mittwoch, 31. Mai 2023, 08:57:23 CEST schrieb Joy Zou: > > > > > Adding support for pmic pca9451a. > > > > > > > > > > > > This patch support old and new pmic pca9451a. The new pmic trimed > > > > BUCK1. > > > > > The default value of Toff_Deb is used to distinguish the old and new > > > pmic. > > > > > > > > > > > > Signed-off-by: Joy Zou <joy.zou@nxp.com> > > > --- > > > > > > drivers/regulator/pca9450-regulator.c | 262 > > > > ++++++++++++++++++++++++-- > > > > > include/linux/regulator/pca9450.h | 2 + > > > 2 files changed, 252 insertions(+), 12 deletions(-) > > > > > > > > > > > > diff --git a/drivers/regulator/pca9450-regulator.c > > > b/drivers/regulator/pca9450-regulator.c index > > > 91bfb7e026c9..654aa4fbe494 > > > 100644 > > > --- a/drivers/regulator/pca9450-regulator.c > > > +++ b/drivers/regulator/pca9450-regulator.c > > > @@ -104,7 +104,15 @@ static const struct regulator_ops > > > pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) > > > > > > */ > > > > > > static const struct linear_range pca9450_dvs_buck_volts[] = { > > > > > > - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > > > + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), }; > > > + > > > +/* > > > + * BUCK1/3 > > > + * 0.65 to 2.2375V (12.5mV step) > > > > > > > > Reading this comment, it seems the same distinction needs to be done for > > BUCK3 as well, no? > > Sorry for the late reply! > The BUCK1 and BUCK3 are dual phase, so don't need to be done for BUCK3. > > > > > > > > + */ > > > +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { > > > + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), > > > > > > }; > > > > > > > > > > > > /* > > > > > > @@ -663,6 +671,207 @@ static const struct pca9450_regulator_desc > > > pca9450bc_regulators[] = { }, }; > > > > > > > > > > > > +static const struct pca9450_regulator_desc pca9451a_regulators[] = { > > > + { > > > + .desc = { > > > + .name = "buck1", > > > + .of_match = of_match_ptr("BUCK1"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_BUCK1, > > > + .ops = &pca9450_dvs_buck_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_dvs_buck_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_dvs_buck_volts), > > > > > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > + .vsel_mask = BUCK1OUT_DVS0_MASK, > > > + .enable_reg = PCA9450_REG_BUCK1CTRL, > > > + .enable_mask = BUCK1_ENMODE_MASK, > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > + .ramp_mask = BUCK1_RAMP_MASK, > > > + .ramp_delay_table = > > > > pca9450_dvs_buck_ramp_table, > > > > > + .n_ramp_values = > > > > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > > > > + .owner = THIS_MODULE, > > > + .of_parse_cb = pca9450_set_dvs_levels, > > > + }, > > > + .dvs = { > > > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > + .run_mask = BUCK1OUT_DVS0_MASK, > > > + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, > > > + .standby_mask = BUCK1OUT_DVS1_MASK, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "buck1_trim", > > > + .of_match = of_match_ptr("BUCK1"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_BUCK1, > > > + .ops = &pca9450_dvs_buck_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_trim_dvs_buck_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_trim_dvs_buck_volts), > > > > > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > + .vsel_mask = BUCK1OUT_DVS0_MASK, > > > + .enable_reg = PCA9450_REG_BUCK1CTRL, > > > + .enable_mask = BUCK1_ENMODE_MASK, > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > + .ramp_mask = BUCK1_RAMP_MASK, > > > + .ramp_delay_table = > > > > pca9450_dvs_buck_ramp_table, > > > > > + .n_ramp_values = > > > > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > > > > + .owner = THIS_MODULE, > > > + .of_parse_cb = pca9450_set_dvs_levels, > > > + }, > > > + .dvs = { > > > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > + .run_mask = BUCK1OUT_DVS0_MASK, > > > + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, > > > + .standby_mask = BUCK1OUT_DVS1_MASK, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "buck2", > > > + .of_match = of_match_ptr("BUCK2"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_BUCK2, > > > + .ops = &pca9450_dvs_buck_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_BUCK2_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_dvs_buck_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_dvs_buck_volts), > > > > > + .vsel_reg = PCA9450_REG_BUCK2OUT_DVS0, > > > + .vsel_mask = BUCK2OUT_DVS0_MASK, > > > + .enable_reg = PCA9450_REG_BUCK2CTRL, > > > + .enable_mask = BUCK2_ENMODE_MASK, > > > + .enable_val = BUCK_ENMODE_ONREQ_STBYREQ, > > > + .ramp_mask = BUCK2_RAMP_MASK, > > > + .ramp_delay_table = > > > > pca9450_dvs_buck_ramp_table, > > > > > + .n_ramp_values = > > > > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > > > > + .owner = THIS_MODULE, > > > + .of_parse_cb = pca9450_set_dvs_levels, > > > + }, > > > + .dvs = { > > > + .run_reg = PCA9450_REG_BUCK2OUT_DVS0, > > > + .run_mask = BUCK2OUT_DVS0_MASK, > > > + .standby_reg = PCA9450_REG_BUCK2OUT_DVS1, > > > + .standby_mask = BUCK2OUT_DVS1_MASK, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "buck4", > > > + .of_match = of_match_ptr("BUCK4"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_BUCK4, > > > + .ops = &pca9450_buck_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_BUCK4_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_buck_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_buck_volts), > > > > > + .vsel_reg = PCA9450_REG_BUCK4OUT, > > > + .vsel_mask = BUCK4OUT_MASK, > > > + .enable_reg = PCA9450_REG_BUCK4CTRL, > > > + .enable_mask = BUCK4_ENMODE_MASK, > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > + .owner = THIS_MODULE, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "buck5", > > > + .of_match = of_match_ptr("BUCK5"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_BUCK5, > > > + .ops = &pca9450_buck_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_BUCK5_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_buck_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_buck_volts), > > > > > + .vsel_reg = PCA9450_REG_BUCK5OUT, > > > + .vsel_mask = BUCK5OUT_MASK, > > > + .enable_reg = PCA9450_REG_BUCK5CTRL, > > > + .enable_mask = BUCK5_ENMODE_MASK, > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > + .owner = THIS_MODULE, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "buck6", > > > + .of_match = of_match_ptr("BUCK6"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_BUCK6, > > > + .ops = &pca9450_buck_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_BUCK6_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_buck_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_buck_volts), > > > > > + .vsel_reg = PCA9450_REG_BUCK6OUT, > > > + .vsel_mask = BUCK6OUT_MASK, > > > + .enable_reg = PCA9450_REG_BUCK6CTRL, > > > + .enable_mask = BUCK6_ENMODE_MASK, > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > + .owner = THIS_MODULE, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "ldo1", > > > + .of_match = of_match_ptr("LDO1"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_LDO1, > > > + .ops = &pca9450_ldo_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_LDO1_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_ldo1_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_ldo1_volts), > > > > > + .vsel_reg = PCA9450_REG_LDO1CTRL, > > > + .vsel_mask = LDO1OUT_MASK, > > > + .enable_reg = PCA9450_REG_LDO1CTRL, > > > + .enable_mask = LDO1_EN_MASK, > > > + .owner = THIS_MODULE, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "ldo4", > > > + .of_match = of_match_ptr("LDO4"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_LDO4, > > > + .ops = &pca9450_ldo_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_LDO4_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_ldo34_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_ldo34_volts), > > > > > + .vsel_reg = PCA9450_REG_LDO4CTRL, > > > + .vsel_mask = LDO4OUT_MASK, > > > + .enable_reg = PCA9450_REG_LDO4CTRL, > > > + .enable_mask = LDO4_EN_MASK, > > > + .owner = THIS_MODULE, > > > + }, > > > + }, > > > + { > > > + .desc = { > > > + .name = "ldo5", > > > + .of_match = of_match_ptr("LDO5"), > > > + .regulators_node = of_match_ptr("regulators"), > > > + .id = PCA9450_LDO5, > > > + .ops = &pca9450_ldo_regulator_ops, > > > + .type = REGULATOR_VOLTAGE, > > > + .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, > > > + .linear_ranges = pca9450_ldo5_volts, > > > + .n_linear_ranges = > > > > ARRAY_SIZE(pca9450_ldo5_volts), > > > > > + .vsel_reg = PCA9450_REG_LDO5CTRL_H, > > > + .vsel_mask = LDO5HOUT_MASK, > > > + .enable_reg = PCA9450_REG_LDO5CTRL_H, > > > + .enable_mask = LDO5H_EN_MASK, > > > + .owner = THIS_MODULE, > > > + }, > > > + }, > > > +}; > > > + > > > > > > static irqreturn_t pca9450_irq_handler(int irq, void *data) { > > > > > > struct pca9450 *pca9450 = data; > > > > > > @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct i2c_client > > > *i2c) > > > > > > const struct pca9450_regulator_desc *regulator_desc; > > > struct regulator_config config = { }; > > > struct pca9450 *pca9450; > > > > > > - unsigned int device_id, i; > > > + unsigned int device_id, i, val; > > > > > > unsigned int reset_ctrl; > > > > > > + bool pmic_trim = false; > > > > > > int ret; > > > > > > > > > > > > if (!i2c->irq) { > > > > > > @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct i2c_client > > > *i2c) > > > > > > if (!pca9450) > > > > > > return -ENOMEM; > > > > > > > > > > > > + pca9450->regmap = devm_regmap_init_i2c(i2c, > > > + > > > > &pca9450_regmap_config); > > > > > + if (IS_ERR(pca9450->regmap)) { > > > + dev_err(&i2c->dev, "regmap initialization failed\n"); > > > + return PTR_ERR(pca9450->regmap); > > > + } > > > + > > > + ret = regmap_read(pca9450->regmap, PCA9450_REG_PWRCTRL, > > > > &val); > > > > > + if (ret) { > > > + dev_err(&i2c->dev, "Read device id error\n"); > > > + return ret; > > > + } > > > + > > > + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) > > > + pmic_trim = true; > > > > > > > > PCA9450_REG_PWRCTRL is a read/write register. How is it possible to detect > > a chip revision using a bit which can be changed by software e.g. > > bootloader? Despite that this bit sets debounce time for PMIC_ON_REQ, how > > is this related to BUCK1 voltage range? > > There are old and new two kind PMIC pca9451a. There is only one part mentioned in the ordering options. How can I distinguish them? Any chip ID, date codes, markings? > This bit sets debounce time in > PCA9450_REG_PWRCTRL was set different value by hardware in order to only > distinguish the old and new PMIC. This bit isn't related to the BUCK1 > voltage range. If the pmic_trim is true that means it's new pca9451a. But this bit is writable. How do you know it has not been modified since reset? Best regards, Alexander > > > + > > > > > > switch (type) { > > > case PCA9450_TYPE_PCA9450A: > > > > > > regulator_desc = pca9450a_regulators; @@ -730,6 +956,10 > > > > > > @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > > > regulator_desc = pca9450bc_regulators; > > > pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); > > > break; > > > > > > + case PCA9450_TYPE_PCA9451A: > > > + regulator_desc = pca9451a_regulators; > > > + pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); > > > + break; > > > > > > default: > > > > > > dev_err(&i2c->dev, "Unknown device type"); > > > return -EINVAL; > > > > > > @@ -741,13 +971,6 @@ static int pca9450_i2c_probe(struct i2c_client > > > *i2c) > > > > > > > > > > > > dev_set_drvdata(&i2c->dev, pca9450); > > > > > > > > > > > > - pca9450->regmap = devm_regmap_init_i2c(i2c, > > > - > > > > &pca9450_regmap_config); > > > > > - if (IS_ERR(pca9450->regmap)) { > > > - dev_err(&i2c->dev, "regmap initialization failed\n"); > > > - return PTR_ERR(pca9450->regmap); > > > - } > > > - > > > > > > ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, > > > > &device_id); > > > > > if (ret) { > > > > > > dev_err(&i2c->dev, "Read device id error\n"); @@ -756,7 > > > > > > +979,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > > > > > > > > > /* Check your board and dts for match the right pmic */ > > > if (((device_id >> 4) != 0x1 && type == PCA9450_TYPE_PCA9450A) || > > > > > > - ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC)) > > > > { > > > > > + ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC) > > > > > || > > || > > > + ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9451A)) > > > + { > > > > > > dev_err(&i2c->dev, "Device id(%x) mismatched\n", > > > > > > device_id >> 4); > > > > > > return -EINVAL; > > > > > > @@ -767,7 +991,16 @@ static int pca9450_i2c_probe(struct i2c_client > > > *i2c) > > > > > > struct regulator_dev *rdev; > > > const struct pca9450_regulator_desc *r; > > > > > > > > > > > > - r = ®ulator_desc[i]; > > > + if (type == PCA9450_TYPE_PCA9451A && > > > + !strcmp((®ulator_desc[i])->desc.name, "buck1") && > > > > pmic_trim) { > > > > > + r = ®ulator_desc[i + 1]; > > > + i = i + 1; > > > + } else if (type == PCA9450_TYPE_PCA9451A && > > > + !strcmp((®ulator_desc[i])->desc.name, > > > > "buck1")) { > > > > > + r = ®ulator_desc[i]; > > > + i = i + 1; > > > > > > > > I would put this in a single 'type == PCA9450_TYPE_PCA9451A' branch, to > > indicate that only PCA9451A needs some kind of special handling. > > Yes, this makes the logic clearer. I will change in next version. > > > > > > > > + } else > > > + r = ®ulator_desc[i]; > > > > > > desc = &r->desc; > > > > > > > > > > > > config.regmap = pca9450->regmap; @@ -847,7 +1080,8 > > > > @@ > > > > > static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > > > } > > > > > > > > > > > > dev_info(&i2c->dev, "%s probed.\n", > > > > > > - type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > > > > "pca9450bc"); > > > > > + type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > > > + (type == PCA9450_TYPE_PCA9451A ? "pca9451a" : > > > > "pca9450bc")); > > > > > > > > > > > return 0; > > > > > > } > > > > > > @@ -865,6 +1099,10 @@ static const struct of_device_id > > > pca9450_of_match[] = { .compatible = "nxp,pca9450c", > > > > > > .data = (void *)PCA9450_TYPE_PCA9450BC, > > > > > > }, > > > > > > + { > > > + .compatible = "nxp,pca9451a", > > > + .data = (void *)PCA9450_TYPE_PCA9451A, > > > + }, > > > > > > { } > > > > > > }; > > > MODULE_DEVICE_TABLE(of, pca9450_of_match); diff --git > > > > > > a/include/linux/regulator/pca9450.h > > > b/include/linux/regulator/pca9450.h index 3c01c2bf84f5..5dd79f52165a > > > 100644 > > > --- a/include/linux/regulator/pca9450.h > > > +++ b/include/linux/regulator/pca9450.h > > > @@ -9,6 +9,7 @@ > > > > > > enum pca9450_chip_type { > > > > > > PCA9450_TYPE_PCA9450A = 0, > > > PCA9450_TYPE_PCA9450BC, > > > > > > + PCA9450_TYPE_PCA9451A, > > > > > > PCA9450_TYPE_AMOUNT, > > > > > > }; > > > > > > > > > > > > @@ -93,6 +94,7 @@ enum { > > > > > > PCA9450_MAX_REGISTER = 0x2F, > > > > > > }; > > > > > > > > > > > > +#define PCA9450_REG_PWRCTRL_TOFF_DEB BIT(5) > > > > > > > > Newline here please. > > Ok, will modify it. > Thank you very much for your comments and efforts. > BR > Joy Zou > > > > > > > Best regards, > > Alexander > > > > > > > > > /* PCA9450 BUCK ENMODE bits */ > > > #define BUCK_ENMODE_OFF 0x00 > > > #define BUCK_ENMODE_ONREQ 0x01 > > > > > > > > > > -- > > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany > > Amtsgericht München, HRB 105018 > > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider > > http://www.tq-/ > > group.com%2F&data=05%7C01%7Cjoy.zou%40nxp.com%7C1ecbe75c432d464 > > cb45f08db61cb08bc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 > > C638211296883052738%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% > > 7C&sdata=mz7vtBiDvAxY9FO7tTZO3oPBA8zvYS6f8hLgAwrU8uk%3D&reserved > > =0 > > > > > >
> -----Original Message----- > From: Alexander Stein <alexander.stein@ew.tq-group.com> > Sent: 2023年7月5日 21:13 > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > broonie@kernel.org; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > linux-arm-kernel@lists.infradead.org; Joy Zou <joy.zou@nxp.com> > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a support > > Caution: This is an external email. Please take care when clicking links or > opening attachments. When in doubt, report the message using the 'Report > this email' button > > > Hello, > > Am Mittwoch, 5. Juli 2023, 08:50:24 CEST schrieb Joy Zou: > > > > > -----Original Message----- > > > From: Alexander Stein <alexander.stein@ew.tq-group.com> > > > Sent: 2023年5月31日 19:35 > > > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > > > broonie@kernel.org; robh+dt@kernel.org; > > > krzysztof.kozlowski+dt@linaro.org; > > > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > > > linux-arm-kernel@lists.infradead.org > > > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > > > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org; > > > Joy Zou > <joy.zou@nxp.com> > > > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > > support > > > > > > > > > > > > Caution: This is an external email. Please take care when clicking > > > links or > opening attachments. When in doubt, report the message using the > > > 'Report this email' button > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > Am Mittwoch, 31. Mai 2023, 08:57:23 CEST schrieb Joy Zou: > > > > > > > Adding support for pmic pca9451a. > > > > > > > > > > > > > > > > This patch support old and new pmic pca9451a. The new pmic trimed > > > > > > BUCK1. > > > > > > > The default value of Toff_Deb is used to distinguish the old and > > > > new pmic. > > > > > > > > > > > > > > > > Signed-off-by: Joy Zou <joy.zou@nxp.com> > > > > --- > > > > > > > > drivers/regulator/pca9450-regulator.c | 262 > > > > > > ++++++++++++++++++++++++-- > > > > > > > include/linux/regulator/pca9450.h | 2 + > > > > 2 files changed, 252 insertions(+), 12 deletions(-) > > > > > > > > > > > > > > > > diff --git a/drivers/regulator/pca9450-regulator.c > > > > b/drivers/regulator/pca9450-regulator.c index > > > > 91bfb7e026c9..654aa4fbe494 > > > > 100644 > > > > --- a/drivers/regulator/pca9450-regulator.c > > > > +++ b/drivers/regulator/pca9450-regulator.c > > > > @@ -104,7 +104,15 @@ static const struct regulator_ops > > > > pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) > > > > > > > > */ > > > > > > > > static const struct linear_range pca9450_dvs_buck_volts[] = { > > > > > > > > - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > > > > + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), }; > > > > + > > > > +/* > > > > + * BUCK1/3 > > > > + * 0.65 to 2.2375V (12.5mV step) > > > > > > > > > > > > Reading this comment, it seems the same distinction needs to be done > > > for > > > BUCK3 as well, no? > > > > Sorry for the late reply! > > The BUCK1 and BUCK3 are dual phase, so don't need to be done for BUCK3. > > > > > > > > > > > > + */ > > > > +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { > > > > + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), > > > > > > > > }; > > > > > > > > > > > > > > > > /* > > > > > > > > @@ -663,6 +671,207 @@ static const struct pca9450_regulator_desc > > > > pca9450bc_regulators[] = { }, }; > > > > > > > > > > > > > > > > +static const struct pca9450_regulator_desc pca9451a_regulators[] = { > > > > + { > > > > + .desc = { > > > > + .name = "buck1", > > > > + .of_match = of_match_ptr("BUCK1"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_BUCK1, > > > > + .ops = &pca9450_dvs_buck_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_dvs_buck_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_dvs_buck_volts), > > > > > > > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > > + .vsel_mask = BUCK1OUT_DVS0_MASK, > > > > + .enable_reg = PCA9450_REG_BUCK1CTRL, > > > > + .enable_mask = BUCK1_ENMODE_MASK, > > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > > + .ramp_mask = BUCK1_RAMP_MASK, > > > > + .ramp_delay_table = > > > > > > pca9450_dvs_buck_ramp_table, > > > > > > > + .n_ramp_values = > > > > > > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > > > > > > + .owner = THIS_MODULE, > > > > + .of_parse_cb = pca9450_set_dvs_levels, > > > > + }, > > > > + .dvs = { > > > > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > > + .run_mask = BUCK1OUT_DVS0_MASK, > > > > + .standby_reg = > PCA9450_REG_BUCK1OUT_DVS1, > > > > + .standby_mask = BUCK1OUT_DVS1_MASK, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "buck1_trim", > > > > + .of_match = of_match_ptr("BUCK1"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_BUCK1, > > > > + .ops = &pca9450_dvs_buck_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_trim_dvs_buck_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_trim_dvs_buck_volts), > > > > > > > + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > > + .vsel_mask = BUCK1OUT_DVS0_MASK, > > > > + .enable_reg = PCA9450_REG_BUCK1CTRL, > > > > + .enable_mask = BUCK1_ENMODE_MASK, > > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > > + .ramp_mask = BUCK1_RAMP_MASK, > > > > + .ramp_delay_table = > > > > > > pca9450_dvs_buck_ramp_table, > > > > > > > + .n_ramp_values = > > > > > > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > > > > > > + .owner = THIS_MODULE, > > > > + .of_parse_cb = pca9450_set_dvs_levels, > > > > + }, > > > > + .dvs = { > > > > + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, > > > > + .run_mask = BUCK1OUT_DVS0_MASK, > > > > + .standby_reg = > PCA9450_REG_BUCK1OUT_DVS1, > > > > + .standby_mask = BUCK1OUT_DVS1_MASK, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "buck2", > > > > + .of_match = of_match_ptr("BUCK2"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_BUCK2, > > > > + .ops = &pca9450_dvs_buck_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_BUCK2_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_dvs_buck_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_dvs_buck_volts), > > > > > > > + .vsel_reg = PCA9450_REG_BUCK2OUT_DVS0, > > > > + .vsel_mask = BUCK2OUT_DVS0_MASK, > > > > + .enable_reg = PCA9450_REG_BUCK2CTRL, > > > > + .enable_mask = BUCK2_ENMODE_MASK, > > > > + .enable_val = > BUCK_ENMODE_ONREQ_STBYREQ, > > > > + .ramp_mask = BUCK2_RAMP_MASK, > > > > + .ramp_delay_table = > > > > > > pca9450_dvs_buck_ramp_table, > > > > > > > + .n_ramp_values = > > > > > > ARRAY_SIZE(pca9450_dvs_buck_ramp_table), > > > > > > > + .owner = THIS_MODULE, > > > > + .of_parse_cb = pca9450_set_dvs_levels, > > > > + }, > > > > + .dvs = { > > > > + .run_reg = PCA9450_REG_BUCK2OUT_DVS0, > > > > + .run_mask = BUCK2OUT_DVS0_MASK, > > > > + .standby_reg = > PCA9450_REG_BUCK2OUT_DVS1, > > > > + .standby_mask = BUCK2OUT_DVS1_MASK, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "buck4", > > > > + .of_match = of_match_ptr("BUCK4"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_BUCK4, > > > > + .ops = &pca9450_buck_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_BUCK4_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_buck_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_buck_volts), > > > > > > > + .vsel_reg = PCA9450_REG_BUCK4OUT, > > > > + .vsel_mask = BUCK4OUT_MASK, > > > > + .enable_reg = PCA9450_REG_BUCK4CTRL, > > > > + .enable_mask = BUCK4_ENMODE_MASK, > > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > > + .owner = THIS_MODULE, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "buck5", > > > > + .of_match = of_match_ptr("BUCK5"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_BUCK5, > > > > + .ops = &pca9450_buck_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_BUCK5_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_buck_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_buck_volts), > > > > > > > + .vsel_reg = PCA9450_REG_BUCK5OUT, > > > > + .vsel_mask = BUCK5OUT_MASK, > > > > + .enable_reg = PCA9450_REG_BUCK5CTRL, > > > > + .enable_mask = BUCK5_ENMODE_MASK, > > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > > + .owner = THIS_MODULE, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "buck6", > > > > + .of_match = of_match_ptr("BUCK6"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_BUCK6, > > > > + .ops = &pca9450_buck_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_BUCK6_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_buck_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_buck_volts), > > > > > > > + .vsel_reg = PCA9450_REG_BUCK6OUT, > > > > + .vsel_mask = BUCK6OUT_MASK, > > > > + .enable_reg = PCA9450_REG_BUCK6CTRL, > > > > + .enable_mask = BUCK6_ENMODE_MASK, > > > > + .enable_val = BUCK_ENMODE_ONREQ, > > > > + .owner = THIS_MODULE, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "ldo1", > > > > + .of_match = of_match_ptr("LDO1"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_LDO1, > > > > + .ops = &pca9450_ldo_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_LDO1_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_ldo1_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_ldo1_volts), > > > > > > > + .vsel_reg = PCA9450_REG_LDO1CTRL, > > > > + .vsel_mask = LDO1OUT_MASK, > > > > + .enable_reg = PCA9450_REG_LDO1CTRL, > > > > + .enable_mask = LDO1_EN_MASK, > > > > + .owner = THIS_MODULE, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "ldo4", > > > > + .of_match = of_match_ptr("LDO4"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_LDO4, > > > > + .ops = &pca9450_ldo_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_LDO4_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_ldo34_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_ldo34_volts), > > > > > > > + .vsel_reg = PCA9450_REG_LDO4CTRL, > > > > + .vsel_mask = LDO4OUT_MASK, > > > > + .enable_reg = PCA9450_REG_LDO4CTRL, > > > > + .enable_mask = LDO4_EN_MASK, > > > > + .owner = THIS_MODULE, > > > > + }, > > > > + }, > > > > + { > > > > + .desc = { > > > > + .name = "ldo5", > > > > + .of_match = of_match_ptr("LDO5"), > > > > + .regulators_node = of_match_ptr("regulators"), > > > > + .id = PCA9450_LDO5, > > > > + .ops = &pca9450_ldo_regulator_ops, > > > > + .type = REGULATOR_VOLTAGE, > > > > + .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, > > > > + .linear_ranges = pca9450_ldo5_volts, > > > > + .n_linear_ranges = > > > > > > ARRAY_SIZE(pca9450_ldo5_volts), > > > > > > > + .vsel_reg = PCA9450_REG_LDO5CTRL_H, > > > > + .vsel_mask = LDO5HOUT_MASK, > > > > + .enable_reg = PCA9450_REG_LDO5CTRL_H, > > > > + .enable_mask = LDO5H_EN_MASK, > > > > + .owner = THIS_MODULE, > > > > + }, > > > > + }, > > > > +}; > > > > + > > > > > > > > static irqreturn_t pca9450_irq_handler(int irq, void *data) { > > > > > > > > struct pca9450 *pca9450 = data; > > > > > > > > @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct i2c_client > > > > *i2c) > > > > > > > > const struct pca9450_regulator_desc *regulator_desc; > > > > struct regulator_config config = { }; > > > > struct pca9450 *pca9450; > > > > > > > > - unsigned int device_id, i; > > > > + unsigned int device_id, i, val; > > > > > > > > unsigned int reset_ctrl; > > > > > > > > + bool pmic_trim = false; > > > > > > > > int ret; > > > > > > > > > > > > > > > > if (!i2c->irq) { > > > > > > > > @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct > > > > i2c_client > > > > *i2c) > > > > > > > > if (!pca9450) > > > > > > > > return -ENOMEM; > > > > > > > > > > > > > > > > + pca9450->regmap = devm_regmap_init_i2c(i2c, > > > > + > > > > > > &pca9450_regmap_config); > > > > > > > + if (IS_ERR(pca9450->regmap)) { > > > > + dev_err(&i2c->dev, "regmap initialization failed\n"); > > > > + return PTR_ERR(pca9450->regmap); > > > > + } > > > > + > > > > + ret = regmap_read(pca9450->regmap, PCA9450_REG_PWRCTRL, > > > > > > &val); > > > > > > > + if (ret) { > > > > + dev_err(&i2c->dev, "Read device id error\n"); > > > > + return ret; > > > > + } > > > > + > > > > + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) > > > > + pmic_trim = true; > > > > > > > > > > > > PCA9450_REG_PWRCTRL is a read/write register. How is it possible to > > > detect a chip revision using a bit which can be changed by software e.g. > > > bootloader? Despite that this bit sets debounce time for > > > PMIC_ON_REQ, how is this related to BUCK1 voltage range? > > > > There are old and new two kind PMIC pca9451a. > > There is only one part mentioned in the ordering options. How can I > distinguish them? Any chip ID, date codes, markings? Yes, there is only one part. We distinguish the new and old part by this bit Toff_Deb of PCA9450_REG_PWRCTRL reset value. The reset value 0 means it's old part, and the reset value 1 means it's new part. > > > This bit sets debounce time in > > PCA9450_REG_PWRCTRL was set different value by hardware in order to > > only distinguish the old and new PMIC. This bit isn't related to the > > BUCK1 voltage range. If the pmic_trim is true that means it's new pca9451a. > > But this bit is writable. How do you know it has not been modified since reset? Yes, we don't consider modify the debounce bit case. Modify the Toff_deb value will influence the old and new part judgement. For example, this default value of Toff_deb is 1 in the new part, if the customers change the Toff_deb value from 1 to 0, and then make the board warm reset, the Toff_deb value still keep 0, if the Toff_deb value is 0, the PMIC driver will think this part is old part. But this part is new part in fact. Have discussed this issue with our internal team member, we will add a note to PCA9451 datasheet – “Please contract NXP If you want to change Toff_deb.” But till now, we am not aware any customers case which need to adjust Toff_deb. Make it more clear: If customers do need to manually adjust Toff_deb, It need PMIC driver update to bypass this bit check and directly apply corresponding voltage config table old or new. Thank you very much! BR Joy Zou > > Best regards, > Alexander > > > > > + > > > > > > > > switch (type) { > > > > case PCA9450_TYPE_PCA9450A: > > > > > > > > regulator_desc = pca9450a_regulators; @@ -730,6 > > > > +956,10 > > > > > > > > @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > > > > > regulator_desc = pca9450bc_regulators; > > > > pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); > > > > break; > > > > > > > > + case PCA9450_TYPE_PCA9451A: > > > > + regulator_desc = pca9451a_regulators; > > > > + pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); > > > > + break; > > > > > > > > default: > > > > > > > > dev_err(&i2c->dev, "Unknown device type"); > > > > return -EINVAL; > > > > > > > > @@ -741,13 +971,6 @@ static int pca9450_i2c_probe(struct > > > > i2c_client > > > > *i2c) > > > > > > > > > > > > > > > > dev_set_drvdata(&i2c->dev, pca9450); > > > > > > > > > > > > > > > > - pca9450->regmap = devm_regmap_init_i2c(i2c, > > > > - > > > > > > &pca9450_regmap_config); > > > > > > > - if (IS_ERR(pca9450->regmap)) { > > > > - dev_err(&i2c->dev, "regmap initialization failed\n"); > > > > - return PTR_ERR(pca9450->regmap); > > > > - } > > > > - > > > > > > > > ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, > > > > > > &device_id); > > > > > > > if (ret) { > > > > > > > > dev_err(&i2c->dev, "Read device id error\n"); @@ > > > > -756,7 > > > > > > > > +979,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > > > > > > > > > > > > > /* Check your board and dts for match the right pmic */ > > > > if (((device_id >> 4) != 0x1 && type == > > > > PCA9450_TYPE_PCA9450A) || > > > > > > > > - ((device_id >> 4) != 0x3 && type == > PCA9450_TYPE_PCA9450BC)) > > > > > > { > > > > > > > + ((device_id >> 4) != 0x3 && type == > > > > + PCA9450_TYPE_PCA9450BC) > > > > > > > || > > > || > > > > + ((device_id >> 4) != 0x9 && type == > > > > + PCA9450_TYPE_PCA9451A)) { > > > > > > > > dev_err(&i2c->dev, "Device id(%x) mismatched\n", > > > > > > > > device_id >> 4); > > > > > > > > return -EINVAL; > > > > > > > > @@ -767,7 +991,16 @@ static int pca9450_i2c_probe(struct > > > > i2c_client > > > > *i2c) > > > > > > > > struct regulator_dev *rdev; > > > > const struct pca9450_regulator_desc *r; > > > > > > > > > > > > > > > > - r = ®ulator_desc[i]; > > > > + if (type == PCA9450_TYPE_PCA9451A && > > > > + !strcmp((®ulator_desc[i])->desc.name, > > > > + "buck1") && > > > > > > pmic_trim) { > > > > > > > + r = ®ulator_desc[i + 1]; > > > > + i = i + 1; > > > > + } else if (type == PCA9450_TYPE_PCA9451A && > > > > + !strcmp((®ulator_desc[i])->desc.name, > > > > > > "buck1")) { > > > > > > > + r = ®ulator_desc[i]; > > > > + i = i + 1; > > > > > > > > > > > > I would put this in a single 'type == PCA9450_TYPE_PCA9451A' branch, > > > to indicate that only PCA9451A needs some kind of special handling. > > > > Yes, this makes the logic clearer. I will change in next version. > > > > > > > > > > > > + } else > > > > + r = ®ulator_desc[i]; > > > > > > > > desc = &r->desc; > > > > > > > > > > > > > > > > config.regmap = pca9450->regmap; @@ -847,7 +1080,8 > > > > > > @@ > > > > > > > static int pca9450_i2c_probe(struct i2c_client *i2c) > > > > > > > > } > > > > > > > > > > > > > > > > dev_info(&i2c->dev, "%s probed.\n", > > > > > > > > - type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > > > > > > "pca9450bc"); > > > > > > > + type == PCA9450_TYPE_PCA9450A ? "pca9450a" : > > > > + (type == PCA9450_TYPE_PCA9451A ? "pca9451a" : > > > > > > "pca9450bc")); > > > > > > > > > > > > > > > return 0; > > > > > > > > } > > > > > > > > @@ -865,6 +1099,10 @@ static const struct of_device_id > > > > pca9450_of_match[] = { .compatible = "nxp,pca9450c", > > > > > > > > .data = (void *)PCA9450_TYPE_PCA9450BC, > > > > > > > > }, > > > > > > > > + { > > > > + .compatible = "nxp,pca9451a", > > > > + .data = (void *)PCA9450_TYPE_PCA9451A, > > > > + }, > > > > > > > > { } > > > > > > > > }; > > > > MODULE_DEVICE_TABLE(of, pca9450_of_match); diff --git > > > > > > > > a/include/linux/regulator/pca9450.h > > > > b/include/linux/regulator/pca9450.h index > > > > 3c01c2bf84f5..5dd79f52165a > > > > 100644 > > > > --- a/include/linux/regulator/pca9450.h > > > > +++ b/include/linux/regulator/pca9450.h > > > > @@ -9,6 +9,7 @@ > > > > > > > > enum pca9450_chip_type { > > > > > > > > PCA9450_TYPE_PCA9450A = 0, > > > > PCA9450_TYPE_PCA9450BC, > > > > > > > > + PCA9450_TYPE_PCA9451A, > > > > > > > > PCA9450_TYPE_AMOUNT, > > > > > > > > }; > > > > > > > > > > > > > > > > @@ -93,6 +94,7 @@ enum { > > > > > > > > PCA9450_MAX_REGISTER = 0x2F, > > > > > > > > }; > > > > > > > > > > > > > > > > +#define PCA9450_REG_PWRCTRL_TOFF_DEB BIT(5) > > > > > > > > > > > > Newline here please. > > > > Ok, will modify it. > > Thank you very much for your comments and efforts. > > BR > > Joy Zou > > > > > > > > > > > Best regards, > > > Alexander > > > > > > > > > > > > > /* PCA9450 BUCK ENMODE bits */ > > > > #define BUCK_ENMODE_OFF 0x00 > > > > #define BUCK_ENMODE_ONREQ 0x01 > > > > > > > > > > > > > > > -- > > > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany > > > Amtsgericht München, HRB 105018 > > > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider > > > http://www/ > > > .tq-%2F&data=05%7C01%7Cjoy.zou%40nxp.com%7C19989354bc054cffbfc > b08db7 > > > > d59888c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63824159 > 5727354 > > > > 598%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMz > IiLCJB > > > > TiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=HBR3huCMS9N > UdrmUBfs > > > rbzr0Rlfy43g8i8ZH2v6blYw%3D&reserved=0 > > > > group.com%2F&data=05%7C01%7Cjoy.zou%40nxp.com%7C1ecbe75c432d464 > > > > cb45f08db61cb08bc%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 > > > > C638211296883052738%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > > > > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% > > > > 7C&sdata=mz7vtBiDvAxY9FO7tTZO3oPBA8zvYS6f8hLgAwrU8uk%3D&reserved > > > =0 > > > > > > > > > > > > > -- > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany > Amtsgericht München, HRB 105018 > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider > http://www.tq-/ > group.com%2F&data=05%7C01%7Cjoy.zou%40nxp.com%7C19989354bc054cf > fbfcb08db7d59888c%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 > C638241595727354598%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% > 7C&sdata=D71%2FiRInAUfBu2F32j4579TV0hwqMAWjM5gf%2Fx3xxdM%3D&r > eserved=0 >
On Mon, Jul 17, 2023 at 09:53:15AM +0000, Joy Zou wrote: > > > -----Original Message----- > > From: Alexander Stein <alexander.stein@ew.tq-group.com> > > Sent: 2023年7月5日 21:13 > > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > > broonie@kernel.org; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > > linux-arm-kernel@lists.infradead.org; Joy Zou <joy.zou@nxp.com> > > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org > > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a support Please delete unneeded context from mails when replying. Doing this makes it much easier to find your reply in the message, helping ensure it won't be missed by people scrolling through the irrelevant quoted material.
> -----Original Message----- > From: Mark Brown <broonie@kernel.org> > Sent: 2023年7月17日 21:33 > To: Joy Zou <joy.zou@nxp.com> > Cc: Alexander Stein <alexander.stein@ew.tq-group.com>; Jacky Bai > <ping.bai@nxp.com>; lgirdwood@gmail.com; robh+dt@kernel.org; > krzysztof.kozlowski+dt@linaro.org; conor+dt@kernel.org; > shawnguo@kernel.org; s.hauer@pengutronix.de; > linux-arm-kernel@lists.infradead.org; kernel@pengutronix.de; > festevam@gmail.com; dl-linux-imx <linux-imx@nxp.com>; > devicetree@vger.kernel.org; linux-kernel@vger.kernel.org > Subject: Re: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > support > > On Mon, Jul 17, 2023 at 09:53:15AM +0000, Joy Zou wrote: > > > > > -----Original Message----- > > > From: Alexander Stein <alexander.stein@ew.tq-group.com> > > > Sent: 2023年7月5日 21:13 > > > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > > > broonie@kernel.org; robh+dt@kernel.org; > > > krzysztof.kozlowski+dt@linaro.org; > > > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > > > linux-arm-kernel@lists.infradead.org; Joy Zou <joy.zou@nxp.com> > > > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > > > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > > > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org > > > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > > support > > Please delete unneeded context from mails when replying. Doing this makes > it much easier to find your reply in the message, helping ensure it won't be > missed by people scrolling through the irrelevant quoted material. Thanks your kind reminder. I have deleted unneeded context and reply again. It can be more clearer. BR Joy Zou
Hi, Am Dienstag, 1. August 2023, 12:17:20 CEST schrieb Joy Zou: > > -----Original Message----- > > From: Alexander Stein > > <alexander.stein@ew.tq-group.com<mailto:alexander.stein@ew.tq-group.com>> > > Sent: 2023年7月5日 21:13 > > To: Jacky Bai <ping.bai@nxp.com<mailto:ping.bai@nxp.com>>; > > lgirdwood@gmail.com<mailto:lgirdwood@gmail.com>; > > broonie@kernel.org<mailto:broonie@kernel.org>; > > robh+dt@kernel.org<mailto:robh+dt@kernel.org>; > > krzysztof.kozlowski+dt@linaro.org<mailto:krzysztof.kozlowski+dt@linaro.or > > g>; conor+dt@kernel.org<mailto:conor+dt@kernel.org>; > > shawnguo@kernel.org<mailto:shawnguo@kernel.org>; > > s.hauer@pengutronix.de<mailto:s.hauer@pengutronix.de>; > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lists.infrad > > ead.org>; Joy Zou <joy.zou@nxp.com<mailto:joy.zou@nxp.com>> Cc: > > kernel@pengutronix.de<mailto:kernel@pengutronix.de>; > > festevam@gmail.com<mailto:festevam@gmail.com>; dl-linux-imx > > <linux-imx@nxp.com<mailto:linux-imx@nxp.com>>; > > devicetree@vger.kernel.org<mailto:devicetree@vger.kernel.org>; > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lists.infrad > > ead.org>; > > linux-kernel@vger.kernel.org<mailto:linux-kernel@vger.kernel.org> > > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > support> > > > > > > Caution: This is an external email. Please take care when clicking links > > or opening attachments. When in doubt, report the message using the > > 'Report this email' button > > > > > > > > > > Hello, > > > > > > > > Am Mittwoch, 5. Juli 2023, 08:50:24 CEST schrieb Joy Zou: > > > > > > > > > > > > -----Original Message----- > > > > From: Alexander Stein > > > > <alexander.stein@ew.tq-group.com<mailto:alexander.stein@ew.tq-group.c > > > > om>> Sent: 2023年5月31日 19:35 > > > > To: Jacky Bai <ping.bai@nxp.com<mailto:ping.bai@nxp.com>>; > > > > lgirdwood@gmail.com<mailto:lgirdwood@gmail.com>; > > > > broonie@kernel.org<mailto:broonie@kernel.org>; > > > > robh+dt@kernel.org<mailto:robh+dt@kernel.org>; > > > > krzysztof.kozlowski+dt@linaro.org<mailto:krzysztof.kozlowski+dt@linar > > > > o.org>; conor+dt@kernel.org<mailto:conor+dt@kernel.org>; > > > > shawnguo@kernel.org<mailto:shawnguo@kernel.org>; > > > > s.hauer@pengutronix.de<mailto:s.hauer@pengutronix.de>; > > > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lists.in > > > > fradead.org> Cc: kernel@pengutronix.de<mailto:kernel@pengutronix.de>; > > > > festevam@gmail.com<mailto:festevam@gmail.com>; dl-linux-imx > > > > <linux-imx@nxp.com<mailto:linux-imx@nxp.com>>; > > > > devicetree@vger.kernel.org<mailto:devicetree@vger.kernel.org>; > > > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lists.in > > > > fradead.org>; > > > > linux-kernel@vger.kernel.org<mailto:linux-kernel@vger.kernel.org>; > > > > Joy Zou > > > > <joy.zou@nxp.com<mailto:joy.zou@nxp.com>> > > > > > > Subject: Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > > > support > > > > > > > > > > > > > > > > Hi, > > > > > > > > > @@ -104,7 +104,15 @@ static const struct regulator_ops > > > > > pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) > > > > > > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > > > > > > static const struct linear_range pca9450_dvs_buck_volts[] = { > > > > > > > > > > > > > > > > > > > > - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > > > > > + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), }; > > > > > + > > > > > +/* > > > > > + * BUCK1/3 > > > > > + * 0.65 to 2.2375V (12.5mV step) > > > > > > > > > > > > > > > > > > > > > > > > Reading this comment, it seems the same distinction needs to be done > > > > for > > > > BUCK3 as well, no? > > > > > > > > > > > > Sorry for the late reply! > > > The BUCK1 and BUCK3 are dual phase, so don't need to be done for BUCK3. > > > > > > > > > > > > > > > > > > > > > > > > > > + */ > > > > > +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { > > > > > + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), > > > > > > > > > > > > > > > > > > > > }; > > > > > > > > @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct i2c_client > > > > > *i2c) > > > > > > > > > > > > > > > > > > > > const struct pca9450_regulator_desc *regulator_desc; > > > > > struct regulator_config config = { }; > > > > > struct pca9450 *pca9450; > > > > > > > > > > > > > > > > > > > > - unsigned int device_id, i; > > > > > + unsigned int device_id, i, val; > > > > > > > > > > > > > > > > > > > > unsigned int reset_ctrl; > > > > > > > > > > > > > > > > > > > > + bool pmic_trim = false; > > > > > > > > > > > > > > > > > > > > int ret; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > if (!i2c->irq) { > > > > > > > > > > > > > > > > > > > > @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct > > > > > i2c_client > > > > > *i2c) > > > > > > > > > > > > > > > > > > > > if (!pca9450) > > > > > > > > > > > > > > > > > > > > return -ENOMEM; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + pca9450->regmap = devm_regmap_init_i2c(i2c, > > > > > + > > > > > > > > > > > > > > > > &pca9450_regmap_config); > > > > > > > > > > > > > > > > > + if (IS_ERR(pca9450->regmap)) { > > > > > + dev_err(&i2c->dev, "regmap initialization failed\n"); > > > > > + return PTR_ERR(pca9450->regmap); > > > > > + } > > > > > + > > > > > + ret = regmap_read(pca9450->regmap, PCA9450_REG_PWRCTRL, > > > > > > > > > > > > > > > > &val); > > > > > > > > > > > > > > > > > + if (ret) { > > > > > + dev_err(&i2c->dev, "Read device id error\n"); > > > > > + return ret; > > > > > + } > > > > > + > > > > > + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) > > > > > + pmic_trim = true; > > > > > > > > > > > > > > > > > > > > > > > > PCA9450_REG_PWRCTRL is a read/write register. How is it possible to > > > > detect a chip revision using a bit which can be changed by software > > > > e.g. > > > > bootloader? Despite that this bit sets debounce time for > > > > PMIC_ON_REQ, how is this related to BUCK1 voltage range? > > > > > > > > > > > > There are old and new two kind PMIC pca9451a. > > > > > > > > There is only one part mentioned in the ordering options. How can I > > distinguish them? Any chip ID, date codes, markings? > > Yes, there is only one part. We distinguish the new and old part by this > bit Toff_Deb of PCA9450_REG_PWRCTRL reset value. The reset value 0 means > it's old part, and the reset value 1 means it's new part. Is the "old" part by coincidence an unofficial prerelease/sample chip? > > > > > > > This bit sets debounce time in > > > PCA9450_REG_PWRCTRL was set different value by hardware in order to > > > only distinguish the old and new PMIC. This bit isn't related to the > > > BUCK1 voltage range. If the pmic_trim is true that means it's new > > > pca9451a. > > > > > > > But this bit is writable. How do you know it has not been modified since > > reset? > Yes, we don't consider modify the debounce bit case. Modify the Toff_deb > value will influence the old and new part judgement. This judgement seems broken to me. How can I know offline whether I have old or new parts? I would like to know if there is a difference on some my boards. > For example, this default value of Toff_deb is 1 in the new part, if the > customers change the Toff_deb value from 1 to 0, and then make the board > warm reset, the Toff_deb value still keep 0, if the Toff_deb value is 0, > the PMIC driver will think this part is old part. But this part is new part > in fact. This should show you it's a bad idea to decide the chip revision depending on Toff_deb. > Have discussed this issue with our internal team member, we will add a note > to PCA9451 datasheet – “Please contract NXP If you want to change > Toff_deb.” But till now, we am not aware any customers case which need to > adjust Toff_deb. > > Make it more clear: If customers do need to manually adjust Toff_deb, It > need PMIC driver update to bypass this bit check and directly apply > corresponding voltage config table old or new. Thank you very much for your > comments and efforts. In this case I need to know if I use old, new or both revision of these parts. Best regards, Alexander
> -----Original Message----- > From: Alexander Stein <alexander.stein@ew.tq-group.com> > Sent: 2023年10月17日 22:02 > To: Jacky Bai <ping.bai@nxp.com>; lgirdwood@gmail.com; > broonie@kernel.org; robh+dt@kernel.org; krzysztof.kozlowski+dt@linaro.org; > conor+dt@kernel.org; shawnguo@kernel.org; s.hauer@pengutronix.de; > linux-arm-kernel@lists.infradead.org; Joy Zou <joy.zou@nxp.com> > Cc: kernel@pengutronix.de; festevam@gmail.com; dl-linux-imx > <linux-imx@nxp.com>; devicetree@vger.kernel.org; > linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a support > > Caution: This is an external email. Please take care when clicking links or > opening attachments. When in doubt, report the message using the 'Report > this email' button > > > Hi, > > Am Dienstag, 1. August 2023, 12:17:20 CEST schrieb Joy Zou: > > > -----Original Message----- > > > From: Alexander Stein > > > <alexander.stein@ew.tq-group.com<mailto:alexander.stein@ew.tq-group. > > > com>> > > > > Sent: 2023年7月5日 21:13 > > > To: Jacky Bai <ping.bai@nxp.com<mailto:ping.bai@nxp.com>>; > > > lgirdwood@gmail.com<mailto:lgirdwood@gmail.com>; > > > broonie@kernel.org<mailto:broonie@kernel.org>; > > > robh+dt@kernel.org<mailto:robh+dt@kernel.org>; > > > krzysztof.kozlowski+dt@linaro.org<mailto:krzysztof.kozlowski+dt@lina > > > ro.or > > > g>; conor+dt@kernel.org<mailto:conor+dt@kernel.org>; > > > shawnguo@kernel.org<mailto:shawnguo@kernel.org>; > > > s.hauer@pengutronix.de<mailto:s.hauer@pengutronix.de>; > > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lists.i > > > nfrad ead.org>; Joy Zou <joy.zou@nxp.com<mailto:joy.zou@nxp.com>> > > > Cc: > > > kernel@pengutronix.de<mailto:kernel@pengutronix.de>; > > > festevam@gmail.com<mailto:festevam@gmail.com>; dl-linux-imx > > > <linux-imx@nxp.com<mailto:linux-imx@nxp.com>>; > > > devicetree@vger.kernel.org<mailto:devicetree@vger.kernel.org>; > > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lists.i > > > nfrad > > > ead.org>; > > > linux-kernel@vger.kernel.org<mailto:linux-kernel@vger.kernel.org> > > > Subject: [EXT] Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > > support> > > > > > > > > > Caution: This is an external email. Please take care when clicking > > > links or > opening attachments. When in doubt, report the message using the > > > 'Report this email' button > > > > > > > > > > > > > > > Hello, > > > > > > > > > > > > Am Mittwoch, 5. Juli 2023, 08:50:24 CEST schrieb Joy Zou: > > > > > > > > > > > > > > > > -----Original Message----- > > > > > From: Alexander Stein > > > > > <alexander.stein@ew.tq-group.com<mailto:alexander.stein@ew.tq-gr > > > > > oup.c > > > > > om>> > Sent: 2023年5月31日 19:35 > > > > > To: Jacky Bai <ping.bai@nxp.com<mailto:ping.bai@nxp.com>>; > > > > > lgirdwood@gmail.com<mailto:lgirdwood@gmail.com>; > > > > > broonie@kernel.org<mailto:broonie@kernel.org>; > > > > > robh+dt@kernel.org<mailto:robh+dt@kernel.org>; > > > > > krzysztof.kozlowski+dt@linaro.org<mailto:krzysztof.kozlowski+dt@ > > > > > linar o.org>; conor+dt@kernel.org<mailto:conor+dt@kernel.org>; > > > > > shawnguo@kernel.org<mailto:shawnguo@kernel.org>; > > > > > s.hauer@pengutronix.de<mailto:s.hauer@pengutronix.de>; > > > > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lis > > > > > ts.in fradead.org> Cc: > > > > > kernel@pengutronix.de<mailto:kernel@pengutronix.de>; > > > > > festevam@gmail.com<mailto:festevam@gmail.com>; dl-linux-imx > > > > > <linux-imx@nxp.com<mailto:linux-imx@nxp.com>>; > > > > > devicetree@vger.kernel.org<mailto:devicetree@vger.kernel.org>; > > > > > linux-arm-kernel@lists.infradead.org<mailto:linux-arm-kernel@lis > > > > > ts.in > > > > > fradead.org>; > > > > > linux-kernel@vger.kernel.org<mailto:linux-kernel@vger.kernel.org > > > > > >; > > > > > Joy Zou > > > > > > <joy.zou@nxp.com<mailto:joy.zou@nxp.com>> > > > > > > > > Subject: Re: [PATCH v1 2/3] regulator: pca9450: add pca9451a > > > > > support > > > > > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > @@ -104,7 +104,15 @@ static const struct regulator_ops > > > > > > pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) > > > > > > > > > > > > > > > > > > > > > > > > */ > > > > > > > > > > > > > > > > > > > > > > > > static const struct linear_range pca9450_dvs_buck_volts[] = { > > > > > > > > > > > > > > > > > > > > > > > > - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), > > > > > > + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), }; > > > > > > + > > > > > > +/* > > > > > > + * BUCK1/3 > > > > > > + * 0.65 to 2.2375V (12.5mV step) > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Reading this comment, it seems the same distinction needs to be > > > > > done for > > > > > BUCK3 as well, no? > > > > > > > > > > > > > > > > Sorry for the late reply! > > > > The BUCK1 and BUCK3 are dual phase, so don't need to be done for > BUCK3. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + */ > > > > > > +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { > > > > > > + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), > > > > > > > > > > > > > > > > > > > > > > > > }; > > > > > > > > > > > > @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct > > > > > > i2c_client > > > > > > *i2c) > > > > > > > > > > > > > > > > > > > > > > > > const struct pca9450_regulator_desc *regulator_desc; > > > > > > struct regulator_config config = { }; > > > > > > struct pca9450 *pca9450; > > > > > > > > > > > > > > > > > > > > > > > > - unsigned int device_id, i; > > > > > > + unsigned int device_id, i, val; > > > > > > > > > > > > > > > > > > > > > > > > unsigned int reset_ctrl; > > > > > > > > > > > > > > > > > > > > > > > > + bool pmic_trim = false; > > > > > > > > > > > > > > > > > > > > > > > > int ret; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > if (!i2c->irq) { > > > > > > > > > > > > > > > > > > > > > > > > @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct > > > > > > i2c_client > > > > > > *i2c) > > > > > > > > > > > > > > > > > > > > > > > > if (!pca9450) > > > > > > > > > > > > > > > > > > > > > > > > return -ENOMEM; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > + pca9450->regmap = devm_regmap_init_i2c(i2c, > > > > > > + > > > > > > > > > > > > > > > > > > > > &pca9450_regmap_config); > > > > > > > > > > > > > > > > > > > > > + if (IS_ERR(pca9450->regmap)) { > > > > > > + dev_err(&i2c->dev, "regmap initialization failed\n"); > > > > > > + return PTR_ERR(pca9450->regmap); > > > > > > + } > > > > > > + > > > > > > + ret = regmap_read(pca9450->regmap, > PCA9450_REG_PWRCTRL, > > > > > > > > > > > > > > > > > > > > &val); > > > > > > > > > > > > > > > > > > > > > + if (ret) { > > > > > > + dev_err(&i2c->dev, "Read device id error\n"); > > > > > > + return ret; > > > > > > + } > > > > > > + > > > > > > + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) > > > > > > + pmic_trim = true; > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > PCA9450_REG_PWRCTRL is a read/write register. How is it possible > > > > > to detect a chip revision using a bit which can be changed by > > > > > software e.g. > > > > > bootloader? Despite that this bit sets debounce time for > > > > > PMIC_ON_REQ, how is this related to BUCK1 voltage range? > > > > > > > > > > > > > > > > There are old and new two kind PMIC pca9451a. > > > > > > > > > > > > There is only one part mentioned in the ordering options. How can I > > > distinguish them? Any chip ID, date codes, markings? > > > > Yes, there is only one part. We distinguish the new and old part by > > this bit > Toff_Deb of PCA9450_REG_PWRCTRL reset value. The reset value 0 means > > it's old part, and the reset value 1 means it's new part. > > Is the "old" part by coincidence an unofficial prerelease/sample chip? Yes, the "old" part is sample chip for the customer. > > > > > > > > > > > This bit sets debounce time in > > > > PCA9450_REG_PWRCTRL was set different value by hardware in order > > > > to only distinguish the old and new PMIC. This bit isn't related > > > > to the > > > > BUCK1 voltage range. If the pmic_trim is true that means it's new > > > > pca9451a. > > > > > > > > > > > But this bit is writable. How do you know it has not been modified > > > since reset? > > Yes, we don't consider modify the debounce bit case. Modify the > > Toff_deb value > will influence the old and new part judgement. > > This judgement seems broken to me. How can I know offline whether I have > old or new parts? I would like to know if there is a difference on some my > boards. Yes, We can't differentiate the old and new parts offline. there is no difference on some my boards. So we select the register bit default value as the check value. Unfortunately, the register is readable and writable. > > > For example, this default value of Toff_deb is 1 in the new part, if > > the customers > change the Toff_deb value from 1 to 0, and then make the board > > warm reset, the Toff_deb value still keep 0, if the Toff_deb value is > > 0, the PMIC driver will think this part is old part. But this part is > > new part in fact. > > This should show you it's a bad idea to decide the chip revision depending on > Toff_deb. Yes, I think so, so we have discussed that we firstly only new pmic. We will bypass the register bit check. And send new patch again. > > > Have discussed this issue with our internal team member, we will add a > > note to PCA9451 > datasheet – “Please contract NXP If you want to change > > Toff_deb.” But till now, we am not aware any customers case which need > > to adjust Toff_deb. > > > > Make it more clear: If customers do need to manually adjust Toff_deb, > > It need PMIC driver > update to bypass this bit check and directly apply > > corresponding voltage config table old or new. Thank you very much for > > your comments and efforts. > > In this case I need to know if I use old, new or both revision of these parts. For the user, you don't need to know the revision. There is no function difference about different version. Thank you very much for your comments and efforts. BR Joy Zou > > Best regards, > Alexander > -- > TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany > Amtsgericht München, HRB 105018 > Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider > http://www.tq-/ > group.com%2F&data=05%7C01%7Cjoy.zou%40nxp.com%7C7195b18abca549c > 7afa208dbcf19a8c9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 > C638331481351694496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAw > MDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C% > 7C&sdata=9SxW%2FUPpKWt0HIUsPoQ54ykworKw7gOZIhKsHfEPZS0%3D&rese > rved=0 >
diff --git a/drivers/regulator/pca9450-regulator.c b/drivers/regulator/pca9450-regulator.c index 91bfb7e026c9..654aa4fbe494 100644 --- a/drivers/regulator/pca9450-regulator.c +++ b/drivers/regulator/pca9450-regulator.c @@ -104,7 +104,15 @@ static const struct regulator_ops pca9450_ldo_regulator_ops = { * 0.60 to 2.1875V (12.5mV step) */ static const struct linear_range pca9450_dvs_buck_volts[] = { - REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), + REGULATOR_LINEAR_RANGE(600000, 0x00, 0x7F, 12500), +}; + +/* + * BUCK1/3 + * 0.65 to 2.2375V (12.5mV step) + */ +static const struct linear_range pca9450_trim_dvs_buck_volts[] = { + REGULATOR_LINEAR_RANGE(650000, 0x00, 0x7F, 12500), }; /* @@ -663,6 +671,207 @@ static const struct pca9450_regulator_desc pca9450bc_regulators[] = { }, }; +static const struct pca9450_regulator_desc pca9451a_regulators[] = { + { + .desc = { + .name = "buck1", + .of_match = of_match_ptr("BUCK1"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_BUCK1, + .ops = &pca9450_dvs_buck_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, + .linear_ranges = pca9450_dvs_buck_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_dvs_buck_volts), + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, + .vsel_mask = BUCK1OUT_DVS0_MASK, + .enable_reg = PCA9450_REG_BUCK1CTRL, + .enable_mask = BUCK1_ENMODE_MASK, + .enable_val = BUCK_ENMODE_ONREQ, + .ramp_mask = BUCK1_RAMP_MASK, + .ramp_delay_table = pca9450_dvs_buck_ramp_table, + .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), + .owner = THIS_MODULE, + .of_parse_cb = pca9450_set_dvs_levels, + }, + .dvs = { + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, + .run_mask = BUCK1OUT_DVS0_MASK, + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, + .standby_mask = BUCK1OUT_DVS1_MASK, + }, + }, + { + .desc = { + .name = "buck1_trim", + .of_match = of_match_ptr("BUCK1"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_BUCK1, + .ops = &pca9450_dvs_buck_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_BUCK1_VOLTAGE_NUM, + .linear_ranges = pca9450_trim_dvs_buck_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_trim_dvs_buck_volts), + .vsel_reg = PCA9450_REG_BUCK1OUT_DVS0, + .vsel_mask = BUCK1OUT_DVS0_MASK, + .enable_reg = PCA9450_REG_BUCK1CTRL, + .enable_mask = BUCK1_ENMODE_MASK, + .enable_val = BUCK_ENMODE_ONREQ, + .ramp_mask = BUCK1_RAMP_MASK, + .ramp_delay_table = pca9450_dvs_buck_ramp_table, + .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), + .owner = THIS_MODULE, + .of_parse_cb = pca9450_set_dvs_levels, + }, + .dvs = { + .run_reg = PCA9450_REG_BUCK1OUT_DVS0, + .run_mask = BUCK1OUT_DVS0_MASK, + .standby_reg = PCA9450_REG_BUCK1OUT_DVS1, + .standby_mask = BUCK1OUT_DVS1_MASK, + }, + }, + { + .desc = { + .name = "buck2", + .of_match = of_match_ptr("BUCK2"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_BUCK2, + .ops = &pca9450_dvs_buck_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_BUCK2_VOLTAGE_NUM, + .linear_ranges = pca9450_dvs_buck_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_dvs_buck_volts), + .vsel_reg = PCA9450_REG_BUCK2OUT_DVS0, + .vsel_mask = BUCK2OUT_DVS0_MASK, + .enable_reg = PCA9450_REG_BUCK2CTRL, + .enable_mask = BUCK2_ENMODE_MASK, + .enable_val = BUCK_ENMODE_ONREQ_STBYREQ, + .ramp_mask = BUCK2_RAMP_MASK, + .ramp_delay_table = pca9450_dvs_buck_ramp_table, + .n_ramp_values = ARRAY_SIZE(pca9450_dvs_buck_ramp_table), + .owner = THIS_MODULE, + .of_parse_cb = pca9450_set_dvs_levels, + }, + .dvs = { + .run_reg = PCA9450_REG_BUCK2OUT_DVS0, + .run_mask = BUCK2OUT_DVS0_MASK, + .standby_reg = PCA9450_REG_BUCK2OUT_DVS1, + .standby_mask = BUCK2OUT_DVS1_MASK, + }, + }, + { + .desc = { + .name = "buck4", + .of_match = of_match_ptr("BUCK4"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_BUCK4, + .ops = &pca9450_buck_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_BUCK4_VOLTAGE_NUM, + .linear_ranges = pca9450_buck_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_buck_volts), + .vsel_reg = PCA9450_REG_BUCK4OUT, + .vsel_mask = BUCK4OUT_MASK, + .enable_reg = PCA9450_REG_BUCK4CTRL, + .enable_mask = BUCK4_ENMODE_MASK, + .enable_val = BUCK_ENMODE_ONREQ, + .owner = THIS_MODULE, + }, + }, + { + .desc = { + .name = "buck5", + .of_match = of_match_ptr("BUCK5"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_BUCK5, + .ops = &pca9450_buck_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_BUCK5_VOLTAGE_NUM, + .linear_ranges = pca9450_buck_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_buck_volts), + .vsel_reg = PCA9450_REG_BUCK5OUT, + .vsel_mask = BUCK5OUT_MASK, + .enable_reg = PCA9450_REG_BUCK5CTRL, + .enable_mask = BUCK5_ENMODE_MASK, + .enable_val = BUCK_ENMODE_ONREQ, + .owner = THIS_MODULE, + }, + }, + { + .desc = { + .name = "buck6", + .of_match = of_match_ptr("BUCK6"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_BUCK6, + .ops = &pca9450_buck_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_BUCK6_VOLTAGE_NUM, + .linear_ranges = pca9450_buck_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_buck_volts), + .vsel_reg = PCA9450_REG_BUCK6OUT, + .vsel_mask = BUCK6OUT_MASK, + .enable_reg = PCA9450_REG_BUCK6CTRL, + .enable_mask = BUCK6_ENMODE_MASK, + .enable_val = BUCK_ENMODE_ONREQ, + .owner = THIS_MODULE, + }, + }, + { + .desc = { + .name = "ldo1", + .of_match = of_match_ptr("LDO1"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_LDO1, + .ops = &pca9450_ldo_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_LDO1_VOLTAGE_NUM, + .linear_ranges = pca9450_ldo1_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo1_volts), + .vsel_reg = PCA9450_REG_LDO1CTRL, + .vsel_mask = LDO1OUT_MASK, + .enable_reg = PCA9450_REG_LDO1CTRL, + .enable_mask = LDO1_EN_MASK, + .owner = THIS_MODULE, + }, + }, + { + .desc = { + .name = "ldo4", + .of_match = of_match_ptr("LDO4"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_LDO4, + .ops = &pca9450_ldo_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_LDO4_VOLTAGE_NUM, + .linear_ranges = pca9450_ldo34_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo34_volts), + .vsel_reg = PCA9450_REG_LDO4CTRL, + .vsel_mask = LDO4OUT_MASK, + .enable_reg = PCA9450_REG_LDO4CTRL, + .enable_mask = LDO4_EN_MASK, + .owner = THIS_MODULE, + }, + }, + { + .desc = { + .name = "ldo5", + .of_match = of_match_ptr("LDO5"), + .regulators_node = of_match_ptr("regulators"), + .id = PCA9450_LDO5, + .ops = &pca9450_ldo_regulator_ops, + .type = REGULATOR_VOLTAGE, + .n_voltages = PCA9450_LDO5_VOLTAGE_NUM, + .linear_ranges = pca9450_ldo5_volts, + .n_linear_ranges = ARRAY_SIZE(pca9450_ldo5_volts), + .vsel_reg = PCA9450_REG_LDO5CTRL_H, + .vsel_mask = LDO5HOUT_MASK, + .enable_reg = PCA9450_REG_LDO5CTRL_H, + .enable_mask = LDO5H_EN_MASK, + .owner = THIS_MODULE, + }, + }, +}; + static irqreturn_t pca9450_irq_handler(int irq, void *data) { struct pca9450 *pca9450 = data; @@ -708,8 +917,9 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) const struct pca9450_regulator_desc *regulator_desc; struct regulator_config config = { }; struct pca9450 *pca9450; - unsigned int device_id, i; + unsigned int device_id, i, val; unsigned int reset_ctrl; + bool pmic_trim = false; int ret; if (!i2c->irq) { @@ -721,6 +931,22 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) if (!pca9450) return -ENOMEM; + pca9450->regmap = devm_regmap_init_i2c(i2c, + &pca9450_regmap_config); + if (IS_ERR(pca9450->regmap)) { + dev_err(&i2c->dev, "regmap initialization failed\n"); + return PTR_ERR(pca9450->regmap); + } + + ret = regmap_read(pca9450->regmap, PCA9450_REG_PWRCTRL, &val); + if (ret) { + dev_err(&i2c->dev, "Read device id error\n"); + return ret; + } + + if (val & PCA9450_REG_PWRCTRL_TOFF_DEB) + pmic_trim = true; + switch (type) { case PCA9450_TYPE_PCA9450A: regulator_desc = pca9450a_regulators; @@ -730,6 +956,10 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) regulator_desc = pca9450bc_regulators; pca9450->rcnt = ARRAY_SIZE(pca9450bc_regulators); break; + case PCA9450_TYPE_PCA9451A: + regulator_desc = pca9451a_regulators; + pca9450->rcnt = ARRAY_SIZE(pca9451a_regulators); + break; default: dev_err(&i2c->dev, "Unknown device type"); return -EINVAL; @@ -741,13 +971,6 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) dev_set_drvdata(&i2c->dev, pca9450); - pca9450->regmap = devm_regmap_init_i2c(i2c, - &pca9450_regmap_config); - if (IS_ERR(pca9450->regmap)) { - dev_err(&i2c->dev, "regmap initialization failed\n"); - return PTR_ERR(pca9450->regmap); - } - ret = regmap_read(pca9450->regmap, PCA9450_REG_DEV_ID, &device_id); if (ret) { dev_err(&i2c->dev, "Read device id error\n"); @@ -756,7 +979,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) /* Check your board and dts for match the right pmic */ if (((device_id >> 4) != 0x1 && type == PCA9450_TYPE_PCA9450A) || - ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC)) { + ((device_id >> 4) != 0x3 && type == PCA9450_TYPE_PCA9450BC) || + ((device_id >> 4) != 0x9 && type == PCA9450_TYPE_PCA9451A)) { dev_err(&i2c->dev, "Device id(%x) mismatched\n", device_id >> 4); return -EINVAL; @@ -767,7 +991,16 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) struct regulator_dev *rdev; const struct pca9450_regulator_desc *r; - r = ®ulator_desc[i]; + if (type == PCA9450_TYPE_PCA9451A && + !strcmp((®ulator_desc[i])->desc.name, "buck1") && pmic_trim) { + r = ®ulator_desc[i + 1]; + i = i + 1; + } else if (type == PCA9450_TYPE_PCA9451A && + !strcmp((®ulator_desc[i])->desc.name, "buck1")) { + r = ®ulator_desc[i]; + i = i + 1; + } else + r = ®ulator_desc[i]; desc = &r->desc; config.regmap = pca9450->regmap; @@ -847,7 +1080,8 @@ static int pca9450_i2c_probe(struct i2c_client *i2c) } dev_info(&i2c->dev, "%s probed.\n", - type == PCA9450_TYPE_PCA9450A ? "pca9450a" : "pca9450bc"); + type == PCA9450_TYPE_PCA9450A ? "pca9450a" : + (type == PCA9450_TYPE_PCA9451A ? "pca9451a" : "pca9450bc")); return 0; } @@ -865,6 +1099,10 @@ static const struct of_device_id pca9450_of_match[] = { .compatible = "nxp,pca9450c", .data = (void *)PCA9450_TYPE_PCA9450BC, }, + { + .compatible = "nxp,pca9451a", + .data = (void *)PCA9450_TYPE_PCA9451A, + }, { } }; MODULE_DEVICE_TABLE(of, pca9450_of_match); diff --git a/include/linux/regulator/pca9450.h b/include/linux/regulator/pca9450.h index 3c01c2bf84f5..5dd79f52165a 100644 --- a/include/linux/regulator/pca9450.h +++ b/include/linux/regulator/pca9450.h @@ -9,6 +9,7 @@ enum pca9450_chip_type { PCA9450_TYPE_PCA9450A = 0, PCA9450_TYPE_PCA9450BC, + PCA9450_TYPE_PCA9451A, PCA9450_TYPE_AMOUNT, }; @@ -93,6 +94,7 @@ enum { PCA9450_MAX_REGISTER = 0x2F, }; +#define PCA9450_REG_PWRCTRL_TOFF_DEB BIT(5) /* PCA9450 BUCK ENMODE bits */ #define BUCK_ENMODE_OFF 0x00 #define BUCK_ENMODE_ONREQ 0x01