diff --git a/drivers/gpu/drm/imx/hdp/Makefile b/drivers/gpu/drm/imx/hdp/Makefile index d289e041492a..ab8af4bac72e 100644 --- a/drivers/gpu/drm/imx/hdp/Makefile +++ b/drivers/gpu/drm/imx/hdp/Makefile @@ -5,5 +5,3 @@ obj-$(CONFIG_DRM_IMX_HDP) += imx-hdp.o \ ss28fdsoi_hdmitx_table.o \ API_AFE_mcu1_dp.o \ imx-hdp-audio.o - -obj-$(CONFIG_IMX_HDP_CEC) += imx-cec.o \ diff --git a/drivers/gpu/drm/imx/hdp/imx-hdp.c b/drivers/gpu/drm/imx/hdp/imx-hdp.c index 689927b7e47c..58eafaa537a2 100644 --- a/drivers/gpu/drm/imx/hdp/imx-hdp.c +++ b/drivers/gpu/drm/imx/hdp/imx-hdp.c @@ -74,6 +74,21 @@ static void imx_hdp_state_init(struct imx_hdp *hdp) state->rw = hdp->rw; } +#ifdef CONFIG_IMX_HDP_CEC +static void imx_hdp_cec_init(struct imx_hdp *hdp) +{ + struct imx_cec_dev *cec = &hdp->cec; + + memset(cec, 0, sizeof(struct imx_cec_dev)); + + if (hdp->clks.clk_core) + cec->clk_core = hdp->clks.clk_core; + cec->dev = hdp->dev; + cec->mem = &hdp->mem; + cec->rw = hdp->rw; +} +#endif + static void imx8qm_pixel_link_mux(state_struct *state, struct drm_display_mode *mode) { struct imx_hdp *hdp = state_to_imx_hdp(state); @@ -1167,8 +1182,10 @@ static int imx_hdp_imx_bind(struct device *dev, struct device *master, enable_irq(hdp->irq[HPD_IRQ_OUT]); } #ifdef CONFIG_IMX_HDP_CEC - if (hdp->is_cec) + if (hdp->is_cec) { + imx_hdp_cec_init(hdp); imx_cec_register(&hdp->cec); + } #endif imx_hdp_register_audio_driver(dev); diff --git a/drivers/gpu/drm/imx/hdp/imx-hdp.h b/drivers/gpu/drm/imx/hdp/imx-hdp.h index 472335be22bd..7a1dfd1f7202 100644 --- a/drivers/gpu/drm/imx/hdp/imx-hdp.h +++ b/drivers/gpu/drm/imx/hdp/imx-hdp.h @@ -27,7 +27,7 @@ #include #include "../../../../mxc/hdp/all.h" -#include "imx-cec.h" +#include "../../../../mxc/hdp-cec/imx-hdp-cec.h" /* For testing hdp firmware define DEBUG_FW_LOAD */ #undef DEBUG_FW_LOAD diff --git a/drivers/mxc/Kconfig b/drivers/mxc/Kconfig index e0b9d68fca0c..79a8aff487dc 100755 --- a/drivers/mxc/Kconfig +++ b/drivers/mxc/Kconfig @@ -9,6 +9,7 @@ source "drivers/mxc/gpu-viv/Kconfig" source "drivers/mxc/hantro/Kconfig" source "drivers/mxc/mlb/Kconfig" source "drivers/mxc/hdp/Kconfig" +source "drivers/mxc/hdp-cec/Kconfig" config MXC_SIM tristate "MXC SIM support" diff --git a/drivers/mxc/Makefile b/drivers/mxc/Makefile index c6bcc9f69355..109166cbc1d2 100755 --- a/drivers/mxc/Makefile +++ b/drivers/mxc/Makefile @@ -10,5 +10,6 @@ obj-$(CONFIG_MXC_HANTRO_845) += hantro_845/ obj-$(CONFIG_MXC_HANTRO_845_H1) += hantro_845_h1/ obj-$(CONFIG_MXC_VPU_MALONE) += vpu-malone/ obj-$(CONFIG_MX8_HDP) += hdp/ +obj-$(CONFIG_IMX_HDP_CEC) += hdp-cec/ obj-$(CONFIG_MXC_VPU_DECODER) += vpu-decoder-b0/ obj-$(CONFIG_MXC_VPU_ENCODER) += vpu-encoder-b0/ diff --git a/drivers/mxc/hdp-cec/Kconfig b/drivers/mxc/hdp-cec/Kconfig new file mode 100644 index 000000000000..7acbc07525cf --- /dev/null +++ b/drivers/mxc/hdp-cec/Kconfig @@ -0,0 +1,5 @@ +config IMX_HDP_CEC + bool "Enable IMX HDP CEC support" + depends on MEDIA_CEC + ---help--- + When selected the imx hdmi will support the optional HDMI CEC feature. diff --git a/drivers/mxc/hdp-cec/Makefile b/drivers/mxc/hdp-cec/Makefile new file mode 100644 index 000000000000..a432aa700990 --- /dev/null +++ b/drivers/mxc/hdp-cec/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_IMX_HDP_CEC) += imx-hdp-cec.o diff --git a/drivers/gpu/drm/imx/hdp/imx-cec.c b/drivers/mxc/hdp-cec/imx-hdp-cec.c similarity index 92% rename from drivers/gpu/drm/imx/hdp/imx-cec.c rename to drivers/mxc/hdp-cec/imx-hdp-cec.c index ef7f889bd14b..8d23c5a7f0ff 100644 --- a/drivers/gpu/drm/imx/hdp/imx-cec.c +++ b/drivers/mxc/hdp-cec/imx-hdp-cec.c @@ -25,7 +25,7 @@ #include #include -#include "imx-hdp.h" +#include "imx-hdp-cec.h" #define CEC_NAME "hdp-cec" @@ -46,22 +46,18 @@ u32 cec_read(struct imx_cec_dev *cec, u32 offset) { - struct imx_hdp *hdp = container_of(cec, struct imx_hdp, cec); - struct hdp_mem *mem = &hdp->mem; u32 addr = (offset << 2) + ADDR_HDP_CEC_BASE; u32 value; - hdp->rw->read_reg(mem, addr, &value); + cec->rw->read_reg(cec->mem, addr, &value); return value; } void cec_write(struct imx_cec_dev *cec, u32 offset, u32 value) { - struct imx_hdp *hdp = container_of(cec, struct imx_hdp, cec); - struct hdp_mem *mem = &hdp->mem; u32 addr = (offset << 2) + ADDR_HDP_CEC_BASE; - hdp->rw->write_reg(mem, addr, value); + cec->rw->write_reg(cec->mem, addr, value); } void cec_clear_rx_buffer(struct imx_cec_dev *cec) @@ -143,7 +139,7 @@ u32 imx_cec_set_logical_addr(struct imx_cec_dev *cec, u32 la) u8 i; u8 la_reg; - if ((la >= MAX_LA_VAL)) { + if (la >= MAX_LA_VAL) { dev_err(cec->dev, "Error logical Addr\n"); return -EINVAL; } @@ -273,13 +269,12 @@ static const struct cec_adap_ops imx_cec_adap_ops = { int imx_cec_register(struct imx_cec_dev *cec) { - struct imx_hdp *hdp = container_of(cec, struct imx_hdp, cec); - struct device *dev = hdp->dev; + struct device *dev = cec->dev; int ret; /* Set CEC clock divider */ - if (hdp->clks.clk_core) - cec->clk_div = clk_get_rate(hdp->clks.clk_core) / 100000; + if (cec->clk_core) + cec->clk_div = clk_get_rate(cec->clk_core) / 100000; else /* Default HDMI core clock rate 133MHz */ cec->clk_div = 1330; @@ -301,9 +296,9 @@ int imx_cec_register(struct imx_cec_dev *cec) cec->dev = dev; cec->cec_worker = kthread_create(cec_poll_worker, cec, "hdp-cec"); - if (IS_ERR(cec->cec_worker)) { + if (IS_ERR(cec->cec_worker)) dev_err(cec->dev, "failed create hdp cec thread\n"); - } + wake_up_process(cec->cec_worker); dev_dbg(dev, "CEC successfuly probed\n"); diff --git a/drivers/gpu/drm/imx/hdp/imx-cec.h b/drivers/mxc/hdp-cec/imx-hdp-cec.h similarity index 97% rename from drivers/gpu/drm/imx/hdp/imx-cec.h rename to drivers/mxc/hdp-cec/imx-hdp-cec.h index 9abe387c8e57..4a7593a8403f 100644 --- a/drivers/gpu/drm/imx/hdp/imx-cec.h +++ b/drivers/mxc/hdp-cec/imx-hdp-cec.h @@ -1,5 +1,5 @@ /* - * Copyright 2017 NXP + * Copyright 2018 NXP * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -12,10 +12,12 @@ * GNU General Public License for more details. */ -#ifndef _IMX_CEC_H_ -#define _IMX_CEC_H_ +#ifndef _IMX_HDP_CEC_H_ +#define _IMX_HDP_CEC_H_ #include +#include "../hdp/util.h" +#include "../hdp/address.h" /* regsiter define */ /* register TX_MSG_HEADER */ @@ -328,13 +330,18 @@ struct imx_cec_dev { struct cec_adapter *adap; struct device *dev; struct mutex lock; - void __iomem *reg_base; struct cec_msg msg; u32 clk_div; struct task_struct *cec_worker; + + /* inited by HDP controller driver */ + struct clk *clk_core; + struct hdp_mem *mem; + struct hdp_rw_func *rw; }; int imx_cec_register(struct imx_cec_dev *cec); int imx_cec_unregister(struct imx_cec_dev *cec); + #endif