From owner-svn-src-head@freebsd.org Fri Mar 17 22:02:03 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 89F37D10A6B; Fri, 17 Mar 2017 22:02:03 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 613A3153D; Fri, 17 Mar 2017 22:02:03 +0000 (UTC) (envelope-from landonf@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v2HM22kj054133; Fri, 17 Mar 2017 22:02:02 GMT (envelope-from landonf@FreeBSD.org) Received: (from landonf@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v2HM22C8054132; Fri, 17 Mar 2017 22:02:02 GMT (envelope-from landonf@FreeBSD.org) Message-Id: <201703172202.v2HM22C8054132@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: landonf set sender to landonf@FreeBSD.org using -f From: "Landon J. Fuller" Date: Fri, 17 Mar 2017 22:02:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r315465 - head/sys/mips/broadcom X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Mar 2017 22:02:03 -0000 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);