Skip to content

Commit

Permalink
Merge branch 'net-ipa-ipa-register-cleanup'
Browse files Browse the repository at this point in the history
Alex Elder says:

====================
net: ipa: IPA register cleanup

This series consists of cleanup patches, almost entirely related to
the definitions for IPA registers.  Some comments are updated or
added to provide better information about defined IPA registers.
Other cleanups ensure symbol names and their assigned values are
defined consistently.  Some essentially duplicate definitions get
consolidated for simplicity.  In a few cases some minor bugs
(missing definitions) are fixed.  With these changes, all IPA
register offsets and associated field masks should be correct for
IPA versions 3.5.1, 4.0, 4.1, and 4.2.
====================

Link: https://lore.kernel.org/r/20201116233805.13775-1-elder@linaro.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Nov 18, 2020
2 parents 2b8473d + 716a115 commit 030946f
Show file tree
Hide file tree
Showing 13 changed files with 265 additions and 210 deletions.
20 changes: 10 additions & 10 deletions drivers/net/ipa/gsi.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ struct ipa_gsi_endpoint_data;

/* Execution environment IDs */
enum gsi_ee_id {
GSI_EE_AP = 0,
GSI_EE_MODEM = 1,
GSI_EE_UC = 2,
GSI_EE_TZ = 3,
GSI_EE_AP = 0x0,
GSI_EE_MODEM = 0x1,
GSI_EE_UC = 0x2,
GSI_EE_TZ = 0x3,
};

struct gsi_ring {
Expand Down Expand Up @@ -96,12 +96,12 @@ struct gsi_trans_info {

/* Hardware values signifying the state of a channel */
enum gsi_channel_state {
GSI_CHANNEL_STATE_NOT_ALLOCATED = 0x0,
GSI_CHANNEL_STATE_ALLOCATED = 0x1,
GSI_CHANNEL_STATE_STARTED = 0x2,
GSI_CHANNEL_STATE_STOPPED = 0x3,
GSI_CHANNEL_STATE_STOP_IN_PROC = 0x4,
GSI_CHANNEL_STATE_ERROR = 0xf,
GSI_CHANNEL_STATE_NOT_ALLOCATED = 0x0,
GSI_CHANNEL_STATE_ALLOCATED = 0x1,
GSI_CHANNEL_STATE_STARTED = 0x2,
GSI_CHANNEL_STATE_STOPPED = 0x3,
GSI_CHANNEL_STATE_STOP_IN_PROC = 0x4,
GSI_CHANNEL_STATE_ERROR = 0xf,
};

/* We only care about channels between IPA and AP */
Expand Down
25 changes: 18 additions & 7 deletions drivers/net/ipa/gsi_reg.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#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,
Expand Down Expand Up @@ -223,6 +224,7 @@ enum gsi_channel_type {
(0x0001f008 + 0x4000 * (ee))
#define CH_CHID_FMASK GENMASK(7, 0)
#define CH_OPCODE_FMASK GENMASK(31, 24)

/** enum gsi_ch_cmd_opcode - CH_OPCODE field values in CH_CMD */
enum gsi_ch_cmd_opcode {
GSI_CH_ALLOCATE = 0x0,
Expand All @@ -238,6 +240,7 @@ enum gsi_ch_cmd_opcode {
(0x0001f010 + 0x4000 * (ee))
#define EV_CHID_FMASK GENMASK(7, 0)
#define EV_OPCODE_FMASK GENMASK(31, 24)

/** enum gsi_evt_cmd_opcode - EV_OPCODE field values in EV_CH_CMD */
enum gsi_evt_cmd_opcode {
GSI_EVT_ALLOCATE = 0x0,
Expand All @@ -252,6 +255,7 @@ enum gsi_evt_cmd_opcode {
#define GENERIC_OPCODE_FMASK GENMASK(4, 0)
#define GENERIC_CHID_FMASK GENMASK(9, 5)
#define GENERIC_EE_FMASK GENMASK(13, 10)

/** enum gsi_generic_cmd_opcode - GENERIC_OPCODE field values in GENERIC_CMD */
enum gsi_generic_cmd_opcode {
GSI_GENERIC_HALT_CHANNEL = 0x1,
Expand All @@ -275,6 +279,7 @@ enum gsi_generic_cmd_opcode {
/* Fields below are present for IPA v4.2 and above */
#define GSI_USE_RD_WR_ENG_FMASK GENMASK(30, 30)
#define GSI_USE_INTER_EE_FMASK GENMASK(31, 31)

/** enum gsi_iram_size - IRAM_SIZE field values in HW_PARAM_2 */
enum gsi_iram_size {
IRAM_SIZE_ONE_KB = 0x0,
Expand All @@ -293,15 +298,16 @@ enum gsi_iram_size {
GSI_EE_N_CNTXT_TYPE_IRQ_MSK_OFFSET(GSI_EE_AP)
#define GSI_EE_N_CNTXT_TYPE_IRQ_MSK_OFFSET(ee) \
(0x0001f088 + 0x4000 * (ee))

/* Values here are bit positions in the TYPE_IRQ and TYPE_IRQ_MSK registers */
enum gsi_irq_type_id {
GSI_CH_CTRL = 0, /* channel allocation, etc. */
GSI_EV_CTRL = 1, /* event ring allocation, etc. */
GSI_GLOB_EE = 2, /* global/general event */
GSI_IEOB = 3, /* TRE completion */
GSI_INTER_EE_CH_CTRL = 4, /* remote-issued stop/reset (unused) */
GSI_INTER_EE_EV_CTRL = 5, /* remote-issued event reset (unused) */
GSI_GENERAL = 6, /* general-purpose event */
GSI_CH_CTRL = 0x0, /* channel allocation, etc. */
GSI_EV_CTRL = 0x1, /* event ring allocation, etc. */
GSI_GLOB_EE = 0x2, /* global/general event */
GSI_IEOB = 0x3, /* TRE completion */
GSI_INTER_EE_CH_CTRL = 0x4, /* remote-issued stop/reset (unused) */
GSI_INTER_EE_EV_CTRL = 0x5, /* remote-issued event reset (unused) */
GSI_GENERAL = 0x6, /* general-purpose event */
};

#define GSI_CNTXT_SRC_CH_IRQ_OFFSET \
Expand Down Expand Up @@ -406,6 +412,7 @@ enum gsi_general_id {
#define ERR_VIRT_IDX_FMASK GENMASK(23, 19)
#define ERR_TYPE_FMASK GENMASK(27, 24)
#define ERR_EE_FMASK GENMASK(31, 28)

/** enum gsi_err_code - ERR_CODE field values in EE_ERR_LOG */
enum gsi_err_code {
GSI_INVALID_TRE = 0x1,
Expand All @@ -417,6 +424,7 @@ enum gsi_err_code {
/* 7 is not assigned */
GSI_HWO_1 = 0x8,
};

/** enum gsi_err_type - ERR_TYPE field values in EE_ERR_LOG */
enum gsi_err_type {
GSI_ERR_TYPE_GLOB = 0x1,
Expand All @@ -435,6 +443,8 @@ enum gsi_err_type {
(0x0001f400 + 0x4000 * (ee))
#define INTER_EE_RESULT_FMASK GENMASK(2, 0)
#define GENERIC_EE_RESULT_FMASK GENMASK(7, 5)

/** enum gsi_generic_ee_result - GENERIC_EE_RESULT field values in SCRATCH_0 */
enum gsi_generic_ee_result {
GENERIC_EE_SUCCESS = 0x1,
GENERIC_EE_CHANNEL_NOT_RUNNING = 0x2,
Expand All @@ -444,6 +454,7 @@ enum gsi_generic_ee_result {
GENERIC_EE_RETRY = 0x6,
GENERIC_EE_NO_RESOURCES = 0x7,
};

#define USB_MAX_PACKET_FMASK GENMASK(15, 15) /* 0: HS; 1: SS */
#define MHI_BASE_CHANNEL_FMASK GENMASK(31, 24)

Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ipa/ipa_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@

/* Some commands can wait until indicated pipeline stages are clear */
enum pipeline_clear_options {
pipeline_clear_hps = 0,
pipeline_clear_src_grp = 1,
pipeline_clear_full = 2,
pipeline_clear_hps = 0x0,
pipeline_clear_src_grp = 0x1,
pipeline_clear_full = 0x2,
};

/* IPA_CMD_IP_V{4,6}_{FILTER,ROUTING}_INIT */
Expand Down
21 changes: 10 additions & 11 deletions drivers/net/ipa/ipa_cmd.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ struct gsi_channel;
* a request is *not* an immediate command.
*/
enum ipa_cmd_opcode {
IPA_CMD_NONE = 0,
IPA_CMD_IP_V4_FILTER_INIT = 3,
IPA_CMD_IP_V6_FILTER_INIT = 4,
IPA_CMD_IP_V4_ROUTING_INIT = 7,
IPA_CMD_IP_V6_ROUTING_INIT = 8,
IPA_CMD_HDR_INIT_LOCAL = 9,
IPA_CMD_REGISTER_WRITE = 12,
IPA_CMD_IP_PACKET_INIT = 16,
IPA_CMD_DMA_SHARED_MEM = 19,
IPA_CMD_IP_PACKET_TAG_STATUS = 20,
IPA_CMD_NONE = 0x0,
IPA_CMD_IP_V4_FILTER_INIT = 0x3,
IPA_CMD_IP_V6_FILTER_INIT = 0x4,
IPA_CMD_IP_V4_ROUTING_INIT = 0x7,
IPA_CMD_IP_V6_ROUTING_INIT = 0x8,
IPA_CMD_HDR_INIT_LOCAL = 0x9,
IPA_CMD_REGISTER_WRITE = 0xc,
IPA_CMD_IP_PACKET_INIT = 0x10,
IPA_CMD_DMA_SHARED_MEM = 0x13,
IPA_CMD_IP_PACKET_TAG_STATUS = 0x14,
};

/**
Expand All @@ -50,7 +50,6 @@ struct ipa_cmd_info {
enum dma_data_direction direction;
};


#ifdef IPA_VALIDATE

/**
Expand Down
10 changes: 5 additions & 5 deletions drivers/net/ipa/ipa_endpoint.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,8 @@ static u32 ipa_reg_init_hol_block_timer_val(struct ipa *ipa, u32 microseconds)
/* ...but we still need to fit into a 32-bit register */
WARN_ON(ticks > U32_MAX);

/* IPA v3.5.1 just records the tick count */
if (ipa->version == IPA_VERSION_3_5_1)
/* IPA v3.5.1 through v4.1 just record the tick count */
if (ipa->version < IPA_VERSION_4_2)
return (u32)ticks;

/* For IPA v4.2, the tick count is represented by base and
Expand Down Expand Up @@ -1545,8 +1545,8 @@ int ipa_endpoint_config(struct ipa *ipa)
val = ioread32(ipa->reg_virt + IPA_REG_FLAVOR_0_OFFSET);

/* Our RX is an IPA producer */
rx_base = u32_get_bits(val, BAM_PROD_LOWEST_FMASK);
max = rx_base + u32_get_bits(val, BAM_MAX_PROD_PIPES_FMASK);
rx_base = u32_get_bits(val, IPA_PROD_LOWEST_FMASK);
max = rx_base + u32_get_bits(val, IPA_MAX_PROD_PIPES_FMASK);
if (max > IPA_ENDPOINT_MAX) {
dev_err(dev, "too many endpoints (%u > %u)\n",
max, IPA_ENDPOINT_MAX);
Expand All @@ -1555,7 +1555,7 @@ int ipa_endpoint_config(struct ipa *ipa)
rx_mask = GENMASK(max - 1, rx_base);

/* Our TX is an IPA consumer */
max = u32_get_bits(val, BAM_MAX_CONS_PIPES_FMASK);
max = u32_get_bits(val, IPA_MAX_CONS_PIPES_FMASK);
tx_mask = GENMASK(max - 1, 0);

ipa->available = rx_mask | tx_mask;
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/ipa/ipa_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ipa_gsi_endpoint_data;
#define IPA_MTU ETH_DATA_LEN

enum ipa_endpoint_name {
IPA_ENDPOINT_AP_MODEM_TX = 0,
IPA_ENDPOINT_AP_MODEM_TX,
IPA_ENDPOINT_MODEM_LAN_TX,
IPA_ENDPOINT_MODEM_COMMAND_TX,
IPA_ENDPOINT_AP_COMMAND_TX,
Expand Down
6 changes: 3 additions & 3 deletions drivers/net/ipa/ipa_interrupt.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ static void ipa_interrupt_suspend_control(struct ipa_interrupt *interrupt,
u32 val;

/* assert(mask & ipa->available); */
val = ioread32(ipa->reg_virt + IPA_REG_SUSPEND_IRQ_EN_OFFSET);
val = ioread32(ipa->reg_virt + IPA_REG_IRQ_SUSPEND_EN_OFFSET);
if (enable)
val |= mask;
else
val &= ~mask;
iowrite32(val, ipa->reg_virt + IPA_REG_SUSPEND_IRQ_EN_OFFSET);
iowrite32(val, ipa->reg_virt + IPA_REG_IRQ_SUSPEND_EN_OFFSET);
}

/* Enable TX_SUSPEND for an endpoint */
Expand All @@ -168,7 +168,7 @@ void ipa_interrupt_suspend_clear_all(struct ipa_interrupt *interrupt)
u32 val;

val = ioread32(ipa->reg_virt + IPA_REG_IRQ_SUSPEND_INFO_OFFSET);
iowrite32(val, ipa->reg_virt + IPA_REG_SUSPEND_IRQ_CLR_OFFSET);
iowrite32(val, ipa->reg_virt + IPA_REG_IRQ_SUSPEND_CLR_OFFSET);
}

/* Simulate arrival of an IPA TX_SUSPEND interrupt */
Expand Down
16 changes: 0 additions & 16 deletions drivers/net/ipa/ipa_interrupt.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@
struct ipa;
struct ipa_interrupt;

/**
* enum ipa_irq_id - IPA interrupt type
* @IPA_IRQ_UC_0: Microcontroller event interrupt
* @IPA_IRQ_UC_1: Microcontroller response interrupt
* @IPA_IRQ_TX_SUSPEND: Data ready interrupt
*
* The data ready interrupt is signaled if data has arrived that is destined
* for an AP RX endpoint whose underlying GSI channel is suspended/stopped.
*/
enum ipa_irq_id {
IPA_IRQ_UC_0 = 2,
IPA_IRQ_UC_1 = 3,
IPA_IRQ_TX_SUSPEND = 14,
IPA_IRQ_COUNT, /* Number of interrupt types (not an index) */
};

/**
* typedef ipa_irq_handler_t - IPA interrupt handler function type
* @ipa: IPA pointer
Expand Down
15 changes: 9 additions & 6 deletions drivers/net/ipa/ipa_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ static void ipa_hardware_config(struct ipa *ipa)

/* Disable PA mask to allow HOLB drop (hardware workaround) */
val = ioread32(ipa->reg_virt + IPA_REG_TX_CFG_OFFSET);
val &= ~PA_MASK_EN;
val &= ~PA_MASK_EN_FMASK;
iowrite32(val, ipa->reg_virt + IPA_REG_TX_CFG_OFFSET);
}

Expand All @@ -336,12 +336,15 @@ static void ipa_hardware_config(struct ipa *ipa)

/* Configure aggregation granularity */
granularity = ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY);
val = u32_encode_bits(granularity, AGGR_GRANULARITY);
val = u32_encode_bits(granularity, AGGR_GRANULARITY_FMASK);
iowrite32(val, ipa->reg_virt + IPA_REG_COUNTER_CFG_OFFSET);

/* Disable hashed IPv4 and IPv6 routing and filtering for IPA v4.2 */
if (ipa->version == IPA_VERSION_4_2)
iowrite32(0, ipa->reg_virt + IPA_REG_FILT_ROUT_HASH_EN_OFFSET);
/* IPA v4.2 does not support hashed tables, so disable them */
if (ipa->version == IPA_VERSION_4_2) {
u32 offset = ipa_reg_filt_rout_hash_en_offset(ipa->version);

iowrite32(0, ipa->reg_virt + offset);
}

/* Enable dynamic clock division */
ipa_hardware_dcd_config(ipa);
Expand Down Expand Up @@ -685,7 +688,7 @@ static void ipa_validate_build(void)
/* Aggregation granularity value can't be 0, and must fit */
BUILD_BUG_ON(!ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY));
BUILD_BUG_ON(ipa_aggr_granularity_val(IPA_AGGR_GRANULARITY) >
field_max(AGGR_GRANULARITY));
field_max(AGGR_GRANULARITY_FMASK));
#endif /* IPA_VALIDATE */
}

Expand Down
12 changes: 6 additions & 6 deletions drivers/net/ipa/ipa_qmi_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ struct ipa_init_complete_ind {

/* The AP tells the modem its platform type. We assume Android. */
enum ipa_platform_type {
IPA_QMI_PLATFORM_TYPE_INVALID = 0, /* Invalid */
IPA_QMI_PLATFORM_TYPE_TN = 1, /* Data card */
IPA_QMI_PLATFORM_TYPE_LE = 2, /* Data router */
IPA_QMI_PLATFORM_TYPE_MSM_ANDROID = 3, /* Android MSM */
IPA_QMI_PLATFORM_TYPE_MSM_WINDOWS = 4, /* Windows MSM */
IPA_QMI_PLATFORM_TYPE_MSM_QNX_V01 = 5, /* QNX MSM */
IPA_QMI_PLATFORM_TYPE_INVALID = 0x0, /* Invalid */
IPA_QMI_PLATFORM_TYPE_TN = 0x1, /* Data card */
IPA_QMI_PLATFORM_TYPE_LE = 0x2, /* Data router */
IPA_QMI_PLATFORM_TYPE_MSM_ANDROID = 0x3, /* Android MSM */
IPA_QMI_PLATFORM_TYPE_MSM_WINDOWS = 0x4, /* Windows MSM */
IPA_QMI_PLATFORM_TYPE_MSM_QNX_V01 = 0x5, /* QNX MSM */
};

/* This defines the start and end offset of a range of memory. Both
Expand Down
Loading

0 comments on commit 030946f

Please sign in to comment.