aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-01-30 11:02:27 -0500
committerRob Clark <robdclark@gmail.com>2017-02-06 11:28:42 -0500
commit1db7afa4914642146637f891c9d369948bb026c7 (patch)
tree04e26a45c9866987c36c6b4975b8543a218e189d
parent1a4a66ddc7b290ea2fd492c9c922ee7205d44724 (diff)
drm/msm: drop qcom,chipid
The original way we determined the gpu version was based on downstream bindings from android kernel. A cleaner way is to get the version from the compatible string. Note that no upstream dtb uses these bindings. But the code still supports falling back to the legacy bindings (with a warning), so that we are still compatible with the gpu dt node from android device kernels. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Eric Anholt <eric@anholt.net> Acked-by: Rob Herring <robh@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/display/msm/gpu.txt11
-rw-r--r--drivers/gpu/drm/msm/adreno/adreno_device.c40
-rw-r--r--drivers/gpu/drm/msm/msm_drv.c1
3 files changed, 46 insertions, 6 deletions
diff --git a/Documentation/devicetree/bindings/display/msm/gpu.txt b/Documentation/devicetree/bindings/display/msm/gpu.txt
index 747b984c7210..7ac3052ca7b5 100644
--- a/Documentation/devicetree/bindings/display/msm/gpu.txt
+++ b/Documentation/devicetree/bindings/display/msm/gpu.txt
@@ -1,7 +1,11 @@
1Qualcomm adreno/snapdragon GPU 1Qualcomm adreno/snapdragon GPU
2 2
3Required properties: 3Required properties:
4- compatible: "qcom,adreno-3xx" 4- compatible: "qcom,adreno-XYZ.W", "qcom,adreno"
5 for example: "qcom,adreno-306.0", "qcom,adreno"
6 Note that you need to list the less specific "qcom,adreno" (since this
7 is what the device is matched on), in addition to the more specific
8 with the chip-id.
5- reg: Physical base address and length of the controller's registers. 9- reg: Physical base address and length of the controller's registers.
6- interrupts: The interrupt signal from the gpu. 10- interrupts: The interrupt signal from the gpu.
7- clocks: device clocks 11- clocks: device clocks
@@ -10,8 +14,6 @@ Required properties:
10 * "core_clk" 14 * "core_clk"
11 * "iface_clk" 15 * "iface_clk"
12 * "mem_iface_clk" 16 * "mem_iface_clk"
13- qcom,chipid: gpu chip-id. Note this may become optional for future
14 devices if we can reliably read the chipid from hw
15 17
16Example: 18Example:
17 19
@@ -19,7 +21,7 @@ Example:
19 ... 21 ...
20 22
21 gpu: qcom,kgsl-3d0@4300000 { 23 gpu: qcom,kgsl-3d0@4300000 {
22 compatible = "qcom,adreno-3xx"; 24 compatible = "qcom,adreno-320.2", "qcom,adreno";
23 reg = <0x04300000 0x20000>; 25 reg = <0x04300000 0x20000>;
24 reg-names = "kgsl_3d0_reg_memory"; 26 reg-names = "kgsl_3d0_reg_memory";
25 interrupts = <GIC_SPI 80 0>; 27 interrupts = <GIC_SPI 80 0>;
@@ -32,6 +34,5 @@ Example:
32 <&mmcc GFX3D_CLK>, 34 <&mmcc GFX3D_CLK>,
33 <&mmcc GFX3D_AHB_CLK>, 35 <&mmcc GFX3D_AHB_CLK>,
34 <&mmcc MMSS_IMEM_AHB_CLK>; 36 <&mmcc MMSS_IMEM_AHB_CLK>;
35 qcom,chipid = <0x03020100>;
36 }; 37 };
37}; 38};
diff --git a/drivers/gpu/drm/msm/adreno/adreno_device.c b/drivers/gpu/drm/msm/adreno/adreno_device.c
index 8d54cb764f77..5fa51a9abc20 100644
--- a/drivers/gpu/drm/msm/adreno/adreno_device.c
+++ b/drivers/gpu/drm/msm/adreno/adreno_device.c
@@ -189,6 +189,43 @@ static const struct {
189 { "qcom,gpu-quirk-fault-detect-mask", ADRENO_QUIRK_FAULT_DETECT_MASK }, 189 { "qcom,gpu-quirk-fault-detect-mask", ADRENO_QUIRK_FAULT_DETECT_MASK },
190}; 190};
191 191
192static int find_chipid(struct device *dev, u32 *chipid)
193{
194 struct device_node *node = dev->of_node;
195 const char *compat;
196 int ret;
197
198 /* first search the compat strings for qcom,adreno-XYZ.W: */
199 ret = of_property_read_string_index(node, "compatible", 0, &compat);
200 if (ret == 0) {
201 unsigned rev, patch;
202
203 if (sscanf(compat, "qcom,adreno-%u.%u", &rev, &patch) == 2) {
204 *chipid = 0;
205 *chipid |= (rev / 100) << 24; /* core */
206 rev %= 100;
207 *chipid |= (rev / 10) << 16; /* major */
208 rev %= 10;
209 *chipid |= rev << 8; /* minor */
210 *chipid |= patch;
211
212 return 0;
213 }
214 }
215
216 /* and if that fails, fall back to legacy "qcom,chipid" property: */
217 ret = of_property_read_u32(node, "qcom,chipid", chipid);
218 if (ret)
219 return ret;
220
221 dev_warn(dev, "Using legacy qcom,chipid binding!\n");
222 dev_warn(dev, "Use compatible qcom,adreno-%u%u%u.%u instead.\n",
223 (*chipid >> 24) & 0xff, (*chipid >> 16) & 0xff,
224 (*chipid >> 8) & 0xff, *chipid & 0xff);
225
226 return 0;
227}
228
192static int adreno_bind(struct device *dev, struct device *master, void *data) 229static int adreno_bind(struct device *dev, struct device *master, void *data)
193{ 230{
194 static struct adreno_platform_config config = {}; 231 static struct adreno_platform_config config = {};
@@ -196,7 +233,7 @@ static int adreno_bind(struct device *dev, struct device *master, void *data)
196 u32 val; 233 u32 val;
197 int ret, i; 234 int ret, i;
198 235
199 ret = of_property_read_u32(node, "qcom,chipid", &val); 236 ret = find_chipid(dev, &val);
200 if (ret) { 237 if (ret) {
201 dev_err(dev, "could not find chipid: %d\n", ret); 238 dev_err(dev, "could not find chipid: %d\n", ret);
202 return ret; 239 return ret;
@@ -262,6 +299,7 @@ static int adreno_remove(struct platform_device *pdev)
262} 299}
263 300
264static const struct of_device_id dt_match[] = { 301static const struct of_device_id dt_match[] = {
302 { .compatible = "qcom,adreno" },
265 { .compatible = "qcom,adreno-3xx" }, 303 { .compatible = "qcom,adreno-3xx" },
266 /* for backwards compat w/ downstream kgsl DT files: */ 304 /* for backwards compat w/ downstream kgsl DT files: */
267 { .compatible = "qcom,kgsl-3d0" }, 305 { .compatible = "qcom,kgsl-3d0" },
diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
index e29bb66f55b1..6b85c4195252 100644
--- a/drivers/gpu/drm/msm/msm_drv.c
+++ b/drivers/gpu/drm/msm/msm_drv.c
@@ -985,6 +985,7 @@ static int add_display_components(struct device *dev,
985 * as components. 985 * as components.
986 */ 986 */
987static const struct of_device_id msm_gpu_match[] = { 987static const struct of_device_id msm_gpu_match[] = {
988 { .compatible = "qcom,adreno" },
988 { .compatible = "qcom,adreno-3xx" }, 989 { .compatible = "qcom,adreno-3xx" },
989 { .compatible = "qcom,kgsl-3d0" }, 990 { .compatible = "qcom,kgsl-3d0" },
990 { }, 991 { },