18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * Toshiba RBTX4927 specific interrupt handlers 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Author: MontaVista Software, Inc. 58c2ecf20Sopenharmony_ci * source@mvista.com 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 2001-2002 MontaVista Software Inc. 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * This program is free software; you can redistribute it and/or modify it 108c2ecf20Sopenharmony_ci * under the terms of the GNU General Public License as published by the 118c2ecf20Sopenharmony_ci * Free Software Foundation; either version 2 of the License, or (at your 128c2ecf20Sopenharmony_ci * option) any later version. 138c2ecf20Sopenharmony_ci * 148c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 158c2ecf20Sopenharmony_ci * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 168c2ecf20Sopenharmony_ci * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 178c2ecf20Sopenharmony_ci * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 188c2ecf20Sopenharmony_ci * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 198c2ecf20Sopenharmony_ci * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 208c2ecf20Sopenharmony_ci * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 218c2ecf20Sopenharmony_ci * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 228c2ecf20Sopenharmony_ci * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 238c2ecf20Sopenharmony_ci * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * You should have received a copy of the GNU General Public License along 268c2ecf20Sopenharmony_ci * with this program; if not, write to the Free Software Foundation, Inc., 278c2ecf20Sopenharmony_ci * 675 Mass Ave, Cambridge, MA 02139, USA. 288c2ecf20Sopenharmony_ci */ 298c2ecf20Sopenharmony_ci/* 308c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+00 318c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+01 PS2/Keyboard 328c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+02 Cascade RBTX4927-ISA (irqs 8-15) 338c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+03 348c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+04 358c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+05 368c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+06 378c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+07 388c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+08 398c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+09 408c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+10 418c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+11 428c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+12 PS2/Mouse (not supported at this time) 438c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+13 448c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+14 IDE 458c2ecf20Sopenharmony_ci * I8259A_IRQ_BASE+15 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+00 Software 0 488c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+01 Software 1 498c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+02 Cascade TX4927-CP0 508c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+03 Multiplexed -- do not use 518c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+04 Multiplexed -- do not use 528c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+05 Multiplexed -- do not use 538c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+06 Multiplexed -- do not use 548c2ecf20Sopenharmony_ci * MIPS_CPU_IRQ_BASE+07 CPU TIMER 558c2ecf20Sopenharmony_ci * 568c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+00 578c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+01 588c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+02 598c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+03 Cascade RBTX4927-IOC 608c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+04 618c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+05 RBTX4927 RTL-8019AS ethernet 628c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+06 638c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+07 648c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+08 TX4927 SerialIO Channel 0 658c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+09 TX4927 SerialIO Channel 1 668c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+10 678c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+11 688c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+12 698c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+13 708c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+14 718c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+15 728c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+16 TX4927 PCI PCI-C 738c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+17 748c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+18 758c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+19 768c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+20 778c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+21 788c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+22 TX4927 PCI PCI-ERR 798c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+23 TX4927 PCI PCI-PMA (not used) 808c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+24 818c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+25 828c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+26 838c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+27 848c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+28 858c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+29 868c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+30 878c2ecf20Sopenharmony_ci * TXX9_IRQ_BASE+31 888c2ecf20Sopenharmony_ci * 898c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+00 FPCIB0 PCI-D (SouthBridge) 908c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+01 FPCIB0 PCI-C (SouthBridge) 918c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+02 FPCIB0 PCI-B (SouthBridge/IDE/pin=1,INTR) 928c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+03 FPCIB0 PCI-A (SouthBridge/USB/pin=4) 938c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+04 948c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+05 958c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+06 968c2ecf20Sopenharmony_ci * RBTX4927_IRQ_IOC+07 978c2ecf20Sopenharmony_ci * 988c2ecf20Sopenharmony_ci * NOTES: 998c2ecf20Sopenharmony_ci * SouthBridge/INTR is mapped to SouthBridge/A=PCI-B/#58 1008c2ecf20Sopenharmony_ci * SouthBridge/ISA/pin=0 no pci irq used by this device 1018c2ecf20Sopenharmony_ci * SouthBridge/IDE/pin=1 no pci irq used by this device, using INTR 1028c2ecf20Sopenharmony_ci * via ISA IRQ14 1038c2ecf20Sopenharmony_ci * SouthBridge/USB/pin=4 using pci irq SouthBridge/D=PCI-A=#59 1048c2ecf20Sopenharmony_ci * SouthBridge/PMC/pin=0 no pci irq used by this device 1058c2ecf20Sopenharmony_ci * SuperIO/PS2/Keyboard, using INTR via ISA IRQ1 1068c2ecf20Sopenharmony_ci * SuperIO/PS2/Mouse, using INTR via ISA IRQ12 (mouse not currently supported) 1078c2ecf20Sopenharmony_ci * JP7 is not bus master -- do NOT use -- only 4 pci bus master's 1088c2ecf20Sopenharmony_ci * allowed -- SouthBridge, JP4, JP5, JP6 1098c2ecf20Sopenharmony_ci */ 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#include <linux/init.h> 1128c2ecf20Sopenharmony_ci#include <linux/types.h> 1138c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 1148c2ecf20Sopenharmony_ci#include <linux/irq.h> 1158c2ecf20Sopenharmony_ci#include <asm/io.h> 1168c2ecf20Sopenharmony_ci#include <asm/mipsregs.h> 1178c2ecf20Sopenharmony_ci#include <asm/txx9/generic.h> 1188c2ecf20Sopenharmony_ci#include <asm/txx9/rbtx4927.h> 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_cistatic int toshiba_rbtx4927_irq_nested(int sw_irq) 1218c2ecf20Sopenharmony_ci{ 1228c2ecf20Sopenharmony_ci u8 level3; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci level3 = readb(rbtx4927_imstat_addr) & 0x1f; 1258c2ecf20Sopenharmony_ci if (unlikely(!level3)) 1268c2ecf20Sopenharmony_ci return -1; 1278c2ecf20Sopenharmony_ci return RBTX4927_IRQ_IOC + __fls8(level3); 1288c2ecf20Sopenharmony_ci} 1298c2ecf20Sopenharmony_ci 1308c2ecf20Sopenharmony_cistatic void toshiba_rbtx4927_irq_ioc_enable(struct irq_data *d) 1318c2ecf20Sopenharmony_ci{ 1328c2ecf20Sopenharmony_ci unsigned char v; 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci v = readb(rbtx4927_imask_addr); 1358c2ecf20Sopenharmony_ci v |= (1 << (d->irq - RBTX4927_IRQ_IOC)); 1368c2ecf20Sopenharmony_ci writeb(v, rbtx4927_imask_addr); 1378c2ecf20Sopenharmony_ci} 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_cistatic void toshiba_rbtx4927_irq_ioc_disable(struct irq_data *d) 1408c2ecf20Sopenharmony_ci{ 1418c2ecf20Sopenharmony_ci unsigned char v; 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci v = readb(rbtx4927_imask_addr); 1448c2ecf20Sopenharmony_ci v &= ~(1 << (d->irq - RBTX4927_IRQ_IOC)); 1458c2ecf20Sopenharmony_ci writeb(v, rbtx4927_imask_addr); 1468c2ecf20Sopenharmony_ci mmiowb(); 1478c2ecf20Sopenharmony_ci} 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci#define TOSHIBA_RBTX4927_IOC_NAME "RBTX4927-IOC" 1508c2ecf20Sopenharmony_cistatic struct irq_chip toshiba_rbtx4927_irq_ioc_type = { 1518c2ecf20Sopenharmony_ci .name = TOSHIBA_RBTX4927_IOC_NAME, 1528c2ecf20Sopenharmony_ci .irq_mask = toshiba_rbtx4927_irq_ioc_disable, 1538c2ecf20Sopenharmony_ci .irq_unmask = toshiba_rbtx4927_irq_ioc_enable, 1548c2ecf20Sopenharmony_ci}; 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_cistatic void __init toshiba_rbtx4927_irq_ioc_init(void) 1578c2ecf20Sopenharmony_ci{ 1588c2ecf20Sopenharmony_ci int i; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci /* mask all IOC interrupts */ 1618c2ecf20Sopenharmony_ci writeb(0, rbtx4927_imask_addr); 1628c2ecf20Sopenharmony_ci /* clear SoftInt interrupts */ 1638c2ecf20Sopenharmony_ci writeb(0, rbtx4927_softint_addr); 1648c2ecf20Sopenharmony_ci 1658c2ecf20Sopenharmony_ci for (i = RBTX4927_IRQ_IOC; 1668c2ecf20Sopenharmony_ci i < RBTX4927_IRQ_IOC + RBTX4927_NR_IRQ_IOC; i++) 1678c2ecf20Sopenharmony_ci irq_set_chip_and_handler(i, &toshiba_rbtx4927_irq_ioc_type, 1688c2ecf20Sopenharmony_ci handle_level_irq); 1698c2ecf20Sopenharmony_ci irq_set_chained_handler(RBTX4927_IRQ_IOCINT, handle_simple_irq); 1708c2ecf20Sopenharmony_ci} 1718c2ecf20Sopenharmony_ci 1728c2ecf20Sopenharmony_cistatic int rbtx4927_irq_dispatch(int pending) 1738c2ecf20Sopenharmony_ci{ 1748c2ecf20Sopenharmony_ci int irq; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_ci if (pending & STATUSF_IP7) /* cpu timer */ 1778c2ecf20Sopenharmony_ci irq = MIPS_CPU_IRQ_BASE + 7; 1788c2ecf20Sopenharmony_ci else if (pending & STATUSF_IP2) { /* tx4927 pic */ 1798c2ecf20Sopenharmony_ci irq = txx9_irq(); 1808c2ecf20Sopenharmony_ci if (irq == RBTX4927_IRQ_IOCINT) 1818c2ecf20Sopenharmony_ci irq = toshiba_rbtx4927_irq_nested(irq); 1828c2ecf20Sopenharmony_ci } else if (pending & STATUSF_IP0) /* user line 0 */ 1838c2ecf20Sopenharmony_ci irq = MIPS_CPU_IRQ_BASE + 0; 1848c2ecf20Sopenharmony_ci else if (pending & STATUSF_IP1) /* user line 1 */ 1858c2ecf20Sopenharmony_ci irq = MIPS_CPU_IRQ_BASE + 1; 1868c2ecf20Sopenharmony_ci else 1878c2ecf20Sopenharmony_ci irq = -1; 1888c2ecf20Sopenharmony_ci return irq; 1898c2ecf20Sopenharmony_ci} 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_civoid __init rbtx4927_irq_setup(void) 1928c2ecf20Sopenharmony_ci{ 1938c2ecf20Sopenharmony_ci txx9_irq_dispatch = rbtx4927_irq_dispatch; 1948c2ecf20Sopenharmony_ci tx4927_irq_init(); 1958c2ecf20Sopenharmony_ci toshiba_rbtx4927_irq_ioc_init(); 1968c2ecf20Sopenharmony_ci /* Onboard 10M Ether: High Active */ 1978c2ecf20Sopenharmony_ci irq_set_irq_type(RBTX4927_RTL_8019_IRQ, IRQF_TRIGGER_HIGH); 1988c2ecf20Sopenharmony_ci} 199