Skip to contentSkip to conversation

Support for ATEVK1100 evaluation board

PATCH New Gunnar Rangoy 7 participants 40 messages Jan 23, 2009 – Feb 23, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover Support for ATEVK1100 evaluation board

This is a patch series which adds support for the ATEVK1100 evaluation board[1], and the AT32UC3A0xxx[2] microcontrollers used on that board. The patch series is based on avr32/next.

Some of these patches has already been submitted and most of the received feedback has been addressed. We would like to thank you for all the received feedback, and say thay we are sorry for the long delay.

This microcontroller is similar to the AT32AP700x, which is already supported by U-Boot, and this code is therefore based on that.

Patch 1 makes a change which works around a bug in the compiler. Patch 2-7 makes changes to other avr32-code in preparation for support of the new microcontroller.
Patch 8 adds support for the AT32UC3A0xxx microcontrollers.
Patch 9 adds support for the ATEVK1100 evaluation board.

The current revisions of the microcontroller have a bug in the SDRAM-controller, which makes it unreliable to run code from SDRAM. We therefore currently don't use SDRAM, but rather SRAM.

Changes since last time:
- Merged the two patch-series.
- Config option for searching for phy-address.
- Config option for limiting macb speed to 10 Mbps.
- Changed serial port speed to 115200.
- Some cleanups.

What works:
Loading U-Boot, serial console, loading image over dhcp/tftp, booting image.

[1] http://www.atmel.com/dyn/Products/tools_card.asp?tool_id=4114
[2] http://www.atmel.com/products/avr32/uc3/uc3_2.asp?family_id=682

#1 lore raw

PATCH v2 1/9 Fix IP alignement problem

From: Olav Morken <[email protected]>

This patch removes volatile from:
volatile IP_t *ip = (IP_t *)xip;

Due to a bug, avr32-gcc will assume that ip is aligned on a word boundary when using volatile, which causes an exception since xip isn't aligned on a word boundary.

---
 net/net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/net.c +1 -1
index 313d5d8..405ca6e 100644
@@ -1685,7 +1685,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
 void
 NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
 {
-	volatile IP_t *ip = (IP_t *)xip;
+	IP_t *ip = (IP_t *)xip;
 
 	/*
 	 *	If the data is an odd number of bytes, zero the
Signature · 1 line
1.6.0.4
#2 lore raw

PATCH v2 2/9 AVR32: Make cacheflush cpu-dependent

From: Olav Morken <[email protected]>

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.

---
 board/atmel/atstk1000/flash.c                      |    2 +-
 board/earthlcd/favr-32-ezkit/flash.c               |    2 +-
 cpu/at32ap/cache.c                                 |    2 +-
 .../asm-avr32/{ => arch-at32ap700x}/cacheflush.h   |    0
 include/asm-avr32/dma-mapping.h                    |    2 +-
 lib_avr32/board.c                                  |    2 +-
 6 files changed, 5 insertions(+), 5 deletions(-)
 rename include/asm-avr32/{ => arch-at32ap700x}/cacheflush.h (100%)
board/atmel/atstk1000/flash.c +1 -1
index e2bfd4a..1b45940 100644
@@ -22,7 +22,7 @@
 #include <common.h>
 
 #ifdef CONFIG_ATSTK1000_EXT_FLASH
-#include <asm/cacheflush.h>
+#include <asm/arch/cacheflush.h>
 #include <asm/io.h>
 #include <asm/sections.h>
 
board/earthlcd/favr-32-ezkit/flash.c +1 -1
index 2aa9415..fdf83ad 100644
@@ -20,7 +20,7 @@
 #include <common.h>
 
 #ifdef CONFIG_FAVR32_EZKIT_EXT_FLASH
-#include <asm/cacheflush.h>
+#include <asm/arch/cacheflush.h>
 #include <asm/io.h>
 #include <asm/sections.h>
 
cpu/at32ap/cache.c +1 -1
index 41fb5aa..3f1eea5 100644
@@ -22,7 +22,7 @@
 
 #include <common.h>
 
-#include <asm/cacheflush.h>
+#include <asm/arch/cacheflush.h>
 
 void dcache_clean_range(volatile void *start, size_t size)
 {
include/asm-avr32/arch-at32ap700x/cacheflush.h renamed from include/asm-avr32/cacheflush.h +0 -0
similarity index 100%
rename from include/asm-avr32/cacheflush.h
rename to include/asm-avr32/arch-at32ap700x/cacheflush.h
include/asm-avr32/dma-mapping.h +1 -1
index 3b46fa3..0be7804 100644
@@ -23,7 +23,7 @@
 #define __ASM_AVR32_DMA_MAPPING_H
 
 #include <asm/io.h>
-#include <asm/cacheflush.h>
+#include <asm/arch/cacheflush.h>
 
 enum dma_data_direction {
 	DMA_BIDIRECTIONAL	= 0,
lib_avr32/board.c +1 -1
index d5147b8..216ff74 100644
@@ -85,7 +85,7 @@ void *sbrk(ptrdiff_t increment)
 }
 
 #ifdef CFG_DMA_ALLOC_LEN
-#include <asm/cacheflush.h>
+#include <asm/arch/cacheflush.h>
 #include <asm/io.h>
 
 static unsigned long dma_alloc_start;
Signature · 1 line
1.6.0.4
#3 lore raw

PATCH v2 3/9 AVR32: Move addrspace.h to arch-directory, and move some functions from io.h to addrspace.h

From: Olav Morken <[email protected]>

The AVR32A architecture (which AT32UC3A-series is based on) has a different memory layout than the AVR32B-architecture. This patch moves addrspace.h to an arch-dependent directory in preparation for AT32UC3A-support. It also moves some address-space manipulation functions from io.h to addrspace.h.

---
 include/asm-avr32/addrspace.h                 |   46 --------------
 include/asm-avr32/arch-at32ap700x/addrspace.h |   84 +++++++++++++++++++++++++
 include/asm-avr32/io.h                        |   39 +-----------
 lib_avr32/bootm.c                             |    2 +-
 4 files changed, 87 insertions(+), 84 deletions(-)
 delete mode 100644 include/asm-avr32/addrspace.h
 create mode 100644 include/asm-avr32/arch-at32ap700x/addrspace.h
include/asm-avr32/addrspace.h deleted +0 -46
deleted file mode 100644
index b2ba1ee..0000000
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2006 Atmel Corporation
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-#ifndef __ASM_AVR32_ADDRSPACE_H
-#define __ASM_AVR32_ADDRSPACE_H
-
-/* Memory segments when segmentation is enabled */
-#define P0SEG		0x00000000
-#define P1SEG		0x80000000
-#define P2SEG		0xa0000000
-#define P3SEG		0xc0000000
-#define P4SEG		0xe0000000
-
-/* Returns the privileged segment base of a given address */
-#define PXSEG(a)	(((unsigned long)(a)) & 0xe0000000)
-
-/* Returns the physical address of a PnSEG (n=1,2) address */
-#define PHYSADDR(a)	(((unsigned long)(a)) & 0x1fffffff)
-
-/*
- * Map an address to a certain privileged segment
- */
-#define P1SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P1SEG))
-#define P2SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P2SEG))
-#define P3SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P3SEG))
-#define P4SEGADDR(a) ((__typeof__(a))(((unsigned long)(a) & 0x1fffffff) | P4SEG))
-
-#endif /* __ASM_AVR32_ADDRSPACE_H */
include/asm-avr32/arch-at32ap700x/addrspace.h new file +84 -0

84 lines not on this page · raw message

include/asm-avr32/io.h +2 -37
index 06e52b1..1cb17ea 100644
@@ -73,21 +73,8 @@ extern void __readwrite_bug(const char *fn);
 #define inw(p)	({ unsigned int __v = __le16_to_cpu(__raw_readw(p)); __v; })
 #define inl(p)	({ unsigned int __v = __le32_to_cpu(__raw_readl(p)); __v; })
 
-#include <asm/addrspace.h>
-
-/* virt_to_phys will only work when address is in P1 or P2 */
-static __inline__ unsigned long virt_to_phys(volatile void *address)
-{
-	return PHYSADDR(address);
-}
-
-static __inline__ void * phys_to_virt(unsigned long address)
-{
-	return (void *)P1SEGADDR(address);
-}
-
-#define cached(addr) ((void *)P1SEGADDR(addr))
-#define uncached(addr) ((void *)P2SEGADDR(addr))
+#include <asm/arch/addrspace.h>
+/* Provides virt_to_phys, phys_to_virt, cached, uncached, map_physmem */
 
 #endif /* __KERNEL__ */
 
@@ -96,28 +83,6 @@ static inline void sync(void)
 }
 
 /*
- * Given a physical address and a length, return a virtual address
- * that can be used to access the memory range with the caching
- * properties specified by "flags".
- *
- * This implementation works for memory below 512MiB (flash, etc.) as
- * well as above 3.5GiB (internal peripherals.)
- */
-#define MAP_NOCACHE	(0)
-#define MAP_WRCOMBINE	(1 << 7)
-#define MAP_WRBACK	(MAP_WRCOMBINE | (1 << 9))
-#define MAP_WRTHROUGH	(MAP_WRBACK | (1 << 0))
-
-static inline void *
-map_physmem(phys_addr_t paddr, unsigned long len, unsigned long flags)
-{
-	if (flags == MAP_WRBACK)
-		return (void *)P1SEGADDR(paddr);
-	else
-		return (void *)P2SEGADDR(paddr);
-}
-
-/*
  * Take down a mapping set up by map_physmem().
  */
 static inline void unmap_physmem(void *vaddr, unsigned long len)
lib_avr32/bootm.c +1 -1
index 35240e2..9f1a817 100644
@@ -24,7 +24,7 @@
 #include <image.h>
 #include <zlib.h>
 #include <asm/byteorder.h>
-#include <asm/addrspace.h>
+#include <asm/arch/addrspace.h>
 #include <asm/io.h>
 #include <asm/setup.h>
 #include <asm/arch/clk.h>
Signature · 1 line
1.6.0.4
#4 lore raw

PATCH v2 4/9 AVR32: Make GPIO implmentation cpu dependent

There are some differences in the implementation of GPIO in the at32uc chip compared to the ap700x series.

---
 include/asm-avr32/arch-at32ap700x/gpio-impl.h |   86 +++++++++++++++++++++++++
 include/asm-avr32/arch-common/portmux-gpio.h  |   83 +-----------------------
 2 files changed, 88 insertions(+), 81 deletions(-)
 create mode 100644 include/asm-avr32/arch-at32ap700x/gpio-impl.h
include/asm-avr32/arch-at32ap700x/gpio-impl.h new file +86 -0
new file mode 100644
index 0000000..8801bd0
@@ -0,0 +1,86 @@
+#ifndef __ASM_AVR32_ARCH_GPIO_IMPL_H__
+#define __ASM_AVR32_ARCH_GPIO_IMPL_H__
+
+/* Register offsets */
+struct gpio_regs {
+	u32	GPER;
+	u32	GPERS;
+	u32	GPERC;
+	u32	GPERT;
+	u32	PMR0;
+	u32	PMR0S;
+	u32	PMR0C;
+	u32	PMR0T;
+	u32	PMR1;
+	u32	PMR1S;
+	u32	PMR1C;
+	u32	PMR1T;
+	u32	__reserved0[4];
+	u32	ODER;
+	u32	ODERS;
+	u32	ODERC;
+	u32	ODERT;
+	u32	OVR;
+	u32	OVRS;
+	u32	OVRC;
+	u32	OVRT;
+	u32	PVR;
+	u32	__reserved_PVRS;
+	u32	__reserved_PVRC;
+	u32	__reserved_PVRT;
+	u32	PUER;
+	u32	PUERS;
+	u32	PUERC;
+	u32	PUERT;
+	u32	PDER;
+	u32	PDERS;
+	u32	PDERC;
+	u32	PDERT;
+	u32	IER;
+	u32	IERS;
+	u32	IERC;
+	u32	IERT;
+	u32	IMR0;
+	u32	IMR0S;
+	u32	IMR0C;
+	u32	IMR0T;
+	u32	IMR1;
+	u32	IMR1S;
+	u32	IMR1C;
+	u32	IMR1T;
+	u32	GFER;
+	u32	GFERS;
+	u32	GFERC;
+	u32	GFERT;
+	u32	IFR;
+	u32	__reserved_IFRS;
+	u32	IFRC;
+	u32	__reserved_IFRT;
+	u32	ODMER;
+	u32	ODMERS;
+	u32	ODMERC;
+	u32	ODMERT;
+	u32	__reserved1[4];
+	u32	ODCR0;
+	u32	ODCR0S;
+	u32	ODCR0C;
+	u32	ODCR0T;
+	u32	ODCR1;
+	u32	ODCR1S;
+	u32	ODCR1C;
+	u32	ODCR1T;
+	u32	__reserved2[4];
+	u32	OSRR0;
+	u32	OSRR0S;
+	u32	OSRR0C;
+	u32	OSRR0T;
+	u32	__reserved3[8];
+	u32	STER;
+	u32	STERS;
+	u32	STERC;
+	u32	STERT;
+	u32	__reserved4[35];
+	u32	VERSION;
+};
+
+#endif /* __ASM_AVR32_ARCH_GPIO_IMPL_H__ */
include/asm-avr32/arch-common/portmux-gpio.h +2 -81

89 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#5 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

From: Olav Morken <[email protected]>

For 100mbps operation, the ethernet controller requires a 25 MHz clock in MII mode, and a 50 MHz clock in RMII mode. If the clock is slower, disable 100 Mbps mode.

---
 drivers/net/macb.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
drivers/net/macb.c +11 -1
index 08bebf7..d47a052 100644
@@ -297,7 +297,17 @@ static void macb_phy_reset(struct macb_device *macb)
 	int i;
 	u16 status, adv;
 
-	adv = ADVERTISE_CSMA | ADVERTISE_ALL;
+	adv = ADVERTISE_CSMA | ADVERTISE_ALL ;
+
+#ifdef CONFIG_MACB_FORCE10M
+	printf("%s: 100Mbps is not supported on this board - forcing 10Mbps.\n",
+	       netdev->name);
+
+	adv &= ~ADVERTISE_100FULL;
+	adv &= ~ADVERTISE_100HALF;
+	adv &= ~ADVERTISE_100BASE4;
+#endif
+
 	macb_mdio_write(macb, MII_ADVERTISE, adv);
 	printf("%s: Starting autonegotiation...\n", netdev->name);
 	macb_mdio_write(macb, MII_BMCR, (BMCR_ANENABLE
Signature · 1 line
1.6.0.4
#6 lore raw

PATCH v2 6/9 AVR32: macb - Search for PHY id

This patch adds support for searching through available PHY-addresses in the macb-driver. This is needed for the ATEVK1100 evaluation board, where the PHY-address will be initialized to either 1 or 7.

This patch adds a config option, CONFIG_MACB_SEARCH_PHY, which when enabled tells the driver to search for the PHY address.

---
 drivers/net/macb.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
drivers/net/macb.c +31 -0
index d47a052..c8beb82 100644
@@ -327,6 +327,30 @@ static void macb_phy_reset(struct macb_device *macb)
 		       netdev->name, status);
 }
 
+#ifdef CONFIG_MACB_SEARCH_PHY
+static int macb_phy_find(struct macb_device *macb)
+{
+	int i;
+	u16 phy_id;
+
+	/* Search for PHY... */
+	for (i = 0; i < 32; i++) {
+		macb->phy_addr = i;
+		phy_id = macb_mdio_read(macb, MII_PHYSID1);
+		if (phy_id != 0xffff) {
+			printf("%s: PHY present at %d\n", macb->netdev.name, i);
+			return 1;
+		}
+	}
+
+	/* PHY isn't up to snuff */
+	printf("%s: PHY not found", macb->netdev.name);
+
+	return 0;
+}
+#endif /* CONFIG_MACB_SEARCH_PHY */
+
+
 static int macb_phy_init(struct macb_device *macb)
 {
 	struct eth_device *netdev = &macb->netdev;
@@ -335,6 +359,13 @@ static int macb_phy_init(struct macb_device *macb)
 	int media, speed, duplex;
 	int i;
 
+#ifdef CONFIG_MACB_SEARCH_PHY
+	/* Auto-detect phy_addr */
+	if (!macb_phy_find(macb)) {
+		return 0;
+	}
+#endif /* CONFIG_MACB_SEARCH_PHY */
+
 	/* Check if the PHY is up to snuff... */
 	phy_id = macb_mdio_read(macb, MII_PHYSID1);
 	if (phy_id == 0xffff) {
Signature · 1 line
1.6.0.4
#7 lore raw

PATCH v2 7/9 AVR32: Must add NOPs after disabling interrupts for AT32UC3A0512ES

From: Olav Morken <[email protected]>

The AT32UC3A0512ES chip has a bug when disabling interrupts. As a workaround, two NOPs can be inserted.

---
 lib_avr32/interrupts.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
lib_avr32/interrupts.c +7 -0
index 28df20d..bbbc490 100644
@@ -35,5 +35,12 @@ int disable_interrupts(void)
 	sr = sysreg_read(SR);
 	asm volatile("ssrf	%0" : : "n"(SYSREG_GM_OFFSET));
 
+#ifdef CONFIG_AT32UC3A0xxx
+	/* Two NOPs are required after masking interrupts on the
+	 * AT32UC3A0512ES. See errata 41.4.5.5. */
+	asm("nop");
+	asm("nop");
+#endif
+
 	return !SYSREG_BFEXT(GM, sr);
 }
Signature · 1 line
1.6.0.4
#8 lore raw

PATCH v2 8/9 AVR32: CPU support for AT32UC3A0xxx CPUs

This patch adds support for the AT32UC3A0xxx chips.

---
 cpu/at32uc/Makefile                                |   57 +++++
 cpu/at32uc/at32uc3a0xxx/Makefile                   |   43 ++++
 cpu/at32uc/at32uc3a0xxx/clk.c                      |   88 +++++++
 cpu/at32uc/at32uc3a0xxx/portmux.c                  |  154 ++++++++++++
 cpu/at32uc/at32uc3a0xxx/sm.h                       |  247 +++++++++++++++++++
 cpu/at32uc/cache.c                                 |   34 +++
 cpu/at32uc/config.mk                               |   22 ++
 cpu/at32uc/cpu.c                                   |   79 ++++++
 cpu/at32uc/exception.c                             |  121 ++++++++++
 cpu/at32uc/flashc.c                                |  144 +++++++++++
 cpu/at32uc/flashc.h                                |   84 +++++++
 cpu/at32uc/interrupts.c                            |  150 ++++++++++++
 cpu/at32uc/portmux-gpio.c                          |   78 ++++++
 cpu/at32uc/sdramc.c                                |  120 ++++++++++
 cpu/at32uc/sdramc.h                                |  137 +++++++++++
 cpu/at32uc/smc.c                                   |   61 +++++
 cpu/at32uc/smc.h                                   |  105 ++++++++
 cpu/at32uc/start.S                                 |  252 ++++++++++++++++++++
 include/asm-avr32/arch-at32uc3a0xxx/addrspace.h    |   63 +++++
 include/asm-avr32/arch-at32uc3a0xxx/cacheflush.h   |   41 ++++
 .../asm-avr32/arch-at32uc3a0xxx/chip-features.h    |   30 +++
 include/asm-avr32/arch-at32uc3a0xxx/clk.h          |   85 +++++++
 include/asm-avr32/arch-at32uc3a0xxx/gpio-impl.h    |   62 +++++
 include/asm-avr32/arch-at32uc3a0xxx/gpio.h         |   44 ++++
 include/asm-avr32/arch-at32uc3a0xxx/hmatrix.h      |   47 ++++
 include/asm-avr32/arch-at32uc3a0xxx/memory-map.h   |   75 ++++++
 include/asm-avr32/arch-at32uc3a0xxx/portmux.h      |   80 ++++++
 include/asm-avr32/sram.h                           |   34 +++
 28 files changed, 2537 insertions(+), 0 deletions(-)
 create mode 100644 cpu/at32uc/Makefile
 create mode 100644 cpu/at32uc/at32uc3a0xxx/Makefile
 create mode 100644 cpu/at32uc/at32uc3a0xxx/clk.c
 create mode 100644 cpu/at32uc/at32uc3a0xxx/portmux.c
 create mode 100644 cpu/at32uc/at32uc3a0xxx/sm.h
 create mode 100644 cpu/at32uc/cache.c
 create mode 100644 cpu/at32uc/config.mk
 create mode 100644 cpu/at32uc/cpu.c
 create mode 100644 cpu/at32uc/exception.c
 create mode 100644 cpu/at32uc/flashc.c
 create mode 100644 cpu/at32uc/flashc.h
 create mode 100644 cpu/at32uc/interrupts.c
 create mode 100644 cpu/at32uc/portmux-gpio.c
 create mode 100644 cpu/at32uc/sdramc.c
 create mode 100644 cpu/at32uc/sdramc.h
 create mode 100644 cpu/at32uc/smc.c
 create mode 100644 cpu/at32uc/smc.h
 create mode 100644 cpu/at32uc/start.S
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/addrspace.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/cacheflush.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/chip-features.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/clk.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/gpio-impl.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/gpio.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/hmatrix.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/memory-map.h
 create mode 100644 include/asm-avr32/arch-at32uc3a0xxx/portmux.h
 create mode 100644 include/asm-avr32/sram.h
cpu/at32uc/Makefile new file +57 -0
new file mode 100644
index 0000000..6714d14
@@ -0,0 +1,57 @@
+#
+# (C) Copyright 2000-2006
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# Copyright (C) 2005-2006 Atmel Corporation.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	:= $(obj)lib$(CPU).a
+
+START-y			+= start.o
+
+COBJS-y			+= cpu.o
+COBJS-y			+= sdramc.o
+COBJS-y			+= exception.o
+COBJS-y			+= cache.o
+COBJS-y			+= interrupts.o
+COBJS-$(CONFIG_PORTMUX_GPIO) += portmux-gpio.o
+COBJS-y			+= flashc.o
+COBJS-y			+= smc.o
+
+SRCS	:= $(START-y:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+START	:= $(addprefix $(obj),$(START-y))
+
+all: $(obj).depend $(START) $(LIB)
+
+$(LIB): $(OBJS)
+	$(AR) $(ARFLAGS) $@ $^
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
cpu/at32uc/at32uc3a0xxx/Makefile new file +43 -0

43 lines not on this page · raw message

cpu/at32uc/at32uc3a0xxx/clk.c new file +88 -0

88 lines not on this page · raw message

cpu/at32uc/at32uc3a0xxx/portmux.c new file +154 -0

154 lines not on this page · raw message

cpu/at32uc/at32uc3a0xxx/sm.h new file +247 -0

247 lines not on this page · raw message

cpu/at32uc/cache.c new file +34 -0
new file mode 100644
index 0000000..d624e6f
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2004-2006 Atmel Corporation
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+
+/*
+ * This is called after loading something into memory.  We need to
+ * make sure that everything that was loaded is actually written to
+ * RAM, and that the icache will look for it. Cleaning the dcache and
+ * invalidating the icache will do the trick.
+ */
+void  flush_cache(unsigned long start_addr, unsigned long size)
+{
+	/* No cache to clean in the at32uc3. */
+}
cpu/at32uc/config.mk new file +22 -0
new file mode 100644
index 0000000..1a6eaa8
@@ -0,0 +1,22 @@
+#
+# Copyright (C) 2005-2006 Atmel Corporation
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+PLATFORM_RELFLAGS       += -mcpu=uc3a0512es
cpu/at32uc/cpu.c new file +79 -0

79 lines not on this page · raw message

cpu/at32uc/exception.c new file +121 -0

121 lines not on this page · raw message

cpu/at32uc/flashc.c new file +144 -0

144 lines not on this page · raw message

cpu/at32uc/flashc.h new file +84 -0

84 lines not on this page · raw message

cpu/at32uc/interrupts.c new file +150 -0

150 lines not on this page · raw message

cpu/at32uc/portmux-gpio.c new file +78 -0

78 lines not on this page · raw message

cpu/at32uc/sdramc.c new file +120 -0

120 lines not on this page · raw message

cpu/at32uc/sdramc.h new file +137 -0

137 lines not on this page · raw message

cpu/at32uc/smc.c new file +61 -0

61 lines not on this page · raw message

cpu/at32uc/smc.h new file +105 -0

105 lines not on this page · raw message

cpu/at32uc/start.S new file +252 -0

252 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/addrspace.h new file +63 -0

63 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/cacheflush.h new file +41 -0

41 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/chip-features.h new file +30 -0
new file mode 100644
index 0000000..25ae8d7
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2007 Atmel Corporation
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef __ASM_AVR32_ARCH_CHIP_FEATURES_H__
+#define __ASM_AVR32_ARCH_CHIP_FEATURES_H__
+
+/* All the UC3A0xxx chips have these. */
+#define AT32UC3A0xxx_CHIP_HAS_USART
+#define AT32UC3A0xxx_CHIP_HAS_SPI
+#define AT32UC3A0xxx_CHIP_HAS_MACB
+
+#endif /* __ASM_AVR32_ARCH_CHIP_FEATURES_H__ */
include/asm-avr32/arch-at32uc3a0xxx/clk.h new file +85 -0

85 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/gpio-impl.h new file +62 -0

62 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/gpio.h new file +44 -0

44 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/hmatrix.h new file +47 -0

47 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/memory-map.h new file +75 -0

75 lines not on this page · raw message

include/asm-avr32/arch-at32uc3a0xxx/portmux.h new file +80 -0

80 lines not on this page · raw message

include/asm-avr32/sram.h new file +34 -0
new file mode 100644
index 0000000..3306d0b
@@ -0,0 +1,34 @@
+#ifndef __ASM_AVR32_SRAM_H
+#define __ASM_AVR32_SRAM_H
+#include <asm/types.h>
+
+struct sram_config {
+	/* Number of data bits. */
+	u8 data_bits;
+
+	/* Chip select */
+	u8 chip_select;
+
+	/* Number of address bits */
+	u8 address_bits;
+
+	/* nwe/nrd waveforms */
+	u8 nwe_setup, nwe_pulse, nwe_hold;
+	u8 nrd_setup, nrd_pulse, nrd_hold;
+
+	/* ncs waveforms */
+	u8 ncs_wr_setup, ncs_wr_pulse, ncs_wr_hold;
+	u8 ncs_rd_setup, ncs_rd_pulse, ncs_rd_hold;
+
+	/* Cycle length */
+	u16 nwe_cycle, nrd_cycle;
+
+	/* mode */
+	u8 read_mode, write_mode, exnw_mode;
+	u8 bat, dbw, tdf_cycles, tdf_mode, pmen, ps;
+};
+
+
+unsigned long sram_init(const struct sram_config *config);
+
+#endif /* __ASM_AVR32_SRAM_H */
Signature · 1 line
1.6.0.4
#9 lore raw

PATCH v2 9/9 AVR32: Board support for ATEVK1100

This patch adds support for the ATEVK1100 evaluation kit, which contains an AT32UC3A0512ES chip.

---
 MAINTAINERS                       |    1 +
 MAKEALL                           |    1 +
 Makefile                          |    3 +
 board/atmel/atevk1100/Makefile    |   44 ++++++++
 board/atmel/atevk1100/atevk1100.c |  122 ++++++++++++++++++++++
 board/atmel/atevk1100/config.mk   |    4 +
 board/atmel/atevk1100/u-boot.lds  |   73 +++++++++++++
 include/configs/atevk1100.h       |  207 +++++++++++++++++++++++++++++++++++++
 8 files changed, 455 insertions(+), 0 deletions(-)
 create mode 100644 board/atmel/atevk1100/Makefile
 create mode 100644 board/atmel/atevk1100/atevk1100.c
 create mode 100644 board/atmel/atevk1100/config.mk
 create mode 100644 board/atmel/atevk1100/u-boot.lds
 create mode 100644 include/configs/atevk1100.h
MAINTAINERS +1 -0
index 9c0d6bf..d83b580 100644
@@ -747,6 +747,7 @@ Haavard Skinnemoen <[email protected]>
 	ATSTK1004	AT32AP7002
 	ATSTK1006	AT32AP7000
 	ATNGW100	AT32AP7000
+	ATEVK1100	AT32UC3A0512
 
 #########################################################################
 # SuperH Systems:							#
MAKEALL +1 -0
index 9ccb9ac..cd33214 100755
@@ -720,6 +720,7 @@ LIST_coldfire="			\
 #########################################################################
 
 LIST_avr32="		\
+	atevk1100	\
 	atstk1002	\
 	atstk1003	\
 	atstk1004	\
Makefile +3 -0
index 58b8331..d9fbc6e 100644
@@ -3047,6 +3047,9 @@ $(BFIN_BOARDS):
 # AVR32
 #========================================================================
 
+atevk1100_config	:	unconfig
+	@$(MKCONFIG) $(@:_config=) avr32 at32uc atevk1100 atmel at32uc3a0xxx
+
 atngw100_config	:	unconfig
 	@$(MKCONFIG) $(@:_config=) avr32 at32ap atngw100 atmel at32ap700x
 
board/atmel/atevk1100/Makefile new file +44 -0

44 lines not on this page · raw message

board/atmel/atevk1100/atevk1100.c new file +122 -0

122 lines not on this page · raw message

board/atmel/atevk1100/config.mk new file +4 -0
new file mode 100644
index 0000000..ca23f88
@@ -0,0 +1,4 @@
+PLATFORM_RELFLAGS	+= -ffunction-sections -fdata-sections
+PLATFORM_LDFLAGS	+= --gc-sections
+TEXT_BASE		= 0x80000000
+LDSCRIPT		= $(obj)board/atmel/atevk1100/u-boot.lds
board/atmel/atevk1100/u-boot.lds new file +73 -0

73 lines not on this page · raw message

include/configs/atevk1100.h new file +207 -0

207 lines not on this page · raw message

Signature · 1 line
1.6.0.4
#10 lore raw

PATCH v2 9/9 AVR32: Board support for ATEVK1100

Dear Gunnar Rangoy,

Quoted 2 lines · In message <7d98d3ebed68dfca910943a360d0b8aaa28d9c17.1232710611.git.gunnar@rang…

This patch adds support for the ATEVK1100 evaluation kit, which contains an AT32UC3A0512ES chip.

...

...

Quoted 2 lines
board/atmel/atevk1100/atevk1100.c new file +0 -0

...

board/atmel/atevk1100/atevk1100.c line 52

Quoted 8 lines
board/atmel/atevk1100/atevk1100.c new file +8 -0
+	/*
+	.ncs_wr_pulse 	= 1,
+	.ncs_rd_pulse	= 1,
+	.nwe_pulse	= 1,
+	.nrd_pulse	= 1,
+	.nwe_cycle	= 2,
+	.nrd_cycle	= 2,
+	*/

All this is dead code. Please remove.

...

board/atmel/atevk1100/atevk1100.c

Quoted 9 lines
board/atmel/atevk1100/atevk1100.c new file +9 -0
+/*
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_ASKENV
+#define CONFIG_CMD_DHCP
+
+#undef CONFIG_CMD_AUTOSCRIPT

Is there a specific reason for not allowing to use shell scripts?

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I'm a programmer: I don't buy software, I write it.
                                                  -- Tom Christiansen
#11 lore raw

PATCH v2 9/9 AVR32: Board support for ATEVK1100

Quoted 20 lines · Wolfgang Denk

Dear Gunnar Rangoy,

Quoted 2 lines · In message <7d98d3ebed68dfca910943a360d0b8aaa28d9c17.1232710611.git.gunnar@rang…

This patch adds support for the ATEVK1100 evaluation kit, which contains an AT32UC3A0512ES chip.

...

...

Quoted 2 lines
board/atmel/atevk1100/atevk1100.c new file +0 -0

...

board/atmel/atevk1100/atevk1100.c line 52

Quoted 8 lines
board/atmel/atevk1100/atevk1100.c new file +8 -0
+     /*
+     .ncs_wr_pulse   = 1,
+     .ncs_rd_pulse   = 1,
+     .nwe_pulse      = 1,
+     .nrd_pulse      = 1,
+     .nwe_cycle      = 2,
+     .nrd_cycle      = 2,
+     */
Quoted 1 line

All this is dead code. Please remove.

Will do that.

Quoted 16 lines

...

board/atmel/atevk1100/atevk1100.c

Quoted 9 lines
board/atmel/atevk1100/atevk1100.c new file +9 -0
+/*
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+
+#define CONFIG_CMD_ASKENV
+#define CONFIG_CMD_DHCP
+
+#undef CONFIG_CMD_AUTOSCRIPT

Is there a specific reason for not allowing to use shell scripts?

Best regards,

Quoted 9 lines

Wolfgang Denk

--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de I'm a programmer: I don't buy software, I write it.
-- Tom Christiansen

No, not really. We did this because this was done in other AVR32 boards we used as references.

Signature · 2 lines
Gunnar Rang?y,
99360699
#12 lore raw

PATCH v2 9/9 AVR32: Board support for ATEVK1100

Dear ?ISO-8859-1?Q?Gunnar_Rang?y?,

In message <[email protected]> you wrote:
...

Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+#undef CONFIG_CMD_AUTOSCRIPT

Is there a specific reason for not allowing to use shell scripts?

...

Quoted 2 lines

No, not really. We did this because this was done in other AVR32 boards we used as references.

Then pleasse don't - let's overcome the bad examples.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Never put off until tomorrow what you can put off indefinitely.
#13 lore raw

PATCH v2 9/9 AVR32: Board support for ATEVK1100

Quoted 4 lines · Wolfgang Denk

Dear ?ISO-8859-1?Q?Gunnar_Rang?y?,

In message <[email protected]> you wrote:
...

Quoted 9 lines
Quoted 3 lines
Quoted 3 lines
Quoted 1 line

+#undef CONFIG_CMD_AUTOSCRIPT

Is there a specific reason for not allowing to use shell scripts?

...

Quoted 2 lines

No, not really. We did this because this was done in other AVR32 boards we used as references.

Then pleasse don't - let's overcome the bad examples.

OK, this is fixed.

Regards Gunnar

#14 lore raw

PATCH v2 8/9 AVR32: CPU support for AT32UC3A0xxx CPUs

In reply to Gunnar Rangoy

Dear Gunnar Rangoy,

Quoted 1 line · In message <b47b53bb44d0d937f9a40249c1cd668640aec400.1232710611.git.gunnar@rang…

This patch adds support for the AT32UC3A0xxx chips.

...

Quoted 2 lines

+++ b/cpu/at32uc/at32uc3a0xxx/portmux.c

(quoted diff) +0 -0
@@ -0,0 +1,154 @@

...

cpu/at32uc/at32uc3a0xxx/portmux.c line 62

Quoted 13 lines
cpu/at32uc/at32uc3a0xxx/portmux.c new file +13 -0
+	portmux_select_peripheral(PORTMUX_PORT(0),
+						0x0003C000 |
+						0x1E000000, PORTMUX_FUNC_C, 0);
+	portmux_select_peripheral(PORTMUX_PORT(1),
+						0x00000010 |
+						0x00007C00 |
+						0x00030000 |
+						0xE0000000, PORTMUX_FUNC_C, 0);
+	portmux_select_peripheral(PORTMUX_PORT(2),
+						0xFFFFFFC0, PORTMUX_FUNC_A, 0);
+	portmux_select_peripheral(PORTMUX_PORT(3),
+						0x00003FFF, PORTMUX_FUNC_A, 0);
+}

It would be nice if you used readable names instead of all these magic hardcoded constants.

Quoted 10 lines

+++ b/cpu/at32uc/at32uc3a0xxx/sm.h

cpu/at32uc/at32uc3a0xxx/sm.h new file +8 -0
@@ -0,0 +1,247 @@
+/*
+ * Register definitions for System Manager
+ */
+#ifndef __CPU_AT32UC_SM_H__
+#define __CPU_AT32UC_SM_H__
+
+/* SM register offsets */
+/* PM starts at 0xFFFF0C00 */

cpu/at32uc/at32uc3a0xxx/sm.h line 18

Quoted 10 lines
cpu/at32uc/at32uc3a0xxx/sm.h new file +10 -0
+#define SM_PM_REGS_OFFSET			0x0c00
+#define SM_PM_MCCTRL				(SM_PM_REGS_OFFSET + 0x0000)
+#define SM_PM_CKSEL				(SM_PM_REGS_OFFSET + 0x0004)
+#define SM_PM_CPU_MASK				(SM_PM_REGS_OFFSET + 0x0008)
+#define SM_PM_HSB_MASK				(SM_PM_REGS_OFFSET + 0x000c)
+#define SM_PM_PBA_MASK				(SM_PM_REGS_OFFSET + 0x0010)
+#define SM_PM_PBB_MASK				(SM_PM_REGS_OFFSET + 0x0014)
+#define SM_PM_PLL0				(SM_PM_REGS_OFFSET + 0x0020)
+#define SM_PM_PLL1				(SM_PM_REGS_OFFSET + 0x0024)
+#define SM_PM_OSCCTRL0				(SM_PM_REGS_OFFSET + 0x0028)

...

Instead of using offsets everywhere I would appreciate if the code could be changed to use C structs instead (like we do in PPC land).

cpu/at32uc/cpu.c line 79

Quoted 11 lines
cpu/at32uc/cpu.c new file +11 -0
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+	/* This will reset the CPU core, caches, MMU and all internal busses */
+	__builtin_mtdr(8, 1 << 13);	/* set DC:DBE */
+	__builtin_mtdr(8, 1 << 30);	/* set DC:RES */
+
+	/* Flush the pipeline before we declare it a failure */
+	asm volatile("sub   pc, pc, -4");
+
+	return -1;
+}

I read this as if you just reset the CPU "internal" stuff. Sorry for asking stupid questions, I don't know this architecture at all, but:
Will external chips be reset this way, too? Or how do you make sure that external peripherals get properly reset?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
365 Days of drinking Lo-Cal beer.                       = 1 Lite-year
#15 lore raw

PATCH v2 8/9 AVR32: CPU support for AT32UC3A0xxx CPUs

Quoted 22 lines · Wolfgang Denk

Dear Gunnar Rangoy,

Quoted 1 line · In message <b47b53bb44d0d937f9a40249c1cd668640aec400.1232710611.git.gunnar@rang…

This patch adds support for the AT32UC3A0xxx chips.

...

Quoted 2 lines

+++ b/cpu/at32uc/at32uc3a0xxx/portmux.c

(quoted diff) +0 -0
@@ -0,0 +1,154 @@

...

cpu/at32uc/at32uc3a0xxx/portmux.c line 62

Quoted 13 lines
cpu/at32uc/at32uc3a0xxx/portmux.c new file +13 -0
+     portmux_select_peripheral(PORTMUX_PORT(0),
+                                             0x0003C000 |
+                                             0x1E000000, PORTMUX_FUNC_C, 0);
+     portmux_select_peripheral(PORTMUX_PORT(1),
+                                             0x00000010 |
+                                             0x00007C00 |
+                                             0x00030000 |
+                                             0xE0000000, PORTMUX_FUNC_C, 0);
+     portmux_select_peripheral(PORTMUX_PORT(2),
+                                             0xFFFFFFC0, PORTMUX_FUNC_A, 0);
+     portmux_select_peripheral(PORTMUX_PORT(3),
+                                             0x00003FFF, PORTMUX_FUNC_A, 0);
+}
Quoted 2 lines

It would be nice if you used readable names instead of all these magic hardcoded constants.

Each bit in the masks represents a single pin on the microcontroller. The readable names would therefore become something like:
#define EBI_PINS_PORT0 (0x0003C000 | 0x1E000000)
#define EBI_PINS_PORT1 (0x00000010 | 0x00007C00 | ...)
I'm not certain that that would make it much more readable. The bitmasks are more or less based on reading the datasheet and counting which pins are used.

Maybe adding a comment before the code would be just as useful?

Quoted 22 lines
Quoted 20 lines

+++ b/cpu/at32uc/at32uc3a0xxx/sm.h

cpu/at32uc/at32uc3a0xxx/sm.h new file +18 -0
@@ -0,0 +1,247 @@
+/*
+ * Register definitions for System Manager
+ */
+#ifndef __CPU_AT32UC_SM_H__
+#define __CPU_AT32UC_SM_H__
+
+/* SM register offsets */
+/* PM starts at 0xFFFF0C00 */
+#define SM_PM_REGS_OFFSET                    0x0c00
+#define SM_PM_MCCTRL                         (SM_PM_REGS_OFFSET + 0x0000)
+#define SM_PM_CKSEL                          (SM_PM_REGS_OFFSET + 0x0004)
+#define SM_PM_CPU_MASK                               (SM_PM_REGS_OFFSET + 0x0008)
+#define SM_PM_HSB_MASK                               (SM_PM_REGS_OFFSET + 0x000c)
+#define SM_PM_PBA_MASK                               (SM_PM_REGS_OFFSET + 0x0010)
+#define SM_PM_PBB_MASK                               (SM_PM_REGS_OFFSET + 0x0014)
+#define SM_PM_PLL0                           (SM_PM_REGS_OFFSET + 0x0020)
+#define SM_PM_PLL1                           (SM_PM_REGS_OFFSET + 0x0024)
+#define SM_PM_OSCCTRL0                               (SM_PM_REGS_OFFSET + 0x0028)

...

Quoted 2 lines

Instead of using offsets everywhere I would appreciate if the code could be changed to use C structs instead (like we do in PPC land).

It was done like this because it was done in the existing AVR32 code which we based our work on. Since we used parts of that code, it made most sense to use the same coding style.

We can change it if you think it is necessary.

Quoted 17 lines

cpu/at32uc/cpu.c line 79

Quoted 12 lines
cpu/at32uc/cpu.c new file +11 -0
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+     /* This will reset the CPU core, caches, MMU and all internal busses */
+     __builtin_mtdr(8, 1 << 13);     /* set DC:DBE */
+     __builtin_mtdr(8, 1 << 30);     /* set DC:RES */
+
+     /* Flush the pipeline before we declare it a failure */
+     asm volatile("sub   pc, pc, -4");
+
+     return -1;
+}

I read this as if you just reset the CPU "internal" stuff. Sorry for asking stupid questions, I don't know this architecture at all, but:
Will external chips be reset this way, too? Or how do you make sure that external peripherals get properly reset?

As most of the needed functionality is embedded in the microcontroller, there are very few external peripherals used by U-Boot. Apart from external memory, and oscillator, and level-shifters for the serial-port, there is only the ethernet PHY, and that one shouldn't need a reset.

Gunnar Rang?y,
99360699

#16 lore raw

PATCH v2 8/9 AVR32: CPU support for AT32UC3A0xxx CPUs

Dear =?ISO-8859-1?Q?Gunnar_Rang=F8y?=,

Quoted 19 lines · In message <[email protected]> you…
Quoted 4 lines

cpu/at32uc/at32uc3a0xxx/portmux.c

Quoted 4 lines
cpu/at32uc/at32uc3a0xxx/portmux.c new file +3 -0
+     portmux_select_peripheral(PORTMUX_PORT(0),
+                                             0x0003C000 |
+                                             0x1E000000, PORTMUX_FUNC_C=

, 0);

Quoted 5 lines

cpu/at32uc/at32uc3a0xxx/portmux.c

Quoted 5 lines
cpu/at32uc/at32uc3a0xxx/portmux.c new file +5 -0
+     portmux_select_peripheral(PORTMUX_PORT(1),
+                                             0x00000010 |
+                                             0x00007C00 |
+                                             0x00030000 |
+                                             0xE0000000, PORTMUX_FUNC_C=

, 0);

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     portmux_select_peripheral(PORTMUX_PORT(2),
+                                             0xFFFFFFC0, PORTMUX_FUNC_A=

, 0);

Quoted 2 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+     portmux_select_peripheral(PORTMUX_PORT(3),
+                                             0x00003FFF, PORTMUX_FUNC_A=

, 0);

Quoted 2 lines
Quoted 1 line

+}

Quoted 7 lines
Quoted 2 lines

It would be nice if you used readable names instead of all these magic hardcoded constants.

Each bit in the masks represents a single pin on the microcontroller. The readable names would therefore become something like:
#define EBI_PINS_PORT0 (0x0003C000 | 0x1E000000)
#define EBI_PINS_PORT1 (0x00000010 | 0x00007C00 | ...)

Um, no. You didn't get it. You use magic numbers again.

That should be some

#define FOO_PIN_XXX 0x0003C000
#define FOO_PIN_YYY 0x1E000000
#define BAR_PIN_XXX 0x00000010
#DEFINE BAR_PIN_YYY 0x00007C00

in one place and

#define EBI_PINS_PORT0 (FOO_PIN_XXX | FOO_PIN_YYY) #define EBI_PINS_PORT1 ((BAR_PIN_XXX| BAR_PIN_YYY)

elsewhere, using readable names for the defines.

Quoted 3 lines

I'm not certain that that would make it much more readable. The bitmasks are more or less based on reading the datasheet and counting which pins are used.

This is exactly what should NOT be necessary to read and understand the code.

If I see a line like

	rtx->txbd[txIdx].cbd_sc |= (BD_ENET_TX_READY | BD_ENET_TX_LAST |BD_ENET_TX_WRAP);

somewhere in a driver (obviously dealing with ethernet), I don;t have to look up any specific bits or ping numbers - I can just read it.

If somebody else writes the (computationally equivalent) code

	rtx->txbd[txIdx].cbd_sc |= 0xA800;
or even
	rtx->txbd[txIdx].cbd_sc |= (0x8000 | 0x0800 | 0x2000);

then I don;t have a clue what's going on, and it takes me precious time to look this up - me and everybody else, each and every time again when I'm reading the code.

This is simply not acceptable.

Quoted 1 line

Maybe adding a comment before the code would be just as useful?

No, a comment can't fix this, especially as you just have to wait a few months to see the comment and the code getting out of sync.

Please fix the code.

Quoted 8 lines
Quoted 2 lines

Instead of using offsets everywhere I would appreciate if the code could be changed to use C structs instead (like we do in PPC land).

It was done like this because it was done in the existing AVR32 code which we based our work on. Since we used parts of that code, it made most sense to use the same coding style.

We can change it if you think it is necessary.

Yes, please change it. And patches to fix the existing code that doe sthis are welcome, too.

Quoted 18 lines
Quoted 3 lines

cpu/at32uc/cpu.c

Quoted 3 lines
cpu/at32uc/cpu.c new file +3 -0
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+     /* This will reset the CPU core, caches, MMU and all internal buss=

es */

Quoted 5 lines
Quoted 5 lines
cpu/at32uc/cpu.c new file +5 -0
+     __builtin_mtdr(8, 1 << 13);     /* set DC:DBE */
+     __builtin_mtdr(8, 1 << 30);     /* set DC:RES */
+
+     /* Flush the pipeline before we declare it a failure */
+     asm volatile("sub   pc, pc, -4");
Quoted 8 lines

cpu/at32uc/cpu.c line 79

Quoted 3 lines
cpu/at32uc/cpu.c new file +3 -0
+
+     return -1;
+}

I read this as if you just reset the CPU "internal" stuff. Sorry for asking stupid questions, I don't know this architecture at all, but:
Will external chips be reset this way, too? Or how do you make sure that external peripherals get properly reset?

Quoted 4 lines

As most of the needed functionality is embedded in the microcontroller, there are very few external peripherals used by U-Boot. Apart from external memory, and oscillator, and level-shifters for the serial-port, there is only the ethernet PHY, and that one shouldn't need a reset.

Famous last words. What if exactrly the PHY is stuck and needs a reset?

Hmmm... "apart from external memory" ... does externam memory also include NOR flash? Eventually the NOR flash you are booting from? Assume the NOR flash is in query mode when you reset the board - how does it get reset, then?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
It is impractical for  the  standard  to  attempt  to  constrain  the
behavior  of code that does not obey the constraints of the standard.
                                                          - Doug Gwyn
#17 lore raw

PATCH v2 8/9 AVR32: CPU support for AT32UC3A0xxx CPUs

Quoted 3 lines · Wolfgang Denk

Dear =?ISO-8859-1?Q?Gunnar_Rang=F8y?=,

In message <[email protected]> you wrote:

[....]

Quoted 18 lines
Quoted 8 lines
Quoted 3 lines

It would be nice if you used readable names instead of all these magic hardcoded constants.

Each bit in the masks represents a single pin on the microcontroller. The readable names would therefore become something like:
#define EBI_PINS_PORT0 (0x0003C000 | 0x1E000000)
#define EBI_PINS_PORT1 (0x00000010 | 0x00007C00 | ...)

Um, no. You didn't get it. You use magic numbers again.

That should be some

#define FOO_PIN_XXX     0x0003C000
#define FOO_PIN_YYY     0x1E000000
#define BAR_PIN_XXX     0x00000010
#DEFINE BAR_PIN_YYY     0x00007C00
Quoted 6 lines

in one place and

#define EBI_PINS_PORT0 (FOO_PIN_XXX | FOO_PIN_YYY) #define EBI_PINS_PORT1 ((BAR_PIN_XXX| BAR_PIN_YYY)

elsewhere, using readable names for the defines.

Sorry, but the bitwise or's in the code are a bit misleading. The only function of them is to make it more readable in the presence of the datasheet for the microcontroller. Each single bit in the bitmask is one pin on the microcontroller. In this case, it would become something like:

#define EBI_PIN_NCS0    (1<<14)
#define EBI_PIN_ADDR20  (1<<15)
#define EBI_PIN_ADDR21  (1<<16)
#define EBI_PIN_ADDR22  (1<<17)
(....)
#define EBI_PINS_PORT0 (EBI_PIN_NCS0 | EBI_PIN_ADDR20 | EBI_PIN_ADDR21 \
                        | EBI_PIN_ADDR22 | (....))
Quoted 6 lines
Quoted 3 lines

I'm not certain that that would make it much more readable. The bitmasks are more or less based on reading the datasheet and counting which pins are used.

This is exactly what should NOT be necessary to read and understand the code.

[....]

But in this case, this is code which should never be changed without looking at the datasheet, and probably schematics for the board in question.

Quoted 8 lines

This is simply not acceptable.

Quoted 1 line

Maybe adding a comment before the code would be just as useful?

No, a comment can't fix this, especially as you just have to wait a few months to see the comment and the code getting out of sync.

Please fix the code.

How about something like this:
/*
* These bitmasks represents the pins used by the EBI on this board.
* Please refer to the datasheet for the UC3A-series microcontrollers
* for a description of the individual pins.
*/
#define EBI_PINS_PORT0 0x1E03C000
#define EBI_PINS_PORT1 0xE0037C10
(....)

And in the portmux-configuration-function:
portmux_select_peripheral(PORTMUX_PORT(0), EBI_PINS_PORT0,

			  PORTMUX_FUNC_C, 0);

(....)

When looking at this code I can see that we need a way for each individual board to change the bitmasks, since the same pin in some cases can be routed out to several places (depending on the board). Maybe a CONFIG_UC3A0xxx_EBI_PINS_PORT0 option or something like that could be added...

Quoted 11 lines
Quoted 8 lines
Quoted 2 lines

Instead of using offsets everywhere I would appreciate if the code could be changed to use C structs instead (like we do in PPC land).

It was done like this because it was done in the existing AVR32 code which we based our work on. Since we used parts of that code, it made most sense to use the same coding style.

We can change it if you think it is necessary.

Yes, please change it. And patches to fix the existing code that doe sthis are welcome, too.

OK, will do this. I do however think that we will leave the code for other chips and boards as it is, since changing it would require very much time, and we don't have any way to test the changes in any case.

Do you have any specific files we could use as a style-guide for such structs?

Quoted 7 lines
Quoted 4 lines

As most of the needed functionality is embedded in the microcontroller, there are very few external peripherals used by U-Boot. Apart from external memory, and oscillator, and level-shifters for the serial-port, there is only the ethernet PHY, and that one shouldn't need a reset.

Famous last words. What if exactrly the PHY is stuck and needs a reset?

The only reset we can do on the PHY is a software reset, by sending a reset command over the (R)MII bus, and I don't believe that the generic chip code is the place to do that. If it should be done, I believe it should be done by the macb-driver after the reset. This would allow it to recover even if the microcontroller wasn't reset by the reset-command, but for example by a watchdog timer.

Quoted 4 lines

Hmmm... "apart from external memory" ... does externam memory also include NOR flash? Eventually the NOR flash you are booting from? Assume the NOR flash is in query mode when you reset the board - how does it get reset, then?

External memory in this case would be SRAM or SDRAM.

Best regards,
Olav Morken

#18 lore raw

PATCH v2 8/9 AVR32: CPU support for AT32UC3A0xxx CPUs

Quoted 35 lines · Olav Morken
Quoted 3 lines · Wolfgang Denk

Dear =?ISO-8859-1?Q?Gunnar_Rang=F8y?=,

In message <[email protected]> you wrote:

[....]

Quoted 18 lines
Quoted 8 lines
Quoted 3 lines

It would be nice if you used readable names instead of all these magic hardcoded constants.

Each bit in the masks represents a single pin on the microcontroller. The readable names would therefore become something like:
#define EBI_PINS_PORT0 (0x0003C000 | 0x1E000000)
#define EBI_PINS_PORT1 (0x00000010 | 0x00007C00 | ...)

Um, no. You didn't get it. You use magic numbers again.

That should be some

#define FOO_PIN_XXX     0x0003C000
#define FOO_PIN_YYY     0x1E000000
#define BAR_PIN_XXX     0x00000010
#DEFINE BAR_PIN_YYY     0x00007C00
Quoted 6 lines

in one place and

#define EBI_PINS_PORT0 (FOO_PIN_XXX | FOO_PIN_YYY) #define EBI_PINS_PORT1 ((BAR_PIN_XXX| BAR_PIN_YYY)

elsewhere, using readable names for the defines.

Sorry, but the bitwise or's in the code are a bit misleading. The only function of them is to make it more readable in the presence of the datasheet for the microcontroller. Each single bit in the bitmask is one pin on the microcontroller. In this case, it would become something like:

Quoted 7 lines
#define EBI_PIN_NCS0    (1<<14)
#define EBI_PIN_ADDR20  (1<<15)
#define EBI_PIN_ADDR21  (1<<16)
#define EBI_PIN_ADDR22  (1<<17)
(....)
#define EBI_PINS_PORT0 (EBI_PIN_NCS0 | EBI_PIN_ADDR20 | EBI_PIN_ADDR21 \
                        | EBI_PIN_ADDR22 | (....))

I don't think that would be much of an improvement. It would make the code much larger, and the pin definitions themselves would still need some magic number...and you'll need to know which GPIO port they belong to in order to actually use them.

Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

I'm not certain that that would make it much more readable. The bitmasks are more or less based on reading the datasheet and counting which pins are used.

Quoted 8 lines
Quoted 2 lines

This is exactly what should NOT be necessary to read and understand the code.

[....]

But in this case, this is code which should never be changed without looking at the datasheet, and probably schematics for the board in question.

Exactly. At some point, you need code which encapsulates the definitions in the data sheet, and that's the whole purpose of these functions.

Quoted 21 lines
Quoted 8 lines

This is simply not acceptable.

Quoted 1 line

Maybe adding a comment before the code would be just as useful?

No, a comment can't fix this, especially as you just have to wait a few months to see the comment and the code getting out of sync.

Please fix the code.

How about something like this:
/*
* These bitmasks represents the pins used by the EBI on this board.
* Please refer to the datasheet for the UC3A-series microcontrollers
* for a description of the individual pins.
*/
#define EBI_PINS_PORT0 0x1E03C000
#define EBI_PINS_PORT1 0xE0037C10
(....)

And in the portmux-configuration-function:
portmux_select_peripheral(PORTMUX_PORT(0), EBI_PINS_PORT0,

Quoted 8 lines
			  PORTMUX_FUNC_C, 0);

(....)

When looking at this code I can see that we need a way for each individual board to change the bitmasks, since the same pin in some cases can be routed out to several places (depending on the board). Maybe a CONFIG_UC3A0xxx_EBI_PINS_PORT0 option or something like that could be added...

I think you need to actually use the parameters passed to that function in order to set up the correct address, data and chip select lines.

Now, the alternative mappings for some of the pins are tricky...but you could perhaps add a few more flags to cover those possibilities...

Once you do that, the whole function becomes a matter of shifting bits into position, and I very much doubt a bunch of defines can make that sort of code any clearer.

Think of this function as the executable equivalent of a pin definition.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

As most of the needed functionality is embedded in the microcontroller, there are very few external peripherals used by U-Boot. Apart from external memory, and oscillator, and level-shifters for the serial-port, there is only the ethernet PHY, and that one shouldn't need a reset.

Famous last words. What if exactrly the PHY is stuck and needs a reset?

Quoted 6 lines

The only reset we can do on the PHY is a software reset, by sending a reset command over the (R)MII bus, and I don't believe that the generic chip code is the place to do that. If it should be done, I believe it should be done by the macb-driver after the reset. This would allow it to recover even if the microcontroller wasn't reset by the reset-command, but for example by a watchdog timer.

I suppose this might be a good idea. But I haven't heard of any problems with other boards because of this...and wasn't there a generic PHY layer in the works anyway?

Quoted 6 lines
Quoted 4 lines

Hmmm... "apart from external memory" ... does externam memory also include NOR flash? Eventually the NOR flash you are booting from? Assume the NOR flash is in query mode when you reset the board - how does it get reset, then?

External memory in this case would be SRAM or SDRAM.

On other chips, it also covers the NOR flash you're booting from. So I suppose we should look into this...maybe we need some sort of "notifier chain" thing to give other drivers a chance to reset their peripherals...

Haavard

#19 lore raw

PATCH v2 7/9 AVR32: Must add NOPs after disabling interrupts for AT32UC3A0512ES

In reply to Gunnar Rangoy
Quoted 8 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

The AT32UC3A0512ES chip has a bug when disabling interrupts. As a workaround, two NOPs can be inserted.

Applied to evk1100-prep, thanks.

Haavard

#20 lore raw

PATCH v2 6/9 AVR32: macb - Search for PHY id

In reply to Gunnar Rangoy
Quoted 54 lines · Gunnar Rangoy

This patch adds support for searching through available PHY-addresses in the macb-driver. This is needed for the ATEVK1100 evaluation board, where the PHY-address will be initialized to either 1 or 7.

This patch adds a config option, CONFIG_MACB_SEARCH_PHY, which when enabled tells the driver to search for the PHY address.

---
 drivers/net/macb.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
drivers/net/macb.c +24 -0
index d47a052..c8beb82 100644
@@ -327,6 +327,30 @@ static void macb_phy_reset(struct macb_device *macb)
 		       netdev->name, status);
 }
 
+#ifdef CONFIG_MACB_SEARCH_PHY
+static int macb_phy_find(struct macb_device *macb)
+{
+	int i;
+	u16 phy_id;
+
+	/* Search for PHY... */
+	for (i = 0; i < 32; i++) {
+		macb->phy_addr = i;
+		phy_id = macb_mdio_read(macb, MII_PHYSID1);
+		if (phy_id != 0xffff) {
+			printf("%s: PHY present at %d\n", macb->netdev.name, i);
+			return 1;
+		}
+	}
+
+	/* PHY isn't up to snuff */
+	printf("%s: PHY not found", macb->netdev.name);
+
+	return 0;
+}
+#endif /* CONFIG_MACB_SEARCH_PHY */
+
+
 static int macb_phy_init(struct macb_device *macb)
 {
 	struct eth_device *netdev = &macb->netdev;
@@ -335,6 +359,13 @@ static int macb_phy_init(struct macb_device *macb)
 	int media, speed, duplex;
 	int i;
 

drivers/net/macb.c static int macb_phy_init(struct macb_device *macb) · line 371

Quoted 10 lines
drivers/net/macb.c +7 -0
+#ifdef CONFIG_MACB_SEARCH_PHY
+	/* Auto-detect phy_addr */
+	if (!macb_phy_find(macb)) {
+		return 0;
+	}
+#endif /* CONFIG_MACB_SEARCH_PHY */
+
 	/* Check if the PHY is up to snuff... */
 	phy_id = macb_mdio_read(macb, MII_PHYSID1);
 	if (phy_id == 0xffff) {

Added to net repo.

thanks,
Ben

#21 lore raw

PATCH v2 6/9 AVR32: macb - Search for PHY id

Quoted 1 line · Ben Warren

Added to net repo.

Great!
Does this mean that we shouldn't include this patch and the patch for volatile IP_t in the next version of the patch series?

Best regards,
Olav Morken

#22 lore raw

PATCH v2 6/9 AVR32: macb - Search for PHY id

Quoted 5 lines · Olav Morken
Quoted 2 lines · Ben Warren

Added to net repo.

Quoted 7 lines

Great!
Does this mean that we shouldn't include this patch and the patch for volatile IP_t in the next version of the patch series?

Best regards,
Olav Morken

Correct. You've done a good job of making them orthogonal to the rest of your code, so the net repo is where they belong. I'll issue a pull request after doing a bit of testing.

regards,
Ben

#23 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

In reply to Gunnar Rangoy
Quoted 18 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

For 100mbps operation, the ethernet controller requires a 25 MHz clock in MII mode, and a 50 MHz clock in RMII mode. If the clock is slower, disable 100 Mbps mode.

---
 drivers/net/macb.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
drivers/net/macb.c +0 -0
index 08bebf7..d47a052 100644

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb) · line 300

Quoted 5 lines
drivers/net/macb.c +1 -1
@@ -297,7 +297,17 @@ static void macb_phy_reset(struct macb_device *macb)
 	int i;
 	u16 status, adv;
 
-	adv = ADVERTISE_CSMA | ADVERTISE_ALL;
+	adv = ADVERTISE_CSMA | ADVERTISE_ALL ;

??

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb) · line 309

Quoted 9 lines
drivers/net/macb.c +9 -0
+
+#ifdef CONFIG_MACB_FORCE10M
+	printf("%s: 100Mbps is not supported on this board - forcing 10Mbps.\n",
+	       netdev->name);
+
+	adv &= ~ADVERTISE_100FULL;
+	adv &= ~ADVERTISE_100HALF;
+	adv &= ~ADVERTISE_100BASE4;
+#endif

not a fan
could you be more specific about the problem?

Best Regards,
J.

#24 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 22 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

For 100mbps operation, the ethernet controller requires a 25 MHz clock in MII mode, and a 50 MHz clock in RMII mode. If the clock is slower, disable 100 Mbps mode.

---
 drivers/net/macb.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
drivers/net/macb.c +0 -0
index 08bebf7..d47a052 100644
@@ -297,7 +297,17 @@ static void macb_phy_reset(struct macb_device *macb)
      int i;
      u16 status, adv;
 
Quoted 3 lines

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb) · line 300

Quoted 2 lines
drivers/net/macb.c +1 -1
-     adv = ADVERTISE_CSMA | ADVERTISE_ALL;
+     adv = ADVERTISE_CSMA | ADVERTISE_ALL ;

??

Oops... Will fix this.

Quoted 12 lines

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb) · line 309

Quoted 9 lines
drivers/net/macb.c +9 -0
+
+#ifdef CONFIG_MACB_FORCE10M
+     printf("%s: 100Mbps is not supported on this board - forcing 10Mbps.\n",
+            netdev->name);
+
+     adv &= ~ADVERTISE_100FULL;
+     adv &= ~ADVERTISE_100HALF;
+     adv &= ~ADVERTISE_100BASE4;
+#endif

not a fan
could you be more specific about the problem?

Quoted 3 lines

Best Regards,
J.

On the EVK1100 board, the CPU (UC3A0512) is connected to the PHY via an RMII bus. This requires the CPU clock to be at least 50 MHz. Unfortunately, the chip on current EVK1100 boards may be unable to run at more than 50 MHz, and with the oscillator on the board, the closest frequency we can generate is 48 MHz.

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

Signature · 2 lines
Gunnar Rang?y,
99360699
#25 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Hi Gunnar,

Quoted 53 lines · Gunnar Rang?y
Quoted 23 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 21 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

For 100mbps operation, the ethernet controller requires a 25 MHz clock in MII mode, and a 50 MHz clock in RMII mode. If the clock is slower, disable 100 Mbps mode.

---
 drivers/net/macb.c |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
drivers/net/macb.c +0 -0
index 08bebf7..d47a052 100644
@@ -297,7 +297,17 @@ static void macb_phy_reset(struct macb_device *macb)
      int i;
      u16 status, adv;
 
Quoted 5 lines

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb)

Quoted 3 lines
drivers/net/macb.c +1 -1
-     adv = ADVERTISE_CSMA | ADVERTISE_ALL;
+     adv = ADVERTISE_CSMA | ADVERTISE_ALL ;
 

??

Oops... Will fix this.

Quoted 13 lines

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb)

Quoted 10 lines
drivers/net/macb.c +9 -0
+
+#ifdef CONFIG_MACB_FORCE10M
+     printf("%s: 100Mbps is not supported on this board - forcing 10Mbps.\n",
+            netdev->name);
+
+     adv &= ~ADVERTISE_100FULL;
+     adv &= ~ADVERTISE_100HALF;
+     adv &= ~ADVERTISE_100BASE4;
+#endif
 

not a fan
could you be more specific about the problem?

Quoted 4 lines

Best Regards,
J.

Quoted 10 lines

On the EVK1100 board, the CPU (UC3A0512) is connected to the PHY via an RMII bus. This requires the CPU clock to be at least 50 MHz. Unfortunately, the chip on current EVK1100 boards may be unable to run at more than 50 MHz, and with the oscillator on the board, the closest frequency we can generate is 48 MHz.

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

How about using a PHY capability override CONFIG. Something like this:

#if defined(CONFIG_MACB_PHY_CAPAB) <-- insert better name here
adv = ADVERTISE_CSMA | CONFIG_MACB_PHY_CAPAB;
#else
adv = ADVERTISE_CSMA | ADVERTISE_ALL
#endif

Just an idea...

regards,
Ben

#26 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

In reply to Gunnar Rangøy
Quoted 16 lines
Quoted 12 lines

drivers/net/macb.c static void macb_phy_reset(struct macb_device *macb) · line 309

Quoted 9 lines
drivers/net/macb.c +9 -0
+
+#ifdef CONFIG_MACB_FORCE10M
+     printf("%s: 100Mbps is not supported on this board - forcing 10Mbps.\n",
+            netdev->name);
+
+     adv &= ~ADVERTISE_100FULL;
+     adv &= ~ADVERTISE_100HALF;
+     adv &= ~ADVERTISE_100BASE4;
+#endif

not a fan
could you be more specific about the problem?

Quoted 3 lines

Best Regards,
J.

Quoted 5 lines

On the EVK1100 board, the CPU (UC3A0512) is connected to the PHY via an RMII bus. This requires the CPU clock to be at least 50 MHz. Unfortunately, the chip on current EVK1100 boards may be unable to run at more than 50 MHz, and with the oscillator on the board, the closest frequency we can generate is 48 MHz.

IMHO It's a HW design error to not use the MII

Quoted 3 lines

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

I guest you may need to disable the phy auto config mode and force him to be see as a 10Mbps phy evenif it's a 10/100

Best Regards,
J.

#27 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines

On the EVK1100 board, the CPU (UC3A0512) is connected to the PHY via an RMII bus. This requires the CPU clock to be at least 50 MHz. Unfortunately, the chip on current EVK1100 boards may be unable to run at more than 50 MHz, and with the oscillator on the board, the closest frequency we can generate is 48 MHz.

IMHO It's a HW design error to not use the MII

Some people want to use the extra pins for other things...

Unfortunately, there are quite a few boards with early engineering samples around, and they have various issues. The chips that are in production are capable of running fast enough to support RMII.

Quoted 4 lines
Quoted 2 lines

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

I guest you may need to disable the phy auto config mode and force him to be see as a 10Mbps phy evenif it's a 10/100

No need to disable autonegotiation -- you still want to select between half an full duplex, for example. But you'll need to limit the available options to the ones that actually work.

That said, I kind of like Ben's suggestion -- it's a more general solution to all sorts of board/phy/chip/whatever limitations.

As for a better name, how about CONFIG_MACB_ADVERTISE?

Haavard

#28 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 9 lines · Haavard Skinnemoen
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 5 lines

On the EVK1100 board, the CPU (UC3A0512) is connected to the PHY via an RMII bus. This requires the CPU clock to be at least 50 MHz. Unfortunately, the chip on current EVK1100 boards may be unable to run at more than 50 MHz, and with the oscillator on the board, the closest frequency we can generate is 48 MHz.

IMHO It's a HW design error to not use the MII

Some people want to use the extra pins for other things...

make sense
so I'll put a 10Mpbs phy personnaly instead or a 10/100 that can be put in a 10 mode instead to avoid to manage it in the code

Quoted 5 lines

Unfortunately, there are quite a few boards with early engineering samples around, and they have various issues. The chips that are in production are capable of running fast enough to support RMII.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

I guest you may need to disable the phy auto config mode and force him to be see as a 10Mbps phy evenif it's a 10/100

No need to disable autonegotiation -- you still want to select between half an full duplex, for example. But you'll need to limit the available options to the ones that actually work.

I do not mean the autoneg but to specify to the phy, if possible, to never accept the 100Mps instead of do it in the code

Quoted 5 lines

That said, I kind of like Ben's suggestion -- it's a more general solution to all sorts of board/phy/chip/whatever limitations.

As for a better name, how about CONFIG_MACB_ADVERTISE?

why not

Best Regards,
J.

#29 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 10 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 8 lines · Haavard Skinnemoen
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 6 lines

On the EVK1100 board, the CPU (UC3A0512) is connected to the PHY via an RMII bus. This requires the CPU clock to be at least 50 MHz. Unfortunately, the chip on current EVK1100 boards may be unable to run at more than 50 MHz, and with the oscillator on the board, the closest frequency we can generate is 48 MHz.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

IMHO It's a HW design error to not use the MII

Some people want to use the extra pins for other things...

make sense
so I'll put a 10Mpbs phy personnaly instead or a 10/100 that can be put in a 10 mode instead to avoid to manage it in the code

I haven't shopped for PHYs in a while, but imagine it's probably hard to find one that's 10Mb only, and if so it's probably more expensive than 10/100

Quoted 11 lines
Quoted 11 lines

Unfortunately, there are quite a few boards with early engineering samples around, and they have various issues. The chips that are in production are capable of running fast enough to support RMII.

Quoted 6 lines
Quoted 3 lines

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

I guest you may need to disable the phy auto config mode and force him to be see as a 10Mbps phy evenif it's a 10/100

Quoted 7 lines
Quoted 4 lines

No need to disable autonegotiation -- you still want to select between half an full duplex, for example. But you'll need to limit the available options to the ones that actually work.

I do not mean the autoneg but to specify to the phy, if possible, to never accept the 100Mps instead of do it in the code

That's basically why the advertise register is r/w, so you can limit autonegotiation through software and don't have to allocate pins for strapping.

Quoted 7 lines
Quoted 5 lines

That said, I kind of like Ben's suggestion -- it's a more general solution to all sorts of board/phy/chip/whatever limitations.

As for a better name, how about CONFIG_MACB_ADVERTISE?

why not

I like it too. One of the common checkbox items, though: do any Atmel chips have more than one MACB, in which case this should be CONFIG_MACBx_ADVERTISE or something like that?

Quoted 3 lines

Best Regards,
J.

regards,
Ben

#30 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 11 lines
Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

This patch makes it possible to limit the macb to 10 MBit for this case. We are open for suggestions for other solutions.

I guest you may need to disable the phy auto config mode and force him to be see as a 10Mbps phy evenif it's a 10/100

No need to disable autonegotiation -- you still want to select between half an full duplex, for example. But you'll need to limit the available options to the ones that actually work.

Quoted 6 lines
Quoted 3 lines

I do not mean the autoneg but to specify to the phy, if possible, to never accept the 100Mps instead of do it in the code

That's basically why the advertise register is r/w, so you can limit autonegotiation through software and don't have to allocate pins for strapping.

I've some phy/switch here that have on option to put them in 10M mode without have to manage it after even via the adverstise

I've just guess maybe the one on the board could allow it too

Quoted 3 lines

I like it too. One of the common checkbox items, though: do any Atmel chips have more than one MACB, in which case this should be CONFIG_MACBx_ADVERTISE or something like that?

on at91 actually not

Best Regards,
J.

#31 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

In reply to Ben Warren
Quoted 3 lines · On Wed, 28 Jan 2009 15:40:49 -0800 Ben Warren <[email protected]> wrote:
Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD

On 22:42 Wed 28 Jan , Haavard Skinnemoen wrote:

<snipp>

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

As for a better name, how about CONFIG_MACB_ADVERTISE?

why not

I like it too. One of the common checkbox items, though: do any Atmel chips have more than one MACB, in which case this should be CONFIG_MACBx_ADVERTISE or something like that?

Yes, AP7000 have two Ethernet MACs. And if I got this right you want to make a generic config about it, so then I guess it should open up for having more than one MAC.

Signature · 2 lines
Best regards,
Hans-Christian Egtvedt
#32 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 13 lines · Hans-Christian Egtvedt
Quoted 3 lines · On Wed, 28 Jan 2009 15:40:49 -0800 Ben Warren <[email protected]> wrote:
Quoted 2 lines · Jean-Christophe PLAGNIOL-VILLARD

On 22:42 Wed 28 Jan , Haavard Skinnemoen wrote:

<snipp>

Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

As for a better name, how about CONFIG_MACB_ADVERTISE?

why not

Quoted 8 lines
Quoted 4 lines

I like it too. One of the common checkbox items, though: do any Atmel chips have more than one MACB, in which case this should be CONFIG_MACBx_ADVERTISE or something like that?

Yes, AP7000 have two Ethernet MACs. And if I got this right you want to make a generic config about it, so then I guess it should open up for having more than one MAC.

OK, how about adding a CONFIG_MACB_ADVERTISE(id)-option, where id is the id of the MACB (passed to the macb_eth_initialize-function). This makes it possible to add this without touching anything but the macb-driver (i.e. without changing the macb_eth_initialize-prototype).

In the config-files, one could then have:

#define CONFIG_MACB_ADVERTISE(id) (				\
	(id == 0) ? (						\
		ADVERTISE_ALL | ADVERTISE_CSMA			\
	) : (							\
		ADVERTISE_CSMA | ADVERTISE_10HALF | 		\
		ADVERTISE_10FULL				\
	))

Or in the simple (and probably mose usual case (only one set of options advertised):
#define CONFIG_MACB_ADVERTISE(id) ( \
(ADVERTISE_CSMA | ADVERTISE_10HALF | ADVERTISE_10FULL)

This would require saving the id to the macb_device struct. If this is unacceptable, it could be changed to using the regs-offset instead of the id.

Any thoughts about this?

Best regards,
Olav Morken

#33 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

Quoted 24 lines · Olav Morken
Quoted 3 lines

Yes, AP7000 have two Ethernet MACs. And if I got this right you want to make a generic config about it, so then I guess it should open up for having more than one MAC.

OK, how about adding a CONFIG_MACB_ADVERTISE(id)-option, where id is the id of the MACB (passed to the macb_eth_initialize-function). This makes it possible to add this without touching anything but the macb-driver (i.e. without changing the macb_eth_initialize-prototype).

In the config-files, one could then have:

#define CONFIG_MACB_ADVERTISE(id) (				\
	(id == 0) ? (						\
		ADVERTISE_ALL | ADVERTISE_CSMA			\
	) : (							\
		ADVERTISE_CSMA | ADVERTISE_10HALF | 		\
		ADVERTISE_10FULL				\
	))

Or in the simple (and probably mose usual case (only one set of options advertised):
#define CONFIG_MACB_ADVERTISE(id) ( \
(ADVERTISE_CSMA | ADVERTISE_10HALF | ADVERTISE_10FULL)

Quoted 5 lines

This would require saving the id to the macb_device struct. If this is unacceptable, it could be changed to using the regs-offset instead of the id.

Any thoughts about this?

Sounds good to me. The board decides the id, so it makes sense to pass it back to the board code.

Haavard

#34 lore raw

PATCH v2 5/9 AVR32: macb - Disable 100mbps if clock is slow

In reply to Ben Warren
Quoted 8 lines · Ben Warren
Quoted 4 lines · Jean-Christophe PLAGNIOL-VILLARD

make sense
so I'll put a 10Mpbs phy personnaly instead or a 10/100 that can be put in a 10 mode instead to avoid to manage it in the code

I haven't shopped for PHYs in a while, but imagine it's probably hard to find one that's 10Mb only, and if so it's probably more expensive than 10/100

Especially when the board really is _supposed_ to do 100Mbps just fine.

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

No need to disable autonegotiation -- you still want to select between half an full duplex, for example. But you'll need to limit the available options to the ones that actually work.

I do not mean the autoneg but to specify to the phy, if possible, to never accept the 100Mps instead of do it in the code

That's basically why the advertise register is r/w, so you can limit autonegotiation through software and don't have to allocate pins for strapping.

Yeah, I thought the advertise register was the correct way of informing the phy about what modes you support...

I suppose we could move the initialization of the advertise register to board code, but that's going to be a lot uglier since the board code would have to access the MACB hardware to drive the MDIO pins.

Perhaps some boards don't need any initialization at all, but then again, isn't it safer to unconditionally write the correct value? And when we're going to write the register _anyway_, we might as well allow the board code to influence the value we're going to write.

The more I think of this, the more I'm convinced we should have allowed that from the beginning. The current driver is making assumptions it shouldn't be making.

Quoted 10 lines
Quoted 7 lines
Quoted 5 lines

That said, I kind of like Ben's suggestion -- it's a more general solution to all sorts of board/phy/chip/whatever limitations.

As for a better name, how about CONFIG_MACB_ADVERTISE?

why not

I like it too. One of the common checkbox items, though: do any Atmel chips have more than one MACB, in which case this should be CONFIG_MACBx_ADVERTISE or something like that?

Yes, AT32AP7000 has two MACBs, so that's probably a good idea.

Better yet, make it CONFIG_MACB_ADVERTISE(macb) so that the board can distinguish between various instances if it has to, and the driver doesn't have to do a long sequence of #ifdefs to find the correct value.

Haavard

#36 lore raw

PATCH v2 3/9 AVR32: Move addrspace.h to arch-directory, and move some functions from io.h to addrspace.h

In reply to Gunnar Rangoy
Quoted 11 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

The AVR32A architecture (which AT32UC3A-series is based on) has a different memory layout than the AVR32B-architecture. This patch moves addrspace.h to an arch-dependent directory in preparation for AT32UC3A-support. It also moves some address-space manipulation functions from io.h to addrspace.h.

Applied to evk1100-prep, thanks.

Haavard

#37 lore raw

PATCH v2 2/9 AVR32: Make cacheflush cpu-dependent

In reply to Gunnar Rangoy
Quoted 9 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

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.

Applied to evk1100-prep and merged into next. I'll send it upstream as soon as it's fine with Wolfgang.

Btw, I had to rebuild my next branch since it's become a bit stale. Since all the non-merge commit IDs are the same, I hope it won't cause any problems -- please let me know if you see any weird merge issues.

Haavard

#38 lore raw

PATCH v2 1/9 Fix IP alignement problem

In reply to Gunnar Rangoy
Quoted 22 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

This patch removes volatile from:
volatile IP_t *ip = (IP_t *)xip;

Due to a bug, avr32-gcc will assume that ip is aligned on a word boundary when using volatile, which causes an exception since xip isn't aligned on a word boundary.

---
 net/net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/net.c +0 -0
index 313d5d8..405ca6e 100644

net/net.c NetSetEther(volatile uchar * xet, uchar * addr, uint prot) · line 1691

Quoted 8 lines
net/net.c +1 -1
@@ -1685,7 +1685,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
 void
 NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
 {
-	volatile IP_t *ip = (IP_t *)xip;
+	IP_t *ip = (IP_t *)xip;
 
 	/*
 	 *	If the data is an odd number of bytes, zero the

This seems reasonable. I'll try it out and will get back to you soon.

regards,
Ben

Applied
#39 lore raw

PATCH v2 1/9 Fix IP alignement problem

In reply to Gunnar Rangoy
Quoted 22 lines · Gunnar Rangoy

From: Olav Morken <[email protected]>

This patch removes volatile from:
volatile IP_t *ip = (IP_t *)xip;

Due to a bug, avr32-gcc will assume that ip is aligned on a word boundary when using volatile, which causes an exception since xip isn't aligned on a word boundary.

---
 net/net.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
net/net.c +0 -0
index 313d5d8..405ca6e 100644

net/net.c NetSetEther(volatile uchar * xet, uchar * addr, uint prot) · line 1691

Quoted 8 lines
net/net.c +1 -1
@@ -1685,7 +1685,7 @@ NetSetEther(volatile uchar * xet, uchar * addr, uint prot)
 void
 NetSetIP(volatile uchar * xip, IPaddr_t dest, int dport, int sport, int len)
 {
-	volatile IP_t *ip = (IP_t *)xip;
+	IP_t *ip = (IP_t *)xip;
 
 	/*
 	 *	If the data is an odd number of bytes, zero the

Applied to net repo (fixed typo in title )

thanks,
Ben