From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/7] ehci mxc: make it more flexible to be used for mx28
Date: Wed, 20 Jul 2011 21:41:12 +0200 [thread overview]
Message-ID: <20110720194112.GN26347@pengutronix.de> (raw)
In-Reply-To: <1311160106-4898-6-git-send-email-tony.lin@freescale.com>
On Wed, Jul 20, 2011 at 07:08:24PM +0800, Tony Lin wrote:
> old driver uses some hard coding for clks' name which could
> not be used for mx28. So workaround these hard codings by
> judging the cpu is mx28 or not.
> add platform callback funtions in usb irq handler in the case
> usb phy need to change its disconnect detector mode after usb
> device is connected and disconnected. These callbacks also
> could be used for other machines whose usb phy need such kind
> of operations
>
> Signed-off-by: Tony Lin <tony.lin@freescale.com>
> ---
> drivers/usb/host/Kconfig | 2 +-
> drivers/usb/host/ehci-mxc.c | 57 +++++++++++++++++++++++++++++++-----------
> 2 files changed, 43 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
> index ab085f1..6a5905b 100644
> --- a/drivers/usb/host/Kconfig
> +++ b/drivers/usb/host/Kconfig
> @@ -139,7 +139,7 @@ config USB_EHCI_FSL
>
> config USB_EHCI_MXC
> bool "Support for Freescale on-chip EHCI USB controller"
> - depends on USB_EHCI_HCD && ARCH_MXC
> + depends on USB_EHCI_HCD && (ARCH_MXC || ARCH_MXS)
> select USB_EHCI_ROOT_HUB_TT
> ---help---
> Variation of ARC USB block used in some Freescale chips.
> diff --git a/drivers/usb/host/ehci-mxc.c b/drivers/usb/host/ehci-mxc.c
> index 0c058be..65e78cd 100644
> --- a/drivers/usb/host/ehci-mxc.c
> +++ b/drivers/usb/host/ehci-mxc.c
> @@ -23,9 +23,7 @@
> #include <linux/usb/otg.h>
> #include <linux/usb/ulpi.h>
> #include <linux/slab.h>
> -
> -#include <mach/mxc_ehci.h>
> -
> +#include <linux/fsl_devices.h>
> #include <asm/mach-types.h>
>
> #define ULPI_VIEWPORT_OFFSET 0x170
> @@ -66,6 +64,30 @@ static int ehci_mxc_setup(struct usb_hcd *hcd)
> return 0;
> }
>
> +static irqreturn_t fsl_ehci_irq(struct usb_hcd *hcd)
> +{
> + struct mxc_usbh_platform_data *pdata;
> + struct ehci_hcd *ehci = hcd_to_ehci(hcd);
> + u32 status;
> +
> + pdata = hcd->self.controller->platform_data;
> + if (pdata->plt_get_usb_connect_status == NULL || \
This backslash is unnecessary
> + pdata->plt_usb_disconnect_detect == NULL)
> + goto out;
> +
> + spin_lock(&ehci->lock);
> + status = ehci_readl(ehci, &ehci->regs->status);
> + if (status & STS_PCD) {
> + if (pdata->plt_get_usb_connect_status())
> + pdata->plt_usb_disconnect_detect(true);
> + else
> + pdata->plt_usb_disconnect_detect(false);
> + }
> + spin_unlock(&ehci->lock);
> +out:
> + return ehci_irq(hcd);
> +}
> +
> static const struct hc_driver ehci_mxc_hc_driver = {
> .description = hcd_name,
> .product_desc = "Freescale On-Chip EHCI Host Controller",
> @@ -74,7 +96,7 @@ static const struct hc_driver ehci_mxc_hc_driver = {
> /*
> * generic hardware linkage
> */
> - .irq = ehci_irq,
> + .irq = fsl_ehci_irq,
> .flags = HCD_USB2 | HCD_MEMORY,
>
> /*
> @@ -165,14 +187,15 @@ static int ehci_mxc_drv_probe(struct platform_device *pdev)
> }
>
> /* enable clocks */
> - priv->usbclk = clk_get(dev, "usb");
> - if (IS_ERR(priv->usbclk)) {
> - ret = PTR_ERR(priv->usbclk);
> - goto err_clk;
> + if (!cpu_is_mx28()) {
> + priv->usbclk = clk_get(dev, "usb");
> + if (IS_ERR(priv->usbclk)) {
> + ret = PTR_ERR(priv->usbclk);
> + goto err_clk;
> + }
> + clk_enable(priv->usbclk);
> }
We should start and provide dummy clocks for usb and ahb clock on
platform which do not have them. Then we can get rid of the cpu checks
in the driver.
> - clk_enable(priv->usbclk);
> -
> - if (!cpu_is_mx35() && !cpu_is_mx25()) {
> + if (!cpu_is_mx35() && !cpu_is_mx25() && !cpu_is_mx28()) {
> priv->ahbclk = clk_get(dev, "usb_ahb");
> if (IS_ERR(priv->ahbclk)) {
> ret = PTR_ERR(priv->ahbclk);
> @@ -272,8 +295,10 @@ err_clk_phy:
> clk_put(priv->ahbclk);
> }
> err_clk_ahb:
> - clk_disable(priv->usbclk);
> - clk_put(priv->usbclk);
> + if (priv->usbclk) {
> + clk_disable(priv->usbclk);
> + clk_put(priv->usbclk);
> + }
> err_clk:
> iounmap(hcd->regs);
> err_ioremap:
> @@ -304,8 +329,10 @@ static int __exit ehci_mxc_drv_remove(struct platform_device *pdev)
> usb_put_hcd(hcd);
> platform_set_drvdata(pdev, NULL);
>
> - clk_disable(priv->usbclk);
> - clk_put(priv->usbclk);
> + if (priv->usbclk) {
> + clk_disable(priv->usbclk);
> + clk_put(priv->usbclk);
> + }
> if (priv->ahbclk) {
> clk_disable(priv->ahbclk);
> clk_put(priv->ahbclk);
> --
> 1.7.0.4
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
next prev parent reply other threads:[~2011-07-20 19:41 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-20 11:08 [PATCH 0/7] ARM: mx28: add usb host function Tony Lin
2011-07-20 10:57 ` Felipe Balbi
2011-07-20 11:08 ` [PATCH 1/7] consolidate definitions and structures to share among platforms Tony Lin
2011-07-20 10:59 ` Felipe Balbi
2011-07-20 11:03 ` Lin Tony-B19295
2011-07-20 11:16 ` Felipe Balbi
2011-07-20 11:21 ` Lin Tony-B19295
2011-07-20 11:08 ` [PATCH 2/7] enable usb1 phy power supply Tony Lin
2011-07-20 11:01 ` Felipe Balbi
2011-07-20 11:41 ` Wolfram Sang
2011-07-22 2:16 ` Lin Tony-B19295
2011-07-20 19:08 ` Sascha Hauer
2011-07-22 2:20 ` Lin Tony-B19295
2011-07-20 11:08 ` [PATCH 3/7] add usb phy clocks to clock tree Tony Lin
2011-07-20 11:02 ` Felipe Balbi
2011-07-20 11:05 ` Lin Tony-B19295
2011-07-20 19:10 ` Sascha Hauer
2011-07-22 6:02 ` Lin Tony-B19295
2011-07-22 9:18 ` Sascha Hauer
2011-07-20 11:08 ` [PATCH 4/7] mx28: add usb host phy functions Tony Lin
2011-07-20 11:12 ` Felipe Balbi
2011-07-20 19:26 ` Sascha Hauer
2011-07-22 2:23 ` Lin Tony-B19295
2011-07-21 6:04 ` Lothar Waßmann
2011-07-20 11:08 ` [PATCH 5/7] ehci mxc: make it more flexible to be used for mx28 Tony Lin
2011-07-20 11:05 ` Arnaud Patard (Rtp)
2011-07-20 11:08 ` Lin Tony-B19295
2011-07-20 11:45 ` Wolfram Sang
2011-07-20 11:14 ` Felipe Balbi
2011-07-20 11:21 ` Lin Tony-B19295
2011-07-20 11:23 ` Felipe Balbi
2011-07-20 11:25 ` Lin Tony-B19295
2011-07-20 11:27 ` Felipe Balbi
2011-07-20 13:59 ` Alan Stern
2011-07-22 5:18 ` Lin Tony-B19295
2011-07-20 19:41 ` Sascha Hauer [this message]
2011-07-20 11:08 ` [PATCH 6/7] add macro definitions according to ehci-mxc driver change Tony Lin
2011-07-20 19:43 ` Sascha Hauer
2011-07-21 6:06 ` Lothar Waßmann
2011-07-20 11:08 ` [PATCH 7/7] add usb host function to default config Tony Lin
2011-07-20 20:07 ` [PATCH 0/7] ARM: mx28: add usb host function Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110720194112.GN26347@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.