From 16655aecb1a151c1f1707c64a571cd06e6a194af Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Mon, 30 Oct 2006 09:35:44 +0100 Subject: [PATCH] Add support for the AVR32 Network Gateway --- arch/avr32/Kconfig | 3 + arch/avr32/Makefile | 1 arch/avr32/boards/atngw/Makefile | 1 arch/avr32/boards/atngw/flash.c | 95 +++++++++++++++++++++++++++++++++++++++ arch/avr32/boards/atngw/setup.c | 81 +++++++++++++++++++++++++++++++++ 5 files changed, 181 insertions(+) Index: linux-2.6.18/arch/avr32/Kconfig =================================================================== --- linux-2.6.18.orig/arch/avr32/Kconfig 2006-12-13 09:45:34.000000000 +0100 +++ linux-2.6.18/arch/avr32/Kconfig 2006-12-13 09:45:34.000000000 +0100 @@ -97,6 +97,9 @@ config BOARD_ATSTK1000 bool "ATSTK1000 evaluation board" select BOARD_ATSTK1002 if CPU_AT32AP7000 + +config BOARD_ATNGW + bool "AVR32 Network Gateway" endchoice choice Index: linux-2.6.18/arch/avr32/Makefile =================================================================== --- linux-2.6.18.orig/arch/avr32/Makefile 2006-12-13 09:45:34.000000000 +0100 +++ linux-2.6.18/arch/avr32/Makefile 2006-12-13 09:45:34.000000000 +0100 @@ -27,6 +27,7 @@ head-y += arch/avr32/kernel/head.o core-$(CONFIG_PLATFORM_AT32AP) += arch/avr32/mach-at32ap/ core-$(CONFIG_BOARD_ATSTK1000) += arch/avr32/boards/atstk1000/ +core-$(CONFIG_BOARD_ATNGW) += arch/avr32/boards/atngw/ core-$(CONFIG_LOADER_U_BOOT) += arch/avr32/boot/u-boot/ core-y += arch/avr32/kernel/ core-y += arch/avr32/mm/ Index: linux-2.6.18/arch/avr32/boards/atngw/Makefile =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.18/arch/avr32/boards/atngw/Makefile 2006-12-13 09:45:34.000000000 +0100 @@ -0,0 +1 @@ +obj-y += setup.o flash.o Index: linux-2.6.18/arch/avr32/boards/atngw/flash.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.18/arch/avr32/boards/atngw/flash.c 2006-12-13 09:45:34.000000000 +0100 @@ -0,0 +1,95 @@ +/* + * ATNGW board-specific flash initialization + * + * Copyright (C) 2005-2006 Atmel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include + +#include + +static struct smc_config flash_config __initdata = { + .ncs_read_setup = 0, + .nrd_setup = 40, + .ncs_write_setup = 0, + .nwe_setup = 10, + + .ncs_read_pulse = 80, + .nrd_pulse = 40, + .ncs_write_pulse = 65, + .nwe_pulse = 55, + + .read_cycle = 120, + .write_cycle = 120, + + .bus_width = 2, + .nrd_controlled = 1, + .nwe_controlled = 1, + .byte_write = 1, +}; + +static struct mtd_partition flash_parts[] = { + { + .name = "u-boot", + .offset = 0x00000000, + .size = 0x00020000, /* 128 KiB */ + .mask_flags = MTD_WRITEABLE, + }, + { + .name = "root", + .offset = 0x00020000, + .size = 0x007d0000, + }, + { + .name = "env", + .offset = 0x007f0000, + .size = 0x00010000, + .mask_flags = MTD_WRITEABLE, + }, +}; + +static struct physmap_flash_data flash_data = { + .width = 2, + .nr_parts = ARRAY_SIZE(flash_parts), + .parts = flash_parts, +}; + +static struct resource flash_resource = { + .start = 0x00000000, + .end = 0x007fffff, + .flags = IORESOURCE_MEM, +}; + +static struct platform_device flash_device = { + .name = "physmap-flash", + .id = 0, + .resource = &flash_resource, + .num_resources = 1, + .dev = { + .platform_data = &flash_data, + }, +}; + +/* This needs to be called after the SMC has been initialized */ +static int __init atngw_flash_init(void) +{ + int ret; + + ret = smc_set_configuration(0, &flash_config); + if (ret < 0) { + printk(KERN_ERR "atngw: failed to set NOR flash timing\n"); + return ret; + } + + platform_device_register(&flash_device); + + return 0; +} +device_initcall(atngw_flash_init); Index: linux-2.6.18/arch/avr32/boards/atngw/setup.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ linux-2.6.18/arch/avr32/boards/atngw/setup.c 2006-12-13 09:59:44.000000000 +0100 @@ -0,0 +1,84 @@ +/* + * Board-specific setup code for the Atmel Network Gateway + * + * Copyright (C) 2005-2006 Atmel Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +/* Initialized by bootloader-specific startup code. */ +struct tag *bootloader_tags __initdata; + +static struct eth_platform_data __initdata eth_data[2]; + +static struct spi_board_info spi_board_info[] __initdata = { + { + .modalias = "mtd_dataflash", + .controller_data = (void *)GPIO_PIN_PA(3), + .max_speed_hz = 66000000, + .bus_num = 0, + .chip_select = 0, + }, +}; + +static int __init parse_tag_ethernet(struct tag *tag) +{ + int i; + + i = tag->u.ethernet.mac_index; + if (i < ARRAY_SIZE(eth_data)) { + eth_data[i].mii_phy_addr = tag->u.ethernet.mii_phy_addr; + memcpy(ð_data[i].hw_addr, tag->u.ethernet.hw_address, + sizeof(eth_data[i].hw_addr)); + eth_data[i].valid = 1; + } + return 0; +} +__tagtable(ATAG_ETHERNET, parse_tag_ethernet); + +void __init setup_board(void) +{ + at32_map_usart(1, 0); /* /dev/ttyS0 */ + + at32_setup_serial_console(0); +} + +static int __init atngw_init(void) +{ + at32_add_system_devices(); + + at32_add_device_usart(0); + + if (eth_data[0].valid) + at32_add_device_eth(0, ð_data[0]); + if (eth_data[1].valid) + at32_add_device_eth(1, ð_data[1]); + + spi_register_board_info(spi_board_info, ARRAY_SIZE(spi_board_info)); + + at32_add_device_spi(0); + at32_add_device_mmci(0); + at32_add_device_usb(0); + + return 0; +} +postcore_initcall(atngw_init); + +void board_setup_fbmem(unsigned long fbmem_start, unsigned long fbmem_size) +{ + +}