All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet
@ 2010-06-10 21:50 Eric Bénard
  2010-06-10 21:50 ` [U-Boot] [PATCH 2/2] cpuat91: convert to new at91 soc architecture Eric Bénard
  2010-06-21  6:02 ` [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Ben Warren
  0 siblings, 2 replies; 5+ messages in thread
From: Eric Bénard @ 2010-06-10 21:50 UTC (permalink / raw)
  To: u-boot

* the following problems are met :
config was set to use the new driver as a default but
- RMII was not enabled for the new driver
- the new driver didn't compile with RMII enabled
- the new driver initialize a PHY at address O when the PHY of
this board is at 1 thus we get "AT91 EMAC RMII: No PHY present"

* to fix these problems, this patch :
- enable RMII for the new driver
- fix the wrong define used in the at91_emac.c
- allow the config file to set a default phy address (and use
0 as a default as in the actual at91_emac.c driver)

Signed-off-by: Eric B?nard <eric@eukrea.com>
---
 drivers/net/at91_emac.c   |   24 ++++++++++++++----------
 include/configs/cpuat91.h |    9 +++------
 2 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index 2399569..1ebcf05 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -53,6 +53,10 @@
 	Please decrease the CONFIG_SYS_RX_ETH_BUFFER value
 #endif
 
+#ifndef CONFIG_DRIVER_AT91EMAC_PHYADDR
+#define CONFIG_DRIVER_AT91EMAC_PHYADDR	0
+#endif
+
 /* MDIO clock must not exceed 2.5 MHz, so enable MCK divider */
 #if (AT91C_MASTER_CLOCK > 80000000)
 	#define HCLK_DIV	AT91_EMAC_CFG_MCLK_64
@@ -198,12 +202,12 @@ static int at91emac_phy_reset(struct eth_device *netdev)
 	emac = (at91_emac_t *) netdev->iobase;
 
 	adv = ADVERTISE_CSMA | ADVERTISE_ALL;
-	at91emac_write(emac, 0, MII_ADVERTISE, adv);
+	at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_ADVERTISE, adv);
 	VERBOSEP("%s: Starting autonegotiation...\n", netdev->name);
-	at91emac_write(emac, 0, MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
+	at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
 
 	for (i = 0; i < 100000 / 100; i++) {
-		at91emac_read(emac, 0, MII_BMSR, &status);
+		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR, &status);
 		if (status & BMSR_ANEGCOMPLETE)
 			break;
 		udelay(100);
@@ -229,13 +233,13 @@ static int at91emac_phy_init(struct eth_device *netdev)
 	emac = (at91_emac_t *) netdev->iobase;
 
 	/* Check if the PHY is up to snuff... */
-	at91emac_read(emac, 0, MII_PHYSID1, &phy_id);
+	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_PHYSID1, &phy_id);
 	if (phy_id == 0xffff) {
 		printf("%s: No PHY present\n", netdev->name);
 		return 1;
 	}
 
-	at91emac_read(emac, 0, MII_BMSR, &status);
+	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR, &status);
 
 	if (!(status & BMSR_LSTATUS)) {
 		/* Try to re-negotiate if we don't have link already. */
@@ -243,7 +247,7 @@ static int at91emac_phy_init(struct eth_device *netdev)
 			return 2;
 
 		for (i = 0; i < 100000 / 100; i++) {
-			at91emac_read(emac, 0, MII_BMSR, &status);
+			at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR, &status);
 			if (status & BMSR_LSTATUS)
 				break;
 			udelay(100);
@@ -253,8 +257,8 @@ static int at91emac_phy_init(struct eth_device *netdev)
 		VERBOSEP("%s: link down\n", netdev->name);
 		return 3;
 	} else {
-		at91emac_read(emac, 0, MII_ADVERTISE, &adv);
-		at91emac_read(emac, 0, MII_LPA, &lpa);
+		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_ADVERTISE, &adv);
+		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_LPA, &lpa);
 		media = mii_nway_result(lpa & adv);
 		speed = (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)
 			 ? 1 : 0);
@@ -271,7 +275,7 @@ int at91emac_UpdateLinkSpeed(at91_emac_t *emac)
 {
 	unsigned short stat1;
 
-	at91emac_read(emac, 0, MII_BMSR, &stat1);
+	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR, &stat1);
 
 	if (!(stat1 & BMSR_LSTATUS))	/* link status up? */
 		return 1;
@@ -372,7 +376,7 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
 	value = AT91_EMAC_CFG_CAF |	AT91_EMAC_CFG_NBC |
 		HCLK_DIV;
 #ifdef CONFIG_RMII
-	value |= AT91C_EMAC_RMII;
+	value |= AT91_EMAC_CFG_RMII;
 #endif
 	writel(value, &emac->cfg);
 
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index b4fda76..049298c 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -131,15 +131,12 @@
 	(CONFIG_SYS_MEMTEST_START + PHYS_SDRAM_SIZE - 512 * 1024)
 
 #define CONFIG_NET_MULTI		1
-#ifdef CONFIG_NET_MULTI
 #define CONFIG_DRIVER_AT91EMAC		1
 #define CONFIG_SYS_RX_ETH_BUFFER	8
-#else
-#define CONFIG_DRIVER_ETHER		1
-#endif
+#define CONFIG_RMII			1
+#define CONFIG_MII			1
+#define CONFIG_DRIVER_AT91EMAC_PHYADDR	1
 #define CONFIG_NET_RETRY_COUNT			20
-#define CONFIG_AT91C_USE_RMII			1
-#define CONFIG_PHY_ADDRESS			(1 << 5)
 #define CONFIG_KS8721_PHY			1
 
 #define CONFIG_SYS_FLASH_CFI			1
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 2/2] cpuat91: convert to new at91 soc architecture
  2010-06-10 21:50 [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Eric Bénard
@ 2010-06-10 21:50 ` Eric Bénard
  2010-06-21  6:02 ` [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Ben Warren
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Bénard @ 2010-06-10 21:50 UTC (permalink / raw)
  To: u-boot

convert the board to the new soc architecture
update default config
i2c upgrade taken from eb_cpux9k2.h & board/BuS/eb_cpux9k2/cpux9k2.c

Signed-off-by: Eric B?nard <eric@eukrea.com>
---
 Makefile                       |    2 +-
 board/eukrea/cpuat91/cpuat91.c |   53 ++++++++++++++++-----------------------
 include/configs/cpuat91.h      |   45 +++++++++++++++++++++++----------
 3 files changed, 54 insertions(+), 46 deletions(-)

diff --git a/Makefile b/Makefile
index c26e491..ffc749d 100644
--- a/Makefile
+++ b/Makefile
@@ -2693,7 +2693,7 @@ CPUAT91_RAM_config \
 CPUAT91_config	:	unconfig
 	@mkdir -p $(obj)include
 	@echo "#define CONFIG_$(@:_config=) 1"	>$(obj)include/config.h
-	@$(MKCONFIG) -a cpuat91 arm arm920t cpuat91 eukrea at91rm9200
+	@$(MKCONFIG) -a cpuat91 arm arm920t cpuat91 eukrea at91
 
 csb637_config	:	unconfig
 	@$(MKCONFIG) $(@:_config=) arm arm920t csb637 NULL at91rm9200
diff --git a/board/eukrea/cpuat91/cpuat91.c b/board/eukrea/cpuat91/cpuat91.c
index 0017962..cd4d42c 100644
--- a/board/eukrea/cpuat91/cpuat91.c
+++ b/board/eukrea/cpuat91/cpuat91.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2006 Eukrea Electromatique <www.eukrea.com>
+ * (C) Copyright 2006-2010 Eukrea Electromatique <www.eukrea.com>
  * Eric Benard <eric@eukrea.com>
  * based on at91rm9200dk.c which is :
  * (C) Copyright 2002
@@ -27,13 +27,11 @@
 
 #include <common.h>
 #include <netdev.h>
-#include <asm/arch/AT91RM9200.h>
-#include <asm/io.h>
 
-#if defined(CONFIG_DRIVER_ETHER)
-#include <at91rm9200_net.h>
-#include <ks8721.h>
-#endif
+#include <asm/io.h>
+#include <asm/arch/hardware.h>
+#include <asm/arch/at91_pio.h>
+#include <asm/arch/at91_pmc.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -61,31 +59,7 @@ int dram_init(void)
 	return 0;
 }
 
-#if defined(CONFIG_DRIVER_ETHER)
-#if defined(CONFIG_CMD_NET)
-
-/*
- * Name:
- *	at91rm9200_GetPhyInterface
- * Description:
- *	Initialise the interface functions to the PHY
- * Arguments:
- *	None
- * Return value:
- *	None
- */
-void at91rm9200_GetPhyInterface(AT91PS_PhyOps p_phyops)
-{
-	p_phyops->Init = ks8721_initphy;
-	p_phyops->IsPhyConnected = ks8721_isphyconnected;
-	p_phyops->GetLinkSpeed = ks8721_getlinkspeed;
-	p_phyops->AutoNegotiate = ks8721_autonegotiate;
-}
-
-#endif	/* CONFIG_CMD_NET */
-#endif	/* CONFIG_DRIVER_ETHER */
 #ifdef CONFIG_DRIVER_AT91EMAC
-
 int board_eth_init(bd_t *bis)
 {
 	int rc = 0;
@@ -93,3 +67,20 @@ int board_eth_init(bd_t *bis)
 	return rc;
 }
 #endif
+
+#ifdef CONFIG_SOFT_I2C
+void i2c_init_board(void)
+{
+	u32 pin;
+	at91_pmc_t *pmc = (at91_pmc_t *) AT91_PMC_BASE;
+	at91_pio_t *pio = (at91_pio_t *) AT91_PIO_BASE;
+
+	writel(1 << AT91_ID_PIOA, &pmc->pcer);
+	pin = AT91_PMX_AA_TWD | AT91_PMX_AA_TWCK;
+	writel(pin, &pio->pioa.idr);
+	writel(pin, &pio->pioa.pudr);
+	writel(pin, &pio->pioa.per);
+	writel(pin, &pio->pioa.oer);
+	writel(pin, &pio->pioa.sodr);
+}
+#endif
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index 049298c..b012782 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -1,5 +1,5 @@
 /*
- * CPUAT91 by (C) Copyright 2006 Eric Benard
+ * CPUAT91 by (C) Copyright 2006-2010 Eric Benard
  * eric at eukrea.com
  *
  * Configuration settings for the CPUAT91 board.
@@ -23,15 +23,12 @@
  * MA 02111-1307 USA
  */
 
-#ifndef __CONFIG_H
-#define __CONFIG_H
-
-#define CONFIG_AT91_LEGACY
+#ifndef _CONFIG_CPUAT91_H
+#define _CONFIG_CPUAT91_H
 
 #ifdef CONFIG_CPUAT91_RAM
 #define CONFIG_SKIP_LOWLEVEL_INIT	1
 #define CONFIG_SKIP_RELOCATE_UBOOT	1
-#define CONFIG_CPUAT91			1
 #else
 #define CONFIG_BOOTDELAY		1
 #endif
@@ -43,6 +40,7 @@
 
 #define CONFIG_ARM920T			1
 #define CONFIG_AT91RM9200		1
+#define CONFIG_CPUAT91			1
 
 #undef CONFIG_USE_IRQ
 #define USE_920T_MMU			1
@@ -89,16 +87,36 @@
 #undef CONFIG_USART0
 #undef CONFIG_USART1
 
-#define CONFIG_HARD_I2C			1
+#undef CONFIG_HARD_I2C
+#define CONFIG_SOFT_I2C			1
+#define AT91_PIN_SDA			(1<<25)
+#define AT91_PIN_SCL			(1<<26)
+
+#define CONFIG_SYS_I2C_INIT_BOARD	1
+#define	CONFIG_SYS_I2C_SPEED		50000
+#define CONFIG_SYS_I2C_SLAVE		0
+
+#define I2C_INIT	i2c_init_board();
+#define I2C_ACTIVE	writel(AT91_PMX_AA_TWD, &pio->pioa.mddr);
+#define I2C_TRISTATE	writel(AT91_PMX_AA_TWD, &pio->pioa.mder);
+#define I2C_READ	((readl(&pio->pioa.pdsr) & AT91_PMX_AA_TWD) != 0)
+#define I2C_SDA(bit)						\
+	if (bit)						\
+		writel(AT91_PMX_AA_TWD, &pio->pioa.sodr);	\
+	else							\
+		writel(AT91_PMX_AA_TWD, &pio->pioa.codr);
+#define I2C_SCL(bit)						\
+	if (bit)						\
+		writel(AT91_PMX_AA_TWCK, &pio->pioa.sodr);	\
+	else							\
+		writel(AT91_PMX_AA_TWCK, &pio->pioa.codr);
+
+#define I2C_DELAY	udelay(2500000/CONFIG_SYS_I2C_SPEED)
 
-#if defined(CONFIG_HARD_I2C)
-#define	CONFIG_SYS_I2C_SPEED			50000
-#define CONFIG_SYS_I2C_SLAVE			0
 #define CONFIG_SYS_I2C_EEPROM_ADDR		0x54
 #define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		1
 #define CONFIG_SYS_I2C_EEPROM_ADDR_OVERFLOW	1
 #define	CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS	10
-#endif
 
 #define CONFIG_BOOTP_BOOTFILESIZE	1
 #define CONFIG_BOOTP_BOOTPATH		1
@@ -117,10 +135,8 @@
 #undef CONFIG_CMD_LOADS
 #undef CONFIG_CMD_NFS
 
-#if defined(CONFIG_HARD_I2C)
 #define CONFIG_CMD_EEPROM		1
 #define CONFIG_CMD_I2C			1
-#endif
 
 #define CONFIG_NR_DRAM_BANKS			1
 #define PHYS_SDRAM				0x20000000
@@ -148,6 +164,7 @@
 #define PHYS_FLASH_1				0x10000000
 #define CONFIG_SYS_FLASH_BASE			PHYS_FLASH_1
 #define CONFIG_SYS_MAX_FLASH_SECT		128
+#define CONFIG_SYS_FLASH_CFI_WIDTH		FLASH_CFI_16BIT
 
 #if defined(CONFIG_CMD_USB)
 #define CONFIG_USB_OHCI_NEW			1
@@ -230,4 +247,4 @@
 	"flashboot=run ramargs;bootm 10040000\0"			\
 	"netboot=run ramargs;tftpboot 21000000 cpuat91/uImage;"		\
 		"bootm 21000000\0"
-#endif	/* __CONFIG_H */
+#endif	/* _CONFIG_CPUAT91_H */
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet
  2010-06-10 21:50 [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Eric Bénard
  2010-06-10 21:50 ` [U-Boot] [PATCH 2/2] cpuat91: convert to new at91 soc architecture Eric Bénard
@ 2010-06-21  6:02 ` Ben Warren
  2010-06-21  7:40   ` [U-Boot] [PATCH v2] " Eric Bénard
  1 sibling, 1 reply; 5+ messages in thread
From: Ben Warren @ 2010-06-21  6:02 UTC (permalink / raw)
  To: u-boot

Hi Eric,

On 6/10/2010 2:50 PM, Eric B?nard wrote:
> * the following problems are met :
> config was set to use the new driver as a default but
> - RMII was not enabled for the new driver
> - the new driver didn't compile with RMII enabled
> - the new driver initialize a PHY at address O when the PHY of
> this board is at 1 thus we get "AT91 EMAC RMII: No PHY present"
>
> * to fix these problems, this patch :
> - enable RMII for the new driver
> - fix the wrong define used in the at91_emac.c
> - allow the config file to set a default phy address (and use
> 0 as a default as in the actual at91_emac.c driver)
>
> Signed-off-by: Eric B?nard<eric@eukrea.com>
> ---
>   drivers/net/at91_emac.c   |   24 ++++++++++++++----------
>   include/configs/cpuat91.h |    9 +++------
>   2 files changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
> index 2399569..1ebcf05 100644
> --- a/drivers/net/at91_emac.c
> +++ b/drivers/net/at91_emac.c
> @@ -53,6 +53,10 @@
>   	Please decrease the CONFIG_SYS_RX_ETH_BUFFER value
>   #endif
>
> +#ifndef CONFIG_DRIVER_AT91EMAC_PHYADDR
> +#define CONFIG_DRIVER_AT91EMAC_PHYADDR	0
> +#endif
> +
>   /* MDIO clock must not exceed 2.5 MHz, so enable MCK divider */
>   #if (AT91C_MASTER_CLOCK>  80000000)
>   	#define HCLK_DIV	AT91_EMAC_CFG_MCLK_64
> @@ -198,12 +202,12 @@ static int at91emac_phy_reset(struct eth_device *netdev)
>   	emac = (at91_emac_t *) netdev->iobase;
>
>   	adv = ADVERTISE_CSMA | ADVERTISE_ALL;
> -	at91emac_write(emac, 0, MII_ADVERTISE, adv);
> +	at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_ADVERTISE, adv);
>   	VERBOSEP("%s: Starting autonegotiation...\n", netdev->name);
> -	at91emac_write(emac, 0, MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
> +	at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
>    
This line's too long.  Please check the other ones too.  Try to keep 
less than 78 characters.
>
>   	for (i = 0; i<  100000 / 100; i++) {
> -		at91emac_read(emac, 0, MII_BMSR,&status);
> +		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR,&status);
>   		if (status&  BMSR_ANEGCOMPLETE)
>   			break;
>   		udelay(100);
> @@ -229,13 +233,13 @@ static int at91emac_phy_init(struct eth_device *netdev)
>   	emac = (at91_emac_t *) netdev->iobase;
>
>   	/* Check if the PHY is up to snuff... */
> -	at91emac_read(emac, 0, MII_PHYSID1,&phy_id);
> +	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_PHYSID1,&phy_id);
>   	if (phy_id == 0xffff) {
>   		printf("%s: No PHY present\n", netdev->name);
>   		return 1;
>   	}
>
> -	at91emac_read(emac, 0, MII_BMSR,&status);
> +	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR,&status);
>
>   	if (!(status&  BMSR_LSTATUS)) {
>   		/* Try to re-negotiate if we don't have link already. */
> @@ -243,7 +247,7 @@ static int at91emac_phy_init(struct eth_device *netdev)
>   			return 2;
>
>   		for (i = 0; i<  100000 / 100; i++) {
> -			at91emac_read(emac, 0, MII_BMSR,&status);
> +			at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR,&status);
>   			if (status&  BMSR_LSTATUS)
>   				break;
>   			udelay(100);
> @@ -253,8 +257,8 @@ static int at91emac_phy_init(struct eth_device *netdev)
>   		VERBOSEP("%s: link down\n", netdev->name);
>   		return 3;
>   	} else {
> -		at91emac_read(emac, 0, MII_ADVERTISE,&adv);
> -		at91emac_read(emac, 0, MII_LPA,&lpa);
> +		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_ADVERTISE,&adv);
> +		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_LPA,&lpa);
>   		media = mii_nway_result(lpa&  adv);
>   		speed = (media&  (ADVERTISE_100FULL | ADVERTISE_100HALF)
>   			 ? 1 : 0);
> @@ -271,7 +275,7 @@ int at91emac_UpdateLinkSpeed(at91_emac_t *emac)
>   {
>   	unsigned short stat1;
>
> -	at91emac_read(emac, 0, MII_BMSR,&stat1);
> +	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR,&stat1);
>
>   	if (!(stat1&  BMSR_LSTATUS))	/* link status up? */
>   		return 1;
> @@ -372,7 +376,7 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
>   	value = AT91_EMAC_CFG_CAF |	AT91_EMAC_CFG_NBC |
>   		HCLK_DIV;
>   #ifdef CONFIG_RMII
> -	value |= AT91C_EMAC_RMII;
> +	value |= AT91_EMAC_CFG_RMII;
>   #endif
>   	writel(value,&emac->cfg);
>
> diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
> index b4fda76..049298c 100644
> --- a/include/configs/cpuat91.h
> +++ b/include/configs/cpuat91.h
> @@ -131,15 +131,12 @@
>   	(CONFIG_SYS_MEMTEST_START + PHYS_SDRAM_SIZE - 512 * 1024)
>
>   #define CONFIG_NET_MULTI		1
> -#ifdef CONFIG_NET_MULTI
>   #define CONFIG_DRIVER_AT91EMAC		1
>   #define CONFIG_SYS_RX_ETH_BUFFER	8
> -#else
> -#define CONFIG_DRIVER_ETHER		1
> -#endif
> +#define CONFIG_RMII			1
> +#define CONFIG_MII			1
> +#define CONFIG_DRIVER_AT91EMAC_PHYADDR	1
>   #define CONFIG_NET_RETRY_COUNT			20
> -#define CONFIG_AT91C_USE_RMII			1
> -#define CONFIG_PHY_ADDRESS			(1<<  5)
>   #define CONFIG_KS8721_PHY			1
>
>   #define CONFIG_SYS_FLASH_CFI			1
>    
regards,
Ben

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] cpuat91: unbreak ethernet
  2010-06-21  6:02 ` [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Ben Warren
@ 2010-06-21  7:40   ` Eric Bénard
  2010-06-21 17:56     ` Ben Warren
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Bénard @ 2010-06-21  7:40 UTC (permalink / raw)
  To: u-boot

* the following problems are met :
config was set to use the new driver as a default but
- RMII was not enabled for the new driver
- the new driver didn't compile with RMII enabled
- the new driver initialize a PHY at address O when the PHY of
this board is at 1 thus we get "AT91 EMAC RMII: No PHY present"

* to fix these problems, this patch :
- enable RMII for the new driver
- fix the wrong define used in the at91_emac.c
- allow the config file to set a default phy address (and use
0 as a default as in the actual at91_emac.c driver)

Signed-off-by: Eric B?nard <eric@eukrea.com>
---
v2 :
	fix line lengths

 drivers/net/at91_emac.c   |   32 ++++++++++++++++++++++----------
 include/configs/cpuat91.h |    9 +++------
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/net/at91_emac.c b/drivers/net/at91_emac.c
index 2399569..cf0a7c0 100644
--- a/drivers/net/at91_emac.c
+++ b/drivers/net/at91_emac.c
@@ -53,6 +53,10 @@
 	Please decrease the CONFIG_SYS_RX_ETH_BUFFER value
 #endif
 
+#ifndef CONFIG_DRIVER_AT91EMAC_PHYADDR
+#define CONFIG_DRIVER_AT91EMAC_PHYADDR	0
+#endif
+
 /* MDIO clock must not exceed 2.5 MHz, so enable MCK divider */
 #if (AT91C_MASTER_CLOCK > 80000000)
 	#define HCLK_DIV	AT91_EMAC_CFG_MCLK_64
@@ -198,12 +202,15 @@ static int at91emac_phy_reset(struct eth_device *netdev)
 	emac = (at91_emac_t *) netdev->iobase;
 
 	adv = ADVERTISE_CSMA | ADVERTISE_ALL;
-	at91emac_write(emac, 0, MII_ADVERTISE, adv);
+	at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, 
+		MII_ADVERTISE, adv);
 	VERBOSEP("%s: Starting autonegotiation...\n", netdev->name);
-	at91emac_write(emac, 0, MII_BMCR, (BMCR_ANENABLE | BMCR_ANRESTART));
+	at91emac_write(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMCR,
+		(BMCR_ANENABLE | BMCR_ANRESTART));
 
 	for (i = 0; i < 100000 / 100; i++) {
-		at91emac_read(emac, 0, MII_BMSR, &status);
+		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+			MII_BMSR, &status);
 		if (status & BMSR_ANEGCOMPLETE)
 			break;
 		udelay(100);
@@ -229,13 +236,15 @@ static int at91emac_phy_init(struct eth_device *netdev)
 	emac = (at91_emac_t *) netdev->iobase;
 
 	/* Check if the PHY is up to snuff... */
-	at91emac_read(emac, 0, MII_PHYSID1, &phy_id);
+	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+		MII_PHYSID1, &phy_id);
 	if (phy_id == 0xffff) {
 		printf("%s: No PHY present\n", netdev->name);
 		return 1;
 	}
 
-	at91emac_read(emac, 0, MII_BMSR, &status);
+	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+		MII_BMSR, &status);
 
 	if (!(status & BMSR_LSTATUS)) {
 		/* Try to re-negotiate if we don't have link already. */
@@ -243,7 +252,8 @@ static int at91emac_phy_init(struct eth_device *netdev)
 			return 2;
 
 		for (i = 0; i < 100000 / 100; i++) {
-			at91emac_read(emac, 0, MII_BMSR, &status);
+			at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+				MII_BMSR, &status);
 			if (status & BMSR_LSTATUS)
 				break;
 			udelay(100);
@@ -253,8 +263,10 @@ static int at91emac_phy_init(struct eth_device *netdev)
 		VERBOSEP("%s: link down\n", netdev->name);
 		return 3;
 	} else {
-		at91emac_read(emac, 0, MII_ADVERTISE, &adv);
-		at91emac_read(emac, 0, MII_LPA, &lpa);
+		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+			MII_ADVERTISE, &adv);
+		at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR,
+			MII_LPA, &lpa);
 		media = mii_nway_result(lpa & adv);
 		speed = (media & (ADVERTISE_100FULL | ADVERTISE_100HALF)
 			 ? 1 : 0);
@@ -271,7 +283,7 @@ int at91emac_UpdateLinkSpeed(at91_emac_t *emac)
 {
 	unsigned short stat1;
 
-	at91emac_read(emac, 0, MII_BMSR, &stat1);
+	at91emac_read(emac, CONFIG_DRIVER_AT91EMAC_PHYADDR, MII_BMSR, &stat1);
 
 	if (!(stat1 & BMSR_LSTATUS))	/* link status up? */
 		return 1;
@@ -372,7 +384,7 @@ static int at91emac_init(struct eth_device *netdev, bd_t *bd)
 	value = AT91_EMAC_CFG_CAF |	AT91_EMAC_CFG_NBC |
 		HCLK_DIV;
 #ifdef CONFIG_RMII
-	value |= AT91C_EMAC_RMII;
+	value |= AT91_EMAC_CFG_RMII;
 #endif
 	writel(value, &emac->cfg);
 
diff --git a/include/configs/cpuat91.h b/include/configs/cpuat91.h
index b4fda76..049298c 100644
--- a/include/configs/cpuat91.h
+++ b/include/configs/cpuat91.h
@@ -131,15 +131,12 @@
 	(CONFIG_SYS_MEMTEST_START + PHYS_SDRAM_SIZE - 512 * 1024)
 
 #define CONFIG_NET_MULTI		1
-#ifdef CONFIG_NET_MULTI
 #define CONFIG_DRIVER_AT91EMAC		1
 #define CONFIG_SYS_RX_ETH_BUFFER	8
-#else
-#define CONFIG_DRIVER_ETHER		1
-#endif
+#define CONFIG_RMII			1
+#define CONFIG_MII			1
+#define CONFIG_DRIVER_AT91EMAC_PHYADDR	1
 #define CONFIG_NET_RETRY_COUNT			20
-#define CONFIG_AT91C_USE_RMII			1
-#define CONFIG_PHY_ADDRESS			(1 << 5)
 #define CONFIG_KS8721_PHY			1
 
 #define CONFIG_SYS_FLASH_CFI			1
-- 
1.6.3.3

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [U-Boot] [PATCH v2] cpuat91: unbreak ethernet
  2010-06-21  7:40   ` [U-Boot] [PATCH v2] " Eric Bénard
@ 2010-06-21 17:56     ` Ben Warren
  0 siblings, 0 replies; 5+ messages in thread
From: Ben Warren @ 2010-06-21 17:56 UTC (permalink / raw)
  To: u-boot

Hi Eric,

On 6/21/2010 12:40 AM, Eric B?nard wrote:
> * the following problems are met :
> config was set to use the new driver as a default but
> - RMII was not enabled for the new driver
> - the new driver didn't compile with RMII enabled
> - the new driver initialize a PHY at address O when the PHY of
> this board is at 1 thus we get "AT91 EMAC RMII: No PHY present"
>
> * to fix these problems, this patch :
> - enable RMII for the new driver
> - fix the wrong define used in the at91_emac.c
> - allow the config file to set a default phy address (and use
> 0 as a default as in the actual at91_emac.c driver)
>
> Signed-off-by: Eric B?nard<eric@eukrea.com>
> ---
>    
Applied to net/next repo.

regards,
Ben

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-06-21 17:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-10 21:50 [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Eric Bénard
2010-06-10 21:50 ` [U-Boot] [PATCH 2/2] cpuat91: convert to new at91 soc architecture Eric Bénard
2010-06-21  6:02 ` [U-Boot] [PATCH 1/2] cpuat91: unbreak ethernet Ben Warren
2010-06-21  7:40   ` [U-Boot] [PATCH v2] " Eric Bénard
2010-06-21 17:56     ` Ben Warren

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.