-+
-+/* Sets the trigger type: edge or level */
-+int avalanche_intr_type_set(unsigned int irq_nr, unsigned long type_val)
-+{
-+ unsigned long flags;
-+ unsigned long chan_nr=0;
-+
-+ printk(KERN_NOTICE "AVALANCHE_INT_END_PRIMARY %d\n",
-+ AVALANCHE_INT_END_PRIMARY);
-+ printk(KERN_NOTICE "AVALANCHE_INT_END_SECONDARY %d\n",
-+ AVALANCHE_INT_END_SECONDARY);
-+ printk(KERN_NOTICE "AVALANCHE_INT_END %d\n", AVALANCHE_INT_END);
-+ printk(KERN_NOTICE "AVALANCHE_INTC_END %d\n", AVALANCHE_INTC_END);
-+ if(irq_nr < MIPS_EXCEPTION_OFFSET ||
-+ irq_nr >= AVALANCHE_INT_END)
-+ {
-+ printk(KERN_ERR "%s: whee, invalid irq_nr %d\n",
-+ __FUNCTION__, irq_nr);
-+ panic("IRQ, you lose...");
-+ return(-1);
-+ }
-+
-+ if(type_val > 1)
-+ {
-+ printk(KERN_ERR "Not a valid polarity value.\n");
-+ return(-1);
-+ }
-+
-+#if defined (CONFIG_AR7_VLYNQ)
-+ /* Vlynq irq_nr are 80-143 in the system and are placed after the interrupts
-+ * managed by the interrupt controller.
-+ */
-+ if(irq_nr >= AVALANCHE_INTC_END)
-+ {
-+ /* Type values for VLYNQ are INTC are different. */
-+ if(irq_nr >= AVALANCHE_INT_END_LOW_VLYNQ)
-+ /* Vlynq interrupts 32-63 */
-+ vlynq_interrupt_set_type(&vlynqDevice1, VLYNQ_REMOTE_DVC,
-+ irq_nr - AVALANCHE_INT_END_LOW_VLYNQ, !type_val);
-+ else
-+ /* Vlynq interupts 0-31 */
-+ vlynq_interrupt_set_type(&vlynqDevice0, VLYNQ_REMOTE_DVC,
-+ irq_nr - AVALANCHE_INTC_END, !type_val);
-+
-+ goto ret_from_set_type;
-+ }
-+#endif
-+
-+ irq_nr = AVINTNUM(irq_nr);
-+
-+ chan_nr = line_to_channel[AVINTNUM(irq_nr)];
-+
-+ save_and_cli(flags);
-+
-+ /* primary interrupt #'s 0-31 */
-+ if(chan_nr < AVALANCHE_INT_END_PRIMARY_REG1)
-+ {
-+ if(type_val)
-+ avalanche_hw0_icregs->inttypr1 |= (1 << chan_nr);
-+ else
-+ avalanche_hw0_icregs->inttypr1 &= ~(1 << chan_nr);
-+ }
-+ /* primary interrupt #'s 32 throuth 39 */
-+ else
-+ {
-+ if(type_val)
-+ avalanche_hw0_icregs->inttypr2 |=
-+ (1 << (chan_nr - AVALANCHE_INT_END_PRIMARY_REG1));
-+ else
-+ avalanche_hw0_icregs->inttypr2 &=
-+ ~(1 << (chan_nr - AVALANCHE_INT_END_PRIMARY_REG1));
-+ }
-+
-+ restore_flags(flags);
-+
-+#if defined (CONFIG_AR7_VLYNQ)
-+ret_from_set_type:
-+#endif
-+
-+ return(0);
-+}
-+
-+
-+int avalanche_intr_polarity_set(unsigned int irq_nr, unsigned long polarity_val)
-+{
-+ unsigned long flags;
-+ unsigned long chan_nr=0;
-+
-+ if(irq_nr < MIPS_EXCEPTION_OFFSET ||
-+ irq_nr >= AVALANCHE_INT_END)
-+ {
-+ printk(KERN_ERR "%s: whee, invalid irq_nr %d\n",
-+ __FUNCTION__, irq_nr);
-+#if defined (CONFIG_AR7_VLYNQ)
-+ printk(KERN_ERR "Not one of the primary or vlynq avalanche interrupts.\n");
-+#else
-+ printk(KERN_ERR "Not one of the primary avalanche interrupts\n");
-+#endif
-+ panic("IRQ, you lose...");
-+ return(-1);
-+ }
-+
-+ if(polarity_val > 1)
-+ {
-+ printk(KERN_ERR "Not a valid polarity value.\n");
-+ return(-1);
-+ }
-+
-+
-+#if defined (CONFIG_AR7_VLYNQ)
-+ /* Vlynq irq_nr are 80-143 in the system and are placed after the interrupts
-+ * managed by the interrupt controller.
-+ */
-+ if(irq_nr >= AVALANCHE_INTC_END)
-+ {
-+ if(irq_nr >= AVALANCHE_INT_END_LOW_VLYNQ)
-+ /* Vlynq interrupts 32-63 */
-+ vlynq_interrupt_set_polarity(&vlynqDevice1, VLYNQ_REMOTE_DVC,
-+ irq_nr - AVALANCHE_INT_END_LOW_VLYNQ, polarity_val);
-+ else
-+ /* Vlynq interupts 0-31 */
-+ vlynq_interrupt_set_polarity(&vlynqDevice0, VLYNQ_REMOTE_DVC,
-+ irq_nr - AVALANCHE_INTC_END, polarity_val);
-+ goto ret_from_set_polarity;
-+ }
-+#endif
-+
-+ irq_nr = AVINTNUM(irq_nr);
-+
-+ chan_nr = line_to_channel[irq_nr];
-+
-+ save_and_cli(flags);
-+
-+ /* primary interrupt #'s 0-31 */
-+ if(chan_nr < AVALANCHE_INT_END_PRIMARY_REG1)
-+ {
-+ if(polarity_val)
-+ avalanche_hw0_icregs->intpolr1 |= (1 << chan_nr);
-+ else
-+ avalanche_hw0_icregs->intpolr1 &= ~(1 << chan_nr);
-+ }
-+ /* primary interrupt #'s 32 throuth 39 */
-+ else
-+ {
-+ if(polarity_val)
-+ avalanche_hw0_icregs->intpolr2 |=
-+ (1 << (chan_nr - AVALANCHE_INT_END_PRIMARY_REG1));
-+ else
-+ avalanche_hw0_icregs->intpolr2 &=
-+ ~(1 << (chan_nr - AVALANCHE_INT_END_PRIMARY_REG1));
-+ }
-+
-+ restore_flags(flags);
-+
-+#if defined (CONFIG_AR7_VLYNQ)
-+ret_from_set_polarity:
-+#endif
-+
-+ return(0);
-+}
-+
-+EXPORT_SYMBOL(avalanche_intr_polarity_set);
-+EXPORT_SYMBOL(avalanche_intr_type_set);