15
15
#include <linux/err.h>
16
16
#include <linux/clkdev.h>
17
17
#include <linux/clk.h>
18
+ #include <linux/clk-provider.h>
18
19
19
20
#include <asm/addrspace.h>
20
21
#include <asm/mach-ar7/ar7.h>
@@ -85,17 +86,17 @@ struct tnetd7200_clocks {
85
86
struct tnetd7200_clock usb ;
86
87
};
87
88
88
- static struct clk bus_clk = {
89
+ struct clk_rate {
90
+ u32 rate ;
91
+ };
92
+ static struct clk_rate bus_clk = {
89
93
.rate = 125000000 ,
90
94
};
91
95
92
- static struct clk cpu_clk = {
96
+ static struct clk_rate cpu_clk = {
93
97
.rate = 150000000 ,
94
98
};
95
99
96
- static struct clk dsp_clk ;
97
- static struct clk vbus_clk ;
98
-
99
100
static void approximate (int base , int target , int * prediv ,
100
101
int * postdiv , int * mul )
101
102
{
@@ -241,6 +242,8 @@ static void __init tnetd7300_init_clocks(void)
241
242
struct tnetd7300_clocks * clocks =
242
243
ioremap (UR8_REGS_CLOCKS ,
243
244
sizeof (struct tnetd7300_clocks ));
245
+ u32 dsp_clk ;
246
+ struct clk * clk ;
244
247
245
248
bus_clk .rate = tnetd7300_get_clock (BUS_PLL_SOURCE_SHIFT ,
246
249
& clocks -> bus , bootcr , AR7_AFE_CLOCK );
@@ -251,12 +254,18 @@ static void __init tnetd7300_init_clocks(void)
251
254
else
252
255
cpu_clk .rate = bus_clk .rate ;
253
256
254
- if (dsp_clk .rate == 250000000 )
257
+ dsp_clk = tnetd7300_dsp_clock ();
258
+ if (dsp_clk == 250000000 )
255
259
tnetd7300_set_clock (DSP_PLL_SOURCE_SHIFT , & clocks -> dsp ,
256
- bootcr , dsp_clk . rate );
260
+ bootcr , dsp_clk );
257
261
258
262
iounmap (clocks );
259
263
iounmap (bootcr );
264
+
265
+ clk = clk_register_fixed_rate (NULL , "cpu" , NULL , 0 , cpu_clk .rate );
266
+ clkdev_create (clk , "cpu" , NULL );
267
+ clk = clk_register_fixed_rate (NULL , "dsp" , NULL , 0 , dsp_clk );
268
+ clkdev_create (clk , "dsp" , NULL );
260
269
}
261
270
262
271
static void tnetd7200_set_clock (int base , struct tnetd7200_clock * clock ,
@@ -328,6 +337,7 @@ static void __init tnetd7200_init_clocks(void)
328
337
int cpu_base , cpu_mul , cpu_prediv , cpu_postdiv ;
329
338
int dsp_base , dsp_mul , dsp_prediv , dsp_postdiv ;
330
339
int usb_base , usb_mul , usb_prediv , usb_postdiv ;
340
+ struct clk * clk ;
331
341
332
342
cpu_base = tnetd7200_get_clock_base (TNETD7200_CLOCK_ID_CPU , bootcr );
333
343
dsp_base = tnetd7200_get_clock_base (TNETD7200_CLOCK_ID_DSP , bootcr );
@@ -396,90 +406,34 @@ static void __init tnetd7200_init_clocks(void)
396
406
usb_prediv , usb_postdiv , -1 , usb_mul ,
397
407
TNETD7200_DEF_USB_CLK );
398
408
399
- dsp_clk .rate = cpu_clk .rate ;
400
-
401
409
iounmap (clocks );
402
410
iounmap (bootcr );
403
- }
404
-
405
- /*
406
- * Linux clock API
407
- */
408
- int clk_enable (struct clk * clk )
409
- {
410
- return 0 ;
411
- }
412
- EXPORT_SYMBOL (clk_enable );
413
411
414
- void clk_disable (struct clk * clk )
415
- {
412
+ clk = clk_register_fixed_rate (NULL , "cpu" , NULL , 0 , cpu_clk .rate );
413
+ clkdev_create (clk , "cpu" , NULL );
414
+ clkdev_create (clk , "dsp" , NULL );
416
415
}
417
- EXPORT_SYMBOL (clk_disable );
418
-
419
- unsigned long clk_get_rate (struct clk * clk )
420
- {
421
- if (!clk )
422
- return 0 ;
423
-
424
- return clk -> rate ;
425
- }
426
- EXPORT_SYMBOL (clk_get_rate );
427
-
428
- static struct clk_lookup ar7_clkdev_table [] = {
429
- CLKDEV_INIT (NULL , "bus" , & bus_clk ),
430
- /* cpmac and vbus share the same rate */
431
- CLKDEV_INIT ("cpmac.0" , "cpmac" , & vbus_clk ),
432
- CLKDEV_INIT ("cpmac.1" , "cpmac" , & vbus_clk ),
433
- CLKDEV_INIT (NULL , "cpu" , & cpu_clk ),
434
- CLKDEV_INIT (NULL , "dsp" , & dsp_clk ),
435
- CLKDEV_INIT (NULL , "vbus" , & vbus_clk ),
436
- };
437
416
438
417
void __init ar7_init_clocks (void )
439
418
{
419
+ struct clk * clk ;
420
+
440
421
switch (ar7_chip_id ()) {
441
422
case AR7_CHIP_7100 :
442
423
case AR7_CHIP_7200 :
443
424
tnetd7200_init_clocks ();
444
425
break ;
445
426
case AR7_CHIP_7300 :
446
- dsp_clk .rate = tnetd7300_dsp_clock ();
447
427
tnetd7300_init_clocks ();
448
428
break ;
449
429
default :
450
430
break ;
451
431
}
432
+ clk = clk_register_fixed_rate (NULL , "bus" , NULL , 0 , bus_clk .rate );
433
+ clkdev_create (clk , "bus" , NULL );
452
434
/* adjust vbus clock rate */
453
- vbus_clk .rate = bus_clk .rate / 2 ;
454
-
455
- clkdev_add_table (ar7_clkdev_table , ARRAY_SIZE (ar7_clkdev_table ));
456
- }
457
-
458
- /* dummy functions, should not be called */
459
- long clk_round_rate (struct clk * clk , unsigned long rate )
460
- {
461
- WARN_ON (clk );
462
- return 0 ;
463
- }
464
- EXPORT_SYMBOL (clk_round_rate );
465
-
466
- int clk_set_rate (struct clk * clk , unsigned long rate )
467
- {
468
- WARN_ON (clk );
469
- return 0 ;
470
- }
471
- EXPORT_SYMBOL (clk_set_rate );
472
-
473
- int clk_set_parent (struct clk * clk , struct clk * parent )
474
- {
475
- WARN_ON (clk );
476
- return 0 ;
477
- }
478
- EXPORT_SYMBOL (clk_set_parent );
479
-
480
- struct clk * clk_get_parent (struct clk * clk )
481
- {
482
- WARN_ON (clk );
483
- return NULL ;
435
+ clk = clk_register_fixed_factor (NULL , "vbus" , "bus" , 0 , 1 , 2 );
436
+ clkdev_create (clk , "vbus" , NULL );
437
+ clkdev_create (clk , "cpmac" , "cpmac.1" );
438
+ clkdev_create (clk , "cpmac" , "cpmac.1" );
484
439
}
485
- EXPORT_SYMBOL (clk_get_parent );
0 commit comments