aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMagnus Damm <damm@opensource.se>2010-02-08 23:24:46 -0500
committerPaul Mundt <lethal@linux-sh.org>2010-02-09 04:23:57 -0500
commit577cd7584cf5199f1ea22cca0ad1fa129a98effa (patch)
tree35a88578e4dc1da2df4bb8b14e8ef6f010819223
parent6339204ecc2aa2067a99595522de0403f0854bb8 (diff)
sh: extend INTC with struct intc_hw_desc
This patch updates the INTC code by moving all vectors, groups and registers from struct intc_desc to struct intc_hw_desc. The idea is that INTC tables should go from using the macro(s) DECLARE_INTC_DESC..() only to using struct intc_desc with name and hw initialized using the macro INTC_HW_DESC(). This move makes it easy to initialize an extended struct intc_desc in the future. Signed-off-by: Magnus Damm <damm@opensource.se> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
-rw-r--r--drivers/sh/intc.c88
-rw-r--r--include/linux/sh_intc.h31
2 files changed, 65 insertions, 54 deletions
diff --git a/drivers/sh/intc.c b/drivers/sh/intc.c
index d5d7f23c19a5..5ec0fffa7db4 100644
--- a/drivers/sh/intc.c
+++ b/drivers/sh/intc.c
@@ -400,11 +400,11 @@ static unsigned int __init intc_get_reg(struct intc_desc_int *d,
400static intc_enum __init intc_grp_id(struct intc_desc *desc, 400static intc_enum __init intc_grp_id(struct intc_desc *desc,
401 intc_enum enum_id) 401 intc_enum enum_id)
402{ 402{
403 struct intc_group *g = desc->groups; 403 struct intc_group *g = desc->hw.groups;
404 unsigned int i, j; 404 unsigned int i, j;
405 405
406 for (i = 0; g && enum_id && i < desc->nr_groups; i++) { 406 for (i = 0; g && enum_id && i < desc->hw.nr_groups; i++) {
407 g = desc->groups + i; 407 g = desc->hw.groups + i;
408 408
409 for (j = 0; g->enum_ids[j]; j++) { 409 for (j = 0; g->enum_ids[j]; j++) {
410 if (g->enum_ids[j] != enum_id) 410 if (g->enum_ids[j] != enum_id)
@@ -421,12 +421,12 @@ static unsigned int __init intc_mask_data(struct intc_desc *desc,
421 struct intc_desc_int *d, 421 struct intc_desc_int *d,
422 intc_enum enum_id, int do_grps) 422 intc_enum enum_id, int do_grps)
423{ 423{
424 struct intc_mask_reg *mr = desc->mask_regs; 424 struct intc_mask_reg *mr = desc->hw.mask_regs;
425 unsigned int i, j, fn, mode; 425 unsigned int i, j, fn, mode;
426 unsigned long reg_e, reg_d; 426 unsigned long reg_e, reg_d;
427 427
428 for (i = 0; mr && enum_id && i < desc->nr_mask_regs; i++) { 428 for (i = 0; mr && enum_id && i < desc->hw.nr_mask_regs; i++) {
429 mr = desc->mask_regs + i; 429 mr = desc->hw.mask_regs + i;
430 430
431 for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) { 431 for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) {
432 if (mr->enum_ids[j] != enum_id) 432 if (mr->enum_ids[j] != enum_id)
@@ -469,12 +469,12 @@ static unsigned int __init intc_prio_data(struct intc_desc *desc,
469 struct intc_desc_int *d, 469 struct intc_desc_int *d,
470 intc_enum enum_id, int do_grps) 470 intc_enum enum_id, int do_grps)
471{ 471{
472 struct intc_prio_reg *pr = desc->prio_regs; 472 struct intc_prio_reg *pr = desc->hw.prio_regs;
473 unsigned int i, j, fn, mode, bit; 473 unsigned int i, j, fn, mode, bit;
474 unsigned long reg_e, reg_d; 474 unsigned long reg_e, reg_d;
475 475
476 for (i = 0; pr && enum_id && i < desc->nr_prio_regs; i++) { 476 for (i = 0; pr && enum_id && i < desc->hw.nr_prio_regs; i++) {
477 pr = desc->prio_regs + i; 477 pr = desc->hw.prio_regs + i;
478 478
479 for (j = 0; j < ARRAY_SIZE(pr->enum_ids); j++) { 479 for (j = 0; j < ARRAY_SIZE(pr->enum_ids); j++) {
480 if (pr->enum_ids[j] != enum_id) 480 if (pr->enum_ids[j] != enum_id)
@@ -517,12 +517,12 @@ static unsigned int __init intc_ack_data(struct intc_desc *desc,
517 struct intc_desc_int *d, 517 struct intc_desc_int *d,
518 intc_enum enum_id) 518 intc_enum enum_id)
519{ 519{
520 struct intc_mask_reg *mr = desc->ack_regs; 520 struct intc_mask_reg *mr = desc->hw.ack_regs;
521 unsigned int i, j, fn, mode; 521 unsigned int i, j, fn, mode;
522 unsigned long reg_e, reg_d; 522 unsigned long reg_e, reg_d;
523 523
524 for (i = 0; mr && enum_id && i < desc->nr_ack_regs; i++) { 524 for (i = 0; mr && enum_id && i < desc->hw.nr_ack_regs; i++) {
525 mr = desc->ack_regs + i; 525 mr = desc->hw.ack_regs + i;
526 526
527 for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) { 527 for (j = 0; j < ARRAY_SIZE(mr->enum_ids); j++) {
528 if (mr->enum_ids[j] != enum_id) 528 if (mr->enum_ids[j] != enum_id)
@@ -549,11 +549,11 @@ static unsigned int __init intc_sense_data(struct intc_desc *desc,
549 struct intc_desc_int *d, 549 struct intc_desc_int *d,
550 intc_enum enum_id) 550 intc_enum enum_id)
551{ 551{
552 struct intc_sense_reg *sr = desc->sense_regs; 552 struct intc_sense_reg *sr = desc->hw.sense_regs;
553 unsigned int i, j, fn, bit; 553 unsigned int i, j, fn, bit;
554 554
555 for (i = 0; sr && enum_id && i < desc->nr_sense_regs; i++) { 555 for (i = 0; sr && enum_id && i < desc->hw.nr_sense_regs; i++) {
556 sr = desc->sense_regs + i; 556 sr = desc->hw.sense_regs + i;
557 557
558 for (j = 0; j < ARRAY_SIZE(sr->enum_ids); j++) { 558 for (j = 0; j < ARRAY_SIZE(sr->enum_ids); j++) {
559 if (sr->enum_ids[j] != enum_id) 559 if (sr->enum_ids[j] != enum_id)
@@ -656,7 +656,7 @@ static void __init intc_register_irq(struct intc_desc *desc,
656 /* irq should be disabled by default */ 656 /* irq should be disabled by default */
657 d->chip.mask(irq); 657 d->chip.mask(irq);
658 658
659 if (desc->ack_regs) 659 if (desc->hw.ack_regs)
660 ack_handle[irq] = intc_ack_data(desc, d, enum_id); 660 ack_handle[irq] = intc_ack_data(desc, d, enum_id);
661} 661}
662 662
@@ -684,6 +684,7 @@ static void intc_redirect_irq(unsigned int irq, struct irq_desc *desc)
684void __init register_intc_controller(struct intc_desc *desc) 684void __init register_intc_controller(struct intc_desc *desc)
685{ 685{
686 unsigned int i, k, smp; 686 unsigned int i, k, smp;
687 struct intc_hw_desc *hw = &desc->hw;
687 struct intc_desc_int *d; 688 struct intc_desc_int *d;
688 689
689 d = kzalloc(sizeof(*d), GFP_NOWAIT); 690 d = kzalloc(sizeof(*d), GFP_NOWAIT);
@@ -691,10 +692,10 @@ void __init register_intc_controller(struct intc_desc *desc)
691 INIT_LIST_HEAD(&d->list); 692 INIT_LIST_HEAD(&d->list);
692 list_add(&d->list, &intc_list); 693 list_add(&d->list, &intc_list);
693 694
694 d->nr_reg = desc->mask_regs ? desc->nr_mask_regs * 2 : 0; 695 d->nr_reg = hw->mask_regs ? hw->nr_mask_regs * 2 : 0;
695 d->nr_reg += desc->prio_regs ? desc->nr_prio_regs * 2 : 0; 696 d->nr_reg += hw->prio_regs ? hw->nr_prio_regs * 2 : 0;
696 d->nr_reg += desc->sense_regs ? desc->nr_sense_regs : 0; 697 d->nr_reg += hw->sense_regs ? hw->nr_sense_regs : 0;
697 d->nr_reg += desc->ack_regs ? desc->nr_ack_regs : 0; 698 d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0;
698 699
699 d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); 700 d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT);
700#ifdef CONFIG_SMP 701#ifdef CONFIG_SMP
@@ -702,30 +703,31 @@ void __init register_intc_controller(struct intc_desc *desc)
702#endif 703#endif
703 k = 0; 704 k = 0;
704 705
705 if (desc->mask_regs) { 706 if (hw->mask_regs) {
706 for (i = 0; i < desc->nr_mask_regs; i++) { 707 for (i = 0; i < hw->nr_mask_regs; i++) {
707 smp = IS_SMP(desc->mask_regs[i]); 708 smp = IS_SMP(hw->mask_regs[i]);
708 k += save_reg(d, k, desc->mask_regs[i].set_reg, smp); 709 k += save_reg(d, k, hw->mask_regs[i].set_reg, smp);
709 k += save_reg(d, k, desc->mask_regs[i].clr_reg, smp); 710 k += save_reg(d, k, hw->mask_regs[i].clr_reg, smp);
710 } 711 }
711 } 712 }
712 713
713 if (desc->prio_regs) { 714 if (hw->prio_regs) {
714 d->prio = kzalloc(desc->nr_vectors * sizeof(*d->prio), GFP_NOWAIT); 715 d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
716 GFP_NOWAIT);
715 717
716 for (i = 0; i < desc->nr_prio_regs; i++) { 718 for (i = 0; i < hw->nr_prio_regs; i++) {
717 smp = IS_SMP(desc->prio_regs[i]); 719 smp = IS_SMP(hw->prio_regs[i]);
718 k += save_reg(d, k, desc->prio_regs[i].set_reg, smp); 720 k += save_reg(d, k, hw->prio_regs[i].set_reg, smp);
719 k += save_reg(d, k, desc->prio_regs[i].clr_reg, smp); 721 k += save_reg(d, k, hw->prio_regs[i].clr_reg, smp);
720 } 722 }
721 } 723 }
722 724
723 if (desc->sense_regs) { 725 if (hw->sense_regs) {
724 d->sense = kzalloc(desc->nr_vectors * sizeof(*d->sense), GFP_NOWAIT); 726 d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
727 GFP_NOWAIT);
725 728
726 for (i = 0; i < desc->nr_sense_regs; i++) { 729 for (i = 0; i < hw->nr_sense_regs; i++)
727 k += save_reg(d, k, desc->sense_regs[i].reg, 0); 730 k += save_reg(d, k, hw->sense_regs[i].reg, 0);
728 }
729 } 731 }
730 732
731 d->chip.name = desc->name; 733 d->chip.name = desc->name;
@@ -738,9 +740,9 @@ void __init register_intc_controller(struct intc_desc *desc)
738 d->chip.set_type = intc_set_sense; 740 d->chip.set_type = intc_set_sense;
739 d->chip.set_wake = intc_set_wake; 741 d->chip.set_wake = intc_set_wake;
740 742
741 if (desc->ack_regs) { 743 if (hw->ack_regs) {
742 for (i = 0; i < desc->nr_ack_regs; i++) 744 for (i = 0; i < hw->nr_ack_regs; i++)
743 k += save_reg(d, k, desc->ack_regs[i].set_reg, 0); 745 k += save_reg(d, k, hw->ack_regs[i].set_reg, 0);
744 746
745 d->chip.mask_ack = intc_mask_ack; 747 d->chip.mask_ack = intc_mask_ack;
746 } 748 }
@@ -748,8 +750,8 @@ void __init register_intc_controller(struct intc_desc *desc)
748 BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */ 750 BUG_ON(k > 256); /* _INTC_ADDR_E() and _INTC_ADDR_D() are 8 bits */
749 751
750 /* register the vectors one by one */ 752 /* register the vectors one by one */
751 for (i = 0; i < desc->nr_vectors; i++) { 753 for (i = 0; i < hw->nr_vectors; i++) {
752 struct intc_vect *vect = desc->vectors + i; 754 struct intc_vect *vect = hw->vectors + i;
753 unsigned int irq = evt2irq(vect->vect); 755 unsigned int irq = evt2irq(vect->vect);
754 struct irq_desc *irq_desc; 756 struct irq_desc *irq_desc;
755 757
@@ -764,8 +766,8 @@ void __init register_intc_controller(struct intc_desc *desc)
764 766
765 intc_register_irq(desc, d, vect->enum_id, irq); 767 intc_register_irq(desc, d, vect->enum_id, irq);
766 768
767 for (k = i + 1; k < desc->nr_vectors; k++) { 769 for (k = i + 1; k < hw->nr_vectors; k++) {
768 struct intc_vect *vect2 = desc->vectors + k; 770 struct intc_vect *vect2 = hw->vectors + k;
769 unsigned int irq2 = evt2irq(vect2->vect); 771 unsigned int irq2 = evt2irq(vect2->vect);
770 772
771 if (vect->enum_id != vect2->enum_id) 773 if (vect->enum_id != vect2->enum_id)
diff --git a/include/linux/sh_intc.h b/include/linux/sh_intc.h
index 4ef246f14654..7b37526bb73f 100644
--- a/include/linux/sh_intc.h
+++ b/include/linux/sh_intc.h
@@ -45,7 +45,7 @@ struct intc_sense_reg {
45#define INTC_SMP(stride, nr) 45#define INTC_SMP(stride, nr)
46#endif 46#endif
47 47
48struct intc_desc { 48struct intc_hw_desc {
49 struct intc_vect *vectors; 49 struct intc_vect *vectors;
50 unsigned int nr_vectors; 50 unsigned int nr_vectors;
51 struct intc_group *groups; 51 struct intc_group *groups;
@@ -56,29 +56,38 @@ struct intc_desc {
56 unsigned int nr_prio_regs; 56 unsigned int nr_prio_regs;
57 struct intc_sense_reg *sense_regs; 57 struct intc_sense_reg *sense_regs;
58 unsigned int nr_sense_regs; 58 unsigned int nr_sense_regs;
59 char *name;
60 struct intc_mask_reg *ack_regs; 59 struct intc_mask_reg *ack_regs;
61 unsigned int nr_ack_regs; 60 unsigned int nr_ack_regs;
62}; 61};
63 62
64#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a) 63#define _INTC_ARRAY(a) a, sizeof(a)/sizeof(*a)
64#define INTC_HW_DESC(vectors, groups, mask_regs, \
65 prio_regs, sense_regs, ack_regs) \
66{ \
67 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \
68 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \
69 _INTC_ARRAY(sense_regs), _INTC_ARRAY(ack_regs), \
70}
71
72struct intc_desc {
73 char *name;
74 struct intc_hw_desc hw;
75};
76
65#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \ 77#define DECLARE_INTC_DESC(symbol, chipname, vectors, groups, \
66 mask_regs, prio_regs, sense_regs) \ 78 mask_regs, prio_regs, sense_regs) \
67struct intc_desc symbol __initdata = { \ 79struct intc_desc symbol __initdata = { \
68 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ 80 .name = chipname, \
69 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ 81 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
70 _INTC_ARRAY(sense_regs), \ 82 prio_regs, sense_regs, NULL), \
71 chipname, \
72} 83}
73 84
74#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \ 85#define DECLARE_INTC_DESC_ACK(symbol, chipname, vectors, groups, \
75 mask_regs, prio_regs, sense_regs, ack_regs) \ 86 mask_regs, prio_regs, sense_regs, ack_regs) \
76struct intc_desc symbol __initdata = { \ 87struct intc_desc symbol __initdata = { \
77 _INTC_ARRAY(vectors), _INTC_ARRAY(groups), \ 88 .name = chipname, \
78 _INTC_ARRAY(mask_regs), _INTC_ARRAY(prio_regs), \ 89 .hw = INTC_HW_DESC(vectors, groups, mask_regs, \
79 _INTC_ARRAY(sense_regs), \ 90 prio_regs, sense_regs, ack_regs), \
80 chipname, \
81 _INTC_ARRAY(ack_regs), \
82} 91}
83 92
84void __init register_intc_controller(struct intc_desc *desc); 93void __init register_intc_controller(struct intc_desc *desc);