svn commit: r349593 - head/sys/dev/bwn
Author: landonf Date: Tue Jul 2 02:52:05 2019 New Revision: 349593 URL: https://svnweb.freebsd.org/changeset/base/349593 Log: bwn(4): Include SROM revision when printing device identification. Modified: head/sys/dev/bwn/if_bwn.c Modified: head/sys/dev/bwn/if_bwn.c == --- head/sys/dev/bwn/if_bwn.c Tue Jul 2 01:12:23 2019(r349592) +++ head/sys/dev/bwn/if_bwn.c Tue Jul 2 02:52:05 2019(r349593) @@ -632,9 +632,10 @@ bwn_attach(device_t dev) goto fail; bhnd_format_chip_id(chip_name, sizeof(chip_name), sc->sc_cid.chip_id); - device_printf(sc->sc_dev, "WLAN (%s rev %u) " + device_printf(sc->sc_dev, "WLAN (%s rev %u sromrev %u) " "PHY (analog %d type %d rev %d) RADIO (manuf %#x ver %#x rev %d)\n", - chip_name, bhnd_get_hwrev(sc->sc_dev), mac->mac_phy.analog, + chip_name, bhnd_get_hwrev(sc->sc_dev), + sc->sc_board_info.board_srom_rev, mac->mac_phy.analog, mac->mac_phy.type, mac->mac_phy.rev, mac->mac_phy.rf_manuf, mac->mac_phy.rf_ver, mac->mac_phy.rf_rev); if (mac->mac_flags & BWN_MAC_FLAG_DMA) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r331746 - in head/sys: dev/bhnd/bhndb mips/broadcom
Author: landonf Date: Thu Mar 29 19:48:50 2018 New Revision: 331746 URL: https://svnweb.freebsd.org/changeset/base/331746 Log: bhnd(4): Use the new BHND_CAP_BP64 capability flag to exclude DMA translations unsupported by the backplane. Modified: head/sys/dev/bhnd/bhndb/bhndb.c head/sys/mips/broadcom/bhnd_nexus.c Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Thu Mar 29 19:48:17 2018 (r331745) +++ head/sys/dev/bhnd/bhndb/bhndb.c Thu Mar 29 19:48:50 2018 (r331746) @@ -2128,7 +2128,14 @@ bhndb_get_dma_translation(device_t dev, device_t child if (sc->bus_res->res->dma_tags == NULL) return (ENODEV); - /* Find the best matching descriptor for the requested type */ + /* Is the requested width supported? */ + if (width > BHND_DMA_ADDR_32BIT) { + /* Backplane must support 64-bit addressing */ + if (!(sc->chipid.chip_caps & BHND_CAP_BP64)) + width = BHND_DMA_ADDR_32BIT; + } + + /* Find the best matching descriptor for the requested width */ addr_mask = BHND_DMA_ADDR_BITMASK(width); match = NULL; Modified: head/sys/mips/broadcom/bhnd_nexus.c == --- head/sys/mips/broadcom/bhnd_nexus.c Thu Mar 29 19:48:17 2018 (r331745) +++ head/sys/mips/broadcom/bhnd_nexus.c Thu Mar 29 19:48:50 2018 (r331746) @@ -234,10 +234,11 @@ bhnd_nexus_get_dma_translation(device_t dev, device_t KASSERT(width > 0 && width <= BHND_DMA_ADDR_64BIT, ("invalid width %u", width)); + /* Is the requested width supported? */ if (width > BHND_DMA_ADDR_32BIT) { /* Backplane must support 64-bit addressing */ - if (!(bp->cc_caps & CHIPC_CAP_BKPLN64)) - return (ENOENT); + if (!(bp->cid.chip_caps & BHND_CAP_BP64)) + width = BHND_DMA_ADDR_32BIT; } /* No DMA address translation required */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r331744 - in head: share/man/man9 sys/dev/bhnd sys/dev/bhnd/bcma sys/dev/bhnd/bhndb sys/dev/bhnd/siba
Author: landonf Date: Thu Mar 29 19:44:15 2018 New Revision: 331744 URL: https://svnweb.freebsd.org/changeset/base/331744 Log: bhnd(4): include a subset of the ChipCommon capability flags in bhnd_chipid; this provides early access to device capability flags required by bhnd(4) bus and bhndb(4) bridge drivers. Modified: head/share/man/man9/bhnd.9 head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_erom.c head/sys/dev/bhnd/bhnd_erom.h head/sys/dev/bhnd/bhnd_eromvar.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/siba/siba_erom.c Modified: head/share/man/man9/bhnd.9 == --- head/share/man/man9/bhnd.9 Thu Mar 29 19:43:29 2018(r331743) +++ head/share/man/man9/bhnd.9 Thu Mar 29 19:44:15 2018(r331744) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 19, 2018 +.Dd March 26, 2018 .Dt BHND 9 .Os .Sh NAME @@ -1130,6 +1130,10 @@ chip, each of which may require driver workarounds for unpopulated components, etc. .It Fa chip_type The interconnect architecture used by this chip. +.It Fa chip_caps +The +.Nm +capability flags supported by this chip. .It Fa enum_addr The backplane enumeration address. On SSB devices, this will be the base address of the first SSB core. @@ -1154,6 +1158,16 @@ This BCMA-derived interconnect is found in Broadcom BC BCM63xx xDSL SoCs. UBUS is not currently supported by .Xr bhnd 4 . +.El +.Pp +The following +.Fa chip_caps +flags are supported: +.Bl -tag -width ".Dv BHND_CAP_BP64" -offset indent -compact +.It Dv BHND_CAP_BP64 +The backplane supports 64-bit addressing. +.It Dv BHND_CAP_PMU +PMU is present. .El .Pp Additional symbolic constants for known Modified: head/sys/dev/bhnd/bcma/bcma_erom.c == --- head/sys/dev/bhnd/bcma/bcma_erom.c Thu Mar 29 19:43:29 2018 (r331743) +++ head/sys/dev/bhnd/bcma/bcma_erom.c Thu Mar 29 19:44:15 2018 (r331744) @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include #include -#include +#include #include "bcma_eromreg.h" #include "bcma_eromvar.h" @@ -168,23 +168,16 @@ static int bcma_erom_probe(bhnd_erom_class_t *cls, struct bhnd_erom_io *eio, const struct bhnd_chipid *hint, struct bhnd_chipid *cid) { - uint32_t idreg, eromptr; + int error; /* Hints aren't supported; all BCMA devices have a ChipCommon * core */ if (hint != NULL) return (EINVAL); - /* Confirm CHIPC_EROMPTR availability */ - idreg = bhnd_erom_io_read(eio, CHIPC_ID, 4); - if (!BHND_CHIPTYPE_HAS_EROM(CHIPC_GET_BITS(idreg, CHIPC_ID_BUS))) - return (ENXIO); - - /* Fetch EROM address */ - eromptr = bhnd_erom_io_read(eio, CHIPC_EROMPTR, 4); - - /* Parse chip identifier */ - *cid = bhnd_parse_chipid(idreg, eromptr); + /* Read and parse chip identification */ + if ((error = bhnd_erom_read_chipid(eio, cid))) + return (error); /* Verify chip type */ switch (cid->chip_type) { Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hThu Mar 29 19:43:29 2018(r331743) +++ head/sys/dev/bhnd/bhnd.hThu Mar 29 19:44:15 2018(r331744) @@ -219,6 +219,7 @@ struct bhnd_chipid { uint8_t chip_rev; /**< chip revision */ uint8_t chip_pkg; /**< chip package (BHND_PKGID_*) */ uint8_t chip_type; /**< chip type (BHND_CHIPTYPE_*) */ + uint32_tchip_caps; /**< chip capabilities (BHND_CAP_*) */ bhnd_addr_t enum_addr; /**< chip_type-specific enumeration * address; either the siba(4) base @@ -230,6 +231,15 @@ struct bhnd_chipid { }; /** + * Chip capabilities + */ +enum bhnd_cap { + BHND_CAP_BP64 = (1<<0), /**< Backplane supports 64-bit + * addressing */ + BHND_CAP_PMU= (1<<1), /**< PMU is present */ +}; + +/** * A bhnd(4) core descriptor. */ struct bhnd_core_info { @@ -519,18 +529,6 @@ int bhnd_alloc_resources(device_t dev, voidbhnd_release_resources(device_t dev, const struct resource_spec *rs, struct bhnd_resource **res); - -struct bhnd_chipid bhnd_parse_chipid(uint32_t idreg, -bhnd_addr_t enum_addr); - -int bhnd_chipid_fixed_ncores( -const struct bhnd_chipid *cid, -uint16_t chipc_hwrev, uint8_t *ncores); - -int
svn commit: r331378 - head/sys/dev/bhnd/nvram
Author: landonf Date: Thu Mar 22 22:13:46 2018 New Revision: 331378 URL: https://svnweb.freebsd.org/changeset/base/331378 Log: Add missing NULL checks when calling malloc(M_NOWAIT) in bhnd_nv_strdup/bhnd_nv_strndup. If malloc(9) failed during initial bhnd(4) attach, while allocating the root NVRAM path string ("/"), the returned NULL pointer would be passed as the destination to memcpy(). Reported by: Ilja Van SprundelModified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_private.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram_private.hThu Mar 22 21:57:10 2018(r331377) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_private.hThu Mar 22 22:13:46 2018(r331378) @@ -91,6 +91,9 @@ bhnd_nv_strdup(const char *str) len = strlen(str); dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT); + if (dest == NULL) + return (NULL); + memcpy(dest, str, len); dest[len] = '\0'; @@ -105,6 +108,9 @@ bhnd_nv_strndup(const char *str, size_t len) len = strnlen(str, len); dest = malloc(len + 1, M_BHND_NVRAM, M_NOWAIT); + if (dest == NULL) + return (NULL); + memcpy(dest, str, len); dest[len] = '\0'; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r329241 - head/sys/dev/bwn
Author: landonf Date: Tue Feb 13 20:07:40 2018 New Revision: 329241 URL: https://svnweb.freebsd.org/changeset/base/329241 Log: bwn(4): Conditionalize "RX decryption attempted" message on a new BWN_DEBUG_HWCRYPTO debug flag. The MAC will attempt decryption (and set BWN_RX_MAC_DEC) even if a key has not been supplied to the hardware; this is expected behavior, and there's no need to spam users' console with this debugging printf. Modified: head/sys/dev/bwn/if_bwn.c head/sys/dev/bwn/if_bwn_debug.h Modified: head/sys/dev/bwn/if_bwn.c == --- head/sys/dev/bwn/if_bwn.c Tue Feb 13 19:28:02 2018(r329240) +++ head/sys/dev/bwn/if_bwn.c Tue Feb 13 20:07:40 2018(r329241) @@ -5983,7 +5983,6 @@ bwn_rxeof(struct bwn_mac *mac, struct mbuf *m, const v int padding, rate, rssi = 0, noise = 0, type; uint16_t phytype, phystat0, phystat3, chanstat; unsigned char *mp = mtod(m, unsigned char *); - static int rx_mac_dec_rpt = 0; BWN_ASSERT_LOCKED(sc); @@ -6032,11 +6031,12 @@ bwn_rxeof(struct bwn_mac *mac, struct mbuf *m, const v } wh = mtod(m, struct ieee80211_frame_min *); - if (macstat & BWN_RX_MAC_DEC && rx_mac_dec_rpt++ < 50) - device_printf(sc->sc_dev, + if (macstat & BWN_RX_MAC_DEC) { + DPRINTF(sc, BWN_DEBUG_HWCRYPTO, "RX decryption attempted (old %d keyidx %#x)\n", BWN_ISOLDFMT(mac), (macstat & BWN_RX_MAC_KEYIDX) >> BWN_RX_MAC_KEYIDX_SHIFT); + } if (phystat0 & BWN_RX_PHYST0_OFDM) rate = bwn_plcp_get_ofdmrate(mac, plcp, Modified: head/sys/dev/bwn/if_bwn_debug.h == --- head/sys/dev/bwn/if_bwn_debug.h Tue Feb 13 19:28:02 2018 (r329240) +++ head/sys/dev/bwn/if_bwn_debug.h Tue Feb 13 20:07:40 2018 (r329241) @@ -53,6 +53,7 @@ enum { BWN_DEBUG_XMIT_POWER= 0x0002, BWN_DEBUG_PHY = 0x0004, BWN_DEBUG_EEPROM= 0x0008, + BWN_DEBUG_HWCRYPTO = 0x0010, /* HW crypto */ BWN_DEBUG_FATAL = 0x8000, /* fatal errors */ BWN_DEBUG_ANY = 0x }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r329228 - head/sys/gnu/dev/bwn/phy_n
Author: landonf Date: Tue Feb 13 17:43:54 2018 New Revision: 329228 URL: https://svnweb.freebsd.org/changeset/base/329228 Log: bwn(4): txpid2g/txpid5g[lh] are not defined after sromrev 7; the default indices into the TX power gain table should be used instead. This enables use of bwn(4) with later BCM4321 revisions. Reported by: Trev Roydhouse Modified: head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c Modified: head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c == --- head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c Tue Feb 13 17:42:16 2018(r329227) +++ head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c Tue Feb 13 17:43:54 2018(r329228) @@ -3906,6 +3906,9 @@ static int bwn_nphy_tx_power_fix(struct bwn_mac *mac) } else if (sc->sc_board_info.board_srom_rev < 4) { txpi[0] = 72; txpi[1] = 72; + } else if (sc->sc_board_info.board_srom_rev > 7) { + txpi[0] = 0; + txpi[1] = 0; } else { #defineBWN_NPHY_GET_TXPI(_name, _result) \ do { \ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r329184 - in head/sys: conf dev/bwn modules/bwn
Author: landonf Date: Mon Feb 12 22:21:11 2018 New Revision: 329184 URL: https://svnweb.freebsd.org/changeset/base/329184 Log: bwn(4): Fix outstanding bug in PHY-G tssi2dbm table generation caught by -Wconstant-conversion, and remove now unnecessary warning suppression flags. Modified: head/sys/conf/files head/sys/dev/bwn/if_bwn_phy_g.c head/sys/modules/bwn/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Feb 12 20:51:28 2018(r329183) +++ head/sys/conf/files Mon Feb 12 22:21:11 2018(r329184) @@ -1326,15 +1326,11 @@ dev/bwi/bwiphy.coptional bwi dev/bwi/bwirf.coptional bwi dev/bwi/if_bwi.c optional bwi dev/bwi/if_bwi_pci.c optional bwi pci -# XXX Work around clang warnings, until maintainer approves fix. -dev/bwn/if_bwn.c optional bwn bhnd \ - compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}" +dev/bwn/if_bwn.c optional bwn bhnd dev/bwn/if_bwn_pci.c optional bwn pci bhnd bhndb bhndb_pci dev/bwn/if_bwn_phy_common.coptional bwn bhnd -dev/bwn/if_bwn_phy_g.c optional bwn bhnd \ - compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED} ${NO_WCONSTANT_CONVERSION}" -dev/bwn/if_bwn_phy_lp.coptional bwn bhnd \ - compile-with "${NORMAL_C} ${NO_WSOMETIMES_UNINITIALIZED}" +dev/bwn/if_bwn_phy_g.c optional bwn bhnd +dev/bwn/if_bwn_phy_lp.coptional bwn bhnd dev/bwn/if_bwn_phy_n.c optional bwn bhnd dev/bwn/if_bwn_util.c optional bwn bhnd dev/cardbus/cardbus.c optional cardbus Modified: head/sys/dev/bwn/if_bwn_phy_g.c == --- head/sys/dev/bwn/if_bwn_phy_g.c Mon Feb 12 20:51:28 2018 (r329183) +++ head/sys/dev/bwn/if_bwn_phy_g.c Mon Feb 12 22:21:11 2018 (r329184) @@ -216,7 +216,7 @@ do { \ } while (delta >= 2); pg->pg_tssi2dbm[i] = MIN(MAX(BWN_TSSI2DBM(m1 * f, 8192), -127), - 128); + 127); } pg->pg_flags |= BWN_PHY_G_FLAG_TSSITABLE_ALLOC; Modified: head/sys/modules/bwn/Makefile == --- head/sys/modules/bwn/Makefile Mon Feb 12 20:51:28 2018 (r329183) +++ head/sys/modules/bwn/Makefile Mon Feb 12 22:21:11 2018 (r329184) @@ -38,8 +38,3 @@ SRCS.BWN_GPL_PHY+= if_bwn_phy_n_ppr.c SRCS.BWN_GPL_PHY+= if_bwn_phy_n_core.c .include - -# XXX Work around clang warnings, until maintainer approves fix. -CWARNFLAGS.if_bwn.c= ${NO_WSOMETIMES_UNINITIALIZED} -CWARNFLAGS.if_bwn_phy_g.c= ${NO_WSOMETIMES_UNINITIALIZED} ${NO_WCONSTANT_CONVERSION} -CWARNFLAGS.if_bwn_phy_lp.c=${NO_WSOMETIMES_UNINITIALIZED} ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r329180 - head/sys/dev/bhnd/siba
Author: landonf Date: Mon Feb 12 19:36:26 2018 New Revision: 329180 URL: https://svnweb.freebsd.org/changeset/base/329180 Log: siba(4): Ignore disabled per-core address match entries. Previously, the address regions described by disabled admatch entries would be treated as being mapped to the given core; while incorrect, this was essentially harmless given that the entries describe unused address space on the few affected devices. We now perform parsing of per-core admatch registers and interrupt flags in siba_erom, correctly skip any disabled admatch entries, and use the siba_erom API in siba_add_children() to perform enumeration of attached cores. Added: head/sys/dev/bhnd/siba/siba_eromvar.h (contents, props changed) Modified: head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_erom.c head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibavar.h Modified: head/sys/dev/bhnd/siba/siba.c == --- head/sys/dev/bhnd/siba/siba.c Mon Feb 12 19:08:17 2018 (r329179) +++ head/sys/dev/bhnd/siba/siba.c Mon Feb 12 19:36:26 2018 (r329180) @@ -47,9 +47,14 @@ __FBSDID("$FreeBSD$"); #include #include +#include "siba_eromvar.h" + #include "sibareg.h" #include "sibavar.h" +/* RID used when allocating EROM resources */ +#defineSIBA_EROM_RID 0 + static bhnd_erom_class_t * siba_get_erom_class(driver_t *driver) { @@ -1057,7 +1062,7 @@ siba_decode_port_rid(device_t dev, device_t child, int return (EINVAL); /* Look for a matching addrspace entry */ - for (u_int i = 0; i < dinfo->core_id.num_addrspace; i++) { + for (u_int i = 0; i < dinfo->core_id.num_admatch; i++) { if (dinfo->addrspace[i].sa_rid != rid) continue; @@ -1131,7 +1136,7 @@ siba_get_intr_count(device_t dev, device_t child) return (BHND_BUS_GET_INTR_COUNT(device_get_parent(dev), child)); dinfo = device_get_ivars(child); - if (!dinfo->intr_en) { + if (!dinfo->core_id.intr_en) { /* No interrupts */ return (0); } else { @@ -1161,121 +1166,14 @@ siba_get_intr_ivec(device_t dev, device_t child, u_int dinfo = device_get_ivars(child); - KASSERT(dinfo->intr_en, ("core does not have an interrupt assigned")); - *ivec = dinfo->intr.flag; - return (0); -} + KASSERT(dinfo->core_id.intr_en, + ("core does not have an interrupt assigned")); -/** - * Register all address space mappings for @p di. - * - * @param dev The siba bus device. - * @param di The device info instance on which to register all address - * space entries. - * @param r A resource mapping the enumeration table block for @p di. - */ -static int -siba_register_addrspaces(device_t dev, struct siba_devinfo *di, -struct bhnd_resource *r) -{ - struct siba_core_id *cid; - uint32_t addr; - uint32_t size; - int error; - - cid = >core_id; - - - /* Register the device address space entries */ - for (uint8_t i = 0; i < di->core_id.num_addrspace; i++) { - uint32_tadm; - u_int adm_offset; - uint32_tbus_reserved; - - /* Determine the register offset */ - adm_offset = siba_admatch_offset(i); - if (adm_offset == 0) { - device_printf(dev, "addrspace %hhu is unsupported", i); - return (ENODEV); - } - - /* Fetch the address match register value */ - adm = bhnd_bus_read_4(r, adm_offset); - - /* Parse the value */ - if ((error = siba_parse_admatch(adm, , ))) { - device_printf(dev, "failed to decode address " - " match register value 0x%x\n", adm); - return (error); - } - - /* If this is the device's core/enumeration addrespace, -* reserve the Sonics configuration register blocks for the -* use of our bus. */ - bus_reserved = 0; - if (i == SIBA_CORE_ADDRSPACE) - bus_reserved = cid->num_cfg_blocks * SIBA_CFG_SIZE; - - /* Append the region info */ - error = siba_append_dinfo_region(di, i, addr, size, - bus_reserved); - if (error) - return (error); - } - + *ivec = dinfo->core_id.intr_flag; return (0); } - /** - * Register all interrupt descriptors for @p dinfo. Must be called after - * configuration blocks have been mapped. - * - * @param dev The siba bus device. - * @param child The siba child device. - * @param dinfo The device info instance on which to register all
svn commit: r328912 - in head: share/man/man4 sys/conf sys/dev/bhnd sys/dev/bwn sys/dev/siba sys/gnu/dev/bwn/phy_n sys/modules sys/modules/bwn sys/modules/bwn_pci sys/modules/siba_bwn
Author: landonf Date: Mon Feb 5 23:38:15 2018 New Revision: 328912 URL: https://svnweb.freebsd.org/changeset/base/328912 Log: bwn(4): migrate bwn(4) to the native bhnd(9) interface, and drop siba_bwn. - Remove the shim interface that allowed bwn(4) to use either siba_bwn or bhnd(4), replacing all siba_bwn calls with their bhnd(4) bus equivalents. - Drop the legay, now-unused siba_bwn bus driver. - Clean up bhnd(4) board flag defines referenced by bwn(4). Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D13518 Added: head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_sprom.c (contents, props changed) head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_sprom.h (contents, props changed) Deleted: head/sys/dev/bwn/if_bwn_bhnd.c head/sys/dev/bwn/if_bwn_chipid.h head/sys/dev/bwn/if_bwn_siba.c head/sys/dev/bwn/if_bwn_siba.h head/sys/dev/bwn/if_bwn_siba_compat.c head/sys/dev/bwn/if_bwn_siba_compat.h head/sys/dev/siba/ head/sys/modules/bwn_pci/ head/sys/modules/siba_bwn/ Modified: head/share/man/man4/bwn.4 head/sys/conf/files head/sys/dev/bhnd/bhnd_ids.h head/sys/dev/bwn/if_bwn.c head/sys/dev/bwn/if_bwn_misc.h head/sys/dev/bwn/if_bwn_pci.c head/sys/dev/bwn/if_bwn_phy_common.c head/sys/dev/bwn/if_bwn_phy_common.h head/sys/dev/bwn/if_bwn_phy_g.c head/sys/dev/bwn/if_bwn_phy_lp.c head/sys/dev/bwn/if_bwn_phy_n.c head/sys/dev/bwn/if_bwn_util.c head/sys/dev/bwn/if_bwnreg.h head/sys/dev/bwn/if_bwnvar.h head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.c head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_core.h head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_ppr.c head/sys/gnu/dev/bwn/phy_n/if_bwn_phy_n_tables.c head/sys/modules/Makefile head/sys/modules/bwn/Makefile Modified: head/share/man/man4/bwn.4 == --- head/share/man/man4/bwn.4 Mon Feb 5 23:35:33 2018(r328911) +++ head/share/man/man4/bwn.4 Mon Feb 5 23:38:15 2018(r328912) @@ -24,26 +24,29 @@ .\" .\" $FreeBSD$ .\" -.Dd June 11, 2015 +.Dd December 16, 2017 .Dt BWN 4 .Os .Sh NAME .Nm bwn -.Nd Broadcom BCM43xx IEEE 802.11b/g wireless network driver +.Nd Broadcom BCM43xx SoftMAC IEEE 802.11 wireless network driver .Sh SYNOPSIS -To compile this driver into the kernel, -place the following lines in your -kernel configuration file: +To compile this driver into the kernel, add the following lines to the kernel +configuration file: .Bd -ragged -offset indent -.Cd "device siba_bwn" .Cd "device bwn" +.Cd "device bhnd" +.Cd "device bhndb" +.Cd "device bhndb_pci" +.Cd "device bcma" +.Cd "device siba" +.Cd "device gpio" .Cd "device wlan" .Cd "device wlan_amrr" .Cd "device firmware" .Ed .Pp -Alternatively, to load the driver as a -module at boot time, place the following line in +To load the driver as a module at boot, add the following lines to .Xr loader.conf 5 : .Bd -literal -offset indent if_bwn_load="YES" @@ -122,9 +125,6 @@ Tunables can be set at the prompt before booting the kernel or stored in .Xr loader.conf 5 . .Bl -tag -width indent -.It Va hw.bwn.msi_disable -This tunable disables MSI support on the hardware. -The default value is 0. .It Va hw.bwn.usedma This tunable enables DMA operations on the hardware. If the value is 0, PIO mode would be used. @@ -132,10 +132,14 @@ The default value is 1. .El .Sh SEE ALSO .Xr arp 4 , +.Xr bcma 4 , +.Xr bhnd 4 , +.Xr bhndb 4 , .Xr bwi 4 , .Xr cardbus 4 , .Xr intro 4 , .Xr pci 4 , +.Xr siba 4 , .Xr wlan 4 , .Xr wlan_amrr 4 , .Xr ifconfig 8 , @@ -145,12 +149,20 @@ The .Nm driver first appeared in .Fx 8.1 . +The driver was updated to support the common Broadcom +.Xr bhnd 4 +bus interface in +.Fx 12.0 . .Sh AUTHORS .An -nosplit The .Nm driver was written by .An Weongyo Jeong Aq Mt weon...@freebsd.org . +Support for +.Xr bhnd 4 +was added by +.An Landon Fuller Aq Mt land...@freebsd.org . .\".Sh BUGS .\"Some card based on the BCM4306 and BCM4309 chips do not work properly .\"on channel 1, 2 and 3. Modified: head/sys/conf/files == --- head/sys/conf/files Mon Feb 5 23:35:33 2018(r328911) +++ head/sys/conf/files Mon Feb 5 23:38:15 2018(r328912) @@ -1250,9 +1250,9 @@ dev/bhnd/bhndb/bhndb.coptional bhndb bhnd dev/bhnd/bhndb/bhndb_bus_if.m optional bhndb bhnd dev/bhnd/bhndb/bhndb_hwdata.c optional bhndb bhnd dev/bhnd/bhndb/bhndb_if.m optional bhndb bhnd -dev/bhnd/bhndb/bhndb_pci.c optional bhndb bhnd pci -dev/bhnd/bhndb/bhndb_pci_hwdata.c optional bhndb bhnd pci -dev/bhnd/bhndb/bhndb_pci_sprom.c optional bhndb bhnd pci +dev/bhnd/bhndb/bhndb_pci.c optional bhndb_pci bhndb bhnd pci +dev/bhnd/bhndb/bhndb_pci_hwdata.c optional bhndb_pci bhndb bhnd pci +dev/bhnd/bhndb/bhndb_pci_sprom.c optional bhndb_pci bhndb bhnd pci
svn commit: r328187 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Sat Jan 20 01:55:34 2018 New Revision: 328187 URL: https://svnweb.freebsd.org/changeset/base/328187 Log: bhnd_chipc(4): Fix leak of child device ivars by explicitly deleting any children prior to detach. With the newbus child deletion ordering changes introduced in r307518, parent devices are now detached (and their driver set to NULL) prior to detaching and deleting child devices; child-related bus methods (e.g. BUS_CHILD_DETACHED, BUS_CHILD_DELETED) are no longer be dispatched to the parent device driver after it returns 0 (success) from DEVICE_DETACH. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/chipc/chipc.c Modified: head/sys/dev/bhnd/cores/chipc/chipc.c == --- head/sys/dev/bhnd/cores/chipc/chipc.c Sat Jan 20 01:01:28 2018 (r328186) +++ head/sys/dev/bhnd/cores/chipc/chipc.c Sat Jan 20 01:55:34 2018 (r328187) @@ -250,6 +250,9 @@ chipc_detach(device_t dev) if ((error = bus_generic_detach(dev))) return (error); + if ((error = device_delete_children(dev))) + return (error); + if ((error = bhnd_deregister_provider(dev, BHND_SERVICE_ANY))) return (error); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328183 - in head: share/man/man9 sys/dev/bhnd sys/dev/bwn
Author: landonf Date: Fri Jan 19 22:43:08 2018 New Revision: 328183 URL: https://svnweb.freebsd.org/changeset/base/328183 Log: bhnd/bwn(4): Define a bhnd(4) softmodem device class for the v.90 modem codec core, and mark the core as unpopulated on all BCM4306 bwn(4) devices. Sponsored by: The FreeBSD Foundation Modified: head/share/man/man9/bhnd.9 head/sys/dev/bhnd/bhnd_ids.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhnd_types.h head/sys/dev/bwn/if_bwn_pci.c head/sys/dev/bwn/if_bwn_pcivar.h Modified: head/share/man/man9/bhnd.9 == --- head/share/man/man9/bhnd.9 Fri Jan 19 22:37:48 2018(r328182) +++ head/share/man/man9/bhnd.9 Fri Jan 19 22:43:08 2018(r328183) @@ -28,7 +28,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 9, 2017 +.Dd January 19, 2018 .Dt BHND 9 .Os .Sh NAME @@ -1217,6 +1217,8 @@ Interconnect Host Bridge Device Enumeration ROM .It Dv BHND_DEVCLASS_NVRAM NVRAM/Flash Controller +.It Dv BHND_DEVCLASS_SOFTMODEM +Analog/PSTN SoftModem Codec .It Dv BHND_DEVCLASS_USB_HOST USB Host Controller .It Dv BHND_DEVCLASS_USB_DEV Modified: head/sys/dev/bhnd/bhnd_ids.h == --- head/sys/dev/bhnd/bhnd_ids.hFri Jan 19 22:37:48 2018 (r328182) +++ head/sys/dev/bhnd/bhnd_ids.hFri Jan 19 22:43:08 2018 (r328183) @@ -444,7 +444,7 @@ #defineBHND_COREID_PCI 0x804 /* pci core */ #defineBHND_COREID_MIPS0x805 /* mips core */ #defineBHND_COREID_ENET0x806 /* enet mac core */ -#defineBHND_COREID_CODEC 0x807 /* v90 codec core */ +#defineBHND_COREID_V90_CODEC 0x807 /* v90 codec core */ #defineBHND_COREID_USB 0x808 /* usb 1.1 host/device core */ #defineBHND_COREID_ADSL0x809 /* ADSL core */ #defineBHND_COREID_ILINE1000x80a /* iline100 core */ Modified: head/sys/dev/bhnd/bhnd_subr.c == --- head/sys/dev/bhnd/bhnd_subr.c Fri Jan 19 22:37:48 2018 (r328182) +++ head/sys/dev/bhnd/bhnd_subr.c Fri Jan 19 22:43:08 2018 (r328183) @@ -85,7 +85,7 @@ static const struct bhnd_core_desc { BHND_CDESC(BCM, PCI,PCI,"PCI Bridge"), BHND_CDESC(BCM, MIPS, CPU,"BMIPS CPU"), BHND_CDESC(BCM, ENET, ENET_MAC, "Fast Ethernet MAC"), - BHND_CDESC(BCM, CODEC, OTHER, "V.90 Modem Codec"), + BHND_CDESC(BCM, V90_CODEC, SOFTMODEM, "V.90 SoftModem Codec"), BHND_CDESC(BCM, USB,USB_DUAL, "USB 1.1 Device/Host Controller"), BHND_CDESC(BCM, ADSL, OTHER, "ADSL Core"), BHND_CDESC(BCM, ILINE100, OTHER, "iLine100 HPNA"), Modified: head/sys/dev/bhnd/bhnd_types.h == --- head/sys/dev/bhnd/bhnd_types.h Fri Jan 19 22:37:48 2018 (r328182) +++ head/sys/dev/bhnd/bhnd_types.h Fri Jan 19 22:43:08 2018 (r328183) @@ -66,6 +66,7 @@ typedef enum { BHND_DEVCLASS_USB_HOST, /**< USB host controller */ BHND_DEVCLASS_USB_DEV, /**< USB device controller */ BHND_DEVCLASS_USB_DUAL, /**< USB host/device controller */ + BHND_DEVCLASS_SOFTMODEM,/**< analog/PSTN softmodem codec */ BHND_DEVCLASS_OTHER = 1000, /**< other / unknown */ BHND_DEVCLASS_INVALID /**< no/invalid class */ Modified: head/sys/dev/bwn/if_bwn_pci.c == --- head/sys/dev/bwn/if_bwn_pci.c Fri Jan 19 22:37:48 2018 (r328182) +++ head/sys/dev/bwn/if_bwn_pci.c Fri Jan 19 22:43:08 2018 (r328183) @@ -61,10 +61,13 @@ TUNABLE_INT("hw.bwn_pci.preferred", _new_driver /* SIBA Devices */ static const struct bwn_pci_device siba_devices[] = { BWN_BCM_DEV(BCM4306_D11A, "BCM4306 802.11a", - BWN_QUIRK_WLAN_DUALCORE), - BWN_BCM_DEV(BCM4306_D11G, "BCM4306 802.11b/g",0), - BWN_BCM_DEV(BCM4306_D11G_ID2, "BCM4306 802.11b/g",0), - BWN_BCM_DEV(BCM4306_D11DUAL,"BCM4306 802.11a/b/g", 0), + BWN_QUIRK_WLAN_DUALCORE|BWN_QUIRK_SOFTMODEM_UNPOPULATED), + BWN_BCM_DEV(BCM4306_D11G, "BCM4306 802.11b/g", + BWN_QUIRK_SOFTMODEM_UNPOPULATED), + BWN_BCM_DEV(BCM4306_D11G_ID2, "BCM4306 802.11b/g", + BWN_QUIRK_SOFTMODEM_UNPOPULATED), + BWN_BCM_DEV(BCM4306_D11DUAL,"BCM4306 802.11a/b/g", + BWN_QUIRK_SOFTMODEM_UNPOPULATED),
svn commit: r328182 - head/sys/dev/bwn
Author: landonf Date: Fri Jan 19 22:37:48 2018 New Revision: 328182 URL: https://svnweb.freebsd.org/changeset/base/328182 Log: bwn(4): Add missing BCM4306 PCI IDs. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bwn/if_bwn_pci.c Modified: head/sys/dev/bwn/if_bwn_pci.c == --- head/sys/dev/bwn/if_bwn_pci.c Fri Jan 19 22:33:25 2018 (r328181) +++ head/sys/dev/bwn/if_bwn_pci.c Fri Jan 19 22:37:48 2018 (r328182) @@ -62,6 +62,9 @@ TUNABLE_INT("hw.bwn_pci.preferred", _new_driver static const struct bwn_pci_device siba_devices[] = { BWN_BCM_DEV(BCM4306_D11A, "BCM4306 802.11a", BWN_QUIRK_WLAN_DUALCORE), + BWN_BCM_DEV(BCM4306_D11G, "BCM4306 802.11b/g",0), + BWN_BCM_DEV(BCM4306_D11G_ID2, "BCM4306 802.11b/g",0), + BWN_BCM_DEV(BCM4306_D11DUAL,"BCM4306 802.11a/b/g", 0), BWN_BCM_DEV(BCM4307,"BCM4307 802.11b", 0), BWN_BCM_DEV(BCM4311_D11G, "BCM4311 802.11b/g",0), ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328181 - head/sys/dev/bwn
Author: landonf Date: Fri Jan 19 22:33:25 2018 New Revision: 328181 URL: https://svnweb.freebsd.org/changeset/base/328181 Log: bwn(4): Fix DMA translation lookup on devices limited to 30-bit host addressing. The host addressing constraint does not apply to device address space, and shouldn't be passed to bhnd_get_dma_translation() as the maximum supported device address width. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bwn/if_bwn_siba_compat.c Modified: head/sys/dev/bwn/if_bwn_siba_compat.c == --- head/sys/dev/bwn/if_bwn_siba_compat.c Fri Jan 19 22:22:02 2018 (r328180) +++ head/sys/dev/bwn/if_bwn_siba_compat.c Fri Jan 19 22:33:25 2018 (r328181) @@ -1782,15 +1782,37 @@ bhnd_compat_dma_translation(device_t dev) struct bhnd_dma_translation dt; struct bwn_softc*sc; struct bwn_mac *mac; - int bwn_dmatype, error; + u_intwidth; + int error; sc = device_get_softc(dev); mac = sc->sc_curmac; KASSERT(mac != NULL, ("no MAC")); + /* +* Use the DMA engine's maximum host address width to determine the +* supported device address width. +*/ + switch (mac->mac_method.dma.dmatype) { + case BWN_DMA_32BIT: + case BWN_DMA_30BIT: + /* The 32-bit engine is always capable of addressing +* a full 32-bit device address */ + width = BHND_DMA_ADDR_32BIT; + break; + + case BWN_DMA_64BIT: + width = BHND_DMA_ADDR_64BIT; + break; + + default: + panic("unknown dma type %d", + mac->mac_method.dma.dmatype); + } + + /* Fetch our DMA translation */ - bwn_dmatype = mac->mac_method.dma.dmatype; - if ((error = bhnd_get_dma_translation(dev, bwn_dmatype, 0, NULL, ))) + if ((error = bhnd_get_dma_translation(dev, width, 0, NULL, ))) panic("error requesting DMA translation: %d\n", error); /* @@ -1820,16 +1842,15 @@ bhnd_compat_dma_translation(device_t dev) * However, we will need to resolve these issues in bwn(4) if DMA is to * work on new hardware (e.g. WiSoCs). */ - switch (bwn_dmatype) { - case BWN_DMA_32BIT: - case BWN_DMA_30BIT: + switch (width) { + case BHND_DMA_ADDR_32BIT: KASSERT((~dt.addr_mask & BHND_DMA_ADDR_BITMASK(32)) == SIBA_DMA_TRANSLATION_MASK, ("unexpected DMA mask: %#jx", (uintmax_t)dt.addr_mask)); return (dt.base_addr); - case BWN_DMA_64BIT: + case BHND_DMA_ADDR_64BIT: /* bwn(4) will shift this left by 32+1 bits before applying it * to the top 32-bits of the DMA address */ KASSERT((~dt.addr_mask & BHND_DMA_ADDR_BITMASK(33)) == 0, @@ -1839,7 +1860,7 @@ bhnd_compat_dma_translation(device_t dev) return (dt.base_addr >> 33); default: - panic("unknown dma type %d", bwn_dmatype); + panic("unsupported address width: %u", width); } } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328180 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Fri Jan 19 22:22:02 2018 New Revision: 328180 URL: https://svnweb.freebsd.org/changeset/base/328180 Log: bhndb_pci(4): Implement bridge support for CardBus-attached devices. - Extend the probe method to accept devclasses that inherit from the pci devclass (e.g. cardbus). - Some BCM4306-based CardBus adapters appear to advertise 4K SPROM, but only the first 2K is mapped into BAR0. We can safely assume that the SPROM data fits within the first 2K of the SPROM, rather than rejecting the SPROM mapping as invalid. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c == --- head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Jan 19 22:19:50 2018 (r328179) +++ head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Jan 19 22:22:02 2018 (r328180) @@ -264,8 +264,8 @@ bhndb_pci_probe(device_t dev) struct bhndb_pci_probe *probe; struct bhndb_pci_core *entry; bhnd_devclass_t hostb_devclass; - device_t parent; - devclass_t parent_bus, pci; + device_t parent, parent_bus; + devclass_t pci, bus_devclass; int error; probe = NULL; @@ -273,9 +273,20 @@ bhndb_pci_probe(device_t dev) /* Our parent must be a PCI/PCIe device. */ pci = devclass_find("pci"); parent = device_get_parent(dev); - parent_bus = device_get_devclass(device_get_parent(parent)); + parent_bus = device_get_parent(parent); + if (parent_bus == NULL) + return (ENXIO); - if (parent_bus != pci) + /* The bus device class may inherit from 'pci' */ + for (bus_devclass = device_get_devclass(parent_bus); + bus_devclass != NULL; + bus_devclass = devclass_get_parent(bus_devclass)) + { + if (bus_devclass == pci) + break; + } + + if (bus_devclass != pci) return (ENXIO); /* Enable clocks */ @@ -629,12 +640,10 @@ bhndb_pci_sprom_size(struct bhndb_pci_softc *sc) return (0); } - if (sprom_sz > sprom_win->win_size) { - device_printf(sc->dev, - "PCI sprom size (0x%x) overruns defined register window\n", - sctl); - return (0); - } + /* If the device has a larger SPROM than can be addressed via our SPROM +* register window, the SPROM image data will still be located within +* the window's addressable range */ + sprom_sz = MIN(sprom_sz, sprom_win->win_size); return (sprom_sz); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328176 - in head/sys/dev/bhnd: cores/chipc/pwrctl siba
Author: landonf Date: Fri Jan 19 21:58:48 2018 New Revision: 328176 URL: https://svnweb.freebsd.org/changeset/base/328176 Log: bhnd(4): fix a few bugs in pwrctl/fixed-clock device support. - Do not panic on siba(4) detach when the bhnd(4) bus calls bhnd_get_pmu_info() on a PMU-less device. - Fix bhnd_pwrctl attach/detach on fixed-clock devices: - Treat bhnd_pwrctl_updateclk() as a no-op on fixed-clock devices. - Use bhnd_pwrctl_updateclk() to perform the appropriate clock transition on detach. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c head/sys/dev/bhnd/siba/siba.c Modified: head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c == --- head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c Fri Jan 19 21:56:22 2018(r328175) +++ head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c Fri Jan 19 21:58:48 2018(r328176) @@ -209,13 +209,13 @@ bhnd_pwrctl_detach(device_t dev) if ((error = bhnd_deregister_provider(dev, BHND_SERVICE_ANY))) return (error); + /* Update clock state */ PWRCTL_LOCK(sc); - - if ((error = bhnd_pwrctl_setclk(sc, BHND_CLOCK_DYN))) + error = bhnd_pwrctl_updateclk(sc, BHND_PWRCTL_WAR_DOWN); + PWRCTL_UNLOCK(sc); + if (error) return (error); - PWRCTL_UNLOCK(sc); - STAILQ_FOREACH_SAFE(clkres, >clkres_list, cr_link, crnext) free(clkres, M_DEVBUF); @@ -343,6 +343,10 @@ bhnd_pwrctl_updateclk(struct bhnd_pwrctl_softc *sc, bh bhnd_clock clock; PWRCTL_LOCK_ASSERT(sc, MA_OWNED); + + /* Nothing to update on fixed clock devices */ + if (PWRCTL_QUIRK(sc, FIXED_CLK)) + return (0); /* Default clock target */ clock = BHND_CLOCK_DYN; Modified: head/sys/dev/bhnd/siba/siba.c == --- head/sys/dev/bhnd/siba/siba.c Fri Jan 19 21:56:22 2018 (r328175) +++ head/sys/dev/bhnd/siba/siba.c Fri Jan 19 21:58:48 2018 (r328176) @@ -170,9 +170,9 @@ siba_read_ivar(device_t dev, device_t child, int index case SIBA_PMU_PWRCTL: case SIBA_PMU_FIXED: - panic("bhnd_get_pmu_info() called with siba PMU state " - "%d", dinfo->pmu_state); - return (ENXIO); + *result = (uintptr_t)NULL; + SIBA_UNLOCK(sc); + return (0); } panic("invalid PMU state: %d", dinfo->pmu_state); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328174 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Fri Jan 19 21:36:28 2018 New Revision: 328174 URL: https://svnweb.freebsd.org/changeset/base/328174 Log: bhnd_chipc(4): Fix the assignment of non-wildcard child unit numbers introduced in r326102 and r326109; all chipc children should be added with a wildcard unit (-1). Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/chipc/chipc.c Modified: head/sys/dev/bhnd/cores/chipc/chipc.c == --- head/sys/dev/bhnd/cores/chipc/chipc.c Fri Jan 19 21:20:24 2018 (r328173) +++ head/sys/dev/bhnd/cores/chipc/chipc.c Fri Jan 19 21:36:28 2018 (r328174) @@ -295,13 +295,13 @@ chipc_add_children(struct chipc_softc *sc) * attached directly to the bhnd(4) bus -- not chipc. */ if (sc->caps.pmu && !sc->caps.aob) { - child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pmu", 0); + child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pmu", -1); if (child == NULL) { device_printf(sc->dev, "failed to add pmu\n"); return (ENXIO); } } else if (sc->caps.pwr_ctrl) { - child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pwrctl", 0); + child = BUS_ADD_CHILD(sc->dev, 0, "bhnd_pwrctl", -1); if (child == NULL) { device_printf(sc->dev, "failed to add pwrctl\n"); return (ENXIO); @@ -309,7 +309,7 @@ chipc_add_children(struct chipc_softc *sc) } /* GPIO */ - child = BUS_ADD_CHILD(sc->dev, 0, "gpio", 0); + child = BUS_ADD_CHILD(sc->dev, 0, "gpio", -1); if (child == NULL) { device_printf(sc->dev, "failed to add gpio\n"); return (ENXIO); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328098 - head/sys/dev/bwn
Author: landonf Date: Wed Jan 17 22:33:19 2018 New Revision: 328098 URL: https://svnweb.freebsd.org/changeset/base/328098 Log: bwn(4): Enable, by default, the opt-in support for bhnd(4) introduced in r326454. bwn(4)/bhnd(4) has been tested with most chipsets currently supported by bwn(4), and this change should be transparent to existing bwn(4) users; please report any regressions that you do encounter. To revert to using siba_bwn(4) instead of bhnd(4), place the following lines in loader.conf(5): hw.bwn_pci.preferred="0" Once we're satisfied that the switch to bhnd(4) has seen sufficient broader testing, bwn(4) will be migrated to use the native bhnd(9) interface directly, and support for siba_bwn(4) will be dropped (see D13518). Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bwn/if_bwn.c head/sys/dev/bwn/if_bwn_pci.c Modified: head/sys/dev/bwn/if_bwn.c == --- head/sys/dev/bwn/if_bwn.c Wed Jan 17 22:10:58 2018(r328097) +++ head/sys/dev/bwn/if_bwn.c Wed Jan 17 22:33:19 2018(r328098) @@ -7493,6 +7493,7 @@ driver_t bwn_driver = { }; static devclass_t bwn_devclass; DRIVER_MODULE(bwn, siba_bwn, bwn_driver, bwn_devclass, 0, 0); +MODULE_DEPEND(bwn, bwn_pci, 1, 1, 1); MODULE_DEPEND(bwn, siba_bwn, 1, 1, 1); MODULE_DEPEND(bwn, gpiobus, 1, 1, 1); MODULE_DEPEND(bwn, wlan, 1, 1, 1); /* 802.11 media layer */ Modified: head/sys/dev/bwn/if_bwn_pci.c == --- head/sys/dev/bwn/if_bwn_pci.c Wed Jan 17 22:10:58 2018 (r328097) +++ head/sys/dev/bwn/if_bwn_pci.c Wed Jan 17 22:33:19 2018 (r328098) @@ -55,7 +55,7 @@ static int attach_untested = 0; TUNABLE_INT("hw.bwn_pci.attach_untested", _untested); /* If non-zero, probe at a higher priority than the stable if_bwn driver. */ -static int prefer_new_driver = 0; +static int prefer_new_driver = 1; TUNABLE_INT("hw.bwn_pci.preferred", _new_driver); /* SIBA Devices */ @@ -300,9 +300,9 @@ DRIVER_MODULE_ORDERED(bwn_pci, pci, bwn_pci_driver, bw NULL, SI_ORDER_ANY); DRIVER_MODULE(bhndb, bwn_pci, bhndb_pci_driver, bhndb_devclass, NULL, NULL); -MODULE_DEPEND(bwn_pci, bwn, 1, 1, 1); MODULE_DEPEND(bwn_pci, bhnd, 1, 1, 1); MODULE_DEPEND(bwn_pci, bhndb, 1, 1, 1); MODULE_DEPEND(bwn_pci, bhndb_pci, 1, 1, 1); MODULE_DEPEND(bwn_pci, bcma_bhndb, 1, 1, 1); MODULE_DEPEND(bwn_pci, siba_bhndb, 1, 1, 1); +MODULE_VERSION(bwn_pci, 1); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r328071 - in head/sys/dev/bhnd: bhndb cores/pci
Author: landonf Date: Wed Jan 17 03:34:26 2018 New Revision: 328071 URL: https://svnweb.freebsd.org/changeset/base/328071 Log: bhndb_pci(4): fix incorrect BHND_PCI_SRSH_PI workaround On a SPROM-less device, the PCI(e) bridge core will be initialized with its power-on-reset defaults; this can leave the SPROM-derived BHND_PCI_SRSH_PI value pointing to the wrong backplane address. This value is used by the PCI core when performing address translation between the static register windows in BAR0 that map the PCI core's register block, and backplane address space. Previously, bhndb_pci(4) incorrectly used the potentially invalid static BAR0 PCI register windows when attempting to correct the BHND_PCI_SRSH_PI value in the PCI core's SPROM shadow. Instead, we now read/update BHND_PCI_SRSH_PI by fetching the PCI core's backplane address from the core enumeration table, and then using a dynamic register window to explicitly map the PCI core's register block into BAR0. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_pcivar.h head/sys/dev/bhnd/cores/pci/bhnd_pcireg.h Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c == --- head/sys/dev/bhnd/bhndb/bhndb_pci.c Tue Jan 16 23:19:57 2018 (r328070) +++ head/sys/dev/bhnd/bhndb/bhndb_pci.c Wed Jan 17 03:34:26 2018 (r328071) @@ -75,13 +75,11 @@ __FBSDID("$FreeBSD$"); #include "bhndb_private.h" struct bhndb_pci_eio; +struct bhndb_pci_probe; static int bhndb_pci_alloc_msi(struct bhndb_pci_softc *sc, int *msi_count); -static int bhndb_pci_read_core_table(device_t dev, - struct bhnd_chipid *chipid, - struct bhnd_core_info **cores, u_int *ncores, - bhnd_erom_class_t **eromcls); + static int bhndb_pci_add_children(struct bhndb_pci_softc *sc); static bhnd_devclass_t bhndb_expected_pci_devclass(device_t dev); @@ -101,15 +99,30 @@ static voidbhndb_pci_write_core(struct bhndb_pci_sof static uint32_tbhndb_pci_read_core(struct bhndb_pci_softc *sc, bus_size_t offset, u_int width); -static voidbhndb_init_sromless_pci_config( - struct bhndb_pci_softc *sc); +static int bhndb_pci_srsh_pi_war(struct bhndb_pci_softc *sc, + struct bhndb_pci_probe *probe); static bus_addr_t bhndb_pci_sprom_addr(struct bhndb_pci_softc *sc); static bus_size_t bhndb_pci_sprom_size(struct bhndb_pci_softc *sc); -static int bhndb_pci_eio_init(struct bhndb_pci_eio *pio, - device_t dev, device_t pci_dev, - struct bhndb_host_resources *hr); +static int bhndb_pci_probe_alloc(struct bhndb_pci_probe **probe, + device_t dev, bhnd_devclass_t pci_devclass); +static voidbhndb_pci_probe_free(struct bhndb_pci_probe *probe); + +static int bhndb_pci_probe_copy_core_table( + struct bhndb_pci_probe *probe, + struct bhnd_core_info **cores, u_int *ncores); +static voidbhndb_pci_probe_free_core_table( + struct bhnd_core_info *cores); + +static voidbhndb_pci_probe_write(struct bhndb_pci_probe *sc, + bhnd_addr_t addr, bhnd_size_t offset, + uint32_t value, u_int width); +static uint32_tbhndb_pci_probe_read(struct bhndb_pci_probe *sc, + bhnd_addr_t addr, bhnd_size_t offset, u_int width); + +static voidbhndb_pci_eio_init(struct bhndb_pci_eio *eio, + struct bhndb_pci_probe *probe); static int bhndb_pci_eio_map(struct bhnd_erom_io *eio, bhnd_addr_t addr, bhnd_size_t size); static uint32_tbhndb_pci_eio_read(struct bhnd_erom_io *eio, @@ -122,26 +135,50 @@ static struct bhndb_pci_quirk bhndb_pcie_quirks[]; static struct bhndb_pci_quirk bhndb_pcie2_quirks[]; static struct bhndb_pci_core bhndb_pci_cores[] = { - BHNDB_PCI_CORE(PCI, BHND_PCI_SRSH_PI_OFFSET, bhndb_pci_quirks), - BHNDB_PCI_CORE(PCIE,BHND_PCIE_SRSH_PI_OFFSET, bhndb_pcie_quirks), - BHNDB_PCI_CORE(PCIE2, BHND_PCIE_SRSH_PI_OFFSET, bhndb_pcie2_quirks), + BHNDB_PCI_CORE(PCI, bhndb_pci_quirks), + BHNDB_PCI_CORE(PCIE,bhndb_pcie_quirks), + BHNDB_PCI_CORE(PCIE2, bhndb_pcie2_quirks), BHNDB_PCI_CORE_END }; /* bhndb_pci erom I/O instance state */ struct bhndb_pci_eio { struct bhnd_erom_io eio; - device_t dev; /**< bridge device */
svn commit: r327798 - head/sys/powerpc/powermac
Author: landonf Date: Wed Jan 10 22:19:11 2018 New Revision: 327798 URL: https://svnweb.freebsd.org/changeset/base/327798 Log: Fix minor locking issues in the Power Mac Uninorth PCI bridge driver. - Call resource_int_value() once during attach, rather than within the pci_(read|write)_config() code path; this avoids taking a blocking mutex to read kenv variables. - Use a spin lock to protect non-atomic config space accesses; this matches the behavior of Darwin's AppleMacRiscPCI driver. Reviewed by: jhibbits Differential Revision:https://reviews.freebsd.org/D13839 Modified: head/sys/powerpc/powermac/uninorthpci.c head/sys/powerpc/powermac/uninorthvar.h Modified: head/sys/powerpc/powermac/uninorthpci.c == --- head/sys/powerpc/powermac/uninorthpci.c Wed Jan 10 21:59:21 2018 (r327797) +++ head/sys/powerpc/powermac/uninorthpci.c Wed Jan 10 22:19:11 2018 (r327798) @@ -34,6 +34,8 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include +#include #include #include @@ -134,13 +136,17 @@ uninorth_attach(device_t dev) { struct uninorth_softc *sc; const char *compatible; + const char *name; phandle_t node; uint32_treg[3]; uint64_tregbase; cell_t acells; + int unit; node = ofw_bus_get_node(dev); sc = device_get_softc(dev); + name = device_get_name(dev); + unit = device_get_unit(dev); if (OF_getprop(node, "reg", reg, sizeof(reg)) < 8) return (ENXIO); @@ -164,6 +170,11 @@ uninorth_attach(device_t dev) sc->sc_addr = (vm_offset_t)pmap_mapdev(regbase + 0x80, PAGE_SIZE); sc->sc_data = (vm_offset_t)pmap_mapdev(regbase + 0xc0, PAGE_SIZE); + if (resource_int_value(name, unit, "skipslot", >sc_skipslot) != 0) + sc->sc_skipslot = -1; + + mtx_init(>sc_cfg_mtx, "uninorth pcicfg", NULL, MTX_SPIN); + return (ofw_pci_attach(dev)); } @@ -173,25 +184,29 @@ uninorth_read_config(device_t dev, u_int bus, u_int sl { struct uninorth_softc *sc; vm_offset_t caoff; + u_int32_t val; sc = device_get_softc(dev); caoff = sc->sc_data + (reg & 0x07); + val = 0x; + mtx_lock_spin(>sc_cfg_mtx); if (uninorth_enable_config(sc, bus, slot, func, reg) != 0) { switch (width) { case 1: - return (in8rb(caoff)); + val = in8rb(caoff); break; case 2: - return (in16rb(caoff)); + val = in16rb(caoff); break; case 4: - return (in32rb(caoff)); + val = in32rb(caoff); break; } } + mtx_unlock_spin(>sc_cfg_mtx); - return (0x); + return (val); } static void @@ -204,6 +219,7 @@ uninorth_write_config(device_t dev, u_int bus, u_int s sc = device_get_softc(dev); caoff = sc->sc_data + (reg & 0x07); + mtx_lock_spin(>sc_cfg_mtx); if (uninorth_enable_config(sc, bus, slot, func, reg)) { switch (width) { case 1: @@ -217,6 +233,7 @@ uninorth_write_config(device_t dev, u_int bus, u_int s break; } } + mtx_unlock_spin(>sc_cfg_mtx); } static int @@ -224,13 +241,11 @@ uninorth_enable_config(struct uninorth_softc *sc, u_in u_int func, u_int reg) { uint32_tcfgval; - uint32_tpass; - if (resource_int_value(device_get_name(sc->pci_sc.sc_dev), - device_get_unit(sc->pci_sc.sc_dev), "skipslot", ) == 0) { - if (pass == slot) - return (0); - } + mtx_assert(>sc_cfg_mtx, MA_OWNED); + + if (sc->sc_skipslot == slot) + return (0); /* * Issue type 0 configuration space accesses for the root bus. Modified: head/sys/powerpc/powermac/uninorthvar.h == --- head/sys/powerpc/powermac/uninorthvar.h Wed Jan 10 21:59:21 2018 (r327797) +++ head/sys/powerpc/powermac/uninorthvar.h Wed Jan 10 22:19:11 2018 (r327798) @@ -39,6 +39,8 @@ struct uninorth_softc { vm_offset_t sc_addr; vm_offset_t sc_data; int sc_ver; + int sc_skipslot; + struct mtx sc_cfg_mtx; }; struct unin_chip_softc { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe,
svn commit: r327558 - head/sys/dev/bhnd/cores/pmu
Author: landonf Date: Thu Jan 4 19:47:01 2018 New Revision: 327558 URL: https://svnweb.freebsd.org/changeset/base/327558 Log: bhnd(4): Add missing BCM4312 backplane clock speed entry. The default 80MHz clock speed returned by bhnd_pmu_si_clock() was already correct; this just prevents the "No backplane clock specified" warning printf from being emitted when querying backplane clock speed. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c Modified: head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c == --- head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c Thu Jan 4 19:43:42 2018 (r327557) +++ head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c Thu Jan 4 19:47:01 2018 (r327558) @@ -2394,6 +2394,7 @@ bhnd_pmu_si_clock(struct bhnd_pmu_query *sc) clock = bhnd_pmu1_cpuclk0(sc); break; + case BHND_CHIPID_BCM4312: case BHND_CHIPID_BCM4313: /* 80MHz backplane clock */ clock = 8 * 1000; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326894 - head/sys/dev/bhnd/nvram
Author: landonf Date: Sat Dec 16 05:22:16 2017 New Revision: 326894 URL: https://svnweb.freebsd.org/changeset/base/326894 Log: bhnd(4): Fix the pa0itssit/pa1itssit NVRAM variable type definitions required by bwn(4); idle TSSI target values are expressed as signed integers. Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/nvram/nvram_map Modified: head/sys/dev/bhnd/nvram/nvram_map == --- head/sys/dev/bhnd/nvram/nvram_map Sat Dec 16 04:35:37 2017 (r326893) +++ head/sys/dev/bhnd/nvram/nvram_map Sat Dec 16 05:22:16 2017 (r326894) @@ -785,7 +785,7 @@ i16 pa0b2 { #desc #help } -u8 pa0itssit { +i8 pa0itssit { fmt decimal #desc #help @@ -830,7 +830,7 @@ u8 pa1himaxpwr { #desc #help } -u8 pa1itssit { +i8 pa1itssit { fmt decimal #desc #help @@ -1880,8 +1880,8 @@ srom 1 { 0x06A: i16 pa1b0 0x06C: i16 pa1b1 0x06E: i16 pa1b2 - 0x070: u8 pa0itssit - 0x071: u8 pa1itssit + 0x070: i8 pa0itssit + 0x071: i8 pa1itssit 0x072: u16 boardflags 0x074: u8 ag0 0x075: u8 ag1 @@ -1945,8 +1945,8 @@ srom 2-3 { 0x06A: i16 pa1b0 0x06C: i16 pa1b1 0x06E: i16 pa1b2 - 0x070: u8 pa0itssit - 0x071: u8 pa1itssit + 0x070: i8 pa0itssit + 0x071: i8 pa1itssit srom 2 { 0x072: u32 boardflags { +0x0: u16 | @@ -2392,7 +2392,7 @@ srom 8 { } 0x0C0: u8 pa0maxpwr 0x0C0: u8 maxp2ga0 - 0x0C1: u8 pa0itssit + 0x0C1: i8 pa0itssit 0x0C1: u8 itt2ga0 0x0C2: i16 pa0b0 0x0C2: u16 pa2gw0a0 @@ -2403,7 +2403,7 @@ srom 8 { 0x0C8: u8 pa1maxpwr 0x0C8: u8 maxp5ga0[1] 0x0C9: u8 itt5ga0 - 0x0C9: u8 pa1itssit + 0x0C9: i8 pa1itssit 0x0CA: u8 maxp5gha0 0x0CA: u8 pa1himaxpwr 0x0CB: u8 maxp5gla0 @@ -2657,7 +2657,7 @@ srom 9-10 { 0x0C0: u8 pa0maxpwr 0x0C0: u8 maxp2ga0 0x0C1: u8 itt2ga0 - 0x0C1: u8 pa0itssit + 0x0C1: i8 pa0itssit 0x0C2: u16 pa2gw0a0 0x0C2: i16 pa0b0 0x0C4: i16 pa0b1 @@ -2667,7 +2667,7 @@ srom 9-10 { 0x0C8: u8 pa1maxpwr 0x0C8: u8 maxp5ga0[1] 0x0C9: u8 itt5ga0 - 0x0C9: u8 pa1itssit + 0x0C9: i8 pa1itssit 0x0CA: u8 pa1himaxpwr 0x0CA: u8 maxp5gha0 0x0CB: u8 maxp5gla0 ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326893 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Sat Dec 16 04:35:37 2017 New Revision: 326893 URL: https://svnweb.freebsd.org/changeset/base/326893 Log: bhndb(4): Enable addrext support on DMA64 devices, and fix an incorrect DMA DMA boundary constraint applied in bhndb_dma_tag_create(). Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb_pci_hwdata.c head/sys/dev/bhnd/bhndb/bhndb_subr.c Modified: head/sys/dev/bhnd/bhndb/bhndb_pci_hwdata.c == --- head/sys/dev/bhnd/bhndb/bhndb_pci_hwdata.c Sat Dec 16 00:47:45 2017 (r326892) +++ head/sys/dev/bhnd/bhndb/bhndb_pci_hwdata.c Sat Dec 16 04:35:37 2017 (r326893) @@ -511,7 +511,7 @@ static const struct bhndb_hwcfg bhndb_pci_hwcfg_v1_pci { .base_addr = BHND_PCIE_DMA64_TRANSLATION, .addr_mask = ~BHND_PCIE_DMA64_MASK, - .addrext_mask = 0 + .addrext_mask = BHND_PCIE_DMA64_MASK }, BHND_DMA_TRANSLATION_TABLE_END } @@ -594,7 +594,7 @@ static const struct bhndb_hwcfg bhndb_pci_hwcfg_v2 = { { .base_addr = BHND_PCIE_DMA64_TRANSLATION, .addr_mask = ~BHND_PCIE_DMA64_MASK, - .addrext_mask = 0 + .addrext_mask = BHND_PCIE_DMA64_MASK }, BHND_DMA_TRANSLATION_TABLE_END } @@ -672,7 +672,7 @@ static const struct bhndb_hwcfg bhndb_pci_hwcfg_v3 = { { .base_addr = BHND_PCIE2_DMA64_TRANSLATION, .addr_mask = ~BHND_PCIE2_DMA64_MASK, - .addrext_mask = 0 + .addrext_mask = BHND_PCIE_DMA64_MASK }, BHND_DMA_TRANSLATION_TABLE_END } Modified: head/sys/dev/bhnd/bhndb/bhndb_subr.c == --- head/sys/dev/bhnd/bhndb/bhndb_subr.cSat Dec 16 00:47:45 2017 (r326892) +++ head/sys/dev/bhnd/bhndb/bhndb_subr.cSat Dec 16 04:35:37 2017 (r326893) @@ -521,12 +521,12 @@ bhndb_dma_tag_create(device_t dev, bus_dma_tag_t paren { bus_dma_tag_t translation_tag; bhnd_addr_t dt_mask; - bus_addr_t boundary; bus_addr_t lowaddr, highaddr; + bus_size_t maxsegsz; int error; highaddr = BUS_SPACE_MAXADDR; - boundary = 0; + maxsegsz = BUS_SPACE_MAXSIZE; /* Determine full addressable mask */ dt_mask = (translation->addr_mask | translation->addrext_mask); @@ -536,19 +536,17 @@ bhndb_dma_tag_create(device_t dev, bus_dma_tag_t paren /* (addr_mask|addrext_mask) is our maximum supported address */ lowaddr = MIN(dt_mask, BUS_SPACE_MAXADDR); - /* Do we need to to avoid crossing a DMA translation window boundary? */ - if (translation->addr_mask < BUS_SPACE_MAXADDR) { - /* round down to nearest power of two */ - boundary = translation->addr_mask & (~1ULL); - } + /* Constrain to translation window size */ + if (translation->addr_mask < maxsegsz) + maxsegsz = translation->addr_mask; /* Create our DMA tag */ error = bus_dma_tag_create(parent_dmat, - 1, /* alignment */ - boundary, lowaddr, highaddr, + 1, 0, /* alignment, boundary */ + lowaddr, highaddr, NULL, NULL, /* filter, filterarg */ BUS_SPACE_MAXSIZE, 0, /* maxsize, nsegments */ - BUS_SPACE_MAXSIZE, 0, /* maxsegsize, flags */ + maxsegsz, 0,/* maxsegsize, flags */ NULL, NULL, /* lockfunc, lockarg */ _tag); if (error) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326871 - in head/sys/dev: bhnd bhnd/bcma bhnd/bhndb bhnd/cores/pmu bhnd/nvram bhnd/siba bwn
Author: landonf Date: Fri Dec 15 04:51:47 2017 New Revision: 326871 URL: https://svnweb.freebsd.org/changeset/base/326871 Log: bhnd(4)/bwn(4): Fix a number of small issues reported by Coverity. - Fix reference of uninitialized error value in bhndb_generic_resume() if the dynamic window count is 0. - Fix incorrect bhnd_pmu(4) UPTME_MASK and PLL0_PC2_WILD_INT_MASK constants. - Variable definitions referenced by our generated SPROM layouts will never be NULL, but add explicit asserts to make that clear. - Add missing variable initialization in bhnd_nvram_sprom_ident(). - Fix leak of driver array in bhnd_erom_probe_driver_classes(). - Fix zero-length memset() in bhndb_pci_eio_init(). - Fix an off-by-one error and potential invalid OOBSEL bit shift operation in bcma_dinfo_init_intrs(). - Remove dead code in siba_suspend_hw(). - Fix duplicate call to bhnd_pmu_enable_regulator() in both the enable and disable code paths of bhnd_compat_cc_pmu_set_ldoparef(). Reported by: Coverity CIDs: 1355194, 1362020, 1362022, 1373114, 1366563, 1373115, 1381569, 1381579, 1383555, 1383566, 1383571 Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bcma/bcma_dmp.h head/sys/dev/bhnd/bcma/bcma_subr.c head/sys/dev/bhnd/bhnd_erom.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/cores/pmu/bhnd_pmureg.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/siba/siba.c head/sys/dev/bwn/if_bwn_siba_compat.c Modified: head/sys/dev/bhnd/bcma/bcma_dmp.h == --- head/sys/dev/bhnd/bcma/bcma_dmp.h Fri Dec 15 04:11:20 2017 (r326870) +++ head/sys/dev/bhnd/bcma/bcma_dmp.h Fri Dec 15 04:51:47 2017 (r326871) @@ -223,7 +223,7 @@ /* OOBSEL(IN|OUT) */ #defineBCMA_DMP_OOBSEL_MASK0xFF/**< OOB selector mask */ #defineBCMA_DMP_OOBSEL_EN (1<<7) /**< OOB selector enable bit */ -#defineBCMA_DMP_OOBSEL_SHIFT(_sel) ((_sel % BCMA_OOB_NUM_SEL) * 8) +#defineBCMA_DMP_OOBSEL_SHIFT(_sel) ((_sel % 4) * 8) #defineBCMA_DMP_OOBSEL_BUSLINE_MASK0x7F/**< OOB selector bus line mask */ #defineBCMA_DMP_OOBSEL_BUSLINE_SHIFT 0 Modified: head/sys/dev/bhnd/bcma/bcma_subr.c == --- head/sys/dev/bhnd/bcma/bcma_subr.c Fri Dec 15 04:11:20 2017 (r326870) +++ head/sys/dev/bhnd/bcma/bcma_subr.c Fri Dec 15 04:51:47 2017 (r326871) @@ -282,7 +282,7 @@ bcma_dinfo_init_intrs(device_t bus, device_t child, /* Fetch width of the OOB interrupt bank */ oobw = bhnd_bus_read_4(dinfo->res_agent, BCMA_DMP_OOB_OUTWIDTH(BCMA_OOB_BANK_INTR)); - if (oobw > BCMA_OOB_NUM_SEL) { + if (oobw >= BCMA_OOB_NUM_SEL) { device_printf(bus, "ignoring invalid OOBOUTWIDTH for core %u: " "%#x\n", BCMA_DINFO_COREIDX(dinfo), oobw); return (0); Modified: head/sys/dev/bhnd/bhnd_erom.c == --- head/sys/dev/bhnd/bhnd_erom.c Fri Dec 15 04:11:20 2017 (r326870) +++ head/sys/dev/bhnd/bhnd_erom.c Fri Dec 15 04:51:47 2017 (r326871) @@ -145,6 +145,7 @@ bhnd_erom_probe_driver_classes(devclass_t bus_devclass break; } + free(drivers, M_TEMP); return (erom_cls); } Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Fri Dec 15 04:11:20 2017 (r326870) +++ head/sys/dev/bhnd/bhndb/bhndb.c Fri Dec 15 04:51:47 2017 (r326871) @@ -687,6 +687,7 @@ bhndb_generic_resume(device_t dev) /* Guarantee that all in-use dynamic register windows are mapped to * their previously configured target address. */ BHNDB_LOCK(sc); + error = 0; for (size_t i = 0; i < bus_res->dwa_count; i++) { dwa = _res->dw_alloc[i]; Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c == --- head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Dec 15 04:11:20 2017 (r326870) +++ head/sys/dev/bhnd/bhndb/bhndb_pci.c Fri Dec 15 04:51:47 2017 (r326871) @@ -1297,7 +1297,7 @@ static int bhndb_pci_eio_init(struct bhndb_pci_eio *pio, device_t dev, device_t pci_dev, struct bhndb_host_resources *hr) { - memset(>eio, sizeof(pio->eio), 0); + memset(>eio, 0, sizeof(pio->eio)); pio->eio.map = bhndb_pci_eio_map; pio->eio.read = bhndb_pci_eio_read; pio->eio.fini = NULL; Modified: head/sys/dev/bhnd/cores/pmu/bhnd_pmureg.h
svn commit: r326841 - head/sys/dev/bwn
Author: landonf Date: Thu Dec 14 06:45:04 2017 New Revision: 326841 URL: https://svnweb.freebsd.org/changeset/base/326841 Log: Add basic bwn(4) support for the (BCMA-based) BCM43224 and BCM43225. - Add the BCM4322X D11 core revision and missing BCM43224 PCI device ID to our device tables. - Disable the DMA engine parity check (rather than adding parity support to the to-be-replaced bwn(4) DMA implementation). Currently, N-PHY support in bwn(4) is GPL licensed, and is not included by default. Until this is replaced with Broadcom's ISC-licensed N-PHY implementation, bwn(4) must be rebuilt to enable N-PHY support. To build bwn(4) with N-PHY support, add the following lines to your kernel configuration file and rebuild the kernel (and modules): options BWN_GPL_PHY To test bwn(4) with a BCM43224/BCM43225 device, install the firmware from the net/bwn-firmware-kmod port, and place the following lines in loader.conf(5): hw.bwn_pci.preferred="1" if_bwn_pci_load="YES bwn_v4_ucode_load="YES" bwn_v4_n_ucode_load="YES" bwn_v4_lp_ucode_load="YES" Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bwn/if_bwn.c head/sys/dev/bwn/if_bwn_bhnd.c head/sys/dev/bwn/if_bwn_pci.c head/sys/dev/bwn/if_bwnreg.h Modified: head/sys/dev/bwn/if_bwn.c == --- head/sys/dev/bwn/if_bwn.c Thu Dec 14 04:41:07 2017(r326840) +++ head/sys/dev/bwn/if_bwn.c Thu Dec 14 06:45:04 2017(r326841) @@ -1421,7 +1421,7 @@ bwn_phy_getinfo(struct bwn_mac *mac, int gmode) (phy->type == BWN_PHYTYPE_B && phy->rev != 2 && phy->rev != 4 && phy->rev != 6 && phy->rev != 7) || (phy->type == BWN_PHYTYPE_G && phy->rev > 9) || - (phy->type == BWN_PHYTYPE_N && phy->rev > 4) || + (phy->type == BWN_PHYTYPE_N && phy->rev > 6) || (phy->type == BWN_PHYTYPE_LP && phy->rev > 2)) goto unsupphy; @@ -3110,6 +3110,7 @@ bwn_dma_setup(struct bwn_dma_ring *dr) addrext = ((ring64 >> 32) & SIBA_DMA_TRANSLATION_MASK) >> 30; value = BWN_DMA64_TXENABLE; + value |= BWN_DMA64_TXPARITY_DISABLE; value |= (addrext << BWN_DMA64_TXADDREXT_SHIFT) & BWN_DMA64_TXADDREXT_MASK; BWN_DMA_WRITE(dr, BWN_DMA64_TXCTL, value); @@ -3122,6 +3123,7 @@ bwn_dma_setup(struct bwn_dma_ring *dr) ring32 = (uint32_t)(dr->dr_ring_dmabase); addrext = (ring32 & SIBA_DMA_TRANSLATION_MASK) >> 30; value = BWN_DMA32_TXENABLE; + value |= BWN_DMA32_TXPARITY_DISABLE; value |= (addrext << BWN_DMA32_TXADDREXT_SHIFT) & BWN_DMA32_TXADDREXT_MASK; BWN_DMA_WRITE(dr, BWN_DMA32_TXCTL, value); @@ -3141,6 +3143,7 @@ bwn_dma_setup(struct bwn_dma_ring *dr) addrext = ((ring64 >> 32) & SIBA_DMA_TRANSLATION_MASK) >> 30; value = (dr->dr_frameoffset << BWN_DMA64_RXFROFF_SHIFT); value |= BWN_DMA64_RXENABLE; + value |= BWN_DMA64_RXPARITY_DISABLE; value |= (addrext << BWN_DMA64_RXADDREXT_SHIFT) & BWN_DMA64_RXADDREXT_MASK; BWN_DMA_WRITE(dr, BWN_DMA64_RXCTL, value); @@ -3155,6 +3158,7 @@ bwn_dma_setup(struct bwn_dma_ring *dr) addrext = (ring32 & SIBA_DMA_TRANSLATION_MASK) >> 30; value = (dr->dr_frameoffset << BWN_DMA32_RXFROFF_SHIFT); value |= BWN_DMA32_RXENABLE; + value |= BWN_DMA32_RXPARITY_DISABLE; value |= (addrext << BWN_DMA32_RXADDREXT_SHIFT) & BWN_DMA32_RXADDREXT_MASK; BWN_DMA_WRITE(dr, BWN_DMA32_RXCTL, value); Modified: head/sys/dev/bwn/if_bwn_bhnd.c == --- head/sys/dev/bwn/if_bwn_bhnd.c Thu Dec 14 04:41:07 2017 (r326840) +++ head/sys/dev/bwn/if_bwn_bhnd.c Thu Dec 14 06:45:04 2017 (r326841) @@ -68,11 +68,14 @@ __FBSDID("$FreeBSD$"); #include "if_bwnvar.h" /* Supported device identifiers */ +#defineBWN_DEV(_hwrev) {{ \ + BHND_MATCH_CORE(BHND_MFGID_BCM, BHND_COREID_D11), \ + BHND_MATCH_CORE_REV(_hwrev),\ +}} + static const struct bhnd_device bwn_devices[] = { - {{ - BHND_MATCH_CORE (BHND_MFGID_BCM, BHND_COREID_D11), - BHND_MATCH_CORE_REV (HWREV_RANGE(5, 16)) - }}, + BWN_DEV(HWREV_RANGE(5, 16)), + BWN_DEV(HWREV_EQ(23)), BHND_DEVICE_END }; Modified:
svn commit: r326839 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Thu Dec 14 03:41:12 2017 New Revision: 326839 URL: https://svnweb.freebsd.org/changeset/base/326839 Log: bhndb(4): Fix two register window overcommit bugs introduced in r326297: - The window target must always be updated when stealing a register window. - Fix missing initialization of bhndb(4) region alloc_flags when registering statically mapped port regions (caught by scan-build). Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb.c Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Thu Dec 14 03:12:05 2017 (r326838) +++ head/sys/dev/bhnd/bhndb/bhndb.c Thu Dec 14 03:41:12 2017 (r326839) @@ -340,7 +340,7 @@ bhndb_init_region_cfg(struct bhndb_softc *sc, bhnd_ero * always HIGH. */ error = bhndb_add_resource_region(br, addr, size, - BHNDB_PRIORITY_HIGH, 0, regw); + BHNDB_PRIORITY_HIGH, alloc_flags, regw); if (error) return (error); } @@ -1634,14 +1634,33 @@ bhndb_deactivate_bhnd_resource(device_t dev, device_t } /** - * Slow path for bhndb_io_resource(). - * - * Iterates over the existing allocated dynamic windows looking for a viable - * in-use region; the first matching region is returned. + * Find the best available bridge resource allocation record capable of handling + * bus I/O requests of @p size at @p addr. + * + * In order of preference, this function will either: + * + * - Configure and return a free allocation record + * - Return an existing allocation record mapping the requested space, or + * - Steal, configure, and return an in-use allocation record. + * + * Will panic if a usable record cannot be found. + * + * @param sc Bridge driver state. + * @param addr The I/O target address. + * @param size The size of the I/O operation to be performed at @p addr. + * @param[out] borrowed Set to true if the allocation record was borrowed to + * fulfill this request; the borrowed record maps the target address range, + * and must not be modified. + * @param[out] stolen Set to true if the allocation record was stolen to fulfill + * this request. If a stolen allocation record is returned, + * bhndb_io_resource_restore() must be called upon completion of the bus I/O + * request. + * @param[out] restore If the allocation record was stolen, this will be set + * to the target that must be restored. */ static struct bhndb_dw_alloc * -bhndb_io_resource_slow(struct bhndb_softc *sc, bus_addr_t addr, bus_size_t size, -bus_size_t *offset, bool *stolen, bus_addr_t *restore) +bhndb_io_resource_get_window(struct bhndb_softc *sc, bus_addr_t addr, +bus_size_t size, bool *borrowed, bool *stolen, bus_addr_t *restore) { struct bhndb_resources *br; struct bhndb_dw_alloc *dwa; @@ -1650,7 +1669,13 @@ bhndb_io_resource_slow(struct bhndb_softc *sc, bus_add BHNDB_LOCK_ASSERT(sc, MA_OWNED); br = sc->bus_res; + *borrowed = false; + *stolen = false; + /* Try to fetch a free window */ + if ((dwa = bhndb_dw_next_free(br)) != NULL) + return (dwa); + /* Search for an existing dynamic mapping of this address range. * Static regions are not searched, as a statically mapped * region would never be allocated as an indirect resource. */ @@ -1671,16 +1696,12 @@ bhndb_io_resource_slow(struct bhndb_softc *sc, bus_add continue; /* Found */ - *offset = dwa->win->win_offset; - *offset += addr - dwa->target; - - *stolen = false; + *borrowed = true; return (dwa); } - /* No existing dynamic mapping found. We'll need to check for a defined -* region to determine whether we can fulfill this request by -* stealing from an existing allocated register window */ + /* Try to steal a window; this should only be required on very early +* PCI_V0 (BCM4318, etc) Wi-Fi chipsets */ region = bhndb_find_resource_region(br, addr, size); if (region == NULL) return (NULL); @@ -1688,12 +1709,16 @@ bhndb_io_resource_slow(struct bhndb_softc *sc, bus_add if ((region->alloc_flags & BHNDB_ALLOC_FULFILL_ON_OVERCOMMIT) == 0) return (NULL); + /* Steal a window. This acquires our backing spinlock, disabling +* interrupts; the spinlock will be released by +* bhndb_dw_return_stolen() */ if ((dwa = bhndb_dw_steal(br, restore)) != NULL) { *stolen = true; return (dwa); } - return (NULL); + panic("register windows exhausted
svn commit: r326838 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Thu Dec 14 03:12:05 2017 New Revision: 326838 URL: https://svnweb.freebsd.org/changeset/base/326838 Log: bhnd_chipc(4): Correct typo in flag macros that broke clearing of GPIO pin flags. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h Modified: head/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h == --- head/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h Thu Dec 14 03:03:08 2017(r326837) +++ head/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h Thu Dec 14 03:12:05 2017(r326838) @@ -111,7 +111,7 @@ struct chipc_gpio_update { if (_val) \ (_upd)->_reg.value |= (1 << (_pin));\ else\ - (_upd)->_reg.value &= (1 << (_pin));\ + (_upd)->_reg.value &= ~(1 << (_pin)); \ } while(0) /** ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326837 - in head/sys/dev/bhnd: . tools
Author: landonf Date: Thu Dec 14 03:03:08 2017 New Revision: 326837 URL: https://svnweb.freebsd.org/changeset/base/326837 Log: bhnd(4): Add missing enclosing parentheses to the bhnd bus space macros to avoid precedence bugs. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/tools/bus_macro.sh Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hThu Dec 14 01:58:05 2017(r326836) +++ head/sys/dev/bhnd/bhnd.hThu Dec 14 03:03:08 2017(r326837) @@ -1502,262 +1502,262 @@ bhnd_get_region_addr(device_t dev, bhnd_port_type port * Generated with bhnd/tools/bus_macro.sh */ #define bhnd_bus_barrier(r, o, l, f) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_barrier((r)->res, (o), (l), (f)) : \ BHND_BUS_BARRIER( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (l), (f)) + rman_get_device((r)->res), (r), (o), (l), (f))) #define bhnd_bus_read_1(r, o) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_read_1((r)->res, (o)) : \ BHND_BUS_READ_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o)) + rman_get_device((r)->res), (r), (o))) #define bhnd_bus_read_multi_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_read_multi_1((r)->res, (o), (d), (c)) : \ BHND_BUS_READ_MULTI_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (d), (c)) + rman_get_device((r)->res), (r), (o), (d), (c))) #define bhnd_bus_read_region_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_read_region_1((r)->res, (o), (d), (c)) : \ BHND_BUS_READ_REGION_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (d), (c)) + rman_get_device((r)->res), (r), (o), (d), (c))) #define bhnd_bus_write_1(r, o, v) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_write_1((r)->res, (o), (v)) : \ BHND_BUS_WRITE_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (v)) + rman_get_device((r)->res), (r), (o), (v))) #define bhnd_bus_write_multi_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_write_multi_1((r)->res, (o), (d), (c)) : \ BHND_BUS_WRITE_MULTI_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (d), (c)) + rman_get_device((r)->res), (r), (o), (d), (c))) #define bhnd_bus_write_region_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_write_region_1((r)->res, (o), (d), (c)) : \ BHND_BUS_WRITE_REGION_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (d), (c)) + rman_get_device((r)->res), (r), (o), (d), (c))) #define bhnd_bus_read_stream_1(r, o) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_read_stream_1((r)->res, (o)) : \ BHND_BUS_READ_STREAM_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o)) + rman_get_device((r)->res), (r), (o))) #define bhnd_bus_read_multi_stream_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_read_multi_stream_1((r)->res, (o), (d), (c)) : \ BHND_BUS_READ_MULTI_STREAM_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (d), (c)) + rman_get_device((r)->res), (r), (o), (d), (c))) #define bhnd_bus_read_region_stream_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_read_region_stream_1((r)->res, (o), (d), (c)) : \ BHND_BUS_READ_REGION_STREAM_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (d), (c)) + rman_get_device((r)->res), (r), (o), (d), (c))) #define bhnd_bus_write_stream_1(r, o, v) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_write_stream_1((r)->res, (o), (v)) : \ BHND_BUS_WRITE_STREAM_1( \ device_get_parent(rman_get_device((r)->res)), \ - rman_get_device((r)->res), (r), (o), (v)) + rman_get_device((r)->res), (r), (o), (v))) #define bhnd_bus_write_multi_stream_1(r, o, d, c) \ -((r)->direct) ? \ +(((r)->direct) ? \ bus_write_multi_stream_1((r)->res, (o), (d), (c)) : \ BHND_BUS_WRITE_MULTI_STREAM_1( \ device_get_parent(rman_get_device((r)->res)), \ -
svn commit: r326836 - in head: share/man/man9 sys/dev/bhnd sys/dev/bhnd/bhndb sys/mips/broadcom
Author: landonf Date: Thu Dec 14 01:58:05 2017 New Revision: 326836 URL: https://svnweb.freebsd.org/changeset/base/326836 Log: bhnd(4): Include board_devid in the bhnd_board_info structure, and populate the expected default board_vendor value on MIPS SoCs. This is required by bwn(4) to differentiate between single-band and dual-band device variants that otherwise share a common chip ID. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/share/man/man9/bhnd.9 head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_match.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/mips/broadcom/bhnd_nexus.c Modified: head/share/man/man9/bhnd.9 == --- head/share/man/man9/bhnd.9 Wed Dec 13 21:17:00 2017(r326835) +++ head/share/man/man9/bhnd.9 Thu Dec 14 01:58:05 2017(r326836) @@ -1309,8 +1309,9 @@ structure contains the following fields: .It Fa board_vendor Vendor ID of the board manufacturer (PCI-SIG assigned). .It Fa board_type +Board ID. +.It Fa board_devid Device ID. -This is generally a Broadcom-assigned globally unique identifier. .It Fa board_rev Board revision. .It Fa board_srom_rev @@ -1323,12 +1324,25 @@ Board flags (2) Board flags (3) .El .Pp +The +.Fa board_devid +field is the Broadcom PCI device ID that most closely matches the +capabilities of the BHND device (if any). +.Pp On PCI devices, the -.Fa board_vendor +.Fa board_vendor , +.Fa board_type , and -.Fa board_type -fields default to the PCI Subsystem Vendor ID and PCI Subsystem ID, unless -overridden in device NVRAM. +.Fa board_devid +fields default to the PCI Subsystem Vendor ID, PCI Subsystem ID, and PCI +device ID, unless overridden in device NVRAM. +.Pp +On other devices, including SoCs, the +.Fa board_vendor , +.Fa board_type , +and +.Fa board_devid +fields will be populated from device NVRAM. .Pp Symbolic constants for common board flags are defined in .In dev/bhnd/bhnd_ids.h . Modified: head/sys/dev/bhnd/bhnd.c == --- head/sys/dev/bhnd/bhnd.cWed Dec 13 21:17:00 2017(r326835) +++ head/sys/dev/bhnd/bhnd.cThu Dec 14 01:58:05 2017(r326836) @@ -1140,7 +1140,6 @@ static device_method_t bhnd_methods[] = { /* BHND interface */ DEVMETHOD(bhnd_bus_get_chipid, bhnd_bus_generic_get_chipid), DEVMETHOD(bhnd_bus_is_hw_disabled, bhnd_bus_generic_is_hw_disabled), - DEVMETHOD(bhnd_bus_read_board_info, bhnd_bus_generic_read_board_info), DEVMETHOD(bhnd_bus_get_probe_order, bhnd_generic_get_probe_order), Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hWed Dec 13 21:17:00 2017(r326835) +++ head/sys/dev/bhnd/bhnd.hThu Dec 14 01:58:05 2017(r326836) @@ -163,20 +163,41 @@ BHND_ACCESSOR(pmu_info, PMU_INFO, void *); * A bhnd(4) board descriptor. */ struct bhnd_board_info { - uint16_tboard_vendor; /**< PCI-SIG vendor ID (even on non-PCI - * devices). + uint16_tboard_vendor; /**< Board vendor (PCI-SIG vendor ID). * - * On PCI devices, this will generally - * be the subsystem vendor ID, but the - * value may be overridden in device - * NVRAM. + * On PCI devices, this will default to + * the PCI subsystem vendor ID, but may + * be overridden by the 'boardtype' + * NVRAM variable. + * + * On SoCs, this will default to + * PCI_VENDOR_BROADCOM, but may be + * overridden by the 'boardvendor' + * NVRAM variable. */ uint16_tboard_type; /**< Board type (See BHND_BOARD_*) * - * On PCI devices, this will generally - * be the subsystem device ID, but the - * value may be overridden in device - * NVRAM. + * This value is usually a + * Broadcom-assigned reference board +
Re: svn commit: r326454 - in head/sys: conf dev/bwn gnu/dev/bwn/phy_n modules/bwn modules/bwn_pci
On Fri, Dec 1, 2017 at 11:21 PM, Kyle Evans <kev...@freebsd.org> wrote: On Dec 1, 2017 8:21 PM, "Landon J. Fuller" <land...@freebsd.org> wrote: Log: Introduce bwn(4) support for the bhnd(4) bus. Hi, I'm pretty sure we've discussed this, but I don't recall to what detail that was- I recall that the 4313 is BCMA, but does it have one of the PHYs that we support already? If so, I'll happily test there. The BCM4313 uses an LCN PHY; we're probably going to have to bring over Broadcom's ISC-licensed LCN-PHY support from their Linux brcmsmac driver before we can bring up the 4313. Cheers, Landon ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326454 - in head/sys: conf dev/bwn gnu/dev/bwn/phy_n modules/bwn modules/bwn_pci
a_sprom_get_ofdm5glpo, + .sprom_get_ofdm5gpo = siba_sprom_get_ofdm5gpo, + .sprom_get_ofdm5ghpo= siba_sprom_get_ofdm5ghpo, + .sprom_get_bf_lo= siba_sprom_get_bf_lo, + .sprom_set_bf_lo= siba_sprom_set_bf_lo, + .sprom_get_bf_hi= siba_sprom_get_bf_hi, + .sprom_get_bf2_lo = siba_sprom_get_bf2_lo, + .sprom_get_bf2_hi = siba_sprom_get_bf2_hi, + .sprom_get_fem_2ghz_tssipos = siba_sprom_get_fem_2ghz_tssipos, + .sprom_get_fem_2ghz_extpa_gain = siba_sprom_get_fem_2ghz_extpa_gain, + .sprom_get_fem_2ghz_pdet_range = siba_sprom_get_fem_2ghz_pdet_range, + .sprom_get_fem_2ghz_tr_iso = siba_sprom_get_fem_2ghz_tr_iso, + .sprom_get_fem_2ghz_antswlut= siba_sprom_get_fem_2ghz_antswlut, + .sprom_get_fem_5ghz_extpa_gain = siba_sprom_get_fem_5ghz_extpa_gain, + .sprom_get_fem_5ghz_pdet_range = siba_sprom_get_fem_5ghz_pdet_range, + .sprom_get_fem_5ghz_antswlut= siba_sprom_get_fem_5ghz_antswlut, + .sprom_get_txpid_2g_0 = siba_sprom_get_txpid_2g_0, + .sprom_get_txpid_2g_1 = siba_sprom_get_txpid_2g_1, + .sprom_get_txpid_5gl_0 = siba_sprom_get_txpid_5gl_0, + .sprom_get_txpid_5gl_1 = siba_sprom_get_txpid_5gl_1, + .sprom_get_txpid_5g_0 = siba_sprom_get_txpid_5g_0, + .sprom_get_txpid_5g_1 = siba_sprom_get_txpid_5g_1, + .sprom_get_txpid_5gh_0 = siba_sprom_get_txpid_5gh_0, + .sprom_get_txpid_5gh_1 = siba_sprom_get_txpid_5gh_1, + .sprom_get_stbcpo = siba_sprom_get_stbcpo, + .sprom_get_cddpo= siba_sprom_get_cddpo, + .powerup= siba_powerup, + .powerdown = siba_powerdown, + .read_2 = siba_read_2, + .write_2= siba_write_2, + .read_4 = siba_read_4, + .write_4= siba_write_4, + .dev_up = siba_dev_up, + .dev_down = siba_dev_down, + .dev_isup = siba_dev_isup, + .pcicore_intr = siba_pcicore_intr, + .dma_translation= siba_dma_translation, + .read_multi_2 = siba_read_multi_2, + .read_multi_4 = siba_read_multi_4, + .write_multi_2 = siba_write_multi_2, + .write_multi_4 = siba_write_multi_4, + .barrier= siba_barrier, + .cc_pmu_set_ldovolt = siba_cc_pmu_set_ldovolt, + .cc_pmu_set_ldoparef= siba_cc_pmu_set_ldoparef, + .gpio_set = siba_gpio_set, + .gpio_get = siba_gpio_get, + .fix_imcfglobug = siba_fix_imcfglobug, + .sprom_get_core_power_info = siba_sprom_get_core_power_info, + .sprom_get_mcs2gpo = siba_sprom_get_mcs2gpo, + .sprom_get_mcs5glpo = siba_sprom_get_mcs5glpo, + .sprom_get_mcs5gpo = siba_sprom_get_mcs5gpo, + .sprom_get_mcs5ghpo = siba_sprom_get_mcs5ghpo, + .pmu_spuravoid_pllupdate= siba_pmu_spuravoid_pllupdate, + .cc_set32 = siba_cc_set32, + .cc_mask32 = siba_cc_mask32, + .cc_write32 = siba_cc_write32, +}; Added: head/sys/dev/bwn/if_bwn_siba.h == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bwn/if_bwn_siba.h Sat Dec 2 02:21:27 2017 (r326454) @@ -0,0 +1,491 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2016 Landon J. Fuller <land...@freebsd.org>. + * Copyright (c) 2007 Bruce M. Simpson. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGE
svn commit: r326452 - head/sys/dev/bhnd/cores/pmu
Author: landonf Date: Sat Dec 2 01:10:45 2017 New Revision: 326452 URL: https://svnweb.freebsd.org/changeset/base/326452 Log: bhnd_pmu(4): Do not leak our chipc provider reference or clkctl state in failure paths of bhnd_pmu_attach() Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c Modified: head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c == --- head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c Sat Dec 2 01:07:41 2017 (r326451) +++ head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c Sat Dec 2 01:10:45 2017 (r326452) @@ -133,33 +133,14 @@ bhnd_pmu_attach(device_t dev, struct bhnd_resource *re return (ENXIO); } - /* Allocate our own core clkctl state directly; we use this to wait on -* PMU state transitions, avoiding a cyclic dependency between bhnd(4)'s -* clkctl handling and registration of this device as a PMU */ - sc->clkctl = bhnd_alloc_core_clkctl(core, dev, sc->res, BHND_CLK_CTL_ST, - BHND_PMU_MAX_TRANSITION_DLY); - if (sc->clkctl == NULL) { - device_printf(sc->dev, "failed to allocate clkctl for %s\n", - device_get_nameunit(core)); - return (ENOMEM); - } - /* Fetch chip and board info */ sc->cid = *bhnd_get_chipid(core); - if ((error = bhnd_read_board_info(core, >board))) { device_printf(sc->dev, "error fetching board info: %d\n", error); return (ENXIO); } - /* Locate ChipCommon device */ - sc->chipc_dev = bhnd_retain_provider(dev, BHND_SERVICE_CHIPC); - if (sc->chipc_dev == NULL) { - device_printf(sc->dev, "chipcommon device not found\n"); - return (ENXIO); - } - /* Initialize query state */ error = bhnd_pmu_query_init(>query, dev, sc->cid, _pmu_res_io, sc); @@ -170,6 +151,26 @@ bhnd_pmu_attach(device_t dev, struct bhnd_resource *re BPMU_LOCK_INIT(sc); + /* Allocate our own core clkctl state directly; we use this to wait on +* PMU state transitions, avoiding a cyclic dependency between bhnd(4)'s +* clkctl handling and registration of this device as a PMU */ + sc->clkctl = bhnd_alloc_core_clkctl(core, dev, sc->res, BHND_CLK_CTL_ST, + BHND_PMU_MAX_TRANSITION_DLY); + if (sc->clkctl == NULL) { + device_printf(sc->dev, "failed to allocate clkctl for %s\n", + device_get_nameunit(core)); + error = ENOMEM; + goto failed; + } + + /* Locate ChipCommon device */ + sc->chipc_dev = bhnd_retain_provider(dev, BHND_SERVICE_CHIPC); + if (sc->chipc_dev == NULL) { + device_printf(sc->dev, "chipcommon device not found\n"); + error = ENXIO; + goto failed; + } + /* Initialize PMU */ if ((error = bhnd_pmu_init(sc))) { device_printf(sc->dev, "PMU init failed: %d\n", error); @@ -204,8 +205,14 @@ bhnd_pmu_attach(device_t dev, struct bhnd_resource *re failed: BPMU_LOCK_DESTROY(sc); bhnd_pmu_query_fini(>query); - bhnd_free_core_clkctl(sc->clkctl); - bhnd_release_provider(sc->dev, sc->chipc_dev, BHND_SERVICE_CHIPC); + + if (sc->clkctl != NULL) + bhnd_free_core_clkctl(sc->clkctl); + + if (sc->chipc_dev != NULL) { + bhnd_release_provider(sc->dev, sc->chipc_dev, + BHND_SERVICE_CHIPC); + } return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326451 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Sat Dec 2 01:07:41 2017 New Revision: 326451 URL: https://svnweb.freebsd.org/changeset/base/326451 Log: bhndb(4): Fix leak of child devices and MSI vectors. - Add missing call to device_delete_children() in bhndb_detach(), without which we're left with stale child devices on module unload. - Pass the parent PCI device to pci_release_msi(), not the bhndb_pci(4) child. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_pci.c Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Sat Dec 2 00:52:59 2017 (r326450) +++ head/sys/dev/bhnd/bhndb/bhndb.c Sat Dec 2 01:07:41 2017 (r326451) @@ -639,6 +639,10 @@ bhndb_generic_detach(device_t dev) if ((error = bus_generic_detach(dev))) return (error); + /* Delete children */ + if ((error = device_delete_children(dev))) + return (error); + /* Clean up our service registry */ if ((error = bhnd_service_registry_fini(>services))) return (error); Modified: head/sys/dev/bhnd/bhndb/bhndb_pci.c == --- head/sys/dev/bhnd/bhndb/bhndb_pci.c Sat Dec 2 00:52:59 2017 (r326450) +++ head/sys/dev/bhnd/bhndb/bhndb_pci.c Sat Dec 2 01:07:41 2017 (r326451) @@ -303,8 +303,10 @@ bhndb_pci_alloc_msi(struct bhndb_pci_softc *sc, int *m return (error); } - if (count < BHNDB_PCI_MSI_COUNT) + if (count < BHNDB_PCI_MSI_COUNT) { + pci_release_msi(sc->parent); return (ENXIO); + } *msi_count = count; return (0); @@ -412,7 +414,7 @@ cleanup: bhndb_free_intr_isrc(sc->isrc); if (sc->msi_count > 0) - pci_release_msi(dev); + pci_release_msi(sc->parent); if (cores != NULL) free(cores, M_BHND); @@ -449,7 +451,7 @@ bhndb_pci_detach(device_t dev) /* Release MSI interrupts */ if (sc->msi_count > 0) - pci_release_msi(dev); + pci_release_msi(sc->parent); /* Disable PCI bus mastering */ pci_disable_busmaster(sc->parent); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326450 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Sat Dec 2 00:52:59 2017 New Revision: 326450 URL: https://svnweb.freebsd.org/changeset/base/326450 Log: bhnd_chipc(4): Break cyclic references to the ChipCommon device bhnd_chipc's children may hold strong provider references to their parent; we must detach any children before attempting to deregister the bhnd_chipc device as a bus service provider. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/cores/chipc/chipc.c Modified: head/sys/dev/bhnd/cores/chipc/chipc.c == --- head/sys/dev/bhnd/cores/chipc/chipc.c Sat Dec 2 00:09:58 2017 (r326449) +++ head/sys/dev/bhnd/cores/chipc/chipc.c Sat Dec 2 00:52:59 2017 (r326450) @@ -245,10 +245,10 @@ chipc_detach(device_t dev) sc = device_get_softc(dev); - if ((error = bhnd_deregister_provider(dev, BHND_SERVICE_ANY))) + if ((error = bus_generic_detach(dev))) return (error); - if ((error = bus_generic_detach(dev))) + if ((error = bhnd_deregister_provider(dev, BHND_SERVICE_ANY))) return (error); chipc_release_region(sc, sc->core_region, RF_ALLOCATED|RF_ACTIVE); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326449 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Sat Dec 2 00:09:58 2017 New Revision: 326449 URL: https://svnweb.freebsd.org/changeset/base/326449 Log: bhndb(4): Fix incorrect assertion in bhndb_deregister_intr_handler(). When deregistered, a handler should be in an 'active' state. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb_subr.c Modified: head/sys/dev/bhnd/bhndb/bhndb_subr.c == --- head/sys/dev/bhnd/bhndb/bhndb_subr.cSat Dec 2 00:07:37 2017 (r326448) +++ head/sys/dev/bhnd/bhndb/bhndb_subr.cSat Dec 2 00:09:58 2017 (r326449) @@ -957,7 +957,7 @@ void bhndb_deregister_intr_handler(struct bhndb_resources *br, struct bhndb_intr_handler *ih) { - KASSERT(!ih->ih_active, ("duplicate deregistration of interrupt " + KASSERT(ih->ih_active, ("duplicate deregistration of interrupt " "handler %p", ih->ih_cookiep)); KASSERT(bhndb_find_intr_handler(br, ih) == ih, ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326301 - in head/sys: dev/bhnd/siba modules/bhnd/siba
Author: landonf Date: Tue Nov 28 00:42:44 2017 New Revision: 326301 URL: https://svnweb.freebsd.org/changeset/base/326301 Log: siba(4): Add support for devices have neither PMU nor PWRCTL support. Very early BHND Wi-Fi devices (e.g. BCM4318) do not support any form of dynamic clock control; on these devices, any PMU requests that cannot be met by the device's fixed clock state will return an appropriate error code. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/sibavar.h head/sys/modules/bhnd/siba/Makefile Modified: head/sys/dev/bhnd/siba/siba.c == --- head/sys/dev/bhnd/siba/siba.c Tue Nov 28 00:41:17 2017 (r326300) +++ head/sys/dev/bhnd/siba/siba.c Tue Nov 28 00:42:44 2017 (r326301) @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include +#include #include #include "sibareg.h" @@ -168,8 +169,9 @@ siba_read_ivar(device_t dev, device_t child, int index return (0); case SIBA_PMU_PWRCTL: - panic("bhnd_get_pmu_info() called with " - "SIBA_PMU_PWRCTL"); + case SIBA_PMU_FIXED: + panic("bhnd_get_pmu_info() called with siba PMU state " + "%d", dinfo->pmu_state); return (ENXIO); } @@ -211,8 +213,9 @@ siba_write_ivar(device_t dev, device_t child, int inde return (0); case SIBA_PMU_PWRCTL: - panic("bhnd_set_pmu_info() called with " - "SIBA_PMU_PWRCTL"); + case SIBA_PMU_FIXED: + panic("bhnd_set_pmu_info() called with siba PMU state " + "%d", dinfo->pmu_state); return (ENXIO); } @@ -237,7 +240,10 @@ siba_alloc_pmu(device_t dev, device_t child) { struct siba_softc *sc; struct siba_devinfo *dinfo; + device_t chipc; device_t pwrctl; + struct chipc_capsccaps; + siba_pmu_state pmu_state; int error; if (device_get_parent(child) != dev) @@ -245,11 +251,20 @@ siba_alloc_pmu(device_t dev, device_t child) sc = device_get_softc(dev); dinfo = device_get_ivars(child); - pwrctl = bhnd_retain_provider(child, BHND_SERVICE_PWRCTL); + pwrctl = NULL; - /* Unless this is a legacy PWRCTL chipset, defer to bhnd(4)'s PMU -* implementation */ - if (pwrctl == NULL) { + /* Fetch ChipCommon capability flags */ + chipc = bhnd_retain_provider(child, BHND_SERVICE_CHIPC); + if (chipc != NULL) { + ccaps = *BHND_CHIPC_GET_CAPS(chipc); + bhnd_release_provider(child, chipc, BHND_SERVICE_CHIPC); + } else { + memset(, 0, sizeof(ccaps)); + } + + /* Defer to bhnd(4)'s PMU implementation if ChipCommon exists and +* advertises PMU support */ + if (ccaps.pmu) { if ((error = bhnd_generic_alloc_pmu(dev, child))) return (error); @@ -259,8 +274,24 @@ siba_alloc_pmu(device_t dev, device_t child) return (0); } - /* This is a legacy PWRCTL chipset; we need to map all bhnd(4) bus PMU -* to PWRCTL operations ourselves.*/ + /* +* This is either a legacy PWRCTL chipset, or the device does not +* support dynamic clock control. +* +* We need to map all bhnd(4) bus PMU to PWRCTL or no-op operations. +*/ + if (ccaps.pwr_ctrl) { + pmu_state = SIBA_PMU_PWRCTL; + pwrctl = bhnd_retain_provider(child, BHND_SERVICE_PWRCTL); + if (pwrctl == NULL) { + device_printf(dev, "PWRCTL not found\n"); + return (ENODEV); + } + } else { + pmu_state = SIBA_PMU_FIXED; + pwrctl = NULL; + } + SIBA_LOCK(sc); /* Per-core PMU state already allocated? */ @@ -270,8 +301,8 @@ siba_alloc_pmu(device_t dev, device_t child) } /* Update the child's PMU allocation state, and transfer ownership of -* the PWRCTL provider reference */ - dinfo->pmu_state = SIBA_PMU_PWRCTL; +* the PWRCTL provider reference (if any) */ + dinfo->pmu_state = pmu_state; dinfo->pmu.pwrctl = pwrctl; SIBA_UNLOCK(sc); @@ -324,6 +355,15 @@ siba_release_pmu(device_t dev, device_t child) /* Release the provider reference */ bhnd_release_provider(child, pwrctl, BHND_SERVICE_PWRCTL); return (0); + + case SIBA_PMU_FIXED: + /* Clean up the
svn commit: r326297 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Tue Nov 28 00:12:14 2017 New Revision: 326297 URL: https://svnweb.freebsd.org/changeset/base/326297 Log: bhndb(4): Implement bridge support for the BCM4312 and other PCI_V0 chipsets. Very early (PCI_V0) Broadcom PCI Wi-Fi chipsets have a few quirks when compared to later PCI(e) core revisions: - The standard static BAR0 mapping of the PCI core registers is discontiguous, with siba's cfg0 register block mapped distinctly from the other core registers. - No dedicated ChipCommon register mapping is provided; instead, the single configurable register window must be used to access both ChipCommon and D11 core registers. The D11 core's operational semantics guarantee the safety of -- after disabling interrupts -- borrowing the single dynamic register window to perform the few ChipCommon operations required by a driver. To support these early PCI devices: - Allow defining multiple discontiguous BHNDB_REGWIN_T_CORE register windows that map a single port/region, and producing bridged resource allocations backed by those discontiguous windows. - Support stealing existing register window allocations to fulfill indirect bhnd(4) bus I/O requests within address ranges tagged with BHNDB_ALLOC_FULFILL_ON_OVERCOMMIT. - Fix an inverted test of bhndb_is_pcie_attached() that disabled PCI-only clock bring-up required by these devices. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb.h head/sys/dev/bhnd/bhndb/bhndb_hwdata.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_pci_hwdata.c head/sys/dev/bhnd/bhndb/bhndb_pcireg.h head/sys/dev/bhnd/bhndb/bhndb_private.h head/sys/dev/bhnd/bhndb/bhndb_subr.c head/sys/dev/bhnd/bhndb/bhndbvar.h Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Mon Nov 27 23:48:21 2017 (r326296) +++ head/sys/dev/bhnd/bhndb/bhndb.c Tue Nov 28 00:12:14 2017 (r326297) @@ -115,9 +115,9 @@ static int bhndb_try_activate_resource( static inline struct bhndb_dw_alloc *bhndb_io_resource(struct bhndb_softc *sc, bus_addr_t addr, bus_size_t size, - bus_size_t *offset); + bus_size_t *offset, bool *stolen, + bus_addr_t *restore); - /** * Default bhndb(4) implementation of DEVICE_PROBE(). * @@ -270,6 +270,9 @@ bhndb_init_region_cfg(struct bhndb_softc *sc, bhnd_ero for (regw = br->cfg->register_windows; regw->win_type != BHNDB_REGWIN_T_INVALID; regw++) { + const struct bhndb_port_priority*pp; + uint32_t alloc_flags; + /* Only core windows are supported */ if (regw->win_type != BHNDB_REGWIN_T_CORE) continue; @@ -295,6 +298,18 @@ bhndb_init_region_cfg(struct bhndb_softc *sc, bhnd_ero } /* +* Apply the register window's region offset, if any. +*/ + if (regw->d.core.offset > size) { + device_printf(sc->dev, "invalid register " + "window offset %#jx for region %#jx+%#jx\n", + regw->d.core.offset, addr, size); + return (EINVAL); + } + + addr += regw->d.core.offset; + + /* * Always defer to the register window's size. * * If the port size is smaller than the window size, @@ -307,14 +322,25 @@ bhndb_init_region_cfg(struct bhndb_softc *sc, bhnd_ero */ size = regw->win_size; + /* Fetch allocation flags from the corresponding port +* priority entry, if any */ + pp = bhndb_hw_priorty_find_port(table, core, + regw->d.core.port_type, regw->d.core.port, + regw->d.core.region); + if (pp != NULL) { + alloc_flags = pp->alloc_flags; + } else { + alloc_flags = 0; + } + /* * Add to the bus region list. * -* The window priority for a statically mapped -* region is always HIGH. +
svn commit: r326294 - head/sys/dev/bhnd/siba
Author: landonf Date: Mon Nov 27 22:38:44 2017 New Revision: 326294 URL: https://svnweb.freebsd.org/changeset/base/326294 Log: siba(4): fix workaround for BCM4312 D11 core backplane timeouts The SIBA_QUIRK_PCIE_D11_SB_TIMEOUT quirk should match on all BCM4312 revisions, and backplane service timeouts must also be disabled. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/siba/siba_bhndb.c Modified: head/sys/dev/bhnd/siba/siba_bhndb.c == --- head/sys/dev/bhnd/siba/siba_bhndb.c Mon Nov 27 22:29:35 2017 (r326293) +++ head/sys/dev/bhnd/siba/siba_bhndb.c Mon Nov 27 22:38:44 2017 (r326294) @@ -77,7 +77,7 @@ static struct bhnd_device_quirk pci_bridge_quirks[] = /* Bus-level quirks when bridged via a PCIe host bridge core */ static struct bhnd_device_quirk pcie_bridge_quirks[] = { BHND_CHIP_QUIRK (4311, HWREV_EQ(2), SIBA_QUIRK_PCIE_D11_SB_TIMEOUT), - BHND_CHIP_QUIRK (4312, HWREV_EQ(0), SIBA_QUIRK_PCIE_D11_SB_TIMEOUT), + BHND_CHIP_QUIRK (4312, HWREV_ANY, SIBA_QUIRK_PCIE_D11_SB_TIMEOUT), BHND_DEVICE_QUIRK_END }; @@ -250,7 +250,7 @@ siba_bhndb_wars_pcie_clear_d11_timeout(struct siba_bhn KASSERT(dinfo->cfg_res[0] != NULL, ("missing core config mapping")); imcfg = bhnd_bus_read_4(dinfo->cfg_res[0], SIBA_CFG0_IMCONFIGLOW); - imcfg &= ~SIBA_IMCL_RTO_MASK; + imcfg &= ~(SIBA_IMCL_RTO_MASK|SIBA_IMCL_STO_MASK); bhnd_bus_write_4(dinfo->cfg_res[0], SIBA_CFG0_IMCONFIGLOW, imcfg); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326293 - head/sys/dev/bhnd
Author: landonf Date: Mon Nov 27 22:29:35 2017 New Revision: 326293 URL: https://svnweb.freebsd.org/changeset/base/326293 Log: bhnd(4): Print the core's hardware revision in bhnd(4)'s BUS_PROBE_NOMATCH(). Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Modified: head/sys/dev/bhnd/bhnd.c Modified: head/sys/dev/bhnd/bhnd.c == --- head/sys/dev/bhnd/bhnd.cMon Nov 27 22:13:30 2017(r326292) +++ head/sys/dev/bhnd/bhnd.cMon Nov 27 22:29:35 2017(r326293) @@ -892,8 +892,8 @@ bhnd_generic_probe_nomatch(device_t dev, device_t chil return; /* Print the non-matched device info */ - device_printf(dev, "<%s %s>", bhnd_get_vendor_name(child), - bhnd_get_device_name(child)); + device_printf(dev, "<%s %s, rev %hhu>", bhnd_get_vendor_name(child), + bhnd_get_device_name(child), bhnd_get_hwrev(child)); rl = BUS_GET_RESOURCE_LIST(dev, child); if (rl != NULL) { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326292 - in head: share/man/man9 sys/dev/bhnd sys/dev/bhnd/bcma sys/dev/bhnd/cores/usb sys/dev/bhnd/siba
Author: landonf Date: Mon Nov 27 22:13:30 2017 New Revision: 326292 URL: https://svnweb.freebsd.org/changeset/base/326292 Log: bhnd(4): Fix bcma/siba core reset behavior Add missing support for specifying I/O control flags during core reset, and resolve a number of siba(4)-specific reset issues: - Add missing check for target reject flags in siba_is_hw_suspended(). - Remove incorrect wait on SIBA_TMH_BUSY when modifying any target state register; this should only be done when waiting for initiated transactions to clear. - Add missing wait on SIBA_IM_BY when asserting SIBA_IM_RJ. - Overwrite any previously set SIBA_TML_REJ flag when bringing the core out of reset. This fixes a lockup that occured when we brought up a core (after reboot) that had previously been placed into RESET by siba_bwn(4). Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D13039 Modified: head/share/man/man9/bhnd.9 head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_subr.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/cores/usb/bhnd_usb.c head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibavar.h Modified: head/share/man/man9/bhnd.9 == --- head/share/man/man9/bhnd.9 Mon Nov 27 21:30:49 2017(r326291) +++ head/share/man/man9/bhnd.9 Mon Nov 27 22:13:30 2017(r326292) @@ -266,9 +266,9 @@ .Fa "device_t dev" "bus_size_t offset" "const void *value" "u_int width" .Fc .Ft int -.Fn bhnd_reset_hw "device_t dev" "uint16_t ioctl" +.Fn bhnd_reset_hw "device_t dev" "uint16_t ioctl" "uint16_t reset_ioctl" .Ft int -.Fn bhnd_suspend_hw "device_t dev" +.Fn bhnd_suspend_hw "device_t dev" "uint16_t ioctl" .Ft bool .Fn bhnd_is_hw_suspended "device_t dev" .\" @@ -1054,7 +1054,10 @@ function transitions the device .Fa dev to a low power .Dq RESET -state. +state, writing +.Fa ioctl +to the I/O control flags of +.Fa dev . The hardware may be brought out of this state using .Fn bhnd_reset_hw . .Pp @@ -1062,10 +1065,14 @@ The .Fn bhnd_reset_hw function first transitions the device .Fa dev -to a low power RESET state, and then brings the device out of RESET, writing +to a low power RESET state, writing +.Fa ioctl_reset +to the I/O control flags +of +.Fa dev , +and then brings the device out of RESET, writing .Fa ioctl -to the I/O control flags of -.Fa dev . +to the device's I/O control flags. .Pp The .Fn bhnd_is_hw_suspended Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Mon Nov 27 21:30:49 2017 (r326291) +++ head/sys/dev/bhnd/bcma/bcma.c Mon Nov 27 22:13:30 2017 (r326292) @@ -296,22 +296,22 @@ bcma_is_hw_suspended(device_t dev, device_t child) } static int -bcma_reset_hw(device_t dev, device_t child, uint16_t ioctl) +bcma_reset_hw(device_t dev, device_t child, uint16_t ioctl, +uint16_t reset_ioctl) { - struct bcma_devinfo *dinfo; - struct bhnd_core_pmu_info *pm; - struct bhnd_resource*r; - int error; + struct bcma_devinfo *dinfo; + struct bhnd_resource*r; + uint16_t clkflags; + int error; if (device_get_parent(child) != dev) return (EINVAL); dinfo = device_get_ivars(child); - pm = dinfo->pmu_info; - /* We require exclusive control over BHND_IOCTL_CLK_EN and -* BHND_IOCTL_CLK_FORCE. */ - if (ioctl & (BHND_IOCTL_CLK_EN | BHND_IOCTL_CLK_FORCE)) + /* We require exclusive control over BHND_IOCTL_CLK_(EN|FORCE) */ + clkflags = BHND_IOCTL_CLK_EN | BHND_IOCTL_CLK_FORCE; + if (ioctl & clkflags) return (EINVAL); /* Can't suspend the core without access to the agent registers */ @@ -319,7 +319,7 @@ bcma_reset_hw(device_t dev, device_t child, uint16_t i return (ENODEV); /* Place core into known RESET state */ - if ((error = BHND_BUS_SUSPEND_HW(dev, child))) + if ((error = bhnd_suspend_hw(child, reset_ioctl))) return (error); /* @@ -329,9 +329,7 @@ bcma_reset_hw(device_t dev, device_t child, uint16_t i * - Force clock distribution to ensure propagation throughout the * core. */ - error = bhnd_write_ioctl(child, - ioctl | BHND_IOCTL_CLK_EN | BHND_IOCTL_CLK_FORCE, UINT16_MAX); - if (error) + if ((error = bhnd_write_ioctl(child, ioctl | clkflags, UINT16_MAX))) return (error); /* Bring the core out of reset */ @@ -347,11 +345,11 @@ bcma_reset_hw(device_t dev, device_t child, uint16_t i } static int
svn commit: r326291 - in head: share/man/man4 share/man/man9 sys/dev/bhnd sys/dev/bhnd/nvram
Author: landonf Date: Mon Nov 27 21:30:49 2017 New Revision: 326291 URL: https://svnweb.freebsd.org/changeset/base/326291 Log: bhnd(4) update inline documentation comments and man pages. This includes a number of copyedits for the inline code documentation comments, updates to the existing bhnd(4), bhndb(4), bcma(4), and siba(4) man pages, and new man pages for bhnd_chipc(4), bhnd_pmu(4), bhndb_pci(4), bhnd(9), and bhnd_erom(9). Approved by: adrian (mentor) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D13021 Added: head/share/man/man4/bhnd_chipc.4 (contents, props changed) head/share/man/man4/bhnd_pmu.4 (contents, props changed) head/share/man/man4/bhndb_pci.4 (contents, props changed) head/share/man/man9/bhnd.9 (contents, props changed) head/share/man/man9/bhnd_erom.9 (contents, props changed) Modified: head/share/man/man4/Makefile head/share/man/man4/bcma.4 head/share/man/man4/bhnd.4 head/share/man/man4/bhndb.4 head/share/man/man4/siba.4 head/share/man/man9/Makefile head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_erom.c head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c Modified: head/share/man/man4/Makefile == --- head/share/man/man4/MakefileMon Nov 27 21:10:50 2017 (r326290) +++ head/share/man/man4/MakefileMon Nov 27 21:30:49 2017 (r326291) @@ -78,7 +78,10 @@ MAN= aac.4 \ bge.4 \ ${_bhyve.4} \ bhnd.4 \ + bhnd_chipc.4 \ + bhnd_pmu.4 \ bhndb.4 \ + bhndb_pci.4 \ bktr.4 \ blackhole.4 \ bnxt.4 \ Modified: head/share/man/man4/bcma.4 == --- head/share/man/man4/bcma.4 Mon Nov 27 21:10:50 2017(r326290) +++ head/share/man/man4/bcma.4 Mon Nov 27 21:30:49 2017(r326291) @@ -32,15 +32,14 @@ .Nm bcma .Nd Broadcom AMBA Backplane driver .Sh SYNOPSIS -To compile this driver into the kernel, -place the following lines in your kernel configuration file: +To compile this driver into the kernel, add the following lines to the +kernel configuration file: .Bd -ragged -offset indent .Cd "device bhnd" .Cd "device bcma" .Ed .Pp -Alternatively, to load the driver as a module at boot time, -place the following line in +To load the driver as a module at boot, add this line to .Xr loader.conf 5 : .Bd -literal -offset indent bcma_load="YES" @@ -51,8 +50,8 @@ The driver provides .Xr bhnd 4 support for devices using the ARM AMBA-based backplane architecture found -in later Broadcom Home Networking Division's (HND) wireless chipsets and -embedded systems. +in later Broadcom Home Networking Division's network chipsets and embedded +systems. .Pp A common interconnect connects all of the backplane's functional blocks. @@ -64,7 +63,9 @@ The IP cores used in devices were adapted by Broadcom for compatibility with the new interconnect. .Sh SEE ALSO -.Xr bhnd 4 +.Xr bhnd 4 , +.Xr intro 4 , +.Xr siba 4 .Sh HISTORY The .Nm Modified: head/share/man/man4/bhnd.4 == --- head/share/man/man4/bhnd.4 Mon Nov 27 21:10:50 2017(r326290) +++ head/share/man/man4/bhnd.4 Mon Nov 27 21:30:49 2017(r326291) @@ -31,14 +31,13 @@ .Nm bhnd .Nd Broadcom Home Networking Division interconnect bus .Sh SYNOPSIS -To compile this driver into the kernel, -place the following lines in your kernel configuration file: +To compile this driver into the kernel, add the following lines to the +kernel configuration file: .Bd -ragged -offset indent .Cd "device bhnd" .Ed .Pp -Alternatively, to load the driver as a module at boot time, -place the following line in +To load the driver as a module at boot, add this line to .Xr loader.conf 5 : .Bd -literal -offset indent bhnd_load="YES" @@ -69,6 +68,7 @@ BHND driver. .Sh SEE ALSO .Xr bcma 4 , .Xr bhndb 4 , +.Xr intro 4 , .Xr siba 4 .Sh HISTORY The Added: head/share/man/man4/bhnd_chipc.4 == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/share/man/man4/bhnd_chipc.4Mon Nov 27 21:30:49 2017 (r326291) @@ -0,0 +1,81 @@ +.\" Copyright (c) 2017 The FreeBSD Foundation +.\" All rights reserved. +.\" +.\" This documentation was written by Landon Fuller under sponsorship from +.\" the FreeBSD Foundation. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\"notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the
svn commit: r326174 - head/sys/modules/bhnd
Author: landonf Date: Fri Nov 24 19:01:14 2017 New Revision: 326174 URL: https://svnweb.freebsd.org/changeset/base/326174 Log: bhnd(4): Add missing dependency on ofw_bus_if.h Reported by: wma Approved by: adrian (mentor, implicit) Modified: head/sys/modules/bhnd/Makefile Modified: head/sys/modules/bhnd/Makefile == --- head/sys/modules/bhnd/Makefile Fri Nov 24 17:57:00 2017 (r326173) +++ head/sys/modules/bhnd/Makefile Fri Nov 24 19:01:14 2017 (r326174) @@ -17,7 +17,7 @@ SRCS+=bhnd_erom_if.c bhnd_erom_if.h SRCS+= chipc.c chipc_subr.c SRCS+= chipc_gpio.c -SRCS+= gpio_if.h +SRCS+= gpio_if.h ofw_bus_if.h SRCS+= bhnd_sprom_chipc.c \ bhnd_pmu_chipc.c ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r326109 - in head/sys: conf dev/bhnd dev/bhnd/cores/chipc mips/conf modules/bhnd
Author: landonf Date: Wed Nov 22 23:10:20 2017 New Revision: 326109 URL: https://svnweb.freebsd.org/changeset/base/326109 Log: bhnd(4): Add a basic ChipCommon GPIO driver sufficient to support bwn(4) The driver is functional on both BHND Wi-Fi adapters and MIPS SoCs, but does not currently include support for features not required by bwn(4), including GPIO interrupt handling. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12708 Added: head/sys/dev/bhnd/cores/chipc/chipc_gpio.c (contents, props changed) head/sys/dev/bhnd/cores/chipc/chipc_gpiovar.h (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/bhnd_types.h head/sys/dev/bhnd/cores/chipc/chipc.c head/sys/dev/bhnd/cores/chipc/chipc_subr.c head/sys/dev/bhnd/cores/chipc/chipcreg.h head/sys/mips/conf/BCM head/sys/mips/conf/SENTRY5 head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Wed Nov 22 22:04:27 2017(r326108) +++ head/sys/conf/files Wed Nov 22 23:10:20 2017(r326109) @@ -1246,6 +1246,7 @@ dev/bhnd/cores/chipc/bhnd_sprom_chipc.c optional bhnd dev/bhnd/cores/chipc/bhnd_pmu_chipc.c optional bhnd dev/bhnd/cores/chipc/chipc.c optional bhnd dev/bhnd/cores/chipc/chipc_cfi.c optional bhnd cfi +dev/bhnd/cores/chipc/chipc_gpio.c optional bhnd gpio dev/bhnd/cores/chipc/chipc_slicer.coptional bhnd cfi | bhnd spibus dev/bhnd/cores/chipc/chipc_spi.c optional bhnd spibus dev/bhnd/cores/chipc/chipc_subr.c optional bhnd Modified: head/sys/dev/bhnd/bhnd_types.h == --- head/sys/dev/bhnd/bhnd_types.h Wed Nov 22 22:04:27 2017 (r326108) +++ head/sys/dev/bhnd/bhnd_types.h Wed Nov 22 23:10:20 2017 (r326109) @@ -75,6 +75,7 @@ typedef enum { BHND_SERVICE_PWRCTL,/**< legacy pwrctl service; implements the bhnd_pwrctl interface */ BHND_SERVICE_PMU, /**< pmu service; implements the bhnd_pmu interface */ BHND_SERVICE_NVRAM, /**< nvram service; implements the bhnd_nvram interface */ + BHND_SERVICE_GPIO, /**< gpio service; implements the standard gpio interface */ BHND_SERVICE_ANY = 1000,/**< match on any service type */ } bhnd_service_t; Modified: head/sys/dev/bhnd/cores/chipc/chipc.c == --- head/sys/dev/bhnd/cores/chipc/chipc.c Wed Nov 22 22:04:27 2017 (r326108) +++ head/sys/dev/bhnd/cores/chipc/chipc.c Wed Nov 22 23:10:20 2017 (r326109) @@ -306,6 +306,20 @@ chipc_add_children(struct chipc_softc *sc) } } + /* GPIO */ + child = BUS_ADD_CHILD(sc->dev, 0, "gpio", 0); + if (child == NULL) { + device_printf(sc->dev, "failed to add gpio\n"); + return (ENXIO); + } + + error = chipc_set_mem_resource(sc, child, 0, 0, RM_MAX_END, 0, 0); + if (error) { + device_printf(sc->dev, "failed to set gpio memory resource: " + "%d\n", error); + return (error); + } + /* All remaining devices are SoC-only */ if (bhnd_get_attach_type(sc->dev) != BHND_ATTACH_NATIVE) return (0); @@ -835,6 +849,25 @@ chipc_alloc_resource(device_t dev, device_t child, int if ((cr = chipc_find_region(sc, start, end)) == NULL) { /* Resource requests outside our shared port regions can be * delegated to our parent. */ + rv = bus_generic_rl_alloc_resource(dev, child, type, rid, + start, end, count, flags); + return (rv); + } + + /* +* As a special case, children that map the complete ChipCommon register +* block are delegated to our parent. +* +* The rman API does not support sharing resources that are not +* identical in size; since we allocate subregions to various children, +* any children that need to map the entire register block (e.g. because +* they require access to discontiguous register ranges) must make the +* allocation through our parent, where we hold a compatible +* RF_SHAREABLE allocation. +*/ + if (cr == sc->core_region && cr->cr_addr == start && + cr->cr_end == end && cr->cr_count == count) + { rv = bus_generic_rl_alloc_resource(dev, child, type, rid, start, end, count, flags); return (rv); Added: head/sys/dev/bhnd/cores/chipc/chipc_gpio.c == --- /dev/null 00:00:00 1970 (empty,
svn commit: r326102 - in head/sys: conf dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/cores/chipc/pwrctl dev/bhnd/cores/pmu dev/bhnd/siba mips/broadcom modules/bhnd modules/bh...
Author: landonf Date: Wed Nov 22 20:27:46 2017 New Revision: 326102 URL: https://svnweb.freebsd.org/changeset/base/326102 Log: bhnd(4): extend the PMU APIs to support bwn(4) The bwn(4) driver requires a number of extensions to the bhnd(4) PMU interface to support external configuration of PLLs, LDOs, and other parameters that require chipset or PHY-specific workarounds. These changes add support for: - Writing raw voltage register values to PHY-specific LDO regulator registers (required by LP-PHY). - Enabling/disabling PHY-specific LDOs (required by LP-PHY) - Writing to arbitrary PMU chipctrl registers (required for common PHY PLL reset support). - Requesting chipset/PLL-specific spurious signal avoidance modes. - Querying clock frequency and latency. Additionally, rather than updating legacy PWRCTL support to conform to the new PMU interface: - PWRCTL API is now provided by a bhnd_pwrctl_if.m interface. - Since PWRCTL is only found in older SSB-based chipsets, translation from bhnd(4) bus APIs to corresponding PWRCTL operations is now handled entirely within the siba(4) driver. - The PWRCTL-specific host bridge clock gating APIs in bhnd_bus_if.m have been lifted out into a standalone bhnd_pwrctl_hostb_if.m interface. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12664 Added: head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.h (contents, props changed) head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_hostb_if.m (contents, props changed) head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_if.m (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmu_types.h (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_private.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhnd_types.h head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndreg.h head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/cores/chipc/chipc.c head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_private.h head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c head/sys/dev/bhnd/cores/pmu/bhnd_pmu.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c head/sys/dev/bhnd/cores/pmu/bhnd_pmu_if.m head/sys/dev/bhnd/cores/pmu/bhnd_pmu_private.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c head/sys/dev/bhnd/cores/pmu/bhnd_pmureg.h head/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_bhndb.c head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibavar.h head/sys/mips/broadcom/siba_nexus.c head/sys/modules/bhnd/Makefile head/sys/modules/bhnd/bhndb/Makefile head/sys/modules/bhnd/bhndb_pci/Makefile head/sys/modules/bhnd/siba/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Wed Nov 22 19:58:29 2017(r326101) +++ head/sys/conf/files Wed Nov 22 20:27:46 2017(r326102) @@ -1250,6 +1250,8 @@ dev/bhnd/cores/chipc/chipc_slicer.c optional bhnd cfi dev/bhnd/cores/chipc/chipc_spi.c optional bhnd spibus dev/bhnd/cores/chipc/chipc_subr.c optional bhnd dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c optional bhnd +dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_if.m optional bhnd +dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_hostb_if.m optional bhnd dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c optional bhnd dev/bhnd/cores/pci/bhnd_pci.c optional bhnd pci dev/bhnd/cores/pci/bhnd_pci_hostb.coptional bhndb bhnd pci Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Wed Nov 22 19:58:29 2017 (r326101) +++ head/sys/dev/bhnd/bcma/bcma.c Wed Nov 22 20:27:46 2017 (r326102) @@ -193,7 +193,7 @@ bcma_write_ivar(device_t dev, device_t child, int inde case BHND_IVAR_CORE_UNIT: return (EINVAL); case BHND_IVAR_PMU_INFO: - dinfo->pmu_info = (struct bhnd_core_pmu_info *) value; + dinfo->pmu_info = (void *)value; return (0); default: return (ENOENT); @@ -349,17 +349,15 @@ bcma_reset_hw(device_t dev, device_t child, uint16_t i static int bcma_suspend_hw(device_t dev, device_t child) { - struct bcma_devinfo *dinfo; - struct bhnd_core_pmu_info *pm; - struct bhnd_resource*r; - uint32_t rst; - int error; + struct bcma_devinfo
svn commit: r326080 - in head/sys: dev/bhnd dev/bhnd/bhndb dev/bhnd/cores/pci dev/bhnd/cores/pcie2 mips/broadcom
Author: landonf Date: Tue Nov 21 23:25:22 2017 New Revision: 326080 URL: https://svnweb.freebsd.org/changeset/base/326080 Log: bhnd(4): Add support for querying DMA address translation parameters BHND Wi-Fi chipsets and SoCs share a common DMA engine, operating within backplane address space. To support host DMA on Wi-Fi chipsets, the bridge core maps host address space onto the backplane; any host addresses must be translated to their corresponding backplane address. - Defines a new bhnd_get_dma_translation(9) API to support querying DMA address translation parameters from the bhnd(4) bus. - Extends bhndb(4) to provide DMA translation descriptors from a DMA address translation table defined in the host bridge-specific bhndb_hwcfg. - Defines bhndb(4) DMA address translation tables for all supported host bridge cores. - Extends mips/broadcom's bhnd_nexus driver to return an identity (no-op) DMA translation descriptor; no translation is required when addressing the SoC backplane. Approved by: adrian (mentor) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12582 Modified: head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb.h head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_pci_hwdata.c head/sys/dev/bhnd/bhndb/bhndb_subr.c head/sys/dev/bhnd/bhndb/bhndbvar.h head/sys/dev/bhnd/cores/pci/bhnd_pcireg.h head/sys/dev/bhnd/cores/pcie2/bhnd_pcie2_reg.h head/sys/mips/broadcom/bhnd_nexus.c Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hTue Nov 21 23:15:20 2017(r326079) +++ head/sys/dev/bhnd/bhnd.hTue Nov 21 23:25:22 2017(r326080) @@ -220,6 +220,94 @@ struct bhnd_core_info { }; /** + * bhnd(4) DMA address widths. + */ +typedef enum { + BHND_DMA_ADDR_30BIT = 30, /**< 30-bit DMA */ + BHND_DMA_ADDR_32BIT = 32, /**< 32-bit DMA */ + BHND_DMA_ADDR_64BIT = 64, /**< 64-bit DMA */ +} bhnd_dma_addrwidth; + +/** + * Convert an address width (in bits) to its corresponding mask. + */ +#defineBHND_DMA_ADDR_BITMASK(_width) \ + ((_width >= 64) ? ~0ULL : \ +(_width == 0) ? 0x0 : \ +((1ULL << (_width)) - 1)) \ + +/** + * bhnd(4) DMA address translation descriptor. + */ +struct bhnd_dma_translation { + /** +* Host-to-device physical address translation. +* +* This may be added to the host physical address to produce a device +* DMA address. +*/ + bhnd_addr_t base_addr; + + /** +* Device-addressable address mask. +* +* This defines the device's DMA address range, excluding any bits +* reserved for mapping the address to the base_addr. +*/ + bhnd_addr_t addr_mask; + + /** +* Device-addressable extended address mask. +* +* If a per-core bhnd(4) DMA engine supports the 'addrext' control +* field, it can be used to provide address bits excluded by addr_mask. +* +* Support for DMA extended address changes – including coordination +* with the core providing DMA translation – is handled transparently by +* the DMA engine. For example, on PCI(e) Wi-Fi chipsets, the Wi-Fi +* core DMA engine will (in effect) update the PCI core's DMA +* sbtopcitranslation base address to map the full address prior to +* performing a DMA transaction. +*/ + bhnd_addr_t addrext_mask; + + /** +* Translation flags (see bhnd_dma_translation_flags) +*/ + uint32_tflags; +}; + +#defineBHND_DMA_TRANSLATION_TABLE_END { 0, 0, 0, 0 } + +#defineBHND_DMA_IS_TRANSLATION_TABLE_END(_dt) \ + ((_dt)->base_addr == 0 && (_dt)->addr_mask == 0 && \ +(_dt)->addrext_mask == 0 && (_dt)->flags == 0) + +/** + * bhnd(4) DMA address translation flags. + */ +enum bhnd_dma_translation_flags { + /** +* The translation remaps the device's physical address space. +* +* This is used in conjunction with BHND_DMA_TRANSLATION_BYTESWAPPED to +* define a DMA translation that provides byteswapped access to +* physical memory on big-endian MIPS SoCs. +*/ + BHND_DMA_TRANSLATION_PHYSMAP= (1<<0), + + /** +* Provides a byte-swapped mapping; write requests will be byte-swapped +* before being written to memory, and read requests will be +* byte-swapped before being returned. +* +* This is primarily used to perform efficient byte swapping of DMA +* data on embedded MIPS SoCs executing in big-endian mode. +*/ +
svn commit: r326079 - in head/sys: dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/cores/pci dev/bhnd/cores/usb dev/bhnd/siba mips/broadcom mips/include mips/mips
Author: landonf Date: Tue Nov 21 23:15:20 2017 New Revision: 326079 URL: https://svnweb.freebsd.org/changeset/base/326079 Log: bhnd(4): implement MIPS and PCI(e) interrupt support On BHND MIPS SoCs, this replaces the use of hard-coded MIPS IRQ#s in the common bhnd(4) core drivers; we now register an INTRNG child PIC that handles routing of backplane interrupt vectors via the MIPS core. On BHND PCI devices, backplane interrupt vectors are now routed to the PCI/PCIe host bridge core when bus_setup_intr() is called, where they are dispatched by the PCI core via a host interrupt (e.g. INTx/MSI). The bhndb(4) bridge driver tracks registered interrupt handlers for the bridged bhnd(4) devices and manages backplane interrupt routing, while delegating actual bus interrupt setup/teardown to the parent bus on behalf of the bridged cores. Approved by: adrian (mentor, implicit) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12518 Added: head/sys/mips/broadcom/bcm_mips.c (contents, props changed) head/sys/mips/broadcom/bcm_mipsvar.h (contents, props changed) Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_subr.c head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_ids.h head/sys/dev/bhnd/bhnd_match.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_if.m head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_pcireg.h head/sys/dev/bhnd/bhndb/bhndb_pcivar.h head/sys/dev/bhnd/bhndb/bhndb_private.h head/sys/dev/bhnd/bhndb/bhndb_subr.c head/sys/dev/bhnd/bhndb/bhndbvar.h head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/cores/chipc/chipc.c head/sys/dev/bhnd/cores/chipc/chipc_private.h head/sys/dev/bhnd/cores/chipc/chipc_subr.c head/sys/dev/bhnd/cores/chipc/chipcvar.h head/sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c head/sys/dev/bhnd/cores/usb/bhnd_usb.c head/sys/dev/bhnd/cores/usb/bhnd_usbvar.h head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_bhndb.c head/sys/dev/bhnd/siba/siba_erom.c head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibareg.h head/sys/dev/bhnd/siba/sibavar.h head/sys/mips/broadcom/bcm_bmips.c head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_machdep.h head/sys/mips/broadcom/bcm_mips74k.c head/sys/mips/broadcom/bcm_mips74kreg.h head/sys/mips/broadcom/bcma_nexus.c head/sys/mips/broadcom/bhnd_nexus.c head/sys/mips/broadcom/files.broadcom head/sys/mips/broadcom/siba_nexus.c head/sys/mips/include/intr.h head/sys/mips/mips/mips_pic.c Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Tue Nov 21 22:06:49 2017 (r326078) +++ head/sys/dev/bhnd/bcma/bcma.c Tue Nov 21 23:15:20 2017 (r326079) @@ -1,7 +1,11 @@ /*- - * Copyright (c) 2015 Landon Fuller+ * Copyright (c) 2015-2016 Landon Fuller + * Copyright (c) 2017 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Landon Fuller + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -124,7 +128,7 @@ bcma_child_deleted(device_t dev, device_t child) /* Free bcma device info */ if ((dinfo = device_get_ivars(child)) != NULL) - bcma_free_dinfo(dev, dinfo); + bcma_free_dinfo(dev, child, dinfo); device_set_ivars(child, NULL); } @@ -613,66 +617,46 @@ bcma_get_region_addr(device_t dev, device_t child, bhn /** * Default bcma(4) bus driver implementation of BHND_BUS_GET_INTR_COUNT(). - * - * This implementation consults @p child's agent register block, - * returning the number of interrupt output lines routed to @p child. */ -int +u_int bcma_get_intr_count(device_t dev, device_t child) { - struct bcma_devinfo *dinfo; - uint32_t dmpcfg, oobw; + struct bcma_devinfo *dinfo; - dinfo = device_get_ivars(child); + /* delegate non-bus-attached devices to our parent */ + if (device_get_parent(child) != dev) + return (BHND_BUS_GET_INTR_COUNT(device_get_parent(dev), child)); - /* Agent block must be mapped */ - if (dinfo->res_agent == NULL) - return (0); - - /* Agent must support OOB */ - dmpcfg = bhnd_bus_read_4(dinfo->res_agent, BCMA_DMP_CONFIG); - if (!BCMA_DMP_GET_FLAG(dmpcfg, BCMA_DMP_CFG_OOB)) - return (0); - - /* Return OOB width as interrupt count */ - oobw = bhnd_bus_read_4(dinfo->res_agent, -
svn commit: r326043 - in head/sys/mips: include mips
Author: landonf Date: Tue Nov 21 01:54:48 2017 New Revision: 326043 URL: https://svnweb.freebsd.org/changeset/base/326043 Log: Preemptively map MIPS INTRNG interrupts on non-FDT MIPS targets This replaces a partial workaround introduced in r305527 that was incompatible with nested INTRNG interrupt controllers if not also using FDT. On non-FDT MIPS INTRNG targets, we now preemptively produce a set of fixed mappings for the MIPS IRQ range during nexus attach. On FDT targets, OFW_BUS_MAP_INTR() remains responsible for mapping the MIPS IRQs. Approved by: adrian (mentor) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12385 Modified: head/sys/mips/include/intr.h head/sys/mips/mips/mips_pic.c head/sys/mips/mips/nexus.c Modified: head/sys/mips/include/intr.h == --- head/sys/mips/include/intr.hTue Nov 21 01:18:58 2017 (r326042) +++ head/sys/mips/include/intr.hTue Nov 21 01:54:48 2017 (r326043) @@ -55,16 +55,23 @@ #defineNIRQMIPS_NIRQ #endif +#ifndef FDT +#defineMIPS_PIC_XREF 1 /**< unique xref */ +#endif + #define INTR_IRQ_NSPC_SWI 4 +/* MIPS32 PIC APIs */ +int mips_pic_map_fixed_intrs(void); +int mips_pic_activate_intr(device_t child, struct resource *r); +int mips_pic_deactivate_intr(device_t child, struct resource *r); + /* MIPS compatibility for legacy mips code */ void cpu_init_interrupts(void); void cpu_establish_hardintr(const char *, driver_filter_t *, driver_intr_t *, void *, int, int, void **); void cpu_establish_softintr(const char *, driver_filter_t *, void (*)(void*), void *, int, int, void **); -int cpu_create_intr_map(int); -struct resource *cpu_get_irq_resource(int); /* MIPS interrupt C entry point */ void cpu_intr(struct trapframe *); Modified: head/sys/mips/mips/mips_pic.c == --- head/sys/mips/mips/mips_pic.c Tue Nov 21 01:18:58 2017 (r326042) +++ head/sys/mips/mips/mips_pic.c Tue Nov 21 01:54:48 2017 (r326043) @@ -2,8 +2,12 @@ * Copyright (c) 2015 Alexander Kabaev * Copyright (c) 2006 Oleksandr Tymoshenko * Copyright (c) 2002-2004 Juli Mallett+ * Copyright (c) 2017 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Landon Fuller + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -44,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -69,24 +74,56 @@ __FBSDID("$FreeBSD$"); #define NSOFT_IRQS 2 #define NREAL_IRQS (NHARD_IRQS + NSOFT_IRQS) -static int mips_pic_intr(void *); +struct mips_pic_softc; +static int mips_pic_intr(void *); +static struct mips_pic_intr*mips_pic_find_intr(struct resource *r); +static int mips_pic_map_fixed_intr(u_int irq, +struct mips_pic_intr **mapping); +static void cpu_establish_intr(struct mips_pic_softc *sc, +const char *name, driver_filter_t *filt, +void (*handler)(void*), void *arg, int irq, +int flags, void **cookiep); + +#defineINTR_MAP_DATA_MIPS INTR_MAP_DATA_PLAT_1 + struct intr_map_data_mips_pic { struct intr_map_datahdr; u_int irq; }; +/** + * MIPS interrupt state; available prior to MIPS PIC device attachment. + */ +static struct mips_pic_intr { + u_intmips_irq; /**< MIPS IRQ# 0-7 */ + u_intintr_irq; /**< INTRNG IRQ#, or INTR_IRQ_INVALID if unmapped */ + u_intconsumers; /**< INTRNG activation refcount */ + struct resource *res; /**< resource shared by all interrupt handlers registered via +cpu_establish_hardintr() or cpu_establish_softintr(); NULL +if no interrupt handlers are yet registered. */ +} mips_pic_intrs[] = { + { 0, INTR_IRQ_INVALID, 0, NULL }, + { 1, INTR_IRQ_INVALID, 0, NULL }, + { 2, INTR_IRQ_INVALID, 0, NULL }, + { 3, INTR_IRQ_INVALID, 0, NULL }, + { 4, INTR_IRQ_INVALID, 0, NULL }, + { 5, INTR_IRQ_INVALID, 0, NULL }, + { 6, INTR_IRQ_INVALID, 0, NULL }, + { 7, INTR_IRQ_INVALID, 0, NULL }, +}; + +struct mtx mips_pic_mtx; +MTX_SYSINIT(mips_pic_mtx, _pic_mtx, "mips intr controller mutex", MTX_DEF); + struct mips_pic_irqsrc {
svn commit: r324071 - in head/sys: dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/siba mips/broadcom modules/bhnd/bhndb_pci
Author: landonf Date: Wed Sep 27 19:48:34 2017 New Revision: 324071 URL: https://svnweb.freebsd.org/changeset/base/324071 Log: bhnd: Add support for supplying bus I/O callbacks when initializing an EROM parser. This allows us to use the EROM parser API in cases where the standard bus space I/O APIs are unsuitable. In particular, this will allow us to parse the device enumeration table directly from bhndb(4) drivers, prior to full attach and configuration of the bridge. Approved by: adrian (mentor) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12510 Added: head/sys/dev/bhnd/bhnd_eromvar.h (contents, props changed) Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/bhnd_erom.c head/sys/dev/bhnd/bhnd_erom.h head/sys/dev/bhnd/bhnd_erom_if.m head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_pcivar.h head/sys/dev/bhnd/bhndb/bhndb_private.h head/sys/dev/bhnd/bhndb/bhndb_subr.c head/sys/dev/bhnd/bhndb/bhndbvar.h head/sys/dev/bhnd/bhndreg.h head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_erom.c head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_machdep.h head/sys/modules/bhnd/bhndb_pci/Makefile Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Wed Sep 27 19:44:23 2017 (r324070) +++ head/sys/dev/bhnd/bcma/bcma.c Wed Sep 27 19:48:34 2017 (r324071) @@ -686,6 +686,7 @@ bcma_add_children(device_t bus) { bhnd_erom_t *erom; struct bcma_erom*bcma_erom; + struct bhnd_erom_io *eio; const struct bhnd_chipid*cid; struct bcma_corecfg *corecfg; struct bcma_devinfo *dinfo; @@ -696,9 +697,12 @@ bcma_add_children(device_t bus) corecfg = NULL; /* Allocate our EROM parser */ - erom = bhnd_erom_alloc(_erom_parser, cid, bus, BCMA_EROM_RID); - if (erom == NULL) + eio = bhnd_erom_iores_new(bus, BCMA_EROM_RID); + erom = bhnd_erom_alloc(_erom_parser, cid, eio); + if (erom == NULL) { + bhnd_erom_io_fini(eio); return (ENODEV); + } /* Add all cores. */ bcma_erom = (struct bcma_erom *)erom; Modified: head/sys/dev/bhnd/bcma/bcma_erom.c == --- head/sys/dev/bhnd/bcma/bcma_erom.c Wed Sep 27 19:44:23 2017 (r324070) +++ head/sys/dev/bhnd/bcma/bcma_erom.c Wed Sep 27 19:48:34 2017 (r324071) @@ -1,7 +1,11 @@ /*- - * Copyright (c) 2015 Landon Fuller+ * Copyright (c) 2015-2017 Landon Fuller + * Copyright (c) 2017 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Landon Fuller + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -58,13 +62,8 @@ __FBSDID("$FreeBSD$"); * marker. */ -struct bcma_erom_io; - static const char *bcma_erom_entry_type_name (uint8_t entry); -static uint32_t bcma_eio_read4(struct bcma_erom_io *io, -bus_size_t offset); - static int bcma_erom_read32(struct bcma_erom *erom, uint32_t *entry); static int bcma_erom_skip32(struct bcma_erom *erom); @@ -105,37 +104,18 @@ static voidbcma_erom_to_core_info(const struct bcma struct bhnd_core_info *info); /** - * BCMA EROM generic I/O context - */ -struct bcma_erom_io { - struct bhnd_resource*res; /**< memory resource, or NULL if initialized -with bus space tag and handle */ - int rid; /**< memory resource id, or -1 */ - - bus_space_tag_t bst; /**< bus space tag, if any */ - bus_space_handle_t bsh; /**< bus space handle, if any */ - - bus_size_t start; /**< base read offset */ -}; - -/** * BCMA EROM per-instance state. */ struct bcma_erom { - struct bhnd_eromobj; - device_tdev;/**< parent device, or NULL if none. */ - struct bcma_erom_io io; /**< I/O context */ - bus_size_t offset; /**< current read offset */ + struct bhnd_erom obj; + device_t dev; /**< parent device, or NULL if none. */ + struct bhnd_erom_io *eio; /**< bus I/O callbacks */ + bhnd_size_t offset;
svn commit: r324070 - in head/sys: dev/bhnd dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/cores/chipc/pwrctl dev/bhnd/cores/pci dev/bhnd/cores/pmu dev/bhnd/nvram dev/bhnd/siba mips/broadcom
Author: landonf Date: Wed Sep 27 19:44:23 2017 New Revision: 324070 URL: https://svnweb.freebsd.org/changeset/base/324070 Log: bhnd: Implement bhnd(4) platform device registration. Add bhnd(4) API for explicitly registering BHND platform devices (ChipCommon, PMU, NVRAM, etc) with the bus, rather than walking the newbus hierarchy to discover platform devices. These devices are now also refcounted; attempting to deregister an actively used platform device will return EBUSY. This resolves a lock ordering incompatibility with bwn(4)'s firmware loading threads; previously it was necessary to acquire Giant to protect newbus access when locating and querying the NVRAM device. Approved by: adrian (mentor) Sponsored by: The FreeBSD Foundation Differential Revision:https://reviews.freebsd.org/D12392 Added: head/sys/dev/bhnd/bhnd_private.h (contents, props changed) Modified: head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhnd_types.h head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndbvar.h head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/cores/chipc/chipc.c head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c head/sys/dev/bhnd/cores/pci/bhnd_pci_hostb.c head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c head/sys/dev/bhnd/nvram/bhnd_sprom.c head/sys/dev/bhnd/siba/siba_bhndb.c head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_machdep.h head/sys/mips/broadcom/bcm_nvram_cfe.c head/sys/mips/broadcom/bhnd_nexus.c Modified: head/sys/dev/bhnd/bhnd.c == --- head/sys/dev/bhnd/bhnd.cWed Sep 27 19:22:10 2017(r324069) +++ head/sys/dev/bhnd/bhnd.cWed Sep 27 19:44:23 2017(r324070) @@ -1,7 +1,11 @@ /*- * Copyright (c) 2015-2016 Landon Fuller+ * Copyright (c) 2017 The FreeBSD Foundation * All rights reserved. * + * Portions of this software were developed by Landon Fuller + * under sponsorship from the FreeBSD Foundation. + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -69,12 +73,10 @@ __FBSDID("$FreeBSD$"); #include "bhnd.h" #include "bhndvar.h" +#include "bhnd_private.h" + MALLOC_DEFINE(M_BHND, "bhnd", "bhnd bus data structures"); -/* Bus pass at which all bus-required children must be available, and - * attachment may be finalized. */ -#defineBHND_FINISH_ATTACH_PASS BUS_PASS_DEFAULT - /** * bhnd_generic_probe_nomatch() reporting configuration. */ @@ -92,23 +94,8 @@ static const struct bhnd_nomatch { { BHND_MFGID_INVALID, BHND_COREID_INVALID,false } }; - static int bhnd_delete_children(struct bhnd_softc *sc); -static int bhnd_finish_attach(struct bhnd_softc *sc); - -static device_t bhnd_find_chipc(struct bhnd_softc *sc); -static struct chipc_caps *bhnd_find_chipc_caps(struct bhnd_softc *sc); -static device_t bhnd_find_platform_dev(struct bhnd_softc *sc, -const char *classname); -static device_t bhnd_find_pmu(struct bhnd_softc *sc); -static device_t bhnd_find_nvram(struct bhnd_softc *sc); - -static int compare_ascending_probe_order(const void *lhs, -const void *rhs); -static int compare_descending_probe_order(const void *lhs, -const void *rhs); - /** * Default bhnd(4) bus driver implementation of DEVICE_ATTACH(). * @@ -119,8 +106,6 @@ int bhnd_generic_attach(device_t dev) { struct bhnd_softc *sc; - device_t*devs; - int ndevs; int error; if (device_is_attached(dev)) @@ -129,29 +114,13 @@ bhnd_generic_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; - if ((error = device_get_children(dev, , ))) - return (error); - /* Probe and attach all children */ - qsort(devs, ndevs, sizeof(*devs), compare_ascending_probe_order); - for (int i = 0; i < ndevs; i++) { - device_t child = devs[i]; - device_probe_and_attach(child); + if ((error = bhnd_bus_probe_children(dev))) { + bhnd_delete_children(sc); + return (error); } - /* Try to finalize attachment */ - if (bus_current_pass >= BHND_FINISH_ATTACH_PASS) { - if ((error = bhnd_finish_attach(sc))) - goto cleanup; - } - -cleanup: - free(devs, M_TEMP); - - if (error) -
svn commit: r323621 - head/sys/mips/include
Author: landonf Date: Fri Sep 15 19:56:21 2017 New Revision: 323621 URL: https://svnweb.freebsd.org/changeset/base/323621 Log: Add MIPS32/64 Rev2 CP0 intctl register definitions. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D12300 Modified: head/sys/mips/include/cpufunc.h head/sys/mips/include/cpuregs.h Modified: head/sys/mips/include/cpufunc.h == --- head/sys/mips/include/cpufunc.h Fri Sep 15 19:48:48 2017 (r323620) +++ head/sys/mips/include/cpufunc.h Fri Sep 15 19:56:21 2017 (r323621) @@ -279,6 +279,15 @@ MIPS_RW32_COP0(entrylo1, MIPS_COP_0_TLB_LO1); MIPS_RW32_COP0(prid, MIPS_COP_0_PRID); /* XXX 64-bit? */ MIPS_RW32_COP0_SEL(ebase, MIPS_COP_0_PRID, 1); + +#if defined(CPU_MIPS24K) || defined(CPU_MIPS34K) ||\ +defined(CPU_MIPS74K) || defined(CPU_MIPS1004K) || \ +defined(CPU_MIPS1074K) || defined(CPU_INTERAPTIV) || \ +defined(CPU_PROAPTIV) +/* MIPS32/64 r2 intctl */ +MIPS_RW32_COP0_SEL(intctl, MIPS_COP_0_INTCTL, 1); +#endif + #ifdef CPU_XBURST MIPS_RW32_COP0_SEL(xburst_mbox0, MIPS_COP_0_XBURST_MBOX, 0); MIPS_RW32_COP0_SEL(xburst_mbox1, MIPS_COP_0_XBURST_MBOX, 1); Modified: head/sys/mips/include/cpuregs.h == --- head/sys/mips/include/cpuregs.h Fri Sep 15 19:48:48 2017 (r323620) +++ head/sys/mips/include/cpuregs.h Fri Sep 15 19:56:21 2017 (r323621) @@ -468,6 +468,7 @@ * 10 MIPS_COP_0_TLB_HI 3636 TLB entry high. * 11 MIPS_COP_0_COMPARE .333 Compare (against Count). * 12 MIPS_COP_0_STATUS Status register. + * 12/1MIPS_COP_0_INTCTL ..33 Interrupt setup (MIPS32/64 r2). * 13 MIPS_COP_0_CAUSE Exception cause register. * 14 MIPS_COP_0_EXC_PC 3636 Exception PC. * 15 MIPS_COP_0_PRID Processor revision identifier. @@ -548,6 +549,7 @@ /* MIPS32/64 */ #defineMIPS_COP_0_USERLOCAL_(4)/* sel 2 is userlevel register */ #defineMIPS_COP_0_HWRENA _(7) +#defineMIPS_COP_0_INTCTL _(12) #defineMIPS_COP_0_DEBUG_(23) #defineMIPS_COP_0_DEPC _(24) #defineMIPS_COP_0_PERFCNT _(25) @@ -560,6 +562,16 @@ #define MIPS_MMU_TLB 0x01/* Standard TLB */ #define MIPS_MMU_BAT 0x02/* Standard BAT */ #define MIPS_MMU_FIXED 0x03/* Standard fixed mapping */ + +/* + * IntCtl Register Fields + */ +#defineMIPS_INTCTL_IPTI_MASK 0xE000 /* bits 31..29 timer intr # */ +#defineMIPS_INTCTL_IPTI_SHIFT 29 +#defineMIPS_INTCTL_IPPCI_MASK 0x1C00 /* bits 26..29 perf counter intr # */ +#defineMIPS_INTCTL_IPPCI_SHIFT 26 +#defineMIPS_INTCTL_VS_MASK 0x01F0 /* bits 5..9 vector spacing */ +#defineMIPS_INTCTL_VS_SHIFT4 /* * Config Register Fields ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r323251 - head/sys/dev/bhnd/cores/usb
Author: landonf Date: Wed Sep 6 23:43:20 2017 New Revision: 323251 URL: https://svnweb.freebsd.org/changeset/base/323251 Log: bhnd: Remove unsupported USB core IDs from the bhnd_usb device table. This resolves a SoC reset triggered by attempting to attach to the BCM5365's USB 1.1 controller. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/cores/usb/bhnd_usb.c Modified: head/sys/dev/bhnd/cores/usb/bhnd_usb.c == --- head/sys/dev/bhnd/cores/usb/bhnd_usb.c Wed Sep 6 23:12:34 2017 (r323250) +++ head/sys/dev/bhnd/cores/usb/bhnd_usb.c Wed Sep 6 23:43:20 2017 (r323251) @@ -51,11 +51,7 @@ __FBSDID("$FreeBSD$"); /** Variables / static const struct bhnd_device bhnd_usb_devs[] = { - BHND_DEVICE(BCM,USB,"USB1.1 Host/Device core", NULL), BHND_DEVICE(BCM,USB20H, "USB2.0 Host core", NULL), - BHND_DEVICE(BCM,USB20D, "USB2.0 Device core", NULL), - BHND_DEVICE(BCM,USB11H, "USB1.1 Host core", NULL), - BHND_DEVICE(BCM,USB11D, "USB1.1 Device core", NULL), BHND_DEVICE_END }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r318760 - head/sys/dev/bhnd/nvram
Author: landonf Date: Tue May 23 22:30:15 2017 New Revision: 318760 URL: https://svnweb.freebsd.org/changeset/base/318760 Log: bhnd(4): Fix a SPROM identification regression introduced in r315866 In r315866, we introduced a direct read of the 8-bit sromrev field from the memory mapped SPROM/OTP device. On OTP devices that require 16-bit access alignment, this read fails, preventing identification of the SPROM layout. So, let's perform an aligned read of the combined 16-bit sromrev/crc field instead. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_sprom.c Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Tue May 23 22:11:45 2017(r318759) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Tue May 23 22:30:15 2017(r318760) @@ -184,6 +184,7 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram u_char buf[512]; size_t nread; uint16_t magic; + uint8_t srevcrc[2]; uint8_t srev; bool crc_valid; bool have_magic; @@ -224,12 +225,15 @@ bhnd_nvram_sprom_ident(struct bhnd_nvram nbytes += nr; } - /* Read SPROM revision */ - error = bhnd_nvram_io_read(io, layout->srev_offset, , - sizeof(srev)); + /* Read 8-bit SPROM revision, maintaining 16-bit size alignment +* required by some OTP/SPROM chipsets. */ + error = bhnd_nvram_io_read(io, layout->srev_offset, , + sizeof(srevcrc)); if (error) return (error); + srev = srevcrc[0]; + /* Early sromrev 1 devices (specifically some BCM440x enet * cards) are reported to have been incorrectly programmed * with a revision of 0x10. */ Modified: head/sys/dev/bhnd/nvram/bhnd_sprom.c == --- head/sys/dev/bhnd/nvram/bhnd_sprom.cTue May 23 22:11:45 2017 (r318759) +++ head/sys/dev/bhnd/nvram/bhnd_sprom.cTue May 23 22:30:15 2017 (r318760) @@ -120,9 +120,9 @@ bhnd_sprom_attach(device_t dev, bus_size sprom_size = r_size - offset; - /* Allocate an I/O context for the SPROM parser. SPROM reads do not -* appear to require any specific alignment. */ - io = bhnd_nvram_iores_new(r, offset, sprom_size, 1); + /* Allocate an I/O context for the SPROM parser. All SPROM reads +* must be 16-bit aligned */ + io = bhnd_nvram_iores_new(r, offset, sprom_size, sizeof(uint16_t)); if (io == NULL) { error = ENXIO; goto failed; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r317380 - in head/sys: dev/bhnd dev/bhnd/bcma dev/bhnd/siba mips/broadcom
Author: landonf Date: Mon Apr 24 18:35:25 2017 New Revision: 317380 URL: https://svnweb.freebsd.org/changeset/base/317380 Log: Add support for dumping bcma/siba EROM tables to the console via a new BHND_EROM_DUMP() method. Dump the EROM tables to the coneole on mips/broadcom devices if bootverbose is enabled; this functionality is primarily useful when debugging SoC EROM parsing and device matching issues during early boot. Reviewed by: mizhka Approved by: adrian (mentor) Sponsored by: Plausible Labs Differential Revision:https://reviews.freebsd.org/D10122 Modified: head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/bhnd_erom.h head/sys/dev/bhnd/bhnd_erom_if.m head/sys/dev/bhnd/siba/siba_erom.c head/sys/mips/broadcom/bcm_machdep.c Modified: head/sys/dev/bhnd/bcma/bcma_erom.c == --- head/sys/dev/bhnd/bcma/bcma_erom.c Mon Apr 24 18:09:52 2017 (r317379) +++ head/sys/dev/bhnd/bcma/bcma_erom.c Mon Apr 24 18:35:25 2017 (r317380) @@ -1367,6 +1367,157 @@ failed: return error; } +static int +bcma_erom_dump(bhnd_erom_t *erom) +{ + struct bcma_erom*sc; + uint32_tentry; + int error; + + sc = (struct bcma_erom *)erom; + + bcma_erom_reset(sc); + + while (!(error = bcma_erom_read32(sc, ))) { + /* Handle EOF */ + if (entry == BCMA_EROM_TABLE_EOF) { + EROM_LOG(sc, "EOF\n"); + return (0); + } + + /* Invalid entry */ + if (!BCMA_EROM_GET_ATTR(entry, ENTRY_ISVALID)) { + EROM_LOG(sc, "invalid EROM entry %#x\n", entry); + return (EINVAL); + } + + switch (BCMA_EROM_GET_ATTR(entry, ENTRY_TYPE)) { + case BCMA_EROM_ENTRY_TYPE_CORE: { + /* CoreDescA */ + EROM_LOG(sc, "coreA (0x%x)\n", entry); + EROM_LOG(sc, "\tdesigner:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREA_DESIGNER)); + EROM_LOG(sc, "\tid:\t\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREA_ID)); + EROM_LOG(sc, "\tclass:\t\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREA_CLASS)); + + /* CoreDescB */ + if ((error = bcma_erom_read32(sc, ))) { + EROM_LOG(sc, "error reading CoreDescB: %d\n", + error); + return (error); + } + + if (!BCMA_EROM_ENTRY_IS(entry, CORE)) { + EROM_LOG(sc, "invalid core descriptor; found " + "unexpected entry %#x (type=%s)\n", + entry, bcma_erom_entry_type_name(entry)); + return (EINVAL); + } + + EROM_LOG(sc, "coreB (0x%x)\n", entry); + EROM_LOG(sc, "\trev:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREB_REV)); + EROM_LOG(sc, "\tnummp:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREB_NUM_MP)); + EROM_LOG(sc, "\tnumdp:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREB_NUM_DP)); + EROM_LOG(sc, "\tnumwmp:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREB_NUM_WMP)); + EROM_LOG(sc, "\tnumwsp:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, COREB_NUM_WMP)); + + break; + } + case BCMA_EROM_ENTRY_TYPE_MPORT: + EROM_LOG(sc, "\tmport 0x%x\n", entry); + EROM_LOG(sc, "\t\tport:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, MPORT_NUM)); + EROM_LOG(sc, "\t\tid:\t\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, MPORT_ID)); + break; + + case BCMA_EROM_ENTRY_TYPE_REGION: { + booladdr64; + uint8_t size_type; + + addr64 = (BCMA_EROM_GET_ATTR(entry, REGION_64BIT) != 0); + size_type = BCMA_EROM_GET_ATTR(entry, REGION_SIZE); + + EROM_LOG(sc, "\tregion 0x%x:\n", entry); + EROM_LOG(sc, "\t\t%s:\t0x%x\n", + addr64 ? "baselo" : "base", + BCMA_EROM_GET_ATTR(entry, REGION_BASE)); + EROM_LOG(sc, "\t\tport:\t0x%x\n", + BCMA_EROM_GET_ATTR(entry, REGION_PORT)); + EROM_LOG(sc, "\t\ttype:\t0x%x\n", +
svn commit: r317379 - head/sys/dev/bhnd/nvram
Author: landonf Date: Mon Apr 24 18:09:52 2017 New Revision: 317379 URL: https://svnweb.freebsd.org/changeset/base/317379 Log: Drop unused/unnecessary return statement. Reported by: Coverity CID: 1373118 Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Apr 24 16:52:26 2017(r317378) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Apr 24 18:09:52 2017(r317379) @@ -1256,7 +1256,6 @@ bhnd_nvram_sprom_read_var(struct bhnd_sp /* Provide value wrapper */ return (bhnd_nvram_val_init(val, var->fmt, inp, ilen, var->type, BHND_NVRAM_VAL_BORROW_DATA)); - return (error); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r315873 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Thu Mar 23 22:14:08 2017 New Revision: 315873 URL: https://svnweb.freebsd.org/changeset/base/315873 Log: Add Northstar/BCM4706 core ID for ChipCommon. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/cores/chipc/chipc.c Modified: head/sys/dev/bhnd/cores/chipc/chipc.c == --- head/sys/dev/bhnd/cores/chipc/chipc.c Thu Mar 23 22:12:14 2017 (r315872) +++ head/sys/dev/bhnd/cores/chipc/chipc.c Thu Mar 23 22:14:08 2017 (r315873) @@ -69,6 +69,7 @@ static struct bhnd_device_quirk chipc_qu /* Supported device identifiers */ static const struct bhnd_device chipc_devices[] = { BHND_DEVICE(BCM, CC, NULL, chipc_quirks), + BHND_DEVICE(BCM, 4706_CC, NULL, chipc_quirks), BHND_DEVICE_END }; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r315872 - head/sys/dev/bhnd/bcma
Author: landonf Date: Thu Mar 23 22:12:14 2017 New Revision: 315872 URL: https://svnweb.freebsd.org/changeset/base/315872 Log: Add a workaround for the BCM4706's dangling core region EROM entries. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bcma/bcma_erom.c Modified: head/sys/dev/bhnd/bcma/bcma_erom.c == --- head/sys/dev/bhnd/bcma/bcma_erom.c Thu Mar 23 22:06:06 2017 (r315871) +++ head/sys/dev/bhnd/bcma/bcma_erom.c Thu Mar 23 22:12:14 2017 (r315872) @@ -1344,6 +1344,19 @@ bcma_erom_next_corecfg(struct bcma_erom goto failed; } + /* +* Seek to the next core entry (if any), skipping any dangling/invalid +* region entries. +* +* On the BCM4706, the EROM entry for the memory controller core +* (0x4bf/0x52E) contains a dangling/unused slave wrapper port region +* descriptor. +*/ + if ((error = bcma_erom_seek_next(erom, BCMA_EROM_ENTRY_TYPE_CORE))) { + if (error != ENOENT) + goto failed; + } + *result = cfg; return (0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r315866 - in head/sys: dev/bhnd/nvram mips/broadcom
Author: landonf Date: Thu Mar 23 19:29:12 2017 New Revision: 315866 URL: https://svnweb.freebsd.org/changeset/base/315866 Log: [mips/broadcom]: Early boot NVRAM support Add support for early boot access to NVRAM variables, using a new bhnd_nvram_data_getvar_direct() API to support zero-allocation direct reading of NVRAM variables from a bhnd_nvram_io instance backed by the CFE NVRAM device. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D9913 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_spromvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_sprom.c head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_machdep.h head/sys/mips/broadcom/bcm_nvram_cfe.c head/sys/mips/broadcom/bcm_nvram_cfevar.h Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Thu Mar 23 17:11:34 2017 (r315865) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Thu Mar 23 19:29:12 2017 (r315866) @@ -228,6 +228,41 @@ bhnd_nvram_data_probe_classes(struct bhn } /** + * Read a variable directly from @p io and decode as @p type. + * + * This may be used to perform reading of NVRAM variables during the very + * early boot process, prior to the availability of the kernel allocator. + * + * @param cls An NVRAM class capable of parsing @p io. + * @param io NVRAM data to be parsed. + * @param nameThe raw name of the variable to be fetched, + * including any device path (/pci/1/1/varname) or + * alias prefix (0:varname). + * @param[out] buf On success, the requested value will be written + * to this buffer. This argment may be NULL if + * the value is not desired. + * @param[in,out] len The capacity of @p buf. On success, will be set + * to the actual size of the requested value. + * @param typeThe data type to be written to @p buf. + * + * @retval 0 success + * @retval ENOMEM If @p buf is non-NULL and a buffer of @p len is too + * small to hold the requested value. + * @retval ENOENT If @p name is not found in @p io. + * @retval EFTYPE If the variable data cannot be coerced to @p type. + * @retval ERANGE If value coercion would overflow @p type. + * @retval non-zeroIf parsing @p io otherwise fails, a regular unix error + * code will be returned. + */ +int +bhnd_nvram_data_getvar_direct(bhnd_nvram_data_class *cls, +struct bhnd_nvram_io *io, const char *name, void *buf, size_t *len, +bhnd_nvram_type type) +{ + return (cls->op_getvar_direct(io, name, buf, len, type)); +} + +/** * Allocate and initialize a new instance of data class @p cls, copying and * parsing NVRAM data from @p io. * Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Thu Mar 23 17:11:34 2017 (r315865) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Thu Mar 23 19:29:12 2017 (r315866) @@ -105,6 +105,11 @@ int bhnd_nvram_data_probe_classes( bhnd_nvram_data_class *classes[], size_t num_classes); +int bhnd_nvram_data_getvar_direct( +bhnd_nvram_data_class *cls, +struct bhnd_nvram_io *io, const char *name, +void *buf, size_t *len, bhnd_nvram_type type); + int bhnd_nvram_data_new(bhnd_nvram_data_class *cls, struct bhnd_nvram_data **nv, struct bhnd_nvram_io *io); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Thu Mar 23 17:11:34 2017(r315865) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Thu Mar 23 19:29:12 2017(r315866) @@ -144,9 +144,229 @@ bhnd_nvram_bcm_probe(struct bhnd_nvram_i if (le32toh(hdr.magic) != BCM_NVRAM_MAGIC) return (ENXIO); + if (le32toh(hdr.size) >
svn commit: r315651 - in head/sys/dev/bhnd/cores: chipc pmu
Author: landonf Date: Mon Mar 20 19:27:35 2017 New Revision: 315651 URL: https://svnweb.freebsd.org/changeset/base/315651 Log: Integrate BCM4706 PMU (rev6) support, derived from the ISC-licensed Broadcom sbchipc.h and hndpmu.c sources included in the RT-N16 and later firmware source drops. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/cores/chipc/chipcreg.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c head/sys/dev/bhnd/cores/pmu/bhnd_pmureg.h Modified: head/sys/dev/bhnd/cores/chipc/chipcreg.h == --- head/sys/dev/bhnd/cores/chipc/chipcreg.hMon Mar 20 19:25:42 2017 (r315650) +++ head/sys/dev/bhnd/cores/chipc/chipcreg.hMon Mar 20 19:27:35 2017 (r315651) @@ -1,11 +1,11 @@ /*- * Copyright (c) 2015-2016 Landon Fuller- * Copyright (c) 2010 Broadcom Corporation + * Copyright (c) 2010-2015 Broadcom Corporation * All rights reserved. * - * This file is derived from the sbchipc.h header distributed with - * Broadcom's initial brcm80211 Linux driver release, as - * contributed to the Linux staging repository. + * This file is derived from the sbchipc.h header contributed by Broadcom + * to to the Linux staging repository, as well as later revisions of sbchipc.h + * distributed with the Asus RT-N16 firmware source code release. * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -928,6 +928,29 @@ enum { #defineCHIPC_CST43228_SDIO_OTP_PRESENT 0x10 #defineCHIPC_CST43228_SDIO_RESET 0x20 +/* 4706 chipstatus reg bits */ +#defineCHIPC_CST4706_LOWCOST_PKG (1<<0) /* 0: full-featured package 1: low-cost package */ +#defineCHIPC_CST4706_SFLASH_PRESENT(1<<1) /* 0: parallel, 1: serial flash is present */ +#defineCHIPC_CST4706_SFLASH_TYPE (1<<2) /* 0: 8b-p/ST-s flash, 1: 16b-p/Atmal-s flash */ +#defineCHIPC_CST4706_MIPS_BENDIAN (1<<3) /* 0: little, 1: big endian */ +#defineCHIPC_CST4706_PCIE1_DISABLE (1<<5) /* PCIE1 enable strap pin */ + +/* 4706 flashstrconfig reg bits */ +#defineCHIPC_FLSTRCF4706_MASK 0x00ff +#defineCHIPC_FLSTRCF4706_SF1 0x0001 /* 2nd serial flash present */ +#defineCHIPC_FLSTRCF4706_PF1 0x0002 /* 2nd parallel flash present */ +#defineCHIPC_FLSTRCF4706_SF1_TYPE 0x0004 /* 2nd serial flash type : 0 : ST, 1 : Atmel */ +#defineCHIPC_FLSTRCF4706_NF1 0x0008 /* 2nd NAND flash present */ +#defineCHIPC_FLSTRCF4706_1ST_MADDR_SEG_MASK0x00f0 /* Valid value mask */ +#defineCHIPC_FLSTRCF4706_1ST_MADDR_SEG_SHIFT 4 +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_4MB 0x1 /* 4MB */ +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_8MB 0x2 /* 8MB */ +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_16MB 0x3 /* 16MB */ +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_32MB 0x4 /* 32MB */ +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_64MB 0x5 /* 64MB */ +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_128MB 0x6 /* 128MB */ +#define CHIPC_FLSTRCF4706_1ST_MADDR_SEG_256MB 0x7 /* 256MB */ + /* * Register eci_inputlo bitfield values. * - BT packet type information bits [7:0] Modified: head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c == --- head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c Mon Mar 20 19:25:42 2017 (r315650) +++ head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c Mon Mar 20 19:27:35 2017 (r315651) @@ -69,6 +69,9 @@ static uint32_t bhnd_pmu1_alpclk0(struct static uint32_tbhnd_pmu5_clock(struct bhnd_pmu_query *sc, u_int pll0, u_int m); +static uint32_tbhnd_pmu6_4706_clock(struct bhnd_pmu_query *sc, u_int pll0, + u_int m); + /* PMU resources */ static boolbhnd_pmu_res_depfltr_bb(struct bhnd_pmu_softc *sc); static boolbhnd_pmu_res_depfltr_ncb(struct bhnd_pmu_softc *sc); @@ -2329,6 +2332,47 @@ bhnd_pmu5_clock(struct bhnd_pmu_query *s return ((fc / div) * 100); } +static uint32_t +bhnd_pmu6_4706_clock(struct bhnd_pmu_query *sc, u_int pll0, u_int m) +{ + uint32_t chipst, clock; + uint32_t ndiv, p1div, p2div, tmp; + + /* Get N, P1 and P2 dividers to determine CPU clock */ + BHND_PMU_WRITE_4(sc, BHND_PMU_PLL_CONTROL_ADDR, + pll0 + BHND_PMU6_4706_PROCPLL_OFF); + BHND_PMU_READ_4(sc, BHND_PMU_PLL_CONTROL_ADDR); + + tmp = BHND_PMU_READ_4(sc, BHND_PMU_PLL_CONTROL_DATA); + ndiv = BHND_PMU_GET_BITS(tmp,
svn commit: r315465 - head/sys/mips/broadcom
Author: landonf Date: Fri Mar 17 22:02:02 2017 New Revision: 315465 URL: https://svnweb.freebsd.org/changeset/base/315465 Log: Add MIPS boot support for the BCM4706/Northstar ChipCommon core. This adds support for matching against a core lookup table when performing early boot core lookup, and includes the BCM4706/Northstar-specific ChipCommon core ID in the set of supported ChipCommon cores. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D10033 Modified: head/sys/mips/broadcom/bcm_machdep.c Modified: head/sys/mips/broadcom/bcm_machdep.c == --- head/sys/mips/broadcom/bcm_machdep.cFri Mar 17 21:40:14 2017 (r315464) +++ head/sys/mips/broadcom/bcm_machdep.cFri Mar 17 22:02:02 2017 (r315465) @@ -98,9 +98,9 @@ __FBSDID("$FreeBSD$"); static int bcm_init_platform_data(struct bcm_platform *bp); -static int bcm_find_core(struct bcm_platform *bp, uint16_t vendor, - uint16_t device, int unit, struct bhnd_core_info *info, - uintptr_t *addr); +static int bcm_find_core(struct bcm_platform *bp, + const struct bhnd_core_match *descs, size_t num_descs, + struct bhnd_core_info *info, uintptr_t *addr); static int bcm_erom_probe_and_attach(bhnd_erom_class_t **erom_cls, kobj_ops_t erom_ops, bhnd_erom_t *erom, size_t esize, @@ -112,6 +112,15 @@ extern int *end; static struct bcm_platform bcm_platform_data; static bool bcm_platform_data_avail = false; +static const struct bhnd_core_match bcm_chipc_cores[] = { + { BHND_MATCH_CORE(BHND_MFGID_BCM, BHND_COREID_CC) }, + { BHND_MATCH_CORE(BHND_MFGID_BCM, BHND_COREID_4706_CC)}, +}; + +static const struct bhnd_core_match bcm_pmu_cores[] = { + { BHND_MATCH_CORE(BHND_MFGID_BCM, BHND_COREID_PMU)}, +}; + struct bcm_platform * bcm_get_platform(void) { @@ -133,39 +142,41 @@ bcm_get_bus_addr(void) } /** - * Search the device enumeration table for a core matching @p vendor, - * @p device, and @p unit. + * Search the device enumeration table for a core matching @p descs, * * @param bp Platform state containing a valid EROM parser. - * @param vendor The core's required vendor. - * @param device The core's required device id. - * @param unitThe core's required unit number. + * @param descs The core match descriptor table. + * @param num_descs The number of match descriptors in @p descs. * @param[out] infoIf non-NULL, will be populated with the core * info. * @param[out] addrIf non-NULL, will be populated with the core's * physical register address. */ static int -bcm_find_core(struct bcm_platform *bp, uint16_t vendor, uint16_t device, -int unit, struct bhnd_core_info *info, uintptr_t *addr) +bcm_find_core(struct bcm_platform *bp, const struct bhnd_core_match *descs, +size_t num_descs, struct bhnd_core_info *info, uintptr_t *addr) { - struct bhnd_core_match md; bhnd_addr_t b_addr; bhnd_size_t b_size; int error; - md = (struct bhnd_core_match) { - BHND_MATCH_CORE_VENDOR(vendor), - BHND_MATCH_CORE_ID(BHND_COREID_CC), - BHND_MATCH_CORE_UNIT(0) - }; - /* Fetch core info */ - error = bhnd_erom_lookup_core_addr(>erom.obj, , BHND_PORT_DEVICE, - 0, 0, info, _addr, _size); - if (error) - return (error); + for (size_t i = 0; i < num_descs; i++) { + error = bhnd_erom_lookup_core_addr(>erom.obj, [i], + BHND_PORT_DEVICE, 0, 0, info, _addr, _size); + + /* Terminate search on first match */ + if (error == 0) + break; + /* Terminate on first error (other than core not found) */ + if (error != ENOENT) + return (error); + + /* Continue search ... */ + } + + /* Provide the core's base address */ if (addr != NULL && b_addr > UINTPTR_MAX) { BCM_ERR("core address %#jx overflows native address width\n", (uintmax_t)b_addr); @@ -286,8 +297,8 @@ bcm_init_platform_data(struct bcm_platfo } /* Fetch chipcommon core info */ - error = bcm_find_core(bp, BHND_MFGID_BCM, BHND_COREID_CC, 0, >cc_id, - >cc_addr); + error = bcm_find_core(bp, bcm_chipc_cores, nitems(bcm_chipc_cores), + >cc_id, >cc_addr); if (error) { BCM_ERR("error locating chipc core: %d\n", error); return (error); @@ -306,9 +317,8 @@
svn commit: r313705 - in head/sys: conf dev/bhnd dev/bhnd/bcma dev/bhnd/siba mips/broadcom
Author: landonf Date: Mon Feb 13 19:58:55 2017 New Revision: 313705 URL: https://svnweb.freebsd.org/changeset/base/313705 Log: [mips/broadcom] Move MIPS-specific bhnd(4) nexus drivers to sys/mips/broadcom, and add MIPS/BCM4706-specific workaround to bhnd_nexus_is_hw_disabled() -- the BCM4706 low-cost package leaves secondary GMAC cores floating. Reviewed by: mizhka Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D9499 Added: head/sys/mips/broadcom/bcma_nexus.c - copied, changed from r313704, head/sys/dev/bhnd/bcma/bcma_nexus.c head/sys/mips/broadcom/bhnd_nexus.c - copied, changed from r313704, head/sys/dev/bhnd/bhnd_nexus.c head/sys/mips/broadcom/bhnd_nexusvar.h - copied, changed from r313704, head/sys/dev/bhnd/bhnd_nexusvar.h head/sys/mips/broadcom/siba_nexus.c - copied, changed from r313704, head/sys/dev/bhnd/siba/siba_nexus.c Deleted: head/sys/dev/bhnd/bcma/bcma_nexus.c head/sys/dev/bhnd/bhnd_nexus.c head/sys/dev/bhnd/bhnd_nexusvar.h head/sys/dev/bhnd/siba/siba_nexus.c Modified: head/sys/conf/files head/sys/mips/broadcom/files.broadcom Modified: head/sys/conf/files == --- head/sys/conf/files Mon Feb 13 19:00:09 2017(r313704) +++ head/sys/conf/files Mon Feb 13 19:58:55 2017(r313705) @@ -1190,8 +1190,6 @@ dev/bge/if_bge.c optional bge dev/bhnd/bhnd.coptional bhnd dev/bhnd/bhnd_erom.c optional bhnd dev/bhnd/bhnd_erom_if.moptional bhnd -dev/bhnd/bhnd_nexus.c optional bhnd siba_nexus | \ -bhnd bcma_nexus dev/bhnd/bhnd_subr.c optional bhnd dev/bhnd/bhnd_bus_if.m optional bhnd dev/bhnd/bhndb/bhnd_bhndb.coptional bhndb bhnd @@ -1206,7 +1204,6 @@ dev/bhnd/bhndb/bhndb_subr.c optional bh dev/bhnd/bcma/bcma.c optional bcma bhnd dev/bhnd/bcma/bcma_bhndb.c optional bcma bhnd bhndb dev/bhnd/bcma/bcma_erom.c optional bcma bhnd -dev/bhnd/bcma/bcma_nexus.c optional bcma_nexus bcma bhnd dev/bhnd/bcma/bcma_subr.c optional bcma bhnd dev/bhnd/cores/chipc/bhnd_chipc_if.m optional bhnd dev/bhnd/cores/chipc/bhnd_sprom_chipc.coptional bhnd @@ -1252,7 +1249,6 @@ dev/bhnd/nvram/bhnd_sprom.c optional bh dev/bhnd/siba/siba.c optional siba bhnd dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb dev/bhnd/siba/siba_erom.c optional siba bhnd -dev/bhnd/siba/siba_nexus.c optional siba_nexus siba bhnd dev/bhnd/siba/siba_subr.c optional siba bhnd # dev/bktr/bktr_audio.c optional bktr pci Copied and modified: head/sys/mips/broadcom/bcma_nexus.c (from r313704, head/sys/dev/bhnd/bcma/bcma_nexus.c) == --- head/sys/dev/bhnd/bcma/bcma_nexus.c Mon Feb 13 19:00:09 2017 (r313704, copy source) +++ head/sys/mips/broadcom/bcma_nexus.c Mon Feb 13 19:58:55 2017 (r313705) @@ -43,49 +43,41 @@ __FBSDID("$FreeBSD$"); #include #include -#include -#include -#include "bcmavar.h" -#include "bcma_eromreg.h" +#include + +#include "bcm_machdep.h" + +#include "bhnd_nexusvar.h" /* - * Supports bcma(4) attachment to a nexus bus. + * Supports bcma(4) attachment to a MIPS nexus bus. */ static int bcma_nexus_attach(device_t); static int bcma_nexus_probe(device_t); -struct bcma_nexus_softc { - struct bcma_softc parent_sc; - struct bhnd_chipid bcma_cid; -}; - static int bcma_nexus_probe(device_t dev) { - struct bcma_nexus_softc *sc; - int error; - - sc = device_get_softc(dev); - - /* Read the ChipCommon info using the hints the kernel -* was compiled with. */ - if ((error = bhnd_nexus_read_chipid(dev, >bcma_cid))) - return (error); + int error; - if (sc->bcma_cid.chip_type != BHND_CHIPTYPE_BCMA) + switch (bcm_get_platform()->cid.chip_type) { + case BHND_CHIPTYPE_BCMA: + case BHND_CHIPTYPE_BCMA_ALT: + case BHND_CHIPTYPE_UBUS: + break; + default: return (ENXIO); + } - if ((error = bcma_probe(dev)) > 0) { - device_printf(dev, "error %d in probe\n", error); + if ((error = bcma_probe(dev)) > 0) return (error); - } /* Set device description */ - bhnd_set_default_bus_desc(dev, >bcma_cid); + bhnd_set_default_bus_desc(dev, _get_platform()->cid); - return (0); + return (BUS_PROBE_SPECIFIC); } static int @@ -108,25 +100,15 @@ failed: return (error); } -static const struct bhnd_chipid *
svn commit: r310342 - head/sys/dev/bhnd/tools
Author: landonf Date: Wed Dec 21 00:50:21 2016 New Revision: 310342 URL: https://svnweb.freebsd.org/changeset/base/310342 Log: bhnd(4): Use a stable sort key to produce deterministic nvram_map_gen.awk output. When ordering SROM layout entries, we now use the unique (var_id, rev_start, rev_end) tuple as the sort key; this fixes the previously non-deterministic output when sorting entries with overlapping var_ids. PR: 215422 Reported by: emaste Reviewed by: emaste Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8859 Modified: head/sys/dev/bhnd/tools/nvram_map_gen.awk Modified: head/sys/dev/bhnd/tools/nvram_map_gen.awk == --- head/sys/dev/bhnd/tools/nvram_map_gen.awk Tue Dec 20 22:47:09 2016 (r310341) +++ head/sys/dev/bhnd/tools/nvram_map_gen.awk Wed Dec 21 00:50:21 2016 (r310342) @@ -1519,8 +1519,10 @@ function write_srom_bindings(layout, _va array_append(_entries, _entry) } - # Sort entries by variable ID, ascending - array_sort(_entries, prop_path_create(p_var, p_vid)) + # Sort entries by (variable ID, revision range), ascending + array_sort(_entries, prop_path_create(p_var, p_vid), + prop_path_create(p_revisions, p_start), + prop_path_create(p_revisions, p_end)) # Emit all entry binding opcodes emit("static const uint8_t " _varname "[] = {\n") @@ -2297,17 +2299,24 @@ function array_get(array, idx) { # # Sort an array, using standard awk comparison operators over its values. # -# If `prop_path` is non-NULL, the corresponding property path (or property ID) +# If `prop_path*` is non-NULL, the corresponding property path (or property ID) # will be fetched from each array element and used as the sorting value. # -function array_sort(array, prop_path, _size) { +# If multiple property paths are specified, the array is first sorted by +# the first path, and then any equal values are sorted by the second path, +# and so on. +# +function array_sort(array, prop_path0, prop_path1, prop_path2, _size) { obj_assert_class(array, Array) + if (_size != null) + errorx("no more than three property paths may be specified") + _size = array_size(array) if (_size <= 1) return - _qsort(array, prop_path, 0, _size-1) + _qsort(array, prop_path0, prop_path1, prop_path2, 0, _size-1) } function _qsort_get_key(array, idx, prop_path, _v) { @@ -2319,8 +2328,35 @@ function _qsort_get_key(array, idx, prop return (prop_get_path(_v, prop_path)) } -function _qsort(array, prop_path, first, last, _qpivot, _qpivot_val, _qleft, -_qleft_val, _qright, _qright_val) +function _qsort_compare(array, lhs_idx, rhs_val, ppath0, ppath1, ppath2, +_lhs_val, _rhs_prop_val) +{ + _lhs_val = _qsort_get_key(array, lhs_idx, ppath0) + if (ppath0 == null) + _rhs_prop_val = rhs_val + else + _rhs_prop_val = prop_get_path(rhs_val, ppath0) + + if (_lhs_val == _rhs_prop_val && ppath1 != null) { + _lhs_val = _qsort_get_key(array, lhs_idx, ppath1) + _rhs_prop_val = prop_get_path(rhs_val, ppath1) + + if (_lhs_val == _rhs_prop_val && ppath2 != null) { + _lhs_val = _qsort_get_key(array, lhs_idx, ppath2) + _rhs_prop_val = prop_get_path(rhs_val, ppath2) + } + } + + if (_lhs_val < _rhs_prop_val) + return (-1) + else if (_lhs_val > _rhs_prop_val) + return (1) + else + return (0) +} + +function _qsort(array, ppath0, ppath1, ppath2, first, last, _qpivot, +_qleft, _qleft_val, _qright, _qright_val) { if (first >= last) return @@ -2330,15 +2366,21 @@ function _qsort(array, prop_path, first, _qleft = first _qright = last - _qpivot_val = _qsort_get_key(array, _qpivot, prop_path) + _qpivot_val = array_get(array, _qpivot) # partition while (_qleft <= _qright) { - while (_qsort_get_key(array, _qleft, prop_path) < _qpivot_val) + while (_qsort_compare(array, _qleft, _qpivot_val, ppath0, ppath1, + ppath2) < 0) + { _qleft++ + } - while (_qsort_get_key(array, _qright, prop_path) > _qpivot_val) + while (_qsort_compare(array, _qright, _qpivot_val, ppath0, ppath1, + ppath2) > 0) + { _qright-- + } # swap if (_qleft <= _qright) { @@ -2354,8 +2396,8 @@ function _qsort(array, prop_path, first, } # sort the partitions - _qsort(array, prop_path, first, _qright) - _qsort(array, prop_path,
svn commit: r310297 - in head/sys: conf dev/bhnd/nvram dev/bhnd/tools modules/bhnd
Author: landonf Date: Mon Dec 19 20:34:05 2016 New Revision: 310297 URL: https://svnweb.freebsd.org/changeset/base/310297 Log: bhnd(4): NVRAM serialization support. This adds support for: - Serializing an bhnd_nvram_plist (as exported from bhnd_nvram_store, etc) to an arbitrary NVRAM data format. - Generating a serialized representation of the current NVRAM store's state suitable for writing back to flash, or re-encoding for upload to a FullMAC device. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8762 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom_subr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_spromvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/tools/nvram_map_gen.awk head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Dec 19 20:31:27 2016(r310296) +++ head/sys/conf/files Mon Dec 19 20:34:05 2016(r310297) @@ -1236,6 +1236,7 @@ dev/bhnd/nvram/bhnd_nvram_data_bcm.c opt dev/bhnd/nvram/bhnd_nvram_data_bcmraw.coptional bhnd dev/bhnd/nvram/bhnd_nvram_data_btxt.c optional bhnd dev/bhnd/nvram/bhnd_nvram_data_sprom.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_data_sprom_subr.coptional bhnd dev/bhnd/nvram/bhnd_nvram_data_tlv.c optional bhnd dev/bhnd/nvram/bhnd_nvram_if.m optional bhnd dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:31:27 2016 (r310296) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:34:05 2016 (r310297) @@ -65,6 +65,54 @@ bhnd_nvram_data_class_desc(bhnd_nvram_da } /** + * Return the class-level capability flags (@see BHND_NVRAM_DATA_CAP_*) for + * of @p cls. + * + * @param cls The NVRAM class. + */ +uint32_t +bhnd_nvram_data_class_caps(bhnd_nvram_data_class *cls) +{ + return (cls->caps); +} + +/** + * Serialize all NVRAM properties in @p plist using @p cls's NVRAM data + * format, writing the result to @p outp. + * + * @param cls The NVRAM data class to be used to perform + * serialization. + * @param props The raw property values to be serialized to + * @p outp, in serialization order. + * @param options Serialization options for @p cls, or NULL. + * @param[out] outpOn success, the serialed NVRAM data will be + * written to this buffer. This argment may be + * NULL if the value is not desired. + * @param[in,out] olenThe capacity of @p buf. On success, will be set + * to the actual length of the serialized data. + * + * @retval 0 success + * + * @retval ENOMEM If @p outp is non-NULL and a buffer of @p olen is too + * small to hold the serialized data. + * @retval EINVAL If a property value required by @p cls is not found in + * @p plist. + * @retval EFTYPE If a property value in @p plist cannot be represented + * as the data type required by @p cls. + * @retval ERANGE If a property value in @p plist would would overflow + * (or underflow) the data type required by @p cls. + * @retval non-zeroIf serialization otherwise fails, a regular unix error + * code will be returned. + */ +int +bhnd_nvram_data_serialize(bhnd_nvram_data_class *cls, +bhnd_nvram_plist *props, bhnd_nvram_plist *options, void *outp, +size_t *olen) +{ + return (cls->op_serialize(cls, props, options, outp, olen)); +} + +/** * Probe to see if this NVRAM data class class supports the data mapped by the * given I/O context, returning a BHND_NVRAM_DATA_PROBE probe result. * @@ -293,51 +341,6 @@ bhnd_nvram_data_options(struct bhnd_nvra } /** - * Compute the size of the serialized form of @p nv. - * - * Serialization may be performed via bhnd_nvram_data_serialize(). - * - * @param nv The NVRAM data to be queried. - * @param[out] len On success, will be set to the computed size. - * -
svn commit: r310296 - head/sys/dev/bhnd/nvram
Author: landonf Date: Mon Dec 19 20:31:27 2016 New Revision: 310296 URL: https://svnweb.freebsd.org/changeset/base/310296 Log: bhnd(4): Add support for exporting all (or a subtree) of NVRAM properties backed by an NVRAM store. This will be used to support: - Serializing the current NVRAM state for writing back to flash. - Exporting subsidiary device paths for serialization and upload to fullmac chipsets. Additionally, this includes an improvement to BCM-RAW format detection to avoid matching on BCM-TEXT NVRAM data. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8761 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:31:27 2016 (r310296) @@ -281,6 +281,18 @@ bhnd_nvram_data_count(struct bhnd_nvram_ } /** + * Return a borrowed reference to the serialization options for @p nv, + * suitable for use with bhnd_nvram_data_serialize(), or NULL if none. + * + * @param nv The NVRAM data to be queried. + */ +bhnd_nvram_plist * +bhnd_nvram_data_options(struct bhnd_nvram_data *nv) +{ + return (nv->cls->op_options(nv)); +} + +/** * Compute the size of the serialized form of @p nv. * * Serialization may be performed via bhnd_nvram_data_serialize(). Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:28:27 2016 (r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:31:27 2016 (r310296) @@ -44,6 +44,7 @@ #include "bhnd_nvram.h" #include "bhnd_nvram_io.h" +#include "bhnd_nvram_plist.h" #include "bhnd_nvram_value.h" /* NVRAM data class */ @@ -115,6 +116,7 @@ int bhnd_nvram_data_size(struct bhnd_ int bhnd_nvram_data_serialize(struct bhnd_nvram_data *nv, void *buf, size_t *len); +bhnd_nvram_plist *bhnd_nvram_data_options(struct bhnd_nvram_data *nv); uint32_tbhnd_nvram_data_caps(struct bhnd_nvram_data *nv); const char *bhnd_nvram_data_next(struct bhnd_nvram_data *nv, Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:28:27 2016(r310295) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:31:27 2016(r310296) @@ -121,6 +121,7 @@ static const struct bhnd_nvram_bcm_hvar struct bhnd_nvram_bcm { struct bhnd_nvram_data nv;/**< common instance state */ struct bhnd_nvram_io*data; /**< backing buffer */ + bhnd_nvram_plist*opts; /**< serialization options */ /** BCM header values */ struct bhnd_nvram_bcm_hvar hvars[nitems(bhnd_nvram_bcm_hvars)]; @@ -157,7 +158,7 @@ bhnd_nvram_bcm_init(struct bhnd_nvram_bc uint8_t *p; void*ptr; size_t io_offset, io_size; - uint8_t crc, valid; + uint8_t crc, valid, bcm_ver; int error; if ((error = bhnd_nvram_io_read(src, 0x0, , sizeof(hdr @@ -344,6 +345,14 @@ bhnd_nvram_bcm_init(struct bhnd_nvram_bc bcm->count++; } + /* Populate serialization options from our header */ + bcm_ver = BCM_NVRAM_GET_BITS(hdr.cfg0, BCM_NVRAM_CFG0_VER); + error = bhnd_nvram_plist_append_bytes(bcm->opts, + BCM_NVRAM_ENCODE_OPT_VERSION, _ver, sizeof(bcm_ver), + BHND_NVRAM_TYPE_UINT8); + if (error) + return (error); + return (0); } @@ -360,6 +369,12 @@ bhnd_nvram_bcm_new(struct bhnd_nvram_dat "hvar declarations must match bhnd_nvram_bcm_hvars template"); memcpy(bcm->hvars, bhnd_nvram_bcm_hvars, sizeof(bcm->hvars)); + /* Allocate (empty) option list, to be populated by +*
svn commit: r310295 - in head/sys: conf dev/bhnd/nvram modules/bhnd
Author: landonf Date: Mon Dec 19 20:28:27 2016 New Revision: 310295 URL: https://svnweb.freebsd.org/changeset/base/310295 Log: bhnd(4): NVRAM device path support. Implements bhnd_nvram_store support for parsing and operating over NVRAM device paths, and device path aliases, as well as tracking per-path NVRAM variable writes. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8760 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_store_subr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Dec 19 20:26:10 2016(r310294) +++ head/sys/conf/files Mon Dec 19 20:28:27 2016(r310295) @@ -1244,6 +1244,7 @@ dev/bhnd/nvram/bhnd_nvram_ioptr.c option dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd dev/bhnd/nvram/bhnd_nvram_plist.c optional bhnd dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_store_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value_fmts.c optional bhnd Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:26:10 2016 (r310294) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:28:27 2016 (r310295) @@ -350,7 +350,26 @@ bhnd_nvram_data_caps(struct bhnd_nvram_d const char * bhnd_nvram_data_next(struct bhnd_nvram_data *nv, void **cookiep) { - return (nv->cls->op_next(nv, cookiep)); + const char *name; +#ifdef BHND_NV_INVARIANTS + void*prev = *cookiep; +#endif + + /* Fetch next */ + if ((name = nv->cls->op_next(nv, cookiep)) == NULL) + return (NULL); + + /* Enforce precedence ordering invariant between bhnd_nvram_data_next() +* and bhnd_nvram_data_getvar_order() */ +#ifdef BHND_NV_INVARIANTS + if (prev != NULL && + bhnd_nvram_data_getvar_order(nv, prev, *cookiep) > 0) + { + BHND_NV_PANIC("%s: returned out-of-order entry", __FUNCTION__); + } +#endif + + return (name); } /** @@ -388,7 +407,7 @@ bhnd_nvram_data_generic_find(struct bhnd cookiep = NULL; while ((next = bhnd_nvram_data_next(nv, ))) { - if (strcasecmp(name, next) == 0) + if (strcmp(name, next) == 0) return (cookiep); } @@ -397,6 +416,37 @@ bhnd_nvram_data_generic_find(struct bhnd } /** + * Compare the declaration order of two NVRAM variables. + * + * Variable declaration order is used to determine the current order of + * the variables in the source data, as well as to determine the precedence + * of variable declarations in data sources that define duplicate names. + * + * The comparison order will match the order of variables returned via + * bhnd_nvstore_path_data_next(). + * + * @param nv The NVRAM data. + * @param cookiep1An NVRAM variable cookie previously + * returned via bhnd_nvram_data_next() or + * bhnd_nvram_data_find(). + * @param cookiep2An NVRAM variable cookie previously + * returned via bhnd_nvram_data_next() or + * bhnd_nvram_data_find(). + * + * @retval <= -1 If @p cookiep1 has an earlier declaration order than + * @p cookiep2. + * @retval 0 If @p cookiep1 and @p cookiep2 are identical. + * @retval >= 1If @p cookiep has a later declaration order than + * @p cookiep2. + */ +int +bhnd_nvram_data_getvar_order(struct bhnd_nvram_data *nv, void *cookiep1, +void *cookiep2) +{ + return (nv->cls->op_getvar_order(nv, cookiep1, cookiep2)); +} + +/** * Read a variable and decode as @p type. * * @param nv The NVRAM data. @@ -423,6 +473,58 @@ bhnd_nvram_data_getvar(struct bhnd_nvram return (nv->cls->op_getvar(nv, cookiep, buf, len, type)); } +/* + *
svn commit: r310294 - in head/sys: conf dev/bhnd/nvram modules/bhnd
Author: landonf Date: Mon Dec 19 20:26:10 2016 New Revision: 310294 URL: https://svnweb.freebsd.org/changeset/base/310294 Log: bhnd(4): add support for wrapping arbitrary pointers in an NVRAM I/O context. Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8759 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_ioptr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_io.h head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Dec 19 20:23:19 2016(r310293) +++ head/sys/conf/files Mon Dec 19 20:26:10 2016(r310294) @@ -1240,6 +1240,7 @@ dev/bhnd/nvram/bhnd_nvram_data_tlv.c opt dev/bhnd/nvram/bhnd_nvram_if.m optional bhnd dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iobuf.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_ioptr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd dev/bhnd/nvram/bhnd_nvram_plist.c optional bhnd dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_io.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram_io.h Mon Dec 19 20:23:19 2016 (r310293) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_io.h Mon Dec 19 20:26:10 2016 (r310294) @@ -52,6 +52,9 @@ struct bhnd_nvram_io *bhnd_nvram_iobuf_c struct bhnd_nvram_io *bhnd_nvram_iobuf_copy_range(struct bhnd_nvram_io *src, size_t offset, size_t size); +struct bhnd_nvram_io *bhnd_nvram_ioptr_new(const void *ptr, size_t size, +size_t capacity, uint32_t flags); + #ifdef _KERNEL struct bhnd_nvram_io *bhnd_nvram_iores_new(struct bhnd_resource *r, bus_size_t offset, bus_size_t size, @@ -76,4 +79,12 @@ int bhnd_nvram_io_write_ptr(struct bh voidbhnd_nvram_io_free(struct bhnd_nvram_io *io); +/** + * bhnd_nvram_ioptr flags + */ +enum { + BHND_NVRAM_IOPTR_RDONLY = (1<<0), /**< read-only */ + BHND_NVRAM_IOPTR_RDWR = (1<<1), /**< read/write */ +}; + #endif /* _BHND_NVRAM_BHND_NVRAM_IO_H_ */ Added: head/sys/dev/bhnd/nvram/bhnd_nvram_ioptr.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_ioptr.c Mon Dec 19 20:26:10 2016 (r310294) @@ -0,0 +1,228 @@ +/*- + * Copyright (c) 2016 Landon Fuller+ * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer, + *without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + *redistribution must be conditioned upon including a substantially + *similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +#ifdef _KERNEL +#include +#include +#include +#else /* !_KERNEL */ +#include +#include +#include +#include +#endif /* _KERNEL */ + +#include "bhnd_nvram_private.h" + +#include "bhnd_nvram_io.h" +#include "bhnd_nvram_iovar.h" + +/** + * Memory-backed NVRAM I/O context. + * + * ioptr instances are gauranteed to provide persistent references to its + * backing contigious memory via bhnd_nvram_io_read_ptr() and + * bhnd_nvram_io_write_ptr(). + */ +struct bhnd_nvram_ioptr { + struct bhnd_nvram_io io;/**< common I/O instance state */ + void*ptr; /**< backing memory */ + size_t size; /**< size at @p ptr */ + size_t capacity;
svn commit: r310293 - head/sys/dev/bhnd/nvram
Author: landonf Date: Mon Dec 19 20:23:19 2016 New Revision: 310293 URL: https://svnweb.freebsd.org/changeset/base/310293 Log: bhnd(4): Add support for three new NVRAM value types; booleans, NULL (which we'll use to denote deleted values in bhnd_nvram_store), and opaque data (aka octet-strings). Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8758 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram.h head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c Modified: head/sys/dev/bhnd/nvram/bhnd_nvram.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram.hMon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram.hMon Dec 19 20:23:19 2016 (r310293) @@ -40,6 +40,14 @@ #endif /* _KERNEL */ /** + * BHND NVRAM boolean type; guaranteed to be exactly 8-bits, representing + * true as integer constant 1, and false as integer constant 0. + * + * Compatible with stdbool constants (true, false). + */ +typedef uint8_tbhnd_nvram_bool_t; + +/** * NVRAM data sources supported by bhnd(4) devices. */ typedef enum { @@ -94,6 +102,10 @@ typedef enum { BHND_NVRAM_TYPE_CHAR= 8,/**< ASCII/UTF-8 character */ BHND_NVRAM_TYPE_STRING = 9,/**< ASCII/UTF-8 NUL-terminated string */ + BHND_NVRAM_TYPE_BOOL= 10, /**< uint8 boolean value. see +bhnd_nvram_bool_t. */ + BHND_NVRAM_TYPE_NULL= 11, /**< NULL (empty) value */ + BHND_NVRAM_TYPE_DATA= 12, /**< opaque octet string */ /* 10-15 reserved for primitive (non-array) types */ @@ -109,13 +121,17 @@ typedef enum { characters */ BHND_NVRAM_TYPE_STRING_ARRAY= 25, /**< array of ASCII/UTF-8 NUL-terminated strings */ + BHND_NVRAM_TYPE_BOOL_ARRAY = 26, /**< array of uint8 boolean +values */ } bhnd_nvram_type; + boolbhnd_nvram_is_signed_type(bhnd_nvram_type type); boolbhnd_nvram_is_unsigned_type(bhnd_nvram_type type); boolbhnd_nvram_is_int_type(bhnd_nvram_type type); boolbhnd_nvram_is_array_type(bhnd_nvram_type type); bhnd_nvram_type bhnd_nvram_base_type(bhnd_nvram_type type); +bhnd_nvram_type bhnd_nvram_raw_type(bhnd_nvram_type type); const char *bhnd_nvram_type_name(bhnd_nvram_type type); size_t bhnd_nvram_type_width(bhnd_nvram_type type); size_t bhnd_nvram_type_host_align(bhnd_nvram_type type); Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c Mon Dec 19 20:20:33 2016 (r310292) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c Mon Dec 19 20:23:19 2016 (r310293) @@ -743,6 +743,27 @@ bhnd_nvram_plist_get_uint64(bhnd_nvram_p } /** + * Return the boolean representation of a named property's value. + * + * @param plist The property list to be queried. + * @param nameThe name of the property value to be returned. + * @param[out] val On success, the boolean value of @p name. + * + * @retval 0 success + * @retval ENOENT If @p name is not found in @p plist. + * @retval EFTYPE If coercion of the property's value to @p val. + * @retval ERANGE If coercion of the property's value would overflow + * (or underflow) @p val. + */ +int +bhnd_nvram_plist_get_bool(bhnd_nvram_plist *plist, const char *name, +bool *val) +{ + return (bhnd_nvram_plist_get_encoded(plist, name, val, sizeof(*val), + BHND_NVRAM_TYPE_BOOL)); +} + +/** * Allocate and initialize a new property value. * * The caller is responsible for releasing the returned property value @@ -901,6 +922,18 @@ bhnd_nvram_prop_type(bhnd_nvram_prop *pr } /** + * Return true if @p prop has a NULL value type (BHND_NVRAM_TYPE_NULL), false + * otherwise. + * + * @param propThe property to query. + */ +bool +bhnd_nvram_prop_is_null(bhnd_nvram_prop *prop) +{ + return (bhnd_nvram_prop_type(prop) == BHND_NVRAM_TYPE_NULL); +} + +/** * Return a borrowed reference to the property's internal value representation. * * @param propThe property to query. Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h
svn commit: r310292 - in head/sys: conf dev/bhnd/nvram modules/bhnd
Author: landonf Date: Mon Dec 19 20:20:33 2016 New Revision: 310292 URL: https://svnweb.freebsd.org/changeset/base/310292 Log: bhnd(4): support direct conversion of bhnd_nvram_val This adds support for bhnd_nvram_val_convert_init() and bhnd_nvram_val_convert_new(), which may be used to perform value format-aware encoding of an NVRAM value to a new target format/type. This will be used to simplify converting to/from serialized format-specific NVRAM value representations to common external representations. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8757 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_value_subr.c (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Dec 19 20:11:48 2016(r310291) +++ head/sys/conf/files Mon Dec 19 20:20:33 2016(r310292) @@ -1247,6 +1247,7 @@ dev/bhnd/nvram/bhnd_nvram_subr.c optiona dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value_fmts.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value_prf.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_value_subr.c optional bhnd dev/bhnd/nvram/bhnd_sprom.coptional bhnd dev/bhnd/siba/siba.c optional siba bhnd dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb Modified: head/sys/dev/bhnd/nvram/bhnd_nvram.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram.hMon Dec 19 20:11:48 2016 (r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram.hMon Dec 19 20:20:33 2016 (r310292) @@ -111,14 +111,16 @@ typedef enum { NUL-terminated strings */ } bhnd_nvram_type; -const char *bhnd_nvram_string_array_next(const char *inp, size_t ilen, -const char *prev); - boolbhnd_nvram_is_signed_type(bhnd_nvram_type type); boolbhnd_nvram_is_unsigned_type(bhnd_nvram_type type); boolbhnd_nvram_is_int_type(bhnd_nvram_type type); boolbhnd_nvram_is_array_type(bhnd_nvram_type type); bhnd_nvram_type bhnd_nvram_base_type(bhnd_nvram_type type); const char *bhnd_nvram_type_name(bhnd_nvram_type type); +size_t bhnd_nvram_type_width(bhnd_nvram_type type); +size_t bhnd_nvram_type_host_align(bhnd_nvram_type type); + +const char *bhnd_nvram_string_array_next(const char *inp, size_t ilen, +const char *prev, size_t *olen); #endif /* _BHND_NVRAM_BHND_NVRAM_H_ */ Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:11:48 2016(r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c Mon Dec 19 20:20:33 2016(r310292) @@ -647,10 +647,8 @@ bhnd_nvram_bcm_getvar_ptr(struct bhnd_nv /* Handle header variables */ if ((hvar = bhnd_nvram_bcm_to_hdrvar(bcm, cookiep)) != NULL) { - BHND_NV_ASSERT( - hvar->len % bhnd_nvram_value_size(hvar->type, NULL, 0, - hvar->nelem) == 0, - ("length is not aligned to type width")); + BHND_NV_ASSERT(bhnd_nvram_value_check_aligned(>value, + hvar->len, hvar->type) == 0, ("value misaligned")); *type = hvar->type; *len = hvar->len; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:11:48 2016(r310291) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c Mon Dec 19 20:20:33 2016(r310292) @@ -597,7 +597,7 @@ bhnd_nvram_sprom_read_offset(struct bhnd } sp_value; /* Determine type width */ - sp_width = bhnd_nvram_value_size(type, NULL, 0, 1); + sp_width = bhnd_nvram_type_width(type); if (sp_width == 0) { /* Variable-width types are unsupported */ BHND_NV_LOG("invalid %s SPROM offset type %d\n", var->name, @@ -716,7 +716,7 @@ bhnd_nvram_sprom_getvar(struct bhnd_nvra var_btype =
svn commit: r310291 - in head/sys: conf dev/bhnd/nvram modules/bhnd
Author: landonf Date: Mon Dec 19 20:11:48 2016 New Revision: 310291 URL: https://svnweb.freebsd.org/changeset/base/310291 Log: bhnd(4): Implement a new bhnd_nvram_plist and bhnd_nvram_prop API for representing arbitrary Broadcom NVRAM key/value pairs. This will be used to track pending changes in bhnd_nvram_store, and provide support for exporting all or a device subpath for NVRAM (as required by some fullmac wifi chipsets). Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8756 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_plist.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_plistvar.h (contents, props changed) Modified: head/sys/conf/files head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Mon Dec 19 20:07:58 2016(r310290) +++ head/sys/conf/files Mon Dec 19 20:11:48 2016(r310291) @@ -1241,6 +1241,7 @@ dev/bhnd/nvram/bhnd_nvram_if.moptional dev/bhnd/nvram/bhnd_nvram_io.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iobuf.c optional bhnd dev/bhnd/nvram/bhnd_nvram_iores.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_plist.c optional bhnd dev/bhnd/nvram/bhnd_nvram_store.c optional bhnd dev/bhnd/nvram/bhnd_nvram_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram_value.c optional bhnd Added: head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_plist.c Mon Dec 19 20:11:48 2016 (r310291) @@ -0,0 +1,947 @@ +/*- + * Copyright (c) 2015-2016 Landon Fuller+ * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer, + *without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + *redistribution must be conditioned upon including a substantially + *similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include + +#ifdef _KERNEL + +#include + +#else /* !_KERNEL */ + +#include +#include +#include +#include + +#endif /* _KERNEL */ + +#include "bhnd_nvram_plistvar.h" +#include "bhnd_nvram_private.h" + +static bhnd_nvram_plist_entry *bhnd_nvram_plist_get_entry( +bhnd_nvram_plist *plist, const char *name); + +/** + * Allocate and initialize a new, empty property list. + * + * The caller is responsible for releasing the returned property value + * via bhnd_nvram_plist_release(). + * + * @retval non-NULLsuccess + * @retval NULLif allocation fails. + */ +bhnd_nvram_plist * +bhnd_nvram_plist_new(void) +{ + bhnd_nvram_plist *plist; + + plist = bhnd_nv_calloc(1, sizeof(*plist)); + if (plist == NULL) + return NULL; + + /* Implicit caller-owned reference */ + plist->refs = 1; + + /* Initialize entry list */ + plist->num_entries = 0; + TAILQ_INIT(>entries); + + /* Initialize entry hash table */ + for (size_t i = 0; i < nitems(plist->names); i++) + LIST_INIT(>names[i]); + + return (plist); +} + +/** + * Retain a reference and return @p plist to the caller. + * + * The caller is responsible for releasing their reference ownership via + * bhnd_nvram_plist_release(). + * + * @param plist The property list to be retained. + */ +bhnd_nvram_plist *
svn commit: r310290 - in head/sys: dev/bhnd/nvram mips/broadcom
Author: landonf Date: Mon Dec 19 20:07:58 2016 New Revision: 310290 URL: https://svnweb.freebsd.org/changeset/base/310290 Log: bhnd(4): minor style(9) fixes Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D8755 Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c head/sys/dev/bhnd/nvram/bhnd_nvram_data.h head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h head/sys/dev/bhnd/nvram/bhnd_nvram_private.h head/sys/dev/bhnd/nvram/bhnd_nvram_store.c head/sys/dev/bhnd/nvram/bhnd_nvram_store.h head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.c head/sys/dev/bhnd/nvram/bhnd_nvram_value.h head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h head/sys/mips/broadcom/bcm_nvram_cfe.c Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.c Mon Dec 19 20:07:58 2016 (r310290) @@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$"); * @param cls The NVRAM class. */ const char * -bhnd_nvram_data_class_desc(bhnd_nvram_data_class_t *cls) +bhnd_nvram_data_class_desc(bhnd_nvram_data_class *cls) { return (cls->desc); } @@ -80,7 +80,7 @@ bhnd_nvram_data_class_desc(bhnd_nvram_da * code should be returned. */ int -bhnd_nvram_data_probe(bhnd_nvram_data_class_t *cls, struct bhnd_nvram_io *io) +bhnd_nvram_data_probe(bhnd_nvram_data_class *cls, struct bhnd_nvram_io *io) { return (cls->op_probe(io)); } @@ -106,10 +106,10 @@ bhnd_nvram_data_probe(bhnd_nvram_data_cl */ int bhnd_nvram_data_probe_classes(struct bhnd_nvram_data **data, -struct bhnd_nvram_io *io, bhnd_nvram_data_class_t *classes[], +struct bhnd_nvram_io *io, bhnd_nvram_data_class *classes[], size_t num_classes) { - bhnd_nvram_data_class_t *cls; + bhnd_nvram_data_class *cls; int error, prio, result; cls = NULL; @@ -124,7 +124,7 @@ bhnd_nvram_data_probe_classes(struct bhn /* Try to find the best data class capable of parsing io */ for (size_t i = 0; i < num_classes; i++) { - bhnd_nvram_data_class_t *next_cls; + bhnd_nvram_data_class *next_cls; next_cls = classes[i]; @@ -196,8 +196,8 @@ bhnd_nvram_data_probe_classes(struct bhn * regular unix error code will be returned. */ int -bhnd_nvram_data_new(bhnd_nvram_data_class_t *cls, -struct bhnd_nvram_data **nv, struct bhnd_nvram_io *io) +bhnd_nvram_data_new(bhnd_nvram_data_class *cls, struct bhnd_nvram_data **nv, +struct bhnd_nvram_io *io) { struct bhnd_nvram_data *data; int error; @@ -263,8 +263,8 @@ bhnd_nvram_data_release(struct bhnd_nvra * * @param nv The NVRAM data instance to be queried. */ -bhnd_nvram_data_class_t * -bhnd_nvram_data_class(struct bhnd_nvram_data *nv) +bhnd_nvram_data_class * +bhnd_nvram_data_get_class(struct bhnd_nvram_data *nv) { return (nv->cls); } @@ -423,6 +423,7 @@ bhnd_nvram_data_getvar(struct bhnd_nvram return (nv->cls->op_getvar(nv, cookiep, buf, len, type)); } + /** * A generic implementation of bhnd_nvram_data_getvar(). * @@ -438,9 +439,9 @@ int bhnd_nvram_data_generic_rp_getvar(struct bhnd_nvram_data *nv, void *cookiep, void *outp, size_t *olen, bhnd_nvram_type otype) { - bhnd_nvram_val_t val; + bhnd_nvram_val val; const struct bhnd_nvram_vardefn *vdefn; - const bhnd_nvram_val_fmt_t *fmt; + const bhnd_nvram_val_fmt*fmt; const char *name; const void *vptr; bhnd_nvram_type vtype; Modified: head/sys/dev/bhnd/nvram/bhnd_nvram_data.h == --- head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 19:40:11 2016 (r310289) +++ head/sys/dev/bhnd/nvram/bhnd_nvram_data.h Mon Dec 19 20:07:58 2016 (r310290) @@ -46,7 +46,7 @@ #include "bhnd_nvram_io.h" /* NVRAM data class */ -typedef struct bhnd_nvram_data_class bhnd_nvram_data_class_t; +typedef struct bhnd_nvram_data_class bhnd_nvram_data_class; /* NVRAM data instance */ struct bhnd_nvram_data; @@ -88,25 +88,24 @@ enum { parsing */ }; -const char *bhnd_nvram_data_class_desc( -bhnd_nvram_data_class_t *cls); +const char *bhnd_nvram_data_class_desc(bhnd_nvram_data_class *cls); -int bhnd_nvram_data_probe(bhnd_nvram_data_class_t *cls, +int
svn commit: r309202 - in head/sys: conf dev/bhnd dev/bhnd/nvram dev/bhnd/tools dev/bwn mips/broadcom modules/bhnd
Author: landonf Date: Sat Nov 26 23:22:32 2016 New Revision: 309202 URL: https://svnweb.freebsd.org/changeset/base/309202 Log: bhnd(4): Unify NVRAM/SPROM parsing, implement compact SPROM layout encoding. - Defined an abstract NVRAM I/O API (bhnd_nvram_io), decoupling NVRAM/SPROM parsing from the actual underlying NVRAM data provider (e.g. CFE firmware devices). - Defined an abstract NVRAM data API (bhnd_nvram_data), decoupling higher-level NVRAM operations (indexed lookup, data conversion, etc) from the underlying NVRAM file format parsing/serialization. - Implemented a new high-level bhnd_nvram_store API, providing indexed variable lookup, pending write tracking, etc on top of an arbitrary bhnd_nvram_data instance. - Migrated all bhnd(4) NVRAM device drivers to the common bhnd_nvram_store API. - Implemented a common bhnd_nvram_val API for parsing/encoding NVRAM variable values, including applying format-specific behavior when converting to/from the NVRAM string representations. - Dropped the now unnecessary bhnd_nvram driver, and moved the broadcom/mips-specific CFE NVRAM driver out into sys/mips/broadcom. - Implemented a new nvram_map file format: - Variable definitions are now defined separately from the SPROM layout. This will also allow us to define CIS tuple NVRAM mappings referencing the common NVRAM variable definitions. - Variables can now be defined within arbitrary named groups. - Textual descriptions and help information can be defined inline for both variables and variable groups. - Implemented a new, compact encoding of SPROM image layout offsets. - Source-level (but not build system) support for building the NVRAM file format APIs (bhnd_nvram_io, bhnd_nvram_data, bhnd_nvram_store) as a userspace library. The new compact SPROM image layout encoding is loosely modeled on Apple dyld compressed LINKEDIT symbol binding opcodes; it provides a compact state-machine encoding of the mapping between NVRAM variables and the SPROM image offset, mask, and shift instructions necessary to decode or encode the SPROM variable data. The compact encoding reduces the size of the generated SPROM layout data from roughly 60KB to 3KB. The sequential nature SPROM layout opcode tables also simplify iteration of the SPROM variables, as it's no longer neccessary to iterate the full NVRAM variable definition table, but instead simply scan the SPROM revision's layout opcode table. Approved by:adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8645 Added: head/sys/dev/bhnd/nvram/bhnd_nvram_data.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcm.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmraw.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmreg.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_bcmvar.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_btxt.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_sprom.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_spromvar.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlv.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_data_tlvreg.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_datavar.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_io.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_io.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_iobuf.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_iores.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_iovar.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_private.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_store.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_store.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_storevar.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_subr.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_value.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_value.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_value_fmts.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_value_prf.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_valuevar.h (contents, props changed) head/sys/mips/broadcom/bcm_nvram_cfe.c (contents, props changed) head/sys/mips/broadcom/bcm_nvram_cfevar.h (contents, props changed) Deleted: head/sys/dev/bhnd/nvram/bhnd_nvram.c head/sys/dev/bhnd/nvram/bhnd_nvram_cfe.c
svn commit: r306287 - in head/sys: dev/bhnd dev/bhnd/bcma dev/bhnd/cores/pmu dev/bhnd/cores/usb dev/bhnd/siba modules/bhnd/bcma modules/bhnd/siba
Author: landonf Date: Sat Sep 24 04:08:16 2016 New Revision: 306287 URL: https://svnweb.freebsd.org/changeset/base/306287 Log: bhnd(4): Implement common API for IOST/IOCTL register access and core reset - Added bhnd(4) bus APIs for per-core ioctl/iost register access. - Updated reset/suspend bhnd(4) APIs for compatibility with ioctl/iost changes. - Implemented core reset/suspend support for both bcma(4) and siba(4). - Implemented explicit release of all outstanding PMU requests at the bus level when putting a core into reset. Approved by:adrian (mentor, implicit) Differential Revision: https://reviews.freebsd.org/D8009 Deleted: head/sys/dev/bhnd/bhnd_core.h Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_dmp.h head/sys/dev/bhnd/bcma/bcma_subr.c head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c head/sys/dev/bhnd/cores/pmu/bhnd_pmu.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_private.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c head/sys/dev/bhnd/cores/usb/bhnd_usb.c head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibareg.h head/sys/dev/bhnd/siba/sibavar.h head/sys/modules/bhnd/bcma/Makefile head/sys/modules/bhnd/siba/Makefile Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Sat Sep 24 01:21:42 2016 (r306286) +++ head/sys/dev/bhnd/bcma/bcma.c Sat Sep 24 04:08:16 2016 (r306287) @@ -39,14 +39,14 @@ __FBSDID("$FreeBSD$"); #include -#include "bcmavar.h" +#include #include "bcma_dmp.h" #include "bcma_eromreg.h" #include "bcma_eromvar.h" -#include +#include "bcmavar.h" /* RID used when allocating EROM table */ #defineBCMA_EROM_RID 0 @@ -91,6 +91,44 @@ bcma_detach(device_t dev) return (bhnd_generic_detach(dev)); } +static device_t +bcma_add_child(device_t dev, u_int order, const char *name, int unit) +{ + struct bcma_devinfo *dinfo; + device_t child; + + child = device_add_child_ordered(dev, order, name, unit); + if (child == NULL) + return (NULL); + + if ((dinfo = bcma_alloc_dinfo(dev)) == NULL) { + device_delete_child(dev, child); + return (NULL); + } + + device_set_ivars(child, dinfo); + + return (child); +} + +static void +bcma_child_deleted(device_t dev, device_t child) +{ + struct bhnd_softc *sc; + struct bcma_devinfo *dinfo; + + sc = device_get_softc(dev); + + /* Call required bhnd(4) implementation */ + bhnd_generic_child_deleted(dev, child); + + /* Free bcma device info */ + if ((dinfo = device_get_ivars(child)) != NULL) + bcma_free_dinfo(dev, dinfo); + + device_set_ivars(child, NULL); +} + static int bcma_read_ivar(device_t dev, device_t child, int index, uintptr_t *result) { @@ -125,6 +163,9 @@ bcma_read_ivar(device_t dev, device_t ch case BHND_IVAR_CORE_UNIT: *result = ci->unit; return (0); + case BHND_IVAR_PMU_INFO: + *result = (uintptr_t) dinfo->pmu_info; + return (0); default: return (ENOENT); } @@ -133,6 +174,10 @@ bcma_read_ivar(device_t dev, device_t ch static int bcma_write_ivar(device_t dev, device_t child, int index, uintptr_t value) { + struct bcma_devinfo *dinfo; + + dinfo = device_get_ivars(child); + switch (index) { case BHND_IVAR_VENDOR: case BHND_IVAR_DEVICE: @@ -143,6 +188,9 @@ bcma_write_ivar(device_t dev, device_t c case BHND_IVAR_CORE_INDEX: case BHND_IVAR_CORE_UNIT: return (EINVAL); + case BHND_IVAR_PMU_INFO: + dinfo->pmu_info = (struct bhnd_core_pmu_info *) value; + return (0); default: return (ENOENT); } @@ -156,136 +204,262 @@ bcma_get_resource_list(device_t dev, dev } static int -bcma_reset_core(device_t dev, device_t child, uint16_t flags) +bcma_read_iost(device_t dev, device_t child, uint16_t *iost) { - struct bcma_devinfo *dinfo; + uint32_tvalue; + int error; + + if ((error = bhnd_read_config(child, BCMA_DMP_IOSTATUS, , 4))) + return (error); + + /* Return only the bottom 16 bits */ + *iost = (value & BCMA_DMP_IOST_MASK); + return (0); +} + +static int +bcma_read_ioctl(device_t dev, device_t child, uint16_t *ioctl) +{ + uint32_tvalue; + int error; + + if ((error = bhnd_read_config(child, BCMA_DMP_IOCTRL, , 4))) + return (error); + + /* Return only the bottom 16 bits */ + *ioctl =
svn commit: r305953 - in head/sys: dev/bhnd mips/broadcom
Author: landonf Date: Sun Sep 18 21:28:09 2016 New Revision: 305953 URL: https://svnweb.freebsd.org/changeset/base/305953 Log: Split bcm_mipscore.c into bcm_bmips (BMIPS32/BMIPS3300) and bcm_mips74k drivers. The BMIPS32/BMIPS3300 cores use a register layout distinct from the MIPS74K core, and are only found on siba(4) devices. Reviewed by: mizhka Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7791 Added: head/sys/mips/broadcom/bcm_bmips.c (contents, props changed) head/sys/mips/broadcom/bcm_bmips_exts.h - copied, changed from r305952, head/sys/mips/broadcom/bcm_mips_exts.h head/sys/mips/broadcom/bcm_bmipsreg.h (contents, props changed) head/sys/mips/broadcom/bcm_mips74k.c - copied, changed from r305952, head/sys/mips/broadcom/bcm_mipscore.c head/sys/mips/broadcom/bcm_mips74kreg.h - copied, changed from r305952, head/sys/mips/broadcom/bcm_mipscore.h Deleted: head/sys/mips/broadcom/bcm_mips_exts.h head/sys/mips/broadcom/bcm_mipscore.c head/sys/mips/broadcom/bcm_mipscore.h Modified: head/sys/dev/bhnd/bhnd_subr.c head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/files.broadcom Modified: head/sys/dev/bhnd/bhnd_subr.c == --- head/sys/dev/bhnd/bhnd_subr.c Sun Sep 18 20:47:55 2016 (r305952) +++ head/sys/dev/bhnd/bhnd_subr.c Sun Sep 18 21:28:09 2016 (r305953) @@ -68,7 +68,7 @@ static const struct bhnd_core_desc { BHND_CDESC(BCM, SRAM, RAM,"SRAM"), BHND_CDESC(BCM, SDRAM, RAM,"SDRAM"), BHND_CDESC(BCM, PCI,PCI,"PCI Bridge"), - BHND_CDESC(BCM, MIPS, CPU,"MIPS Core"), + BHND_CDESC(BCM, MIPS, CPU,"BMIPS CPU"), BHND_CDESC(BCM, ENET, ENET_MAC, "Fast Ethernet MAC"), BHND_CDESC(BCM, CODEC, OTHER, "V.90 Modem Codec"), BHND_CDESC(BCM, USB,USB_DUAL, "USB 1.1 Device/Host Controller"), @@ -85,7 +85,7 @@ static const struct bhnd_core_desc { BHND_CDESC(BCM, APHY, WLAN_PHY, "802.11a PHY"), BHND_CDESC(BCM, BPHY, WLAN_PHY, "802.11b PHY"), BHND_CDESC(BCM, GPHY, WLAN_PHY, "802.11g PHY"), - BHND_CDESC(BCM, MIPS33, CPU,"MIPS3302 Core"), + BHND_CDESC(BCM, MIPS33, CPU,"BMIPS33 CPU"), BHND_CDESC(BCM, USB11H, USB_HOST, "USB 1.1 Host Controller"), BHND_CDESC(BCM, USB11D, USB_DEV,"USB 1.1 Device Controller"), BHND_CDESC(BCM, USB20H, USB_HOST, "USB 2.0 Host Controller"), Added: head/sys/mips/broadcom/bcm_bmips.c == --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sys/mips/broadcom/bcm_bmips.c Sun Sep 18 21:28:09 2016 (r305953) @@ -0,0 +1,123 @@ +/*- + * Copyright (c) 2016 Landon Fuller+ * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer, + *without modification. + * 2. Redistributions in binary form must reproduce at minimum a disclaimer + *similar to the "NO WARRANTY" disclaimer below ("Disclaimer") and any + *redistribution must be conditioned upon including a substantially + *similar Disclaimer requirement for further binary redistribution. + * + * NO WARRANTY + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF NONINFRINGEMENT, MERCHANTIBILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, + * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER + * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF + * THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include "bcm_bmipsreg.h" + +/* + * BMIPS32 and BMIPS3300 core driver. + * + * These cores are only found on siba(4) chipsets, allowing + * us to assume the availability of siba interrupt registers. + */ + +static const struct
svn commit: r305907 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Sat Sep 17 22:18:32 2016 New Revision: 305907 URL: https://svnweb.freebsd.org/changeset/base/305907 Log: bhnd(4): Fix regression in BCM4331 SPROM pin reference counting. In r304870, refcount handling was lifted out into a common OTP/SPROM code path, but the refcount assertions in chipc_disable_sprom_pins() were not updated accordingly; this triggered an assertion on BCM4331 devices when releasing a SPROM pin reservation. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/cores/chipc/chipc.c Modified: head/sys/dev/bhnd/cores/chipc/chipc.c == --- head/sys/dev/bhnd/cores/chipc/chipc.c Sat Sep 17 22:13:03 2016 (r305906) +++ head/sys/dev/bhnd/cores/chipc/chipc.c Sat Sep 17 22:18:32 2016 (r305907) @@ -1261,8 +1261,7 @@ chipc_disable_sprom_pins(struct chipc_so return; CHIPC_LOCK_ASSERT(sc, MA_OWNED); - KASSERT(sc->sprom_refcnt != 0, ("sprom pins already disabled")); - KASSERT(sc->sprom_refcnt == 1, ("sprom pins in use")); + KASSERT(sc->sprom_refcnt == 0, ("sprom pins in use")); cctrl = bhnd_bus_read_4(sc->core, CHIPC_CHIPCTRL); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r305444 - in head/sys/dev: bhnd bhnd/bcma bhnd/bhndb bhnd/cores/pmu bhnd/siba bwn
Author: landonf Date: Mon Sep 5 22:11:46 2016 New Revision: 305444 URL: https://svnweb.freebsd.org/changeset/base/305444 Log: bhnd(4): Implement backplane interrupt handling. This adds bhnd(4) bus-level support for querying backplane interrupt vector routing, and delegating machine/bridge-specific interrupt handling to the concrete bhnd(4) driver implementation. On bhndb(4) bridged PCI devices, we provide the PCI/MSI interrupt directly to attached cores. On MIPS devices, we report a backplane interrupt count of 0, effectively disabling the bus-level interrupt assignment. This allows mips/broadcom to temporarily continue using hard-coded MIPS IRQs until bhnd_mips PIC support is implemented. Reviewed by: mizhka Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_dmp.h head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_nexus.c head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_pcivar.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_bhndb.c head/sys/dev/bhnd/siba/sibareg.h head/sys/dev/bhnd/siba/sibavar.h head/sys/dev/bwn/bwn_mac.c Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Mon Sep 5 21:55:27 2016 (r305443) +++ head/sys/dev/bhnd/bcma/bcma.c Mon Sep 5 22:11:46 2016 (r305444) @@ -41,8 +41,11 @@ __FBSDID("$FreeBSD$"); #include "bcmavar.h" +#include "bcma_dmp.h" + #include "bcma_eromreg.h" #include "bcma_eromvar.h" + #include /* RID used when allocating EROM table */ @@ -434,6 +437,70 @@ bcma_get_region_addr(device_t dev, devic return (ENOENT); } +/** + * Default bcma(4) bus driver implementation of BHND_BUS_GET_INTR_COUNT(). + * + * This implementation consults @p child's agent register block, + * returning the number of interrupt output lines routed to @p child. + */ +int +bcma_get_intr_count(device_t dev, device_t child) +{ + struct bcma_devinfo *dinfo; + uint32_t dmpcfg, oobw; + + dinfo = device_get_ivars(child); + + /* Agent block must be mapped */ + if (dinfo->res_agent == NULL) + return (0); + + /* Agent must support OOB */ + dmpcfg = bhnd_bus_read_4(dinfo->res_agent, BCMA_DMP_CONFIG); + if (!BCMA_DMP_GET_FLAG(dmpcfg, BCMA_DMP_CFG_OOB)) + return (0); + + /* Return OOB width as interrupt count */ + oobw = bhnd_bus_read_4(dinfo->res_agent, + BCMA_DMP_OOB_OUTWIDTH(BCMA_OOB_BANK_INTR)); + if (oobw > BCMA_OOB_NUM_SEL) { + device_printf(dev, "ignoring invalid OOBOUTWIDTH for core %u: " + "%#x\n", BCMA_DINFO_COREIDX(dinfo), oobw); + return (0); + } + + return (oobw); +} + +/** + * Default bcma(4) bus driver implementation of BHND_BUS_GET_CORE_IVEC(). + * + * This implementation consults @p child's agent register block, + * returning the interrupt output line routed to @p child, at OOB selector + * @p intr. + */ +int +bcma_get_core_ivec(device_t dev, device_t child, u_int intr, uint32_t *ivec) +{ + struct bcma_devinfo *dinfo; + uint32_t oobsel; + + dinfo = device_get_ivars(child); + + /* Interrupt ID must be valid. */ + if (intr >= bcma_get_intr_count(dev, child)) + return (ENXIO); + + /* Fetch OOBSEL busline value */ + KASSERT(dinfo->res_agent != NULL, ("missing agent registers")); + oobsel = bhnd_bus_read_4(dinfo->res_agent, BCMA_DMP_OOBSELOUT( + BCMA_OOB_BANK_INTR, intr)); + *ivec = (oobsel >> BCMA_DMP_OOBSEL_SHIFT(intr)) & + BCMA_DMP_OOBSEL_BUSLINE_MASK; + + return (0); +} + static struct bhnd_devinfo * bcma_alloc_bhnd_dinfo(device_t dev) { @@ -475,6 +542,8 @@ bcma_add_children(device_t bus) /* Add all cores. */ bcma_erom = (struct bcma_erom *)erom; while ((error = bcma_erom_next_corecfg(bcma_erom, )) == 0) { + int nintr; + /* Add the child device */ child = BUS_ADD_CHILD(bus, 0, NULL, -1); if (child == NULL) { @@ -494,6 +563,17 @@ bcma_add_children(device_t bus) if ((error = bcma_dinfo_alloc_agent(bus, child, dinfo))) goto cleanup; + /* Assign interrupts */ + nintr = bhnd_get_intr_count(child); + for (int rid = 0; rid < nintr; rid++) { + error = BHND_BUS_ASSIGN_INTR(bus, child, rid); + if (error) { + device_printf(bus, "failed to assign interrupt " +
svn commit: r305443 - head/sys/dev/bwn
Author: landonf Date: Mon Sep 5 21:55:27 2016 New Revision: 305443 URL: https://svnweb.freebsd.org/changeset/base/305443 Log: bwn(4): ignore BCM4321's unpopulated USB11 host controller core. Broadcom Intensi-fi chipsets provided a common set of IP cores; on PCI/PCIe devices, the USB11 host controller is left floating. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bwn/if_bwn_pci.c head/sys/dev/bwn/if_bwn_pcivar.h Modified: head/sys/dev/bwn/if_bwn_pci.c == --- head/sys/dev/bwn/if_bwn_pci.c Mon Sep 5 21:48:16 2016 (r305442) +++ head/sys/dev/bwn/if_bwn_pci.c Mon Sep 5 21:55:27 2016 (r305443) @@ -84,10 +84,12 @@ static const struct bwn_pci_device siba_ BWN_BCM_DEV(BCM4318_D11A, "BCM4318 802.11a", BWN_QUIRK_UNTESTED|BWN_QUIRK_WLAN_DUALCORE), - BWN_BCM_DEV(BCM4321_D11N, "BCM4321 802.11n Dual-Band",0), - BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 2GHz", 0), + BWN_BCM_DEV(BCM4321_D11N, "BCM4321 802.11n Dual-Band", + BWN_QUIRK_USBH_UNPOPULATED), + BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 2GHz", + BWN_QUIRK_USBH_UNPOPULATED), BWN_BCM_DEV(BCM4321_D11N2G, "BCM4321 802.11n 5GHz", - BWN_QUIRK_UNTESTED), + BWN_QUIRK_UNTESTED|BWN_QUIRK_USBH_UNPOPULATED), BWN_BCM_DEV(BCM4322_D11N, "BCM4322 802.11n Dual-Band",0), BWN_BCM_DEV(BCM4322_D11N2G, "BCM4322 802.11n 2GHz", @@ -263,6 +265,9 @@ bwn_pci_is_core_disabled(device_t dev, d case BHND_DEVCLASS_ENET_MAC: case BHND_DEVCLASS_ENET_PHY: return ((sc->quirks & BWN_QUIRK_ENET_HW_UNPOPULATED) != 0); + + case BHND_DEVCLASS_USB_HOST: + return ((sc->quirks & BWN_QUIRK_USBH_UNPOPULATED) != 0); default: return (false); Modified: head/sys/dev/bwn/if_bwn_pcivar.h == --- head/sys/dev/bwn/if_bwn_pcivar.hMon Sep 5 21:48:16 2016 (r305442) +++ head/sys/dev/bwn/if_bwn_pcivar.hMon Sep 5 21:55:27 2016 (r305443) @@ -68,6 +68,13 @@ enum { * this quirk to treat these cores as unpopulated. */ BWN_QUIRK_ENET_HW_UNPOPULATED = 1<<2, + + /** +* Some PCI/PCIe "Intensi-fi" chipsets shipped with floating USB +* host controller cores; set this quirk to treat these cores as +* unpopulated. +*/ + BWN_QUIRK_USBH_UNPOPULATED = 1<<3, }; /* PCI device descriptor */ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r305442 - head/sys/dev/bhnd
Author: landonf Date: Mon Sep 5 21:48:16 2016 New Revision: 305442 URL: https://svnweb.freebsd.org/changeset/base/305442 Log: bhnd(4): Add device classes for USB host/dev/dual-mode controller cores. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhnd_types.h Modified: head/sys/dev/bhnd/bhnd_subr.c == --- head/sys/dev/bhnd/bhnd_subr.c Mon Sep 5 21:25:45 2016 (r305441) +++ head/sys/dev/bhnd/bhnd_subr.c Mon Sep 5 21:48:16 2016 (r305442) @@ -71,7 +71,7 @@ static const struct bhnd_core_desc { BHND_CDESC(BCM, MIPS, CPU,"MIPS Core"), BHND_CDESC(BCM, ENET, ENET_MAC, "Fast Ethernet MAC"), BHND_CDESC(BCM, CODEC, OTHER, "V.90 Modem Codec"), - BHND_CDESC(BCM, USB,OTHER, "USB 1.1 Device/Host Controller"), + BHND_CDESC(BCM, USB,USB_DUAL, "USB 1.1 Device/Host Controller"), BHND_CDESC(BCM, ADSL, OTHER, "ADSL Core"), BHND_CDESC(BCM, ILINE100, OTHER, "iLine100 HPNA"), BHND_CDESC(BCM, IPSEC, OTHER, "IPsec Accelerator"), @@ -86,10 +86,10 @@ static const struct bhnd_core_desc { BHND_CDESC(BCM, BPHY, WLAN_PHY, "802.11b PHY"), BHND_CDESC(BCM, GPHY, WLAN_PHY, "802.11g PHY"), BHND_CDESC(BCM, MIPS33, CPU,"MIPS3302 Core"), - BHND_CDESC(BCM, USB11H, OTHER, "USB 1.1 Host Controller"), - BHND_CDESC(BCM, USB11D, OTHER, "USB 1.1 Device Core"), - BHND_CDESC(BCM, USB20H, OTHER, "USB 2.0 Host Controller"), - BHND_CDESC(BCM, USB20D, OTHER, "USB 2.0 Device Core"), + BHND_CDESC(BCM, USB11H, USB_HOST, "USB 1.1 Host Controller"), + BHND_CDESC(BCM, USB11D, USB_DEV,"USB 1.1 Device Controller"), + BHND_CDESC(BCM, USB20H, USB_HOST, "USB 2.0 Host Controller"), + BHND_CDESC(BCM, USB20D, USB_DEV,"USB 2.0 Device Controller"), BHND_CDESC(BCM, SDIOH, OTHER, "SDIO Host Controller"), BHND_CDESC(BCM, ROBO, OTHER, "RoboSwitch"), BHND_CDESC(BCM, ATA100, OTHER, "Parallel ATA Controller"), @@ -130,8 +130,8 @@ static const struct bhnd_core_desc { BHND_CDESC(BCM, NS_PCIE2, PCIE, "PCIe Bridge (Gen2)"), BHND_CDESC(BCM, NS_DMA, OTHER, "DMA engine"), BHND_CDESC(BCM, NS_SDIO,OTHER, "SDIO 3.0 Host Controller"), - BHND_CDESC(BCM, NS_USB20H, OTHER, "USB 2.0 Host Controller"), - BHND_CDESC(BCM, NS_USB30H, OTHER, "USB 3.0 Host Controller"), + BHND_CDESC(BCM, NS_USB20H, USB_HOST, "USB 2.0 Host Controller"), + BHND_CDESC(BCM, NS_USB30H, USB_HOST, "USB 3.0 Host Controller"), BHND_CDESC(BCM, NS_A9JTAG, OTHER, "ARM Cortex A9 JTAG Interface"), BHND_CDESC(BCM, NS_DDR23_MEMC, MEMC, "Denali DDR2/DD3 Memory Controller"), BHND_CDESC(BCM, NS_ROM, NVRAM, "System ROM"), Modified: head/sys/dev/bhnd/bhnd_types.h == --- head/sys/dev/bhnd/bhnd_types.h Mon Sep 5 21:25:45 2016 (r305441) +++ head/sys/dev/bhnd/bhnd_types.h Mon Sep 5 21:48:16 2016 (r305442) @@ -57,8 +57,11 @@ typedef enum { BHND_DEVCLASS_SOC_BRIDGE, /**< interconnect host bridge */ BHND_DEVCLASS_EROM, /**< bus device enumeration ROM */ BHND_DEVCLASS_NVRAM,/**< nvram/flash controller */ - BHND_DEVCLASS_OTHER,/**< other / unknown */ + BHND_DEVCLASS_USB_HOST, /**< USB host controller */ + BHND_DEVCLASS_USB_DEV, /**< USB device controller */ + BHND_DEVCLASS_USB_DUAL, /**< USB host/device controller */ + BHND_DEVCLASS_OTHER = 1000, /**< other / unknown */ BHND_DEVCLASS_INVALID /**< no/invalid class */ } bhnd_devclass_t; ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r305375 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Sun Sep 4 01:47:21 2016 New Revision: 305375 URL: https://svnweb.freebsd.org/changeset/base/305375 Log: bhndb(4): Fix probing of bhndb-attached bhnd_nvram devices. This fixes bhnd(4) nvram handling on devices that map SPROM CSRs via PCI configuration space. The probe method previously required that a bhnd(4) device be attached to the parent bridge; now that the bhnd_nvram device is always attached first, this unnecessary sanity check always failed. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bhndb/bhndb_pci_sprom.c Modified: head/sys/dev/bhnd/bhndb/bhndb_pci_sprom.c == --- head/sys/dev/bhnd/bhndb/bhndb_pci_sprom.c Sun Sep 4 01:43:54 2016 (r305374) +++ head/sys/dev/bhnd/bhndb/bhndb_pci_sprom.c Sun Sep 4 01:47:21 2016 (r305375) @@ -60,17 +60,13 @@ __FBSDID("$FreeBSD$"); static int bhndb_pci_sprom_probe(device_t dev) { - device_tbridge, bus; + device_tbridge; int error; - /* Our parent must be a PCI-BHND bridge with an attached bhnd bus */ + /* Our parent must be a PCI-BHND bridge */ bridge = device_get_parent(dev); if (device_get_driver(bridge) != _pci_driver) return (ENXIO); - - bus = device_find_child(bridge, devclass_get_name(bhnd_devclass), 0); - if (bus == NULL) - return (ENXIO); /* Defer to default driver implementation */ if ((error = bhnd_sprom_probe(dev)) > 0) ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r305374 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Sun Sep 4 01:43:54 2016 New Revision: 305374 URL: https://svnweb.freebsd.org/changeset/base/305374 Log: bhndb(4): Skip disabled cores when performing bridge configuration probing. On BCM4321 chipsets, both PCI and PCIe cores are included, with one of the cores potentially left floating. Since the PCI core appears first in the device table, and the PCI profiles appear first in the resource configuration tables, this resulted in incorrectly matching and using the PCI/v1 resource configuration on PCIe devices, rather than the correct PCIe/v1 profile. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_if.m Modified: head/sys/dev/bhnd/bhndb/bhnd_bhndb.c == --- head/sys/dev/bhnd/bhndb/bhnd_bhndb.cSun Sep 4 01:25:46 2016 (r305373) +++ head/sys/dev/bhnd/bhndb/bhnd_bhndb.cSun Sep 4 01:43:54 2016 (r305374) @@ -66,6 +66,17 @@ bhnd_bhndb_get_attach_type(device_t dev, return (BHND_ATTACH_ADAPTER); } + +static bool +bhnd_bhndb_is_hw_disabled(device_t dev, device_t child) +{ + struct bhnd_core_info core = bhnd_get_core_info(child); + + /* Delegate to parent bridge */ + return (BHNDB_IS_CORE_DISABLED(device_get_parent(dev), dev, )); +} + + static device_t bhnd_bhndb_find_hostb_device(device_t dev) { @@ -112,6 +123,7 @@ bhnd_bhndb_pwrctl_ungate_clock(device_t static device_method_t bhnd_bhndb_methods[] = { /* BHND interface */ DEVMETHOD(bhnd_bus_get_attach_type, bhnd_bhndb_get_attach_type), + DEVMETHOD(bhnd_bus_is_hw_disabled, bhnd_bhndb_is_hw_disabled), DEVMETHOD(bhnd_bus_find_hostb_device, bhnd_bhndb_find_hostb_device), DEVMETHOD(bhnd_bus_read_board_info, bhnd_bhndb_read_board_info), Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Sun Sep 4 01:25:46 2016 (r305373) +++ head/sys/dev/bhnd/bhndb/bhndb.c Sun Sep 4 01:43:54 2016 (r305374) @@ -85,8 +85,9 @@ static int bhndb_init_full_config(str static struct bhnd_core_info *bhndb_get_bridge_core(struct bhndb_softc *sc); -static bool bhndb_hw_matches(struct bhnd_core_info *cores, -u_int ncores, const struct bhndb_hw *hw); +static bool bhndb_hw_matches(struct bhndb_softc *sc, +struct bhnd_core_info *cores, u_int ncores, +const struct bhndb_hw *hw); static int bhndb_init_region_cfg(struct bhndb_softc *sc, bhnd_erom_t *erom, @@ -212,14 +213,15 @@ bhndb_get_bridge_core(struct bhndb_softc /** * Return true if @p cores matches the @p hw specification. - * + * + * @param sc BHNDB device state. * @param cores A device table to match against. * @param ncores The number of cores in @p cores. * @param hw The hardware description to be matched against. */ static bool -bhndb_hw_matches(struct bhnd_core_info *cores, u_int ncores, -const struct bhndb_hw *hw) +bhndb_hw_matches(struct bhndb_softc *sc, struct bhnd_core_info *cores, +u_int ncores, const struct bhndb_hw *hw) { for (u_int i = 0; i < hw->num_hw_reqs; i++) { const struct bhnd_core_match*match; @@ -229,7 +231,12 @@ bhndb_hw_matches(struct bhnd_core_info * found = false; for (u_int d = 0; d < ncores; d++) { - if (!bhnd_core_matches([d], match)) + struct bhnd_core_info *core = [d]; + + if (BHNDB_IS_CORE_DISABLED(sc->dev, sc->bus_dev, core)) + continue; + + if (!bhnd_core_matches(core, match)) continue; found = true; @@ -353,7 +360,7 @@ bhndb_init_region_cfg(struct bhndb_softc */ /* ... do not require bridge resources */ - if (BHNDB_BUS_IS_CORE_DISABLED(sc->parent_dev, sc->dev, core)) + if (BHNDB_IS_CORE_DISABLED(sc->dev, sc->bus_dev, core)) continue; /* ... do not have a priority table entry */ @@ -475,7 +482,7 @@ bhndb_find_hwspec(struct bhndb_softc *sc /* Search for the first matching hardware config. */ hw_table = BHNDB_BUS_GET_HARDWARE_TABLE(sc->parent_dev, sc->dev); for (next = hw_table; next->hw_reqs != NULL; next++) { - if (!bhndb_hw_matches(cores, ncores, next)) + if (!bhndb_hw_matches(sc, cores, ncores, next)) continue; /*
svn commit: r305373 - head/sys/dev/bhnd/siba
Author: landonf Date: Sun Sep 4 01:25:46 2016 New Revision: 305373 URL: https://svnweb.freebsd.org/changeset/base/305373 Log: siba(4): Add missing bhnd_device/bhnd_device_quirk table terminator entries. This resulted in an over-read on siba chipsets that failed to match the existing entries. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/siba/siba_bhndb.c Modified: head/sys/dev/bhnd/siba/siba_bhndb.c == --- head/sys/dev/bhnd/siba/siba_bhndb.c Sun Sep 4 01:17:16 2016 (r305372) +++ head/sys/dev/bhnd/siba/siba_bhndb.c Sun Sep 4 01:25:46 2016 (r305373) @@ -71,10 +71,12 @@ enum { static struct bhnd_device_quirk bridge_quirks[] = { BHND_CHIP_QUIRK(4311, HWREV_EQ(2), SIBA_QUIRK_PCIE_D11_SB_TIMEOUT), BHND_CHIP_QUIRK(4312, HWREV_EQ(0), SIBA_QUIRK_PCIE_D11_SB_TIMEOUT), + BHND_DEVICE_QUIRK_END }; static struct bhnd_device bridge_devs[] = { BHND_DEVICE(BCM, PCI, NULL, bridge_quirks), + BHND_DEVICE_END }; static int ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r305372 - in head/sys: dev/bhnd/pmu dev/bhnd/soc mips/sentry5 modules/bhnd/nvram
Author: landonf Date: Sun Sep 4 01:17:16 2016 New Revision: 305372 URL: https://svnweb.freebsd.org/changeset/base/305372 Log: Remove empty directories left by r299241, r302190, r304870, and r301410 Approved by: adrian (mentor, implicit) Deleted: head/sys/dev/bhnd/pmu/ head/sys/dev/bhnd/soc/ head/sys/mips/sentry5/ head/sys/modules/bhnd/nvram/ ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r305371 - in head/sys: dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/siba dev/bwn mips/broadcom modules/bhnd/bhndb
Author: landonf Date: Sun Sep 4 00:58:19 2016 New Revision: 305371 URL: https://svnweb.freebsd.org/changeset/base/305371 Log: Migrate bhndb(4) to the new bhnd_erom API. Adds support for probing and initializing bhndb(4) bridge state using the bhnd_erom API, ensuring that full bridge configuration is available *prior* to actually attaching and enumerating the bhnd(4) child device, allowing us to safely allocate bus-level agent/device resources during bhnd(4) bus enumeration. - Add a bhnd_erom_probe() method usable by bhndb(4). This is an analogue to the existing bhnd_erom_probe_static() method, and allows the bhndb bridge to discover the best available erom parser class prior to newbus probing of its children. - Add support for supplying identification hints when probing erom devices. This is required on early EXTIF-only chipsets, where chip identification registers are not available. - Migrate bhndb over to the new bhnd_erom API, using bhnd_core_info records rather than bridged bhnd(4) device_t references to determine the bridged chipsets' capability/bridge configuration. - The bhndb parent (e.g. if_bwn) is now required to supply a hardware priority table to the bridge. The default table is currently sufficient for our supported devices. - Drop the two-pass attach approach we used for compatibility with bhndb(4) in the bhnd(4) bus drivers, and instead perform bus enumeration immediately, and allocate bridged per-child bus-level resources during that enumeration. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7768 Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_bhndb.c head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/bcma/bcma_eromvar.h head/sys/dev/bhnd/bcma/bcma_nexus.c head/sys/dev/bhnd/bcma/bcma_subr.c head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_erom.c head/sys/dev/bhnd/bhnd_erom.h head/sys/dev/bhnd/bhnd_erom_if.m head/sys/dev/bhnd/bhnd_match.h head/sys/dev/bhnd/bhnd_nexus.c head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_bus_if.m head/sys/dev/bhnd/bhndb/bhndb_if.m head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndb/bhndb_private.h head/sys/dev/bhnd/bhndb/bhndb_subr.c head/sys/dev/bhnd/bhndb/bhndbvar.h head/sys/dev/bhnd/cores/chipc/chipcreg.h head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_bhndb.c head/sys/dev/bhnd/siba/siba_erom.c head/sys/dev/bhnd/siba/siba_nexus.c head/sys/dev/bhnd/siba/sibavar.h head/sys/dev/bwn/if_bwn_pci.c head/sys/dev/bwn/if_bwn_pcivar.h head/sys/mips/broadcom/bcm_machdep.c head/sys/modules/bhnd/bhndb/Makefile Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Sun Sep 4 00:35:55 2016 (r305370) +++ head/sys/dev/bhnd/bcma/bcma.c Sun Sep 4 00:58:19 2016 (r305371) @@ -48,6 +48,12 @@ __FBSDID("$FreeBSD$"); /* RID used when allocating EROM table */ #defineBCMA_EROM_RID 0 +static bhnd_erom_class_t * +bcma_get_erom_class(driver_t *driver) +{ + return (_erom_parser); +} + int bcma_probe(device_t dev) { @@ -55,70 +61,25 @@ bcma_probe(device_t dev) return (BUS_PROBE_DEFAULT); } +/** + * Default bcma(4) bus driver implementation of DEVICE_ATTACH(). + * + * This implementation initializes internal bcma(4) state and performs + * bus enumeration, and must be called by subclassing drivers in + * DEVICE_ATTACH() before any other bus methods. + */ int bcma_attach(device_t dev) { - struct bcma_devinfo *dinfo; - device_t*devs, child; - int ndevs; - int error; + int error; - - if ((error = device_get_children(dev, , ))) + /* Enumerate children */ + if ((error = bcma_add_children(dev))) { + device_delete_children(dev); return (error); - - /* -* Map our children's agent register block. -*/ - for (int i = 0; i < ndevs; i++) { - bhnd_addr_t addr; - bhnd_size_t size; - rman_res_t r_start, r_count, r_end; - - child = devs[i]; - dinfo = device_get_ivars(child); - - KASSERT(!device_is_suspended(child), - ("bcma(4) stateful suspend handling requires that devices " - "not be suspended before bcma_attach()")); - - /* Verify that the agent register block exists and is -* mappable */ - if (bhnd_get_port_rid(child, BHND_PORT_AGENT, 0, 0) == -1) - continue; - - /* Fetch the
svn commit: r305366 - in head/sys: conf dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/siba mips/broadcom modules/bhnd modules/bhnd/bcma modules/bhnd/bcma_bhndb modules/bhnd/siba modules/bhnd/siba_...
Author: landonf Date: Sat Sep 3 23:57:17 2016 New Revision: 305366 URL: https://svnweb.freebsd.org/changeset/base/305366 Log: Implement a generic bhnd(4) device enumeration table API. This defines a new bhnd_erom_if API, providing a common interface to device enumeration on siba(4) and bcma(4) devices, for use both in the bhndb bridge and SoC early boot contexts, and migrates mips/broadcom over to the new API. This also replaces the previous adhoc device enumeration support implemented for mips/broadcom. Migration of bhndb to the new API will be implemented in a follow-up commit. - Defined new bhnd_erom_if interface for bhnd(4) device enumeration, along with bcma(4) and siba(4)-specific implementations. - Fixed a minor bug in bhndb that logged an error when we attempted to map the full siba(4) bus space (1800-17FF) in the siba EROM parser. - Reverted use of the resource's start address as the ChipCommon enum_addr in bhnd_read_chipid(). When called from bhndb, this address is found within the host address space, resulting in an invalid bridged enum_addr. - Added support for falling back on standard bus_activate_resource() in bhnd_bus_generic_activate_resource(), enabling allocation of the bhnd_erom's bhnd_resource directly from a nexus-attached bhnd(4) device. - Removed BHND_BUS_GET_CORE_TABLE(); it has been replaced by the erom API. - Added support for statically initializing bhnd_erom instances, for use prior to malloc availability. The statically allocated buffer size is verified both at runtime, and via a compile-time assertion (see BHND_EROM_STATIC_BYTES). - bhnd_erom classes are registered within a module via a linker set, allowing mips/broadcom to probe available EROM parser instances without creating a strong reference to bcma/siba-specific symbols. - Migrated mips/broadcom to bhnd_erom_if, replacing the previous MIPS-specific device enumeration implementation. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7748 Added: head/sys/dev/bhnd/bhnd_erom.c (contents, props changed) head/sys/dev/bhnd/bhnd_erom.h (contents, props changed) head/sys/dev/bhnd/bhnd_erom_if.m (contents, props changed) head/sys/dev/bhnd/bhnd_erom_types.h (contents, props changed) head/sys/dev/bhnd/siba/siba_erom.c (contents, props changed) Deleted: head/sys/mips/broadcom/bcm_bcma.c head/sys/mips/broadcom/bcm_siba.c Modified: head/sys/conf/files head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma.h head/sys/dev/bhnd/bcma/bcma_bhndb.c head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/bcma/bcma_eromvar.h head/sys/dev/bhnd/bcma/bcma_nexus.c head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba.h head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibareg.h head/sys/dev/bhnd/siba/sibavar.h head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_machdep.h head/sys/mips/broadcom/bcm_pmu.c head/sys/mips/broadcom/files.broadcom head/sys/modules/bhnd/Makefile head/sys/modules/bhnd/bcma/Makefile head/sys/modules/bhnd/bcma_bhndb/Makefile head/sys/modules/bhnd/siba/Makefile head/sys/modules/bhnd/siba_bhndb/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Sat Sep 3 23:04:56 2016(r305365) +++ head/sys/conf/files Sat Sep 3 23:57:17 2016(r305366) @@ -1140,6 +1140,8 @@ dev/bce/if_bce.c optional bce dev/bfe/if_bfe.c optional bfe dev/bge/if_bge.c optional bge dev/bhnd/bhnd.coptional bhnd +dev/bhnd/bhnd_erom.c optional bhnd +dev/bhnd/bhnd_erom_if.moptional bhnd dev/bhnd/bhnd_nexus.c optional bhnd siba_nexus | \ bhnd bcma_nexus dev/bhnd/bhnd_subr.c optional bhnd @@ -1188,6 +1190,7 @@ dev/bhnd/nvram/bhnd_sprom.c optional bh dev/bhnd/nvram/bhnd_sprom_parser.c optional bhnd dev/bhnd/siba/siba.c optional siba bhnd dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb +dev/bhnd/siba/siba_erom.c optional siba bhnd dev/bhnd/siba/siba_nexus.c optional siba_nexus siba bhnd dev/bhnd/siba/siba_subr.c optional siba bhnd # Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Sat Sep 3 23:04:56 2016 (r305365) +++ head/sys/dev/bhnd/bcma/bcma.c Sat Sep 3 23:57:17 2016 (r305366) @@ -45,6 +45,9 @@ __FBSDID("$FreeBSD$");
svn commit: r304967 - in head/sys/dev/bhnd: . siba
Author: landonf Date: Sun Aug 28 20:39:53 2016 New Revision: 304967 URL: https://svnweb.freebsd.org/changeset/base/304967 Log: bhnd(4): Apply the siba chipid ncore fixup in bhnd_read_chipid(), ensuring that bhndb et al are always operating on a valid core count. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/siba/siba.c Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hSun Aug 28 20:39:33 2016(r304966) +++ head/sys/dev/bhnd/bhnd.hSun Aug 28 20:39:53 2016(r304967) @@ -317,6 +317,10 @@ void bhnd_release_resources(device_t struct bhnd_chipid bhnd_parse_chipid(uint32_t idreg, bhnd_addr_t enum_addr); +int bhnd_chipid_fixed_ncores( +const struct bhnd_chipid *cid, +uint16_t chipc_hwrev, uint8_t *ncores); + int bhnd_read_chipid(device_t dev, struct resource_spec *rs, bus_size_t chipc_offset, Modified: head/sys/dev/bhnd/bhnd_subr.c == --- head/sys/dev/bhnd/bhnd_subr.c Sun Aug 28 20:39:33 2016 (r304966) +++ head/sys/dev/bhnd/bhnd_subr.c Sun Aug 28 20:39:53 2016 (r304967) @@ -38,6 +38,8 @@ __FBSDID("$FreeBSD$"); #include #include +#include + #include #include "nvram/bhnd_nvram.h" @@ -840,6 +842,63 @@ bhnd_parse_chipid(uint32_t idreg, bhnd_a return (result); } + +/** + * Determine the correct core count for a chip identification value that + * may contain an invalid core count. + * + * On some early siba(4) devices (see CHIPC_NCORES_MIN_HWREV()), the ChipCommon + * core does not provide a valid CHIPC_ID_NUMCORE field. + * + * @param cid The chip identification to be queried. + * @param chipc_hwrev The hardware revision of the ChipCommon core from which + * @p cid was parsed. + * @param[out] ncores On success, will be set to the correct core count. + * + * @retval 0 If the core count is already correct, or was mapped to a + * a correct value. + * @retval EINVAL If the core count is incorrect, but the chip was not + * recognized. + */ +int +bhnd_chipid_fixed_ncores(const struct bhnd_chipid *cid, uint16_t chipc_hwrev, +uint8_t *ncores) +{ + /* bcma(4), and most siba(4) devices */ + if (CHIPC_NCORES_MIN_HWREV(chipc_hwrev)) { + *ncores = cid->ncores; + return (0); + } + + /* broken siba(4) chipsets */ + switch (cid->chip_id) { + case BHND_CHIPID_BCM4306: + *ncores = 6; + break; + case BHND_CHIPID_BCM4704: + *ncores = 9; + break; + case BHND_CHIPID_BCM5365: + /* + * BCM5365 does support ID_NUMCORE in at least + * some of its revisions, but for unknown + * reasons, Broadcom's drivers always exclude + * the ChipCommon revision (0x5) used by BCM5365 + * from the set of revisions supporting + * ID_NUMCORE, and instead supply a fixed value. + * + * Presumably, at least some of these devices + * shipped with a broken ID_NUMCORE value. + */ + *ncores = 7; + break; + default: + return (EINVAL); + } + + return (0); +} + /** * Allocate the resource defined by @p rs via @p dev, use it * to read the ChipCommon ID register relative to @p chipc_offset, @@ -894,6 +953,27 @@ bhnd_read_chipid(device_t dev, struct re *result = bhnd_parse_chipid(reg, enum_addr); + /* Fix the core count on early siba(4) devices */ + if (chip_type == BHND_CHIPTYPE_SIBA) { + uint32_tidh; + uint16_tchipc_hwrev; + + /* +* We need the ChipCommon revision to determine whether +* the ncore field is valid. +* +* We can safely assume the siba IDHIGH register is mapped +* within the chipc register block. +*/ + idh = bus_read_4(res, SB0_REG_ABS(SIBA_CFG0_IDHIGH)); + chipc_hwrev = SIBA_IDH_CORE_REV(idh); + + error = bhnd_chipid_fixed_ncores(result, chipc_hwrev, + >ncores); + if (error) + goto cleanup; + } + cleanup: /* Clean up */ bus_release_resource(dev, rtype, rid, res); Modified: head/sys/dev/bhnd/siba/siba.c == ---
svn commit: r304963 - in head/sys/dev/bhnd: . bcma siba
Author: landonf Date: Sun Aug 28 19:34:22 2016 New Revision: 304963 URL: https://svnweb.freebsd.org/changeset/base/304963 Log: bhnd(4): Add a bhnd bus method for fetching the device's core table. This will allow us to perform bhndb(4) bridge configuration based on the identified hardware, prior to performing full enumeration of the child bhnd bus. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/siba/siba.c Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Sun Aug 28 19:33:09 2016 (r304962) +++ head/sys/dev/bhnd/bcma/bcma.c Sun Aug 28 19:34:22 2016 (r304963) @@ -492,6 +492,42 @@ bcma_free_bhnd_dinfo(device_t dev, struc bcma_free_dinfo(dev, (struct bcma_devinfo *)dinfo); } + +static int +bcma_get_core_table(device_t dev, device_t child, struct bhnd_core_info **cores, +u_int *num_cores) +{ + struct bcma_softc *sc; + struct bcma_erom erom; + const struct bhnd_chipid*cid; + struct resource *r; + int error; + int rid; + + sc = device_get_softc(dev); + + /* Map the EROM table. */ + cid = BHND_BUS_GET_CHIPID(dev, dev); + rid = 0; + r = bus_alloc_resource(dev, SYS_RES_MEMORY, , cid->enum_addr, + cid->enum_addr + BCMA_EROM_TABLE_SIZE, BCMA_EROM_TABLE_SIZE, + RF_ACTIVE); + if (r == NULL) { + device_printf(dev, "failed to allocate EROM resource\n"); + return (ENXIO); + } + + /* Enumerate all declared cores */ + if ((error = bcma_erom_open(, r, BCMA_EROM_TABLE_START))) + goto cleanup; + + error = bcma_erom_get_core_info(, cores, num_cores); + +cleanup: + bus_release_resource(dev, SYS_RES_MEMORY, rid, r); + return (error); +} + /** * Scan a device enumeration ROM table, adding all valid discovered cores to * the bus. @@ -577,6 +613,7 @@ static device_method_t bcma_methods[] = DEVMETHOD(bhnd_bus_find_hostb_device, bcma_find_hostb_device), DEVMETHOD(bhnd_bus_alloc_devinfo, bcma_alloc_bhnd_dinfo), DEVMETHOD(bhnd_bus_free_devinfo,bcma_free_bhnd_dinfo), + DEVMETHOD(bhnd_bus_get_core_table, bcma_get_core_table), DEVMETHOD(bhnd_bus_reset_core, bcma_reset_core), DEVMETHOD(bhnd_bus_suspend_core,bcma_suspend_core), DEVMETHOD(bhnd_bus_read_config, bcma_read_config), Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hSun Aug 28 19:33:09 2016(r304962) +++ head/sys/dev/bhnd/bhnd.hSun Aug 28 19:34:22 2016(r304963) @@ -425,6 +425,32 @@ bhnd_get_chipid(device_t dev) { }; /** + * Get a list of all cores discoverable on the bhnd bus. + * + * Enumerates all cores discoverable on @p dev, returning the list in + * @p cores and the count in @p num_cores. + * + * The memory allocated for the list should be freed using + * `free(*cores, M_BHND)`. @p cores and @p num_cores are not changed + * when an error is returned. + * + * @param dev A bhnd bus child device. + * @param[out] cores The table of core descriptors. + * @param[out] num_cores The number of core descriptors in @p cores. + * + * @retval 0 success + * @retval non-zeroif an error occurs enumerating @p dev, a regular UNIX + * error code should be returned. + */ +static inline int +bhnd_get_core_table(device_t dev, struct bhnd_core_info **cores, +u_int *num_cores) +{ + return (BHND_BUS_GET_CORE_TABLE(device_get_parent(dev), dev, cores, + num_cores)); +} + +/** * If supported by the chipset, return the clock source for the given clock. * * This function is only supported on early PWRCTL-equipped chipsets Modified: head/sys/dev/bhnd/bhnd_bus_if.m == --- head/sys/dev/bhnd/bhnd_bus_if.m Sun Aug 28 19:33:09 2016 (r304962) +++ head/sys/dev/bhnd/bhnd_bus_if.m Sun Aug 28 19:34:22 2016 (r304963) @@ -56,6 +56,13 @@ CODE { panic("bhnd_bus_get_chipid unimplemented"); } + static int + bhnd_bus_null_get_core_table(device_t dev, device_t child, + struct bhnd_core_info **cores, u_int *num_cores) + { + panic("bhnd_bus_get_core_table unimplemented"); + } + static bhnd_attach_type bhnd_bus_null_get_attach_type(device_t dev, device_t child) { @@ -271,6 +278,32 @@ METHOD const struct bhnd_chipid * get_ch } DEFAULT bhnd_bus_null_get_chipid;
svn commit: r304876 - in head/sys/dev/bhnd: . siba
Author: landonf Date: Sat Aug 27 00:58:21 2016 New Revision: 304876 URL: https://svnweb.freebsd.org/changeset/base/304876 Log: Implement siba(4) support for bhnd_(read|write)_config. This provides access to the siba(4) bus-mapped per-core cfg0 register block. Approved by: adrian (mentor, implicit) Modified: head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/siba/siba.c Modified: head/sys/dev/bhnd/bhnd_bus_if.m == --- head/sys/dev/bhnd/bhnd_bus_if.m Sat Aug 27 00:56:37 2016 (r304875) +++ head/sys/dev/bhnd/bhnd_bus_if.m Sat Aug 27 00:58:21 2016 (r304876) @@ -565,8 +565,9 @@ METHOD int release_ext_rsrc { * @param offset The offset to be read. * @param width The size of the access. Must be 1, 2 or 4 bytes. * - * The exact behavior of this method is bus-specific. In the case of - * bcma(4), this method provides access to the first agent port of @p child. + * The exact behavior of this method is bus-specific. On a bcma(4) bus, this + * method provides access to the first agent port of @p child; on a siba(4) bus, + * this method provides access to the core's CFG0 register block. * * @note Device drivers should only use this API for functionality * that is not available via another bhnd(4) function. Modified: head/sys/dev/bhnd/siba/siba.c == --- head/sys/dev/bhnd/siba/siba.c Sat Aug 27 00:56:37 2016 (r304875) +++ head/sys/dev/bhnd/siba/siba.c Sat Aug 27 00:58:21 2016 (r304876) @@ -263,6 +263,32 @@ siba_suspend_core(device_t dev, device_t static uint32_t siba_read_config(device_t dev, device_t child, bus_size_t offset, u_int width) { + struct siba_devinfo *dinfo; + rman_res_t r_size; + + /* Must be directly attached */ + if (device_get_parent(child) != dev) + return (UINT32_MAX); + + /* CFG0 registers must be available */ + dinfo = device_get_ivars(child); + if (dinfo->cfg[0] == NULL) + return (UINT32_MAX); + + /* Offset must fall within CFG0 */ + r_size = rman_get_size(dinfo->cfg[0]->res); + if (r_size < offset || r_size - offset < width) + return (UINT32_MAX); + + switch (width) { + case 1: + return (bhnd_bus_read_1(dinfo->cfg[0], offset)); + case 2: + return (bhnd_bus_read_2(dinfo->cfg[0], offset)); + case 4: + return (bhnd_bus_read_4(dinfo->cfg[0], offset)); + } + /* Unsuported */ return (UINT32_MAX); } @@ -271,8 +297,31 @@ static void siba_write_config(device_t dev, device_t child, bus_size_t offset, uint32_t val, u_int width) { - /* Unsuported */ - return; + struct siba_devinfo *dinfo; + rman_res_t r_size; + + /* Must be directly attached */ + if (device_get_parent(child) != dev) + return; + + /* CFG0 registers must be available */ + dinfo = device_get_ivars(child); + if (dinfo->cfg[0] == NULL) + return; + + /* Offset must fall within CFG0 */ + r_size = rman_get_size(dinfo->cfg[0]->res); + if (r_size < offset || r_size - offset < width) + return; + + switch (width) { + case 1: + bhnd_bus_write_1(dinfo->cfg[0], offset, val); + case 2: + bhnd_bus_write_2(dinfo->cfg[0], offset, val); + case 4: + bhnd_bus_write_4(dinfo->cfg[0], offset, val); + } } static u_int ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r304872 - in head/sys/dev/bhnd: . bcma siba
Author: landonf Date: Sat Aug 27 00:07:48 2016 New Revision: 304872 URL: https://svnweb.freebsd.org/changeset/base/304872 Log: bhnd(4): Include the chip model (e.g. BCM4xxx) in bhnd(4) bus's device descriptions. Reviewed by: mizhka Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7570 Modified: head/sys/dev/bhnd/bcma/bcma_bhndb.c head/sys/dev/bhnd/bcma/bcma_nexus.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/siba/siba_bhndb.c head/sys/dev/bhnd/siba/siba_nexus.c Modified: head/sys/dev/bhnd/bcma/bcma_bhndb.c == --- head/sys/dev/bhnd/bcma/bcma_bhndb.c Sat Aug 27 00:06:20 2016 (r304871) +++ head/sys/dev/bhnd/bcma/bcma_bhndb.c Sat Aug 27 00:07:48 2016 (r304872) @@ -51,15 +51,22 @@ __FBSDID("$FreeBSD$"); static int bcma_bhndb_probe(device_t dev) { - const struct bhnd_chipid *cid; + const struct bhnd_chipid*cid; + int error; + + /* Defer to default probe implementation */ + if ((error = bcma_probe(dev)) > 0) + return (error); /* Check bus type */ cid = BHNDB_GET_CHIPID(device_get_parent(dev), dev); if (cid->chip_type != BHND_CHIPTYPE_BCMA) return (ENXIO); - /* Delegate to default probe implementation */ - return (bcma_probe(dev)); + /* Set device description */ + bhnd_set_default_bus_desc(dev, cid); + + return (error); } static int Modified: head/sys/dev/bhnd/bcma/bcma_nexus.c == --- head/sys/dev/bhnd/bcma/bcma_nexus.c Sat Aug 27 00:06:20 2016 (r304871) +++ head/sys/dev/bhnd/bcma/bcma_nexus.c Sat Aug 27 00:07:48 2016 (r304872) @@ -82,6 +82,9 @@ bcma_nexus_probe(device_t dev) return (error); } + /* Set device description */ + bhnd_set_default_bus_desc(dev, >bcma_cid); + return (0); } Modified: head/sys/dev/bhnd/bhnd.h == --- head/sys/dev/bhnd/bhnd.hSat Aug 27 00:06:20 2016(r304871) +++ head/sys/dev/bhnd/bhnd.hSat Aug 27 00:07:48 2016(r304872) @@ -49,6 +49,9 @@ extern devclass_t bhnd_devclass; extern devclass_t bhnd_hostb_devclass; extern devclass_t bhnd_nvram_devclass; +#defineBHND_CHIPID_MAX_NAMELEN 32 /**< maximum buffer required for a +bhnd_format_chip_id() */ + /** * bhnd child instance variables */ @@ -254,6 +257,8 @@ bhnd_devclass_t bhnd_find_core_class( const char *bhnd_core_name(const struct bhnd_core_info *ci); bhnd_devclass_t bhnd_core_class(const struct bhnd_core_info *ci); +int bhnd_format_chip_id(char *buffer, size_t size, +uint16_t chip_id); device_tbhnd_match_child(device_t dev, const struct bhnd_core_match *desc); @@ -321,6 +326,9 @@ void bhnd_set_custom_core_desc(devic const char *name); voidbhnd_set_default_core_desc(device_t dev); +voidbhnd_set_default_bus_desc(device_t dev, +const struct bhnd_chipid *chip_id); + int bhnd_nvram_getvar_str(device_t dev, const char *name, char *buf, size_t len, size_t *rlen); Modified: head/sys/dev/bhnd/bhnd_subr.c == --- head/sys/dev/bhnd/bhnd_subr.c Sat Aug 27 00:06:20 2016 (r304871) +++ head/sys/dev/bhnd/bhnd_subr.c Sat Aug 27 00:07:48 2016 (r304872) @@ -288,6 +288,30 @@ bhnd_core_class(const struct bhnd_core_i } /** + * Write a human readable name representation of the given + * BHND_CHIPID_* constant to @p buffer. + * + * @param buffer Output buffer, or NULL to compute the required size. + * @param size Capacity of @p buffer, in bytes. + * @param chip_id Chip ID to be formatted. + * + * @return Returns the required number of bytes on success, or a negative + * integer on failure. No more than @p size-1 characters be written, with + * the @p size'th set to '\0'. + * + * @sa BHND_CHIPID_MAX_NAMELEN + */ +int +bhnd_format_chip_id(char *buffer, size_t size, uint16_t chip_id) +{ + /* All hex formatted IDs are within the range of 0x4000-0x9C3F (4-1) */ + if (chip_id >= 0x4000 && chip_id <= 0x9C3F) + return (snprintf(buffer, size, "BCM%hX", chip_id)); + else + return (snprintf(buffer, size,
svn commit: r304871 - in head/sys: dev/bhnd/cores/chipc dev/bhnd/cores/chipc/pwrctl dev/bhnd/cores/pmu mips/broadcom
Author: landonf Date: Sat Aug 27 00:06:20 2016 New Revision: 304871 URL: https://svnweb.freebsd.org/changeset/base/304871 Log: [mips/broadcom]: Replace static frequency table with generic PMU clock handling. - Extended PWRCTL/PMU APIs to support querying clock frequency during very early boot, prior to bus attach. - Implement generic PMU-based calculation of UART rclk values. - Replaced use of static frequency tables (bcm_socinfo) with runtime-determined values. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7552 Added: head/sys/mips/broadcom/bcm_pmu.c (contents, props changed) Deleted: head/sys/mips/broadcom/bcm_socinfo.c head/sys/mips/broadcom/bcm_socinfo.h Modified: head/sys/dev/bhnd/cores/chipc/chipcreg.h head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctlvar.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c head/sys/dev/bhnd/cores/pmu/bhnd_pmu_private.h head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c head/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_machdep.h head/sys/mips/broadcom/files.broadcom head/sys/mips/broadcom/uart_bus_chipc.c head/sys/mips/broadcom/uart_cpu_chipc.c Modified: head/sys/dev/bhnd/cores/chipc/chipcreg.h == --- head/sys/dev/bhnd/cores/chipc/chipcreg.hSat Aug 27 00:03:02 2016 (r304870) +++ head/sys/dev/bhnd/cores/chipc/chipcreg.hSat Aug 27 00:06:20 2016 (r304871) @@ -31,6 +31,10 @@ required during bus enumeration */ +/** Evaluates to true if the given ChipCommon core revision supports + * the CHIPC_CORECTRL register */ +#defineCHIPC_HWREV_HAS_CORECTRL(hwrev) ((hwrev) >= 1) + /** Evaluates to true if the given ChipCommon core revision provides * the core count via the chip identification register. */ #defineCHIPC_NCORES_MIN_HWREV(hwrev) ((hwrev) == 4 || (hwrev) >= 6) @@ -278,14 +282,14 @@ enum { #defineCHIPC_CST_SPROM_OTP_SEL_R23_SHIFT 6 /* PLL type */ -#defineCHIPC_PLL_NONE 0x00 -#defineCHIPC_PLL_TYPE1 0x10/* 48MHz base, 3 dividers */ -#defineCHIPC_PLL_TYPE2 0x20/* 48MHz, 4 dividers */ -#defineCHIPC_PLL_TYPE3 0x30/* 25MHz, 2 dividers */ -#defineCHIPC_PLL_TYPE4 0x08/* 48MHz, 4 dividers */ -#defineCHIPC_PLL_TYPE5 0x18/* 25MHz, 4 dividers */ -#defineCHIPC_PLL_TYPE6 0x28/* 100/200 or 120/240 only */ -#defineCHIPC_PLL_TYPE7 0x38/* 25MHz, 4 dividers */ +#defineCHIPC_PLL_NONE 0x0 +#defineCHIPC_PLL_TYPE1 0x2 /* 48MHz base, 3 dividers */ +#defineCHIPC_PLL_TYPE2 0x4 /* 48MHz, 4 dividers */ +#defineCHIPC_PLL_TYPE3 0x6 /* 25MHz, 2 dividers */ +#defineCHIPC_PLL_TYPE4 0x8 /* 48MHz, 4 dividers */ +#defineCHIPC_PLL_TYPE5 0x3 /* 25MHz, 4 dividers */ +#defineCHIPC_PLL_TYPE6 0x5 /* 100/200 or 120/240 only */ +#defineCHIPC_PLL_TYPE7 0x7 /* 25MHz, 4 dividers */ /* dynamic clock control defines */ #defineCHIPC_LPOMINFREQ25000 /* low power oscillator min */ Modified: head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c == --- head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c Sat Aug 27 00:03:02 2016(r304870) +++ head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c Sat Aug 27 00:06:20 2016(r304871) @@ -46,8 +46,6 @@ __FBSDID("$FreeBSD$"); #include "bhnd_pwrctl_private.h" static uint32_tbhnd_pwrctl_factor6(uint32_t x); -static uint32_tbhnd_pwrctl_clock_rate(uint32_t pll_type, uint32_t n, - uint32_t m); /** * Return the factor value corresponding to a given N3M clock control magic @@ -75,14 +73,122 @@ bhnd_pwrctl_factor6(uint32_t x) } /** + * Return the backplane clock's chipc 'M' register offset for a given PLL type, + * or 0 if a fixed clock speed should be used. + * + * @param cid Chip identification. + * @param pll_type PLL type (CHIPC_PLL_TYPE*) + * @param[out] fixed_hz If 0 is returned, will be set to the fixed clock + * speed for this device. + */ +bus_size_t +bhnd_pwrctl_si_clkreg_m(const struct bhnd_chipid *cid, +uint8_t pll_type, uint32_t *fixed_hz) +{ + switch (pll_type) { + case CHIPC_PLL_TYPE6: + return (CHIPC_CLKC_M3); + case CHIPC_PLL_TYPE3: + return (CHIPC_CLKC_M2); + default: + return (CHIPC_CLKC_SB); + } +} + +/** + * Calculate the backplane clock speed (in Hz) for a
svn commit: r304870 - in head/sys: conf dev/bhnd dev/bhnd/bcma dev/bhnd/bhndb dev/bhnd/cores/chipc dev/bhnd/cores/chipc/pwrctl dev/bhnd/cores/pmu dev/bhnd/nvram dev/bhnd/pmu dev/bhnd/siba mips/broa...
Author: landonf Date: Sat Aug 27 00:03:02 2016 New Revision: 304870 URL: https://svnweb.freebsd.org/changeset/base/304870 Log: bhnd(4): Initial PMU/PWRCTL power and clock management support. - Added bhnd_pmu driver implementations for PMU and PWRCTL chipsets, derived from Broadcom's ISC-licensed HND code. - Added bhnd bus-level support for routing per-core clock and resource power requests to the PMU device. - Lift ChipCommon support out into the bhnd module, dropping bhnd_chipc. Reviewed by: mizhka Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7492 Added: head/sys/dev/bhnd/cores/chipc/bhnd_pmu_chipc.c (contents, props changed) head/sys/dev/bhnd/cores/chipc/pwrctl/ head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c (contents, props changed) head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_private.h (contents, props changed) head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c (contents, props changed) head/sys/dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctlvar.h (contents, props changed) head/sys/dev/bhnd/cores/pmu/ head/sys/dev/bhnd/cores/pmu/bhnd_pmu.c (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmu.h (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmu_core.c (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmu_if.m (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmu_private.h (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmu_subr.c (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmureg.h (contents, props changed) head/sys/dev/bhnd/cores/pmu/bhnd_pmuvar.h (contents, props changed) head/sys/dev/bhnd/pmu/ Deleted: head/sys/modules/bhnd/cores/bhnd_chipc/ Modified: head/sys/conf/files head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_dmp.h head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_core.h head/sys/dev/bhnd/bhnd_ids.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhnd_types.h head/sys/dev/bhnd/bhndb/bhnd_bhndb.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndb/bhndb_pci.c head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/cores/chipc/bhnd_chipc_if.m head/sys/dev/bhnd/cores/chipc/bhnd_sprom_chipc.c head/sys/dev/bhnd/cores/chipc/chipc.c head/sys/dev/bhnd/cores/chipc/chipc.h head/sys/dev/bhnd/cores/chipc/chipc_subr.c head/sys/dev/bhnd/cores/chipc/chipcreg.h head/sys/dev/bhnd/cores/chipc/chipcvar.h head/sys/dev/bhnd/nvram/nvram_map head/sys/dev/bhnd/siba/siba.c head/sys/mips/broadcom/bcm_machdep.c head/sys/modules/bhnd/Makefile head/sys/modules/bhnd/cores/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Fri Aug 26 23:50:44 2016(r304869) +++ head/sys/conf/files Sat Aug 27 00:03:02 2016(r304870) @@ -1157,19 +1157,26 @@ dev/bhnd/bcma/bcma_bhndb.c optional bcm dev/bhnd/bcma/bcma_erom.c optional bcma bhnd dev/bhnd/bcma/bcma_nexus.c optional bcma_nexus bcma bhnd dev/bhnd/bcma/bcma_subr.c optional bcma bhnd +dev/bhnd/cores/chipc/bhnd_chipc_if.m optional bhnd +dev/bhnd/cores/chipc/bhnd_sprom_chipc.coptional bhnd +dev/bhnd/cores/chipc/bhnd_pmu_chipc.c optional bhnd dev/bhnd/cores/chipc/chipc.c optional bhnd dev/bhnd/cores/chipc/chipc_cfi.c optional bhnd cfi dev/bhnd/cores/chipc/chipc_slicer.coptional bhnd cfi | bhnd spibus dev/bhnd/cores/chipc/chipc_spi.c optional bhnd spibus dev/bhnd/cores/chipc/chipc_subr.c optional bhnd -dev/bhnd/cores/chipc/bhnd_chipc_if.m optional bhnd -dev/bhnd/cores/chipc/bhnd_sprom_chipc.coptional bhnd +dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl.c optional bhnd +dev/bhnd/cores/chipc/pwrctl/bhnd_pwrctl_subr.c optional bhnd dev/bhnd/cores/pci/bhnd_pci.c optional bhnd pci dev/bhnd/cores/pci/bhnd_pci_hostb.coptional bhndb bhnd pci dev/bhnd/cores/pci/bhnd_pcib.c optional bhnd_pcib bhnd pci dev/bhnd/cores/pcie2/bhnd_pcie2.c optional bhnd pci dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.coptional bhndb bhnd pci dev/bhnd/cores/pcie2/bhnd_pcie2b.c optional bhnd_pcie2b bhnd pci +dev/bhnd/cores/pmu/bhnd_pmu.c optional bhnd +dev/bhnd/cores/pmu/bhnd_pmu_core.c optional bhnd +dev/bhnd/cores/pmu/bhnd_pmu_if.m optional bhnd +dev/bhnd/cores/pmu/bhnd_pmu_subr.c optional bhnd dev/bhnd/nvram/bhnd_nvram.coptional bhnd dev/bhnd/nvram/bhnd_nvram_common.c optional bhnd dev/bhnd/nvram/bhnd_nvram_cfe.coptional bhnd siba_nexus cfe | \ Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Fri Aug 26 23:50:44 2016 (r304869) +++ head/sys/dev/bhnd/bcma/bcma.c Sat Aug
svn commit: r304859 - in head/sys: dev/bhnd dev/bhnd/bcma dev/bhnd/cores/chipc mips/broadcom
Author: landonf Date: Fri Aug 26 20:16:02 2016 New Revision: 304859 URL: https://svnweb.freebsd.org/changeset/base/304859 Log: [mips/broadcom] Generic platform_reset() support. This adds support for performing platform_reset() on all supported devices, using early boot enumeration of chipc capabilities and available cores. - Added Broadcom-specific MIPS CP0 register definitions used by BCM4785-specific reset handling. - Added a bcm_platform structure for tracking chipc/pmu/cfe platform data. - Extended the BCMA EROM API to support early boot lookup of core info (including port/region mappings). - Extended platform_reset() to support PMU, PMU+AOB, and non-PMU devices. Reviewed by: mizhka Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7539 Added: head/sys/mips/broadcom/bcm_bcma.c (contents, props changed) head/sys/mips/broadcom/bcm_machdep.h (contents, props changed) head/sys/mips/broadcom/bcm_mips_exts.h (contents, props changed) head/sys/mips/broadcom/bcm_siba.c (contents, props changed) Modified: head/sys/dev/bhnd/bcma/bcma_erom.c head/sys/dev/bhnd/bcma/bcma_eromvar.h head/sys/dev/bhnd/bhnd_ids.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/cores/chipc/chipcreg.h head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/broadcom/bcm_socinfo.c head/sys/mips/broadcom/bcm_socinfo.h head/sys/mips/broadcom/files.broadcom head/sys/mips/broadcom/uart_cpu_chipc.c Modified: head/sys/dev/bhnd/bcma/bcma_erom.c == --- head/sys/dev/bhnd/bcma/bcma_erom.c Fri Aug 26 20:15:22 2016 (r304858) +++ head/sys/dev/bhnd/bcma/bcma_erom.c Fri Aug 26 20:16:02 2016 (r304859) @@ -65,10 +65,18 @@ static int erom_skip_mport(struct bcma static int erom_skip_sport_region(struct bcma_erom *erom); static int erom_seek_next(struct bcma_erom *erom, uint8_t etype); +static int erom_region_to_port_type(struct bcma_erom *erom, + uint8_t region_type, bhnd_port_type *port_type); -#defineEROM_LOG(erom, fmt, ...)\ - device_printf(erom->dev, "erom[0x%llx]: " fmt, \ - (unsigned long long) (erom->offset), ##__VA_ARGS__); +#defineEROM_LOG(erom, fmt, ...)do { \ + if (erom->dev != NULL) {\ + device_printf(erom->dev, "erom[0x%llx]: " fmt, \ + (unsigned long long) (erom->offset), ##__VA_ARGS__);\ + } else {\ + printf("erom[0x%llx]: " fmt,\ + (unsigned long long) (erom->offset), ##__VA_ARGS__);\ + } \ +} while(0) /** * Open an EROM table for reading. @@ -82,11 +90,37 @@ static int erom_seek_next(struct bcma_ * @retval non-zero if the erom table could not be opened. */ int -bcma_erom_open(struct bcma_erom *erom, struct resource *r, bus_size_t offset) +bcma_erom_open(struct bcma_erom *erom, struct resource *r, +bus_size_t offset) +{ + return (bhnd_erom_bus_space_open(erom, rman_get_device(r), + rman_get_bustag(r), rman_get_bushandle(r), offset)); + + return (0); +} + +/** + * Open an EROM table for reading using the provided bus space tag and + * handle. + * + * @param[out] erom On success, will be populated with a valid EROM + * read state. + * @param dev The owning device, or NULL if none. + * @param bst EROM table bus space tag. + * @param bsh EROM table bus space handle. + * @param offset Offset of the EROM core from @p resource. + * + * @retval 0 success + * @retval non-zero if the erom table could not be opened. + */ +int +bhnd_erom_bus_space_open(struct bcma_erom *erom, device_t dev, +bus_space_tag_t bst, bus_space_handle_t bsh, bus_size_t offset) { /* Initialize the EROM reader */ - erom->dev = rman_get_device(r); - erom->r = r; + erom->dev = dev; + erom->bst = bst; + erom->bsh = bsh; erom->start = offset + BCMA_EROM_TABLE_START; erom->offset = 0; @@ -145,7 +179,8 @@ bcma_erom_peek32(struct bcma_erom *erom, return (EINVAL); } - *entry = bus_read_4(erom->r, erom->start + erom->offset); + *entry = bus_space_read_4(erom->bst, erom->bsh, + erom->start + erom->offset); return (0); } @@ -300,6 +335,20 @@ bcma_erom_reset(struct bcma_erom *erom) } /** + * Seek to the next core entry. + * + * @param erom EROM read state. + * @retval 0 success + * @retval ENOENT The end of the EROM table was reached. + * @retval non-zero Reading or parsing failed. + */ +int +bcma_erom_seek_next_core(struct bcma_erom *erom) +{ + return (erom_seek_next(erom,
Re: svn commit: r304692 - head/sys/dev/bhnd/bhndb
On Wed, Aug 24, 2016 at 6:09 AM, Shawn Webb <shawn.w...@hardenedbsd.org> wrote: On Tue, Aug 23, 2016 at 07:03:11PM +, Landon J. Fuller wrote: Author: landonf Date: Tue Aug 23 19:03:11 2016 New Revision: 304692 URL: https://svnweb.freebsd.org/changeset/base/304692 Log: bhndb(4): Fix unsigned integer underflow in dynamic register window handling. This resulted in the window target being left uninitialized when an underflow occured. Is this remotely exploitable? What are the ramifications of this bug? As Michael noted, the WIP code isn't actively used anywhere, but if it were: The target address of a PCI BAR mapping into SoC address space could be left uninitialized, leading to a bhnd(4) bus driver reading/writing to whatever SoC physical address range the window happened to be pointing to -- most likely unmapped memory. It's very unlikely that full driver attach and network interface bring-up would succeed. -landonf ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r304692 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Tue Aug 23 19:03:11 2016 New Revision: 304692 URL: https://svnweb.freebsd.org/changeset/base/304692 Log: bhndb(4): Fix unsigned integer underflow in dynamic register window handling. This resulted in the window target being left uninitialized when an underflow occured. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7617 Modified: head/sys/dev/bhnd/bhndb/bhndb.c Modified: head/sys/dev/bhnd/bhndb/bhndb.c == --- head/sys/dev/bhnd/bhndb/bhndb.c Tue Aug 23 17:42:03 2016 (r304691) +++ head/sys/dev/bhnd/bhndb/bhndb.c Tue Aug 23 19:03:11 2016 (r304692) @@ -1728,8 +1728,9 @@ bhndb_io_resource(struct bhndb_softc *sc /* Adjust the window if the I/O request won't fit in the current * target range. */ - if (addr < dwa->target || - (dwa->target + dwa->win->win_size) - addr < size) + if (addr < dwa->target || + addr > dwa->target + dwa->win->win_size || + (dwa->target + dwa->win->win_size) - addr < size) { error = bhndb_dw_set_addr(sc->dev, sc->bus_res, dwa, addr, size); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r304314 - in head/sys/mips: broadcom conf
Author: landonf Date: Wed Aug 17 20:24:14 2016 New Revision: 304314 URL: https://svnweb.freebsd.org/changeset/base/304314 Log: mips/broadcom: Implement CFE-based EARLY_PRINTF support. This adds support for EARLY_PRINTF via the CFE console; the aim is to provide a fix for the otherwise cyclic dependency between PMU discovery and console printf/DELAY: - We need to parse the bhnd(4) core table to determine the address (and type) of the PMU/PLL registers and calculate the CPU clock frequency. - The core table parsing code will emit a printf() if a parse error is hit. - Safely calling printf() without EARLY_PRINTF requires a working DELAY+cninit, which means we need the PMU. Errors in core table parsing shouldn't happen, but lack of EARLY_PRINTF makes debugging more difficult. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7498 Modified: head/sys/mips/broadcom/bcm_machdep.c head/sys/mips/conf/BCM head/sys/mips/conf/SENTRY5 Modified: head/sys/mips/broadcom/bcm_machdep.c == --- head/sys/mips/broadcom/bcm_machdep.cWed Aug 17 20:21:33 2016 (r304313) +++ head/sys/mips/broadcom/bcm_machdep.cWed Aug 17 20:24:14 2016 (r304314) @@ -198,6 +198,21 @@ platform_start(__register_t a0, __regist /* Initialize pcpu stuff */ mips_pcpu0_init(); +#ifdef CFE + /* +* Initialize CFE firmware trampolines. This must be done +* before any CFE APIs are called, including writing +* to the CFE console. +* +* CFE passes the following values in registers: +* a0: firmware handle +* a2: firmware entry point +* a3: entry point seal +*/ + if (a3 == CFE_EPTSEAL) + cfe_init(a0, a2); +#endif + #if 0 /* * Probe the Broadcom on-chip PLL clock registers @@ -234,23 +249,40 @@ platform_start(__register_t a0, __regist mips_timer_early_init(platform_counter_freq); -#ifdef CFE - /* -* Initialize CFE firmware trampolines before -* we initialize the low-level console. -* -* CFE passes the following values in registers: -* a0: firmware handle -* a2: firmware entry point -* a3: entry point seal -*/ - if (a3 == CFE_EPTSEAL) - cfe_init(a0, a2); -#endif - cninit(); mips_init(); mips_timer_init_params(platform_counter_freq, socinfo->double_count); } + +/* + * CFE-based EARLY_PRINTF support. To use, add the following to the kernel + * config: + * option EARLY_PRINTF + * option CFE + * device cfe + */ +#if defined(EARLY_PRINTF) && defined(CFE) +static void +bcm_cfe_eputc(int c) +{ + static int fd = -1; + unsigned char ch; + + ch = (unsigned char) c; + + if (fd == -1) { + if ((fd = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE)) < 0) + return; + } + + if (ch == '\n') + early_putc('\r'); + + while ((cfe_write(fd, , 1)) == 0) + continue; +} + +early_putc_t *early_putc = bcm_cfe_eputc; +#endif /* EARLY_PRINTF */ Modified: head/sys/mips/conf/BCM == --- head/sys/mips/conf/BCM Wed Aug 17 20:21:33 2016(r304313) +++ head/sys/mips/conf/BCM Wed Aug 17 20:24:14 2016(r304314) @@ -52,6 +52,7 @@ options INVARIANT_SUPPORT #options BHND_LOGLEVEL=BHND_DEBUG_LEVEL #options BUS_DEBUG #makeoptions BUS_DEBUG +optionsEARLY_PRINTF #options VERBOSE_SYSINIT #makeoptions VERBOSE_SYSINIT Modified: head/sys/mips/conf/SENTRY5 == --- head/sys/mips/conf/SENTRY5 Wed Aug 17 20:21:33 2016(r304313) +++ head/sys/mips/conf/SENTRY5 Wed Aug 17 20:24:14 2016(r304314) @@ -31,9 +31,8 @@ makeoptions TRAMPLOADADDR=0x807963c0 hints "SENTRY5.hints" include"../broadcom/std.broadcom" -# sentry5 normally ships with cfe firmware; use the console for now +# sentry5 normally ships with cfe firmware optionsCFE -optionsCFE_CONSOLE optionsALT_BREAK_TO_DEBUGGER device cfe @@ -57,6 +56,7 @@ options INVARIANT_SUPPORT #options BUS_DEBUG #makeoptions BUS_DEBUG +optionsEARLY_PRINTF device bhnd device siba ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r304243 - in head/sys: conf dev/bhnd dev/bhnd/cores/chipc dev/bhnd/nvram dev/bhnd/tools dev/bwn mips/conf modules/bhnd
Author: landonf Date: Tue Aug 16 21:32:05 2016 New Revision: 304243 URL: https://svnweb.freebsd.org/changeset/base/304243 Log: bhnd(4): Implement NVRAM support required for PMU bring-up. - Added a generic bhnd_nvram_parser API, with support for the TLV format used on WGT634U devices, the standard BCM NVRAM format used on most modern devices, and the "board text file" format used on some hardware to supply external NVRAM data at runtime (e.g. via an EFI variable). - Extended the bhnd_bus_if and bhnd_nvram_if interfaces to support both string-based and primitive data type variable access, required for common behavior across both SPROM and NVRAM data sources. - Extended the existing SPROM implementation to support the new string-based NVRAM APIs. - Added an abstract bhnd_nvram driver, implementing the bhnd_nvram_if atop the bhnd_nvram_parser API. - Added a CFE-based bhnd_nvram driver to provide read-only access to NVRAM data on MIPS SoCs, pending implementation of a flash-aware bhnd_nvram driver. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7489 Added: head/sys/dev/bhnd/nvram/bhnd_nvram.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_cfe.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_common.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_common.h - copied, changed from r304242, head/sys/dev/bhnd/nvram/nvramvar.h head/sys/dev/bhnd/nvram/bhnd_nvram_parser.c (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_parser.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_parserreg.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvram_parservar.h (contents, props changed) head/sys/dev/bhnd/nvram/bhnd_nvramvar.h - copied, changed from r304242, head/sys/dev/bhnd/nvram/bhnd_spromreg.h head/sys/dev/bhnd/nvram/bhnd_sprom_parser.c - copied, changed from r304242, head/sys/dev/bhnd/nvram/bhnd_sprom_subr.c head/sys/dev/bhnd/nvram/bhnd_sprom_parser.h - copied, changed from r304242, head/sys/dev/bhnd/nvram/bhnd_spromvar.h head/sys/dev/bhnd/nvram/bhnd_sprom_parservar.h - copied, changed from r304242, head/sys/dev/bhnd/nvram/bhnd_spromreg.h Deleted: head/sys/dev/bhnd/nvram/bhnd_sprom_subr.c head/sys/dev/bhnd/nvram/bhnd_spromreg.h head/sys/dev/bhnd/nvram/nvram_subr.c head/sys/dev/bhnd/nvram/nvramvar.h Modified: head/sys/conf/files head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhnd_types.h head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/cores/chipc/chipc.c head/sys/dev/bhnd/nvram/bhnd_nvram.h head/sys/dev/bhnd/nvram/bhnd_nvram_if.m head/sys/dev/bhnd/nvram/bhnd_sprom.c head/sys/dev/bhnd/nvram/bhnd_spromvar.h head/sys/dev/bhnd/tools/nvram_map_gen.awk head/sys/dev/bwn/bwn_mac.c head/sys/mips/conf/BCM head/sys/mips/conf/BCM.hints head/sys/mips/conf/SENTRY5 head/sys/mips/conf/SENTRY5.hints head/sys/modules/bhnd/Makefile Modified: head/sys/conf/files == --- head/sys/conf/files Tue Aug 16 21:20:05 2016(r304242) +++ head/sys/conf/files Tue Aug 16 21:32:05 2016(r304243) @@ -1163,10 +1163,14 @@ dev/bhnd/cores/pci/bhnd_pcib.c optional dev/bhnd/cores/pcie2/bhnd_pcie2.c optional bhnd pci dev/bhnd/cores/pcie2/bhnd_pcie2_hostb.coptional bhndb bhnd pci dev/bhnd/cores/pcie2/bhnd_pcie2b.c optional bhnd_pcie2b bhnd pci +dev/bhnd/nvram/bhnd_nvram.coptional bhnd +dev/bhnd/nvram/bhnd_nvram_common.c optional bhnd +dev/bhnd/nvram/bhnd_nvram_cfe.coptional bhnd siba_nexus cfe | \ +bhnd bcma_nexus cfe dev/bhnd/nvram/bhnd_nvram_if.m optional bhnd +dev/bhnd/nvram/bhnd_nvram_parser.c optional bhnd dev/bhnd/nvram/bhnd_sprom.coptional bhnd -dev/bhnd/nvram/bhnd_sprom_subr.c optional bhnd -dev/bhnd/nvram/nvram_subr.coptional bhnd +dev/bhnd/nvram/bhnd_sprom_parser.c optional bhnd dev/bhnd/siba/siba.c optional siba bhnd dev/bhnd/siba/siba_bhndb.c optional siba bhnd bhndb dev/bhnd/siba/siba_nexus.c optional siba_nexus siba bhnd Modified: head/sys/dev/bhnd/bhnd.c == --- head/sys/dev/bhnd/bhnd.cTue Aug 16 21:20:05 2016(r304242) +++ head/sys/dev/bhnd/bhnd.cTue Aug 16 21:32:05 2016(r304243) @@ -361,7 +361,7 @@ bhnd_finish_attach(struct bhnd_softc *sc if (ccaps->nvram_src != BHND_NVRAM_SRC_UNKNOWN) { if ((sc->nvram_dev = bhnd_find_nvram(sc)) == NULL) { device_printf(sc->dev, - "warning: %s NVRAM device not found\n", +
svn commit: r304242 - head/sys/dev/bhnd/bhndb
Author: landonf Date: Tue Aug 16 21:20:05 2016 New Revision: 304242 URL: https://svnweb.freebsd.org/changeset/base/304242 Log: bhndb(4): Drop MIPS-incompatible __builtin_ctz dependency. This replaces the bitfield representation of the bhndb register window freelist with the bitstring API, eliminating a dependency on (MIPS-unsupported) __builtin_ctz(). Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7495 Modified: head/sys/dev/bhnd/bhndb/bhndb_private.h head/sys/dev/bhnd/bhndb/bhndb_subr.c Modified: head/sys/dev/bhnd/bhndb/bhndb_private.h == --- head/sys/dev/bhnd/bhndb/bhndb_private.h Tue Aug 16 21:17:51 2016 (r304241) +++ head/sys/dev/bhnd/bhndb/bhndb_private.h Tue Aug 16 21:20:05 2016 (r304242) @@ -33,6 +33,7 @@ #define _BHND_BHNDB_PRIVATE_H_ #include +#include #include #include @@ -184,21 +185,23 @@ struct bhndb_resources { struct bhndb_dw_alloc *dw_alloc; /**< dynamic window allocation records */ size_t dwa_count; /**< number of dynamic windows available. */ - uint32_t dwa_freelist; /**< dynamic window free list */ + bitstr_t*dwa_freelist; /**< dynamic window free list */ bhndb_priority_t min_prio; /**< minimum resource priority required to allocate a dynamic window */ }; /** - * Returns true if the all dynamic windows have been exhausted, false + * Returns true if the all dynamic windows are marked free, false * otherwise. * * @param br The resource state to check. */ static inline bool -bhndb_dw_exhausted(struct bhndb_resources *br) +bhndb_dw_all_free(struct bhndb_resources *br) { - return (br->dwa_freelist == 0); + int bit; + bit_ffs(br->dwa_freelist, br->dwa_count, ); + return (bit == -1); } /** @@ -209,12 +212,14 @@ bhndb_dw_exhausted(struct bhndb_resource static inline struct bhndb_dw_alloc * bhndb_dw_next_free(struct bhndb_resources *br) { - struct bhndb_dw_alloc *dw_free; + struct bhndb_dw_alloc *dw_free; + int bit; - if (bhndb_dw_exhausted(br)) + bit_ffc(br->dwa_freelist, br->dwa_count, ); + if (bit == -1) return (NULL); - dw_free = >dw_alloc[__builtin_ctz(br->dwa_freelist)]; + dw_free = >dw_alloc[bit]; KASSERT(LIST_EMPTY(_free->refs), ("free list out of sync with refs")); @@ -233,7 +238,7 @@ bhndb_dw_is_free(struct bhndb_resources { bool is_free = LIST_EMPTY(>refs); - KASSERT(is_free == ((br->dwa_freelist & (1 << dwa->rnid)) != 0), + KASSERT(is_free == !bit_test(br->dwa_freelist, dwa->rnid), ("refs out of sync with free list")); return (is_free); Modified: head/sys/dev/bhnd/bhndb/bhndb_subr.c == --- head/sys/dev/bhnd/bhndb/bhndb_subr.cTue Aug 16 21:17:51 2016 (r304241) +++ head/sys/dev/bhnd/bhndb/bhndb_subr.cTue Aug 16 21:20:05 2016 (r304242) @@ -32,6 +32,7 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include "bhndb_private.h" #include "bhndbvar.h" @@ -264,7 +265,7 @@ bhndb_alloc_resources(device_t dev, devi const struct bhndb_regwin *win; bus_size_t last_window_size; size_t res_num; - u_intrnid; + int rnid; int error; bool free_parent_res; bool free_ht_mem, free_br_mem; @@ -371,10 +372,10 @@ bhndb_alloc_resources(device_t dev, devi } /* Fetch the dynamic regwin count and verify that it does not exceed -* what is representable via our freelist bitmask. */ +* what is representable via our freelist bitstring. */ r->dwa_count = bhndb_regwin_count(cfg->register_windows, BHNDB_REGWIN_T_DYN); - if (r->dwa_count >= (8 * sizeof(r->dwa_freelist))) { + if (r->dwa_count >= INT_MAX) { device_printf(r->dev, "max dynamic regwin count exceeded\n"); goto failed; } @@ -385,8 +386,12 @@ bhndb_alloc_resources(device_t dev, devi if (r->dw_alloc == NULL) goto failed; - /* Initialize the dynamic window table and freelist. */ - r->dwa_freelist = 0; + /* Allocate the dynamic window allocation freelist */ + r->dwa_freelist = bit_alloc(r->dwa_count, M_BHND, M_NOWAIT); + if (r->dwa_freelist == NULL) + goto failed; + + /* Initialize the dynamic window table */
svn commit: r303623 - in head/sys/mips: broadcom conf
Author: landonf Date: Mon Aug 1 16:29:32 2016 New Revision: 303623 URL: https://svnweb.freebsd.org/changeset/base/303623 Log: [mips/broadcom] Fetch UART console configuration from CFE. Relying on the boot loader console configuration allows us to use a common set of device hints for all SENTRY5 devices. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7376 Modified: head/sys/mips/broadcom/uart_cpu_chipc.c head/sys/mips/conf/SENTRY5.hints Modified: head/sys/mips/broadcom/uart_cpu_chipc.c == --- head/sys/mips/broadcom/uart_cpu_chipc.c Mon Aug 1 16:29:04 2016 (r303622) +++ head/sys/mips/broadcom/uart_cpu_chipc.c Mon Aug 1 16:29:32 2016 (r303623) @@ -47,6 +47,12 @@ __FBSDID("$FreeBSD$"); #include "bcm_socinfo.h" +#ifdef CFE +#include +#include +#include +#endif + bus_space_tag_t uart_bus_space_io; bus_space_tag_t uart_bus_space_mem; @@ -61,7 +67,7 @@ uart_cpu_eqres(struct uart_bas *b1, stru } static int -uart_cpu_init(struct uart_devinfo *di, int uart, int baudrate) +uart_cpu_init(struct uart_devinfo *di, u_int uart, int baudrate) { struct bcm_socinfo *socinfo; @@ -83,6 +89,44 @@ uart_cpu_init(struct uart_devinfo *di, i return (0); } +#ifdef CFE +static int +uart_getenv_cfe(int devtype, struct uart_devinfo *di) +{ + chardevice[sizeof("uartXX")]; + int baud, fd, len; + int ret; + u_int uart; + + /* CFE only vends console configuration */ + if (devtype != UART_DEV_CONSOLE) + return (ENODEV); + + /* Fetch console device */ + ret = cfe_getenv("BOOT_CONSOLE", device, sizeof(device)); + if (ret != CFE_OK) + return (ENXIO); + + /* Parse serial console unit. Fails on non-uart devices. */ + if (sscanf(device, "uart%u", ) != 1) + return (ENXIO); + + /* Fetch device handle */ + fd = cfe_getstdhandle(CFE_STDHANDLE_CONSOLE); + if (fd < 0) + return (ENXIO); + + /* Fetch serial configuration */ + ret = cfe_ioctl(fd, IOCTL_SERIAL_GETSPEED, (unsigned char *), + sizeof(baud), , 0); + if (ret != CFE_OK) + baud = CHIPC_UART_BAUDRATE; + + /* Initialize device info */ + return (uart_cpu_init(di, uart, baud)); +} +#endif /* CFE */ + int uart_cpu_getdev(int devtype, struct uart_devinfo *di) { @@ -91,12 +135,18 @@ uart_cpu_getdev(int devtype, struct uart uart_bus_space_io = NULL; uart_bus_space_mem = mips_bus_space_generic; - /* Check the environment. */ +#ifdef CFE + /* Check the CFE environment */ + if (uart_getenv_cfe(devtype, di) == 0) + return (0); +#endif /* CFE */ + + /* Check the kernel environment. */ if (uart_getenv(devtype, di, chipc_uart_class) == 0) return (0); /* Scan the device hints for the first matching device */ - for (int i = 0; i < CHIPC_UART_MAX; i++) { + for (u_int i = 0; i < CHIPC_UART_MAX; i++) { if (resource_int_value("uart", i, "flags", )) continue; Modified: head/sys/mips/conf/SENTRY5.hints == --- head/sys/mips/conf/SENTRY5.hintsMon Aug 1 16:29:04 2016 (r303622) +++ head/sys/mips/conf/SENTRY5.hintsMon Aug 1 16:29:32 2016 (r303623) @@ -2,6 +2,3 @@ hint.bhnd.0.at="nexus0" hint.bhnd.0.maddr="0x1800" hint.bhnd.0.msize="0x0010" - -# console on uart1 -hint.uart.1.flags="0x10" ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r303621 - head/sys/dev/cfe
Author: landonf Date: Mon Aug 1 16:26:08 2016 New Revision: 303621 URL: https://svnweb.freebsd.org/changeset/base/303621 Log: Sync CFE interface with upstream cfe-1.4.2 release. Approved by: adrian (mentor) Obtained from: https://www.broadcom.com/support/communications-processors Differential Revision:https://reviews.freebsd.org/D7375 Modified: head/sys/dev/cfe/cfe_api.c head/sys/dev/cfe/cfe_api.h head/sys/dev/cfe/cfe_api_int.h head/sys/dev/cfe/cfe_error.h head/sys/dev/cfe/cfe_ioctl.h Modified: head/sys/dev/cfe/cfe_api.c == --- head/sys/dev/cfe/cfe_api.c Mon Aug 1 16:24:46 2016(r303620) +++ head/sys/dev/cfe/cfe_api.c Mon Aug 1 16:26:08 2016(r303621) @@ -1,5 +1,4 @@ -/* $NetBSD: cfe_api.c,v 1.5 2005/12/11 12:18:07 christos Exp $ */ -/* from: SiByte Id: cfe_api.c,v 1.16 2002/07/09 23:29:11 cgd Exp $ */ +/* from: Broadcom Id: cfe_api.c,v 1.18 2006/08/24 02:13:56 binh Exp $ */ /*- * Copyright 2000, 2001, 2002 @@ -177,6 +176,27 @@ cfe_enumenv(int idx, char *name, int nam } #endif /* CFE_API_enumenv || CFE_API_ALL */ +#if defined(CFE_API_enumdev) || defined(CFE_API_ALL) +int +cfe_enumdev(int idx, char *name, int namelen) +{ +cfe_xiocb_t xiocb; + +xiocb.xiocb_fcode = CFE_CMD_DEV_ENUM; +xiocb.xiocb_status = 0; +xiocb.xiocb_handle = 0; +xiocb.xiocb_flags = 0; +xiocb.xiocb_psize = sizeof(xiocb_envbuf_t); +xiocb.plist.xiocb_envbuf.enum_idx = idx; +xiocb.plist.xiocb_envbuf.name_ptr = XPTR_FROM_NATIVE(name); +xiocb.plist.xiocb_envbuf.name_length = namelen; + +cfe_iocb_dispatch(); + +return xiocb.xiocb_status; +} +#endif /* CFE_API_enumdev || CFE_API_ALL */ + #if defined(CFE_API_enummem) || defined(CFE_API_ALL) int cfe_enummem(int idx, int flags, cfe_xuint_t *start, cfe_xuint_t *length, Modified: head/sys/dev/cfe/cfe_api.h == --- head/sys/dev/cfe/cfe_api.h Mon Aug 1 16:24:46 2016(r303620) +++ head/sys/dev/cfe/cfe_api.h Mon Aug 1 16:26:08 2016(r303621) @@ -1,5 +1,4 @@ -/* $NetBSD: cfe_api.h,v 1.3 2003/02/07 17:38:48 cgd Exp $ */ -/* from: SiByte Id: cfe_api.h,v 1.29 2002/07/09 23:29:11 cgd Exp $ */ +/* from: Broadcom Id: cfe_api.h,v 1.31 2006/08/24 02:13:56 binh Exp $ */ /*- * Copyright 2000, 2001, 2002 @@ -154,6 +153,7 @@ int64_t cfe_getticks(void); #define cfe_cpu_start(a,b,c,d,e) __cfe_cpu_start(a,b,c,d,e) #define cfe_cpu_stop(a)__cfe_cpu_stop(a) #define cfe_enumenv(a,b,d,e,f) __cfe_enumenv(a,b,d,e,f) +#define cfe_enumdev(a,b,c) __cfe_enumdev(a,b,c) #define cfe_enummem(a,b,c,d,e) __cfe_enummem(a,b,c,d,e) #define cfe_exit(a,b) __cfe_exit(a,b) #define cfe_flushcache(a) __cfe_cacheflush(a) @@ -176,6 +176,7 @@ int cfe_close(int handle); int cfe_cpu_start(int cpu, void (*fn)(void), long sp, long gp, long a1); int cfe_cpu_stop(int cpu); int cfe_enumenv(int idx, char *name, int namelen, char *val, int vallen); +int cfe_enumdev(int idx, char *name, int namelen); int cfe_enummem(int idx, int flags, uint64_t *start, uint64_t *length, uint64_t *type); int cfe_exit(int warm,int status); Modified: head/sys/dev/cfe/cfe_api_int.h == --- head/sys/dev/cfe/cfe_api_int.h Mon Aug 1 16:24:46 2016 (r303620) +++ head/sys/dev/cfe/cfe_api_int.h Mon Aug 1 16:26:08 2016 (r303621) @@ -1,5 +1,4 @@ -/* $NetBSD: cfe_api_int.h,v 1.2 2003/02/07 17:38:48 cgd Exp $ */ -/* from: SiByte Id: cfe_api_int.h,v 1.21 2002/07/09 23:29:11 cgd Exp $ */ +/* from: Broadcom Id: cfe_api_int.h,v 1.22 2003/02/07 17:27:56 cgd Exp $ */ /*- * Copyright 2000, 2001, 2002 Modified: head/sys/dev/cfe/cfe_error.h == --- head/sys/dev/cfe/cfe_error.hMon Aug 1 16:24:46 2016 (r303620) +++ head/sys/dev/cfe/cfe_error.hMon Aug 1 16:26:08 2016 (r303621) @@ -1,5 +1,4 @@ -/* $NetBSD: cfe_error.h,v 1.2 2003/02/07 17:38:48 cgd Exp $ */ -/* from: SiByte Id: cfe_error.h,v 1.2 2002/07/09 19:37:52 cgd Exp $ */ +/* from: Broadcom Id: cfe_error.h,v 1.3 2003/02/07 17:27:56 cgd Exp $ */ /*- * Copyright 2000, 2001, 2002 Modified: head/sys/dev/cfe/cfe_ioctl.h == --- head/sys/dev/cfe/cfe_ioctl.hMon Aug 1 16:24:46 2016 (r303620) +++ head/sys/dev/cfe/cfe_ioctl.hMon Aug 1 16:26:08 2016 (r303621) @@ -1,14 +1,13 @@ -/* $NetBSD: cfe_ioctl.h,v 1.2 2003/02/07 17:52:08 cgd Exp $ */ - /*- - * Copyright 2000, 2001 + * Copyright 2000, 2001, 2002, 2003 * Broadcom Corporation. All rights reserved. * - * This software is furnished under license and may be used and copied only
svn commit: r302604 - in head/sys/dev/bhnd: . bhndb
Author: landonf Date: Tue Jul 12 02:16:48 2016 New Revision: 302604 URL: https://svnweb.freebsd.org/changeset/base/302604 Log: bhnd(4): Add bus pass-aware discovery of platform devices (PMU, NVRAM, ChipCommon, etc). This extends the existing handling of NVRAM core discovery to support locating additional devices that may be attached either directly as real cores, or indirectly via ChipCommon (e.g. bhnd_pmu). When attached as a SoC root bus (as opposed to a bridged WiFi device), the platform devices may not be attached until later bus passes, necessitating delayed discovery/initialization. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D6962 Modified: head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd.h head/sys/dev/bhnd/bhnd_subr.c head/sys/dev/bhnd/bhndb/bhndb.c head/sys/dev/bhnd/bhndvar.h Modified: head/sys/dev/bhnd/bhnd.c == --- head/sys/dev/bhnd/bhnd.cTue Jul 12 02:12:31 2016(r302603) +++ head/sys/dev/bhnd/bhnd.cTue Jul 12 02:16:48 2016(r302604) @@ -58,11 +58,20 @@ __FBSDID("$FreeBSD$"); #include #include +#include + +#include "bhnd_chipc_if.h" +#include "bhnd_nvram_if.h" + #include "bhnd.h" #include "bhndvar.h" MALLOC_DEFINE(M_BHND, "bhnd", "bhnd bus data structures"); +/* Bus pass at which all bus-required children must be available, and + * attachment may be finalized. */ +#defineBHND_FINISH_ATTACH_PASS BUS_PASS_DEFAULT + /** * bhnd_generic_probe_nomatch() reporting configuration. */ @@ -80,10 +89,22 @@ static const struct bhnd_nomatch { { BHND_MFGID_INVALID, BHND_COREID_INVALID,false } }; -static int compare_ascending_probe_order(const void *lhs, - const void *rhs); -static int compare_descending_probe_order(const void *lhs, - const void *rhs); + +static int bhnd_delete_children(struct bhnd_softc *sc); + +static int bhnd_finish_attach(struct bhnd_softc *sc); + +static device_t bhnd_find_chipc(struct bhnd_softc *sc); +static struct chipc_caps *bhnd_find_chipc_caps(struct bhnd_softc *sc); +static device_t bhnd_find_platform_dev(struct bhnd_softc *sc, +const char *classname); +static device_t bhnd_find_pmu(struct bhnd_softc *sc); +static device_t bhnd_find_nvram(struct bhnd_softc *sc); + +static int compare_ascending_probe_order(const void *lhs, +const void *rhs); +static int compare_descending_probe_order(const void *lhs, +const void *rhs); /** * Default bhnd(4) bus driver implementation of DEVICE_ATTACH(). @@ -94,44 +115,53 @@ static int compare_descending_probe_orde int bhnd_generic_attach(device_t dev) { - device_t*devs; - int ndevs; - int error; + struct bhnd_softc *sc; + device_t*devs; + int ndevs; + int error; if (device_is_attached(dev)) return (EBUSY); + sc = device_get_softc(dev); + sc->dev = dev; + if ((error = device_get_children(dev, , ))) return (error); + /* Probe and attach all children */ qsort(devs, ndevs, sizeof(*devs), compare_ascending_probe_order); for (int i = 0; i < ndevs; i++) { device_t child = devs[i]; device_probe_and_attach(child); } + /* Try to finalize attachment */ + if (bus_current_pass >= BHND_FINISH_ATTACH_PASS) { + if ((error = bhnd_finish_attach(sc))) + goto cleanup; + } + +cleanup: free(devs, M_TEMP); - return (0); + + if (error) + bhnd_delete_children(sc); + + return (error); } /** - * Default bhnd(4) bus driver implementation of DEVICE_DETACH(). - * - * This implementation calls device_detach() for each of the device's - * children, in reverse bhnd probe order, terminating if any call to - * device_detach() fails. + * Detach and delete all children, in reverse of their attach order. */ -int -bhnd_generic_detach(device_t dev) +static int +bhnd_delete_children(struct bhnd_softc *sc) { - device_t*devs; - int ndevs; - int error; + device_t*devs; + int ndevs; + int error; - if (!device_is_attached(dev)) - return (EBUSY); - - if ((error = device_get_children(dev, , ))) + if ((error = device_get_children(sc->dev, , ))) return (error); /* Detach in
svn commit: r302603 - head/sys/mips/mips
Author: landonf Date: Tue Jul 12 02:12:31 2016 New Revision: 302603 URL: https://svnweb.freebsd.org/changeset/base/302603 Log: mips/ddb: fix MIPS backtrace truncation and MIPS32 register printing. - Cast 32-bit register values to uintmax_t for use with %jx. - Add special-case return address handling for MipsKernGenException to avoid early termination of stack walking in the exception handler stack frame. Submitted by: Michael ZhilinReviewed by: ray Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D6907 Modified: head/sys/mips/mips/db_trace.c Modified: head/sys/mips/mips/db_trace.c == --- head/sys/mips/mips/db_trace.c Tue Jul 12 01:15:00 2016 (r302602) +++ head/sys/mips/mips/db_trace.c Tue Jul 12 02:12:31 2016 (r302603) @@ -144,6 +144,7 @@ stacktrace_subr(register_t pc, register_ unsigned instr, mask; unsigned int frames = 0; int more, stksize, j; + register_t next_ra; /* Jump here when done with a frame, to start a new one */ loop: @@ -155,6 +156,7 @@ loop: valid_args[1] = 0; valid_args[2] = 0; valid_args[3] = 0; + next_ra = 0; /* Jump here after a nonstandard (interrupt handler) frame */ stksize = 0; subr = 0; @@ -288,9 +290,17 @@ loop: /* look for saved registers on the stack */ if (i.IType.rs != 29) break; - /* only restore the first one */ - if (mask & (1 << i.IType.rt)) + /* +* only restore the first one except RA for +* MipsKernGenException case +*/ + if (mask & (1 << i.IType.rt)) { + if (subr == (uintptr_t)MipsKernGenException && + i.IType.rt == 31) + next_ra = kdbpeek((int *)(sp + + (short)i.IType.imm)); break; + } mask |= (1 << i.IType.rt); switch (i.IType.rt) { case 4:/* a0 */ @@ -374,7 +384,10 @@ done: (*printfn)("?"); } - (*printfn) (") ra %jx sp %jx sz %d\n", ra, sp, stksize); + (*printfn) (") ra %jx sp %jx sz %d\n", + (uintmax_t)(u_register_t) ra, + (uintmax_t)(u_register_t) sp, + stksize); if (ra) { if (pc == ra && stksize == 0) @@ -382,7 +395,7 @@ done: else { pc = ra; sp += stksize; - ra = 0; + ra = next_ra; goto loop; } } else { ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r302602 - head/sys/dev/bhnd/cores/chipc
Author: landonf Date: Tue Jul 12 01:15:00 2016 New Revision: 302602 URL: https://svnweb.freebsd.org/changeset/base/302602 Log: bhnd(4): print extra register information on chipc SPI timeout. Submitted by: Michael ZhilinReviewed by: imp Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D6993 Modified: head/sys/dev/bhnd/cores/chipc/chipc_spi.c Modified: head/sys/dev/bhnd/cores/chipc/chipc_spi.c == --- head/sys/dev/bhnd/cores/chipc/chipc_spi.c Tue Jul 12 00:37:48 2016 (r302601) +++ head/sys/dev/bhnd/cores/chipc/chipc_spi.c Tue Jul 12 01:15:00 2016 (r302602) @@ -184,7 +184,9 @@ chipc_spi_wait(struct chipc_spi_softc *s if (i > 0) return (0); - BHND_DEBUG_DEV(sc->sc_dev, "busy"); + BHND_WARN_DEV(sc->sc_dev, "busy: CTL=0x%x DATA=0x%x", + SPI_READ(sc, CHIPC_SPI_FLASHCTL), + SPI_READ(sc, CHIPC_SPI_FLASHDATA)); return (-1); } ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r302509 - head/sys/dev/bhnd/nvram
Author: landonf Date: Sun Jul 10 00:08:40 2016 New Revision: 302509 URL: https://svnweb.freebsd.org/changeset/base/302509 Log: Fix heap overflow in bhnd(4) SPROM parsing. The bus_region_* APIs accept the number of data items to be read, while the code was passing the total number of bytes, resulting in an overflow of the SPROM parser's buffer. Approved by: adrian (mentor) Differential Revision:https://reviews.freebsd.org/D7168 Modified: head/sys/dev/bhnd/nvram/bhnd_sprom_subr.c Modified: head/sys/dev/bhnd/nvram/bhnd_sprom_subr.c == --- head/sys/dev/bhnd/nvram/bhnd_sprom_subr.c Sat Jul 9 23:22:44 2016 (r302508) +++ head/sys/dev/bhnd/nvram/bhnd_sprom_subr.c Sun Jul 10 00:08:40 2016 (r302509) @@ -523,7 +523,8 @@ sprom_direct_read(struct bhnd_sprom *sc, p = (uint16_t *)buf; res_offset = sc->sp_res_off + offset; - bhnd_bus_read_region_stream_2(sc->sp_res, res_offset, p, nbytes); + bhnd_bus_read_region_stream_2(sc->sp_res, res_offset, p, + (nbytes / sizeof(uint16_t))); *crc = bhnd_nvram_crc8(p, nbytes, *crc); return (0); ___ svn-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"
svn commit: r302191 - in head/sys/dev/bhnd: . bcma siba
Author: landonf Date: Sat Jun 25 04:36:30 2016 New Revision: 302191 URL: https://svnweb.freebsd.org/changeset/base/302191 Log: bhnd(4): Add devinfo allocation and child addition methods, modeled on pci_if. This allows bhnd(4) to manage per-device state (such as per-core pmu/clock refcounting) on behalf of subclass driver instances. Approved by: re (gjb), adrian (mentor) Differential Revision:https://reviews.freebsd.org/D6959 Modified: head/sys/dev/bhnd/bcma/bcma.c head/sys/dev/bhnd/bcma/bcma_subr.c head/sys/dev/bhnd/bcma/bcmavar.h head/sys/dev/bhnd/bhnd.c head/sys/dev/bhnd/bhnd_bus_if.m head/sys/dev/bhnd/bhndvar.h head/sys/dev/bhnd/siba/siba.c head/sys/dev/bhnd/siba/siba_subr.c head/sys/dev/bhnd/siba/sibavar.h Modified: head/sys/dev/bhnd/bcma/bcma.c == --- head/sys/dev/bhnd/bcma/bcma.c Sat Jun 25 04:34:54 2016 (r302190) +++ head/sys/dev/bhnd/bcma/bcma.c Sat Jun 25 04:36:30 2016 (r302191) @@ -181,14 +181,6 @@ bcma_write_ivar(device_t dev, device_t c } } -static void -bcma_child_deleted(device_t dev, device_t child) -{ - struct bcma_devinfo *dinfo = device_get_ivars(child); - if (dinfo != NULL) - bcma_free_dinfo(dev, dinfo); -} - static struct resource_list * bcma_get_resource_list(device_t dev, device_t child) { @@ -415,6 +407,19 @@ bcma_get_region_addr(device_t dev, devic return (ENOENT); } +static struct bhnd_devinfo * +bcma_alloc_bhnd_dinfo(device_t dev) +{ + struct bcma_devinfo *dinfo = bcma_alloc_dinfo(dev); + return ((struct bhnd_devinfo *)dinfo); +} + +static void +bcma_free_bhnd_dinfo(device_t dev, struct bhnd_devinfo *dinfo) +{ + bcma_free_dinfo(dev, (struct bcma_devinfo *)dinfo); +} + /** * Scan a device enumeration ROM table, adding all valid discovered cores to * the bus. @@ -431,8 +436,7 @@ bcma_add_children(device_t bus, struct r struct bcma_devinfo *dinfo; device_t child; int error; - - dinfo = NULL; + corecfg = NULL; /* Initialize our reader */ @@ -450,26 +454,20 @@ bcma_add_children(device_t bus, struct r goto failed; } - /* Allocate per-device bus info */ - dinfo = bcma_alloc_dinfo(bus, corecfg); - if (dinfo == NULL) { - error = ENXIO; - goto failed; - } - - /* The dinfo instance now owns the corecfg value */ - corecfg = NULL; - /* Add the child device */ - child = device_add_child(bus, NULL, -1); + child = BUS_ADD_CHILD(bus, 0, NULL, -1); if (child == NULL) { error = ENXIO; goto failed; } - /* The child device now owns the dinfo pointer */ - device_set_ivars(child, dinfo); - dinfo = NULL; + /* Initialize device ivars */ + dinfo = device_get_ivars(child); + if ((error = bcma_init_dinfo(bus, dinfo, corecfg))) + goto failed; + + /* The dinfo instance now owns the corecfg value */ + corecfg = NULL; /* If pins are floating or the hardware is otherwise * unpopulated, the device shouldn't be used. */ @@ -482,9 +480,6 @@ bcma_add_children(device_t bus, struct r return (0); failed: - if (dinfo != NULL) - bcma_free_dinfo(bus, dinfo); - if (corecfg != NULL) bcma_free_corecfg(corecfg); @@ -499,13 +494,14 @@ static device_method_t bcma_methods[] = DEVMETHOD(device_detach,bcma_detach), /* Bus interface */ - DEVMETHOD(bus_child_deleted,bcma_child_deleted), DEVMETHOD(bus_read_ivar,bcma_read_ivar), DEVMETHOD(bus_write_ivar, bcma_write_ivar), DEVMETHOD(bus_get_resource_list,bcma_get_resource_list), /* BHND interface */ DEVMETHOD(bhnd_bus_find_hostb_device, bcma_find_hostb_device), + DEVMETHOD(bhnd_bus_alloc_devinfo, bcma_alloc_bhnd_dinfo), + DEVMETHOD(bhnd_bus_free_devinfo,bcma_free_bhnd_dinfo), DEVMETHOD(bhnd_bus_reset_core, bcma_reset_core), DEVMETHOD(bhnd_bus_suspend_core,bcma_suspend_core), DEVMETHOD(bhnd_bus_get_port_count, bcma_get_port_count), Modified: head/sys/dev/bhnd/bcma/bcma_subr.c == --- head/sys/dev/bhnd/bcma/bcma_subr.c Sat Jun 25 04:34:54 2016 (r302190) +++ head/sys/dev/bhnd/bcma/bcma_subr.c Sat Jun 25 04:36:30 2016 (r302191) @@ -186,28