diff --git a/sys/dev/cardbus/cardbus_cis.c b/sys/dev/cardbus/cardbus_cis.c index 8c1cb768a7e9..4d7b97358576 100644 --- a/sys/dev/cardbus/cardbus_cis.c +++ b/sys/dev/cardbus/cardbus_cis.c @@ -493,21 +493,21 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start, struct resource *res; uint32_t space; - space = CARDBUS_CIS_SPACE(*start); + space = *start & PCIM_CIS_ASI_MASK; switch (space) { - case CARDBUS_CIS_ASI_TUPLE: + case PCIM_CIS_ASI_TUPLE: /* CIS in PCI config space need no initialization */ return ((struct resource*)~0UL); - case CARDBUS_CIS_ASI_BAR0: - case CARDBUS_CIS_ASI_BAR1: - case CARDBUS_CIS_ASI_BAR2: - case CARDBUS_CIS_ASI_BAR3: - case CARDBUS_CIS_ASI_BAR4: - case CARDBUS_CIS_ASI_BAR5: - *rid = PCIR_BAR(space - CARDBUS_CIS_ASI_BAR0); + case PCIM_CIS_ASI_BAR0: + case PCIM_CIS_ASI_BAR1: + case PCIM_CIS_ASI_BAR2: + case PCIM_CIS_ASI_BAR3: + case PCIM_CIS_ASI_BAR4: + case PCIM_CIS_ASI_BAR5: + *rid = PCIR_BAR(space - PCIM_CIS_ASI_BAR0); break; - case CARDBUS_CIS_ASI_ROM: - *rid = CARDBUS_ROM_REG; + case PCIM_CIS_ASI_ROM: + *rid = PCIR_BIOS; break; default: device_printf(cbdev, "Unable to read CIS: Unknown space: %d\n", @@ -523,7 +523,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start, * This bit has a different meaning depending if we are dealing * with a normal BAR or an Option ROM BAR. */ - if (((testval & 0x1) == 0x1) && (*rid != CARDBUS_ROM_REG)) { + if (((testval & 0x1) == 0x1) && (*rid != PCIR_BIOS)) { device_printf(cbdev, "CIS Space is IO, expecting memory.\n"); return (NULL); } @@ -541,12 +541,12 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start, return (NULL); } pci_write_config(child, *rid, - rman_get_start(res) | ((*rid == CARDBUS_ROM_REG) ? - CARDBUS_ROM_ENABLE : 0), 4); + rman_get_start(res) | ((*rid == PCIR_BIOS) ? PCIM_BIOS_ENABLE : 0), + 4); PCI_ENABLE_IO(cbdev, child, SYS_RES_MEMORY); /* Flip to the right ROM image if CIS is in ROM */ - if (space == CARDBUS_CIS_ASI_ROM) { + if (space == PCIM_CIS_ASI_ROM) { bus_space_tag_t bt; bus_space_handle_t bh; uint32_t imagesize; @@ -559,7 +559,7 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start, bt = rman_get_bustag(res); bh = rman_get_bushandle(res); - imagenum = CARDBUS_CIS_ASI_ROM_IMAGE(*start); + imagenum = (*start & PCIM_CIS_ROM_MASK) >> 28; for (romnum = 0;; romnum++) { romsig = bus_space_read_2(bt, bh, imagebase + CARDBUS_EXROM_SIGNATURE); @@ -611,9 +611,9 @@ cardbus_read_tuple_init(device_t cbdev, device_t child, uint32_t *start, } imagebase += imagesize; } - *start = imagebase + CARDBUS_CIS_ADDR(*start); + *start = imagebase + (*start & PCIM_CIS_ADDR_MASK); } else { - *start = CARDBUS_CIS_ADDR(*start); + *start = *start & PCIM_CIS_ADDR_MASK; } return (res); @@ -652,7 +652,7 @@ cardbus_parse_cis(device_t cbdev, device_t child, bzero(tupledata, MAXTUPLESIZE); expect_linktarget = TRUE; - if ((start = pci_read_config(child, CARDBUS_CIS_REG, 4)) == 0) { + if ((start = pci_read_config(child, PCIR_CIS, 4)) == 0) { device_printf(cbdev, "CIS pointer is 0!\n"); return (ENXIO); } diff --git a/sys/dev/cardbus/cardbusreg.h b/sys/dev/cardbus/cardbusreg.h index 04f4b7bf8ce6..741ee7f97255 100644 --- a/sys/dev/cardbus/cardbusreg.h +++ b/sys/dev/cardbus/cardbusreg.h @@ -35,22 +35,6 @@ #define CARDBUS_SLOTMAX 0 #define CARDBUS_FUNCMAX 7 -/* Cardbus configuration header registers */ -#define CARDBUS_CIS_REG 0x28 -# define CARDBUS_CIS_ASIMASK 0x07 -# define CARDBUS_CIS_ADDRMASK 0x0ffffff8 -# define CARDBUS_CIS_ASI_TUPLE 0x00 -# define CARDBUS_CIS_ASI_BAR0 0x01 -# define CARDBUS_CIS_ASI_BAR1 0x02 -# define CARDBUS_CIS_ASI_BAR2 0x03 -# define CARDBUS_CIS_ASI_BAR3 0x04 -# define CARDBUS_CIS_ASI_BAR4 0x05 -# define CARDBUS_CIS_ASI_BAR5 0x06 -# define CARDBUS_CIS_ASI_ROM 0x07 -#define CARDBUS_ROM_REG 0x30 -# define CARDBUS_ROM_ENABLE 0x00000001 -# define CARDBUS_ROM_ADDRMASK 0xfffff800 - /* EXROM offsets for reading CIS */ #define CARDBUS_EXROM_SIGNATURE 0x00 #define CARDBUS_EXROM_DATA_PTR 0x18 @@ -66,16 +50,6 @@ #define CARDBUS_EXROM_DATA_CODE_TYPE 0x14 /* Code Type */ #define CARDBUS_EXROM_DATA_INDICATOR 0x15 /* Indicator */ -/* useful macros */ -#define CARDBUS_CIS_ADDR(x) \ - (CARDBUS_CIS_ADDRMASK & (x)) -#define CARDBUS_CIS_SPACE(x) \ - (CARDBUS_CIS_ASIMASK & (x)) -#define CARDBUS_CIS_ASI_BAR(x) \ - (((CARDBUS_CIS_ASIMASK & (x))-1)*4+0x10) -#define CARDBUS_CIS_ASI_ROM_IMAGE(x) \ - (((x) >> 28) & 0xf) - #define CARDBUS_MAPREG_MEM_ADDR_MASK 0x0ffffff0 #define CARDBUS_MAPREG_MEM_ADDR(mr) \ ((mr) & CARDBUS_MAPREG_MEM_ADDR_MASK)