aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-tegra.c
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-04-11 14:53:09 -0400
committerStephen Warren <swarren@nvidia.com>2012-04-18 12:26:40 -0400
commit52f48fe00fcad83cd5fc4c961d851a3530fe032b (patch)
tree68fdb2a2580914f17b74374ad6b390027824c389 /drivers/pinctrl/pinctrl-tegra.c
parentecc295bbab6b9d1baf0c0a8c2d5a945b201df547 (diff)
pinctrl: tegra: refactor probe handling
Rather than having a single tegra-pinctrl driver that determines whether it's running on Tegra20 or Tegra30, instead have separate drivers for each that call into utility functions to implement the majority of the driver. This change is based on review feedback of the SPEAr pinctrl driver, which had originally copied to Tegra driver structure. This requires that the two drivers have unique names. Update a couple spots in arch/arm/mach-tegra for the name change. Signed-off-by: Stephen Warren <swarren@nvidia.com> Acked-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-tegra.c')
-rw-r--r--drivers/pinctrl/pinctrl-tegra.c80
1 files changed, 12 insertions, 68 deletions
diff --git a/drivers/pinctrl/pinctrl-tegra.c b/drivers/pinctrl/pinctrl-tegra.c
index f6eba9c3c9e2..3ac8ad3829e4 100644
--- a/drivers/pinctrl/pinctrl-tegra.c
+++ b/drivers/pinctrl/pinctrl-tegra.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * Driver for the NVIDIA Tegra pinmux 2 * Driver for the NVIDIA Tegra pinmux
3 * 3 *
4 * Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved. 4 * Copyright (c) 2011-2012, NVIDIA CORPORATION. All rights reserved.
5 * 5 *
6 * Derived from code: 6 * Derived from code:
7 * Copyright (C) 2010 Google, Inc. 7 * Copyright (C) 2010 Google, Inc.
@@ -22,7 +22,8 @@
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/io.h> 23#include <linux/io.h>
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/of_device.h> 25#include <linux/of.h>
26#include <linux/platform_device.h>
26#include <linux/pinctrl/machine.h> 27#include <linux/pinctrl/machine.h>
27#include <linux/pinctrl/pinctrl.h> 28#include <linux/pinctrl/pinctrl.h>
28#include <linux/pinctrl/pinmux.h> 29#include <linux/pinctrl/pinmux.h>
@@ -31,10 +32,9 @@
31 32
32#include <mach/pinconf-tegra.h> 33#include <mach/pinconf-tegra.h>
33 34
35#include "core.h"
34#include "pinctrl-tegra.h" 36#include "pinctrl-tegra.h"
35 37
36#define DRIVER_NAME "tegra-pinmux"
37
38struct tegra_pmx { 38struct tegra_pmx {
39 struct device *dev; 39 struct device *dev;
40 struct pinctrl_dev *pctl; 40 struct pinctrl_dev *pctl;
@@ -87,7 +87,7 @@ static void tegra_pinctrl_pin_dbg_show(struct pinctrl_dev *pctldev,
87 struct seq_file *s, 87 struct seq_file *s,
88 unsigned offset) 88 unsigned offset)
89{ 89{
90 seq_printf(s, " " DRIVER_NAME); 90 seq_printf(s, " %s", dev_name(pctldev->dev));
91} 91}
92 92
93static int reserve_map(struct pinctrl_map **map, unsigned *reserved_maps, 93static int reserve_map(struct pinctrl_map **map, unsigned *reserved_maps,
@@ -589,60 +589,29 @@ static struct pinctrl_gpio_range tegra_pinctrl_gpio_range = {
589}; 589};
590 590
591static struct pinctrl_desc tegra_pinctrl_desc = { 591static struct pinctrl_desc tegra_pinctrl_desc = {
592 .name = DRIVER_NAME,
593 .pctlops = &tegra_pinctrl_ops, 592 .pctlops = &tegra_pinctrl_ops,
594 .pmxops = &tegra_pinmux_ops, 593 .pmxops = &tegra_pinmux_ops,
595 .confops = &tegra_pinconf_ops, 594 .confops = &tegra_pinconf_ops,
596 .owner = THIS_MODULE, 595 .owner = THIS_MODULE,
597}; 596};
598 597
599static struct of_device_id tegra_pinctrl_of_match[] __devinitdata = { 598int __devinit tegra_pinctrl_probe(struct platform_device *pdev,
600#ifdef CONFIG_PINCTRL_TEGRA20 599 const struct tegra_pinctrl_soc_data *soc_data)
601 {
602 .compatible = "nvidia,tegra20-pinmux",
603 .data = tegra20_pinctrl_init,
604 },
605#endif
606#ifdef CONFIG_PINCTRL_TEGRA30
607 {
608 .compatible = "nvidia,tegra30-pinmux",
609 .data = tegra30_pinctrl_init,
610 },
611#endif
612 {},
613};
614
615static int __devinit tegra_pinctrl_probe(struct platform_device *pdev)
616{ 600{
617 const struct of_device_id *match;
618 tegra_pinctrl_soc_initf initf = NULL;
619 struct tegra_pmx *pmx; 601 struct tegra_pmx *pmx;
620 struct resource *res; 602 struct resource *res;
621 int i; 603 int i;
622 604
623 match = of_match_device(tegra_pinctrl_of_match, &pdev->dev);
624 if (match)
625 initf = (tegra_pinctrl_soc_initf)match->data;
626#ifdef CONFIG_PINCTRL_TEGRA20
627 if (!initf)
628 initf = tegra20_pinctrl_init;
629#endif
630 if (!initf) {
631 dev_err(&pdev->dev,
632 "Could not determine SoC-specific init func\n");
633 return -EINVAL;
634 }
635
636 pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL); 605 pmx = devm_kzalloc(&pdev->dev, sizeof(*pmx), GFP_KERNEL);
637 if (!pmx) { 606 if (!pmx) {
638 dev_err(&pdev->dev, "Can't alloc tegra_pmx\n"); 607 dev_err(&pdev->dev, "Can't alloc tegra_pmx\n");
639 return -ENOMEM; 608 return -ENOMEM;
640 } 609 }
641 pmx->dev = &pdev->dev; 610 pmx->dev = &pdev->dev;
642 611 pmx->soc = soc_data;
643 (*initf)(&pmx->soc);
644 612
645 tegra_pinctrl_gpio_range.npins = pmx->soc->ngpios; 613 tegra_pinctrl_gpio_range.npins = pmx->soc->ngpios;
614 tegra_pinctrl_desc.name = dev_name(&pdev->dev);
646 tegra_pinctrl_desc.pins = pmx->soc->pins; 615 tegra_pinctrl_desc.pins = pmx->soc->pins;
647 tegra_pinctrl_desc.npins = pmx->soc->npins; 616 tegra_pinctrl_desc.npins = pmx->soc->npins;
648 617
@@ -697,8 +666,9 @@ static int __devinit tegra_pinctrl_probe(struct platform_device *pdev)
697 666
698 return 0; 667 return 0;
699} 668}
669EXPORT_SYMBOL_GPL(tegra_pinctrl_probe);
700 670
701static int __devexit tegra_pinctrl_remove(struct platform_device *pdev) 671int __devexit tegra_pinctrl_remove(struct platform_device *pdev)
702{ 672{
703 struct tegra_pmx *pmx = platform_get_drvdata(pdev); 673 struct tegra_pmx *pmx = platform_get_drvdata(pdev);
704 674
@@ -707,30 +677,4 @@ static int __devexit tegra_pinctrl_remove(struct platform_device *pdev)
707 677
708 return 0; 678 return 0;
709} 679}
710 680EXPORT_SYMBOL_GPL(tegra_pinctrl_remove);
711static struct platform_driver tegra_pinctrl_driver = {
712 .driver = {
713 .name = DRIVER_NAME,
714 .owner = THIS_MODULE,
715 .of_match_table = tegra_pinctrl_of_match,
716 },
717 .probe = tegra_pinctrl_probe,
718 .remove = __devexit_p(tegra_pinctrl_remove),
719};
720
721static int __init tegra_pinctrl_init(void)
722{
723 return platform_driver_register(&tegra_pinctrl_driver);
724}
725arch_initcall(tegra_pinctrl_init);
726
727static void __exit tegra_pinctrl_exit(void)
728{
729 platform_driver_unregister(&tegra_pinctrl_driver);
730}
731module_exit(tegra_pinctrl_exit);
732
733MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>");
734MODULE_DESCRIPTION("NVIDIA Tegra pinctrl driver");
735MODULE_LICENSE("GPL v2");
736MODULE_DEVICE_TABLE(of, tegra_pinctrl_of_match);