Annotation of sys/arch/macppc/macppc/rbus_machdep.c, Revision 1.1
1.1 ! nbrk 1: /* $OpenBSD: rbus_machdep.c,v 1.6 2004/03/23 03:25:46 drahn Exp $ */
! 2: /* $NetBSD: rbus_machdep.c,v 1.2 1999/10/15 06:43:06 haya Exp $ */
! 3:
! 4: /*
! 5: * Copyright (c) 1999
! 6: * HAYAKAWA Koichi. All rights reserved.
! 7: *
! 8: * Redistribution and use in source and binary forms, with or without
! 9: * modification, are permitted provided that the following conditions
! 10: * are met:
! 11: * 1. Redistributions of source code must retain the above copyright
! 12: * notice, this list of conditions and the following disclaimer.
! 13: * 2. Redistributions in binary form must reproduce the above copyright
! 14: * notice, this list of conditions and the following disclaimer in the
! 15: * documentation and/or other materials provided with the distribution.
! 16: * 3. All advertising materials mentioning features or use of this software
! 17: * must display the following acknowledgement:
! 18: * This product includes software developed by HAYAKAWA Koichi.
! 19: * 4. The name of the author may not be used to endorse or promote products
! 20: * derived from this software without specific prior written permission.
! 21: *
! 22: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
! 23: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
! 24: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
! 25: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
! 26: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
! 27: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
! 28: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
! 29: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
! 30: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
! 31: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
! 32: */
! 33:
! 34: #include <sys/param.h>
! 35: #include <sys/systm.h>
! 36: #include <sys/extent.h>
! 37:
! 38: #include <uvm/uvm_extern.h>
! 39:
! 40: #include <sys/sysctl.h>
! 41:
! 42: #include <sys/device.h>
! 43:
! 44: #include <machine/bus.h>
! 45: #include <dev/cardbus/rbus.h>
! 46:
! 47: #include <dev/pci/pcivar.h>
! 48: #include <arch/macppc/pci/pcibrvar.h>
! 49:
! 50: void macppc_cardbus_init(pci_chipset_tag_t pc, pcitag_t tag);
! 51:
! 52: /**********************************************************************
! 53: * rbus_tag_t rbus_fakeparent_mem(struct pci_attach_args *pa)
! 54: *
! 55: * This function makes an rbus tag for memory space. This rbus tag
! 56: * shares the all memory region of ex_iomem.
! 57: **********************************************************************/
! 58: #define RBUS_MEM_SIZE 0x10000000
! 59:
! 60: rbus_tag_t
! 61: rbus_pccbb_parent_mem(struct device *self, struct pci_attach_args *pa)
! 62: {
! 63: bus_addr_t start;
! 64: bus_size_t size;
! 65: struct extent *ex;
! 66:
! 67: macppc_cardbus_init(pa->pa_pc, pa->pa_tag);
! 68:
! 69: size = RBUS_MEM_SIZE;
! 70: if ((ex = pciaddr_search(PCIADDR_SEARCH_MEM, self, &start, size)) ==
! 71: NULL)
! 72: {
! 73: /* XXX */
! 74: printf("failed\n");
! 75: }
! 76:
! 77: return rbus_new_root_share(pa->pa_memt, ex, start, size, 0);
! 78: }
! 79:
! 80:
! 81: /**********************************************************************
! 82: * rbus_tag_t rbus_pccbb_parent_io(struct pci_attach_args *pa)
! 83: **********************************************************************/
! 84: #define RBUS_IO_SIZE 0x1000
! 85:
! 86: rbus_tag_t
! 87: rbus_pccbb_parent_io(struct device *self, struct pci_attach_args *pa)
! 88: {
! 89: struct extent *ex;
! 90: bus_addr_t start;
! 91: bus_size_t size;
! 92:
! 93:
! 94: size = RBUS_IO_SIZE;
! 95: if ((ex = pciaddr_search(PCIADDR_SEARCH_IO, self, &start, size)) ==
! 96: NULL)
! 97: {
! 98: /* XXX */
! 99: printf("failed\n");
! 100: }
! 101:
! 102: return rbus_new_root_share(pa->pa_iot, ex, start, size, 0);
! 103: }
! 104:
! 105:
! 106: /*
! 107: * Big ugly hack to enable bridge/fix interrupts
! 108: */
! 109: void
! 110: macppc_cardbus_init(pci_chipset_tag_t pc, pcitag_t tag)
! 111: {
! 112: u_int x;
! 113: static int initted = 0;
! 114:
! 115: if (initted)
! 116: return;
! 117: initted = 1;
! 118:
! 119: /* XXX What about other bridges? */
! 120:
! 121: x = pci_conf_read(pc, tag, PCI_ID_REG);
! 122: if (PCI_VENDOR(x) == PCI_VENDOR_TI &&
! 123: PCI_PRODUCT(x) == PCI_PRODUCT_TI_PCI1211) {
! 124: /* For CardBus card. */
! 125: pci_conf_write(pc, tag, 0x18, 0x10010100);
! 126:
! 127: /* Route INTA to MFUNC0 */
! 128: x = pci_conf_read(pc, tag, 0x8c);
! 129: x |= 0x02;
! 130: pci_conf_write(pc, tag, 0x8c, x);
! 131:
! 132: tag = pci_make_tag(pc, 0, 0, 0);
! 133: x = pci_conf_read(pc, tag, PCI_ID_REG);
! 134: if (PCI_VENDOR(x) == PCI_VENDOR_MOT &&
! 135: PCI_PRODUCT(x) == PCI_PRODUCT_MOT_MPC106) {
! 136: /* Set subordinate bus number to 1. */
! 137: x = pci_conf_read(pc, tag, 0x40);
! 138: x |= 1 << 8;
! 139: pci_conf_write(pc, tag, 0x40, x);
! 140: }
! 141: }
! 142:
! 143: if (PCI_VENDOR(x) == PCI_VENDOR_TI &&
! 144: (PCI_PRODUCT(x) == PCI_PRODUCT_TI_PCI1410 ||
! 145: PCI_PRODUCT(x) == PCI_PRODUCT_TI_PCI1510)) {
! 146: /* dont mess with the bus numbers or latency timer */
! 147:
! 148: /* Route INTA to MFUNC0 */
! 149: x = pci_conf_read(pc, tag, 0x8c);
! 150: x |= 0x02;
! 151: pci_conf_write(pc, tag, 0x8c, x);
! 152: }
! 153: }
CVSweb