diff mbox

[U-Boot,v2,5/5] malta: Use device model & tree for UART

Message ID 1463420679-5042-6-git-send-email-paul.burton@imgtec.com
State Superseded
Delegated to: Daniel Schwierzeck
Headers show

Commit Message

Paul Burton May 16, 2016, 5:44 p.m. UTC
Make use of device model & device tree to probe the UART driver. This is
the initial step in bringing Malta up to date with driver model, and
allows for cleaner handling of the different I/O addresses for different
system controllers by specifying the ISA bus address instead of a
translated memory address.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
---

Changes in v2:
- Only handle the UART we already use, for simplicity.

 arch/mips/Kconfig           |  5 +++++
 arch/mips/dts/Makefile      |  3 ++-
 arch/mips/dts/mti,malta.dts | 32 ++++++++++++++++++++++++++++++++
 configs/malta_defconfig     |  1 +
 configs/maltael_defconfig   |  1 +
 include/configs/malta.h     |  6 ------
 6 files changed, 41 insertions(+), 7 deletions(-)
 create mode 100644 arch/mips/dts/mti,malta.dts

Comments

Daniel Schwierzeck May 16, 2016, 6:56 p.m. UTC | #1
Am 16.05.2016 um 19:44 schrieb Paul Burton:
> Make use of device model & device tree to probe the UART driver. This is
> the initial step in bringing Malta up to date with driver model, and
> allows for cleaner handling of the different I/O addresses for different
> system controllers by specifying the ISA bus address instead of a
> translated memory address.
> 
> Signed-off-by: Paul Burton <paul.burton@imgtec.com>

Reviewed-by: Daniel Schwierzeck <daniel.schwierzeck@gmail.com>

nits below

> ---
> 
> Changes in v2:
> - Only handle the UART we already use, for simplicity.
> 
>  arch/mips/Kconfig           |  5 +++++
>  arch/mips/dts/Makefile      |  3 ++-
>  arch/mips/dts/mti,malta.dts | 32 ++++++++++++++++++++++++++++++++
>  configs/malta_defconfig     |  1 +
>  configs/maltael_defconfig   |  1 +
>  include/configs/malta.h     |  6 ------
>  6 files changed, 41 insertions(+), 7 deletions(-)
>  create mode 100644 arch/mips/dts/mti,malta.dts
> 
> diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
> index fe37d1f..e407b19 100644
> --- a/arch/mips/Kconfig
> +++ b/arch/mips/Kconfig
> @@ -23,7 +23,12 @@ config TARGET_QEMU_MIPS
>  
>  config TARGET_MALTA
>  	bool "Support malta"
> +	select DM
> +	select DM_SERIAL

actually DM_SERIAL should be selected in the defconfig. But Malta is a single target so it's ok.

>  	select DYNAMIC_IO_PORT_BASE
> +	select OF_CONTROL
> +	select OF_EMBED

but OF_EMBED should go into the defconfig. The user should decide if the DTB should be appended or be embedded.

> +	select OF_ISA_BUS
>  	select SUPPORTS_BIG_ENDIAN
>  	select SUPPORTS_LITTLE_ENDIAN
>  	select SUPPORTS_CPU_MIPS32_R1
> diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
> index b513918..45d623f 100644
> --- a/arch/mips/dts/Makefile
> +++ b/arch/mips/dts/Makefile
> @@ -2,7 +2,8 @@
>  # SPDX-License-Identifier:	GPL-2.0+
>  #
>  
> -dtb-$(CONFIG_TARGET_PIC32MZDASK) += pic32mzda_sk.dtb
> +dtb-$(CONFIG_TARGET_MALTA)		+= mti,malta.dtb
> +dtb-$(CONFIG_TARGET_PIC32MZDASK)	+= pic32mzda_sk.dtb

this doesn't apply to u-boot-mips/next but I can fix it.

>  
>  targets += $(dtb-y)
>  
> diff --git a/arch/mips/dts/mti,malta.dts b/arch/mips/dts/mti,malta.dts
> new file mode 100644
> index 0000000..1dba606
> --- /dev/null
> +++ b/arch/mips/dts/mti,malta.dts
> @@ -0,0 +1,32 @@
> +/dts-v1/;
> +
> +/memreserve/ 0x00000000 0x00001000;	/* Exception vectors */
> +/memreserve/ 0x000f0000 0x00010000;	/* PIIX4 ISA memory */
> +
> +/ {
> +	#address-cells = <1>;
> +	#size-cells = <1>;
> +	compatible = "mti,malta";
> +
> +	chosen {
> +		stdout-path = &uart0;
> +	};
> +
> +	isa {
> +		compatible = "isa";
> +		#address-cells = <2>;
> +		#size-cells = <1>;
> +		ranges = <1 0 0 0x1000>;

is following dtc warning fixable?

Warning (unit_address_vs_reg): Node /isa has a reg or ranges property, but no unit name

> +
> +		uart0: serial@3f8 {
> +			compatible = "ns16550a";
> +
> +			reg = <1 0x3f8 0x40>;
> +			reg-shift = <0>;
> +
> +			clock-frequency = <1843200>;
> +
> +			u-boot,dm-pre-reloc;
> +		};
> +	};
> +};
> diff --git a/configs/malta_defconfig b/configs/malta_defconfig
> index a16f10b..0b5075f 100644
> --- a/configs/malta_defconfig
> +++ b/configs/malta_defconfig
> @@ -11,3 +11,4 @@ CONFIG_CMD_DHCP=y
>  CONFIG_CMD_PING=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_USE_PRIVATE_LIBGCC=y
> +CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
> diff --git a/configs/maltael_defconfig b/configs/maltael_defconfig
> index 5289797..876e806 100644
> --- a/configs/maltael_defconfig
> +++ b/configs/maltael_defconfig
> @@ -12,3 +12,4 @@ CONFIG_CMD_DHCP=y
>  CONFIG_CMD_PING=y
>  CONFIG_SYS_NS16550=y
>  CONFIG_USE_PRIVATE_LIBGCC=y
> +CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
> diff --git a/include/configs/malta.h b/include/configs/malta.h
> index 1c3c83c..e03935b 100644
> --- a/include/configs/malta.h
> +++ b/include/configs/malta.h
> @@ -65,13 +65,7 @@
>   * Serial driver
>   */
>  #define CONFIG_BAUDRATE			115200
> -
> -#define CONFIG_SYS_NS16550_SERIAL
>  #define CONFIG_SYS_NS16550_PORT_MAPPED
> -#define CONFIG_SYS_NS16550_REG_SIZE	1
> -#define CONFIG_SYS_NS16550_CLK		(115200 * 16)
> -#define CONFIG_SYS_NS16550_COM1		0x3f8
> -#define CONFIG_CONS_INDEX		1
>  
>  /*
>   * Flash configuration
>
Paul Burton May 17, 2016, 6:40 a.m. UTC | #2
On Mon, May 16, 2016 at 08:56:32PM +0200, Daniel Schwierzeck wrote:
> > diff --git a/arch/mips/dts/mti,malta.dts b/arch/mips/dts/mti,malta.dts
> > new file mode 100644
> > index 0000000..1dba606
> > --- /dev/null
> > +++ b/arch/mips/dts/mti,malta.dts
> > @@ -0,0 +1,32 @@
> > +/dts-v1/;
> > +
> > +/memreserve/ 0x00000000 0x00001000;	/* Exception vectors */
> > +/memreserve/ 0x000f0000 0x00010000;	/* PIIX4 ISA memory */
> > +
> > +/ {
> > +	#address-cells = <1>;
> > +	#size-cells = <1>;
> > +	compatible = "mti,malta";
> > +
> > +	chosen {
> > +		stdout-path = &uart0;
> > +	};
> > +
> > +	isa {
> > +		compatible = "isa";
> > +		#address-cells = <2>;
> > +		#size-cells = <1>;
> > +		ranges = <1 0 0 0x1000>;
> 
> is following dtc warning fixable?
> 
> Warning (unit_address_vs_reg): Node /isa has a reg or ranges property, but no unit name

Hi Daniel,

Thanks for reviewing. I'm not seeing this warning with DTC 1.4.1. Which
version are you using?

Thanks,
    Paul
Daniel Schwierzeck May 17, 2016, 10:57 a.m. UTC | #3
2016-05-17 8:40 GMT+02:00 Paul Burton <paul.burton@imgtec.com>:
> On Mon, May 16, 2016 at 08:56:32PM +0200, Daniel Schwierzeck wrote:
>> > diff --git a/arch/mips/dts/mti,malta.dts b/arch/mips/dts/mti,malta.dts
>> > new file mode 100644
>> > index 0000000..1dba606
>> > --- /dev/null
>> > +++ b/arch/mips/dts/mti,malta.dts
>> > @@ -0,0 +1,32 @@
>> > +/dts-v1/;
>> > +
>> > +/memreserve/ 0x00000000 0x00001000;        /* Exception vectors */
>> > +/memreserve/ 0x000f0000 0x00010000;        /* PIIX4 ISA memory */
>> > +
>> > +/ {
>> > +   #address-cells = <1>;
>> > +   #size-cells = <1>;
>> > +   compatible = "mti,malta";
>> > +
>> > +   chosen {
>> > +           stdout-path = &uart0;
>> > +   };
>> > +
>> > +   isa {
>> > +           compatible = "isa";
>> > +           #address-cells = <2>;
>> > +           #size-cells = <1>;
>> > +           ranges = <1 0 0 0x1000>;
>>
>> is following dtc warning fixable?
>>
>> Warning (unit_address_vs_reg): Node /isa has a reg or ranges property, but no unit name
>
> Hi Daniel,
>
> Thanks for reviewing. I'm not seeing this warning with DTC 1.4.1. Which
> version are you using?
>

Currently I'm using DTC mainline. There was a patch [1] by Stephen
Warren applied some time ago which causes those warnings.

[1] https://git.kernel.org/cgit/utils/dtc/dtc.git/commit/?id=c9d9121683b35281239305e15adddfff2b462cf9
diff mbox

Patch

diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
index fe37d1f..e407b19 100644
--- a/arch/mips/Kconfig
+++ b/arch/mips/Kconfig
@@ -23,7 +23,12 @@  config TARGET_QEMU_MIPS
 
 config TARGET_MALTA
 	bool "Support malta"
+	select DM
+	select DM_SERIAL
 	select DYNAMIC_IO_PORT_BASE
+	select OF_CONTROL
+	select OF_EMBED
+	select OF_ISA_BUS
 	select SUPPORTS_BIG_ENDIAN
 	select SUPPORTS_LITTLE_ENDIAN
 	select SUPPORTS_CPU_MIPS32_R1
diff --git a/arch/mips/dts/Makefile b/arch/mips/dts/Makefile
index b513918..45d623f 100644
--- a/arch/mips/dts/Makefile
+++ b/arch/mips/dts/Makefile
@@ -2,7 +2,8 @@ 
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-dtb-$(CONFIG_TARGET_PIC32MZDASK) += pic32mzda_sk.dtb
+dtb-$(CONFIG_TARGET_MALTA)		+= mti,malta.dtb
+dtb-$(CONFIG_TARGET_PIC32MZDASK)	+= pic32mzda_sk.dtb
 
 targets += $(dtb-y)
 
diff --git a/arch/mips/dts/mti,malta.dts b/arch/mips/dts/mti,malta.dts
new file mode 100644
index 0000000..1dba606
--- /dev/null
+++ b/arch/mips/dts/mti,malta.dts
@@ -0,0 +1,32 @@ 
+/dts-v1/;
+
+/memreserve/ 0x00000000 0x00001000;	/* Exception vectors */
+/memreserve/ 0x000f0000 0x00010000;	/* PIIX4 ISA memory */
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+	compatible = "mti,malta";
+
+	chosen {
+		stdout-path = &uart0;
+	};
+
+	isa {
+		compatible = "isa";
+		#address-cells = <2>;
+		#size-cells = <1>;
+		ranges = <1 0 0 0x1000>;
+
+		uart0: serial@3f8 {
+			compatible = "ns16550a";
+
+			reg = <1 0x3f8 0x40>;
+			reg-shift = <0>;
+
+			clock-frequency = <1843200>;
+
+			u-boot,dm-pre-reloc;
+		};
+	};
+};
diff --git a/configs/malta_defconfig b/configs/malta_defconfig
index a16f10b..0b5075f 100644
--- a/configs/malta_defconfig
+++ b/configs/malta_defconfig
@@ -11,3 +11,4 @@  CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
+CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
diff --git a/configs/maltael_defconfig b/configs/maltael_defconfig
index 5289797..876e806 100644
--- a/configs/maltael_defconfig
+++ b/configs/maltael_defconfig
@@ -12,3 +12,4 @@  CONFIG_CMD_DHCP=y
 CONFIG_CMD_PING=y
 CONFIG_SYS_NS16550=y
 CONFIG_USE_PRIVATE_LIBGCC=y
+CONFIG_DEFAULT_DEVICE_TREE="mti,malta"
diff --git a/include/configs/malta.h b/include/configs/malta.h
index 1c3c83c..e03935b 100644
--- a/include/configs/malta.h
+++ b/include/configs/malta.h
@@ -65,13 +65,7 @@ 
  * Serial driver
  */
 #define CONFIG_BAUDRATE			115200
-
-#define CONFIG_SYS_NS16550_SERIAL
 #define CONFIG_SYS_NS16550_PORT_MAPPED
-#define CONFIG_SYS_NS16550_REG_SIZE	1
-#define CONFIG_SYS_NS16550_CLK		(115200 * 16)
-#define CONFIG_SYS_NS16550_COM1		0x3f8
-#define CONFIG_CONS_INDEX		1
 
 /*
  * Flash configuration