svn commit: r315465 - head/sys/mips/broadcom

Landon J. Fuller landonf at FreeBSD.org
Fri Mar 17 22:02:03 UTC 2017


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.c	Fri Mar 17 21:40:14 2017	(r315464)
+++ head/sys/mips/broadcom/bcm_machdep.c	Fri 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	unit		The 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]	info		If non-NULL, will be populated with the core
  *				info.
  * @param[out]	addr		If 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(&bp->erom.obj, &md, BHND_PORT_DEVICE,
-	    0, 0, info, &b_addr, &b_size);
-	if (error)
-		return (error);
+	for (size_t i = 0; i < num_descs; i++) {
+		error = bhnd_erom_lookup_core_addr(&bp->erom.obj, &descs[i],
+		    BHND_PORT_DEVICE, 0, 0, info, &b_addr, &b_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, &bp->cc_id,
-	    &bp->cc_addr);
+	error = bcm_find_core(bp, bcm_chipc_cores, nitems(bcm_chipc_cores),
+	    &bp->cc_id, &bp->cc_addr);
 	if (error) {
 		BCM_ERR("error locating chipc core: %d\n", error);
 		return (error);
@@ -306,9 +317,8 @@ bcm_init_platform_data(struct bcm_platfo
 
 	if (pmu && aob) {
 		/* PMU block mapped to a PMU core on the Always-on-Bus (aob) */
-		error = bcm_find_core(bp, BHND_MFGID_BCM, BHND_COREID_PMU, 0,
+		error = bcm_find_core(bp, bcm_pmu_cores, nitems(bcm_pmu_cores),
 		    &bp->pmu_id,  &bp->pmu_addr);
-
 		if (error) {
 			BCM_ERR("error locating pmu core: %d\n", error);
 			return (error);


More information about the svn-src-head mailing list