Commit 728bde66 authored by Jordan Crouse's avatar Jordan Crouse Committed by Rob Clark

drm/msm/adreno: Cleanup chipid parsing

We don't need to convert the chipid to an intermediate value and
then back again into a struct adreno_rev.
Signed-off-by: default avatarJordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: default avatarRob Clark <robdclark@gmail.com>
parent 1babd706
...@@ -161,39 +161,45 @@ static void set_gpu_pdev(struct drm_device *dev, ...@@ -161,39 +161,45 @@ static void set_gpu_pdev(struct drm_device *dev,
priv->gpu_pdev = pdev; priv->gpu_pdev = pdev;
} }
static int find_chipid(struct device *dev, u32 *chipid) static int find_chipid(struct device *dev, struct adreno_rev *rev)
{ {
struct device_node *node = dev->of_node; struct device_node *node = dev->of_node;
const char *compat; const char *compat;
int ret; int ret;
u32 chipid;
/* first search the compat strings for qcom,adreno-XYZ.W: */ /* first search the compat strings for qcom,adreno-XYZ.W: */
ret = of_property_read_string_index(node, "compatible", 0, &compat); ret = of_property_read_string_index(node, "compatible", 0, &compat);
if (ret == 0) { if (ret == 0) {
unsigned rev, patch; unsigned int r, patch;
if (sscanf(compat, "qcom,adreno-%u.%u", &rev, &patch) == 2) { if (sscanf(compat, "qcom,adreno-%u.%u", &r, &patch) == 2) {
*chipid = 0; rev->core = r / 100;
*chipid |= (rev / 100) << 24; /* core */ r %= 100;
rev %= 100; rev->major = r / 10;
*chipid |= (rev / 10) << 16; /* major */ r %= 10;
rev %= 10; rev->minor = r;
*chipid |= rev << 8; /* minor */ rev->patchid = patch;
*chipid |= patch;
return 0; return 0;
} }
} }
/* and if that fails, fall back to legacy "qcom,chipid" property: */ /* and if that fails, fall back to legacy "qcom,chipid" property: */
ret = of_property_read_u32(node, "qcom,chipid", chipid); ret = of_property_read_u32(node, "qcom,chipid", &chipid);
if (ret) if (ret) {
dev_err(dev, "could not parse qcom,chipid: %d\n", ret);
return ret; return ret;
}
rev->core = (chipid >> 24) & 0xff;
rev->major = (chipid >> 16) & 0xff;
rev->minor = (chipid >> 8) & 0xff;
rev->patchid = (chipid & 0xff);
dev_warn(dev, "Using legacy qcom,chipid binding!\n"); dev_warn(dev, "Using legacy qcom,chipid binding!\n");
dev_warn(dev, "Use compatible qcom,adreno-%u%u%u.%u instead.\n", dev_warn(dev, "Use compatible qcom,adreno-%u%u%u.%u instead.\n",
(*chipid >> 24) & 0xff, (*chipid >> 16) & 0xff, rev->core, rev->major, rev->minor, rev->patchid);
(*chipid >> 8) & 0xff, *chipid & 0xff);
return 0; return 0;
} }
...@@ -268,17 +274,11 @@ static int adreno_bind(struct device *dev, struct device *master, void *data) ...@@ -268,17 +274,11 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
const struct adreno_info *info; const struct adreno_info *info;
struct drm_device *drm = dev_get_drvdata(master); struct drm_device *drm = dev_get_drvdata(master);
struct msm_gpu *gpu; struct msm_gpu *gpu;
u32 val;
int ret; int ret;
ret = find_chipid(dev, &val); ret = find_chipid(dev, &config.rev);
if (ret) { if (ret)
dev_err(dev, "could not find chipid: %d\n", ret);
return ret; return ret;
}
config.rev = ADRENO_REV((val >> 24) & 0xff,
(val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff);
/* find clock rates: */ /* find clock rates: */
config.fast_rate = 0; config.fast_rate = 0;
......
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