diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2020-08-06 14:15:47 +0300 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2020-08-06 14:15:47 +0300 |
commit | 94fb1afb14c4f0ceb8c5508ddddac6819f662e95 (patch) | |
tree | 4988e5769dc7482caa7f441475ae31f50bbd37ef /drivers/usb/common | |
parent | c4735d990268399da9133b0ad445e488ece009ad (diff) | |
parent | 47ec5303d73ea344e84f46660fff693c57641386 (diff) | |
download | linux-94fb1afb14c4f0ceb8c5508ddddac6819f662e95.tar.xz |
Mgerge remote-tracking branch 'torvalds/master' into perf/core
To sync headers, for instance, in this case tools/perf was ahead of
upstream till Linus merged tip/perf/core to get the
PERF_RECORD_TEXT_POKE changes:
Warning: Kernel ABI header at 'tools/include/uapi/linux/perf_event.h' differs from latest version at 'include/uapi/linux/perf_event.h'
diff -u tools/include/uapi/linux/perf_event.h include/uapi/linux/perf_event.h
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'drivers/usb/common')
-rw-r--r-- | drivers/usb/common/Kconfig | 1 | ||||
-rw-r--r-- | drivers/usb/common/debug.c | 16 | ||||
-rw-r--r-- | drivers/usb/common/ulpi.c | 5 | ||||
-rw-r--r-- | drivers/usb/common/usb-conn-gpio.c | 47 |
4 files changed, 58 insertions, 11 deletions
diff --git a/drivers/usb/common/Kconfig b/drivers/usb/common/Kconfig index d611477aae41..5e8a04e3dd3c 100644 --- a/drivers/usb/common/Kconfig +++ b/drivers/usb/common/Kconfig @@ -40,6 +40,7 @@ config USB_CONN_GPIO tristate "USB GPIO Based Connection Detection Driver" depends on GPIOLIB select USB_ROLE_SWITCH + select POWER_SUPPLY help The driver supports USB role switch between host and device via GPIO based USB cable detection, used typically if an input GPIO is used diff --git a/drivers/usb/common/debug.c b/drivers/usb/common/debug.c index 92a986aeaa5d..ba849c7bc5c7 100644 --- a/drivers/usb/common/debug.c +++ b/drivers/usb/common/debug.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * Common USB debugging functions * - * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2010-2011 Texas Instruments Incorporated - https://www.ti.com * * Authors: Felipe Balbi <balbi@ti.com>, * Sebastian Andrzej Siewior <bigeasy@linutronix.de> @@ -53,15 +53,15 @@ static const char *usb_decode_device_feature(u16 wValue) static const char *usb_decode_test_mode(u16 wIndex) { switch (wIndex) { - case TEST_J: + case USB_TEST_J: return ": TEST_J"; - case TEST_K: + case USB_TEST_K: return ": TEST_K"; - case TEST_SE0_NAK: + case USB_TEST_SE0_NAK: return ": TEST_SE0_NAK"; - case TEST_PACKET: + case USB_TEST_PACKET: return ": TEST_PACKET"; - case TEST_FORCE_EN: + case USB_TEST_FORCE_ENABLE: return ": TEST_FORCE_EN"; default: return ": UNKNOWN"; @@ -207,7 +207,7 @@ static void usb_decode_set_isoch_delay(__u8 wValue, char *str, size_t size) snprintf(str, size, "Set Isochronous Delay(Delay = %d ns)", wValue); } -/** +/* * usb_decode_ctrl - returns a string representation of ctrl request */ const char *usb_decode_ctrl(char *str, size_t size, __u8 bRequestType, diff --git a/drivers/usb/common/ulpi.c b/drivers/usb/common/ulpi.c index 9a2ab6751a23..a18d7c4222dd 100644 --- a/drivers/usb/common/ulpi.c +++ b/drivers/usb/common/ulpi.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 -/** +/* * ulpi.c - USB ULPI PHY bus * * Copyright (C) 2015 Intel Corporation @@ -143,6 +143,7 @@ static const struct device_type ulpi_dev_type = { /** * ulpi_register_driver - register a driver with the ULPI bus * @drv: driver being registered + * @module: ends up being THIS_MODULE * * Registers a driver with the ULPI bus. */ @@ -290,7 +291,7 @@ EXPORT_SYMBOL_GPL(ulpi_register_interface); /** * ulpi_unregister_interface - unregister ULPI interface - * @intrf: struct ulpi_interface + * @ulpi: struct ulpi_interface * * Unregisters a ULPI device and it's interface that was created with * ulpi_create_interface(). diff --git a/drivers/usb/common/usb-conn-gpio.c b/drivers/usb/common/usb-conn-gpio.c index ed204cbb63ea..7b3a21360d7c 100644 --- a/drivers/usb/common/usb-conn-gpio.c +++ b/drivers/usb/common/usb-conn-gpio.c @@ -17,6 +17,7 @@ #include <linux/of.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> +#include <linux/power_supply.h> #include <linux/regulator/consumer.h> #include <linux/usb/role.h> @@ -38,9 +39,12 @@ struct usb_conn_info { struct gpio_desc *vbus_gpiod; int id_irq; int vbus_irq; + + struct power_supply_desc desc; + struct power_supply *charger; }; -/** +/* * "DEVICE" = VBUS and "HOST" = !ID, so we have: * Both "DEVICE" and "HOST" can't be set as active at the same time * so if "HOST" is active (i.e. ID is 0) we keep "DEVICE" inactive @@ -104,6 +108,8 @@ static void usb_conn_detect_cable(struct work_struct *work) dev_dbg(info->dev, "vbus regulator is %s\n", regulator_is_enabled(info->vbus) ? "enabled" : "disabled"); + + power_supply_changed(info->charger); } static void usb_conn_queue_dwork(struct usb_conn_info *info, @@ -121,10 +127,35 @@ static irqreturn_t usb_conn_isr(int irq, void *dev_id) return IRQ_HANDLED; } +static enum power_supply_property usb_charger_properties[] = { + POWER_SUPPLY_PROP_ONLINE, +}; + +static int usb_charger_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + struct usb_conn_info *info = power_supply_get_drvdata(psy); + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + val->intval = info->last_role == USB_ROLE_DEVICE; + break; + default: + return -EINVAL; + } + + return 0; +} + static int usb_conn_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; + struct power_supply_desc *desc; struct usb_conn_info *info; + struct power_supply_config cfg = { + .of_node = dev->of_node, + }; int ret = 0; info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL); @@ -203,6 +234,20 @@ static int usb_conn_probe(struct platform_device *pdev) } } + desc = &info->desc; + desc->name = "usb-charger"; + desc->properties = usb_charger_properties; + desc->num_properties = ARRAY_SIZE(usb_charger_properties); + desc->get_property = usb_charger_get_property; + desc->type = POWER_SUPPLY_TYPE_USB; + cfg.drv_data = info; + + info->charger = devm_power_supply_register(dev, desc, &cfg); + if (IS_ERR(info->charger)) { + dev_err(dev, "Unable to register charger\n"); + return PTR_ERR(info->charger); + } + platform_set_drvdata(pdev, info); /* Perform initial detection */ |