diff mbox

[U-Boot,05/12] ns16550: unify serial_x86

Message ID 1447684616-10297-6-git-send-email-thomas@wytron.com.tw
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Thomas Chou Nov. 16, 2015, 2:36 p.m. UTC
Unify serial_x86, and use the generic binding.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
---
 arch/x86/Kconfig            |  4 ++++
 arch/x86/dts/serial.dtsi    |  2 +-
 configs/efi-x86_defconfig   |  2 +-
 drivers/serial/Kconfig      | 10 ----------
 drivers/serial/Makefile     |  1 -
 drivers/serial/serial_x86.c | 44 --------------------------------------------
 6 files changed, 6 insertions(+), 57 deletions(-)
 delete mode 100644 drivers/serial/serial_x86.c

Comments

Tom Rini Nov. 16, 2015, 6:22 p.m. UTC | #1
On Mon, Nov 16, 2015 at 10:36:49PM +0800, Thomas Chou wrote:

> Unify serial_x86, and use the generic binding.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>

Reviewed-by: Tom Rini <trini@konsulko.com>
Bin Meng Nov. 18, 2015, 1:07 a.m. UTC | #2
Hi Thomas,

On Mon, Nov 16, 2015 at 10:36 PM, Thomas Chou <thomas@wytron.com.tw> wrote:
> Unify serial_x86, and use the generic binding.
>
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  arch/x86/Kconfig            |  4 ++++
>  arch/x86/dts/serial.dtsi    |  2 +-
>  configs/efi-x86_defconfig   |  2 +-
>  drivers/serial/Kconfig      | 10 ----------
>  drivers/serial/Makefile     |  1 -
>  drivers/serial/serial_x86.c | 44 --------------------------------------------
>  6 files changed, 6 insertions(+), 57 deletions(-)
>  delete mode 100644 drivers/serial/serial_x86.c
>
> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
> index f92082d..61011c9 100644
> --- a/arch/x86/Kconfig
> +++ b/arch/x86/Kconfig
> @@ -422,4 +422,8 @@ config PCIE_ECAM_SIZE
>
>  source "arch/x86/lib/efi/Kconfig"
>
> +config NS16550_SERIAL
> +       depends on DM_SERIAL
> +       default y

I am not in favor of adding driver options to arch Kconfig. I would
suggest updating NS16550_SERIAL option in driver/serial/Kconfig, like
what was done in X86_SERIAL before:

config NS16550_SERIAL
        default y if X86

> +
>  endmenu
> diff --git a/arch/x86/dts/serial.dtsi b/arch/x86/dts/serial.dtsi
> index 6865eed..54c3faf 100644
> --- a/arch/x86/dts/serial.dtsi
> +++ b/arch/x86/dts/serial.dtsi
> @@ -1,6 +1,6 @@
>  / {
>         serial: serial {
> -               compatible = "x86-uart";
> +               compatible = "ns16550";
>                 reg = <0x3f8 8>;
>                 reg-shift = <0>;
>                 clock-frequency = <1843200>;
> diff --git a/configs/efi-x86_defconfig b/configs/efi-x86_defconfig
> index 43fb0c4..b1573df 100644
> --- a/configs/efi-x86_defconfig
> +++ b/configs/efi-x86_defconfig
> @@ -3,6 +3,7 @@ CONFIG_VENDOR_EFI=y
>  CONFIG_DEFAULT_DEVICE_TREE="efi"
>  CONFIG_TARGET_EFI=y
>  CONFIG_TSC_CALIBRATION_BYPASS=y
> +# CONFIG_NS16550_SERIAL is not set
>  # CONFIG_CMD_BOOTM is not set
>  # CONFIG_CMD_NET is not set
>  CONFIG_OF_CONTROL=y
> @@ -12,5 +13,4 @@ CONFIG_DEBUG_UART=y
>  CONFIG_DEBUG_EFI_CONSOLE=y
>  CONFIG_DEBUG_UART_BASE=0
>  CONFIG_DEBUG_UART_CLOCK=0
> -# CONFIG_X86_SERIAL is not set
>  CONFIG_EFI=y
> diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
> index 1261356..abcf2aa 100644
> --- a/drivers/serial/Kconfig
> +++ b/drivers/serial/Kconfig
> @@ -224,14 +224,4 @@ config UNIPHIER_SERIAL
>           If you have a UniPhier based board and want to use the on-chip
>           serial ports, say Y to this option. If unsure, say N.
>
> -config X86_SERIAL
> -       bool "Support for 16550 serial port on x86 machines"
> -       depends on X86
> -       default y
> -       help
> -         Most x86 machines have a ns16550 UART or compatible. This can be
> -         enabled in the device tree with the correct input clock frequency
> -         provided (default 1843200). Enable this to obtain serial console
> -         output.
> -
>  endmenu
> diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
> index 1818c7c..9036a8e 100644
> --- a/drivers/serial/Makefile
> +++ b/drivers/serial/Makefile
> @@ -46,7 +46,6 @@ obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
>  obj-$(CONFIG_TEGRA_SERIAL) += serial_tegra.o
>  obj-$(CONFIG_UNIPHIER_SERIAL) += serial_uniphier.o
>  obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
> -obj-$(CONFIG_X86_SERIAL) += serial_x86.o
>  obj-$(CONFIG_STM32_SERIAL) += serial_stm32.o
>
>  ifndef CONFIG_SPL_BUILD
> diff --git a/drivers/serial/serial_x86.c b/drivers/serial/serial_x86.c
> deleted file mode 100644
> index 4bf6062..0000000
> --- a/drivers/serial/serial_x86.c
> +++ /dev/null
> @@ -1,44 +0,0 @@
> -/*
> - * Copyright (c) 2014 Google, Inc
> - *
> - * SPDX-License-Identifier:    GPL-2.0+
> - */
> -
> -#include <common.h>
> -#include <dm.h>
> -#include <fdtdec.h>
> -#include <ns16550.h>
> -#include <serial.h>
> -
> -DECLARE_GLOBAL_DATA_PTR;
> -
> -static const struct udevice_id x86_serial_ids[] = {
> -       { .compatible = "x86-uart" },
> -       { }
> -};
> -
> -static int x86_serial_ofdata_to_platdata(struct udevice *dev)
> -{
> -       struct ns16550_platdata *plat = dev_get_platdata(dev);
> -       int ret;
> -
> -       ret = ns16550_serial_ofdata_to_platdata(dev);
> -       if (ret)
> -               return ret;
> -
> -       plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
> -                                    "clock-frequency", 1843200);
> -
> -       return 0;
> -}
> -
> -U_BOOT_DRIVER(serial_ns16550) = {
> -       .name   = "serial_x86",
> -       .id     = UCLASS_SERIAL,
> -       .of_match = x86_serial_ids,
> -       .ofdata_to_platdata = x86_serial_ofdata_to_platdata,
> -       .platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
> -       .priv_auto_alloc_size = sizeof(struct NS16550),
> -       .probe = ns16550_serial_probe,
> -       .ops    = &ns16550_serial_ops,
> -};
> --

Regards,
Bin
Thomas Chou Nov. 18, 2015, 2:02 a.m. UTC | #3
Hi Bin,

On 2015年11月18日 09:07, Bin Meng wrote:
> Hi Thomas,
>
> On Mon, Nov 16, 2015 at 10:36 PM, Thomas Chou <thomas@wytron.com.tw> wrote:
>> Unify serial_x86, and use the generic binding.
>>
>> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
>> ---
>>   arch/x86/Kconfig            |  4 ++++
>>   arch/x86/dts/serial.dtsi    |  2 +-
>>   configs/efi-x86_defconfig   |  2 +-
>>   drivers/serial/Kconfig      | 10 ----------
>>   drivers/serial/Makefile     |  1 -
>>   drivers/serial/serial_x86.c | 44 --------------------------------------------
>>   6 files changed, 6 insertions(+), 57 deletions(-)
>>   delete mode 100644 drivers/serial/serial_x86.c
>>
>> diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
>> index f92082d..61011c9 100644
>> --- a/arch/x86/Kconfig
>> +++ b/arch/x86/Kconfig
>> @@ -422,4 +422,8 @@ config PCIE_ECAM_SIZE
>>
>>   source "arch/x86/lib/efi/Kconfig"
>>
>> +config NS16550_SERIAL
>> +       depends on DM_SERIAL
>> +       default y
>
> I am not in favor of adding driver options to arch Kconfig. I would
> suggest updating NS16550_SERIAL option in driver/serial/Kconfig, like
> what was done in X86_SERIAL before:
>
> config NS16550_SERIAL
>          default y if X86
>

Thanks for reminding. I was trying to recall how to use this "if". :)

Best regards,
Thomas
diff mbox

Patch

diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index f92082d..61011c9 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -422,4 +422,8 @@  config PCIE_ECAM_SIZE
 
 source "arch/x86/lib/efi/Kconfig"
 
+config NS16550_SERIAL
+	depends on DM_SERIAL
+	default y
+
 endmenu
diff --git a/arch/x86/dts/serial.dtsi b/arch/x86/dts/serial.dtsi
index 6865eed..54c3faf 100644
--- a/arch/x86/dts/serial.dtsi
+++ b/arch/x86/dts/serial.dtsi
@@ -1,6 +1,6 @@ 
 / {
 	serial: serial {
-		compatible = "x86-uart";
+		compatible = "ns16550";
 		reg = <0x3f8 8>;
 		reg-shift = <0>;
 		clock-frequency = <1843200>;
diff --git a/configs/efi-x86_defconfig b/configs/efi-x86_defconfig
index 43fb0c4..b1573df 100644
--- a/configs/efi-x86_defconfig
+++ b/configs/efi-x86_defconfig
@@ -3,6 +3,7 @@  CONFIG_VENDOR_EFI=y
 CONFIG_DEFAULT_DEVICE_TREE="efi"
 CONFIG_TARGET_EFI=y
 CONFIG_TSC_CALIBRATION_BYPASS=y
+# CONFIG_NS16550_SERIAL is not set
 # CONFIG_CMD_BOOTM is not set
 # CONFIG_CMD_NET is not set
 CONFIG_OF_CONTROL=y
@@ -12,5 +13,4 @@  CONFIG_DEBUG_UART=y
 CONFIG_DEBUG_EFI_CONSOLE=y
 CONFIG_DEBUG_UART_BASE=0
 CONFIG_DEBUG_UART_CLOCK=0
-# CONFIG_X86_SERIAL is not set
 CONFIG_EFI=y
diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig
index 1261356..abcf2aa 100644
--- a/drivers/serial/Kconfig
+++ b/drivers/serial/Kconfig
@@ -224,14 +224,4 @@  config UNIPHIER_SERIAL
 	  If you have a UniPhier based board and want to use the on-chip
 	  serial ports, say Y to this option. If unsure, say N.
 
-config X86_SERIAL
-	bool "Support for 16550 serial port on x86 machines"
-	depends on X86
-	default y
-	help
-	  Most x86 machines have a ns16550 UART or compatible. This can be
-	  enabled in the device tree with the correct input clock frequency
-	  provided (default 1843200). Enable this to obtain serial console
-	  output.
-
 endmenu
diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile
index 1818c7c..9036a8e 100644
--- a/drivers/serial/Makefile
+++ b/drivers/serial/Makefile
@@ -46,7 +46,6 @@  obj-$(CONFIG_ARC_SERIAL) += serial_arc.o
 obj-$(CONFIG_TEGRA_SERIAL) += serial_tegra.o
 obj-$(CONFIG_UNIPHIER_SERIAL) += serial_uniphier.o
 obj-$(CONFIG_OMAP_SERIAL) += serial_omap.o
-obj-$(CONFIG_X86_SERIAL) += serial_x86.o
 obj-$(CONFIG_STM32_SERIAL) += serial_stm32.o
 
 ifndef CONFIG_SPL_BUILD
diff --git a/drivers/serial/serial_x86.c b/drivers/serial/serial_x86.c
deleted file mode 100644
index 4bf6062..0000000
--- a/drivers/serial/serial_x86.c
+++ /dev/null
@@ -1,44 +0,0 @@ 
-/*
- * Copyright (c) 2014 Google, Inc
- *
- * SPDX-License-Identifier:	GPL-2.0+
- */
-
-#include <common.h>
-#include <dm.h>
-#include <fdtdec.h>
-#include <ns16550.h>
-#include <serial.h>
-
-DECLARE_GLOBAL_DATA_PTR;
-
-static const struct udevice_id x86_serial_ids[] = {
-	{ .compatible = "x86-uart" },
-	{ }
-};
-
-static int x86_serial_ofdata_to_platdata(struct udevice *dev)
-{
-	struct ns16550_platdata *plat = dev_get_platdata(dev);
-	int ret;
-
-	ret = ns16550_serial_ofdata_to_platdata(dev);
-	if (ret)
-		return ret;
-
-	plat->clock = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
-				     "clock-frequency", 1843200);
-
-	return 0;
-}
-
-U_BOOT_DRIVER(serial_ns16550) = {
-	.name	= "serial_x86",
-	.id	= UCLASS_SERIAL,
-	.of_match = x86_serial_ids,
-	.ofdata_to_platdata = x86_serial_ofdata_to_platdata,
-	.platdata_auto_alloc_size = sizeof(struct ns16550_platdata),
-	.priv_auto_alloc_size = sizeof(struct NS16550),
-	.probe = ns16550_serial_probe,
-	.ops	= &ns16550_serial_ops,
-};