diff options
author | Hung-Te Lin <hungte@chromium.org> | 2019-10-04 14:48:46 +0800 |
---|---|---|
committer | Werner Zeh <werner.zeh@siemens.com> | 2019-10-08 05:54:10 +0000 |
commit | dafb66142e90b531209a59aa2484c92d2f33d0b0 (patch) | |
tree | c7f7235fe148e49df3a649df5645e98270dcdca8 /src/include | |
parent | 2431a707d3d184358a4667df6a46decf23cda8e1 (diff) |
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 <hungte@chromium.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35787
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/device/mmio.h | 8 |
1 files changed, 7 insertions, 1 deletions
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) |