Replace serial setparity by setconfig
v3 cover Replace serial setparity by setconfig
This series :
- Replace setparity ops by more complete setconfig in serial uclass
- Replace setparity by setconfig in STM32 serial driver _ Adds test for serial setconfig
Changes in v3:
- Update SERIAL_PAR_MASK definition
- Don't remove setparity ops declaration in patch 1 to not break bissectability
- Replace u8 by uint for parity/bits/stop in stm32_serial_setconfig()
- Add patch to remove obsolete setparity ops
- Update serial test when wrong serial options are specified
- Add SERIAL_CONFIG(par, bits, stop) macro to create serial mask
Changes in v2:
- Update SERIAL_BITS_MASK and SERIAL_STOP_MASK
- Update serial_setconfig prototype
- Update stm32_serial_setconfig prototype
- Add sandbox serial test
Patrice Chotard (4):
dm: serial: Replace setparity by setconfig
serial: stm32: Replace setparity by setconfig
dm: serial: Remove setparity ops
sandbox: Add serial test
drivers/serial/sandbox.c | 14 +++++++++++ drivers/serial/serial-uclass.c | 16 +++++++++++++ drivers/serial/serial_stm32.c | 21 +++++++++++----- include/common.h | 1 + include/serial.h | 48 ++++++++++++++++++++++++++++++++++--- test/dm/Makefile | 1 + test/dm/serial.c | 54 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 146 insertions(+), 9 deletions(-) create mode 100644 test/dm/serial.c
Signature · 1 line
1.9.1
PATCH v3 1/4 dm: serial: Replace setparity by setconfig
Replace setparity by more generic setconfig ops to allow uart parity, bits word length and stop bits number change.
Adds SERIAL_GET_PARITY/BITS/STOP macros.
---
Changes in v3:
- Update SERIAL_PAR_MASK definition
- Don't remove setparity ops declaration in patch 1 to not break bissectability
Changes in v2:
- Update SERIAL_BITS_MASK and SERIAL_STOP_MASK
- Update serial_setconfig prototype
drivers/serial/serial-uclass.c | 16 ++++++++++++++ include/serial.h | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
drivers/serial/serial-uclass.c +16 -0
@@ -287,6 +287,20 @@ void serial_setbrg(void) ops->setbrg (gd->cur_serial_dev, gd->baudrate); } +int serial_setconfig (uint config) +{ +struct dm_serial_ops *ops; + +if (!gd->cur_serial_dev) +return 0 ; + + ops =serial_get_ops (gd->cur_serial_dev); +if (ops->setconfig) +return ops->setconfig (gd->cur_serial_dev, config); + +return 0 ; +} +void serial_stdio_init (void ) { }
@@ -398,6 +412,8 @@ static int serial_post_probe(struct udevice *dev) ops->pending += gd->reloc_off;if (ops->clear) ops->clear += gd->reloc_off; +if (ops->setconfig) + ops->setconfig += gd->reloc_off;#if CONFIG_POST &CONFIG_SYS_POST_UART if (ops->loop) ops->loop += gd->reloc_off
include/serial.h +47 -0
59 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 1/4 dm: serial: Replace setparity by setconfig
Quoted 15 lines · Patrice Chotard
Replace setparity by more generic setconfig ops to allow uart parity, bits word length and stop bits number change.
Adds SERIAL_GET_PARITY/BITS/STOP macros.
Signed-off-by Patrick Delaunay <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
Changes in v3:
- UpdateSERIAL_PAR_MASKdefinition
- Don't remove setparity ops declaration in patch 1 to not break bissectability
Quoted 7 lines
Changes in v2:
- UpdateSERIAL_BITS_MASKandSERIAL_STOP_MASK
- Updateserial_setconfigprototypedrivers/serial/serial-uclass.c | 16 ++++++++++++++ include/serial.h | 47 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+)
PATCH v3 1/4 dm: serial: Replace setparity by setconfig
In reply to Patrice ChotardQuoted 9 lines · Patrice Chotard
Replace setparity by more generic setconfig ops to allow uart parity, bits word length and stop bits number change.
Adds SERIAL_GET_PARITY/BITS/STOP macros.
Signed-off-by Patrick Delaunay <[email protected]>Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/b5b338a6/attachment.sig>
PATCH v3 2/4 serial: stm32: Replace setparity by setconfig
In reply to Patrice ChotardReplace stm32_serial_setparity by stm32_serial_setconfig which allows to set serial bits number, parity and stop bits number.
Only parity setting is implemented.
---
Changes in v3:
- Replace u8 by uint for parity/bits/stop in stm32_serial_setconfig()
Changes in v2:
- Update stm32_serial_setconfig prototype
drivers/serial/serial_stm32.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
drivers/serial/serial_stm32.c +15 -6
@@ -47,20 +47,28 @@ static int stm32_serial_setbrg(struct udevice *dev, int baudrate)return 0 ; } -static int stm32_serial_setparity (struct udevice *dev,enum serial_par parity) +static int stm32_serial_setconfig (struct udevice *dev,uint serial_config) {struct stm32x7_serial_platdata *plat =dev_get_platdata (dev);bool stm32f4 = plat->uart_info->stm32f4;u8 uart_enable_bit = plat->uart_info->uart_enable_bit;u32 cr1 = plat->base +CR1_OFFSET (stm32f4);u32 config =0 ; - -if (stm32f4) -return -EINVAL ;/* not supported in driver*/ +uint parity =SERIAL_GET_PARITY (serial_config); +uint bits =SERIAL_GET_BITS (serial_config); +uint stop =SERIAL_GET_STOP (serial_config); + +/* +* only parity config is implemented, check if other serial settings +* are the default one. +* (STM32F4 serial IP didn't support parity setting) +*/ +if (bits !=SERIAL_8_BITS || stop !=SERIAL_ONE_STOP || stm32f4) +return -ENOTSUPP ;/* not supported in driver*/ clrbits_le32 (cr1,USART_CR1_RE |USART_CR1_TE |BIT (uart_enable_bit));/* update usart configuration (uart need to be disable) -* PCE: parity check control +* PCE: parity check enable * PS : '0' : Even / '1' : Odd * M[1:0] = '00' : 8 Data bits * M[1:0] = '01' : 9 Data bits with parity
@@ -77,6 +85,7 @@ static int stm32_serial_setparity(struct udevice *dev, enum serial_par parity) config =USART_CR1_PCE |USART_CR1_M0 ;break ; } + clrsetbits_le32(cr1, USART_CR1_PCE | USART_CR1_PS | USART_CR1_M1 | USART_CR1_M0,
@@ -210,7 +219,7 @@ static const struct dm_serial_ops stm32_serial_ops = { .pending = stm32_serial_pending, .getc = stm32_serial_getc, .setbrg = stm32_serial_setbrg, - .setparity = stm32_serial_setparity + .setconfig = stm32_serial_setconfig };U_BOOT_DRIVER (serial_stm32) = {
Signature · 1 line
1.9.1
PATCH v3 2/4 serial: stm32: Replace setparity by setconfig
Quoted 9 lines · Patrice Chotard
Replace
stm32_serial_setparitybystm32_serial_setconfigwhich allows to set serial bits number, parity and stop bits number.
Only parity setting is implemented.Signed-off-by Patrick Delaunay <[email protected]>Signed-off-by Patrice Chotard <[email protected]>---
Quoted 8 lines
Changes in v3:
- Replace u8 by uint for parity/bits/stop instm32_serial_setconfig()Changes in v2:
- Updatestm32_serial_setconfigprototypedrivers/serial/serial_stm32.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
PATCH v3 2/4 serial: stm32: Replace setparity by setconfig
In reply to Patrice ChotardQuoted 8 lines · Patrice Chotard
Replace
stm32_serial_setparitybystm32_serial_setconfigwhich allows to set serial bits number, parity and stop bits number.
Only parity setting is implemented.Signed-off-by Patrick Delaunay <[email protected]>Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/65238d66/attachment.sig>
PATCH v3 3/4 dm: serial: Remove setparity ops
In reply to Patrice Chotardsetparity users has been updated to use new setconfig ops, so we can safely remove setparity ops
---
Changes in v3:
- Add patch to remove obsolete setparity ops
Changes in v2: None
include/serial.h | 10 ---------- 1 file changed, 10 deletions(-)
include/serial.h +0 -10
@@ -182,16 +182,6 @@ struct dm_serial_ops {*/ int (*loop)(struct udevice *dev,int on);#endif -/** -* setparity() - Set up the parity -* -* Set up a new parity for this device. -* -* @dev: Device pointer -* @parity: parity to use -* @return 0 if OK, -ve on error -*/ -int (*setparity)(struct udevice *dev,enum serial_par parity);/** * setconfig() - Set up the uart configuration
Signature · 1 line
1.9.1
PATCH v3 3/4 dm: serial: Remove setparity ops
Quoted 6 lines · Patrice Chotard
setparity users has been updated to use new setconfig ops, so we can safely remove setparity ops
Signed-off-by Patrice Chotard <[email protected]>---
Quoted 7 lines
Changes in v3:
- Add patch to remove obsolete setparity opsChanges in v2: None
include/serial.h | 10 ---------- 1 file changed, 10 deletions(-)
PATCH v3 3/4 dm: serial: Remove setparity ops
In reply to Patrice ChotardQuoted 5 lines · Patrice Chotard
setparity users has been updated to use new setconfig ops, so we can safely remove setparity ops
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/493006a8/attachment.sig>
PATCH v3 4/4 sandbox: Add serial test
In reply to Patrice Chotard---
Changes in v3:
- Update serial test when wrong serial options are specified
- Add SERIAL_CONFIG(par, bits, stop) macro to create serial mask
Changes in v2:
- Add sandbox serial test
drivers/serial/sandbox.c | 14 +++++++++++++ include/common.h | 1 + include/serial.h | 5 +++++ test/dm/Makefile | 1 + test/dm/serial.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 test/dm/serial.c
drivers/serial/sandbox.c +14 -0
@@ -143,6 +143,19 @@ static int sandbox_serial_getc(struct udevice *dev)return result; } +static int sandbox_serial_setconfig (struct udevice *dev,uint serial_config) +{ +u8 parity =SERIAL_GET_PARITY (serial_config); +u8 bits =SERIAL_GET_BITS (serial_config); +u8 stop =SERIAL_GET_STOP (serial_config); + +if (bits !=SERIAL_8_BITS || stop !=SERIAL_ONE_STOP || + parity !=SERIAL_PAR_NONE ) +return -ENOTSUPP ;/* not supported in driver*/ + +return 0 ; +} +static const char *const ansi_colour[] = {"black" ,"red" ,"green" ,"yellow" ,"blue" ,"megenta" ,"cyan" ,"white" ,
@@ -173,6 +186,7 @@ static const struct dm_serial_ops sandbox_serial_ops = { .putc = sandbox_serial_putc, .pending = sandbox_serial_pending, .getc = sandbox_serial_getc, + .setconfig = sandbox_serial_setconfig, };static const struct udevice_id sandbox_serial_ids[] = {
include/common.h +1 -0
@@ -359,6 +359,7 @@ void serial_putc_raw(const char);void serial_puts (const char *);int serial_getc (void );int serial_tstc (void ); +int serial_setconfig (uint config);/* $(CPU)/speed.c */ int get_clocks (void );
include/serial.h +5 -0
@@ -102,6 +102,11 @@ enum serial_stop {#define SERIAL_GET_STOP (config) \ ((config & SERIAL_STOP_MASK) >> SERIAL_STOP_SHIFT) +#define SERIAL_CONFIG (par, bits, stop) \ + (par << SERIAL_PAR_SHIFT | \ + bits << SERIAL_BITS_SHIFT | \ + stop << SERIAL_STOP_SHIFT) +#define SERIAL_DEFAULT_CONFIG SERIAL_PAR_NONE << SERIAL_PAR_SHIFT | \ SERIAL_8_BITS << SERIAL_BITS_SHIFT | \ SERIAL_ONE_STOP << SERIAL_STOP_SHIFT
test/dm/Makefile +1 -0
@@ -44,4 +44,5 @@ obj-$(CONFIG_DM_VIDEO) += video.o obj-$(CONFIG_ADC) += adc.o obj-$(CONFIG_SPMI) += spmi.o obj-$(CONFIG_WDT) += wdt.o +obj-$(CONFIG_DM_SERIAL) += serial.o endif
test/dm/serial.c new file +54 -0
54 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v3 4/4 sandbox: Add serial test
Quoted 10 lines · Patrice Chotard
Signed-off-by Patrice Chotard <[email protected]>---
Changes in v3:
- Update serial test when wrong serial options are specified
- AddSERIAL_CONFIG(par, bits, stop)macro to create serial maskChanges in v2:
- Add sandbox serial test
Quoted 7 lines
drivers/serial/sandbox.c | 14 +++++++++++++ include/common.h | 1 + include/serial.h | 5 +++++ test/dm/Makefile | 1 + test/dm/serial.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 75 insertions(+) create mode 100644 test/dm/serial.c
PATCH v3 4/4 sandbox: Add serial test
In reply to Patrice ChotardQuoted 2 lines · Patrice Chotard
Signed-off-by Patrice Chotard <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180911/59bf4429/attachment.sig>