[U-Boot] [PATCH 2/8] x86: quark: Add clrbits, setbits, clrsetbits macros for message port access

Simon Glass sjg at chromium.org
Wed Sep 9 20:06:31 CEST 2015


Hi Bin,

On Tuesday, 8 September 2015, Bin Meng <bmeng.cn at gmail.com> wrote:
>
> On Intel Quark, lots of registers on the message port need be
> programmed. Add handy clrbits, setbits, clrsetbits macros for
> message port access.
>
> Signed-off-by: Bin Meng <bmeng.cn at gmail.com>


Reviewed-by: Simon Glass <sjg at chromium.org>

But please see below.

>
> ---
>
>  arch/x86/include/asm/arch-quark/msg_port.h | 39 ++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
>
> diff --git a/arch/x86/include/asm/arch-quark/msg_port.h b/arch/x86/include/asm/arch-quark/msg_port.h
> index 2e78a66..825ae90 100644
> --- a/arch/x86/include/asm/arch-quark/msg_port.h
> +++ b/arch/x86/include/asm/arch-quark/msg_port.h
> @@ -101,6 +101,45 @@ u32 msg_port_io_read(u8 port, u32 reg);
>   */
>  void msg_port_io_write(u8 port, u32 reg, u32 value);
>
> +/* clrbits, setbits, clrsetbits macros for message port access */
> +
> +#define msg_port_normal_read   msg_port_read
> +#define msg_port_normal_write  msg_port_write
> +
> +#define msg_port_generic_clrbits(type, port, reg, clr)                 \
> +       msg_port_##type##_write(port, reg,                              \
> +                               msg_port_##type##_read(port, reg) & ~(clr))


Could be #defined to msg_port_clrsetbits(type, port, reg, clr, 0)

>
> +
> +#define msg_port_generic_setbits(type, port, reg, set)                 \
> +       msg_port_##type##_write(port, reg,                              \
> +                               msg_port_##type##_read(port, reg) | (set))
> +


Similarly msg_port_clrsetbits(type, port, reg, 0, set)

>
> +#define msg_port_generic_clrsetbits(type, port, reg, clr, set)         \
> +       msg_port_##type##_write(port, reg,                              \
> +                               (msg_port_##type##_read(port, reg)      \
> +                               & ~(clr)) | (set))
> +
> +#define msg_port_clrbits(port, reg, clr)               \
> +       msg_port_generic_clrbits(normal, port, reg, clr)
>
> +#define msg_port_setbits(port, reg, set)               \
> +       msg_port_generic_setbits(normal, port, reg, set)
> +#define msg_port_clrsetbits(port, reg, clr, set)       \
> +       msg_port_generic_clrsetbits(normal, port, reg, clr, set)
> +
> +#define msg_port_alt_clrbits(port, reg, clr)           \
> +       msg_port_generic_clrbits(alt, port, reg, clr)
> +#define msg_port_alt_setbits(port, reg, set)           \
> +       msg_port_generic_setbits(alt, port, reg, set)
> +#define msg_port_alt_clrsetbits(port, reg, clr, set)   \
> +       msg_port_generic_clrsetbits(alt, port, reg, clr, set)
> +
> +#define msg_port_io_clrbits(port, reg, clr)            \
> +       msg_port_generic_clrbits(io, port, reg, clr)
> +#define msg_port_io_setbits(port, reg, set)            \
> +       msg_port_generic_setbits(io, port, reg, set)
> +#define msg_port_io_clrsetbits(port, reg, clr, set)    \
> +       msg_port_generic_clrsetbits(io, port, reg, clr, set)
> +
>  #endif /* __ASSEMBLY__ */
>
>  #endif /* _QUARK_MSG_PORT_H_ */
> --
> 1.8.2.1
>

Regards,
Simon


More information about the U-Boot mailing list