cpcap: adjustments of PMIC and subdevices
cover cpcap: adjustments of PMIC and subdevices
Minor improvements and alignments for CPCAP PMIC and it's subdevices.
Svyatoslav Ryhel (5):
power: regulator: cpcap: remove bit_offset_from_cpcap_lowest_voltage
power: pmic: cpcap: add Mapphone and Mot compatibles
power: cpcap: make regulator node names case independent
input: cpcap_pwrbutton: set default keycode fallback
input: cpcap_pwrbutton: simplify parent verification
drivers/input/cpcap_pwrbutton.c | 6 +-- drivers/power/pmic/cpcap.c | 4 ++ drivers/power/regulator/cpcap_regulator.c | 55 +++++++++++------------ include/power/cpcap.h | 48 +++++++------------- 4 files changed, 47 insertions(+), 66 deletions(-)
Signature · 1 line
2.51.0
PATCH 1/5 power: regulator: cpcap: remove bit_offset_from_cpcap_lowest_voltage
The bit_offset_from_cpcap_lowest_voltage value was inherited from the downstream kernel as a quirk. With the correct voltage table, it is no longer needed. An additional benefit is that SW1, SW2, and SW4 now share the same voltage table.
--- drivers/power/regulator/cpcap_regulator.c | 53 +++++++++++------------ include/power/cpcap.h | 48 +++++++------------- 2 files changed, 40 insertions(+), 61 deletions(-)
drivers/power/regulator/cpcap_regulator.c +25 -28
@@ -55,7 +55,7 @@#define CPCAP_REG (_reg, _assignment_reg, _assignment_mask, _mode_mask, \ _volt_mask, _volt_shft, _mode_val, _off_mode_val, _val_tbl, \ - _mode_cntr, _volt_trans_time, _turn_on_time, _bit_offset) { \ + _mode_cntr, _volt_trans_time, _turn_on_time) { \ .reg = CPCAP_REG_##_reg, \ .assignment_reg = CPCAP_REG_##_assignment_reg, \ .assignment_mask = CPCAP_BIT_##_assignment_mask, \
@@ -69,60 +69,59 @@ .mode_cntr = _mode_cntr, \ .volt_trans_time = _volt_trans_time, \ .turn_on_time = _turn_on_time, \ - .bit_offset_from_cpcap_lowest_voltage = _bit_offset, \ }static const struct cpcap_regulator_data tegra20_regulators[CPCAP_REGULATORS_COUNT ] = {/* BUCK */ [CPCAP_SW1 ] =CPCAP_REG (S1C1 ,ASSIGN2 ,S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,1000 ,0 ), +1 ,0x0 ,0 , vrf1_val_tbl,0 ,10 ,1000 ), [CPCAP_VRF2 ] =CPCAP_REG (VRF2C ,ASSIGN3 ,VRF2_SEL ,0x0023 ,0x0008 , -3 ,0x0 ,0 , vrf2_val_tbl,0 ,10 ,1000 ,0 ), +3 ,0x0 ,0 , vrf2_val_tbl,0 ,10 ,1000 ), [CPCAP_VRFREF ] =CPCAP_REG (VRFREFC ,ASSIGN3 ,VRFREF_SEL ,0x0023 ,0x0008 , -3 ,0x0 ,0 , vrfref_val_tbl,0 ,420 ,100 ,0 ), +3 ,0x0 ,0 , vrfref_val_tbl,0 ,420 ,100 ), [CPCAP_VWLAN1 ] =CPCAP_REG (VWLAN1C ,ASSIGN3 ,VWLAN1_SEL ,0x0047 ,0x0010 , -4 ,0x0 ,0 , vwlan1_val_tbl,0 ,420 ,1000 ,0 ), +4 ,0x0 ,0 , vwlan1_val_tbl,0 ,420 ,1000 ), [CPCAP_VWLAN2 ] =CPCAP_REG (VWLAN2C ,ASSIGN3 ,VWLAN2_SEL ,0x020c ,0x00c0 , -6 ,0xd ,0 , vwlan2_val_tbl,0 ,420 ,1000 ,0 ), +6 ,0xd ,0 , vwlan2_val_tbl,0 ,420 ,1000 ), [CPCAP_VSIM ] =CPCAP_REG (VSIMC ,ASSIGN3 ,NONE ,0x0023 ,0x0008 , -3 ,0x0 ,0 , vsim_val_tbl,0 ,420 ,1000 ,0 ), +3 ,0x0 ,0 , vsim_val_tbl,0 ,420 ,1000 ), [CPCAP_VSIMCARD ] =CPCAP_REG (VSIMC ,ASSIGN3 ,NONE ,0x1e80 ,0x0008 , -3 ,0x1E00 ,0 , vsimcard_val_tbl,0 ,420 ,1000 ,0 ), +3 ,0x1E00 ,0 , vsimcard_val_tbl,0 ,420 ,1000 ), [CPCAP_VVIB ] =CPCAP_REG (VVIBC ,ASSIGN3 ,VVIB_SEL ,0x0001 ,0x000c , -2 ,0x1 ,0 , vvib_val_tbl,0 ,500 ,500 ,0 ), +2 ,0x1 ,0 , vvib_val_tbl,0 ,500 ,500 ), [CPCAP_VUSB ] =CPCAP_REG (VUSBC ,ASSIGN3 ,VUSB_SEL ,0x011c ,0x0040 , -6 ,0xc ,0 , vusb_val_tbl,0 ,0 ,1000 ,0 ), +6 ,0xc ,0 , vusb_val_tbl,0 ,0 ,1000 ), [CPCAP_VAUDIO ] =CPCAP_REG (VAUDIOC ,ASSIGN4 ,VAUDIO_SEL ,0x0016 ,0x0001 , -0 ,0x5 ,0 , vaudio_val_tbl,0 ,0 ,1000 ,0 ), +0 ,0x5 ,0 , vaudio_val_tbl,0 ,0 ,1000 ), };static int cpcap_regulator_get_value (struct udevice *dev)
@@ -139,7 +138,6 @@ static int cpcap_regulator_get_value(struct udevice *dev)return 0 ; value &= regulator->volt_mask; - value -= regulator->bit_offset_from_cpcap_lowest_voltage;return regulator->val_tbl[value >> volt_shift]; }
@@ -164,7 +162,6 @@ static int cpcap_regulator_set_value(struct udevice *dev, int uV) value = regulator->val_tbl_sz; value <<= volt_shift; - value += regulator->bit_offset_from_cpcap_lowest_voltage; } ret = pmic_clrsetbits(dev->parent, regulator->reg, regulator->volt_mask,
include/power/cpcap.h +15 -33
60 lines not on this page · raw message
Signature · 1 line
2.51.0
PATCH 2/5 power: pmic: cpcap: add Mapphone and Mot compatibles
In reply to Svyatoslav RyhelAdd Mapphone and Mot compatibles supported by Linux kernel.
--- drivers/power/pmic/cpcap.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/power/pmic/cpcap.c +2 -0
@@ -112,6 +112,8 @@ static struct dm_pmic_ops cpcap_ops = {static const struct udevice_id cpcap_ids[] = { { .compatible ="motorola,cpcap" }, { .compatible ="st,6556002" }, + { .compatible ="motorola,mapphone-cpcap" }, + { .compatible ="motorola,mot-cpcap" }, { } };
Signature · 1 line
2.51.0
PATCH 3/5 power: cpcap: make regulator node names case independent
In reply to Svyatoslav RyhelThe Linux kernel CPCAP driver uses uppercase regulator node names, while this driver uses lowercase. Since regulator names can be case-insensitive, update the driver to support both uppercase and lowercase node names.
--- drivers/power/pmic/cpcap.c | 2 ++ drivers/power/regulator/cpcap_regulator.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/power/pmic/cpcap.c +2 -0
@@ -14,7 +14,9 @@static const struct pmic_child_info pmic_children_info[] = { { .prefix ="sw" , .driver =CPCAP_SW_DRIVER }, + { .prefix ="SW" , .driver =CPCAP_SW_DRIVER }, { .prefix ="v" , .driver =CPCAP_LDO_DRIVER }, + { .prefix ="V" , .driver =CPCAP_LDO_DRIVER }, { }, };
drivers/power/regulator/cpcap_regulator.c +1 -1
@@ -229,7 +229,7 @@ static int cpcap_regulator_probe(struct udevice *dev)for (id =0 ; id <CPCAP_REGULATORS_COUNT ; id++)if (cpcap_regulator_to_name[id]) -if (!strcmp (dev->name, cpcap_regulator_to_name[id])) +if (!strcasecmp (dev->name, cpcap_regulator_to_name[id]))break ;switch (id) {
Signature · 1 line
2.51.0
PATCH 4/5 input: cpcap_pwrbutton: set default keycode fallback
In reply to Svyatoslav RyhelSet a default fallback value if no keycode is defined
--- drivers/input/cpcap_pwrbutton.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/input/cpcap_pwrbutton.c +1 -3
@@ -87,9 +87,7 @@ static int cpcap_pwrbutton_of_to_plat(struct udevice *dev) priv->bank = irq_desc /16 ; priv->id = irq_desc %16 ; - ret =dev_read_u32 (dev,"linux,code" , &priv->keycode); -if (ret) -return ret; + priv->keycode =dev_read_u32_default (dev,"linux,code" ,KEY_POWER ); priv->old_state = false; priv->skip = false;
Signature · 1 line
2.51.0
PATCH 5/5 input: cpcap_pwrbutton: simplify parent verification
In reply to Svyatoslav RyhelCheck for 'cpcap' within the compatible string, as various CPCAP compositions always include this component.
--- drivers/input/cpcap_pwrbutton.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/cpcap_pwrbutton.c +1 -1
@@ -76,7 +76,7 @@ static int cpcap_pwrbutton_of_to_plat(struct udevice *dev)/* Check interrupt parent, driver supports only CPCAP as parent */ irq_parent =ofnode_parse_phandle (dev_ofnode (dev),"interrupt-parent" ,0 ); -if (!ofnode_device_is_compatible (irq_parent,"motorola,cpcap" )) +if (!strstr (ofnode_get_name (irq_parent),"cpcap" ))return -EINVAL ; ret =dev_read_u32 (dev,"interrupts" , &irq_desc);
Signature · 1 line
2.51.0