From nobody Thu Nov 28 00:52:22 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AD263C2F; Mon, 7 Oct 2024 00:14:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260095; cv=none; b=IvIluLsNRH1aFAt9ydWhSzwx+by3E2OzV5fxqmh/hDPX9Fnhu8sB4xHPyp5LZ8iSxT83LISfUVtful1BUJqBIChdi5Sqph8RyJiaeYyNUXCTH5o1moFrj04937bD9B4jZ36GRXTU0k++5tCvJ1Wu+wPcn1dbiiaKGxsa45ScrQo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260095; c=relaxed/simple; bh=F3MvYsqwn0fo9JQlrrxZFS9dBzp6tOLz4f0HKJr7jCA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gjexT2+ZvdCoSYl9McIYIcHcHyzX38oEZB8E1YsvbLnOPd52W0gwfpGu1t6IMSiWM4H+t/yjG7fOpth/CT13df7rbgcr0SQ+5IH5ari2VT9S83uPEkq3/bza4EPb1oOIJeOZQMdk9pHoss4bdxp+G87qvXQNNdHWAQvluTymqIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 303081007; Sun, 6 Oct 2024 17:15:22 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ECDA23F640; Sun, 6 Oct 2024 17:14:50 -0700 (PDT) From: Andre Przywara To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Liam Girdwood , Mark Brown Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Botka , Chris Morgan Subject: [PATCH v2 1/5] dt-bindings: mfd: x-powers,axp152: Document AXP323 Date: Mon, 7 Oct 2024 01:14:04 +0100 Message-ID: <20241007001408.27249-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com> References: <20241007001408.27249-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The X-Powers AXP323 is a PMIC used on some newer Allwinner devices. It is almost the same as the AXP313, but supports dual-phasing the first two DC/DC converters. A pure AXP313 driver wouldn't know about this, and might turn the linked DCDC2 regulator off, as it does not seem to be used. This makes the AXP323 incompatible to the AXP313a. Add the new compatible string, and treat it like the AXP313a. Signed-off-by: Andre Przywara Reviewed-by: Chen-Yu Tsai Acked-by: Rob Herring (Arm) --- Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml b/D= ocumentation/devicetree/bindings/mfd/x-powers,axp152.yaml index 14ab367fc8871..3f7661bdd2020 100644 --- a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml +++ b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml @@ -71,6 +71,7 @@ allOf: - x-powers,axp15060 - x-powers,axp305 - x-powers,axp313a + - x-powers,axp323 =20 then: required: @@ -82,6 +83,7 @@ allOf: contains: enum: - x-powers,axp313a + - x-powers,axp323 - x-powers,axp15060 - x-powers,axp717 =20 @@ -100,6 +102,7 @@ properties: - x-powers,axp221 - x-powers,axp223 - x-powers,axp313a + - x-powers,axp323 - x-powers,axp717 - x-powers,axp803 - x-powers,axp806 --=20 2.46.2 From nobody Thu Nov 28 00:52:22 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB3C14C98; Mon, 7 Oct 2024 00:14:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260096; cv=none; b=SJAWlVjTQvgcnOfzJLRg9kdMZyMrYurFJoxggGIW9dE4i8+/71IsIMpslD6ttbiQI4g9F/6lGEQgAQ72IU6HvP3wN5ZqaCcY/8AjYdhHSUA8EaLRy6v/ZAsku2Om9Nw4v1vjn4aboAtNRUY0ayNzqvxGzhHNxWqmuDaSKTERv28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260096; c=relaxed/simple; bh=DrkghZ9iCBPij4tMtQpGuKTetzJpES+lEVEwvbnLsWY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kWzNtQvdNEzjrTMeAXjNIi7bEr1hgAYUUe0YNnNd7dANGi972RU9GWNezjq2vpEf5qZxSzs7qmxfJlgTeeTmeshKA2YrBLiabAECxqFOQA5FTGatItiABO3nF51euUZ7dAQJUbMqUKC15Lo8W7HzOtzZu3oLNN4nm+qjHo2D5zY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1EE7CFEC; Sun, 6 Oct 2024 17:15:24 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7C5C3F640; Sun, 6 Oct 2024 17:14:52 -0700 (PDT) From: Andre Przywara To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Liam Girdwood , Mark Brown Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Botka , Chris Morgan Subject: [PATCH v2 2/5] mfd: axp20x: ensure relationship between IDs and model names Date: Mon, 7 Oct 2024 01:14:05 +0100 Message-ID: <20241007001408.27249-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com> References: <20241007001408.27249-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At the moment there is an implicit relationship between the AXP model IDs and the order of the strings in the axp20x_model_names[] array. This is fragile, and makes adding IDs in the middle error prone. Make this relationship official by changing the ID type to the actual enum used, and using indexed initialisers for the string list. Signed-off-by: Andre Przywara Reviewed-by: Chen-Yu Tsai --- drivers/mfd/axp20x.c | 30 ++++++++++++++-------------- drivers/regulator/axp20x-regulator.c | 2 +- include/linux/mfd/axp20x.h | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 4051551757f2d..5ceea359289f4 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -34,20 +34,20 @@ #define AXP806_REG_ADDR_EXT_ADDR_SLAVE_MODE BIT(4) =20 static const char * const axp20x_model_names[] =3D { - "AXP152", - "AXP192", - "AXP202", - "AXP209", - "AXP221", - "AXP223", - "AXP288", - "AXP313a", - "AXP717", - "AXP803", - "AXP806", - "AXP809", - "AXP813", - "AXP15060", + [AXP152_ID] =3D "AXP152", + [AXP192_ID] =3D "AXP192", + [AXP202_ID] =3D "AXP202", + [AXP209_ID] =3D "AXP209", + [AXP221_ID] =3D "AXP221", + [AXP223_ID] =3D "AXP223", + [AXP288_ID] =3D "AXP288", + [AXP313A_ID] =3D "AXP313a", + [AXP717_ID] =3D "AXP717", + [AXP803_ID] =3D "AXP803", + [AXP806_ID] =3D "AXP806", + [AXP809_ID] =3D "AXP809", + [AXP813_ID] =3D "AXP813", + [AXP15060_ID] =3D "AXP15060", }; =20 static const struct regmap_range axp152_writeable_ranges[] =3D { @@ -1345,7 +1345,7 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_irq_chip =3D &axp15060_regmap_irq_chip; break; default: - dev_err(dev, "unsupported AXP20X ID %lu\n", axp20x->variant); + dev_err(dev, "unsupported AXP20X ID %u\n", axp20x->variant); return -EINVAL; } =20 diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20= x-regulator.c index a8e91d9d028b8..3ba76dbd0fb9e 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -1597,7 +1597,7 @@ static int axp20x_regulator_probe(struct platform_dev= ice *pdev) nregulators =3D AXP15060_REG_ID_MAX; break; default: - dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n", + dev_err(&pdev->dev, "Unsupported AXP variant: %d\n", axp20x->variant); return -EINVAL; } diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index f4dfc1871a95b..79ecaaaa20703 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -959,7 +959,7 @@ struct axp20x_dev { unsigned long irq_flags; struct regmap *regmap; struct regmap_irq_chip_data *regmap_irqc; - long variant; + enum axp20x_variants variant; int nr_cells; const struct mfd_cell *cells; const struct regmap_config *regmap_cfg; --=20 2.46.2 From nobody Thu Nov 28 00:52:22 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 010FD14267; Mon, 7 Oct 2024 00:14:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260098; cv=none; b=dNub63l9OrjPePo1Dscpk+bjJwbrL+FqQbJWpKxoC4IBzQn8ciitPjkM12/Z+py9/rYmE7UdXRKEn0nJHIcVXbnlUnf8FWWRSmyDsh1i6S815cRVK4DsG1+Aa+zmmzAmHTUqCg8EJi/xYAf1vwy4fR2INA0B9RBDtzIb42/ZlCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260098; c=relaxed/simple; bh=3EAE5Wl4zK8cef/TNe/paFWhmOnSq1SzHQhGAN0cUSM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lbdcnsq/bpDqj0MqRsfRhJADf240WHre+uzpMAXl3Vh6AXSVpxyA89ChbMeN4hMDFj4tct5EhlhyswkgvM1KzENW9bxS0912gi65JTVqjEIZc761h7hBxQ9/WMAFtgdMWn0MHbzB/B23r2AfYyDW8HoODJgEGH8lgYoxg+l8nds= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 06C131007; Sun, 6 Oct 2024 17:15:26 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C364D3F640; Sun, 6 Oct 2024 17:14:54 -0700 (PDT) From: Andre Przywara To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Liam Girdwood , Mark Brown Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Botka , Chris Morgan Subject: [PATCH v2 3/5] mfd: axp20x: Allow multiple regulators Date: Mon, 7 Oct 2024 01:14:06 +0100 Message-ID: <20241007001408.27249-4-andre.przywara@arm.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com> References: <20241007001408.27249-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" At the moment trying to register a second AXP chip makes the probe fail, as some sysfs registration fails due to a duplicate name: ... [ 3.688215] axp20x-i2c 0-0035: AXP20X driver loaded [ 3.695610] axp20x-i2c 0-0036: AXP20x variant AXP323 found [ 3.706151] sysfs: cannot create duplicate filename '/bus/platform/devic= es/axp20x-regulator' [ 3.714718] CPU: 0 UID: 0 PID: 1 Comm: swapper/0 Not tainted 6.12.0-rc1-= 00026-g50bf2e2c079d-dirty #192 [ 3.724020] Hardware name: Avaota A1 (DT) [ 3.728029] Call trace: [ 3.730477] dump_backtrace+0x94/0xec [ 3.734146] show_stack+0x18/0x24 [ 3.737462] dump_stack_lvl+0x80/0xf4 [ 3.741128] dump_stack+0x18/0x24 [ 3.744444] sysfs_warn_dup+0x64/0x80 [ 3.748109] sysfs_do_create_link_sd+0xf0/0xf8 [ 3.752553] sysfs_create_link+0x20/0x40 [ 3.756476] bus_add_device+0x64/0x104 [ 3.760229] device_add+0x310/0x760 [ 3.763717] platform_device_add+0x10c/0x238 [ 3.767990] mfd_add_device+0x4ec/0x5c8 [ 3.771829] mfd_add_devices+0x88/0x11c [ 3.775666] axp20x_device_probe+0x70/0x184 [ 3.779851] axp20x_i2c_probe+0x9c/0xd8 ... This is because we use PLATFORM_DEVID_NONE for the mfd_add_devices() call, which would number the child devices in the same 0-based way, even for the second (or any other) instance. Use PLATFORM_DEVID_AUTO instead, which automatically assigns non-conflicting device numbers. Signed-off-by: Andre Przywara Reviewed-by: Chen-Yu Tsai --- drivers/mfd/axp20x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 5ceea359289f4..bc08ae4332604 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -1419,7 +1419,7 @@ int axp20x_device_probe(struct axp20x_dev *axp20x) } } =20 - ret =3D mfd_add_devices(axp20x->dev, -1, axp20x->cells, + ret =3D mfd_add_devices(axp20x->dev, PLATFORM_DEVID_AUTO, axp20x->cells, axp20x->nr_cells, NULL, 0, NULL); =20 if (ret) { --=20 2.46.2 From nobody Thu Nov 28 00:52:22 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D93D918C22; Mon, 7 Oct 2024 00:14:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260100; cv=none; b=rdysMaCCjfJOvyPKNqIopPtqtOJnTE0vPmaS5WoDtwHauQL5Vp1/SRTllbzTtMdEiTojaoHSgZc6VINu9crhnZdOPitzzSSZL61z8e57sZBSEUB7D/t5kROP5GbAoGoeQ5ITIhCXKm2XdLDy7H3rGj6nFhtZw0YvHDy08kR2mLI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260100; c=relaxed/simple; bh=yLzQTkLZ+nr7Onps5le2X5ohuhcu6HMjNYjzkpsIgkY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pCeVWh5SPWTomG+7WWupyxZMtxUrAG90Ra8FVi4O2fe5Oroqxx/GbV8AwwQsNZAYIgTv1RRrya+5VcT6BbtQmlAFb0/5+3n5FsZxI+kFgSRE7TTui7L/Ndj5tCtI/6Qq282OoGH57ZBW7e813GV0U/F7xH3tqURvmBf1gScBaKs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id E6AAEFEC; Sun, 6 Oct 2024 17:15:27 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AE8CE3F640; Sun, 6 Oct 2024 17:14:56 -0700 (PDT) From: Andre Przywara To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Liam Girdwood , Mark Brown Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Botka , Chris Morgan Subject: [PATCH v2 4/5] mfd: axp20x: Add support for AXP323 Date: Mon, 7 Oct 2024 01:14:07 +0100 Message-ID: <20241007001408.27249-5-andre.przywara@arm.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com> References: <20241007001408.27249-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The X-Powers AXP323 is a very close sibling of the AXP313A. The only difference seems to be the ability to dual-phase the first two DC/DC converter, which adds another register. Add the required boilerplate to introduce a new PMIC to the AXP MFD driver. Where possible, this just maps into the existing structs defined for the AXP313A, only deviating where needed. Signed-off-by: Andre Przywara Reviewed-by: Chen-Yu Tsai --- drivers/mfd/axp20x-i2c.c | 1 + drivers/mfd/axp20x.c | 26 ++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 2 ++ 3 files changed, 29 insertions(+) diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c index 791a0b4cb64bb..5c93136f977e7 100644 --- a/drivers/mfd/axp20x-i2c.c +++ b/drivers/mfd/axp20x-i2c.c @@ -65,6 +65,7 @@ static const struct of_device_id axp20x_i2c_of_match[] = =3D { { .compatible =3D "x-powers,axp221", .data =3D (void *)AXP221_ID }, { .compatible =3D "x-powers,axp223", .data =3D (void *)AXP223_ID }, { .compatible =3D "x-powers,axp313a", .data =3D (void *)AXP313A_ID }, + { .compatible =3D "x-powers,axp323", .data =3D (void *)AXP323_ID }, { .compatible =3D "x-powers,axp717", .data =3D (void *)AXP717_ID }, { .compatible =3D "x-powers,axp803", .data =3D (void *)AXP803_ID }, { .compatible =3D "x-powers,axp806", .data =3D (void *)AXP806_ID }, diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index bc08ae4332604..251465a656d09 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -42,6 +42,7 @@ static const char * const axp20x_model_names[] =3D { [AXP223_ID] =3D "AXP223", [AXP288_ID] =3D "AXP288", [AXP313A_ID] =3D "AXP313a", + [AXP323_ID] =3D "AXP323", [AXP717_ID] =3D "AXP717", [AXP803_ID] =3D "AXP803", [AXP806_ID] =3D "AXP806", @@ -193,6 +194,10 @@ static const struct regmap_range axp313a_writeable_ran= ges[] =3D { regmap_reg_range(AXP313A_ON_INDICATE, AXP313A_IRQ_STATE), }; =20 +static const struct regmap_range axp323_writeable_ranges[] =3D { + regmap_reg_range(AXP313A_ON_INDICATE, AXP323_DCDC_MODE_CTRL2), +}; + static const struct regmap_range axp313a_volatile_ranges[] =3D { regmap_reg_range(AXP313A_SHUTDOWN_CTRL, AXP313A_SHUTDOWN_CTRL), regmap_reg_range(AXP313A_IRQ_STATE, AXP313A_IRQ_STATE), @@ -203,6 +208,11 @@ static const struct regmap_access_table axp313a_writea= ble_table =3D { .n_yes_ranges =3D ARRAY_SIZE(axp313a_writeable_ranges), }; =20 +static const struct regmap_access_table axp323_writeable_table =3D { + .yes_ranges =3D axp323_writeable_ranges, + .n_yes_ranges =3D ARRAY_SIZE(axp323_writeable_ranges), +}; + static const struct regmap_access_table axp313a_volatile_table =3D { .yes_ranges =3D axp313a_volatile_ranges, .n_yes_ranges =3D ARRAY_SIZE(axp313a_volatile_ranges), @@ -433,6 +443,15 @@ static const struct regmap_config axp313a_regmap_confi= g =3D { .cache_type =3D REGCACHE_MAPLE, }; =20 +static const struct regmap_config axp323_regmap_config =3D { + .reg_bits =3D 8, + .val_bits =3D 8, + .wr_table =3D &axp323_writeable_table, + .volatile_table =3D &axp313a_volatile_table, + .max_register =3D AXP323_DCDC_MODE_CTRL2, + .cache_type =3D REGCACHE_MAPLE, +}; + static const struct regmap_config axp717_regmap_config =3D { .reg_bits =3D 8, .val_bits =3D 8, @@ -1221,6 +1240,7 @@ static int axp20x_power_off(struct sys_off_data *data) unsigned int shutdown_reg; =20 switch (axp20x->variant) { + case AXP323_ID: case AXP313A_ID: shutdown_reg =3D AXP313A_SHUTDOWN_CTRL; break; @@ -1289,6 +1309,12 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_cfg =3D &axp313a_regmap_config; axp20x->regmap_irq_chip =3D &axp313a_regmap_irq_chip; break; + case AXP323_ID: + axp20x->nr_cells =3D ARRAY_SIZE(axp313a_cells); + axp20x->cells =3D axp313a_cells; + axp20x->regmap_cfg =3D &axp323_regmap_config; + axp20x->regmap_irq_chip =3D &axp313a_regmap_irq_chip; + break; case AXP717_ID: axp20x->nr_cells =3D ARRAY_SIZE(axp717_cells); axp20x->cells =3D axp717_cells; diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index 79ecaaaa20703..c3df0e615fbf4 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -19,6 +19,7 @@ enum axp20x_variants { AXP223_ID, AXP288_ID, AXP313A_ID, + AXP323_ID, AXP717_ID, AXP803_ID, AXP806_ID, @@ -113,6 +114,7 @@ enum axp20x_variants { #define AXP313A_SHUTDOWN_CTRL 0x1a #define AXP313A_IRQ_EN 0x20 #define AXP313A_IRQ_STATE 0x21 +#define AXP323_DCDC_MODE_CTRL2 0x22 =20 #define AXP717_ON_INDICATE 0x00 #define AXP717_PMU_STATUS_2 0x01 --=20 2.46.2 From nobody Thu Nov 28 00:52:22 2024 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 98F871C286; Mon, 7 Oct 2024 00:15:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260102; cv=none; b=DfD5NB/M9hdVQmKjv9EyEdPBfRUsMOWzLPpXagvk1LIPxvZ0zuQbAm0UheZu4iiE7TGmwWQn/Bjgp9XnjI6XPbqfqpe4pHzyCDe2wV48kyKOFLwSOZPOgFDxMYMGcFdzVihsDVBt4ejcWt9J+Lj0/EZMrg/8DaRclP3bSMUQUH0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728260102; c=relaxed/simple; bh=bec/01JxAr7IzhBCiOlqiK9tbhRVeNxlqYeVvOESsz0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=amE7XK5WZu8KZcDdqY0ZGSIjt2VUQbKXpV09kPHNPwEC8hAqN7jNM/a50w7PWuovfoi6rARthXtGBi0ZupVyFfjRFKIH3gg4qyhQdOYuqenvo7sgpFsu0ZjlIOMouyHlzbc/jiHIVjnTS5TS4p5MY7nixJbijOPiFj4B3DFsTnQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D233E1007; Sun, 6 Oct 2024 17:15:29 -0700 (PDT) Received: from localhost.localdomain (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9A1BC3F640; Sun, 6 Oct 2024 17:14:58 -0700 (PDT) From: Andre Przywara To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Liam Girdwood , Mark Brown Cc: devicetree@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Martin Botka , Chris Morgan Subject: [PATCH v2 5/5] regulator: axp20x: add support for the AXP323 Date: Mon, 7 Oct 2024 01:14:08 +0100 Message-ID: <20241007001408.27249-6-andre.przywara@arm.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241007001408.27249-1-andre.przywara@arm.com> References: <20241007001408.27249-1-andre.przywara@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The X-Powers AXP323 is a very close sibling of the AXP313A. The only difference seems to be the ability to dual-phase the first two DC/DC converters. Place the new AXP323 ID next to the existing AXP313A checks, to let them share most code. The only difference is the poly-phase detection code, which gets extended to check the respective bit in a newly used register. Signed-off-by: Andre Przywara Reviewed-by: Chen-Yu Tsai Reviewed-by: Mark Brown --- drivers/regulator/axp20x-regulator.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20= x-regulator.c index 3ba76dbd0fb9e..e3cc59b82ea61 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -1341,6 +1341,7 @@ static int axp20x_set_dcdc_freq(struct platform_devic= e *pdev, u32 dcdcfreq) step =3D 150; break; case AXP313A_ID: + case AXP323_ID: case AXP717_ID: case AXP15060_ID: /* The DCDC PWM frequency seems to be fixed to 3 MHz. */ @@ -1527,6 +1528,15 @@ static bool axp20x_is_polyphase_slave(struct axp20x_= dev *axp20x, int id) } break; =20 + case AXP323_ID: + regmap_read(axp20x->regmap, AXP323_DCDC_MODE_CTRL2, ®); + + switch (id) { + case AXP313A_DCDC2: + return !!(reg & BIT(1)); + } + break; + default: return false; } @@ -1565,6 +1575,7 @@ static int axp20x_regulator_probe(struct platform_dev= ice *pdev) "x-powers,drive-vbus-en"); break; case AXP313A_ID: + case AXP323_ID: regulators =3D axp313a_regulators; nregulators =3D AXP313A_REG_ID_MAX; break; --=20 2.46.2