Skip to content

Commit 007f84e

Browse files
committed
m68k: coldfire: remove private clk_get/clk_put
Only three SoCs remain that use the custom clk_get/clk_put. Move these over to clkdev_lookup tables as well. As before, treat the "sys.0" and "pll.0" clocks as system-wide clocks, and all the other ones as device specific. The "name" field in 'struct clock' is now unused, so rename that as well as a cleanup and to reduce the object code size. The DEFINE_CLK macro could be changed the same way, but it is less churn to just leave those in place, that can be done as a follow-up later if someone is interested. Acked-by: Greg Ungerer <[email protected]> Tested-by: Greg Ungerer <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 63aadb7 commit 007f84e

File tree

6 files changed

+128
-158
lines changed

6 files changed

+128
-158
lines changed

arch/m68k/Kconfig.cpu

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ config COLDFIRE
2929
select CPU_HAS_NO_MULDIV64
3030
select GENERIC_CSUM
3131
select GPIOLIB
32+
select CLKDEV_LOOKUP
3233
select HAVE_LEGACY_CLK
3334

3435
endchoice
@@ -328,10 +329,6 @@ config COLDFIRE_SLTIMERS
328329
bool
329330
select LEGACY_TIMER_TICK
330331

331-
config COLDFIRE_CLKDEV_LOOKUP
332-
def_bool !(M5206 || M5206e || M53xx || M5441x)
333-
select CLKDEV_LOOKUP
334-
335332
endif # COLDFIRE
336333

337334

arch/m68k/coldfire/clk.c

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,27 +71,6 @@ struct clk_ops clk_ops1 = {
7171
.disable = __clk_disable1,
7272
};
7373
#endif /* MCFPM_PPMCR1 */
74-
75-
struct clk *clk_get(struct device *dev, const char *id)
76-
{
77-
const char *clk_name = dev ? dev_name(dev) : id ? id : NULL;
78-
struct clk *clk;
79-
unsigned i;
80-
81-
for (i = 0; (clk = mcf_clks[i]) != NULL; ++i)
82-
if (!strcmp(clk->name, clk_name))
83-
return clk;
84-
pr_warn("clk_get: didn't find clock %s\n", clk_name);
85-
return ERR_PTR(-ENOENT);
86-
}
87-
EXPORT_SYMBOL(clk_get);
88-
89-
void clk_put(struct clk *clk)
90-
{
91-
if (clk->enabled != 0)
92-
pr_warn("clk_put %s still enabled\n", clk->name);
93-
}
94-
EXPORT_SYMBOL(clk_put);
9574
#endif /* MCFPM_PPMCR0 */
9675

9776
int clk_enable(struct clk *clk)

arch/m68k/coldfire/m520x.c

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
/***************************************************************************/
1414

15+
#include <linux/clkdev.h>
1516
#include <linux/kernel.h>
1617
#include <linux/param.h>
1718
#include <linux/init.h>
@@ -48,31 +49,29 @@ DEFINE_CLK(0, "sys.0", 40, MCF_BUSCLK);
4849
DEFINE_CLK(0, "gpio.0", 41, MCF_BUSCLK);
4950
DEFINE_CLK(0, "sdram.0", 42, MCF_CLK);
5051

51-
struct clk *mcf_clks[] = {
52-
&__clk_0_2, /* flexbus */
53-
&__clk_0_12, /* fec.0 */
54-
&__clk_0_17, /* edma */
55-
&__clk_0_18, /* intc.0 */
56-
&__clk_0_21, /* iack.0 */
57-
&__clk_0_22, /* imx1-i2c.0 */
58-
&__clk_0_23, /* mcfqspi.0 */
59-
&__clk_0_24, /* mcfuart.0 */
60-
&__clk_0_25, /* mcfuart.1 */
61-
&__clk_0_26, /* mcfuart.2 */
62-
&__clk_0_28, /* mcftmr.0 */
63-
&__clk_0_29, /* mcftmr.1 */
64-
&__clk_0_30, /* mcftmr.2 */
65-
&__clk_0_31, /* mcftmr.3 */
66-
67-
&__clk_0_32, /* mcfpit.0 */
68-
&__clk_0_33, /* mcfpit.1 */
69-
&__clk_0_34, /* mcfeport.0 */
70-
&__clk_0_35, /* mcfwdt.0 */
71-
&__clk_0_36, /* pll.0 */
72-
&__clk_0_40, /* sys.0 */
73-
&__clk_0_41, /* gpio.0 */
74-
&__clk_0_42, /* sdram.0 */
75-
NULL,
52+
static struct clk_lookup m520x_clk_lookup[] = {
53+
CLKDEV_INIT(NULL, "flexbus", &__clk_0_2),
54+
CLKDEV_INIT("fec.0", NULL, &__clk_0_12),
55+
CLKDEV_INIT("edma", NULL, &__clk_0_17),
56+
CLKDEV_INIT("intc.0", NULL, &__clk_0_18),
57+
CLKDEV_INIT("iack.0", NULL, &__clk_0_21),
58+
CLKDEV_INIT("imx1-i2c.0", NULL, &__clk_0_22),
59+
CLKDEV_INIT("mcfqspi.0", NULL, &__clk_0_23),
60+
CLKDEV_INIT("mcfuart.0", NULL, &__clk_0_24),
61+
CLKDEV_INIT("mcfuart.1", NULL, &__clk_0_25),
62+
CLKDEV_INIT("mcfuart.2", NULL, &__clk_0_26),
63+
CLKDEV_INIT("mcftmr.0", NULL, &__clk_0_28),
64+
CLKDEV_INIT("mcftmr.1", NULL, &__clk_0_29),
65+
CLKDEV_INIT("mcftmr.2", NULL, &__clk_0_30),
66+
CLKDEV_INIT("mcftmr.3", NULL, &__clk_0_31),
67+
CLKDEV_INIT("mcfpit.0", NULL, &__clk_0_32),
68+
CLKDEV_INIT("mcfpit.1", NULL, &__clk_0_33),
69+
CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_34),
70+
CLKDEV_INIT("mcfwdt.0", NULL, &__clk_0_35),
71+
CLKDEV_INIT(NULL, "pll.0", &__clk_0_36),
72+
CLKDEV_INIT(NULL, "sys.0", &__clk_0_40),
73+
CLKDEV_INIT("gpio.0", NULL, &__clk_0_41),
74+
CLKDEV_INIT("sdram.0", NULL, &__clk_0_42),
7675
};
7776

7877
static struct clk * const enable_clks[] __initconst = {
@@ -115,6 +114,8 @@ static void __init m520x_clk_init(void)
115114
/* make sure these clocks are disabled */
116115
for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
117116
__clk_init_disabled(disable_clks[i]);
117+
118+
clkdev_add_table(m520x_clk_lookup, ARRAY_SIZE(m520x_clk_lookup));
118119
}
119120

120121
/***************************************************************************/

arch/m68k/coldfire/m53xx.c

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
/***************************************************************************/
1515

16+
#include <linux/clkdev.h>
1617
#include <linux/kernel.h>
1718
#include <linux/param.h>
1819
#include <linux/init.h>
@@ -65,45 +66,42 @@ DEFINE_CLK(1, "mdha.0", 32, MCF_CLK);
6566
DEFINE_CLK(1, "skha.0", 33, MCF_CLK);
6667
DEFINE_CLK(1, "rng.0", 34, MCF_CLK);
6768

68-
struct clk *mcf_clks[] = {
69-
&__clk_0_2, /* flexbus */
70-
&__clk_0_8, /* mcfcan.0 */
71-
&__clk_0_12, /* fec.0 */
72-
&__clk_0_17, /* edma */
73-
&__clk_0_18, /* intc.0 */
74-
&__clk_0_19, /* intc.1 */
75-
&__clk_0_21, /* iack.0 */
76-
&__clk_0_22, /* imx1-i2c.0 */
77-
&__clk_0_23, /* mcfqspi.0 */
78-
&__clk_0_24, /* mcfuart.0 */
79-
&__clk_0_25, /* mcfuart.1 */
80-
&__clk_0_26, /* mcfuart.2 */
81-
&__clk_0_28, /* mcftmr.0 */
82-
&__clk_0_29, /* mcftmr.1 */
83-
&__clk_0_30, /* mcftmr.2 */
84-
&__clk_0_31, /* mcftmr.3 */
85-
86-
&__clk_0_32, /* mcfpit.0 */
87-
&__clk_0_33, /* mcfpit.1 */
88-
&__clk_0_34, /* mcfpit.2 */
89-
&__clk_0_35, /* mcfpit.3 */
90-
&__clk_0_36, /* mcfpwm.0 */
91-
&__clk_0_37, /* mcfeport.0 */
92-
&__clk_0_38, /* mcfwdt.0 */
93-
&__clk_0_40, /* sys.0 */
94-
&__clk_0_41, /* gpio.0 */
95-
&__clk_0_42, /* mcfrtc.0 */
96-
&__clk_0_43, /* mcflcd.0 */
97-
&__clk_0_44, /* mcfusb-otg.0 */
98-
&__clk_0_45, /* mcfusb-host.0 */
99-
&__clk_0_46, /* sdram.0 */
100-
&__clk_0_47, /* ssi.0 */
101-
&__clk_0_48, /* pll.0 */
102-
103-
&__clk_1_32, /* mdha.0 */
104-
&__clk_1_33, /* skha.0 */
105-
&__clk_1_34, /* rng.0 */
106-
NULL,
69+
static struct clk_lookup m53xx_clk_lookup[] = {
70+
CLKDEV_INIT("flexbus", NULL, &__clk_0_2),
71+
CLKDEV_INIT("mcfcan.0", NULL, &__clk_0_8),
72+
CLKDEV_INIT("fec.0", NULL, &__clk_0_12),
73+
CLKDEV_INIT("edma", NULL, &__clk_0_17),
74+
CLKDEV_INIT("intc.0", NULL, &__clk_0_18),
75+
CLKDEV_INIT("intc.1", NULL, &__clk_0_19),
76+
CLKDEV_INIT("iack.0", NULL, &__clk_0_21),
77+
CLKDEV_INIT("imx1-i2c.0", NULL, &__clk_0_22),
78+
CLKDEV_INIT("mcfqspi.0", NULL, &__clk_0_23),
79+
CLKDEV_INIT("mcfuart.0", NULL, &__clk_0_24),
80+
CLKDEV_INIT("mcfuart.1", NULL, &__clk_0_25),
81+
CLKDEV_INIT("mcfuart.2", NULL, &__clk_0_26),
82+
CLKDEV_INIT("mcftmr.0", NULL, &__clk_0_28),
83+
CLKDEV_INIT("mcftmr.1", NULL, &__clk_0_29),
84+
CLKDEV_INIT("mcftmr.2", NULL, &__clk_0_30),
85+
CLKDEV_INIT("mcftmr.3", NULL, &__clk_0_31),
86+
CLKDEV_INIT("mcfpit.0", NULL, &__clk_0_32),
87+
CLKDEV_INIT("mcfpit.1", NULL, &__clk_0_33),
88+
CLKDEV_INIT("mcfpit.2", NULL, &__clk_0_34),
89+
CLKDEV_INIT("mcfpit.3", NULL, &__clk_0_35),
90+
CLKDEV_INIT("mcfpwm.0", NULL, &__clk_0_36),
91+
CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_37),
92+
CLKDEV_INIT("mcfwdt.0", NULL, &__clk_0_38),
93+
CLKDEV_INIT(NULL, "sys.0", &__clk_0_40),
94+
CLKDEV_INIT("gpio.0", NULL, &__clk_0_41),
95+
CLKDEV_INIT("mcfrtc.0", NULL, &__clk_0_42),
96+
CLKDEV_INIT("mcflcd.0", NULL, &__clk_0_43),
97+
CLKDEV_INIT("mcfusb-otg.0", NULL, &__clk_0_44),
98+
CLKDEV_INIT("mcfusb-host.0", NULL, &__clk_0_45),
99+
CLKDEV_INIT("sdram.0", NULL, &__clk_0_46),
100+
CLKDEV_INIT("ssi.0", NULL, &__clk_0_47),
101+
CLKDEV_INIT(NULL, "pll.0", &__clk_0_48),
102+
CLKDEV_INIT("mdha.0", NULL, &__clk_1_32),
103+
CLKDEV_INIT("skha.0", NULL, &__clk_1_33),
104+
CLKDEV_INIT("rng.0", NULL, &__clk_1_34),
107105
};
108106

109107
static struct clk * const enable_clks[] __initconst = {
@@ -158,6 +156,8 @@ static void __init m53xx_clk_init(void)
158156
/* make sure these clocks are disabled */
159157
for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
160158
__clk_init_disabled(disable_clks[i]);
159+
160+
clkdev_add_table(m53xx_clk_lookup, ARRAY_SIZE(m53xx_clk_lookup));
161161
}
162162

163163
/***************************************************************************/

arch/m68k/coldfire/m5441x.c

Lines changed: 62 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* (C) Copyright Steven King <[email protected]>
66
*/
77

8+
#include <linux/clkdev.h>
89
#include <linux/kernel.h>
910
#include <linux/param.h>
1011
#include <linux/init.h>
@@ -78,72 +79,67 @@ DEFINE_CLK(2, "ipg.0", 0, MCF_CLK);
7879
DEFINE_CLK(2, "ahb.0", 1, MCF_CLK);
7980
DEFINE_CLK(2, "per.0", 2, MCF_CLK);
8081

81-
struct clk *mcf_clks[] = {
82-
&__clk_0_2,
83-
&__clk_0_8,
84-
&__clk_0_9,
85-
&__clk_0_14,
86-
&__clk_0_15,
87-
&__clk_0_17,
88-
&__clk_0_18,
89-
&__clk_0_19,
90-
&__clk_0_20,
91-
&__clk_0_22,
92-
&__clk_0_23,
93-
&__clk_0_24,
94-
&__clk_0_25,
95-
&__clk_0_26,
96-
&__clk_0_27,
97-
&__clk_0_28,
98-
&__clk_0_29,
99-
&__clk_0_30,
100-
&__clk_0_31,
101-
&__clk_0_32,
102-
&__clk_0_33,
103-
&__clk_0_34,
104-
&__clk_0_35,
105-
&__clk_0_37,
106-
&__clk_0_38,
107-
&__clk_0_39,
108-
&__clk_0_42,
109-
&__clk_0_43,
110-
&__clk_0_44,
111-
&__clk_0_45,
112-
&__clk_0_46,
113-
&__clk_0_47,
114-
&__clk_0_48,
115-
&__clk_0_49,
116-
&__clk_0_50,
117-
&__clk_0_51,
118-
&__clk_0_53,
119-
&__clk_0_54,
120-
&__clk_0_55,
121-
&__clk_0_56,
122-
&__clk_0_63,
123-
124-
&__clk_1_2,
125-
&__clk_1_4,
126-
&__clk_1_5,
127-
&__clk_1_6,
128-
&__clk_1_7,
129-
&__clk_1_24,
130-
&__clk_1_25,
131-
&__clk_1_26,
132-
&__clk_1_27,
133-
&__clk_1_28,
134-
&__clk_1_29,
135-
&__clk_1_34,
136-
&__clk_1_36,
137-
&__clk_1_37,
138-
139-
&__clk_2_0,
140-
&__clk_2_1,
141-
&__clk_2_2,
142-
143-
NULL,
82+
static struct clk_lookup m5411x_clk_lookup[] = {
83+
CLKDEV_INIT("flexbus", NULL, &__clk_0_2),
84+
CLKDEV_INIT("mcfcan.0", NULL, &__clk_0_8),
85+
CLKDEV_INIT("mcfcan.1", NULL, &__clk_0_9),
86+
CLKDEV_INIT("imx1-i2c.1", NULL, &__clk_0_14),
87+
CLKDEV_INIT("mcfdspi.1", NULL, &__clk_0_15),
88+
CLKDEV_INIT("edma", NULL, &__clk_0_17),
89+
CLKDEV_INIT("intc.0", NULL, &__clk_0_18),
90+
CLKDEV_INIT("intc.1", NULL, &__clk_0_19),
91+
CLKDEV_INIT("intc.2", NULL, &__clk_0_20),
92+
CLKDEV_INIT("imx1-i2c.0", NULL, &__clk_0_22),
93+
CLKDEV_INIT("fsl-dspi.0", NULL, &__clk_0_23),
94+
CLKDEV_INIT("mcfuart.0", NULL, &__clk_0_24),
95+
CLKDEV_INIT("mcfuart.1", NULL, &__clk_0_25),
96+
CLKDEV_INIT("mcfuart.2", NULL, &__clk_0_26),
97+
CLKDEV_INIT("mcfuart.3", NULL, &__clk_0_27),
98+
CLKDEV_INIT("mcftmr.0", NULL, &__clk_0_28),
99+
CLKDEV_INIT("mcftmr.1", NULL, &__clk_0_29),
100+
CLKDEV_INIT("mcftmr.2", NULL, &__clk_0_30),
101+
CLKDEV_INIT("mcftmr.3", NULL, &__clk_0_31),
102+
CLKDEV_INIT("mcfpit.0", NULL, &__clk_0_32),
103+
CLKDEV_INIT("mcfpit.1", NULL, &__clk_0_33),
104+
CLKDEV_INIT("mcfpit.2", NULL, &__clk_0_34),
105+
CLKDEV_INIT("mcfpit.3", NULL, &__clk_0_35),
106+
CLKDEV_INIT("mcfeport.0", NULL, &__clk_0_37),
107+
CLKDEV_INIT("mcfadc.0", NULL, &__clk_0_38),
108+
CLKDEV_INIT("mcfdac.0", NULL, &__clk_0_39),
109+
CLKDEV_INIT("mcfrtc.0", NULL, &__clk_0_42),
110+
CLKDEV_INIT("mcfsim.0", NULL, &__clk_0_43),
111+
CLKDEV_INIT("mcfusb-otg.0", NULL, &__clk_0_44),
112+
CLKDEV_INIT("mcfusb-host.0", NULL, &__clk_0_45),
113+
CLKDEV_INIT("mcfddr-sram.0", NULL, &__clk_0_46),
114+
CLKDEV_INIT("mcfssi.0", NULL, &__clk_0_47),
115+
CLKDEV_INIT(NULL, "pll.0", &__clk_0_48),
116+
CLKDEV_INIT("mcfrng.0", NULL, &__clk_0_49),
117+
CLKDEV_INIT("mcfssi.1", NULL, &__clk_0_50),
118+
CLKDEV_INIT("sdhci-esdhc-mcf.0", NULL, &__clk_0_51),
119+
CLKDEV_INIT("enet-fec.0", NULL, &__clk_0_53),
120+
CLKDEV_INIT("enet-fec.1", NULL, &__clk_0_54),
121+
CLKDEV_INIT("switch.0", NULL, &__clk_0_55),
122+
CLKDEV_INIT("switch.1", NULL, &__clk_0_56),
123+
CLKDEV_INIT("nand.0", NULL, &__clk_0_63),
124+
CLKDEV_INIT("mcfow.0", NULL, &__clk_1_2),
125+
CLKDEV_INIT("imx1-i2c.2", NULL, &__clk_1_4),
126+
CLKDEV_INIT("imx1-i2c.3", NULL, &__clk_1_5),
127+
CLKDEV_INIT("imx1-i2c.4", NULL, &__clk_1_6),
128+
CLKDEV_INIT("imx1-i2c.5", NULL, &__clk_1_7),
129+
CLKDEV_INIT("mcfuart.4", NULL, &__clk_1_24),
130+
CLKDEV_INIT("mcfuart.5", NULL, &__clk_1_25),
131+
CLKDEV_INIT("mcfuart.6", NULL, &__clk_1_26),
132+
CLKDEV_INIT("mcfuart.7", NULL, &__clk_1_27),
133+
CLKDEV_INIT("mcfuart.8", NULL, &__clk_1_28),
134+
CLKDEV_INIT("mcfuart.9", NULL, &__clk_1_29),
135+
CLKDEV_INIT("mcfpwm.0", NULL, &__clk_1_34),
136+
CLKDEV_INIT(NULL, "sys.0", &__clk_1_36),
137+
CLKDEV_INIT("gpio.0", NULL, &__clk_1_37),
138+
CLKDEV_INIT("ipg.0", NULL, &__clk_2_0),
139+
CLKDEV_INIT("ahb.0", NULL, &__clk_2_1),
140+
CLKDEV_INIT("per.0", NULL, &__clk_2_2),
144141
};
145142

146-
147143
static struct clk * const enable_clks[] __initconst = {
148144
/* make sure these clocks are enabled */
149145
&__clk_0_15, /* dspi.1 */
@@ -228,6 +224,8 @@ static void __init m5441x_clk_init(void)
228224
/* make sure these clocks are disabled */
229225
for (i = 0; i < ARRAY_SIZE(disable_clks); ++i)
230226
__clk_init_disabled(disable_clks[i]);
227+
228+
clkdev_add_table(m5411x_clk_lookup, ARRAY_SIZE(m5411x_clk_lookup));
231229
}
232230

233231
static void __init m5441x_uarts_init(void)

arch/m68k/include/asm/mcfclk.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ struct clk_ops {
1515
};
1616

1717
struct clk {
18-
const char *name;
1918
struct clk_ops *clk_ops;
2019
unsigned long rate;
2120
unsigned long enabled;
2221
u8 slot;
2322
};
2423

25-
extern struct clk *mcf_clks[];
26-
2724
#ifdef MCFPM_PPMCR0
2825
extern struct clk_ops clk_ops0;
2926
#ifdef MCFPM_PPMCR1
@@ -34,7 +31,6 @@ extern struct clk_ops clk_ops2;
3431

3532
#define DEFINE_CLK(clk_bank, clk_name, clk_slot, clk_rate) \
3633
static struct clk __clk_##clk_bank##_##clk_slot = { \
37-
.name = clk_name, \
3834
.clk_ops = &clk_ops##clk_bank, \
3935
.rate = clk_rate, \
4036
.slot = clk_slot, \
@@ -45,7 +41,6 @@ void __clk_init_disabled(struct clk *);
4541
#else
4642
#define DEFINE_CLK(clk_ref, clk_name, clk_rate) \
4743
static struct clk clk_##clk_ref = { \
48-
.name = clk_name, \
4944
.rate = clk_rate, \
5045
}
5146
#endif /* MCFPM_PPMCR0 */

0 commit comments

Comments
 (0)