From d8ac7720f0b8f81d4343e19ad555a96956acc31b Mon Sep 17 00:00:00 2001 From: Maheshwar Ajja Date: Mon, 15 Feb 2016 18:34:10 +0530 Subject: msm: vidc: read platform version from efuse register Read platform version through efuse register for clients to know the underlying platform version. CRs-Fixed: 987512 Change-Id: I16cdb8655e4a79d6f05e3185cac4014d3c0f0f77 Signed-off-by: Maheshwar Ajja --- drivers/media/platform/msm/vidc/msm_v4l2_vidc.c | 51 +++++++++++++++++++++- .../media/platform/msm/vidc/msm_vidc_internal.h | 1 + .../media/platform/msm/vidc/msm_vidc_res_parse.c | 41 ++++++++++++++++- .../media/platform/msm/vidc/msm_vidc_resources.h | 7 ++- 4 files changed, 97 insertions(+), 3 deletions(-) (limited to 'drivers') diff --git a/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c b/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c index dd58dd671baf..9d82d590174d 100644 --- a/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c +++ b/drivers/media/platform/msm/vidc/msm_v4l2_vidc.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -22,6 +22,7 @@ #include #include #include +#include #include #include "msm_vidc_common.h" #include "msm_vidc_debug.h" @@ -397,9 +398,28 @@ static ssize_t store_thermal_level(struct device *dev, static DEVICE_ATTR(thermal_level, S_IRUGO | S_IWUSR, show_thermal_level, store_thermal_level); +static ssize_t show_platform_version(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return scnprintf(buf, PAGE_SIZE, "%d", + vidc_driver->platform_version); +} + +static ssize_t store_platform_version(struct device *dev, + struct device_attribute *attr, const char *buf, + size_t count) +{ + dprintk(VIDC_WARN, "store platform version is not allowed\n"); + return count; +} + +static DEVICE_ATTR(platform_version, S_IRUGO, show_platform_version, + store_platform_version); + static struct attribute *msm_vidc_core_attrs[] = { &dev_attr_pwr_collapse_delay.attr, &dev_attr_thermal_level.attr, + &dev_attr_platform_version.attr, NULL }; @@ -417,6 +437,8 @@ static const struct of_device_id msm_vidc_dt_match[] = { static int msm_vidc_probe_vidc_device(struct platform_device *pdev) { int rc = 0; + void __iomem *base; + struct resource *res; struct msm_vidc_core *core; struct device *dev; int nr = BASE_DEVICE_NUMBER; @@ -531,6 +553,33 @@ static int msm_vidc_probe_vidc_device(struct platform_device *pdev) core->debugfs_root = msm_vidc_debugfs_init_core( core, vidc_driver->debugfs_root); + vidc_driver->platform_version = 0; + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "efuse"); + if (!res) { + dprintk(VIDC_DBG, "failed to get efuse resource\n"); + } else { + base = devm_ioremap(&pdev->dev, res->start, resource_size(res)); + if (!base) { + dprintk(VIDC_ERR, + "failed efuse ioremap: res->start %#x, size %d\n", + (u32)res->start, (u32)resource_size(res)); + } else { + u32 efuse = 0; + struct platform_version_table *pf_ver_tbl = + core->resources.pf_ver_tbl; + + efuse = readl_relaxed(base); + vidc_driver->platform_version = + (efuse & pf_ver_tbl->version_mask) >> + pf_ver_tbl->version_shift; + dprintk(VIDC_DBG, + "efuse 0x%x, platform version 0x%x\n", + efuse, vidc_driver->platform_version); + + devm_iounmap(&pdev->dev, base); + } + } + dprintk(VIDC_DBG, "populating sub devices\n"); /* * Trigger probe for each sub-device i.e. qcom,msm-vidc,context-bank. diff --git a/drivers/media/platform/msm/vidc/msm_vidc_internal.h b/drivers/media/platform/msm/vidc/msm_vidc_internal.h index d7edff4fba01..97d5abf17922 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc_internal.h +++ b/drivers/media/platform/msm/vidc/msm_vidc_internal.h @@ -149,6 +149,7 @@ struct msm_vidc_drv { int num_cores; struct dentry *debugfs_root; int thermal_level; + u32 platform_version; }; struct msm_video_device { diff --git a/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c b/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c index 6a98ceaea592..4503e46b044d 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c +++ b/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c @@ -77,6 +77,12 @@ static inline void msm_vidc_free_cycles_per_mb_table( res->clock_freq_tbl.clk_prof_entries = NULL; } +static inline void msm_vidc_free_platform_version_table( + struct msm_vidc_platform_resources *res) +{ + res->pf_ver_tbl = NULL; +} + static inline void msm_vidc_free_freq_table( struct msm_vidc_platform_resources *res) { @@ -155,6 +161,7 @@ void msm_vidc_free_platform_resources( msm_vidc_free_clock_table(res); msm_vidc_free_regulator_table(res); msm_vidc_free_freq_table(res); + msm_vidc_free_platform_version_table(res); msm_vidc_free_dcvs_table(res); msm_vidc_free_dcvs_limit(res); msm_vidc_free_cycles_per_mb_table(res); @@ -351,12 +358,40 @@ int msm_vidc_load_u32_table(struct platform_device *pdev, return -EINVAL; } - *num_elements = num_elemts; *table = ptbl; + if (num_elements) + *num_elements = num_elemts; return rc; } +static int msm_vidc_load_platform_version_table( + struct msm_vidc_platform_resources *res) +{ + int rc = 0; + struct platform_device *pdev = res->pdev; + + if (!of_find_property(pdev->dev.of_node, + "qcom,platform-version", NULL)) { + dprintk(VIDC_DBG, "qcom,platform-version not found\n"); + return 0; + } + + rc = msm_vidc_load_u32_table(pdev, pdev->dev.of_node, + "qcom,platform-version", + sizeof(*res->pf_ver_tbl), + (u32 **)&res->pf_ver_tbl, + NULL); + if (rc) { + dprintk(VIDC_ERR, + "%s: failed to read platform version table\n", + __func__); + return rc; + } + + return 0; +} + static int msm_vidc_load_allowed_clocks_table( struct msm_vidc_platform_resources *res) { @@ -968,6 +1003,10 @@ int read_platform_resources_from_dt( if (rc) dprintk(VIDC_DBG, "HFI packetization will default to legacy\n"); + rc = msm_vidc_load_platform_version_table(res); + if (rc) + dprintk(VIDC_ERR, "Failed to load pf version table: %d\n", rc); + rc = msm_vidc_load_freq_table(res); if (rc) { dprintk(VIDC_ERR, "Failed to load freq table: %d\n", rc); diff --git a/drivers/media/platform/msm/vidc/msm_vidc_resources.h b/drivers/media/platform/msm/vidc/msm_vidc_resources.h index c0a9fe7ef6bb..1fc1888e81c6 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc_resources.h +++ b/drivers/media/platform/msm/vidc/msm_vidc_resources.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. +/* Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -19,6 +19,10 @@ #include #define MAX_BUFFER_TYPES 32 +struct platform_version_table { + u32 version_mask; + u32 version_shift; +}; struct load_freq_table { u32 load; @@ -151,6 +155,7 @@ struct msm_vidc_platform_resources { phys_addr_t register_base; uint32_t register_size; uint32_t irq; + struct platform_version_table *pf_ver_tbl; struct allowed_clock_rates_table *allowed_clks_tbl; u32 allowed_clks_tbl_size; struct clock_freq_table clock_freq_tbl; -- cgit v1.2.3