linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: grant.likely@secretlab.ca (Grant Likely)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2 v7] pinmux: add a driver for the U300 pinmux
Date: Thu, 29 Sep 2011 20:12:39 -0600	[thread overview]
Message-ID: <20110930021239.GL12606@ponder.secretlab.ca> (raw)
In-Reply-To: <1316175249-10780-1-git-send-email-linus.walleij@stericsson.com>

On Fri, Sep 16, 2011 at 02:14:09PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij@linaro.org>
> 
> This adds a driver for the U300 pinmux portions of the system
> controller "SYSCON". It also serves as an example of how to use
> the pinmux subsystem. This driver also houses the platform data
> for the only supported platform.

Hi Linus, comments below.

> diff --git a/arch/arm/mach-u300/Kconfig b/arch/arm/mach-u300/Kconfig
> index 32a7b0f..449fd6a 100644
> --- a/arch/arm/mach-u300/Kconfig
> +++ b/arch/arm/mach-u300/Kconfig
> @@ -6,6 +6,8 @@ comment "ST-Ericsson Mobile Platform Products"
>  
>  config MACH_U300
>  	bool "U300"
> +	select PINCTRL
> +	select PINMUX_U300

Shouldn't PINMUX_U300 select PINCTRL?

> +#include "pinmux-u300.h"

There is only one file that uses this header data.  Just put it into
the .c file.

> +static int __init u300_pmx_probe(struct platform_device *pdev)
> +{
> +	int ret;
> +	struct u300_pmx *upmx;
> +	struct resource *res;
> +
> +	/* Create state holders etc for this driver */
> +	upmx = kzalloc(sizeof(struct u300_pmx), GFP_KERNEL);

devm_kzalloc()

> +	if (!upmx)
> +		return -ENOMEM;
> +
> +	upmx->dev = &pdev->dev;
> +
> +	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res) {
> +		ret = -ENOENT;
> +		goto out_no_resource;
> +	}
> +	upmx->phybase = res->start;
> +	upmx->physize = resource_size(res);
> +
> +	if (request_mem_region(upmx->phybase, upmx->physize,
> +			       DRIVER_NAME) == NULL) {
> +		ret = -EBUSY;
> +		goto out_no_memregion;
> +	}
> +
> +	upmx->virtbase = ioremap(upmx->phybase, upmx->physize);
> +	if (!upmx->virtbase) {
> +		ret = -ENOMEM;
> +		goto out_no_remap;
> +	}
> +
> +	upmx->pctl = pinctrl_register(&u300_pmx_desc, &pdev->dev, upmx);
> +	if (IS_ERR(upmx->pctl)) {
> +		dev_err(&pdev->dev, "could not register U300 pinmux driver\n");
> +		ret = PTR_ERR(upmx->pctl);
> +		goto out_no_pmx;
> +	}
> +
> +	/* We will handle a range of GPIO pins */
> +	pinctrl_add_gpio_range(upmx->pctl, &u300_gpio_range);
> +
> +	platform_set_drvdata(pdev, upmx);
> +
> +	u300_pmx_dumpregs(upmx);
> +
> +	dev_info(&pdev->dev, "initialized U300 pinmux driver\n");
> +
> +	return 0;
> +
> +out_no_pmx:
> +	iounmap(upmx->virtbase);
> +out_no_remap:
> +	platform_set_drvdata(pdev, NULL);
> +out_no_memregion:
> +	release_mem_region(upmx->phybase, upmx->physize);
> +out_no_resource:
> +	kfree(upmx);
> +	return ret;
> +}
> +
> +static int __exit u300_pmx_remove(struct platform_device *pdev)

__devexit

> +{
> +	struct u300_pmx *upmx = platform_get_drvdata(pdev);
> +
> +	pinctrl_remove_gpio_range(upmx->pctl, &u300_gpio_range);
> +	pinctrl_unregister(upmx->pctl);
> +	iounmap(upmx->virtbase);
> +	release_mem_region(upmx->phybase, upmx->physize);
> +	platform_set_drvdata(pdev, NULL);
> +	kfree(upmx);
> +
> +	return 0;
> +}
> +
> +static struct platform_driver u300_pmx_driver = {
> +	.driver = {
> +		.name = DRIVER_NAME,
> +		.owner = THIS_MODULE,
> +	},
> +	.remove = __exit_p(u300_pmx_remove),

__devexit_p

  parent reply	other threads:[~2011-09-30  2:12 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-16 12:14 [PATCH 2/2 v7] pinmux: add a driver for the U300 pinmux Linus Walleij
2011-09-20 22:15 ` Stephen Warren
2011-09-21  8:25   ` Linus Walleij
2011-09-21 19:39     ` Stephen Warren
2011-09-27  8:00       ` Linus Walleij
2011-09-28  0:15         ` Stephen Warren
2011-09-28 11:58           ` Linus Walleij
2011-09-28 17:28             ` Stephen Warren
2011-09-30  2:12 ` Grant Likely [this message]
2011-09-30 13:37   ` Linus Walleij

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=20110930021239.GL12606@ponder.secretlab.ca \
    --to=grant.likely@secretlab.ca \
    --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).