Skip to content

Commit e65d593

Browse files
wanahmadzainiegratian
authored andcommitted
usb: dwc3: call _DSM for core soft reset
The issue is, if core soft reset is issued while Intel Apollo Lake USB mux is in Host role mode, it takes close to 7 minutes before we are able to switch USB mux from Host mode to Device mode. This is due to RTL bug. The workaround is to let BIOS issue the core soft reset via _DSM method. It will ensure that USB mux is in Device role mode before issuing core soft reset, and will inform the driver whether the reset is success within the timeout value, or the timeout is exceeded. commit cd78b8067c6e ("usb: dwc3: call _DSM for core soft reset") originated from http://git.yoctoproject.org/cgit/cgit.cgi/linux-yocto-4.1/ Signed-off-by: Wan Ahmad Zainie <wan.ahmad.zainie.wan.mohamad@intel.com> [akash.mankar@ni.com: changed the way has_dsm_for_softreset property is set in dwc3-pci.c and read in core.c] Signed-off-by: Akash Mankar <akash.mankar@ni.com> Signed-off-by: Brad Mouring <brad.mouring@ni.com> Acked-by: Gratian Crisan <gratian.crisan@ni.com> Acked-by: Brandon Streiff <brandon.streif@ni.com> Natinst-ReviewBoard-ID: 178124 [gratian: fixed merge conflicts, mainly due to dwc3_soft_reset removal] Signed-off-by: Gratian Crisan <gratian.crisan@ni.com> [bstreiff: fixed merge conflicts due to property refactor by 1a7b12f ("usb: dwc3: pci: Supply device properties via driver data")] [gratian: fix merge conflict with f580170 ("usb: dwc3: Add splitdisable quirk for Hisilicon Kirin Soc")] Signed-off-by: Gratian Crisan <gratian.crisan@ni.com> [gratian: fix conflict with 582ab24 ("usb: dwc3: pci: Set "linux,phy_charger_detect" property on some Bay Trail boards")] Signed-off-by: Gratian Crisan <gratian.crisan@ni.com>
1 parent 206a8e8 commit e65d593

3 files changed

Lines changed: 57 additions & 3 deletions

File tree

‎drivers/usb/dwc3/core.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,38 @@ u32 dwc3_core_fifo_space(struct dwc3_ep *dep, u8 type)
265265
return DWC3_GDBGFIFOSPACE_SPACE_AVAILABLE(reg);
266266
}
267267

268+
/**
269+
* WORKAROUND: We let BIOS issues the core soft reset to Device
270+
* controller for Intel Apollo Lake, via _DSM method.
271+
*
272+
* The issue is, if core soft reset is issued while Intel Apollo Lake
273+
* USB mux is in Host role mode, it takes close to 7 minutes before
274+
* we are able to switch USB mux from Host mode to Device mode.
275+
*/
276+
static int dwc3_pci_dsm_soft_reset(struct device *dev)
277+
{
278+
int ret = -ETIMEDOUT;
279+
union acpi_object *obj;
280+
guid_t guid;
281+
282+
WARN_ON(guid_parse("732b85d5-b7a7-4a1b-9ba0-4bbd00ffd511", &guid));
283+
284+
obj = acpi_evaluate_dsm(ACPI_HANDLE(dev),
285+
&guid,
286+
1, 6, NULL);
287+
if (!obj) {
288+
dev_err(dev, "failed to evaluate _DSM\n");
289+
return -EIO;
290+
}
291+
292+
if (obj->type == ACPI_TYPE_INTEGER)
293+
ret = (obj->integer.value == 0) ? 0 : -ETIMEDOUT;
294+
dev_dbg(dev, "dwc3_pci_dsm_soft_reset() ret= %d\n", ret);
295+
296+
ACPI_FREE(obj);
297+
return ret;
298+
}
299+
268300
/**
269301
* dwc3_core_soft_reset - Issues core soft reset and PHY reset
270302
* @dwc: pointer to our context structure
@@ -282,6 +314,11 @@ int dwc3_core_soft_reset(struct dwc3 *dwc)
282314
if (dwc->current_dr_role == DWC3_GCTL_PRTCAP_HOST)
283315
return 0;
284316

317+
if (dwc->has_dsm_for_softreset) {
318+
dev_dbg(dwc->dev, "calling dwc3_pci_dsm_soft_reset()");
319+
return dwc3_pci_dsm_soft_reset(dwc->dev);
320+
}
321+
285322
reg = dwc3_readl(dwc->regs, DWC3_DCTL);
286323
reg |= DWC3_DCTL_CSFTRST;
287324
reg &= ~DWC3_DCTL_RUN_STOP;
@@ -1575,6 +1612,9 @@ static void dwc3_get_properties(struct dwc3 *dwc)
15751612
dwc->dis_split_quirk = device_property_read_bool(dev,
15761613
"snps,dis-split-quirk");
15771614

1615+
dwc->has_dsm_for_softreset = device_property_read_bool(dev,
1616+
"snps,has_dsm_for_softreset");
1617+
15781618
dwc->lpm_nyet_threshold = lpm_nyet_threshold;
15791619
dwc->tx_de_emphasis = tx_de_emphasis;
15801620

‎drivers/usb/dwc3/core.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,6 +1110,7 @@ struct dwc3_scratchpad_array {
11101110
* 3 - Reserved
11111111
* @dis_metastability_quirk: set to disable metastability quirk.
11121112
* @dis_split_quirk: set to disable split boundary.
1113+
* @has_dsm_for_softreset: set if we want to use BIOS to do core soft reset
11131114
* @imod_interval: set the interrupt moderation interval in 250ns
11141115
* increments or 0 to disable.
11151116
* @max_cfg_eps: current max number of IN eps used across all USB configs.
@@ -1327,6 +1328,8 @@ struct dwc3 {
13271328
unsigned dis_split_quirk:1;
13281329
unsigned async_callbacks:1;
13291330

1331+
unsigned has_dsm_for_softreset:1;
1332+
13301333
u16 imod_interval;
13311334

13321335
int max_cfg_eps;

‎drivers/usb/dwc3/dwc3-pci.c‎

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ static const struct property_entry dwc3_pci_intel_phy_charger_detect_properties[
133133
{}
134134
};
135135

136+
static const struct property_entry dwc3_pci_intel_bxt_properties[] = {
137+
PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
138+
PROPERTY_ENTRY_BOOL("snps,has_dsm_for_softreset"),
139+
PROPERTY_ENTRY_BOOL("linux,sysdev_is_parent"),
140+
{}
141+
};
142+
136143
static const struct property_entry dwc3_pci_intel_byt_properties[] = {
137144
PROPERTY_ENTRY_STRING("dr_mode", "peripheral"),
138145
PROPERTY_ENTRY_BOOL("snps,dis_u2_susphy_quirk"),
@@ -186,6 +193,10 @@ static const struct software_node dwc3_pci_intel_phy_charger_detect_swnode = {
186193
.properties = dwc3_pci_intel_phy_charger_detect_properties,
187194
};
188195

196+
static const struct software_node dwc3_pci_intel_bxt_swnode = {
197+
.properties = dwc3_pci_intel_bxt_properties,
198+
};
199+
189200
static const struct software_node dwc3_pci_intel_byt_swnode = {
190201
.properties = dwc3_pci_intel_byt_properties,
191202
};
@@ -408,13 +419,13 @@ static const struct pci_device_id dwc3_pci_id_table[] = {
408419
(kernel_ulong_t) &dwc3_pci_intel_swnode, },
409420

410421
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT),
411-
(kernel_ulong_t) &dwc3_pci_intel_swnode, },
422+
(kernel_ulong_t) &dwc3_pci_intel_bxt_swnode, },
412423

413424
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_BXT_M),
414-
(kernel_ulong_t) &dwc3_pci_intel_swnode, },
425+
(kernel_ulong_t) &dwc3_pci_intel_bxt_swnode, },
415426

416427
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_APL),
417-
(kernel_ulong_t) &dwc3_pci_intel_swnode, },
428+
(kernel_ulong_t) &dwc3_pci_intel_bxt_swnode, },
418429

419430
{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_KBP),
420431
(kernel_ulong_t) &dwc3_pci_intel_swnode, },

0 commit comments

Comments
 (0)