aboutsummaryrefslogtreecommitdiffstats
path: root/arch/avr32/boards
diff options
context:
space:
mode:
authorHaavard Skinnemoen <hskinnemoen@atmel.com>2007-04-12 11:26:57 -0400
committerHaavard Skinnemoen <hskinnemoen@atmel.com>2007-04-27 07:44:15 -0400
commit9ca20a8366462c553c27216161c735937f9de108 (patch)
treeda29b02189dca4c13caa784a3b941b7948eee75b /arch/avr32/boards
parent2c1a2a3441a754a9b5a8e7184071154f8a9bd61b (diff)
[AVR32] Board code for ATNGW100
Add board code and defconfig for the ATNGW100 Network Gateway kit. For more information about this board, see http://www.atmel.com/dyn/products/tools_card.asp?tool_id=4102 Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Diffstat (limited to 'arch/avr32/boards')
-rw-r--r--arch/avr32/boards/atngw100/Makefile1
-rw-r--r--arch/avr32/boards/atngw100/flash.c95
-rw-r--r--arch/avr32/boards/atngw100/setup.c124
3 files changed, 220 insertions, 0 deletions
diff --git a/arch/avr32/boards/atngw100/Makefile b/arch/avr32/boards/atngw100/Makefile
new file mode 100644
index 000000000000..c740aa116755
--- /dev/null
+++ b/arch/avr32/boards/atngw100/Makefile
@@ -0,0 +1 @@
obj-y += setup.o flash.o
diff --git a/arch/avr32/boards/atngw100/flash.c b/arch/avr32/boards/atngw100/flash.c
new file mode 100644
index 000000000000..f9b32a8eab9b
--- /dev/null
+++ b/arch/avr32/boards/atngw100/flash.c
@@ -0,0 +1,95 @@
1/*
2 * ATNGW100 board-specific flash initialization
3 *
4 * Copyright (C) 2005-2006 Atmel Corporation
5 *
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.
9 */
10#include <linux/init.h>
11#include <linux/platform_device.h>
12#include <linux/mtd/mtd.h>
13#include <linux/mtd/partitions.h>
14#include <linux/mtd/physmap.h>
15
16#include <asm/arch/smc.h>
17
18static struct smc_config flash_config __initdata = {
19 .ncs_read_setup = 0,
20 .nrd_setup = 40,
21 .ncs_write_setup = 0,
22 .nwe_setup = 10,
23
24 .ncs_read_pulse = 80,
25 .nrd_pulse = 40,
26 .ncs_write_pulse = 65,
27 .nwe_pulse = 55,
28
29 .read_cycle = 120,
30 .write_cycle = 120,
31
32 .bus_width = 2,
33 .nrd_controlled = 1,
34 .nwe_controlled = 1,
35 .byte_write = 1,
36};
37
38static struct mtd_partition flash_parts[] = {
39 {
40 .name = "u-boot",
41 .offset = 0x00000000,
42 .size = 0x00020000, /* 128 KiB */
43 .mask_flags = MTD_WRITEABLE,
44 },
45 {
46 .name = "root",
47 .offset = 0x00020000,
48 .size = 0x007d0000,
49 },
50 {
51 .name = "env",
52 .offset = 0x007f0000,
53 .size = 0x00010000,
54 .mask_flags = MTD_WRITEABLE,
55 },
56};
57
58static struct physmap_flash_data flash_data = {
59 .width = 2,
60 .nr_parts = ARRAY_SIZE(flash_parts),
61 .parts = flash_parts,
62};
63
64static struct resource flash_resource = {
65 .start = 0x00000000,
66 .end = 0x007fffff,
67 .flags = IORESOURCE_MEM,
68};
69
70static struct platform_device flash_device = {
71 .name = "physmap-flash",
72 .id = 0,
73 .resource = &flash_resource,
74 .num_resources = 1,
75 .dev = {
76 .platform_data = &flash_data,
77 },
78};
79
80/* This needs to be called after the SMC has been initialized */
81static int __init atngw100_flash_init(void)
82{
83 int ret;
84
85 ret = smc_set_configuration(0, &flash_config);
86 if (ret < 0) {
87 printk(KERN_ERR "atngw100: failed to set NOR flash timing\n");
88 return ret;
89 }
90
91 platform_device_register(&flash_device);
92
93 return 0;
94}
95device_initcall(atngw100_flash_init);
diff --git a/arch/avr32/boards/atngw100/setup.c b/arch/avr32/boards/atngw100/setup.c
new file mode 100644
index 000000000000..9bc37d4f6687
--- /dev/null
+++ b/arch/avr32/boards/atngw100/setup.c
@@ -0,0 +1,124 @@
1/*
2 * Board-specific setup code for the ATNGW100 Network Gateway
3 *
4 * Copyright (C) 2005-2006 Atmel Corporation
5 *
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.
9 */
10#include <linux/clk.h>
11#include <linux/etherdevice.h>
12#include <linux/init.h>
13#include <linux/linkage.h>
14#include <linux/platform_device.h>
15#include <linux/types.h>
16#include <linux/spi/spi.h>
17
18#include <asm/io.h>
19#include <asm/setup.h>
20
21#include <asm/arch/at32ap7000.h>
22#include <asm/arch/board.h>
23#include <asm/arch/init.h>
24
25/* Initialized by bootloader-specific startup code. */
26struct tag *bootloader_tags __initdata;
27
28struct eth_addr {
29 u8 addr[6];
30};
31static struct eth_addr __initdata hw_addr[2];
32static struct eth_platform_data __initdata eth_data[2];
33
34static struct spi_board_info spi0_board_info[] __initdata = {
35 {
36 .modalias = "mtd_dataflash",
37 .max_speed_hz = 10000000,
38 .chip_select = 0,
39 },
40};
41
42/*
43 * The next two functions should go away as the boot loader is
44 * supposed to initialize the macb address registers with a valid
45 * ethernet address. But we need to keep it around for a while until
46 * we can be reasonably sure the boot loader does this.
47 *
48 * The phy_id is ignored as the driver will probe for it.
49 */
50static int __init parse_tag_ethernet(struct tag *tag)
51{
52 int i;
53
54 i = tag->u.ethernet.mac_index;
55 if (i < ARRAY_SIZE(hw_addr))
56 memcpy(hw_addr[i].addr, tag->u.ethernet.hw_address,
57 sizeof(hw_addr[i].addr));
58
59 return 0;
60}
61__tagtable(ATAG_ETHERNET, parse_tag_ethernet);
62
63static void __init set_hw_addr(struct platform_device *pdev)
64{
65 struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
66 const u8 *addr;
67 void __iomem *regs;
68 struct clk *pclk;
69
70 if (!res)
71 return;
72 if (pdev->id >= ARRAY_SIZE(hw_addr))
73 return;
74
75 addr = hw_addr[pdev->id].addr;
76 if (!is_valid_ether_addr(addr))
77 return;
78
79 /*
80 * Since this is board-specific code, we'll cheat and use the
81 * physical address directly as we happen to know that it's
82 * the same as the virtual address.
83 */
84 regs = (void __iomem __force *)res->start;
85 pclk = clk_get(&pdev->dev, "pclk");
86 if (!pclk)
87 return;
88
89 clk_enable(pclk);
90 __raw_writel((addr[3] << 24) | (addr[2] << 16)
91 | (addr[1] << 8) | addr[0], regs + 0x98);
92 __raw_writel((addr[5] << 8) | addr[4], regs + 0x9c);
93 clk_disable(pclk);
94 clk_put(pclk);
95}
96
97struct platform_device *at32_usart_map[1];
98unsigned int at32_nr_usarts = 1;
99
100void __init setup_board(void)
101{
102 at32_map_usart(1, 0); /* USART 1: /dev/ttyS0, DB9 */
103 at32_setup_serial_console(0);
104}
105
106static int __init atngw100_init(void)
107{
108 /*
109 * ATNGW100 uses 16-bit SDRAM interface, so we don't need to
110 * reserve any pins for it.
111 */
112
113 at32_add_system_devices();
114
115 at32_add_device_usart(0);
116
117 set_hw_addr(at32_add_device_eth(0, &eth_data[0]));
118 set_hw_addr(at32_add_device_eth(1, &eth_data[1]));
119
120 at32_add_device_spi(0, spi0_board_info, ARRAY_SIZE(spi0_board_info));
121
122 return 0;
123}
124postcore_initcall(atngw100_init);