2 * Copyright (c) 1997 Ted Faber
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice immediately at the beginning of the file, without modification,
11 * this list of conditions, and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Absolutely no warranty of function or purpose is made by the author
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
19 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
22 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * $Id: pcic_p.c,v 1.7 1998/12/14 06:32:57 dillon Exp $
35 #include <sys/param.h>
36 #include <sys/kernel.h>
37 #include <sys/systm.h>
38 #include <pci/pcireg.h>
39 #include <pci/pcivar.h>
40 #include <pci/pcic_p.h>
41 #include <pccard/i82365.h>
45 static u_long pcic_pci_count = 0;
47 static const char *pcic_pci_probe(pcici_t, pcidi_t);
48 static void pcic_pci_attach(pcici_t, int);
50 static void pd6832_legacy_init(pcici_t tag, int unit);
52 static struct pci_device pcic_pci_driver = {
60 DATA_SET(pcidevice_set, pcic_pci_driver);
63 * Return the ID string for the controller if the vendor/product id
64 * matches, NULL otherwise.
67 pcic_pci_probe(pcici_t tag, pcidi_t type)
70 case PCI_DEVICE_ID_PCIC_CLPD6729:
71 return ("Cirrus Logic PD6729/6730 PC-Card Controller");
72 case PCI_DEVICE_ID_PCIC_CLPD6832:
73 return ("Cirrus Logic PD6832 CardBus Adapter");
74 case PCI_DEVICE_ID_PCIC_TI1130:
75 return ("TI 1130 PCMCIA/CardBus Bridge");
76 case PCI_DEVICE_ID_PCIC_TI1131:
77 return ("TI 1131 PCI to PCMCIA/CardBus bridge");
78 case PCI_DEVICE_ID_PCIC_TI1250:
79 return ("TI 1250 PCI to PCMCIA/CardBus bridge");
88 * General PCI based card dispatch routine. Right now
89 * it only understands the CL-PD6832.
92 pcic_pci_attach(pcici_t config_id, int unit)
94 u_long pcic_type; /* The vendor id of the PCI pcic */
96 pcic_type = pci_conf_read(config_id, PCI_ID_REG);
99 case PCI_DEVICE_ID_PCIC_CLPD6832:
100 pd6832_legacy_init(config_id, unit);
109 printf("PCI Config space:\n");
110 for (j = 0; j < 0x98; j += 16) {
112 for (i = 0; i < 16; i += 4)
113 printf(" %08lx", pci_conf_read(config_id, i+j));
116 p = (u_char *)pmap_mapdev(pci_conf_read(config_id, 0x10),
119 printf("Cardbus Socket registers:\n");
121 for (i = 0; i < 4; i += 1)
122 printf(" %08lx:", pl[i]);
124 for (i = 4; i < 8; i += 1)
125 printf(" %08lx:", pl[i]);
126 printf("\nExCa registers:\n");
127 for (i = 0; i < 0x40; i += 16)
128 printf("%02x: %16D\n", i, p + 0x800 + i, " ");
133 * Set up the CL-PD6832 to look like a ISA based PCMCIA chip (a
134 * PD672X). This routine is called once per PCMCIA socket.
137 pd6832_legacy_init(pcici_t tag, int unit)
139 u_long bcr; /* to set interrupts */
140 u_short io_port; /* the io_port to map this slot on */
141 static int num6832 = 0; /* The number of 6832s initialized */
144 * Some BIOS leave the legacy address uninitialized. This
145 * insures that the PD6832 puts itself where the driver will
146 * look. We assume that multiple 6832's should be laid out
147 * sequentially. We only initialize the first socket's legacy port,
148 * the other is a dummy.
150 io_port = PCIC_INDEX_0 + num6832 * CLPD6832_NUM_REGS;
152 pci_conf_write(tag, CLPD6832_LEGACY_16BIT_IOADDR,
153 io_port & ~PCI_MAP_IO);
156 * I think this should be a call to pci_map_port, but that
157 * routine won't map regiaters above 0x28, and the register we
158 * need to map is 0x44.
160 io_port = pci_conf_read(tag, CLPD6832_LEGACY_16BIT_IOADDR)
164 * Configure the first I/O window to contain CLPD6832_NUM_REGS
165 * words and deactivate the second by setting the limit lower
168 pci_conf_write(tag, CLPD6832_IO_BASE0, io_port | 1);
169 pci_conf_write(tag, CLPD6832_IO_LIMIT0,
170 (io_port + CLPD6832_NUM_REGS) | 1);
172 pci_conf_write(tag, CLPD6832_IO_BASE1, (io_port + 0x20) | 1);
173 pci_conf_write(tag, CLPD6832_IO_LIMIT1, io_port | 1 );
176 * Set default operating mode (I/O port space) and allocate
177 * this socket to the current unit.
179 pci_conf_write(tag, PCI_COMMAND_STATUS_REG, CLPD6832_COMMAND_DEFAULTS );
180 pci_conf_write(tag, CLPD6832_SOCKET, unit);
183 * Set up the card inserted/card removed interrupts to come
184 * through the isa IRQ.
186 bcr = pci_conf_read(tag, CLPD6832_BRIDGE_CONTROL);
187 bcr |= (CLPD6832_BCR_ISA_IRQ|CLPD6832_BCR_MGMT_IRQ_ENA);
188 pci_conf_write(tag, CLPD6832_BRIDGE_CONTROL, bcr);
190 /* After initializing 2 sockets, the chip is fully configured */
195 printf("CardBus: Legacy PC-card 16bit I/O address [0x%x]\n",
198 #endif /* NPCI > 0 */