diff options
-rw-r--r-- | arch/arm/mach-kirkwood/mpp.c | 58 | ||||
-rw-r--r-- | arch/arm/mach-kirkwood/mpp.h | 6 | ||||
-rw-r--r-- | arch/arm/mach-mv78xx0/mpp.c | 58 | ||||
-rw-r--r-- | arch/arm/mach-mv78xx0/mpp.h | 6 | ||||
-rw-r--r-- | arch/arm/plat-orion/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/plat-orion/include/plat/mpp.h | 34 | ||||
-rw-r--r-- | arch/arm/plat-orion/mpp.c | 81 |
7 files changed, 122 insertions, 123 deletions
diff --git a/arch/arm/mach-kirkwood/mpp.c b/arch/arm/mach-kirkwood/mpp.c index 7ce201848067..b0a7d979a8ed 100644 --- a/arch/arm/mach-kirkwood/mpp.c +++ b/arch/arm/mach-kirkwood/mpp.c | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <asm/gpio.h> | 15 | #include <asm/gpio.h> |
16 | #include <mach/hardware.h> | 16 | #include <mach/hardware.h> |
17 | #include <plat/mpp.h> | ||
17 | #include "common.h" | 18 | #include "common.h" |
18 | #include "mpp.h" | 19 | #include "mpp.h" |
19 | 20 | ||
@@ -36,61 +37,8 @@ static unsigned int __init kirkwood_variant(void) | |||
36 | return 0; | 37 | return 0; |
37 | } | 38 | } |
38 | 39 | ||
39 | #define MPP_CTRL(i) (DEV_BUS_VIRT_BASE + (i) * 4) | ||
40 | #define MPP_NR_REGS (1 + MPP_MAX/8) | ||
41 | |||
42 | void __init kirkwood_mpp_conf(unsigned int *mpp_list) | 40 | void __init kirkwood_mpp_conf(unsigned int *mpp_list) |
43 | { | 41 | { |
44 | u32 mpp_ctrl[MPP_NR_REGS]; | 42 | orion_mpp_conf(mpp_list, kirkwood_variant(), |
45 | unsigned int variant_mask; | 43 | MPP_MAX, DEV_BUS_VIRT_BASE); |
46 | int i; | ||
47 | |||
48 | variant_mask = kirkwood_variant(); | ||
49 | if (!variant_mask) | ||
50 | return; | ||
51 | |||
52 | printk(KERN_DEBUG "initial MPP regs:"); | ||
53 | for (i = 0; i < MPP_NR_REGS; i++) { | ||
54 | mpp_ctrl[i] = readl(MPP_CTRL(i)); | ||
55 | printk(" %08x", mpp_ctrl[i]); | ||
56 | } | ||
57 | printk("\n"); | ||
58 | |||
59 | for ( ; *mpp_list; mpp_list++) { | ||
60 | unsigned int num = MPP_NUM(*mpp_list); | ||
61 | unsigned int sel = MPP_SEL(*mpp_list); | ||
62 | int shift, gpio_mode; | ||
63 | |||
64 | if (num > MPP_MAX) { | ||
65 | printk(KERN_ERR "kirkwood_mpp_conf: invalid MPP " | ||
66 | "number (%u)\n", num); | ||
67 | continue; | ||
68 | } | ||
69 | if (!(*mpp_list & variant_mask)) { | ||
70 | printk(KERN_WARNING | ||
71 | "kirkwood_mpp_conf: requested MPP%u config " | ||
72 | "unavailable on this hardware\n", num); | ||
73 | continue; | ||
74 | } | ||
75 | |||
76 | shift = (num & 7) << 2; | ||
77 | mpp_ctrl[num / 8] &= ~(0xf << shift); | ||
78 | mpp_ctrl[num / 8] |= sel << shift; | ||
79 | |||
80 | gpio_mode = 0; | ||
81 | if (*mpp_list & MPP_INPUT_MASK) | ||
82 | gpio_mode |= GPIO_INPUT_OK; | ||
83 | if (*mpp_list & MPP_OUTPUT_MASK) | ||
84 | gpio_mode |= GPIO_OUTPUT_OK; | ||
85 | if (sel != 0) | ||
86 | gpio_mode = 0; | ||
87 | orion_gpio_set_valid(num, gpio_mode); | ||
88 | } | ||
89 | |||
90 | printk(KERN_DEBUG " final MPP regs:"); | ||
91 | for (i = 0; i < MPP_NR_REGS; i++) { | ||
92 | writel(mpp_ctrl[i], MPP_CTRL(i)); | ||
93 | printk(" %08x", mpp_ctrl[i]); | ||
94 | } | ||
95 | printk("\n"); | ||
96 | } | 44 | } |
diff --git a/arch/arm/mach-kirkwood/mpp.h b/arch/arm/mach-kirkwood/mpp.h index 9b0a94d85c3e..ac787957e2d9 100644 --- a/arch/arm/mach-kirkwood/mpp.h +++ b/arch/arm/mach-kirkwood/mpp.h | |||
@@ -22,14 +22,8 @@ | |||
22 | /* available on F6281 */ ((!!(_F6281)) << 17) | \ | 22 | /* available on F6281 */ ((!!(_F6281)) << 17) | \ |
23 | /* available on F6282 */ ((!!(_F6282)) << 18)) | 23 | /* available on F6282 */ ((!!(_F6282)) << 18)) |
24 | 24 | ||
25 | #define MPP_NUM(x) ((x) & 0xff) | ||
26 | #define MPP_SEL(x) (((x) >> 8) & 0xf) | ||
27 | |||
28 | /* num sel i o 6180 6190 6192 6281 6282 */ | 25 | /* num sel i o 6180 6190 6192 6281 6282 */ |
29 | 26 | ||
30 | #define MPP_INPUT_MASK MPP( 0, 0x0, 1, 0, 0, 0, 0, 0, 0 ) | ||
31 | #define MPP_OUTPUT_MASK MPP( 0, 0x0, 0, 1, 0, 0, 0, 0, 0 ) | ||
32 | |||
33 | #define MPP_F6180_MASK MPP( 0, 0x0, 0, 0, 1, 0, 0, 0, 0 ) | 27 | #define MPP_F6180_MASK MPP( 0, 0x0, 0, 0, 1, 0, 0, 0, 0 ) |
34 | #define MPP_F6190_MASK MPP( 0, 0x0, 0, 0, 0, 1, 0, 0, 0 ) | 28 | #define MPP_F6190_MASK MPP( 0, 0x0, 0, 0, 0, 1, 0, 0, 0 ) |
35 | #define MPP_F6192_MASK MPP( 0, 0x0, 0, 0, 0, 0, 1, 0, 0 ) | 29 | #define MPP_F6192_MASK MPP( 0, 0x0, 0, 0, 0, 0, 1, 0, 0 ) |
diff --git a/arch/arm/mach-mv78xx0/mpp.c b/arch/arm/mach-mv78xx0/mpp.c index 65b72c454cb0..59b7686b9209 100644 --- a/arch/arm/mach-mv78xx0/mpp.c +++ b/arch/arm/mach-mv78xx0/mpp.c | |||
@@ -12,6 +12,7 @@ | |||
12 | #include <linux/init.h> | 12 | #include <linux/init.h> |
13 | #include <linux/mbus.h> | 13 | #include <linux/mbus.h> |
14 | #include <linux/io.h> | 14 | #include <linux/io.h> |
15 | #include <plat/mpp.h> | ||
15 | #include <asm/gpio.h> | 16 | #include <asm/gpio.h> |
16 | #include <mach/hardware.h> | 17 | #include <mach/hardware.h> |
17 | #include "common.h" | 18 | #include "common.h" |
@@ -31,61 +32,8 @@ static unsigned int __init mv78xx0_variant(void) | |||
31 | return 0; | 32 | return 0; |
32 | } | 33 | } |
33 | 34 | ||
34 | #define MPP_CTRL(i) (DEV_BUS_VIRT_BASE + (i) * 4) | ||
35 | #define MPP_NR_REGS (1 + MPP_MAX/8) | ||
36 | |||
37 | void __init mv78xx0_mpp_conf(unsigned int *mpp_list) | 35 | void __init mv78xx0_mpp_conf(unsigned int *mpp_list) |
38 | { | 36 | { |
39 | u32 mpp_ctrl[MPP_NR_REGS]; | 37 | orion_mpp_conf(mpp_list, mv78xx0_variant(), |
40 | unsigned int variant_mask; | 38 | MPP_MAX, DEV_BUS_VIRT_BASE); |
41 | int i; | ||
42 | |||
43 | variant_mask = mv78xx0_variant(); | ||
44 | if (!variant_mask) | ||
45 | return; | ||
46 | |||
47 | printk(KERN_DEBUG "initial MPP regs:"); | ||
48 | for (i = 0; i < MPP_NR_REGS; i++) { | ||
49 | mpp_ctrl[i] = readl(MPP_CTRL(i)); | ||
50 | printk(" %08x", mpp_ctrl[i]); | ||
51 | } | ||
52 | printk("\n"); | ||
53 | |||
54 | for ( ; *mpp_list; mpp_list++) { | ||
55 | unsigned int num = MPP_NUM(*mpp_list); | ||
56 | unsigned int sel = MPP_SEL(*mpp_list); | ||
57 | int shift, gpio_mode; | ||
58 | |||
59 | if (num > MPP_MAX) { | ||
60 | printk(KERN_ERR "mv78xx0_mpp_conf: invalid MPP " | ||
61 | "number (%u)\n", num); | ||
62 | continue; | ||
63 | } | ||
64 | if (!(*mpp_list & variant_mask)) { | ||
65 | printk(KERN_WARNING | ||
66 | "mv78xx0_mpp_conf: requested MPP%u config " | ||
67 | "unavailable on this hardware\n", num); | ||
68 | continue; | ||
69 | } | ||
70 | |||
71 | shift = (num & 7) << 2; | ||
72 | mpp_ctrl[num / 8] &= ~(0xf << shift); | ||
73 | mpp_ctrl[num / 8] |= sel << shift; | ||
74 | |||
75 | gpio_mode = 0; | ||
76 | if (*mpp_list & MPP_INPUT_MASK) | ||
77 | gpio_mode |= GPIO_INPUT_OK; | ||
78 | if (*mpp_list & MPP_OUTPUT_MASK) | ||
79 | gpio_mode |= GPIO_OUTPUT_OK; | ||
80 | if (sel != 0) | ||
81 | gpio_mode = 0; | ||
82 | orion_gpio_set_valid(num, gpio_mode); | ||
83 | } | ||
84 | |||
85 | printk(KERN_DEBUG " final MPP regs:"); | ||
86 | for (i = 0; i < MPP_NR_REGS; i++) { | ||
87 | writel(mpp_ctrl[i], MPP_CTRL(i)); | ||
88 | printk(" %08x", mpp_ctrl[i]); | ||
89 | } | ||
90 | printk("\n"); | ||
91 | } | 39 | } |
diff --git a/arch/arm/mach-mv78xx0/mpp.h b/arch/arm/mach-mv78xx0/mpp.h index 80840b781eaa..b61b50927123 100644 --- a/arch/arm/mach-mv78xx0/mpp.h +++ b/arch/arm/mach-mv78xx0/mpp.h | |||
@@ -19,14 +19,8 @@ | |||
19 | /* may be output signal */ ((!!(_out)) << 13) | \ | 19 | /* may be output signal */ ((!!(_out)) << 13) | \ |
20 | /* available on A0 */ ((!!(_78100_A0)) << 14)) | 20 | /* available on A0 */ ((!!(_78100_A0)) << 14)) |
21 | 21 | ||
22 | #define MPP_NUM(x) ((x) & 0xff) | ||
23 | #define MPP_SEL(x) (((x) >> 8) & 0xf) | ||
24 | |||
25 | /* num sel i o 78100_A0 */ | 22 | /* num sel i o 78100_A0 */ |
26 | 23 | ||
27 | #define MPP_INPUT_MASK MPP(0, 0x0, 1, 0, 0) | ||
28 | #define MPP_OUTPUT_MASK MPP(0, 0x0, 0, 1, 0) | ||
29 | |||
30 | #define MPP_78100_A0_MASK MPP(0, 0x0, 0, 0, 1) | 24 | #define MPP_78100_A0_MASK MPP(0, 0x0, 0, 0, 1) |
31 | 25 | ||
32 | #define MPP0_GPIO MPP(0, 0x0, 1, 1, 1) | 26 | #define MPP0_GPIO MPP(0, 0x0, 1, 1, 1) |
diff --git a/arch/arm/plat-orion/Makefile b/arch/arm/plat-orion/Makefile index 0f048c58b4c9..95a5fc53b6db 100644 --- a/arch/arm/plat-orion/Makefile +++ b/arch/arm/plat-orion/Makefile | |||
@@ -2,7 +2,7 @@ | |||
2 | # Makefile for the linux kernel. | 2 | # Makefile for the linux kernel. |
3 | # | 3 | # |
4 | 4 | ||
5 | obj-y := irq.o pcie.o time.o common.o | 5 | obj-y := irq.o pcie.o time.o common.o mpp.o |
6 | obj-m := | 6 | obj-m := |
7 | obj-n := | 7 | obj-n := |
8 | obj- := | 8 | obj- := |
diff --git a/arch/arm/plat-orion/include/plat/mpp.h b/arch/arm/plat-orion/include/plat/mpp.h new file mode 100644 index 000000000000..723adce99f41 --- /dev/null +++ b/arch/arm/plat-orion/include/plat/mpp.h | |||
@@ -0,0 +1,34 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/include/plat/mpp.h | ||
3 | * | ||
4 | * Marvell Orion SoC MPP handling. | ||
5 | * | ||
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. | ||
9 | */ | ||
10 | |||
11 | #ifndef __PLAT_MPP_H | ||
12 | #define __PLAT_MPP_H | ||
13 | |||
14 | #define MPP_NUM(x) ((x) & 0xff) | ||
15 | #define MPP_SEL(x) (((x) >> 8) & 0xf) | ||
16 | |||
17 | /* This is the generic MPP macro, without any variant information. | ||
18 | Each machine architecture is expected to extend this with further | ||
19 | bit fields indicating which MPP configurations are valid for a | ||
20 | specific variant. */ | ||
21 | |||
22 | #define GENERIC_MPP(_num, _sel, _in, _out) ( \ | ||
23 | /* MPP number */ ((_num) & 0xff) | \ | ||
24 | /* MPP select value */ (((_sel) & 0xf) << 8) | \ | ||
25 | /* may be input signal */ ((!!(_in)) << 12) | \ | ||
26 | /* may be output signal */ ((!!(_out)) << 13)) | ||
27 | |||
28 | #define MPP_INPUT_MASK GENERIC_MPP(0, 0x0, 1, 0) | ||
29 | #define MPP_OUTPUT_MASK GENERIC_MPP(0, 0x0, 0, 1) | ||
30 | |||
31 | void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask, | ||
32 | unsigned int mpp_max, unsigned int dev_bus); | ||
33 | |||
34 | #endif | ||
diff --git a/arch/arm/plat-orion/mpp.c b/arch/arm/plat-orion/mpp.c new file mode 100644 index 000000000000..248c02205b66 --- /dev/null +++ b/arch/arm/plat-orion/mpp.c | |||
@@ -0,0 +1,81 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/mpp.c | ||
3 | * | ||
4 | * MPP functions for Marvell orion SoCs | ||
5 | * | ||
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. | ||
9 | */ | ||
10 | |||
11 | #include <linux/kernel.h> | ||
12 | #include <linux/init.h> | ||
13 | #include <linux/mbus.h> | ||
14 | #include <linux/io.h> | ||
15 | #include <linux/gpio.h> | ||
16 | #include <mach/hardware.h> | ||
17 | #include <plat/mpp.h> | ||
18 | |||
19 | /* Address of the ith MPP control register */ | ||
20 | static __init unsigned long mpp_ctrl_addr(unsigned int i, | ||
21 | unsigned long dev_bus) | ||
22 | { | ||
23 | return dev_bus + (i) * 4; | ||
24 | } | ||
25 | |||
26 | |||
27 | void __init orion_mpp_conf(unsigned int *mpp_list, unsigned int variant_mask, | ||
28 | unsigned int mpp_max, unsigned int dev_bus) | ||
29 | { | ||
30 | unsigned int mpp_nr_regs = (1 + mpp_max/8); | ||
31 | u32 mpp_ctrl[mpp_nr_regs]; | ||
32 | int i; | ||
33 | |||
34 | if (!variant_mask) | ||
35 | return; | ||
36 | |||
37 | printk(KERN_DEBUG "initial MPP regs:"); | ||
38 | for (i = 0; i < mpp_nr_regs; i++) { | ||
39 | mpp_ctrl[i] = readl(mpp_ctrl_addr(i, dev_bus)); | ||
40 | printk(" %08x", mpp_ctrl[i]); | ||
41 | } | ||
42 | printk("\n"); | ||
43 | |||
44 | for ( ; *mpp_list; mpp_list++) { | ||
45 | unsigned int num = MPP_NUM(*mpp_list); | ||
46 | unsigned int sel = MPP_SEL(*mpp_list); | ||
47 | int shift, gpio_mode; | ||
48 | |||
49 | if (num > mpp_max) { | ||
50 | printk(KERN_ERR "orion_mpp_conf: invalid MPP " | ||
51 | "number (%u)\n", num); | ||
52 | continue; | ||
53 | } | ||
54 | if (!(*mpp_list & variant_mask)) { | ||
55 | printk(KERN_WARNING | ||
56 | "orion_mpp_conf: requested MPP%u config " | ||
57 | "unavailable on this hardware\n", num); | ||
58 | continue; | ||
59 | } | ||
60 | |||
61 | shift = (num & 7) << 2; | ||
62 | mpp_ctrl[num / 8] &= ~(0xf << shift); | ||
63 | mpp_ctrl[num / 8] |= sel << shift; | ||
64 | |||
65 | gpio_mode = 0; | ||
66 | if (*mpp_list & MPP_INPUT_MASK) | ||
67 | gpio_mode |= GPIO_INPUT_OK; | ||
68 | if (*mpp_list & MPP_OUTPUT_MASK) | ||
69 | gpio_mode |= GPIO_OUTPUT_OK; | ||
70 | if (sel != 0) | ||
71 | gpio_mode = 0; | ||
72 | orion_gpio_set_valid(num, gpio_mode); | ||
73 | } | ||
74 | |||
75 | printk(KERN_DEBUG " final MPP regs:"); | ||
76 | for (i = 0; i < mpp_nr_regs; i++) { | ||
77 | writel(mpp_ctrl[i], mpp_ctrl_addr(i, dev_bus)); | ||
78 | printk(" %08x", mpp_ctrl[i]); | ||
79 | } | ||
80 | printk("\n"); | ||
81 | } | ||