diff options
author | Patrice Chotard | 2018-08-03 15:07:38 +0200 |
---|---|---|
committer | Tom Rini | 2018-09-10 20:20:38 -0400 |
commit | cbf538831d4b49d914cfdd885204f2551c8608e2 (patch) | |
tree | 88e228fb4e37b585a33b21ded149756fa143fc2c /include/serial.h | |
parent | 555e378ca7658e817986e18e4a3f214a7fac60ad (diff) |
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.
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'include/serial.h')
-rw-r--r-- | include/serial.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/include/serial.h b/include/serial.h index 9cd6f107032..8b00f38280f 100644 --- a/include/serial.h +++ b/include/serial.h @@ -73,6 +73,39 @@ enum serial_par { SERIAL_PAR_EVEN }; +#define SERIAL_PAR_SHIFT 0 +#define SERIAL_PAR_MASK (0x03 << SERIAL_PAR_SHIFT) +#define SERIAL_GET_PARITY(config) \ + ((config & SERIAL_PAR_MASK) >> SERIAL_PAR_SHIFT) + +enum serial_bits { + SERIAL_5_BITS, + SERIAL_6_BITS, + SERIAL_7_BITS, + SERIAL_8_BITS +}; + +#define SERIAL_BITS_SHIFT 2 +#define SERIAL_BITS_MASK (0x3 << SERIAL_BITS_SHIFT) +#define SERIAL_GET_BITS(config) \ + ((config & SERIAL_BITS_MASK) >> SERIAL_BITS_SHIFT) + +enum serial_stop { + SERIAL_HALF_STOP, /* 0.5 stop bit */ + SERIAL_ONE_STOP, /* 1 stop bit */ + SERIAL_ONE_HALF_STOP, /* 1.5 stop bit */ + SERIAL_TWO_STOP /* 2 stop bit */ +}; + +#define SERIAL_STOP_SHIFT 4 +#define SERIAL_STOP_MASK (0x3 << SERIAL_STOP_SHIFT) +#define SERIAL_GET_STOP(config) \ + ((config & SERIAL_STOP_MASK) >> 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 + /** * struct struct dm_serial_ops - Driver model serial operations * @@ -159,6 +192,20 @@ struct dm_serial_ops { * @return 0 if OK, -ve on error */ int (*setparity)(struct udevice *dev, enum serial_par parity); + + /** + * setconfig() - Set up the uart configuration + * (parity, 5/6/7/8 bits word length, stop bits) + * + * Set up a new config for this device. + * + * @dev: Device pointer + * @parity: parity to use + * @bits: bits number to use + * @stop: stop bits number to use + * @return 0 if OK, -ve on error + */ + int (*setconfig)(struct udevice *dev, uint serial_config); }; /** |