From e91214d3d452d335b1b9b7aa488deaa6dbeadbae Mon Sep 17 00:00:00 2001 From: Harshdeep Dhatt Date: Mon, 13 Jan 2020 14:44:03 -0700 Subject: [PATCH] msm: kgsl: Add support for multiple ddr tables The lahaina device can have either LP4X or LP5 DDR. So look for the corresponding ddr table in the device tree. If ddr specific table is not found, fall back to a generic table for devices that may have only one type of ddr. Change-Id: I92cb802820eeb61e4afd0a79ed38a7f8b4a5916d Signed-off-by: Harshdeep Dhatt --- drivers/gpu/msm/kgsl_bus.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/msm/kgsl_bus.c b/drivers/gpu/msm/kgsl_bus.c index 106961e5604c..8d0aafbc7d77 100644 --- a/drivers/gpu/msm/kgsl_bus.c +++ b/drivers/gpu/msm/kgsl_bus.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2019-2020, The Linux Foundation. All rights reserved. */ #include @@ -147,15 +147,28 @@ u32 *kgsl_bus_get_table(struct platform_device *pdev, int kgsl_bus_init(struct kgsl_device *device, struct platform_device *pdev) { struct kgsl_pwrctrl *pwr = &device->pwrctrl; - int ret, count; + int count; + int ddr = of_fdt_get_ddrtype(); + if (ddr >= 0) { + char str[32]; + + snprintf(str, sizeof(str), "qcom,bus-table-ddr%d", ddr); + + pwr->ddr_table = kgsl_bus_get_table(pdev, str, &count); + if (!IS_ERR(pwr->ddr_table)) + goto done; + } + + /* Look if a generic table is present */ pwr->ddr_table = kgsl_bus_get_table(pdev, "qcom,bus-table-ddr", &count); if (IS_ERR(pwr->ddr_table)) { - ret = PTR_ERR(pwr->ddr_table); + int ret = PTR_ERR(pwr->ddr_table); + pwr->ddr_table = NULL; return ret; } - +done: pwr->ddr_table_count = count; validate_pwrlevels(device, pwr->ddr_table, pwr->ddr_table_count);