1
2
3
4
5
6
7
8
9
10
11
12#include <common.h>
13#include <asm/io.h>
14#include <asm/arch/cpu.h>
15#include <asm/arch/kirkwood.h>
16#include <asm/arch/mpp.h>
17
18static u32 kirkwood_variant(void)
19{
20 switch (readl(KW_REG_DEVICE_ID) & 0x03) {
21 case 1:
22 return MPP_F6192_MASK;
23 case 2:
24 return MPP_F6281_MASK;
25 default:
26 debug("MPP setup: unknown kirkwood variant\n");
27 return 0;
28 }
29}
30
31#define MPP_CTRL(i) (KW_MPP_BASE + (i* 4))
32#define MPP_NR_REGS (1 + MPP_MAX/8)
33
34void kirkwood_mpp_conf(u32 *mpp_list)
35{
36 u32 mpp_ctrl[MPP_NR_REGS];
37 unsigned int variant_mask;
38 int i;
39
40 variant_mask = kirkwood_variant();
41 if (!variant_mask)
42 return;
43
44 debug( "initial MPP regs:");
45 for (i = 0; i < MPP_NR_REGS; i++) {
46 mpp_ctrl[i] = readl(MPP_CTRL(i));
47 debug(" %08x", mpp_ctrl[i]);
48 }
49 debug("\n");
50
51
52 while (*mpp_list) {
53 unsigned int num = MPP_NUM(*mpp_list);
54 unsigned int sel = MPP_SEL(*mpp_list);
55 int shift;
56
57 if (num > MPP_MAX) {
58 debug("kirkwood_mpp_conf: invalid MPP "
59 "number (%u)\n", num);
60 continue;
61 }
62 if (!(*mpp_list & variant_mask)) {
63 debug("kirkwood_mpp_conf: requested MPP%u config "
64 "unavailable on this hardware\n", num);
65 continue;
66 }
67
68 shift = (num & 7) << 2;
69 mpp_ctrl[num / 8] &= ~(0xf << shift);
70 mpp_ctrl[num / 8] |= sel << shift;
71
72 mpp_list++;
73 }
74
75 debug(" final MPP regs:");
76 for (i = 0; i < MPP_NR_REGS; i++) {
77 writel(mpp_ctrl[i], MPP_CTRL(i));
78 debug(" %08x", mpp_ctrl[i]);
79 }
80 debug("\n");
81
82}
83