From patchwork Mon Jan 16 14:24:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 44190 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1231786wrn; Mon, 16 Jan 2023 06:52:37 -0800 (PST) X-Google-Smtp-Source: AMrXdXs8FLe3iw2KhUQwPlpppngBKV7SMTFuZIzmD+1NOVQfZM0atz/gazwOxkcq43dsIsHzsLge X-Received: by 2002:a05:6a20:6d1a:b0:b6:597f:66a1 with SMTP id fv26-20020a056a206d1a00b000b6597f66a1mr19106145pzb.60.1673880756897; Mon, 16 Jan 2023 06:52:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673880756; cv=none; d=google.com; s=arc-20160816; b=LWQOvcB1HF+R5IIDyBZGW+QacI/aBztDs/JPJ2m/3j53l2s+3iLj7+re6c2o4j1PPe 2jy1P+fGf5bEq+3O4e8suOrL8mDljUssgrn8WmVWPe/FLRklehDvMM5FCYH9lQbyzTjF 7Rw27EL6n5yajlfH1xyjB/yySQ5bwcLJ7FryZC+78D5nVOW5thCj72FZskixHLgz1D99 1UEBjZBu7eQlsSP3fUR0xObFmXpDuRC5V+E2J2iIDLXFqfXwSeSPZTN3Eygtf/enmN82 ihMiURC1+zmDdWWGJetzQJc+cixr0AHbM9f+FmAjZPcAXvy6kCgCgc0sIOTDxBvI4l6e CIbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EjO7ZQRdD5QHy2IfsNxfsWnGHxpJzC8+I3VX01ShNcE=; b=tgGrwkfNt1LDqL5XAdUpMGjWHGbJ4nBA3awmfzlCYDhEL1i/9VPsusxh2u6HzebhaH 7QFEXXR9v6roW7F5d8s76/8heyC1kI0f+27kwcnR+7d7yYhj028NrsLZl7vW5N2XyL2w Vd7N/KU1ybtFfBA2q6NNJuQF2dxsgH4SvE40KYTYuZVM5jlc+MbhzDrHLSQOkURM6H9V 6l0E4ZdvH5TH3UgnE+YoUZCsADMaSN9IgDsJwaABMsqzHJ6OPNvnm+GzRDzxTpxBZMRz LqRuwTlN7Wty8Hf83CNsN3bMcVnOhgV6y9KzF4AMK6uq9ZWqiMxV4OKMlEk5+hIgUS8k +GsA== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o25-20020a635a19000000b004c7f8208d17si6853742pgb.457.2023.01.16.06.52.23; Mon, 16 Jan 2023 06:52:36 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230527AbjAPOp5 (ORCPT + 99 others); Mon, 16 Jan 2023 09:45:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230496AbjAPOpX (ORCPT ); Mon, 16 Jan 2023 09:45:23 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D94A12749C; Mon, 16 Jan 2023 06:25:26 -0800 (PST) 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 BC2EE1570; Mon, 16 Jan 2023 06:26:08 -0800 (PST) Received: from donnerap.cambridge.arm.com (donnerap.cambridge.arm.com [10.1.197.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB68E3F67D; Mon, 16 Jan 2023 06:25:24 -0800 (PST) From: Andre Przywara To: Liam Girdwood , Chen-Yu Tsai , Mark Brown , Lee Jones , Martin Botka Cc: Rob Herring , Krzysztof Kozlowski , martin.botka1@gmail.com, Samuel Holland , Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v6 1/3] dt-bindings: mfd: x-powers,axp152: Document the AXP313a variant Date: Mon, 16 Jan 2023 14:24:59 +0000 Message-Id: <20230116142501.767142-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230116142501.767142-1-andre.przywara@arm.com> References: <20230116142501.767142-1-andre.przywara@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755191188447381319?= X-GMAIL-MSGID: =?utf-8?q?1755191188447381319?= From: Martin Botka The X-Powers AXP313a is a PMIC used on some devices with the Allwinner H616 or H313 SoC. Signed-off-by: Martin Botka Signed-off-by: Andre Przywara --- Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml index b7a8747d5fa0e..d4f0a75a8c7ad 100644 --- a/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml +++ b/Documentation/devicetree/bindings/mfd/x-powers,axp152.yaml @@ -84,6 +84,7 @@ properties: oneOf: - enum: - x-powers,axp152 + - x-powers,axp313a - x-powers,axp202 - x-powers,axp209 - x-powers,axp221 From patchwork Mon Jan 16 14:25:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 44192 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1231934wrn; Mon, 16 Jan 2023 06:52:55 -0800 (PST) X-Google-Smtp-Source: AMrXdXtXKcZRrZ2QinX9TF+1kUOn3ILYX76kuWjzGCuLqF0V+bqoGtle01VqsbAriGiB6qTTtwhp X-Received: by 2002:a17:903:41d2:b0:191:4575:48aa with SMTP id u18-20020a17090341d200b00191457548aamr56949ple.11.1673880775422; Mon, 16 Jan 2023 06:52:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673880775; cv=none; d=google.com; s=arc-20160816; b=KYkN+nfHpkScggA9E3l8RlVPbIucj6OgssUR7B+OGe9E09QtL1hhYCvHH7Jdzy/zU3 QIrpgXCyIALldYMSkwDfpITx/B3tmlK7kAGK+kApfAwJ1tUhNu0zr/btMdJBLxZ2VgCb DkpvWSyahobNpH3sM4c825jV5boHUA0xeEdy1ixUEMzr/Pk2ilznV+2rzmZL0xPnh9u2 DjI8Ex7kRGcFPFMg6CBrNYD64Z/TmzQPH4NbJc9o1HzEWACSL9s27f613VOz1AXKP4+j 7wwtmCfT/7WGcQnfeGtBIaJ5sWpPnnWEsYXCGwLDKYmH9SwQu49sHhERv0ln/fjMvEJ+ /n2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=cKweWDRFmPBTXdwX94zZraW3AJP0kIiQ4Dxjj8r4GtU=; b=dSE6zef0WAXDaMNJEfTzZZ/pZgNLNX6bRYz8WJMyBmqvfqgUgupTt2JtfCKHowvGpH DguNc2f6qZMaTJvZjLtQ3UrchOhF34MSnPNj2NU13qaR/r7OZi+PCwgeZmakeRsJeJVB Y8GEH3Y9lNA7j6N8Ssgv14EkhCCsdqg6UxfTd/tONvtoqFyC+oOVsZOt5uzn2jpf03+8 6+8XqXSuzNqWB+nKmWb46WShvJh6xk9FL621pEYhnNA3bUfm4LGacGck2CZ7Tu9vbWdc QVOMF6CAS9jaDdzbDaNy8k0eujDUsgEgmG0T8IdiqZbFDktJEu3VM4vUATSdZtdMiMMX o6Mw== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k184-20020a6384c1000000b004bec17d1700si5866816pgd.725.2023.01.16.06.52.43; Mon, 16 Jan 2023 06:52:55 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230391AbjAPOqB (ORCPT + 99 others); Mon, 16 Jan 2023 09:46:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230170AbjAPOpZ (ORCPT ); Mon, 16 Jan 2023 09:45:25 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ADC552749D for ; Mon, 16 Jan 2023 06:25:28 -0800 (PST) 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 99CB115A1; Mon, 16 Jan 2023 06:26:10 -0800 (PST) Received: from donnerap.cambridge.arm.com (donnerap.cambridge.arm.com [10.1.197.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D36413F67D; Mon, 16 Jan 2023 06:25:26 -0800 (PST) From: Andre Przywara To: Liam Girdwood , Chen-Yu Tsai , Mark Brown , Lee Jones , Martin Botka Cc: Rob Herring , Krzysztof Kozlowski , martin.botka1@gmail.com, Samuel Holland , Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v6 2/3] mfd: axp20x: Add support for AXP313a PMIC Date: Mon, 16 Jan 2023 14:25:00 +0000 Message-Id: <20230116142501.767142-3-andre.przywara@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230116142501.767142-1-andre.przywara@arm.com> References: <20230116142501.767142-1-andre.przywara@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755191208210250026?= X-GMAIL-MSGID: =?utf-8?q?1755191208210250026?= From: Martin Botka The AXP313a is a PMIC chip produced by X-Powers, it can be connected via an I2C bus. The name AXP1530 seems to appear as well, and this is what is used in the BSP driver. From all we know it's the same chip, just a different name. However we have only seen AXP313a chips in the wild, so go with this name. Compared to the other AXP PMICs it's a rather simple affair: just three DCDC converters, three LDOs, and no battery charging support. Describe the regmap and the MFD bits, along with the registers exposed via I2C. Eventually advertise the device using the new compatible string. Signed-off-by: Martin Botka Signed-off-by: Andre Przywara --- drivers/mfd/axp20x-i2c.c | 2 ++ drivers/mfd/axp20x.c | 61 ++++++++++++++++++++++++++++++++++++++ include/linux/mfd/axp20x.h | 32 ++++++++++++++++++++ 3 files changed, 95 insertions(+) diff --git a/drivers/mfd/axp20x-i2c.c b/drivers/mfd/axp20x-i2c.c index f49fbd3079589..5a592c29cccce 100644 --- a/drivers/mfd/axp20x-i2c.c +++ b/drivers/mfd/axp20x-i2c.c @@ -59,6 +59,7 @@ static void axp20x_i2c_remove(struct i2c_client *i2c) #ifdef CONFIG_OF static const struct of_device_id axp20x_i2c_of_match[] = { { .compatible = "x-powers,axp152", .data = (void *)AXP152_ID }, + { .compatible = "x-powers,axp313a", .data = (void *)AXP313A_ID}, { .compatible = "x-powers,axp202", .data = (void *)AXP202_ID }, { .compatible = "x-powers,axp209", .data = (void *)AXP209_ID }, { .compatible = "x-powers,axp221", .data = (void *)AXP221_ID }, @@ -72,6 +73,7 @@ MODULE_DEVICE_TABLE(of, axp20x_i2c_of_match); static const struct i2c_device_id axp20x_i2c_id[] = { { "axp152", 0 }, + { "axp313a", 0 }, { "axp202", 0 }, { "axp209", 0 }, { "axp221", 0 }, diff --git a/drivers/mfd/axp20x.c b/drivers/mfd/axp20x.c index 47fd700f284f1..3019f091882fa 100644 --- a/drivers/mfd/axp20x.c +++ b/drivers/mfd/axp20x.c @@ -34,6 +34,7 @@ static const char * const axp20x_model_names[] = { "AXP152", + "AXP313a", "AXP202", "AXP209", "AXP221", @@ -66,6 +67,24 @@ static const struct regmap_access_table axp152_volatile_table = { .n_yes_ranges = ARRAY_SIZE(axp152_volatile_ranges), }; +static const struct regmap_range axp313a_writeable_ranges[] = { + regmap_reg_range(AXP313A_ON_INDICATE, AXP313A_IRQ_STATE), +}; + +static const struct regmap_range axp313a_volatile_ranges[] = { + regmap_reg_range(AXP313A_ON_INDICATE, AXP313A_IRQ_STATE), +}; + +static const struct regmap_access_table axp313a_writeable_table = { + .yes_ranges = axp313a_writeable_ranges, + .n_yes_ranges = ARRAY_SIZE(axp313a_writeable_ranges), +}; + +static const struct regmap_access_table axp313a_volatile_table = { + .yes_ranges = axp313a_volatile_ranges, + .n_yes_ranges = ARRAY_SIZE(axp313a_volatile_ranges), +}; + static const struct regmap_range axp20x_writeable_ranges[] = { regmap_reg_range(AXP20X_DATACACHE(0), AXP20X_IRQ5_STATE), regmap_reg_range(AXP20X_CHRG_CTRL1, AXP20X_CHRG_CTRL2), @@ -245,6 +264,15 @@ static const struct regmap_config axp152_regmap_config = { .cache_type = REGCACHE_RBTREE, }; +static const struct regmap_config axp313a_regmap_config = { + .reg_bits = 8, + .val_bits = 8, + .wr_table = &axp313a_writeable_table, + .volatile_table = &axp313a_volatile_table, + .max_register = AXP313A_IRQ_STATE, + .cache_type = REGCACHE_RBTREE, +}; + static const struct regmap_config axp20x_regmap_config = { .reg_bits = 8, .val_bits = 8, @@ -304,6 +332,16 @@ static const struct regmap_irq axp152_regmap_irqs[] = { INIT_REGMAP_IRQ(AXP152, GPIO0_INPUT, 2, 0), }; +static const struct regmap_irq axp313a_regmap_irqs[] = { + INIT_REGMAP_IRQ(AXP313A, PEK_RIS_EDGE, 0, 7), + INIT_REGMAP_IRQ(AXP313A, PEK_FAL_EDGE, 0, 6), + INIT_REGMAP_IRQ(AXP313A, PEK_SHORT, 0, 5), + INIT_REGMAP_IRQ(AXP313A, PEK_LONG, 0, 4), + INIT_REGMAP_IRQ(AXP313A, DCDC3_V_LOW, 0, 3), + INIT_REGMAP_IRQ(AXP313A, DCDC2_V_LOW, 0, 2), + INIT_REGMAP_IRQ(AXP313A, DIE_TEMP_HIGH, 0, 0), +}; + static const struct regmap_irq axp20x_regmap_irqs[] = { INIT_REGMAP_IRQ(AXP20X, ACIN_OVER_V, 0, 7), INIT_REGMAP_IRQ(AXP20X, ACIN_PLUGIN, 0, 6), @@ -513,6 +551,17 @@ static const struct regmap_irq_chip axp152_regmap_irq_chip = { .num_regs = 3, }; +static const struct regmap_irq_chip axp313a_regmap_irq_chip = { + .name = "axp313a_irq_chip", + .status_base = AXP313A_IRQ_STATE, + .ack_base = AXP313A_IRQ_STATE, + .unmask_base = AXP313A_IRQ_EN, + .init_ack_masked = true, + .irqs = axp313a_regmap_irqs, + .num_irqs = ARRAY_SIZE(axp313a_regmap_irqs), + .num_regs = 1, +}; + static const struct regmap_irq_chip axp20x_regmap_irq_chip = { .name = "axp20x_irq_chip", .status_base = AXP20X_IRQ1_STATE, @@ -676,6 +725,12 @@ static const struct mfd_cell axp152_cells[] = { }, }; +static struct mfd_cell axp313a_cells[] = { + { + .name = "axp20x-regulator", + }, +}; + static const struct resource axp288_adc_resources[] = { DEFINE_RES_IRQ_NAMED(AXP288_IRQ_GPADC, "GPADC"), }; @@ -867,6 +922,12 @@ int axp20x_match_device(struct axp20x_dev *axp20x) axp20x->regmap_cfg = &axp152_regmap_config; axp20x->regmap_irq_chip = &axp152_regmap_irq_chip; break; + case AXP313A_ID: + axp20x->nr_cells = ARRAY_SIZE(axp313a_cells); + axp20x->cells = axp313a_cells; + axp20x->regmap_cfg = &axp313a_regmap_config; + axp20x->regmap_irq_chip = &axp313a_regmap_irq_chip; + break; case AXP202_ID: case AXP209_ID: axp20x->nr_cells = ARRAY_SIZE(axp20x_cells); diff --git a/include/linux/mfd/axp20x.h b/include/linux/mfd/axp20x.h index 9ab0e2fca7eac..ae18f8630238c 100644 --- a/include/linux/mfd/axp20x.h +++ b/include/linux/mfd/axp20x.h @@ -12,6 +12,7 @@ enum axp20x_variants { AXP152_ID = 0, + AXP313A_ID, AXP202_ID, AXP209_ID, AXP221_ID, @@ -45,6 +46,17 @@ enum axp20x_variants { #define AXP152_DCDC_FREQ 0x37 #define AXP152_DCDC_MODE 0x80 +#define AXP313A_ON_INDICATE 0x00 +#define AXP313A_OUTPUT_CONTROL 0x10 +#define AXP313A_DCDC1_CONRTOL 0x13 +#define AXP313A_DCDC2_CONRTOL 0x14 +#define AXP313A_DCDC3_CONRTOL 0x15 +#define AXP313A_ALDO1_CONRTOL 0x16 +#define AXP313A_DLDO1_CONRTOL 0x17 +#define AXP313A_OUTPUT_MONITOR 0x1d +#define AXP313A_IRQ_EN 0x20 +#define AXP313A_IRQ_STATE 0x21 + #define AXP20X_PWR_INPUT_STATUS 0x00 #define AXP20X_PWR_OP_MODE 0x01 #define AXP20X_USB_OTG_STATUS 0x02 @@ -287,6 +299,16 @@ enum axp20x_variants { #define AXP288_FG_TUNE5 0xed /* Regulators IDs */ +enum { + AXP313A_DCDC1 = 0, + AXP313A_DCDC2, + AXP313A_DCDC3, + AXP313A_LDO1, + AXP313A_LDO2, + AXP313A_RTC_LDO, + AXP313A_REG_ID_MAX, +}; + enum { AXP20X_LDO1 = 0, AXP20X_LDO2, @@ -440,6 +462,16 @@ enum { AXP152_IRQ_GPIO0_INPUT, }; +enum axp313a_irqs { + AXP313A_IRQ_DIE_TEMP_HIGH, + AXP313A_IRQ_DCDC2_V_LOW = 2, + AXP313A_IRQ_DCDC3_V_LOW, + AXP313A_IRQ_PEK_LONG, + AXP313A_IRQ_PEK_SHORT, + AXP313A_IRQ_PEK_FAL_EDGE, + AXP313A_IRQ_PEK_RIS_EDGE, +}; + enum { AXP20X_IRQ_ACIN_OVER_V = 1, AXP20X_IRQ_ACIN_PLUGIN, From patchwork Mon Jan 16 14:25:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 44205 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1232952wrn; Mon, 16 Jan 2023 06:55:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXvk7mstJHCicJmEnBgZdfx6piWhB3zo+hNMxlT5aaH3MacJb/Qz1r+OJMKIlyI4Tk+yVnk6 X-Received: by 2002:a17:906:30d4:b0:7a6:5b50:a32c with SMTP id b20-20020a17090630d400b007a65b50a32cmr74035441ejb.12.1673880919694; Mon, 16 Jan 2023 06:55:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673880919; cv=none; d=google.com; s=arc-20160816; b=JDaII5MaYRVRh8PBupXV8XgRu8QxGQiRFn1eQAJsGX3yRkBlVJ0kXVatOkEssfD6d2 kJxeXWygJwFh2+sd/4HJjUogvMzKC7H13L8Ed6Bc8kuskZtzD87sF5LJ/IgZxpZHhXvf 9RZGqVK8Z/DQWc00pFS4cSlBdaQ8PAZAux7JMFyNmIpNy38PQqqisitE0kq7/sIn1i3H 83ePIgbLRaUeFHz/gPFOYsjTBhpugkM3pV7ERlCX84QHYDk2TWGz66HqgClR9JHz9oRm 6SO9Zk3/VuWwYQkxq5JOxXIfHyIhmMpuoInm9wWVHnANwMbpRpguZ9BL9onwVrhOaxyR xAcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hyKxG/lyDHoYbBeJX0Xv8QQGPlxxRqQHOtXtB9POBK0=; b=Bui8tR/gcWpmwrmmidvb0Cu19Os3B0tDaLZl5P5/QBLK9PmycVmn3WoHMVE+aF8zoR s146+VK3hmBp5WEfDigKFB0wJwHFnMfTetkaHyHuPcWBSKJVJd8VWzKdBei8h00/n/0s u9U6ITsaP6m7V+ws9//3T8KNHH9IvRnuajc04C/uq4RyV9HFhB8yVjXaqRyNxyFYnFfd hv2v57ACgndw0M3abxD1/jJBWUI7hilxngwPzvnu1p+u1nRMYLXrjcrRQF/mKZSTMtBc hMpiyQLKv/2YdRRT944ESAblXfeLW4lTYFK2fcEmr2pQNteFwyHwWcxZYvAdo3Bisn0g UNWA== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hw8-20020a170907a0c800b00871afe07cdbsi1242085ejc.57.2023.01.16.06.54.56; Mon, 16 Jan 2023 06:55:19 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229741AbjAPOqH (ORCPT + 99 others); Mon, 16 Jan 2023 09:46:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39770 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230466AbjAPOp0 (ORCPT ); Mon, 16 Jan 2023 09:45:26 -0500 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8B1DB2749F for ; Mon, 16 Jan 2023 06:25:30 -0800 (PST) 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 77336C14; Mon, 16 Jan 2023 06:26:12 -0800 (PST) Received: from donnerap.cambridge.arm.com (donnerap.cambridge.arm.com [10.1.197.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B111B3F67D; Mon, 16 Jan 2023 06:25:28 -0800 (PST) From: Andre Przywara To: Liam Girdwood , Chen-Yu Tsai , Mark Brown , Lee Jones , Martin Botka Cc: Rob Herring , Krzysztof Kozlowski , martin.botka1@gmail.com, Samuel Holland , Jernej Skrabec , linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Subject: [PATCH v6 3/3] regulator: axp20x: Add support for AXP313a variant Date: Mon, 16 Jan 2023 14:25:01 +0000 Message-Id: <20230116142501.767142-4-andre.przywara@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230116142501.767142-1-andre.przywara@arm.com> References: <20230116142501.767142-1-andre.przywara@arm.com> MIME-Version: 1.0 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755191359260738016?= X-GMAIL-MSGID: =?utf-8?q?1755191359260738016?= From: Martin Botka The AXP313a is your typical I2C controlled PMIC, although in a lighter fashion compared to the other X-Powers PMICs: it has only three DCDC rails, three LDOs, and no battery charging support. The AXP313a datasheet does not describe a register to change the DCDC switching frequency, and talks of it being fixed at 3 MHz. The BSP driver hints at a register being able to change that, but we haven't verified that, so leave that one out. It can be added later, if needed and/or required. The third LDO, RTCLDO, is fixed, and cannot even be turned on or off, programmatically. On top of that, its voltage is customisable (either 1.8V or 3.3V), which we cannot describe easily using the existing regulator wrapper functions. This should be fixed properly, using regulator-{min,max}-microvolt in the DT, but this requires more changes to the code. As some other PMICs (AXP2xx, AXP803) seem to paper over the same problem as well, we follow suit here and pretend it's a fixed 1.8V regulator. A proper fix can follow later. The BSP code seems to ignore this regulator altogether. Describe the AXP313A's voltage settings and switch registers, how the voltages are encoded, and connect this to the MFD device via its regulator ID. Signed-off-by: Martin Botka Signed-off-by: Andre Przywara --- drivers/regulator/axp20x-regulator.c | 60 ++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index d260c442b788d..f310a959de9a7 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -134,6 +134,11 @@ #define AXP22X_PWR_OUT_DLDO4_MASK BIT_MASK(6) #define AXP22X_PWR_OUT_ALDO3_MASK BIT_MASK(7) +#define AXP313A_DCDC1_NUM_VOLTAGES 107 +#define AXP313A_DCDC23_NUM_VOLTAGES 88 +#define AXP313A_DCDC_V_OUT_MASK GENMASK(6, 0) +#define AXP313A_LDO_V_OUT_MASK GENMASK(4, 0) + #define AXP803_PWR_OUT_DCDC1_MASK BIT_MASK(0) #define AXP803_PWR_OUT_DCDC2_MASK BIT_MASK(1) #define AXP803_PWR_OUT_DCDC3_MASK BIT_MASK(2) @@ -1001,6 +1006,48 @@ static const struct regulator_desc axp813_regulators[] = { AXP22X_PWR_OUT_CTRL2, AXP22X_PWR_OUT_DC1SW_MASK), }; +static const struct linear_range axp313a_dcdc1_ranges[] = { + REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000), + REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000), + REGULATOR_LINEAR_RANGE(1600000, 88, 106, 100000), +}; + +static const struct linear_range axp313a_dcdc2_ranges[] = { + REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000), + REGULATOR_LINEAR_RANGE(1220000, 71, 87, 20000), +}; + +/* + * This is deviating from the datasheet. The values here are taken from the + * BSP driver and have been confirmed by measurements. + */ +static const struct linear_range axp313a_dcdc3_ranges[] = { + REGULATOR_LINEAR_RANGE(500000, 0, 70, 10000), + REGULATOR_LINEAR_RANGE(1220000, 71, 102, 20000), +}; + +static const struct regulator_desc axp313a_regulators[] = { + AXP_DESC_RANGES(AXP313A, DCDC1, "dcdc1", "vin1", + axp313a_dcdc1_ranges, AXP313A_DCDC1_NUM_VOLTAGES, + AXP313A_DCDC1_CONRTOL, AXP313A_DCDC_V_OUT_MASK, + AXP313A_OUTPUT_CONTROL, BIT(0)), + AXP_DESC_RANGES(AXP313A, DCDC2, "dcdc2", "vin2", + axp313a_dcdc2_ranges, AXP313A_DCDC23_NUM_VOLTAGES, + AXP313A_DCDC2_CONRTOL, AXP313A_DCDC_V_OUT_MASK, + AXP313A_OUTPUT_CONTROL, BIT(1)), + AXP_DESC_RANGES(AXP313A, DCDC3, "dcdc3", "vin3", + axp313a_dcdc3_ranges, AXP313A_DCDC23_NUM_VOLTAGES, + AXP313A_DCDC3_CONRTOL, AXP313A_DCDC_V_OUT_MASK, + AXP313A_OUTPUT_CONTROL, BIT(2)), + AXP_DESC(AXP313A, LDO1, "ldo1", "vin1", 500, 3500, 100, + AXP313A_ALDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK, + AXP313A_OUTPUT_CONTROL, BIT(3)), + AXP_DESC(AXP313A, LDO2, "ldo2", "vin1", 500, 3500, 100, + AXP313A_DLDO1_CONRTOL, AXP313A_LDO_V_OUT_MASK, + AXP313A_OUTPUT_CONTROL, BIT(4)), + AXP_DESC_FIXED(AXP313A, RTC_LDO, "rtc-ldo", "vin1", 1800), +}; + static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) { struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); @@ -1040,6 +1087,15 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) def = 3000; step = 150; break; + case AXP313A_ID: + /* The DCDC PWM frequency seems to be fixed to 3 MHz. */ + if (dcdcfreq != 3000000) { + dev_err(&pdev->dev, + "DCDC frequency on AXP313a is fixed to 3 MHz.\n"); + return -EINVAL; + } + + return 0; default: dev_err(&pdev->dev, "Setting DCDC frequency for unsupported AXP variant\n"); @@ -1220,6 +1276,10 @@ static int axp20x_regulator_probe(struct platform_device *pdev) bool drivevbus = false; switch (axp20x->variant) { + case AXP313A_ID: + regulators = axp313a_regulators; + nregulators = AXP313A_REG_ID_MAX; + break; case AXP202_ID: case AXP209_ID: regulators = axp20x_regulators;