Skip to content

Commit 87c3884

Browse files
committed
Merge branch 'bits/040-dwc3' into asahi-wip
2 parents 6df204f + eefe4aa commit 87c3884

13 files changed

Lines changed: 1015 additions & 11 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/usb/apple,dwc3.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Apple Silicon DWC3 USB controller
8+
9+
maintainers:
10+
- Sven Peter <sven@kernel.org>
11+
12+
description:
13+
Apple Silicon SoCs use a Synopsys DesignWare DWC3 based controller for each of
14+
their Type-C ports.
15+
16+
allOf:
17+
- $ref: snps,dwc3-common.yaml#
18+
19+
properties:
20+
compatible:
21+
oneOf:
22+
- items:
23+
- enum:
24+
- apple,t6000-dwc3
25+
- apple,t6020-dwc3
26+
- apple,t8112-dwc3
27+
- const: apple,t8103-dwc3
28+
- const: apple,t8103-dwc3
29+
30+
reg:
31+
items:
32+
- description: Core DWC3 region
33+
- description: Apple-specific DWC3 region
34+
35+
reg-names:
36+
items:
37+
- const: dwc3-core
38+
- const: dwc3-apple
39+
40+
interrupts:
41+
maxItems: 1
42+
43+
iommus:
44+
maxItems: 2
45+
46+
resets:
47+
maxItems: 1
48+
49+
power-domains:
50+
maxItems: 1
51+
52+
required:
53+
- compatible
54+
- reg
55+
- reg-names
56+
- interrupts
57+
- iommus
58+
- resets
59+
- power-domains
60+
- usb-role-switch
61+
62+
unevaluatedProperties: false
63+
64+
examples:
65+
- |
66+
#include <dt-bindings/interrupt-controller/apple-aic.h>
67+
#include <dt-bindings/interrupt-controller/irq.h>
68+
69+
usb@82280000 {
70+
compatible = "apple,t8103-dwc3";
71+
reg = <0x82280000 0xcd00>, <0x8228cd00 0x3200>;
72+
reg-names = "dwc3-core", "dwc3-apple";
73+
interrupts = <AIC_IRQ 777 IRQ_TYPE_LEVEL_HIGH>;
74+
iommus = <&dwc3_0_dart_0 0>, <&dwc3_0_dart_1 1>;
75+
76+
power-domains = <&ps_atc0_usb>;
77+
resets = <&atcphy0>;
78+
79+
usb-role-switch;
80+
};

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,7 @@ F: Documentation/devicetree/bindings/power/reset/apple,smc-reboot.yaml
24422442
F: Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml
24432443
F: Documentation/devicetree/bindings/spi/apple,spi.yaml
24442444
F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml
2445+
F: Documentation/devicetree/bindings/usb/apple,dwc3.yaml
24452446
F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml
24462447
F: arch/arm64/boot/dts/apple/
24472448
F: drivers/bluetooth/hci_bcm4377.c
@@ -2466,6 +2467,7 @@ F: drivers/pwm/pwm-apple.c
24662467
F: drivers/soc/apple/*
24672468
F: drivers/spi/spi-apple.c
24682469
F: drivers/spmi/spmi-apple-controller.c
2470+
F: drivers/usb/dwc3/dwc3-apple.c
24692471
F: drivers/video/backlight/apple_dwi_bl.c
24702472
F: drivers/watchdog/apple_wdt.c
24712473
F: include/dt-bindings/interrupt-controller/apple-aic.h

drivers/usb/dwc3/Kconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,4 +200,15 @@ config USB_DWC3_GENERIC_PLAT
200200
the dwc3 child node in the device tree.
201201
Say 'Y' or 'M' here if your platform integrates DWC3 in a similar way.
202202

203+
config USB_DWC3_APPLE
204+
tristate "Apple Silicon DWC3 Platform Driver"
205+
depends on OF && ARCH_APPLE
206+
default USB_DWC3
207+
select USB_ROLE_SWITCH
208+
help
209+
Support Apple Silicon SoCs with DesignWare Core USB3 IP.
210+
The DesignWare Core USB3 IP has to be used in dual-role
211+
mode on these machines.
212+
Say 'Y' or 'M' if you have such device.
213+
203214
endif

drivers/usb/dwc3/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ endif
4343
##
4444

4545
obj-$(CONFIG_USB_DWC3_AM62) += dwc3-am62.o
46+
obj-$(CONFIG_USB_DWC3_APPLE) += dwc3-apple.o
4647
obj-$(CONFIG_USB_DWC3_OMAP) += dwc3-omap.o
4748
obj-$(CONFIG_USB_DWC3_EXYNOS) += dwc3-exynos.o
4849
obj-$(CONFIG_USB_DWC3_PCI) += dwc3-pci.o

drivers/usb/dwc3/core.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void dwc3_enable_susphy(struct dwc3 *dwc, bool enable)
133133
dwc3_writel(dwc->regs, DWC3_GUSB2PHYCFG(i), reg);
134134
}
135135
}
136+
EXPORT_SYMBOL_GPL(dwc3_enable_susphy);
136137

137138
void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode, bool ignore_susphy)
138139
{
@@ -159,6 +160,7 @@ void dwc3_set_prtcap(struct dwc3 *dwc, u32 mode, bool ignore_susphy)
159160
dwc->current_dr_role = mode;
160161
trace_dwc3_set_prtcap(mode);
161162
}
163+
EXPORT_SYMBOL_GPL(dwc3_set_prtcap);
162164

163165
static void __dwc3_set_mode(struct work_struct *work)
164166
{
@@ -976,14 +978,15 @@ static void dwc3_clk_disable(struct dwc3 *dwc)
976978
clk_disable_unprepare(dwc->bus_clk);
977979
}
978980

979-
static void dwc3_core_exit(struct dwc3 *dwc)
981+
void dwc3_core_exit(struct dwc3 *dwc)
980982
{
981983
dwc3_event_buffers_cleanup(dwc);
982984
dwc3_phy_power_off(dwc);
983985
dwc3_phy_exit(dwc);
984986
dwc3_clk_disable(dwc);
985987
reset_control_assert(dwc->reset);
986988
}
989+
EXPORT_SYMBOL_GPL(dwc3_core_exit);
987990

988991
static bool dwc3_core_is_valid(struct dwc3 *dwc)
989992
{
@@ -1331,7 +1334,7 @@ static void dwc3_config_threshold(struct dwc3 *dwc)
13311334
*
13321335
* Returns 0 on success otherwise negative errno.
13331336
*/
1334-
static int dwc3_core_init(struct dwc3 *dwc)
1337+
int dwc3_core_init(struct dwc3 *dwc)
13351338
{
13361339
unsigned int hw_mode;
13371340
u32 reg;
@@ -1531,6 +1534,7 @@ static int dwc3_core_init(struct dwc3 *dwc)
15311534

15321535
return ret;
15331536
}
1537+
EXPORT_SYMBOL_GPL(dwc3_core_init);
15341538

15351539
static int dwc3_core_get_phy(struct dwc3 *dwc)
15361540
{
@@ -1669,14 +1673,21 @@ static void dwc3_core_exit_mode(struct dwc3 *dwc)
16691673
dwc3_set_prtcap(dwc, DWC3_GCTL_PRTCAP_DEVICE, true);
16701674
}
16711675

1672-
static void dwc3_get_software_properties(struct dwc3 *dwc)
1676+
static void dwc3_get_software_properties(struct dwc3 *dwc,
1677+
const struct dwc3_properties *properties)
16731678
{
16741679
struct device *tmpdev;
16751680
u16 gsbuscfg0_reqinfo;
16761681
int ret;
16771682

16781683
dwc->gsbuscfg0_reqinfo = DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED;
16791684

1685+
if (properties->gsbuscfg0_reqinfo !=
1686+
DWC3_GSBUSCFG0_REQINFO_UNSPECIFIED) {
1687+
dwc->gsbuscfg0_reqinfo = properties->gsbuscfg0_reqinfo;
1688+
return;
1689+
}
1690+
16801691
/*
16811692
* Iterate over all parent nodes for finding swnode properties
16821693
* and non-DT (non-ABI) properties.
@@ -2209,7 +2220,7 @@ int dwc3_core_probe(const struct dwc3_probe_data *data)
22092220

22102221
dwc3_get_properties(dwc);
22112222

2212-
dwc3_get_software_properties(dwc);
2223+
dwc3_get_software_properties(dwc, &data->properties);
22132224

22142225
dwc->usb_psy = dwc3_get_usb_power_supply(dwc);
22152226
if (IS_ERR(dwc->usb_psy))
@@ -2302,9 +2313,11 @@ int dwc3_core_probe(const struct dwc3_probe_data *data)
23022313
dwc3_check_params(dwc);
23032314
dwc3_debugfs_init(dwc);
23042315

2305-
ret = dwc3_core_init_mode(dwc);
2306-
if (ret)
2307-
goto err_exit_debugfs;
2316+
if (!data->skip_core_init_mode) {
2317+
ret = dwc3_core_init_mode(dwc);
2318+
if (ret)
2319+
goto err_exit_debugfs;
2320+
}
23082321

23092322
pm_runtime_put(dev);
23102323

@@ -2359,6 +2372,7 @@ static int dwc3_probe(struct platform_device *pdev)
23592372

23602373
probe_data.dwc = dwc;
23612374
probe_data.res = res;
2375+
probe_data.properties = DWC3_DEFAULT_PROPERTIES;
23622376

23632377
return dwc3_core_probe(&probe_data);
23642378
}

drivers/usb/dwc3/drd.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,7 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
515515
dwc3_role_switch.set = dwc3_usb_role_switch_set;
516516
dwc3_role_switch.get = dwc3_usb_role_switch_get;
517517
dwc3_role_switch.driver_data = dwc;
518+
dwc3_role_switch.allow_userspace_control = true;
518519
dwc->role_sw = usb_role_switch_register(dwc->dev, &dwc3_role_switch);
519520
if (IS_ERR(dwc->role_sw))
520521
return PTR_ERR(dwc->role_sw);

0 commit comments

Comments
 (0)