Commit 8c365f74 authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: distinguish between resource group types

The number of resource groups supported by the hardware can be
different for source and destination resources.  Determine the
number supported for each using separate functions.  Make the
functions inline end move their definitions into "ipa_reg.h",
because they determine whether certain register definitions are
valid.  Pass just the IPA hardware version as argument.

IPA_RESOURCE_GROUP_COUNT represents the maximum number of resource
groups the driver supports for any hardware version.  Change that
symbol to be two separate constants, one for source and the other
for destination resource groups.  Rename them to end with "_MAX"
rather than "_COUNT", to reflect their true purpose.
Tested-by: default avatarSujit Kautkar <sujitka@chromium.org>
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 2d265342
...@@ -45,10 +45,10 @@ ...@@ -45,10 +45,10 @@
* the IPA endpoint. * the IPA endpoint.
*/ */
/* The maximum value returned by ipa_resource_group_count() */ /* The maximum value returned by ipa_resource_group_{src,dst}_count() */
#define IPA_RESOURCE_GROUP_COUNT 4 #define IPA_RESOURCE_GROUP_SRC_MAX 4
#define IPA_RESOURCE_GROUP_DST_MAX 4
/** enum ipa_resource_type_src - source resource types */
/** /**
* struct gsi_channel_data - GSI channel configuration data * struct gsi_channel_data - GSI channel configuration data
* @tre_count: number of TREs in the channel ring * @tre_count: number of TREs in the channel ring
...@@ -208,7 +208,7 @@ struct ipa_resource_limits { ...@@ -208,7 +208,7 @@ struct ipa_resource_limits {
*/ */
struct ipa_resource_src { struct ipa_resource_src {
enum ipa_resource_type_src type; enum ipa_resource_type_src type;
struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT]; struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX];
}; };
/** /**
...@@ -218,7 +218,7 @@ struct ipa_resource_src { ...@@ -218,7 +218,7 @@ struct ipa_resource_src {
*/ */
struct ipa_resource_dst { struct ipa_resource_dst {
enum ipa_resource_type_dst type; enum ipa_resource_type_dst type;
struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_COUNT]; struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX];
}; };
/** /**
......
...@@ -363,52 +363,38 @@ static void ipa_hardware_deconfig(struct ipa *ipa) ...@@ -363,52 +363,38 @@ static void ipa_hardware_deconfig(struct ipa *ipa)
#ifdef IPA_VALIDATION #ifdef IPA_VALIDATION
/* # IPA resources used based on version (see IPA_RESOURCE_GROUP_COUNT) */
static int ipa_resource_group_count(struct ipa *ipa)
{
switch (ipa->version) {
case IPA_VERSION_3_5_1:
return 3;
case IPA_VERSION_4_0:
case IPA_VERSION_4_1:
return 4;
case IPA_VERSION_4_2:
return 1;
default:
return 0;
}
}
static bool ipa_resource_limits_valid(struct ipa *ipa, static bool ipa_resource_limits_valid(struct ipa *ipa,
const struct ipa_resource_data *data) const struct ipa_resource_data *data)
{ {
u32 group_count = ipa_resource_group_count(ipa); u32 group_count;
u32 i; u32 i;
u32 j; u32 j;
group_count = ipa_resource_group_src_count(ipa->version);
if (!group_count) if (!group_count)
return false; return false;
/* Return an error if a non-zero resource group limit is specified /* Return an error if a non-zero resource limit is specified
* for a resource not supported by hardware. * for a resource group not supported by hardware.
*/ */
for (i = 0; i < data->resource_src_count; i++) { for (i = 0; i < data->resource_src_count; i++) {
const struct ipa_resource_src *resource; const struct ipa_resource_src *resource;
resource = &data->resource_src[i]; resource = &data->resource_src[i];
for (j = group_count; j < IPA_RESOURCE_GROUP_COUNT; j++) for (j = group_count; j < IPA_RESOURCE_GROUP_SRC_MAX; j++)
if (resource->limits[j].min || resource->limits[j].max) if (resource->limits[j].min || resource->limits[j].max)
return false; return false;
} }
group_count = ipa_resource_group_dst_count(ipa->version);
if (!group_count)
return false;
for (i = 0; i < data->resource_dst_count; i++) { for (i = 0; i < data->resource_dst_count; i++) {
const struct ipa_resource_dst *resource; const struct ipa_resource_dst *resource;
resource = &data->resource_dst[i]; resource = &data->resource_dst[i];
for (j = group_count; j < IPA_RESOURCE_GROUP_COUNT; j++) for (j = group_count; j < IPA_RESOURCE_GROUP_DST_MAX; j++)
if (resource->limits[j].min || resource->limits[j].max) if (resource->limits[j].min || resource->limits[j].max)
return false; return false;
} }
......
...@@ -244,6 +244,43 @@ static inline u32 ipa_reg_idle_indication_cfg_offset(enum ipa_version version) ...@@ -244,6 +244,43 @@ static inline u32 ipa_reg_idle_indication_cfg_offset(enum ipa_version version)
#define ENTER_IDLE_DEBOUNCE_THRESH_FMASK GENMASK(15, 0) #define ENTER_IDLE_DEBOUNCE_THRESH_FMASK GENMASK(15, 0)
#define CONST_NON_IDLE_ENABLE_FMASK GENMASK(16, 16) #define CONST_NON_IDLE_ENABLE_FMASK GENMASK(16, 16)
/* # IPA source resource groups available based on version */
static inline u32 ipa_resource_group_src_count(enum ipa_version version)
{
switch (version) {
case IPA_VERSION_3_5_1:
case IPA_VERSION_4_0:
case IPA_VERSION_4_1:
return 4;
case IPA_VERSION_4_2:
return 1;
default:
return 0;
}
}
/* # IPA destination resource groups available based on version */
static inline u32 ipa_resource_group_dst_count(enum ipa_version version)
{
switch (version) {
case IPA_VERSION_3_5_1:
return 3;
case IPA_VERSION_4_0:
case IPA_VERSION_4_1:
return 4;
case IPA_VERSION_4_2:
return 1;
default:
return 0;
}
}
/* Not all of the following are valid (depends on the count, above) */
#define IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(rt) \ #define IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(rt) \
(0x00000400 + 0x0020 * (rt)) (0x00000400 + 0x0020 * (rt))
#define IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(rt) \ #define IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(rt) \
......
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