Skip to contentSkip to conversation

(no subject)

U-Boot Superseded Angelo Dureghello 2 participants 19 messages Sep 20, 2018 – Oct 2, 2018

Subsystems (3)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

This patch adds an initial fdt support to the m68k architecture.

It has been tested on stmark2 board, with a devicetree and CONFIG_DM_SERIAL=y + CONFIG_DM_SPI=y.

----- test log -----

U-Boot 2018.09-00137-g1be43784f1 (Sep 20 2018 - 22:34:42 +0200)

CPU: Freescale MCF54415 (Mask:a0 Version:2)
CPU CLK 240 MHz BUS CLK 120 MHz FLB CLK 60 MHz INP CLK 30 MHz VCO CLK 480 MHz

SPI:   ready
DRAM:  128 MiB

Loading Environment from SPI Flash... SF: Detected is25lp128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB *** Warning - bad CRC, using default environment

In:    uart at fc060000
Out:   uart at fc060000
Err:   uart at fc060000
Hit any key to stop autoboot:  0 
SF: Detected is25lp128 with page size 256 Bytes, erase size 64 KiB, total 16 MiB
device 0 offset 0x100000, size 0x700000
SF: 7340032 bytes @ 0x100000 Read: OK
## Booting kernel from Legacy Image at 40001000 ...
   Image Name:   mainline kernel
   Created:      2018-09-14  19:06:13 UTC
   Image Type:   M68K Linux Kernel Image (uncompressed)
   Data Size:    2184848 Bytes = 2.1 MiB

Load Address: 40001000
Entry Point: 40001000
Verifying Checksum ... OK
Loading Kernel Image ... OK

#1 lore raw

PATCH 1/7 m68k: add basic set of devicetrees

This patch adds a basic group of devicetrees, one for each cpu, including actually just uart and dspi devices, since these are the drivers supporting devicetree (support added in this patch).

---
 arch/m68k/dts/mcf5208.dtsi                    | 36 ++++++++
 arch/m68k/dts/mcf5227x.dtsi                   | 48 ++++++++++
 arch/m68k/dts/mcf523x.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5249.dtsi                    | 38 ++++++++
 arch/m68k/dts/mcf5253.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5271.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5272.dtsi                    | 38 ++++++++
 arch/m68k/dts/mcf5275.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5282.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5301x.dtsi                   | 48 ++++++++++
 arch/m68k/dts/mcf5307.dtsi                    | 39 +++++++++
 arch/m68k/dts/mcf5329.dtsi                    | 36 ++++++++
 arch/m68k/dts/mcf5441x.dtsi                   | 87 +++++++++++++++++++
 arch/m68k/dts/mcf5445x.dtsi                   | 48 ++++++++++
 doc/device-tree-bindings/serial/mcf-uart.txt  | 19 ++++
 doc/device-tree-bindings/spi/spi-mcf-dspi.txt | 22 +++++
 16 files changed, 679 insertions(+)
 create mode 100644 arch/m68k/dts/mcf5208.dtsi
 create mode 100644 arch/m68k/dts/mcf5227x.dtsi
 create mode 100644 arch/m68k/dts/mcf523x.dtsi
 create mode 100644 arch/m68k/dts/mcf5249.dtsi
 create mode 100644 arch/m68k/dts/mcf5253.dtsi
 create mode 100644 arch/m68k/dts/mcf5271.dtsi
 create mode 100644 arch/m68k/dts/mcf5272.dtsi
 create mode 100644 arch/m68k/dts/mcf5275.dtsi
 create mode 100644 arch/m68k/dts/mcf5282.dtsi
 create mode 100644 arch/m68k/dts/mcf5301x.dtsi
 create mode 100644 arch/m68k/dts/mcf5307.dtsi
 create mode 100644 arch/m68k/dts/mcf5329.dtsi
 create mode 100644 arch/m68k/dts/mcf5441x.dtsi
 create mode 100644 arch/m68k/dts/mcf5445x.dtsi
 create mode 100644 doc/device-tree-bindings/serial/mcf-uart.txt
 create mode 100644 doc/device-tree-bindings/spi/spi-mcf-dspi.txt
arch/m68k/dts/mcf5208.dtsi new file +36 -0
new file mode 100644
index 0000000000..558d8bf41a
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ */
+
+/ {
+	compatible = "fsl,mcf5208";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		uart0: uart at fc060000 {
+			compatible = "fsl,mcf-uart";
+			reg = <0xfc060000 0x40>;
+			status = "disabled";
+		};
+
+		uart1: uart at fc064000 {
+			compatible = "fsl,mcf-uart";
+			reg = <0xfc064000 0x40>;
+			status = "disabled";
+		};
+
+		uart2: uart at fc068000 {
+			compatible = "fsl,mcf-uart";
+			reg = <0xfc068000 0x40>;
+			status = "disabled";
+		};
+	};
+};
arch/m68k/dts/mcf5227x.dtsi new file +48 -0

48 lines not on this page · raw message

arch/m68k/dts/mcf523x.dtsi new file +44 -0

44 lines not on this page · raw message

arch/m68k/dts/mcf5249.dtsi new file +38 -0
new file mode 100644
index 0000000000..248b3dc68b
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ */
+
+/ {
+	compatible = "fsl,mcf5249";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		mbar: mbar at 10000000 {
+			compatible = "simple-bus";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x00000000 0x10000000 0x10000>;
+			reg = <0x10000000 0x10000>;
+
+			uart0: uart at 1c0 {
+				compatible = "fsl,mcf-uart";
+				reg = <0x1c0 0x40>;
+				status = "disabled";
+			};
+
+			uart1: uart at 200 {
+				compatible = "fsl,mcf-uart";
+				reg = <0x200 0x40>;
+				status = "disabled";
+			};
+		};
+	};
+};
arch/m68k/dts/mcf5253.dtsi new file +44 -0

44 lines not on this page · raw message

arch/m68k/dts/mcf5271.dtsi new file +44 -0

44 lines not on this page · raw message

arch/m68k/dts/mcf5272.dtsi new file +38 -0
new file mode 100644
index 0000000000..a56117728b
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ */
+
+/ {
+	compatible = "fsl,mcf5272";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		mbar: mbar at 10000000 {
+			compatible = "simple-bus";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x00000000 0x10000000 0x10000>;
+			reg = <0x10000000 0x10000>;
+
+			uart0: uart at 100 {
+				compatible = "fsl,mcf-uart";
+				reg = <0x100 0x40>;
+				status = "disabled";
+			};
+
+			uart1: uart at 140 {
+				compatible = "fsl,mcf-uart";
+				reg = <0x140 0x40>;
+				status = "disabled";
+			};
+		};
+	};
+};
arch/m68k/dts/mcf5275.dtsi new file +44 -0

44 lines not on this page · raw message

arch/m68k/dts/mcf5282.dtsi new file +44 -0

44 lines not on this page · raw message

arch/m68k/dts/mcf5301x.dtsi new file +48 -0

48 lines not on this page · raw message

arch/m68k/dts/mcf5307.dtsi new file +39 -0
new file mode 100644
index 0000000000..e199cf9991
@@ -0,0 +1,39 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ */
+
+/ {
+	compatible = "fsl,mcf5307";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		/* MBAR */
+		mbar: mbar at 10000000 {
+			compatible = "simple-bus";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0x00000000 0x10000000 0x10000>;
+			reg = <0x10000000 0x10000>;
+
+			uart0: uart at 1c0 {
+				compatible = "fsl,mcf-uart";
+				reg = <0x1c0 0x40>;
+				status = "disabled";
+			};
+
+			uart1: uart at 200 {
+				compatible = "fsl,mcf-uart";
+				reg = <0x200 0x40>;
+				status = "disabled";
+			};
+		};
+	};
+};
arch/m68k/dts/mcf5329.dtsi new file +36 -0
new file mode 100644
index 0000000000..aeaa6430af
@@ -0,0 +1,36 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ */
+
+/ {
+	compatible = "fsl,mcf5329";
+
+	aliases {
+		serial0 = &uart0;
+	};
+
+	soc {
+		compatible = "simple-bus";
+		#address-cells = <1>;
+		#size-cells = <1>;
+
+		uart0: uart at fc060000 {
+			compatible = "fsl,mcf-uart";
+			reg = <0xfc060000 0x40>;
+			status = "disabled";
+		};
+
+		uart1: uart at fc064000 {
+			compatible = "fsl,mcf-uart";
+			reg = <0xfc064000 0x40>;
+			status = "disabled";
+		};
+
+		uart2: uart at fc068000 {
+			compatible = "fsl,mcf-uart";
+			reg = <0xfc068000 0x40>;
+			status = "disabled";
+		};
+	};
+};
arch/m68k/dts/mcf5441x.dtsi new file +87 -0

87 lines not on this page · raw message

arch/m68k/dts/mcf5445x.dtsi new file +48 -0

48 lines not on this page · raw message

doc/device-tree-bindings/serial/mcf-uart.txt new file +19 -0
new file mode 100644
index 0000000000..d73f764c01
@@ -0,0 +1,19 @@
+Freescale ColdFire UART
+
+Required properties:
+- compatible : should be "fsl,mcf-uart"
+- reg: start address and size of the registers
+
+Example:
+
+soc {
+	compatible = "simple-bus";
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	uart0: uart at fc060000 {
+		compatible = "fsl,mcf-uart";
+		reg = <0xfc060000 0x40>;
+		status = "disabled";
+	};
+};
doc/device-tree-bindings/spi/spi-mcf-dspi.txt new file +22 -0
new file mode 100644
index 0000000000..1a02e674af
@@ -0,0 +1,22 @@
+Freescale ColdFire DSPI controller
+
+Required properties:
+- compatible : "fsl,mcf-dspi",
+- #address-cells: <1>, as required by generic SPI binding,
+- #size-cells: <0>, also as required by generic SPI binding,
+- reg : offset and length of the register set for the device,
+- spi-max-frequency : max supported spi frequency,
+- num-cs : the number of the chipselect signals,
+- spi-mode: spi motorola mode, 0 to 3,
+
+Example:
+
+dspi0: dspi at fc05c000 {
+	compatible = "fsl,mcf-dspi";
+	#address-cells = <1>;
+	#size-cells = <0>;
+	reg = <0xfc05c000 0x100>;
+	spi-max-frequency = <50000000>;
+	num-cs = <4>;
+	spi-mode = <0>;
+};
Signature · 1 line
2.19.0
#3 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

In reply to Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h
drivers/spi/Kconfig +12 -6
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
 	  used to access the SPI NOR flash on platforms embedding this
 	  Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
 	bool "Designware SPI driver"
 	help
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
-config SOFT_SPI
-	bool "Soft SPI driver"
-	help
-	 Enable Soft SPI driver. This driver is to use GPIO simulate
-	 the SPI protocol.
-
 config CF_SPI
 	bool "ColdFire SPI driver"
 	help
 	  Enable the ColdFire SPI driver. This driver can be used on
 	  some m68k SoCs.
 
+config SOFT_SPI
+	bool "Soft SPI driver"
+	help
+	 Enable Soft SPI driver. This driver is to use GPIO simulate
+	 the SPI protocol.
+
 config FSL_ESPI
 	bool "Freescale eSPI driver"
 	help
drivers/spi/cf_spi.c +332 -163

616 lines not on this page · raw message

include/dm/platform_data/spi_coldfire.h new file +25 -0
new file mode 100644
index 0000000000..ee8726ad51
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2018  Angelo Dureghello <[email protected]>
+ */
+
+#ifndef __spi_coldfire_h
+#define __spi_coldfire_h
+
+/*
+ * struct coldfire_spi_platdata - information about a coldfire spi module
+ *
+ * @regs_addr: base address for module registers
+ * @speed_hz: default SCK frequency
+ * @mode: default SPI mode
+ * @num_cs: number of DSPI chipselect signals
+ */
+struct coldfire_spi_platdata {
+	fdt_addr_t regs_addr;
+	uint speed_hz;
+	uint mode;
+	uint num_cs;
+};
+
+#endif /* __spi_coldfire_h */
+
Signature · 1 line
2.19.0
#10 lore raw

PATCH 3/7 drivers: serial: mcfuart: add DT support

In reply to Angelo Dureghello

This patch adds devicetree support to the mcfuart.c driver.

---
 drivers/serial/mcfuart.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
drivers/serial/mcfuart.c +28 -0
index 1371049de2..5896a19805 100644
@@ -5,6 +5,9 @@
  *
  * Modified to add device model (DM) support
  * (C) Copyright 2015  Angelo Dureghello <[email protected]>
+ *
+ * Modified to add fdt support
+ * (C) Copyright 2018  Angelo Dureghello <[email protected]>
  */
 
 /*
@@ -212,6 +215,23 @@ static int coldfire_serial_pending(struct udevice *dev, bool input)
 	return 0;
 }
 
+static int coldfire_ofdata_to_platdata(struct udevice *dev)
+{
+	struct coldfire_serial_platdata *plat = dev_get_platdata(dev);
+	fdt_addr_t addr_base;
+
+	addr_base = devfdt_get_addr(dev);
+	if (addr_base == FDT_ADDR_T_NONE)
+		return -ENODEV;
+
+	plat->base = (uint32_t)addr_base;
+
+	plat->port = dev->seq;
+	plat->baudrate = gd->baudrate;
+
+	return 0;
+}
+
 static const struct dm_serial_ops coldfire_serial_ops = {
 	.putc = coldfire_serial_putc,
 	.pending = coldfire_serial_pending,
@@ -219,9 +239,17 @@ static const struct dm_serial_ops coldfire_serial_ops = {
 	.setbrg = coldfire_serial_setbrg,
 };
 
+static const struct udevice_id coldfire_serial_ids[] = {
+	{ .compatible = "fsl,mcf-uart" },
+	{ }
+};
+
 U_BOOT_DRIVER(serial_coldfire) = {
 	.name = "serial_coldfire",
 	.id = UCLASS_SERIAL,
+	.of_match = coldfire_serial_ids,
+	.ofdata_to_platdata = coldfire_ofdata_to_platdata,
+	.platdata_auto_alloc_size = sizeof(struct coldfire_serial_platdata),
 	.probe = coldfire_serial_probe,
 	.ops = &coldfire_serial_ops,
 	.flags = DM_FLAG_PRE_RELOC,
Signature · 1 line
2.19.0
#12 lore raw

PATCH 4/7 drivers: serial: mcfuart: add Kconfig option

In reply to Angelo Dureghello

This patch adds missing CONFIG_MCFUART to Kconfig.

---
 drivers/serial/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/serial/Kconfig +7 -0
index 5fa27254e3..dcbe999776 100644
@@ -499,6 +499,13 @@ config MVEBU_A3700_UART
 	  Choose this option to add support for UART driver on the Marvell
 	  Armada 3700 SoC. The base address is configured via DT.
 
+config MCFUART
+	bool "Freescale ColdFire UART support"
+        default n
+        help
+          Choose this option to add support for UART driver on the ColFfire
+          SoC's family.
+
 config MXC_UART
 	bool "IMX serial port support"
 	depends on MX5 || MX6
Signature · 1 line
2.19.0
#14 lore raw

PATCH 5/7 m68k: architecture changes to support fdt

In reply to Angelo Dureghello

This patch adds ftd support to the m68k architecture.

---
 arch/Kconfig             | 1 +
 arch/m68k/Kconfig        | 2 ++
 arch/m68k/cpu/u-boot.lds | 2 ++
 3 files changed, 5 insertions(+)
arch/Kconfig +1 -0
index bf1b4a9afa..d1917f91e1 100644
@@ -28,6 +28,7 @@ config M68K
 	select HAVE_PRIVATE_LIBGCC
 	select SYS_BOOT_GET_CMDLINE
 	select SYS_BOOT_GET_KBD
+	select SUPPORT_OF_CONTROL
 
 config MICROBLAZE
 	bool "MicroBlaze architecture"
arch/m68k/Kconfig +2 -0
index 1f6df5c870..60cb9411ed 100644
@@ -199,6 +199,8 @@ config TARGET_AMCORE
 config TARGET_STMARK2
         bool "Support stmark2"
         select M54418
+	select OF_CONTROL
+	select DM
 
 endchoice
 
arch/m68k/cpu/u-boot.lds +2 -0
index 96451208e5..e61630db20 100644
@@ -75,6 +75,8 @@ SECTIONS
 	. = ALIGN(256);
 	__init_end = .;
 
+	_end = .;
+
 	__bss_start = .;
 	.bss (NOLOAD)       :
 	{
Signature · 1 line
2.19.0
#16 lore raw

PATCH 6/7 m68k: add stmark2 fdt support

In reply to Angelo Dureghello

This patch adds stmark2 board fdt support to the m68k arch.

---
 arch/m68k/dts/Makefile    | 12 ++++++++++++
 arch/m68k/dts/stmark2.dts | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 arch/m68k/dts/Makefile
 create mode 100644 arch/m68k/dts/stmark2.dts
arch/m68k/dts/Makefile new file +12 -0
new file mode 100644
index 0000000000..9d2e17abf3
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+dtb-$(CONFIG_TARGET_STMARK2) += stmark2.dtb
+targets += $(dtb-y)
+
+DTC_FLAGS += -R 4 -p 0x1000
+
+PHONY += dtbs
+dtbs: $(addprefix $(obj)/, $(dtb-y))
+	@:
+
+clean-files := *.dtb
arch/m68k/dts/stmark2.dts new file +34 -0
new file mode 100644
index 0000000000..fd8ce4fa35
@@ -0,0 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ */
+
+/dts-v1/;
+/include/ "mcf5441x.dtsi"
+
+/ {
+	model = "Sysam stmark2";
+	compatible = "sysam,stmark2";
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+};
+
+&uart0 {
+	u-boot,dm-pre-reloc;
+	status = "okay";
+};
+
+&dspi0 {
+	spi-mode = <3>;
+	status = "okay";
+
+	flash: is25lp128 at 1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "spi-flash";
+		spi-max-frequency = <60000000>;
+		reg = <1>;
+	};
+};
Signature · 1 line
2.19.0
#18 lore raw

PATCH 7/7 board: stmark2: updates for DM and DT

In reply to Angelo Dureghello

This patch enables fdt, and enables DM uart and spi.

---
 configs/stmark2_defconfig | 6 ++++++
 1 file changed, 6 insertions(+)
configs/stmark2_defconfig +6 -0
index 48e851d4a4..7b05b2e20b 100644
@@ -2,6 +2,7 @@ CONFIG_M68K=y
 CONFIG_SYS_TEXT_BASE=0x47E00000
 CONFIG_TARGET_STMARK2=y
 CONFIG_SYS_EXTRA_OPTIONS="CF_SBF,SYS_SERIAL_BOOT,SYS_INPUT_CLKSRC=30000000"
+CONFIG_DEFAULT_FDT_FILE="stmark2"
 # CONFIG_DISPLAY_BOARDINFO is not set
 CONFIG_HUSH_PARSER=y
 # CONFIG_CMDLINE_EDITING is not set
@@ -19,12 +20,17 @@ CONFIG_CMD_CACHE=y
 CONFIG_CMD_MTDPARTS=y
 CONFIG_MTDIDS_DEFAULT="nor0=spi-flash.0"
 CONFIG_MTDPARTS_DEFAULT="mtdparts=spi-flash.0:1m(u-boot),7m(kernel),-(rootfs)"
+CONFIG_OF_EMBED=y
+CONFIG_DEFAULT_DEVICE_TREE="stmark2"
 CONFIG_ENV_IS_IN_SPI_FLASH=y
 # CONFIG_NET is not set
 CONFIG_MTD_DEVICE=y
 CONFIG_SPI_FLASH=y
 CONFIG_SPI_FLASH_ISSI=y
+CONFIG_DM_SERIAL=y
 CONFIG_SPI_FLASH_MTD=y
 CONFIG_SPI=y
+CONFIG_DM_SPI=y
+CONFIG_DM_SPI_FLASH=y
 CONFIG_CF_SPI=y
 CONFIG_REGEX=y
Signature · 1 line
2.19.0
#2 lore raw

PATCH 1/7 m68k: add basic set of devicetrees

In reply to Angelo Dureghello
Quoted 32 lines · Angelo Dureghello

This patch adds a basic group of devicetrees, one for each cpu, including actually just uart and dspi devices, since these are the drivers supporting devicetree (support added in this patch).

---
 arch/m68k/dts/mcf5208.dtsi                    | 36 ++++++++
 arch/m68k/dts/mcf5227x.dtsi                   | 48 ++++++++++
 arch/m68k/dts/mcf523x.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5249.dtsi                    | 38 ++++++++
 arch/m68k/dts/mcf5253.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5271.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5272.dtsi                    | 38 ++++++++
 arch/m68k/dts/mcf5275.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5282.dtsi                    | 44 ++++++++++
 arch/m68k/dts/mcf5301x.dtsi                   | 48 ++++++++++
 arch/m68k/dts/mcf5307.dtsi                    | 39 +++++++++
 arch/m68k/dts/mcf5329.dtsi                    | 36 ++++++++
 arch/m68k/dts/mcf5441x.dtsi                   | 87 +++++++++++++++++++
 arch/m68k/dts/mcf5445x.dtsi                   | 48 ++++++++++
 doc/device-tree-bindings/serial/mcf-uart.txt  | 19 ++++
 doc/device-tree-bindings/spi/spi-mcf-dspi.txt | 22 +++++
 16 files changed, 679 insertions(+)
 create mode 100644 arch/m68k/dts/mcf5208.dtsi
 create mode 100644 arch/m68k/dts/mcf5227x.dtsi
 create mode 100644 arch/m68k/dts/mcf523x.dtsi
 create mode 100644 arch/m68k/dts/mcf5249.dtsi
 create mode 100644 arch/m68k/dts/mcf5253.dtsi
 create mode 100644 arch/m68k/dts/mcf5271.dtsi
 create mode 100644 arch/m68k/dts/mcf5272.dtsi
 create mode 100644 arch/m68k/dts/mcf5275.dtsi
Quoted 8 lines
 create mode 100644 arch/m68k/dts/mcf5282.dtsi
 create mode 100644 arch/m68k/dts/mcf5301x.dtsi
 create mode 100644 arch/m68k/dts/mcf5307.dtsi
 create mode 100644 arch/m68k/dts/mcf5329.dtsi
 create mode 100644 arch/m68k/dts/mcf5441x.dtsi
 create mode 100644 arch/m68k/dts/mcf5445x.dtsi
 create mode 100644 doc/device-tree-bindings/serial/mcf-uart.txt
 create mode 100644 doc/device-tree-bindings/spi/spi-mcf-dspi.txt
#4 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

In reply to Angelo Dureghello

Hi Angelo,

Quoted 7 lines · Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

Quoted 8 lines
---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h

Good to see this.

Quoted 18 lines
drivers/spi/Kconfig +6 -0
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
          used to access the SPI NOR flash on platforms embedding this
          Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
        bool "Designware SPI driver"
        help

drivers/spi/Kconfig config ZYNQMP_GQSPI · line 251

Quoted 8 lines
drivers/spi/Kconfig +0 -5
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
-config SOFT_SPI
-       bool "Soft SPI driver"
-       help
-        Enable Soft SPI driver. This driver is to use GPIO simulate
-        the SPI protocol.

How come this is changing? That should be a separate patch.

Quoted 71 lines
drivers/spi/Kconfig +6 -1
-
 config CF_SPI
        bool "ColdFire SPI driver"
        help
          Enable the ColdFire SPI driver. This driver can be used on
          some m68k SoCs.
 
+config SOFT_SPI
+       bool "Soft SPI driver"
+       help
+        Enable Soft SPI driver. This driver is to use GPIO simulate
+        the SPI protocol.
+
 config FSL_ESPI
        bool "Freescale eSPI driver"
        help
drivers/spi/cf_spi.c +18 -7
index 522631cbbf..11a11f79c4 100644
@@ -6,16 +6,27 @@
  *
  * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
+ *
+ * Support for device model:
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ *
  */
 
 #include <common.h>
+#include <dm.h>
+#include <dm/platform_data/spi_coldfire.h>
 #include <spi.h>
 #include <malloc.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 
-struct cf_spi_slave {
+struct coldfire_spi_priv {
+#ifndef CONFIG_DM_SPI
        struct spi_slave slave;
+#endif
+       struct dspi *regs;
        uint baudrate;
+       int mode;
        int charbit;
 };
 
@@ -38,14 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_MODE_MOD   0x00200000
 #define SPI_DBLRATE    0x00100000
 
-static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave)
-{
-       return container_of(slave, struct cf_spi_slave, slave);
-}
+/* Default values */
+#define MCF_DSPI_DEFAULT_SCK_FREQ      10000000
+#define MCF_DSPI_MAX_CHIPSELECTS       4
+#define MCF_DSPI_MODE                  0
 
-static void cfspi_init(void)
+static void __spi_init(struct coldfire_spi_priv *cfspi)
 {
-       volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
+       struct dspi *dspi = cfspi->regs;
 
        cfspi_port_conf();      /* port configuration */
 

drivers/spi/cf_spi.c static void cfspi_init(void) · line 70

Quoted 5 lines
drivers/spi/cf_spi.c +1 -1
@@ -56,125 +67,32 @@ static void cfspi_init(void)
 
        /* Default setting in platform configuration */
 #ifdef CONFIG_SYS_DSPI_CTAR0
-       dspi->ctar[0] = CONFIG_SYS_DSPI_CTAR0;
+       writel(CONFIG_SYS_DSPI_CTAR0, &dspi->ctar[0]);

What is going on here? I think these CONFIG options are addresses? If so, they should be read from the DT, not a CONFIG.

Quoted 21 lines
drivers/spi/cf_spi.c +5 -5
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR1
-       dspi->ctar[1] = CONFIG_SYS_DSPI_CTAR1;
+       writel(CONFIG_SYS_DSPI_CTAR1, &dspi->ctar[1]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR2
-       dspi->ctar[2] = CONFIG_SYS_DSPI_CTAR2;
+       writel(CONFIG_SYS_DSPI_CTAR2, &dspi->ctar[2]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR3
-       dspi->ctar[3] = CONFIG_SYS_DSPI_CTAR3;
+       writel(CONFIG_SYS_DSPI_CTAR3, &dspi->ctar[3]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR4
-       dspi->ctar[4] = CONFIG_SYS_DSPI_CTAR4;
+       writel(CONFIG_SYS_DSPI_CTAR4, &dspi->ctar[4]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR5
-       dspi->ctar[5] = CONFIG_SYS_DSPI_CTAR5;
+       writel(CONFIG_SYS_DSPI_CTAR5, &dspi->ctar[5]);
 #endif

drivers/spi/cf_spi.c static void cfspi_init(void) · line 94

Quoted 10 lines
drivers/spi/cf_spi.c +2 -2
 #ifdef CONFIG_SYS_DSPI_CTAR6
-       dspi->ctar[6] = CONFIG_SYS_DSPI_CTAR6;
+       writel(CONFIG_SYS_DSPI_CTAR6, &dspi->ctar[6]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR7
-       dspi->ctar[7] = CONFIG_SYS_DSPI_CTAR7;
+       writel(CONFIG_SYS_DSPI_CTAR7, &dspi->ctar[7]);
 #endif
 }
 

[..]

Regards,
Simon

#13 lore raw

PATCH 4/7 drivers: serial: mcfuart: add Kconfig option

In reply to Angelo Dureghello
Quoted 7 lines · Angelo Dureghello

This patch adds missing CONFIG_MCFUART to Kconfig.

---
 drivers/serial/Kconfig | 7 +++++++
 1 file changed, 7 insertions(+)

Suggest you expand the help to mention what features the driver supports (baud rates, serial format?)

Quoted 25 lines
drivers/serial/Kconfig +7 -1
index 5fa27254e3..dcbe999776 100644
@@ -499,6 +499,13 @@ config MVEBU_A3700_UART
          Choose this option to add support for UART driver on the Marvell
          Armada 3700 SoC. The base address is configured via DT.
 
+config MCFUART
+       bool "Freescale ColdFire UART support"
+        default n
+        help
+          Choose this option to add support for UART driver on the ColFfire
+          SoC's family.
+
 config MXC_UART
        bool "IMX serial port support"
        depends on MX5 || MX6
--

2.19.0

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

#17 lore raw

PATCH 6/7 m68k: add stmark2 fdt support

In reply to Angelo Dureghello
Quoted 9 lines · Angelo Dureghello

This patch adds stmark2 board fdt support to the m68k arch.

---
 arch/m68k/dts/Makefile    | 12 ++++++++++++
 arch/m68k/dts/stmark2.dts | 34 ++++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)
 create mode 100644 arch/m68k/dts/Makefile
 create mode 100644 arch/m68k/dts/stmark2.dts
#5 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

In reply to Simon Glass

Hi Simon,

thanks for the review.

Quoted 42 lines · Simon Glass

Hi Angelo,

Quoted 7 lines · Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

Quoted 8 lines
---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h

Good to see this.

Quoted 21 lines
drivers/spi/Kconfig +6 -0
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
          used to access the SPI NOR flash on platforms embedding this
          Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
        bool "Designware SPI driver"
        help
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
Quoted 8 lines

drivers/spi/Kconfig config ZYNQMP_GQSPI · line 251

Quoted 5 lines
drivers/spi/Kconfig +0 -5
-config SOFT_SPI
-       bool "Soft SPI driver"
-       help
-        Enable Soft SPI driver. This driver is to use GPIO simulate
-        the SPI protocol.

How come this is changing? That should be a separate patch.

I just respected Kconfig alphabetical order, SOFT_SPI is just moved after.

Quoted 72 lines
Quoted 72 lines
drivers/spi/Kconfig +6 -1
-
 config CF_SPI
        bool "ColdFire SPI driver"
        help
          Enable the ColdFire SPI driver. This driver can be used on
          some m68k SoCs.
 
+config SOFT_SPI
+       bool "Soft SPI driver"
+       help
+        Enable Soft SPI driver. This driver is to use GPIO simulate
+        the SPI protocol.
+
 config FSL_ESPI
        bool "Freescale eSPI driver"
        help
drivers/spi/cf_spi.c +18 -7
index 522631cbbf..11a11f79c4 100644
@@ -6,16 +6,27 @@
  *
  * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
+ *
+ * Support for device model:
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ *
  */
 
 #include <common.h>
+#include <dm.h>
+#include <dm/platform_data/spi_coldfire.h>
 #include <spi.h>
 #include <malloc.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 
-struct cf_spi_slave {
+struct coldfire_spi_priv {
+#ifndef CONFIG_DM_SPI
        struct spi_slave slave;
+#endif
+       struct dspi *regs;
        uint baudrate;
+       int mode;
        int charbit;
 };
 
@@ -38,14 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_MODE_MOD   0x00200000
 #define SPI_DBLRATE    0x00100000
 
-static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave)
-{
-       return container_of(slave, struct cf_spi_slave, slave);
-}
+/* Default values */
+#define MCF_DSPI_DEFAULT_SCK_FREQ      10000000
+#define MCF_DSPI_MAX_CHIPSELECTS       4
+#define MCF_DSPI_MODE                  0
 
-static void cfspi_init(void)
+static void __spi_init(struct coldfire_spi_priv *cfspi)
 {
-       volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
+       struct dspi *dspi = cfspi->regs;
 
        cfspi_port_conf();      /* port configuration */
 
@@ -56,125 +67,32 @@ static void cfspi_init(void)
 
Quoted 8 lines

drivers/spi/cf_spi.c static void cfspi_init(void) · line 70

Quoted 4 lines
drivers/spi/cf_spi.c +1 -1
        /* Default setting in platform configuration */
 #ifdef CONFIG_SYS_DSPI_CTAR0
-       dspi->ctar[0] = CONFIG_SYS_DSPI_CTAR0;
+       writel(CONFIG_SYS_DSPI_CTAR0, &dspi->ctar[0]);

What is going on here? I think these CONFIG options are addresses? If so, they should be read from the DT, not a CONFIG.

These are just default settings for each channel (bus), actually coming from the include/configs/boardxxx.h. Their speed an mode bitfields are rewritten later, with values coming from devicetree.
Some driver #define the default value inside the driver itself, in case i may change in this way. No one seems reading them from device tree.

Quoted 32 lines
Quoted 21 lines
drivers/spi/cf_spi.c +5 -5
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR1
-       dspi->ctar[1] = CONFIG_SYS_DSPI_CTAR1;
+       writel(CONFIG_SYS_DSPI_CTAR1, &dspi->ctar[1]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR2
-       dspi->ctar[2] = CONFIG_SYS_DSPI_CTAR2;
+       writel(CONFIG_SYS_DSPI_CTAR2, &dspi->ctar[2]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR3
-       dspi->ctar[3] = CONFIG_SYS_DSPI_CTAR3;
+       writel(CONFIG_SYS_DSPI_CTAR3, &dspi->ctar[3]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR4
-       dspi->ctar[4] = CONFIG_SYS_DSPI_CTAR4;
+       writel(CONFIG_SYS_DSPI_CTAR4, &dspi->ctar[4]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR5
-       dspi->ctar[5] = CONFIG_SYS_DSPI_CTAR5;
+       writel(CONFIG_SYS_DSPI_CTAR5, &dspi->ctar[5]);
 #endif

drivers/spi/cf_spi.c static void cfspi_init(void) · line 94

Quoted 10 lines
drivers/spi/cf_spi.c +2 -2
 #ifdef CONFIG_SYS_DSPI_CTAR6
-       dspi->ctar[6] = CONFIG_SYS_DSPI_CTAR6;
+       writel(CONFIG_SYS_DSPI_CTAR6, &dspi->ctar[6]);
 #endif
 #ifdef CONFIG_SYS_DSPI_CTAR7
-       dspi->ctar[7] = CONFIG_SYS_DSPI_CTAR7;
+       writel(CONFIG_SYS_DSPI_CTAR7, &dspi->ctar[7]);
 #endif
 }
 
Quoted 4 lines

[..]

Regards,
Simon

Regards,
Angelo

#6 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

Hi Angelo,

Quoted 55 lines · Angelo Dureghello

Hi Simon,

thanks for the review.

Quoted 42 lines · Simon Glass

Hi Angelo,

Quoted 7 lines · Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

Quoted 8 lines
---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h

Good to see this.

Quoted 21 lines
drivers/spi/Kconfig +6 -0
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
          used to access the SPI NOR flash on platforms embedding this
          Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
        bool "Designware SPI driver"
        help
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
Quoted 8 lines

drivers/spi/Kconfig config ZYNQMP_GQSPI · line 251

Quoted 5 lines
drivers/spi/Kconfig +0 -5
-config SOFT_SPI
-       bool "Soft SPI driver"
-       help
-        Enable Soft SPI driver. This driver is to use GPIO simulate
-        the SPI protocol.

How come this is changing? That should be a separate patch.

Quoted 1 line

I just respected Kconfig alphabetical order, SOFT_SPI is just moved after.

OK, well I do think this should be in a separate patch.

Quoted 82 lines
Quoted 73 lines
Quoted 73 lines
drivers/spi/Kconfig +6 -1
-
 config CF_SPI
        bool "ColdFire SPI driver"
        help
          Enable the ColdFire SPI driver. This driver can be used on
          some m68k SoCs.
 
+config SOFT_SPI
+       bool "Soft SPI driver"
+       help
+        Enable Soft SPI driver. This driver is to use GPIO simulate
+        the SPI protocol.
+
 config FSL_ESPI
        bool "Freescale eSPI driver"
        help
drivers/spi/cf_spi.c +18 -7
index 522631cbbf..11a11f79c4 100644
@@ -6,16 +6,27 @@
  *
  * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
+ *
+ * Support for device model:
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ *
  */
 
 #include <common.h>
+#include <dm.h>
+#include <dm/platform_data/spi_coldfire.h>
 #include <spi.h>
 #include <malloc.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 
-struct cf_spi_slave {
+struct coldfire_spi_priv {
+#ifndef CONFIG_DM_SPI
        struct spi_slave slave;
+#endif
+       struct dspi *regs;
        uint baudrate;
+       int mode;
        int charbit;
 };
 
@@ -38,14 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_MODE_MOD   0x00200000
 #define SPI_DBLRATE    0x00100000
 
-static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave)
-{
-       return container_of(slave, struct cf_spi_slave, slave);
-}
+/* Default values */
+#define MCF_DSPI_DEFAULT_SCK_FREQ      10000000
+#define MCF_DSPI_MAX_CHIPSELECTS       4
+#define MCF_DSPI_MODE                  0
 
-static void cfspi_init(void)
+static void __spi_init(struct coldfire_spi_priv *cfspi)
 {
-       volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
+       struct dspi *dspi = cfspi->regs;
 
        cfspi_port_conf();      /* port configuration */
 
@@ -56,125 +67,32 @@ static void cfspi_init(void)
 
Quoted 8 lines

drivers/spi/cf_spi.c static void cfspi_init(void) · line 70

Quoted 4 lines
drivers/spi/cf_spi.c +1 -1
        /* Default setting in platform configuration */
 #ifdef CONFIG_SYS_DSPI_CTAR0
-       dspi->ctar[0] = CONFIG_SYS_DSPI_CTAR0;
+       writel(CONFIG_SYS_DSPI_CTAR0, &dspi->ctar[0]);

What is going on here? I think these CONFIG options are addresses? If so, they should be read from the DT, not a CONFIG.

Quoted 5 lines

These are just default settings for each channel (bus), actually coming from the include/configs/boardxxx.h. Their speed an mode bitfields are rewritten later, with values coming from devicetree.
Some driver #define the default value inside the driver itself, in case i may change in this way. No one seems reading them from device tree.

OK, can we remove these? At least they should not have a CONFIG_ prefix, so we can remove them from the whitelist.

Regards,
Simon

#7 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

Hi Simon,

Quoted 58 lines · Simon Glass

Hi Angelo,

Quoted 55 lines · Angelo Dureghello

Hi Simon,

thanks for the review.

Quoted 50 lines · Simon Glass

Hi Angelo,

Quoted 7 lines · Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

Quoted 8 lines
---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h

Good to see this.

Quoted 18 lines
drivers/spi/Kconfig +6 -0
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
          used to access the SPI NOR flash on platforms embedding this
          Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
        bool "Designware SPI driver"
        help

drivers/spi/Kconfig config ZYNQMP_GQSPI · line 251

Quoted 8 lines
drivers/spi/Kconfig +0 -5
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
-config SOFT_SPI
-       bool "Soft SPI driver"
-       help
-        Enable Soft SPI driver. This driver is to use GPIO simulate
-        the SPI protocol.

How come this is changing? That should be a separate patch.

Quoted 4 lines
Quoted 1 line

I just respected Kconfig alphabetical order, SOFT_SPI is just moved after.

OK, well I do think this should be in a separate patch.

Ah, ok. Will do.

Quoted 82 lines
Quoted 82 lines
Quoted 81 lines
Quoted 72 lines
drivers/spi/Kconfig +6 -1
-
 config CF_SPI
        bool "ColdFire SPI driver"
        help
          Enable the ColdFire SPI driver. This driver can be used on
          some m68k SoCs.
 
+config SOFT_SPI
+       bool "Soft SPI driver"
+       help
+        Enable Soft SPI driver. This driver is to use GPIO simulate
+        the SPI protocol.
+
 config FSL_ESPI
        bool "Freescale eSPI driver"
        help
drivers/spi/cf_spi.c +18 -7
index 522631cbbf..11a11f79c4 100644
@@ -6,16 +6,27 @@
  *
  * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
+ *
+ * Support for device model:
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ *
  */
 
 #include <common.h>
+#include <dm.h>
+#include <dm/platform_data/spi_coldfire.h>
 #include <spi.h>
 #include <malloc.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 
-struct cf_spi_slave {
+struct coldfire_spi_priv {
+#ifndef CONFIG_DM_SPI
        struct spi_slave slave;
+#endif
+       struct dspi *regs;
        uint baudrate;
+       int mode;
        int charbit;
 };
 
@@ -38,14 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_MODE_MOD   0x00200000
 #define SPI_DBLRATE    0x00100000
 
-static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave)
-{
-       return container_of(slave, struct cf_spi_slave, slave);
-}
+/* Default values */
+#define MCF_DSPI_DEFAULT_SCK_FREQ      10000000
+#define MCF_DSPI_MAX_CHIPSELECTS       4
+#define MCF_DSPI_MODE                  0
 
-static void cfspi_init(void)
+static void __spi_init(struct coldfire_spi_priv *cfspi)
 {
-       volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
+       struct dspi *dspi = cfspi->regs;
 
        cfspi_port_conf();      /* port configuration */
 

drivers/spi/cf_spi.c static void cfspi_init(void) · line 70

Quoted 5 lines
drivers/spi/cf_spi.c +1 -1
@@ -56,125 +67,32 @@ static void cfspi_init(void)
 
        /* Default setting in platform configuration */
 #ifdef CONFIG_SYS_DSPI_CTAR0
-       dspi->ctar[0] = CONFIG_SYS_DSPI_CTAR0;
+       writel(CONFIG_SYS_DSPI_CTAR0, &dspi->ctar[0]);

What is going on here? I think these CONFIG options are addresses? If so, they should be read from the DT, not a CONFIG.

Quoted 9 lines
Quoted 5 lines

These are just default settings for each channel (bus), actually coming from the include/configs/boardxxx.h. Their speed an mode bitfields are rewritten later, with values coming from devicetree.
Some driver #define the default value inside the driver itself, in case i may change in this way. No one seems reading them from device tree.

OK, can we remove these? At least they should not have a CONFIG_ prefix, so we can remove them from the whitelist.

Ok, i can set a default in the driver itself for now.

Quoted 2 lines

Regards,
Simon

Regards,
Angelo

#8 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

In reply to Simon Glass

Hi Simon,

Quoted 58 lines · Simon Glass

Hi Angelo,

Quoted 55 lines · Angelo Dureghello

Hi Simon,

thanks for the review.

Quoted 50 lines · Simon Glass

Hi Angelo,

Quoted 7 lines · Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

Quoted 8 lines
---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h

Good to see this.

Quoted 18 lines
drivers/spi/Kconfig +6 -0
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
          used to access the SPI NOR flash on platforms embedding this
          Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
        bool "Designware SPI driver"
        help

drivers/spi/Kconfig config ZYNQMP_GQSPI · line 251

Quoted 8 lines
drivers/spi/Kconfig +0 -5
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
-config SOFT_SPI
-       bool "Soft SPI driver"
-       help
-        Enable Soft SPI driver. This driver is to use GPIO simulate
-        the SPI protocol.

How come this is changing? That should be a separate patch.

Quoted 4 lines
Quoted 1 line

I just respected Kconfig alphabetical order, SOFT_SPI is just moved after.

OK, well I do think this should be in a separate patch.

this is done, ready into a v2

Quoted 82 lines
Quoted 82 lines
Quoted 81 lines
Quoted 72 lines
drivers/spi/Kconfig +6 -1
-
 config CF_SPI
        bool "ColdFire SPI driver"
        help
          Enable the ColdFire SPI driver. This driver can be used on
          some m68k SoCs.
 
+config SOFT_SPI
+       bool "Soft SPI driver"
+       help
+        Enable Soft SPI driver. This driver is to use GPIO simulate
+        the SPI protocol.
+
 config FSL_ESPI
        bool "Freescale eSPI driver"
        help
drivers/spi/cf_spi.c +18 -7
index 522631cbbf..11a11f79c4 100644
@@ -6,16 +6,27 @@
  *
  * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
+ *
+ * Support for device model:
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ *
  */
 
 #include <common.h>
+#include <dm.h>
+#include <dm/platform_data/spi_coldfire.h>
 #include <spi.h>
 #include <malloc.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 
-struct cf_spi_slave {
+struct coldfire_spi_priv {
+#ifndef CONFIG_DM_SPI
        struct spi_slave slave;
+#endif
+       struct dspi *regs;
        uint baudrate;
+       int mode;
        int charbit;
 };
 
@@ -38,14 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_MODE_MOD   0x00200000
 #define SPI_DBLRATE    0x00100000
 
-static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave)
-{
-       return container_of(slave, struct cf_spi_slave, slave);
-}
+/* Default values */
+#define MCF_DSPI_DEFAULT_SCK_FREQ      10000000
+#define MCF_DSPI_MAX_CHIPSELECTS       4
+#define MCF_DSPI_MODE                  0
 
-static void cfspi_init(void)
+static void __spi_init(struct coldfire_spi_priv *cfspi)
 {
-       volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
+       struct dspi *dspi = cfspi->regs;
 
        cfspi_port_conf();      /* port configuration */
 

drivers/spi/cf_spi.c static void cfspi_init(void) · line 70

Quoted 5 lines
drivers/spi/cf_spi.c +1 -1
@@ -56,125 +67,32 @@ static void cfspi_init(void)
 
        /* Default setting in platform configuration */
 #ifdef CONFIG_SYS_DSPI_CTAR0
-       dspi->ctar[0] = CONFIG_SYS_DSPI_CTAR0;
+       writel(CONFIG_SYS_DSPI_CTAR0, &dspi->ctar[0]);

What is going on here? I think these CONFIG options are addresses? If so, they should be read from the DT, not a CONFIG.

Quoted 9 lines
Quoted 5 lines

These are just default settings for each channel (bus), actually coming from the include/configs/boardxxx.h. Their speed an mode bitfields are rewritten later, with values coming from devicetree.
Some driver #define the default value inside the driver itself, in case i may change in this way. No one seems reading them from device tree.

OK, can we remove these? At least they should not have a CONFIG_ prefix, so we can remove them from the whitelist.

I verified that in particular 1 m68k board (ls1012aqds.h) wants different defaults as cs-clock delays. This is something that atually can only be done by those CONFIG_SYS_DSPI_CTARX.

This settings may be moved into DT but all the related boards should have been moved to use a dts. Not sure if i can do this now, since i cannot test DT migration without owning the related physical board (hw).

How does it work in general ? Should i move al boards to dts, leaving tests to board maintaners in the future ? Can we keep those CONFIG_SYS_DSPI_CTARX in this way and perform the all-boards conversion to dts in a later step ?

Quoted 2 lines

Regards,
Simon

Regards,
Angelo

#9 lore raw

PATCH 2/7 drivers: spi: cf_spi: migrate to DM and DT

Hi Angelo,

Quoted 163 lines · Angelo Dureghello

Hi Simon,

Quoted 58 lines · Simon Glass

Hi Angelo,

Quoted 55 lines · Angelo Dureghello

Hi Simon,

thanks for the review.

Quoted 50 lines · Simon Glass

Hi Angelo,

Quoted 7 lines · Angelo Dureghello

This patch converts cf_spi.c to DM and to read driver platform data from flat devicetree.

---
Changes from v1:
- split into 2 patches

Quoted 8 lines
---
 drivers/spi/Kconfig                     |  18 +-
 drivers/spi/cf_spi.c                    | 495 ++++++++++++++++--------
 include/dm/platform_data/spi_coldfire.h |  25 ++
 3 files changed, 369 insertions(+), 169 deletions(-)
 create mode 100644 include/dm/platform_data/spi_coldfire.h

Good to see this.

Quoted 18 lines
drivers/spi/Kconfig +6 -0
index dcd719ff0a..974c5bbed8 100644
@@ -80,6 +80,12 @@ config CADENCE_QSPI
          used to access the SPI NOR flash on platforms embedding this
          Cadence IP core.
 
+config CF_SPI
+        bool "ColdFire SPI driver"
+        help
+          Enable the ColdFire SPI driver. This driver can be used on
+          some m68k SoCs.
+
 config DESIGNWARE_SPI
        bool "Designware SPI driver"
        help

drivers/spi/Kconfig config ZYNQMP_GQSPI · line 251

Quoted 8 lines
drivers/spi/Kconfig +0 -5
@@ -244,18 +250,18 @@ config ZYNQMP_GQSPI
 
 endif # if DM_SPI
 
-config SOFT_SPI
-       bool "Soft SPI driver"
-       help
-        Enable Soft SPI driver. This driver is to use GPIO simulate
-        the SPI protocol.

How come this is changing? That should be a separate patch.

Quoted 4 lines
Quoted 1 line

I just respected Kconfig alphabetical order, SOFT_SPI is just moved after.

OK, well I do think this should be in a separate patch.

this is done, ready into a v2

Quoted 82 lines
Quoted 82 lines
Quoted 81 lines
Quoted 72 lines
drivers/spi/Kconfig +6 -1
-
 config CF_SPI
        bool "ColdFire SPI driver"
        help
          Enable the ColdFire SPI driver. This driver can be used on
          some m68k SoCs.
 
+config SOFT_SPI
+       bool "Soft SPI driver"
+       help
+        Enable Soft SPI driver. This driver is to use GPIO simulate
+        the SPI protocol.
+
 config FSL_ESPI
        bool "Freescale eSPI driver"
        help
drivers/spi/cf_spi.c +18 -7
index 522631cbbf..11a11f79c4 100644
@@ -6,16 +6,27 @@
  *
  * Copyright (C) 2004-2009 Freescale Semiconductor, Inc.
  * TsiChung Liew (Tsi-Chung.Liew at freescale.com)
+ *
+ * Support for device model:
+ * Copyright (C) 2018 Angelo Dureghello <[email protected]>
+ *
  */
 
 #include <common.h>
+#include <dm.h>
+#include <dm/platform_data/spi_coldfire.h>
 #include <spi.h>
 #include <malloc.h>
 #include <asm/immap.h>
+#include <asm/io.h>
 
-struct cf_spi_slave {
+struct coldfire_spi_priv {
+#ifndef CONFIG_DM_SPI
        struct spi_slave slave;
+#endif
+       struct dspi *regs;
        uint baudrate;
+       int mode;
        int charbit;
 };
 
@@ -38,14 +49,14 @@ DECLARE_GLOBAL_DATA_PTR;
 #define SPI_MODE_MOD   0x00200000
 #define SPI_DBLRATE    0x00100000
 
-static inline struct cf_spi_slave *to_cf_spi_slave(struct spi_slave *slave)
-{
-       return container_of(slave, struct cf_spi_slave, slave);
-}
+/* Default values */
+#define MCF_DSPI_DEFAULT_SCK_FREQ      10000000
+#define MCF_DSPI_MAX_CHIPSELECTS       4
+#define MCF_DSPI_MODE                  0
 
-static void cfspi_init(void)
+static void __spi_init(struct coldfire_spi_priv *cfspi)
 {
-       volatile dspi_t *dspi = (dspi_t *) MMAP_DSPI;
+       struct dspi *dspi = cfspi->regs;
 
        cfspi_port_conf();      /* port configuration */
 

drivers/spi/cf_spi.c static void cfspi_init(void) · line 70

Quoted 5 lines
drivers/spi/cf_spi.c +1 -1
@@ -56,125 +67,32 @@ static void cfspi_init(void)
 
        /* Default setting in platform configuration */
 #ifdef CONFIG_SYS_DSPI_CTAR0
-       dspi->ctar[0] = CONFIG_SYS_DSPI_CTAR0;
+       writel(CONFIG_SYS_DSPI_CTAR0, &dspi->ctar[0]);

What is going on here? I think these CONFIG options are addresses? If so, they should be read from the DT, not a CONFIG.

Quoted 9 lines
Quoted 5 lines

These are just default settings for each channel (bus), actually coming from the include/configs/boardxxx.h. Their speed an mode bitfields are rewritten later, with values coming from devicetree.
Some driver #define the default value inside the driver itself, in case i may change in this way. No one seems reading them from device tree.

OK, can we remove these? At least they should not have a CONFIG_ prefix, so we can remove them from the whitelist.

I verified that in particular 1 m68k board (ls1012aqds.h) wants different defaults as cs-clock delays. This is something that atually can only be done by those CONFIG_SYS_DSPI_CTARX.

Quoted 8 lines

This settings may be moved into DT but all the related boards should have been moved to use a dts. Not sure if i can do this now, since i cannot test DT migration without owning the related physical board (hw).

How does it work in general ? Should i move al boards to dts, leaving tests to board maintaners in the future ? Can we keep those CONFIG_SYS_DSPI_CTARX in this way and perform the all-boards conversion to dts in a later step ?

Yes you can migrate them forcibly since the alternative is presumably to delete their support from mainline.

Regards,
Simon