diff options
Diffstat (limited to 'drivers/usb/chipidea')
-rw-r--r-- | drivers/usb/chipidea/Makefile | 1 | ||||
-rw-r--r-- | drivers/usb/chipidea/ci_hdrc_msm.c | 2 | ||||
-rw-r--r-- | drivers/usb/chipidea/ci_hdrc_pci.c | 1 | ||||
-rw-r--r-- | drivers/usb/chipidea/ci_hdrc_tegra.c | 155 | ||||
-rw-r--r-- | drivers/usb/chipidea/ci_hdrc_usb2.c | 2 | ||||
-rw-r--r-- | drivers/usb/chipidea/core.c | 6 | ||||
-rw-r--r-- | drivers/usb/chipidea/otg_fsm.c | 2 | ||||
-rw-r--r-- | drivers/usb/chipidea/udc.c | 8 |
8 files changed, 167 insertions, 10 deletions
diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile index 39fca5715ed3..ddcbddf8361a 100644 --- a/drivers/usb/chipidea/Makefile +++ b/drivers/usb/chipidea/Makefile | |||
@@ -15,3 +15,4 @@ obj-$(CONFIG_USB_CHIPIDEA) += ci_hdrc_zevio.o | |||
15 | obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o | 15 | obj-$(CONFIG_USB_CHIPIDEA_PCI) += ci_hdrc_pci.o |
16 | 16 | ||
17 | obj-$(CONFIG_USB_CHIPIDEA_OF) += usbmisc_imx.o ci_hdrc_imx.o | 17 | obj-$(CONFIG_USB_CHIPIDEA_OF) += usbmisc_imx.o ci_hdrc_imx.o |
18 | obj-$(CONFIG_USB_CHIPIDEA_OF) += ci_hdrc_tegra.o | ||
diff --git a/drivers/usb/chipidea/ci_hdrc_msm.c b/drivers/usb/chipidea/ci_hdrc_msm.c index 0bdfcdcbf7a5..bb626120296f 100644 --- a/drivers/usb/chipidea/ci_hdrc_msm.c +++ b/drivers/usb/chipidea/ci_hdrc_msm.c | |||
@@ -251,7 +251,7 @@ static int ci_hdrc_msm_probe(struct platform_device *pdev) | |||
251 | if (ret) | 251 | if (ret) |
252 | goto err_mux; | 252 | goto err_mux; |
253 | 253 | ||
254 | ulpi_node = of_find_node_by_name(pdev->dev.of_node, "ulpi"); | 254 | ulpi_node = of_find_node_by_name(of_node_get(pdev->dev.of_node), "ulpi"); |
255 | if (ulpi_node) { | 255 | if (ulpi_node) { |
256 | phy_node = of_get_next_available_child(ulpi_node, NULL); | 256 | phy_node = of_get_next_available_child(ulpi_node, NULL); |
257 | ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy"); | 257 | ci->hsic = of_device_is_compatible(phy_node, "qcom,usb-hsic-phy"); |
diff --git a/drivers/usb/chipidea/ci_hdrc_pci.c b/drivers/usb/chipidea/ci_hdrc_pci.c index b635ab67490d..39414e4b2d81 100644 --- a/drivers/usb/chipidea/ci_hdrc_pci.c +++ b/drivers/usb/chipidea/ci_hdrc_pci.c | |||
@@ -170,5 +170,4 @@ module_pci_driver(ci_hdrc_pci_driver); | |||
170 | MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>"); | 170 | MODULE_AUTHOR("MIPS - David Lopo <dlopo@chipidea.mips.com>"); |
171 | MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller"); | 171 | MODULE_DESCRIPTION("MIPS CI13XXX USB Peripheral Controller"); |
172 | MODULE_LICENSE("GPL"); | 172 | MODULE_LICENSE("GPL"); |
173 | MODULE_VERSION("June 2008"); | ||
174 | MODULE_ALIAS("platform:ci13xxx_pci"); | 173 | MODULE_ALIAS("platform:ci13xxx_pci"); |
diff --git a/drivers/usb/chipidea/ci_hdrc_tegra.c b/drivers/usb/chipidea/ci_hdrc_tegra.c new file mode 100644 index 000000000000..bfcee2702d50 --- /dev/null +++ b/drivers/usb/chipidea/ci_hdrc_tegra.c | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | * Copyright (c) 2016, NVIDIA Corporation | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify it | ||
5 | * under the terms and conditions of the GNU General Public License, | ||
6 | * version 2, as published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/clk.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/of_device.h> | ||
12 | #include <linux/reset.h> | ||
13 | |||
14 | #include <linux/usb/chipidea.h> | ||
15 | |||
16 | #include "ci.h" | ||
17 | |||
18 | struct tegra_udc { | ||
19 | struct ci_hdrc_platform_data data; | ||
20 | struct platform_device *dev; | ||
21 | |||
22 | struct usb_phy *phy; | ||
23 | struct clk *clk; | ||
24 | }; | ||
25 | |||
26 | struct tegra_udc_soc_info { | ||
27 | unsigned long flags; | ||
28 | }; | ||
29 | |||
30 | static const struct tegra_udc_soc_info tegra20_udc_soc_info = { | ||
31 | .flags = CI_HDRC_REQUIRES_ALIGNED_DMA, | ||
32 | }; | ||
33 | |||
34 | static const struct tegra_udc_soc_info tegra30_udc_soc_info = { | ||
35 | .flags = 0, | ||
36 | }; | ||
37 | |||
38 | static const struct tegra_udc_soc_info tegra114_udc_soc_info = { | ||
39 | .flags = 0, | ||
40 | }; | ||
41 | |||
42 | static const struct tegra_udc_soc_info tegra124_udc_soc_info = { | ||
43 | .flags = 0, | ||
44 | }; | ||
45 | |||
46 | static const struct of_device_id tegra_udc_of_match[] = { | ||
47 | { | ||
48 | .compatible = "nvidia,tegra20-udc", | ||
49 | .data = &tegra20_udc_soc_info, | ||
50 | }, { | ||
51 | .compatible = "nvidia,tegra30-udc", | ||
52 | .data = &tegra30_udc_soc_info, | ||
53 | }, { | ||
54 | .compatible = "nvidia,tegra114-udc", | ||
55 | .data = &tegra114_udc_soc_info, | ||
56 | }, { | ||
57 | .compatible = "nvidia,tegra124-udc", | ||
58 | .data = &tegra124_udc_soc_info, | ||
59 | }, { | ||
60 | /* sentinel */ | ||
61 | } | ||
62 | }; | ||
63 | MODULE_DEVICE_TABLE(of, tegra_udc_of_match); | ||
64 | |||
65 | static int tegra_udc_probe(struct platform_device *pdev) | ||
66 | { | ||
67 | const struct tegra_udc_soc_info *soc; | ||
68 | struct tegra_udc *udc; | ||
69 | int err; | ||
70 | |||
71 | udc = devm_kzalloc(&pdev->dev, sizeof(*udc), GFP_KERNEL); | ||
72 | if (!udc) | ||
73 | return -ENOMEM; | ||
74 | |||
75 | soc = of_device_get_match_data(&pdev->dev); | ||
76 | if (!soc) { | ||
77 | dev_err(&pdev->dev, "failed to match OF data\n"); | ||
78 | return -EINVAL; | ||
79 | } | ||
80 | |||
81 | udc->phy = devm_usb_get_phy_by_phandle(&pdev->dev, "nvidia,phy", 0); | ||
82 | if (IS_ERR(udc->phy)) { | ||
83 | err = PTR_ERR(udc->phy); | ||
84 | dev_err(&pdev->dev, "failed to get PHY: %d\n", err); | ||
85 | return err; | ||
86 | } | ||
87 | |||
88 | udc->clk = devm_clk_get(&pdev->dev, NULL); | ||
89 | if (IS_ERR(udc->clk)) { | ||
90 | err = PTR_ERR(udc->clk); | ||
91 | dev_err(&pdev->dev, "failed to get clock: %d\n", err); | ||
92 | return err; | ||
93 | } | ||
94 | |||
95 | err = clk_prepare_enable(udc->clk); | ||
96 | if (err < 0) { | ||
97 | dev_err(&pdev->dev, "failed to enable clock: %d\n", err); | ||
98 | return err; | ||
99 | } | ||
100 | |||
101 | /* | ||
102 | * Tegra's USB PHY driver doesn't implement optional phy_init() | ||
103 | * hook, so we have to power on UDC controller before ChipIdea | ||
104 | * driver initialization kicks in. | ||
105 | */ | ||
106 | usb_phy_set_suspend(udc->phy, 0); | ||
107 | |||
108 | /* setup and register ChipIdea HDRC device */ | ||
109 | udc->data.name = "tegra-udc"; | ||
110 | udc->data.flags = soc->flags; | ||
111 | udc->data.usb_phy = udc->phy; | ||
112 | udc->data.capoffset = DEF_CAPOFFSET; | ||
113 | |||
114 | udc->dev = ci_hdrc_add_device(&pdev->dev, pdev->resource, | ||
115 | pdev->num_resources, &udc->data); | ||
116 | if (IS_ERR(udc->dev)) { | ||
117 | err = PTR_ERR(udc->dev); | ||
118 | dev_err(&pdev->dev, "failed to add HDRC device: %d\n", err); | ||
119 | goto fail_power_off; | ||
120 | } | ||
121 | |||
122 | platform_set_drvdata(pdev, udc); | ||
123 | |||
124 | return 0; | ||
125 | |||
126 | fail_power_off: | ||
127 | usb_phy_set_suspend(udc->phy, 1); | ||
128 | clk_disable_unprepare(udc->clk); | ||
129 | return err; | ||
130 | } | ||
131 | |||
132 | static int tegra_udc_remove(struct platform_device *pdev) | ||
133 | { | ||
134 | struct tegra_udc *udc = platform_get_drvdata(pdev); | ||
135 | |||
136 | usb_phy_set_suspend(udc->phy, 1); | ||
137 | clk_disable_unprepare(udc->clk); | ||
138 | |||
139 | return 0; | ||
140 | } | ||
141 | |||
142 | static struct platform_driver tegra_udc_driver = { | ||
143 | .driver = { | ||
144 | .name = "tegra-udc", | ||
145 | .of_match_table = tegra_udc_of_match, | ||
146 | }, | ||
147 | .probe = tegra_udc_probe, | ||
148 | .remove = tegra_udc_remove, | ||
149 | }; | ||
150 | module_platform_driver(tegra_udc_driver); | ||
151 | |||
152 | MODULE_DESCRIPTION("NVIDIA Tegra USB device mode driver"); | ||
153 | MODULE_AUTHOR("Thierry Reding <treding@nvidia.com>"); | ||
154 | MODULE_ALIAS("platform:tegra-udc"); | ||
155 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/usb/chipidea/ci_hdrc_usb2.c b/drivers/usb/chipidea/ci_hdrc_usb2.c index d162cc0bb8ce..99425db9ba62 100644 --- a/drivers/usb/chipidea/ci_hdrc_usb2.c +++ b/drivers/usb/chipidea/ci_hdrc_usb2.c | |||
@@ -52,6 +52,8 @@ static int ci_hdrc_usb2_probe(struct platform_device *pdev) | |||
52 | 52 | ||
53 | if (!ci_pdata) { | 53 | if (!ci_pdata) { |
54 | ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL); | 54 | ci_pdata = devm_kmalloc(dev, sizeof(*ci_pdata), GFP_KERNEL); |
55 | if (!ci_pdata) | ||
56 | return -ENOMEM; | ||
55 | *ci_pdata = ci_default_pdata; /* struct copy */ | 57 | *ci_pdata = ci_default_pdata; /* struct copy */ |
56 | } | 58 | } |
57 | 59 | ||
diff --git a/drivers/usb/chipidea/core.c b/drivers/usb/chipidea/core.c index b17ed3a9a304..43ea5fb87b9a 100644 --- a/drivers/usb/chipidea/core.c +++ b/drivers/usb/chipidea/core.c | |||
@@ -736,7 +736,7 @@ static int ci_extcon_register(struct ci_hdrc *ci) | |||
736 | 736 | ||
737 | id = &ci->platdata->id_extcon; | 737 | id = &ci->platdata->id_extcon; |
738 | id->ci = ci; | 738 | id->ci = ci; |
739 | if (!IS_ERR(id->edev)) { | 739 | if (!IS_ERR_OR_NULL(id->edev)) { |
740 | ret = devm_extcon_register_notifier(ci->dev, id->edev, | 740 | ret = devm_extcon_register_notifier(ci->dev, id->edev, |
741 | EXTCON_USB_HOST, &id->nb); | 741 | EXTCON_USB_HOST, &id->nb); |
742 | if (ret < 0) { | 742 | if (ret < 0) { |
@@ -747,7 +747,7 @@ static int ci_extcon_register(struct ci_hdrc *ci) | |||
747 | 747 | ||
748 | vbus = &ci->platdata->vbus_extcon; | 748 | vbus = &ci->platdata->vbus_extcon; |
749 | vbus->ci = ci; | 749 | vbus->ci = ci; |
750 | if (!IS_ERR(vbus->edev)) { | 750 | if (!IS_ERR_OR_NULL(vbus->edev)) { |
751 | ret = devm_extcon_register_notifier(ci->dev, vbus->edev, | 751 | ret = devm_extcon_register_notifier(ci->dev, vbus->edev, |
752 | EXTCON_USB, &vbus->nb); | 752 | EXTCON_USB, &vbus->nb); |
753 | if (ret < 0) { | 753 | if (ret < 0) { |
@@ -887,7 +887,7 @@ static struct attribute *ci_attrs[] = { | |||
887 | NULL, | 887 | NULL, |
888 | }; | 888 | }; |
889 | 889 | ||
890 | static struct attribute_group ci_attr_group = { | 890 | static const struct attribute_group ci_attr_group = { |
891 | .attrs = ci_attrs, | 891 | .attrs = ci_attrs, |
892 | }; | 892 | }; |
893 | 893 | ||
diff --git a/drivers/usb/chipidea/otg_fsm.c b/drivers/usb/chipidea/otg_fsm.c index 949183ede16f..5ea0246f650d 100644 --- a/drivers/usb/chipidea/otg_fsm.c +++ b/drivers/usb/chipidea/otg_fsm.c | |||
@@ -193,7 +193,7 @@ static struct attribute *inputs_attrs[] = { | |||
193 | NULL, | 193 | NULL, |
194 | }; | 194 | }; |
195 | 195 | ||
196 | static struct attribute_group inputs_attr_group = { | 196 | static const struct attribute_group inputs_attr_group = { |
197 | .name = "inputs", | 197 | .name = "inputs", |
198 | .attrs = inputs_attrs, | 198 | .attrs = inputs_attrs, |
199 | }; | 199 | }; |
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index d68b125796f9..fe8a90543ea3 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
@@ -944,7 +944,6 @@ isr_setup_status_complete(struct usb_ep *ep, struct usb_request *req) | |||
944 | */ | 944 | */ |
945 | static int isr_setup_status_phase(struct ci_hdrc *ci) | 945 | static int isr_setup_status_phase(struct ci_hdrc *ci) |
946 | { | 946 | { |
947 | int retval; | ||
948 | struct ci_hw_ep *hwep; | 947 | struct ci_hw_ep *hwep; |
949 | 948 | ||
950 | /* | 949 | /* |
@@ -960,9 +959,7 @@ static int isr_setup_status_phase(struct ci_hdrc *ci) | |||
960 | ci->status->context = ci; | 959 | ci->status->context = ci; |
961 | ci->status->complete = isr_setup_status_complete; | 960 | ci->status->complete = isr_setup_status_complete; |
962 | 961 | ||
963 | retval = _ep_queue(&hwep->ep, ci->status, GFP_ATOMIC); | 962 | return _ep_queue(&hwep->ep, ci->status, GFP_ATOMIC); |
964 | |||
965 | return retval; | ||
966 | } | 963 | } |
967 | 964 | ||
968 | /** | 965 | /** |
@@ -1899,6 +1896,9 @@ static int udc_start(struct ci_hdrc *ci) | |||
1899 | ci->gadget.name = ci->platdata->name; | 1896 | ci->gadget.name = ci->platdata->name; |
1900 | ci->gadget.otg_caps = otg_caps; | 1897 | ci->gadget.otg_caps = otg_caps; |
1901 | 1898 | ||
1899 | if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA) | ||
1900 | ci->gadget.quirk_avoids_skb_reserve = 1; | ||
1901 | |||
1902 | if (ci->is_otg && (otg_caps->hnp_support || otg_caps->srp_support || | 1902 | if (ci->is_otg && (otg_caps->hnp_support || otg_caps->srp_support || |
1903 | otg_caps->adp_support)) | 1903 | otg_caps->adp_support)) |
1904 | ci->gadget.is_otg = 1; | 1904 | ci->gadget.is_otg = 1; |