summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorSandor Yu <Sandor.yu@nxp.com>2018-08-28 15:40:03 +0800
committerJason Liu <jason.hui.liu@nxp.com>2019-02-12 10:33:36 +0800
commit6e19e3a427b2a91cdff20d17a76e67bda26c7829 (patch)
treeff294ab47b747f32225e02e6540bb8a88df261cb /drivers
parent71a7f03246b874c4561d438949d553e0e0c8c717 (diff)
MLK-19227-5: hdp: Add mutex for register access function
Both CEC and HPD thread will access HDP register read/write function, add mutex to support mulit-thread access. Signed-off-by: Sandor Yu <Sandor.yu@nxp.com> (cherry picked from commit 7e62bd0ad4b5d3187a3d1c0f2258c1d4e3ba66a6)
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpu/drm/imx/hdp/imx-hdp.c58
-rw-r--r--drivers/mxc/hdp/util.h1
2 files changed, 47 insertions, 12 deletions
diff --git a/drivers/gpu/drm/imx/hdp/imx-hdp.c b/drivers/gpu/drm/imx/hdp/imx-hdp.c
index 8d8f62a324f8..316e1eab89d5 100644
--- a/drivers/gpu/drm/imx/hdp/imx-hdp.c
+++ b/drivers/gpu/drm/imx/hdp/imx-hdp.c
@@ -13,6 +13,7 @@
*/
#include <linux/clk.h>
#include <linux/kthread.h>
+#include <linux/mutex.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/component.h>
@@ -947,57 +948,80 @@ static const struct drm_encoder_funcs imx_hdp_imx_encoder_funcs = {
static int imx8mq_hdp_read(struct hdp_mem *mem, unsigned int addr, unsigned int *value)
{
unsigned int temp;
- void *tmp_addr = mem->regs_base + addr;
+ void *tmp_addr;
+
+ mutex_lock(&mem->mutex);
+ tmp_addr = mem->regs_base + addr;
temp = __raw_readl((volatile unsigned int *)tmp_addr);
*value = temp;
+ mutex_unlock(&mem->mutex);
return 0;
}
static int imx8mq_hdp_write(struct hdp_mem *mem, unsigned int addr, unsigned int value)
{
- void *tmp_addr = mem->regs_base + addr;
+ void *tmp_addr;
+ mutex_lock(&mem->mutex);
+ tmp_addr = mem->regs_base + addr;
__raw_writel(value, (volatile unsigned int *)tmp_addr);
+ mutex_unlock(&mem->mutex);
return 0;
}
static int imx8mq_hdp_sread(struct hdp_mem *mem, unsigned int addr, unsigned int *value)
{
unsigned int temp;
- void *tmp_addr = mem->ss_base + addr;
+ void *tmp_addr;
+
+ mutex_lock(&mem->mutex);
+ tmp_addr = mem->ss_base + addr;
temp = __raw_readl((volatile unsigned int *)tmp_addr);
*value = temp;
+ mutex_unlock(&mem->mutex);
return 0;
}
static int imx8mq_hdp_swrite(struct hdp_mem *mem, unsigned int addr, unsigned int value)
{
- void *tmp_addr = mem->ss_base + addr;
+ void *tmp_addr;
+
+ mutex_lock(&mem->mutex);
+ tmp_addr = mem->ss_base + addr;
__raw_writel(value, (volatile unsigned int *)tmp_addr);
+ mutex_unlock(&mem->mutex);
return 0;
}
static int imx8qm_hdp_read(struct hdp_mem *mem, unsigned int addr, unsigned int *value)
{
unsigned int temp;
- void *tmp_addr = (addr & 0xfff) + mem->regs_base;
- void *off_addr = 0x8 + mem->ss_base;;
+ void *tmp_addr;
+ void *off_addr;
+ mutex_lock(&mem->mutex);
+ tmp_addr = (addr & 0xfff) + mem->regs_base;
+ off_addr = 0x8 + mem->ss_base;;
__raw_writel(addr >> 12, off_addr);
temp = __raw_readl((volatile unsigned int *)tmp_addr);
*value = temp;
+ mutex_unlock(&mem->mutex);
return 0;
}
static int imx8qm_hdp_write(struct hdp_mem *mem, unsigned int addr, unsigned int value)
{
- void *tmp_addr = (addr & 0xfff) + mem->regs_base;
- void *off_addr = 0x8 + mem->ss_base;;
+ void *tmp_addr;
+ void *off_addr;
+ mutex_lock(&mem->mutex);
+ tmp_addr = (addr & 0xfff) + mem->regs_base;
+ off_addr = 0x8 + mem->ss_base;
__raw_writel(addr >> 12, off_addr);
__raw_writel(value, (volatile unsigned int *) tmp_addr);
+ mutex_unlock(&mem->mutex);
return 0;
}
@@ -1005,23 +1029,31 @@ static int imx8qm_hdp_write(struct hdp_mem *mem, unsigned int addr, unsigned int
static int imx8qm_hdp_sread(struct hdp_mem *mem, unsigned int addr, unsigned int *value)
{
unsigned int temp;
- void *tmp_addr = (addr & 0xfff) + mem->regs_base;
- void *off_addr = 0xc + mem->ss_base;;
+ void *tmp_addr;
+ void *off_addr;
+ mutex_lock(&mem->mutex);
+ tmp_addr = (addr & 0xfff) + mem->regs_base;
+ off_addr = 0xc + mem->ss_base;
__raw_writel(addr >> 12, off_addr);
temp = __raw_readl((volatile unsigned int *)tmp_addr);
*value = temp;
+ mutex_unlock(&mem->mutex);
return 0;
}
static int imx8qm_hdp_swrite(struct hdp_mem *mem, unsigned int addr, unsigned int value)
{
- void *tmp_addr = (addr & 0xfff) + mem->regs_base;
- void *off_addr = 0xc + mem->ss_base;
+ void *tmp_addr;
+ void *off_addr;
+ mutex_lock(&mem->mutex);
+ tmp_addr = (addr & 0xfff) + mem->regs_base;
+ off_addr = 0xc + mem->ss_base;
__raw_writel(addr >> 12, off_addr);
__raw_writel(value, (volatile unsigned int *)tmp_addr);
+ mutex_unlock(&mem->mutex);
return 0;
}
@@ -1220,6 +1252,8 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master,
if (hdp->irq[HPD_IRQ_OUT] < 0)
dev_info(&pdev->dev, "No plug_out irq number\n");
+
+ mutex_init(&hdp->mem.mutex);
/* register map */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hdp->mem.regs_base = devm_ioremap_resource(dev, res);
diff --git a/drivers/mxc/hdp/util.h b/drivers/mxc/hdp/util.h
index 5cf3c815a059..a034752c6edc 100644
--- a/drivers/mxc/hdp/util.h
+++ b/drivers/mxc/hdp/util.h
@@ -182,6 +182,7 @@ struct hdp_mem {
void __iomem *regs_base; /* Controller regs base */
void __iomem *ss_base; /* HDP Subsystem regs base */
void __iomem *rst_base; /* HDP Subsystem reset base */
+ struct mutex mutex;
};
struct hdp_rw_func {