mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-28 22:54:05 +08:00
net: ipa: GSI register cleanup
Move some static inline function definitions out of "gsi_reg.h" and into "gsi.c", which is the only place they're used. Rename them so their names identify the register they're associated with. Move the gsi_channel_type enumerated type definition below the offset and field definitions for the CH_C_CNTXT_0 register where it's used. Signed-off-by: Alex Elder <elder@linaro.org> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c5ebba75c7
commit
0ec573ef2a
@ -182,6 +182,41 @@ static bool gsi_channel_initialized(struct gsi_channel *channel)
|
||||
return !!channel->gsi;
|
||||
}
|
||||
|
||||
/* Encode the channel protocol for the CH_C_CNTXT_0 register */
|
||||
static u32 ch_c_cntxt_0_type_encode(enum ipa_version version,
|
||||
enum gsi_channel_type type)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = u32_encode_bits(type, CHTYPE_PROTOCOL_FMASK);
|
||||
if (version < IPA_VERSION_4_5)
|
||||
return val;
|
||||
|
||||
type >>= hweight32(CHTYPE_PROTOCOL_FMASK);
|
||||
|
||||
return val | u32_encode_bits(type, CHTYPE_PROTOCOL_MSB_FMASK);
|
||||
}
|
||||
|
||||
/* Encode a channel ring buffer length for the CH_C_CNTXT_1 register */
|
||||
static u32 ch_c_cntxt_1_length_encode(enum ipa_version version, u32 length)
|
||||
{
|
||||
if (version < IPA_VERSION_4_9)
|
||||
return u32_encode_bits(length, GENMASK(15, 0));
|
||||
|
||||
return u32_encode_bits(length, GENMASK(19, 0));
|
||||
}
|
||||
|
||||
/* Encode the length of the event channel ring buffer for the
|
||||
* EV_CH_E_CNTXT_1 register.
|
||||
*/
|
||||
static u32 ev_ch_e_cntxt_1_length_encode(enum ipa_version version, u32 length)
|
||||
{
|
||||
if (version < IPA_VERSION_4_9)
|
||||
return u32_encode_bits(length, GENMASK(15, 0));
|
||||
|
||||
return u32_encode_bits(length, GENMASK(19, 0));
|
||||
}
|
||||
|
||||
/* Update the GSI IRQ type register with the cached value */
|
||||
static void gsi_irq_type_update(struct gsi *gsi, u32 val)
|
||||
{
|
||||
@ -676,7 +711,7 @@ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id)
|
||||
iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_0_OFFSET(evt_ring_id));
|
||||
|
||||
size = ring->count * GSI_RING_ELEMENT_SIZE;
|
||||
val = ev_r_length_encoded(gsi->version, size);
|
||||
val = ev_ch_e_cntxt_1_length_encode(gsi->version, size);
|
||||
iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_1_OFFSET(evt_ring_id));
|
||||
|
||||
/* The context 2 and 3 registers store the low-order and
|
||||
@ -765,14 +800,14 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell)
|
||||
u32 val;
|
||||
|
||||
/* We program all channels as GPI type/protocol */
|
||||
val = chtype_protocol_encoded(gsi->version, GSI_CHANNEL_TYPE_GPI);
|
||||
val = ch_c_cntxt_0_type_encode(gsi->version, GSI_CHANNEL_TYPE_GPI);
|
||||
if (channel->toward_ipa)
|
||||
val |= CHTYPE_DIR_FMASK;
|
||||
val |= u32_encode_bits(channel->evt_ring_id, ERINDEX_FMASK);
|
||||
val |= u32_encode_bits(GSI_RING_ELEMENT_SIZE, ELEMENT_SIZE_FMASK);
|
||||
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_0_OFFSET(channel_id));
|
||||
|
||||
val = r_length_encoded(gsi->version, size);
|
||||
val = ch_c_cntxt_1_length_encode(gsi->version, size);
|
||||
iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_1_OFFSET(channel_id));
|
||||
|
||||
/* The context 2 and 3 registers store the low-order and
|
||||
|
@ -62,6 +62,18 @@
|
||||
|
||||
/* All other register offsets are relative to gsi->virt */
|
||||
|
||||
#define GSI_CH_C_CNTXT_0_OFFSET(ch) \
|
||||
(0x0001c000 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
|
||||
#define CHTYPE_PROTOCOL_FMASK GENMASK(2, 0)
|
||||
#define CHTYPE_DIR_FMASK GENMASK(3, 3)
|
||||
#define EE_FMASK GENMASK(7, 4)
|
||||
#define CHID_FMASK GENMASK(12, 8)
|
||||
/* The next field is present for IPA v4.5 and above */
|
||||
#define CHTYPE_PROTOCOL_MSB_FMASK GENMASK(13, 13)
|
||||
#define ERINDEX_FMASK GENMASK(18, 14)
|
||||
#define CHSTATE_FMASK GENMASK(23, 20)
|
||||
#define ELEMENT_SIZE_FMASK GENMASK(31, 24)
|
||||
|
||||
/** enum gsi_channel_type - CHTYPE_PROTOCOL field values in CH_C_CNTXT_0 */
|
||||
enum gsi_channel_type {
|
||||
GSI_CHANNEL_TYPE_MHI = 0x0,
|
||||
@ -76,46 +88,9 @@ enum gsi_channel_type {
|
||||
GSI_CHANNEL_TYPE_11AD = 0x9,
|
||||
};
|
||||
|
||||
#define GSI_CH_C_CNTXT_0_OFFSET(ch) \
|
||||
(0x0001c000 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
|
||||
#define CHTYPE_PROTOCOL_FMASK GENMASK(2, 0)
|
||||
#define CHTYPE_DIR_FMASK GENMASK(3, 3)
|
||||
#define EE_FMASK GENMASK(7, 4)
|
||||
#define CHID_FMASK GENMASK(12, 8)
|
||||
/* The next field is present for IPA v4.5 and above */
|
||||
#define CHTYPE_PROTOCOL_MSB_FMASK GENMASK(13, 13)
|
||||
#define ERINDEX_FMASK GENMASK(18, 14)
|
||||
#define CHSTATE_FMASK GENMASK(23, 20)
|
||||
#define ELEMENT_SIZE_FMASK GENMASK(31, 24)
|
||||
|
||||
/* Encoded value for CH_C_CNTXT_0 register channel protocol fields */
|
||||
static inline u32
|
||||
chtype_protocol_encoded(enum ipa_version version, enum gsi_channel_type type)
|
||||
{
|
||||
u32 val;
|
||||
|
||||
val = u32_encode_bits(type, CHTYPE_PROTOCOL_FMASK);
|
||||
if (version < IPA_VERSION_4_5)
|
||||
return val;
|
||||
|
||||
/* Encode upper bit(s) as well */
|
||||
type >>= hweight32(CHTYPE_PROTOCOL_FMASK);
|
||||
val |= u32_encode_bits(type, CHTYPE_PROTOCOL_MSB_FMASK);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
#define GSI_CH_C_CNTXT_1_OFFSET(ch) \
|
||||
(0x0001c004 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
|
||||
|
||||
/* Encoded value for CH_C_CNTXT_1 register R_LENGTH field */
|
||||
static inline u32 r_length_encoded(enum ipa_version version, u32 length)
|
||||
{
|
||||
if (version < IPA_VERSION_4_9)
|
||||
return u32_encode_bits(length, GENMASK(15, 0));
|
||||
return u32_encode_bits(length, GENMASK(19, 0));
|
||||
}
|
||||
|
||||
#define GSI_CH_C_CNTXT_2_OFFSET(ch) \
|
||||
(0x0001c008 + 0x4000 * GSI_EE_AP + 0x80 * (ch))
|
||||
|
||||
@ -167,13 +142,6 @@ enum gsi_prefetch_mode {
|
||||
|
||||
#define GSI_EV_CH_E_CNTXT_1_OFFSET(ev) \
|
||||
(0x0001d004 + 0x4000 * GSI_EE_AP + 0x80 * (ev))
|
||||
/* Encoded value for EV_CH_C_CNTXT_1 register EV_R_LENGTH field */
|
||||
static inline u32 ev_r_length_encoded(enum ipa_version version, u32 length)
|
||||
{
|
||||
if (version < IPA_VERSION_4_9)
|
||||
return u32_encode_bits(length, GENMASK(15, 0));
|
||||
return u32_encode_bits(length, GENMASK(19, 0));
|
||||
}
|
||||
|
||||
#define GSI_EV_CH_E_CNTXT_2_OFFSET(ev) \
|
||||
(0x0001d008 + 0x4000 * GSI_EE_AP + 0x80 * (ev))
|
||||
|
Loading…
Reference in New Issue
Block a user