Skip to content

Commit b408b61

Browse files
committed
mips: ar7: convert to CONFIG_COMMON_CLK
Perform a minimal conversion of the ar7 clock implementation to the common clock framework. While the hardware can control the rates, this is left unchanged, and all clocks are registered as fixed-rate or fixed-divider clocks. Similarly, the clkdev lookup information is left unchanged but moved from the table format into individual allocations. There is a small increase in code size: text data bss dec hex filename 4757116 596640 91328 5445084 5315dc vmlinux-before 4806159 602360 91344 5499863 53ebd7 vmlinux-after Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 4410c42 commit b408b61

File tree

3 files changed

+29
-80
lines changed

3 files changed

+29
-80
lines changed

arch/mips/Kconfig

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ config MIPS_ALCHEMY
201201
config AR7
202202
bool "Texas Instruments AR7"
203203
select BOOT_ELF32
204+
select COMMON_CLK
204205
select DMA_NONCOHERENT
205206
select CEVT_R4K
206207
select CSRC_R4K
@@ -215,8 +216,6 @@ config AR7
215216
select SYS_SUPPORTS_ZBOOT_UART16550
216217
select GPIOLIB
217218
select VLYNQ
218-
select CLKDEV_LOOKUP
219-
select HAVE_LEGACY_CLK
220219
help
221220
Support for the Texas Instruments AR7 System-on-a-Chip
222221
family: TNETD7100, 7200 and 7300.

arch/mips/ar7/clock.c

Lines changed: 28 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/err.h>
1616
#include <linux/clkdev.h>
1717
#include <linux/clk.h>
18+
#include <linux/clk-provider.h>
1819

1920
#include <asm/addrspace.h>
2021
#include <asm/mach-ar7/ar7.h>
@@ -85,17 +86,17 @@ struct tnetd7200_clocks {
8586
struct tnetd7200_clock usb;
8687
};
8788

88-
static struct clk bus_clk = {
89+
struct clk_rate {
90+
u32 rate;
91+
};
92+
static struct clk_rate bus_clk = {
8993
.rate = 125000000,
9094
};
9195

92-
static struct clk cpu_clk = {
96+
static struct clk_rate cpu_clk = {
9397
.rate = 150000000,
9498
};
9599

96-
static struct clk dsp_clk;
97-
static struct clk vbus_clk;
98-
99100
static void approximate(int base, int target, int *prediv,
100101
int *postdiv, int *mul)
101102
{
@@ -241,6 +242,8 @@ static void __init tnetd7300_init_clocks(void)
241242
struct tnetd7300_clocks *clocks =
242243
ioremap(UR8_REGS_CLOCKS,
243244
sizeof(struct tnetd7300_clocks));
245+
u32 dsp_clk;
246+
struct clk *clk;
244247

245248
bus_clk.rate = tnetd7300_get_clock(BUS_PLL_SOURCE_SHIFT,
246249
&clocks->bus, bootcr, AR7_AFE_CLOCK);
@@ -251,12 +254,18 @@ static void __init tnetd7300_init_clocks(void)
251254
else
252255
cpu_clk.rate = bus_clk.rate;
253256

254-
if (dsp_clk.rate == 250000000)
257+
dsp_clk = tnetd7300_dsp_clock();
258+
if (dsp_clk == 250000000)
255259
tnetd7300_set_clock(DSP_PLL_SOURCE_SHIFT, &clocks->dsp,
256-
bootcr, dsp_clk.rate);
260+
bootcr, dsp_clk);
257261

258262
iounmap(clocks);
259263
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);
260269
}
261270

262271
static void tnetd7200_set_clock(int base, struct tnetd7200_clock *clock,
@@ -328,6 +337,7 @@ static void __init tnetd7200_init_clocks(void)
328337
int cpu_base, cpu_mul, cpu_prediv, cpu_postdiv;
329338
int dsp_base, dsp_mul, dsp_prediv, dsp_postdiv;
330339
int usb_base, usb_mul, usb_prediv, usb_postdiv;
340+
struct clk *clk;
331341

332342
cpu_base = tnetd7200_get_clock_base(TNETD7200_CLOCK_ID_CPU, bootcr);
333343
dsp_base = tnetd7200_get_clock_base(TNETD7200_CLOCK_ID_DSP, bootcr);
@@ -396,90 +406,34 @@ static void __init tnetd7200_init_clocks(void)
396406
usb_prediv, usb_postdiv, -1, usb_mul,
397407
TNETD7200_DEF_USB_CLK);
398408

399-
dsp_clk.rate = cpu_clk.rate;
400-
401409
iounmap(clocks);
402410
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);
413411

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);
416415
}
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-
};
437416

438417
void __init ar7_init_clocks(void)
439418
{
419+
struct clk *clk;
420+
440421
switch (ar7_chip_id()) {
441422
case AR7_CHIP_7100:
442423
case AR7_CHIP_7200:
443424
tnetd7200_init_clocks();
444425
break;
445426
case AR7_CHIP_7300:
446-
dsp_clk.rate = tnetd7300_dsp_clock();
447427
tnetd7300_init_clocks();
448428
break;
449429
default:
450430
break;
451431
}
432+
clk = clk_register_fixed_rate(NULL, "bus", NULL, 0, bus_clk.rate);
433+
clkdev_create(clk, "bus", NULL);
452434
/* 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");
484439
}
485-
EXPORT_SYMBOL(clk_get_parent);

arch/mips/include/asm/mach-ar7/ar7.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,6 @@ static inline u8 ar7_chip_rev(void)
131131
0x14))) >> 16) & 0xff;
132132
}
133133

134-
struct clk {
135-
unsigned int rate;
136-
};
137-
138134
static inline int ar7_has_high_cpmac(void)
139135
{
140136
u16 chip_id = ar7_chip_id();

0 commit comments

Comments
 (0)