Skip to content

Commit 97238b3

Browse files
Sebastian Andrzej SiewiorFelipe Balbi
Sebastian Andrzej Siewior
authored and
Felipe Balbi
committed
usb: musb: dsps: use proper child nodes
This moves the two instances from the big node into two child nodes. The glue layer ontop does almost nothing. There is one devices containing the control module for USB (2) phy, (2) usb and later the dma engine. The usb device is the "glue device" which contains the musb device as a child. This is what we do ever since. The new file musb_am335x is just here to prob the new bus and populate child devices. There are a lot of changes to the dsps file as a result of the changes: - musb_core_offset This is gone. The device tree provides memory ressources information for the device there is no need to "fix" things - instances This is gone as well. If we have two instances then we have have two child enabled nodes in the device tree. For instance the SoC in beagle bone has two USB instances but only one has been wired up so there is no need to load and init the second instance since it won't be used. - dsps_glue is now per glue device In the past there was one of this structs but with an array of two and each instance accessed its variable depending on the platform device id. - no unneeded copy of structs I do not know why struct dsps_musb_wrapper is copied but it is not necessary. The same goes for musb_hdrc_platform_data which allocated on demand and then again by platform_device_add_data(). One copy is enough. Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent e96bdc3 commit 97238b3

File tree

8 files changed

+299
-171
lines changed

8 files changed

+299
-171
lines changed

Diff for: arch/arm/boot/dts/am335x-bone.dts

+16
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@
120120
status = "okay";
121121
};
122122

123+
musb: usb@47400000 {
124+
status = "okay";
125+
126+
control@44e10000 {
127+
status = "okay";
128+
};
129+
130+
phy@47401300 {
131+
status = "okay";
132+
};
133+
134+
usb@47401000 {
135+
status = "okay";
136+
};
137+
};
138+
123139
i2c0: i2c@44e0b000 {
124140
pinctrl-names = "default";
125141
pinctrl-0 = <&i2c0_pins>;

Diff for: arch/arm/boot/dts/am335x-evm.dts

+24
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,30 @@
171171
};
172172
};
173173

174+
musb: usb@47400000 {
175+
status = "okay";
176+
177+
control@44e10000 {
178+
status = "okay";
179+
};
180+
181+
phy@47401300 {
182+
status = "okay";
183+
};
184+
185+
phy@47401b00 {
186+
status = "okay";
187+
};
188+
189+
usb@47401000 {
190+
status = "okay";
191+
};
192+
193+
usb@47401800 {
194+
status = "okay";
195+
};
196+
};
197+
174198
i2c1: i2c@4802a000 {
175199
pinctrl-names = "default";
176200
pinctrl-0 = <&i2c1_pins>;

Diff for: arch/arm/boot/dts/am335x-evmsk.dts

+16
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@
207207
};
208208
};
209209

210+
musb: usb@47400000 {
211+
status = "okay";
212+
213+
control@44e10000 {
214+
status = "okay";
215+
};
216+
217+
phy@47401300 {
218+
status = "okay";
219+
};
220+
221+
usb@47401000 {
222+
status = "okay";
223+
};
224+
};
225+
210226
epwmss2: epwmss@48304000 {
211227
status = "okay";
212228

Diff for: arch/arm/boot/dts/am33xx.dtsi

+83-14
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
serial5 = &uart5;
2727
d_can0 = &dcan0;
2828
d_can1 = &dcan1;
29+
usb0 = &usb0;
30+
usb1 = &usb1;
31+
phy0 = &usb0_phy;
32+
phy1 = &usb1_phy;
2933
};
3034

3135
cpus {
@@ -333,21 +337,86 @@
333337
status = "disabled";
334338
};
335339

336-
usb@47400000 {
337-
compatible = "ti,musb-am33xx";
338-
reg = <0x47400000 0x1000 /* usbss */
339-
0x47401000 0x800 /* musb instance 0 */
340-
0x47401800 0x800>; /* musb instance 1 */
341-
interrupts = <17 /* usbss */
342-
18 /* musb instance 0 */
343-
19>; /* musb instance 1 */
344-
multipoint = <1>;
345-
num-eps = <16>;
346-
ram-bits = <12>;
347-
port0-mode = <3>;
348-
port1-mode = <3>;
349-
power = <250>;
340+
usb: usb@47400000 {
341+
compatible = "ti,am33xx-usb";
342+
reg = <0x47400000 0x1000>;
343+
ranges;
344+
#address-cells = <1>;
345+
#size-cells = <1>;
350346
ti,hwmods = "usb_otg_hs";
347+
status = "disabled";
348+
349+
ctrl_mod: control@44e10000 {
350+
compatible = "ti,am335x-usb-ctrl-module";
351+
reg = <0x44e10620 0x10
352+
0x44e10648 0x4>;
353+
reg-names = "phy_ctrl", "wakeup";
354+
status = "disabled";
355+
};
356+
357+
usb0_phy: phy@47401300 {
358+
compatible = "ti,am335x-usb-phy";
359+
reg = <0x47401300 0x100>;
360+
reg-names = "phy";
361+
status = "disabled";
362+
ti,ctrl_mod = <&ctrl_mod>;
363+
};
364+
365+
usb0: usb@47401000 {
366+
compatible = "ti,musb-am33xx";
367+
ranges;
368+
#address-cells = <1>;
369+
#size-cells = <1>;
370+
reg = <0x47401000 0x200>;
371+
reg-names = "control";
372+
status = "disabled";
373+
374+
musb0: usb@47401400 {
375+
compatible = "mg,musbmhdrc";
376+
reg = <0x47401400 0x400>;
377+
reg-names = "mc";
378+
interrupts = <18>;
379+
interrupt-names = "mc";
380+
multipoint = <1>;
381+
num-eps = <16>;
382+
ram-bits = <12>;
383+
port-mode = <3>;
384+
power = <250>;
385+
phys = <&usb0_phy>;
386+
};
387+
};
388+
389+
usb1_phy: phy@47401b00 {
390+
compatible = "ti,am335x-usb-phy";
391+
reg = <0x47401b00 0x100>;
392+
reg-names = "phy";
393+
status = "disabled";
394+
ti,ctrl_mod = <&ctrl_mod>;
395+
};
396+
397+
usb1: usb@47401800 {
398+
compatible = "ti,musb-am33xx";
399+
ranges;
400+
#address-cells = <1>;
401+
#size-cells = <1>;
402+
reg = <0x47401800 0x200>;
403+
reg-names = "control";
404+
status = "disabled";
405+
406+
musb1: usb@47401c00 {
407+
compatible = "mg,musbmhdrc";
408+
reg = <0x47401c00 0x400>;
409+
reg-names = "mc";
410+
interrupts = <19>;
411+
interrupt-names = "mc";
412+
multipoint = <1>;
413+
num-eps = <16>;
414+
ram-bits = <12>;
415+
port-mode = <3>;
416+
power = <250>;
417+
phys = <&usb1_phy>;
418+
};
419+
};
351420
};
352421

353422
epwmss0: epwmss@48300000 {

Diff for: drivers/usb/musb/Kconfig

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ config USB_MUSB_AM35X
8383

8484
config USB_MUSB_DSPS
8585
tristate "TI DSPS platforms"
86+
select USB_MUSB_AM335X_CHILD
8687

8788
config USB_MUSB_BLACKFIN
8889
tristate "Blackfin"
@@ -93,6 +94,9 @@ config USB_MUSB_UX500
9394

9495
endchoice
9596

97+
config USB_MUSB_AM335X_CHILD
98+
tristate
99+
96100
choice
97101
prompt 'MUSB DMA mode'
98102
default MUSB_PIO_ONLY if ARCH_MULTIPLATFORM

Diff for: drivers/usb/musb/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ obj-$(CONFIG_USB_MUSB_DA8XX) += da8xx.o
2020
obj-$(CONFIG_USB_MUSB_BLACKFIN) += blackfin.o
2121
obj-$(CONFIG_USB_MUSB_UX500) += ux500.o
2222

23+
24+
obj-$(CONFIG_USB_MUSB_AM335X_CHILD) += musb_am335x.o
25+
2326
# the kconfig must guarantee that only one of the
2427
# possible I/O schemes will be enabled at a time ...
2528
# PIO only, or DMA (several potential schemes).

Diff for: drivers/usb/musb/musb_am335x.c

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#include <linux/init.h>
2+
#include <linux/platform_device.h>
3+
#include <linux/pm_runtime.h>
4+
#include <linux/module.h>
5+
#include <linux/of_platform.h>
6+
7+
static int am335x_child_probe(struct platform_device *pdev)
8+
{
9+
int ret;
10+
11+
pm_runtime_enable(&pdev->dev);
12+
13+
ret = of_platform_populate(pdev->dev.of_node, NULL, NULL, &pdev->dev);
14+
if (ret)
15+
goto err;
16+
17+
return 0;
18+
err:
19+
pm_runtime_disable(&pdev->dev);
20+
return ret;
21+
}
22+
23+
static int of_remove_populated_child(struct device *dev, void *d)
24+
{
25+
struct platform_device *pdev = to_platform_device(dev);
26+
27+
of_device_unregister(pdev);
28+
return 0;
29+
}
30+
31+
static int am335x_child_remove(struct platform_device *pdev)
32+
{
33+
device_for_each_child(&pdev->dev, NULL, of_remove_populated_child);
34+
pm_runtime_disable(&pdev->dev);
35+
return 0;
36+
}
37+
38+
static const struct of_device_id am335x_child_of_match[] = {
39+
{ .compatible = "ti,am33xx-usb" },
40+
{ },
41+
};
42+
MODULE_DEVICE_TABLE(of, am335x_child_of_match);
43+
44+
static struct platform_driver am335x_child_driver = {
45+
.probe = am335x_child_probe,
46+
.remove = am335x_child_remove,
47+
.driver = {
48+
.name = "am335x-usb-childs",
49+
.of_match_table = of_match_ptr(am335x_child_of_match),
50+
},
51+
};
52+
53+
module_platform_driver(am335x_child_driver);
54+
MODULE_DESCRIPTION("AM33xx child devices");
55+
MODULE_LICENSE("GPL v2");

0 commit comments

Comments
 (0)