diff options
| -rw-r--r-- | drivers/irqchip/irq-mips-gic.c | 68 | ||||
| -rw-r--r-- | include/linux/irqchip/mips-gic.h | 44 |
2 files changed, 12 insertions, 100 deletions
diff --git a/drivers/irqchip/irq-mips-gic.c b/drivers/irqchip/irq-mips-gic.c index 42d7866c6cd5..ff6c2df86fe8 100644 --- a/drivers/irqchip/irq-mips-gic.c +++ b/drivers/irqchip/irq-mips-gic.c | |||
| @@ -45,42 +45,6 @@ DECLARE_BITMAP(ipi_available, GIC_MAX_INTRS); | |||
| 45 | 45 | ||
| 46 | static void __gic_irq_dispatch(void); | 46 | static void __gic_irq_dispatch(void); |
| 47 | 47 | ||
| 48 | static inline u32 gic_read32(unsigned int reg) | ||
| 49 | { | ||
| 50 | return __raw_readl(mips_gic_base + reg); | ||
| 51 | } | ||
| 52 | |||
| 53 | static inline u64 gic_read64(unsigned int reg) | ||
| 54 | { | ||
| 55 | return __raw_readq(mips_gic_base + reg); | ||
| 56 | } | ||
| 57 | |||
| 58 | static inline unsigned long gic_read(unsigned int reg) | ||
| 59 | { | ||
| 60 | if (!mips_cm_is64) | ||
| 61 | return gic_read32(reg); | ||
| 62 | else | ||
| 63 | return gic_read64(reg); | ||
| 64 | } | ||
| 65 | |||
| 66 | static inline void gic_write32(unsigned int reg, u32 val) | ||
| 67 | { | ||
| 68 | return __raw_writel(val, mips_gic_base + reg); | ||
| 69 | } | ||
| 70 | |||
| 71 | static inline void gic_write64(unsigned int reg, u64 val) | ||
| 72 | { | ||
| 73 | return __raw_writeq(val, mips_gic_base + reg); | ||
| 74 | } | ||
| 75 | |||
| 76 | static inline void gic_write(unsigned int reg, unsigned long val) | ||
| 77 | { | ||
| 78 | if (!mips_cm_is64) | ||
| 79 | return gic_write32(reg, (u32)val); | ||
| 80 | else | ||
| 81 | return gic_write64(reg, (u64)val); | ||
| 82 | } | ||
| 83 | |||
| 84 | static bool gic_local_irq_is_routable(int intr) | 48 | static bool gic_local_irq_is_routable(int intr) |
| 85 | { | 49 | { |
| 86 | u32 vpe_ctl; | 50 | u32 vpe_ctl; |
| @@ -89,17 +53,17 @@ static bool gic_local_irq_is_routable(int intr) | |||
| 89 | if (cpu_has_veic) | 53 | if (cpu_has_veic) |
| 90 | return true; | 54 | return true; |
| 91 | 55 | ||
| 92 | vpe_ctl = gic_read32(GIC_REG(VPE_LOCAL, GIC_VPE_CTL)); | 56 | vpe_ctl = read_gic_vl_ctl(); |
| 93 | switch (intr) { | 57 | switch (intr) { |
| 94 | case GIC_LOCAL_INT_TIMER: | 58 | case GIC_LOCAL_INT_TIMER: |
| 95 | return vpe_ctl & GIC_VPE_CTL_TIMER_RTBL_MSK; | 59 | return vpe_ctl & GIC_VX_CTL_TIMER_ROUTABLE; |
| 96 | case GIC_LOCAL_INT_PERFCTR: | 60 | case GIC_LOCAL_INT_PERFCTR: |
| 97 | return vpe_ctl & GIC_VPE_CTL_PERFCNT_RTBL_MSK; | 61 | return vpe_ctl & GIC_VX_CTL_PERFCNT_ROUTABLE; |
| 98 | case GIC_LOCAL_INT_FDC: | 62 | case GIC_LOCAL_INT_FDC: |
| 99 | return vpe_ctl & GIC_VPE_CTL_FDC_RTBL_MSK; | 63 | return vpe_ctl & GIC_VX_CTL_FDC_ROUTABLE; |
| 100 | case GIC_LOCAL_INT_SWINT0: | 64 | case GIC_LOCAL_INT_SWINT0: |
| 101 | case GIC_LOCAL_INT_SWINT1: | 65 | case GIC_LOCAL_INT_SWINT1: |
| 102 | return vpe_ctl & GIC_VPE_CTL_SWINT_RTBL_MSK; | 66 | return vpe_ctl & GIC_VX_CTL_SWINT_ROUTABLE; |
| 103 | default: | 67 | default: |
| 104 | return true; | 68 | return true; |
| 105 | } | 69 | } |
| @@ -111,8 +75,7 @@ static void gic_bind_eic_interrupt(int irq, int set) | |||
| 111 | irq -= GIC_PIN_TO_VEC_OFFSET; | 75 | irq -= GIC_PIN_TO_VEC_OFFSET; |
| 112 | 76 | ||
| 113 | /* Set irq to use shadow set */ | 77 | /* Set irq to use shadow set */ |
| 114 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_EIC_SHADOW_SET_BASE) + | 78 | write_gic_vl_eic_shadow_set(irq, set); |
| 115 | GIC_VPE_EIC_SS(irq), set); | ||
| 116 | } | 79 | } |
| 117 | 80 | ||
| 118 | static void gic_send_ipi(struct irq_data *d, unsigned int cpu) | 81 | static void gic_send_ipi(struct irq_data *d, unsigned int cpu) |
| @@ -371,8 +334,7 @@ static void gic_mask_local_irq_all_vpes(struct irq_data *d) | |||
| 371 | 334 | ||
| 372 | spin_lock_irqsave(&gic_lock, flags); | 335 | spin_lock_irqsave(&gic_lock, flags); |
| 373 | for (i = 0; i < gic_vpes; i++) { | 336 | for (i = 0; i < gic_vpes; i++) { |
| 374 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), | 337 | write_gic_vl_other(mips_cm_vp_id(i)); |
| 375 | mips_cm_vp_id(i)); | ||
| 376 | write_gic_vo_rmask(BIT(intr)); | 338 | write_gic_vo_rmask(BIT(intr)); |
| 377 | } | 339 | } |
| 378 | spin_unlock_irqrestore(&gic_lock, flags); | 340 | spin_unlock_irqrestore(&gic_lock, flags); |
| @@ -386,8 +348,7 @@ static void gic_unmask_local_irq_all_vpes(struct irq_data *d) | |||
| 386 | 348 | ||
| 387 | spin_lock_irqsave(&gic_lock, flags); | 349 | spin_lock_irqsave(&gic_lock, flags); |
| 388 | for (i = 0; i < gic_vpes; i++) { | 350 | for (i = 0; i < gic_vpes; i++) { |
| 389 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), | 351 | write_gic_vl_other(mips_cm_vp_id(i)); |
| 390 | mips_cm_vp_id(i)); | ||
| 391 | write_gic_vo_smask(BIT(intr)); | 352 | write_gic_vo_smask(BIT(intr)); |
| 392 | } | 353 | } |
| 393 | spin_unlock_irqrestore(&gic_lock, flags); | 354 | spin_unlock_irqrestore(&gic_lock, flags); |
| @@ -427,8 +388,7 @@ static void __init gic_basic_init(void) | |||
| 427 | for (i = 0; i < gic_vpes; i++) { | 388 | for (i = 0; i < gic_vpes; i++) { |
| 428 | unsigned int j; | 389 | unsigned int j; |
| 429 | 390 | ||
| 430 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), | 391 | write_gic_vl_other(mips_cm_vp_id(i)); |
| 431 | mips_cm_vp_id(i)); | ||
| 432 | for (j = 0; j < GIC_NUM_LOCAL_INTRS; j++) { | 392 | for (j = 0; j < GIC_NUM_LOCAL_INTRS; j++) { |
| 433 | if (!gic_local_irq_is_routable(j)) | 393 | if (!gic_local_irq_is_routable(j)) |
| 434 | continue; | 394 | continue; |
| @@ -712,10 +672,8 @@ static void __init __gic_init(unsigned long gic_base_addr, | |||
| 712 | if (cpu_has_veic) { | 672 | if (cpu_has_veic) { |
| 713 | /* Set EIC mode for all VPEs */ | 673 | /* Set EIC mode for all VPEs */ |
| 714 | for_each_present_cpu(cpu) { | 674 | for_each_present_cpu(cpu) { |
| 715 | gic_write(GIC_REG(VPE_LOCAL, GIC_VPE_OTHER_ADDR), | 675 | write_gic_vl_other(mips_cm_vp_id(cpu)); |
| 716 | mips_cm_vp_id(cpu)); | 676 | write_gic_vo_ctl(GIC_VX_CTL_EIC); |
| 717 | gic_write(GIC_REG(VPE_OTHER, GIC_VPE_CTL), | ||
| 718 | GIC_VPE_CTL_EIC_MODE_MSK); | ||
| 719 | } | 677 | } |
| 720 | 678 | ||
| 721 | /* Always use vector 1 in EIC mode */ | 679 | /* Always use vector 1 in EIC mode */ |
| @@ -740,9 +698,7 @@ static void __init __gic_init(unsigned long gic_base_addr, | |||
| 740 | */ | 698 | */ |
| 741 | if (IS_ENABLED(CONFIG_MIPS_CMP) && | 699 | if (IS_ENABLED(CONFIG_MIPS_CMP) && |
| 742 | gic_local_irq_is_routable(GIC_LOCAL_INT_TIMER)) { | 700 | gic_local_irq_is_routable(GIC_LOCAL_INT_TIMER)) { |
| 743 | timer_cpu_pin = gic_read32(GIC_REG(VPE_LOCAL, | 701 | timer_cpu_pin = read_gic_vl_timer_map() & GIC_MAP_PIN_MAP; |
| 744 | GIC_VPE_TIMER_MAP)) & | ||
| 745 | GIC_MAP_MSK; | ||
| 746 | irq_set_chained_handler(MIPS_CPU_IRQ_BASE + | 702 | irq_set_chained_handler(MIPS_CPU_IRQ_BASE + |
| 747 | GIC_CPU_PIN_OFFSET + | 703 | GIC_CPU_PIN_OFFSET + |
| 748 | timer_cpu_pin, | 704 | timer_cpu_pin, |
diff --git a/include/linux/irqchip/mips-gic.h b/include/linux/irqchip/mips-gic.h index 011698962a8d..b7a3ce1da9a7 100644 --- a/include/linux/irqchip/mips-gic.h +++ b/include/linux/irqchip/mips-gic.h | |||
| @@ -13,58 +13,14 @@ | |||
| 13 | 13 | ||
| 14 | #define GIC_MAX_INTRS 256 | 14 | #define GIC_MAX_INTRS 256 |
| 15 | 15 | ||
| 16 | #define MSK(n) ((1 << (n)) - 1) | ||
| 17 | |||
| 18 | /* Accessors */ | ||
| 19 | #define GIC_REG(segment, offset) (segment##_##SECTION_OFS + offset##_##OFS) | ||
| 20 | |||
| 21 | /* GIC Address Space */ | 16 | /* GIC Address Space */ |
| 22 | #define VPE_LOCAL_SECTION_OFS 0x8000 | ||
| 23 | #define VPE_LOCAL_SECTION_SIZE 0x4000 | ||
| 24 | #define VPE_OTHER_SECTION_OFS 0xc000 | ||
| 25 | #define VPE_OTHER_SECTION_SIZE 0x4000 | ||
| 26 | #define USM_VISIBLE_SECTION_OFS 0x10000 | 17 | #define USM_VISIBLE_SECTION_OFS 0x10000 |
| 27 | #define USM_VISIBLE_SECTION_SIZE 0x10000 | 18 | #define USM_VISIBLE_SECTION_SIZE 0x10000 |
| 28 | 19 | ||
| 29 | /* Register Map for Local Section */ | ||
| 30 | #define GIC_VPE_CTL_OFS 0x0000 | ||
| 31 | #define GIC_VPE_TIMER_MAP_OFS 0x0048 | ||
| 32 | #define GIC_VPE_OTHER_ADDR_OFS 0x0080 | ||
| 33 | #define GIC_VPE_WD_CONFIG0_OFS 0x0090 | ||
| 34 | #define GIC_VPE_WD_COUNT0_OFS 0x0094 | ||
| 35 | #define GIC_VPE_WD_INITIAL0_OFS 0x0098 | ||
| 36 | |||
| 37 | #define GIC_VPE_EIC_SHADOW_SET_BASE_OFS 0x0100 | ||
| 38 | #define GIC_VPE_EIC_SS(intr) (4 * (intr)) | ||
| 39 | |||
| 40 | #define GIC_VPE_EIC_VEC_BASE_OFS 0x0800 | ||
| 41 | #define GIC_VPE_EIC_VEC(intr) (4 * (intr)) | ||
| 42 | |||
| 43 | #define GIC_VPE_TENABLE_NMI_OFS 0x1000 | ||
| 44 | #define GIC_VPE_TENABLE_YQ_OFS 0x1004 | ||
| 45 | #define GIC_VPE_TENABLE_INT_31_0_OFS 0x1080 | ||
| 46 | #define GIC_VPE_TENABLE_INT_63_32_OFS 0x1084 | ||
| 47 | |||
| 48 | /* User Mode Visible Section Register Map */ | 20 | /* User Mode Visible Section Register Map */ |
| 49 | #define GIC_UMV_SH_COUNTER_31_00_OFS 0x0000 | 21 | #define GIC_UMV_SH_COUNTER_31_00_OFS 0x0000 |
| 50 | #define GIC_UMV_SH_COUNTER_63_32_OFS 0x0004 | 22 | #define GIC_UMV_SH_COUNTER_63_32_OFS 0x0004 |
| 51 | 23 | ||
| 52 | /* Masks */ | ||
| 53 | #define GIC_MAP_SHF 0 | ||
| 54 | #define GIC_MAP_MSK (MSK(6) << GIC_MAP_SHF) | ||
| 55 | |||
| 56 | /* GIC_VPE_CTL Masks */ | ||
| 57 | #define GIC_VPE_CTL_FDC_RTBL_SHF 4 | ||
| 58 | #define GIC_VPE_CTL_FDC_RTBL_MSK (MSK(1) << GIC_VPE_CTL_FDC_RTBL_SHF) | ||
| 59 | #define GIC_VPE_CTL_SWINT_RTBL_SHF 3 | ||
| 60 | #define GIC_VPE_CTL_SWINT_RTBL_MSK (MSK(1) << GIC_VPE_CTL_SWINT_RTBL_SHF) | ||
| 61 | #define GIC_VPE_CTL_PERFCNT_RTBL_SHF 2 | ||
| 62 | #define GIC_VPE_CTL_PERFCNT_RTBL_MSK (MSK(1) << GIC_VPE_CTL_PERFCNT_RTBL_SHF) | ||
| 63 | #define GIC_VPE_CTL_TIMER_RTBL_SHF 1 | ||
| 64 | #define GIC_VPE_CTL_TIMER_RTBL_MSK (MSK(1) << GIC_VPE_CTL_TIMER_RTBL_SHF) | ||
| 65 | #define GIC_VPE_CTL_EIC_MODE_SHF 0 | ||
| 66 | #define GIC_VPE_CTL_EIC_MODE_MSK (MSK(1) << GIC_VPE_CTL_EIC_MODE_SHF) | ||
| 67 | |||
| 68 | /* GIC nomenclature for Core Interrupt Pins. */ | 24 | /* GIC nomenclature for Core Interrupt Pins. */ |
| 69 | #define GIC_CPU_INT0 0 /* Core Interrupt 2 */ | 25 | #define GIC_CPU_INT0 0 /* Core Interrupt 2 */ |
| 70 | #define GIC_CPU_INT1 1 /* . */ | 26 | #define GIC_CPU_INT1 1 /* . */ |
