24
24
* Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com
25
25
*/
26
26
27
+ #include <linux/clk.h>
27
28
#include <linux/init.h>
28
29
#include <linux/time.h>
29
30
#include <linux/sched_clock.h>
@@ -76,6 +77,49 @@ static u64 notrace omap_32k_read_sched_clock(void)
76
77
return ti_32k_read_cycles (& ti_32k_timer .cs );
77
78
}
78
79
80
+ static void __init ti_32k_timer_enable_clock (struct device_node * np ,
81
+ const char * name )
82
+ {
83
+ struct clk * clock ;
84
+ int error ;
85
+
86
+ clock = of_clk_get_by_name (np -> parent , name );
87
+ if (IS_ERR (clock )) {
88
+ /* Only some SoCs have a separate interface clock */
89
+ if (PTR_ERR (clock ) == - EINVAL && !strncmp ("ick" , name , 3 ))
90
+ return ;
91
+
92
+ pr_warn ("%s: could not get clock %s %li\n" ,
93
+ __func__ , name , PTR_ERR (clock ));
94
+ return ;
95
+ }
96
+
97
+ error = clk_prepare_enable (clock );
98
+ if (error ) {
99
+ pr_warn ("%s: could not enable %s: %i\n" ,
100
+ __func__ , name , error );
101
+ return ;
102
+ }
103
+ }
104
+
105
+ static void __init ti_32k_timer_module_init (struct device_node * np ,
106
+ void __iomem * base )
107
+ {
108
+ void __iomem * sysc = base + 4 ;
109
+
110
+ if (!of_device_is_compatible (np -> parent , "ti,sysc" ))
111
+ return ;
112
+
113
+ ti_32k_timer_enable_clock (np , "fck" );
114
+ ti_32k_timer_enable_clock (np , "ick" );
115
+
116
+ /*
117
+ * Force idle module as wkup domain is active with MPU.
118
+ * No need to tag the module disabled for ti-sysc probe.
119
+ */
120
+ writel_relaxed (0 , sysc );
121
+ }
122
+
79
123
static int __init ti_32k_timer_init (struct device_node * np )
80
124
{
81
125
int ret ;
@@ -90,6 +134,7 @@ static int __init ti_32k_timer_init(struct device_node *np)
90
134
ti_32k_timer .cs .flags |= CLOCK_SOURCE_SUSPEND_NONSTOP ;
91
135
92
136
ti_32k_timer .counter = ti_32k_timer .base ;
137
+ ti_32k_timer_module_init (np , ti_32k_timer .base );
93
138
94
139
/*
95
140
* 32k sync Counter IP register offsets vary between the highlander
@@ -104,14 +149,15 @@ static int __init ti_32k_timer_init(struct device_node *np)
104
149
else
105
150
ti_32k_timer .counter += OMAP2_32KSYNCNT_CR_OFF_LOW ;
106
151
152
+ pr_info ("OMAP clocksource: 32k_counter at 32768 Hz\n" );
153
+
107
154
ret = clocksource_register_hz (& ti_32k_timer .cs , 32768 );
108
155
if (ret ) {
109
156
pr_err ("32k_counter: can't register clocksource\n" );
110
157
return ret ;
111
158
}
112
159
113
160
sched_clock_register (omap_32k_read_sched_clock , 32 , 32768 );
114
- pr_info ("OMAP clocksource: 32k_counter at 32768 Hz\n" );
115
161
116
162
return 0 ;
117
163
}
0 commit comments