diff options
Diffstat (limited to 'arch/arm/plat-orion')
-rw-r--r-- | arch/arm/plat-orion/Makefile | 6 | ||||
-rw-r--r-- | arch/arm/plat-orion/addr-map.c | 178 | ||||
-rw-r--r-- | arch/arm/plat-orion/gpio.c | 59 |
3 files changed, 59 insertions, 184 deletions
diff --git a/arch/arm/plat-orion/Makefile b/arch/arm/plat-orion/Makefile index ad97400ba3ad..2eca54b65906 100644 --- a/arch/arm/plat-orion/Makefile +++ b/arch/arm/plat-orion/Makefile | |||
@@ -3,12 +3,6 @@ | |||
3 | # | 3 | # |
4 | ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include | 4 | ccflags-$(CONFIG_ARCH_MULTIPLATFORM) := -I$(srctree)/$(src)/include |
5 | 5 | ||
6 | obj-$(CONFIG_ARCH_MVEBU) += addr-map.o | ||
7 | obj-$(CONFIG_ARCH_KIRKWOOD) += addr-map.o | ||
8 | obj-$(CONFIG_ARCH_DOVE) += addr-map.o | ||
9 | obj-$(CONFIG_ARCH_ORION5X) += addr-map.o | ||
10 | obj-$(CONFIG_ARCH_MV78XX0) += addr-map.o | ||
11 | |||
12 | orion-gpio-$(CONFIG_GENERIC_GPIO) += gpio.o | 6 | orion-gpio-$(CONFIG_GENERIC_GPIO) += gpio.o |
13 | obj-$(CONFIG_PLAT_ORION_LEGACY) += irq.o pcie.o time.o common.o mpp.o | 7 | obj-$(CONFIG_PLAT_ORION_LEGACY) += irq.o pcie.o time.o common.o mpp.o |
14 | obj-$(CONFIG_PLAT_ORION_LEGACY) += $(orion-gpio-y) | 8 | obj-$(CONFIG_PLAT_ORION_LEGACY) += $(orion-gpio-y) |
diff --git a/arch/arm/plat-orion/addr-map.c b/arch/arm/plat-orion/addr-map.c deleted file mode 100644 index 807ac8e5cbc0..000000000000 --- a/arch/arm/plat-orion/addr-map.c +++ /dev/null | |||
@@ -1,178 +0,0 @@ | |||
1 | /* | ||
2 | * arch/arm/plat-orion/addr-map.c | ||
3 | * | ||
4 | * Address map functions for Marvell Orion based 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/module.h> | ||
13 | #include <linux/init.h> | ||
14 | #include <linux/mbus.h> | ||
15 | #include <linux/io.h> | ||
16 | #include <plat/addr-map.h> | ||
17 | |||
18 | struct mbus_dram_target_info orion_mbus_dram_info; | ||
19 | |||
20 | const struct mbus_dram_target_info *mv_mbus_dram_info(void) | ||
21 | { | ||
22 | return &orion_mbus_dram_info; | ||
23 | } | ||
24 | EXPORT_SYMBOL_GPL(mv_mbus_dram_info); | ||
25 | |||
26 | /* | ||
27 | * DDR target is the same on all Orion platforms. | ||
28 | */ | ||
29 | #define TARGET_DDR 0 | ||
30 | |||
31 | /* | ||
32 | * Helpers to get DDR bank info | ||
33 | */ | ||
34 | #define DDR_BASE_CS_OFF(n) (0x0000 + ((n) << 3)) | ||
35 | #define DDR_SIZE_CS_OFF(n) (0x0004 + ((n) << 3)) | ||
36 | |||
37 | /* | ||
38 | * CPU Address Decode Windows registers | ||
39 | */ | ||
40 | #define WIN_CTRL_OFF 0x0000 | ||
41 | #define WIN_BASE_OFF 0x0004 | ||
42 | #define WIN_REMAP_LO_OFF 0x0008 | ||
43 | #define WIN_REMAP_HI_OFF 0x000c | ||
44 | |||
45 | #define ATTR_HW_COHERENCY (0x1 << 4) | ||
46 | |||
47 | /* | ||
48 | * Default implementation | ||
49 | */ | ||
50 | static void __init __iomem * | ||
51 | orion_win_cfg_base(const struct orion_addr_map_cfg *cfg, int win) | ||
52 | { | ||
53 | return cfg->bridge_virt_base + (win << 4); | ||
54 | } | ||
55 | |||
56 | /* | ||
57 | * Default implementation | ||
58 | */ | ||
59 | static int __init orion_cpu_win_can_remap(const struct orion_addr_map_cfg *cfg, | ||
60 | const int win) | ||
61 | { | ||
62 | if (win < cfg->remappable_wins) | ||
63 | return 1; | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | void __init orion_setup_cpu_win(const struct orion_addr_map_cfg *cfg, | ||
69 | const int win, const u32 base, | ||
70 | const u32 size, const u8 target, | ||
71 | const u8 attr, const int remap) | ||
72 | { | ||
73 | void __iomem *addr = cfg->win_cfg_base(cfg, win); | ||
74 | u32 ctrl, base_high, remap_addr; | ||
75 | |||
76 | if (win >= cfg->num_wins) { | ||
77 | printk(KERN_ERR "setup_cpu_win: trying to allocate window " | ||
78 | "%d when only %d allowed\n", win, cfg->num_wins); | ||
79 | } | ||
80 | |||
81 | base_high = base & 0xffff0000; | ||
82 | ctrl = ((size - 1) & 0xffff0000) | (attr << 8) | (target << 4) | 1; | ||
83 | |||
84 | writel(base_high, addr + WIN_BASE_OFF); | ||
85 | writel(ctrl, addr + WIN_CTRL_OFF); | ||
86 | if (cfg->cpu_win_can_remap(cfg, win)) { | ||
87 | if (remap < 0) | ||
88 | remap_addr = base; | ||
89 | else | ||
90 | remap_addr = remap; | ||
91 | writel(remap_addr & 0xffff0000, addr + WIN_REMAP_LO_OFF); | ||
92 | writel(0, addr + WIN_REMAP_HI_OFF); | ||
93 | } | ||
94 | } | ||
95 | |||
96 | /* | ||
97 | * Configure a number of windows. | ||
98 | */ | ||
99 | static void __init orion_setup_cpu_wins(const struct orion_addr_map_cfg * cfg, | ||
100 | const struct orion_addr_map_info *info) | ||
101 | { | ||
102 | while (info->win != -1) { | ||
103 | orion_setup_cpu_win(cfg, info->win, info->base, info->size, | ||
104 | info->target, info->attr, info->remap); | ||
105 | info++; | ||
106 | } | ||
107 | } | ||
108 | |||
109 | static void __init orion_disable_wins(const struct orion_addr_map_cfg * cfg) | ||
110 | { | ||
111 | void __iomem *addr; | ||
112 | int i; | ||
113 | |||
114 | for (i = 0; i < cfg->num_wins; i++) { | ||
115 | addr = cfg->win_cfg_base(cfg, i); | ||
116 | |||
117 | writel(0, addr + WIN_BASE_OFF); | ||
118 | writel(0, addr + WIN_CTRL_OFF); | ||
119 | if (cfg->cpu_win_can_remap(cfg, i)) { | ||
120 | writel(0, addr + WIN_REMAP_LO_OFF); | ||
121 | writel(0, addr + WIN_REMAP_HI_OFF); | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | |||
126 | /* | ||
127 | * Disable, clear and configure windows. | ||
128 | */ | ||
129 | void __init orion_config_wins(struct orion_addr_map_cfg * cfg, | ||
130 | const struct orion_addr_map_info *info) | ||
131 | { | ||
132 | if (!cfg->cpu_win_can_remap) | ||
133 | cfg->cpu_win_can_remap = orion_cpu_win_can_remap; | ||
134 | |||
135 | if (!cfg->win_cfg_base) | ||
136 | cfg->win_cfg_base = orion_win_cfg_base; | ||
137 | |||
138 | orion_disable_wins(cfg); | ||
139 | |||
140 | if (info) | ||
141 | orion_setup_cpu_wins(cfg, info); | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * Setup MBUS dram target info. | ||
146 | */ | ||
147 | void __init orion_setup_cpu_mbus_target(const struct orion_addr_map_cfg *cfg, | ||
148 | const void __iomem *ddr_window_cpu_base) | ||
149 | { | ||
150 | int i; | ||
151 | int cs; | ||
152 | |||
153 | orion_mbus_dram_info.mbus_dram_target_id = TARGET_DDR; | ||
154 | |||
155 | for (i = 0, cs = 0; i < 4; i++) { | ||
156 | u32 base = readl(ddr_window_cpu_base + DDR_BASE_CS_OFF(i)); | ||
157 | u32 size = readl(ddr_window_cpu_base + DDR_SIZE_CS_OFF(i)); | ||
158 | |||
159 | /* | ||
160 | * We only take care of entries for which the chip | ||
161 | * select is enabled, and that don't have high base | ||
162 | * address bits set (devices can only access the first | ||
163 | * 32 bits of the memory). | ||
164 | */ | ||
165 | if ((size & 1) && !(base & 0xF)) { | ||
166 | struct mbus_dram_window *w; | ||
167 | |||
168 | w = &orion_mbus_dram_info.cs[cs++]; | ||
169 | w->cs_index = i; | ||
170 | w->mbus_attr = 0xf & ~(1 << i); | ||
171 | if (cfg->hw_io_coherency) | ||
172 | w->mbus_attr |= ATTR_HW_COHERENCY; | ||
173 | w->base = base & 0xffff0000; | ||
174 | w->size = (size | 0x0000ffff) + 1; | ||
175 | } | ||
176 | } | ||
177 | orion_mbus_dram_info.num_cs = cs; | ||
178 | } | ||
diff --git a/arch/arm/plat-orion/gpio.c b/arch/arm/plat-orion/gpio.c index c29ee7ea200b..e39c2ba6e2fb 100644 --- a/arch/arm/plat-orion/gpio.c +++ b/arch/arm/plat-orion/gpio.c | |||
@@ -439,6 +439,64 @@ static void gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
439 | } | 439 | } |
440 | } | 440 | } |
441 | 441 | ||
442 | #ifdef CONFIG_DEBUG_FS | ||
443 | #include <linux/seq_file.h> | ||
444 | |||
445 | static void orion_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) | ||
446 | { | ||
447 | struct orion_gpio_chip *ochip = | ||
448 | container_of(chip, struct orion_gpio_chip, chip); | ||
449 | u32 out, io_conf, blink, in_pol, data_in, cause, edg_msk, lvl_msk; | ||
450 | int i; | ||
451 | |||
452 | out = readl_relaxed(GPIO_OUT(ochip)); | ||
453 | io_conf = readl_relaxed(GPIO_IO_CONF(ochip)); | ||
454 | blink = readl_relaxed(GPIO_BLINK_EN(ochip)); | ||
455 | in_pol = readl_relaxed(GPIO_IN_POL(ochip)); | ||
456 | data_in = readl_relaxed(GPIO_DATA_IN(ochip)); | ||
457 | cause = readl_relaxed(GPIO_EDGE_CAUSE(ochip)); | ||
458 | edg_msk = readl_relaxed(GPIO_EDGE_MASK(ochip)); | ||
459 | lvl_msk = readl_relaxed(GPIO_LEVEL_MASK(ochip)); | ||
460 | |||
461 | for (i = 0; i < chip->ngpio; i++) { | ||
462 | const char *label; | ||
463 | u32 msk; | ||
464 | bool is_out; | ||
465 | |||
466 | label = gpiochip_is_requested(chip, i); | ||
467 | if (!label) | ||
468 | continue; | ||
469 | |||
470 | msk = 1 << i; | ||
471 | is_out = !(io_conf & msk); | ||
472 | |||
473 | seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label); | ||
474 | |||
475 | if (is_out) { | ||
476 | seq_printf(s, " out %s %s\n", | ||
477 | out & msk ? "hi" : "lo", | ||
478 | blink & msk ? "(blink )" : ""); | ||
479 | continue; | ||
480 | } | ||
481 | |||
482 | seq_printf(s, " in %s (act %s) - IRQ", | ||
483 | (data_in ^ in_pol) & msk ? "hi" : "lo", | ||
484 | in_pol & msk ? "lo" : "hi"); | ||
485 | if (!((edg_msk | lvl_msk) & msk)) { | ||
486 | seq_printf(s, " disabled\n"); | ||
487 | continue; | ||
488 | } | ||
489 | if (edg_msk & msk) | ||
490 | seq_printf(s, " edge "); | ||
491 | if (lvl_msk & msk) | ||
492 | seq_printf(s, " level"); | ||
493 | seq_printf(s, " (%s)\n", cause & msk ? "pending" : "clear "); | ||
494 | } | ||
495 | } | ||
496 | #else | ||
497 | #define orion_gpio_dbg_show NULL | ||
498 | #endif | ||
499 | |||
442 | void __init orion_gpio_init(struct device_node *np, | 500 | void __init orion_gpio_init(struct device_node *np, |
443 | int gpio_base, int ngpio, | 501 | int gpio_base, int ngpio, |
444 | void __iomem *base, int mask_offset, | 502 | void __iomem *base, int mask_offset, |
@@ -471,6 +529,7 @@ void __init orion_gpio_init(struct device_node *np, | |||
471 | #ifdef CONFIG_OF | 529 | #ifdef CONFIG_OF |
472 | ochip->chip.of_node = np; | 530 | ochip->chip.of_node = np; |
473 | #endif | 531 | #endif |
532 | ochip->chip.dbg_show = orion_gpio_dbg_show; | ||
474 | 533 | ||
475 | spin_lock_init(&ochip->lock); | 534 | spin_lock_init(&ochip->lock); |
476 | ochip->base = (void __iomem *)base; | 535 | ochip->base = (void __iomem *)base; |