Deleted Added
full compact
33c33
< __FBSDID("$FreeBSD: head/sys/dev/pccard/pccard.c 121521 2003-10-26 00:51:40Z imp $");
---
> __FBSDID("$FreeBSD: head/sys/dev/pccard/pccard.c 121905 2003-11-02 20:18:19Z imp $");
266c266,267
< "offset %x: %x %x %x %x, %x %x %x %x, %x\n",
---
> "offset %x mask %x: "
> "%x %x %x %x, %x %x %x %x, %x\n",
268c269
< pccard_ccr_read(pf, 0x00),
---
> pf->ccr_mask, pccard_ccr_read(pf, 0x00),
530a532,568
> static void
> pccard_mfc_adjust_iobase(struct pccard_function *pf, bus_addr_t addr,
> bus_addr_t offset, bus_size_t size)
> {
> bus_addr_t iosize;
> bus_size_t tmp;
>
> if (addr != 0) {
> if (pf->pf_mfc_iomax == 0) {
> pf->pf_mfc_iobase = addr + offset;
> pf->pf_mfc_iomax = pf->pf_mfc_iobase + size;
> } else {
> /* this makes the assumption that nothing overlaps */
> if (pf->pf_mfc_iobase > addr + offset)
> pf->pf_mfc_iobase = addr + offset;
> if (pf->pf_mfc_iomax < addr + offset + size)
> pf->pf_mfc_iomax = addr + offset + size;
> }
> }
>
> tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase;
> /* round up to nearest (2^n)-1 */
> for (iosize = 1; iosize < tmp; iosize <<= 1)
> ;
> iosize--;
>
> DEVPRINTF((pf->dev, "MFC: I/O base 0x%x IOSIZE %lld\n",
> pf->pf_mfc_iobase, (uint64_t) iosize));
> pccard_ccr_write(pf, PCCARD_CCR_IOBASE0,
> pf->pf_mfc_iobase & 0xff);
> pccard_ccr_write(pf, PCCARD_CCR_IOBASE1,
> (pf->pf_mfc_iobase >> 8) & 0xff);
> pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0);
> pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0);
> pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize);
> }
>
618,619c656,657
< if (pccard_mfc(pf->sc)) {
< long tmp, iosize;
---
> if (pccard_mfc(pf->sc))
> pccard_mfc_adjust_iobase(pf, 0, 0, 0);
621,636d658
< tmp = pf->pf_mfc_iomax - pf->pf_mfc_iobase;
< /* round up to nearest (2^n)-1 */
< for (iosize = 1; iosize < tmp; iosize <<= 1)
< ;
< iosize--;
<
< pccard_ccr_write(pf, PCCARD_CCR_IOBASE0,
< pf->pf_mfc_iobase & 0xff);
< pccard_ccr_write(pf, PCCARD_CCR_IOBASE1,
< (pf->pf_mfc_iobase >> 8) & 0xff);
< pccard_ccr_write(pf, PCCARD_CCR_IOBASE2, 0);
< pccard_ccr_write(pf, PCCARD_CCR_IOBASE3, 0);
<
< pccard_ccr_write(pf, PCCARD_CCR_IOSIZE, iosize);
< }
<
1054a1077
> int isdefault = (start == 0 && end == ~0UL && count == 1);
1056a1080
> /* XXX I'm no longer sure this is right */
1065,1087c1089,1103
< if (rle == NULL)
< return (NULL); /* no resource of that type/rid */
<
< if (rle->res == NULL) {
< switch(type) {
< case SYS_RES_IOPORT:
< r = bus_alloc_resource(dev, type, rid, start, end,
< count, rman_make_alignment_flags(count));
< if (r == NULL)
< goto bad;
< resource_list_add(&dinfo->resources, type, *rid,
< rman_get_start(r), rman_get_end(r), count);
< rle = resource_list_find(&dinfo->resources, type, *rid);
< if (!rle)
< goto bad;
< rle->res = r;
< break;
< case SYS_RES_MEMORY:
< break;
< case SYS_RES_IRQ:
< break;
< }
< return (rle->res);
---
> if (rle == NULL && isdefault)
> return (NULL); /* no resource of that type/rid */
> if (rle == NULL || rle->res == NULL) {
> /* Do we want this device to own it? */
> /* XXX I think so, but that might be lame XXX */
> r = bus_alloc_resource(dev, type, rid, start, end,
> count, flags /* XXX aligment? */);
> if (r == NULL)
> goto bad;
> resource_list_add(&dinfo->resources, type, *rid,
> rman_get_start(r), rman_get_end(r), count);
> rle = resource_list_find(&dinfo->resources, type, *rid);
> if (!rle)
> goto bad;
> rle->res = r;
1088a1105,1109
> /*
> * XXX the following looks wrong, in theory, but likely it is
> * XXX needed because of how the CIS code allocates resources
> * XXX for this device.
> */
1254a1276,1306
> static int
> pccard_activate_resource(device_t brdev, device_t child, int type, int rid,
> struct resource *r)
> {
> struct pccard_ivar *ivar = PCCARD_IVAR(child);
> struct pccard_function *pf = ivar->fcn;
>
> switch(type) {
> case SYS_RES_IOPORT:
> /*
> * We need to adjust IOBASE[01] and IOSIZE if we're an MFC
> * card.
> */
> if (pccard_mfc(pf->sc))
> pccard_mfc_adjust_iobase(pf, rman_get_start(r), 0,
> rman_get_size(r));
> break;
> default:
> break;
> }
> return (bus_generic_activate_resource(brdev, child, type, rid, r));
> }
>
> static int
> pccard_deactivate_resource(device_t brdev, device_t child, int type,
> int rid, struct resource *r)
> {
> /* XXX undo pccard_activate_resource? XXX */
> return (bus_generic_deactivate_resource(brdev, child, type, rid, r));
> }
>
1270,1271c1322,1323
< DEVMETHOD(bus_activate_resource, bus_generic_activate_resource),
< DEVMETHOD(bus_deactivate_resource, bus_generic_deactivate_resource),
---
> DEVMETHOD(bus_activate_resource, pccard_activate_resource),
> DEVMETHOD(bus_deactivate_resource, pccard_deactivate_resource),