diff options
author | Tomasz Figa <t.figa@samsung.com> | 2012-10-11 04:11:09 -0400 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2012-10-15 03:10:11 -0400 |
commit | 40ba6227aeb3712b0cea0c4f9c3e355cf801f4c4 (patch) | |
tree | 1c253f6caa545c065c0bfc3c31cbdcf128501016 /drivers/pinctrl/pinctrl-samsung.c | |
parent | 62f14c0ef5d1bbd640b42a59f8f084f764a067c4 (diff) |
pinctrl: samsung: Assing pin numbers dynamically
This patch modifies the pinctrl-samsung driver to assign numbers to pins
dynamically instead of static enumerations.
Thanks to this change the amount of code requried to support a SoC can
be greatly reduced and the code made more readable.
Signed-off-by: Tomasz Figa <t.figa@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Thomas Abraham <thomas.abraham@linaro.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/pinctrl/pinctrl-samsung.c')
-rw-r--r-- | drivers/pinctrl/pinctrl-samsung.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/drivers/pinctrl/pinctrl-samsung.c b/drivers/pinctrl/pinctrl-samsung.c index aa42d54e89c6..f219bb6779ef 100644 --- a/drivers/pinctrl/pinctrl-samsung.c +++ b/drivers/pinctrl/pinctrl-samsung.c | |||
@@ -46,6 +46,8 @@ struct pin_config { | |||
46 | { "samsung,pin-pud-pdn", PINCFG_TYPE_PUD_PDN }, | 46 | { "samsung,pin-pud-pdn", PINCFG_TYPE_PUD_PDN }, |
47 | }; | 47 | }; |
48 | 48 | ||
49 | static unsigned int pin_base = 0; | ||
50 | |||
49 | /* check if the selector is a valid pin group selector */ | 51 | /* check if the selector is a valid pin group selector */ |
50 | static int samsung_get_group_count(struct pinctrl_dev *pctldev) | 52 | static int samsung_get_group_count(struct pinctrl_dev *pctldev) |
51 | { | 53 | { |
@@ -792,6 +794,9 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( | |||
792 | int id; | 794 | int id; |
793 | const struct of_device_id *match; | 795 | const struct of_device_id *match; |
794 | const struct device_node *node = pdev->dev.of_node; | 796 | const struct device_node *node = pdev->dev.of_node; |
797 | struct samsung_pin_ctrl *ctrl; | ||
798 | struct samsung_pin_bank *bank; | ||
799 | int i; | ||
795 | 800 | ||
796 | id = of_alias_get_id(pdev->dev.of_node, "pinctrl"); | 801 | id = of_alias_get_id(pdev->dev.of_node, "pinctrl"); |
797 | if (id < 0) { | 802 | if (id < 0) { |
@@ -799,7 +804,22 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( | |||
799 | return NULL; | 804 | return NULL; |
800 | } | 805 | } |
801 | match = of_match_node(samsung_pinctrl_dt_match, node); | 806 | match = of_match_node(samsung_pinctrl_dt_match, node); |
802 | return (struct samsung_pin_ctrl *)match->data + id; | 807 | ctrl = (struct samsung_pin_ctrl *)match->data + id; |
808 | |||
809 | bank = ctrl->pin_banks; | ||
810 | for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { | ||
811 | bank->pin_base = ctrl->nr_pins; | ||
812 | ctrl->nr_pins += bank->nr_pins; | ||
813 | if (bank->eint_type == EINT_TYPE_GPIO) { | ||
814 | bank->irq_base = ctrl->nr_gint; | ||
815 | ctrl->nr_gint += bank->nr_pins; | ||
816 | } | ||
817 | } | ||
818 | |||
819 | ctrl->base = pin_base; | ||
820 | pin_base += ctrl->nr_pins; | ||
821 | |||
822 | return ctrl; | ||
803 | } | 823 | } |
804 | 824 | ||
805 | static int __devinit samsung_pinctrl_probe(struct platform_device *pdev) | 825 | static int __devinit samsung_pinctrl_probe(struct platform_device *pdev) |