Hi,
This is a rebased version of the earlier RFC series. It is mostly about the first patch, which moves the IPUv3 core code (drivers/staging/imx-drm/ipu-v3) to drivers/gpu. host1x, which serves a similar purpose, already sits there.
I'd like to move the IPUv3 core code out of staging so that we can start submitting V4L2 code for video capture and scaling / colorspace conversion. The other four patches add necessary preparations for CSI and SMFC handling. These are used by the V4L2 CSI & capture drivers.
This series is based on the current staging-next tree, it is otherwise nearly unchanged. I hope we can get this move in before the approaching merge window so that we have a base for submitting the CSI V4L2 patches in the following round.
regards Philipp
--- Changes since RFC: - Rebased onto current staging-next - Streamlined destaging patch a bit --- Philipp Zabel (5): gpu: ipu-v3: Move i.MX IPUv3 core driver out of staging gpu: ipu-v3: Add SMFC code gpu: ipu-v3: Add ipu_idmac_get_current_buffer function gpu: ipu-v3: Add CSI and SMFC module enable wrappers gpu: ipu-v3: Register the CSI modules
drivers/gpu/Makefile | 1 + drivers/gpu/ipu-v3/Kconfig | 7 ++ drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile | 4 +- .../{staging/imx-drm => gpu}/ipu-v3/ipu-common.c | 82 ++++++++++++++++-- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c | 3 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h | 8 +- drivers/gpu/ipu-v3/ipu-smfc.c | 97 ++++++++++++++++++++++ drivers/staging/imx-drm/Kconfig | 11 +-- drivers/staging/imx-drm/Makefile | 1 - drivers/staging/imx-drm/imx-hdmi.c | 2 +- drivers/staging/imx-drm/imx-tve.c | 2 +- drivers/staging/imx-drm/ipuv3-crtc.c | 2 +- drivers/staging/imx-drm/ipuv3-plane.c | 2 +- drivers/video/Kconfig | 1 + .../imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h | 16 ++++ 18 files changed, 216 insertions(+), 29 deletions(-) create mode 100644 drivers/gpu/ipu-v3/Kconfig rename drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile (51%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c (94%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h (96%) create mode 100644 drivers/gpu/ipu-v3/ipu-smfc.c rename {drivers/staging/imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h (95%)
The i.MX Image Processing Unit (IPU) contains a number of image processing blocks that sit right in the middle between DRM and V4L2. Some of the modules, such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS Sensor Interface (CSI) and their FIFOs could be assigned to either framework, but others, such as the dma controller (IDMAC) and image converter (IC) can be used by both. The IPUv3 core driver provides an internal API to access the modules, to be used by both DRM and V4L2 IPUv3 drivers.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Philipp Zabel p.zabel@pengutronix.de --- Changes since RFC: - Rebased onto current staging-next - Removed an unrelated change to ipu_pixelformat_to_colorspace - Avoided moving around the IPU_PIX_FMT_GBR24 #define --- drivers/gpu/Makefile | 1 + drivers/gpu/ipu-v3/Kconfig | 7 +++++++ drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c | 3 +-- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c | 2 +- drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h | 2 +- drivers/staging/imx-drm/Kconfig | 11 +---------- drivers/staging/imx-drm/Makefile | 1 - drivers/staging/imx-drm/imx-hdmi.c | 2 +- drivers/staging/imx-drm/imx-tve.c | 2 +- drivers/staging/imx-drm/ipuv3-crtc.c | 2 +- drivers/staging/imx-drm/ipuv3-plane.c | 2 +- drivers/video/Kconfig | 1 + .../staging/imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h | 0 17 files changed, 21 insertions(+), 23 deletions(-) create mode 100644 drivers/gpu/ipu-v3/Kconfig rename drivers/{staging/imx-drm => gpu}/ipu-v3/Makefile (59%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-common.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dc.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-di.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dmfc.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-dp.c (99%) rename drivers/{staging/imx-drm => gpu}/ipu-v3/ipu-prv.h (99%) rename {drivers/staging/imx-drm/ipu-v3 => include/video}/imx-ipu-v3.h (100%)
diff --git a/drivers/gpu/Makefile b/drivers/gpu/Makefile index d8a22c2..70da9eb 100644 --- a/drivers/gpu/Makefile +++ b/drivers/gpu/Makefile @@ -1,2 +1,3 @@ obj-y += drm/ vga/ obj-$(CONFIG_TEGRA_HOST1X) += host1x/ +obj-$(CONFIG_IMX_IPUV3_CORE) += ipu-v3/ diff --git a/drivers/gpu/ipu-v3/Kconfig b/drivers/gpu/ipu-v3/Kconfig new file mode 100644 index 0000000..2f228a2 --- /dev/null +++ b/drivers/gpu/ipu-v3/Kconfig @@ -0,0 +1,7 @@ +config IMX_IPUV3_CORE + tristate "IPUv3 core support" + depends on SOC_IMX5 || SOC_IMX6Q || SOC_IMX6SL || ARCH_MULTIPLATFORM + depends on RESET_CONTROLLER + help + Choose this if you have a i.MX5/6 system and want to use the Image + Processing Unit. This option only enables IPU base support. diff --git a/drivers/staging/imx-drm/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile similarity index 59% rename from drivers/staging/imx-drm/ipu-v3/Makefile rename to drivers/gpu/ipu-v3/Makefile index 28ed72e..d21cc37 100644 --- a/drivers/staging/imx-drm/ipu-v3/Makefile +++ b/drivers/gpu/ipu-v3/Makefile @@ -1,3 +1,3 @@ -obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += imx-ipu-v3.o +obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o
imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c similarity index 99% rename from drivers/staging/imx-drm/ipu-v3/ipu-common.c rename to drivers/gpu/ipu-v3/ipu-common.c index a1f7b20..ad99477 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -31,7 +31,7 @@
#include <drm/drm_fourcc.h>
-#include "imx-ipu-v3.h" +#include <video/imx-ipu-v3.h> #include "ipu-prv.h"
static inline u32 ipu_cm_read(struct ipu_soc *ipu, unsigned offset) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c b/drivers/gpu/ipu-v3/ipu-dc.c similarity index 99% rename from drivers/staging/imx-drm/ipu-v3/ipu-dc.c rename to drivers/gpu/ipu-v3/ipu-dc.c index 784a4a1..2326c75 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dc.c +++ b/drivers/gpu/ipu-v3/ipu-dc.c @@ -21,8 +21,7 @@ #include <linux/interrupt.h> #include <linux/io.h>
-#include "../imx-drm.h" -#include "imx-ipu-v3.h" +#include <video/imx-ipu-v3.h> #include "ipu-prv.h"
#define DC_MAP_CONF_PTR(n) (0x108 + ((n) & ~0x1) * 2) diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-di.c b/drivers/gpu/ipu-v3/ipu-di.c similarity index 99% rename from drivers/staging/imx-drm/ipu-v3/ipu-di.c rename to drivers/gpu/ipu-v3/ipu-di.c index 849b3e120..c490ba4 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-di.c +++ b/drivers/gpu/ipu-v3/ipu-di.c @@ -20,7 +20,7 @@ #include <linux/err.h> #include <linux/platform_device.h>
-#include "imx-ipu-v3.h" +#include <video/imx-ipu-v3.h> #include "ipu-prv.h"
struct ipu_di { diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c b/drivers/gpu/ipu-v3/ipu-dmfc.c similarity index 99% rename from drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c rename to drivers/gpu/ipu-v3/ipu-dmfc.c index 59f182b..042c395 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dmfc.c +++ b/drivers/gpu/ipu-v3/ipu-dmfc.c @@ -17,7 +17,7 @@ #include <linux/errno.h> #include <linux/io.h>
-#include "imx-ipu-v3.h" +#include <video/imx-ipu-v3.h> #include "ipu-prv.h"
#define DMFC_RD_CHAN 0x0000 diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c b/drivers/gpu/ipu-v3/ipu-dp.c similarity index 99% rename from drivers/staging/imx-drm/ipu-v3/ipu-dp.c rename to drivers/gpu/ipu-v3/ipu-dp.c index d90f82a..98686ed 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-dp.c +++ b/drivers/gpu/ipu-v3/ipu-dp.c @@ -19,7 +19,7 @@ #include <linux/io.h> #include <linux/err.h>
-#include "imx-ipu-v3.h" +#include <video/imx-ipu-v3.h> #include "ipu-prv.h"
#define DP_SYNC 0 diff --git a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h similarity index 99% rename from drivers/staging/imx-drm/ipu-v3/ipu-prv.h rename to drivers/gpu/ipu-v3/ipu-prv.h index bfc1b33..72e1158 100644 --- a/drivers/staging/imx-drm/ipu-v3/ipu-prv.h +++ b/drivers/gpu/ipu-v3/ipu-prv.h @@ -22,7 +22,7 @@ struct ipu_soc; #include <linux/clk.h> #include <linux/platform_device.h>
-#include "imx-ipu-v3.h" +#include <video/imx-ipu-v3.h>
#define IPUV3_CHANNEL_CSI0 0 #define IPUV3_CHANNEL_CSI1 1 diff --git a/drivers/staging/imx-drm/Kconfig b/drivers/staging/imx-drm/Kconfig index c6e8ba7..82fb758 100644 --- a/drivers/staging/imx-drm/Kconfig +++ b/drivers/staging/imx-drm/Kconfig @@ -39,19 +39,10 @@ config DRM_IMX_LDB Choose this to enable the internal LVDS Display Bridge (LDB) found on i.MX53 and i.MX6 processors.
-config DRM_IMX_IPUV3_CORE - tristate "IPUv3 core support" - depends on DRM_IMX - depends on RESET_CONTROLLER - help - Choose this if you have a i.MX5/6 system and want - to use the IPU. This option only enables IPU base - support. - config DRM_IMX_IPUV3 tristate "DRM Support for i.MX IPUv3" depends on DRM_IMX - depends on DRM_IMX_IPUV3_CORE + depends on IMX_IPUV3_CORE help Choose this if you have a i.MX5 or i.MX6 processor.
diff --git a/drivers/staging/imx-drm/Makefile b/drivers/staging/imx-drm/Makefile index 129e3a3..582c438 100644 --- a/drivers/staging/imx-drm/Makefile +++ b/drivers/staging/imx-drm/Makefile @@ -6,7 +6,6 @@ obj-$(CONFIG_DRM_IMX) += imxdrm.o obj-$(CONFIG_DRM_IMX_PARALLEL_DISPLAY) += parallel-display.o obj-$(CONFIG_DRM_IMX_TVE) += imx-tve.o obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o -obj-$(CONFIG_DRM_IMX_IPUV3_CORE) += ipu-v3/
imx-ipuv3-crtc-objs := ipuv3-crtc.o ipuv3-plane.o obj-$(CONFIG_DRM_IMX_IPUV3) += imx-ipuv3-crtc.o diff --git a/drivers/staging/imx-drm/imx-hdmi.c b/drivers/staging/imx-drm/imx-hdmi.c index 1b44048..e7f3de5 100644 --- a/drivers/staging/imx-drm/imx-hdmi.c +++ b/drivers/staging/imx-drm/imx-hdmi.c @@ -27,8 +27,8 @@ #include <drm/drm_crtc_helper.h> #include <drm/drm_edid.h> #include <drm/drm_encoder_slave.h> +#include <video/imx-ipu-v3.h>
-#include "ipu-v3/imx-ipu-v3.h" #include "imx-hdmi.h" #include "imx-drm.h"
diff --git a/drivers/staging/imx-drm/imx-tve.c b/drivers/staging/imx-drm/imx-tve.c index a23f4f7..b12fb17 100644 --- a/drivers/staging/imx-drm/imx-tve.c +++ b/drivers/staging/imx-drm/imx-tve.c @@ -30,8 +30,8 @@ #include <drm/drmP.h> #include <drm/drm_fb_helper.h> #include <drm/drm_crtc_helper.h> +#include <video/imx-ipu-v3.h>
-#include "ipu-v3/imx-ipu-v3.h" #include "imx-drm.h"
#define TVE_COM_CONF_REG 0x00 diff --git a/drivers/staging/imx-drm/ipuv3-crtc.c b/drivers/staging/imx-drm/ipuv3-crtc.c index 47bec5e..720868b 100644 --- a/drivers/staging/imx-drm/ipuv3-crtc.c +++ b/drivers/staging/imx-drm/ipuv3-crtc.c @@ -30,7 +30,7 @@ #include <drm/drm_gem_cma_helper.h> #include <drm/drm_fb_cma_helper.h>
-#include "ipu-v3/imx-ipu-v3.h" +#include <video/imx-ipu-v3.h> #include "imx-drm.h" #include "ipuv3-plane.h"
diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 5697e59..6f393a1 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -17,7 +17,7 @@ #include <drm/drm_fb_cma_helper.h> #include <drm/drm_gem_cma_helper.h>
-#include "ipu-v3/imx-ipu-v3.h" +#include "video/imx-ipu-v3.h" #include "ipuv3-plane.h"
#define to_ipu_plane(x) container_of(x, struct ipu_plane, base) diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index c7b4f0f..8bf495f 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -20,6 +20,7 @@ source "drivers/char/agp/Kconfig" source "drivers/gpu/vga/Kconfig"
source "drivers/gpu/host1x/Kconfig" +source "drivers/gpu/ipu-v3/Kconfig"
menu "Direct Rendering Manager" source "drivers/gpu/drm/Kconfig" diff --git a/drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h b/include/video/imx-ipu-v3.h similarity index 100% rename from drivers/staging/imx-drm/ipu-v3/imx-ipu-v3.h rename to include/video/imx-ipu-v3.h
On Mon, May 26, 2014 at 04:19:39PM +0200, Philipp Zabel wrote:
The i.MX Image Processing Unit (IPU) contains a number of image processing blocks that sit right in the middle between DRM and V4L2. Some of the modules, such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS Sensor Interface (CSI) and their FIFOs could be assigned to either framework, but others, such as the dma controller (IDMAC) and image converter (IC) can be used by both. The IPUv3 core driver provides an internal API to access the modules, to be used by both DRM and V4L2 IPUv3 drivers.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Philipp Zabel p.zabel@pengutronix.de
Changes since RFC:
- Rebased onto current staging-next
- Removed an unrelated change to ipu_pixelformat_to_colorspace
- Avoided moving around the IPU_PIX_FMT_GBR24 #define
Acked-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Am Mittwoch, den 28.05.2014, 14:13 -0700 schrieb Greg Kroah-Hartman:
On Mon, May 26, 2014 at 04:19:39PM +0200, Philipp Zabel wrote:
The i.MX Image Processing Unit (IPU) contains a number of image processing blocks that sit right in the middle between DRM and V4L2. Some of the modules, such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS Sensor Interface (CSI) and their FIFOs could be assigned to either framework, but others, such as the dma controller (IDMAC) and image converter (IC) can be used by both. The IPUv3 core driver provides an internal API to access the modules, to be used by both DRM and V4L2 IPUv3 drivers.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Philipp Zabel p.zabel@pengutronix.de
Changes since RFC:
- Rebased onto current staging-next
- Removed an unrelated change to ipu_pixelformat_to_colorspace
- Avoided moving around the IPU_PIX_FMT_GBR24 #define
Acked-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Thank you. My favourite next step would be to send a pull request and have this merged into drm-next. Dave, Greg would you be ok with this?
regards Philipp
On Mon, Jun 02, 2014 at 06:36:22PM +0200, Philipp Zabel wrote:
Am Mittwoch, den 28.05.2014, 14:13 -0700 schrieb Greg Kroah-Hartman:
On Mon, May 26, 2014 at 04:19:39PM +0200, Philipp Zabel wrote:
The i.MX Image Processing Unit (IPU) contains a number of image processing blocks that sit right in the middle between DRM and V4L2. Some of the modules, such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS Sensor Interface (CSI) and their FIFOs could be assigned to either framework, but others, such as the dma controller (IDMAC) and image converter (IC) can be used by both. The IPUv3 core driver provides an internal API to access the modules, to be used by both DRM and V4L2 IPUv3 drivers.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Philipp Zabel p.zabel@pengutronix.de
Changes since RFC:
- Rebased onto current staging-next
- Removed an unrelated change to ipu_pixelformat_to_colorspace
- Avoided moving around the IPU_PIX_FMT_GBR24 #define
Acked-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Thank you. My favourite next step would be to send a pull request and have this merged into drm-next. Dave, Greg would you be ok with this?
No objection from me, it's up to Dave what he wants for this.
greg k-h
On 3 June 2014 03:06, Greg Kroah-Hartman gregkh@linuxfoundation.org wrote:
On Mon, Jun 02, 2014 at 06:36:22PM +0200, Philipp Zabel wrote:
Am Mittwoch, den 28.05.2014, 14:13 -0700 schrieb Greg Kroah-Hartman:
On Mon, May 26, 2014 at 04:19:39PM +0200, Philipp Zabel wrote:
The i.MX Image Processing Unit (IPU) contains a number of image processing blocks that sit right in the middle between DRM and V4L2. Some of the modules, such as Display Controller, Processor, and Interface (DC, DP, DI) or CMOS Sensor Interface (CSI) and their FIFOs could be assigned to either framework, but others, such as the dma controller (IDMAC) and image converter (IC) can be used by both. The IPUv3 core driver provides an internal API to access the modules, to be used by both DRM and V4L2 IPUv3 drivers.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Philipp Zabel p.zabel@pengutronix.de
Changes since RFC:
- Rebased onto current staging-next
- Removed an unrelated change to ipu_pixelformat_to_colorspace
- Avoided moving around the IPU_PIX_FMT_GBR24 #define
Acked-by: Greg Kroah-Hartman gregkh@linuxfoundation.org
Thank you. My favourite next step would be to send a pull request and have this merged into drm-next. Dave, Greg would you be ok with this?
No objection from me, it's up to Dave what he wants for this.
Yes please send me a pull req for this.
Dave.
The Sensor Multi Fifo Controller (SMFC) is used as a buffer between the two CSIs (writing simultaneously) and up to four IDMAC channels.
Signed-off-by: Philipp Zabel p.zabel@pengutronix.de --- drivers/gpu/ipu-v3/Makefile | 2 +- drivers/gpu/ipu-v3/ipu-common.c | 10 +++++ drivers/gpu/ipu-v3/ipu-prv.h | 6 +++ drivers/gpu/ipu-v3/ipu-smfc.c | 97 +++++++++++++++++++++++++++++++++++++++++ include/video/imx-ipu-v3.h | 6 +++ 5 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 drivers/gpu/ipu-v3/ipu-smfc.c
diff --git a/drivers/gpu/ipu-v3/Makefile b/drivers/gpu/ipu-v3/Makefile index d21cc37..1887972b 100644 --- a/drivers/gpu/ipu-v3/Makefile +++ b/drivers/gpu/ipu-v3/Makefile @@ -1,3 +1,3 @@ obj-$(CONFIG_IMX_IPUV3_CORE) += imx-ipu-v3.o
-imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o +imx-ipu-v3-objs := ipu-common.o ipu-dc.o ipu-di.o ipu-dp.o ipu-dmfc.o ipu-smfc.o diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index ad99477..6b3f4f1 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -896,8 +896,17 @@ static int ipu_submodules_init(struct ipu_soc *ipu, goto err_dp; }
+ ret = ipu_smfc_init(ipu, dev, ipu_base + + devtype->cm_ofs + IPU_CM_SMFC_REG_OFS); + if (ret) { + unit = "smfc"; + goto err_smfc; + } + return 0;
+err_smfc: + ipu_dp_exit(ipu); err_dp: ipu_dmfc_exit(ipu); err_dmfc: @@ -977,6 +986,7 @@ EXPORT_SYMBOL_GPL(ipu_idmac_channel_irq);
static void ipu_submodules_exit(struct ipu_soc *ipu) { + ipu_smfc_exit(ipu); ipu_dp_exit(ipu); ipu_dmfc_exit(ipu); ipu_dc_exit(ipu); diff --git a/drivers/gpu/ipu-v3/ipu-prv.h b/drivers/gpu/ipu-v3/ipu-prv.h index 72e1158..c93f50e 100644 --- a/drivers/gpu/ipu-v3/ipu-prv.h +++ b/drivers/gpu/ipu-v3/ipu-prv.h @@ -151,6 +151,8 @@ struct ipuv3_channel { struct ipu_dc_priv; struct ipu_dmfc_priv; struct ipu_di; +struct ipu_smfc_priv; + struct ipu_devtype;
struct ipu_soc { @@ -178,6 +180,7 @@ struct ipu_soc { struct ipu_dp_priv *dp_priv; struct ipu_dmfc_priv *dmfc_priv; struct ipu_di *di_priv[2]; + struct ipu_smfc_priv *smfc_priv; };
void ipu_srm_dp_sync_update(struct ipu_soc *ipu); @@ -206,4 +209,7 @@ void ipu_dc_exit(struct ipu_soc *ipu); int ipu_cpmem_init(struct ipu_soc *ipu, struct device *dev, unsigned long base); void ipu_cpmem_exit(struct ipu_soc *ipu);
+int ipu_smfc_init(struct ipu_soc *ipu, struct device *dev, unsigned long base); +void ipu_smfc_exit(struct ipu_soc *ipu); + #endif /* __IPU_PRV_H__ */ diff --git a/drivers/gpu/ipu-v3/ipu-smfc.c b/drivers/gpu/ipu-v3/ipu-smfc.c new file mode 100644 index 0000000..e4f85ad --- /dev/null +++ b/drivers/gpu/ipu-v3/ipu-smfc.c @@ -0,0 +1,97 @@ +/* + * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved. + * + * The code contained herein is licensed under the GNU General Public + * License. You may obtain a copy of the GNU General Public License + * Version 2 or later at the following locations: + * + * http://www.opensource.org/licenses/gpl-license.html + * http://www.gnu.org/copyleft/gpl.html + */ +#define DEBUG +#include <linux/export.h> +#include <linux/types.h> +#include <linux/init.h> +#include <linux/io.h> +#include <linux/errno.h> +#include <linux/spinlock.h> +#include <linux/delay.h> +#include <linux/clk.h> +#include <video/imx-ipu-v3.h> + +#include "ipu-prv.h" + +struct ipu_smfc_priv { + void __iomem *base; + spinlock_t lock; +}; + +/*SMFC Registers */ +#define SMFC_MAP 0x0000 +#define SMFC_WMC 0x0004 +#define SMFC_BS 0x0008 + +int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize) +{ + struct ipu_smfc_priv *smfc = ipu->smfc_priv; + unsigned long flags; + u32 val, shift; + + spin_lock_irqsave(&smfc->lock, flags); + + shift = channel * 4; + val = readl(smfc->base + SMFC_BS); + val &= ~(0xf << shift); + val |= burstsize << shift; + writel(val, smfc->base + SMFC_BS); + + spin_unlock_irqrestore(&smfc->lock, flags); + + return 0; +} +EXPORT_SYMBOL_GPL(ipu_smfc_set_burstsize); + +int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id) +{ + struct ipu_smfc_priv *smfc = ipu->smfc_priv; + unsigned long flags; + u32 val, shift; + + spin_lock_irqsave(&smfc->lock, flags); + + shift = channel * 3; + val = readl(smfc->base + SMFC_MAP); + val &= ~(0x7 << shift); + val |= ((csi_id << 2) | mipi_id) << shift; + writel(val, smfc->base + SMFC_MAP); + + spin_unlock_irqrestore(&smfc->lock, flags); + + return 0; +} +EXPORT_SYMBOL_GPL(ipu_smfc_map_channel); + +int ipu_smfc_init(struct ipu_soc *ipu, struct device *dev, + unsigned long base) +{ + struct ipu_smfc_priv *smfc; + + smfc = devm_kzalloc(dev, sizeof(*smfc), GFP_KERNEL); + if (!smfc) + return -ENOMEM; + + ipu->smfc_priv = smfc; + spin_lock_init(&smfc->lock); + + smfc->base = devm_ioremap(dev, base, PAGE_SIZE); + if (!smfc->base) + return -ENOMEM; + + pr_debug("%s: ioremap 0x%08lx -> %p\n", __func__, base, smfc->base); + + return 0; +} + +void ipu_smfc_exit(struct ipu_soc *ipu) +{ +} diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index c2c6fab..2c71ba7 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -165,6 +165,12 @@ int ipu_dp_set_window_pos(struct ipu_dp *, u16 x_pos, u16 y_pos); int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha, bool bg_chan);
+/* + * IPU Sensor Multiple FIFO Controller (SMFC) functions + */ +int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id); +int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize); + #define IPU_CPMEM_WORD(word, ofs, size) ((((word) * 160 + (ofs)) << 8) | (size))
#define IPU_FIELD_UBO IPU_CPMEM_WORD(0, 46, 22)
This function returns the currently active buffer (0 or 1) of a double buffered IDMAC channel. It is to be used by the CSI driver.
Signed-off-by: Philipp Zabel p.zabel@pengutronix.de --- drivers/gpu/ipu-v3/ipu-common.c | 9 +++++++++ include/video/imx-ipu-v3.h | 1 + 2 files changed, 10 insertions(+)
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 6b3f4f1..706a6f2 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -661,6 +661,15 @@ int ipu_module_disable(struct ipu_soc *ipu, u32 mask) } EXPORT_SYMBOL_GPL(ipu_module_disable);
+int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel) +{ + struct ipu_soc *ipu = channel->ipu; + unsigned int chno = channel->num; + + return (ipu_cm_read(ipu, IPU_CHA_CUR_BUF(chno)) & idma_mask(chno)) ? 1 : 0; +} +EXPORT_SYMBOL_GPL(ipu_idmac_get_current_buffer); + void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num) { struct ipu_soc *ipu = channel->ipu; diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index 2c71ba7..a7edf6a 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -104,6 +104,7 @@ int ipu_idmac_wait_busy(struct ipuv3_channel *channel, int ms);
void ipu_idmac_set_double_buffer(struct ipuv3_channel *channel, bool doublebuffer); +int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel); void ipu_idmac_select_buffer(struct ipuv3_channel *channel, u32 buf_num);
/*
IPU_CONF_..._EN bits are implementation details, not to be made public. Add wrappers around ipu_module_enable/disable, so the CSI V4L2 driver can enable/disable the CSI and SMFC modules.
Signed-off-by: Philipp Zabel p.zabel@pengutronix.de --- drivers/gpu/ipu-v3/ipu-common.c | 24 ++++++++++++++++++++++++ include/video/imx-ipu-v3.h | 8 ++++++++ 2 files changed, 32 insertions(+)
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 706a6f2..03f48b7 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -661,6 +661,30 @@ int ipu_module_disable(struct ipu_soc *ipu, u32 mask) } EXPORT_SYMBOL_GPL(ipu_module_disable);
+int ipu_csi_enable(struct ipu_soc *ipu, int csi) +{ + return ipu_module_enable(ipu, csi ? IPU_CONF_CSI1_EN : IPU_CONF_CSI0_EN); +} +EXPORT_SYMBOL_GPL(ipu_csi_enable); + +int ipu_csi_disable(struct ipu_soc *ipu, int csi) +{ + return ipu_module_disable(ipu, csi ? IPU_CONF_CSI1_EN : IPU_CONF_CSI0_EN); +} +EXPORT_SYMBOL_GPL(ipu_csi_disable); + +int ipu_smfc_enable(struct ipu_soc *ipu) +{ + return ipu_module_enable(ipu, IPU_CONF_SMFC_EN); +} +EXPORT_SYMBOL_GPL(ipu_smfc_enable); + +int ipu_smfc_disable(struct ipu_soc *ipu) +{ + return ipu_module_disable(ipu, IPU_CONF_SMFC_EN); +} +EXPORT_SYMBOL_GPL(ipu_smfc_disable); + int ipu_idmac_get_current_buffer(struct ipuv3_channel *channel) { struct ipu_soc *ipu = channel->ipu; diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index a7edf6a..ac7fbfa 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -167,8 +167,16 @@ int ipu_dp_set_global_alpha(struct ipu_dp *dp, bool enable, u8 alpha, bool bg_chan);
/* + * IPU CMOS Sensor Interface (csi) functions + */ +int ipu_csi_enable(struct ipu_soc *ipu, int csi); +int ipu_csi_disable(struct ipu_soc *ipu, int csi); + +/* * IPU Sensor Multiple FIFO Controller (SMFC) functions */ +int ipu_smfc_enable(struct ipu_soc *ipu); +int ipu_smfc_disable(struct ipu_soc *ipu); int ipu_smfc_map_channel(struct ipu_soc *ipu, int channel, int csi_id, int mipi_id); int ipu_smfc_set_burstsize(struct ipu_soc *ipu, int channel, int burstsize);
This patch registers the two CSI platform devices per IPU.
Signed-off-by: Lucas Stach l.stach@pengutronix.de Signed-off-by: Philipp Zabel p.zabel@pengutronix.de --- Changes since RFC: - Rebased onto current staging-next --- drivers/gpu/ipu-v3/ipu-common.c | 37 ++++++++++++++++++++++++++++++++----- include/video/imx-ipu-v3.h | 1 + 2 files changed, 33 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c index 03f48b7..04e7b2e 100644 --- a/drivers/gpu/ipu-v3/ipu-common.c +++ b/drivers/gpu/ipu-v3/ipu-common.c @@ -1044,6 +1044,7 @@ static void platform_device_unregister_children(struct platform_device *pdev) struct ipu_platform_reg { struct ipu_client_platformdata pdata; const char *name; + int reg_offset; };
static const struct ipu_platform_reg client_reg[] = { @@ -1065,13 +1066,29 @@ static const struct ipu_platform_reg client_reg[] = { .dma[1] = -EINVAL, }, .name = "imx-ipuv3-crtc", + }, { + .pdata = { + .csi = 0, + .dma[0] = IPUV3_CHANNEL_CSI0, + .dma[1] = -EINVAL, + }, + .reg_offset = IPU_CM_CSI0_REG_OFS, + .name = "imx-ipuv3-camera", + }, { + .pdata = { + .csi = 1, + .dma[0] = IPUV3_CHANNEL_CSI1, + .dma[1] = -EINVAL, + }, + .reg_offset = IPU_CM_CSI1_REG_OFS, + .name = "imx-ipuv3-camera", }, };
static DEFINE_MUTEX(ipu_client_id_mutex); static int ipu_client_id;
-static int ipu_add_client_devices(struct ipu_soc *ipu) +static int ipu_add_client_devices(struct ipu_soc *ipu, unsigned long ipu_base) { struct device *dev = ipu->dev; unsigned i; @@ -1085,9 +1102,19 @@ static int ipu_add_client_devices(struct ipu_soc *ipu) for (i = 0; i < ARRAY_SIZE(client_reg); i++) { const struct ipu_platform_reg *reg = &client_reg[i]; struct platform_device *pdev; - - pdev = platform_device_register_data(dev, reg->name, - id++, ®->pdata, sizeof(reg->pdata)); + struct resource res; + + if (reg->reg_offset) { + memset(&res, 0, sizeof(res)); + res.flags = IORESOURCE_MEM; + res.start = ipu_base + ipu->devtype->cm_ofs + reg->reg_offset; + res.end = res.start + PAGE_SIZE - 1; + pdev = platform_device_register_resndata(dev, reg->name, + id++, &res, 1, ®->pdata, sizeof(reg->pdata)); + } else { + pdev = platform_device_register_data(dev, reg->name, + id++, ®->pdata, sizeof(reg->pdata)); + }
if (IS_ERR(pdev)) goto err_register; @@ -1284,7 +1311,7 @@ static int ipu_probe(struct platform_device *pdev) if (ret) goto failed_submodules_init;
- ret = ipu_add_client_devices(ipu); + ret = ipu_add_client_devices(ipu, ipu_base); if (ret) { dev_err(&pdev->dev, "adding client devices failed with %d\n", ret); diff --git a/include/video/imx-ipu-v3.h b/include/video/imx-ipu-v3.h index ac7fbfa..3e43e22 100644 --- a/include/video/imx-ipu-v3.h +++ b/include/video/imx-ipu-v3.h @@ -336,6 +336,7 @@ static inline void ipu_cpmem_set_burstsize(struct ipu_ch_param __iomem *p, };
struct ipu_client_platformdata { + int csi; int di; int dc; int dp;
On Mon, May 26, 2014 at 4:19 PM, Philipp Zabel p.zabel@pengutronix.de wrote: [...]
Cc: drm-devel@vger.kernel.org
Sorry about this unfortunate combination of me misremembering dri-devel, noticing something is wrong, looking up and inserting the correct address, and then, after a context switch, failing to remove the wrong entry.
regards Philipp
dri-devel@lists.freedesktop.org