From: Boris BREZILLON <boris.brezillon@free-electrons.com> To: Samuel Ortiz <sameo@linux.intel.com>, Lee Jones <lee.jones@linaro.org>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org> Cc: Maxime Ripard <maxime.ripard@free-electrons.com>, Carlo Caione <carlo@caione.org>, Shuge <shuge@allwinnertech.com>, kevin@allwinnertech.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dev@linux-sunxi.org, Boris BREZILLON <boris.brezillon@free-electrons.com> Subject: [PATCH v3 3/6] regulator: axp20x: add support for AXP221 regulators Date: Tue, 27 May 2014 11:38:52 +0200 [thread overview] Message-ID: <1401183535-31003-4-git-send-email-boris.brezillon@free-electrons.com> (raw) In-Reply-To: <1401183535-31003-1-git-send-email-boris.brezillon@free-electrons.com> Add AXP221 regulator definitions and choose the appropriate definitions according to the variant id passed by the MFD device. Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com> --- drivers/regulator/axp20x-regulator.c | 98 +++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index 5a59982..feaa0b5 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -27,6 +27,9 @@ #define AXP20X_IO_ENABLED 0x03 #define AXP20X_IO_DISABLED 0x07 +#define AXP22X_IO_ENABLED 0x04 +#define AXP22X_IO_DISABLED 0x03 + #define AXP20X_WORKMODE_DCDC2_MASK BIT(2) #define AXP20X_WORKMODE_DCDC3_MASK BIT(1) @@ -143,6 +146,48 @@ static const struct regulator_desc axp20x_regulators[] = { AXP20X_IO_DISABLED), }; +static const struct regulator_desc axp22x_regulators[] = { + AXP_DESC(AXP22X, DCDC1, "vin1", 1600, 3400, 100, AXP22X_DCDC1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(1)), + AXP_DESC(AXP22X, DCDC2, "vin2", 600, 1540, 20, AXP22X_DCDC2_V_OUT, 0x3f, + AXP22X_PWR_OUT_CTRL1, BIT(2)), + AXP_DESC(AXP22X, DCDC3, "vin3", 600, 1860, 20, AXP22X_DCDC3_V_OUT, 0x3f, + AXP22X_PWR_OUT_CTRL1, BIT(3)), + AXP_DESC(AXP22X, DCDC4, "vin4", 600, 1540, 20, AXP22X_DCDC4_V_OUT, 0x3f, + AXP22X_PWR_OUT_CTRL1, BIT(3)), + AXP_DESC(AXP22X, DCDC5, "vin5", 1000, 2550, 50, AXP22X_DCDC5_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(4)), + AXP_DESC(AXP22X, DC5LDO, "vin5", 700, 1400, 100, AXP22X_DC5LDO_V_OUT, 0x7, + AXP22X_PWR_OUT_CTRL1, BIT(0)), + AXP_DESC(AXP22X, ALDO1, "aldoin", 700, 3300, 100, AXP22X_ALDO1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(6)), + AXP_DESC(AXP22X, ALDO2, "aldoin", 700, 3300, 100, AXP22X_ALDO2_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(7)), + AXP_DESC(AXP22X, ALDO3, "aldoin", 700, 3300, 100, AXP22X_ALDO3_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL3, BIT(7)), + AXP_DESC(AXP22X, DLDO1, "dldoin", 700, 3300, 100, AXP22X_DLDO1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(3)), + AXP_DESC(AXP22X, DLDO2, "dldoin", 700, 3300, 100, AXP22X_DLDO2_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(4)), + AXP_DESC(AXP22X, DLDO3, "dldoin", 700, 3300, 100, AXP22X_DLDO3_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(5)), + AXP_DESC(AXP22X, DLDO4, "dldoin", 700, 3300, 100, AXP22X_DLDO4_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(6)), + AXP_DESC(AXP22X, ELDO1, "eldoin", 700, 3300, 100, AXP22X_ELDO1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(0)), + AXP_DESC(AXP22X, ELDO2, "eldoin", 700, 3300, 100, AXP22X_ELDO2_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(1)), + AXP_DESC(AXP22X, ELDO3, "eldoin", 700, 3300, 100, AXP22X_ELDO3_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(2)), + AXP_DESC_IO(AXP22X, LDO_IO0, "ldoioin", 1800, 3300, 100, AXP22X_LDO_IO0_V_OUT, + 0x1f, AXP20X_GPIO0_CTRL, 0x07, AXP22X_IO_ENABLED, + AXP22X_IO_DISABLED), + AXP_DESC_IO(AXP22X, LDO_IO1, "ldoioin", 1800, 3300, 100, AXP22X_LDO_IO1_V_OUT, + 0x1f, AXP20X_GPIO1_CTRL, 0x07, AXP22X_IO_ENABLED, + AXP22X_IO_DISABLED), + AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtcldoin", 3000), +}; + #define AXP_MATCH(_family, _name, _id) \ [_family##_##_id] = { \ .name = #_name, \ @@ -159,6 +204,28 @@ static struct of_regulator_match axp20x_matches[] = { AXP_MATCH(AXP20X, ldo5, LDO5), }; +static struct of_regulator_match axp22x_matches[] = { + AXP_MATCH(AXP22X, dcdc1, DCDC1), + AXP_MATCH(AXP22X, dcdc2, DCDC2), + AXP_MATCH(AXP22X, dcdc3, DCDC3), + AXP_MATCH(AXP22X, dcdc4, DCDC4), + AXP_MATCH(AXP22X, dcdc5, DCDC5), + AXP_MATCH(AXP22X, dc5ldo, DC5LDO), + AXP_MATCH(AXP22X, aldo1, ALDO1), + AXP_MATCH(AXP22X, aldo2, ALDO2), + AXP_MATCH(AXP22X, aldo3, ALDO3), + AXP_MATCH(AXP22X, dldo1, DLDO1), + AXP_MATCH(AXP22X, dldo2, DLDO2), + AXP_MATCH(AXP22X, dldo3, DLDO3), + AXP_MATCH(AXP22X, dldo4, DLDO4), + AXP_MATCH(AXP22X, eldo1, ELDO1), + AXP_MATCH(AXP22X, eldo2, ELDO2), + AXP_MATCH(AXP22X, eldo3, ELDO3), + AXP_MATCH(AXP22X, ldo_io0, LDO_IO0), + AXP_MATCH(AXP22X, ldo_io1, LDO_IO1), + AXP_MATCH(AXP22X, rtc_ldo, RTC_LDO), +}; + static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) { struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); @@ -237,37 +304,52 @@ static int axp20x_regulator_probe(struct platform_device *pdev) struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct regulator_config config = { }; struct regulator_init_data *init_data; + struct of_regulator_match *matches; + int nmatches; + const struct regulator_desc *regulators; + int nregulators; int ret, i; u32 workmode; - ret = axp20x_regulator_parse_dt(pdev, axp20x_matches, - ARRAY_SIZE(axp20x_matches)); + if (axp20x->variant == AXP221_ID) { + matches = axp22x_matches; + nmatches = ARRAY_SIZE(axp22x_matches); + regulators = axp22x_regulators; + nregulators = AXP22X_REG_ID_MAX; + } else { + matches = axp20x_matches; + nmatches = ARRAY_SIZE(axp20x_matches); + regulators = axp20x_regulators; + nregulators = AXP20X_REG_ID_MAX; + } + + ret = axp20x_regulator_parse_dt(pdev, matches, nmatches); if (ret) return ret; for (i = 0; i < AXP20X_REG_ID_MAX; i++) { - init_data = axp20x_matches[i].init_data; + init_data = matches[i].init_data; config.dev = &pdev->dev; config.init_data = init_data; config.regmap = axp20x->regmap; - config.of_node = axp20x_matches[i].of_node; + config.of_node = matches[i].of_node; - rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], + rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "Failed to register %s\n", - axp20x_regulators[i].name); + regulators[i].name); return PTR_ERR(rdev); } - ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", + ret = of_property_read_u32(matches[i].of_node, "x-powers,dcdc-workmode", &workmode); if (!ret) { if (axp20x_set_dcdc_workmode(rdev, i, workmode)) dev_err(&pdev->dev, "Failed to set workmode on %s\n", - axp20x_regulators[i].name); + regulators[i].name); } } -- 1.8.3.2
WARNING: multiple messages have this Message-ID (diff)
From: boris.brezillon@free-electrons.com (Boris BREZILLON) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3 3/6] regulator: axp20x: add support for AXP221 regulators Date: Tue, 27 May 2014 11:38:52 +0200 [thread overview] Message-ID: <1401183535-31003-4-git-send-email-boris.brezillon@free-electrons.com> (raw) In-Reply-To: <1401183535-31003-1-git-send-email-boris.brezillon@free-electrons.com> Add AXP221 regulator definitions and choose the appropriate definitions according to the variant id passed by the MFD device. Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com> --- drivers/regulator/axp20x-regulator.c | 98 +++++++++++++++++++++++++++++++++--- 1 file changed, 90 insertions(+), 8 deletions(-) diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c index 5a59982..feaa0b5 100644 --- a/drivers/regulator/axp20x-regulator.c +++ b/drivers/regulator/axp20x-regulator.c @@ -27,6 +27,9 @@ #define AXP20X_IO_ENABLED 0x03 #define AXP20X_IO_DISABLED 0x07 +#define AXP22X_IO_ENABLED 0x04 +#define AXP22X_IO_DISABLED 0x03 + #define AXP20X_WORKMODE_DCDC2_MASK BIT(2) #define AXP20X_WORKMODE_DCDC3_MASK BIT(1) @@ -143,6 +146,48 @@ static const struct regulator_desc axp20x_regulators[] = { AXP20X_IO_DISABLED), }; +static const struct regulator_desc axp22x_regulators[] = { + AXP_DESC(AXP22X, DCDC1, "vin1", 1600, 3400, 100, AXP22X_DCDC1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(1)), + AXP_DESC(AXP22X, DCDC2, "vin2", 600, 1540, 20, AXP22X_DCDC2_V_OUT, 0x3f, + AXP22X_PWR_OUT_CTRL1, BIT(2)), + AXP_DESC(AXP22X, DCDC3, "vin3", 600, 1860, 20, AXP22X_DCDC3_V_OUT, 0x3f, + AXP22X_PWR_OUT_CTRL1, BIT(3)), + AXP_DESC(AXP22X, DCDC4, "vin4", 600, 1540, 20, AXP22X_DCDC4_V_OUT, 0x3f, + AXP22X_PWR_OUT_CTRL1, BIT(3)), + AXP_DESC(AXP22X, DCDC5, "vin5", 1000, 2550, 50, AXP22X_DCDC5_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(4)), + AXP_DESC(AXP22X, DC5LDO, "vin5", 700, 1400, 100, AXP22X_DC5LDO_V_OUT, 0x7, + AXP22X_PWR_OUT_CTRL1, BIT(0)), + AXP_DESC(AXP22X, ALDO1, "aldoin", 700, 3300, 100, AXP22X_ALDO1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(6)), + AXP_DESC(AXP22X, ALDO2, "aldoin", 700, 3300, 100, AXP22X_ALDO2_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL1, BIT(7)), + AXP_DESC(AXP22X, ALDO3, "aldoin", 700, 3300, 100, AXP22X_ALDO3_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL3, BIT(7)), + AXP_DESC(AXP22X, DLDO1, "dldoin", 700, 3300, 100, AXP22X_DLDO1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(3)), + AXP_DESC(AXP22X, DLDO2, "dldoin", 700, 3300, 100, AXP22X_DLDO2_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(4)), + AXP_DESC(AXP22X, DLDO3, "dldoin", 700, 3300, 100, AXP22X_DLDO3_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(5)), + AXP_DESC(AXP22X, DLDO4, "dldoin", 700, 3300, 100, AXP22X_DLDO4_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(6)), + AXP_DESC(AXP22X, ELDO1, "eldoin", 700, 3300, 100, AXP22X_ELDO1_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(0)), + AXP_DESC(AXP22X, ELDO2, "eldoin", 700, 3300, 100, AXP22X_ELDO2_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(1)), + AXP_DESC(AXP22X, ELDO3, "eldoin", 700, 3300, 100, AXP22X_ELDO3_V_OUT, 0x1f, + AXP22X_PWR_OUT_CTRL2, BIT(2)), + AXP_DESC_IO(AXP22X, LDO_IO0, "ldoioin", 1800, 3300, 100, AXP22X_LDO_IO0_V_OUT, + 0x1f, AXP20X_GPIO0_CTRL, 0x07, AXP22X_IO_ENABLED, + AXP22X_IO_DISABLED), + AXP_DESC_IO(AXP22X, LDO_IO1, "ldoioin", 1800, 3300, 100, AXP22X_LDO_IO1_V_OUT, + 0x1f, AXP20X_GPIO1_CTRL, 0x07, AXP22X_IO_ENABLED, + AXP22X_IO_DISABLED), + AXP_DESC_FIXED(AXP22X, RTC_LDO, "rtcldoin", 3000), +}; + #define AXP_MATCH(_family, _name, _id) \ [_family##_##_id] = { \ .name = #_name, \ @@ -159,6 +204,28 @@ static struct of_regulator_match axp20x_matches[] = { AXP_MATCH(AXP20X, ldo5, LDO5), }; +static struct of_regulator_match axp22x_matches[] = { + AXP_MATCH(AXP22X, dcdc1, DCDC1), + AXP_MATCH(AXP22X, dcdc2, DCDC2), + AXP_MATCH(AXP22X, dcdc3, DCDC3), + AXP_MATCH(AXP22X, dcdc4, DCDC4), + AXP_MATCH(AXP22X, dcdc5, DCDC5), + AXP_MATCH(AXP22X, dc5ldo, DC5LDO), + AXP_MATCH(AXP22X, aldo1, ALDO1), + AXP_MATCH(AXP22X, aldo2, ALDO2), + AXP_MATCH(AXP22X, aldo3, ALDO3), + AXP_MATCH(AXP22X, dldo1, DLDO1), + AXP_MATCH(AXP22X, dldo2, DLDO2), + AXP_MATCH(AXP22X, dldo3, DLDO3), + AXP_MATCH(AXP22X, dldo4, DLDO4), + AXP_MATCH(AXP22X, eldo1, ELDO1), + AXP_MATCH(AXP22X, eldo2, ELDO2), + AXP_MATCH(AXP22X, eldo3, ELDO3), + AXP_MATCH(AXP22X, ldo_io0, LDO_IO0), + AXP_MATCH(AXP22X, ldo_io1, LDO_IO1), + AXP_MATCH(AXP22X, rtc_ldo, RTC_LDO), +}; + static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) { struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); @@ -237,37 +304,52 @@ static int axp20x_regulator_probe(struct platform_device *pdev) struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent); struct regulator_config config = { }; struct regulator_init_data *init_data; + struct of_regulator_match *matches; + int nmatches; + const struct regulator_desc *regulators; + int nregulators; int ret, i; u32 workmode; - ret = axp20x_regulator_parse_dt(pdev, axp20x_matches, - ARRAY_SIZE(axp20x_matches)); + if (axp20x->variant == AXP221_ID) { + matches = axp22x_matches; + nmatches = ARRAY_SIZE(axp22x_matches); + regulators = axp22x_regulators; + nregulators = AXP22X_REG_ID_MAX; + } else { + matches = axp20x_matches; + nmatches = ARRAY_SIZE(axp20x_matches); + regulators = axp20x_regulators; + nregulators = AXP20X_REG_ID_MAX; + } + + ret = axp20x_regulator_parse_dt(pdev, matches, nmatches); if (ret) return ret; for (i = 0; i < AXP20X_REG_ID_MAX; i++) { - init_data = axp20x_matches[i].init_data; + init_data = matches[i].init_data; config.dev = &pdev->dev; config.init_data = init_data; config.regmap = axp20x->regmap; - config.of_node = axp20x_matches[i].of_node; + config.of_node = matches[i].of_node; - rdev = devm_regulator_register(&pdev->dev, &axp20x_regulators[i], + rdev = devm_regulator_register(&pdev->dev, ®ulators[i], &config); if (IS_ERR(rdev)) { dev_err(&pdev->dev, "Failed to register %s\n", - axp20x_regulators[i].name); + regulators[i].name); return PTR_ERR(rdev); } - ret = of_property_read_u32(axp20x_matches[i].of_node, "x-powers,dcdc-workmode", + ret = of_property_read_u32(matches[i].of_node, "x-powers,dcdc-workmode", &workmode); if (!ret) { if (axp20x_set_dcdc_workmode(rdev, i, workmode)) dev_err(&pdev->dev, "Failed to set workmode on %s\n", - axp20x_regulators[i].name); + regulators[i].name); } } -- 1.8.3.2
next prev parent reply other threads:[~2014-05-27 9:41 UTC|newest] Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-05-27 9:38 [PATCH v3 0/6] mfd: axp20x: add AXP221 PMIC support Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON 2014-05-27 9:38 ` [PATCH v3 1/6] " Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON 2014-05-27 10:05 ` Lee Jones 2014-05-27 10:05 ` Lee Jones 2014-05-27 10:14 ` Boris BREZILLON 2014-05-27 10:14 ` Boris BREZILLON 2014-05-27 9:38 ` [PATCH v3 2/6] regulator: axp20x: prepare support for multiple AXP chip families Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON [this message] 2014-05-27 9:38 ` [PATCH v3 3/6] regulator: axp20x: add support for AXP221 regulators Boris BREZILLON 2014-05-27 9:38 ` [PATCH v3 4/6] regulator: axp20x: reset probe data before each probe Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON 2014-05-27 9:38 ` [PATCH v3 5/6] regulator: add support for regulator set registration Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON 2014-06-10 13:40 ` Boris BREZILLON 2014-06-10 13:40 ` Boris BREZILLON 2014-06-16 8:08 ` Lee Jones 2014-06-16 8:08 ` Lee Jones 2014-06-16 13:24 ` Boris BREZILLON 2014-06-16 13:24 ` Boris BREZILLON 2014-05-27 9:38 ` [PATCH v3 6/6] regulator: axp20x: make use of devm_regulator_set_register Boris BREZILLON 2014-05-27 9:38 ` Boris BREZILLON 2014-05-27 19:49 ` [PATCH v3 0/6] mfd: axp20x: add AXP221 PMIC support Mark Brown 2014-05-27 19:49 ` Mark Brown [not found] ` <9ed19670-7a2e-4324-a201-6d3c8514bdb3@googlegroups.com> 2014-05-28 17:49 ` Mark Brown 2014-05-28 17:49 ` Mark Brown 2014-05-28 19:46 ` Boris BREZILLON 2014-05-28 19:46 ` Boris BREZILLON
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1401183535-31003-4-git-send-email-boris.brezillon@free-electrons.com \ --to=boris.brezillon@free-electrons.com \ --cc=broonie@kernel.org \ --cc=carlo@caione.org \ --cc=dev@linux-sunxi.org \ --cc=kevin@allwinnertech.com \ --cc=lee.jones@linaro.org \ --cc=lgirdwood@gmail.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maxime.ripard@free-electrons.com \ --cc=sameo@linux.intel.com \ --cc=shuge@allwinnertech.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.