usb: musb/dwc3: add driver for control module
Subsystems (8)
v4 cover usb: musb/dwc3: add driver for control module
Added a new driver for the usb part of control module. This has an API to power on the USB2 phy and an API to write to the mailbox depending on whether MUSB has to act in host mode or in device mode.
Also added an API to power on usb3 phy (omap5).
Writing to control module registers for doing the above task which was previously done in omap glue and in omap-usb2 phy is removed.
Changes from v3:
* Changed property names from "ti,has_mailbox" to "ti,has-mailbox" and "ctrl_module" to "ctrl-module"
* Fixed a compiler warning.
Changes from v2:
* removed "ti,has_mailbox" and added "ti,type" to differentiate whether the control module has usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to notify events to the musb core and omap5 has usb3 phy power register to power on usb3 phy.
* Added an API to power on USB3 PHY needed for OMAP5.
Changes from v1:
* renamed get_omap_control_dev to omap_get_control_dev
* created and exported a single API (omap_control_usb_set_mode) to change the usb mode
* Before writing to the otghs_control regster, the value from otghs_control regster is read and only the appropriate bits are set.
* In omap_init_control_usb, the indentation is now reduced as per Felipe's suggestion.
Changes from RFC:
* Used "#if IS_ENABLED(CONFIG_OMAP_CONTROL_USB)" instead of "#if (defined(CONFIG_OMAP_CONTROL_USB) || \
defined(CONFIG_OMAP_CONTROL_USB_MODULE))"
* return "-EADDRNOTAVAIL" if devm_request_and_ioremap fails.
* Removed the dt data from this patch series (I'll send that as a separate series).
* added "ctrl_module" binding to usb otg glue and usb phy in the Documentaion. This binding is not planned to be used until an actual requirement for it arises.
This series was developed ongit://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb.git xceiv
I've kept this patch series and all the patch series to follow in a single branchgit://gitorious.org/linux-usb/linux-usb.git omap5-with-palmas (changes up to 23b4dfa2ab7052569cd88acc6383c4b1a8e8a482)
Did basic enumeration testing in omap4 panda, omap3 beagle and omap5 evm.
Kishon Vijay Abraham I (4):
drivers: usb: phy: add a new driver for usb part of control module
ARM: OMAP: devices: create device for usb part of control module
ARM: OMAP2: MUSB: Specify omap4 has mailbox
drivers: usb: start using the control module driver
Documentation/devicetree/bindings/usb/omap-usb.txt | 34 ++- Documentation/devicetree/bindings/usb/usb-phy.txt | 12 +- arch/arm/mach-omap2/devices.c | 45 +++ arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 - arch/arm/mach-omap2/usb-musb.c | 3 + drivers/usb/musb/Kconfig | 1 + drivers/usb/musb/omap2430.c | 68 ++--- drivers/usb/musb/omap2430.h | 9 - drivers/usb/phy/Kconfig | 11 + drivers/usb/phy/Makefile | 1 + drivers/usb/phy/omap-control-usb.c | 295 ++++++++++++++++++++ drivers/usb/phy/omap-usb2.c | 41 +-- include/linux/usb/musb.h | 2 + include/linux/usb/omap_control_usb.h | 92 ++++++ include/linux/usb/omap_usb.h | 4 +- 15 files changed, 522 insertions(+), 109 deletions(-) create mode 100644 drivers/usb/phy/omap-control-usb.c create mode 100644 include/linux/usb/omap_control_usb.h
Signature · 1 line
1.7.9.5
PATCH v4 1/4 drivers: usb: phy: add a new driver for usb part of control module
Added a new driver for the usb part of control module. This has an API to power on the USB2 phy and an API to write to the mailbox depending on whether MUSB has to act in host mode or in device mode.
Writing to control module registers for doing the above task which was previously done in omap glue and in omap-usb2 phy will be removed.
--- Documentation/devicetree/bindings/usb/omap-usb.txt | 30 +- Documentation/devicetree/bindings/usb/usb-phy.txt | 5 + drivers/usb/phy/Kconfig | 10 + drivers/usb/phy/Makefile | 1 + drivers/usb/phy/omap-control-usb.c | 295 ++++++++++++++++++++ include/linux/usb/omap_control_usb.h | 92 ++++++ 6 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/phy/omap-control-usb.c create mode 100644 include/linux/usb/omap_control_usb.h
Documentation/devicetree/bindings/usb/omap-usb.txt +29 -1
@@ -1,4 +1,4 @@ -OMAP GLUE +OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS OMAP MUSB GLUE - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb"
@@ -16,6 +16,10 @@ OMAP MUSB GLUE - power : Should be "50". This signifies the controller can supply upto 100mA when operating in host mode. +Optional properties: + - ctrl-module : phandle of the control module this glue uses to write to + mailbox + SOC specific device node entry usb_otg_hs: usb_otg_hs at 4a0ab000 { compatible = "ti,omap4-musb";
@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs at 4a0ab000 { multipoint = <1>; num_eps = <16>; ram_bits = <12>; + ctrl-module = <&omap_control_usb>; }; Board specific device node entry
@@ -31,3 +36,26 @@ Board specific device node entry mode = <3>; power = <50>; }; + +OMAP CONTROL USB + +Required properties: + - compatible: Should be "ti,omap-control-usb" + - reg : Address and length of the register set for the device. It contains + the address of "control_dev_conf" and "otghs_control" or "phy_power_usb" + depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power. + +omap_control_usb: omap-control-usb at 4a002300 { + compatible = "ti,omap-control-usb"; + reg = <0x4a002300 0x4>, + <0x4a00233c 0x4>; + reg-names = "control_dev_conf", "otghs_control"; + ti,type = <1>; +};
Documentation/devicetree/bindings/usb/usb-phy.txt +5 -0
@@ -8,10 +8,15 @@ Required properties: add the address of control module dev conf register until a driver for control module is added +Optional properties: + - ctrl-module : phandle of the control module used by PHY driver to power on + the PHY. + This is usually a subnode of ocp2scp to which it is connected. usb2phy at 4a0ad080 { compatible = "ti,omap-usb2"; reg = <0x4a0ad080 0x58>, <0x4a002300 0x4>; + ctrl-module = <&omap_control_usb>; };
drivers/usb/phy/Kconfig +10 -0
@@ -14,6 +14,16 @@ config OMAP_USB2 The USB OTG controller communicates with the comparator using this driver. +config OMAP_CONTROL_USB + tristate "OMAP CONTROL USB Driver" + depends on ARCH_OMAP2PLUS + help + Enable this to add support for the USB part present in the control + module. This driver has API to power on the USB2 PHY and to write to + the mailbox. The mailbox is present only in omap4 and the register to + power on the USB2 PHY is present in OMAP4 and OMAP5. OMAP5 has an + additional register to power on USB3 PHY. + config USB_ISP1301 tristate "NXP ISP1301 USB transceiver support" depends on USB || USB_GADGET
drivers/usb/phy/Makefile +1 -0
@@ -5,6 +5,7 @@ ccflags-$(CONFIG_USB_DEBUG) := -DDEBUG obj-$(CONFIG_OMAP_USB2) += omap-usb2.o +obj-$(CONFIG_OMAP_CONTROL_USB) += omap-control-usb.o obj-$(CONFIG_USB_ISP1301) += isp1301.o obj-$(CONFIG_MV_U3D_PHY) += mv_u3d_phy.o obj-$(CONFIG_USB_EHCI_TEGRA) += tegra_usb_phy.o
drivers/usb/phy/omap-control-usb.c new file +295 -0
295 lines not on this page · raw message
include/linux/usb/omap_control_usb.h new file +92 -0
92 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
Quoted 49 lines · Kishon Vijay Abraham I
Added a new driver for the usb part of control module. This has an API to power on the USB2 phy and an API to write to the mailbox depending on whether MUSB has to act in host mode or in device mode.
Writing to control module registers for doing the above task which was previously done in omap glue and in omap-usb2 phy will be removed.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 30 +- Documentation/devicetree/bindings/usb/usb-phy.txt | 5 + drivers/usb/phy/Kconfig | 10 + drivers/usb/phy/Makefile | 1 + drivers/usb/phy/omap-control-usb.c | 295 ++++++++++++++++++++ include/linux/usb/omap_control_usb.h | 92 ++++++ 6 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/phy/omap-control-usb.c create mode 100644 include/linux/usb/omap_control_usb.hDocumentation/devicetree/bindings/usb/omap-usb.txt +6
-1@@ -1,4 +1,4 @@ -OMAP GLUE +OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS OMAP MUSB GLUE - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb"@@ -16,6 +16,10 @@ OMAP MUSB GLUE - power : Should be "50". This signifies the controller can supply upto 100mA when operating in host mode. +Optional properties: + - ctrl-module : phandle of the control module this glue uses to write to + mailbox + SOC specific device node entry usb_otg_hs: usb_otg_hs at 4a0ab000 { compatible = "ti,omap4-musb";@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs at 4a0ab000 { multipoint = <1>; num_eps = <16>; ram_bits = <12>; + ctrl-module = <&omap_control_usb>; }; Board specific device node entry
Documentation/devicetree/bindings/usb/omap-usb.txt Board specific device node entry · line 45
Quoted 10 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +7
-0@@ -31,3 +36,26 @@ Board specific device node entry mode = <3>; power = <50>; }; + +OMAP CONTROL USB + +Required properties: + - compatible: Should be "ti,omap-control-usb" + - reg : Address and length of the register set for the device. It contains + the address of "control_dev_conf" and "otghs_control" or "phy_power_usb"
Could you not use '-' over '_' here?
Documentation/devicetree/bindings/usb/omap-usb.txt Board specific device node entry · line 53
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.
Why not make this a string property, perhaps values "mailbox" or "register"?
That way it's easy for humans and code to verify the dts, and easy to expand arbitrarily in future if necessary. It also means you're not leaking kernel-side constants as an ABI.
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ +omap_control_usb: omap-control-usb at 4a002300 { + compatible = "ti,omap-control-usb"; + reg = <0x4a002300 0x4>, + <0x4a00233c 0x4>; + reg-names = "control_dev_conf", "otghs_control"; + ti,type = <1>; +};
[...]
Quoted 11 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +11
-0+static int omap_control_usb_probe(struct platform_device *pdev) +{ + struct resource *res; + struct device_node *np = pdev->dev.of_node; + struct omap_control_usb_platform_data *pdata = pdev->dev.platform_data; + + control_usb = devm_kzalloc(&pdev->dev, sizeof(*control_usb), + GFP_KERNEL); + if (!control_usb) { + dev_err(&pdev->dev, "unable to alloc memory for control usb\n"); + return -ENOMEM;
Documentation/devicetree/bindings/usb/omap-usb.txt
Quoted 10 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +10
-0+ } + + if (np) { + of_property_read_u32(np, "ti,type", &control_usb->type); + } else if (pdata) { + control_usb->type = pdata->type; + } else { + dev_err(&pdev->dev, "no pdata present\n"); + return -EINVAL; + }
Please do some sanity checking here on type. What if it's not OMAP_CTRL_DEV_TYPE1 or OMAP_CTRL_DEV_TYPE2?
What if the values for OMAP_CTRL_DEV_TYPE{1,2} change? The binding will be broken.
If you change ti,type to a string, the parsing also becomes sanity checking:
if (np) {
char *type;
if (of_property_read_string(np, "ti,type", &type) != 0)
return -EINVAL;
if (strcmp(type, "mailbox") == 0)
control_usb->type = OMAP_CTRL_DEV_TYPE1;
else if (strcmp(type, "register") == 0)
control_usb->type = OMAP_CTRL_DEV_TYPE2;
else
return -EINVAL;
} else {
... pdata case ...
}Also, TYPE1 and TYPE2 aren't very descriptive. These could probably be better named.
Quoted 35 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +35
-0+ + control_usb->dev = &pdev->dev; + + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + "control_dev_conf"); + control_usb->dev_conf = devm_request_and_ioremap(&pdev->dev, res); + if (!control_usb->dev_conf) { + dev_err(&pdev->dev, "Failed to obtain io memory\n"); + return -EADDRNOTAVAIL; + } + + if (control_usb->type == OMAP_CTRL_DEV_TYPE1) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + "otghs_control"); + control_usb->otghs_control = devm_request_and_ioremap( + &pdev->dev, res); + if (!control_usb->otghs_control) { + dev_err(&pdev->dev, "Failed to obtain io memory\n"); + return -EADDRNOTAVAIL; + } + } + + if (control_usb->type == OMAP_CTRL_DEV_TYPE2) { + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, + "phy_power_usb"); + control_usb->phy_power = devm_request_and_ioremap( + &pdev->dev, res); + if (!control_usb->phy_power) { + dev_dbg(&pdev->dev, "Failed to obtain io memory\n"); + return -EADDRNOTAVAIL; + } + + control_usb->sys_clk = devm_clk_get(control_usb->dev, + "sys_clkin"); + if (IS_ERR(control_usb->sys_clk)) {
Documentation/devicetree/bindings/usb/omap-usb.txt
Quoted 10 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +10
-0+ pr_err("%s: unable to get sys_clkin\n", __func__); + return -EINVAL; + } + } + + + dev_set_drvdata(control_usb->dev, control_usb); + + return 0; +}
[...]
Thanks,
Mark.
Felipe Balbi
NAKRe: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
Quoted 48 lines · Mark Rutland
Quoted 47 lines · Kishon Vijay Abraham I
Added a new driver for the usb part of control module. This has an API to power on the USB2 phy and an API to write to the mailbox depending on whether MUSB has to act in host mode or in device mode.
Writing to control module registers for doing the above task which was previously done in omap glue and in omap-usb2 phy will be removed.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 30 +- Documentation/devicetree/bindings/usb/usb-phy.txt | 5 + drivers/usb/phy/Kconfig | 10 + drivers/usb/phy/Makefile | 1 + drivers/usb/phy/omap-control-usb.c | 295 ++++++++++++++++++++ include/linux/usb/omap_control_usb.h | 92 ++++++ 6 files changed, 432 insertions(+), 1 deletion(-) create mode 100644 drivers/usb/phy/omap-control-usb.c create mode 100644 include/linux/usb/omap_control_usb.hDocumentation/devicetree/bindings/usb/omap-usb.txt +6
-1@@ -1,4 +1,4 @@ -OMAP GLUE +OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS OMAP MUSB GLUE - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb"@@ -16,6 +16,10 @@ OMAP MUSB GLUE - power : Should be "50". This signifies the controller can supply upto 100mA when operating in host mode. +Optional properties: + - ctrl-module : phandle of the control module this glue uses to write to + mailbox + SOC specific device node entry usb_otg_hs: usb_otg_hs at 4a0ab000 { compatible = "ti,omap4-musb";@@ -23,6 +27,7 @@ usb_otg_hs: usb_otg_hs at 4a0ab000 { multipoint = <1>; num_eps = <16>; ram_bits = <12>; + ctrl-module = <&omap_control_usb>; };
Quoted 14 lines
Documentation/devicetree/bindings/usb/omap-usb.txt Board specific device node entry · line 45
Quoted 12 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +7
-0Board specific device node entry@@ -31,3 +36,26 @@ Board specific device node entry mode = <3>; power = <50>; }; + +OMAP CONTROL USB + +Required properties: + - compatible: Should be "ti,omap-control-usb" + - reg : Address and length of the register set for the device. It contains + the address of "control_dev_conf" and "otghs_control" or "phy_power_usb"Could you not use '-' over '_' here?
that's part of omap hwmod.
Quoted 10 lines
Documentation/devicetree/bindings/usb/omap-usb.txt Board specific device node entry · line 53
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.Why not make this a string property, perhaps values "mailbox" or "register"?
NAK.
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130125/801829f3/attachment.sig>
Re: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
[...]
Quoted 10 lines
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt Board specific device node entry · line 45
Quoted 6 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +6
-0+OMAP CONTROL USB + +Required properties: + - compatible: Should be "ti,omap-control-usb" + - reg : Address and length of the register set for the device. It contains + the address of "control_dev_conf" and "otghs_control" or "phy_power_usb"Could you not use '-' over '_' here?
that's part of omap hwmod.
Aha, that makes sense (unlike my original comment, now I reread it). Sorry for the noise.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.
Quoted 3 lines
Quoted 1 line
Why not make this a string property, perhaps values "mailbox" or "register"?
NAK.
Can I ask what your objection to using a string property is?
As far as I can see, "ti,type" is only used by this driver, so there's no common convention to stick to. Using a string makes the binding easier for humans to read, and thus harder to mess up in a dts, and it decouples the binding from kernel-side constants.
Thanks,
Mark.
Re: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
Hi,
Quoted 11 lines · Mark Rutland
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/usb/omap-usb.txt Board specific device node entry · line 53
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.Why not make this a string property, perhaps values "mailbox" or "register"?
Quoted 8 lines
Quoted 1 line
NAK.
Can I ask what your objection to using a string property is?
As far as I can see, "ti,type" is only used by this driver, so there's no common convention to stick to. Using a string makes the binding easier for humans to read, and thus harder to mess up in a dts, and it decouples the binding from kernel-side constants.
IIRC there is some work going on to add #define-like support for DT, which would allow us to match against integers while still having meaningful symbolic representations.
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130125/868c5612/attachment.sig>
Re: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
Quoted 18 lines · Felipe Balbi
Hi,
Quoted 15 lines · Mark Rutland
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.Quoted 3 lines
Quoted 1 line
Why not make this a string property, perhaps values "mailbox" or "register"?
NAK.
Can I ask what your objection to using a string property is?
Quoted 8 lines
Quoted 4 lines
As far as I can see, "ti,type" is only used by this driver, so there's no common convention to stick to. Using a string makes the binding easier for humans to read, and thus harder to mess up in a dts, and it decouples the binding from kernel-side constants.
IIRC there is some work going on to add #define-like support for DT, which would allow us to match against integers while still having meaningful symbolic representations.
I was under the impression that the motivation for using the preprocessor on the DT was to allow symbolic names for device/soc-specific values like addresses, rather than what amounts to ABI values for the binding.
I don't see the point in building a binding that depends on future functionality to be legible, especially as we can make it more readable, robust, and just as extensible today, with a simple change to the proposed binding.
Even ignoring the above, the driver isn't doing appropriate sanity checking. If you use a string property, this sanity check is implicit in the parsing -- you've either matched a value you can handle or you haven't.
Thanks,
Mark.
Re: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
Hi,
Quoted 32 lines · Mark Rutland
Quoted 18 lines · Felipe Balbi
Hi,
Quoted 15 lines · Mark Rutland
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Documentation/devicetree/bindings/usb/omap-usb.txt +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.Quoted 3 lines
Quoted 1 line
Why not make this a string property, perhaps values "mailbox" or "register"?
NAK.
Can I ask what your objection to using a string property is?
Quoted 8 lines
Quoted 4 lines
As far as I can see, "ti,type" is only used by this driver, so there's no common convention to stick to. Using a string makes the binding easier for humans to read, and thus harder to mess up in a dts, and it decouples the binding from kernel-side constants.
IIRC there is some work going on to add #define-like support for DT, which would allow us to match against integers while still having meaningful symbolic representations.
I was under the impression that the motivation for using the preprocessor on the DT was to allow symbolic names for device/soc-specific values like addresses, rather than what amounts to ABI values for the binding.
Quoted 8 lines
I don't see the point in building a binding that depends on future functionality to be legible, especially as we can make it more readable, robust, and just as extensible today, with a simple change to the proposed binding.
Even ignoring the above, the driver isn't doing appropriate sanity checking. If you use a string property, this sanity check is implicit in the parsing -- you've either matched a value you can handle or you haven't.
Even IRQs use numbers (not talking about the IRQ number, but the IRQ flags), why would we depend on string comparisson ? It doesn't make sense.
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130125/1d9f17bb/attachment-0001.sig>
Re: [PATCH v4 1/4] drivers: usb: phy: add a new driver for usb part of control module
Quoted 40 lines · Felipe Balbi
Hi,
Quoted 37 lines · Mark Rutland
Quoted 18 lines · Felipe Balbi
Hi,
Quoted 15 lines · Mark Rutland
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
(quoted diff) +8
-0+ depending upon omap4 or omap5. + - reg-names: The names of the register addresses corresponding to the registers + filled in "reg". + - ti,type: This is used to differentiate whether the control module has + usb mailbox or usb3 phy power. omap4 has usb mailbox in control module to + notify events to the musb core and omap5 has usb3 phy power register to + power on usb3 phy. Should be "1" if it has mailbox and "2" if it has usb3 + phy power.Quoted 3 lines
Quoted 1 line
Why not make this a string property, perhaps values "mailbox" or "register"?
NAK.
Can I ask what your objection to using a string property is?
Quoted 8 lines
Quoted 4 lines
As far as I can see, "ti,type" is only used by this driver, so there's no common convention to stick to. Using a string makes the binding easier for humans to read, and thus harder to mess up in a dts, and it decouples the binding from kernel-side constants.
IIRC there is some work going on to add #define-like support for DT, which would allow us to match against integers while still having meaningful symbolic representations.
I was under the impression that the motivation for using the preprocessor on the DT was to allow symbolic names for device/soc-specific values like addresses, rather than what amounts to ABI values for the binding.
I don't see the point in building a binding that depends on future functionality to be legible, especially as we can make it more readable, robust, and just as extensible today, with a simple change to the proposed binding.
Quoted 7 lines
Quoted 3 lines
Even ignoring the above, the driver isn't doing appropriate sanity checking. If you use a string property, this sanity check is implicit in the parsing -- you've either matched a value you can handle or you haven't.
Even IRQs use numbers (not talking about the IRQ number, but the IRQ flags), why would we depend on string comparisson ? It doesn't make sense.
When describing interrupts, the flags are associated with the interrupt number, and don't really make sense on their own. devicetree does not allow you to mix strings and integers in a value, so you'd never be able to encode irq flags with strings without completely breaking away from the way ePAPR describes how to encode interrupts.
By using a string property, the binding is self-describing and easy for humans to read and verify. It doesn't add a large overhead to either the driver or the dts, and is no worse (possibly better) for future extension of bindings to support new device variants while retaining backwards compatibility.
See the standard "status" property, which is string encoded. This would still work were it an integer-encoded enumeration. Having it as a string makes the meaning clear to a reader of the dts, and it's trivial for code to deal with.
I don't understand why you think encoding a more legible value in the dt does not make sense.
Thanks,
Mark.
PATCH v4 2/4 ARM: OMAP: devices: create device for usb part of control module
In reply to Kishon Vijay Abraham IA seperate driver has been added to handle the usb part of control module. A device for the above driver is created here, using the register address information to be used by the driver for powering on the PHY and for writing to the mailbox.
--- arch/arm/mach-omap2/devices.c | 45 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+)
arch/arm/mach-omap2/devices.c +45 -0
@@ -20,6 +20,7 @@#include <linux/pinctrl/machine.h> #include <linux/platform_data/omap4-keypad.h> #include <linux/platform_data/omap_ocp2scp.h> +#include <linux/usb/omap_control_usb.h> #include <asm/mach-types.h> #include <asm/mach/map.h>
@@ -254,6 +255,49 @@ static inline void omap_init_camera(void)#endif } +#if IS_ENABLED (CONFIG_OMAP_CONTROL_USB ) +static struct omap_control_usb_platform_data omap4_control_usb_pdata = { + .type =1 , +}; + +struct resource omap4_control_usb_res[] = { + { + .name ="control_dev_conf" , + .start =0x4a002300 , + .end =0x4a002303 , + .flags =IORESOURCE_MEM , + }, + { + .name ="otghs_control" , + .start =0x4a00233c , + .end =0x4a00233f , + .flags =IORESOURCE_MEM , + }, +}; + +static struct platform_device omap4_control_usb = { + .name ="omap-control-usb" , + .id =-1 , + .dev = { + .platform_data = &omap4_control_usb_pdata, + }, + .num_resources =2 , + .resource = omap4_control_usb_res, +}; + +static inline void __init omap_init_control_usb (void ) +{ +if (!cpu_is_omap44xx ()) +return ; + +if (platform_device_register (&omap4_control_usb)) +pr_err ("Error registering omap_control_usb device\n" ); +} + +#else +static inline void omap_init_control_usb (void ) { } +#endif /* CONFIG_OMAP_CONTROL_USB */ +int __init omap4_keyboard_init (struct omap4_keypad_platform_data *sdp4430_keypad_data,struct omap_board_data *bdata) {
@@ -721,6 +765,7 @@ static int __init omap2_init_devices(void)omap_init_mbox ();/* If dtb is there, the devices will be created dynamically */ if (!of_have_populated_dt ()) { +omap_init_control_usb ();omap_init_dmic ();omap_init_mcpdm ();omap_init_mcspi ();
Signature · 1 line
1.7.9.5
PATCH v4 3/4 ARM: OMAP2: MUSB: Specify omap4 has mailbox
In reply to Kishon Vijay Abraham IAdded has_mailbox to the musb platform data to specify that omap uses an external mailbox (in control module) to communicate with the musb core during device connect and disconnect.
--- arch/arm/mach-omap2/usb-musb.c | 3 +++ include/linux/usb/musb.h | 2 ++ 2 files changed, 5 insertions(+)
arch/arm/mach-omap2/usb-musb.c +3 -0
@@ -85,6 +85,9 @@ void __init usb_musb_init(struct omap_musb_board_data *musb_board_data) musb_plat.mode = board_data->mode; musb_plat.extvbus = board_data->extvbus; +if (cpu_is_omap44xx ()) + musb_plat.has_mailbox = true; +if (soc_is_am35xx ()) { oh_name ="am35x_otg_hs" ; name ="musb-am35x" ;
include/linux/usb/musb.h +2 -0
@@ -99,6 +99,8 @@ struct musb_hdrc_platform_data {/* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */ u8 mode; + u8 has_mailbox:1; +/* for clk_get() */ const char *clock;
Signature · 1 line
1.7.9.5
PATCH v4 4/4 drivers: usb: start using the control module driver
In reply to Kishon Vijay Abraham IStart using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own.
--- Documentation/devicetree/bindings/usb/omap-usb.txt | 4 ++ Documentation/devicetree/bindings/usb/usb-phy.txt | 7 +- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 ---- drivers/usb/musb/Kconfig | 1 + drivers/usb/musb/omap2430.c | 68 +++++++------------- drivers/usb/musb/omap2430.h | 9 --- drivers/usb/phy/Kconfig | 1 + drivers/usb/phy/omap-usb2.c | 41 +++--------- include/linux/usb/omap_usb.h | 4 +- 9 files changed, 40 insertions(+), 108 deletions(-)
Documentation/devicetree/bindings/usb/omap-usb.txt +4 -0
@@ -3,6 +3,9 @@ OMAP GLUE AND OTHER OMAP SPECIFIC COMPONENTS OMAP MUSB GLUE - compatible : Should be "ti,omap4-musb" or "ti,omap3-musb" - ti,hwmods : must be "usb_otg_hs" + - ti,has-mailbox : to specify that omap uses an external mailbox + (in control module) to communicate with the musb core during device connect + and disconnect. - multipoint : Should be "1" indicating the musb controller supports multipoint. This is a MUSB configuration-specific setting. - num_eps : Specifies the number of endpoints. This is also a
@@ -24,6 +27,7 @@ SOC specific device node entry usb_otg_hs: usb_otg_hs at 4a0ab000 { compatible = "ti,omap4-musb"; ti,hwmods = "usb_otg_hs"; + ti,has-mailbox; multipoint = <1>; num_eps = <16>; ram_bits = <12>;
Documentation/devicetree/bindings/usb/usb-phy.txt +2 -5
@@ -4,9 +4,7 @@ OMAP USB2 PHY Required properties: - compatible: Should be "ti,omap-usb2" - - reg : Address and length of the register set for the device. Also -add the address of control module dev conf register until a driver for -control module is added + - reg : Address and length of the register set for the device. Optional properties: - ctrl-module : phandle of the control module used by PHY driver to power on
@@ -16,7 +14,6 @@ This is usually a subnode of ocp2scp to which it is connected. usb2phy at 4a0ad080 { compatible = "ti,omap-usb2"; - reg = <0x4a0ad080 0x58>, - <0x4a002300 0x4>; + reg = <0x4a0ad080 0x58>; ctrl-module = <&omap_control_usb>; };
arch/arm/mach-omap2/omap_hwmod_44xx_data.c +0 -13
@@ -2698,13 +2698,6 @@ static struct resource omap44xx_usb_phy_and_pll_addrs[] = { .end = 0x4a0ae000, .flags = IORESOURCE_MEM, }, - { -/* XXX: Remove this once control module driver is in place */ - .name = "ctrl_dev", - .start = 0x4a002300, - .end = 0x4a002303, - .flags = IORESOURCE_MEM, - }, { } };
@@ -6152,12 +6145,6 @@ static struct omap_hwmod_addr_space omap44xx_usb_otg_hs_addrs[] = { .pa_end = 0x4a0ab7ff, .flags = ADDR_TYPE_RT }, - { -/* XXX: Remove this once control module driver is in place */ - .pa_start = 0x4a00233c, - .pa_end = 0x4a00233f, - .flags = ADDR_TYPE_RT - }, { } };
drivers/usb/musb/Kconfig +1 -0
@@ -11,6 +11,7 @@ config USB_MUSB_HDRC select NOP_USB_XCEIV if (SOC_TI81XX || SOC_AM33XX) select TWL4030_USB if MACH_OMAP_3430SDP select TWL6030_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA + select OMAP_CONTROL_USB if MACH_OMAP_4430SDP || MACH_OMAP4_PANDA select USB_OTG_UTILS help Say Y here if your system has a dual role high speed USB
drivers/usb/musb/omap2430.c +23 -45
160 lines not on this page · raw message
drivers/usb/musb/omap2430.h +0 -9
@@ -49,13 +49,4 @@#define OTG_FORCESTDBY 0x414# define ENABLEFORCE (1 << 0) -/* -* Control Module bit definitions -* XXX: Will be removed once we have a driver for control module. -*/ -#define AVALID BIT(0) -#define BVALID BIT(1) -#define VBUSVALID BIT(2) -#define SESSEND BIT(3) -#define IDDIG BIT(4)#endif /* __MUSB_OMAP243X_H__ */
drivers/usb/phy/Kconfig +1 -0
@@ -8,6 +8,7 @@ config OMAP_USB2 tristate "OMAP USB2 PHY Driver" depends on ARCH_OMAP2PLUS select USB_OTG_UTILS + select OMAP_CONTROL_USB help Enable this to support the transceiver that is part of SOC. This driver takes care of all the PHY functionality apart from comparator.
drivers/usb/phy/omap-usb2.c +8 -33
80 lines not on this page · raw message
include/linux/usb/omap_usb.h +1 -3
@@ -25,13 +25,11 @@ struct omap_usb {struct usb_phy phy;struct phy_companion *comparator;struct device *dev; -u32 __iomem *control_dev; +struct device *control_dev;struct clk *wkupclk; u8 is_suspended:1; }; -#define PHY_PD 0x1 -#define phy_to_omapusb (x) container_of((x), struct omap_usb, phy)#if defined(CONFIG_OMAP_USB2 ) || defined(CONFIG_OMAP_USB2_MODULE )
Signature · 1 line
1.7.9.5
Re: [PATCH v4 4/4] drivers: usb: start using the control module driver
Hi,
Quoted 9 lines · Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 4 ++ Documentation/devicetree/bindings/usb/usb-phy.txt | 7 +- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 ----
I'm taking this patch but I'm leaving out the omap_hwmod_44xx_data.c change just to kill dependency. Can you send that single change as a separate patch which Tony can queue ?
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130125/f9714c65/attachment.sig>
Re: [PATCH v4 4/4] drivers: usb: start using the control module driver
Quoted 13 lines · Felipe Balbi
Hi,
Quoted 9 lines · Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 4 ++ Documentation/devicetree/bindings/usb/usb-phy.txt | 7 +- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 ----
Quoted 4 lines
I'm taking this patch but I'm leaving out the
omap_hwmod_44xx_data.cchange just to kill dependency. Can you send that single change as a separate patch which Tony can queue ?
Sure.
Thanks
Kishon
Tony Lindgren
maintainerRe: [PATCH v4 4/4] drivers: usb: start using the control module driver
In reply to Felipe BalbiQuoted 13 lines · Felipe Balbi
Hi,
Quoted 9 lines · Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 4 ++ Documentation/devicetree/bindings/usb/usb-phy.txt | 7 +- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 ----
Quoted 3 lines
I'm taking this patch but I'm leaving out the
omap_hwmod_44xx_data.cchange just to kill dependency. Can you send that single change as a separate patch which Tony can queue ?
For the USB patches, please also leave out patches touching arch/arm/mach-omap2/devices.c. Those are almost guaranteed to cause pointless merge conflicts with other branches.
I suggest you set up few immutable branches:
1. Minimal platform_data changes for all your USB changes
This should contain include/linux/platform_data changes and changes to arch/arm/*omap* so me and Paul can merge it in too to avoid merge conflicts.
2. The rest of the driver/usb changes
This can then be based on #1 branch above.
3. Changes for the .dts files for Benoit
These can be queued separately from #1 and #2 above.
Regards,
Tony
Re: [PATCH v4 4/4] drivers: usb: start using the control module driver
Hi,
Quoted 30 lines · Tony Lindgren
Quoted 13 lines · Felipe Balbi
Hi,
Quoted 9 lines · Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 4 ++ Documentation/devicetree/bindings/usb/usb-phy.txt | 7 +- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 ----Quoted 3 lines
I'm taking this patch but I'm leaving out the
omap_hwmod_44xx_data.cchange just to kill dependency. Can you send that single change as a separate patch which Tony can queue ?For the USB patches, please also leave out patches touching
arch/arm/mach-omap2/devices.c. Those are almost guaranteed to cause pointless merge conflicts with other branches.I suggest you set up few immutable branches:
1. Minimal
platform_datachanges for all your USB changesThis should contain
include/linux/platform_datachanges and changes toarch/arm/*omap*so me and Paul can merge it in too to avoid merge conflicts.
Quoted 7 lines
2. The rest of the driver/usb changes
This can then be based on #1 branch above.
3. Changes for the .dts files for Benoit
These can be queued separately from #1 and #2 above.
I'm done with all USB stuff for this merge window. The patches which I didn't take have no dependencies on any drivers/ part. You can easily queue this through your tree.
cheers
Signature · 8 lines
balbi -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130204/db23f9de/attachment.sig>
Tony Lindgren
maintainerRe: [PATCH v4 4/4] drivers: usb: start using the control module driver
Quoted 37 lines · Felipe Balbi
Hi,
Quoted 34 lines · Tony Lindgren
Quoted 13 lines · Felipe Balbi
Hi,
Quoted 9 lines · Kishon Vijay Abraham I
Start using the control module driver for powering on the PHY and for writing to the mailbox instead of writing to the control module registers on their own.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/usb/omap-usb.txt | 4 ++ Documentation/devicetree/bindings/usb/usb-phy.txt | 7 +- arch/arm/mach-omap2/omap_hwmod_44xx_data.c | 13 ----Quoted 3 lines
I'm taking this patch but I'm leaving out the
omap_hwmod_44xx_data.cchange just to kill dependency. Can you send that single change as a separate patch which Tony can queue ?For the USB patches, please also leave out patches touching
arch/arm/mach-omap2/devices.c. Those are almost guaranteed to cause pointless merge conflicts with other branches.I suggest you set up few immutable branches:
1. Minimal
platform_datachanges for all your USB changesThis should contain
include/linux/platform_datachanges and changes toarch/arm/*omap*so me and Paul can merge it in too to avoid merge conflicts.2. The rest of the driver/usb changes
This can then be based on #1 branch above.
Quoted 7 lines
Quoted 3 lines
3. Changes for the .dts files for Benoit
These can be queued separately from #1 and #2 above.
I'm done with all USB stuff for this merge window. The patches which I didn't take have no dependencies on any
drivers/part. You can easily queue this through your tree.
Sorry with a huge pile of USB patches being posted I have no idea at this point which USB related patches for arch/arm/*omap* have no dependencies to the USB driver changes.
So I suggest that you, Kishon and Roger figure it out and put together a pull request for me against v3.8-rc6 for the patches I should merge.
Regards,
Tony