Commit 030946fd authored by Jakub Kicinski's avatar Jakub Kicinski

Merge branch 'net-ipa-ipa-register-cleanup'

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.orgSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parents 2b8473d2 716a115b
......@@ -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 {
......@@ -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 */
......
......@@ -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,
......@@ -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,
......@@ -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,
......@@ -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,
......@@ -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,
......@@ -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 \
......@@ -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,
......@@ -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,
......@@ -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,
......@@ -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)
......
......@@ -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 */
......
......@@ -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,
};
/**
......@@ -50,7 +50,6 @@ struct ipa_cmd_info {
enum dma_data_direction direction;
};
#ifdef IPA_VALIDATE
/**
......
......@@ -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
......@@ -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);
......@@ -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;
......
......@@ -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,
......
......@@ -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 */
......@@ -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 */
......
......@@ -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
......
......@@ -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);
}
......@@ -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);
......@@ -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 */
}
......
......@@ -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
......
This diff is collapsed.
......@@ -422,8 +422,8 @@ int ipa_table_hash_flush(struct ipa *ipa)
return -EBUSY;
}
val = IPV4_FILTER_HASH_FLUSH | IPV6_FILTER_HASH_FLUSH;
val |= IPV6_ROUTER_HASH_FLUSH | IPV4_ROUTER_HASH_FLUSH;
val = IPV4_FILTER_HASH_FMASK | IPV6_FILTER_HASH_FMASK;
val |= IPV6_ROUTER_HASH_FMASK | IPV4_ROUTER_HASH_FMASK;
ipa_cmd_register_write_add(trans, offset, val, val, false);
......
......@@ -86,32 +86,32 @@ struct ipa_uc_mem_area {
/** enum ipa_uc_command - commands from the AP to the microcontroller */
enum ipa_uc_command {
IPA_UC_COMMAND_NO_OP = 0,
IPA_UC_COMMAND_UPDATE_FLAGS = 1,
IPA_UC_COMMAND_DEBUG_RUN_TEST = 2,
IPA_UC_COMMAND_DEBUG_GET_INFO = 3,
IPA_UC_COMMAND_ERR_FATAL = 4,
IPA_UC_COMMAND_CLK_GATE = 5,
IPA_UC_COMMAND_CLK_UNGATE = 6,
IPA_UC_COMMAND_MEMCPY = 7,
IPA_UC_COMMAND_RESET_PIPE = 8,
IPA_UC_COMMAND_REG_WRITE = 9,
IPA_UC_COMMAND_GSI_CH_EMPTY = 10,
IPA_UC_COMMAND_NO_OP = 0x0,
IPA_UC_COMMAND_UPDATE_FLAGS = 0x1,
IPA_UC_COMMAND_DEBUG_RUN_TEST = 0x2,
IPA_UC_COMMAND_DEBUG_GET_INFO = 0x3,
IPA_UC_COMMAND_ERR_FATAL = 0x4,
IPA_UC_COMMAND_CLK_GATE = 0x5,
IPA_UC_COMMAND_CLK_UNGATE = 0x6,
IPA_UC_COMMAND_MEMCPY = 0x7,
IPA_UC_COMMAND_RESET_PIPE = 0x8,
IPA_UC_COMMAND_REG_WRITE = 0x9,
IPA_UC_COMMAND_GSI_CH_EMPTY = 0xa,
};
/** enum ipa_uc_response - microcontroller response codes */
enum ipa_uc_response {
IPA_UC_RESPONSE_NO_OP = 0,
IPA_UC_RESPONSE_INIT_COMPLETED = 1,
IPA_UC_RESPONSE_CMD_COMPLETED = 2,
IPA_UC_RESPONSE_DEBUG_GET_INFO = 3,
IPA_UC_RESPONSE_NO_OP = 0x0,
IPA_UC_RESPONSE_INIT_COMPLETED = 0x1,
IPA_UC_RESPONSE_CMD_COMPLETED = 0x2,
IPA_UC_RESPONSE_DEBUG_GET_INFO = 0x3,
};
/** enum ipa_uc_event - common cpu events reported by the microcontroller */
enum ipa_uc_event {
IPA_UC_EVENT_NO_OP = 0,
IPA_UC_EVENT_ERROR = 1,
IPA_UC_EVENT_LOG_INFO = 2,
IPA_UC_EVENT_NO_OP = 0x0,
IPA_UC_EVENT_ERROR = 0x1,
IPA_UC_EVENT_LOG_INFO = 0x2,
};
static struct ipa_uc_mem_area *ipa_uc_shared(struct ipa *ipa)
......@@ -192,14 +192,19 @@ void ipa_uc_teardown(struct ipa *ipa)
static void send_uc_command(struct ipa *ipa, u32 command, u32 command_param)
{
struct ipa_uc_mem_area *shared = ipa_uc_shared(ipa);
u32 val;
/* Fill in the command data */
shared->command = command;
shared->command_param = cpu_to_le32(command_param);
shared->command_param_hi = 0;
shared->response = 0;
shared->response_param = 0;
iowrite32(1, ipa->reg_virt + IPA_REG_IRQ_UC_OFFSET);
/* Use an interrupt to tell the microcontroller the command is ready */
val = u32_encode_bits(1, UC_INTR_FMASK);
iowrite32(val, ipa->reg_virt + IPA_REG_IRQ_UC_OFFSET);
}
/* Tell the microcontroller the AP is shutting down */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment