Skip to contentSkip to conversation

misc: Add simple driver to enable the legacy UART on Winbond Super IO chips

PATCH New Stefan Roese 3 participants 9 messages Jan 19, 2016 – Jan 26, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 misc: Add simple driver to enable the legacy UART on Winbond Super IO chips

On most x86 boards, the legacy serial ports (io address 0x3f8/0x2f8) are provided by a superio chip connected to the LPC bus. We must program the superio chip so that serial ports are available for us.

---
v2:
- Address Bin's comments:
- Make description more generic, so that other functions of this Winbond super IO chip may be integrated
- Lowercase hex value
- Minor changes to the comments

 drivers/misc/Kconfig          |  8 ++++++++
 drivers/misc/Makefile         |  1 +
 drivers/misc/winbond_w83627.c | 41 +++++++++++++++++++++++++++++++++++++++++
 include/winbond_w83627.h      | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)
 create mode 100644 drivers/misc/winbond_w83627.c
 create mode 100644 include/winbond_w83627.h
drivers/misc/Kconfig +8 -0
index b92da4e..dfd804f 100644
@@ -112,4 +112,12 @@ config RESET
 	  effect a reset. The uclass will try all available drivers when
 	  reset_walk() is called.
 
+config WINBOND_W83627
+	bool "Enable Winbond Super I/O driver"
+	help
+	  If you say Y here, you will get support for the Winbond
+	  W83627 Super I/O driver. This can be used to enable the
+	  legacy UART or other devices in the Winbond Super IO chips
+	  on X86 platforms.
+
 endmenu
drivers/misc/Makefile +1 -0
index aa137f5..15505bf 100644
@@ -38,3 +38,4 @@ obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
 obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
 obj-$(CONFIG_RESET) += reset-uclass.o
 obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o
+obj-$(CONFIG_WINBOND_W83627) += winbond_w83627.o
drivers/misc/winbond_w83627.c new file +41 -0

41 lines not on this page · raw message

include/winbond_w83627.h new file +35 -0
new file mode 100644
index 0000000..ac3bec6
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Stefan Roese <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef _WINBOND_W83627_H_
+#define _WINBOND_W83627_H_
+
+/* I/O address of Winbond Super IO chip */
+#define WINBOND_IO_PORT		0x2e
+
+/* Logical device number */
+#define W83627DHG_FDC		0	/* Floppy */
+#define W83627DHG_PP		1	/* Parallel port */
+#define W83627DHG_SP1		2	/* Com1 */
+#define W83627DHG_SP2		3	/* Com2 */
+#define W83627DHG_KBC		5	/* PS/2 keyboard & mouse */
+#define W83627DHG_SPI		6	/* Serial peripheral interface */
+#define W83627DHG_WDTO_PLED	8	/* WDTO#, PLED */
+#define W83627DHG_ACPI		10	/* ACPI */
+#define W83627DHG_HWM		11	/* Hardware monitor */
+#define W83627DHG_PECI_SST	12	/* PECI, SST */
+
+/**
+ * Configure the base I/O port of the specified serial device and enable the
+ * serial device.
+ *
+ * @dev: high 8 bits = super I/O port, low 8 bits = logical device number
+ * @iobase: processor I/O port address to assign to this serial device
+ * @irq: processor IRQ number to assign to this serial device
+ */
+void winbond_enable_serial(uint dev, uint iobase, uint irq);
+
+#endif /* _WINBOND_W83627_H_ */
Signature · 1 line
2.6.5
#1 lore raw

PATCH 2/2 x86: BayTrail: Add option to disable the internal UART to setup_early_uart()

This patch adds a parameter to the function setup_early_uart() to either enable or disable the internal BayTrail legacy UART. Since the name setup_early_uart() does not match its functionality any more, lets rename it to setup_internal_uart() as well in this patch.

---
 arch/x86/cpu/baytrail/early_uart.c | 10 +++++++---
 arch/x86/include/asm/u-boot-x86.h  |  2 +-
 arch/x86/lib/fsp/fsp_support.c     |  2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/cpu/baytrail/early_uart.c +7 -3
index b64a3a9..471d592 100644
@@ -59,11 +59,15 @@ static void x86_pci_write_config32(int dev, unsigned int where, u32 value)
 }
 
 /* This can be called after memory-mapped PCI is working */
-int setup_early_uart(void)
+int setup_internal_uart(int enable)
 {
-	/* Enable the legacy UART hardware. */
+	/* Enable or disable the legacy UART hardware */
 	x86_pci_write_config32(PCI_DEV_CONFIG(0, LPC_DEV, LPC_FUNC), UART_CONT,
-			       1);
+			       enable);
+
+	/* All done for the disable part, so just return */
+	if (!enable)
+		return 0;
 
 	/*
 	 * Set up the pads to the UART function. This allows the signals to
arch/x86/include/asm/u-boot-x86.h +1 -1
index dbf8e95..cc5c953 100644
@@ -45,7 +45,7 @@ void dram_init_banksize(void);
 int default_print_cpuinfo(void);
 
 /* Set up a UART which can be used with printch(), printhex8(), etc. */
-int setup_early_uart(void);
+int setup_internal_uart(int enable);
 
 void setup_pcat_compatibility(void);
 
arch/x86/lib/fsp/fsp_support.c +1 -1
index 875c96a..29fa060 100644
@@ -111,7 +111,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 #endif
 
 #ifdef CONFIG_DEBUG_UART
-	setup_early_uart();
+	setup_internal_uart(1);
 #endif
 
 	fsp_hdr = find_fsp_header();
Signature · 1 line
2.6.5
#2 lore raw

PATCH 2/2 x86: BayTrail: Add option to disable the internal UART to setup_early_uart()

Hi Stefan,

Quoted 55 lines · Stefan Roese

This patch adds a parameter to the function setup_early_uart() to either enable or disable the internal BayTrail legacy UART. Since the name setup_early_uart() does not match its functionality any more, lets rename it to setup_internal_uart() as well in this patch.

---
 arch/x86/cpu/baytrail/early_uart.c | 10 +++++++---
 arch/x86/include/asm/u-boot-x86.h  |  2 +-
 arch/x86/lib/fsp/fsp_support.c     |  2 +-
 3 files changed, 9 insertions(+), 5 deletions(-)
arch/x86/cpu/baytrail/early_uart.c +7 -3
index b64a3a9..471d592 100644
@@ -59,11 +59,15 @@ static void x86_pci_write_config32(int dev, unsigned int where, u32 value)
 }
 
 /* This can be called after memory-mapped PCI is working */
-int setup_early_uart(void)
+int setup_internal_uart(int enable)
 {
-       /* Enable the legacy UART hardware. */
+       /* Enable or disable the legacy UART hardware */
        x86_pci_write_config32(PCI_DEV_CONFIG(0, LPC_DEV, LPC_FUNC), UART_CONT,
-                              1);
+                              enable);
+
+       /* All done for the disable part, so just return */
+       if (!enable)
+               return 0;
 
        /*
         * Set up the pads to the UART function. This allows the signals to
arch/x86/include/asm/u-boot-x86.h +1 -1
index dbf8e95..cc5c953 100644
@@ -45,7 +45,7 @@ void dram_init_banksize(void);
 int default_print_cpuinfo(void);
 
 /* Set up a UART which can be used with printch(), printhex8(), etc. */
-int setup_early_uart(void);
+int setup_internal_uart(int enable);
 
 void setup_pcat_compatibility(void);
 
arch/x86/lib/fsp/fsp_support.c +0 -0
index 875c96a..29fa060 100644

arch/x86/lib/fsp/fsp_support.c void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)

Quoted 9 lines
arch/x86/lib/fsp/fsp_support.c +1 -2
@@ -111,7 +111,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 #endif
 
 #ifdef CONFIG_DEBUG_UART
-       setup_early_uart();
+       setup_internal_uart(1);
 #endif
 
        fsp_hdr = find_fsp_header();
--

There is one more instance of setup_early_uart() in README.x86 that needs to be changed.

Other than that,

Regards,
Bin

#3 lore raw

PATCH v2 2/2 x86: BayTrail: Add option to disable the internal UART to setup_early_uart()

In reply to Stefan Roese

This patch adds a parameter to the function setup_early_uart() to either enable or disable the internal BayTrail legacy UART. Since the name setup_early_uart() does not match its functionality any more, lets rename it to setup_internal_uart() as well in this patch.

---
v2:
- Also change reference in README.x86

 arch/x86/cpu/baytrail/early_uart.c | 10 +++++++---
 arch/x86/include/asm/u-boot-x86.h  |  2 +-
 arch/x86/lib/fsp/fsp_support.c     |  2 +-
 doc/README.x86                     |  2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/cpu/baytrail/early_uart.c +7 -3
index b64a3a9..471d592 100644
@@ -59,11 +59,15 @@ static void x86_pci_write_config32(int dev, unsigned int where, u32 value)
 }
 
 /* This can be called after memory-mapped PCI is working */
-int setup_early_uart(void)
+int setup_internal_uart(int enable)
 {
-	/* Enable the legacy UART hardware. */
+	/* Enable or disable the legacy UART hardware */
 	x86_pci_write_config32(PCI_DEV_CONFIG(0, LPC_DEV, LPC_FUNC), UART_CONT,
-			       1);
+			       enable);
+
+	/* All done for the disable part, so just return */
+	if (!enable)
+		return 0;
 
 	/*
 	 * Set up the pads to the UART function. This allows the signals to
arch/x86/include/asm/u-boot-x86.h +1 -1
index dbf8e95..cc5c953 100644
@@ -45,7 +45,7 @@ void dram_init_banksize(void);
 int default_print_cpuinfo(void);
 
 /* Set up a UART which can be used with printch(), printhex8(), etc. */
-int setup_early_uart(void);
+int setup_internal_uart(int enable);
 
 void setup_pcat_compatibility(void);
 
arch/x86/lib/fsp/fsp_support.c +1 -1
index 875c96a..29fa060 100644
@@ -111,7 +111,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 #endif
 
 #ifdef CONFIG_DEBUG_UART
-	setup_early_uart();
+	setup_internal_uart(1);
 #endif
 
 	fsp_hdr = find_fsp_header();
doc/README.x86 +1 -1
index 36aaef0..6d9cb10 100644
@@ -706,7 +706,7 @@ the board, then you can use post_code() calls from C or assembler to monitor
 boot progress. This can be good for debugging.
 
 If not, you can try to get serial working as early as possible. The early
-debug serial port may be useful here. See setup_early_uart() for an example.
+debug serial port may be useful here. See setup_internal_uart() for an example.
 
 During the U-Boot porting, one of the important steps is to write correct PIRQ
 routing information in the board device tree. Without it, device drivers in the
Signature · 1 line
2.6.5
#4 lore raw

PATCH v2 2/2 x86: BayTrail: Add option to disable the internal UART to setup_early_uart()

Hi Simon,

Quoted 72 lines · Stefan Roese

This patch adds a parameter to the function setup_early_uart() to either enable or disable the internal BayTrail legacy UART. Since the name setup_early_uart() does not match its functionality any more, lets rename it to setup_internal_uart() as well in this patch.

---
v2:
- Also change reference in README.x86

 arch/x86/cpu/baytrail/early_uart.c | 10 +++++++---
 arch/x86/include/asm/u-boot-x86.h  |  2 +-
 arch/x86/lib/fsp/fsp_support.c     |  2 +-
 doc/README.x86                     |  2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)
arch/x86/cpu/baytrail/early_uart.c +7 -3
index b64a3a9..471d592 100644
@@ -59,11 +59,15 @@ static void x86_pci_write_config32(int dev, unsigned int where, u32 value)
 }
 
 /* This can be called after memory-mapped PCI is working */
-int setup_early_uart(void)
+int setup_internal_uart(int enable)
 {
-       /* Enable the legacy UART hardware. */
+       /* Enable or disable the legacy UART hardware */
        x86_pci_write_config32(PCI_DEV_CONFIG(0, LPC_DEV, LPC_FUNC), UART_CONT,
-                              1);
+                              enable);
+
+       /* All done for the disable part, so just return */
+       if (!enable)
+               return 0;
 
        /*
         * Set up the pads to the UART function. This allows the signals to
arch/x86/include/asm/u-boot-x86.h +1 -1
index dbf8e95..cc5c953 100644
@@ -45,7 +45,7 @@ void dram_init_banksize(void);
 int default_print_cpuinfo(void);
 
 /* Set up a UART which can be used with printch(), printhex8(), etc. */
-int setup_early_uart(void);
+int setup_internal_uart(int enable);
 
 void setup_pcat_compatibility(void);
 
arch/x86/lib/fsp/fsp_support.c +1 -1
index 875c96a..29fa060 100644
@@ -111,7 +111,7 @@ void fsp_init(u32 stack_top, u32 boot_mode, void *nvs_buf)
 #endif
 
 #ifdef CONFIG_DEBUG_UART
-       setup_early_uart();
+       setup_internal_uart(1);
 #endif
 
        fsp_hdr = find_fsp_header();
doc/README.x86 +0 -0
index 36aaef0..6d9cb10 100644

doc/README.x86 the board, then you can use post_code() calls from C or assembler to monitor

Quoted 9 lines
doc/README.x86 +1 -2
@@ -706,7 +706,7 @@ the board, then you can use post_code() calls from C or assembler to monitor
 boot progress. This can be good for debugging.
 
 If not, you can try to get serial working as early as possible. The early
-debug serial port may be useful here. See setup_early_uart() for an example.
+debug serial port may be useful here. See setup_internal_uart() for an example.
 
 During the U-Boot porting, one of the important steps is to write correct PIRQ
 routing information in the board device tree. Without it, device drivers in the
--

Do you have any comments about Stefan's series? If not, I am going to apply it soon.

Regards,
Bin

#5 lore raw

PATCH v2 2/2 x86: BayTrail: Add option to disable the internal UART to setup_early_uart()

Quoted 20 lines · Bin Meng

Hi Simon,

Quoted 17 lines · Stefan Roese

This patch adds a parameter to the function setup_early_uart() to either enable or disable the internal BayTrail legacy UART. Since the name setup_early_uart() does not match its functionality any more, lets rename it to setup_internal_uart() as well in this patch.

---
v2:
- Also change reference in README.x86

 arch/x86/cpu/baytrail/early_uart.c | 10 +++++++---
 arch/x86/include/asm/u-boot-x86.h  |  2 +-
 arch/x86/lib/fsp/fsp_support.c     |  2 +-
 doc/README.x86                     |  2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)
#6 lore raw

PATCH v2 2/2 x86: BayTrail: Add option to disable the internal UART to setup_early_uart()

Quoted 16 lines · Simon Glass
Quoted 15 lines · Bin Meng

Hi Simon,

Quoted 12 lines · Stefan Roese

This patch adds a parameter to the function setup_early_uart() to either enable or disable the internal BayTrail legacy UART. Since the name setup_early_uart() does not match its functionality any more, lets rename it to setup_internal_uart() as well in this patch.

---
v2:
- Also change reference in README.x86

Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
 arch/x86/cpu/baytrail/early_uart.c | 10 +++++++---
 arch/x86/include/asm/u-boot-x86.h  |  2 +-
 arch/x86/lib/fsp/fsp_support.c     |  2 +-
 doc/README.x86                     |  2 +-
 4 files changed, 10 insertions(+), 6 deletions(-)

applied to u-boot-x86/master, thanks!

#7 lore raw

PATCH v2 1/2 misc: Add simple driver to enable the legacy UART on Winbond Super IO chips

In reply to Stefan Roese
Quoted 15 lines · Stefan Roese

On most x86 boards, the legacy serial ports (io address 0x3f8/0x2f8) are provided by a superio chip connected to the LPC bus. We must program the superio chip so that serial ports are available for us.

---
v2:
- Address Bin's comments:
- Make description more generic, so that other functions of this Winbond super IO chip may be integrated
- Lowercase hex value
- Minor changes to the comments

Quoted 8 lines
 drivers/misc/Kconfig          |  8 ++++++++
 drivers/misc/Makefile         |  1 +
 drivers/misc/winbond_w83627.c | 41 +++++++++++++++++++++++++++++++++++++++++
 include/winbond_w83627.h      | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)
 create mode 100644 drivers/misc/winbond_w83627.c
 create mode 100644 include/winbond_w83627.h
#8 lore raw

PATCH v2 1/2 misc: Add simple driver to enable the legacy UART on Winbond Super IO chips

Quoted 25 lines · Bin Meng
Quoted 15 lines · Stefan Roese

On most x86 boards, the legacy serial ports (io address 0x3f8/0x2f8) are provided by a superio chip connected to the LPC bus. We must program the superio chip so that serial ports are available for us.

---
v2:
- Address Bin's comments:
- Make description more generic, so that other functions of this Winbond super IO chip may be integrated
- Lowercase hex value
- Minor changes to the comments

Quoted 8 lines
 drivers/misc/Kconfig          |  8 ++++++++
 drivers/misc/Makefile         |  1 +
 drivers/misc/winbond_w83627.c | 41 +++++++++++++++++++++++++++++++++++++++++
 include/winbond_w83627.h      | 35 +++++++++++++++++++++++++++++++++++
 4 files changed, 85 insertions(+)
 create mode 100644 drivers/misc/winbond_w83627.c
 create mode 100644 include/winbond_w83627.h
Quoted 1 line

applied to u-boot-x86/master, thanks!