Re: [PATCH 2/2 v2] efi: add serial driver support
On 17:23 Sat 11 Mar , Michael Olbrich wrote: > On Mon, Mar 06, 2017 at 10:34:47AM +0100, Jean-Christophe PLAGNIOL-VILLARD > wrote: > > So now we can stop to use the efi-stdio as this driver > > print on the Framebuffer and the serial at the same time. > > > > This is specially usefull if we want to use the framebuffer via efi-gop for > > something else. > > > > Do not forget to disable the efi-stdio device before enabling the console > > otherwise you will get double printing. > > Works nicely here (with a unrelated fix). However, it might be better to > implement this as a console_platform_driver. The efi drivers are loaded > rather late during startup and this makes early debugging impossible. I did not did it as you can use efi-stdio as early as possible but we can take a look to probe it earlier Best Regards, J. ___ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox
Re: [PATCH 2/2 v2] efi: add serial driver support
On Mon, Mar 06, 2017 at 10:34:47AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote: > So now we can stop to use the efi-stdio as this driver > print on the Framebuffer and the serial at the same time. > > This is specially usefull if we want to use the framebuffer via efi-gop for > something else. > > Do not forget to disable the efi-stdio device before enabling the console > otherwise you will get double printing. Works nicely here (with a unrelated fix). However, it might be better to implement this as a console_platform_driver. The efi drivers are loaded rather late during startup and this makes early debugging impossible. Michael > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD > --- > Fix copyright > > drivers/serial/Kconfig | 4 + > drivers/serial/Makefile | 1 + > drivers/serial/serial_efi.c | 221 > > 3 files changed, 226 insertions(+) > create mode 100644 drivers/serial/serial_efi.c > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index ced30530a..cfddc2ee9 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -21,6 +21,10 @@ config DRIVER_SERIAL_AR933X > If you have an Atheros AR933X SOC based board and want to use the > built-in UART of the SoC, say Y to this option. > > +config DRIVER_SERIAL_EFI > + bool "EFI serial" > + depends on EFI_BOOTUP > + > config DRIVER_SERIAL_IMX > depends on ARCH_IMX > default y > diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile > index 7d1bae195..3d9f735ed 100644 > --- a/drivers/serial/Makefile > +++ b/drivers/serial/Makefile > @@ -1,6 +1,7 @@ > obj-$(CONFIG_DRIVER_SERIAL_ARM_DCC) += arm_dcc.o > obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o > obj-$(CONFIG_DRIVER_SERIAL_AR933X) += serial_ar933x.o > +obj-$(CONFIG_DRIVER_SERIAL_EFI) += serial_efi.o > obj-$(CONFIG_DRIVER_SERIAL_IMX) += serial_imx.o > obj-$(CONFIG_DRIVER_SERIAL_STM378X) += stm-serial.o > obj-$(CONFIG_DRIVER_SERIAL_ATMEL)+= atmel.o > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c > new file mode 100644 > index 0..f0a2b22c2 > --- /dev/null > +++ b/drivers/serial/serial_efi.c > @@ -0,0 +1,221 @@ > +/* > + * Copyright (C) 2017 Jean-Christophe PLAGNIOL-VILLARD > > + * > + * Under GPLv2 Only > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * define for Control bits, grouped by read only, write only, and read write > + * > + * Read Only > + */ > +#define EFI_SERIAL_CLEAR_TO_SEND0x0010 > +#define EFI_SERIAL_DATA_SET_READY 0x0020 > +#define EFI_SERIAL_RING_INDICATE0x0040 > +#define EFI_SERIAL_CARRIER_DETECT 0x0080 > +#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 > +#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 > + > +/* > + * Write Only > + */ > +#define EFI_SERIAL_REQUEST_TO_SEND 0x0002 > +#define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 > + > +/* > + * Read Write > + */ > +#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 > +#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 > +#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 > + > +typedef enum { > + DefaultParity, > + NoParity, > + EvenParity, > + OddParity, > + MarkParity, > + SpaceParity > +} efi_parity_type; > + > +typedef enum { > + DefaultStopBits, > + OneStopBit, > + OneFiveStopBits, > + TwoStopBits > +} efi_stop_bits_type; > + > +struct efi_serial_io_mode { > + uint32_t controlmask; > + uint32_t timeout; > + uint64_t baudrate; > + uint32_t receivefifodepth; > + uint32_t databits; > + uint32_t parity; > + uint32_t stopbits; > +}; > + > +struct efi_serial_io_protocol { > + uint32_t revision; > + > + efi_status_t (EFIAPI *reset) (struct efi_serial_io_protocol *This); > + efi_status_t (EFIAPI *set_attributes) (struct efi_serial_io_protocol > *This, > + uint64_t baudrate, uint32_t receivefifodepth, > + uint32_t timeout, efi_parity_type parity, > + uint8_t databits, efi_stop_bits_type stopbits); > + efi_status_t (EFIAPI *setcontrol) (struct efi_serial_io_protocol *This, > + uint32_t control); > + efi_status_t (EFIAPI *getcontrol) (struct efi_serial_io_protocol *This, > + uint32_t *control); > + efi_status_t (EFIAPI *write) (struct efi_serial_io_protocol *This, > + unsigned long *buffersize, void *buffer); > + efi_status_t (EFIAPI *read) (struct efi_serial_io_protocol *This, > + unsigned long *buffersize, void *buffer); > + > + struct efi_serial_io_mode *mode; > +}; > + > +/* > + * We wrap our port structure around the generic console_device. > + */ > +struct efi_seri
Re: [PATCH 2/2 v2] efi: add serial driver support
On Mon, Mar 06, 2017 at 10:34:47AM +0100, Jean-Christophe PLAGNIOL-VILLARD wrote: > So now we can stop to use the efi-stdio as this driver > print on the Framebuffer and the serial at the same time. > > This is specially usefull if we want to use the framebuffer via efi-gop for > something else. > > Do not forget to disable the efi-stdio device before enabling the console > otherwise you will get double printing. > > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD > --- > Fix copyright Replaced with this version. Sascha > > drivers/serial/Kconfig | 4 + > drivers/serial/Makefile | 1 + > drivers/serial/serial_efi.c | 221 > > 3 files changed, 226 insertions(+) > create mode 100644 drivers/serial/serial_efi.c > > diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig > index ced30530a..cfddc2ee9 100644 > --- a/drivers/serial/Kconfig > +++ b/drivers/serial/Kconfig > @@ -21,6 +21,10 @@ config DRIVER_SERIAL_AR933X > If you have an Atheros AR933X SOC based board and want to use the > built-in UART of the SoC, say Y to this option. > > +config DRIVER_SERIAL_EFI > + bool "EFI serial" > + depends on EFI_BOOTUP > + > config DRIVER_SERIAL_IMX > depends on ARCH_IMX > default y > diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile > index 7d1bae195..3d9f735ed 100644 > --- a/drivers/serial/Makefile > +++ b/drivers/serial/Makefile > @@ -1,6 +1,7 @@ > obj-$(CONFIG_DRIVER_SERIAL_ARM_DCC) += arm_dcc.o > obj-$(CONFIG_SERIAL_AMBA_PL011) += amba-pl011.o > obj-$(CONFIG_DRIVER_SERIAL_AR933X) += serial_ar933x.o > +obj-$(CONFIG_DRIVER_SERIAL_EFI) += serial_efi.o > obj-$(CONFIG_DRIVER_SERIAL_IMX) += serial_imx.o > obj-$(CONFIG_DRIVER_SERIAL_STM378X) += stm-serial.o > obj-$(CONFIG_DRIVER_SERIAL_ATMEL)+= atmel.o > diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c > new file mode 100644 > index 0..f0a2b22c2 > --- /dev/null > +++ b/drivers/serial/serial_efi.c > @@ -0,0 +1,221 @@ > +/* > + * Copyright (C) 2017 Jean-Christophe PLAGNIOL-VILLARD > > + * > + * Under GPLv2 Only > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* > + * define for Control bits, grouped by read only, write only, and read write > + * > + * Read Only > + */ > +#define EFI_SERIAL_CLEAR_TO_SEND0x0010 > +#define EFI_SERIAL_DATA_SET_READY 0x0020 > +#define EFI_SERIAL_RING_INDICATE0x0040 > +#define EFI_SERIAL_CARRIER_DETECT 0x0080 > +#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 > +#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 > + > +/* > + * Write Only > + */ > +#define EFI_SERIAL_REQUEST_TO_SEND 0x0002 > +#define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 > + > +/* > + * Read Write > + */ > +#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 > +#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 > +#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 > + > +typedef enum { > + DefaultParity, > + NoParity, > + EvenParity, > + OddParity, > + MarkParity, > + SpaceParity > +} efi_parity_type; > + > +typedef enum { > + DefaultStopBits, > + OneStopBit, > + OneFiveStopBits, > + TwoStopBits > +} efi_stop_bits_type; > + > +struct efi_serial_io_mode { > + uint32_t controlmask; > + uint32_t timeout; > + uint64_t baudrate; > + uint32_t receivefifodepth; > + uint32_t databits; > + uint32_t parity; > + uint32_t stopbits; > +}; > + > +struct efi_serial_io_protocol { > + uint32_t revision; > + > + efi_status_t (EFIAPI *reset) (struct efi_serial_io_protocol *This); > + efi_status_t (EFIAPI *set_attributes) (struct efi_serial_io_protocol > *This, > + uint64_t baudrate, uint32_t receivefifodepth, > + uint32_t timeout, efi_parity_type parity, > + uint8_t databits, efi_stop_bits_type stopbits); > + efi_status_t (EFIAPI *setcontrol) (struct efi_serial_io_protocol *This, > + uint32_t control); > + efi_status_t (EFIAPI *getcontrol) (struct efi_serial_io_protocol *This, > + uint32_t *control); > + efi_status_t (EFIAPI *write) (struct efi_serial_io_protocol *This, > + unsigned long *buffersize, void *buffer); > + efi_status_t (EFIAPI *read) (struct efi_serial_io_protocol *This, > + unsigned long *buffersize, void *buffer); > + > + struct efi_serial_io_mode *mode; > +}; > + > +/* > + * We wrap our port structure around the generic console_device. > + */ > +struct efi_serial_port { > + struct efi_serial_io_protocol *serial; > + struct console_device uart; /* uart */ > + struct efi_device *efidev; > +}; > + > +static inline struct
[PATCH 2/2 v2] efi: add serial driver support
So now we can stop to use the efi-stdio as this driver print on the Framebuffer and the serial at the same time. This is specially usefull if we want to use the framebuffer via efi-gop for something else. Do not forget to disable the efi-stdio device before enabling the console otherwise you will get double printing. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD --- Fix copyright drivers/serial/Kconfig | 4 + drivers/serial/Makefile | 1 + drivers/serial/serial_efi.c | 221 3 files changed, 226 insertions(+) create mode 100644 drivers/serial/serial_efi.c diff --git a/drivers/serial/Kconfig b/drivers/serial/Kconfig index ced30530a..cfddc2ee9 100644 --- a/drivers/serial/Kconfig +++ b/drivers/serial/Kconfig @@ -21,6 +21,10 @@ config DRIVER_SERIAL_AR933X If you have an Atheros AR933X SOC based board and want to use the built-in UART of the SoC, say Y to this option. +config DRIVER_SERIAL_EFI + bool "EFI serial" + depends on EFI_BOOTUP + config DRIVER_SERIAL_IMX depends on ARCH_IMX default y diff --git a/drivers/serial/Makefile b/drivers/serial/Makefile index 7d1bae195..3d9f735ed 100644 --- a/drivers/serial/Makefile +++ b/drivers/serial/Makefile @@ -1,6 +1,7 @@ obj-$(CONFIG_DRIVER_SERIAL_ARM_DCC)+= arm_dcc.o obj-$(CONFIG_SERIAL_AMBA_PL011)+= amba-pl011.o obj-$(CONFIG_DRIVER_SERIAL_AR933X) += serial_ar933x.o +obj-$(CONFIG_DRIVER_SERIAL_EFI)+= serial_efi.o obj-$(CONFIG_DRIVER_SERIAL_IMX)+= serial_imx.o obj-$(CONFIG_DRIVER_SERIAL_STM378X)+= stm-serial.o obj-$(CONFIG_DRIVER_SERIAL_ATMEL) += atmel.o diff --git a/drivers/serial/serial_efi.c b/drivers/serial/serial_efi.c new file mode 100644 index 0..f0a2b22c2 --- /dev/null +++ b/drivers/serial/serial_efi.c @@ -0,0 +1,221 @@ +/* + * Copyright (C) 2017 Jean-Christophe PLAGNIOL-VILLARD + * + * Under GPLv2 Only + */ + +#include +#include +#include +#include +#include +#include +#include + +/* + * define for Control bits, grouped by read only, write only, and read write + * + * Read Only + */ +#define EFI_SERIAL_CLEAR_TO_SEND0x0010 +#define EFI_SERIAL_DATA_SET_READY 0x0020 +#define EFI_SERIAL_RING_INDICATE0x0040 +#define EFI_SERIAL_CARRIER_DETECT 0x0080 +#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x0100 +#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x0200 + +/* + * Write Only + */ +#define EFI_SERIAL_REQUEST_TO_SEND 0x0002 +#define EFI_SERIAL_DATA_TERMINAL_READY 0x0001 + +/* + * Read Write + */ +#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x1000 +#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x2000 +#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x4000 + +typedef enum { + DefaultParity, + NoParity, + EvenParity, + OddParity, + MarkParity, + SpaceParity +} efi_parity_type; + +typedef enum { + DefaultStopBits, + OneStopBit, + OneFiveStopBits, + TwoStopBits +} efi_stop_bits_type; + +struct efi_serial_io_mode { + uint32_t controlmask; + uint32_t timeout; + uint64_t baudrate; + uint32_t receivefifodepth; + uint32_t databits; + uint32_t parity; + uint32_t stopbits; +}; + +struct efi_serial_io_protocol { + uint32_t revision; + + efi_status_t (EFIAPI *reset) (struct efi_serial_io_protocol *This); + efi_status_t (EFIAPI *set_attributes) (struct efi_serial_io_protocol *This, + uint64_t baudrate, uint32_t receivefifodepth, + uint32_t timeout, efi_parity_type parity, + uint8_t databits, efi_stop_bits_type stopbits); + efi_status_t (EFIAPI *setcontrol) (struct efi_serial_io_protocol *This, + uint32_t control); + efi_status_t (EFIAPI *getcontrol) (struct efi_serial_io_protocol *This, + uint32_t *control); + efi_status_t (EFIAPI *write) (struct efi_serial_io_protocol *This, + unsigned long *buffersize, void *buffer); + efi_status_t (EFIAPI *read) (struct efi_serial_io_protocol *This, + unsigned long *buffersize, void *buffer); + + struct efi_serial_io_mode *mode; +}; + +/* + * We wrap our port structure around the generic console_device. + */ +struct efi_serial_port { + struct efi_serial_io_protocol *serial; + struct console_device uart; /* uart */ + struct efi_device *efidev; +}; + +static inline struct efi_serial_port * +to_efi_serial_port(struct console_device *uart) +{ + return container_of(uart, struct efi_serial_port, uart); +} + +static int efi_serial_setbaudrate(struct console_device *cdev, int baudrate) +{ + struct efi_serial_port *uart = to_efi_serial_port(cdev); + struct efi_serial_io_protocol *se