diff --git a/sys/arm/xscale/ixp425/if_npe.c b/sys/arm/xscale/ixp425/if_npe.c index e7738c9a23fb..3b797df02891 100644 --- a/sys/arm/xscale/ixp425/if_npe.c +++ b/sys/arm/xscale/ixp425/if_npe.c @@ -550,11 +550,27 @@ npe_activate(device_t dev) struct npe_softc * sc = device_get_softc(dev); int unit = device_get_unit(dev); int error, i; + uint32_t imageid; - /* load NPE firmware and start it running */ - error = ixpnpe_init(sc->sc_npe, "npe_fw", npeconfig[unit].imageid); - if (error != 0) - return error; + /* + * Load NPE firmware and start it running. We assume + * that minor version bumps remain compatible so probe + * the firmware image starting with the expected version + * and then bump the minor version up to the max. + */ + imageid = npeconfig[unit].imageid; + for (;;) { + error = ixpnpe_init(sc->sc_npe, "npe_fw", imageid); + if (error == 0) + break; + /* ESRCH is returned when the requested image is not present */ + if (error != ESRCH) + return error; + /* bump the minor version up to the max possible */ + if (NPEIMAGE_MINOR(imageid) == 0xff) + return error; + imageid++; + } if (bus_space_map(sc->sc_iot, npeconfig[unit].regbase, npeconfig[unit].regsize, 0, &sc->sc_ioh)) { diff --git a/sys/arm/xscale/ixp425/ixp425_npe.c b/sys/arm/xscale/ixp425/ixp425_npe.c index 2d5680d29678..a35a4ad2bcbf 100644 --- a/sys/arm/xscale/ixp425/ixp425_npe.c +++ b/sys/arm/xscale/ixp425/ixp425_npe.c @@ -407,14 +407,14 @@ npe_findimage(struct ixpnpe_softc *sc, } /* 2 consecutive NPE_IMAGE_MARKER's indicates end of library */ if (image->id == NPE_IMAGE_MARKER) { - device_printf(sc->sc_dev, + DPRINTF(sc->sc_dev, "imageId 0x%08x not found in image library header\n", imageId); /* reached end of library, image not found */ - return EIO; + return ESRCH; } offset += image->size; } - return EIO; + return ESRCH; } int diff --git a/sys/arm/xscale/ixp425/ixp425_npevar.h b/sys/arm/xscale/ixp425/ixp425_npevar.h index c30ff5f55117..6d365fcb1001 100644 --- a/sys/arm/xscale/ixp425/ixp425_npevar.h +++ b/sys/arm/xscale/ixp425/ixp425_npevar.h @@ -32,7 +32,17 @@ * * Firmware Id's for current firmware image. These are typed by * NPE ID and the feature set. Not all features are available - * on all NPE's. + * on all NPE's. The Image ID has the following structure: + * + * Field [Bit Location] + * ----------------------------------- + * Device ID [28..31] + * NPE ID [24..27] + * NPE Functionality ID [16..23] + * Major Release Number [8..15] + * Minor Release Number [0..7] + * + * The following "feature sets" are known to exist: * * HSS-0: supports 32 channelized and 4 packetized. * HSS-0 + ATM + SPHY: @@ -56,6 +66,15 @@ * ETH+VLAN+HDR: Ethernet Rx/Tx which includes: * SPANNING_TREE, FIREWALL, VLAN_QOS, HEADER_CONVERSION */ +#define NPEIMAGE_DEVID(id) (((id) >> 28) & 0xf) +#define NPEIMAGE_NPEID(id) (((id) >> 24) & 0xf) +#define NPEIMAGE_FUNCID(id) (((id) >> 16) & 0xff) +#define NPEIMAGE_MAJOR(id) (((id) >> 8) & 0xff) +#define NPEIMAGE_MINOR(id) (((id) >> 0) & 0xff) +#define NPEIMAGE_MAKEID(dev, npe, func, maj, min) \ + ((((dev) & 0xf) << 28) | (((npe) & 0xf) << 24) | \ + (((func) & 0xff) << 16) (((maj) & 0xff) << 8) | (((min) & 0xff) << 0)) + /* XXX not right, revise */ /* NPE A Firmware Image Id's */ #define NPEFW_A_HSS0 0x00010000 /* HSS-0: 32 chan+4 packet */