Drivers: USB: DA8xx MUSB: added DT support
PATCH 1/1 Drivers: USB: DA8xx MUSB: added DT support
TI DA8xx MUSB driver equipped with DeviceTree support. Tested with AM1808 board and USB2.0 (OTG) in host mode.
--- .../devicetree/bindings/usb/da8xx-usb.txt | 52 +++++++ drivers/usb/musb/da8xx.c | 166 +++++++++++++++++++++ include/linux/platform_data/usb-davinci.h | 3 +- 3 files changed, 220 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/usb/da8xx-usb.txt
Documentation/devicetree/bindings/usb/da8xx-usb.txt new file +57 -0
@@ -0,0 +1,57 @@ +TI DA8xx MUSB +~~~~~~~~~~~~~ + +Required properties: +~~~~~~~~~~~~~~~~~~~~ + - compatible : Should be "ti,da8xx-musb" + + - dr_mode: The USB operation mode. Should be one of "host", "peripheral" or "otg". + + - mentor,power : Specifies the maximum current in milli-ampers the controller can + supply in host mode. The maximum configurable value is 510mA. + + - mentor,num-eps : Valid only in host mode. Specifies the number of target endpoints + supported by the controller. For DA8xx it is "5". + + - mentor,multipoint : Valid only in host mode. Enables addressing of USB hubs, + which is normally something you want and therefore should be set to "1". + If set to "0" only point-to-point communication is enabled, i.e. only a single + device can be attached. + + - mentor,ram-bits : This 2-base logarithm value defines the RAM FIFO size of the controller. + The FIFO size is calculated in 32-bit words. E.g. if your controller has 4kiB of RAM FIFO + this value should be set to "10": 2^10 = 1024 words of 32-bits, i.e. 4096 bytes. + For the DA8xx controller this value should be set to 10. + + +Optional properties: + + - ti,phy20-clkmux-cfg: Integer. Defines the USB 2.0 PHY reference clock source. + Supported values: "0" for external pin, "1" for internal PLL. + + - ti,phy20-refclock-frequency : Integer. Defines the USB 2.0 PHY reference clock input + frequency in Hz in case the clock is generated by the internal PLL. + Supported values are 12MHz, 13MHz, 19.2MHz, 20MHz, 24MHz, 26MHz, 38.4MHz, 40MHz, 48MHz + + +Example: + + usb20: usb@1e00000 { + compatible = "ti,da8xx-musb"; + ti,hwmods = "usb_otg_hs"; + reg = <0x00200000 0x10000>; + interrupt-parent = <&intc>; + interrupts = <58>; + interrupt-names = "mc"; + + dr_mode = "host"; + mentor,power = <500>; + mentor,multipoint = <1>; + mentor,num-eps = <5>; + mentor,ram-bits = <10>; + + ti,phy20-clkmux-cfg = <1>; /* PHY clock internally generated from the PLL */ + ti,phy20-refclock-frequency = <24000000>; + + status = "okay"; + };
drivers/usb/musb/da8xx.c +158 -0
193 lines not on this page · raw message
glue->phy = usb_phy_generic_register();
@@ -627,11 +784,22 @@ static int da8xx_remove(struct platform_device *pdev)
return 0;
}
+#ifdef CONFIG_OF
+static const struct of_device_id da8xx_id_table[] = {
+ {
+ .compatible = "ti,da8xx-musb"
+ },
+ {},
+};
+MODULE_DEVICE_TABLE(of, da8xx_id_table); +#endif
+
static struct platform_driver da8xx_driver = {
.probe = da8xx_probe,
.remove = da8xx_remove,
.driver = {
.name = "musb-da8xx",
+ .of_match_table = of_match_ptr(da8xx_id_table),
},
};
include/linux/platform_data/usb-davinci.h +2 -1
@@ -21,7 +21,8 @@#define CFGCHIP2_FORCE_DEVICE (2 << 13)#define CFGCHIP2_FORCE_HOST_VBUS_LOW (3 << 13)#define CFGCHIP2_USB1PHYCLKMUX (1 << 12) -#define CFGCHIP2_USB2PHYCLKMUX (1 << 11) +#define CFGCHIP2_USB2PHYCLKMUX_SHIFT (11) +#define CFGCHIP2_USB2PHYCLKMUX (1 << CFGCHIP2_USB2PHYCLKMUX_SHIFT)#define CFGCHIP2_PHYPWRDN (1 << 10)#define CFGCHIP2_OTGPWRDN (1 << 9)#define CFGCHIP2_DATPOL (1 << 8)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 4 lines · On Thursday 04 February 2016 14:00:07 Petr Kulhavy wrote:
drivers/usb/musb/da8xx.c +0
-0@@ -560,6 +626,97 @@ static int da8xx_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->clk = clk;
drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 638
Quoted 10 lines
drivers/usb/musb/da8xx.c +10
-0+if (np) { +struct musb_hdrc_config *config; +struct musb_hdrc_platform_data *data; +u32 phy20_refclock_freq, phy20_clkmux_cfg; + + pdata =devm_kzalloc (&pdev->dev,sizeof (*pdata),GFP_KERNEL ); +if (!pdata) { + ret = -ENOMEM ; + goto err5; + }
So all the code here is built unconditionally...
Quoted 4 lines
(quoted diff) +0
-0@@ -627,11 +784,22 @@ static int da8xx_remove(struct platform_device *pdev) return 0; }
Review static int da8xx_remove(struct platform_device *pdev) · line 796
Quoted 10 lines
(quoted diff) +10
-0+#ifdef CONFIG_OF +static const struct of_device_id da8xx_id_table[] = { + { + .compatible = "ti,da8xx-musb" + }, + {}, +}; +MODULE_DEVICE_TABLE(of, da8xx_id_table); +#endif +
but this is in an #ifdef?
I would suggest you do the opposite and leave the id table in there but change the first check to
if (IS_ENABLED(CONFIG_OF) && np)
So the compiler can discard that code when CONFIG_OF is disabled.
drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 718
Quoted 2 lines
drivers/usb/musb/da8xx.c +2
-0+ pdev->dev.dma_mask = &da8xx_dmamask; + pdev->dev.coherent_dma_mask = da8xx_dmamask;
Don't hardcode DMA masks like this, the mask should be set to a 32-bit mask whenever the device is created, and the driver can override it by calling dma_set_mask().
Arnd
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Arnd,
thanks for your feedback, please see my comments below.
Quoted 6 lines · Arnd Bergmann
I would suggest you do the opposite and leave the id table in there but change the first check to
if (IS_ENABLED(CONFIG_OF) && np)So the compiler can discard that code when
CONFIG_OFis disabled.
That's a good point!
Quoted 7 lines
drivers/usb/musb/da8xx.c static int da8xx_probe(struct platform_device *pdev) · line 718
Quoted 3 lines
drivers/usb/musb/da8xx.c +2
-0+ pdev->dev.dma_mask = &da8xx_dmamask; + pdev->dev.coherent_dma_mask = da8xx_dmamask;Don't hardcode DMA masks like this, the mask should be set to a 32-bit mask whenever the device is created, and the driver can override it by calling
dma_set_mask().
You're right these two lines can be completely removed as a) they are setting the wrong thing and b) platform_device_register_full() already sets the correct dma mask from the pinfo (in the original source file).
I will prepare a new patch.
Cheers
Petr
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html