11 #include <linux/export.h>
14 #include <asm/delay.h>
16 #include <lantiq_soc.h>
21 #define SYS1_INFRAC 0x00bc
23 #define STATUS_CONFIG 0x0040
26 #define GPPC_OFFSET 24
27 #define GPEFREQ_MASK 0x00000C0
28 #define GPEFREQ_OFFSET 10
30 #define SYSCTL_CLKS 0x0000
32 #define SYSCTL_CLKEN 0x0004
34 #define SYSCTL_CLKCLR 0x0008
36 #define SYSCTL_ACTS 0x0020
38 #define SYSCTL_ACT 0x0024
40 #define SYSCTL_DEACT 0x0028
42 #define SYSCTL_RBT 0x002c
44 #define SYS1_CPU0CC 0x0040
46 #define SYS1_HRSTOUTC 0x00c0
48 #define CPU0CC_CPUDIV 0x0001
51 #define ACTS_ASC1_ACT 0x00000800
52 #define ACTS_I2C_ACT 0x00004000
53 #define ACTS_P0 0x00010000
54 #define ACTS_P1 0x00010000
55 #define ACTS_P2 0x00020000
56 #define ACTS_P3 0x00020000
57 #define ACTS_P4 0x00040000
58 #define ACTS_PADCTRL0 0x00100000
59 #define ACTS_PADCTRL1 0x00100000
60 #define ACTS_PADCTRL2 0x00200000
61 #define ACTS_PADCTRL3 0x00200000
62 #define ACTS_PADCTRL4 0x00400000
64 #define sysctl_w32(m, x, y) ltq_w32((x), sysctl_membase[m] + (y))
65 #define sysctl_r32(m, x) ltq_r32(sysctl_membase[m] + (x))
66 #define sysctl_w32_mask(m, clear, set, reg) \
67 sysctl_w32(m, (sysctl_r32(m, reg) & ~(clear)) | (set), reg)
69 #define status_w32(x, y) ltq_w32((x), status_membase + (y))
70 #define status_r32(x) ltq_r32(status_membase + (x))
72 static void __iomem *sysctl_membase[3], *status_membase;
80 static inline void sysctl_wait(
struct clk *
clk,
81 unsigned int test,
unsigned int reg)
86 & clk->
bits) != test));
88 pr_err(
"module de/activation failed %d %08X %08X %08X\n",
93 static int sysctl_activate(
struct clk *clk)
101 static void sysctl_deactivate(
struct clk *clk)
108 static int sysctl_clken(
struct clk *clk)
115 static void sysctl_clkdis(
struct clk *clk)
121 static void sysctl_reboot(
struct clk *clk)
127 bits = ~act & clk->
bits;
138 static void falcon_gpe_enable(
void)
165 static inline void clkdev_add_sys(
const char *
dev,
unsigned int module,
168 struct clk *clk = kzalloc(
sizeof(
struct clk),
GFP_KERNEL);
170 clk->
cl.dev_id =
dev;
177 clk->
enable = sysctl_clken;
179 clk->
reboot = sysctl_reboot;
195 struct resource res_status, res_ebu, res_sys[3];
199 if (!np_status || !np_ebu || !np_sys1 || !np_syseth || !np_sysgpe)
200 panic(
"Failed to load core nodes from devicetree");
207 panic(
"Failed to get core resources");
210 res_status.
name) < 0) ||
212 res_ebu.
name) < 0) ||
214 resource_size(&res_sys[0]),
215 res_sys[0].
name) < 0) ||
217 resource_size(&res_sys[1]),
218 res_sys[1].name) < 0) ||
220 resource_size(&res_sys[2]),
221 res_sys[2].name) < 0))
222 pr_err(
"Failed to request core reources");
225 resource_size(&res_status));
227 resource_size(&res_ebu));
230 panic(
"Failed to remap core resources");
232 for (i = 0; i < 3; i++) {
234 resource_size(&res_sys[i]));
235 if (!sysctl_membase[i])
236 panic(
"Failed to remap sysctrl resources");
249 clkdev_add_sys(
"1d810000.gpio", SYSCTL_SYSETH,
ACTS_P0);
250 clkdev_add_sys(
"1d810100.gpio", SYSCTL_SYSETH,
ACTS_P2);
251 clkdev_add_sys(
"1e800100.gpio", SYSCTL_SYS1,
ACTS_P1);
252 clkdev_add_sys(
"1e800200.gpio", SYSCTL_SYS1,
ACTS_P3);
253 clkdev_add_sys(
"1e800300.gpio", SYSCTL_SYS1,
ACTS_P4);
254 clkdev_add_sys(
"1db01000.pad", SYSCTL_SYSETH,
ACTS_PADCTRL0);
255 clkdev_add_sys(
"1db02000.pad", SYSCTL_SYSETH,
ACTS_PADCTRL2);
259 clkdev_add_sys(
"1e100C00.serial", SYSCTL_SYS1,
ACTS_ASC1_ACT);
260 clkdev_add_sys(
"1e200000.i2c", SYSCTL_SYS1,
ACTS_I2C_ACT);