puc_pci.c (102717) | puc_pci.c (102734) |
---|---|
1/* $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ */ 2 3/*- 4 * Copyright (c) 2002 JF Hay. All rights reserved. 5 * Copyright (c) 2000 M. Warner Losh. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 44 unchanged lines hidden (view full) --- 53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60#include <sys/cdefs.h> | 1/* $NetBSD: puc.c,v 1.7 2000/07/29 17:43:38 jlam Exp $ */ 2 3/*- 4 * Copyright (c) 2002 JF Hay. All rights reserved. 5 * Copyright (c) 2000 M. Warner Losh. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 44 unchanged lines hidden (view full) --- 53 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 54 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 55 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 56 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 57 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 58 */ 59 60#include <sys/cdefs.h> |
61__FBSDID("$FreeBSD: head/sys/dev/puc/puc_pci.c 102717 2002-08-31 18:42:31Z phk $"); | 61__FBSDID("$FreeBSD: head/sys/dev/puc/puc_pci.c 102734 2002-08-31 20:29:46Z phk $"); |
62 63#include <sys/param.h> 64#include <sys/systm.h> 65#include <sys/kernel.h> 66#include <sys/bus.h> 67#include <sys/conf.h> 68#include <sys/malloc.h> 69 --- 61 unchanged lines hidden (view full) --- 131static driver_t puc_pci_driver = { 132 "puc", 133 puc_pci_methods, 134 sizeof(struct puc_softc), 135}; 136 137DRIVER_MODULE(puc, pci, puc_pci_driver, puc_devclass, 0, 0); 138DRIVER_MODULE(puc, cardbus, puc_pci_driver, puc_devclass, 0, 0); | 62 63#include <sys/param.h> 64#include <sys/systm.h> 65#include <sys/kernel.h> 66#include <sys/bus.h> 67#include <sys/conf.h> 68#include <sys/malloc.h> 69 --- 61 unchanged lines hidden (view full) --- 131static driver_t puc_pci_driver = { 132 "puc", 133 puc_pci_methods, 134 sizeof(struct puc_softc), 135}; 136 137DRIVER_MODULE(puc, pci, puc_pci_driver, puc_devclass, 0, 0); 138DRIVER_MODULE(puc, cardbus, puc_pci_driver, puc_devclass, 0, 0); |
139 140 141#define rdspio(indx) (bus_space_write_1(bst, bsh, efir, indx), \ 142 bus_space_read_1(bst, bsh, efdr)) 143#define wrspio(indx,data) (bus_space_write_1(bst, bsh, efir, indx), \ 144 bus_space_write_1(bst, bsh, efdr, data)) 145 146#ifdef PUC_DEBUG 147static void 148puc_print_win877(bus_space_tag_t bst, bus_space_handle_t bsh, u_int efir, 149 u_int efdr) 150{ 151 u_char cr00, cr01, cr04, cr09, cr0d, cr14, cr15, cr16, cr17; 152 u_char cr18, cr19, cr24, cr25, cr28, cr2c, cr31, cr32; 153 154 cr00 = rdspio(0x00); 155 cr01 = rdspio(0x01); 156 cr04 = rdspio(0x04); 157 cr09 = rdspio(0x09); 158 cr0d = rdspio(0x0d); 159 cr14 = rdspio(0x14); 160 cr15 = rdspio(0x15); 161 cr16 = rdspio(0x16); 162 cr17 = rdspio(0x17); 163 cr18 = rdspio(0x18); 164 cr19 = rdspio(0x19); 165 cr24 = rdspio(0x24); 166 cr25 = rdspio(0x25); 167 cr28 = rdspio(0x28); 168 cr2c = rdspio(0x2c); 169 cr31 = rdspio(0x31); 170 cr32 = rdspio(0x32); 171 printf("877T: cr00 %x, cr01 %x, cr04 %x, cr09 %x, cr0d %x, cr14 %x, " 172 "cr15 %x, cr16 %x, cr17 %x, cr18 %x, cr19 %x, cr24 %x, cr25 %x, " 173 "cr28 %x, cr2c %x, cr31 %x, cr32 %x\n", cr00, cr01, cr04, cr09, 174 cr0d, cr14, cr15, cr16, cr17, 175 cr18, cr19, cr24, cr25, cr28, cr2c, cr31, cr32); 176} 177#endif 178 179int 180puc_config_win877(struct puc_softc *sc) 181{ 182 u_char val; 183 u_int efir, efdr; 184 bus_space_tag_t bst; 185 bus_space_handle_t bsh; 186 struct resource *res; 187 188 res = sc->sc_bar_mappings[0].res; 189 190 bst = rman_get_bustag(res); 191 bsh = rman_get_bushandle(res); 192 193 /* configure the first W83877TF */ 194 bus_space_write_1(bst, bsh, 0x250, 0x89); 195 efir = 0x251; 196 efdr = 0x252; 197 val = rdspio(0x09) & 0x0f; 198 if (val != 0x0c) { 199 printf("conf_win877: Oops not a W83877TF\n"); 200 return (ENXIO); 201 } 202 203#ifdef PUC_DEBUG 204 printf("before: "); 205 puc_print_win877(bst, bsh, efir, efdr); 206#endif 207 208 val = rdspio(0x16); 209 val |= 0x04; 210 wrspio(0x16, val); 211 val &= ~0x04; 212 wrspio(0x16, val); 213 214 wrspio(0x24, 0x2e8 >> 2); 215 wrspio(0x25, 0x2f8 >> 2); 216 wrspio(0x17, 0x03); 217 wrspio(0x28, 0x43); 218 219#ifdef PUC_DEBUG 220 printf("after: "); 221 puc_print_win877(bst, bsh, efir, efdr); 222#endif 223 224 bus_space_write_1(bst, bsh, 0x250, 0xaa); 225 226 /* configure the second W83877TF */ 227 bus_space_write_1(bst, bsh, 0x3f0, 0x87); 228 bus_space_write_1(bst, bsh, 0x3f0, 0x87); 229 efir = 0x3f0; 230 efdr = 0x3f1; 231 val = rdspio(0x09) & 0x0f; 232 if (val != 0x0c) { 233 printf("conf_win877: Oops not a W83877TF\n"); 234 return(ENXIO); 235 } 236 237#ifdef PUC_DEBUG 238 printf("before: "); 239 puc_print_win877(bst, bsh, efir, efdr); 240#endif 241 242 val = rdspio(0x16); 243 val |= 0x04; 244 wrspio(0x16, val); 245 val &= ~0x04; 246 wrspio(0x16, val); 247 248 wrspio(0x24, 0x3e8 >> 2); 249 wrspio(0x25, 0x3f8 >> 2); 250 wrspio(0x17, 0x03); 251 wrspio(0x28, 0x43); 252 253#ifdef PUC_DEBUG 254 printf("after: "); 255 puc_print_win877(bst, bsh, efir, efdr); 256#endif 257 258 bus_space_write_1(bst, bsh, 0x3f0, 0xaa); 259 return (0); 260} 261 262#undef rdspio 263#undef wrspio 264 |
|