Move am335x_sys_clk() and am335x_cpu_clk() here.

This commit is contained in:
matt 2013-06-29 20:43:33 +00:00
parent 052045ad4c
commit 3110b17134
2 changed files with 37 additions and 3 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: am335x_prcm.c,v 1.3 2013/06/29 20:21:41 matt Exp $ */
/* $NetBSD: am335x_prcm.c,v 1.4 2013/06/29 20:43:33 matt Exp $ */
/*
* TI OMAP Power, Reset, and Clock Management on the AM335x
@ -34,14 +34,16 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: am335x_prcm.c,v 1.3 2013/06/29 20:21:41 matt Exp $");
__KERNEL_RCSID(0, "$NetBSD: am335x_prcm.c,v 1.4 2013/06/29 20:43:33 matt Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/sysctl.h>
#include <arm/omap/am335x_prcm.h>
#include <arm/omap/omap2_reg.h>
#include <arm/omap/omap2_prcm.h>
#include <arm/omap/omap_var.h>
#define AM335X_CLKCTRL_MODULEMODE_MASK __BITS(0, 1)
#define AM335X_CLKCTRL_MODULEMODE_DISABLED 0
@ -216,3 +218,31 @@ SYSCTL_SETUP(sysctl_am335x_machdep_setup, "sysctl am335x machdep subtree setup")
mpu_current_frequency_sysctl_helper, 0, NULL, 0
CTL_CREATE, CTL_EOL);
}
void
am335x_sys_clk(bus_space_handle_t ctlmode_ioh)
{
static const uint32_t sys_clks[4] = {
[0] = 19200000, [1] = 24000000, [2] = 25000000, [3] = 26000000
};
const uint32_t control_status = bus_space_read_4(&omap_bs_tag,
ctlmode_ioh, CTLMOD_CONTROL_STATUS);
omap_sys_clk = sys_clks[__SHIFTOUT(control_status, CTLMOD_CONTROL_STATUS_SYSBOOT1)];
}
void
am335x_cpu_clk(void)
{
const bus_size_t cm_wkup = AM335X_PRCM_CM_WKUP;
const uint32_t clksel = prcm_read_4(cm_wkup, AM335X_PRCM_CM_CLKSEL_DPLL_MPU);
const uint32_t div_m2 = prcm_read_4(cm_wkup, AM335X_PRCM_CM_DIV_M2_DPLL_MPU);
const uint32_t m = __SHIFTOUT(clksel, AM335X_PRCM_CM_CLKSEL_DPLL_MULT);
const uint32_t n = __SHIFTOUT(clksel, AM335X_PRCM_CM_CLKSEL_DPLL_DIV);
const uint32_t m2 = __SHIFTOUT(div_m2, AM335X_PRCM_CM_DIV_M2_DPLL_CLKOUT_DIV);
/* XXX This ignores CM_CLKSEL_DPLL_MPU[DPLL_REGM4XEN]. */
curcpu()->ci_data.cpu_cc_freq = (m * ((uint64_t)omap_sys_clk / (n + 1))) / m2;
printf("%s: %"PRIu64": sys_clk=%u m=%u n=%u (%u) m2=%u\n",
__func__, curcpu()->ci_data.cpu_cc_freq,
omap_sys_clk, m, n, n+1, m2);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: am335x_prcm.h,v 1.4 2013/06/29 20:21:41 matt Exp $ */
/* $NetBSD: am335x_prcm.h,v 1.5 2013/06/29 20:43:33 matt Exp $ */
/*
* TI OMAP Power, Reset, and Clock Management on the AM335x
@ -83,6 +83,10 @@ struct omap_module {
#define RST_GLOBAL_WARM_SW __BIT(0)
#define RST_GLOBAL_COLD_SW __BIT(1)
#ifdef _KERNEL
void prcm_mpu_pll_config(u_int);
void am335x_sys_clk(bus_space_handle_t);
void am335x_cpu_clk(void);
#endif
#endif /* _ARM_OMAP_AM335X_PRCM_H_ */