mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/5] Enable DT support for AT91SAM9263EK
@ 2017-12-27 21:17 Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 1/5] at91sam9263ek: enable multi-image build Sam Ravnborg
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-27 21:17 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

This patchset enabledevice tree support for AT91SAM9263EK.

On the quest towards getting so far several drivers was
converted to support DT.
These patches went in around august.

There was also issues with mach-at91 calling code
in the board directory (dependency in the
wrong direction).
This was fixed in "at91: move reset .." which is
pending (already posted).

I have failed to get the bootstrap mode to work.
It stops somewhere - and I have not invested enough
time to figure out where and why things goes wrong.
bootstrap mode was also broken before these patches.
No JTAG debugger available to help me.
And then I have at91bootstrap that works so motivation
was not too high.

I do not think the NAND support works either.
The device tree introduces some nand-controller
stuff that is not supported by barebox (at least I assume so).
And this part I did not look further into.

Next step is to get a proprietary board up and
running (which uses NOR flash).
But I wanted this patchset out in the open first.

Any fedback highly appreciated!

	Sam

Sam Ravnborg (5):
      at91sam9263ek: enable multi-image build
      at91sam9263ek: add DT file from Linux kernel v4.14-rc4
      at91sam9263ek: fix SD card in DT
      arm: at91: enable CPU specific init with OF
      at91sam9263ek: enable devicetree

 arch/arm/boards/at91sam9263ek/Makefile        |   5 +
 arch/arm/boards/at91sam9263ek/lowlevel_init.c |  24 ++-
 arch/arm/boards/at91sam9263ek/of_init.c       |  98 ++++++++++
 arch/arm/configs/at91sam9263ek_defconfig      |  10 +-
 arch/arm/dts/Makefile                         |   2 +-
 arch/arm/dts/at91sam9263ek.dts                | 253 ++++++++++++++++++++++++++
 arch/arm/mach-at91/Kconfig                    |  30 ++-
 arch/arm/mach-at91/at91sam9263.c              |   8 +
 arch/arm/mach-at91/generic.h                  |   4 +
 arch/arm/mach-at91/setup.c                    |   6 -
 images/Makefile.at91                          |   4 +
 11 files changed, 424 insertions(+), 20 deletions(-)

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 1/5] at91sam9263ek: enable multi-image build
  2017-12-27 21:17 [PATCH 0/5] Enable DT support for AT91SAM9263EK Sam Ravnborg
@ 2017-12-27 21:18 ` Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 2/5] at91sam9263ek: add DT file from Linux kernel v4.14-rc4 Sam Ravnborg
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-27 21:18 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

Convert at91sam9263ek to multi-image build as we already do
for many of the i.MX based boards and recently for
the at91sam9x5ek board.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/boards/at91sam9263ek/lowlevel_init.c |  2 +-
 arch/arm/configs/at91sam9263ek_defconfig      |  4 +++-
 arch/arm/mach-at91/Kconfig                    | 20 ++++++++++++--------
 images/Makefile.at91                          |  4 ++++
 4 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/arch/arm/boards/at91sam9263ek/lowlevel_init.c b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
index 70e0da3b1..3138bc7ca 100644
--- a/arch/arm/boards/at91sam9263ek/lowlevel_init.c
+++ b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
@@ -115,7 +115,7 @@ static void __bare_init at91sam9263ek_init(void)
 	                  NULL);
 }
 
-void __naked __bare_init barebox_arm_reset_vector(void)
+ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
 {
 	arm_cpu_lowlevel_init();
 
diff --git a/arch/arm/configs/at91sam9263ek_defconfig b/arch/arm/configs/at91sam9263ek_defconfig
index b28614d43..fc92615eb 100644
--- a/arch/arm/configs/at91sam9263ek_defconfig
+++ b/arch/arm/configs/at91sam9263ek_defconfig
@@ -1,10 +1,12 @@
 CONFIG_ARCH_AT91SAM9263=y
+CONFIG_AT91_MULTI_BOARDS=y
+CONFIG_MACH_AT91SAM9263EK=y
 CONFIG_BAREBOX_MAX_IMAGE_SIZE=0x40000
 CONFIG_ARM_OPTIMZED_STRING_FUNCTIONS=y
-CONFIG_PBL_IMAGE=y
 CONFIG_MMU=y
 CONFIG_EXPERIMENTAL=y
 CONFIG_MALLOC_TLSF=y
+CONFIG_RELOCATABLE=y
 CONFIG_PROMPT="9263-EK:"
 CONFIG_GLOB=y
 CONFIG_HUSH_FANCY_PROMPT=y
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index b877c269d..f5160ade1 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -228,6 +228,8 @@ config SUPPORT_CALAO_DAB_MMX
 config SUPPORT_CALAO_MOB_TNY_MD2
 	bool
 
+if !AT91_MULTI_BOARDS
+
 # ----------------------------------------------------------
 
 if ARCH_AT91RM9200
@@ -399,14 +401,6 @@ if ARCH_AT91SAM9263
 choice
 	prompt "AT91SAM9263 Board Type"
 
-config MACH_AT91SAM9263EK
-	bool "Atmel AT91SAM9263-EK"
-	select HAVE_NAND_ATMEL_BUSWIDTH_16
-	select HAVE_AT91_BOOTSTRAP
-	select AT91SAM926X_BOARD_INIT
-	help
-	  Say y here if you are using Atmel's AT91SAM9263-EK Evaluation board
-
 config MACH_MMCCPU
 	bool "Bucyrus MMC-CPU"
 	help
@@ -523,6 +517,7 @@ config MACH_SAMA5D4_XPLAINED
 endchoice
 
 endif
+endif
 
 # ----------------------------------------------------------
 
@@ -533,6 +528,15 @@ config AT91_MULTI_BOARDS
 
 if AT91_MULTI_BOARDS
 
+config MACH_AT91SAM9263EK
+	bool "Atmel AT91SAM9263-EK"
+	depends on ARCH_AT91SAM9263
+	select HAVE_NAND_ATMEL_BUSWIDTH_16
+	select HAVE_AT91_BOOTSTRAP
+	select AT91SAM926X_BOARD_INIT
+	help
+	  Say y here if you are using Atmel's AT91SAM9263-EK Evaluation board
+
 config MACH_AT91SAM9X5EK
 	bool "Atmel AT91SAM9x5 Series Evaluation Kit"
 	depends on ARCH_AT91SAM9X5
diff --git a/images/Makefile.at91 b/images/Makefile.at91
index dc6c1db4b..c7d86563a 100644
--- a/images/Makefile.at91
+++ b/images/Makefile.at91
@@ -5,3 +5,7 @@
 pblx-$(CONFIG_MACH_AT91SAM9X5EK) += start_at91sam9x5ek
 FILE_barebox-at91sam9x5ek.img = start_at91sam9x5ek.pblx
 image-$(CONFIG_MACH_AT91SAM9X5EK) += barebox-at91sam9x5ek.img
+
+pblx-$(CONFIG_MACH_AT91SAM9263EK) += start_at91sam9263ek
+FILE_barebox-at91sam9263ek.img = start_at91sam9263ek.pblx
+image-$(CONFIG_MACH_AT91SAM9263EK) += barebox-at91sam9263ek.img
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 2/5] at91sam9263ek: add DT file from Linux kernel v4.14-rc4
  2017-12-27 21:17 [PATCH 0/5] Enable DT support for AT91SAM9263EK Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 1/5] at91sam9263ek: enable multi-image build Sam Ravnborg
@ 2017-12-27 21:18 ` Sam Ravnborg
  2017-12-30  2:13   ` Andrey Smirnov
  2017-12-27 21:18 ` [PATCH 3/5] at91sam9263ek: fix SD card in DT Sam Ravnborg
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-27 21:18 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

Include the at91sam9263ek.dts file from
linux kernel v4.14-rc4 and wire it up in the build.

Prepare at91sam9263ek lowlevel_init.c to use DT.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/boards/at91sam9263ek/lowlevel_init.c |  22 ++-
 arch/arm/dts/Makefile                         |   2 +-
 arch/arm/dts/at91sam9263ek.dts                | 246 ++++++++++++++++++++++++++
 arch/arm/mach-at91/Kconfig                    |   7 +
 4 files changed, 273 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/at91sam9263ek.dts

diff --git a/arch/arm/boards/at91sam9263ek/lowlevel_init.c b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
index 3138bc7ca..86d7a79e9 100644
--- a/arch/arm/boards/at91sam9263ek/lowlevel_init.c
+++ b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
@@ -99,7 +99,7 @@ static void __bare_init at91sam9263ek_board_config(struct at91sam926x_board_cfg
 		AT91_RSTC_RSTTYP_WATCHDOG;
 }
 
-static void __bare_init at91sam9263ek_init(void)
+static void __bare_init at91sam9263ek_init(void *fdt)
 {
 	struct at91sam926x_board_cfg cfg;
 
@@ -112,14 +112,30 @@ static void __bare_init at91sam9263ek_init(void)
 	at91sam926x_board_init(&cfg);
 
 	barebox_arm_entry(AT91_CHIPSELECT_1, at91_get_sdram_size(cfg.sdramc),
-	                  NULL);
+			  fdt);
 }
 
+#ifdef CONFIG_MACH_AT91SAM9263EK_DT
+extern char __dtb_at91sam9263ek_start[];
+
+ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
+{
+	void *fdt;
+
+	arm_cpu_lowlevel_init();
+
+	arm_setup_stack(AT91SAM9263_SRAM0_BASE + AT91SAM9263_SRAM0_SIZE - 16);
+	fdt = __dtb_at91sam9263ek_start - get_runtime_offset();
+
+	at91sam9263ek_init(fdt);
+}
+#else
 ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
 {
 	arm_cpu_lowlevel_init();
 
 	arm_setup_stack(AT91SAM9263_SRAM0_BASE + AT91SAM9263_SRAM0_SIZE - 16);
 
-	at91sam9263ek_init();
+	at91sam9263ek_init(NULL);
 }
+#endif
diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 4f13d4e37..0526a6f40 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -104,7 +104,7 @@ pbl-dtb-$(CONFIG_MACH_ZII_VF610_DEV) += \
 	vf610-zii-cfu1-rev-a.dtb.o	\
 	vf610-zii-spu3-rev-a.dtb.o	\
 	vf610-zii-scu4-aib-rev-c.dtb.o
-
+pbl-dtb-$(CONFIG_MACH_AT91SAM9263EK_DT) += at91sam9263ek.dtb.o
 pbl-dtb-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek.dtb.o
 
 clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
diff --git a/arch/arm/dts/at91sam9263ek.dts b/arch/arm/dts/at91sam9263ek.dts
new file mode 100644
index 000000000..224748ecc
--- /dev/null
+++ b/arch/arm/dts/at91sam9263ek.dts
@@ -0,0 +1,246 @@
+/*
+ * at91sam9263ek.dts - Device Tree file for Atmel at91sam9263 reference board
+ *
+ *  Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
+ *
+ * Licensed under GPLv2 only
+ */
+/dts-v1/;
+#include "arm/at91sam9263.dtsi"
+
+/ {
+	model = "Atmel at91sam9263ek";
+	compatible = "atmel,at91sam9263ek", "atmel,at91sam9263", "atmel,at91sam9";
+
+	chosen {
+		bootargs = "mem=64M root=/dev/mtdblock5 rw rootfstype=ubifs";
+		stdout-path = "serial0:115200n8";
+	};
+
+	memory {
+		reg = <0x20000000 0x4000000>;
+	};
+
+	clocks {
+		slow_xtal {
+			clock-frequency = <32768>;
+		};
+
+		main_xtal {
+			clock-frequency = <16367660>;
+		};
+	};
+
+	ahb {
+		apb {
+			dbgu: serial@ffffee00 {
+				status = "okay";
+			};
+
+			usart0: serial@fff8c000 {
+				pinctrl-0 = <
+					&pinctrl_usart0
+					&pinctrl_usart0_rts
+					&pinctrl_usart0_cts>;
+				status = "okay";
+			};
+
+			macb0: ethernet@fffbc000 {
+				phy-mode = "rmii";
+				status = "okay";
+			};
+
+			usb1: gadget@fff78000 {
+				atmel,vbus-gpio = <&pioA 25 GPIO_ACTIVE_HIGH>;
+				status = "okay";
+			};
+
+			mmc0: mmc@fff80000 {
+				pinctrl-0 = <
+					&pinctrl_board_mmc0
+					&pinctrl_mmc0_clk
+					&pinctrl_mmc0_slot0_cmd_dat0
+					&pinctrl_mmc0_slot0_dat1_3>;
+				status = "okay";
+				slot@0 {
+					reg = <0>;
+					bus-width = <4>;
+					cd-gpios = <&pioE 18 GPIO_ACTIVE_HIGH>;
+					wp-gpios = <&pioE 19 GPIO_ACTIVE_HIGH>;
+				};
+			};
+
+			pinctrl@fffff200 {
+				mmc0 {
+					pinctrl_board_mmc0: mmc0-board {
+						atmel,pins =
+							<AT91_PIOE 18 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP_DEGLITCH 	/* PE18 gpio CD pin pull up and deglitch */
+							 AT91_PIOE 19 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP>;	/* PE19 gpio WP pin pull up */
+					};
+				};
+			};
+
+			spi0: spi@fffa4000 {
+				status = "okay";
+				cs-gpios = <&pioA 5 0>, <0>, <0>, <0>;
+				mtd_dataflash@0 {
+					compatible = "atmel,at45", "atmel,dataflash";
+					spi-max-frequency = <50000000>;
+					reg = <0>;
+				};
+			};
+
+			watchdog@fffffd40 {
+				status = "okay";
+			};
+		};
+
+		fb0: fb@0x00700000 {
+			display = <&display0>;
+			status = "okay";
+
+			display0: display {
+				bits-per-pixel = <16>;
+				atmel,lcdcon-backlight;
+				atmel,dmacon = <0x1>;
+				atmel,lcdcon2 = <0x80008002>;
+				atmel,guard-time = <1>;
+
+				display-timings {
+					native-mode = <&timing0>;
+					timing0: timing0 {
+						clock-frequency = <4965000>;
+						hactive = <240>;
+						vactive = <320>;
+						hback-porch = <1>;
+						hfront-porch = <33>;
+						vback-porch = <1>;
+						vfront-porch = <0>;
+						hsync-len = <5>;
+						vsync-len = <1>;
+						hsync-active = <1>;
+						vsync-active = <1>;
+					};
+				};
+			};
+		};
+
+		ebi0: ebi@10000000 {
+			status = "okay";
+
+			nand_controller: nand-controller {
+				status = "okay";
+				pinctrl-0 = <&pinctrl_nand_cs &pinctrl_nand_rb>;
+				pinctrl-names = "default";
+
+				nand@3 {
+					reg = <0x3 0x0 0x800000>;
+					rb-gpios = <&pioA 22 GPIO_ACTIVE_HIGH>;
+					cs-gpios = <&pioA 15 GPIO_ACTIVE_HIGH>;
+					nand-bus-width = <8>;
+					nand-ecc-mode = "soft";
+					nand-on-flash-bbt;
+					label = "atmel_nand";
+
+					partitions {
+						compatible = "fixed-partitions";
+						#address-cells = <1>;
+						#size-cells = <1>;
+
+						at91bootstrap@0 {
+							label = "at91bootstrap";
+							reg = <0x0 0x20000>;
+						};
+
+						barebox@20000 {
+							label = "barebox";
+							reg = <0x20000 0x40000>;
+						};
+
+						bareboxenv@60000 {
+							label = "bareboxenv";
+							reg = <0x60000 0x20000>;
+						};
+
+						bareboxenv2@80000 {
+							label = "bareboxenv2";
+							reg = <0x80000 0x20000>;
+						};
+
+						oftree@80000 {
+							label = "oftree";
+							reg = <0xa0000 0x20000>;
+						};
+
+						kernel@a0000 {
+							label = "kernel";
+							reg = <0xc0000 0x400000>;
+						};
+
+						rootfs@4a0000 {
+							label = "rootfs";
+							reg = <0x4c0000 0x7800000>;
+						};
+
+						data@7ca0000 {
+							label = "data";
+							reg = <0x7cc0000 0x8340000>;
+						};
+					};
+				};
+			};
+		};
+
+		usb0: ohci@00a00000 {
+			num-ports = <2>;
+			status = "okay";
+			atmel,vbus-gpio = <&pioA 24 GPIO_ACTIVE_HIGH
+					   &pioA 21 GPIO_ACTIVE_HIGH
+					  >;
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		d3 {
+			label = "d3";
+			gpios = <&pioB 7 GPIO_ACTIVE_HIGH>;
+			linux,default-trigger = "heartbeat";
+		};
+
+		d2 {
+			label = "d2";
+			gpios = <&pioC 29 GPIO_ACTIVE_LOW>;
+			linux,default-trigger = "nand-disk";
+		};
+	};
+
+	gpio_keys {
+		compatible = "gpio-keys";
+
+		left_click {
+			label = "left_click";
+			gpios = <&pioC 5 GPIO_ACTIVE_LOW>;
+			linux,code = <272>;
+			wakeup-source;
+		};
+
+		right_click {
+			label = "right_click";
+			gpios = <&pioC 4 GPIO_ACTIVE_LOW>;
+			linux,code = <273>;
+			wakeup-source;
+		};
+	};
+
+	i2c-gpio-0 {
+		status = "okay";
+
+		24c512@50 {
+			compatible = "24c512";
+			reg = <0x50>;
+			pagesize = <128>;
+		};
+	};
+};
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index f5160ade1..5e9c575cc 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -20,6 +20,13 @@ config COMMON_CLK_AT91
 	select COMMON_CLK
 	select MFD_SYSCON
 
+config MACH_AT91SAM9263EK_DT
+	def_bool y
+	depends on MACH_AT91SAM9263EK && OFDEVICE
+	help
+	  Enabled for at91sam9263ek - evaluation kit.
+	  But only if we need the device tree (bootstrap do not use DT)
+
 config HAVE_AT91_SMD
 	bool
 
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 3/5] at91sam9263ek: fix SD card in DT
  2017-12-27 21:17 [PATCH 0/5] Enable DT support for AT91SAM9263EK Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 1/5] at91sam9263ek: enable multi-image build Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 2/5] at91sam9263ek: add DT file from Linux kernel v4.14-rc4 Sam Ravnborg
@ 2017-12-27 21:18 ` Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 4/5] arm: at91: enable CPU specific init with OF Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 5/5] at91sam9263ek: enable devicetree Sam Ravnborg
  4 siblings, 0 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-27 21:18 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

The DT file from the linux kernel uses mmc0 for SD card,
but the evaluation board uses mmc1.
Fix DT file so it has same behaviour like the non-DT
version where mmc1 is used.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/dts/at91sam9263ek.dts | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/arch/arm/dts/at91sam9263ek.dts b/arch/arm/dts/at91sam9263ek.dts
index 224748ecc..7d0ae0447 100644
--- a/arch/arm/dts/at91sam9263ek.dts
+++ b/arch/arm/dts/at91sam9263ek.dts
@@ -55,12 +55,13 @@
 				status = "okay";
 			};
 
-			mmc0: mmc@fff80000 {
+			mmc1: mmc@fff84000 {
 				pinctrl-0 = <
-					&pinctrl_board_mmc0
-					&pinctrl_mmc0_clk
-					&pinctrl_mmc0_slot0_cmd_dat0
-					&pinctrl_mmc0_slot0_dat1_3>;
+					&pinctrl_board_mmc1
+					&pinctrl_mmc1_clk
+					&pinctrl_mmc1_slot0_cmd_dat0
+					&pinctrl_mmc1_slot0_dat1_3>;
+				cd-gpios = <&pioE 18 GPIO_ACTIVE_HIGH>;
 				status = "okay";
 				slot@0 {
 					reg = <0>;
@@ -71,8 +72,8 @@
 			};
 
 			pinctrl@fffff200 {
-				mmc0 {
-					pinctrl_board_mmc0: mmc0-board {
+				mmc1 {
+					pinctrl_board_mmc1: mmc1-board {
 						atmel,pins =
 							<AT91_PIOE 18 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP_DEGLITCH 	/* PE18 gpio CD pin pull up and deglitch */
 							 AT91_PIOE 19 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP>;	/* PE19 gpio WP pin pull up */
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 4/5] arm: at91: enable CPU specific init with OF
  2017-12-27 21:17 [PATCH 0/5] Enable DT support for AT91SAM9263EK Sam Ravnborg
                   ` (2 preceding siblings ...)
  2017-12-27 21:18 ` [PATCH 3/5] at91sam9263ek: fix SD card in DT Sam Ravnborg
@ 2017-12-27 21:18 ` Sam Ravnborg
  2017-12-27 21:18 ` [PATCH 5/5] at91sam9263ek: enable devicetree Sam Ravnborg
  4 siblings, 0 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-27 21:18 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

This drops the panic in the case where no
at91_boot_soc.init() is specified, as this
is with DT support added now optional.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/mach-at91/generic.h | 4 ++++
 arch/arm/mach-at91/setup.c   | 6 ------
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index a47bcb2c5..c99dce533 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -9,7 +9,11 @@
  */
 
  /* Clocks */
+#ifdef CONFIG_COMMON_CLK_OF_PROVIDER
+static inline int __init at91_clock_init(void) { return 0; }
+#else
 extern int __init at91_clock_init(void);
+#endif
 
 static inline struct device_d *at91_add_rm9200_gpio(int id, resource_size_t start)
 {
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 8f32af043..c8c6e2ba4 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -283,12 +283,6 @@ static int at91_detect(void)
 	pr_info("AT91: Detected soc subtype: %s\n",
 		at91_get_soc_subtype(&at91_soc_initdata));
 
-	if (IS_ENABLED(CONFIG_COMMON_CLK_OF_PROVIDER))
-		return 0;
-
-	if (!at91_soc_is_enabled())
-		panic("AT91: Soc not enabled");
-
 	/* Init clock subsystem */
 	at91_clock_init();
 
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [PATCH 5/5] at91sam9263ek: enable devicetree
  2017-12-27 21:17 [PATCH 0/5] Enable DT support for AT91SAM9263EK Sam Ravnborg
                   ` (3 preceding siblings ...)
  2017-12-27 21:18 ` [PATCH 4/5] arm: at91: enable CPU specific init with OF Sam Ravnborg
@ 2017-12-27 21:18 ` Sam Ravnborg
  2017-12-30  2:02   ` Andrey Smirnov
  4 siblings, 1 reply; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-27 21:18 UTC (permalink / raw)
  To: Barebox List; +Cc: Sam Ravnborg

Following is tested and works with DT:
- GPIO LEDs
- GPIO buttons
- UART
- nand probe
- macb probe
- SD card (mci1)
- network
- loading environment
- loading kernel

Following is not tested:
- i2c
- USB

Changes:
- Added of_init.c, simpler than using ifdefs in the existing init.c
- Selected relevant symbols in Kconfig to enable use of DT
- Added additional commands (used for debugging)
  - iomem, clk*
- Extended DT with:
  - environment,barebox, to tell where to find the enviroment

The log below shows:
- barebox-environment environment.6: probe failed: No such device
  Likely something with setup od NAND
  But not something that has been looked into

barebox 2017.12.0-00033-g0c8627b65 #6 Wed Dec 27 21:14:40 CET 2017

Board: Atmel at91sam9263ek
gpio-at91 fffff200.gpio: AT91 gpio driver registered
gpio-at91 fffff400.gpio: AT91 gpio driver registered
gpio-at91 fffff600.gpio: AT91 gpio driver registered
gpio-at91 fffff800.gpio: AT91 gpio driver registered
gpio-at91 fffffa00.gpio: AT91 gpio driver registered
pinctrl-at91 pinctrl.2: AT91 pinctrl registered
initcall 0x23e44540 failed: error -1073741823
AT91: Detected soc type: at91sam9263
AT91: Detected soc subtype: Unknown
mdio_bus: miibus0: probed
macb fffbc000.ethernet: Cadence MACB at 0xfffbc000
at91_udc fff78000.gadget: at91_udc version 3 May 2006
atmel_mci fff84000.mmc: version: 0x210
atmel_mci fff84000.mmc: registered as fff84000.mmc
malloc space: 0x239facc0 -> 0x23dfacbf (size 4 MiB)
barebox-environment environment.6: probe failed: No such device
environment load /dev/env0: No such file or directory
Maybe you have to create the partition.
running /env/bin/init...
No USB Device cable plugged, normal boot
\e[?25h
Hit any key to stop autoboot:    2

barebox@Atmel at91sam9263ek:/ iomem
0x00000000 - 0xffffffff (size 0x00000000) iomem
  0x00300000 - 0x00313fff (size 0x00014000) 300000.sram
  0x00500000 - 0x00503fff (size 0x00004000) 500000.sram
  0x00700000 - 0x00700fff (size 0x00001000) 700000.fb
  0x20000000 - 0x23ffffff (size 0x04000000) ram0
    0x239facc0 - 0x23dfacbf (size 0x00400000) malloc space
    0x23dfacc0 - 0x23dfffef (size 0x00005330) board data
    0x23e00000 - 0x23e54008 (size 0x00054009) barebox
    0x23e54009 - 0x23e64cf7 (size 0x00010cef) barebox data
    0x23e64cf8 - 0x23e681f7 (size 0x00003500) bss
    0x23fe4000 - 0x23fe7fff (size 0x00004000) ttb
    0x23fe8000 - 0x23feffff (size 0x00008000) stack
  0xfff78000 - 0xfff7bfff (size 0x00004000) fff78000.gadget
  0xfff84000 - 0xfff845ff (size 0x00000600) fff84000.mmc
  0xfff8c000 - 0xfff8c1ff (size 0x00000200) fff8c000.serial
  0xfffbc000 - 0xfffbc0ff (size 0x00000100) fffbc000.ethernet
  0xffffe400 - 0xffffe5ff (size 0x00000200) at91sam9-smc0
  0xffffea00 - 0xffffebff (size 0x00000200) at91sam9-smc1
  0xffffee00 - 0xffffefff (size 0x00000200) ffffee00.serial
  0xfffff200 - 0xfffff3ff (size 0x00000200) fffff200.gpio
  0xfffff400 - 0xfffff5ff (size 0x00000200) fffff400.gpio
  0xfffff600 - 0xfffff7ff (size 0x00000200) fffff600.gpio
  0xfffff800 - 0xfffff9ff (size 0x00000200) fffff800.gpio
  0xfffffa00 - 0xfffffbff (size 0x00000200) fffffa00.gpio
  0xfffffd30 - 0xfffffd3e (size 0x0000000f) fffffd30.timer

barebox@Atmel at91sam9263ek:/ clk_dump
slow_xtal (rate 32768, enabled)
    prog0 (rate 32768, enabled)
        pck0 (rate 32768, disabled)
    prog1 (rate 32768, enabled)
        pck1 (rate 32768, disabled)
    prog2 (rate 32768, enabled)
        pck2 (rate 32768, disabled)
    prog3 (rate 32768, enabled)
        pck3 (rate 32768, disabled)
main_xtal (rate 16367660, enabled)
    main_osc (rate 16367660, enabled)
        mainck (rate 16367660, enabled)
            pllbck (rate 98205960, enabled)
                usbck (rate 49102980, enabled)
                    uhpck (rate 49102980, disabled)
                    udpck (rate 49102980, disabled)
            pllack (rate 204595750, enabled)
                masterck (rate 102297875, enabled)
                    pioA_clk (rate 102297875, enabled)
                    pioB_clk (rate 102297875, enabled)
                    pioCDE_clk (rate 102297875, enabled)
                    usart0_clk (rate 102297875, enabled)
                    usart1_clk (rate 102297875, disabled)
                    usart2_clk (rate 102297875, disabled)
                    mci0_clk (rate 102297875, disabled)
                    mci1_clk (rate 102297875, disabled)
                    can_clk (rate 102297875, disabled)
                    twi0_clk (rate 102297875, disabled)
                    spi0_clk (rate 102297875, disabled)
                    spi1_clk (rate 102297875, disabled)
                    ssc0_clk (rate 102297875, disabled)
                    ssc1_clk (rate 102297875, disabled)
                    ac97_clk (rate 102297875, disabled)
                    tcb_clk (rate 102297875, disabled)
                    pwm_clk (rate 102297875, disabled)
                    macb0_clk (rate 102297875, enabled)
                    g2de_clk (rate 102297875, disabled)
                    udc_clk (rate 102297875, disabled)
                    isi_clk (rate 102297875, disabled)
                    lcd_clk (rate 102297875, enabled)
                    dma_clk (rate 102297875, disabled)
                    ohci_clk (rate 102297875, disabled)

barebox@Atmel at91sam9263ek:/ devinfo
`-- global
`-- nv
`-- platform
   `-- mem0
      `-- 0x00000000-0x03ffffff (    64 MiB): /dev/ram0
   `-- 300000.sram
      `-- 0x00000000-0x00013fff (    80 KiB): /dev/sram0
   `-- 500000.sram
      `-- 0x00000000-0x00003fff (    16 KiB): /dev/sram1
   `-- ahb.0
      `-- apb.1
         `-- fffff000.interrupt-controller
         `-- fffffc00.pmc
         `-- ffffe200.ramc
         `-- ffffe400.smc
         `-- ffffe800.ramc
         `-- ffffea00.smc
         `-- ffffec00.matrix
         `-- fffffd30.timer
         `-- fff7c000.timer
         `-- fffffd00.rstc
         `-- fffffd10.shdwc
         `-- pinctrl.2
            `-- fffff200.gpio
            `-- fffff400.gpio
            `-- fffff600.gpio
            `-- fffff800.gpio
            `-- fffffa00.gpio
         `-- ffffee00.serial
            `-- cs0
               `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs0
         `-- fff8c000.serial
            `-- cs1
               `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs1
         `-- fffbc000.ethernet
            `-- miibus0
            `-- eth0
         `-- fff78000.gadget
            `-- usbgadget
         `-- fff84000.mmc
            `-- mci0
         `-- fffffd40.watchdog
         `-- fffa4000.spi
         `-- fffac000.can
      `-- 700000.fb
      `-- a00000.ohci
      `-- 10000000.ebi
   `-- i2c-gpio-0.3
   `-- leds.4
   `-- gpio_keys.5
   `-- at91sam9-smc0
   `-- at91sam9-smc1
   `-- cs2
      `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs2
   `-- soc
   `-- mem1
      `-- 0x00000000-0xfffffffe (     4 GiB): /dev/mem
   `-- environment.6
`-- mdio_bus
`-- fs
   `-- ramfs0
   `-- devfs0
`-- net
`-- udc0
`-- fb0
   `-- 0x00000000-0x000257ff (   150 KiB): /dev/fb0

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/boards/at91sam9263ek/Makefile   |  5 ++
 arch/arm/boards/at91sam9263ek/of_init.c  | 98 ++++++++++++++++++++++++++++++++
 arch/arm/configs/at91sam9263ek_defconfig |  6 ++
 arch/arm/dts/at91sam9263ek.dts           |  6 ++
 arch/arm/mach-at91/Kconfig               |  3 +
 arch/arm/mach-at91/at91sam9263.c         |  8 +++
 6 files changed, 126 insertions(+)
 create mode 100644 arch/arm/boards/at91sam9263ek/of_init.c

diff --git a/arch/arm/boards/at91sam9263ek/Makefile b/arch/arm/boards/at91sam9263ek/Makefile
index de4d75690..85b6ba0a5 100644
--- a/arch/arm/boards/at91sam9263ek/Makefile
+++ b/arch/arm/boards/at91sam9263ek/Makefile
@@ -1,4 +1,9 @@
+
+ifeq ($(CONFIG_OFDEVICE),)
 obj-y += init.o
+else
+obj-y += of_init.o
+endif
 
 lwl-y += lowlevel_init.o
 bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC) += defaultenv-at91sam9263ek
diff --git a/arch/arm/boards/at91sam9263ek/of_init.c b/arch/arm/boards/at91sam9263ek/of_init.c
new file mode 100644
index 000000000..155659124
--- /dev/null
+++ b/arch/arm/boards/at91sam9263ek/of_init.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2017 Sam Ravnborg <sam@ravnborg.org>
+ *
+ * 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.
+ */
+
+#include <common.h>
+#include <envfs.h>
+#include <init.h>
+#include <gpio.h>
+
+#include <mach/at91sam9263_matrix.h>
+#include <mach/at91sam9_smc.h>
+#include <mach/hardware.h>
+#include <mach/iomux.h>
+#include <mach/io.h>
+
+static int check_fdt(void)
+{
+	return of_machine_is_compatible("atmel,at91sam9263ek");
+}
+postcore_initcall(check_fdt);
+
+static struct sam9_smc_config ek_nand_smc_config = {
+	.ncs_read_setup		= 0,
+	.nrd_setup		= 1,
+	.ncs_write_setup	= 0,
+	.nwe_setup		= 1,
+
+	.ncs_read_pulse		= 3,
+	.nrd_pulse		= 3,
+	.ncs_write_pulse	= 3,
+	.nwe_pulse		= 3,
+
+	.read_cycle		= 5,
+	.write_cycle		= 5,
+
+	.mode			= AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
+	.tdf_cycles		= 2,
+};
+
+/*
+ * Initialize of SMC must come after we
+ * probe the at91sam9_smc_driver.
+ * But is required before we start the other drives.
+ * Use fs_initcall() to maintain this order.
+ */
+static int at91sam9263_smc_init(void)
+{
+	unsigned long csa;
+
+	/* setup bus-width (8 or 16) */
+#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
+	ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
+#else
+	ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
+#endif
+
+	csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
+	csa |= AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA;
+	at91_sys_write(AT91_MATRIX_EBI0CSA, csa);
+
+	/* configure chip-select 3 (NAND) */
+	sam9_smc_configure(0, 3, &ek_nand_smc_config);
+
+	return 0;
+}
+fs_initcall(at91sam9263_smc_init);
+
+static int at91sam9263ek_phy_init(void)
+{
+	/*
+	 * PB27 enables the 50MHz oscillator for Ethernet PHY
+	 * 1 - enable
+	 * 0 - disable
+	 */
+	at91_set_gpio_output(AT91_PIN_PB27, 1);
+	gpio_set_value(AT91_PIN_PB27, 1); /* 1- enable, 0 - disable */
+	return 0;
+}
+device_initcall(at91sam9263ek_phy_init);
+
+static int at91sam9263ek_env_init(void)
+{
+	if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
+		defaultenv_append_directory(defaultenv_at91sam9263ek);
+
+	return 0;
+}
+late_initcall(at91sam9263ek_env_init);
diff --git a/arch/arm/configs/at91sam9263ek_defconfig b/arch/arm/configs/at91sam9263ek_defconfig
index fc92615eb..e8ad841fa 100644
--- a/arch/arm/configs/at91sam9263ek_defconfig
+++ b/arch/arm/configs/at91sam9263ek_defconfig
@@ -20,6 +20,7 @@ CONFIG_CONSOLE_ACTIVATE_ALL=y
 CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
 # CONFIG_CMD_ARM_CPUINFO is not set
 CONFIG_LONGHELP=y
+CONFIG_CMD_IOMEM=y
 CONFIG_CMD_MEMINFO=y
 # CONFIG_CMD_BOOTU is not set
 CONFIG_CMD_GO=y
@@ -38,6 +39,7 @@ CONFIG_CMD_EDIT=y
 CONFIG_CMD_SPLASH=y
 CONFIG_CMD_READLINE=y
 CONFIG_CMD_TIMEOUT=y
+CONFIG_CMD_CLK=y
 CONFIG_CMD_FLASH=y
 CONFIG_CMD_GPIO=y
 CONFIG_CMD_LED=y
@@ -45,6 +47,7 @@ CONFIG_CMD_LED_TRIGGER=y
 CONFIG_CMD_OFTREE=y
 CONFIG_NET=y
 CONFIG_NET_NFS=y
+CONFIG_OF_BAREBOX_DRIVERS=y
 CONFIG_DRIVER_NET_MACB=y
 # CONFIG_SPI is not set
 CONFIG_MTD=y
@@ -64,9 +67,12 @@ CONFIG_VIDEO=y
 CONFIG_DRIVER_VIDEO_ATMEL=y
 CONFIG_MCI=y
 CONFIG_MCI_ATMEL=y
+CONFIG_SRAM=y
 CONFIG_LED=y
 CONFIG_LED_GPIO=y
+CONFIG_LED_GPIO_OF=y
 CONFIG_LED_TRIGGERS=y
+CONFIG_KEYBOARD_GPIO=y
 CONFIG_FS_TFTP=y
 CONFIG_FS_FAT=y
 CONFIG_FS_FAT_LFN=y
diff --git a/arch/arm/dts/at91sam9263ek.dts b/arch/arm/dts/at91sam9263ek.dts
index 7d0ae0447..f4b3098ac 100644
--- a/arch/arm/dts/at91sam9263ek.dts
+++ b/arch/arm/dts/at91sam9263ek.dts
@@ -15,6 +15,11 @@
 	chosen {
 		bootargs = "mem=64M root=/dev/mtdblock5 rw rootfstype=ubifs";
 		stdout-path = "serial0:115200n8";
+
+		environment@0 {
+			compatible = "barebox,environment";
+			device-path = &nand_controller, "partname:bareboxenv";
+		};
 	};
 
 	memory {
@@ -106,6 +111,7 @@
 				atmel,dmacon = <0x1>;
 				atmel,lcdcon2 = <0x80008002>;
 				atmel,guard-time = <1>;
+				atmel,lcd-wiring-mode = "IBGR";
 
 				display-timings {
 					native-mode = <&timing0>;
diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
index 5e9c575cc..a4fc024c1 100644
--- a/arch/arm/mach-at91/Kconfig
+++ b/arch/arm/mach-at91/Kconfig
@@ -538,6 +538,9 @@ if AT91_MULTI_BOARDS
 config MACH_AT91SAM9263EK
 	bool "Atmel AT91SAM9263-EK"
 	depends on ARCH_AT91SAM9263
+	select OFDEVICE
+	select COMMON_CLK_OF_PROVIDER
+	select HAVE_AT91_USB_CLK
 	select HAVE_NAND_ATMEL_BUSWIDTH_16
 	select HAVE_AT91_BOOTSTRAP
 	select AT91SAM926X_BOARD_INIT
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 35d187b4b..9d7b78dc7 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -12,6 +12,13 @@
  *  Clocks
  * -------------------------------------------------------------------- */
 
+#if defined(CONFIG_COMMON_CLK_AT91)
+static void at91sam9263_initialize(void)
+{
+	at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
+	at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
+}
+#else
 /*
  * The peripheral clocks.
  */
@@ -248,6 +255,7 @@ static void at91sam9263_initialize(void)
 	at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
 	at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
 }
+#endif
 
 AT91_SOC_START(sam9263)
 	.init = at91sam9263_initialize,
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 5/5] at91sam9263ek: enable devicetree
  2017-12-27 21:18 ` [PATCH 5/5] at91sam9263ek: enable devicetree Sam Ravnborg
@ 2017-12-30  2:02   ` Andrey Smirnov
  2017-12-30 21:24     ` Sam Ravnborg
  0 siblings, 1 reply; 11+ messages in thread
From: Andrey Smirnov @ 2017-12-30  2:02 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List

On Wed, Dec 27, 2017 at 1:18 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> Following is tested and works with DT:
> - GPIO LEDs
> - GPIO buttons
> - UART
> - nand probe
> - macb probe
> - SD card (mci1)
> - network
> - loading environment
> - loading kernel
>
> Following is not tested:
> - i2c
> - USB
>
> Changes:
> - Added of_init.c, simpler than using ifdefs in the existing init.c
> - Selected relevant symbols in Kconfig to enable use of DT
> - Added additional commands (used for debugging)
>   - iomem, clk*
> - Extended DT with:
>   - environment,barebox, to tell where to find the enviroment
>
> The log below shows:
> - barebox-environment environment.6: probe failed: No such device
>   Likely something with setup od NAND
>   But not something that has been looked into
>
> barebox 2017.12.0-00033-g0c8627b65 #6 Wed Dec 27 21:14:40 CET 2017
>
> Board: Atmel at91sam9263ek
> gpio-at91 fffff200.gpio: AT91 gpio driver registered
> gpio-at91 fffff400.gpio: AT91 gpio driver registered
> gpio-at91 fffff600.gpio: AT91 gpio driver registered
> gpio-at91 fffff800.gpio: AT91 gpio driver registered
> gpio-at91 fffffa00.gpio: AT91 gpio driver registered
> pinctrl-at91 pinctrl.2: AT91 pinctrl registered
> initcall 0x23e44540 failed: error -1073741823
> AT91: Detected soc type: at91sam9263
> AT91: Detected soc subtype: Unknown
> mdio_bus: miibus0: probed
> macb fffbc000.ethernet: Cadence MACB at 0xfffbc000
> at91_udc fff78000.gadget: at91_udc version 3 May 2006
> atmel_mci fff84000.mmc: version: 0x210
> atmel_mci fff84000.mmc: registered as fff84000.mmc
> malloc space: 0x239facc0 -> 0x23dfacbf (size 4 MiB)
> barebox-environment environment.6: probe failed: No such device
> environment load /dev/env0: No such file or directory
> Maybe you have to create the partition.
> running /env/bin/init...
> No USB Device cable plugged, normal boot
> \e[?25h
> Hit any key to stop autoboot:    2
>
> barebox@Atmel at91sam9263ek:/ iomem
> 0x00000000 - 0xffffffff (size 0x00000000) iomem
>   0x00300000 - 0x00313fff (size 0x00014000) 300000.sram
>   0x00500000 - 0x00503fff (size 0x00004000) 500000.sram
>   0x00700000 - 0x00700fff (size 0x00001000) 700000.fb
>   0x20000000 - 0x23ffffff (size 0x04000000) ram0
>     0x239facc0 - 0x23dfacbf (size 0x00400000) malloc space
>     0x23dfacc0 - 0x23dfffef (size 0x00005330) board data
>     0x23e00000 - 0x23e54008 (size 0x00054009) barebox
>     0x23e54009 - 0x23e64cf7 (size 0x00010cef) barebox data
>     0x23e64cf8 - 0x23e681f7 (size 0x00003500) bss
>     0x23fe4000 - 0x23fe7fff (size 0x00004000) ttb
>     0x23fe8000 - 0x23feffff (size 0x00008000) stack
>   0xfff78000 - 0xfff7bfff (size 0x00004000) fff78000.gadget
>   0xfff84000 - 0xfff845ff (size 0x00000600) fff84000.mmc
>   0xfff8c000 - 0xfff8c1ff (size 0x00000200) fff8c000.serial
>   0xfffbc000 - 0xfffbc0ff (size 0x00000100) fffbc000.ethernet
>   0xffffe400 - 0xffffe5ff (size 0x00000200) at91sam9-smc0
>   0xffffea00 - 0xffffebff (size 0x00000200) at91sam9-smc1
>   0xffffee00 - 0xffffefff (size 0x00000200) ffffee00.serial
>   0xfffff200 - 0xfffff3ff (size 0x00000200) fffff200.gpio
>   0xfffff400 - 0xfffff5ff (size 0x00000200) fffff400.gpio
>   0xfffff600 - 0xfffff7ff (size 0x00000200) fffff600.gpio
>   0xfffff800 - 0xfffff9ff (size 0x00000200) fffff800.gpio
>   0xfffffa00 - 0xfffffbff (size 0x00000200) fffffa00.gpio
>   0xfffffd30 - 0xfffffd3e (size 0x0000000f) fffffd30.timer
>
> barebox@Atmel at91sam9263ek:/ clk_dump
> slow_xtal (rate 32768, enabled)
>     prog0 (rate 32768, enabled)
>         pck0 (rate 32768, disabled)
>     prog1 (rate 32768, enabled)
>         pck1 (rate 32768, disabled)
>     prog2 (rate 32768, enabled)
>         pck2 (rate 32768, disabled)
>     prog3 (rate 32768, enabled)
>         pck3 (rate 32768, disabled)
> main_xtal (rate 16367660, enabled)
>     main_osc (rate 16367660, enabled)
>         mainck (rate 16367660, enabled)
>             pllbck (rate 98205960, enabled)
>                 usbck (rate 49102980, enabled)
>                     uhpck (rate 49102980, disabled)
>                     udpck (rate 49102980, disabled)
>             pllack (rate 204595750, enabled)
>                 masterck (rate 102297875, enabled)
>                     pioA_clk (rate 102297875, enabled)
>                     pioB_clk (rate 102297875, enabled)
>                     pioCDE_clk (rate 102297875, enabled)
>                     usart0_clk (rate 102297875, enabled)
>                     usart1_clk (rate 102297875, disabled)
>                     usart2_clk (rate 102297875, disabled)
>                     mci0_clk (rate 102297875, disabled)
>                     mci1_clk (rate 102297875, disabled)
>                     can_clk (rate 102297875, disabled)
>                     twi0_clk (rate 102297875, disabled)
>                     spi0_clk (rate 102297875, disabled)
>                     spi1_clk (rate 102297875, disabled)
>                     ssc0_clk (rate 102297875, disabled)
>                     ssc1_clk (rate 102297875, disabled)
>                     ac97_clk (rate 102297875, disabled)
>                     tcb_clk (rate 102297875, disabled)
>                     pwm_clk (rate 102297875, disabled)
>                     macb0_clk (rate 102297875, enabled)
>                     g2de_clk (rate 102297875, disabled)
>                     udc_clk (rate 102297875, disabled)
>                     isi_clk (rate 102297875, disabled)
>                     lcd_clk (rate 102297875, enabled)
>                     dma_clk (rate 102297875, disabled)
>                     ohci_clk (rate 102297875, disabled)
>
> barebox@Atmel at91sam9263ek:/ devinfo
> `-- global
> `-- nv
> `-- platform
>    `-- mem0
>       `-- 0x00000000-0x03ffffff (    64 MiB): /dev/ram0
>    `-- 300000.sram
>       `-- 0x00000000-0x00013fff (    80 KiB): /dev/sram0
>    `-- 500000.sram
>       `-- 0x00000000-0x00003fff (    16 KiB): /dev/sram1
>    `-- ahb.0
>       `-- apb.1
>          `-- fffff000.interrupt-controller
>          `-- fffffc00.pmc
>          `-- ffffe200.ramc
>          `-- ffffe400.smc
>          `-- ffffe800.ramc
>          `-- ffffea00.smc
>          `-- ffffec00.matrix
>          `-- fffffd30.timer
>          `-- fff7c000.timer
>          `-- fffffd00.rstc
>          `-- fffffd10.shdwc
>          `-- pinctrl.2
>             `-- fffff200.gpio
>             `-- fffff400.gpio
>             `-- fffff600.gpio
>             `-- fffff800.gpio
>             `-- fffffa00.gpio
>          `-- ffffee00.serial
>             `-- cs0
>                `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs0
>          `-- fff8c000.serial
>             `-- cs1
>                `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs1
>          `-- fffbc000.ethernet
>             `-- miibus0
>             `-- eth0
>          `-- fff78000.gadget
>             `-- usbgadget
>          `-- fff84000.mmc
>             `-- mci0
>          `-- fffffd40.watchdog
>          `-- fffa4000.spi
>          `-- fffac000.can
>       `-- 700000.fb
>       `-- a00000.ohci
>       `-- 10000000.ebi
>    `-- i2c-gpio-0.3
>    `-- leds.4
>    `-- gpio_keys.5
>    `-- at91sam9-smc0
>    `-- at91sam9-smc1
>    `-- cs2
>       `-- 0x00000000-0xffffffffffffffff (   0 Bytes): /dev/cs2
>    `-- soc
>    `-- mem1
>       `-- 0x00000000-0xfffffffe (     4 GiB): /dev/mem
>    `-- environment.6
> `-- mdio_bus
> `-- fs
>    `-- ramfs0
>    `-- devfs0
> `-- net
> `-- udc0
> `-- fb0
>    `-- 0x00000000-0x000257ff (   150 KiB): /dev/fb0
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  arch/arm/boards/at91sam9263ek/Makefile   |  5 ++
>  arch/arm/boards/at91sam9263ek/of_init.c  | 98 ++++++++++++++++++++++++++++++++
>  arch/arm/configs/at91sam9263ek_defconfig |  6 ++
>  arch/arm/dts/at91sam9263ek.dts           |  6 ++
>  arch/arm/mach-at91/Kconfig               |  3 +
>  arch/arm/mach-at91/at91sam9263.c         |  8 +++
>  6 files changed, 126 insertions(+)
>  create mode 100644 arch/arm/boards/at91sam9263ek/of_init.c
>
> diff --git a/arch/arm/boards/at91sam9263ek/Makefile b/arch/arm/boards/at91sam9263ek/Makefile
> index de4d75690..85b6ba0a5 100644
> --- a/arch/arm/boards/at91sam9263ek/Makefile
> +++ b/arch/arm/boards/at91sam9263ek/Makefile
> @@ -1,4 +1,9 @@
> +
> +ifeq ($(CONFIG_OFDEVICE),)
>  obj-y += init.o
> +else
> +obj-y += of_init.o
> +endif
>
>  lwl-y += lowlevel_init.o
>  bbenv-$(CONFIG_DEFAULT_ENVIRONMENT_GENERIC) += defaultenv-at91sam9263ek
> diff --git a/arch/arm/boards/at91sam9263ek/of_init.c b/arch/arm/boards/at91sam9263ek/of_init.c
> new file mode 100644
> index 000000000..155659124
> --- /dev/null
> +++ b/arch/arm/boards/at91sam9263ek/of_init.c
> @@ -0,0 +1,98 @@
> +/*
> + * Copyright (C) 2017 Sam Ravnborg <sam@ravnborg.org>
> + *
> + * 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.
> + */
> +
> +#include <common.h>
> +#include <envfs.h>
> +#include <init.h>
> +#include <gpio.h>
> +
> +#include <mach/at91sam9263_matrix.h>
> +#include <mach/at91sam9_smc.h>
> +#include <mach/hardware.h>
> +#include <mach/iomux.h>
> +#include <mach/io.h>
> +
> +static int check_fdt(void)
> +{
> +       return of_machine_is_compatible("atmel,at91sam9263ek");
> +}
> +postcore_initcall(check_fdt);
> +

Reading this I realized that I wrote buggy initcalls in my original
AT91SAM9x5EK patches and set a bad example/precedent (I'll submit
patches to fix that). That check above is just going to print a error
message, but it wouldn't prevent the code for wrong board from being
executed (say if you are running image that supports both
at91sam9263ek and at91sam9g45 on either). IMHO, what you want to do,
and what I should've done as well, is to add

if (!of_machine_is_compatible("atmel,at91sam9263ek"))
    return 0;

early exit code to the start of very *_callback call. Here's a decent
example where I didn't screw this up:

https://git.pengutronix.de/cgit/barebox/tree/arch/arm/boards/zii-vf610-dev/board.c#n55


> +static struct sam9_smc_config ek_nand_smc_config = {
> +       .ncs_read_setup         = 0,
> +       .nrd_setup              = 1,
> +       .ncs_write_setup        = 0,
> +       .nwe_setup              = 1,
> +
> +       .ncs_read_pulse         = 3,
> +       .nrd_pulse              = 3,
> +       .ncs_write_pulse        = 3,
> +       .nwe_pulse              = 3,
> +
> +       .read_cycle             = 5,
> +       .write_cycle            = 5,
> +
> +       .mode                   = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE,
> +       .tdf_cycles             = 2,
> +};
> +
> +/*
> + * Initialize of SMC must come after we
> + * probe the at91sam9_smc_driver.
> + * But is required before we start the other drives.
> + * Use fs_initcall() to maintain this order.
> + */
> +static int at91sam9263_smc_init(void)
> +{
> +       unsigned long csa;
> +
> +       /* setup bus-width (8 or 16) */
> +#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
> +       ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
> +#else
> +       ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
> +#endif
> +

You already use IS_ENABLED below, so it might be more consistent to
use it here as well.

> +       csa = at91_sys_read(AT91_MATRIX_EBI0CSA);
> +       csa |= AT91_MATRIX_EBI0_CS3A_SMC_SMARTMEDIA;
> +       at91_sys_write(AT91_MATRIX_EBI0CSA, csa);
> +
> +       /* configure chip-select 3 (NAND) */
> +       sam9_smc_configure(0, 3, &ek_nand_smc_config);
> +
> +       return 0;
> +}
> +fs_initcall(at91sam9263_smc_init);
> +
> +static int at91sam9263ek_phy_init(void)
> +{
> +       /*
> +        * PB27 enables the 50MHz oscillator for Ethernet PHY
> +        * 1 - enable
> +        * 0 - disable
> +        */
> +       at91_set_gpio_output(AT91_PIN_PB27, 1);
> +       gpio_set_value(AT91_PIN_PB27, 1); /* 1- enable, 0 - disable */
> +       return 0;
> +}
> +device_initcall(at91sam9263ek_phy_init);
> +

This is fine as it is, but you can probably drop the code above in
favor of gpio-hog in DT file.

> +static int at91sam9263ek_env_init(void)
> +{
> +       if (IS_ENABLED(CONFIG_DEFAULT_ENVIRONMENT_GENERIC))
> +               defaultenv_append_directory(defaultenv_at91sam9263ek);
> +
> +       return 0;
> +}
> +late_initcall(at91sam9263ek_env_init);
> diff --git a/arch/arm/configs/at91sam9263ek_defconfig b/arch/arm/configs/at91sam9263ek_defconfig
> index fc92615eb..e8ad841fa 100644
> --- a/arch/arm/configs/at91sam9263ek_defconfig
> +++ b/arch/arm/configs/at91sam9263ek_defconfig
> @@ -20,6 +20,7 @@ CONFIG_CONSOLE_ACTIVATE_ALL=y
>  CONFIG_DEFAULT_ENVIRONMENT_GENERIC=y
>  # CONFIG_CMD_ARM_CPUINFO is not set
>  CONFIG_LONGHELP=y
> +CONFIG_CMD_IOMEM=y
>  CONFIG_CMD_MEMINFO=y
>  # CONFIG_CMD_BOOTU is not set
>  CONFIG_CMD_GO=y
> @@ -38,6 +39,7 @@ CONFIG_CMD_EDIT=y
>  CONFIG_CMD_SPLASH=y
>  CONFIG_CMD_READLINE=y
>  CONFIG_CMD_TIMEOUT=y
> +CONFIG_CMD_CLK=y
>  CONFIG_CMD_FLASH=y
>  CONFIG_CMD_GPIO=y
>  CONFIG_CMD_LED=y
> @@ -45,6 +47,7 @@ CONFIG_CMD_LED_TRIGGER=y
>  CONFIG_CMD_OFTREE=y
>  CONFIG_NET=y
>  CONFIG_NET_NFS=y
> +CONFIG_OF_BAREBOX_DRIVERS=y
>  CONFIG_DRIVER_NET_MACB=y
>  # CONFIG_SPI is not set
>  CONFIG_MTD=y
> @@ -64,9 +67,12 @@ CONFIG_VIDEO=y
>  CONFIG_DRIVER_VIDEO_ATMEL=y
>  CONFIG_MCI=y
>  CONFIG_MCI_ATMEL=y
> +CONFIG_SRAM=y
>  CONFIG_LED=y
>  CONFIG_LED_GPIO=y
> +CONFIG_LED_GPIO_OF=y
>  CONFIG_LED_TRIGGERS=y
> +CONFIG_KEYBOARD_GPIO=y
>  CONFIG_FS_TFTP=y
>  CONFIG_FS_FAT=y
>  CONFIG_FS_FAT_LFN=y
> diff --git a/arch/arm/dts/at91sam9263ek.dts b/arch/arm/dts/at91sam9263ek.dts
> index 7d0ae0447..f4b3098ac 100644
> --- a/arch/arm/dts/at91sam9263ek.dts
> +++ b/arch/arm/dts/at91sam9263ek.dts
> @@ -15,6 +15,11 @@
>         chosen {
>                 bootargs = "mem=64M root=/dev/mtdblock5 rw rootfstype=ubifs";
>                 stdout-path = "serial0:115200n8";
> +
> +               environment@0 {
> +                       compatible = "barebox,environment";
> +                       device-path = &nand_controller, "partname:bareboxenv";
> +               };
>         };
>
>         memory {
> @@ -106,6 +111,7 @@
>                                 atmel,dmacon = <0x1>;
>                                 atmel,lcdcon2 = <0x80008002>;
>                                 atmel,guard-time = <1>;
> +                               atmel,lcd-wiring-mode = "IBGR";
>
>                                 display-timings {
>                                         native-mode = <&timing0>;
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> index 5e9c575cc..a4fc024c1 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -538,6 +538,9 @@ if AT91_MULTI_BOARDS
>  config MACH_AT91SAM9263EK
>         bool "Atmel AT91SAM9263-EK"
>         depends on ARCH_AT91SAM9263
> +       select OFDEVICE
> +       select COMMON_CLK_OF_PROVIDER
> +       select HAVE_AT91_USB_CLK
>         select HAVE_NAND_ATMEL_BUSWIDTH_16
>         select HAVE_AT91_BOOTSTRAP
>         select AT91SAM926X_BOARD_INIT
> diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
> index 35d187b4b..9d7b78dc7 100644
> --- a/arch/arm/mach-at91/at91sam9263.c
> +++ b/arch/arm/mach-at91/at91sam9263.c
> @@ -12,6 +12,13 @@
>   *  Clocks
>   * -------------------------------------------------------------------- */
>
> +#if defined(CONFIG_COMMON_CLK_AT91)
> +static void at91sam9263_initialize(void)
> +{
> +       at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
> +       at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
> +}
> +#else
>  /*
>   * The peripheral clocks.
>   */
> @@ -248,6 +255,7 @@ static void at91sam9263_initialize(void)
>         at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
>         at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
>  }
> +#endif

Is it too much work to move those two SMC-related calls into board
file and not compile mach-at91/at91sam9263.c for DT enabled build at
all?

Thanks,
Andrey Smirnov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 2/5] at91sam9263ek: add DT file from Linux kernel v4.14-rc4
  2017-12-27 21:18 ` [PATCH 2/5] at91sam9263ek: add DT file from Linux kernel v4.14-rc4 Sam Ravnborg
@ 2017-12-30  2:13   ` Andrey Smirnov
  0 siblings, 0 replies; 11+ messages in thread
From: Andrey Smirnov @ 2017-12-30  2:13 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Barebox List

On Wed, Dec 27, 2017 at 1:18 PM, Sam Ravnborg <sam@ravnborg.org> wrote:
> Include the at91sam9263ek.dts file from
> linux kernel v4.14-rc4 and wire it up in the build.
>
> Prepare at91sam9263ek lowlevel_init.c to use DT.
>
> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
> ---
>  arch/arm/boards/at91sam9263ek/lowlevel_init.c |  22 ++-
>  arch/arm/dts/Makefile                         |   2 +-
>  arch/arm/dts/at91sam9263ek.dts                | 246 ++++++++++++++++++++++++++
>  arch/arm/mach-at91/Kconfig                    |   7 +
>  4 files changed, 273 insertions(+), 4 deletions(-)
>  create mode 100644 arch/arm/dts/at91sam9263ek.dts
>
> diff --git a/arch/arm/boards/at91sam9263ek/lowlevel_init.c b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
> index 3138bc7ca..86d7a79e9 100644
> --- a/arch/arm/boards/at91sam9263ek/lowlevel_init.c
> +++ b/arch/arm/boards/at91sam9263ek/lowlevel_init.c
> @@ -99,7 +99,7 @@ static void __bare_init at91sam9263ek_board_config(struct at91sam926x_board_cfg
>                 AT91_RSTC_RSTTYP_WATCHDOG;
>  }
>
> -static void __bare_init at91sam9263ek_init(void)
> +static void __bare_init at91sam9263ek_init(void *fdt)
>  {
>         struct at91sam926x_board_cfg cfg;
>
> @@ -112,14 +112,30 @@ static void __bare_init at91sam9263ek_init(void)
>         at91sam926x_board_init(&cfg);
>
>         barebox_arm_entry(AT91_CHIPSELECT_1, at91_get_sdram_size(cfg.sdramc),
> -                         NULL);
> +                         fdt);
>  }
>
> +#ifdef CONFIG_MACH_AT91SAM9263EK_DT
> +extern char __dtb_at91sam9263ek_start[];
> +
> +ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
> +{
> +       void *fdt;
> +
> +       arm_cpu_lowlevel_init();
> +
> +       arm_setup_stack(AT91SAM9263_SRAM0_BASE + AT91SAM9263_SRAM0_SIZE - 16);
> +       fdt = __dtb_at91sam9263ek_start - get_runtime_offset();
> +
> +       at91sam9263ek_init(fdt);
> +}
> +#else
>  ENTRY_FUNCTION(start_at91sam9263ek, r0, r1, r2)
>  {
>         arm_cpu_lowlevel_init();
>
>         arm_setup_stack(AT91SAM9263_SRAM0_BASE + AT91SAM9263_SRAM0_SIZE - 16);
>
> -       at91sam9263ek_init();
> +       at91sam9263ek_init(NULL);
>  }
> +#endif

I think you can get away with defining this function once if you do:

if (IS_ENABLED(CONFIG_MACH_AT91SAM9263EK_DT))
    fdt = __dtb_at91sam9263ek_start - get_runtime_offset();
else
    fdt = NULL;

at91sam9263ek_init(fdt);


> diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
> index 4f13d4e37..0526a6f40 100644
> --- a/arch/arm/dts/Makefile
> +++ b/arch/arm/dts/Makefile
> @@ -104,7 +104,7 @@ pbl-dtb-$(CONFIG_MACH_ZII_VF610_DEV) += \
>         vf610-zii-cfu1-rev-a.dtb.o      \
>         vf610-zii-spu3-rev-a.dtb.o      \
>         vf610-zii-scu4-aib-rev-c.dtb.o
> -
> +pbl-dtb-$(CONFIG_MACH_AT91SAM9263EK_DT) += at91sam9263ek.dtb.o
>  pbl-dtb-$(CONFIG_MACH_AT91SAM9X5EK) += at91sam9x5ek.dtb.o
>
>  clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.lzo
> diff --git a/arch/arm/dts/at91sam9263ek.dts b/arch/arm/dts/at91sam9263ek.dts
> new file mode 100644
> index 000000000..224748ecc
> --- /dev/null
> +++ b/arch/arm/dts/at91sam9263ek.dts
> @@ -0,0 +1,246 @@
> +/*
> + * at91sam9263ek.dts - Device Tree file for Atmel at91sam9263 reference board
> + *
> + *  Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> + *
> + * Licensed under GPLv2 only
> + */
> +/dts-v1/;
> +#include "arm/at91sam9263.dtsi"
> +

AFAIU you are including this from the "dts/" directory, so you may as
well use angle brackets to indicate that, e.g. #include
<arm/at91sam9263.dtsi>.

But more importantly, is there a way you can use <arm/at91sam9263.dts>
and avoid bringing all of the code below in? The only reason I didn't
do that for 9x5ek was because the kernel doesn't have a generic
9x5ek.dts and instead it has specific files for every value of "x", so
to speak (9g45ek, 9g15ek, etc).

E.g. something like this:

https://git.pengutronix.de/cgit/barebox/tree/arch/arm/dts/vf610-zii-dev-rev-c.dts?h=next

> +/ {
> +       model = "Atmel at91sam9263ek";
> +       compatible = "atmel,at91sam9263ek", "atmel,at91sam9263", "atmel,at91sam9";
> +
> +       chosen {
> +               bootargs = "mem=64M root=/dev/mtdblock5 rw rootfstype=ubifs";
> +               stdout-path = "serial0:115200n8";
> +       };
> +
> +       memory {
> +               reg = <0x20000000 0x4000000>;
> +       };
> +
> +       clocks {
> +               slow_xtal {
> +                       clock-frequency = <32768>;
> +               };
> +
> +               main_xtal {
> +                       clock-frequency = <16367660>;
> +               };
> +       };
> +
> +       ahb {
> +               apb {
> +                       dbgu: serial@ffffee00 {
> +                               status = "okay";
> +                       };
> +
> +                       usart0: serial@fff8c000 {
> +                               pinctrl-0 = <
> +                                       &pinctrl_usart0
> +                                       &pinctrl_usart0_rts
> +                                       &pinctrl_usart0_cts>;
> +                               status = "okay";
> +                       };
> +
> +                       macb0: ethernet@fffbc000 {
> +                               phy-mode = "rmii";
> +                               status = "okay";
> +                       };
> +
> +                       usb1: gadget@fff78000 {
> +                               atmel,vbus-gpio = <&pioA 25 GPIO_ACTIVE_HIGH>;
> +                               status = "okay";
> +                       };
> +
> +                       mmc0: mmc@fff80000 {
> +                               pinctrl-0 = <
> +                                       &pinctrl_board_mmc0
> +                                       &pinctrl_mmc0_clk
> +                                       &pinctrl_mmc0_slot0_cmd_dat0
> +                                       &pinctrl_mmc0_slot0_dat1_3>;
> +                               status = "okay";
> +                               slot@0 {
> +                                       reg = <0>;
> +                                       bus-width = <4>;
> +                                       cd-gpios = <&pioE 18 GPIO_ACTIVE_HIGH>;
> +                                       wp-gpios = <&pioE 19 GPIO_ACTIVE_HIGH>;
> +                               };
> +                       };
> +
> +                       pinctrl@fffff200 {
> +                               mmc0 {
> +                                       pinctrl_board_mmc0: mmc0-board {
> +                                               atmel,pins =
> +                                                       <AT91_PIOE 18 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP_DEGLITCH    /* PE18 gpio CD pin pull up and deglitch */
> +                                                        AT91_PIOE 19 AT91_PERIPH_GPIO AT91_PINCTRL_PULL_UP>;   /* PE19 gpio WP pin pull up */
> +                                       };
> +                               };
> +                       };
> +
> +                       spi0: spi@fffa4000 {
> +                               status = "okay";
> +                               cs-gpios = <&pioA 5 0>, <0>, <0>, <0>;
> +                               mtd_dataflash@0 {
> +                                       compatible = "atmel,at45", "atmel,dataflash";
> +                                       spi-max-frequency = <50000000>;
> +                                       reg = <0>;
> +                               };
> +                       };
> +
> +                       watchdog@fffffd40 {
> +                               status = "okay";
> +                       };
> +               };
> +
> +               fb0: fb@0x00700000 {
> +                       display = <&display0>;
> +                       status = "okay";
> +
> +                       display0: display {
> +                               bits-per-pixel = <16>;
> +                               atmel,lcdcon-backlight;
> +                               atmel,dmacon = <0x1>;
> +                               atmel,lcdcon2 = <0x80008002>;
> +                               atmel,guard-time = <1>;
> +
> +                               display-timings {
> +                                       native-mode = <&timing0>;
> +                                       timing0: timing0 {
> +                                               clock-frequency = <4965000>;
> +                                               hactive = <240>;
> +                                               vactive = <320>;
> +                                               hback-porch = <1>;
> +                                               hfront-porch = <33>;
> +                                               vback-porch = <1>;
> +                                               vfront-porch = <0>;
> +                                               hsync-len = <5>;
> +                                               vsync-len = <1>;
> +                                               hsync-active = <1>;
> +                                               vsync-active = <1>;
> +                                       };
> +                               };
> +                       };
> +               };
> +
> +               ebi0: ebi@10000000 {
> +                       status = "okay";
> +
> +                       nand_controller: nand-controller {
> +                               status = "okay";
> +                               pinctrl-0 = <&pinctrl_nand_cs &pinctrl_nand_rb>;
> +                               pinctrl-names = "default";
> +
> +                               nand@3 {
> +                                       reg = <0x3 0x0 0x800000>;
> +                                       rb-gpios = <&pioA 22 GPIO_ACTIVE_HIGH>;
> +                                       cs-gpios = <&pioA 15 GPIO_ACTIVE_HIGH>;
> +                                       nand-bus-width = <8>;
> +                                       nand-ecc-mode = "soft";
> +                                       nand-on-flash-bbt;
> +                                       label = "atmel_nand";
> +
> +                                       partitions {
> +                                               compatible = "fixed-partitions";
> +                                               #address-cells = <1>;
> +                                               #size-cells = <1>;
> +
> +                                               at91bootstrap@0 {
> +                                                       label = "at91bootstrap";
> +                                                       reg = <0x0 0x20000>;
> +                                               };
> +
> +                                               barebox@20000 {
> +                                                       label = "barebox";
> +                                                       reg = <0x20000 0x40000>;
> +                                               };
> +
> +                                               bareboxenv@60000 {
> +                                                       label = "bareboxenv";
> +                                                       reg = <0x60000 0x20000>;
> +                                               };
> +
> +                                               bareboxenv2@80000 {
> +                                                       label = "bareboxenv2";
> +                                                       reg = <0x80000 0x20000>;
> +                                               };
> +
> +                                               oftree@80000 {
> +                                                       label = "oftree";
> +                                                       reg = <0xa0000 0x20000>;
> +                                               };
> +
> +                                               kernel@a0000 {
> +                                                       label = "kernel";
> +                                                       reg = <0xc0000 0x400000>;
> +                                               };
> +
> +                                               rootfs@4a0000 {
> +                                                       label = "rootfs";
> +                                                       reg = <0x4c0000 0x7800000>;
> +                                               };
> +
> +                                               data@7ca0000 {
> +                                                       label = "data";
> +                                                       reg = <0x7cc0000 0x8340000>;
> +                                               };
> +                                       };
> +                               };
> +                       };
> +               };
> +
> +               usb0: ohci@00a00000 {
> +                       num-ports = <2>;
> +                       status = "okay";
> +                       atmel,vbus-gpio = <&pioA 24 GPIO_ACTIVE_HIGH
> +                                          &pioA 21 GPIO_ACTIVE_HIGH
> +                                         >;
> +               };
> +       };
> +
> +       leds {
> +               compatible = "gpio-leds";
> +
> +               d3 {
> +                       label = "d3";
> +                       gpios = <&pioB 7 GPIO_ACTIVE_HIGH>;
> +                       linux,default-trigger = "heartbeat";
> +               };
> +
> +               d2 {
> +                       label = "d2";
> +                       gpios = <&pioC 29 GPIO_ACTIVE_LOW>;
> +                       linux,default-trigger = "nand-disk";
> +               };
> +       };
> +
> +       gpio_keys {
> +               compatible = "gpio-keys";
> +
> +               left_click {
> +                       label = "left_click";
> +                       gpios = <&pioC 5 GPIO_ACTIVE_LOW>;
> +                       linux,code = <272>;
> +                       wakeup-source;
> +               };
> +
> +               right_click {
> +                       label = "right_click";
> +                       gpios = <&pioC 4 GPIO_ACTIVE_LOW>;
> +                       linux,code = <273>;
> +                       wakeup-source;
> +               };
> +       };
> +
> +       i2c-gpio-0 {
> +               status = "okay";
> +
> +               24c512@50 {
> +                       compatible = "24c512";
> +                       reg = <0x50>;
> +                       pagesize = <128>;
> +               };
> +       };
> +};
> diff --git a/arch/arm/mach-at91/Kconfig b/arch/arm/mach-at91/Kconfig
> index f5160ade1..5e9c575cc 100644
> --- a/arch/arm/mach-at91/Kconfig
> +++ b/arch/arm/mach-at91/Kconfig
> @@ -20,6 +20,13 @@ config COMMON_CLK_AT91
>         select COMMON_CLK
>         select MFD_SYSCON
>
> +config MACH_AT91SAM9263EK_DT
> +       def_bool y
> +       depends on MACH_AT91SAM9263EK && OFDEVICE
> +       help
> +         Enabled for at91sam9263ek - evaluation kit.
> +         But only if we need the device tree (bootstrap do not use DT)
> +
>  config HAVE_AT91_SMD
>         bool
>
> --
> 2.12.0
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 5/5] at91sam9263ek: enable devicetree
  2017-12-30  2:02   ` Andrey Smirnov
@ 2017-12-30 21:24     ` Sam Ravnborg
  2017-12-30 22:58       ` [RFC PATCH 1/2] arm: at91: move irq_fixup to header file Sam Ravnborg
  2017-12-30 22:59       ` [RFC PATCH 2/2] arm: at91: simplify soc setup Sam Ravnborg
  0 siblings, 2 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-30 21:24 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

Hi Andrey.

> > +static int check_fdt(void)
> > +{
> > +       return of_machine_is_compatible("atmel,at91sam9263ek");
> > +}
> > +postcore_initcall(check_fdt);
> > +
> 
> Reading this I realized that I wrote buggy initcalls in my original
> AT91SAM9x5EK patches and set a bad example/precedent (I'll submit
> patches to fix that). That check above is just going to print a error
> message, but it wouldn't prevent the code for wrong board from being
> executed (say if you are running image that supports both
> at91sam9263ek and at91sam9g45 on either). IMHO, what you want to do,
> and what I should've done as well, is to add
> 
> if (!of_machine_is_compatible("atmel,at91sam9263ek"))
>     return 0;
> 
> early exit code to the start of very *_callback call. Here's a decent
> example where I didn't screw this up:
> 
> https://git.pengutronix.de/cgit/barebox/tree/arch/arm/boards/zii-vf610-dev/board.c#n55

Lucas Stach already told me so in another mail some months ago.
But I somehow missed it when re-spinning the patches.
So very good that you noticed this.

If you do a respin of the AT91SAM9x5EK then consider if the current
DT support for the display can replace what is used today.

> > +       /* setup bus-width (8 or 16) */
> > +#if defined(CONFIG_MTD_NAND_ATMEL_BUSWIDTH_16)
> > +       ek_nand_smc_config.mode |= AT91_SMC_DBW_16;
> > +#else
> > +       ek_nand_smc_config.mode |= AT91_SMC_DBW_8;
> > +#endif
> > +
> 
> You already use IS_ENABLED below, so it might be more consistent to
> use it here as well.
Agreed, much nicer.

> > +static int at91sam9263ek_phy_init(void)
> > +{
> > +       /*
> > +        * PB27 enables the 50MHz oscillator for Ethernet PHY
> > +        * 1 - enable
> > +        * 0 - disable
> > +        */
> > +       at91_set_gpio_output(AT91_PIN_PB27, 1);
> > +       gpio_set_value(AT91_PIN_PB27, 1); /* 1- enable, 0 - disable */
> > +       return 0;
> > +}
> > +device_initcall(at91sam9263ek_phy_init);
> > +
> 
> This is fine as it is, but you can probably drop the code above in
> favor of gpio-hog in DT file.
Did not know of the hog thingy. Done, thanks,

> >
> > +#if defined(CONFIG_COMMON_CLK_AT91)
> > +static void at91sam9263_initialize(void)
> > +{
> > +       at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
> > +       at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
> > +}
> > +#else
> >  /*
> >   * The peripheral clocks.
> >   */
> > @@ -248,6 +255,7 @@ static void at91sam9263_initialize(void)
> >         at91_add_sam9_smc(0, AT91SAM9263_BASE_SMC0, 0x200);
> >         at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
> >  }
> > +#endif
> 
> Is it too much work to move those two SMC-related calls into board
> file and not compile mach-at91/at91sam9263.c for DT enabled build at
> all?
This is more work than what one would think looking at this diff.
And if done right then both at91sam9263.c and at91sam9263_devices.c
should no longer be used.

But...
- The code uses at91_rtt_irq_fixup() which can only be called from mach-at91.
- setup.c has the at91_init_soc thing that must be defined

so looking into solving these in a nice way as a preparation.

	Sam

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [RFC PATCH 1/2] arm: at91: move irq_fixup to header file
  2017-12-30 21:24     ` Sam Ravnborg
@ 2017-12-30 22:58       ` Sam Ravnborg
  2017-12-30 22:59       ` [RFC PATCH 2/2] arm: at91: simplify soc setup Sam Ravnborg
  1 sibling, 0 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-30 22:58 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

From 8ef36be7ab518c2c61b60665cad0777f6f2398a6 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 30 Dec 2017 22:15:18 +0100
Subject: [PATCH 1/2] arm: at91: move irq_fixup to header file

This allows at91_rtt_irq_fixup() to be used outside
of the mach-at91/ directory.
Adjust all call sites to include the at91_rtt header

Deleting one .c file is another nice side effect of this move.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/mach-at91/Makefile                |  2 +-
 arch/arm/mach-at91/at91sam9260_devices.c   |  1 +
 arch/arm/mach-at91/at91sam9261_devices.c   |  1 +
 arch/arm/mach-at91/at91sam9263_devices.c   |  1 +
 arch/arm/mach-at91/at91sam9g45_devices.c   |  1 +
 arch/arm/mach-at91/generic.h               |  2 --
 arch/arm/mach-at91/include/mach/at91_rtt.h | 16 ++++++++++++++++
 arch/arm/mach-at91/irq_fixup.c             | 22 ----------------------
 8 files changed, 21 insertions(+), 25 deletions(-)
 delete mode 100644 arch/arm/mach-at91/irq_fixup.c

diff --git a/arch/arm/mach-at91/Makefile b/arch/arm/mach-at91/Makefile
index 8462cba60..8adeee9bc 100644
--- a/arch/arm/mach-at91/Makefile
+++ b/arch/arm/mach-at91/Makefile
@@ -1,4 +1,4 @@
-obj-y += setup.o irq_fixup.o
+obj-y += setup.o
 
 ifeq ($(CONFIG_COMMON_CLK_OF_PROVIDER),)
 obj-y += clock.o
diff --git a/arch/arm/mach-at91/at91sam9260_devices.c b/arch/arm/mach-at91/at91sam9260_devices.c
index 99919b3f8..1cb898351 100644
--- a/arch/arm/mach-at91/at91sam9260_devices.c
+++ b/arch/arm/mach-at91/at91sam9260_devices.c
@@ -19,6 +19,7 @@
 #include <mach/at91_pmc.h>
 #include <mach/at91sam9260_matrix.h>
 #include <mach/at91sam9_sdramc.h>
+#include <mach/at91_rtt.h>
 #include <mach/iomux.h>
 #include <mach/io.h>
 #include <mach/cpu.h>
diff --git a/arch/arm/mach-at91/at91sam9261_devices.c b/arch/arm/mach-at91/at91sam9261_devices.c
index e63e0e751..6be390937 100644
--- a/arch/arm/mach-at91/at91sam9261_devices.c
+++ b/arch/arm/mach-at91/at91sam9261_devices.c
@@ -18,6 +18,7 @@
 #include <mach/at91_pmc.h>
 #include <mach/at91sam9261_matrix.h>
 #include <mach/at91sam9_sdramc.h>
+#include <mach/at91_rtt.h>
 #include <mach/board.h>
 #include <mach/iomux.h>
 #include <mach/io.h>
diff --git a/arch/arm/mach-at91/at91sam9263_devices.c b/arch/arm/mach-at91/at91sam9263_devices.c
index 559b77e9d..6302684b2 100644
--- a/arch/arm/mach-at91/at91sam9263_devices.c
+++ b/arch/arm/mach-at91/at91sam9263_devices.c
@@ -18,6 +18,7 @@
 #include <mach/at91_pmc.h>
 #include <mach/at91sam9263_matrix.h>
 #include <mach/at91sam9_sdramc.h>
+#include <mach/at91_rtt.h>
 #include <mach/board.h>
 #include <mach/iomux.h>
 #include <mach/io.h>
diff --git a/arch/arm/mach-at91/at91sam9g45_devices.c b/arch/arm/mach-at91/at91sam9g45_devices.c
index bc4132040..67ca3590c 100644
--- a/arch/arm/mach-at91/at91sam9g45_devices.c
+++ b/arch/arm/mach-at91/at91sam9g45_devices.c
@@ -18,6 +18,7 @@
 #include <mach/at91_pmc.h>
 #include <mach/at91sam9g45_matrix.h>
 #include <mach/at91sam9_ddrsdr.h>
+#include <mach/at91_rtt.h>
 #include <mach/board.h>
 #include <mach/iomux.h>
 #include <mach/io.h>
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index a47bcb2c5..deba01924 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -35,5 +35,3 @@ static inline struct device_d *at91_add_sam9_smc(int id, resource_size_t start,
 	return add_generic_device("at91sam9-smc", id, NULL, start, size,
 				  IORESOURCE_MEM, NULL);
 }
-
-void at91_rtt_irq_fixup(void *base);
diff --git a/arch/arm/mach-at91/include/mach/at91_rtt.h b/arch/arm/mach-at91/include/mach/at91_rtt.h
index 7ec75de8b..85a302858 100644
--- a/arch/arm/mach-at91/include/mach/at91_rtt.h
+++ b/arch/arm/mach-at91/include/mach/at91_rtt.h
@@ -16,6 +16,8 @@
 #ifndef AT91_RTT_H
 #define AT91_RTT_H
 
+#include <io.h>
+
 #define AT91_RTT_MR		0x00			/* Real-time Mode Register */
 #define		AT91_RTT_RTPRES		(0xffff << 0)		/* Real-time Timer Prescaler Value */
 #define		AT91_RTT_ALMIEN		(1 << 16)		/* Alarm Interrupt Enable */
@@ -32,4 +34,18 @@
 #define		AT91_RTT_ALMS		(1 << 0)		/* Real-time Alarm Status */
 #define		AT91_RTT_RTTINC		(1 << 1)		/* Real-time Timer Increment */
 
+
+/*
+ * As the RTT is powered by the backup power so if the interrupt
+ * is still on when the kernel start, the kernel will end up with
+ * dead lock interrupt that it can not clear. Because the interrupt line is
+ * shared with the basic timer (PIT) on AT91_ID_SYS.
+ */
+static void at91_rtt_irq_fixup(void *base)
+{
+        void __iomem *reg = base + AT91_RTT_MR;
+        u32 mr = readl(reg);
+
+        writel(mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN), reg);
+}
 #endif
diff --git a/arch/arm/mach-at91/irq_fixup.c b/arch/arm/mach-at91/irq_fixup.c
deleted file mode 100644
index 9815ac2ca..000000000
--- a/arch/arm/mach-at91/irq_fixup.c
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
- *
- * Under GPLv2 only
- */
-
-#include <io.h>
-#include <mach/at91_rtt.h>
-
-/*
- * As the RTT is powered by the backup power so if the interrupt
- * is still on when the kernel start, the kernel will end up with
- * dead lock interrupt that it can not clear. Because the interrupt line is
- * shared with the basic timer (PIT) on AT91_ID_SYS.
- */
-void at91_rtt_irq_fixup(void *base)
-{
-	void __iomem *reg = base + AT91_RTT_MR;
-	u32 mr = readl(reg);
-
-	writel(mr & ~(AT91_RTT_ALMIEN | AT91_RTT_RTTINCIEN), reg);
-}
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* [RFC PATCH 2/2] arm: at91: simplify soc setup
  2017-12-30 21:24     ` Sam Ravnborg
  2017-12-30 22:58       ` [RFC PATCH 1/2] arm: at91: move irq_fixup to header file Sam Ravnborg
@ 2017-12-30 22:59       ` Sam Ravnborg
  1 sibling, 0 replies; 11+ messages in thread
From: Sam Ravnborg @ 2017-12-30 22:59 UTC (permalink / raw)
  To: Andrey Smirnov; +Cc: Barebox List

From 640f1f0b4496cf34130a64ece2e389431b231607 Mon Sep 17 00:00:00 2001
From: Sam Ravnborg <sam@ravnborg.org>
Date: Sat, 30 Dec 2017 23:48:00 +0100
Subject: [PATCH 2/2] arm: at91: simplify soc setup

The at91 soc support inherited a complex scheme
from the kernel.
This schme did not really give any benefits, and when
migrating at91sam9263ek to use DT it started to
get in the way for a proper way to do things.

Replace the former setup with a simple function
pointer that can be called from setup.c

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/arm/mach-at91/at91rm9200.c  | 10 +++---
 arch/arm/mach-at91/at91sam9260.c | 10 +++---
 arch/arm/mach-at91/at91sam9261.c | 10 +++---
 arch/arm/mach-at91/at91sam9263.c | 10 +++---
 arch/arm/mach-at91/at91sam9g45.c | 10 +++---
 arch/arm/mach-at91/at91sam9n12.c | 10 +++---
 arch/arm/mach-at91/generic.h     |  3 ++
 arch/arm/mach-at91/sama5d3.c     | 10 +++---
 arch/arm/mach-at91/sama5d4.c     | 10 +++---
 arch/arm/mach-at91/setup.c       | 23 +++---------
 arch/arm/mach-at91/soc.h         | 76 ----------------------------------------
 11 files changed, 55 insertions(+), 127 deletions(-)
 delete mode 100644 arch/arm/mach-at91/soc.h

diff --git a/arch/arm/mach-at91/at91rm9200.c b/arch/arm/mach-at91/at91rm9200.c
index d12e8d97b..ba680eb81 100644
--- a/arch/arm/mach-at91/at91rm9200.c
+++ b/arch/arm/mach-at91/at91rm9200.c
@@ -4,7 +4,6 @@
 #include <mach/hardware.h>
 #include <mach/at91_pmc.h>
 
-#include "soc.h"
 #include "clock.h"
 #include "generic.h"
 
@@ -235,6 +234,9 @@ static void __init at91rm9200_initialize(void)
 	at91_add_rm9200_gpio(3, AT91RM9200_BASE_PIOD);
 }
 
-AT91_SOC_START(rm9200)
-	.init = at91rm9200_initialize,
-AT91_SOC_END
+static int at91rm9200_setup(void)
+{
+	at91_boot_soc = at91rm9200_initialize;
+	return 0;
+}
+pure_initcall(at91rm9200_setup);
diff --git a/arch/arm/mach-at91/at91sam9260.c b/arch/arm/mach-at91/at91sam9260.c
index fbd788414..b170cb524 100644
--- a/arch/arm/mach-at91/at91sam9260.c
+++ b/arch/arm/mach-at91/at91sam9260.c
@@ -4,7 +4,6 @@
 #include <mach/hardware.h>
 #include <mach/at91_pmc.h>
 
-#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
@@ -236,6 +235,9 @@ static void at91sam9260_initialize(void)
 	at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9260_BASE_SMC, 0x200);
 }
 
-AT91_SOC_START(sam9260)
-	.init = at91sam9260_initialize,
-AT91_SOC_END
+static int at91sam9260_setup(void)
+{
+        at91_boot_soc = at91sam9260_initialize;
+	return 0;
+}
+pure_initcall(at91sam9260_setup);
diff --git a/arch/arm/mach-at91/at91sam9261.c b/arch/arm/mach-at91/at91sam9261.c
index 37a65ecd3..35aaa9c96 100644
--- a/arch/arm/mach-at91/at91sam9261.c
+++ b/arch/arm/mach-at91/at91sam9261.c
@@ -4,7 +4,6 @@
 #include <mach/hardware.h>
 #include <mach/at91_pmc.h>
 
-#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
@@ -228,6 +227,9 @@ static void at91sam9261_initialize(void)
 	at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9261_BASE_SMC, 0x200);
 }
 
-AT91_SOC_START(sam9261)
-	.init = at91sam9261_initialize,
-AT91_SOC_END
+static int at91sam9261_setup(void)
+{
+	at91_boot_soc = at91sam9261_initialize;
+	return 0;
+}
+pure_initcall(at91sam9261_setup);
diff --git a/arch/arm/mach-at91/at91sam9263.c b/arch/arm/mach-at91/at91sam9263.c
index 35d187b4b..b4eef4932 100644
--- a/arch/arm/mach-at91/at91sam9263.c
+++ b/arch/arm/mach-at91/at91sam9263.c
@@ -4,7 +4,6 @@
 #include <mach/hardware.h>
 #include <mach/at91_pmc.h>
 
-#include "soc.h"
 #include "clock.h"
 #include "generic.h"
 
@@ -249,6 +248,9 @@ static void at91sam9263_initialize(void)
 	at91_add_sam9_smc(1, AT91SAM9263_BASE_SMC1, 0x200);
 }
 
-AT91_SOC_START(sam9263)
-	.init = at91sam9263_initialize,
-AT91_SOC_END
+static int at91sam9263_setup(void)
+{
+        at91_boot_soc = at91sam9263_initialize;
+        return 0;
+}
+pure_initcall(at91sam9263_setup);
diff --git a/arch/arm/mach-at91/at91sam9g45.c b/arch/arm/mach-at91/at91sam9g45.c
index ce6ce90db..488ed7a32 100644
--- a/arch/arm/mach-at91/at91sam9g45.c
+++ b/arch/arm/mach-at91/at91sam9g45.c
@@ -6,7 +6,6 @@
 #include <mach/at91_pmc.h>
 #include <mach/cpu.h>
 
-#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
@@ -264,6 +263,9 @@ static void at91sam9g45_initialize(void)
 	at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9G45_BASE_SMC, 0x200);
 }
 
-AT91_SOC_START(sam9g45)
-	.init = at91sam9g45_initialize,
-AT91_SOC_END
+static int at91sam9g45_setup(void)
+{
+        at91_boot_soc = at91sam9g45_initialize;
+        return 0;
+}
+pure_initcall(at91sam9g45_setup);
diff --git a/arch/arm/mach-at91/at91sam9n12.c b/arch/arm/mach-at91/at91sam9n12.c
index c551f9a74..31c5a18f6 100644
--- a/arch/arm/mach-at91/at91sam9n12.c
+++ b/arch/arm/mach-at91/at91sam9n12.c
@@ -6,7 +6,6 @@
 #include <mach/io.h>
 #include <mach/cpu.h>
 
-#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
@@ -220,6 +219,9 @@ static void at91sam9n12_initialize(void)
 	at91_add_sam9_smc(DEVICE_ID_SINGLE, AT91SAM9N12_BASE_SMC, 0x200);
 }
 
-AT91_SOC_START(sam9n12)
-	.init = at91sam9n12_initialize,
-AT91_SOC_END
+static int at91sam9n12_setup(void)
+{
+        at91_boot_soc = at91sam9n12_initialize;
+        return 0;
+}
+pure_initcall(at91sam9n12_setup);
diff --git a/arch/arm/mach-at91/generic.h b/arch/arm/mach-at91/generic.h
index deba01924..0c27f627a 100644
--- a/arch/arm/mach-at91/generic.h
+++ b/arch/arm/mach-at91/generic.h
@@ -8,6 +8,9 @@
  * published by the Free Software Foundation.
  */
 
+/* function called by setup to perform late init */
+extern void (*at91_boot_soc)(void);
+
  /* Clocks */
 extern int __init at91_clock_init(void);
 
diff --git a/arch/arm/mach-at91/sama5d3.c b/arch/arm/mach-at91/sama5d3.c
index 85efb2d78..8b1bb51f4 100644
--- a/arch/arm/mach-at91/sama5d3.c
+++ b/arch/arm/mach-at91/sama5d3.c
@@ -7,7 +7,6 @@
 #include <mach/cpu.h>
 #include <linux/clk.h>
 
-#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
@@ -391,6 +390,9 @@ static void sama5d3_initialize(void)
 	at91_add_sam9_smc(DEVICE_ID_SINGLE, SAMA5D3_BASE_HSMC + 0x600, 0xa0);
 }
 
-AT91_SOC_START(sama5d3)
-	.init = sama5d3_initialize,
-AT91_SOC_END
+static int sama5d3_setup(void)
+{
+        at91_boot_soc = sama5d3_initialize;
+        return 0;
+}
+pure_initcall(sama5d3_setup);
diff --git a/arch/arm/mach-at91/sama5d4.c b/arch/arm/mach-at91/sama5d4.c
index 4d380ed88..e34847c36 100644
--- a/arch/arm/mach-at91/sama5d4.c
+++ b/arch/arm/mach-at91/sama5d4.c
@@ -16,7 +16,6 @@
 #include <mach/cpu.h>
 #include <linux/clk.h>
 
-#include "soc.h"
 #include "generic.h"
 #include "clock.h"
 
@@ -299,6 +298,9 @@ static void sama5d4_initialize(void)
 	at91_add_sam9_smc(DEVICE_ID_SINGLE, SAMA5D4_BASE_HSMC + 0x600, 0xa0);
 }
 
-AT91_SOC_START(sama5d4)
-	.init = sama5d4_initialize,
-AT91_SOC_END
+static int sama5d4_setup(void)
+{
+        at91_boot_soc = sama5d4_initialize;
+        return 0;
+}
+pure_initcall(sama5d4_setup);
diff --git a/arch/arm/mach-at91/setup.c b/arch/arm/mach-at91/setup.c
index 8f32af043..66516eaeb 100644
--- a/arch/arm/mach-at91/setup.c
+++ b/arch/arm/mach-at91/setup.c
@@ -14,10 +14,10 @@
 #include <mach/cpu.h>
 #include <mach/at91_dbgu.h>
 
-#include "soc.h"
 #include "generic.h"
 
-struct at91_init_soc __initdata at91_boot_soc;
+/* function called by at91_detect() - if assigned */
+void __initdata (*at91_boot_soc)(void);
 
 struct at91_socinfo at91_soc_initdata;
 EXPORT_SYMBOL(at91_soc_initdata);
@@ -48,39 +48,32 @@ static void __init soc_detect(u32 dbgu_base)
 		at91_soc_initdata.type = AT91_SOC_RM9200;
 		if (at91_soc_initdata.subtype == AT91_SOC_SUBTYPE_NONE)
 			at91_soc_initdata.subtype = AT91_SOC_RM9200_BGA;
-		at91_boot_soc = at91rm9200_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9260:
 		at91_soc_initdata.type = AT91_SOC_SAM9260;
-		at91_boot_soc = at91sam9260_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9261:
 		at91_soc_initdata.type = AT91_SOC_SAM9261;
-		at91_boot_soc = at91sam9261_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9263:
 		at91_soc_initdata.type = AT91_SOC_SAM9263;
-		at91_boot_soc = at91sam9263_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9G20:
 		at91_soc_initdata.type = AT91_SOC_SAM9G20;
-		at91_boot_soc = at91sam9260_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9G45:
 		at91_soc_initdata.type = AT91_SOC_SAM9G45;
 		if (cidr == ARCH_ID_AT91SAM9G45ES)
 			at91_soc_initdata.subtype = AT91_SOC_SAM9G45ES;
-		at91_boot_soc = at91sam9g45_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9RL64:
 		at91_soc_initdata.type = AT91_SOC_SAM9RL;
-		at91_boot_soc = at91sam9rl_soc;
 		break;
 
 	case ARCH_ID_AT91SAM9X5:
@@ -89,17 +82,14 @@ static void __init soc_detect(u32 dbgu_base)
 
 	case ARCH_ID_AT91SAM9N12:
 		at91_soc_initdata.type = AT91_SOC_SAM9N12;
-		at91_boot_soc = at91sam9n12_soc;
 		break;
 
 	case ARCH_ID_SAMA5:
 		if (at91_soc_initdata.exid & ARCH_EXID_SAMA5D3) {
 			at91_soc_initdata.type = AT91_SOC_SAMA5D3;
-			at91_boot_soc = at91sama5d3_soc;
 		} else {
 			if (at91_soc_initdata.exid & ARCH_EXID_SAMA5D4) {
 				at91_soc_initdata.type = AT91_SOC_SAMA5D4;
-				at91_boot_soc = at91sama5d4_soc;
 			}
 		}
 		break;
@@ -108,13 +98,11 @@ static void __init soc_detect(u32 dbgu_base)
 	/* at91sam9g10 */
 	if ((socid & ~AT91_CIDR_EXT) == ARCH_ID_AT91SAM9G10) {
 		at91_soc_initdata.type = AT91_SOC_SAM9G10;
-		at91_boot_soc = at91sam9261_soc;
 	}
 	/* at91sam9xe */
 	else if ((cidr & AT91_CIDR_ARCH) == ARCH_FAMILY_AT91SAM9XE) {
 		at91_soc_initdata.type = AT91_SOC_SAM9260;
 		at91_soc_initdata.subtype = AT91_SOC_SAM9XE;
-		at91_boot_soc = at91sam9260_soc;
 	}
 
 	if (!at91_soc_is_detected())
@@ -286,14 +274,11 @@ static int at91_detect(void)
 	if (IS_ENABLED(CONFIG_COMMON_CLK_OF_PROVIDER))
 		return 0;
 
-	if (!at91_soc_is_enabled())
-		panic("AT91: Soc not enabled");
-
 	/* Init clock subsystem */
 	at91_clock_init();
 
-	if (at91_boot_soc.init)
-		at91_boot_soc.init();
+	if (at91_boot_soc != NULL)
+		at91_boot_soc();
 
 	return 0;
 }
diff --git a/arch/arm/mach-at91/soc.h b/arch/arm/mach-at91/soc.h
deleted file mode 100644
index 76e4621f8..000000000
--- a/arch/arm/mach-at91/soc.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
- *
- * Under GPLv2
- */
-
-struct at91_init_soc {
-	int builtin;
-	void (*init)(void);
-};
-
-extern struct at91_init_soc at91_boot_soc;
-extern struct at91_init_soc at91rm9200_soc;
-extern struct at91_init_soc at91sam9260_soc;
-extern struct at91_init_soc at91sam9261_soc;
-extern struct at91_init_soc at91sam9263_soc;
-extern struct at91_init_soc at91sam9g45_soc;
-extern struct at91_init_soc at91sam9rl_soc;
-extern struct at91_init_soc at91sam9x5_soc;
-extern struct at91_init_soc at91sam9n12_soc;
-extern struct at91_init_soc at91sama5d3_soc;
-extern struct at91_init_soc at91sama5d4_soc;
-
-#define AT91_SOC_START(_name)				\
-struct at91_init_soc __initdata at91##_name##_soc	\
- __used							\
-						= {	\
-	.builtin	= 1,				\
-
-#define AT91_SOC_END					\
-};
-
-static inline int at91_soc_is_enabled(void)
-{
-	return at91_boot_soc.builtin;
-}
-
-#if !defined(CONFIG_SOC_AT91RM9200)
-#define at91rm9200_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9260)
-#define at91sam9260_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9261)
-#define at91sam9261_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9263)
-#define at91sam9263_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9G45)
-#define at91sam9g45_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9RL)
-#define at91sam9rl_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9X5)
-#define at91sam9x5_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_SOC_AT91SAM9N12)
-#define at91sam9n12_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_ARCH_SAMA5D3)
-#define at91sama5d3_soc	at91_boot_soc
-#endif
-
-#if !defined(CONFIG_ARCH_SAMA5D4)
-#define at91sama5d4_soc	at91_boot_soc
-#endif
-- 
2.12.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2017-12-30 22:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-27 21:17 [PATCH 0/5] Enable DT support for AT91SAM9263EK Sam Ravnborg
2017-12-27 21:18 ` [PATCH 1/5] at91sam9263ek: enable multi-image build Sam Ravnborg
2017-12-27 21:18 ` [PATCH 2/5] at91sam9263ek: add DT file from Linux kernel v4.14-rc4 Sam Ravnborg
2017-12-30  2:13   ` Andrey Smirnov
2017-12-27 21:18 ` [PATCH 3/5] at91sam9263ek: fix SD card in DT Sam Ravnborg
2017-12-27 21:18 ` [PATCH 4/5] arm: at91: enable CPU specific init with OF Sam Ravnborg
2017-12-27 21:18 ` [PATCH 5/5] at91sam9263ek: enable devicetree Sam Ravnborg
2017-12-30  2:02   ` Andrey Smirnov
2017-12-30 21:24     ` Sam Ravnborg
2017-12-30 22:58       ` [RFC PATCH 1/2] arm: at91: move irq_fixup to header file Sam Ravnborg
2017-12-30 22:59       ` [RFC PATCH 2/2] arm: at91: simplify soc setup Sam Ravnborg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox