3 * arch/xtensa/platform/xtavnet/setup.c
7 * Authors: Chris Zankel <chris@zankel.net>
8 * Joe Taylor <joe@tensilica.com>
10 * Copyright 2001 - 2006 Tensilica Inc.
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
18 #include <linux/stddef.h>
19 #include <linux/kernel.h>
20 #include <linux/init.h>
21 #include <linux/errno.h>
22 #include <linux/reboot.h>
23 #include <linux/kdev_t.h>
24 #include <linux/types.h>
25 #include <linux/major.h>
26 #include <linux/console.h>
27 #include <linux/delay.h>
30 #include <asm/timex.h>
31 #include <asm/processor.h>
32 #include <asm/platform.h>
33 #include <asm/bootparam.h>
34 #include <platform/lcd.h>
36 void platform_halt(void)
38 lcd_disp_at_pos(" HALT ", 0);
44 void platform_power_off(void)
46 lcd_disp_at_pos("POWEROFF", 0);
52 void platform_restart(void)
54 /* Flush and reset the mmu, simulate a processor reset, and
55 * jump to the reset vector. */
58 __asm__ __volatile__ ("movi a2, 15\n\t"
59 "wsr a2, icountlevel\n\t"
62 "wsr a2, ibreakenable\n\t"
69 : "a" (XCHAL_RESET_VECTOR_VADDR)
73 /* control never gets here */
76 void __init platform_setup(char **cmdline)
82 static void __init update_clock_frequency(struct device_node *node)
84 struct property *newfreq;
87 if (!of_property_read_u32(node, "clock-frequency", &freq) &&
91 newfreq = kzalloc(sizeof(*newfreq) + sizeof(u32), GFP_KERNEL);
94 newfreq->value = newfreq + 1;
95 newfreq->length = sizeof(freq);
96 newfreq->name = kstrdup("clock-frequency", GFP_KERNEL);
102 *(u32 *)newfreq->value = cpu_to_be32(*(u32 *)XTFPGA_CLKFRQ_VADDR);
103 prom_update_property(node, newfreq);
106 static int __init machine_setup(void)
108 struct device_node *serial = NULL;
110 while ((serial = of_find_compatible_node(serial, NULL, "ns16550a")))
111 update_clock_frequency(serial);
114 arch_initcall(machine_setup);
118 /* early initialization */
120 void __init platform_init(bp_tag_t *first)
126 void platform_heartbeat(void)
130 #ifdef CONFIG_XTENSA_CALIBRATE_CCOUNT
132 void platform_calibrate_ccount(void)
136 struct device_node *cpu =
137 of_find_compatible_node(NULL, NULL, "xtensa,cpu");
140 update_clock_frequency(cpu);
141 if (!of_property_read_u32(cpu, "clock-frequency", &freq))
146 clk_freq = *(long *)XTFPGA_CLKFRQ_VADDR;
148 ccount_per_jiffy = clk_freq / HZ;
149 nsec_per_ccount = 1000000000UL / clk_freq;
156 #include <linux/serial_8250.h>
157 #include <linux/if.h>
158 #include <net/ethoc.h>
160 /*----------------------------------------------------------------------------
161 * Ethernet -- OpenCores Ethernet MAC (ethoc driver)
164 static struct resource ethoc_res[] __initdata = {
165 [0] = { /* register space */
166 .start = OETH_REGS_PADDR,
167 .end = OETH_REGS_PADDR + OETH_REGS_SIZE - 1,
168 .flags = IORESOURCE_MEM,
170 [1] = { /* buffer space */
171 .start = OETH_SRAMBUFF_PADDR,
172 .end = OETH_SRAMBUFF_PADDR + OETH_SRAMBUFF_SIZE - 1,
173 .flags = IORESOURCE_MEM,
175 [2] = { /* IRQ number */
178 .flags = IORESOURCE_IRQ,
182 static struct ethoc_platform_data ethoc_pdata __initdata = {
184 * The MAC address for these boards is 00:50:c2:13:6f:xx.
185 * The last byte (here as zero) is read from the DIP switches on the
188 .hwaddr = { 0x00, 0x50, 0xc2, 0x13, 0x6f, 0 },
192 static struct platform_device ethoc_device __initdata = {
195 .num_resources = ARRAY_SIZE(ethoc_res),
196 .resource = ethoc_res,
198 .platform_data = ðoc_pdata,
202 /*----------------------------------------------------------------------------
206 static struct resource serial_resource __initdata = {
207 .start = DUART16552_PADDR,
208 .end = DUART16552_PADDR + 0x1f,
209 .flags = IORESOURCE_MEM,
212 static struct plat_serial8250_port serial_platform_data[] __initdata = {
214 .mapbase = DUART16552_PADDR,
215 .irq = DUART16552_INTNUM,
216 .flags = UPF_BOOT_AUTOCONF | UPF_SKIP_TEST |
218 .iotype = UPIO_MEM32,
220 .uartclk = 0, /* set in xtavnet_init() */
225 static struct platform_device xtavnet_uart __initdata = {
226 .name = "serial8250",
227 .id = PLAT8250_DEV_PLATFORM,
229 .platform_data = serial_platform_data,
232 .resource = &serial_resource,
235 /* platform devices */
236 static struct platform_device *platform_devices[] __initdata = {
242 static int __init xtavnet_init(void)
244 /* Ethernet MAC address. */
245 ethoc_pdata.hwaddr[5] = *(u32 *)DIP_SWITCHES_VADDR;
247 /* Clock rate varies among FPGA bitstreams; board specific FPGA register
248 * reports the actual clock rate.
250 serial_platform_data[0].uartclk = *(long *)XTFPGA_CLKFRQ_VADDR;
253 /* register platform devices */
254 platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices));
256 /* ETHOC driver is a bit quiet; at least display Ethernet MAC, so user
257 * knows whether they set it correctly on the DIP switches.
259 pr_info("XTFPGA: Ethernet MAC %pM\n", ethoc_pdata.hwaddr);
265 * Register to be done during do_initcalls().
267 arch_initcall(xtavnet_init);
269 #endif /* CONFIG_OF */