2 * arch/arm/mach-mcs814x/common.c
4 * Core functions for Moschip MCS814x 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>
14 #include <linux/gpio.h>
16 #include <linux/of_address.h>
18 #include <asm/setup.h>
19 #include <asm/mach-types.h>
20 #include <asm/mach/arch.h>
21 #include <mach/mcs814x.h>
23 #include <asm/pgtable.h>
24 #include <asm/mach/map.h>
26 void __iomem
*mcs814x_sysdbg_base
;
28 static struct map_desc mcs814x_io_desc
[] __initdata
= {
30 .virtual = MCS814X_IO_BASE
,
31 .pfn
= __phys_to_pfn(MCS814X_IO_START
),
32 .length
= MCS814X_IO_SIZE
,
43 static const struct cpu_mode cpu_modes
[] = {
55 .name
= "External MII",
66 static void mcs814x_eth_hardware_filter_set(u8 value
)
70 reg
= readl_relaxed(MCS814X_VIRT_BASE
+ MCS814X_DBGLED
);
75 writel_relaxed(reg
, MCS814X_VIRT_BASE
+ MCS814X_DBGLED
);
78 static void mcs814x_eth_led_cfg_set(u8 cfg
)
82 reg
= readl_relaxed(mcs814x_sysdbg_base
+ SYSDBG_BS2
);
85 writel_relaxed(reg
, mcs814x_sysdbg_base
+ SYSDBG_BS2
);
88 static void mcs814x_eth_buffer_shifting_set(u8 value
)
92 reg
= readb_relaxed(mcs814x_sysdbg_base
+ SYSDBG_SYSCTL_MAC
);
96 reg
&= ~BUF_SHIFT_BIT
;
97 writeb_relaxed(reg
, mcs814x_sysdbg_base
+ SYSDBG_SYSCTL_MAC
);
100 static struct of_device_id mcs814x_eth_ids
[] __initdata
= {
101 { .compatible
= "moschip,nuport-mac", },
105 /* Configure platform specific knobs based on ethernet device node
107 static void mcs814x_eth_init(void)
109 struct device_node
*np
;
110 const unsigned int *intspec
;
112 np
= of_find_matching_node(NULL
, mcs814x_eth_ids
);
116 /* hardware filter must always be enabled */
117 mcs814x_eth_hardware_filter_set(1);
119 intspec
= of_get_property(np
, "nuport-mac,buffer-shifting", NULL
);
121 mcs814x_eth_buffer_shifting_set(0);
123 mcs814x_eth_buffer_shifting_set(1);
125 intspec
= of_get_property(np
, "nuport-mac,link-activity", NULL
);
127 mcs814x_eth_led_cfg_set(be32_to_cpup(intspec
));
132 void __init
mcs814x_init_machine(void)
137 bs2
= readl_relaxed(mcs814x_sysdbg_base
+ SYSDBG_BS2
);
138 cpu_mode
= (bs2
>> CPU_MODE_SHIFT
) & CPU_MODE_MASK
;
140 pr_info("CPU mode: %s\n", cpu_modes
[cpu_mode
].name
);
142 /* request the gpios since the pins are muxed for functionnality */
143 for (gpio
= cpu_modes
[cpu_mode
].gpio_start
;
144 gpio
== cpu_modes
[cpu_mode
].gpio_end
; gpio
++) {
146 gpio_request(gpio
, cpu_modes
[cpu_mode
].name
);
152 void __init
mcs814x_map_io(void)
154 iotable_init(mcs814x_io_desc
, ARRAY_SIZE(mcs814x_io_desc
));
156 mcs814x_sysdbg_base
= ioremap(MCS814X_IO_START
+ MCS814X_SYSDBG
,
157 MCS814X_SYSDBG_SIZE
);
158 if (!mcs814x_sysdbg_base
)
159 panic("unable to remap sysdbg base");
162 void mcs814x_restart(enum reboot_mode mode
, const char *cmd
)
164 writel_relaxed(~(1 << 31), mcs814x_sysdbg_base
);