Module Name: src Committed By: skrll Date: Wed Jan 17 06:56:50 UTC 2024
Modified Files: src/sys/arch/riscv/starfive: jh7100_clkc.c Log Message: Implement jh7100_clkc_fracdiv_get_rate To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/starfive/jh7100_clkc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/riscv/starfive/jh7100_clkc.c diff -u src/sys/arch/riscv/starfive/jh7100_clkc.c:1.1 src/sys/arch/riscv/starfive/jh7100_clkc.c:1.2 --- src/sys/arch/riscv/starfive/jh7100_clkc.c:1.1 Tue Jan 16 09:06:46 2024 +++ src/sys/arch/riscv/starfive/jh7100_clkc.c Wed Jan 17 06:56:50 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: jh7100_clkc.c,v 1.1 2024/01/16 09:06:46 skrll Exp $ */ +/* $NetBSD: jh7100_clkc.c,v 1.2 2024/01/17 06:56:50 skrll Exp $ */ /*- * Copyright (c) 2023 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: jh7100_clkc.c,v 1.1 2024/01/16 09:06:46 skrll Exp $"); +__KERNEL_RCSID(0, "$NetBSD: jh7100_clkc.c,v 1.2 2024/01/17 06:56:50 skrll Exp $"); #include <sys/param.h> @@ -395,9 +395,12 @@ jh7100_clkc_fracdiv_get_rate(struct jh71 if (rate == 0) return 0; - panic("Implement me"); + uint32_t val = RD4(sc, jcc->jcc_reg); + unsigned long div100 = + 100UL * __SHIFTOUT(val, JH7100_CLK_INT_MASK) + + __SHIFTOUT(val, JH7100_CLK_FRAC_MASK); - return rate; + return (div100 >= JH7100_CLK_FRAC_MIN) ? 100UL * rate / div100 : 0; } int