2 * arch/arm/mach-mv78x00/mpp.c
4 * MPP functions for Marvell MV78x00 SoCs
6 * This file is licensed under the terms of the GNU General Public
7 * License version 2. This program is licensed "as is" without any
8 * warranty of any kind, whether express or implied.
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/mbus.h>
16 #include <mach/hardware.h>
20 static unsigned int __init
mv78xx0_variant(void)
24 mv78xx0_pcie_id(&dev
, &rev
);
26 if (dev
== MV78100_DEV_ID
&& rev
>= MV78100_REV_A0
)
27 return MPP_78100_A0_MASK
;
29 printk(KERN_ERR
"MPP setup: unknown mv78x00 variant "
30 "(dev %#x rev %#x)\n", dev
, rev
);
34 #define MPP_CTRL(i) (DEV_BUS_VIRT_BASE + (i) * 4)
35 #define MPP_NR_REGS (1 + MPP_MAX/8)
37 void __init
mv78xx0_mpp_conf(unsigned int *mpp_list
)
39 u32 mpp_ctrl
[MPP_NR_REGS
];
40 unsigned int variant_mask
;
43 variant_mask
= mv78xx0_variant();
47 /* Initialize gpiolib. */
50 printk(KERN_DEBUG
"initial MPP regs:");
51 for (i
= 0; i
< MPP_NR_REGS
; i
++) {
52 mpp_ctrl
[i
] = readl(MPP_CTRL(i
));
53 printk(" %08x", mpp_ctrl
[i
]);
57 for ( ; *mpp_list
; mpp_list
++) {
58 unsigned int num
= MPP_NUM(*mpp_list
);
59 unsigned int sel
= MPP_SEL(*mpp_list
);
63 printk(KERN_ERR
"mv78xx0_mpp_conf: invalid MPP "
64 "number (%u)\n", num
);
67 if (!(*mpp_list
& variant_mask
)) {
69 "mv78xx0_mpp_conf: requested MPP%u config "
70 "unavailable on this hardware\n", num
);
74 shift
= (num
& 7) << 2;
75 mpp_ctrl
[num
/ 8] &= ~(0xf << shift
);
76 mpp_ctrl
[num
/ 8] |= sel
<< shift
;
79 if (*mpp_list
& MPP_INPUT_MASK
)
80 gpio_mode
|= GPIO_INPUT_OK
;
81 if (*mpp_list
& MPP_OUTPUT_MASK
)
82 gpio_mode
|= GPIO_OUTPUT_OK
;
85 orion_gpio_set_valid(num
, gpio_mode
);
88 printk(KERN_DEBUG
" final MPP regs:");
89 for (i
= 0; i
< MPP_NR_REGS
; i
++) {
90 writel(mpp_ctrl
[i
], MPP_CTRL(i
));
91 printk(" %08x", mpp_ctrl
[i
]);