2 * arch/arm/mach-kirkwood/mpp.c
4 * MPP functions for Marvell Kirkwood SoCs
5 * Referenced from Linux kernel source
7 * This file is licensed under the terms of the GNU General Public
8 * License version 2. This program is licensed "as is" without any
9 * warranty of any kind, whether express or implied.
14 #include <asm/arch/cpu.h>
15 #include <asm/arch/kirkwood.h>
16 #include <asm/arch/mpp.h>
18 static u32 kirkwood_variant(void)
20 switch (readl(KW_REG_DEVICE_ID) & 0x03) {
22 return MPP_F6192_MASK;
24 return MPP_F6281_MASK;
26 debug("MPP setup: unknown kirkwood variant\n");
31 #define MPP_CTRL(i) (KW_MPP_BASE + (i* 4))
32 #define MPP_NR_REGS (1 + MPP_MAX/8)
34 void kirkwood_mpp_conf(const u32 *mpp_list, u32 *mpp_save)
36 u32 mpp_ctrl[MPP_NR_REGS];
37 unsigned int variant_mask;
40 variant_mask = kirkwood_variant();
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]);
53 unsigned int num = MPP_NUM(*mpp_list);
54 unsigned int sel = MPP_SEL(*mpp_list);
55 unsigned int sel_save;
59 debug("kirkwood_mpp_conf: invalid MPP "
60 "number (%u)\n", num);
63 if (!(*mpp_list & variant_mask)) {
64 debug("kirkwood_mpp_conf: requested MPP%u config "
65 "unavailable on this hardware\n", num);
69 shift = (num & 7) << 2;
72 sel_save = (mpp_ctrl[num / 8] >> shift) & 0xf;
73 *mpp_save = num | (sel_save << 8) | variant_mask;
77 mpp_ctrl[num / 8] &= ~(0xf << shift);
78 mpp_ctrl[num / 8] |= sel << shift;
83 debug(" final MPP regs:");
84 for (i = 0; i < MPP_NR_REGS; i++) {
85 writel(mpp_ctrl[i], MPP_CTRL(i));
86 debug(" %08x", mpp_ctrl[i]);