Lines Matching +full:bus +full:- +full:num
1 /*-
2 * SPDX-License-Identifier: BSD-4-Clause AND BSD-2-Clause
4 * Copyright (c) 2002-2005 M. Warner Losh <imp@FreeBSD.org>
69 #include <sys/bus.h>
70 #include <machine/bus.h>
91 "Intel i82365SL-A/B or clone",
92 "Intel i82365sl-DF step",
114 #define EXCA_MEMINFO(NUM) { \
115 EXCA_SYSMEM_ADDR ## NUM ## _START_LSB, \
116 EXCA_SYSMEM_ADDR ## NUM ## _START_MSB, \
117 EXCA_SYSMEM_ADDR ## NUM ## _STOP_LSB, \
118 EXCA_SYSMEM_ADDR ## NUM ## _STOP_MSB, \
119 EXCA_SYSMEM_ADDR ## NUM ## _WIN, \
120 EXCA_CARDMEM_ADDR ## NUM ## _LSB, \
121 EXCA_CARDMEM_ADDR ## NUM ## _MSB, \
122 EXCA_ADDRWIN_ENABLE_MEM ## NUM, \
146 return (bus_space_read_1(sc->bst, sc->bsh, sc->offset + reg));
152 bus_space_write_1(sc->bst, sc->bsh, sc->offset + reg, val);
158 bus_space_write_1(sc->bst, sc->bsh, EXCA_REG_INDEX, reg + sc->offset);
159 return (bus_space_read_1(sc->bst, sc->bsh, EXCA_REG_DATA));
165 bus_space_write_1(sc->bst, sc->bsh, EXCA_REG_INDEX, reg + sc->offset);
166 bus_space_write_1(sc->bst, sc->bsh, EXCA_REG_DATA, val);
185 mem = &sc->mem[win];
186 mem16 = (mem->kind & PCCARD_MEM_16BIT) ?
188 attrmem = (mem->kind & PCCARD_MEM_ATTR) ?
190 offset = ((mem->cardaddr >> EXCA_CARDMEM_ADDRX_SHIFT) -
191 (mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT)) & 0x3fff;
192 exca_putb(sc, map->sysmem_start_lsb,
193 mem->addr >> EXCA_SYSMEM_ADDRX_SHIFT);
194 exca_putb(sc, map->sysmem_start_msb,
195 ((mem->addr >> (EXCA_SYSMEM_ADDRX_SHIFT + 8)) &
198 exca_putb(sc, map->sysmem_stop_lsb,
199 (mem->addr + mem->realsize - 1) >> EXCA_SYSMEM_ADDRX_SHIFT);
200 exca_putb(sc, map->sysmem_stop_msb,
201 (((mem->addr + mem->realsize - 1) >>
205 exca_putb(sc, map->sysmem_win, mem->addr >> EXCA_MEMREG_WIN_SHIFT);
207 exca_putb(sc, map->cardmem_lsb, offset & 0xff);
208 exca_putb(sc, map->cardmem_msb, ((offset >> 8) &
211 DPRINTF("%s %d-bit memory",
212 mem->kind & PCCARD_MEM_ATTR ? "attribute" : "common",
213 mem->kind & PCCARD_MEM_16BIT ? 16 : 8);
214 exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->memenable |
221 r1 = exca_getb(sc, map->sysmem_start_msb);
222 r2 = exca_getb(sc, map->sysmem_start_lsb);
223 r3 = exca_getb(sc, map->sysmem_stop_msb);
224 r4 = exca_getb(sc, map->sysmem_stop_lsb);
225 r5 = exca_getb(sc, map->cardmem_msb);
226 r6 = exca_getb(sc, map->cardmem_lsb);
227 r7 = exca_getb(sc, map->sysmem_win);
231 mem->addr, mem->size, mem->realsize,
232 mem->cardaddr, mem->kind);
251 if ((sc->memalloc & (1 << win)) == 0) {
252 sc->memalloc |= (1 << win);
258 if (sc->flags & EXCA_HAS_MEMREG_WIN) {
261 device_printf(sc->dev,
268 device_printf(sc->dev,
274 sc->mem[win].cardaddr = 0;
275 sc->mem[win].memt = rman_get_bustag(res);
276 sc->mem[win].memh = rman_get_bushandle(res);
277 sc->mem[win].addr = rman_get_start(res);
278 sc->mem[win].size = rman_get_end(res) - sc->mem[win].addr + 1;
279 sc->mem[win].realsize = sc->mem[win].size + EXCA_MEM_PAGESIZE - 1;
280 sc->mem[win].realsize = sc->mem[win].realsize -
281 (sc->mem[win].realsize % EXCA_MEM_PAGESIZE);
282 sc->mem[win].kind = kind;
283 DPRINTF("exca_mem_map window %d bus %x+%x card addr %x\n",
284 win, sc->mem[win].addr, sc->mem[win].size, sc->mem[win].cardaddr);
305 sc->memalloc &= ~(1 << window);
321 if (sc->mem[win].memt == rman_get_bustag(res) &&
322 sc->mem[win].addr == rman_get_start(res) &&
323 sc->mem[win].size == rman_get_size(res))
326 return (-1);
345 device_printf(sc->dev,
353 sc->mem[win].kind |= PCCARD_MEM_ATTR;
356 sc->mem[win].kind &= ~PCCARD_MEM_ATTR;
359 sc->mem[win].kind |= PCCARD_MEM_16BIT;
362 sc->mem[win].kind &= ~PCCARD_MEM_16BIT;
400 device_printf(sc->dev,
404 sc->mem[win].cardaddr = rounddown2(cardaddr, EXCA_MEM_PAGESIZE);
408 sc->mem[win].realsize = sc->mem[win].size + delta +
409 EXCA_MEM_PAGESIZE - 1;
410 sc->mem[win].realsize = sc->mem[win].realsize -
411 (sc->mem[win].realsize % EXCA_MEM_PAGESIZE);
420 #define EXCA_IOINFO(NUM) { \
421 EXCA_IOADDR ## NUM ## _START_LSB, \
422 EXCA_IOADDR ## NUM ## _START_MSB, \
423 EXCA_IOADDR ## NUM ## _STOP_LSB, \
424 EXCA_IOADDR ## NUM ## _STOP_MSB, \
425 EXCA_ADDRWIN_ENABLE_IO ## NUM, \
426 EXCA_IOCTL_IO ## NUM ## _WAITSTATE \
427 | EXCA_IOCTL_IO ## NUM ## _ZEROWAIT \
428 | EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_MASK \
429 | EXCA_IOCTL_IO ## NUM ## _DATASIZE_MASK, \
431 EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_CARD, \
432 EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_DATASIZE \
433 | EXCA_IOCTL_IO ## NUM ## _DATASIZE_8BIT, \
434 EXCA_IOCTL_IO ## NUM ## _IOCS16SRC_DATASIZE \
435 | EXCA_IOCTL_IO ## NUM ## _DATASIZE_16BIT, \
461 io = &sc->io[win];
462 exca_putb(sc, map->start_lsb, io->addr & 0xff);
463 exca_putb(sc, map->start_msb, (io->addr >> 8) & 0xff);
465 exca_putb(sc, map->stop_lsb, (io->addr + io->size - 1) & 0xff);
466 exca_putb(sc, map->stop_msb, ((io->addr + io->size - 1) >> 8) & 0xff);
468 exca_clrb(sc, EXCA_IOCTL, map->ioctlmask);
469 exca_setb(sc, EXCA_IOCTL, map->ioctlbits[io->width]);
471 exca_setb(sc, EXCA_ADDRWIN_ENABLE, map->ioenable);
475 r1 = exca_getb(sc, map->start_msb);
476 r2 = exca_getb(sc, map->start_lsb);
477 r3 = exca_getb(sc, map->stop_msb);
478 r4 = exca_getb(sc, map->stop_lsb);
481 io->addr, io->size);
494 if ((sc->ioalloc & (1 << win)) == 0) {
495 sc->ioalloc |= (1 << win);
502 sc->io[win].iot = rman_get_bustag(r);
503 sc->io[win].ioh = rman_get_bushandle(r);
504 sc->io[win].addr = rman_get_start(r);
505 sc->io[win].size = rman_get_end(r) - sc->io[win].addr + 1;
506 sc->io[win].flags = 0;
507 sc->io[win].width = width;
509 win, width_names[width], sc->io[win].addr,
510 sc->io[win].size);
524 sc->ioalloc &= ~(1 << window);
526 sc->io[window].iot = 0;
527 sc->io[window].ioh = 0;
528 sc->io[window].addr = 0;
529 sc->io[window].size = 0;
530 sc->io[window].flags = 0;
531 sc->io[window].width = 0;
540 if (sc->io[win].iot == rman_get_bustag(res) &&
541 sc->io[win].addr == rman_get_start(res) &&
542 sc->io[win].size == rman_get_size(res))
545 return (-1);
575 DEVPRINTF(sc->dev, "exca_wait_ready: status 0x%02x\n",
582 device_printf(sc->dev, "ready never happened, status = %02x\n",
621 DEVPRINTF(sc->dev, "card type is io\n");
625 if (sc->memalloc & (1 << win))
628 if (sc->ioalloc & (1 << win))
639 sc->dev = dev;
640 sc->memalloc = 0;
641 sc->ioalloc = 0;
642 sc->bst = bst;
643 sc->bsh = bsh;
644 sc->offset = offset;
645 sc->flags = 0;
646 sc->getb = exca_mem_getb;
647 sc->putb = exca_mem_putb;
648 sc->pccarddev = device_add_child(dev, "pccard", DEVICE_UNIT_ANY);
649 if (sc->pccarddev == NULL)
650 DEVPRINTF(brdev, "WARNING: cannot add pccard bus.\n");
651 else if (device_probe_and_attach(sc->pccarddev) != 0)
652 DEVPRINTF(brdev, "WARNING: cannot attach pccard bus.\n");
664 exca->chipset = EXCA_BOGUS;
672 DEVPRINTF(exca->dev, "Ident is %x\n", c);
683 exca->chipset = EXCA_I82365;
691 bus_space_write_1(exca->bst, exca->bsh, EXCA_REG_INDEX,
693 bus_space_write_1(exca->bst, exca->bsh, EXCA_REG_INDEX,
700 exca->chipset = EXCA_VG365;
703 exca->chipset = EXCA_VG465;
706 exca->chipset = EXCA_VG468;
709 exca->chipset = EXCA_VG469;
720 exca->chipset = EXCA_RF5C396;
723 exca->chipset = EXCA_RF5C296;
736 exca->chipset = EXCA_PD6722;
738 exca->chipset = EXCA_PD6710;
746 * Intel i82365sl-DF step or maybe a vlsi 82c146
749 * XXXX Except we didn't -- this is a regression but VLSI
752 exca->chipset = EXCA_I82365SL_DF;
756 exca->chipset = EXCA_IBM;
759 exca->chipset = EXCA_IBM_KING;
784 exca->getb = exca_io_getb;
785 exca->putb = exca_io_putb;
797 if (device_is_attached(exca->pccarddev)) {
798 if (CARD_ATTACH_CARD(exca->pccarddev) != 0)
799 device_printf(exca->dev,
802 device_printf(exca->dev,
803 "PC Card inserted, but no pccard bus.\n");
811 if (device_is_attached(exca->pccarddev))
812 CARD_DETACH_CARD(exca->pccarddev);
823 err = BUS_ACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
836 BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
857 return (BUS_DEACTIVATE_RESOURCE(device_get_parent(exca->dev), child,
885 tmp = rman_get_start(sc->irq_res);
887 device_printf(child, "requested interrupt %ld-%ld,"
893 start = end = rman_get_start(sc->irq_res);