aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl
diff options
context:
space:
mode:
authorTomasz Figa <tomasz.figa@gmail.com>2014-09-23 15:05:40 -0400
committerTomasz Figa <tomasz.figa@gmail.com>2014-11-09 07:30:14 -0500
commit1bf00d7a6dbff0a29eff4f8c022653b2bc9f5b97 (patch)
tree99cf95b25d3b0f21c55214832bdfcbfdb6685e93 /drivers/pinctrl
parent94ce944bed8a849a9b83b4e66f0e6e4abc16c457 (diff)
pinctrl: samsung: Constify samsung_pin_ctrl struct
In order to separate initialization constants from runtime data, this patch modifies the driver to store only constant data in samsung_pin_ctrl struct and copy data required at runtime to samsung_pinctrl_drv_data struct. This makes it possible to mark all existing instances of samsung_pin_ctrl struct as const and __initconst. Signed-off-by: Tomasz Figa <tomasz.figa@gmail.com>
Diffstat (limited to 'drivers/pinctrl')
-rw-r--r--drivers/pinctrl/samsung/pinctrl-exynos.c39
-rw-r--r--drivers/pinctrl/samsung/pinctrl-s3c24xx.c12
-rw-r--r--drivers/pinctrl/samsung/pinctrl-s3c64xx.c14
-rw-r--r--drivers/pinctrl/samsung/pinctrl-samsung.c87
-rw-r--r--drivers/pinctrl/samsung/pinctrl-samsung.h40
5 files changed, 97 insertions, 95 deletions
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c
index 0202e0016233..552f7c75243d 100644
--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
+++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
@@ -277,8 +277,7 @@ static const struct irq_domain_ops exynos_gpio_irqd_ops = {
277static irqreturn_t exynos_eint_gpio_irq(int irq, void *data) 277static irqreturn_t exynos_eint_gpio_irq(int irq, void *data)
278{ 278{
279 struct samsung_pinctrl_drv_data *d = data; 279 struct samsung_pinctrl_drv_data *d = data;
280 struct samsung_pin_ctrl *ctrl = d->ctrl; 280 struct samsung_pin_bank *bank = d->pin_banks;
281 struct samsung_pin_bank *bank = ctrl->pin_banks;
282 unsigned int svc, group, pin, virq; 281 unsigned int svc, group, pin, virq;
283 282
284 svc = readl(d->virt_base + EXYNOS_SVC_OFFSET); 283 svc = readl(d->virt_base + EXYNOS_SVC_OFFSET);
@@ -325,8 +324,8 @@ static int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
325 return -ENXIO; 324 return -ENXIO;
326 } 325 }
327 326
328 bank = d->ctrl->pin_banks; 327 bank = d->pin_banks;
329 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 328 for (i = 0; i < d->nr_banks; ++i, ++bank) {
330 if (bank->eint_type != EINT_TYPE_GPIO) 329 if (bank->eint_type != EINT_TYPE_GPIO)
331 continue; 330 continue;
332 bank->irq_domain = irq_domain_add_linear(bank->of_node, 331 bank->irq_domain = irq_domain_add_linear(bank->of_node,
@@ -498,8 +497,8 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
498 if (!wkup_np) 497 if (!wkup_np)
499 return -ENODEV; 498 return -ENODEV;
500 499
501 bank = d->ctrl->pin_banks; 500 bank = d->pin_banks;
502 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 501 for (i = 0; i < d->nr_banks; ++i, ++bank) {
503 if (bank->eint_type != EINT_TYPE_WKUP) 502 if (bank->eint_type != EINT_TYPE_WKUP)
504 continue; 503 continue;
505 504
@@ -556,9 +555,9 @@ static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d)
556 irq_set_chained_handler(irq, exynos_irq_demux_eint16_31); 555 irq_set_chained_handler(irq, exynos_irq_demux_eint16_31);
557 irq_set_handler_data(irq, muxed_data); 556 irq_set_handler_data(irq, muxed_data);
558 557
559 bank = d->ctrl->pin_banks; 558 bank = d->pin_banks;
560 idx = 0; 559 idx = 0;
561 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 560 for (i = 0; i < d->nr_banks; ++i, ++bank) {
562 if (bank->eint_type != EINT_TYPE_WKUP_MUX) 561 if (bank->eint_type != EINT_TYPE_WKUP_MUX)
563 continue; 562 continue;
564 563
@@ -590,11 +589,10 @@ static void exynos_pinctrl_suspend_bank(
590 589
591static void exynos_pinctrl_suspend(struct samsung_pinctrl_drv_data *drvdata) 590static void exynos_pinctrl_suspend(struct samsung_pinctrl_drv_data *drvdata)
592{ 591{
593 struct samsung_pin_ctrl *ctrl = drvdata->ctrl; 592 struct samsung_pin_bank *bank = drvdata->pin_banks;
594 struct samsung_pin_bank *bank = ctrl->pin_banks;
595 int i; 593 int i;
596 594
597 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) 595 for (i = 0; i < drvdata->nr_banks; ++i, ++bank)
598 if (bank->eint_type == EINT_TYPE_GPIO) 596 if (bank->eint_type == EINT_TYPE_GPIO)
599 exynos_pinctrl_suspend_bank(drvdata, bank); 597 exynos_pinctrl_suspend_bank(drvdata, bank);
600} 598}
@@ -626,11 +624,10 @@ static void exynos_pinctrl_resume_bank(
626 624
627static void exynos_pinctrl_resume(struct samsung_pinctrl_drv_data *drvdata) 625static void exynos_pinctrl_resume(struct samsung_pinctrl_drv_data *drvdata)
628{ 626{
629 struct samsung_pin_ctrl *ctrl = drvdata->ctrl; 627 struct samsung_pin_bank *bank = drvdata->pin_banks;
630 struct samsung_pin_bank *bank = ctrl->pin_banks;
631 int i; 628 int i;
632 629
633 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) 630 for (i = 0; i < drvdata->nr_banks; ++i, ++bank)
634 if (bank->eint_type == EINT_TYPE_GPIO) 631 if (bank->eint_type == EINT_TYPE_GPIO)
635 exynos_pinctrl_resume_bank(drvdata, bank); 632 exynos_pinctrl_resume_bank(drvdata, bank);
636} 633}
@@ -673,7 +670,7 @@ static struct samsung_pin_bank s5pv210_pin_bank[] = {
673 EXYNOS_PIN_BANK_EINTW(8, 0xc60, "gph3", 0x0c), 670 EXYNOS_PIN_BANK_EINTW(8, 0xc60, "gph3", 0x0c),
674}; 671};
675 672
676struct samsung_pin_ctrl s5pv210_pin_ctrl[] = { 673const struct samsung_pin_ctrl s5pv210_pin_ctrl[] __initconst = {
677 { 674 {
678 /* pin-controller instance 0 data */ 675 /* pin-controller instance 0 data */
679 .pin_banks = s5pv210_pin_bank, 676 .pin_banks = s5pv210_pin_bank,
@@ -720,7 +717,7 @@ static struct samsung_pin_bank exynos3250_pin_banks1[] = {
720 * Samsung pinctrl driver data for Exynos3250 SoC. Exynos3250 SoC includes 717 * Samsung pinctrl driver data for Exynos3250 SoC. Exynos3250 SoC includes
721 * two gpio/pin-mux/pinconfig controllers. 718 * two gpio/pin-mux/pinconfig controllers.
722 */ 719 */
723struct samsung_pin_ctrl exynos3250_pin_ctrl[] = { 720const struct samsung_pin_ctrl exynos3250_pin_ctrl[] __initconst = {
724 { 721 {
725 /* pin-controller instance 0 data */ 722 /* pin-controller instance 0 data */
726 .pin_banks = exynos3250_pin_banks0, 723 .pin_banks = exynos3250_pin_banks0,
@@ -792,7 +789,7 @@ static struct samsung_pin_bank exynos4210_pin_banks2[] = {
792 * Samsung pinctrl driver data for Exynos4210 SoC. Exynos4210 SoC includes 789 * Samsung pinctrl driver data for Exynos4210 SoC. Exynos4210 SoC includes
793 * three gpio/pin-mux/pinconfig controllers. 790 * three gpio/pin-mux/pinconfig controllers.
794 */ 791 */
795struct samsung_pin_ctrl exynos4210_pin_ctrl[] = { 792const struct samsung_pin_ctrl exynos4210_pin_ctrl[] __initconst = {
796 { 793 {
797 /* pin-controller instance 0 data */ 794 /* pin-controller instance 0 data */
798 .pin_banks = exynos4210_pin_banks0, 795 .pin_banks = exynos4210_pin_banks0,
@@ -877,7 +874,7 @@ static struct samsung_pin_bank exynos4x12_pin_banks3[] = {
877 * Samsung pinctrl driver data for Exynos4x12 SoC. Exynos4x12 SoC includes 874 * Samsung pinctrl driver data for Exynos4x12 SoC. Exynos4x12 SoC includes
878 * four gpio/pin-mux/pinconfig controllers. 875 * four gpio/pin-mux/pinconfig controllers.
879 */ 876 */
880struct samsung_pin_ctrl exynos4x12_pin_ctrl[] = { 877const struct samsung_pin_ctrl exynos4x12_pin_ctrl[] __initconst = {
881 { 878 {
882 /* pin-controller instance 0 data */ 879 /* pin-controller instance 0 data */
883 .pin_banks = exynos4x12_pin_banks0, 880 .pin_banks = exynos4x12_pin_banks0,
@@ -970,7 +967,7 @@ static struct samsung_pin_bank exynos5250_pin_banks3[] = {
970 * Samsung pinctrl driver data for Exynos5250 SoC. Exynos5250 SoC includes 967 * Samsung pinctrl driver data for Exynos5250 SoC. Exynos5250 SoC includes
971 * four gpio/pin-mux/pinconfig controllers. 968 * four gpio/pin-mux/pinconfig controllers.
972 */ 969 */
973struct samsung_pin_ctrl exynos5250_pin_ctrl[] = { 970const struct samsung_pin_ctrl exynos5250_pin_ctrl[] __initconst = {
974 { 971 {
975 /* pin-controller instance 0 data */ 972 /* pin-controller instance 0 data */
976 .pin_banks = exynos5250_pin_banks0, 973 .pin_banks = exynos5250_pin_banks0,
@@ -1047,7 +1044,7 @@ static struct samsung_pin_bank exynos5260_pin_banks2[] = {
1047 * Samsung pinctrl driver data for Exynos5260 SoC. Exynos5260 SoC includes 1044 * Samsung pinctrl driver data for Exynos5260 SoC. Exynos5260 SoC includes
1048 * three gpio/pin-mux/pinconfig controllers. 1045 * three gpio/pin-mux/pinconfig controllers.
1049 */ 1046 */
1050struct samsung_pin_ctrl exynos5260_pin_ctrl[] = { 1047const struct samsung_pin_ctrl exynos5260_pin_ctrl[] __initconst = {
1051 { 1048 {
1052 /* pin-controller instance 0 data */ 1049 /* pin-controller instance 0 data */
1053 .pin_banks = exynos5260_pin_banks0, 1050 .pin_banks = exynos5260_pin_banks0,
@@ -1127,7 +1124,7 @@ static struct samsung_pin_bank exynos5420_pin_banks4[] = {
1127 * Samsung pinctrl driver data for Exynos5420 SoC. Exynos5420 SoC includes 1124 * Samsung pinctrl driver data for Exynos5420 SoC. Exynos5420 SoC includes
1128 * four gpio/pin-mux/pinconfig controllers. 1125 * four gpio/pin-mux/pinconfig controllers.
1129 */ 1126 */
1130struct samsung_pin_ctrl exynos5420_pin_ctrl[] = { 1127const struct samsung_pin_ctrl exynos5420_pin_ctrl[] __initconst = {
1131 { 1128 {
1132 /* pin-controller instance 0 data */ 1129 /* pin-controller instance 0 data */
1133 .pin_banks = exynos5420_pin_banks0, 1130 .pin_banks = exynos5420_pin_banks0,
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
index 9db6cf5c8823..c0c7924657e6 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c24xx.c
@@ -518,8 +518,8 @@ static int s3c24xx_eint_init(struct samsung_pinctrl_drv_data *d)
518 irq_set_handler_data(irq, eint_data); 518 irq_set_handler_data(irq, eint_data);
519 } 519 }
520 520
521 bank = d->ctrl->pin_banks; 521 bank = d->pin_banks;
522 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 522 for (i = 0; i < d->nr_banks; ++i, ++bank) {
523 struct s3c24xx_eint_domain_data *ddata; 523 struct s3c24xx_eint_domain_data *ddata;
524 unsigned int mask; 524 unsigned int mask;
525 unsigned int irq; 525 unsigned int irq;
@@ -573,7 +573,7 @@ static struct samsung_pin_bank s3c2412_pin_banks[] = {
573 PIN_BANK_2BIT(13, 0x080, "gpj"), 573 PIN_BANK_2BIT(13, 0x080, "gpj"),
574}; 574};
575 575
576struct samsung_pin_ctrl s3c2412_pin_ctrl[] = { 576const struct samsung_pin_ctrl s3c2412_pin_ctrl[] __initconst = {
577 { 577 {
578 .pin_banks = s3c2412_pin_banks, 578 .pin_banks = s3c2412_pin_banks,
579 .nr_banks = ARRAY_SIZE(s3c2412_pin_banks), 579 .nr_banks = ARRAY_SIZE(s3c2412_pin_banks),
@@ -595,7 +595,7 @@ static struct samsung_pin_bank s3c2416_pin_banks[] = {
595 PIN_BANK_2BIT(2, 0x100, "gpm"), 595 PIN_BANK_2BIT(2, 0x100, "gpm"),
596}; 596};
597 597
598struct samsung_pin_ctrl s3c2416_pin_ctrl[] = { 598const struct samsung_pin_ctrl s3c2416_pin_ctrl[] __initconst = {
599 { 599 {
600 .pin_banks = s3c2416_pin_banks, 600 .pin_banks = s3c2416_pin_banks,
601 .nr_banks = ARRAY_SIZE(s3c2416_pin_banks), 601 .nr_banks = ARRAY_SIZE(s3c2416_pin_banks),
@@ -615,7 +615,7 @@ static struct samsung_pin_bank s3c2440_pin_banks[] = {
615 PIN_BANK_2BIT(13, 0x0d0, "gpj"), 615 PIN_BANK_2BIT(13, 0x0d0, "gpj"),
616}; 616};
617 617
618struct samsung_pin_ctrl s3c2440_pin_ctrl[] = { 618const struct samsung_pin_ctrl s3c2440_pin_ctrl[] __initconst = {
619 { 619 {
620 .pin_banks = s3c2440_pin_banks, 620 .pin_banks = s3c2440_pin_banks,
621 .nr_banks = ARRAY_SIZE(s3c2440_pin_banks), 621 .nr_banks = ARRAY_SIZE(s3c2440_pin_banks),
@@ -638,7 +638,7 @@ static struct samsung_pin_bank s3c2450_pin_banks[] = {
638 PIN_BANK_2BIT(2, 0x100, "gpm"), 638 PIN_BANK_2BIT(2, 0x100, "gpm"),
639}; 639};
640 640
641struct samsung_pin_ctrl s3c2450_pin_ctrl[] = { 641const struct samsung_pin_ctrl s3c2450_pin_ctrl[] __initconst = {
642 { 642 {
643 .pin_banks = s3c2450_pin_banks, 643 .pin_banks = s3c2450_pin_banks,
644 .nr_banks = ARRAY_SIZE(s3c2450_pin_banks), 644 .nr_banks = ARRAY_SIZE(s3c2450_pin_banks),
diff --git a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
index 2a14db2826d8..14c3f9823cc5 100644
--- a/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
+++ b/drivers/pinctrl/samsung/pinctrl-s3c64xx.c
@@ -468,8 +468,8 @@ static int s3c64xx_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
468 } 468 }
469 469
470 nr_domains = 0; 470 nr_domains = 0;
471 bank = d->ctrl->pin_banks; 471 bank = d->pin_banks;
472 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 472 for (i = 0; i < d->nr_banks; ++i, ++bank) {
473 unsigned int nr_eints; 473 unsigned int nr_eints;
474 unsigned int mask; 474 unsigned int mask;
475 475
@@ -497,9 +497,9 @@ static int s3c64xx_eint_gpio_init(struct samsung_pinctrl_drv_data *d)
497 } 497 }
498 data->drvdata = d; 498 data->drvdata = d;
499 499
500 bank = d->ctrl->pin_banks; 500 bank = d->pin_banks;
501 nr_domains = 0; 501 nr_domains = 0;
502 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 502 for (i = 0; i < d->nr_banks; ++i, ++bank) {
503 if (bank->eint_type != EINT_TYPE_GPIO) 503 if (bank->eint_type != EINT_TYPE_GPIO)
504 continue; 504 continue;
505 505
@@ -735,8 +735,8 @@ static int s3c64xx_eint_eint0_init(struct samsung_pinctrl_drv_data *d)
735 irq_set_handler_data(irq, data); 735 irq_set_handler_data(irq, data);
736 } 736 }
737 737
738 bank = d->ctrl->pin_banks; 738 bank = d->pin_banks;
739 for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { 739 for (i = 0; i < d->nr_banks; ++i, ++bank) {
740 struct s3c64xx_eint0_domain_data *ddata; 740 struct s3c64xx_eint0_domain_data *ddata;
741 unsigned int nr_eints; 741 unsigned int nr_eints;
742 unsigned int mask; 742 unsigned int mask;
@@ -804,7 +804,7 @@ static struct samsung_pin_bank s3c64xx_pin_banks0[] = {
804 * Samsung pinctrl driver data for S3C64xx SoC. S3C64xx SoC includes 804 * Samsung pinctrl driver data for S3C64xx SoC. S3C64xx SoC includes
805 * one gpio/pin-mux/pinconfig controller. 805 * one gpio/pin-mux/pinconfig controller.
806 */ 806 */
807struct samsung_pin_ctrl s3c64xx_pin_ctrl[] = { 807const struct samsung_pin_ctrl s3c64xx_pin_ctrl[] __initconst = {
808 { 808 {
809 /* pin-controller instance 1 data */ 809 /* pin-controller instance 1 data */
810 .pin_banks = s3c64xx_pin_banks0, 810 .pin_banks = s3c64xx_pin_banks0,
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index 63a97f1d8a21..6e14811d1316 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -349,7 +349,7 @@ static void pin_to_reg_bank(struct samsung_pinctrl_drv_data *drvdata,
349{ 349{
350 struct samsung_pin_bank *b; 350 struct samsung_pin_bank *b;
351 351
352 b = drvdata->ctrl->pin_banks; 352 b = drvdata->pin_banks;
353 353
354 while ((pin >= b->pin_base) && 354 while ((pin >= b->pin_base) &&
355 ((b->pin_base + b->nr_pins - 1) < pin)) 355 ((b->pin_base + b->nr_pins - 1) < pin))
@@ -378,7 +378,7 @@ static void samsung_pinmux_setup(struct pinctrl_dev *pctldev, unsigned selector,
378 func = &drvdata->pmx_functions[selector]; 378 func = &drvdata->pmx_functions[selector];
379 grp = &drvdata->pin_groups[group]; 379 grp = &drvdata->pin_groups[group];
380 380
381 pin_to_reg_bank(drvdata, grp->pins[0] - drvdata->ctrl->base, 381 pin_to_reg_bank(drvdata, grp->pins[0] - drvdata->pin_base,
382 &reg, &pin_offset, &bank); 382 &reg, &pin_offset, &bank);
383 type = bank->type; 383 type = bank->type;
384 mask = (1 << type->fld_width[PINCFG_TYPE_FUNC]) - 1; 384 mask = (1 << type->fld_width[PINCFG_TYPE_FUNC]) - 1;
@@ -431,7 +431,7 @@ static int samsung_pinconf_rw(struct pinctrl_dev *pctldev, unsigned int pin,
431 unsigned long flags; 431 unsigned long flags;
432 432
433 drvdata = pinctrl_dev_get_drvdata(pctldev); 433 drvdata = pinctrl_dev_get_drvdata(pctldev);
434 pin_to_reg_bank(drvdata, pin - drvdata->ctrl->base, &reg_base, 434 pin_to_reg_bank(drvdata, pin - drvdata->pin_base, &reg_base,
435 &pin_offset, &bank); 435 &pin_offset, &bank);
436 type = bank->type; 436 type = bank->type;
437 437
@@ -834,32 +834,32 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
834 ctrldesc->confops = &samsung_pinconf_ops; 834 ctrldesc->confops = &samsung_pinconf_ops;
835 835
836 pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * 836 pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
837 drvdata->ctrl->nr_pins, GFP_KERNEL); 837 drvdata->nr_pins, GFP_KERNEL);
838 if (!pindesc) { 838 if (!pindesc) {
839 dev_err(&pdev->dev, "mem alloc for pin descriptors failed\n"); 839 dev_err(&pdev->dev, "mem alloc for pin descriptors failed\n");
840 return -ENOMEM; 840 return -ENOMEM;
841 } 841 }
842 ctrldesc->pins = pindesc; 842 ctrldesc->pins = pindesc;
843 ctrldesc->npins = drvdata->ctrl->nr_pins; 843 ctrldesc->npins = drvdata->nr_pins;
844 844
845 /* dynamically populate the pin number and pin name for pindesc */ 845 /* dynamically populate the pin number and pin name for pindesc */
846 for (pin = 0, pdesc = pindesc; pin < ctrldesc->npins; pin++, pdesc++) 846 for (pin = 0, pdesc = pindesc; pin < ctrldesc->npins; pin++, pdesc++)
847 pdesc->number = pin + drvdata->ctrl->base; 847 pdesc->number = pin + drvdata->pin_base;
848 848
849 /* 849 /*
850 * allocate space for storing the dynamically generated names for all 850 * allocate space for storing the dynamically generated names for all
851 * the pins which belong to this pin-controller. 851 * the pins which belong to this pin-controller.
852 */ 852 */
853 pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH * 853 pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH *
854 drvdata->ctrl->nr_pins, GFP_KERNEL); 854 drvdata->nr_pins, GFP_KERNEL);
855 if (!pin_names) { 855 if (!pin_names) {
856 dev_err(&pdev->dev, "mem alloc for pin names failed\n"); 856 dev_err(&pdev->dev, "mem alloc for pin names failed\n");
857 return -ENOMEM; 857 return -ENOMEM;
858 } 858 }
859 859
860 /* for each pin, the name of the pin is pin-bank name + pin number */ 860 /* for each pin, the name of the pin is pin-bank name + pin number */
861 for (bank = 0; bank < drvdata->ctrl->nr_banks; bank++) { 861 for (bank = 0; bank < drvdata->nr_banks; bank++) {
862 pin_bank = &drvdata->ctrl->pin_banks[bank]; 862 pin_bank = &drvdata->pin_banks[bank];
863 for (pin = 0; pin < pin_bank->nr_pins; pin++) { 863 for (pin = 0; pin < pin_bank->nr_pins; pin++) {
864 sprintf(pin_names, "%s-%d", pin_bank->name, pin); 864 sprintf(pin_names, "%s-%d", pin_bank->name, pin);
865 pdesc = pindesc + pin_bank->pin_base + pin; 865 pdesc = pindesc + pin_bank->pin_base + pin;
@@ -878,11 +878,11 @@ static int samsung_pinctrl_register(struct platform_device *pdev,
878 return -EINVAL; 878 return -EINVAL;
879 } 879 }
880 880
881 for (bank = 0; bank < drvdata->ctrl->nr_banks; ++bank) { 881 for (bank = 0; bank < drvdata->nr_banks; ++bank) {
882 pin_bank = &drvdata->ctrl->pin_banks[bank]; 882 pin_bank = &drvdata->pin_banks[bank];
883 pin_bank->grange.name = pin_bank->name; 883 pin_bank->grange.name = pin_bank->name;
884 pin_bank->grange.id = bank; 884 pin_bank->grange.id = bank;
885 pin_bank->grange.pin_base = drvdata->ctrl->base 885 pin_bank->grange.pin_base = drvdata->pin_base
886 + pin_bank->pin_base; 886 + pin_bank->pin_base;
887 pin_bank->grange.base = pin_bank->gpio_chip.base; 887 pin_bank->grange.base = pin_bank->gpio_chip.base;
888 pin_bank->grange.npins = pin_bank->gpio_chip.ngpio; 888 pin_bank->grange.npins = pin_bank->gpio_chip.ngpio;
@@ -918,17 +918,16 @@ static const struct gpio_chip samsung_gpiolib_chip = {
918static int samsung_gpiolib_register(struct platform_device *pdev, 918static int samsung_gpiolib_register(struct platform_device *pdev,
919 struct samsung_pinctrl_drv_data *drvdata) 919 struct samsung_pinctrl_drv_data *drvdata)
920{ 920{
921 struct samsung_pin_ctrl *ctrl = drvdata->ctrl; 921 struct samsung_pin_bank *bank = drvdata->pin_banks;
922 struct samsung_pin_bank *bank = ctrl->pin_banks;
923 struct gpio_chip *gc; 922 struct gpio_chip *gc;
924 int ret; 923 int ret;
925 int i; 924 int i;
926 925
927 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { 926 for (i = 0; i < drvdata->nr_banks; ++i, ++bank) {
928 bank->gpio_chip = samsung_gpiolib_chip; 927 bank->gpio_chip = samsung_gpiolib_chip;
929 928
930 gc = &bank->gpio_chip; 929 gc = &bank->gpio_chip;
931 gc->base = ctrl->base + bank->pin_base; 930 gc->base = drvdata->pin_base + bank->pin_base;
932 gc->ngpio = bank->nr_pins; 931 gc->ngpio = bank->nr_pins;
933 gc->dev = &pdev->dev; 932 gc->dev = &pdev->dev;
934 gc->of_node = bank->of_node; 933 gc->of_node = bank->of_node;
@@ -954,27 +953,27 @@ fail:
954static int samsung_gpiolib_unregister(struct platform_device *pdev, 953static int samsung_gpiolib_unregister(struct platform_device *pdev,
955 struct samsung_pinctrl_drv_data *drvdata) 954 struct samsung_pinctrl_drv_data *drvdata)
956{ 955{
957 struct samsung_pin_ctrl *ctrl = drvdata->ctrl; 956 struct samsung_pin_bank *bank = drvdata->pin_banks;
958 struct samsung_pin_bank *bank = ctrl->pin_banks;
959 int i; 957 int i;
960 958
961 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) 959 for (i = 0; i < drvdata->nr_banks; ++i, ++bank)
962 gpiochip_remove(&bank->gpio_chip); 960 gpiochip_remove(&bank->gpio_chip);
961
963 return 0; 962 return 0;
964} 963}
965 964
966static const struct of_device_id samsung_pinctrl_dt_match[]; 965static const struct of_device_id samsung_pinctrl_dt_match[];
967 966
968/* retrieve the soc specific data */ 967/* retrieve the soc specific data */
969static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data( 968static const struct samsung_pin_ctrl *
970 struct samsung_pinctrl_drv_data *d, 969samsung_pinctrl_get_soc_data(struct samsung_pinctrl_drv_data *d,
971 struct platform_device *pdev) 970 struct platform_device *pdev)
972{ 971{
973 int id; 972 int id;
974 const struct of_device_id *match; 973 const struct of_device_id *match;
975 struct device_node *node = pdev->dev.of_node; 974 struct device_node *node = pdev->dev.of_node;
976 struct device_node *np; 975 struct device_node *np;
977 struct samsung_pin_ctrl *ctrl; 976 const struct samsung_pin_ctrl *ctrl;
978 struct samsung_pin_bank *bank; 977 struct samsung_pin_bank *bank;
979 int i; 978 int i;
980 979
@@ -986,19 +985,24 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
986 match = of_match_node(samsung_pinctrl_dt_match, node); 985 match = of_match_node(samsung_pinctrl_dt_match, node);
987 ctrl = (struct samsung_pin_ctrl *)match->data + id; 986 ctrl = (struct samsung_pin_ctrl *)match->data + id;
988 987
989 bank = ctrl->pin_banks; 988 d->suspend = ctrl->suspend;
990 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { 989 d->resume = ctrl->resume;
990 d->pin_banks = ctrl->pin_banks;
991 d->nr_banks = ctrl->nr_banks;
992
993 bank = d->pin_banks;
994 for (i = 0; i < d->nr_banks; ++i, ++bank) {
991 spin_lock_init(&bank->slock); 995 spin_lock_init(&bank->slock);
992 bank->drvdata = d; 996 bank->drvdata = d;
993 bank->pin_base = ctrl->nr_pins; 997 bank->pin_base = d->nr_pins;
994 ctrl->nr_pins += bank->nr_pins; 998 d->nr_pins += bank->nr_pins;
995 } 999 }
996 1000
997 for_each_child_of_node(node, np) { 1001 for_each_child_of_node(node, np) {
998 if (!of_find_property(np, "gpio-controller", NULL)) 1002 if (!of_find_property(np, "gpio-controller", NULL))
999 continue; 1003 continue;
1000 bank = ctrl->pin_banks; 1004 bank = d->pin_banks;
1001 for (i = 0; i < ctrl->nr_banks; ++i, ++bank) { 1005 for (i = 0; i < d->nr_banks; ++i, ++bank) {
1002 if (!strcmp(bank->name, np->name)) { 1006 if (!strcmp(bank->name, np->name)) {
1003 bank->of_node = np; 1007 bank->of_node = np;
1004 break; 1008 break;
@@ -1006,8 +1010,8 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
1006 } 1010 }
1007 } 1011 }
1008 1012
1009 ctrl->base = pin_base; 1013 d->pin_base = pin_base;
1010 pin_base += ctrl->nr_pins; 1014 pin_base += d->nr_pins;
1011 1015
1012 return ctrl; 1016 return ctrl;
1013} 1017}
@@ -1015,8 +1019,8 @@ static struct samsung_pin_ctrl *samsung_pinctrl_get_soc_data(
1015static int samsung_pinctrl_probe(struct platform_device *pdev) 1019static int samsung_pinctrl_probe(struct platform_device *pdev)
1016{ 1020{
1017 struct samsung_pinctrl_drv_data *drvdata; 1021 struct samsung_pinctrl_drv_data *drvdata;
1022 const struct samsung_pin_ctrl *ctrl;
1018 struct device *dev = &pdev->dev; 1023 struct device *dev = &pdev->dev;
1019 struct samsung_pin_ctrl *ctrl;
1020 struct resource *res; 1024 struct resource *res;
1021 int ret; 1025 int ret;
1022 1026
@@ -1037,7 +1041,6 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
1037 dev_err(&pdev->dev, "driver data not available\n"); 1041 dev_err(&pdev->dev, "driver data not available\n");
1038 return PTR_ERR(ctrl); 1042 return PTR_ERR(ctrl);
1039 } 1043 }
1040 drvdata->ctrl = ctrl;
1041 drvdata->dev = dev; 1044 drvdata->dev = dev;
1042 1045
1043 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1046 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1082,12 +1085,11 @@ static int samsung_pinctrl_probe(struct platform_device *pdev)
1082static void samsung_pinctrl_suspend_dev( 1085static void samsung_pinctrl_suspend_dev(
1083 struct samsung_pinctrl_drv_data *drvdata) 1086 struct samsung_pinctrl_drv_data *drvdata)
1084{ 1087{
1085 struct samsung_pin_ctrl *ctrl = drvdata->ctrl;
1086 void __iomem *virt_base = drvdata->virt_base; 1088 void __iomem *virt_base = drvdata->virt_base;
1087 int i; 1089 int i;
1088 1090
1089 for (i = 0; i < ctrl->nr_banks; i++) { 1091 for (i = 0; i < drvdata->nr_banks; i++) {
1090 struct samsung_pin_bank *bank = &ctrl->pin_banks[i]; 1092 struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
1091 void __iomem *reg = virt_base + bank->pctl_offset; 1093 void __iomem *reg = virt_base + bank->pctl_offset;
1092 const u8 *offs = bank->type->reg_offset; 1094 const u8 *offs = bank->type->reg_offset;
1093 const u8 *widths = bank->type->fld_width; 1095 const u8 *widths = bank->type->fld_width;
@@ -1115,8 +1117,8 @@ static void samsung_pinctrl_suspend_dev(
1115 } 1117 }
1116 } 1118 }
1117 1119
1118 if (ctrl->suspend) 1120 if (drvdata->suspend)
1119 ctrl->suspend(drvdata); 1121 drvdata->suspend(drvdata);
1120} 1122}
1121 1123
1122/** 1124/**
@@ -1129,15 +1131,14 @@ static void samsung_pinctrl_suspend_dev(
1129 */ 1131 */
1130static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata) 1132static void samsung_pinctrl_resume_dev(struct samsung_pinctrl_drv_data *drvdata)
1131{ 1133{
1132 struct samsung_pin_ctrl *ctrl = drvdata->ctrl;
1133 void __iomem *virt_base = drvdata->virt_base; 1134 void __iomem *virt_base = drvdata->virt_base;
1134 int i; 1135 int i;
1135 1136
1136 if (ctrl->resume) 1137 if (drvdata->resume)
1137 ctrl->resume(drvdata); 1138 drvdata->resume(drvdata);
1138 1139
1139 for (i = 0; i < ctrl->nr_banks; i++) { 1140 for (i = 0; i < drvdata->nr_banks; i++) {
1140 struct samsung_pin_bank *bank = &ctrl->pin_banks[i]; 1141 struct samsung_pin_bank *bank = &drvdata->pin_banks[i];
1141 void __iomem *reg = virt_base + bank->pctl_offset; 1142 void __iomem *reg = virt_base + bank->pctl_offset;
1142 const u8 *offs = bank->type->reg_offset; 1143 const u8 *offs = bank->type->reg_offset;
1143 const u8 *widths = bank->type->fld_width; 1144 const u8 *widths = bank->type->fld_width;
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.h b/drivers/pinctrl/samsung/pinctrl-samsung.h
index c67738597d2a..cf2d61d0f001 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.h
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.h
@@ -155,8 +155,6 @@ struct samsung_pin_bank {
155 * struct samsung_pin_ctrl: represent a pin controller. 155 * struct samsung_pin_ctrl: represent a pin controller.
156 * @pin_banks: list of pin banks included in this controller. 156 * @pin_banks: list of pin banks included in this controller.
157 * @nr_banks: number of pin banks. 157 * @nr_banks: number of pin banks.
158 * @base: starting system wide pin number.
159 * @nr_pins: number of pins supported by the controller.
160 * @eint_gpio_init: platform specific callback to setup the external gpio 158 * @eint_gpio_init: platform specific callback to setup the external gpio
161 * interrupts for the controller. 159 * interrupts for the controller.
162 * @eint_wkup_init: platform specific callback to setup the external wakeup 160 * @eint_wkup_init: platform specific callback to setup the external wakeup
@@ -166,9 +164,6 @@ struct samsung_pin_ctrl {
166 struct samsung_pin_bank *pin_banks; 164 struct samsung_pin_bank *pin_banks;
167 u32 nr_banks; 165 u32 nr_banks;
168 166
169 u32 base;
170 u32 nr_pins;
171
172 int (*eint_gpio_init)(struct samsung_pinctrl_drv_data *); 167 int (*eint_gpio_init)(struct samsung_pinctrl_drv_data *);
173 int (*eint_wkup_init)(struct samsung_pinctrl_drv_data *); 168 int (*eint_wkup_init)(struct samsung_pinctrl_drv_data *);
174 void (*suspend)(struct samsung_pinctrl_drv_data *); 169 void (*suspend)(struct samsung_pinctrl_drv_data *);
@@ -188,6 +183,8 @@ struct samsung_pin_ctrl {
188 * @nr_groups: number of such pin groups. 183 * @nr_groups: number of such pin groups.
189 * @pmx_functions: list of pin functions available to the driver. 184 * @pmx_functions: list of pin functions available to the driver.
190 * @nr_function: number of such pin functions. 185 * @nr_function: number of such pin functions.
186 * @pin_base: starting system wide pin number.
187 * @nr_pins: number of pins supported by the controller.
191 */ 188 */
192struct samsung_pinctrl_drv_data { 189struct samsung_pinctrl_drv_data {
193 struct list_head node; 190 struct list_head node;
@@ -195,7 +192,6 @@ struct samsung_pinctrl_drv_data {
195 struct device *dev; 192 struct device *dev;
196 int irq; 193 int irq;
197 194
198 struct samsung_pin_ctrl *ctrl;
199 struct pinctrl_desc pctl; 195 struct pinctrl_desc pctl;
200 struct pinctrl_dev *pctl_dev; 196 struct pinctrl_dev *pctl_dev;
201 197
@@ -203,6 +199,14 @@ struct samsung_pinctrl_drv_data {
203 unsigned int nr_groups; 199 unsigned int nr_groups;
204 const struct samsung_pmx_func *pmx_functions; 200 const struct samsung_pmx_func *pmx_functions;
205 unsigned int nr_functions; 201 unsigned int nr_functions;
202
203 struct samsung_pin_bank *pin_banks;
204 u32 nr_banks;
205 unsigned int pin_base;
206 unsigned int nr_pins;
207
208 void (*suspend)(struct samsung_pinctrl_drv_data *);
209 void (*resume)(struct samsung_pinctrl_drv_data *);
206}; 210};
207 211
208/** 212/**
@@ -233,17 +237,17 @@ struct samsung_pmx_func {
233}; 237};
234 238
235/* list of all exported SoC specific data */ 239/* list of all exported SoC specific data */
236extern struct samsung_pin_ctrl exynos3250_pin_ctrl[]; 240extern const struct samsung_pin_ctrl exynos3250_pin_ctrl[];
237extern struct samsung_pin_ctrl exynos4210_pin_ctrl[]; 241extern const struct samsung_pin_ctrl exynos4210_pin_ctrl[];
238extern struct samsung_pin_ctrl exynos4x12_pin_ctrl[]; 242extern const struct samsung_pin_ctrl exynos4x12_pin_ctrl[];
239extern struct samsung_pin_ctrl exynos5250_pin_ctrl[]; 243extern const struct samsung_pin_ctrl exynos5250_pin_ctrl[];
240extern struct samsung_pin_ctrl exynos5260_pin_ctrl[]; 244extern const struct samsung_pin_ctrl exynos5260_pin_ctrl[];
241extern struct samsung_pin_ctrl exynos5420_pin_ctrl[]; 245extern const struct samsung_pin_ctrl exynos5420_pin_ctrl[];
242extern struct samsung_pin_ctrl s3c64xx_pin_ctrl[]; 246extern const struct samsung_pin_ctrl s3c64xx_pin_ctrl[];
243extern struct samsung_pin_ctrl s3c2412_pin_ctrl[]; 247extern const struct samsung_pin_ctrl s3c2412_pin_ctrl[];
244extern struct samsung_pin_ctrl s3c2416_pin_ctrl[]; 248extern const struct samsung_pin_ctrl s3c2416_pin_ctrl[];
245extern struct samsung_pin_ctrl s3c2440_pin_ctrl[]; 249extern const struct samsung_pin_ctrl s3c2440_pin_ctrl[];
246extern struct samsung_pin_ctrl s3c2450_pin_ctrl[]; 250extern const struct samsung_pin_ctrl s3c2450_pin_ctrl[];
247extern struct samsung_pin_ctrl s5pv210_pin_ctrl[]; 251extern const struct samsung_pin_ctrl s5pv210_pin_ctrl[];
248 252
249#endif /* __PINCTRL_SAMSUNG_H */ 253#endif /* __PINCTRL_SAMSUNG_H */