Commit 288cb34e authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:
 "Power-supply core:
   - introduce power_supply_show_enum_with_available() helper
   - change usb_types from an array into a bitmask
   - fix early usage of power_supply_property_is_writeable() resulting
     in sysfs files not being writable
   - fix missing temp1_max_alarm attribute in power-supply's hwmon
     devices

  Drivers:
   - max1720x: expose nvmem device
   - brcmstb: cleanup driver to use latest APIs
   - max77693: expose input and charging current limit
   - max17042_battery: fix state of charge reading for devices without
     current sensing
   - axp20x_battery: add AXP717 support
   - axp20x_battery: fix min/max voltage properties
   - axp20x_usb_power: add AXP717 support
   - axp20x_usb_power: add DT based input current limit

  Documentation updates

  Misc minor cleanups and fixes"

* tag 'for-v6.12' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (38 commits)
  power: supply: hwmon: Fix missing temp1_max_alarm attribute
  power: supply: Drop use_cnt check from power_supply_property_is_writeable()
  power: supply: ab8500: Constify struct kobj_type
  power: supply: max1720x: fix a double free on error in probe()
  power: supply: axp20x_battery: add support for AXP717
  power: supply: axp20x_usb_power: Add support for AXP717
  dt-bindings: power: supply: axp20x: Add AXP717 compatible
  dt-bindings: power: supply: axp20x: Add AXP717 compatible
  power: supply: axp20x_usb_power: Fix spelling mistake "reqested" -> "requested"
  power: supply: Change usb_types from an array into a bitmask
  power: supply: sysfs: Move power_supply_show_enum_with_available() up
  power: supply: sysfs: Add power_supply_show_enum_with_available() helper
  power: supply: rt9467-charger: Remove "usb_type" property write support
  power: supply: ucs1002: Adjust ucs1002_set_usb_type() to accept string values
  power: supply: "usb_type" property may be written to
  power: supply: max1720x: add read support for nvmem
  mfd: axp20x: Add ADC, BAT, and USB cells for AXP717
  power: supply: core: constify psy_tzd_ops
  power: reset: brcmstb: Do not go into infinite loop if reset fails
  power: reset: brcmstb: Use devm_register_sys_off_handler()
  ...
parents bfbb9632 e50a57d1
...@@ -377,17 +377,33 @@ What: /sys/class/power_supply/<supply_name>/charge_type ...@@ -377,17 +377,33 @@ What: /sys/class/power_supply/<supply_name>/charge_type
Date: July 2009 Date: July 2009
Contact: linux-pm@vger.kernel.org Contact: linux-pm@vger.kernel.org
Description: Description:
Represents the type of charging currently being applied to the Select the charging algorithm to use for a battery.
battery. "Trickle", "Fast", and "Standard" all mean different
charging speeds. "Adaptive" means that the charger uses some Standard:
algorithm to adjust the charge rate dynamically, without Fully charge the battery at a moderate rate.
any user configuration required. "Custom" means that the charger Fast:
uses the charge_control_* properties as configuration for some Quickly charge the battery using fast-charge
different algorithm. "Long Life" means the charger reduces its technology. This is typically harder on the battery
charging rate in order to prolong the battery health. "Bypass" than standard charging and may lower its lifespan.
means the charger bypasses the charging path around the Trickle:
integrated converter allowing for a "smart" wall adaptor to Users who primarily operate the system while
perform the power conversion externally. plugged into an external power source can extend
battery life with this mode. Vendor tooling may
call this "Primarily AC Use".
Adaptive:
Automatically optimize battery charge rate based
on typical usage pattern.
Custom:
Use the charge_control_* properties to determine
when to start and stop charging. Advanced users
can use this to drastically extend battery life.
Long Life:
The charger reduces its charging rate in order to
prolong the battery health.
Bypass:
The charger bypasses the charging path around the
integrated converter allowing for a "smart" wall
adaptor to perform the power conversion externally.
Access: Read, Write Access: Read, Write
...@@ -592,7 +608,12 @@ Description: ...@@ -592,7 +608,12 @@ Description:
the supply, for example it can show if USB-PD capable source the supply, for example it can show if USB-PD capable source
is attached. is attached.
Access: Read-Only Access: For power-supplies which consume USB power such
as battery charger chips, this indicates the type of
the connected USB power source and is Read-Only.
For power-supplies which act as a USB power-source such as
e.g. the UCS1002 USB Port Power Controller this is writable.
Valid values: Valid values:
"Unknown", "SDP", "DCP", "CDP", "ACA", "C", "PD", "Unknown", "SDP", "DCP", "CDP", "ACA", "C", "PD",
......
...@@ -27,6 +27,9 @@ properties: ...@@ -27,6 +27,9 @@ properties:
battery-detect-gpios: battery-detect-gpios:
maxItems: 1 maxItems: 1
interrupts:
maxItems: 1
io-channels: io-channels:
items: items:
- description: Battery Temperature ADC - description: Battery Temperature ADC
...@@ -53,6 +56,7 @@ required: ...@@ -53,6 +56,7 @@ required:
- compatible - compatible
- reg - reg
- battery-detect-gpios - battery-detect-gpios
- interrupts
- io-channels - io-channels
- io-channel-names - io-channel-names
- nvmem-cells - nvmem-cells
...@@ -88,6 +92,8 @@ examples: ...@@ -88,6 +92,8 @@ examples:
compatible = "sprd,sc2731-fgu"; compatible = "sprd,sc2731-fgu";
reg = <0xa00>; reg = <0xa00>;
battery-detect-gpios = <&pmic_eic 9 GPIO_ACTIVE_HIGH>; battery-detect-gpios = <&pmic_eic 9 GPIO_ACTIVE_HIGH>;
interrupt-parent = <&sc2731_pmic>;
interrupts = <4>;
io-channels = <&pmic_adc 5>, <&pmic_adc 14>; io-channels = <&pmic_adc 5>, <&pmic_adc 14>;
io-channel-names = "bat-temp", "charge-vol"; io-channel-names = "bat-temp", "charge-vol";
nvmem-cells = <&fgu_calib>; nvmem-cells = <&fgu_calib>;
......
...@@ -23,11 +23,18 @@ properties: ...@@ -23,11 +23,18 @@ properties:
- const: x-powers,axp202-battery-power-supply - const: x-powers,axp202-battery-power-supply
- const: x-powers,axp209-battery-power-supply - const: x-powers,axp209-battery-power-supply
- const: x-powers,axp221-battery-power-supply - const: x-powers,axp221-battery-power-supply
- const: x-powers,axp717-battery-power-supply
- items: - items:
- const: x-powers,axp803-battery-power-supply - const: x-powers,axp803-battery-power-supply
- const: x-powers,axp813-battery-power-supply - const: x-powers,axp813-battery-power-supply
- const: x-powers,axp813-battery-power-supply - const: x-powers,axp813-battery-power-supply
monitored-battery:
description:
Specifies the phandle of an optional simple-battery connected to
this gauge.
$ref: /schemas/types.yaml#/definitions/phandle
required: required:
- compatible - compatible
......
...@@ -15,9 +15,6 @@ maintainers: ...@@ -15,9 +15,6 @@ maintainers:
- Chen-Yu Tsai <wens@csie.org> - Chen-Yu Tsai <wens@csie.org>
- Sebastian Reichel <sre@kernel.org> - Sebastian Reichel <sre@kernel.org>
allOf:
- $ref: power-supply.yaml#
properties: properties:
compatible: compatible:
oneOf: oneOf:
...@@ -26,13 +23,82 @@ properties: ...@@ -26,13 +23,82 @@ properties:
- x-powers,axp202-usb-power-supply - x-powers,axp202-usb-power-supply
- x-powers,axp221-usb-power-supply - x-powers,axp221-usb-power-supply
- x-powers,axp223-usb-power-supply - x-powers,axp223-usb-power-supply
- x-powers,axp717-usb-power-supply
- x-powers,axp813-usb-power-supply - x-powers,axp813-usb-power-supply
- items: - items:
- const: x-powers,axp803-usb-power-supply - const: x-powers,axp803-usb-power-supply
- const: x-powers,axp813-usb-power-supply - const: x-powers,axp813-usb-power-supply
input-current-limit-microamp:
description:
Optional value to clamp the maximum input current limit to for
the device. If omitted, the programmed value from the EFUSE will
be used.
minimum: 100000
maximum: 4000000
required: required:
- compatible - compatible
allOf:
- $ref: power-supply.yaml#
- if:
properties:
compatible:
contains:
enum:
- x-powers,axp192-usb-power-supply
then:
properties:
input-current-limit-microamp:
enum: [100000, 500000]
- if:
properties:
compatible:
contains:
enum:
- x-powers,axp202-usb-power-supply
- x-powers,axp223-usb-power-supply
then:
properties:
input-current-limit-microamp:
enum: [100000, 500000, 900000]
- if:
properties:
compatible:
contains:
enum:
- x-powers,axp221-usb-power-supply
then:
properties:
input-current-limit-microamp:
enum: [500000, 900000]
- if:
properties:
compatible:
contains:
enum:
- x-powers,axp717-usb-power-supply
then:
properties:
input-current-limit-microamp:
description: Maximum input current in increments of 50000 uA.
minimum: 100000
maximum: 3250000
- if:
properties:
compatible:
contains:
enum:
- x-powers,axp813-usb-power-supply
then:
properties:
input-current-limit-microamp:
enum: [100000, 500000, 900000, 1500000, 2000000, 2500000,
3000000, 3500000, 4000000]
additionalProperties: false additionalProperties: false
...@@ -461,14 +461,6 @@ static int cht_wc_extcon_psy_get_prop(struct power_supply *psy, ...@@ -461,14 +461,6 @@ static int cht_wc_extcon_psy_get_prop(struct power_supply *psy,
return 0; return 0;
} }
static const enum power_supply_usb_type cht_wc_extcon_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_ACA,
POWER_SUPPLY_USB_TYPE_UNKNOWN,
};
static const enum power_supply_property cht_wc_extcon_psy_props[] = { static const enum power_supply_property cht_wc_extcon_psy_props[] = {
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
...@@ -477,8 +469,11 @@ static const enum power_supply_property cht_wc_extcon_psy_props[] = { ...@@ -477,8 +469,11 @@ static const enum power_supply_property cht_wc_extcon_psy_props[] = {
static const struct power_supply_desc cht_wc_extcon_psy_desc = { static const struct power_supply_desc cht_wc_extcon_psy_desc = {
.name = "cht_wcove_pwrsrc", .name = "cht_wcove_pwrsrc",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = cht_wc_extcon_psy_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(cht_wc_extcon_psy_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_ACA) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = cht_wc_extcon_psy_props, .properties = cht_wc_extcon_psy_props,
.num_properties = ARRAY_SIZE(cht_wc_extcon_psy_props), .num_properties = ARRAY_SIZE(cht_wc_extcon_psy_props),
.get_property = cht_wc_extcon_psy_get_prop, .get_property = cht_wc_extcon_psy_get_prop,
......
...@@ -209,15 +209,23 @@ static const struct regmap_access_table axp313a_volatile_table = { ...@@ -209,15 +209,23 @@ static const struct regmap_access_table axp313a_volatile_table = {
}; };
static const struct regmap_range axp717_writeable_ranges[] = { static const struct regmap_range axp717_writeable_ranges[] = {
regmap_reg_range(AXP717_MODULE_EN_CONTROL_2, AXP717_MODULE_EN_CONTROL_2), regmap_reg_range(AXP717_PMU_FAULT, AXP717_MODULE_EN_CONTROL_1),
regmap_reg_range(AXP717_BOOST_CONTROL, AXP717_BOOST_CONTROL), regmap_reg_range(AXP717_MIN_SYS_V_CONTROL, AXP717_BOOST_CONTROL),
regmap_reg_range(AXP717_VSYS_V_POWEROFF, AXP717_VSYS_V_POWEROFF),
regmap_reg_range(AXP717_IRQ0_EN, AXP717_IRQ4_EN), regmap_reg_range(AXP717_IRQ0_EN, AXP717_IRQ4_EN),
regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE), regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE),
regmap_reg_range(AXP717_ICC_CHG_SET, AXP717_CV_CHG_SET),
regmap_reg_range(AXP717_DCDC_OUTPUT_CONTROL, AXP717_CPUSLDO_CONTROL), regmap_reg_range(AXP717_DCDC_OUTPUT_CONTROL, AXP717_CPUSLDO_CONTROL),
regmap_reg_range(AXP717_ADC_CH_EN_CONTROL, AXP717_ADC_CH_EN_CONTROL),
regmap_reg_range(AXP717_ADC_DATA_SEL, AXP717_ADC_DATA_SEL),
}; };
static const struct regmap_range axp717_volatile_ranges[] = { static const struct regmap_range axp717_volatile_ranges[] = {
regmap_reg_range(AXP717_ON_INDICATE, AXP717_PMU_FAULT),
regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE), regmap_reg_range(AXP717_IRQ0_STATE, AXP717_IRQ4_STATE),
regmap_reg_range(AXP717_BATT_PERCENT_DATA, AXP717_BATT_PERCENT_DATA),
regmap_reg_range(AXP717_BATT_V_H, AXP717_BATT_CHRG_I_L),
regmap_reg_range(AXP717_ADC_DATA_H, AXP717_ADC_DATA_L),
}; };
static const struct regmap_access_table axp717_writeable_table = { static const struct regmap_access_table axp717_writeable_table = {
...@@ -310,6 +318,12 @@ static const struct resource axp22x_usb_power_supply_resources[] = { ...@@ -310,6 +318,12 @@ static const struct resource axp22x_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"), DEFINE_RES_IRQ_NAMED(AXP22X_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
}; };
static const struct resource axp717_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP717_IRQ_VBUS_OVER_V, "VBUS_OVER_V"),
DEFINE_RES_IRQ_NAMED(AXP717_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
DEFINE_RES_IRQ_NAMED(AXP717_IRQ_VBUS_REMOVAL, "VBUS_REMOVAL"),
};
/* AXP803 and AXP813/AXP818 share the same interrupts */ /* AXP803 and AXP813/AXP818 share the same interrupts */
static const struct resource axp803_usb_power_supply_resources[] = { static const struct resource axp803_usb_power_supply_resources[] = {
DEFINE_RES_IRQ_NAMED(AXP803_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"), DEFINE_RES_IRQ_NAMED(AXP803_IRQ_VBUS_PLUGIN, "VBUS_PLUGIN"),
...@@ -424,7 +438,7 @@ static const struct regmap_config axp717_regmap_config = { ...@@ -424,7 +438,7 @@ static const struct regmap_config axp717_regmap_config = {
.val_bits = 8, .val_bits = 8,
.wr_table = &axp717_writeable_table, .wr_table = &axp717_writeable_table,
.volatile_table = &axp717_volatile_table, .volatile_table = &axp717_volatile_table,
.max_register = AXP717_CPUSLDO_CONTROL, .max_register = AXP717_ADC_DATA_L,
.cache_type = REGCACHE_MAPLE, .cache_type = REGCACHE_MAPLE,
}; };
...@@ -1026,6 +1040,13 @@ static struct mfd_cell axp313a_cells[] = { ...@@ -1026,6 +1040,13 @@ static struct mfd_cell axp313a_cells[] = {
static struct mfd_cell axp717_cells[] = { static struct mfd_cell axp717_cells[] = {
MFD_CELL_NAME("axp20x-regulator"), MFD_CELL_NAME("axp20x-regulator"),
MFD_CELL_RES("axp20x-pek", axp717_pek_resources), MFD_CELL_RES("axp20x-pek", axp717_pek_resources),
MFD_CELL_OF("axp717-adc",
NULL, NULL, 0, 0, "x-powers,axp717-adc"),
MFD_CELL_OF("axp20x-usb-power-supply",
axp717_usb_power_supply_resources, NULL, 0, 0,
"x-powers,axp717-usb-power-supply"),
MFD_CELL_OF("axp20x-battery-power-supply",
NULL, NULL, 0, 0, "x-powers,axp717-battery-power-supply"),
}; };
static const struct resource axp288_adc_resources[] = { static const struct resource axp288_adc_resources[] = {
......
...@@ -411,12 +411,6 @@ static int tusb1210_psy_get_prop(struct power_supply *psy, ...@@ -411,12 +411,6 @@ static int tusb1210_psy_get_prop(struct power_supply *psy,
return 0; return 0;
} }
static const enum power_supply_usb_type tusb1210_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_UNKNOWN,
};
static const enum power_supply_property tusb1210_psy_props[] = { static const enum power_supply_property tusb1210_psy_props[] = {
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
...@@ -426,8 +420,9 @@ static const enum power_supply_property tusb1210_psy_props[] = { ...@@ -426,8 +420,9 @@ static const enum power_supply_property tusb1210_psy_props[] = {
static const struct power_supply_desc tusb1210_psy_desc = { static const struct power_supply_desc tusb1210_psy_desc = {
.name = "tusb1211-charger-detect", .name = "tusb1211-charger-detect",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = tusb1210_psy_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(tusb1210_psy_usb_types), BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = tusb1210_psy_props, .properties = tusb1210_psy_props,
.num_properties = ARRAY_SIZE(tusb1210_psy_props), .num_properties = ARRAY_SIZE(tusb1210_psy_props),
.get_property = tusb1210_psy_get_prop, .get_property = tusb1210_psy_get_prop,
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/mfd/syscon.h> #include <linux/mfd/syscon.h>
#define RESET_SOURCE_ENABLE_REG 1
#define SW_MASTER_RESET_REG 2
static struct regmap *regmap; static struct regmap *regmap;
static u32 rst_src_en; static u32 rst_src_en;
static u32 sw_mstr_rst; static u32 sw_mstr_rst;
...@@ -32,8 +29,7 @@ struct reset_reg_mask { ...@@ -32,8 +29,7 @@ struct reset_reg_mask {
static const struct reset_reg_mask *reset_masks; static const struct reset_reg_mask *reset_masks;
static int brcmstb_restart_handler(struct notifier_block *this, static int brcmstb_restart_handler(struct sys_off_data *data)
unsigned long mode, void *cmd)
{ {
int rc; int rc;
u32 tmp; u32 tmp;
...@@ -62,17 +58,9 @@ static int brcmstb_restart_handler(struct notifier_block *this, ...@@ -62,17 +58,9 @@ static int brcmstb_restart_handler(struct notifier_block *this,
return NOTIFY_DONE; return NOTIFY_DONE;
} }
while (1)
;
return NOTIFY_DONE; return NOTIFY_DONE;
} }
static struct notifier_block brcmstb_restart_nb = {
.notifier_call = brcmstb_restart_handler,
.priority = 128,
};
static const struct reset_reg_mask reset_bits_40nm = { static const struct reset_reg_mask reset_bits_40nm = {
.rst_src_en_mask = BIT(0), .rst_src_en_mask = BIT(0),
.sw_mstr_rst_mask = BIT(0), .sw_mstr_rst_mask = BIT(0),
...@@ -83,46 +71,28 @@ static const struct reset_reg_mask reset_bits_65nm = { ...@@ -83,46 +71,28 @@ static const struct reset_reg_mask reset_bits_65nm = {
.sw_mstr_rst_mask = BIT(31), .sw_mstr_rst_mask = BIT(31),
}; };
static const struct of_device_id of_match[] = {
{ .compatible = "brcm,brcmstb-reboot", .data = &reset_bits_40nm },
{ .compatible = "brcm,bcm7038-reboot", .data = &reset_bits_65nm },
{},
};
static int brcmstb_reboot_probe(struct platform_device *pdev) static int brcmstb_reboot_probe(struct platform_device *pdev)
{ {
int rc; int rc;
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
const struct of_device_id *of_id; unsigned int args[2];
of_id = of_match_node(of_match, np); reset_masks = device_get_match_data(&pdev->dev);
if (!of_id) { if (!reset_masks) {
pr_err("failed to look up compatible string\n"); pr_err("failed to get match data\n");
return -EINVAL; return -EINVAL;
} }
reset_masks = of_id->data;
regmap = syscon_regmap_lookup_by_phandle(np, "syscon"); regmap = syscon_regmap_lookup_by_phandle_args(np, "syscon", ARRAY_SIZE(args), args);
if (IS_ERR(regmap)) { if (IS_ERR(regmap)) {
pr_err("failed to get syscon phandle\n"); pr_err("failed to get syscon phandle\n");
return -EINVAL; return -EINVAL;
} }
rst_src_en = args[0];
sw_mstr_rst = args[1];
rc = of_property_read_u32_index(np, "syscon", RESET_SOURCE_ENABLE_REG, rc = devm_register_sys_off_handler(&pdev->dev, SYS_OFF_MODE_RESTART,
&rst_src_en); 128, brcmstb_restart_handler, NULL);
if (rc) {
pr_err("can't get rst_src_en offset (%d)\n", rc);
return -EINVAL;
}
rc = of_property_read_u32_index(np, "syscon", SW_MASTER_RESET_REG,
&sw_mstr_rst);
if (rc) {
pr_err("can't get sw_mstr_rst offset (%d)\n", rc);
return -EINVAL;
}
rc = register_restart_handler(&brcmstb_restart_nb);
if (rc) if (rc)
dev_err(&pdev->dev, dev_err(&pdev->dev,
"cannot register restart handler (err=%d)\n", rc); "cannot register restart handler (err=%d)\n", rc);
...@@ -130,6 +100,12 @@ static int brcmstb_reboot_probe(struct platform_device *pdev) ...@@ -130,6 +100,12 @@ static int brcmstb_reboot_probe(struct platform_device *pdev)
return rc; return rc;
} }
static const struct of_device_id of_match[] = {
{ .compatible = "brcm,brcmstb-reboot", .data = &reset_bits_40nm },
{ .compatible = "brcm,bcm7038-reboot", .data = &reset_bits_65nm },
{},
};
static struct platform_driver brcmstb_reboot_driver = { static struct platform_driver brcmstb_reboot_driver = {
.probe = brcmstb_reboot_probe, .probe = brcmstb_reboot_probe,
.driver = { .driver = {
...@@ -140,7 +116,6 @@ static struct platform_driver brcmstb_reboot_driver = { ...@@ -140,7 +116,6 @@ static struct platform_driver brcmstb_reboot_driver = {
static int __init brcmstb_reboot_init(void) static int __init brcmstb_reboot_init(void)
{ {
return platform_driver_probe(&brcmstb_reboot_driver, return platform_driver_register(&brcmstb_reboot_driver);
brcmstb_reboot_probe);
} }
subsys_initcall(brcmstb_reboot_init); subsys_initcall(brcmstb_reboot_init);
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
struct pwr_mlxbf { struct pwr_mlxbf {
struct work_struct reboot_work; struct work_struct reboot_work;
struct work_struct shutdown_work;
const char *hid; const char *hid;
}; };
...@@ -27,22 +26,17 @@ static void pwr_mlxbf_reboot_work(struct work_struct *work) ...@@ -27,22 +26,17 @@ static void pwr_mlxbf_reboot_work(struct work_struct *work)
acpi_bus_generate_netlink_event("button/reboot.*", "Reboot Button", 0x80, 1); acpi_bus_generate_netlink_event("button/reboot.*", "Reboot Button", 0x80, 1);
} }
static void pwr_mlxbf_shutdown_work(struct work_struct *work)
{
acpi_bus_generate_netlink_event("button/power.*", "Power Button", 0x80, 1);
}
static irqreturn_t pwr_mlxbf_irq(int irq, void *ptr) static irqreturn_t pwr_mlxbf_irq(int irq, void *ptr)
{ {
const char *rst_pwr_hid = "MLNXBF24"; const char *rst_pwr_hid = "MLNXBF24";
const char *low_pwr_hid = "MLNXBF29"; const char *shutdown_hid = "MLNXBF29";
struct pwr_mlxbf *priv = ptr; struct pwr_mlxbf *priv = ptr;
if (!strncmp(priv->hid, rst_pwr_hid, 8)) if (!strncmp(priv->hid, rst_pwr_hid, 8))
schedule_work(&priv->reboot_work); schedule_work(&priv->reboot_work);
if (!strncmp(priv->hid, low_pwr_hid, 8)) if (!strncmp(priv->hid, shutdown_hid, 8))
schedule_work(&priv->shutdown_work); orderly_poweroff(true);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -70,10 +64,6 @@ static int pwr_mlxbf_probe(struct platform_device *pdev) ...@@ -70,10 +64,6 @@ static int pwr_mlxbf_probe(struct platform_device *pdev)
if (irq < 0) if (irq < 0)
return dev_err_probe(dev, irq, "Error getting %s irq.\n", priv->hid); return dev_err_probe(dev, irq, "Error getting %s irq.\n", priv->hid);
err = devm_work_autocancel(dev, &priv->shutdown_work, pwr_mlxbf_shutdown_work);
if (err)
return err;
err = devm_work_autocancel(dev, &priv->reboot_work, pwr_mlxbf_reboot_work); err = devm_work_autocancel(dev, &priv->reboot_work, pwr_mlxbf_reboot_work);
if (err) if (err)
return err; return err;
......
...@@ -2531,7 +2531,7 @@ static struct attribute *ab8500_fg_attrs[] = { ...@@ -2531,7 +2531,7 @@ static struct attribute *ab8500_fg_attrs[] = {
}; };
ATTRIBUTE_GROUPS(ab8500_fg); ATTRIBUTE_GROUPS(ab8500_fg);
static struct kobj_type ab8500_fg_ktype = { static const struct kobj_type ab8500_fg_ktype = {
.sysfs_ops = &ab8500_fg_sysfs_ops, .sysfs_ops = &ab8500_fg_sysfs_ops,
.default_groups = ab8500_fg_groups, .default_groups = ab8500_fg_groups,
}; };
......
This diff is collapsed.
This diff is collapsed.
...@@ -334,14 +334,6 @@ static const int bq25618_619_ichg_values[] = { ...@@ -334,14 +334,6 @@ static const int bq25618_619_ichg_values[] = {
1290000, 1360000, 1430000, 1500000 1290000, 1360000, 1430000, 1500000
}; };
static enum power_supply_usb_type bq256xx_usb_type[] = {
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_ACA,
};
static int bq256xx_array_parse(int array_size, int val, const int array[]) static int bq256xx_array_parse(int array_size, int val, const int array[])
{ {
int i = 0; int i = 0;
...@@ -1252,8 +1244,11 @@ static int bq256xx_property_is_writeable(struct power_supply *psy, ...@@ -1252,8 +1244,11 @@ static int bq256xx_property_is_writeable(struct power_supply *psy,
static const struct power_supply_desc bq256xx_power_supply_desc = { static const struct power_supply_desc bq256xx_power_supply_desc = {
.name = "bq256xx-charger", .name = "bq256xx-charger",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = bq256xx_usb_type, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(bq256xx_usb_type), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_ACA) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = bq256xx_power_supply_props, .properties = bq256xx_power_supply_props,
.num_properties = ARRAY_SIZE(bq256xx_power_supply_props), .num_properties = ARRAY_SIZE(bq256xx_power_supply_props),
.get_property = bq256xx_get_charger_property, .get_property = bq256xx_get_charger_property,
......
...@@ -904,7 +904,7 @@ static int cpcap_charger_probe(struct platform_device *pdev) ...@@ -904,7 +904,7 @@ static int cpcap_charger_probe(struct platform_device *pdev)
psy_cfg.of_node = pdev->dev.of_node; psy_cfg.of_node = pdev->dev.of_node;
psy_cfg.drv_data = ddata; psy_cfg.drv_data = ddata;
psy_cfg.supplied_to = cpcap_charger_supplied_to; psy_cfg.supplied_to = cpcap_charger_supplied_to;
psy_cfg.num_supplicants = ARRAY_SIZE(cpcap_charger_supplied_to), psy_cfg.num_supplicants = ARRAY_SIZE(cpcap_charger_supplied_to);
ddata->usb = devm_power_supply_register(ddata->dev, ddata->usb = devm_power_supply_register(ddata->dev,
&cpcap_charger_usb_desc, &cpcap_charger_usb_desc,
......
...@@ -73,17 +73,6 @@ static enum power_supply_property cros_usbpd_dedicated_charger_props[] = { ...@@ -73,17 +73,6 @@ static enum power_supply_property cros_usbpd_dedicated_charger_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_VOLTAGE_NOW,
}; };
static enum power_supply_usb_type cros_usbpd_charger_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_PD_DRP,
POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID
};
/* Input voltage/current limit in mV/mA. Default to none. */ /* Input voltage/current limit in mV/mA. Default to none. */
static u16 input_voltage_limit = EC_POWER_LIMIT_NONE; static u16 input_voltage_limit = EC_POWER_LIMIT_NONE;
static u16 input_current_limit = EC_POWER_LIMIT_NONE; static u16 input_current_limit = EC_POWER_LIMIT_NONE;
...@@ -643,9 +632,14 @@ static int cros_usbpd_charger_probe(struct platform_device *pd) ...@@ -643,9 +632,14 @@ static int cros_usbpd_charger_probe(struct platform_device *pd)
psy_desc->properties = cros_usbpd_charger_props; psy_desc->properties = cros_usbpd_charger_props;
psy_desc->num_properties = psy_desc->num_properties =
ARRAY_SIZE(cros_usbpd_charger_props); ARRAY_SIZE(cros_usbpd_charger_props);
psy_desc->usb_types = cros_usbpd_charger_usb_types; psy_desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
psy_desc->num_usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
ARRAY_SIZE(cros_usbpd_charger_usb_types); BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_C) |
BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_DRP) |
BIT(POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID);
} }
psy_desc->name = port->name; psy_desc->name = port->name;
......
...@@ -353,15 +353,10 @@ static enum power_supply_property yoga_c630_psy_adpt_properties[] = { ...@@ -353,15 +353,10 @@ static enum power_supply_property yoga_c630_psy_adpt_properties[] = {
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
}; };
static const enum power_supply_usb_type yoga_c630_psy_adpt_usb_type[] = {
POWER_SUPPLY_USB_TYPE_C,
};
static const struct power_supply_desc yoga_c630_psy_adpt_psy_desc = { static const struct power_supply_desc yoga_c630_psy_adpt_psy_desc = {
.name = "yoga-c630-adapter", .name = "yoga-c630-adapter",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = yoga_c630_psy_adpt_usb_type, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_C),
.num_usb_types = ARRAY_SIZE(yoga_c630_psy_adpt_usb_type),
.properties = yoga_c630_psy_adpt_properties, .properties = yoga_c630_psy_adpt_properties,
.num_properties = ARRAY_SIZE(yoga_c630_psy_adpt_properties), .num_properties = ARRAY_SIZE(yoga_c630_psy_adpt_properties),
.get_property = yoga_c630_psy_adpt_get_property, .get_property = yoga_c630_psy_adpt_get_property,
......
...@@ -853,7 +853,10 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off) ...@@ -853,7 +853,10 @@ static void max17042_set_soc_threshold(struct max17042_chip *chip, u16 off)
/* program interrupt thresholds such that we should /* program interrupt thresholds such that we should
* get interrupt for every 'off' perc change in the soc * get interrupt for every 'off' perc change in the soc
*/ */
if (chip->pdata->enable_current_sense)
regmap_read(map, MAX17042_RepSOC, &soc); regmap_read(map, MAX17042_RepSOC, &soc);
else
regmap_read(map, MAX17042_VFSOC, &soc);
soc >>= 8; soc >>= 8;
soc_tr = (soc + off) << 8; soc_tr = (soc + off) << 8;
if (off < soc) if (off < soc)
......
This diff is collapsed.
...@@ -197,12 +197,58 @@ static int max77693_get_online(struct regmap *regmap, int *val) ...@@ -197,12 +197,58 @@ static int max77693_get_online(struct regmap *regmap, int *val)
return 0; return 0;
} }
/*
* There are *two* current limit registers:
* - CHGIN limit, which limits the input current from the external charger;
* - Fast charge current limit, which limits the current going to the battery.
*/
static int max77693_get_input_current_limit(struct regmap *regmap, int *val)
{
unsigned int data;
int ret;
ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_CNFG_09, &data);
if (ret < 0)
return ret;
data &= CHG_CNFG_09_CHGIN_ILIM_MASK;
data >>= CHG_CNFG_09_CHGIN_ILIM_SHIFT;
if (data <= 0x03)
/* The first four values (0x00..0x03) are 60mA */
*val = 60000;
else
*val = data * 20000; /* 20mA steps */
return 0;
}
static int max77693_get_fast_charge_current(struct regmap *regmap, int *val)
{
unsigned int data;
int ret;
ret = regmap_read(regmap, MAX77693_CHG_REG_CHG_CNFG_02, &data);
if (ret < 0)
return ret;
data &= CHG_CNFG_02_CC_MASK;
data >>= CHG_CNFG_02_CC_SHIFT;
*val = data * 33300; /* 33.3mA steps */
return 0;
}
static enum power_supply_property max77693_charger_props[] = { static enum power_supply_property max77693_charger_props[] = {
POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_CHARGE_TYPE, POWER_SUPPLY_PROP_CHARGE_TYPE,
POWER_SUPPLY_PROP_HEALTH, POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
POWER_SUPPLY_PROP_MODEL_NAME, POWER_SUPPLY_PROP_MODEL_NAME,
POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_MANUFACTURER,
}; };
...@@ -231,6 +277,12 @@ static int max77693_charger_get_property(struct power_supply *psy, ...@@ -231,6 +277,12 @@ static int max77693_charger_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_ONLINE: case POWER_SUPPLY_PROP_ONLINE:
ret = max77693_get_online(regmap, &val->intval); ret = max77693_get_online(regmap, &val->intval);
break; break;
case POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT:
ret = max77693_get_input_current_limit(regmap, &val->intval);
break;
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
ret = max77693_get_fast_charge_current(regmap, &val->intval);
break;
case POWER_SUPPLY_PROP_MODEL_NAME: case POWER_SUPPLY_PROP_MODEL_NAME:
val->strval = max77693_charger_model; val->strval = max77693_charger_model;
break; break;
......
...@@ -191,6 +191,7 @@ static const struct platform_device_id max8998_battery_id[] = { ...@@ -191,6 +191,7 @@ static const struct platform_device_id max8998_battery_id[] = {
{ "max8998-battery", TYPE_MAX8998 }, { "max8998-battery", TYPE_MAX8998 },
{ } { }
}; };
MODULE_DEVICE_TABLE(platform, max8998_battery_id);
static struct platform_driver max8998_battery_driver = { static struct platform_driver max8998_battery_driver = {
.driver = { .driver = {
......
...@@ -94,14 +94,6 @@ struct mp2629_prop { ...@@ -94,14 +94,6 @@ struct mp2629_prop {
int shift; int shift;
}; };
static enum power_supply_usb_type mp2629_usb_types[] = {
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_PD_DRP,
POWER_SUPPLY_USB_TYPE_UNKNOWN
};
static enum power_supply_property mp2629_charger_usb_props[] = { static enum power_supply_property mp2629_charger_usb_props[] = {
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
...@@ -487,8 +479,11 @@ static irqreturn_t mp2629_irq_handler(int irq, void *dev_id) ...@@ -487,8 +479,11 @@ static irqreturn_t mp2629_irq_handler(int irq, void *dev_id)
static const struct power_supply_desc mp2629_usb_desc = { static const struct power_supply_desc mp2629_usb_desc = {
.name = "mp2629_usb", .name = "mp2629_usb",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = mp2629_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(mp2629_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_PD_DRP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = mp2629_charger_usb_props, .properties = mp2629_charger_usb_props,
.num_properties = ARRAY_SIZE(mp2629_charger_usb_props), .num_properties = ARRAY_SIZE(mp2629_charger_usb_props),
.get_property = mp2629_charger_usb_get_prop, .get_property = mp2629_charger_usb_get_prop,
......
...@@ -154,13 +154,6 @@ enum mt6360_pmu_chg_type { ...@@ -154,13 +154,6 @@ enum mt6360_pmu_chg_type {
MT6360_CHG_TYPE_MAX, MT6360_CHG_TYPE_MAX,
}; };
static enum power_supply_usb_type mt6360_charger_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
};
static int mt6360_get_chrdet_ext_stat(struct mt6360_chg_info *mci, static int mt6360_get_chrdet_ext_stat(struct mt6360_chg_info *mci,
bool *pwr_rdy) bool *pwr_rdy)
{ {
...@@ -574,8 +567,10 @@ static const struct power_supply_desc mt6360_charger_desc = { ...@@ -574,8 +567,10 @@ static const struct power_supply_desc mt6360_charger_desc = {
.get_property = mt6360_charger_get_property, .get_property = mt6360_charger_get_property,
.set_property = mt6360_charger_set_property, .set_property = mt6360_charger_set_property,
.property_is_writeable = mt6360_charger_property_is_writeable, .property_is_writeable = mt6360_charger_property_is_writeable,
.usb_types = mt6360_charger_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(mt6360_charger_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
}; };
static const struct regulator_ops mt6360_chg_otg_ops = { static const struct regulator_ops mt6360_chg_otg_ops = {
......
...@@ -624,13 +624,6 @@ static enum power_supply_property mt6370_chg_properties[] = { ...@@ -624,13 +624,6 @@ static enum power_supply_property mt6370_chg_properties[] = {
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
}; };
static enum power_supply_usb_type mt6370_chg_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_DCP,
};
static const struct power_supply_desc mt6370_chg_psy_desc = { static const struct power_supply_desc mt6370_chg_psy_desc = {
.name = "mt6370-charger", .name = "mt6370-charger",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
...@@ -639,8 +632,10 @@ static const struct power_supply_desc mt6370_chg_psy_desc = { ...@@ -639,8 +632,10 @@ static const struct power_supply_desc mt6370_chg_psy_desc = {
.get_property = mt6370_chg_get_property, .get_property = mt6370_chg_get_property,
.set_property = mt6370_chg_set_property, .set_property = mt6370_chg_set_property,
.property_is_writeable = mt6370_chg_property_is_writeable, .property_is_writeable = mt6370_chg_property_is_writeable,
.usb_types = mt6370_chg_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(mt6370_chg_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
}; };
static const struct regulator_ops mt6370_chg_otg_ops = { static const struct regulator_ops mt6370_chg_otg_ops = {
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
* Modified: 2004, Oct Szabolcs Gyurko * Modified: 2004, Oct Szabolcs Gyurko
*/ */
#include <linux/cleanup.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/init.h> #include <linux/init.h>
...@@ -756,10 +757,10 @@ int power_supply_get_battery_info(struct power_supply *psy, ...@@ -756,10 +757,10 @@ int power_supply_get_battery_info(struct power_supply *psy,
for (index = 0; index < len; index++) { for (index = 0; index < len; index++) {
struct power_supply_battery_ocv_table *table; struct power_supply_battery_ocv_table *table;
char *propname;
int i, tab_len, size; int i, tab_len, size;
propname = kasprintf(GFP_KERNEL, "ocv-capacity-table-%d", index); char *propname __free(kfree) = kasprintf(GFP_KERNEL, "ocv-capacity-table-%d",
index);
if (!propname) { if (!propname) {
power_supply_put_battery_info(psy, info); power_supply_put_battery_info(psy, info);
err = -ENOMEM; err = -ENOMEM;
...@@ -768,13 +769,11 @@ int power_supply_get_battery_info(struct power_supply *psy, ...@@ -768,13 +769,11 @@ int power_supply_get_battery_info(struct power_supply *psy,
list = of_get_property(battery_np, propname, &size); list = of_get_property(battery_np, propname, &size);
if (!list || !size) { if (!list || !size) {
dev_err(&psy->dev, "failed to get %s\n", propname); dev_err(&psy->dev, "failed to get %s\n", propname);
kfree(propname);
power_supply_put_battery_info(psy, info); power_supply_put_battery_info(psy, info);
err = -EINVAL; err = -EINVAL;
goto out_put_node; goto out_put_node;
} }
kfree(propname);
tab_len = size / (2 * sizeof(__be32)); tab_len = size / (2 * sizeof(__be32));
info->ocv_table_size[index] = tab_len; info->ocv_table_size[index] = tab_len;
...@@ -1232,11 +1231,7 @@ EXPORT_SYMBOL_GPL(power_supply_set_property); ...@@ -1232,11 +1231,7 @@ EXPORT_SYMBOL_GPL(power_supply_set_property);
int power_supply_property_is_writeable(struct power_supply *psy, int power_supply_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp) enum power_supply_property psp)
{ {
if (atomic_read(&psy->use_cnt) <= 0 || return psy->desc->property_is_writeable && psy->desc->property_is_writeable(psy, psp);
!psy->desc->property_is_writeable)
return -ENODEV;
return psy->desc->property_is_writeable(psy, psp);
} }
EXPORT_SYMBOL_GPL(power_supply_property_is_writeable); EXPORT_SYMBOL_GPL(power_supply_property_is_writeable);
...@@ -1296,7 +1291,7 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd, ...@@ -1296,7 +1291,7 @@ static int power_supply_read_temp(struct thermal_zone_device *tzd,
return ret; return ret;
} }
static struct thermal_zone_device_ops psy_tzd_ops = { static const struct thermal_zone_device_ops psy_tzd_ops = {
.get_temp = power_supply_read_temp, .get_temp = power_supply_read_temp,
}; };
...@@ -1361,10 +1356,6 @@ __power_supply_register(struct device *parent, ...@@ -1361,10 +1356,6 @@ __power_supply_register(struct device *parent,
pr_warn("%s: Expected proper parent device for '%s'\n", pr_warn("%s: Expected proper parent device for '%s'\n",
__func__, desc->name); __func__, desc->name);
if (psy_has_property(desc, POWER_SUPPLY_PROP_USB_TYPE) &&
(!desc->usb_types || !desc->num_usb_types))
return ERR_PTR(-EINVAL);
psy = kzalloc(sizeof(*psy), GFP_KERNEL); psy = kzalloc(sizeof(*psy), GFP_KERNEL);
if (!psy) if (!psy)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
...@@ -318,7 +318,8 @@ static const struct hwmon_channel_info * const power_supply_hwmon_info[] = { ...@@ -318,7 +318,8 @@ static const struct hwmon_channel_info * const power_supply_hwmon_info[] = {
HWMON_T_INPUT | HWMON_T_INPUT |
HWMON_T_MAX | HWMON_T_MAX |
HWMON_T_MIN | HWMON_T_MIN |
HWMON_T_MIN_ALARM, HWMON_T_MIN_ALARM |
HWMON_T_MAX_ALARM,
HWMON_T_LABEL | HWMON_T_LABEL |
HWMON_T_INPUT | HWMON_T_INPUT |
......
...@@ -209,7 +209,7 @@ static struct power_supply_attr power_supply_attrs[] = { ...@@ -209,7 +209,7 @@ static struct power_supply_attr power_supply_attrs[] = {
POWER_SUPPLY_ATTR(TIME_TO_FULL_NOW), POWER_SUPPLY_ATTR(TIME_TO_FULL_NOW),
POWER_SUPPLY_ATTR(TIME_TO_FULL_AVG), POWER_SUPPLY_ATTR(TIME_TO_FULL_AVG),
POWER_SUPPLY_ENUM_ATTR(TYPE), POWER_SUPPLY_ENUM_ATTR(TYPE),
POWER_SUPPLY_ATTR(USB_TYPE), POWER_SUPPLY_ENUM_ATTR(USB_TYPE),
POWER_SUPPLY_ENUM_ATTR(SCOPE), POWER_SUPPLY_ENUM_ATTR(SCOPE),
POWER_SUPPLY_ATTR(PRECHARGE_CURRENT), POWER_SUPPLY_ATTR(PRECHARGE_CURRENT),
POWER_SUPPLY_ATTR(CHARGE_TERM_CURRENT), POWER_SUPPLY_ATTR(CHARGE_TERM_CURRENT),
...@@ -237,31 +237,28 @@ static enum power_supply_property dev_attr_psp(struct device_attribute *attr) ...@@ -237,31 +237,28 @@ static enum power_supply_property dev_attr_psp(struct device_attribute *attr)
return to_ps_attr(attr) - power_supply_attrs; return to_ps_attr(attr) - power_supply_attrs;
} }
static ssize_t power_supply_show_usb_type(struct device *dev, static ssize_t power_supply_show_enum_with_available(
const struct power_supply_desc *desc, struct device *dev, const char * const labels[], int label_count,
union power_supply_propval *value, unsigned int available_values, int value, char *buf)
char *buf)
{ {
enum power_supply_usb_type usb_type; bool match = false, available, active;
ssize_t count = 0; ssize_t count = 0;
bool match = false;
int i; int i;
for (i = 0; i < desc->num_usb_types; ++i) { for (i = 0; i < label_count; i++) {
usb_type = desc->usb_types[i]; available = available_values & BIT(i);
active = i == value;
if (value->intval == usb_type) { if (available && active) {
count += sysfs_emit_at(buf, count, "[%s] ", count += sysfs_emit_at(buf, count, "[%s] ", labels[i]);
POWER_SUPPLY_USB_TYPE_TEXT[usb_type]);
match = true; match = true;
} else { } else if (available) {
count += sysfs_emit_at(buf, count, "%s ", count += sysfs_emit_at(buf, count, "%s ", labels[i]);
POWER_SUPPLY_USB_TYPE_TEXT[usb_type]);
} }
} }
if (!match) { if (!match) {
dev_warn(dev, "driver reporting unsupported connected type\n"); dev_warn(dev, "driver reporting unavailable enum value %d\n", value);
return -EINVAL; return -EINVAL;
} }
...@@ -300,8 +297,10 @@ static ssize_t power_supply_show_property(struct device *dev, ...@@ -300,8 +297,10 @@ static ssize_t power_supply_show_property(struct device *dev,
switch (psp) { switch (psp) {
case POWER_SUPPLY_PROP_USB_TYPE: case POWER_SUPPLY_PROP_USB_TYPE:
ret = power_supply_show_usb_type(dev, psy->desc, ret = power_supply_show_enum_with_available(
&value, buf); dev, POWER_SUPPLY_USB_TYPE_TEXT,
ARRAY_SIZE(POWER_SUPPLY_USB_TYPE_TEXT),
psy->desc->usb_types, value.intval, buf);
break; break;
case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR: case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours, ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
...@@ -523,33 +522,10 @@ ssize_t power_supply_charge_behaviour_show(struct device *dev, ...@@ -523,33 +522,10 @@ ssize_t power_supply_charge_behaviour_show(struct device *dev,
enum power_supply_charge_behaviour current_behaviour, enum power_supply_charge_behaviour current_behaviour,
char *buf) char *buf)
{ {
bool match = false, available, active; return power_supply_show_enum_with_available(
ssize_t count = 0; dev, POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT,
int i; ARRAY_SIZE(POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT),
available_behaviours, current_behaviour, buf);
for (i = 0; i < ARRAY_SIZE(POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT); i++) {
available = available_behaviours & BIT(i);
active = i == current_behaviour;
if (available && active) {
count += sysfs_emit_at(buf, count, "[%s] ",
POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT[i]);
match = true;
} else if (available) {
count += sysfs_emit_at(buf, count, "%s ",
POWER_SUPPLY_CHARGE_BEHAVIOUR_TEXT[i]);
}
}
if (!match) {
dev_warn(dev, "driver reporting unsupported charge behaviour\n");
return -EINVAL;
}
if (count)
buf[count - 1] = '\n';
return count;
} }
EXPORT_SYMBOL_GPL(power_supply_charge_behaviour_show); EXPORT_SYMBOL_GPL(power_supply_charge_behaviour_show);
......
...@@ -786,19 +786,6 @@ static int qcom_battmgr_usb_get_property(struct power_supply *psy, ...@@ -786,19 +786,6 @@ static int qcom_battmgr_usb_get_property(struct power_supply *psy,
return 0; return 0;
} }
static const enum power_supply_usb_type usb_psy_supported_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_ACA,
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_PD_DRP,
POWER_SUPPLY_USB_TYPE_PD_PPS,
POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID,
};
static const enum power_supply_property sc8280xp_usb_props[] = { static const enum power_supply_property sc8280xp_usb_props[] = {
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
}; };
...@@ -809,8 +796,16 @@ static const struct power_supply_desc sc8280xp_usb_psy_desc = { ...@@ -809,8 +796,16 @@ static const struct power_supply_desc sc8280xp_usb_psy_desc = {
.properties = sc8280xp_usb_props, .properties = sc8280xp_usb_props,
.num_properties = ARRAY_SIZE(sc8280xp_usb_props), .num_properties = ARRAY_SIZE(sc8280xp_usb_props),
.get_property = qcom_battmgr_usb_get_property, .get_property = qcom_battmgr_usb_get_property,
.usb_types = usb_psy_supported_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
.num_usb_types = ARRAY_SIZE(usb_psy_supported_types), BIT(POWER_SUPPLY_USB_TYPE_SDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_ACA) |
BIT(POWER_SUPPLY_USB_TYPE_C) |
BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_DRP) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS) |
BIT(POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID),
}; };
static const enum power_supply_property sm8350_usb_props[] = { static const enum power_supply_property sm8350_usb_props[] = {
...@@ -829,8 +824,16 @@ static const struct power_supply_desc sm8350_usb_psy_desc = { ...@@ -829,8 +824,16 @@ static const struct power_supply_desc sm8350_usb_psy_desc = {
.properties = sm8350_usb_props, .properties = sm8350_usb_props,
.num_properties = ARRAY_SIZE(sm8350_usb_props), .num_properties = ARRAY_SIZE(sm8350_usb_props),
.get_property = qcom_battmgr_usb_get_property, .get_property = qcom_battmgr_usb_get_property,
.usb_types = usb_psy_supported_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
.num_usb_types = ARRAY_SIZE(usb_psy_supported_types), BIT(POWER_SUPPLY_USB_TYPE_SDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_ACA) |
BIT(POWER_SUPPLY_USB_TYPE_C) |
BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_DRP) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS) |
BIT(POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID),
}; };
static const u8 sm8350_wls_prop_map[] = { static const u8 sm8350_wls_prop_map[] = {
......
...@@ -411,13 +411,6 @@ static enum power_supply_property smb2_properties[] = { ...@@ -411,13 +411,6 @@ static enum power_supply_property smb2_properties[] = {
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
}; };
static enum power_supply_usb_type smb2_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
};
static int smb2_get_prop_usb_online(struct smb2_chip *chip, int *val) static int smb2_get_prop_usb_online(struct smb2_chip *chip, int *val)
{ {
unsigned int stat; unsigned int stat;
...@@ -775,8 +768,10 @@ static irqreturn_t smb2_handle_wdog_bark(int irq, void *data) ...@@ -775,8 +768,10 @@ static irqreturn_t smb2_handle_wdog_bark(int irq, void *data)
static const struct power_supply_desc smb2_psy_desc = { static const struct power_supply_desc smb2_psy_desc = {
.name = "pmi8998_charger", .name = "pmi8998_charger",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = smb2_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(smb2_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = smb2_properties, .properties = smb2_properties,
.num_properties = ARRAY_SIZE(smb2_properties), .num_properties = ARRAY_SIZE(smb2_properties),
.get_property = smb2_get_property, .get_property = smb2_get_property,
......
...@@ -673,11 +673,6 @@ static enum power_supply_property rk817_chg_props[] = { ...@@ -673,11 +673,6 @@ static enum power_supply_property rk817_chg_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_AVG, POWER_SUPPLY_PROP_VOLTAGE_AVG,
}; };
static enum power_supply_usb_type rk817_usb_type[] = {
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_UNKNOWN,
};
static const struct power_supply_desc rk817_bat_desc = { static const struct power_supply_desc rk817_bat_desc = {
.name = "rk817-battery", .name = "rk817-battery",
.type = POWER_SUPPLY_TYPE_BATTERY, .type = POWER_SUPPLY_TYPE_BATTERY,
...@@ -689,8 +684,8 @@ static const struct power_supply_desc rk817_bat_desc = { ...@@ -689,8 +684,8 @@ static const struct power_supply_desc rk817_bat_desc = {
static const struct power_supply_desc rk817_chg_desc = { static const struct power_supply_desc rk817_chg_desc = {
.name = "rk817-charger", .name = "rk817-charger",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = rk817_usb_type, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_DCP) |
.num_usb_types = ARRAY_SIZE(rk817_usb_type), BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = rk817_chg_props, .properties = rk817_chg_props,
.num_properties = ARRAY_SIZE(rk817_chg_props), .num_properties = ARRAY_SIZE(rk817_chg_props),
.get_property = rk817_chg_get_prop, .get_property = rk817_chg_get_prop,
......
...@@ -70,13 +70,6 @@ struct rn5t618_power_info { ...@@ -70,13 +70,6 @@ struct rn5t618_power_info {
int irq; int irq;
}; };
static enum power_supply_usb_type rn5t618_usb_types[] = {
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_UNKNOWN
};
static enum power_supply_property rn5t618_usb_props[] = { static enum power_supply_property rn5t618_usb_props[] = {
/* input current limit is not very accurate */ /* input current limit is not very accurate */
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT, POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
...@@ -681,8 +674,10 @@ static const struct power_supply_desc rn5t618_adp_desc = { ...@@ -681,8 +674,10 @@ static const struct power_supply_desc rn5t618_adp_desc = {
static const struct power_supply_desc rn5t618_usb_desc = { static const struct power_supply_desc rn5t618_usb_desc = {
.name = "rn5t618-usb", .name = "rn5t618-usb",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = rn5t618_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(rn5t618_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = rn5t618_usb_props, .properties = rn5t618_usb_props,
.num_properties = ARRAY_SIZE(rn5t618_usb_props), .num_properties = ARRAY_SIZE(rn5t618_usb_props),
.get_property = rn5t618_usb_get_property, .get_property = rn5t618_usb_get_property,
......
...@@ -630,13 +630,6 @@ static int rt9467_psy_set_ieoc(struct rt9467_chg_data *data, int microamp) ...@@ -630,13 +630,6 @@ static int rt9467_psy_set_ieoc(struct rt9467_chg_data *data, int microamp)
return ret; return ret;
} }
static const enum power_supply_usb_type rt9467_chg_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
};
static const enum power_supply_property rt9467_chg_properties[] = { static const enum power_supply_property rt9467_chg_properties[] = {
POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
...@@ -745,8 +738,6 @@ static int rt9467_psy_set_property(struct power_supply *psy, ...@@ -745,8 +738,6 @@ static int rt9467_psy_set_property(struct power_supply *psy,
RT9467_RANGE_IPREC, val->intval); RT9467_RANGE_IPREC, val->intval);
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
return rt9467_psy_set_ieoc(data, val->intval); return rt9467_psy_set_ieoc(data, val->intval);
case POWER_SUPPLY_PROP_USB_TYPE:
return regmap_field_write(data->rm_field[F_USBCHGEN], val->intval);
default: default:
return -EINVAL; return -EINVAL;
} }
...@@ -764,7 +755,6 @@ static int rt9467_chg_prop_is_writeable(struct power_supply *psy, ...@@ -764,7 +755,6 @@ static int rt9467_chg_prop_is_writeable(struct power_supply *psy,
case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT: case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT:
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT: case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
case POWER_SUPPLY_PROP_PRECHARGE_CURRENT: case POWER_SUPPLY_PROP_PRECHARGE_CURRENT:
case POWER_SUPPLY_PROP_USB_TYPE:
return 1; return 1;
default: default:
return 0; return 0;
...@@ -774,8 +764,10 @@ static int rt9467_chg_prop_is_writeable(struct power_supply *psy, ...@@ -774,8 +764,10 @@ static int rt9467_chg_prop_is_writeable(struct power_supply *psy,
static const struct power_supply_desc rt9467_chg_psy_desc = { static const struct power_supply_desc rt9467_chg_psy_desc = {
.name = "rt9467-charger", .name = "rt9467-charger",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = rt9467_chg_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(rt9467_chg_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.properties = rt9467_chg_properties, .properties = rt9467_chg_properties,
.num_properties = ARRAY_SIZE(rt9467_chg_properties), .num_properties = ARRAY_SIZE(rt9467_chg_properties),
.property_is_writeable = rt9467_chg_prop_is_writeable, .property_is_writeable = rt9467_chg_prop_is_writeable,
......
...@@ -333,14 +333,6 @@ static enum power_supply_property rt9471_charger_properties[] = { ...@@ -333,14 +333,6 @@ static enum power_supply_property rt9471_charger_properties[] = {
POWER_SUPPLY_PROP_MANUFACTURER, POWER_SUPPLY_PROP_MANUFACTURER,
}; };
static enum power_supply_usb_type rt9471_charger_usb_types[] = {
POWER_SUPPLY_USB_TYPE_UNKNOWN,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID,
};
static int rt9471_charger_property_is_writeable(struct power_supply *psy, static int rt9471_charger_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp) enum power_supply_property psp)
{ {
...@@ -726,8 +718,11 @@ static int rt9471_register_psy(struct rt9471_chip *chip) ...@@ -726,8 +718,11 @@ static int rt9471_register_psy(struct rt9471_chip *chip)
desc->name = psy_name; desc->name = psy_name;
desc->type = POWER_SUPPLY_TYPE_USB; desc->type = POWER_SUPPLY_TYPE_USB;
desc->usb_types = rt9471_charger_usb_types; desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
desc->num_usb_types = ARRAY_SIZE(rt9471_charger_usb_types); BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_APPLE_BRICK_ID) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN);
desc->properties = rt9471_charger_properties; desc->properties = rt9471_charger_properties;
desc->num_properties = ARRAY_SIZE(rt9471_charger_properties); desc->num_properties = ARRAY_SIZE(rt9471_charger_properties);
desc->get_property = rt9471_charger_get_property; desc->get_property = rt9471_charger_get_property;
......
...@@ -363,7 +363,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci) ...@@ -363,7 +363,7 @@ static int twl4030_charger_update_current(struct twl4030_bci *bci)
if (status < 0) if (status < 0)
return status; return status;
cur_reg |= oldreg << 8; cur_reg |= oldreg << 8;
if (reg != oldreg) { if (reg != cur_reg) {
/* disable write protection for one write access for /* disable write protection for one write access for
* BCIIREF */ * BCIIREF */
status = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 0xE7, status = twl_i2c_write_u8(TWL_MODULE_MAIN_CHARGE, 0xE7,
......
...@@ -296,22 +296,17 @@ static int ucs1002_set_max_current(struct ucs1002_info *info, u32 val) ...@@ -296,22 +296,17 @@ static int ucs1002_set_max_current(struct ucs1002_info *info, u32 val)
return 0; return 0;
} }
static enum power_supply_usb_type ucs1002_usb_types[] = {
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_SDP,
POWER_SUPPLY_USB_TYPE_DCP,
POWER_SUPPLY_USB_TYPE_CDP,
POWER_SUPPLY_USB_TYPE_UNKNOWN,
};
static int ucs1002_set_usb_type(struct ucs1002_info *info, int val) static int ucs1002_set_usb_type(struct ucs1002_info *info, int val)
{ {
unsigned int mode; unsigned int mode;
if (val < 0 || val >= ARRAY_SIZE(ucs1002_usb_types)) switch (val) {
return -EINVAL; /*
* POWER_SUPPLY_USB_TYPE_UNKNOWN == 0, map this to dedicated for
switch (ucs1002_usb_types[val]) { * userspace API compatibility with older versions of this driver
* which mapped 0 to dedicated.
*/
case POWER_SUPPLY_USB_TYPE_UNKNOWN:
case POWER_SUPPLY_USB_TYPE_PD: case POWER_SUPPLY_USB_TYPE_PD:
mode = V_SET_ACTIVE_MODE_DEDICATED; mode = V_SET_ACTIVE_MODE_DEDICATED;
break; break;
...@@ -428,8 +423,11 @@ static int ucs1002_property_is_writeable(struct power_supply *psy, ...@@ -428,8 +423,11 @@ static int ucs1002_property_is_writeable(struct power_supply *psy,
static const struct power_supply_desc ucs1002_charger_desc = { static const struct power_supply_desc ucs1002_charger_desc = {
.name = "ucs1002", .name = "ucs1002",
.type = POWER_SUPPLY_TYPE_USB, .type = POWER_SUPPLY_TYPE_USB,
.usb_types = ucs1002_usb_types, .usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
.num_usb_types = ARRAY_SIZE(ucs1002_usb_types), BIT(POWER_SUPPLY_USB_TYPE_CDP) |
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
.get_property = ucs1002_get_property, .get_property = ucs1002_get_property,
.set_property = ucs1002_set_property, .set_property = ucs1002_set_property,
.property_is_writeable = ucs1002_property_is_writeable, .property_is_writeable = ucs1002_property_is_writeable,
......
...@@ -1339,12 +1339,6 @@ static void anx7411_get_gpio_irq(struct anx7411_data *ctx) ...@@ -1339,12 +1339,6 @@ static void anx7411_get_gpio_irq(struct anx7411_data *ctx)
dev_err(dev, "failed to get GPIO IRQ\n"); dev_err(dev, "failed to get GPIO IRQ\n");
} }
static enum power_supply_usb_type anx7411_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_PD_PPS,
};
static enum power_supply_property anx7411_psy_props[] = { static enum power_supply_property anx7411_psy_props[] = {
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
...@@ -1422,8 +1416,9 @@ static int anx7411_psy_register(struct anx7411_data *ctx) ...@@ -1422,8 +1416,9 @@ static int anx7411_psy_register(struct anx7411_data *ctx)
psy_desc->name = psy_name; psy_desc->name = psy_name;
psy_desc->type = POWER_SUPPLY_TYPE_USB; psy_desc->type = POWER_SUPPLY_TYPE_USB;
psy_desc->usb_types = anx7411_psy_usb_types; psy_desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
psy_desc->num_usb_types = ARRAY_SIZE(anx7411_psy_usb_types); BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
psy_desc->properties = anx7411_psy_props; psy_desc->properties = anx7411_psy_props;
psy_desc->num_properties = ARRAY_SIZE(anx7411_psy_props); psy_desc->num_properties = ARRAY_SIZE(anx7411_psy_props);
......
...@@ -109,12 +109,6 @@ struct rt1719_data { ...@@ -109,12 +109,6 @@ struct rt1719_data {
u16 conn_stat; u16 conn_stat;
}; };
static const enum power_supply_usb_type rt1719_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_PD_PPS
};
static const enum power_supply_property rt1719_psy_properties[] = { static const enum power_supply_property rt1719_psy_properties[] = {
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_USB_TYPE, POWER_SUPPLY_PROP_USB_TYPE,
...@@ -572,8 +566,9 @@ static int devm_rt1719_psy_register(struct rt1719_data *data) ...@@ -572,8 +566,9 @@ static int devm_rt1719_psy_register(struct rt1719_data *data)
data->psy_desc.name = psy_name; data->psy_desc.name = psy_name;
data->psy_desc.type = POWER_SUPPLY_TYPE_USB; data->psy_desc.type = POWER_SUPPLY_TYPE_USB;
data->psy_desc.usb_types = rt1719_psy_usb_types; data->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
data->psy_desc.num_usb_types = ARRAY_SIZE(rt1719_psy_usb_types); BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
data->psy_desc.properties = rt1719_psy_properties; data->psy_desc.properties = rt1719_psy_properties;
data->psy_desc.num_properties = ARRAY_SIZE(rt1719_psy_properties); data->psy_desc.num_properties = ARRAY_SIZE(rt1719_psy_properties);
data->psy_desc.get_property = rt1719_psy_get_property; data->psy_desc.get_property = rt1719_psy_get_property;
......
...@@ -7483,12 +7483,6 @@ static int tcpm_psy_prop_writeable(struct power_supply *psy, ...@@ -7483,12 +7483,6 @@ static int tcpm_psy_prop_writeable(struct power_supply *psy,
} }
} }
static enum power_supply_usb_type tcpm_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_PD_PPS,
};
static const char *tcpm_psy_name_prefix = "tcpm-source-psy-"; static const char *tcpm_psy_name_prefix = "tcpm-source-psy-";
static int devm_tcpm_psy_register(struct tcpm_port *port) static int devm_tcpm_psy_register(struct tcpm_port *port)
...@@ -7509,8 +7503,9 @@ static int devm_tcpm_psy_register(struct tcpm_port *port) ...@@ -7509,8 +7503,9 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
port_dev_name); port_dev_name);
port->psy_desc.name = psy_name; port->psy_desc.name = psy_name;
port->psy_desc.type = POWER_SUPPLY_TYPE_USB; port->psy_desc.type = POWER_SUPPLY_TYPE_USB;
port->psy_desc.usb_types = tcpm_psy_usb_types; port->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
port->psy_desc.num_usb_types = ARRAY_SIZE(tcpm_psy_usb_types); BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
port->psy_desc.properties = tcpm_psy_props; port->psy_desc.properties = tcpm_psy_props;
port->psy_desc.num_properties = ARRAY_SIZE(tcpm_psy_props); port->psy_desc.num_properties = ARRAY_SIZE(tcpm_psy_props);
port->psy_desc.get_property = tcpm_psy_get_prop; port->psy_desc.get_property = tcpm_psy_get_prop;
......
...@@ -150,11 +150,6 @@ static enum power_supply_property tps6598x_psy_props[] = { ...@@ -150,11 +150,6 @@ static enum power_supply_property tps6598x_psy_props[] = {
POWER_SUPPLY_PROP_ONLINE, POWER_SUPPLY_PROP_ONLINE,
}; };
static enum power_supply_usb_type tps6598x_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
};
static const char *tps6598x_psy_name_prefix = "tps6598x-source-psy-"; static const char *tps6598x_psy_name_prefix = "tps6598x-source-psy-";
/* /*
...@@ -827,8 +822,8 @@ static int devm_tps6598_psy_register(struct tps6598x *tps) ...@@ -827,8 +822,8 @@ static int devm_tps6598_psy_register(struct tps6598x *tps)
tps->psy_desc.name = psy_name; tps->psy_desc.name = psy_name;
tps->psy_desc.type = POWER_SUPPLY_TYPE_USB; tps->psy_desc.type = POWER_SUPPLY_TYPE_USB;
tps->psy_desc.usb_types = tps6598x_psy_usb_types; tps->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
tps->psy_desc.num_usb_types = ARRAY_SIZE(tps6598x_psy_usb_types); BIT(POWER_SUPPLY_USB_TYPE_PD);
tps->psy_desc.properties = tps6598x_psy_props; tps->psy_desc.properties = tps6598x_psy_props;
tps->psy_desc.num_properties = ARRAY_SIZE(tps6598x_psy_props); tps->psy_desc.num_properties = ARRAY_SIZE(tps6598x_psy_props);
tps->psy_desc.get_property = tps6598x_psy_get_prop; tps->psy_desc.get_property = tps6598x_psy_get_prop;
......
...@@ -254,12 +254,6 @@ static int ucsi_psy_get_prop(struct power_supply *psy, ...@@ -254,12 +254,6 @@ static int ucsi_psy_get_prop(struct power_supply *psy,
} }
} }
static enum power_supply_usb_type ucsi_psy_usb_types[] = {
POWER_SUPPLY_USB_TYPE_C,
POWER_SUPPLY_USB_TYPE_PD,
POWER_SUPPLY_USB_TYPE_PD_PPS,
};
int ucsi_register_port_psy(struct ucsi_connector *con) int ucsi_register_port_psy(struct ucsi_connector *con)
{ {
struct power_supply_config psy_cfg = {}; struct power_supply_config psy_cfg = {};
...@@ -276,8 +270,9 @@ int ucsi_register_port_psy(struct ucsi_connector *con) ...@@ -276,8 +270,9 @@ int ucsi_register_port_psy(struct ucsi_connector *con)
con->psy_desc.name = psy_name; con->psy_desc.name = psy_name;
con->psy_desc.type = POWER_SUPPLY_TYPE_USB; con->psy_desc.type = POWER_SUPPLY_TYPE_USB;
con->psy_desc.usb_types = ucsi_psy_usb_types; con->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
con->psy_desc.num_usb_types = ARRAY_SIZE(ucsi_psy_usb_types); BIT(POWER_SUPPLY_USB_TYPE_PD) |
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
con->psy_desc.properties = ucsi_psy_props; con->psy_desc.properties = ucsi_psy_props;
con->psy_desc.num_properties = ARRAY_SIZE(ucsi_psy_props); con->psy_desc.num_properties = ARRAY_SIZE(ucsi_psy_props);
con->psy_desc.get_property = ucsi_psy_get_prop; con->psy_desc.get_property = ucsi_psy_get_prop;
......
...@@ -115,8 +115,16 @@ enum axp20x_variants { ...@@ -115,8 +115,16 @@ enum axp20x_variants {
#define AXP313A_IRQ_STATE 0x21 #define AXP313A_IRQ_STATE 0x21
#define AXP717_ON_INDICATE 0x00 #define AXP717_ON_INDICATE 0x00
#define AXP717_PMU_STATUS_2 0x01
#define AXP717_BC_DETECT 0x05
#define AXP717_PMU_FAULT 0x08
#define AXP717_MODULE_EN_CONTROL_1 0x0b
#define AXP717_MIN_SYS_V_CONTROL 0x15
#define AXP717_INPUT_VOL_LIMIT_CTRL 0x16
#define AXP717_INPUT_CUR_LIMIT_CTRL 0x17
#define AXP717_MODULE_EN_CONTROL_2 0x19 #define AXP717_MODULE_EN_CONTROL_2 0x19
#define AXP717_BOOST_CONTROL 0x1e #define AXP717_BOOST_CONTROL 0x1e
#define AXP717_VSYS_V_POWEROFF 0x24
#define AXP717_IRQ0_EN 0x40 #define AXP717_IRQ0_EN 0x40
#define AXP717_IRQ1_EN 0x41 #define AXP717_IRQ1_EN 0x41
#define AXP717_IRQ2_EN 0x42 #define AXP717_IRQ2_EN 0x42
...@@ -127,6 +135,9 @@ enum axp20x_variants { ...@@ -127,6 +135,9 @@ enum axp20x_variants {
#define AXP717_IRQ2_STATE 0x4a #define AXP717_IRQ2_STATE 0x4a
#define AXP717_IRQ3_STATE 0x4b #define AXP717_IRQ3_STATE 0x4b
#define AXP717_IRQ4_STATE 0x4c #define AXP717_IRQ4_STATE 0x4c
#define AXP717_ICC_CHG_SET 0x62
#define AXP717_ITERM_CHG_SET 0x63
#define AXP717_CV_CHG_SET 0x64
#define AXP717_DCDC_OUTPUT_CONTROL 0x80 #define AXP717_DCDC_OUTPUT_CONTROL 0x80
#define AXP717_DCDC1_CONTROL 0x83 #define AXP717_DCDC1_CONTROL 0x83
#define AXP717_DCDC2_CONTROL 0x84 #define AXP717_DCDC2_CONTROL 0x84
...@@ -147,6 +158,19 @@ enum axp20x_variants { ...@@ -147,6 +158,19 @@ enum axp20x_variants {
#define AXP717_CLDO3_CONTROL 0x9d #define AXP717_CLDO3_CONTROL 0x9d
#define AXP717_CLDO4_CONTROL 0x9e #define AXP717_CLDO4_CONTROL 0x9e
#define AXP717_CPUSLDO_CONTROL 0x9f #define AXP717_CPUSLDO_CONTROL 0x9f
#define AXP717_BATT_PERCENT_DATA 0xa4
#define AXP717_ADC_CH_EN_CONTROL 0xc0
#define AXP717_BATT_V_H 0xc4
#define AXP717_BATT_V_L 0xc5
#define AXP717_VBUS_V_H 0xc6
#define AXP717_VBUS_V_L 0xc7
#define AXP717_VSYS_V_H 0xc8
#define AXP717_VSYS_V_L 0xc9
#define AXP717_BATT_CHRG_I_H 0xca
#define AXP717_BATT_CHRG_I_L 0xcb
#define AXP717_ADC_DATA_SEL 0xcd
#define AXP717_ADC_DATA_H 0xce
#define AXP717_ADC_DATA_L 0xcf
#define AXP806_STARTUP_SRC 0x00 #define AXP806_STARTUP_SRC 0x00
#define AXP806_CHIP_ID 0x03 #define AXP806_CHIP_ID 0x03
......
...@@ -217,6 +217,10 @@ enum max77693_charger_battery_state { ...@@ -217,6 +217,10 @@ enum max77693_charger_battery_state {
#define CHG_CNFG_01_CHGRSTRT_MASK (0x3 << CHG_CNFG_01_CHGRSTRT_SHIFT) #define CHG_CNFG_01_CHGRSTRT_MASK (0x3 << CHG_CNFG_01_CHGRSTRT_SHIFT)
#define CHG_CNFG_01_PQEN_MAKS BIT(CHG_CNFG_01_PQEN_SHIFT) #define CHG_CNFG_01_PQEN_MAKS BIT(CHG_CNFG_01_PQEN_SHIFT)
/* MAX77693_CHG_REG_CHG_CNFG_02 register */
#define CHG_CNFG_02_CC_SHIFT 0
#define CHG_CNFG_02_CC_MASK 0x3F
/* MAX77693_CHG_REG_CHG_CNFG_03 register */ /* MAX77693_CHG_REG_CHG_CNFG_03 register */
#define CHG_CNFG_03_TOITH_SHIFT 0 #define CHG_CNFG_03_TOITH_SHIFT 0
#define CHG_CNFG_03_TOTIME_SHIFT 3 #define CHG_CNFG_03_TOTIME_SHIFT 3
...@@ -244,6 +248,7 @@ enum max77693_charger_battery_state { ...@@ -244,6 +248,7 @@ enum max77693_charger_battery_state {
#define CHG_CNFG_12_VCHGINREG_MASK (0x3 << CHG_CNFG_12_VCHGINREG_SHIFT) #define CHG_CNFG_12_VCHGINREG_MASK (0x3 << CHG_CNFG_12_VCHGINREG_SHIFT)
/* MAX77693 CHG_CNFG_09 Register */ /* MAX77693 CHG_CNFG_09 Register */
#define CHG_CNFG_09_CHGIN_ILIM_SHIFT 0
#define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F #define CHG_CNFG_09_CHGIN_ILIM_MASK 0x7F
/* MAX77693 CHG_CTRL Register */ /* MAX77693 CHG_CTRL Register */
......
...@@ -243,8 +243,7 @@ struct power_supply_desc { ...@@ -243,8 +243,7 @@ struct power_supply_desc {
const char *name; const char *name;
enum power_supply_type type; enum power_supply_type type;
u8 charge_behaviours; u8 charge_behaviours;
const enum power_supply_usb_type *usb_types; u32 usb_types;
size_t num_usb_types;
const enum power_supply_property *properties; const enum power_supply_property *properties;
size_t num_properties; size_t num_properties;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment