From dafb66142e90b531209a59aa2484c92d2f33d0b0 Mon Sep 17 00:00:00 2001 From: Hung-Te Lin Date: Fri, 4 Oct 2019 14:48:46 +0800 Subject: device/mmio.h: Add more bit field helpers For fields with single bit, it's easier to declare as DEFINE_BIT(name, bit) Change-Id: If20e6b1809073b2c0dc84190edc25b207bf332b7 Signed-off-by: Hung-Te Lin Reviewed-on: https://review.coreboot.org/c/coreboot/+/35787 Tested-by: build bot (Jenkins) Reviewed-by: Julius Werner Reviewed-by: Yu-Ping Wu --- src/include/device/mmio.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/include/device/mmio.h') diff --git a/src/include/device/mmio.h b/src/include/device/mmio.h index 7b95a3cd74..df36eb6f96 100644 --- a/src/include/device/mmio.h +++ b/src/include/device/mmio.h @@ -63,6 +63,10 @@ static inline void buffer_to_fifo32(void *buffer, size_t size, void *fifo, * - high_bit: highest bit that's part of the bit field. * - low_bit: lowest bit in the bit field. * + * To define a field with a single bit: + * + * DEFINE_BIT(name, bit) + * * To extract one field value from a raw reg value: * * EXTRACT_BITFIELD(value, name); @@ -85,7 +89,7 @@ static inline void buffer_to_fifo32(void *buffer, size_t size, void *fifo, * Examples: * * DEFINE_BITFIELD(DISP_TYPE, 2, 1) - * DEFINE_BITFIELD(DISP_EN, 0, 0) + * DEFINE_BIT(DISP_EN, 0) * * SET32_BITFIELDS(&disp_regs.ctrl, DISP_TYPE, 2); * SET32_BITFIELDS(&disp_regs.ctrl, DISP_EN, 0); @@ -118,6 +122,8 @@ static inline void buffer_to_fifo32(void *buffer, size_t size, void *fifo, name##_BITFIELD_SIZE = (high_bit) - (low_bit) + 1, \ }; +#define DEFINE_BIT(name, bit) DEFINE_BITFIELD(name, bit, bit) + #define _BF_MASK(name, value) \ (((1 << name##_BITFIELD_SIZE) - 1) << name##_BITFIELD_SHIFT) -- cgit v1.2.3