[PATCH 2/2 v7] pinmux: add a driver for the U300 pinmux
Grant Likely
grant.likely at secretlab.ca
Thu Sep 29 22:12:39 EDT 2011
On Fri, Sep 16, 2011 at 02:14:09PM +0200, Linus Walleij wrote:
> From: Linus Walleij <linus.walleij at 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
More information about the linux-arm-kernel
mailing list