usb: Import xiaomi changes from mayfly-s-oss
Change-Id: I8fe3c64906ce7ee33788b6c5d893dd7c73205658
This commit is contained in:
parent
c259056378
commit
ca9a3a1fb8
@ -3295,6 +3295,9 @@ static void dwc3_set_phy_speed_flags(struct dwc3_msm *mdwc)
|
||||
}
|
||||
}
|
||||
} else if (mdwc->drd_state == DRD_STATE_PERIPHERAL_SUSPEND) {
|
||||
if (!dwc->gadget)
|
||||
return;
|
||||
|
||||
if (dwc->gadget->speed == USB_SPEED_HIGH ||
|
||||
dwc->gadget->speed == USB_SPEED_FULL)
|
||||
mdwc->hs_phy->flags |= PHY_HSFS_MODE;
|
||||
@ -3587,6 +3590,7 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc, bool force_power_collapse)
|
||||
dwc3_set_phy_speed_flags(mdwc);
|
||||
/* Suspend HS PHY */
|
||||
usb_phy_set_suspend(mdwc->hs_phy, 1);
|
||||
usb_phy_set_suspend(mdwc->ss_phy, 1);
|
||||
|
||||
/*
|
||||
* Synopsys Superspeed PHY does not support ss_phy_irq, so to detect
|
||||
@ -6067,8 +6071,9 @@ static int dwc3_otg_start_host(struct dwc3_msm *mdwc, int on)
|
||||
flush_work(&dwc->drd_work);
|
||||
dwc3_msm_override_pm_ops(&dwc->xhci->dev, mdwc->xhci_pm_ops, true);
|
||||
mdwc->in_host_mode = true;
|
||||
dwc3_msm_override_pm_ops(&dwc->xhci->dev, mdwc->xhci_pm_ops, true);
|
||||
pm_runtime_use_autosuspend(&dwc->xhci->dev);
|
||||
pm_runtime_set_autosuspend_delay(&dwc->xhci->dev, 0);
|
||||
pm_runtime_set_autosuspend_delay(&dwc->xhci->dev, 3000);
|
||||
pm_runtime_allow(&dwc->xhci->dev);
|
||||
pm_runtime_mark_last_busy(&dwc->xhci->dev);
|
||||
|
||||
@ -6256,7 +6261,6 @@ static int dwc3_otg_start_peripheral(struct dwc3_msm *mdwc, int on)
|
||||
msm_dwc3_perf_vote_enable(mdwc, false);
|
||||
cpu_latency_qos_remove_request(&mdwc->pm_qos_req_dma);
|
||||
|
||||
dwc3_override_vbus_status(mdwc, false);
|
||||
mdwc->in_device_mode = false;
|
||||
usb_phy_notify_disconnect(mdwc->hs_phy, USB_SPEED_HIGH);
|
||||
usb_phy_set_power(mdwc->hs_phy, 0);
|
||||
@ -6323,6 +6327,7 @@ static void dwc3_otg_sm_work(struct work_struct *w)
|
||||
int ret = 0;
|
||||
unsigned long delay = 0;
|
||||
const char *state;
|
||||
unsigned int timeout = 20;
|
||||
|
||||
if (mdwc->dwc3)
|
||||
dwc = platform_get_drvdata(mdwc->dwc3);
|
||||
@ -6388,6 +6393,21 @@ static void dwc3_otg_sm_work(struct work_struct *w)
|
||||
dbg_event(0xFF, "Exit UNDEF", 0);
|
||||
/* fall-through */
|
||||
case DRD_STATE_IDLE:
|
||||
if (test_bit(WAIT_FOR_LPM, &mdwc->inputs)){
|
||||
do {
|
||||
msleep(20);
|
||||
} while (--timeout && (test_bit(WAIT_FOR_LPM, &mdwc->inputs)));
|
||||
|
||||
if (!timeout) {
|
||||
dev_info(mdwc->dev,
|
||||
"Not in LPM after disconnect, forcing suspend...\n");
|
||||
dbg_event(0xFF, "Force:SUSP",
|
||||
atomic_read(&mdwc->dev->power.usage_count));
|
||||
pm_runtime_suspend(mdwc->dev);
|
||||
} else
|
||||
dev_info(mdwc->dev, "enter in lpm after:%d ms\n",20*timeout);
|
||||
}
|
||||
|
||||
if (test_bit(WAIT_FOR_LPM, &mdwc->inputs)) {
|
||||
dev_dbg(mdwc->dev, "still not in lpm, wait.\n");
|
||||
dbg_event(0xFF, "WAIT_FOR_LPM", 0);
|
||||
|
@ -4270,6 +4270,12 @@ static void dwc3_gadget_interrupt(struct dwc3 *dwc,
|
||||
dwc3_gadget_linksts_change_interrupt(dwc, event->event_info);
|
||||
break;
|
||||
case DWC3_DEVICE_EVENT_SUSPEND:
|
||||
#ifdef CONFIG_FACTORY_BUILD
|
||||
if (dwc->gadget.state >= USB_STATE_CONFIGURED){
|
||||
pr_info("Do not active the suspend irq under factory build version\n");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
/* It changed to be suspend event for version 2.30a and above */
|
||||
if (!DWC3_VER_IS_PRIOR(DWC3, 230A))
|
||||
dwc3_gadget_suspend_interrupt(dwc, event->event_info);
|
||||
|
@ -2363,6 +2363,10 @@ static int fsg_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
|
||||
static void fsg_disable(struct usb_function *f)
|
||||
{
|
||||
struct fsg_dev *fsg = fsg_from_func(f);
|
||||
struct fsg_common *common = fsg->common;
|
||||
|
||||
do_set_interface(fsg->common, NULL);
|
||||
wait_event(common->fsg_wait, common->fsg != fsg);
|
||||
|
||||
/* Disable the endpoints */
|
||||
if (fsg->bulk_in_enabled) {
|
||||
|
@ -679,7 +679,7 @@ static int msm_eusb2_repeater_reset_and_init(struct msm_eusb2_phy *phy)
|
||||
if (ret)
|
||||
dev_err(phy->phy.dev, "repeater reset failed.\n");
|
||||
|
||||
ret = usb_repeater_init(phy->ur);
|
||||
ret = usb_repeater_init(phy->ur, phy->phy.flags);
|
||||
if (ret)
|
||||
dev_err(phy->phy.dev, "repeater init failed.\n");
|
||||
|
||||
@ -691,7 +691,7 @@ static int msm_eusb2_phy_init(struct usb_phy *uphy)
|
||||
struct msm_eusb2_phy *phy = container_of(uphy, struct msm_eusb2_phy, phy);
|
||||
int ret;
|
||||
|
||||
dev_dbg(uphy->dev, "phy_flags:%x\n", phy->phy.flags);
|
||||
dev_err(uphy->dev, "msm_eusb2_phy phy_flags:%x\n", phy->phy.flags);
|
||||
if (is_eud_debug_mode_active(phy)) {
|
||||
/* if in host mode, disable EUD debug mode */
|
||||
if (phy->phy.flags & PHY_HOST_MODE) {
|
||||
@ -1140,3 +1140,4 @@ static struct platform_driver msm_eusb2_phy_driver = {
|
||||
module_platform_driver(msm_eusb2_phy_driver);
|
||||
MODULE_DESCRIPTION("MSM USB eUSB2 PHY driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
MODULE_SOFTDEP("pre: repeater-i2c-eusb2");
|
||||
|
@ -18,6 +18,7 @@
|
||||
#include <linux/regulator/consumer.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/usb/repeater.h>
|
||||
#include <linux/usb/dwc3-msm.h>
|
||||
|
||||
#define EUSB2_3P0_VOL_MIN 3075000 /* uV */
|
||||
#define EUSB2_3P0_VOL_MAX 3300000 /* uV */
|
||||
@ -89,6 +90,8 @@ struct eusb2_repeater {
|
||||
struct gpio_desc *reset_gpiod;
|
||||
u32 *param_override_seq;
|
||||
u8 param_override_seq_cnt;
|
||||
u32 *param_override_seq_host;
|
||||
u8 param_override_seq_cnt_host;
|
||||
};
|
||||
|
||||
static const struct regmap_config eusb2_i2c_regmap = {
|
||||
@ -114,7 +117,7 @@ static int eusb2_i2c_read_reg(struct eusb2_repeater *er, u8 reg, u8 *val)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int eusb2_i2c_write_reg(struct eusb2_repeater *er, u8 reg, u8 val)
|
||||
static int eusb2_i2c_write_reg(struct eusb2_repeater *er, u8 reg, u32 val)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -241,7 +244,7 @@ static int eusb2_repeater_power(struct eusb2_repeater *er, bool on)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int eusb2_repeater_init(struct usb_repeater *ur)
|
||||
static int eusb2_repeater_init(struct usb_repeater *ur, unsigned int flags)
|
||||
{
|
||||
struct eusb2_repeater *er =
|
||||
container_of(ur, struct eusb2_repeater, ur);
|
||||
@ -265,11 +268,18 @@ static int eusb2_repeater_init(struct usb_repeater *ur)
|
||||
dev_info(er->ur.dev, "eUSB2 repeater version = 0x%x ur->flags:0x%x\n", reg_val, ur->flags);
|
||||
|
||||
/* override init sequence using devicetree based values */
|
||||
if (er->param_override_seq_cnt)
|
||||
eusb2_repeater_update_seq(er, er->param_override_seq,
|
||||
if (er->param_override_seq_cnt) {
|
||||
if (flags & PHY_HOST_MODE) {
|
||||
/*it's host, then write host eye params*/
|
||||
eusb2_repeater_update_seq(er, er->param_override_seq_host,
|
||||
er->param_override_seq_cnt_host);
|
||||
dev_info(er->ur.dev, "eUSB2 repeater init host \n");
|
||||
} else {
|
||||
eusb2_repeater_update_seq(er, er->param_override_seq,
|
||||
er->param_override_seq_cnt);
|
||||
|
||||
dev_info(er->ur.dev, "eUSB2 repeater init\n");
|
||||
dev_info(er->ur.dev, "eUSB2 repeater init device!\n");
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -405,6 +415,36 @@ static int eusb2_repeater_i2c_probe(struct i2c_client *client)
|
||||
}
|
||||
}
|
||||
|
||||
/*This is for host params. start*/
|
||||
num_elem = of_property_count_elems_of_size(dev->of_node, "qcom,param-override-seq-host",
|
||||
sizeof(*er->param_override_seq_host));
|
||||
if (num_elem > 0) {
|
||||
if (num_elem % 2) {
|
||||
dev_err(dev, "invalid param_override_seq_len\n");
|
||||
ret = -EINVAL;
|
||||
goto err_probe;
|
||||
}
|
||||
|
||||
er->param_override_seq_cnt_host = num_elem;
|
||||
er->param_override_seq_host = devm_kcalloc(dev,
|
||||
er->param_override_seq_cnt_host,
|
||||
sizeof(*er->param_override_seq_host), GFP_KERNEL);
|
||||
if (!er->param_override_seq_host) {
|
||||
ret = -ENOMEM;
|
||||
goto err_probe;
|
||||
}
|
||||
|
||||
ret = of_property_read_u32_array(dev->of_node,
|
||||
"qcom,param-override-seq-host",
|
||||
er->param_override_seq_host,
|
||||
er->param_override_seq_cnt_host);
|
||||
if (ret) {
|
||||
dev_err(dev, "qcom,param-override-seq-host read failed %d\n",
|
||||
ret);
|
||||
goto err_probe;
|
||||
}
|
||||
}
|
||||
/*This is for host params. end*/
|
||||
|
||||
er->ur.dev = dev;
|
||||
|
||||
|
@ -18,7 +18,7 @@ struct usb_repeater {
|
||||
|
||||
struct list_head head;
|
||||
int (*reset)(struct usb_repeater *x, bool bring_out_of_reset);
|
||||
int (*init)(struct usb_repeater *x);
|
||||
int (*init)(struct usb_repeater *x, unsigned int flags);
|
||||
int (*suspend)(struct usb_repeater *r, int suspend);
|
||||
int (*powerup)(struct usb_repeater *r);
|
||||
int (*powerdown)(struct usb_repeater *r);
|
||||
@ -60,10 +60,10 @@ static inline int usb_repeater_reset(struct usb_repeater *r,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int usb_repeater_init(struct usb_repeater *r)
|
||||
static inline int usb_repeater_init(struct usb_repeater *r, unsigned int flags)
|
||||
{
|
||||
if (r && r->init != NULL)
|
||||
return r->init(r);
|
||||
return r->init(r, flags);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user