All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v3 0/4] board: sama5d2_xplained: Convert to use device tree and drivers with DM
@ 2016-10-17  1:55 Wenyou Yang
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 1/4] board: sama5d2_xplained: Move config options to defconfigs Wenyou Yang
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Wenyou Yang @ 2016-10-17  1:55 UTC (permalink / raw)
  To: u-boot

Convert to use the drivers which support the driver model and use the
device tree. And add the support to enable an early debug UART for
debugging.

It is based on the following patches:
  - [PATCH v3] i2c: at91_i2c: Fix the wrong include file
  	http://lists.denx.de/pipermail/u-boot/2016-October/270249.html
  - [PATCH v2] clk: at91: Fix at91-pmc and at91-sckc's class ID
  	http://lists.denx.de/pipermail/u-boot/2016-September/266408.html
  - [PATCH v2] mmc: mmc-uclass: Add mmc_init() in mmc preinit phrase
  	http://lists.denx.de/pipermail/u-boot/2016-September/266409.html
  - [PATCH v3 0/2] serial: atmel_usart: Support to enable an early debug UART
  	http://lists.denx.de/pipermail/u-boot/2016-October/270250.html
  - [PATCH v9] dm: at91: Add driver model support for the spi driver
  	http://lists.denx.de/pipermail/u-boot/2016-September/266407.html
  - [PATCH] sf: fix sf probe
  	http://lists.denx.de/pipermail/u-boot/2016-August/264104.html

Changes in v3:
 - Collect Reviewed-by tag.
 - Collect Reviewed-by tag.
 - Collect Reviewed-by tag.
 - Rename CONFIG_AT24MAC_ADDR and CONFIG_AT24MAC_REG to AT24MAC_ADDR
   and AT24MAC_REG,  removing the prefix CONFIG_, to avoid compile
   warning.
 - Collect Reviewed-by tag.

Changes in v2:
 - Collect Reviewed-by tags.

Wenyou Yang (4):
  board: sama5d2_xplained: Move config options to defconfigs
  board: sama5d2_xplained: Clean up code
  board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC
  board: sama5d2_xplained: Enable an early debug UART

 board/atmel/sama5d2_xplained/sama5d2_xplained.c | 167 +++++++++---------------
 configs/sama5d2_xplained_mmc_defconfig          |  37 +++++-
 configs/sama5d2_xplained_spiflash_defconfig     |  37 +++++-
 include/configs/sama5d2_xplained.h              |  31 +----
 4 files changed, 144 insertions(+), 128 deletions(-)

-- 
2.7.4

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

* [U-Boot] [PATCH v3 1/4] board: sama5d2_xplained: Move config options to defconfigs
  2016-10-17  1:55 [U-Boot] [PATCH v3 0/4] board: sama5d2_xplained: Convert to use device tree and drivers with DM Wenyou Yang
@ 2016-10-17  1:55 ` Wenyou Yang
  2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 2/4] board: sama5d2_xplained: Clean up code Wenyou Yang
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2016-10-17  1:55 UTC (permalink / raw)
  To: u-boot

Move the config options from the include/configs/sama5d2_xplained.h
to configs/sama5d2_xplained_*_defconfig.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Reviewed-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---

Changes in v3:
 - Collect Reviewed-by tag.

Changes in v2: None

 board/atmel/sama5d2_xplained/sama5d2_xplained.c |  2 ++
 configs/sama5d2_xplained_mmc_defconfig          | 31 ++++++++++++++++++++++++-
 configs/sama5d2_xplained_spiflash_defconfig     | 31 ++++++++++++++++++++++++-
 include/configs/sama5d2_xplained.h              | 25 --------------------
 4 files changed, 62 insertions(+), 27 deletions(-)

diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index 93df7ba..413a000 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -25,10 +25,12 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifndef CONFIG_DM_SPI
 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
 {
 	return bus == 0 && cs == 0;
 }
+#endif
 
 void spi_cs_activate(struct spi_slave *slave)
 {
diff --git a/configs/sama5d2_xplained_mmc_defconfig b/configs/sama5d2_xplained_mmc_defconfig
index 23ab4d6..08ecea6 100644
--- a/configs/sama5d2_xplained_mmc_defconfig
+++ b/configs/sama5d2_xplained_mmc_defconfig
@@ -8,6 +8,9 @@ CONFIG_SPL_FAT_SUPPORT=y
 CONFIG_SPL_LIBDISK_SUPPORT=y
 CONFIG_SPL_MMC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_SERIAL=y
+CONFIG_DEFAULT_DEVICE_TREE="at91-sama5d2_xplained"
 CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2,SYS_USE_MMC"
 CONFIG_BOOTDELAY=3
@@ -21,14 +24,40 @@ CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_DM=y
+CONFIG_SPL_DM=y
+CONFIG_BLK=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_AT91_UTMI=y
+CONFIG_AT91_H32MX=y
+CONFIG_AT91_GENERIC_CLK=y
+CONFIG_ATMEL_PIO4=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_AT91=y
+CONFIG_DM_MMC=y
+CONFIG_DM_MMC_OPS=y
+CONFIG_ATMEL_SDHCI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91PIO4=y
+CONFIG_ATMEL_USART=y
+CONFIG_DM_SPI=y
+CONFIG_ATMEL_SPI=y
 CONFIG_USB=y
 CONFIG_USB_STORAGE=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_ATMEL_USBA=y
-CONFIG_OF_LIBFDT=y
diff --git a/configs/sama5d2_xplained_spiflash_defconfig b/configs/sama5d2_xplained_spiflash_defconfig
index f208dc2..b49d2ad 100644
--- a/configs/sama5d2_xplained_spiflash_defconfig
+++ b/configs/sama5d2_xplained_spiflash_defconfig
@@ -7,6 +7,9 @@ CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_DM_GPIO=y
+CONFIG_DM_SERIAL=y
+CONFIG_DEFAULT_DEVICE_TREE="at91-sama5d2_xplained"
 CONFIG_FIT=y
 CONFIG_SYS_EXTRA_OPTIONS="SAMA5D2,SYS_USE_SERIALFLASH"
 CONFIG_BOOTDELAY=3
@@ -20,14 +23,40 @@ CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_FLASH is not set
 CONFIG_CMD_MMC=y
 CONFIG_CMD_SF=y
+CONFIG_CMD_I2C=y
 CONFIG_CMD_USB=y
 # CONFIG_CMD_FPGA is not set
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_SPL_OF_CONTROL=y
+CONFIG_DM=y
+CONFIG_SPL_DM=y
+CONFIG_BLK=y
+CONFIG_CLK=y
+CONFIG_SPL_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_AT91_UTMI=y
+CONFIG_AT91_H32MX=y
+CONFIG_AT91_GENERIC_CLK=y
+CONFIG_ATMEL_PIO4=y
+CONFIG_DM_I2C=y
+CONFIG_SYS_I2C_AT91=y
+CONFIG_DM_MMC=y
+CONFIG_DM_MMC_OPS=y
+CONFIG_ATMEL_SDHCI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
+CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91PIO4=y
+CONFIG_ATMEL_USART=y
+CONFIG_DM_SPI=y
+CONFIG_ATMEL_SPI=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
+CONFIG_USB_EHCI_HCD=y
 CONFIG_USB_STORAGE=y
 CONFIG_USB_GADGET=y
 CONFIG_USB_GADGET_ATMEL_USBA=y
-CONFIG_OF_LIBFDT=y
diff --git a/include/configs/sama5d2_xplained.h b/include/configs/sama5d2_xplained.h
index e684d2a..399d40f 100644
--- a/include/configs/sama5d2_xplained.h
+++ b/include/configs/sama5d2_xplained.h
@@ -15,11 +15,6 @@
 
 #include "at91-sama5_common.h"
 
-/* serial console */
-#define CONFIG_ATMEL_USART
-#define CONFIG_USART_BASE		ATMEL_BASE_UART1
-#define CONFIG_USART_ID			ATMEL_ID_UART1
-
 /* SDRAM */
 #define CONFIG_NR_DRAM_BANKS		1
 #define CONFIG_SYS_SDRAM_BASE           ATMEL_BASE_DDRCS
@@ -34,14 +29,8 @@
 
 #define CONFIG_SYS_LOAD_ADDR		0x22000000 /* load address */
 
-#undef CONFIG_AT91_GPIO
-#define CONFIG_ATMEL_PIO4
-
 /* SerialFlash */
 #ifdef CONFIG_CMD_SF
-#define CONFIG_ATMEL_SPI
-#define CONFIG_ATMEL_SPI0
-#define CONFIG_SPI_FLASH_ATMEL
 #define CONFIG_SF_DEFAULT_BUS		0
 #define CONFIG_SF_DEFAULT_CS		0
 #define CONFIG_SF_DEFAULT_SPEED		30000000
@@ -51,23 +40,9 @@
 #undef CONFIG_CMD_NAND
 
 /* MMC */
-
 #ifdef CONFIG_CMD_MMC
-#define CONFIG_MMC
 #define CONFIG_GENERIC_MMC
 #define CONFIG_SDHCI
-#define CONFIG_ATMEL_SDHCI
-#define CONFIG_ATMEL_SDHCI0
-#define CONFIG_ATMEL_SDHCI1
-#define CONFIG_SUPPORT_EMMC_BOOT
-#endif
-
-/* USB */
-
-#ifdef CONFIG_CMD_USB
-#define CONFIG_USB_EHCI
-#define CONFIG_USB_EHCI_ATMEL
-#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS	3
 #endif
 
 /* USB device */
-- 
2.7.4

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

* [U-Boot] [PATCH v3 2/4] board: sama5d2_xplained: Clean up code
  2016-10-17  1:55 [U-Boot] [PATCH v3 0/4] board: sama5d2_xplained: Convert to use device tree and drivers with DM Wenyou Yang
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 1/4] board: sama5d2_xplained: Move config options to defconfigs Wenyou Yang
@ 2016-10-17  1:55 ` Wenyou Yang
  2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 3/4] board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC Wenyou Yang
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 4/4] board: sama5d2_xplained: Enable an early debug UART Wenyou Yang
  3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2016-10-17  1:55 UTC (permalink / raw)
  To: u-boot

Since the introduction of pinctrl and clk driver, and the dts file,
remove unneeded the pin configurations and the clock enabling code.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---

Changes in v3:
 - Collect Reviewed-by tag.

Changes in v2: None

 board/atmel/sama5d2_xplained/sama5d2_xplained.c | 104 ------------------------
 1 file changed, 104 deletions(-)

diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index 413a000..7ccadf2 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -25,34 +25,6 @@
 
 DECLARE_GLOBAL_DATA_PTR;
 
-#ifndef CONFIG_DM_SPI
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-	return bus == 0 && cs == 0;
-}
-#endif
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-	atmel_pio4_set_pio_output(AT91_PIO_PORTA, 17, 0);
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-	atmel_pio4_set_pio_output(AT91_PIO_PORTA, 17, 1);
-}
-
-static void board_spi0_hw_init(void)
-{
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 14, 0);
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 15, 0);
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 16, 0);
-
-	atmel_pio4_set_pio_output(AT91_PIO_PORTA, 17, 1);
-
-	at91_periph_clk_enable(ATMEL_ID_SPI0);
-}
-
 static void board_usb_hw_init(void)
 {
 	atmel_pio4_set_pio_output(AT91_PIO_PORTB, 10, 1);
@@ -159,55 +131,6 @@ static void board_gmac_hw_init(void)
 	at91_periph_clk_enable(ATMEL_ID_GMAC);
 }
 
-static void board_sdhci0_hw_init(void)
-{
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 0, 0);	/* SDMMC0_CK */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 1, 0);	/* SDMMC0_CMD */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 2, 0);	/* SDMMC0_DAT0 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 3, 0);	/* SDMMC0_DAT1 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 4, 0);	/* SDMMC0_DAT2 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 5, 0);	/* SDMMC0_DAT3 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 6, 0);	/* SDMMC0_DAT4 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 7, 0);	/* SDMMC0_DAT5 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 8, 0);	/* SDMMC0_DAT6 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 9, 0);	/* SDMMC0_DAT7 */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 10, 0);	/* SDMMC0_RSTN */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 11, 0);	/* SDMMC0_VDDSEL */
-	atmel_pio4_set_a_periph(AT91_PIO_PORTA, 13, 0);	/* SDMMC0_CD */
-
-	at91_periph_clk_enable(ATMEL_ID_SDMMC0);
-	at91_enable_periph_generated_clk(ATMEL_ID_SDMMC0,
-					 GCK_CSS_UPLL_CLK, 1);
-}
-
-static void board_sdhci1_hw_init(void)
-{
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 18, 0);	/* SDMMC1_DAT0 */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 19, 0);	/* SDMMC1_DAT1 */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 20, 0);	/* SDMMC1_DAT2 */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 21, 0);	/* SDMMC1_DAT3 */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 22, 0);	/* SDMMC1_CK */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 27, 0);	/* SDMMC1_RSTN */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 28, 0);	/* SDMMC1_CMD */
-	atmel_pio4_set_e_periph(AT91_PIO_PORTA, 30, 0);	/* SDMMC1_CD */
-
-	at91_periph_clk_enable(ATMEL_ID_SDMMC1);
-	at91_enable_periph_generated_clk(ATMEL_ID_SDMMC1,
-					 GCK_CSS_UPLL_CLK, 1);
-}
-
-int board_mmc_init(bd_t *bis)
-{
-#ifdef CONFIG_ATMEL_SDHCI0
-	atmel_sdhci_init((void *)ATMEL_BASE_SDMMC0, ATMEL_ID_SDMMC0);
-#endif
-#ifdef CONFIG_ATMEL_SDHCI1
-	atmel_sdhci_init((void *)ATMEL_BASE_SDMMC1, ATMEL_ID_SDMMC1);
-#endif
-
-	return 0;
-}
-
 static void board_uart1_hw_init(void)
 {
 	atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, 1);	/* URXD1 */
@@ -218,11 +141,6 @@ static void board_uart1_hw_init(void)
 
 int board_early_init_f(void)
 {
-	at91_periph_clk_enable(ATMEL_ID_PIOA);
-	at91_periph_clk_enable(ATMEL_ID_PIOB);
-	at91_periph_clk_enable(ATMEL_ID_PIOC);
-	at91_periph_clk_enable(ATMEL_ID_PIOD);
-
 	board_uart1_hw_init();
 
 	return 0;
@@ -233,17 +151,6 @@ int board_init(void)
 	/* address of boot parameters */
 	gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
 
-#ifdef CONFIG_ATMEL_SPI
-	board_spi0_hw_init();
-#endif
-#ifdef CONFIG_ATMEL_SDHCI
-#ifdef CONFIG_ATMEL_SDHCI0
-	board_sdhci0_hw_init();
-#endif
-#ifdef CONFIG_ATMEL_SDHCI1
-	board_sdhci1_hw_init();
-#endif
-#endif
 #ifdef CONFIG_MACB
 	board_gmac_hw_init();
 #endif
@@ -289,17 +196,6 @@ int board_eth_init(bd_t *bis)
 #ifdef CONFIG_SPL_BUILD
 void spl_board_init(void)
 {
-#ifdef CONFIG_SYS_USE_SERIALFLASH
-	board_spi0_hw_init();
-#endif
-#ifdef CONFIG_ATMEL_SDHCI
-#ifdef CONFIG_ATMEL_SDHCI0
-	board_sdhci0_hw_init();
-#endif
-#ifdef CONFIG_ATMEL_SDHCI1
-	board_sdhci1_hw_init();
-#endif
-#endif
 }
 
 static void ddrc_conf(struct atmel_mpddrc_config *ddrc)
-- 
2.7.4

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

* [U-Boot] [PATCH v3 3/4] board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC
  2016-10-17  1:55 [U-Boot] [PATCH v3 0/4] board: sama5d2_xplained: Convert to use device tree and drivers with DM Wenyou Yang
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 1/4] board: sama5d2_xplained: Move config options to defconfigs Wenyou Yang
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 2/4] board: sama5d2_xplained: Clean up code Wenyou Yang
@ 2016-10-17  1:55 ` Wenyou Yang
  2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 4/4] board: sama5d2_xplained: Enable an early debug UART Wenyou Yang
  3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2016-10-17  1:55 UTC (permalink / raw)
  To: u-boot

If 'ethaddr' is not set, we will get the ethernet address from AT24MAC,
and set it to 'ethaddr' variable.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Signed-off-by: Songjun Wu <songjun.wu@microchip.com>
Reviewed-by: Andreas Bie?mann <biessmann@corscience.de>
---

Changes in v3:
 - Collect Reviewed-by tag.
 - Rename CONFIG_AT24MAC_ADDR and CONFIG_AT24MAC_REG to AT24MAC_ADDR
   and AT24MAC_REG,  removing the prefix CONFIG_, to avoid compile
   warning.

Changes in v2: None

 board/atmel/sama5d2_xplained/sama5d2_xplained.c | 51 +++++++++++++++++++++++++
 include/configs/sama5d2_xplained.h              |  6 +++
 2 files changed, 57 insertions(+)

diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index 7ccadf2..cceccd2 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -7,6 +7,8 @@
 
 #include <common.h>
 #include <atmel_hlcdc.h>
+#include <dm.h>
+#include <i2c.h>
 #include <lcd.h>
 #include <mmc.h>
 #include <net.h>
@@ -192,6 +194,55 @@ int board_eth_init(bd_t *bis)
 	return rc;
 }
 
+#ifdef CONFIG_CMD_I2C
+static int set_ethaddr_from_eeprom(void)
+{
+	const int ETH_ADDR_LEN = 6;
+	unsigned char ethaddr[ETH_ADDR_LEN];
+	const char *ETHADDR_NAME = "ethaddr";
+	struct udevice *bus, *dev;
+
+	if (getenv(ETHADDR_NAME))
+		return 0;
+
+	if (uclass_get_device_by_seq(UCLASS_I2C, 1, &bus)) {
+		printf("Cannot find I2C bus 1\n");
+		return -1;
+	}
+
+	if (dm_i2c_probe(bus, AT24MAC_ADDR, 0, &dev)) {
+		printf("Failed to probe I2C chip\n");
+		return -1;
+	}
+
+	if (dm_i2c_read(dev, AT24MAC_REG, ethaddr, ETH_ADDR_LEN)) {
+		printf("Failed to read ethernet address from EEPROM\n");
+		return -1;
+	}
+
+	if (!is_valid_ethaddr(ethaddr)) {
+		printf("The ethernet address read from EEPROM is not valid!\n");
+		return -1;
+	}
+
+	return eth_setenv_enetaddr(ETHADDR_NAME, ethaddr);
+}
+#else
+static int set_ethaddr_from_eeprom(void)
+{
+	return 0;
+}
+#endif
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+	set_ethaddr_from_eeprom();
+
+	return 0;
+}
+#endif
+
 /* SPL */
 #ifdef CONFIG_SPL_BUILD
 void spl_board_init(void)
diff --git a/include/configs/sama5d2_xplained.h b/include/configs/sama5d2_xplained.h
index 399d40f..c3515cc 100644
--- a/include/configs/sama5d2_xplained.h
+++ b/include/configs/sama5d2_xplained.h
@@ -15,6 +15,8 @@
 
 #include "at91-sama5_common.h"
 
+#define CONFIG_MISC_INIT_R
+
 /* SDRAM */
 #define CONFIG_NR_DRAM_BANKS		1
 #define CONFIG_SYS_SDRAM_BASE           ATMEL_BASE_DDRCS
@@ -54,6 +56,10 @@
 #define CONFIG_DOS_PARTITION
 #endif
 
+/* I2C */
+#define AT24MAC_ADDR		0x5c
+#define AT24MAC_REG		0x9a
+
 /* Ethernet Hardware */
 #define CONFIG_MACB
 #define CONFIG_RMII
-- 
2.7.4

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

* [U-Boot] [PATCH v3 4/4] board: sama5d2_xplained: Enable an early debug UART
  2016-10-17  1:55 [U-Boot] [PATCH v3 0/4] board: sama5d2_xplained: Convert to use device tree and drivers with DM Wenyou Yang
                   ` (2 preceding siblings ...)
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 3/4] board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC Wenyou Yang
@ 2016-10-17  1:55 ` Wenyou Yang
  2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
  3 siblings, 1 reply; 9+ messages in thread
From: Wenyou Yang @ 2016-10-17  1:55 UTC (permalink / raw)
  To: u-boot

Enable an early debug UART to debug problems when an ICE or other
debug mechanism is not available.

Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Andreas Bie?mann <andreas.devel@googlemail.com>
---

Changes in v3:
 - Collect Reviewed-by tag.

Changes in v2:
 - Collect Reviewed-by tags.

 board/atmel/sama5d2_xplained/sama5d2_xplained.c | 14 ++++++++++++++
 configs/sama5d2_xplained_mmc_defconfig          |  6 ++++++
 configs/sama5d2_xplained_spiflash_defconfig     |  6 ++++++
 include/configs/sama5d2_xplained.h              |  2 ++
 4 files changed, 28 insertions(+)

diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index cceccd2..c5337af 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -7,6 +7,7 @@
 
 #include <common.h>
 #include <atmel_hlcdc.h>
+#include <debug_uart.h>
 #include <dm.h>
 #include <i2c.h>
 #include <lcd.h>
@@ -141,12 +142,25 @@ static void board_uart1_hw_init(void)
 	at91_periph_clk_enable(ATMEL_ID_UART1);
 }
 
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+	board_uart1_hw_init();
+}
+#endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
+#ifdef CONFIG_DEBUG_UART
+	debug_uart_init();
+#else
 	board_uart1_hw_init();
+#endif
 
 	return 0;
 }
+#endif
 
 int board_init(void)
 {
diff --git a/configs/sama5d2_xplained_mmc_defconfig b/configs/sama5d2_xplained_mmc_defconfig
index 08ecea6..8a786f1 100644
--- a/configs/sama5d2_xplained_mmc_defconfig
+++ b/configs/sama5d2_xplained_mmc_defconfig
@@ -52,6 +52,12 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91PIO4=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ATMEL=y
+CONFIG_DEBUG_UART_BASE=0xf8020000
+CONFIG_DEBUG_UART_CLOCK=0
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_ATMEL_USART=y
 CONFIG_DM_SPI=y
 CONFIG_ATMEL_SPI=y
diff --git a/configs/sama5d2_xplained_spiflash_defconfig b/configs/sama5d2_xplained_spiflash_defconfig
index b49d2ad..51594e7 100644
--- a/configs/sama5d2_xplained_spiflash_defconfig
+++ b/configs/sama5d2_xplained_spiflash_defconfig
@@ -51,6 +51,12 @@ CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91PIO4=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ATMEL=y
+CONFIG_DEBUG_UART_BASE=0xf8020000
+CONFIG_DEBUG_UART_CLOCK=0
+CONFIG_DEBUG_UART_BOARD_INIT=y
+CONFIG_DEBUG_UART_ANNOUNCE=y
 CONFIG_ATMEL_USART=y
 CONFIG_DM_SPI=y
 CONFIG_ATMEL_SPI=y
diff --git a/include/configs/sama5d2_xplained.h b/include/configs/sama5d2_xplained.h
index c3515cc..bef478d 100644
--- a/include/configs/sama5d2_xplained.h
+++ b/include/configs/sama5d2_xplained.h
@@ -15,6 +15,8 @@
 
 #include "at91-sama5_common.h"
 
+#define CONFIG_BOARD_EARLY_INIT_F
+
 #define CONFIG_MISC_INIT_R
 
 /* SDRAM */
-- 
2.7.4

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

* [U-Boot] [U-Boot, v3, 1/4] board: sama5d2_xplained: Move config options to defconfigs
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 1/4] board: sama5d2_xplained: Move config options to defconfigs Wenyou Yang
@ 2016-10-28 16:49   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2016-10-28 16:49 UTC (permalink / raw)
  To: u-boot

Dear Wenyou Yang,

Wenyou Yang <wenyou.yang@atmel.com> writes:
>Move the config options from the include/configs/sama5d2_xplained.h
>to configs/sama5d2_xplained_*_defconfig.
>
>Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
>Reviewed-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>---
>
>Changes in v3:
> - Collect Reviewed-by tag.
>
>Changes in v2: None
>
> board/atmel/sama5d2_xplained/sama5d2_xplained.c |  2 ++
> configs/sama5d2_xplained_mmc_defconfig          | 31 ++++++++++++++++++++++++-
> configs/sama5d2_xplained_spiflash_defconfig     | 31 ++++++++++++++++++++++++-
> include/configs/sama5d2_xplained.h              | 25 --------------------
> 4 files changed, 62 insertions(+), 27 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

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

* [U-Boot] [U-Boot, v3, 2/4] board: sama5d2_xplained: Clean up code
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 2/4] board: sama5d2_xplained: Clean up code Wenyou Yang
@ 2016-10-28 16:49   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2016-10-28 16:49 UTC (permalink / raw)
  To: u-boot

Dear Wenyou Yang,

Wenyou Yang <wenyou.yang@atmel.com> writes:
>Since the introduction of pinctrl and clk driver, and the dts file,
>remove unneeded the pin configurations and the clock enabling code.
>
>Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
>Reviewed-by: Simon Glass <sjg@chromium.org>
>Reviewed-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>---
>
>Changes in v3:
> - Collect Reviewed-by tag.
>
>Changes in v2: None
>
> board/atmel/sama5d2_xplained/sama5d2_xplained.c | 104 ------------------------
> 1 file changed, 104 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

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

* [U-Boot] [U-Boot, v3, 3/4] board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 3/4] board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC Wenyou Yang
@ 2016-10-28 16:49   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2016-10-28 16:49 UTC (permalink / raw)
  To: u-boot

Dear Wenyou Yang,

Wenyou Yang <wenyou.yang@atmel.com> writes:
>If 'ethaddr' is not set, we will get the ethernet address from AT24MAC,
>and set it to 'ethaddr' variable.
>
>Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
>Signed-off-by: Songjun Wu <songjun.wu@microchip.com>
>Reviewed-by: Andreas Bie?mann <biessmann@corscience.de>
>---
>
>Changes in v3:
> - Collect Reviewed-by tag.
> - Rename CONFIG_AT24MAC_ADDR and CONFIG_AT24MAC_REG to AT24MAC_ADDR
>   and AT24MAC_REG,  removing the prefix CONFIG_, to avoid compile
>   warning.
>
>Changes in v2: None
>
> board/atmel/sama5d2_xplained/sama5d2_xplained.c | 51 +++++++++++++++++++++++++
> include/configs/sama5d2_xplained.h              |  6 +++
> 2 files changed, 57 insertions(+)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

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

* [U-Boot] [U-Boot, v3, 4/4] board: sama5d2_xplained: Enable an early debug UART
  2016-10-17  1:55 ` [U-Boot] [PATCH v3 4/4] board: sama5d2_xplained: Enable an early debug UART Wenyou Yang
@ 2016-10-28 16:49   ` Andreas Bießmann
  0 siblings, 0 replies; 9+ messages in thread
From: Andreas Bießmann @ 2016-10-28 16:49 UTC (permalink / raw)
  To: u-boot

Dear Wenyou Yang,

Wenyou Yang <wenyou.yang@atmel.com> writes:
>Enable an early debug UART to debug problems when an ICE or other
>debug mechanism is not available.
>
>Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
>Reviewed-by: Simon Glass <sjg@chromium.org>
>Reviewed-by: Andreas Bie?mann <andreas.devel@googlemail.com>
>---
>
>Changes in v3:
> - Collect Reviewed-by tag.
>
>Changes in v2:
> - Collect Reviewed-by tags.
>
> board/atmel/sama5d2_xplained/sama5d2_xplained.c | 14 ++++++++++++++
> configs/sama5d2_xplained_mmc_defconfig          |  6 ++++++
> configs/sama5d2_xplained_spiflash_defconfig     |  6 ++++++
> include/configs/sama5d2_xplained.h              |  2 ++
> 4 files changed, 28 insertions(+)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

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

end of thread, other threads:[~2016-10-28 16:49 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-17  1:55 [U-Boot] [PATCH v3 0/4] board: sama5d2_xplained: Convert to use device tree and drivers with DM Wenyou Yang
2016-10-17  1:55 ` [U-Boot] [PATCH v3 1/4] board: sama5d2_xplained: Move config options to defconfigs Wenyou Yang
2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2016-10-17  1:55 ` [U-Boot] [PATCH v3 2/4] board: sama5d2_xplained: Clean up code Wenyou Yang
2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2016-10-17  1:55 ` [U-Boot] [PATCH v3 3/4] board: sama5d2_xplained: Set 'ethaddr' got from AT24MAC Wenyou Yang
2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann
2016-10-17  1:55 ` [U-Boot] [PATCH v3 4/4] board: sama5d2_xplained: Enable an early debug UART Wenyou Yang
2016-10-28 16:49   ` [U-Boot] [U-Boot, v3, " Andreas Bießmann

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.