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.
13 #include <asm/arch/kirkwood.h>
14 #include <asm/arch/mpp.h>
16 static u32 kirkwood_variant(void)
18 switch (readl(KW_REG_DEVICE_ID) & 0x03) {
20 return MPP_F6192_MASK;
22 return MPP_F6281_MASK;
24 debug("MPP setup: unknown kirkwood variant\n");
29 #define MPP_CTRL(i) (KW_MPP_BASE + (i* 4))
30 #define MPP_NR_REGS (1 + MPP_MAX/8)
32 void kirkwood_mpp_conf(u32 *mpp_list)
34 u32 mpp_ctrl[MPP_NR_REGS];
35 unsigned int variant_mask;
38 variant_mask = kirkwood_variant();
42 debug( "initial MPP regs:");
43 for (i = 0; i < MPP_NR_REGS; i++) {
44 mpp_ctrl[i] = readl(MPP_CTRL(i));
45 debug(" %08x", mpp_ctrl[i]);
51 unsigned int num = MPP_NUM(*mpp_list);
52 unsigned int sel = MPP_SEL(*mpp_list);
56 debug("kirkwood_mpp_conf: invalid MPP "
57 "number (%u)\n", num);
60 if (!(*mpp_list & variant_mask)) {
61 debug("kirkwood_mpp_conf: requested MPP%u config "
62 "unavailable on this hardware\n", num);
66 shift = (num & 7) << 2;
67 mpp_ctrl[num / 8] &= ~(0xf << shift);
68 mpp_ctrl[num / 8] |= sel << shift;
73 debug(" final MPP regs:");
74 for (i = 0; i < MPP_NR_REGS; i++) {
75 writel(mpp_ctrl[i], MPP_CTRL(i));
76 debug(" %08x", mpp_ctrl[i]);