Skip to content

Commit c5eb5b3

Browse files
committed
Merge branch 'sh/clkfwk'
2 parents 15f2a79 + f5ca6d4 commit c5eb5b3

23 files changed

Lines changed: 1698 additions & 1326 deletions

File tree

‎arch/sh/boards/mach-ecovec24/setup.c‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,6 @@ static struct clk_ops fsimck_clk_ops = {
710710
};
711711

712712
static struct clk fsimckb_clk = {
713-
.name = "fsimckb_clk",
714-
.id = -1,
715713
.ops = &fsimck_clk_ops,
716714
.enable_reg = (void __iomem *)FCLKBCR,
717715
.rate = 0, /* unknown */
@@ -1138,16 +1136,20 @@ static int __init arch_setup(void)
11381136

11391137
/* set SPU2 clock to 83.4 MHz */
11401138
clk = clk_get(NULL, "spu_clk");
1141-
clk_set_rate(clk, clk_round_rate(clk, 83333333));
1142-
clk_put(clk);
1139+
if (clk) {
1140+
clk_set_rate(clk, clk_round_rate(clk, 83333333));
1141+
clk_put(clk);
1142+
}
11431143

11441144
/* change parent of FSI B */
11451145
clk = clk_get(NULL, "fsib_clk");
1146-
clk_register(&fsimckb_clk);
1147-
clk_set_parent(clk, &fsimckb_clk);
1148-
clk_set_rate(clk, 11000);
1149-
clk_set_rate(&fsimckb_clk, 11000);
1150-
clk_put(clk);
1146+
if (clk) {
1147+
clk_register(&fsimckb_clk);
1148+
clk_set_parent(clk, &fsimckb_clk);
1149+
clk_set_rate(clk, 11000);
1150+
clk_set_rate(&fsimckb_clk, 11000);
1151+
clk_put(clk);
1152+
}
11511153

11521154
gpio_request(GPIO_PTU0, NULL);
11531155
gpio_direction_output(GPIO_PTU0, 0);
@@ -1159,8 +1161,10 @@ static int __init arch_setup(void)
11591161

11601162
/* set VPU clock to 166 MHz */
11611163
clk = clk_get(NULL, "vpu_clk");
1162-
clk_set_rate(clk, clk_round_rate(clk, 166000000));
1163-
clk_put(clk);
1164+
if (clk) {
1165+
clk_set_rate(clk, clk_round_rate(clk, 166000000));
1166+
clk_put(clk);
1167+
}
11641168

11651169
/* enable IrDA */
11661170
gpio_request(GPIO_FN_IRDA_OUT, NULL);

‎arch/sh/boards/mach-highlander/setup.c‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* for more details.
1515
*/
1616
#include <linux/init.h>
17+
#include <linux/io.h>
1718
#include <linux/platform_device.h>
1819
#include <linux/ata_platform.h>
1920
#include <linux/types.h>
@@ -26,6 +27,7 @@
2627
#include <net/ax88796.h>
2728
#include <asm/machvec.h>
2829
#include <mach/highlander.h>
30+
#include <asm/clkdev.h>
2931
#include <asm/clock.h>
3032
#include <asm/heartbeat.h>
3133
#include <asm/io.h>
@@ -326,14 +328,20 @@ static struct clk_ops ivdr_clk_ops = {
326328
};
327329

328330
static struct clk ivdr_clk = {
329-
.name = "ivdr_clk",
330331
.ops = &ivdr_clk_ops,
331332
};
332333

333334
static struct clk *r7780rp_clocks[] = {
334335
&ivdr_clk,
335336
};
336337

338+
#define CLKDEV_CON_ID(_id, _clk) { .con_id = _id, .clk = _clk }
339+
340+
static struct clk_lookup lookups[] = {
341+
/* main clocks */
342+
CLKDEV_CON_ID("ivdr_clk", &ivdr_clk),
343+
};
344+
337345
static void r7780rp_power_off(void)
338346
{
339347
if (mach_is_r7780mp() || mach_is_r7785rp())
@@ -370,6 +378,8 @@ static void __init highlander_setup(char **cmdline_p)
370378
clk_enable(clk);
371379
}
372380

381+
clkdev_add_table(lookups, ARRAY_SIZE(lookups));
382+
373383
__raw_writew(0x0000, PA_OBLED); /* Clear LED. */
374384

375385
if (mach_is_r7780rp())

‎arch/sh/boards/mach-se/7724/setup.c‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,6 @@ static struct clk_ops fsimck_clk_ops = {
276276
};
277277

278278
static struct clk fsimcka_clk = {
279-
.name = "fsimcka_clk",
280-
.id = -1,
281279
.ops = &fsimck_clk_ops,
282280
.enable_reg = (void __iomem *)FCLKACR,
283281
.rate = 0, /* unknown */
@@ -771,16 +769,20 @@ static int __init devices_setup(void)
771769

772770
/* set SPU2 clock to 83.4 MHz */
773771
clk = clk_get(NULL, "spu_clk");
774-
clk_set_rate(clk, clk_round_rate(clk, 83333333));
775-
clk_put(clk);
772+
if (clk) {
773+
clk_set_rate(clk, clk_round_rate(clk, 83333333));
774+
clk_put(clk);
775+
}
776776

777777
/* change parent of FSI A */
778778
clk = clk_get(NULL, "fsia_clk");
779-
clk_register(&fsimcka_clk);
780-
clk_set_parent(clk, &fsimcka_clk);
781-
clk_set_rate(clk, 11000);
782-
clk_set_rate(&fsimcka_clk, 11000);
783-
clk_put(clk);
779+
if (clk) {
780+
clk_register(&fsimcka_clk);
781+
clk_set_parent(clk, &fsimcka_clk);
782+
clk_set_rate(clk, 11000);
783+
clk_set_rate(&fsimcka_clk, 11000);
784+
clk_put(clk);
785+
}
784786

785787
/* SDHI0 connected to cn7 */
786788
gpio_request(GPIO_FN_SDHI0CD, NULL);

‎arch/sh/include/asm/clock.h‎

Lines changed: 3 additions & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,16 @@
11
#ifndef __ASM_SH_CLOCK_H
22
#define __ASM_SH_CLOCK_H
33

4-
#include <linux/list.h>
5-
#include <linux/seq_file.h>
6-
#include <linux/cpufreq.h>
7-
#include <linux/clk.h>
8-
#include <linux/err.h>
9-
10-
struct clk;
11-
12-
struct clk_ops {
13-
void (*init)(struct clk *clk);
14-
int (*enable)(struct clk *clk);
15-
void (*disable)(struct clk *clk);
16-
unsigned long (*recalc)(struct clk *clk);
17-
int (*set_rate)(struct clk *clk, unsigned long rate, int algo_id);
18-
int (*set_parent)(struct clk *clk, struct clk *parent);
19-
long (*round_rate)(struct clk *clk, unsigned long rate);
20-
};
21-
22-
struct clk {
23-
struct list_head node;
24-
const char *name;
25-
int id;
26-
struct module *owner;
27-
28-
struct clk *parent;
29-
struct clk_ops *ops;
30-
31-
struct list_head children;
32-
struct list_head sibling; /* node for children */
33-
34-
int usecount;
35-
36-
unsigned long rate;
37-
unsigned long flags;
38-
39-
void __iomem *enable_reg;
40-
unsigned int enable_bit;
41-
42-
unsigned long arch_flags;
43-
void *priv;
44-
struct dentry *dentry;
45-
struct cpufreq_frequency_table *freq_table;
46-
};
47-
48-
#define CLK_ENABLE_ON_INIT (1 << 0)
4+
#include <linux/sh_clk.h>
495

506
/* Should be defined by processor-specific code */
517
void __deprecated arch_init_clk_ops(struct clk_ops **, int type);
528
int __init arch_clk_init(void);
539

54-
/* arch/sh/kernel/cpu/clock.c */
55-
int clk_init(void);
56-
unsigned long followparent_recalc(struct clk *);
57-
void recalculate_root_clocks(void);
58-
void propagate_rate(struct clk *);
59-
int clk_reparent(struct clk *child, struct clk *parent);
60-
int clk_register(struct clk *);
61-
void clk_unregister(struct clk *);
62-
6310
/* arch/sh/kernel/cpu/clock-cpg.c */
6411
int __init __deprecated cpg_clk_init(void);
6512

66-
/* the exported API, in addition to clk_set_rate */
67-
/**
68-
* clk_set_rate_ex - set the clock rate for a clock source, with additional parameter
69-
* @clk: clock source
70-
* @rate: desired clock rate in Hz
71-
* @algo_id: algorithm id to be passed down to ops->set_rate
72-
*
73-
* Returns success (0) or negative errno.
74-
*/
75-
int clk_set_rate_ex(struct clk *clk, unsigned long rate, int algo_id);
76-
77-
enum clk_sh_algo_id {
78-
NO_CHANGE = 0,
79-
80-
IUS_N1_N1,
81-
IUS_322,
82-
IUS_522,
83-
IUS_N11,
84-
85-
SB_N1,
86-
87-
SB3_N1,
88-
SB3_32,
89-
SB3_43,
90-
SB3_54,
91-
92-
BP_N1,
93-
94-
IP_N1,
95-
};
96-
97-
struct clk_div_mult_table {
98-
unsigned int *divisors;
99-
unsigned int nr_divisors;
100-
unsigned int *multipliers;
101-
unsigned int nr_multipliers;
102-
};
103-
104-
struct cpufreq_frequency_table;
105-
void clk_rate_table_build(struct clk *clk,
106-
struct cpufreq_frequency_table *freq_table,
107-
int nr_freqs,
108-
struct clk_div_mult_table *src_table,
109-
unsigned long *bitmap);
110-
111-
long clk_rate_table_round(struct clk *clk,
112-
struct cpufreq_frequency_table *freq_table,
113-
unsigned long rate);
114-
115-
int clk_rate_table_find(struct clk *clk,
116-
struct cpufreq_frequency_table *freq_table,
117-
unsigned long rate);
118-
119-
#define SH_CLK_MSTP32(_name, _id, _parent, _enable_reg, \
120-
_enable_bit, _flags) \
121-
{ \
122-
.name = _name, \
123-
.id = _id, \
124-
.parent = _parent, \
125-
.enable_reg = (void __iomem *)_enable_reg, \
126-
.enable_bit = _enable_bit, \
127-
.flags = _flags, \
128-
}
129-
130-
int sh_clk_mstp32_register(struct clk *clks, int nr);
131-
132-
#define SH_CLK_DIV4(_name, _parent, _reg, _shift, _div_bitmap, _flags) \
133-
{ \
134-
.name = _name, \
135-
.parent = _parent, \
136-
.enable_reg = (void __iomem *)_reg, \
137-
.enable_bit = _shift, \
138-
.arch_flags = _div_bitmap, \
139-
.flags = _flags, \
140-
}
141-
142-
struct clk_div4_table {
143-
struct clk_div_mult_table *div_mult_table;
144-
void (*kick)(struct clk *clk);
145-
};
146-
147-
int sh_clk_div4_register(struct clk *clks, int nr,
148-
struct clk_div4_table *table);
149-
int sh_clk_div4_enable_register(struct clk *clks, int nr,
150-
struct clk_div4_table *table);
151-
int sh_clk_div4_reparent_register(struct clk *clks, int nr,
152-
struct clk_div4_table *table);
153-
154-
#define SH_CLK_DIV6(_parent, _reg, _flags) \
155-
{ \
156-
.parent = _parent, \
157-
.enable_reg = (void __iomem *)_reg, \
158-
.flags = _flags, \
159-
}
160-
161-
int sh_clk_div6_register(struct clk *clks, int nr);
13+
/* arch/sh/kernel/cpu/clock.c */
14+
int clk_init(void);
16215

16316
#endif /* __ASM_SH_CLOCK_H */

‎arch/sh/kernel/cpu/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ obj-$(CONFIG_ARCH_SHMOBILE) += shmobile/
1616
# Common interfaces.
1717

1818
obj-$(CONFIG_SH_ADC) += adc.o
19-
obj-$(CONFIG_SH_CLK_CPG) += clock-cpg.o
19+
obj-$(CONFIG_SH_CLK_CPG_LEGACY) += clock-cpg.o
2020
obj-$(CONFIG_SH_FPU) += fpu.o
2121
obj-$(CONFIG_SH_FPU_EMU) += fpu.o
2222

0 commit comments

Comments
 (0)