1616#include <linux/module.h>
1717#include <linux/string.h>
1818#include <linux/io.h>
19+
20+ #include <asm/clkdev.h>
1921#include <asm/div64.h>
2022#include <mach/hardware.h>
2123
2224struct clk {
23- char * name ;
2425 unsigned long rate ;
2526 int users ;
2627 u32 enable_reg ;
2728 u32 enable_mask ;
2829};
2930
3031static struct clk clk_uart = {
31- .name = "UARTCLK" ,
3232 .rate = 14745600 ,
3333};
34- static struct clk clk_pll1 = {
35- .name = "pll1" ,
36- };
37- static struct clk clk_f = {
38- .name = "fclk" ,
39- };
40- static struct clk clk_h = {
41- .name = "hclk" ,
42- };
43- static struct clk clk_p = {
44- .name = "pclk" ,
45- };
46- static struct clk clk_pll2 = {
47- .name = "pll2" ,
48- };
34+ static struct clk clk_pll1 ;
35+ static struct clk clk_f ;
36+ static struct clk clk_h ;
37+ static struct clk clk_p ;
38+ static struct clk clk_pll2 ;
4939static struct clk clk_usb_host = {
50- .name = "usb_host" ,
5140 .enable_reg = EP93XX_SYSCON_CLOCK_CONTROL ,
5241 .enable_mask = EP93XX_SYSCON_CLOCK_USH_EN ,
5342};
5443
55-
56- static struct clk * clocks [] = {
57- & clk_uart ,
58- & clk_pll1 ,
59- & clk_f ,
60- & clk_h ,
61- & clk_p ,
62- & clk_pll2 ,
63- & clk_usb_host ,
44+ #define INIT_CK (dev ,con ,ck ) \
45+ { .dev_id = dev, .con_id = con, .clk = ck }
46+
47+ static struct clk_lookup clocks [] = {
48+ INIT_CK ("apb:uart1" , NULL , & clk_uart ),
49+ INIT_CK ("apb:uart2" , NULL , & clk_uart ),
50+ INIT_CK ("apb:uart3" , NULL , & clk_uart ),
51+ INIT_CK (NULL , "pll1" , & clk_pll1 ),
52+ INIT_CK (NULL , "fclk" , & clk_f ),
53+ INIT_CK (NULL , "hclk" , & clk_h ),
54+ INIT_CK (NULL , "pclk" , & clk_p ),
55+ INIT_CK (NULL , "pll2" , & clk_pll2 ),
56+ INIT_CK (NULL , "usb_host" , & clk_usb_host ),
6457};
6558
66- struct clk * clk_get (struct device * dev , const char * id )
67- {
68- int i ;
69-
70- for (i = 0 ; i < ARRAY_SIZE (clocks ); i ++ ) {
71- if (!strcmp (clocks [i ]-> name , id ))
72- return clocks [i ];
73- }
74-
75- return ERR_PTR (- ENOENT );
76- }
77- EXPORT_SYMBOL (clk_get );
7859
7960int clk_enable (struct clk * clk )
8061{
@@ -106,12 +87,6 @@ unsigned long clk_get_rate(struct clk *clk)
10687}
10788EXPORT_SYMBOL (clk_get_rate );
10889
109- void clk_put (struct clk * clk )
110- {
111- }
112- EXPORT_SYMBOL (clk_put );
113-
114-
11590
11691static char fclk_divisors [] = { 1 , 2 , 4 , 8 , 16 , 1 , 1 , 1 };
11792static char hclk_divisors [] = { 1 , 2 , 4 , 5 , 6 , 8 , 16 , 32 };
@@ -138,6 +113,7 @@ static unsigned long calc_pll_rate(u32 config_word)
138113static int __init ep93xx_clock_init (void )
139114{
140115 u32 value ;
116+ int i ;
141117
142118 value = __raw_readl (EP93XX_SYSCON_CLOCK_SET1 );
143119 if (!(value & 0x00800000 )) { /* PLL1 bypassed? */
@@ -165,6 +141,8 @@ static int __init ep93xx_clock_init(void)
165141 clk_f .rate / 1000000 , clk_h .rate / 1000000 ,
166142 clk_p .rate / 1000000 );
167143
144+ for (i = 0 ; i < ARRAY_SIZE (clocks ); i ++ )
145+ clkdev_add (& clocks [i ]);
168146 return 0 ;
169147}
170148arch_initcall (ep93xx_clock_init );
0 commit comments