Home | History | Annotate | Line # | Download | only in pci
      1  1.1  xtraeme /*	$NetBSD: via8231reg.h,v 1.1 2006/01/01 12:12:44 xtraeme Exp $	*/
      2  1.1  xtraeme /*	OpenBSD: via8231reg.h,v 1.4 2005/10/26 21:38:28 mickey Exp 	*/
      3  1.1  xtraeme 
      4  1.1  xtraeme /*
      5  1.1  xtraeme  * Copyright (c) 2005, by Michael Shalayeff
      6  1.1  xtraeme  * Copyright (c) 2003, by Matthew Gream
      7  1.1  xtraeme  * Copyright (c) 1999, by UCHIYAMA Yasushi
      8  1.1  xtraeme  * All rights reserved.
      9  1.1  xtraeme  *
     10  1.1  xtraeme  * Redistribution and use in source and binary forms, with or without
     11  1.1  xtraeme  * modification, are permitted provided that the following conditions
     12  1.1  xtraeme  * are met:
     13  1.1  xtraeme  * 1. Redistributions of source code must retain the above copyright
     14  1.1  xtraeme  *    notice, this list of conditions and the following disclaimer.
     15  1.1  xtraeme  * 2. The name of the developer may NOT be used to endorse or promote products
     16  1.1  xtraeme  *    derived from this software without specific prior written permission.
     17  1.1  xtraeme  *
     18  1.1  xtraeme  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
     19  1.1  xtraeme  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     20  1.1  xtraeme  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     21  1.1  xtraeme  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
     22  1.1  xtraeme  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     23  1.1  xtraeme  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     24  1.1  xtraeme  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     25  1.1  xtraeme  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     26  1.1  xtraeme  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     27  1.1  xtraeme  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     28  1.1  xtraeme  * SUCH DAMAGE.
     29  1.1  xtraeme  */
     30  1.1  xtraeme 
     31  1.1  xtraeme /*
     32  1.1  xtraeme  * Register definitions for the VIA8231 PCI to ISA Bridge
     33  1.1  xtraeme  */
     34  1.1  xtraeme 
     35  1.1  xtraeme /*
     36  1.1  xtraeme  * Edge Triggered Interrupt Select register. (0x54)
     37  1.1  xtraeme  * bits 7-4: reserved
     38  1.1  xtraeme  * bit 3: Edge Triggered Interrupt Select for PCI Interrupt A
     39  1.1  xtraeme  * bit 2: Edge Triggered Interrupt Select for PCI Interrupt B
     40  1.1  xtraeme  * bit 1: Edge Triggered Interrupt Select for PCI Interrupt C
     41  1.1  xtraeme  * bit 0: Edge Triggered Interrupt Select for PCI Interrupt D
     42  1.1  xtraeme  *   0 = Non-invert (level)
     43  1.1  xtraeme  *   1 = Invert (edge)
     44  1.1  xtraeme  *
     45  1.1  xtraeme  * PIRQ Select register. (0x55 - 0x57)
     46  1.1  xtraeme  * (0x55)
     47  1.1  xtraeme  * bits 7-4:   PINTA# Routing
     48  1.1  xtraeme  * bits 3-0:   reserved
     49  1.1  xtraeme  * (0x56)
     50  1.1  xtraeme  * bits 7-4:   PINTC# Routing
     51  1.1  xtraeme  * bits 3-0:   PINTB# Routing
     52  1.1  xtraeme  * (0x57)
     53  1.1  xtraeme  * bits 7-4:   PINTD# Routing
     54  1.1  xtraeme  * bits 3-0:   reserved
     55  1.1  xtraeme  * PIRQ Select register. (0x44 - 0x47)
     56  1.1  xtraeme  * (0x44)
     57  1.1  xtraeme  * bits 7-4:   PINTF# Routing
     58  1.1  xtraeme  * bits 3-0:   PINTE# Routing
     59  1.1  xtraeme  * (0x45)
     60  1.1  xtraeme  * bits 7-4:   PINTH# Routing
     61  1.1  xtraeme  * bits 3-0:   PINTG# Routing
     62  1.1  xtraeme  * (0x46)
     63  1.1  xtraeme  * bit 4:	EFGH/ABCD share (1 -- use above mappings)
     64  1.1  xtraeme  * bit 3: Edge Triggered Interrupt Select for PCI Interrupt H
     65  1.1  xtraeme  * bit 2: Edge Triggered Interrupt Select for PCI Interrupt G
     66  1.1  xtraeme  * bit 1: Edge Triggered Interrupt Select for PCI Interrupt F
     67  1.1  xtraeme  * bit 0: Edge Triggered Interrupt Select for PCI Interrupt E
     68  1.1  xtraeme  *
     69  1.1  xtraeme  *   0000: Disabled  0100: IRQ4      1000: Reserved  1100: IRQ12
     70  1.1  xtraeme  *   0001: IRQ1      0101: IRQ5      1001: IRQ9      1101: Reserved
     71  1.1  xtraeme  *   0010: Reserved  0110: IRQ6      1010: IRQ10     1110: IRQ14
     72  1.1  xtraeme  *   0011: IRQ3      0111: IRQ7      1011: IRQ11     1111: IRQ15
     73  1.1  xtraeme  */
     74  1.1  xtraeme #define VIA8231_CFG_PIR		0x54
     75  1.1  xtraeme #define VIA8237_CFG_PIR		0x44
     76  1.1  xtraeme 
     77  1.1  xtraeme #define VIA8231_TRIGGER_CNFG_MASK		0x000000ff
     78  1.1  xtraeme #define VIA8231_TRIGGER_CNFG_SHFT		0
     79  1.1  xtraeme #define VIA8237_TRIGGER_CNFG_MASK		0x000f0000
     80  1.1  xtraeme #define VIA8237_TRIGGER_CNFG_SHFT		16
     81  1.1  xtraeme #define VIA8231_TRIGGER_CNFG_LEVEL		0
     82  1.1  xtraeme #define VIA8231_TRIGGER_CNFG_EDGE		1
     83  1.1  xtraeme #define VIA8237_TRIGGER_CNFG_ENA		0x00100000
     84  1.1  xtraeme 
     85  1.1  xtraeme #define VIA8231_GET_TRIGGER(ph)						\
     86  1.1  xtraeme 	((pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8231_CFG_PIR)	\
     87  1.1  xtraeme 	    & VIA8231_TRIGGER_CNFG_MASK) >> VIA8231_TRIGGER_CNFG_SHFT)
     88  1.1  xtraeme #define VIA8237_GET_TRIGGER(ph)						\
     89  1.1  xtraeme 	((pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8237_CFG_PIR)	\
     90  1.1  xtraeme 	    & VIA8237_TRIGGER_CNFG_MASK) >> VIA8237_TRIGGER_CNFG_SHFT)
     91  1.1  xtraeme 
     92  1.1  xtraeme #define VIA8231_SET_TRIGGER(ph, n)					\
     93  1.1  xtraeme 	pci_conf_write((ph)->ph_pc, (ph)->ph_tag, VIA8231_CFG_PIR,	\
     94  1.1  xtraeme 	(pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8231_CFG_PIR)	\
     95  1.1  xtraeme 	    & ~VIA8231_TRIGGER_CNFG_MASK) | ((n) << VIA8231_TRIGGER_CNFG_SHFT))
     96  1.1  xtraeme #define VIA8237_SET_TRIGGER(ph, n)					\
     97  1.1  xtraeme 	pci_conf_write((ph)->ph_pc, (ph)->ph_tag, VIA8237_CFG_PIR,	\
     98  1.1  xtraeme 	(pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8237_CFG_PIR)	\
     99  1.1  xtraeme 	    & ~VIA8237_TRIGGER_CNFG_MASK) | ((n) << VIA8237_TRIGGER_CNFG_SHFT))
    100  1.1  xtraeme 
    101  1.1  xtraeme 
    102  1.1  xtraeme #define VIA8231_ROUTING_CNFG_MASK		0xffffff00
    103  1.1  xtraeme #define VIA8231_ROUTING_CNFG_SHFT		8 /* skip 0x54 triggers */
    104  1.1  xtraeme #define VIA8231_ROUTING_CNFG_DISABLED		0
    105  1.1  xtraeme #define VIA8237_ROUTING_CNFG_MASK		0xffff
    106  1.1  xtraeme #define VIA8237_ROUTING_CNFG_SHFT		0
    107  1.1  xtraeme 
    108  1.1  xtraeme #define VIA8231_GET_ROUTING(ph)						\
    109  1.1  xtraeme 	((pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8231_CFG_PIR)	\
    110  1.1  xtraeme 	    & VIA8231_ROUTING_CNFG_MASK) >> VIA8231_ROUTING_CNFG_SHFT)
    111  1.1  xtraeme #define VIA8237_GET_ROUTING(ph)						\
    112  1.1  xtraeme 	((pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8237_CFG_PIR)	\
    113  1.1  xtraeme 	    & VIA8237_ROUTING_CNFG_MASK) >> VIA8237_ROUTING_CNFG_SHFT)
    114  1.1  xtraeme 
    115  1.1  xtraeme #define VIA8231_SET_ROUTING(ph, n)					\
    116  1.1  xtraeme 	pci_conf_write((ph)->ph_pc, (ph)->ph_tag, VIA8231_CFG_PIR,	\
    117  1.1  xtraeme 	(pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8231_CFG_PIR)	\
    118  1.1  xtraeme 	    & ~VIA8231_ROUTING_CNFG_MASK) | ((n) << VIA8231_ROUTING_CNFG_SHFT))
    119  1.1  xtraeme #define VIA8237_SET_ROUTING(ph, n)					\
    120  1.1  xtraeme 	pci_conf_write((ph)->ph_pc, (ph)->ph_tag, VIA8237_CFG_PIR,	\
    121  1.1  xtraeme 	(pci_conf_read((ph)->ph_pc, (ph)->ph_tag, VIA8237_CFG_PIR)	\
    122  1.1  xtraeme 	    & ~VIA8237_ROUTING_CNFG_MASK) | \
    123  1.1  xtraeme 	    ((n) << VIA8237_ROUTING_CNFG_SHFT) | VIA8237_TRIGGER_CNFG_ENA)
    124  1.1  xtraeme 
    125  1.1  xtraeme 
    126  1.1  xtraeme #define VIA8231_PIRQ_MASK		0xdefa
    127  1.1  xtraeme #define VIA8231_PIRQ_LEGAL(irq)		\
    128  1.1  xtraeme 	((irq) >= 0 && (irq) <= 15 && ((1 << (irq)) & VIA8231_PIRQ_MASK))
    129  1.1  xtraeme #define VIA8231_LINK_MAX		3
    130  1.1  xtraeme #define VIA8237_LINK_MAX		7
    131  1.1  xtraeme #define	VIA8231_LINK_LEGAL(link)	\
    132  1.1  xtraeme 	((link) >= 0 && (link) <= VIA8231_LINK_MAX)
    133  1.1  xtraeme #define	VIA8237_LINK_LEGAL(link)	\
    134  1.1  xtraeme 	((link) >= 0 && (link) <= VIA8237_LINK_MAX)
    135  1.1  xtraeme #define VIA8231_TRIG_LEGAL(trig)	\
    136  1.1  xtraeme 	((trig) == IST_LEVEL || (trig) == IST_EDGE)
    137  1.1  xtraeme 
    138