2 * ATSTK1002 daughterboard-specific init code
4 * Copyright (C) 2005-2006 Atmel Corporation
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation.
10 #include <linux/clk.h>
11 #include <linux/etherdevice.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/platform_device.h>
15 #include <linux/string.h>
16 #include <linux/types.h>
19 #include <asm/setup.h>
20 #include <asm/arch/board.h>
21 #include <asm/arch/init.h>
27 static struct eth_addr __initdata hw_addr[2];
29 static struct eth_platform_data __initdata eth_data[2];
30 extern struct lcdc_platform_data atstk1000_fb0_data;
33 * The next two functions should go away as the boot loader is
34 * supposed to initialize the macb address registers with a valid
35 * ethernet address. But we need to keep it around for a while until
36 * we can be reasonably sure the boot loader does this.
38 * The phy_id is ignored as the driver will probe for it.
40 static int __init parse_tag_ethernet(struct tag *tag)
44 i = tag->u.ethernet.mac_index;
45 if (i < ARRAY_SIZE(hw_addr))
46 memcpy(hw_addr[i].addr, tag->u.ethernet.hw_address,
47 sizeof(hw_addr[i].addr));
51 __tagtable(ATAG_ETHERNET, parse_tag_ethernet);
53 static void __init set_hw_addr(struct platform_device *pdev)
55 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
62 if (pdev->id >= ARRAY_SIZE(hw_addr))
65 addr = hw_addr[pdev->id].addr;
66 if (!is_valid_ether_addr(addr))
70 * Since this is board-specific code, we'll cheat and use the
71 * physical address directly as we happen to know that it's
72 * the same as the virtual address.
74 regs = (void __iomem __force *)res->start;
75 pclk = clk_get(&pdev->dev, "pclk");
80 __raw_writel((addr[3] << 24) | (addr[2] << 16)
81 | (addr[1] << 8) | addr[0], regs + 0x98);
82 __raw_writel((addr[5] << 8) | addr[4], regs + 0x9c);
87 void __init setup_board(void)
89 at32_map_usart(1, 0); /* /dev/ttyS0 */
90 at32_map_usart(2, 1); /* /dev/ttyS1 */
91 at32_map_usart(3, 2); /* /dev/ttyS2 */
93 at32_setup_serial_console(0);
96 static int __init atstk1002_init(void)
98 at32_add_system_devices();
100 at32_add_device_usart(0);
101 at32_add_device_usart(1);
102 at32_add_device_usart(2);
104 set_hw_addr(at32_add_device_eth(0, ð_data[0]));
106 at32_add_device_spi(0);
107 at32_add_device_lcdc(0, &atstk1000_fb0_data);
111 postcore_initcall(atstk1002_init);