Loading drivers/power/supply/power_supply_sysfs.c +20 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,17 @@ static ssize_t power_supply_show_property(struct device *dev, static char *scope_text[] = { "Unknown", "System", "Device" }; static const char * const typec_text[] = { "Nothing attached", "Sink attached", "Powered cable w/ sink", "Debug Accessory", "Audio Adapter", "Powered cable w/o sink", "Source attached (default current)", "Source attached (medium current)", "Source attached (high current)", "Non compliant", }; static const char * const typec_pr_text[] = { "none", "dual power role", "sink", "source" }; ssize_t ret = 0; struct power_supply *psy = dev_get_drvdata(dev); const ptrdiff_t off = attr - power_supply_attrs; Loading Loading @@ -104,6 +115,10 @@ static ssize_t power_supply_show_property(struct device *dev, return sprintf(buf, "%s\n", type_text[value.intval]); else if (off == POWER_SUPPLY_PROP_SCOPE) return sprintf(buf, "%s\n", scope_text[value.intval]); else if (off == POWER_SUPPLY_PROP_TYPEC_MODE) return sprintf(buf, "%s\n", typec_text[value.intval]); else if (off == POWER_SUPPLY_PROP_TYPEC_POWER_ROLE) return sprintf(buf, "%s\n", typec_pr_text[value.intval]); else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) return sprintf(buf, "%s\n", value.strval); Loading Loading @@ -205,6 +220,11 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(usb_hc), POWER_SUPPLY_ATTR(usb_otg), POWER_SUPPLY_ATTR(charge_enabled), POWER_SUPPLY_ATTR(typec_mode), POWER_SUPPLY_ATTR(typec_cc_orientation), POWER_SUPPLY_ATTR(typec_power_role), POWER_SUPPLY_ATTR(pd_allowed), POWER_SUPPLY_ATTR(pd_active), POWER_SUPPLY_ATTR(set_ship_mode), /* Local extensions of type int64_t */ POWER_SUPPLY_ATTR(charge_counter_ext), Loading include/linux/power_supply.h +30 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,11 @@ enum power_supply_property { POWER_SUPPLY_PROP_USB_HC, POWER_SUPPLY_PROP_USB_OTG, POWER_SUPPLY_PROP_CHARGE_ENABLED, POWER_SUPPLY_PROP_TYPEC_MODE, POWER_SUPPLY_PROP_TYPEC_CC_ORIENTATION, /* 0: N/C, 1: CC1, 2: CC2 */ POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, POWER_SUPPLY_PROP_PD_ALLOWED, POWER_SUPPLY_PROP_PD_ACTIVE, POWER_SUPPLY_PROP_SET_SHIP_MODE, /* Local extensions of type int64_t */ POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT, Loading @@ -176,6 +181,31 @@ enum power_supply_type { POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */ }; /* Indicates USB Type-C CC connection status */ enum power_supply_typec_mode { POWER_SUPPLY_TYPEC_NONE, /* Acting as source */ POWER_SUPPLY_TYPEC_SINK, /* Rd only */ POWER_SUPPLY_TYPEC_SINK_POWERED_CABLE, /* Rd/Ra */ POWER_SUPPLY_TYPEC_SINK_DEBUG_ACCESSORY, /* Rd/Rd */ POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER, /* Ra/Ra */ POWER_SUPPLY_TYPEC_POWERED_CABLE_ONLY, /* Ra only */ /* Acting as sink */ POWER_SUPPLY_TYPEC_SOURCE_DEFAULT, /* Rp default */ POWER_SUPPLY_TYPEC_SOURCE_MEDIUM, /* Rp 1.5A */ POWER_SUPPLY_TYPEC_SOURCE_HIGH, /* Rp 3A */ POWER_SUPPLY_TYPEC_NON_COMPLIANT, }; enum power_supply_typec_power_role { POWER_SUPPLY_TYPEC_PR_NONE, /* CC lines in high-Z */ POWER_SUPPLY_TYPEC_PR_DUAL, POWER_SUPPLY_TYPEC_PR_SINK, POWER_SUPPLY_TYPEC_PR_SOURCE, }; enum power_supply_notifier_events { PSY_EVENT_PROP_CHANGED, }; Loading Loading
drivers/power/supply/power_supply_sysfs.c +20 −0 Original line number Diff line number Diff line Loading @@ -69,6 +69,17 @@ static ssize_t power_supply_show_property(struct device *dev, static char *scope_text[] = { "Unknown", "System", "Device" }; static const char * const typec_text[] = { "Nothing attached", "Sink attached", "Powered cable w/ sink", "Debug Accessory", "Audio Adapter", "Powered cable w/o sink", "Source attached (default current)", "Source attached (medium current)", "Source attached (high current)", "Non compliant", }; static const char * const typec_pr_text[] = { "none", "dual power role", "sink", "source" }; ssize_t ret = 0; struct power_supply *psy = dev_get_drvdata(dev); const ptrdiff_t off = attr - power_supply_attrs; Loading Loading @@ -104,6 +115,10 @@ static ssize_t power_supply_show_property(struct device *dev, return sprintf(buf, "%s\n", type_text[value.intval]); else if (off == POWER_SUPPLY_PROP_SCOPE) return sprintf(buf, "%s\n", scope_text[value.intval]); else if (off == POWER_SUPPLY_PROP_TYPEC_MODE) return sprintf(buf, "%s\n", typec_text[value.intval]); else if (off == POWER_SUPPLY_PROP_TYPEC_POWER_ROLE) return sprintf(buf, "%s\n", typec_pr_text[value.intval]); else if (off >= POWER_SUPPLY_PROP_MODEL_NAME) return sprintf(buf, "%s\n", value.strval); Loading Loading @@ -205,6 +220,11 @@ static struct device_attribute power_supply_attrs[] = { POWER_SUPPLY_ATTR(usb_hc), POWER_SUPPLY_ATTR(usb_otg), POWER_SUPPLY_ATTR(charge_enabled), POWER_SUPPLY_ATTR(typec_mode), POWER_SUPPLY_ATTR(typec_cc_orientation), POWER_SUPPLY_ATTR(typec_power_role), POWER_SUPPLY_ATTR(pd_allowed), POWER_SUPPLY_ATTR(pd_active), POWER_SUPPLY_ATTR(set_ship_mode), /* Local extensions of type int64_t */ POWER_SUPPLY_ATTR(charge_counter_ext), Loading
include/linux/power_supply.h +30 −0 Original line number Diff line number Diff line Loading @@ -153,6 +153,11 @@ enum power_supply_property { POWER_SUPPLY_PROP_USB_HC, POWER_SUPPLY_PROP_USB_OTG, POWER_SUPPLY_PROP_CHARGE_ENABLED, POWER_SUPPLY_PROP_TYPEC_MODE, POWER_SUPPLY_PROP_TYPEC_CC_ORIENTATION, /* 0: N/C, 1: CC1, 2: CC2 */ POWER_SUPPLY_PROP_TYPEC_POWER_ROLE, POWER_SUPPLY_PROP_PD_ALLOWED, POWER_SUPPLY_PROP_PD_ACTIVE, POWER_SUPPLY_PROP_SET_SHIP_MODE, /* Local extensions of type int64_t */ POWER_SUPPLY_PROP_CHARGE_COUNTER_EXT, Loading @@ -176,6 +181,31 @@ enum power_supply_type { POWER_SUPPLY_TYPE_USB_PD_DRP, /* PD Dual Role Port */ }; /* Indicates USB Type-C CC connection status */ enum power_supply_typec_mode { POWER_SUPPLY_TYPEC_NONE, /* Acting as source */ POWER_SUPPLY_TYPEC_SINK, /* Rd only */ POWER_SUPPLY_TYPEC_SINK_POWERED_CABLE, /* Rd/Ra */ POWER_SUPPLY_TYPEC_SINK_DEBUG_ACCESSORY, /* Rd/Rd */ POWER_SUPPLY_TYPEC_SINK_AUDIO_ADAPTER, /* Ra/Ra */ POWER_SUPPLY_TYPEC_POWERED_CABLE_ONLY, /* Ra only */ /* Acting as sink */ POWER_SUPPLY_TYPEC_SOURCE_DEFAULT, /* Rp default */ POWER_SUPPLY_TYPEC_SOURCE_MEDIUM, /* Rp 1.5A */ POWER_SUPPLY_TYPEC_SOURCE_HIGH, /* Rp 3A */ POWER_SUPPLY_TYPEC_NON_COMPLIANT, }; enum power_supply_typec_power_role { POWER_SUPPLY_TYPEC_PR_NONE, /* CC lines in high-Z */ POWER_SUPPLY_TYPEC_PR_DUAL, POWER_SUPPLY_TYPEC_PR_SINK, POWER_SUPPLY_TYPEC_PR_SOURCE, }; enum power_supply_notifier_events { PSY_EVENT_PROP_CHANGED, }; Loading