regulator: cpcap: Add basic regulator support
Subsystems (2)
PATCH 1/1 regulator: cpcap: Add basic regulator support
Many Motorola phones like droid 4 are using a custom PMIC called CPCAP or 6556002. This PMIC is used with several SoCs, I've noticed at least omap3, omap4 and Tegra2 based Motorola phones and tablets using it.
---
With the cpcap core MFD driver now in Linux next as commit 3d66c8abc13e ("mfd: cpcap: Add minimal support"), here's a related regulator driver. This is needed to support more devices on droid 4, such as the LCD and touchscreen.
--- .../bindings/regulator/cpcap-regulator.txt | 34 ++ drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/cpcap-regulator.c | 517 +++++++++++++++++++++ 4 files changed, 559 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/cpcap-regulator.txt create mode 100644 drivers/regulator/cpcap-regulator.c
Documentation/devicetree/bindings/regulator/cpcap-regulator.txt new file +34 -0
@@ -0,0 +1,34 @@ +Motorola CPCAP PMIC voltage regulators +------------------------------------ + +Requires node properties: +- "compatible" value one of: + "motorola,cpcap-regulator" + "motorola,mapphone-cpcap-regulator" + +Required regulator properties: +- "regulator-name" +- "regulator-enable-ramp-delay" +- "regulator-min-microvolt" +- "regulator-max-microvolt" + +Optional regulator properties: +- "regulator-boot-on" + +See Documentation/devicetree/bindings/regulator/regulator.txt +for more details about the regulator properties. + +Example: + +cpcap_regulator: regulator@600 { + compatible = "motorola,cpcap-regulator"; + + cpcap_regulators: regulators { + sw5: SW5 { + regulator-min-microvolt = <5050000>; + regulator-max-microvolt = <5050000>; + regulator-enable-ramp-delay = <50000>; + regulator-boot-on; + }; + }; +};
drivers/regulator/Kconfig +7 -0
@@ -163,6 +163,13 @@ config REGULATOR_BCM590XX BCM590xx PMUs. This will enable support for the software controllable LDO/Switching regulators. +config REGULATOR_CPCAP + tristate "Motorola CPCAP regulator" + depends on MFD_CPCAP + help + Say y here for CPCAP regulator found on some Motorola phones + and tablets such as Droid 4. + config REGULATOR_DA903X tristate "Dialog Semiconductor DA9030/DA9034 regulators" depends on PMIC_DA903X
drivers/regulator/Makefile +1 -0
@@ -11,6 +11,7 @@ obj-$(CONFIG_REGULATOR_USERSPACE_CONSUMER) += userspace-consumer.o obj-$(CONFIG_REGULATOR_88PM800) += 88pm800.o obj-$(CONFIG_REGULATOR_88PM8607) += 88pm8607.o +obj-$(CONFIG_REGULATOR_CPCAP) += cpcap-regulator.o obj-$(CONFIG_REGULATOR_AAT2870) += aat2870-regulator.o obj-$(CONFIG_REGULATOR_AB3100) += ab3100.o obj-$(CONFIG_REGULATOR_AB8500) += ab8500-ext.o ab8500.o
drivers/regulator/cpcap-regulator.c new file +517 -0
517 lines not on this page · raw message
Signature · 5 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerdrivers/regulator/cpcap-regulator.c line 171
Quoted 8 lines · Tony Lindgren
drivers/regulator/cpcap-regulator.c new file +8
-0+static int cpcap_regulator_is_enabled (struct regulator_dev *rdev) +{ +unsigned int value =0 ; + +regmap_read (rdev->regmap, rdev->desc->enable_reg, &value); + +return ((value & rdev->desc->enable_mask) == rdev->desc->enable_reg); +}
Use the core support for this, reulator_is_enabled_regmap().
drivers/regulator/cpcap-regulator.c line 190
Quoted 13 lines
drivers/regulator/cpcap-regulator.c new file +13
-0+ error =regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_val); +if (error) +return error; + +if (rdev->desc->enable_val &CPCAP_REG_OFF_MODE_SEC ) { + error =regmap_update_bits (rdev->regmap, regulator->assign_reg, + regulator->assign_mask, + regulator->assign_mask); +if (error) +return error; + }
What does this second register bit do?
drivers/regulator/cpcap-regulator.c line 219
Quoted 5 lines
drivers/regulator/cpcap-regulator.c new file +5
-0+static int cpcap_regulator_get_voltage (struct regulator_dev *rdev) +{ +struct cpcap_regulator *regulator =rdev_get_drvdata (rdev); +unsigned int value =0 ; +int voltage;
regulator_get_voltage_sel_regmap() (the driver should just use selectors and let the mapping happen in the core).
drivers/regulator/cpcap-regulator.c line 224
Quoted 4 lines
drivers/regulator/cpcap-regulator.c new file +4
-0+regmap_read (rdev->regmap, rdev->desc->enable_reg, &value); + +if (!(value & rdev->desc->enable_mask)) +return 0 ;
This is buggy, the driver should report the voltage the regulator will have when powered.
drivers/regulator/cpcap-regulator.c line 234
Quoted 3 lines
drivers/regulator/cpcap-regulator.c new file +3
-0+static int cpcap_regulator_set_voltage (struct regulator_dev *rdev, +int min_uV,int max_uV, +unsigned int *selector)
regulator_map_voltage_iterate() and regulator_set_voltage_regmap()
drivers/regulator/cpcap-regulator.c line 285
Quoted 8 lines
drivers/regulator/cpcap-regulator.c new file +8
-0+switch (mode) { +case REGULATOR_MODE_NORMAL : + value =CPCAP_BIT_AUDIO_LOW_PWR ; +break ; +case REGULATOR_MODE_IDLE : +case REGULATOR_MODE_STANDBY : + value =0 ; +break ;
There should be a 1:1 mapping between modes and register values, if the device only supports two modes so should the driver.
drivers/regulator/cpcap-regulator.c line 475
Quoted 5 lines
drivers/regulator/cpcap-regulator.c new file +5
-0+ init_data.constraints.valid_modes_mask = +REGULATOR_MODE_NORMAL |REGULATOR_MODE_STANDBY ; + init_data.constraints.valid_ops_mask = +REGULATOR_CHANGE_MODE |REGULATOR_CHANGE_STATUS ; + config.init_data = &init_data;
Drivers should not configure constraints, they're part of the system integration and come from the firmware or board file.
Review
Quoted 2 lines
(quoted diff) +2
-0+ dev_info(&pdev->dev, "registering regulator %s\n", + regulator->rdesc.name);
This is needless spam, please remove it.
Quoted 16 lines · Mark Brown
drivers/regulator/cpcap-regulator.c line 190
Quoted 13 lines · Tony Lindgren
drivers/regulator/cpcap-regulator.c new file +13
-0+ error =regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_val); +if (error) +return error; + +if (rdev->desc->enable_val &CPCAP_REG_OFF_MODE_SEC ) { + error =regmap_update_bits (rdev->regmap, regulator->assign_reg, + regulator->assign_mask, + regulator->assign_mask); +if (error) +return error; + }What does this second register bit do?
My guess is that it triggers regulator idle modes in the PMIC based on the SoC off mode. There's no documentation for this thing..
I've just kept what the Motorola Linux kernel tree does here and added some comments to CPCAP_REG_OFF_MODE_SEC.
I'll address the rest of the comments and post v2, thanks for looking.
Regards,
Tony
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Mark Brown
maintainerQuoted 18 lines · Tony Lindgren
Quoted 16 lines · Mark Brown
drivers/regulator/cpcap-regulator.c line 190
Quoted 13 lines · Tony Lindgren
drivers/regulator/cpcap-regulator.c new file +13
-0+ error =regmap_update_bits (rdev->regmap, rdev->desc->enable_reg, + rdev->desc->enable_mask, + rdev->desc->enable_val); +if (error) +return error; + +if (rdev->desc->enable_val &CPCAP_REG_OFF_MODE_SEC ) { + error =regmap_update_bits (rdev->regmap, regulator->assign_reg, + regulator->assign_mask, + regulator->assign_mask); +if (error) +return error; + }What does this second register bit do?
Quoted 7 lines
My guess is that it triggers regulator idle modes in the PMIC based on the SoC off mode. There's no documentation for this thing..
I've just kept what the Motorola Linux kernel tree does here and added some comments to
CPCAP_REG_OFF_MODE_SEC.I'll address the rest of the comments and post v2, thanks for looking.
OK, thanks - comments should cover it here.
Rob Herring
maintainerQuoted 42 lines · Tony Lindgren
Many Motorola phones like droid 4 are using a custom PMIC called CPCAP or 6556002. This PMIC is used with several SoCs, I've noticed at least omap3, omap4 and Tegra2 based Motorola phones and tablets using it.
Cc Marcel Partap <[email protected]>Cc Michael Scott <[email protected]>Signed-off-by Tony Lindgren <[email protected]>---
With the cpcap core MFD driver now in Linux next as commit
3d66c8abc13e("mfd: cpcap: Add minimal support"), here's a related regulator driver. This is needed to support more devices on droid 4, such as the LCD and touchscreen.--- .../bindings/regulator/cpcap-regulator.txt | 34 ++ drivers/regulator/Kconfig | 7 + drivers/regulator/Makefile | 1 + drivers/regulator/cpcap-regulator.c | 517 +++++++++++++++++++++ 4 files changed, 559 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/cpcap-regulator.txt create mode 100644 drivers/regulator/cpcap-regulator.cDocumentation/devicetree/bindings/regulator/cpcap-regulator.txt new file +13
-0@@ -0,0 +1,34 @@ +Motorola CPCAP PMIC voltage regulators +------------------------------------ + +Requires node properties: +- "compatible" value one of: + "motorola,cpcap-regulator" + "motorola,mapphone-cpcap-regulator" + +Required regulator properties: +- "regulator-name" +- "regulator-enable-ramp-delay" +- "regulator-min-microvolt" +- "regulator-max-microvolt"
Documentation/devicetree/bindings/regulator/cpcap-regulator.txt line 23
Quoted 10 lines
Documentation/devicetree/bindings/regulator/cpcap-regulator.txt new file +10
-0+ +Optional regulator properties: +- "regulator-boot-on" + +See Documentation/devicetree/bindings/regulator/regulator.txt +for more details about the regulator properties. + +Example: + +cpcap_regulator: regulator@600 {
unit-address with no reg prop.
Quoted 11 lines
Documentation/devicetree/bindings/regulator/cpcap-regulator.txt new file +11
-0+ compatible = "motorola,cpcap-regulator"; + + cpcap_regulators: regulators { + sw5: SW5 { + regulator-min-microvolt = <5050000>; + regulator-max-microvolt = <5050000>; + regulator-enable-ramp-delay = <50000>; + regulator-boot-on; + }; + }; +};
Quoted 6 lines · Rob Herring
Documentation/devicetree/bindings/regulator/cpcap-regulator.txt line 23
Quoted 3 lines · Tony Lindgren
Documentation/devicetree/bindings/regulator/cpcap-regulator.txt new file +3
-0+Example: + +cpcap_regulator: regulator@600 {unit-address with no reg prop.
Oops thanks for spotting that. Will resend v2 shortly.
Regards,
Tony