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/hardware.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
,
35 #define SYSDBG_BS2 0x04
36 #define LED_CFG_MASK 0x03
37 #define CPU_MODE_SHIFT 23
38 #define CPU_MODE_MASK 0x03
40 #define SYSDBG_SYSCTL_MAC 0x1d
48 static const struct cpu_mode cpu_modes
[] = {
60 .name
= "External MII",
71 static void mcs814x_eth_hardware_filter_set(u8 value
)
75 reg
= __raw_readl(_CONFADDR_DBGLED
);
80 __raw_writel(reg
, _CONFADDR_DBGLED
);
83 static void mcs814x_eth_led_cfg_set(u8 cfg
)
87 reg
= __raw_readl(_CONFADDR_SYSDBG
+ SYSDBG_BS2
);
90 __raw_writel(reg
, _CONFADDR_SYSDBG
+ SYSDBG_BS2
);
93 static void mcs814x_eth_buffer_shifting_set(u8 value
)
97 reg
= __raw_readb(_CONFADDR_SYSDBG
+ SYSDBG_SYSCTL_MAC
);
102 __raw_writeb(reg
, _CONFADDR_SYSDBG
+ SYSDBG_SYSCTL_MAC
);
105 static struct of_device_id mcs814x_eth_ids
[] __initdata
= {
106 { .compatible
= "moschip,nuport-mac", },
110 /* Configure platform specific knobs based on ethernet device node
112 static void mcs814x_eth_init(void)
114 struct device_node
*np
;
115 const unsigned int *intspec
;
117 np
= of_find_matching_node(NULL
, mcs814x_eth_ids
);
121 /* hardware filter must always be enabled */
122 mcs814x_eth_hardware_filter_set(1);
124 intspec
= of_get_property(np
, "nuport-mac,buffer-shifting", NULL
);
126 mcs814x_eth_buffer_shifting_set(0);
128 mcs814x_eth_buffer_shifting_set(1);
130 intspec
= of_get_property(np
, "nuport-mac,link-activity", NULL
);
132 mcs814x_eth_led_cfg_set(be32_to_cpup(intspec
));
135 void __init
mcs814x_init_machine(void)
140 bs2
= __raw_readl(_CONFADDR_SYSDBG
+ SYSDBG_BS2
);
141 cpu_mode
= (bs2
>> CPU_MODE_SHIFT
) & CPU_MODE_MASK
;
143 pr_info("CPU mode: %s\n", cpu_modes
[cpu_mode
].name
);
145 /* request the gpios since the pins are muxed for functionnality */
146 for (gpio
= cpu_modes
[cpu_mode
].gpio_start
;
147 gpio
== cpu_modes
[cpu_mode
].gpio_end
; gpio
++) {
149 gpio_request(gpio
, cpu_modes
[cpu_mode
].name
);
155 void __init
mcs814x_map_io(void)
157 iotable_init(mcs814x_io_desc
, ARRAY_SIZE(mcs814x_io_desc
));
160 void mcs814x_restart(char mode
, const char *cmd
)
162 __raw_writel(~(1 << 31), _CONFADDR_SYSDBG
);