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.
15 #include <asm/arch/cpu.h>
16 #include <asm/arch/soc.h>
17 #include <asm/arch/mpp.h>
19 static u32 kirkwood_variant(void)
21 switch (readl(KW_REG_DEVICE_ID) & 0x03) {
23 return MPP_F6192_MASK;
25 return MPP_F6281_MASK;
27 debug("MPP setup: unknown kirkwood variant\n");
32 #define MPP_CTRL(i) (KW_MPP_BASE + (i* 4))
33 #define MPP_NR_REGS (1 + MPP_MAX/8)
35 void kirkwood_mpp_conf(const u32 *mpp_list, u32 *mpp_save)
37 u32 mpp_ctrl[MPP_NR_REGS];
38 unsigned int variant_mask;
41 variant_mask = kirkwood_variant();
45 debug( "initial MPP regs:");
46 for (i = 0; i < MPP_NR_REGS; i++) {
47 mpp_ctrl[i] = readl(MPP_CTRL(i));
48 debug(" %08x", mpp_ctrl[i]);
54 unsigned int num = MPP_NUM(*mpp_list);
55 unsigned int sel = MPP_SEL(*mpp_list);
56 unsigned int sel_save;
60 debug("kirkwood_mpp_conf: invalid MPP "
61 "number (%u)\n", num);
64 if (!(*mpp_list & variant_mask)) {
65 debug("kirkwood_mpp_conf: requested MPP%u config "
66 "unavailable on this hardware\n", num);
70 shift = (num & 7) << 2;
73 sel_save = (mpp_ctrl[num / 8] >> shift) & 0xf;
74 *mpp_save = num | (sel_save << 8) | variant_mask;
78 mpp_ctrl[num / 8] &= ~(0xf << shift);
79 mpp_ctrl[num / 8] |= sel << shift;
84 debug(" final MPP regs:");
85 for (i = 0; i < MPP_NR_REGS; i++) {
86 writel(mpp_ctrl[i], MPP_CTRL(i));
87 debug(" %08x", mpp_ctrl[i]);