Patchwork [v2,6/6] usb: host: tegra: Tegra30 support

login
register
mail settings
Submitter Tuomas Tynkkynen
Date Aug. 6, 2013, 6:08 p.m.
Message ID <1375812518-3847-7-git-send-email-ttynkkynen@nvidia.com>
Download mbox | patch
Permalink /patch/265194/
State Not Applicable, archived
Headers show

Comments

Tuomas Tynkkynen - Aug. 6, 2013, 6:08 p.m.
The Tegra30 EHCI controller is mostly compatible with the Tegra20
controller, except Tegra30 includes the HOSTPC register extension.
The has_hostpc capability bit must be set in the ehci_hcd structure if
the controller has such extensions. The new tegra_ehci_soc_config
structure is added to describe the differences between the SoCs.

Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
---
 drivers/usb/host/ehci-tegra.c | 34 +++++++++++++++++++++++++++++-----
 1 file changed, 29 insertions(+), 5 deletions(-)
Sergei Shtylyov - Aug. 6, 2013, 6:35 p.m.
Hello.

On 08/06/2013 10:08 PM, Tuomas Tynkkynen wrote:

> The Tegra30 EHCI controller is mostly compatible with the Tegra20
> controller, except Tegra30 includes the HOSTPC register extension.
> The has_hostpc capability bit must be set in the ehci_hcd structure if
> the controller has such extensions. The new tegra_ehci_soc_config
> structure is added to describe the differences between the SoCs.

> Signed-off-by: Tuomas Tynkkynen <ttynkkynen@nvidia.com>
> ---
>   drivers/usb/host/ehci-tegra.c | 34 +++++++++++++++++++++++++++++-----
>   1 file changed, 29 insertions(+), 5 deletions(-)

> diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
> index db8031f..c0d1f27 100644
> --- a/drivers/usb/host/ehci-tegra.c
> +++ b/drivers/usb/host/ehci-tegra.c
[...]
>   static int tegra_ehci_probe(struct platform_device *pdev)
>   {
> +	const struct of_device_id *match;
> +	const struct tegra_ehci_soc_config *soc_config;
>   	struct resource *res;
>   	struct usb_hcd *hcd;
>   	struct ehci_hcd *ehci;
> @@ -330,6 +351,13 @@ static int tegra_ehci_probe(struct platform_device *pdev)
>   	int irq;
>   	struct usb_phy *u_phy;
>
> +	match = of_match_device(tegra_ehci_of_match, &pdev->dev);
> +	if (!match) {
> +		dev_err(&pdev->dev, "Error: No device match found\n");
> +		return -ENODEV;
> +	}
> +	soc_config = (struct tegra_ehci_soc_config *)match->data;

    Aren't casts from 'const void *' automatic?

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Tuomas Tynkkynen - Aug. 6, 2013, 7:16 p.m.
On 08/06/2013 09:35 PM, Sergei Shtylyov wrote:
> Hello.
> 
[...]
>>
>> +	match = of_match_device(tegra_ehci_of_match, &pdev->dev);
>> +	if (!match) {
>> +		dev_err(&pdev->dev, "Error: No device match found\n");
>> +		return -ENODEV;
>> +	}
>> +	soc_config = (struct tegra_ehci_soc_config *)match->data;
> 
>     Aren't casts from 'const void *' automatic?
> 
> WBR, Sergei
> 

Indeed they are, but those explicit casts seem to be used in many places in the kernel.
--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sergei Shtylyov - Aug. 6, 2013, 7:27 p.m.
Hello.

On 08/06/2013 11:16 PM, Tuomas Tynkkynen wrote:

> [...]

>>> +	match = of_match_device(tegra_ehci_of_match, &pdev->dev);
>>> +	if (!match) {
>>> +		dev_err(&pdev->dev, "Error: No device match found\n");
>>> +		return -ENODEV;
>>> +	}
>>> +	soc_config = (struct tegra_ehci_soc_config *)match->data;

>>      Aren't casts from 'const void *' automatic?

>> WBR, Sergei

> Indeed they are, but those explicit casts seem to be used in many places in the kernel.

    I suspect people just don't know C well enough. They are also being 
gradually removed.

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe linux-tegra" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Felipe Balbi - Aug. 9, 2013, 1:37 p.m.
On Tue, Aug 06, 2013 at 11:27:11PM +0400, Sergei Shtylyov wrote:
> Hello.
> 
> On 08/06/2013 11:16 PM, Tuomas Tynkkynen wrote:
> 
> >[...]
> 
> >>>+	match = of_match_device(tegra_ehci_of_match, &pdev->dev);
> >>>+	if (!match) {
> >>>+		dev_err(&pdev->dev, "Error: No device match found\n");
> >>>+		return -ENODEV;
> >>>+	}
> >>>+	soc_config = (struct tegra_ehci_soc_config *)match->data;
> 
> >>     Aren't casts from 'const void *' automatic?
> 
> >>WBR, Sergei
> 
> >Indeed they are, but those explicit casts seem to be used in many places in the kernel.
> 
>    I suspect people just don't know C well enough. They are also
> being gradually removed.

yeah, please resend with the cast removed. Also, put Tested-by, Acked-by
and Reviewed-by in place.

Patch

diff --git a/drivers/usb/host/ehci-tegra.c b/drivers/usb/host/ehci-tegra.c
index db8031f..c0d1f27 100644
--- a/drivers/usb/host/ehci-tegra.c
+++ b/drivers/usb/host/ehci-tegra.c
@@ -25,6 +25,7 @@ 
 #include <linux/irq.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_device.h>
 #include <linux/of_gpio.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
@@ -50,6 +51,10 @@ 
 
 static struct hc_driver __read_mostly tegra_ehci_hc_driver;
 
+struct tegra_ehci_soc_config {
+	bool has_hostpc;
+};
+
 static int (*orig_hub_control)(struct usb_hcd *hcd,
 				u16 typeReq, u16 wValue, u16 wIndex,
 				char *buf, u16 wLength);
@@ -320,8 +325,24 @@  static void tegra_ehci_unmap_urb_for_dma(struct usb_hcd *hcd, struct urb *urb)
 	free_dma_aligned_buffer(urb);
 }
 
+static const struct tegra_ehci_soc_config tegra30_soc_config = {
+	.has_hostpc = true,
+};
+
+static const struct tegra_ehci_soc_config tegra20_soc_config = {
+	.has_hostpc = false,
+};
+
+static struct of_device_id tegra_ehci_of_match[] = {
+	{ .compatible = "nvidia,tegra30-ehci", .data = &tegra30_soc_config },
+	{ .compatible = "nvidia,tegra20-ehci", .data = &tegra20_soc_config },
+	{ },
+};
+
 static int tegra_ehci_probe(struct platform_device *pdev)
 {
+	const struct of_device_id *match;
+	const struct tegra_ehci_soc_config *soc_config;
 	struct resource *res;
 	struct usb_hcd *hcd;
 	struct ehci_hcd *ehci;
@@ -330,6 +351,13 @@  static int tegra_ehci_probe(struct platform_device *pdev)
 	int irq;
 	struct usb_phy *u_phy;
 
+	match = of_match_device(tegra_ehci_of_match, &pdev->dev);
+	if (!match) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
+	soc_config = (struct tegra_ehci_soc_config *)match->data;
+
 	/* Right now device-tree probed devices don't get dma_mask set.
 	 * Since shared usb code relies on it, set it here for now.
 	 * Once we have dma capability bindings this can go away.
@@ -391,6 +419,7 @@  static int tegra_ehci_probe(struct platform_device *pdev)
 		goto cleanup_clk_en;
 	}
 	ehci->caps = hcd->regs + 0x100;
+	ehci->has_hostpc = soc_config->has_hostpc;
 
 	err = usb_phy_init(hcd->phy);
 	if (err) {
@@ -468,11 +497,6 @@  static void tegra_ehci_hcd_shutdown(struct platform_device *pdev)
 		hcd->driver->shutdown(hcd);
 }
 
-static struct of_device_id tegra_ehci_of_match[] = {
-	{ .compatible = "nvidia,tegra20-ehci", },
-	{ },
-};
-
 static struct platform_driver tegra_ehci_driver = {
 	.probe		= tegra_ehci_probe,
 	.remove		= tegra_ehci_remove,