Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/omap Move am335x_sys_clk() and am335x_cpu_clk()...



details:   https://anonhg.NetBSD.org/src/rev/e203b974cfb8
branches:  trunk
changeset: 787725:e203b974cfb8
user:      matt <matt%NetBSD.org@localhost>
date:      Sat Jun 29 20:43:33 2013 +0000

description:
Move am335x_sys_clk() and am335x_cpu_clk() here.

diffstat:

 sys/arch/arm/omap/am335x_prcm.c |  34 ++++++++++++++++++++++++++++++++--
 sys/arch/arm/omap/am335x_prcm.h |   6 +++++-
 2 files changed, 37 insertions(+), 3 deletions(-)

diffs (79 lines):

diff -r c0ac4f130942 -r e203b974cfb8 sys/arch/arm/omap/am335x_prcm.c
--- a/sys/arch/arm/omap/am335x_prcm.c   Sat Jun 29 20:41:47 2013 +0000
+++ b/sys/arch/arm/omap/am335x_prcm.c   Sat Jun 29 20:43:33 2013 +0000
@@ -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 @@
                       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);
+}
diff -r c0ac4f130942 -r e203b974cfb8 sys/arch/arm/omap/am335x_prcm.h
--- a/sys/arch/arm/omap/am335x_prcm.h   Sat Jun 29 20:41:47 2013 +0000
+++ b/sys/arch/arm/omap/am335x_prcm.h   Sat Jun 29 20:43:33 2013 +0000
@@ -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 @@
 #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_ */



Home | Main Index | Thread Index | Old Index