From ab0df36fc7db9dda0b786b909f653e279dfeb9cf Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Fri, 29 Aug 2008 21:09:49 +0200 Subject: avr32: refactor the portmux/gpio code - Separate the portmux configuration functionality from the GPIO pin control API. - Separate the controller-specific code from the chip-specific code. - Allow "ganged" port configuration (multiple pins at once). - Add more flexibility to the "canned" peripheral select functions: - Allow using more than 23 address bits, more chip selects, as well as NAND- and CF-specific pins. - Make the MACB SPEED pin optional, and choose between MII/RMII using a parameter instead of an #ifdef. - Make it possible to use other MMC slots than slot 0, and support different MMC/SDCard data bus widths. - Use more reasonable pull-up defaults; floating pins may consume a lot of power. - Get rid of some custom portmux code from the mimc200 board code. The old gpio/portmux API couldn't really handle its requirements, but the new one can. - Add documentation. The end result is slightly smaller code for all boards. Which isn't really the point, but at least it isn't any larger. This has been verified on ATSTK1002 and ATNGW100. I'd appreciate if the board maintainers could help me test this on their boards. In particular, the mimc200 port has lost a lot of code, so I'm hoping Mark can help me out. Signed-off-by: Haavard Skinnemoen Cc: Hans-Christian Egtvedt Cc: Mark Jackson Cc: Alex Raimondi Cc: Julien May Changes since v1: * Enable pullup on NWAIT * Add missing include to portmux-pio.h * Rename CONFIG_PIO2 -> CONFIG_PORTMUX_PIO to match docs --- board/atmel/atngw100/atngw100.c | 15 ++++++++------- board/atmel/atstk1000/atstk1000.c | 12 ++++++------ 2 files changed, 14 insertions(+), 13 deletions(-) (limited to 'board/atmel') diff --git a/board/atmel/atngw100/atngw100.c b/board/atmel/atngw100/atngw100.c index 7f3e48541..03544aa21 100644 --- a/board/atmel/atngw100/atngw100.c +++ b/board/atmel/atngw100/atngw100.c @@ -26,6 +26,7 @@ #include #include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -50,18 +51,18 @@ int board_early_init_f(void) /* Enable SDRAM in the EBI mux */ hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE)); - gpio_enable_ebi(); - gpio_enable_usart1(); + portmux_enable_ebi(16, 23, 0, PORTMUX_DRIVE_HIGH); + portmux_enable_usart1(PORTMUX_DRIVE_MIN); #if defined(CONFIG_MACB) - gpio_enable_macb0(); - gpio_enable_macb1(); + portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH); + portmux_enable_macb1(PORTMUX_MACB_MII, PORTMUX_DRIVE_HIGH); #endif #if defined(CONFIG_MMC) - gpio_enable_mmci(); + portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW); #endif #if defined(CONFIG_ATMEL_SPI) - gpio_enable_spi0(1 << 0); + portmux_enable_spi0(1 << 0, PORTMUX_DRIVE_LOW); #endif return 0; @@ -108,7 +109,7 @@ int board_eth_init(bd_t *bi) #ifdef CONFIG_ATMEL_SPI #include -#define ATNGW100_DATAFLASH_CS_PIN GPIO_PIN_PA3 +#define ATNGW100_DATAFLASH_CS_PIN GPIO_PIN_PA(3) int spi_cs_is_valid(unsigned int bus, unsigned int cs) { diff --git a/board/atmel/atstk1000/atstk1000.c b/board/atmel/atstk1000/atstk1000.c index 915b1c353..cc400a92f 100644 --- a/board/atmel/atstk1000/atstk1000.c +++ b/board/atmel/atstk1000/atstk1000.c @@ -24,8 +24,8 @@ #include #include #include -#include #include +#include DECLARE_GLOBAL_DATA_PTR; @@ -77,14 +77,14 @@ int board_early_init_f(void) /* Enable SDRAM in the EBI mux */ hmatrix_slave_write(EBI, SFR, HMATRIX_BIT(EBI_SDRAM_ENABLE)); - gpio_enable_ebi(); - gpio_enable_usart1(); + portmux_enable_ebi(sdram_config.data_bits, 23, 0, PORTMUX_DRIVE_HIGH); + portmux_enable_usart1(PORTMUX_DRIVE_MIN); #if defined(CONFIG_MACB) - gpio_enable_macb0(); - gpio_enable_macb1(); + portmux_enable_macb0(PORTMUX_MACB_MII, PORTMUX_DRIVE_LOW); + portmux_enable_macb1(PORTMUX_MACB_MII, PORTMUX_DRIVE_LOW); #endif #if defined(CONFIG_MMC) - gpio_enable_mmci(); + portmux_enable_mmci(0, PORTMUX_MMCI_4BIT, PORTMUX_DRIVE_LOW); #endif return 0; -- cgit v1.2.3 From 25e6854d42c11046a468576179b5494f850311b2 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Sun, 31 Aug 2008 18:46:35 +0200 Subject: avr32: use board_early_init_r instead of board_init_info Replace the avr32-specific board_init_info hook by the standard board_early_init_r hook and make it optional. board_early_init_r() runs somewhat earlier than board_init_info used to do, but this isn't a problem for any of the in-tree boards. Signed-off-by: Haavard Skinnemoen --- board/atmel/atngw100/atngw100.c | 3 ++- board/atmel/atstk1000/atstk1000.c | 3 ++- board/earthlcd/favr-32-ezkit/favr-32-ezkit.c | 3 ++- board/mimc/mimc200/mimc200.c | 3 ++- board/miromico/hammerhead/hammerhead.c | 3 ++- include/asm-avr32/initcalls.h | 1 - lib_avr32/board.c | 4 +++- 7 files changed, 13 insertions(+), 7 deletions(-) (limited to 'board/atmel') diff --git a/board/atmel/atngw100/atngw100.c b/board/atmel/atngw100/atngw100.c index 03544aa21..480d5255f 100644 --- a/board/atmel/atngw100/atngw100.c +++ b/board/atmel/atngw100/atngw100.c @@ -88,10 +88,11 @@ phys_size_t initdram(int board_type) return actual_size; } -void board_init_info(void) +int board_early_init_r(void) { gd->bd->bi_phy_id[0] = 0x01; gd->bd->bi_phy_id[1] = 0x03; + return 0; } extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); diff --git a/board/atmel/atstk1000/atstk1000.c b/board/atmel/atstk1000/atstk1000.c index cc400a92f..7be39931e 100644 --- a/board/atmel/atstk1000/atstk1000.c +++ b/board/atmel/atstk1000/atstk1000.c @@ -110,10 +110,11 @@ phys_size_t initdram(int board_type) return actual_size; } -void board_init_info(void) +int board_early_init_r(void) { gd->bd->bi_phy_id[0] = 0x10; gd->bd->bi_phy_id[1] = 0x11; + return 0; } extern int macb_eth_initialize(int id, void *regs, unsigned int phy_addr); diff --git a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c index b2ddd089d..d53ca4c13 100644 --- a/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c +++ b/board/earthlcd/favr-32-ezkit/favr-32-ezkit.c @@ -81,9 +81,10 @@ phys_size_t initdram(int board_type) return actual_size; } -void board_init_info(void) +int board_early_init_r(void) { gd->bd->bi_phy_id[0] = 0x01; + return 0; } #if defined(CONFIG_MACB) && defined(CONFIG_CMD_NET) diff --git a/board/mimc/mimc200/mimc200.c b/board/mimc/mimc200/mimc200.c index 4da467860..c30bcb6d3 100644 --- a/board/mimc/mimc200/mimc200.c +++ b/board/mimc/mimc200/mimc200.c @@ -124,10 +124,11 @@ phys_size_t initdram(int board_type) return actual_size; } -void board_init_info(void) +int board_early_init_r(void) { gd->bd->bi_phy_id[0] = 0x01; gd->bd->bi_phy_id[1] = 0x03; + return 0; } /* SPI chip select control */ diff --git a/board/miromico/hammerhead/hammerhead.c b/board/miromico/hammerhead/hammerhead.c index 867052789..7fd078125 100644 --- a/board/miromico/hammerhead/hammerhead.c +++ b/board/miromico/hammerhead/hammerhead.c @@ -95,9 +95,10 @@ phys_size_t initdram(int board_type) return actual_size; } -void board_init_info(void) +int board_early_init_r(void) { gd->bd->bi_phy_id[0] = 0x01; + return 0; } int board_postclk_init(void) diff --git a/include/asm-avr32/initcalls.h b/include/asm-avr32/initcalls.h index 583e5dc10..57a278b6a 100644 --- a/include/asm-avr32/initcalls.h +++ b/include/asm-avr32/initcalls.h @@ -26,6 +26,5 @@ extern int cpu_init(void); extern int timer_init(void); -extern void board_init_info(void); #endif /* __ASM_AVR32_INITCALLS_H__ */ diff --git a/lib_avr32/board.c b/lib_avr32/board.c index 19d76d2ca..4ed6c9663 100644 --- a/lib_avr32/board.c +++ b/lib_avr32/board.c @@ -53,6 +53,7 @@ static int __do_nothing(void) return 0; } int board_postclk_init(void) __attribute__((weak, alias("__do_nothing"))); +int board_early_init_r(void) __attribute__((weak, alias("__do_nothing"))); /* The malloc area is right below the monitor image in RAM */ static void mem_malloc_init(void) @@ -282,6 +283,8 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) gd->flags |= GD_FLG_RELOC; gd->reloc_off = dest_addr - CFG_MONITOR_BASE; + board_early_init_r(); + monitor_flash_len = _edata - _text; /* @@ -318,7 +321,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) mem_malloc_init(); malloc_bin_reloc(); dma_alloc_init(); - board_init_info(); enable_interrupts(); -- cgit v1.2.3 From d92852579546c46bdaac978e0b6767a6645b69e0 Mon Sep 17 00:00:00 2001 From: Haavard Skinnemoen Date: Fri, 15 Aug 2008 15:02:29 +0200 Subject: atstk1000: Convert to new-style makefile Signed-off-by: Haavard Skinnemoen --- board/atmel/atstk1000/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'board/atmel') diff --git a/board/atmel/atstk1000/Makefile b/board/atmel/atstk1000/Makefile index 155d46ac9..f9b26e5d3 100644 --- a/board/atmel/atstk1000/Makefile +++ b/board/atmel/atstk1000/Makefile @@ -24,12 +24,13 @@ include $(TOPDIR)/config.mk -LIB := $(obj)lib$(BOARD).a +LIB := $(obj)lib$(BOARD).a -COBJS := $(BOARD).o flash.o +COBJS-y += $(BOARD).o +COBJS-y += flash.o -SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) -OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) +SRCS := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y)) $(LIB): $(obj).depend $(OBJS) $(AR) $(ARFLAGS) $@ $(OBJS) -- cgit v1.2.3 From d8f2aa3298610b44127dbc4796d8038aa5847e0b Mon Sep 17 00:00:00 2001 From: Olav Morken Date: Fri, 23 Jan 2009 12:56:27 +0100 Subject: AVR32: Make cacheflush cpu-dependent The AT32UC3A series of processors doesn't contain any cache, and issuing cache control instructions on those will cause an exception. This commit makes cacheflush.h arch-dependent in preparation for the AT32UC3A-support. Signed-off-by: Gunnar Rangoy Signed-off-by: Paul Driveklepp Signed-off-by: Olav Morken Signed-off-by: Haavard Skinnemoen --- board/atmel/atstk1000/flash.c | 2 +- board/earthlcd/favr-32-ezkit/flash.c | 2 +- cpu/at32ap/cache.c | 2 +- include/asm-avr32/dma-mapping.h | 2 +- lib_avr32/board.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'board/atmel') diff --git a/board/atmel/atstk1000/flash.c b/board/atmel/atstk1000/flash.c index 4d380f3fa..0ba06ddc5 100644 --- a/board/atmel/atstk1000/flash.c +++ b/board/atmel/atstk1000/flash.c @@ -22,7 +22,7 @@ #include #ifdef CONFIG_ATSTK1000_EXT_FLASH -#include +#include #include #include diff --git a/board/earthlcd/favr-32-ezkit/flash.c b/board/earthlcd/favr-32-ezkit/flash.c index 5f73ff04d..0a2614667 100644 --- a/board/earthlcd/favr-32-ezkit/flash.c +++ b/board/earthlcd/favr-32-ezkit/flash.c @@ -20,7 +20,7 @@ #include #ifdef CONFIG_FAVR32_EZKIT_EXT_FLASH -#include +#include #include #include diff --git a/cpu/at32ap/cache.c b/cpu/at32ap/cache.c index 16a0565df..28b945669 100644 --- a/cpu/at32ap/cache.c +++ b/cpu/at32ap/cache.c @@ -22,7 +22,7 @@ #include -#include +#include void dcache_clean_range(volatile void *start, size_t size) { diff --git a/include/asm-avr32/dma-mapping.h b/include/asm-avr32/dma-mapping.h index 3b46fa3e6..0be7804da 100644 --- a/include/asm-avr32/dma-mapping.h +++ b/include/asm-avr32/dma-mapping.h @@ -23,7 +23,7 @@ #define __ASM_AVR32_DMA_MAPPING_H #include -#include +#include enum dma_data_direction { DMA_BIDIRECTIONAL = 0, diff --git a/lib_avr32/board.c b/lib_avr32/board.c index 959375a48..57115df09 100644 --- a/lib_avr32/board.c +++ b/lib_avr32/board.c @@ -86,7 +86,7 @@ void *sbrk(ptrdiff_t increment) } #ifdef CONFIG_SYS_DMA_ALLOC_LEN -#include +#include #include static unsigned long dma_alloc_start; -- cgit v1.2.3