Skip to contentSkip to conversation

board: at91sam9n12ek: convert the board to support DM and DT

PATCH Superseded Wenyou Yang 1 participant 5 messages Feb 28, 2017

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover board: at91sam9n12ek: convert the board to support DM and DT

The purpose of the patch set is to convert the board to support the Driver Model and the Device Tree.

Wenyou Yang (4):
ARM: dts: at91: add dts files for at91sam9n12ek
configs: at91sam9n12ek: update for DT and DM support
board: at91sam9n12ek: clean up code
board: at91sam9n12ek: enable early debug UART

 arch/arm/dts/Makefile                     |    2 +
 arch/arm/dts/at91sam9n12.dtsi             | 1051 +++++++++++++++++++++++++++++
 arch/arm/dts/at91sam9n12ek.dts            |  263 ++++++++
 board/atmel/at91sam9n12ek/at91sam9n12ek.c |   65 +-
 configs/at91sam9n12ek_mmc_defconfig       |   24 +-
 configs/at91sam9n12ek_nandflash_defconfig |   24 +-
 configs/at91sam9n12ek_spiflash_defconfig  |   31 +-
 include/configs/at91sam9n12ek.h           |   17 -
 8 files changed, 1399 insertions(+), 78 deletions(-)
 create mode 100644 arch/arm/dts/at91sam9n12.dtsi
 create mode 100644 arch/arm/dts/at91sam9n12ek.dts
Signature · 1 line
2.11.0
#1 lore raw

PATCH 1/4 ARM: dts: at91: add dts files for at91sam9n12ek

The device tree source files of at91sam9n12ek boards are copied from the Linux v4.10, do the changes as below.
- Add the reg property for the pinctrl node.
- Move the gpio (pioA, pioB, pioC, pioD) nodes as the pinctrl's slibling nodes, instead of the child nodes.
- Add spi0 aliases.
- Change the compatible of the spi flash to "spi-flash".
- Fix the pinctrl-names of mmc0 node.
- Fix the compilation warnings.

---

 arch/arm/dts/Makefile          |    2 +
 arch/arm/dts/at91sam9n12.dtsi  | 1051 ++++++++++++++++++++++++++++++++++++++++
 arch/arm/dts/at91sam9n12ek.dts |  263 ++++++++++
 3 files changed, 1316 insertions(+)
 create mode 100644 arch/arm/dts/at91sam9n12.dtsi
 create mode 100644 arch/arm/dts/at91sam9n12ek.dts
arch/arm/dts/Makefile +2 -0
index 76dc6562ed..b77948078a 100644
@@ -337,6 +337,8 @@ dtb-$(CONFIG_TARGET_AT91SAM9X5EK) += \
 	at91sam9x25ek.dtb	\
 	at91sam9x35ek.dtb
 
+dtb-$(CONFIG_TARGET_AT91SAM9N12EK) += at91sam9n12ek.dtb
+
 dtb-$(CONFIG_TARGET_SAMA5D2_XPLAINED) += \
 	at91-sama5d2_xplained.dtb
 
arch/arm/dts/at91sam9n12.dtsi new file +1051 -0

1,051 lines not on this page · raw message

arch/arm/dts/at91sam9n12ek.dts new file +263 -0

263 lines not on this page · raw message

Signature · 1 line
2.11.0
#2 lore raw

PATCH 2/4 configs: at91sam9n12ek: update for DT and DM support

In reply to Wenyou Yang

Support the device tree and enable CONFIG_CLK and CONFIG_PINCTRL options to support at91 clock driver and at91 pinctrl driver.

Enable DM_GPIO, DM_MMC and DM_SPI support, move CONFIG_AT91_GPIO, CONFIG_GENERIC_ATMEL_MCI and CONFIG_ATMEL_SPI config option to the default config files.

Due to the limitation of internal SRAM size, disable the CONFIG_SPL config option for the spi flash configuration.

---

 board/atmel/at91sam9n12ek/at91sam9n12ek.c |  2 ++
 configs/at91sam9n12ek_mmc_defconfig       | 18 +++++++++++++++++-
 configs/at91sam9n12ek_nandflash_defconfig | 18 +++++++++++++++++-
 configs/at91sam9n12ek_spiflash_defconfig  | 25 +++++++++++++++++--------
 include/configs/at91sam9n12ek.h           | 17 -----------------
 5 files changed, 53 insertions(+), 27 deletions(-)
board/atmel/at91sam9n12ek/at91sam9n12ek.c +2 -0
index 58da2d27f8..e3f9cbbe50 100644
@@ -133,6 +133,7 @@ void lcd_show_board_info(void)
 #endif /* CONFIG_LCD */
 
 /* SPI chip select control */
+#ifndef CONFIG_DM_SPI
 #ifdef CONFIG_ATMEL_SPI
 #include <spi.h>
 int spi_cs_is_valid(unsigned int bus, unsigned int cs)
@@ -164,6 +165,7 @@ void spi_cs_deactivate(struct spi_slave *slave)
 	}
 }
 #endif /* CONFIG_ATMEL_SPI */
+#endif
 
 #ifdef CONFIG_GENERIC_ATMEL_MCI
 int board_mmc_init(bd_t *bd)
configs/at91sam9n12ek_mmc_defconfig +17 -1
index ef9250bce9..8fe19c0c55 100644
@@ -1,6 +1,7 @@
 CONFIG_ARM=y
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_AT91SAM9N12EK=y
+CONFIG_DEFAULT_DEVICE_TREE="at91sam9n12ek"
 CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9N12,SYS_USE_MMC"
 CONFIG_BOOTDELAY=3
 # CONFIG_CONSOLE_MUX is not set
@@ -19,9 +20,24 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_DM_GPIO=y
+CONFIG_AT91_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_GENERIC_ATMEL_MCI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91=y
+CONFIG_DM_SERIAL=y
+CONFIG_ATMEL_USART=y
+CONFIG_DM_SPI=y
+CONFIG_ATMEL_SPI=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_LCD=y
-CONFIG_OF_LIBFDT=y
configs/at91sam9n12ek_nandflash_defconfig +17 -1
index da0ea60e8b..1acacbddc2 100644
@@ -6,6 +6,7 @@ CONFIG_SPL_LIBCOMMON_SUPPORT=y
 CONFIG_SPL_LIBGENERIC_SUPPORT=y
 CONFIG_SPL_NAND_SUPPORT=y
 CONFIG_SPL_SERIAL_SUPPORT=y
+CONFIG_DEFAULT_DEVICE_TREE="at91sam9n12ek"
 CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9N12,SYS_USE_NANDFLASH"
 CONFIG_BOOTDELAY=3
 # CONFIG_CONSOLE_MUX is not set
@@ -25,9 +26,24 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_DM_GPIO=y
+CONFIG_AT91_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_GENERIC_ATMEL_MCI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91=y
+CONFIG_DM_SERIAL=y
+CONFIG_ATMEL_USART=y
+CONFIG_DM_SPI=y
+CONFIG_ATMEL_SPI=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_LCD=y
-CONFIG_OF_LIBFDT=y
configs/at91sam9n12ek_spiflash_defconfig +17 -8
index 4e5d10226e..74457861b6 100644
@@ -1,18 +1,12 @@
 CONFIG_ARM=y
 CONFIG_ARCH_AT91=y
 CONFIG_TARGET_AT91SAM9N12EK=y
-CONFIG_SPL_GPIO_SUPPORT=y
-CONFIG_SPL_LIBCOMMON_SUPPORT=y
-CONFIG_SPL_LIBGENERIC_SUPPORT=y
-CONFIG_SPL_SERIAL_SUPPORT=y
-CONFIG_SPL_SPI_FLASH_SUPPORT=y
-CONFIG_SPL_SPI_SUPPORT=y
+CONFIG_DEFAULT_DEVICE_TREE="at91sam9n12ek"
 CONFIG_SYS_EXTRA_OPTIONS="AT91SAM9N12,SYS_USE_SPIFLASH"
 CONFIG_BOOTDELAY=3
 # CONFIG_CONSOLE_MUX is not set
 CONFIG_SYS_CONSOLE_IS_IN_ENV=y
 # CONFIG_DISPLAY_BOARDINFO is not set
-CONFIG_SPL=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PROMPT="U-Boot> "
 CONFIG_CMD_BOOTZ=y
@@ -26,9 +20,24 @@ CONFIG_CMD_USB=y
 CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_CMD_FAT=y
+CONFIG_OF_CONTROL=y
+CONFIG_DM=y
+CONFIG_CLK=y
+CONFIG_CLK_AT91=y
+CONFIG_DM_GPIO=y
+CONFIG_AT91_GPIO=y
+CONFIG_DM_MMC=y
+CONFIG_GENERIC_ATMEL_MCI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_ATMEL=y
+CONFIG_PINCTRL=y
+CONFIG_PINCTRL_AT91=y
+CONFIG_DM_SERIAL=y
+CONFIG_ATMEL_USART=y
+CONFIG_DM_SPI=y
+CONFIG_ATMEL_SPI=y
 CONFIG_USB=y
+CONFIG_DM_USB=y
 CONFIG_USB_STORAGE=y
 CONFIG_LCD=y
-CONFIG_OF_LIBFDT=y
include/configs/at91sam9n12ek.h +0 -17
index c4ac21d351..f1a4e35e17 100644
@@ -28,11 +28,7 @@
 #define CONFIG_INITRD_TAG
 #define CONFIG_SKIP_LOWLEVEL_INIT
 
-/* general purpose I/O */
-#define CONFIG_AT91_GPIO
-
 /* serial console */
-#define CONFIG_ATMEL_USART
 #define CONFIG_USART_BASE		ATMEL_BASE_DBGU
 #define CONFIG_USART_ID			ATMEL_ID_SYS
 #define CONFIG_BAUDRATE			115200
@@ -76,14 +72,6 @@
 # define CONFIG_SYS_INIT_SP_ADDR \
 	(ATMEL_BASE_SRAM + 0x1000 - GENERATED_GBL_DATA_SIZE)
 
-/* DataFlash */
-#ifdef CONFIG_CMD_SF
-#define CONFIG_ATMEL_SPI
-#define CONFIG_SF_DEFAULT_SPEED		30000000
-#define CONFIG_ENV_SPI_MODE		SPI_MODE_3
-#define CONFIG_SF_DEFAULT_MODE		SPI_MODE_3
-#endif
-
 /* NAND flash */
 #ifdef CONFIG_CMD_NAND
 #define CONFIG_NAND_ATMEL
@@ -120,11 +108,6 @@
 	"bootargs_nand=rootfstype=ubifs ubi.mtd=7 root=ubi0:rootfs rw\0"\
 	"bootargs_mmc=root=/dev/mmcblk0p2 rw rootfstype=ext4 rootwait\0"
 
-/* MMC */
-#ifdef CONFIG_CMD_MMC
-#define CONFIG_GENERIC_ATMEL_MCI
-#endif
-
 /* Ethernet */
 #define CONFIG_KS8851_MLL
 #define CONFIG_KS8851_MLL_BASEADDR	0x30000000 /* use NCS2 */
Signature · 1 line
2.11.0
#3 lore raw

PATCH 3/4 board: at91sam9n12ek: clean up code

In reply to Wenyou Yang

Since the introduction of the pinctrl and clk driver and the dts file, remove unneeded hard coded related code from the board file.

---

 board/atmel/at91sam9n12ek/at91sam9n12ek.c | 53 -------------------------------
 1 file changed, 53 deletions(-)
board/atmel/at91sam9n12ek/at91sam9n12ek.c +0 -53
index e3f9cbbe50..8a17bb3bbe 100644
@@ -15,8 +15,6 @@
 #include <asm/arch/clk.h>
 #include <lcd.h>
 #include <atmel_hlcdc.h>
-#include <atmel_mci.h>
-#include <netdev.h>
 
 #ifdef CONFIG_LCD_INFO
 #include <nand.h>
@@ -132,50 +130,6 @@ void lcd_show_board_info(void)
 #endif /* CONFIG_LCD_INFO */
 #endif /* CONFIG_LCD */
 
-/* SPI chip select control */
-#ifndef CONFIG_DM_SPI
-#ifdef CONFIG_ATMEL_SPI
-#include <spi.h>
-int spi_cs_is_valid(unsigned int bus, unsigned int cs)
-{
-	return bus == 0 && cs < 2;
-}
-
-void spi_cs_activate(struct spi_slave *slave)
-{
-	switch (slave->cs) {
-	case 0:
-		at91_set_pio_output(AT91_PIO_PORTA, 14, 0);
-		break;
-	case 1:
-		at91_set_pio_output(AT91_PIO_PORTA, 7, 0);
-		break;
-	}
-}
-
-void spi_cs_deactivate(struct spi_slave *slave)
-{
-	switch (slave->cs) {
-	case 0:
-		at91_set_pio_output(AT91_PIO_PORTA, 14, 1);
-		break;
-	case 1:
-		at91_set_pio_output(AT91_PIO_PORTA, 7, 1);
-		break;
-	}
-}
-#endif /* CONFIG_ATMEL_SPI */
-#endif
-
-#ifdef CONFIG_GENERIC_ATMEL_MCI
-int board_mmc_init(bd_t *bd)
-{
-	at91_mci_hw_init();
-
-	return atmel_mci_init((void *)ATMEL_BASE_HSMCI0);
-}
-#endif
-
 #ifdef CONFIG_KS8851_MLL
 void at91sam9n12ek_ks8851_hw_init(void)
 {
@@ -209,9 +163,6 @@ void at91sam9n12ek_usb_hw_init(void)
 
 int board_early_init_f(void)
 {
-	at91_periph_clk_enable(ATMEL_ID_PIOAB);
-	at91_periph_clk_enable(ATMEL_ID_PIOCD);
-
 	at91_seriald_hw_init();
 	return 0;
 }
@@ -225,10 +176,6 @@ int board_init(void)
 	at91sam9n12ek_nand_hw_init();
 #endif
 
-#ifdef CONFIG_ATMEL_SPI
-	at91_spi0_hw_init(1 << 0);
-#endif
-
 #ifdef CONFIG_LCD
 	at91_lcd_hw_init();
 #endif
Signature · 1 line
2.11.0
#4 lore raw

PATCH 4/4 board: at91sam9n12ek: enable early debug UART

In reply to Wenyou Yang

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

---

 board/atmel/at91sam9n12ek/at91sam9n12ek.c | 14 ++++++++++++++
 configs/at91sam9n12ek_mmc_defconfig       |  6 ++++++
 configs/at91sam9n12ek_nandflash_defconfig |  6 ++++++
 configs/at91sam9n12ek_spiflash_defconfig  |  6 ++++++
 4 files changed, 32 insertions(+)
board/atmel/at91sam9n12ek/at91sam9n12ek.c +14 -0
index 8a17bb3bbe..bd483c1836 100644
@@ -13,6 +13,7 @@
 #include <asm/arch/at91_rstc.h>
 #include <asm/arch/at91_pio.h>
 #include <asm/arch/clk.h>
+#include <debug_uart.h>
 #include <lcd.h>
 #include <atmel_hlcdc.h>
 
@@ -161,11 +162,24 @@ void at91sam9n12ek_usb_hw_init(void)
 }
 #endif
 
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+void board_debug_uart_init(void)
+{
+	at91_seriald_hw_init();
+}
+#endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
 int board_early_init_f(void)
 {
+#ifdef CONFIG_DEBUG_UART
+	debug_uart_init();
+#else
 	at91_seriald_hw_init();
+#endif
 	return 0;
 }
+#endif
 
 int board_init(void)
 {
configs/at91sam9n12ek_mmc_defconfig +6 -0
index 8fe19c0c55..89232987cd 100644
@@ -34,6 +34,12 @@ CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ATMEL=y
+CONFIG_DEBUG_UART_BASE=0xfffff200
+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
configs/at91sam9n12ek_nandflash_defconfig +6 -0
index 1acacbddc2..5a6eff409e 100644
@@ -40,6 +40,12 @@ CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ATMEL=y
+CONFIG_DEBUG_UART_BASE=0xfffff200
+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
configs/at91sam9n12ek_spiflash_defconfig +6 -0
index 74457861b6..10650a3ae2 100644
@@ -34,6 +34,12 @@ CONFIG_SPI_FLASH_ATMEL=y
 CONFIG_PINCTRL=y
 CONFIG_PINCTRL_AT91=y
 CONFIG_DM_SERIAL=y
+CONFIG_DEBUG_UART=y
+CONFIG_DEBUG_UART_ATMEL=y
+CONFIG_DEBUG_UART_BASE=0xfffff200
+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
Signature · 1 line
2.11.0