linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: s.hauer@pengutronix.de (Sascha Hauer)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 12/12] USB: chipidea: add imx usbmisc support
Date: Mon, 16 Jul 2012 10:25:20 +0200	[thread overview]
Message-ID: <20120716082520.GN24458@pengutronix.de> (raw)
In-Reply-To: <1342076512-19207-13-git-send-email-richard.zhao@freescale.com>

On Thu, Jul 12, 2012 at 03:01:52PM +0800, Richard Zhao wrote:
> i.MX usb controllers shares non-core registers, which may include
> SoC specific controls. We take it as a usbmisc device and usbmisc
> driver export functions needed by ci13xxx_imx driver.
> 
> For example, Sabrelite board has bad over-current design, we can
> usbmisc to disable over-current detect.
> 
> Signed-off-by: Richard Zhao <richard.zhao@freescale.com>
> ---
>  .../devicetree/bindings/usb/imx-usbmisc.txt        |   15 ++
>  drivers/usb/chipidea/Makefile                      |    2 +-
>  drivers/usb/chipidea/ci13xxx_imx.c                 |    4 +
>  drivers/usb/chipidea/imx_usbmisc.c                 |  144 ++++++++++++++++++++
>  4 files changed, 164 insertions(+), 1 deletion(-)
>  create mode 100644 Documentation/devicetree/bindings/usb/imx-usbmisc.txt
>  create mode 100644 drivers/usb/chipidea/imx_usbmisc.c
> 
> diff --git a/Documentation/devicetree/bindings/usb/imx-usbmisc.txt b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
> new file mode 100644
> index 0000000..09f01ca
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/usb/imx-usbmisc.txt
> @@ -0,0 +1,15 @@
> +* Freescale i.MX non-core registers
> +
> +Required properties:
> +- compatible: Should be "fsl,imx6q-usbmisc"
> +- reg: Should contain registers location and length
> +
> +Optional properties:
> +- fsl,disable-over-current: disable over current detect
> +
> +Examples:
> +usbmisc at 02184800 {
> +	compatible = "fsl,imx6q-usbmisc";
> +	reg = <0x02184800 0x200>;
> +	fsl,disable-over-current;
> +};
> diff --git a/drivers/usb/chipidea/Makefile b/drivers/usb/chipidea/Makefile
> index 3f56b76..46fc31c 100644
> --- a/drivers/usb/chipidea/Makefile
> +++ b/drivers/usb/chipidea/Makefile
> @@ -17,5 +17,5 @@ ifneq ($(CONFIG_PCI),)
>  endif
>  
>  ifneq ($(CONFIG_OF_DEVICE),)
> -	obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_imx.o
> +	obj-$(CONFIG_USB_CHIPIDEA)	+= ci13xxx_imx.o imx_usbmisc.o
>  endif
> diff --git a/drivers/usb/chipidea/ci13xxx_imx.c b/drivers/usb/chipidea/ci13xxx_imx.c
> index b3173d8..dd7f3a3 100644
> --- a/drivers/usb/chipidea/ci13xxx_imx.c
> +++ b/drivers/usb/chipidea/ci13xxx_imx.c
> @@ -24,6 +24,8 @@
>  
>  #include "ci.h"
>  
> +int imx_usbmisc_init(struct device *usbdev);
> +
>  #define pdev_to_phy(pdev) \
>  	((struct usb_phy *)platform_get_drvdata(pdev))
>  #define ci_to_imx_data(ci) \
> @@ -142,6 +144,8 @@ static int __devinit ci13xxx_imx_probe(struct platform_device *pdev)
>  		dma_set_coherent_mask(&pdev->dev, *pdev->dev.dma_mask);
>  	}
>  
> +	imx_usbmisc_init(&pdev->dev);
> +
>  	platform_set_drvdata(pdev, data);
>  
>  	plat_ci = ci13xxx_add_device(&pdev->dev,
> diff --git a/drivers/usb/chipidea/imx_usbmisc.c b/drivers/usb/chipidea/imx_usbmisc.c
> new file mode 100644
> index 0000000..33a8ec0
> --- /dev/null
> +++ b/drivers/usb/chipidea/imx_usbmisc.c
> @@ -0,0 +1,144 @@
> +/*
> + * Copyright 2012 Freescale Semiconductor, Inc.
> + *
> + * The code contained herein is licensed under the GNU General Public
> + * License. You may obtain a copy of the GNU General Public License
> + * Version 2 or later at the following locations:
> + *
> + * http://www.opensource.org/licenses/gpl-license.html
> + * http://www.gnu.org/copyleft/gpl.html
> + */
> +
> +#include <linux/module.h>
> +#include <linux/of_platform.h>
> +#include <linux/clk.h>
> +#include <linux/err.h>
> +#include <asm/io.h>

linux/io.h

> +
> +struct usbmisc;
> +
> +struct soc_data {
> +	int (*init) (struct usbmisc *usbmisc, int id);
> +	void (*exit) (struct usbmisc *usbmisc, int id);
> +};
> +
> +struct usbmisc {
> +	struct soc_data *soc_data;
> +	void __iomem *base;
> +	struct clk *clk;
> +
> +	int dis_oc:1;
> +};
> +
> +/* Since we only have one usbmisc device at runtime, we global variables */
> +static struct usbmisc *usbmisc;

NACK

What you've done here exactly matches your current usecase but is not
enough for any of the other usecases I can think of. Even the i.MX6 has
three USB ports, each of them has a overcurrent disable bit. Also, there
are more flags, like:

- use internal phy
- power pin polarity
- ttl enabled

I think the best you can do here is to add the flags to the
fsl,imx6q-usb device nodes:

	usb at 02184000 { /* USB OTG */
		compatible = "fsl,imx6q-usb", "fsl,imx27-usb";
		reg = <0x02184000 0x200>;
		interrupts = <0 43 0x04>;
		fsl,usbphy = <&usbphy1>;
		status = "disabled";
		fsl,disable-over-current;
		<other flags>;
	};

Then add a usbmisc device which does not contain any flags. During
initialization of the fsl,imx6q-usb device you can then pass a pointer
to its device node to imx_usbmisc_init.

Sascha

-- 
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 |

  parent reply	other threads:[~2012-07-16  8:25 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-12  7:01 [PATCH 00/12] chipidea/imx: add otg support and some bug fix Richard Zhao
2012-07-12  7:01 ` [PATCH 01/12] USB: chipidea: imx: add pinctrl support Richard Zhao
2012-07-12  7:01 ` [PATCH 02/12] USB: chipidea: delay 2ms before read ID status at probe time Richard Zhao
2012-07-12  7:01 ` [PATCH 03/12] USB: chipidea: move OTGSC_IDIS clearing from ci_role_work to irq handler Richard Zhao
2012-07-12  7:01 ` [PATCH 04/12] USB: chipidea: clear gadget struct at udc_start fail path Richard Zhao
2012-07-12  7:01 ` [PATCH 05/12] USB: chipidea: don't let probe fail if otg controller start one role failed Richard Zhao
2012-07-12  7:01 ` [PATCH 06/12] USB: mxs-phy: add basic otg support Richard Zhao
2012-07-12  7:01 ` [PATCH 07/12] USB: chipidea: add vbus detect for udc Richard Zhao
2012-07-12  7:01 ` [PATCH 08/12] USB: chipidea: convert to use devm_request_irq Richard Zhao
2012-07-12  7:01 ` [PATCH 09/12] USB: chipidea: add -DDEBUG if CONFIG_USB_CHIPIDEA_DEBUG Richard Zhao
2012-07-12  7:01 ` [PATCH 10/12] USB: chipidea: add set_vbus_power support Richard Zhao
2012-07-16 12:10   ` Marc Kleine-Budde
2012-07-17  1:30     ` Richard Zhao
2012-07-12  7:01 ` [PATCH 11/12] USB: chipidea: re-order irq handling to avoid unhandled irq Richard Zhao
2012-07-12  7:01 ` [PATCH 12/12] USB: chipidea: add imx usbmisc support Richard Zhao
2012-07-12  7:10   ` Richard Zhao
2012-07-13 12:25   ` Michael Grzeschik
2012-07-13 14:02     ` Richard Zhao
2012-07-13 14:14       ` Marc Kleine-Budde
2012-07-16  2:53         ` Richard Zhao
2012-07-16  8:25   ` Sascha Hauer [this message]
2012-07-16  8:38     ` Richard Zhao
2012-07-16  8:50       ` Sascha Hauer
2012-07-16 12:24   ` Marek Vasut
2012-07-17  0:40 ` [PATCH 00/12] chipidea/imx: add otg support and some bug fix Greg KH
2012-07-19  2:05   ` Richard Zhao
2012-07-26 10:59     ` Richard Zhao
2012-07-30  9:17       ` Richard Zhao
2012-07-30 16:00         ` Greg KH

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=20120716082520.GN24458@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).