32 #include <linux/module.h>
38 #define MAX_DEVSTATE_IDS 32
39 #define MAX_DEVCTL_REGS 8
40 #define MAX_DEVSTAT_REGS 8
41 #define MAX_LOCKED_REGS 4
42 #define MAX_SOC_EMACS 2
124 if (dscr.locked[i].key && reg == dscr.locked[i].reg)
125 return &dscr.locked[
i];
132 static void dscr_write_locked1(
u32 reg,
u32 val,
136 void __iomem *lock_addr = dscr.base + lock;
144 asm volatile (
"b .s2 0f\n"
151 :
"a"(
reg_addr),
"b"(val),
"a"(lock_addr),
"b"(key)
161 static void dscr_write_locked2(
u32 reg,
u32 val,
172 static void dscr_write(
u32 reg,
u32 val)
176 lock = find_locked_reg(reg);
178 dscr_write_locked1(reg, val, lock->
lockreg, lock->
key);
179 else if (dscr.kick_key[0])
180 dscr_write_locked2(reg, val, dscr.kick_reg[0], dscr.kick_key[0],
181 dscr.kick_reg[1], dscr.kick_key[1]);
196 int ctl_shift, ctl_mask;
205 info = &dscr.devstate_info[
id];
213 ctl_mask = ((1 << ctl->
nbits) - 1) << ctl_shift;
217 ctl_val = ctl->
enable << ctl_shift;
222 ctl_val = ctl->
disable << ctl_shift;
234 dscr_write(ctl->
reg, val);
236 spin_unlock_irqrestore(&dscr.lock, flags);
251 val &= ((1 << stat->
nbits) - 1);
252 }
while (val != ctl_val);
268 r = &dscr.rmii_resets[
id];
276 dscr_write(r->
reg, val | r->
mask);
278 dscr_write(r->
reg, val & ~(r->
mask));
280 spin_unlock_irqrestore(&dscr.lock, flags);
338 for (f = 0; f < 2; f++) {
340 for (j = (f * 5) + 1, i = 24; i >= 0; i -= 8, j++)
341 if (vals[j] && vals[j] <= 6)
356 size /= (
sizeof(*p) * 2);
360 for (i = 0; i <
size; i++) {
377 dscr_write(vals[0], vals[1]);
406 size /= (
sizeof(*p) * 3);
407 if (size > MAX_LOCKED_REGS)
410 for (i = 0; i <
size; i++) {
439 dscr.kick_reg[0] = vals[0];
440 dscr.kick_key[0] = vals[1];
441 dscr.kick_reg[1] = vals[2];
442 dscr.kick_key[1] = vals[3];
479 size /= (
sizeof(*p) * 7);
483 for (i = 0; i <
size; i++) {
499 dscr.devstate_info[
j].ctl =
r;
535 size /= (
sizeof(*p) * 7);
539 for (i = 0; i <
size; i++) {
540 r = &dscr.devstat[
i];
553 dscr.devstate_info[
j].stat =
r;
559 { .compatible =
"ti,c64x+dscr" },
589 dscr_parse_devstat(node, base);
590 dscr_parse_silicon_rev(node, base);
591 dscr_parse_mac_fuse(node, base);
592 dscr_parse_rmii_resets(node, base);
593 dscr_parse_locked_regs(node, base);
594 dscr_parse_kick_regs(node, base);
595 dscr_parse_devstate_ctl_regs(node, base);
596 dscr_parse_devstate_stat_regs(node, base);
597 dscr_parse_privperm(node, base);