Date: Wed, 31 May 2006 05:42:52 GMT From: Kevin Lo <kevlo@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 98190 for review Message-ID: <200605310542.k4V5gqCv034225@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=98190 Change 98190 by kevlo@kevlo_rtsl on 2006/05/31 05:42:16 Implement s3c24x0_clock_freq and s3c24x0_clock_freq2. Obtained from: NetBSD Affected files ... .. //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#3 edit Differences ... ==== //depot/projects/arm/src/sys/arm/s3c2xx0/s3c2410.c#3 (text+ko) ==== @@ -158,18 +158,59 @@ S3C24X0_TIMER_SIZE, 0, &sc->sc_timer_ioh)) panic("cannot map TIMER"); -#if 0 /* calculate current clock frequency */ s3c24x0_clock_freq(&sc->sc_sx); printf(": fclk %d MHz hclk %d MHz pclk %d MHz", sc->sc_sx.sc_fclk / 1000000, sc->sc_sx.sc_hclk / 1000000, sc->sc_sx.sc_pclk / 1000000); -#endif printf("\n"); /* get busdma tag for the platform */ } +/* + * fill sc_pclk, sc_hclk, sc_fclk from values of clock controller register. + * + * s3c24x0_clock_freq2() is meant to be called from kernel startup routines. + * s3c24x0_clock_freq() is for after kernel initialization is done. + */ +void +s3c24x0_clock_freq2(vm_offset_t clkman_base, int *fclk, int *hclk, int *pclk) +{ + uint32_t pllcon, divn; + int mdiv, pdiv, sdiv; + int f, h, p; + + pllcon = *(volatile uint32_t *)(clkman_base + CLKMAN_MPLLCON); + divn = *(volatile uint32_t *)(clkman_base + CLKMAN_CLKDIVN); + + mdiv = (pllcon & PLLCON_MDIV_MASK) >> PLLCON_MDIV_SHIFT; + pdiv = (pllcon & PLLCON_PDIV_MASK) >> PLLCON_PDIV_SHIFT; + sdiv = (pllcon & PLLCON_SDIV_MASK) >> PLLCON_SDIV_SHIFT; + + f = ((mdiv + 8) * S3C2XX0_XTAL_CLK) / ((pdiv + 2) * (1 << sdiv)); + h = f; + if (divn & CLKDIVN_HDIVN) + h /= 2; + p = h; + if (divn & CLKDIVN_PDIVN) + p /= 2; + + if (fclk) *fclk = f; + if (hclk) *hclk = h; + if (pclk) *pclk = p; + +} + +void +s3c24x0_clock_freq(struct s3c2xx0_softc *sc) +{ + vm_offset_t va; + + va = sc->sc_clkman_ioh; + s3c24x0_clock_freq2(va, &sc->sc_fclk, &sc->sc_hclk, &sc->sc_pclk); +} + void cpu_reset(void) {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200605310542.k4V5gqCv034225>