1/* |
2 * Copyright (c) 2002 M. Warner Losh. |
3 * Copyright (c) 2000,2001 Jonathan Chen. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer, --- 10 unchanged lines hidden (view full) --- 21 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * |
29 * $FreeBSD: head/sys/dev/pccbb/pccbb.c 100704 2002-07-26 08:05:25Z imp $ |
30 */ 31 32/* 33 * Copyright (c) 1998, 1999 and 2000 34 * HAYAKAWA Koichi. All rights reserved. 35 * 36 * Redistribution and use in source and binary forms, with or without 37 * modification, are permitted provided that the following conditions --- 83 unchanged lines hidden (view full) --- 121#define PCCBB_START_16_IO 0x100 122 123struct yenta_chipinfo { 124 uint32_t yc_id; 125 const char *yc_name; 126 int yc_chiptype; 127} yc_chipsets[] = { 128 /* Texas Instruments chips */ |
129 {PCIC_ID_TI1031, "TI1031 PCI-PC Card Bridge", CB_TI113X}, 130 {PCIC_ID_TI1130, "TI1130 PCI-CardBus Bridge", CB_TI113X}, 131 {PCIC_ID_TI1131, "TI1131 PCI-CardBus Bridge", CB_TI113X}, |
132 |
133 {PCIC_ID_TI1210, "TI1210 PCI-CardBus Bridge", CB_TI12XX}, 134 {PCIC_ID_TI1211, "TI1211 PCI-CardBus Bridge", CB_TI12XX}, 135 {PCIC_ID_TI1220, "TI1220 PCI-CardBus Bridge", CB_TI12XX}, 136 {PCIC_ID_TI1221, "TI1221 PCI-CardBus Bridge", CB_TI12XX}, 137 {PCIC_ID_TI1225, "TI1225 PCI-CardBus Bridge", CB_TI12XX}, 138 {PCIC_ID_TI1250, "TI1250 PCI-CardBus Bridge", CB_TI125X}, 139 {PCIC_ID_TI1251, "TI1251 PCI-CardBus Bridge", CB_TI125X}, 140 {PCIC_ID_TI1251B,"TI1251B PCI-CardBus Bridge",CB_TI125X}, 141 {PCIC_ID_TI1260, "TI1260 PCI-CardBus Bridge", CB_TI12XX}, 142 {PCIC_ID_TI1260B,"TI1260B PCI-CardBus Bridge",CB_TI12XX}, 143 {PCIC_ID_TI1410, "TI1410 PCI-CardBus Bridge", CB_TI12XX}, 144 {PCIC_ID_TI1420, "TI1420 PCI-CardBus Bridge", CB_TI12XX}, 145 {PCIC_ID_TI1421, "TI1421 PCI-CardBus Bridge", CB_TI12XX}, 146 {PCIC_ID_TI1450, "TI1450 PCI-CardBus Bridge", CB_TI125X}, 147 {PCIC_ID_TI1451, "TI1451 PCI-CardBus Bridge", CB_TI12XX}, 148 {PCIC_ID_TI1510, "TI1510 PCI-CardBus Bridge", CB_TI12XX}, 149 {PCIC_ID_TI1520, "TI1520 PCI-CardBus Bridge", CB_TI12XX}, 150 {PCIC_ID_TI4410, "TI4410 PCI-CardBus Bridge", CB_TI12XX}, 151 {PCIC_ID_TI4450, "TI4450 PCI-CardBus Bridge", CB_TI12XX}, 152 {PCIC_ID_TI4451, "TI4451 PCI-CardBus Bridge", CB_TI12XX}, 153 {PCIC_ID_TI4510, "TI4510 PCI-CardBus Bridge", CB_TI12XX}, |
154 155 /* Ricoh chips */ |
156 {PCIC_ID_RICOH_RL5C465, "RF5C465 PCI-CardBus Bridge", CB_RF5C46X}, 157 {PCIC_ID_RICOH_RL5C466, "RF5C466 PCI-CardBus Bridge", CB_RF5C46X}, 158 {PCIC_ID_RICOH_RL5C475, "RF5C475 PCI-CardBus Bridge", CB_RF5C47X}, 159 {PCIC_ID_RICOH_RL5C476, "RF5C476 PCI-CardBus Bridge", CB_RF5C47X}, 160 {PCIC_ID_RICOH_RL5C477, "RF5C477 PCI-CardBus Bridge", CB_RF5C47X}, 161 {PCIC_ID_RICOH_RL5C478, "RF5C478 PCI-CardBus Bridge", CB_RF5C47X}, |
162 163 /* Toshiba products */ |
164 {PCIC_ID_TOPIC95, "ToPIC95 PCI-CardBus Bridge", CB_TOPIC95}, 165 {PCIC_ID_TOPIC95B, "ToPIC95B PCI-CardBus Bridge", CB_TOPIC95}, 166 {PCIC_ID_TOPIC97, "ToPIC97 PCI-CardBus Bridge", CB_TOPIC97}, 167 {PCIC_ID_TOPIC100, "ToPIC100 PCI-CardBus Bridge", CB_TOPIC97}, |
168 169 /* Cirrus Logic */ |
170 {PCIC_ID_CLPD6832, "CLPD6832 PCI-CardBus Bridge", CB_CIRRUS}, 171 {PCIC_ID_CLPD6833, "CLPD6833 PCI-CardBus Bridge", CB_CIRRUS}, 172 {PCIC_ID_CLPD6834, "CLPD6834 PCI-CardBus Bridge", CB_CIRRUS}, |
173 174 /* 02Micro */ |
175 {PCIC_ID_OZ6832, "O2Mirco OZ6832/6833 PCI-CardBus Bridge", CB_CIRRUS}, 176 {PCIC_ID_OZ6860, "O2Mirco OZ6836/6860 PCI-CardBus Bridge", CB_CIRRUS}, 177 {PCIC_ID_OZ6872, "O2Mirco OZ6812/6872 PCI-CardBus Bridge", CB_CIRRUS}, 178 {PCIC_ID_OZ6912, "O2Mirco OZ6912/6972 PCI-CardBus Bridge", CB_CIRRUS}, 179 {PCIC_ID_OZ6922, "O2Mirco OZ6822 PCI-CardBus Bridge", CB_CIRRUS}, 180 {PCIC_ID_OZ6933, "O2Mirco OZ6833 PCI-CardBus Bridge", CB_CIRRUS}, |
181 182 /* sentinel */ 183 {0 /* null id */, "unknown", CB_UNKNOWN}, 184}; 185 186/* sysctl vars */ 187SYSCTL_NODE(_hw, OID_AUTO, cbb, CTLFLAG_RD, 0, "CBB parameters"); 188 --- 97 unchanged lines hidden (view full) --- 286} 287 288static __inline void 289pccbb_clrb(struct pccbb_softc *sc, uint32_t reg, uint32_t bits) 290{ 291 pccbb_set(sc, reg, pccbb_get(sc, reg) & ~bits); 292} 293 |
294static void 295pccbb_remove_res(struct pccbb_softc *sc, struct resource *res) 296{ 297 struct pccbb_reslist *rle; 298 299 SLIST_FOREACH(rle, &sc->rl, link) { 300 if (rle->res == res) { 301 SLIST_REMOVE(&sc->rl, rle, pccbb_reslist, link); --- 96 unchanged lines hidden (view full) --- 398 } 399 return (ENXIO); 400} 401 402 403static void 404pccbb_chipinit(struct pccbb_softc *sc) 405{ |
406 uint32_t mux, sysctrl; 407 |
408 /* Set CardBus latency timer */ 409 if (pci_read_config(sc->dev, PCIR_SECLAT_1, 1) < 0x20) 410 pci_write_config(sc->dev, PCIR_SECLAT_1, 0x20, 1); 411 412 /* Set PCI latency timer */ 413 if (pci_read_config(sc->dev, PCIR_LATTIMER, 1) < 0x20) 414 pci_write_config(sc->dev, PCIR_LATTIMER, 0x20, 1); 415 --- 38 unchanged lines hidden (view full) --- 454 PCI_MASK_CONFIG(sc->dev, CBBR_CBCTRL, 455 | CBBM_CBCTRL_113X_PCI_INTR | 456 CBBM_CBCTRL_113X_PCI_CSC | CBBM_CBCTRL_113X_PCI_IRQ_EN, 457 1); 458 PCI_MASK_CONFIG(sc->dev, CBBR_DEVCTRL, 459 & ~(CBBM_DEVCTRL_INT_SERIAL | 460 CBBM_DEVCTRL_INT_PCI), 1); 461 break; |
462 case CB_TI12XX: 463 /* 464 * Some TI 12xx (and [14][45]xx) based pci cards 465 * sometimes have issues with the MFUNC register not 466 * being initialized due to a bad EEPROM on board. 467 * Laptops that this matters on have this register 468 * properly initialized. 469 * 470 * The TI125X parts have a different register. 471 */ 472 mux = pci_read_config(sc->dev, CBBR_MFUNC, 4); 473 sysctrl = pci_read_config(sc->dev, CBBR_SYSCTRL, 4); 474 if (mux == 0) { 475 mux = (mux & ~CBBM_MFUNC_PIN0) | 476 CBBM_MFUNC_PIN0_INTA; 477 if ((sysctrl & CBBM_SYSCTRL_INTRTIE) == 0) 478 mux = (mux & ~CBBM_MFUNC_PIN1) | 479 CBBM_MFUNC_PIN1_INTB; 480 pci_write_config(sc->dev, CBBR_MFUNC, mux, 4); 481 } 482 /*FALLTHROUGH*/ 483 case CB_TI125X: 484 /* 485 * Disable zoom video. Some machines initialize this 486 * improperly and exerpience has shown that this helps 487 * on some machines. 488 */ 489 pci_write_config(sc->dev, CBBR_MMCTRL, 0, 4); 490 break; |
491 case CB_TOPIC97: 492 /* 493 * Disable Zoom Video, ToPIC 97, 100. 494 */ 495 pci_write_config(sc->dev, CBBR_TOPIC_ZV_CONTROL, 0, 1); 496 /* 497 * ToPIC 97, 100 498 * At offset 0xa1: INTERRUPT CONTROL register --- 57 unchanged lines hidden (view full) --- 556 pci_write_config(sc->dev, CBBR_IOLIMIT1, 0, 4); 557} 558 559static int 560pccbb_attach(device_t brdev) 561{ 562 struct pccbb_softc *sc = (struct pccbb_softc *)device_get_softc(brdev); 563 int rid; |
564 565 mtx_init(&sc->mtx, device_get_nameunit(brdev), "pccbb", MTX_DEF); 566 cv_init(&sc->cv, "pccbb cv"); 567 sc->chipset = pccbb_chipset(pci_get_devid(brdev), NULL); 568 sc->dev = brdev; 569 sc->cbdev = NULL; 570 sc->pccarddev = NULL; 571 sc->secbus = pci_read_config(brdev, PCIR_SECBUS_2, 1); --- 41 unchanged lines hidden (view full) --- 613 DEVPRINTF((brdev, "PCI Memory allocated: %08lx\n", 614 rman_get_start(sc->base_res))); 615 } else { 616 device_printf(brdev, "Could not map register memory\n"); 617 mtx_destroy(&sc->mtx); 618 cv_destroy(&sc->cv); 619 return (ENOMEM); 620 } |
621#endif |
622 } 623 624 sc->bst = rman_get_bustag(sc->base_res); 625 sc->bsh = rman_get_bushandle(sc->base_res); |
626 exca_init(&sc->exca, brdev, sc->bst, sc->bsh, CBB_EXCA_OFFSET); 627 sc->exca.flags |= EXCA_HAS_MEMREG_WIN; |
628 pccbb_chipinit(sc); 629 630 /* attach children */ 631 sc->cbdev = device_add_child(brdev, "cardbus", -1); 632 if (sc->cbdev == NULL) 633 DEVPRINTF((brdev, "WARNING: cannot add cardbus bus.\n")); 634 else if (device_probe_and_attach(sc->cbdev) != 0) { 635 DEVPRINTF((brdev, "WARNING: cannot attach cardbus bus!\n")); --- 1332 unchanged lines hidden --- |