2016-08-26 20:16:02 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org>
|
2017-09-27 19:44:23 +00:00
|
|
|
* Copyright (c) 2017 The FreeBSD Foundation
|
2016-08-26 20:16:02 +00:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
2017-09-27 19:44:23 +00:00
|
|
|
* Portions of this software were developed by Landon Fuller
|
|
|
|
* under sponsorship from the FreeBSD Foundation.
|
|
|
|
*
|
2016-08-26 20:16:02 +00:00
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* $FreeBSD$
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _MIPS_BROADCOM_BCM_MACHDEP_H_
|
|
|
|
#define _MIPS_BROADCOM_BCM_MACHDEP_H_
|
|
|
|
|
|
|
|
#include <machine/cpufunc.h>
|
|
|
|
#include <machine/cpuregs.h>
|
|
|
|
|
|
|
|
#include <dev/bhnd/bhnd.h>
|
2017-09-27 19:48:34 +00:00
|
|
|
#include <dev/bhnd/bhnd_eromvar.h>
|
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 (18000000-17FFFFFF) 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
2016-09-03 23:57:17 +00:00
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#include <dev/bhnd/cores/pmu/bhnd_pmuvar.h>
|
|
|
|
|
2017-03-23 19:29:12 +00:00
|
|
|
#include "bcm_nvram_cfevar.h"
|
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
extern const struct bhnd_pmu_io bcm_pmu_soc_io;
|
|
|
|
|
2016-08-26 20:16:02 +00:00
|
|
|
struct bcm_platform {
|
2017-09-27 19:44:23 +00:00
|
|
|
struct bhnd_chipid cid; /**< chip id */
|
|
|
|
struct bhnd_core_info cc_id; /**< chipc core info */
|
|
|
|
uintptr_t cc_addr; /**< chipc core phys address */
|
|
|
|
uint32_t cc_caps; /**< chipc capabilities */
|
|
|
|
uint32_t cc_caps_ext; /**< chipc extended capabilies */
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2017-11-21 23:15:20 +00:00
|
|
|
struct bhnd_core_info cpu_id; /**< cpu core info */
|
|
|
|
uintptr_t cpu_addr; /**< cpu core phys address */
|
|
|
|
|
2016-08-26 20:16:02 +00:00
|
|
|
/* On non-AOB devices, the PMU register block is mapped to chipc;
|
|
|
|
* the pmu_id and pmu_addr values will be copied from cc_id
|
|
|
|
* and cc_addr. */
|
2017-11-21 23:15:20 +00:00
|
|
|
struct bhnd_core_info pmu_id; /**< PMU core info */
|
2017-09-27 19:44:23 +00:00
|
|
|
uintptr_t pmu_addr; /**< PMU core phys address, or
|
2017-11-21 23:15:20 +00:00
|
|
|
0x0 if no PMU */
|
2016-08-27 00:06:20 +00:00
|
|
|
|
2017-09-27 19:44:23 +00:00
|
|
|
struct bhnd_pmu_query pmu; /**< PMU query instance */
|
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 (18000000-17FFFFFF) 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
2016-09-03 23:57:17 +00:00
|
|
|
|
2017-09-27 19:44:23 +00:00
|
|
|
bhnd_erom_class_t *erom_impl; /**< erom parser class */
|
|
|
|
struct kobj_ops erom_ops; /**< compiled kobj opcache */
|
2017-09-27 19:48:34 +00:00
|
|
|
struct bhnd_erom_iobus erom_io; /**< erom I/O callbacks */
|
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 (18000000-17FFFFFF) 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
2016-09-03 23:57:17 +00:00
|
|
|
union {
|
|
|
|
bhnd_erom_static_t data;
|
|
|
|
bhnd_erom_t obj;
|
|
|
|
} erom;
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2017-09-27 19:44:23 +00:00
|
|
|
struct bhnd_nvram_io *nvram_io; /**< NVRAM I/O context, or NULL if unavailable */
|
|
|
|
bhnd_nvram_data_class *nvram_cls; /**< NVRAM data class, or NULL if unavailable */
|
|
|
|
|
|
|
|
struct bhnd_service_registry services; /**< platform service providers */
|
2017-03-23 19:29:12 +00:00
|
|
|
|
2016-08-26 20:16:02 +00:00
|
|
|
#ifdef CFE
|
2017-09-27 19:44:23 +00:00
|
|
|
int cfe_console; /**< Console handle, or -1 */
|
2016-08-26 20:16:02 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
struct bcm_platform *bcm_get_platform(void);
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
uint64_t bcm_get_cpufreq(struct bcm_platform *bp);
|
|
|
|
uint64_t bcm_get_sifreq(struct bcm_platform *bp);
|
|
|
|
uint64_t bcm_get_alpfreq(struct bcm_platform *bp);
|
|
|
|
uint64_t bcm_get_ilpfreq(struct bcm_platform *bp);
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
u_int bcm_get_uart_rclk(struct bcm_platform *bp);
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2017-03-23 19:29:12 +00:00
|
|
|
int bcm_get_nvram(struct bcm_platform *bp,
|
|
|
|
const char *name, void *outp, size_t *olen,
|
|
|
|
bhnd_nvram_type type);
|
|
|
|
|
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 (18000000-17FFFFFF) 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
2016-09-03 23:57:17 +00:00
|
|
|
#define BCM_ERR(fmt, ...) \
|
|
|
|
printf("%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
#define BCM_SOC_BSH(_addr, _offset) \
|
|
|
|
((bus_space_handle_t)BCM_SOC_ADDR((_addr), (_offset)))
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_SOC_ADDR(_addr, _offset) \
|
2016-08-26 20:16:02 +00:00
|
|
|
MIPS_PHYS_TO_KSEG1((_addr) + (_offset))
|
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_SOC_READ_4(_addr, _offset) \
|
2016-08-26 20:16:02 +00:00
|
|
|
readl(BCM_SOC_ADDR((_addr), (_offset)))
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_SOC_WRITE_4(_addr, _reg, _val) \
|
2016-08-26 20:16:02 +00:00
|
|
|
writel(BCM_SOC_ADDR((_addr), (_offset)), (_val))
|
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_CORE_ADDR(_bp, _name, _reg) \
|
|
|
|
BCM_SOC_ADDR(_bp->_name, (_reg))
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_CORE_READ_4(_bp, _name, _reg) \
|
|
|
|
readl(BCM_CORE_ADDR(_bp, _name, (_reg)))
|
|
|
|
#define BCM_CORE_WRITE_4(_bp, _name, _reg, _val) \
|
|
|
|
writel(BCM_CORE_ADDR(_bp, _name, (_reg)), (_val))
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_CHIPC_READ_4(_bp, _reg) \
|
|
|
|
BCM_CORE_READ_4(_bp, cc_addr, (_reg))
|
|
|
|
#define BCM_CHIPC_WRITE_4(_bp, _reg, _val) \
|
|
|
|
BCM_CORE_WRITE_4(_bp, cc_addr, (_reg), (_val))
|
2016-08-26 20:16:02 +00:00
|
|
|
|
2017-11-21 23:15:20 +00:00
|
|
|
#define BCM_CPU_READ_4(_bp, _reg) \
|
|
|
|
BCM_CORE_READ_4(_bp, cpu_addr, (_reg))
|
|
|
|
#define BCM_CPU_WRITE_4(_bp, _reg, _val) \
|
|
|
|
BCM_CORE_WRITE_4(_bp, cpu_addr, (_reg), (_val))
|
|
|
|
|
2016-08-27 00:06:20 +00:00
|
|
|
#define BCM_PMU_READ_4(_bp, _reg) \
|
|
|
|
BCM_CORE_READ_4(_bp, pmu_addr, (_reg))
|
|
|
|
#define BCM_PMU_WRITE_4(_bp, _reg, _val) \
|
|
|
|
BCM_CORE_WRITE_4(_bp, pmu_addr, (_reg), (_val))
|
2016-08-26 20:16:02 +00:00
|
|
|
|
|
|
|
#endif /* _MIPS_BROADCOM_BCM_MACHDEP_H_ */
|