From: visa Date: Mon, 19 Jun 2017 14:47:27 +0000 (+0000) Subject: Fix the timecounter register on CN72xx/CN73xx. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=39db07acc392d74ddcfd5eb5bce997a4947cb020;p=openbsd Fix the timecounter register on CN72xx/CN73xx. --- diff --git a/sys/arch/octeon/include/octeonreg.h b/sys/arch/octeon/include/octeonreg.h index a36ad4fb86c..f5f9f674e5f 100644 --- a/sys/arch/octeon/include/octeonreg.h +++ b/sys/arch/octeon/include/octeonreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: octeonreg.h,v 1.6 2016/12/17 14:14:09 visa Exp $ */ +/* $OpenBSD: octeonreg.h,v 1.7 2017/06/19 14:47:27 visa Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.com). @@ -165,6 +165,8 @@ #define CIU_INT0_EN4_1 0x00000C88 #define CIU_INT1_EN4_1 0x00000C98 +#define FPA3_CLK_COUNT 0x12800000000f0ULL + /* OCTEON II */ #define MIO_RST_BOOT 0x1180000001600ULL #define MIO_RST_BOOT_PNR_MUL_SHIFT 24 diff --git a/sys/arch/octeon/octeon/machdep.c b/sys/arch/octeon/octeon/machdep.c index c2026a3840d..c089a76f8c9 100644 --- a/sys/arch/octeon/octeon/machdep.c +++ b/sys/arch/octeon/octeon/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.94 2017/06/19 14:25:53 visa Exp $ */ +/* $OpenBSD: machdep.c,v 1.95 2017/06/19 14:47:27 visa Exp $ */ /* * Copyright (c) 2009, 2010 Miodrag Vallat. @@ -142,16 +142,18 @@ extern void parse_uboot_root(void); cons_decl(cn30xxuart); struct consdev uartcons = cons_init(cn30xxuart); -u_int ipdclock_get_timecount(struct timecounter *); +u_int ioclock_get_timecount(struct timecounter *); -struct timecounter ipdclock_timecounter = { - .tc_get_timecount = ipdclock_get_timecount, +struct timecounter ioclock_timecounter = { + .tc_get_timecount = ioclock_get_timecount, .tc_poll_pps = NULL, .tc_counter_mask = 0xffffffff, /* truncated to 32 bits */ .tc_frequency = 0, /* determined at runtime */ - .tc_name = "ipdclock", - .tc_quality = 0 /* ipdclock can be overridden + .tc_name = "ioclock", + .tc_quality = 0, /* ioclock can be overridden * by cp0 counter */ + .tc_priv = 0 /* clock register, + * determined at runtime */ }; void @@ -521,8 +523,16 @@ mips_init(register_t a0, register_t a1, register_t a2, register_t a3) db_enter(); #endif - ipdclock_timecounter.tc_frequency = octeon_ioclock_speed(); - tc_init(&ipdclock_timecounter); + switch (octeon_model_family(prid)) { + case OCTEON_MODEL_FAMILY_CN73XX: + ioclock_timecounter.tc_priv = (void *)FPA3_CLK_COUNT; + break; + default: + ioclock_timecounter.tc_priv = (void *)IPD_CLK_COUNT; + break; + } + ioclock_timecounter.tc_frequency = octeon_ioclock_speed(); + tc_init(&ioclock_timecounter); /* * Return the new kernel stack pointer. @@ -830,9 +840,11 @@ is_memory_range(paddr_t pa, psize_t len, psize_t limit) } u_int -ipdclock_get_timecount(struct timecounter *arg) +ioclock_get_timecount(struct timecounter *tc) { - return octeon_xkphys_read_8(IPD_CLK_COUNT); + uint64_t reg = (uint64_t)tc->tc_priv; + + return octeon_xkphys_read_8(reg); } #ifdef MULTIPROCESSOR