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 v3 5/6] ARM: mxs: add usb phy operations
Date: Wed, 27 Jul 2011 10:03:15 +0200	[thread overview]
Message-ID: <20110727080315.GN20587@pengutronix.de> (raw)
In-Reply-To: <1311744574-3610-6-git-send-email-tony.lin@freescale.com>

On Wed, Jul 27, 2011 at 01:29:33PM +0800, Tony Lin wrote:
> add usb phy register definitions and functions
> usb host driver will use these callback functions
> to initialize usb phy and change working mode
> 
> Signed-off-by: Tony Lin <tony.lin@freescale.com>
> ---
>  arch/arm/mach-mxs/Kconfig           |    1 +
>  arch/arm/mach-mxs/Makefile          |    1 +
>  arch/arm/mach-mxs/mxs_usb.c         |  288 +++++++++++++++++++++++++++++++++++
>  arch/arm/mach-mxs/regs-usbphy-mxs.h |  240 +++++++++++++++++++++++++++++
>  4 files changed, 530 insertions(+), 0 deletions(-)
> 
> +}
> +static int fsl_usb_host_init(struct platform_device *pdev)
> +{
> +	struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
> +	struct mxs_usb_private_date *ppriv = pdata->ppriv;
> +
> +	ppriv->phy_regs = ioremap(MX28_USBPHY1_BASE_ADDR, SZ_8K);
> +	ppriv->ctrl_regs = ioremap(MX28_USBCTRL1_BASE_ADDR, SZ_8K);

Did I mention that the i.MX28 has *two* USB controllers?

> +	if (!ppriv->phy_regs || !ppriv->ctrl_regs) {
> +		iounmap(ppriv->phy_regs);
> +		iounmap(ppriv->ctrl_regs);
> +		return -ENOMEM;
> +	}

So you call iounmap(0) here.

> +	ppriv->usb_clk = clk_get(&pdev->dev, "usb1");
> +	if (IS_ERR(ppriv->usb_clk)) {
> +		iounmap(ppriv->phy_regs);
> +		iounmap(ppriv->ctrl_regs);
> +		return PTR_ERR(ppriv->usb_clk);

In the kernel community we are not afraid of 'goto'.

> +	}
> +	clk_enable(ppriv->usb_clk);
> +
> +	ppriv->usb_phy_clk = clk_get(&pdev->dev, "usb1_phy");
> +	if (IS_ERR(ppriv->usb_phy_clk)) {
> +		clk_disable(ppriv->usb_clk);
> +		clk_put(ppriv->usb_clk);
> +		iounmap(ppriv->phy_regs);
> +		iounmap(ppriv->ctrl_regs);
> +		return PTR_ERR(ppriv->usb_phy_clk);
> +	}
> +	clk_enable(ppriv->usb_phy_clk);
> +
> +	phy_clock_gate(ppriv, true);
> +	return fsl_usbh_init(pdev);
> +}
> +
> +static int fsl_usb_host_uninit(struct platform_device *pdev)
> +{
> +	struct mxc_usbh_platform_data *pdata = pdev->dev.platform_data;
> +	struct mxs_usb_private_date *ppriv = pdata->ppriv;
> +
> +	phy_clock_gate(ppriv, false);
> +	clk_disable(ppriv->usb_phy_clk);
> +	clk_put(ppriv->usb_phy_clk);
> +	clk_disable(ppriv->usb_clk);
> +	clk_put(ppriv->usb_clk);
> +	iounmap(ppriv->phy_regs);
> +	iounmap(ppriv->ctrl_regs);
> +
> +	return 0;
> +}
> +
> +static struct mxs_usb_private_date usbh_private = {
> +	.internal_phy_clk_already_on = 0,
> +};

unitialized fields in static initializers are zero anyway.
Remove all this ppriv crap. clk_enable/disable will do the
reference counting for you.

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 |

  reply	other threads:[~2011-07-27  8:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-27  5:29 [PATCH v3 0/6] ARM: mx28: add usb host function Tony Lin
2011-07-27  5:29 ` [PATCH v3 1/6] ARM: mxs: ehci: consolidate definitions and structures to share among platforms Tony Lin
2011-07-27  5:29 ` [PATCH v3 2/6] ARM: mxs: enable usb1 phy power supply Tony Lin
2011-07-27  5:29 ` [PATCH v3 3/6] ARM: mxs: add usb clocks to clock tree Tony Lin
2011-07-27  5:29 ` [PATCH v3 4/6] ARM: mxs: make ehci-mxc more flexible to be used on different platforms Tony Lin
2011-07-27  8:19   ` Marc Kleine-Budde
2011-07-27  5:29 ` [PATCH v3 5/6] ARM: mxs: add usb phy operations Tony Lin
2011-07-27  8:03   ` Sascha Hauer [this message]
2011-07-27  8:16     ` Lin Tony-B19295
2011-07-28  7:39     ` Lin Tony-B19295
2011-07-28 11:27     ` Russell King - ARM Linux
2011-07-27  8:48   ` Lothar Waßmann
2011-07-27  9:10     ` Lin Tony-B19295
2011-07-27  9:24       ` Lothar Waßmann
2011-07-27  8:57   ` Marc Kleine-Budde
2011-07-27  5:29 ` [PATCH v3 6/6] ARM: mxs: add usb host function to default config Tony Lin
2011-07-27  9:01 ` [PATCH v3 0/6] ARM: mx28: add usb host function Marc Kleine-Budde
2011-07-27  9:15   ` Lin Tony-B19295

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=20110727080315.GN20587@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).