2018-12-06 14:17:51 +00:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2017-04-21 10:43:26 +00:00
|
|
|
*
|
2018-12-06 14:17:51 +00:00
|
|
|
* Copyright 2017 NXP
|
2017-04-21 10:43:26 +00:00
|
|
|
*
|
2018-05-15 09:49:22 +00:00
|
|
|
*/
|
2017-04-21 10:43:26 +00:00
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
#ifndef __DPAA_BITS_H
|
|
|
|
#define __DPAA_BITS_H
|
2017-04-21 10:43:26 +00:00
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
/* Bitfield stuff. */
|
|
|
|
#define BITS_PER_ULONG (sizeof(unsigned long) << 3)
|
|
|
|
#define SHIFT_PER_ULONG (((1 << 5) == BITS_PER_ULONG) ? 5 : 6)
|
|
|
|
#define BITS_MASK(idx) (1UL << ((idx) & (BITS_PER_ULONG - 1)))
|
|
|
|
#define BITS_IDX(idx) ((idx) >> SHIFT_PER_ULONG)
|
2017-04-21 10:43:26 +00:00
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
static inline void dpaa_set_bits(unsigned long mask,
|
|
|
|
volatile unsigned long *p)
|
2017-04-21 10:43:26 +00:00
|
|
|
{
|
2018-05-15 09:49:22 +00:00
|
|
|
*p |= mask;
|
2017-04-21 10:43:26 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
static inline void dpaa_set_bit(int idx, volatile unsigned long *bits)
|
2017-04-21 10:43:26 +00:00
|
|
|
{
|
2018-05-15 09:49:22 +00:00
|
|
|
dpaa_set_bits(BITS_MASK(idx), bits + BITS_IDX(idx));
|
2017-04-21 10:43:26 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
static inline void dpaa_clear_bits(unsigned long mask,
|
|
|
|
volatile unsigned long *p)
|
2017-04-21 10:43:26 +00:00
|
|
|
{
|
2018-05-15 09:49:22 +00:00
|
|
|
*p &= ~mask;
|
2017-04-21 10:43:26 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
static inline void dpaa_clear_bit(int idx,
|
|
|
|
volatile unsigned long *bits)
|
2017-04-21 10:43:26 +00:00
|
|
|
{
|
2018-05-15 09:49:22 +00:00
|
|
|
dpaa_clear_bits(BITS_MASK(idx), bits + BITS_IDX(idx));
|
2017-04-21 10:43:26 +00:00
|
|
|
}
|
|
|
|
|
2018-05-15 09:49:22 +00:00
|
|
|
#endif /* __DPAA_BITS_H */
|