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 static struct map_desc mcs814x_io_desc[] __initdata = {
28 .virtual = MCS814X_IO_BASE,
29 .pfn = __phys_to_pfn(MCS814X_IO_START),
30 .length = MCS814X_IO_SIZE,
41 static const struct cpu_mode cpu_modes[] = {
53 .name = "External MII",
64 static void mcs814x_eth_hardware_filter_set(u8 value)
68 reg = __raw_readl(_CONFADDR_DBGLED);
73 __raw_writel(reg, _CONFADDR_DBGLED);
76 static void mcs814x_eth_led_cfg_set(u8 cfg)
80 reg = __raw_readl(_CONFADDR_SYSDBG + SYSDBG_BS2);
83 __raw_writel(reg, _CONFADDR_SYSDBG + SYSDBG_BS2);
86 static void mcs814x_eth_buffer_shifting_set(u8 value)
90 reg = __raw_readb(_CONFADDR_SYSDBG + SYSDBG_SYSCTL_MAC);
94 reg &= ~BUF_SHIFT_BIT;
95 __raw_writeb(reg, _CONFADDR_SYSDBG + SYSDBG_SYSCTL_MAC);
98 static struct of_device_id mcs814x_eth_ids[] __initdata = {
99 { .compatible = "moschip,nuport-mac", },
103 /* Configure platform specific knobs based on ethernet device node
105 static void mcs814x_eth_init(void)
107 struct device_node *np;
108 const unsigned int *intspec;
110 np = of_find_matching_node(NULL, mcs814x_eth_ids);
114 /* hardware filter must always be enabled */
115 mcs814x_eth_hardware_filter_set(1);
117 intspec = of_get_property(np, "nuport-mac,buffer-shifting", NULL);
119 mcs814x_eth_buffer_shifting_set(0);
121 mcs814x_eth_buffer_shifting_set(1);
123 intspec = of_get_property(np, "nuport-mac,link-activity", NULL);
125 mcs814x_eth_led_cfg_set(be32_to_cpup(intspec));
128 void __init mcs814x_init_machine(void)
133 bs2 = __raw_readl(_CONFADDR_SYSDBG + SYSDBG_BS2);
134 cpu_mode = (bs2 >> CPU_MODE_SHIFT) & CPU_MODE_MASK;
136 pr_info("CPU mode: %s\n", cpu_modes[cpu_mode].name);
138 /* request the gpios since the pins are muxed for functionnality */
139 for (gpio = cpu_modes[cpu_mode].gpio_start;
140 gpio == cpu_modes[cpu_mode].gpio_end; gpio++) {
142 gpio_request(gpio, cpu_modes[cpu_mode].name);
148 void __init mcs814x_map_io(void)
150 iotable_init(mcs814x_io_desc, ARRAY_SIZE(mcs814x_io_desc));
153 void mcs814x_restart(char mode, const char *cmd)
155 __raw_writel(~(1 << 31), _CONFADDR_SYSDBG);