Changeset View
Changeset View
Standalone View
Standalone View
sys/mips/broadcom/bcm_siba.c
- This file was copied from sys/mips/broadcom/bcm_socinfo.h.
/*- | /*- | ||||
* Copyright (c) 2016 Michael Zhilin <mizhka@gmail.com> | * Copyright (c) 2016 Landon Fuller <landonf@FreeBSD.org> | ||||
* | * | ||||
* All rights reserved. | * All rights reserved. | ||||
* | * | ||||
* Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
* modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
* are met: | * are met: | ||||
* 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
* notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
Show All 9 Lines | |||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | ||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | * 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 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | ||||
* SUCH DAMAGE. | * SUCH DAMAGE. | ||||
*/ | */ | ||||
/* | #include <sys/cdefs.h> | ||||
* $FreeBSD$ | __FBSDID("$FreeBSD$"); | ||||
*/ | |||||
#ifndef _MIPS_BROADCOM_BCM_SOCINFO_H_ | #include <dev/bhnd/bhnd.h> | ||||
#define _MIPS_BROADCOM_BCM_SOCINFO_H_ | #include <dev/bhnd/bhndreg.h> | ||||
#include <machine/cpuregs.h> | #include <dev/bhnd/siba/sibareg.h> | ||||
#include <dev/bhnd/siba/sibavar.h> | |||||
struct bcm_socinfo { | #include "bcm_machdep.h" | ||||
uint32_t id; | |||||
uint32_t cpurate; /* in MHz */ | |||||
uint32_t uartrate; /* in Hz */ | |||||
int double_count; | |||||
}; | |||||
struct bcm_socinfo* bcm_get_socinfo_by_socid(uint32_t key); | int | ||||
struct bcm_socinfo* bcm_get_socinfo(void); | bcm_find_core_siba(struct bhnd_chipid *chipid, bhnd_devclass_t devclass, | ||||
int unit, struct bhnd_core_info *info, uintptr_t *addr) | |||||
{ | |||||
struct siba_core_id scid; | |||||
uintptr_t cc_addr; | |||||
uint32_t idhigh, idlow; | |||||
#define BCM_SOCADDR 0x18000000 | /* No other cores are required during early boot on siba(4) devices */ | ||||
#define BCM_REG_CHIPC_ID 0x0 | if (devclass != BHND_DEVCLASS_CC || unit != 0) | ||||
#define BCM_REG_CHIPC_UART 0x300 | return (ENOENT); | ||||
#define BCM_REG_CHIPC_PMUWD_OFFS 0x634 | |||||
#define BCM_SOCREG(reg) \ | |||||
MIPS_PHYS_TO_KSEG1((BCM_SOCADDR + (reg))) | |||||
#define BCM_READ_REG32(reg) \ | |||||
*((volatile uint32_t *)BCM_SOCREG(reg)) | |||||
#define BCM_WRITE_REG32(reg, value) \ | |||||
do { \ | |||||
writel((void*)BCM_SOCREG((reg)),value); \ | |||||
} while (0); | |||||
#endif /* _MIPS_BROADCOM_BCM_SOCINFO_H_ */ | cc_addr = chipid->enum_addr; | ||||
idhigh = BCM_SOC_READ_4(cc_addr, SB0_REG_ABS(SIBA_CFG0_IDHIGH)); | |||||
idlow = BCM_SOC_READ_4(cc_addr, SB0_REG_ABS(SIBA_CFG0_IDHIGH)); | |||||
scid = siba_parse_core_id(idhigh, idlow, 0, 0); | |||||
if (info != NULL) | |||||
*info = scid.core_info; | |||||
if (addr != NULL) | |||||
*addr = cc_addr; | |||||
return (0); | |||||
} |