mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-06 02:50:49 +09:00
FROMGIT: usb: dwc3: add a power supply for current control
Currently, VBUS draw callback does no action when the generic PHYs are used. This patch adds an additional path to control charging current through power supply interface. Signed-off-by: Ray Chi <raychi@google.com> Link: https://lore.kernel.org/r/20210222115149.3606776-2-raychi@google.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit 59fa3def35de957881ac142a384487e27e8fe527 https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-next) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I394373ad476d21c9666fa7daa9fd2d9ecfcf6ab7
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
d92620d79b
commit
790c8081d9
@@ -1238,6 +1238,8 @@ static void dwc3_get_properties(struct dwc3 *dwc)
|
||||
u8 rx_max_burst_prd;
|
||||
u8 tx_thr_num_pkt_prd;
|
||||
u8 tx_max_burst_prd;
|
||||
const char *usb_psy_name;
|
||||
int ret;
|
||||
|
||||
/* default to highest possible threshold */
|
||||
lpm_nyet_threshold = 0xf;
|
||||
@@ -1263,6 +1265,13 @@ static void dwc3_get_properties(struct dwc3 *dwc)
|
||||
else
|
||||
dwc->sysdev = dwc->dev;
|
||||
|
||||
ret = device_property_read_string(dev, "usb-psy-name", &usb_psy_name);
|
||||
if (ret >= 0) {
|
||||
dwc->usb_psy = power_supply_get_by_name(usb_psy_name);
|
||||
if (!dwc->usb_psy)
|
||||
dev_err(dev, "couldn't get usb power supply\n");
|
||||
}
|
||||
|
||||
dwc->has_lpm_erratum = device_property_read_bool(dev,
|
||||
"snps,has-lpm-erratum");
|
||||
device_property_read_u8(dev, "snps,lpm-nyet-threshold",
|
||||
@@ -1619,6 +1628,9 @@ disable_clks:
|
||||
assert_reset:
|
||||
reset_control_assert(dwc->reset);
|
||||
|
||||
if (!dwc->usb_psy)
|
||||
power_supply_put(dwc->usb_psy);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1641,6 +1653,9 @@ static int dwc3_remove(struct platform_device *pdev)
|
||||
dwc3_free_event_buffers(dwc);
|
||||
dwc3_free_scratch_buffers(dwc);
|
||||
|
||||
if (!dwc->usb_psy)
|
||||
power_supply_put(dwc->usb_psy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
|
||||
#include <linux/phy/phy.h>
|
||||
|
||||
#include <linux/power_supply.h>
|
||||
|
||||
#define DWC3_MSG_MAX 500
|
||||
|
||||
/* Global constants */
|
||||
@@ -1125,6 +1127,8 @@ struct dwc3 {
|
||||
struct usb_role_switch *role_sw;
|
||||
enum usb_dr_mode role_switch_default_mode;
|
||||
|
||||
struct power_supply *usb_psy;
|
||||
|
||||
u32 fladj;
|
||||
u32 irq_gadget;
|
||||
u32 otg_irq;
|
||||
|
||||
Reference in New Issue
Block a user