power: supply: Change usb_types from an array into a bitmask
The bit_types array just hold a list of valid enum power_supply_usb_type values which map to 0 - 9. This can easily be represented as a bitmap. This reduces the size of struct power_supply_desc and further reduces the data section size by drivers no longer needing to store the array. This also unifies how usb_types are handled with charge_behaviours, which allows power_supply_show_usb_type() to be removed. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Link: https://lore.kernel.org/r/20240831142039.28830-7-hdegoede@redhat.com Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
This commit is contained in:
parent
322900ac7d
commit
364ea7ccae
@ -461,14 +461,6 @@ static int cht_wc_extcon_psy_get_prop(struct power_supply *psy,
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_USB_TYPE,
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
@ -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 = {
|
||||
.name = "cht_wcove_pwrsrc",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = cht_wc_extcon_psy_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(cht_wc_extcon_psy_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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,
|
||||
.num_properties = ARRAY_SIZE(cht_wc_extcon_psy_props),
|
||||
.get_property = cht_wc_extcon_psy_get_prop,
|
||||
|
@ -411,12 +411,6 @@ static int tusb1210_psy_get_prop(struct power_supply *psy,
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
POWER_SUPPLY_PROP_USB_TYPE,
|
||||
@ -426,8 +420,9 @@ static const enum power_supply_property tusb1210_psy_props[] = {
|
||||
static const struct power_supply_desc tusb1210_psy_desc = {
|
||||
.name = "tusb1211-charger-detect",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = tusb1210_psy_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(tusb1210_psy_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
|
||||
.properties = tusb1210_psy_props,
|
||||
.num_properties = ARRAY_SIZE(tusb1210_psy_props),
|
||||
.get_property = tusb1210_psy_get_prop,
|
||||
|
@ -412,13 +412,6 @@ static enum power_supply_property axp813_usb_power_properties[] = {
|
||||
POWER_SUPPLY_PROP_USB_TYPE,
|
||||
};
|
||||
|
||||
static enum power_supply_usb_type axp813_usb_types[] = {
|
||||
POWER_SUPPLY_USB_TYPE_SDP,
|
||||
POWER_SUPPLY_USB_TYPE_DCP,
|
||||
POWER_SUPPLY_USB_TYPE_CDP,
|
||||
POWER_SUPPLY_USB_TYPE_UNKNOWN,
|
||||
};
|
||||
|
||||
static const struct power_supply_desc axp20x_usb_power_desc = {
|
||||
.name = "axp20x-usb",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
@ -447,8 +440,10 @@ static const struct power_supply_desc axp813_usb_power_desc = {
|
||||
.property_is_writeable = axp20x_usb_power_prop_writeable,
|
||||
.get_property = axp20x_usb_power_get_property,
|
||||
.set_property = axp20x_usb_power_set_property,
|
||||
.usb_types = axp813_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(axp813_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
|
||||
};
|
||||
|
||||
static const char * const axp20x_irq_names[] = {
|
||||
|
@ -334,14 +334,6 @@ static const int bq25618_619_ichg_values[] = {
|
||||
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[])
|
||||
{
|
||||
int i = 0;
|
||||
@ -1252,8 +1244,11 @@ static int bq256xx_property_is_writeable(struct power_supply *psy,
|
||||
static const struct power_supply_desc bq256xx_power_supply_desc = {
|
||||
.name = "bq256xx-charger",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = bq256xx_usb_type,
|
||||
.num_usb_types = ARRAY_SIZE(bq256xx_usb_type),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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,
|
||||
.num_properties = ARRAY_SIZE(bq256xx_power_supply_props),
|
||||
.get_property = bq256xx_get_charger_property,
|
||||
|
@ -73,17 +73,6 @@ static enum power_supply_property cros_usbpd_dedicated_charger_props[] = {
|
||||
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. */
|
||||
static u16 input_voltage_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)
|
||||
psy_desc->properties = cros_usbpd_charger_props;
|
||||
psy_desc->num_properties =
|
||||
ARRAY_SIZE(cros_usbpd_charger_props);
|
||||
psy_desc->usb_types = cros_usbpd_charger_usb_types;
|
||||
psy_desc->num_usb_types =
|
||||
ARRAY_SIZE(cros_usbpd_charger_usb_types);
|
||||
psy_desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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;
|
||||
|
@ -353,15 +353,10 @@ static enum power_supply_property yoga_c630_psy_adpt_properties[] = {
|
||||
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 = {
|
||||
.name = "yoga-c630-adapter",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = yoga_c630_psy_adpt_usb_type,
|
||||
.num_usb_types = ARRAY_SIZE(yoga_c630_psy_adpt_usb_type),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C),
|
||||
.properties = yoga_c630_psy_adpt_properties,
|
||||
.num_properties = ARRAY_SIZE(yoga_c630_psy_adpt_properties),
|
||||
.get_property = yoga_c630_psy_adpt_get_property,
|
||||
|
@ -94,14 +94,6 @@ struct mp2629_prop {
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
POWER_SUPPLY_PROP_USB_TYPE,
|
||||
@ -487,8 +479,11 @@ unlock:
|
||||
static const struct power_supply_desc mp2629_usb_desc = {
|
||||
.name = "mp2629_usb",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = mp2629_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(mp2629_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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,
|
||||
.num_properties = ARRAY_SIZE(mp2629_charger_usb_props),
|
||||
.get_property = mp2629_charger_usb_get_prop,
|
||||
|
@ -154,13 +154,6 @@ enum mt6360_pmu_chg_type {
|
||||
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,
|
||||
bool *pwr_rdy)
|
||||
{
|
||||
@ -574,8 +567,10 @@ static const struct power_supply_desc mt6360_charger_desc = {
|
||||
.get_property = mt6360_charger_get_property,
|
||||
.set_property = mt6360_charger_set_property,
|
||||
.property_is_writeable = mt6360_charger_property_is_writeable,
|
||||
.usb_types = mt6360_charger_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(mt6360_charger_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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 = {
|
||||
|
@ -624,13 +624,6 @@ static enum power_supply_property mt6370_chg_properties[] = {
|
||||
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 = {
|
||||
.name = "mt6370-charger",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
@ -639,8 +632,10 @@ static const struct power_supply_desc mt6370_chg_psy_desc = {
|
||||
.get_property = mt6370_chg_get_property,
|
||||
.set_property = mt6370_chg_set_property,
|
||||
.property_is_writeable = mt6370_chg_property_is_writeable,
|
||||
.usb_types = mt6370_chg_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(mt6370_chg_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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 = {
|
||||
|
@ -1361,10 +1361,6 @@ __power_supply_register(struct device *parent,
|
||||
pr_warn("%s: Expected proper parent device for '%s'\n",
|
||||
__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);
|
||||
if (!psy)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
@ -268,40 +268,6 @@ static ssize_t power_supply_show_enum_with_available(
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t power_supply_show_usb_type(struct device *dev,
|
||||
const struct power_supply_desc *desc,
|
||||
union power_supply_propval *value,
|
||||
char *buf)
|
||||
{
|
||||
enum power_supply_usb_type usb_type;
|
||||
ssize_t count = 0;
|
||||
bool match = false;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < desc->num_usb_types; ++i) {
|
||||
usb_type = desc->usb_types[i];
|
||||
|
||||
if (value->intval == usb_type) {
|
||||
count += sysfs_emit_at(buf, count, "[%s] ",
|
||||
POWER_SUPPLY_USB_TYPE_TEXT[usb_type]);
|
||||
match = true;
|
||||
} else {
|
||||
count += sysfs_emit_at(buf, count, "%s ",
|
||||
POWER_SUPPLY_USB_TYPE_TEXT[usb_type]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
dev_warn(dev, "driver reporting unsupported connected type\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (count)
|
||||
buf[count - 1] = '\n';
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t power_supply_show_property(struct device *dev,
|
||||
struct device_attribute *attr,
|
||||
char *buf) {
|
||||
@ -331,8 +297,10 @@ static ssize_t power_supply_show_property(struct device *dev,
|
||||
|
||||
switch (psp) {
|
||||
case POWER_SUPPLY_PROP_USB_TYPE:
|
||||
ret = power_supply_show_usb_type(dev, psy->desc,
|
||||
&value, buf);
|
||||
ret = power_supply_show_enum_with_available(
|
||||
dev, POWER_SUPPLY_USB_TYPE_TEXT,
|
||||
ARRAY_SIZE(POWER_SUPPLY_USB_TYPE_TEXT),
|
||||
psy->desc->usb_types, value.intval, buf);
|
||||
break;
|
||||
case POWER_SUPPLY_PROP_CHARGE_BEHAVIOUR:
|
||||
ret = power_supply_charge_behaviour_show(dev, psy->desc->charge_behaviours,
|
||||
|
@ -786,19 +786,6 @@ static int qcom_battmgr_usb_get_property(struct power_supply *psy,
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
};
|
||||
@ -809,8 +796,16 @@ static const struct power_supply_desc sc8280xp_usb_psy_desc = {
|
||||
.properties = sc8280xp_usb_props,
|
||||
.num_properties = ARRAY_SIZE(sc8280xp_usb_props),
|
||||
.get_property = qcom_battmgr_usb_get_property,
|
||||
.usb_types = usb_psy_supported_types,
|
||||
.num_usb_types = ARRAY_SIZE(usb_psy_supported_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
|
||||
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[] = {
|
||||
@ -829,8 +824,16 @@ static const struct power_supply_desc sm8350_usb_psy_desc = {
|
||||
.properties = sm8350_usb_props,
|
||||
.num_properties = ARRAY_SIZE(sm8350_usb_props),
|
||||
.get_property = qcom_battmgr_usb_get_property,
|
||||
.usb_types = usb_psy_supported_types,
|
||||
.num_usb_types = ARRAY_SIZE(usb_psy_supported_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN) |
|
||||
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[] = {
|
||||
|
@ -411,13 +411,6 @@ static enum power_supply_property smb2_properties[] = {
|
||||
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)
|
||||
{
|
||||
unsigned int stat;
|
||||
@ -775,8 +768,10 @@ static irqreturn_t smb2_handle_wdog_bark(int irq, void *data)
|
||||
static const struct power_supply_desc smb2_psy_desc = {
|
||||
.name = "pmi8998_charger",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = smb2_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(smb2_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
|
||||
.properties = smb2_properties,
|
||||
.num_properties = ARRAY_SIZE(smb2_properties),
|
||||
.get_property = smb2_get_property,
|
||||
|
@ -673,11 +673,6 @@ static enum power_supply_property rk817_chg_props[] = {
|
||||
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 = {
|
||||
.name = "rk817-battery",
|
||||
.type = POWER_SUPPLY_TYPE_BATTERY,
|
||||
@ -689,8 +684,8 @@ static const struct power_supply_desc rk817_bat_desc = {
|
||||
static const struct power_supply_desc rk817_chg_desc = {
|
||||
.name = "rk817-charger",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = rk817_usb_type,
|
||||
.num_usb_types = ARRAY_SIZE(rk817_usb_type),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_DCP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
|
||||
.properties = rk817_chg_props,
|
||||
.num_properties = ARRAY_SIZE(rk817_chg_props),
|
||||
.get_property = rk817_chg_get_prop,
|
||||
|
@ -70,13 +70,6 @@ struct rn5t618_power_info {
|
||||
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[] = {
|
||||
/* input current limit is not very accurate */
|
||||
POWER_SUPPLY_PROP_INPUT_CURRENT_LIMIT,
|
||||
@ -681,8 +674,10 @@ static const struct power_supply_desc rn5t618_adp_desc = {
|
||||
static const struct power_supply_desc rn5t618_usb_desc = {
|
||||
.name = "rn5t618-usb",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = rn5t618_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(rn5t618_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
|
||||
.properties = rn5t618_usb_props,
|
||||
.num_properties = ARRAY_SIZE(rn5t618_usb_props),
|
||||
.get_property = rn5t618_usb_get_property,
|
||||
|
@ -630,13 +630,6 @@ out:
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_STATUS,
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
@ -771,8 +764,10 @@ static int rt9467_chg_prop_is_writeable(struct power_supply *psy,
|
||||
static const struct power_supply_desc rt9467_chg_psy_desc = {
|
||||
.name = "rt9467-charger",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = rt9467_chg_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(rt9467_chg_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_CDP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_DCP) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_UNKNOWN),
|
||||
.properties = rt9467_chg_properties,
|
||||
.num_properties = ARRAY_SIZE(rt9467_chg_properties),
|
||||
.property_is_writeable = rt9467_chg_prop_is_writeable,
|
||||
|
@ -333,14 +333,6 @@ static enum power_supply_property rt9471_charger_properties[] = {
|
||||
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,
|
||||
enum power_supply_property psp)
|
||||
{
|
||||
@ -726,8 +718,11 @@ static int rt9471_register_psy(struct rt9471_chip *chip)
|
||||
|
||||
desc->name = psy_name;
|
||||
desc->type = POWER_SUPPLY_TYPE_USB;
|
||||
desc->usb_types = rt9471_charger_usb_types;
|
||||
desc->num_usb_types = ARRAY_SIZE(rt9471_charger_usb_types);
|
||||
desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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->num_properties = ARRAY_SIZE(rt9471_charger_properties);
|
||||
desc->get_property = rt9471_charger_get_property;
|
||||
|
@ -296,14 +296,6 @@ static int ucs1002_set_max_current(struct ucs1002_info *info, u32 val)
|
||||
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)
|
||||
{
|
||||
unsigned int mode;
|
||||
@ -431,8 +423,11 @@ static int ucs1002_property_is_writeable(struct power_supply *psy,
|
||||
static const struct power_supply_desc ucs1002_charger_desc = {
|
||||
.name = "ucs1002",
|
||||
.type = POWER_SUPPLY_TYPE_USB,
|
||||
.usb_types = ucs1002_usb_types,
|
||||
.num_usb_types = ARRAY_SIZE(ucs1002_usb_types),
|
||||
.usb_types = BIT(POWER_SUPPLY_USB_TYPE_SDP) |
|
||||
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,
|
||||
.set_property = ucs1002_set_property,
|
||||
.property_is_writeable = ucs1002_property_is_writeable,
|
||||
|
@ -1339,12 +1339,6 @@ static void anx7411_get_gpio_irq(struct anx7411_data *ctx)
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_USB_TYPE,
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
@ -1422,8 +1416,9 @@ static int anx7411_psy_register(struct anx7411_data *ctx)
|
||||
|
||||
psy_desc->name = psy_name;
|
||||
psy_desc->type = POWER_SUPPLY_TYPE_USB;
|
||||
psy_desc->usb_types = anx7411_psy_usb_types;
|
||||
psy_desc->num_usb_types = ARRAY_SIZE(anx7411_psy_usb_types);
|
||||
psy_desc->usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
|
||||
psy_desc->properties = anx7411_psy_props;
|
||||
psy_desc->num_properties = ARRAY_SIZE(anx7411_psy_props);
|
||||
|
||||
|
@ -109,12 +109,6 @@ struct rt1719_data {
|
||||
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[] = {
|
||||
POWER_SUPPLY_PROP_ONLINE,
|
||||
POWER_SUPPLY_PROP_USB_TYPE,
|
||||
@ -572,8 +566,9 @@ static int devm_rt1719_psy_register(struct rt1719_data *data)
|
||||
|
||||
data->psy_desc.name = psy_name;
|
||||
data->psy_desc.type = POWER_SUPPLY_TYPE_USB;
|
||||
data->psy_desc.usb_types = rt1719_psy_usb_types;
|
||||
data->psy_desc.num_usb_types = ARRAY_SIZE(rt1719_psy_usb_types);
|
||||
data->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
|
||||
data->psy_desc.properties = rt1719_psy_properties;
|
||||
data->psy_desc.num_properties = ARRAY_SIZE(rt1719_psy_properties);
|
||||
data->psy_desc.get_property = rt1719_psy_get_property;
|
||||
|
@ -7484,12 +7484,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 int devm_tcpm_psy_register(struct tcpm_port *port)
|
||||
@ -7510,8 +7504,9 @@ static int devm_tcpm_psy_register(struct tcpm_port *port)
|
||||
port_dev_name);
|
||||
port->psy_desc.name = psy_name;
|
||||
port->psy_desc.type = POWER_SUPPLY_TYPE_USB;
|
||||
port->psy_desc.usb_types = tcpm_psy_usb_types;
|
||||
port->psy_desc.num_usb_types = ARRAY_SIZE(tcpm_psy_usb_types);
|
||||
port->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
|
||||
port->psy_desc.properties = tcpm_psy_props;
|
||||
port->psy_desc.num_properties = ARRAY_SIZE(tcpm_psy_props);
|
||||
port->psy_desc.get_property = tcpm_psy_get_prop;
|
||||
|
@ -150,11 +150,6 @@ static enum power_supply_property tps6598x_psy_props[] = {
|
||||
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-";
|
||||
|
||||
/*
|
||||
@ -827,8 +822,8 @@ static int devm_tps6598_psy_register(struct tps6598x *tps)
|
||||
|
||||
tps->psy_desc.name = psy_name;
|
||||
tps->psy_desc.type = POWER_SUPPLY_TYPE_USB;
|
||||
tps->psy_desc.usb_types = tps6598x_psy_usb_types;
|
||||
tps->psy_desc.num_usb_types = ARRAY_SIZE(tps6598x_psy_usb_types);
|
||||
tps->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD);
|
||||
tps->psy_desc.properties = tps6598x_psy_props;
|
||||
tps->psy_desc.num_properties = ARRAY_SIZE(tps6598x_psy_props);
|
||||
tps->psy_desc.get_property = tps6598x_psy_get_prop;
|
||||
|
@ -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)
|
||||
{
|
||||
struct power_supply_config psy_cfg = {};
|
||||
@ -276,8 +270,9 @@ int ucsi_register_port_psy(struct ucsi_connector *con)
|
||||
|
||||
con->psy_desc.name = psy_name;
|
||||
con->psy_desc.type = POWER_SUPPLY_TYPE_USB;
|
||||
con->psy_desc.usb_types = ucsi_psy_usb_types;
|
||||
con->psy_desc.num_usb_types = ARRAY_SIZE(ucsi_psy_usb_types);
|
||||
con->psy_desc.usb_types = BIT(POWER_SUPPLY_USB_TYPE_C) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD) |
|
||||
BIT(POWER_SUPPLY_USB_TYPE_PD_PPS);
|
||||
con->psy_desc.properties = ucsi_psy_props;
|
||||
con->psy_desc.num_properties = ARRAY_SIZE(ucsi_psy_props);
|
||||
con->psy_desc.get_property = ucsi_psy_get_prop;
|
||||
|
@ -243,8 +243,7 @@ struct power_supply_desc {
|
||||
const char *name;
|
||||
enum power_supply_type type;
|
||||
u8 charge_behaviours;
|
||||
const enum power_supply_usb_type *usb_types;
|
||||
size_t num_usb_types;
|
||||
u32 usb_types;
|
||||
const enum power_supply_property *properties;
|
||||
size_t num_properties;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user