mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Sin <davidsin@ti.com>
To: Greg KH <greg@kroah.com>, Russell King <rmk@arm.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: David Sin <davidsin@ti.com>, Lajos Molnar <molnar@ti.com>
Subject: [PATCH 1/9] TILER-DMM: DMM-PAT driver for TI TILER
Date: Mon,  6 Dec 2010 16:27:18 -0600	[thread overview]
Message-ID: <1291674446-10766-2-git-send-email-davidsin@ti.com> (raw)
In-Reply-To: <1291674446-10766-1-git-send-email-davidsin@ti.com>

This patch adds support for DMM-PAT initialization and programming.

Signed-off-by: David Sin <davidsin@ti.com>
Signed-off-by: Lajos Molnar <molnar@ti.com>
---
 arch/arm/mach-omap2/include/mach/dmm.h |   92 ++++++++++++++++
 drivers/misc/tiler/dmm-main.c          |  187 ++++++++++++++++++++++++++++++++
 2 files changed, 279 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/mach-omap2/include/mach/dmm.h
 create mode 100644 drivers/misc/tiler/dmm-main.c

diff --git a/arch/arm/mach-omap2/include/mach/dmm.h b/arch/arm/mach-omap2/include/mach/dmm.h
new file mode 100644
index 0000000..33a1215
--- /dev/null
+++ b/arch/arm/mach-omap2/include/mach/dmm.h
@@ -0,0 +1,92 @@
+/*
+ * Dynamic Memory Manager (DMM) driver support functions for
+ * TI DMM-TILER hardware block.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#ifndef DMM_H
+#define DMM_H
+
+#define DMM_TILER_OR__0       0x220
+#define DMM_TILER_OR__1       0x224
+#define DMM_PAT_VIEW__0       0x420
+#define DMM_PAT_VIEW__1       0x424
+#define DMM_PAT_VIEW_MAP__0   0x440
+#define DMM_PAT_VIEW_MAP_BASE 0x460
+#define DMM_PAT_IRQSTATUS_RAW 0x480
+#define DMM_PAT_IRQSTATUS     0x490
+#define DMM_PAT_STATUS__0     0x4C0
+#define DMM_PAT_DESCR__0      0x500
+#define DMM_PAT_AREA__0       0x504
+#define DMM_PAT_CTRL__0       0x508
+#define DMM_PAT_DATA__0       0x50C
+
+/*
+ * Physical Address Translator (PAT) refill programming mode
+ */
+enum pat_mode {
+	MANUAL,
+	AUTO
+};
+
+/*
+ * Area definition for DMM physical address translator
+ */
+struct pat_area {
+	s8 x0:8;
+	s8 y0:8;
+	s8 x1:8;
+	s8 y1:8;
+};
+
+/*
+ * DMM physical address translator control
+ */
+struct pat_ctrl {
+	s32 start:4;
+	s32 dir:4;
+	s32 lut_id:8;
+	s32 sync:12;
+	s32 ini:4;
+};
+
+/*
+ * Physical Address Translator (PAT) descriptor
+ */
+struct pat {
+	struct pat *next;
+	struct pat_area area;
+	struct pat_ctrl ctrl;
+	u32 data;
+};
+
+/*
+ * DMM device data
+ */
+struct dmm {
+	const char *oh_name;
+	void __iomem *base;
+	int irq;
+};
+
+/*
+ * Create and initialize the physical address translator
+ */
+struct dmm *dmm_pat_init(u32 id);
+
+/*
+ * Program the physical address translator
+ */
+int dmm_pat_refill(struct dmm *dmm, struct pat *desc, enum pat_mode mode);
+
+#endif
diff --git a/drivers/misc/tiler/dmm-main.c b/drivers/misc/tiler/dmm-main.c
new file mode 100644
index 0000000..f337bd9
--- /dev/null
+++ b/drivers/misc/tiler/dmm-main.c
@@ -0,0 +1,187 @@
+/*
+ * DMM driver support functions for TI OMAP processors.
+ *
+ * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any
+ * kind, whether express or implied; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/errno.h>
+#include <linux/slab.h>
+#include <linux/delay.h>
+
+#include <mach/dmm.h>
+
+#define MASK(msb, lsb) (((1 << ((msb) + 1 - (lsb))) - 1) << (lsb))
+#define SET_FLD(reg, msb, lsb, val) \
+(((reg) & ~MASK((msb), (lsb))) | (((val) << (lsb)) & MASK((msb), (lsb))))
+#define MAX_RETRY_MS	1000
+
+static struct dmm *dmm;
+
+static int dmm_probe(struct platform_device *dev)
+{
+	if (dev)
+		dmm = dev->dev.platform_data;
+
+	if (dmm && dmm->base) {
+		writel(0x88888888, dmm->base + DMM_TILER_OR__0);
+		writel(0x88888888, dmm->base + DMM_TILER_OR__1);
+		return 0;
+	}
+	return -EFAULT;
+}
+
+static int dmm_remove(struct platform_device *dev)
+{
+	return 0;
+}
+
+static struct platform_driver dmm_driver = {
+	.probe = dmm_probe,
+	.remove = dmm_remove,
+	.driver = {
+		.owner = THIS_MODULE,
+		.name = "dmm",
+	},
+};
+
+int dmm_pat_refill(struct dmm *dmm, struct pat *pd, enum pat_mode mode)
+{
+	void __iomem *r;
+	u32 v, i;
+
+	if (!dmm || !dmm->base || !pd)
+		return -EFAULT;
+
+	/* Only manual refill supported */
+	if (mode != MANUAL)
+		return -EFAULT;
+
+	/* Check that the DMM_PAT_STATUS register has not reported an error */
+	r = dmm->base + DMM_PAT_STATUS__0;
+	v = readl(r);
+	if (WARN(v & 0xFC00, KERN_ERR "dmm_pat_refill() error.\n"))
+		return -EIO;
+
+	/* Set "next" register to NULL */
+	r = dmm->base + DMM_PAT_DESCR__0;
+	v = readl(r);
+	v = SET_FLD(v, 31, 4, (u32) NULL);
+	writel(v, r);
+
+	/* Set area to be refilled */
+	r = dmm->base + DMM_PAT_AREA__0;
+	v = readl(r);
+	v = SET_FLD(v, 30, 24, pd->area.y1);
+	v = SET_FLD(v, 23, 16, pd->area.x1);
+	v = SET_FLD(v, 14, 8, pd->area.y0);
+	v = SET_FLD(v, 7, 0, pd->area.x0);
+	writel(v, r);
+
+	/* First, clear the DMM_PAT_IRQSTATUS register */
+	writel(0xFFFFFFFF, dmm->base + DMM_PAT_IRQSTATUS);
+
+	i = 1000;
+	while (readl(dmm->base + DMM_PAT_IRQSTATUS_RAW) != 0) {
+		if (--i == 0)
+			return -EFAULT;
+		udelay(1);
+	}
+
+	/* Fill data register */
+	v = readl(dmm->base + DMM_PAT_DATA__0);
+
+	v = SET_FLD(v, 31, 4, pd->data >> 4);
+	writel(v, r);
+
+	/* Read back PAT_DATA__0 to see if write was successful */
+	i = 1000;
+	while (readl(r) != pd->data) {
+		if (--i == 0)
+			return -EFAULT;
+		udelay(1);
+	}
+
+	v = readl(dmm->base + DMM_PAT_CTRL__0);
+	v = SET_FLD(v, 31, 28, pd->ctrl.ini);
+	v = SET_FLD(v, 16, 16, pd->ctrl.sync);
+	v = SET_FLD(v, 9, 8, pd->ctrl.lut_id);
+	v = SET_FLD(v, 6, 4, pd->ctrl.dir);
+	v = SET_FLD(v, 0, 0, pd->ctrl.start);
+	writel(v, r);
+
+	/* Check if PAT_IRQSTATUS_RAW is set after the PAT has been refilled */
+	i = 1000;
+	while ((readl(dmm->base + DMM_PAT_IRQSTATUS_RAW) & 0x3) != 0x3) {
+		if (--i == 0)
+			return -EFAULT;
+		udelay(1);
+	}
+
+	/* Again, clear the DMM_PAT_IRQSTATUS register */
+	writel(0xFFFFFFFF, dmm->base + DMM_PAT_IRQSTATUS);
+
+	i = 1000;
+	while (readl(dmm->base + DMM_PAT_IRQSTATUS_RAW) != 0) {
+		if (--i == 0)
+			return -EFAULT;
+		udelay(1);
+	}
+
+	/* Again, set "next" register to NULL to clear any PAT STATUS errors */
+	v = readl(dmm->base + DMM_PAT_DESCR__0);
+	v = SET_FLD(v, 31, 4, (u32) NULL);
+	writel(v, r);
+
+	/*
+	 * Now, check that the DMM_PAT_STATUS register
+	 * has not reported an error before exiting.
+	 */
+	v = readl(dmm->base + DMM_PAT_STATUS__0);
+	if (WARN(v & 0xFC00, KERN_ERR "dmm_pat_refill() error.\n"))
+		return -EIO;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(dmm_pat_refill);
+
+struct dmm *dmm_pat_init(u32 id)
+{
+	if (dmm && dmm->base) {
+		writel(0x88888888, dmm->base + DMM_PAT_VIEW__0);
+		writel(0x88888888, dmm->base + DMM_PAT_VIEW__1);
+		writel(0x80808080, dmm->base + DMM_PAT_VIEW_MAP__0);
+		writel(0x80000000, dmm->base + DMM_PAT_VIEW_MAP_BASE);
+	}
+
+	return dmm;
+}
+EXPORT_SYMBOL_GPL(dmm_pat_init);
+
+static s32 __init dmm_init(void)
+{
+	return platform_driver_register(&dmm_driver);
+}
+
+static void __exit dmm_exit(void)
+{
+	platform_driver_unregister(&dmm_driver);
+}
+
+MODULE_LICENSE("GPL v2");
+MODULE_AUTHOR("David Sin <davidsin@ti.com>");
+MODULE_AUTHOR("Lajos Molnar <molnar@ti.com>");
+module_init(dmm_init);
+module_exit(dmm_exit);
-- 
1.7.0.4


  reply	other threads:[~2010-12-06 22:17 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-06 22:27 [PATCH 0/9] TI DMM-TILER driver David Sin
2010-12-06 22:27 ` David Sin [this message]
2010-12-06 22:27 ` [PATCH 2/9] TILER-DMM: Container manager interface and utility definitons David Sin
2010-12-06 22:27 ` [PATCH 3/9] TILER-DMM: Sample TCM implementation: Simple TILER Allocator (SiTA) David Sin
2010-12-06 22:27 ` [PATCH 4/9] TILER-DMM: TILER Memory Manager interface and implementation David Sin
2010-12-06 22:27 ` [PATCH 5/9] TILER-DMM: TILER interface file and documentation David Sin
2010-12-06 22:27 ` [PATCH 6/9] TILER-DMM: Geometry and view manipulation functions David Sin
2010-12-06 22:27 ` [PATCH 7/9] TILER-DMM: Main TILER driver implementation David Sin
2010-12-06 23:21   ` Tony Lindgren
2010-12-13 17:32     ` David Sin
2010-12-06 22:27 ` [PATCH 8/9] TILER-DMM: Linking TILER driver into the Linux kernel build David Sin
2010-12-06 22:27 ` [PATCH 9/9] TILER-DMM: Device support for OMAP David Sin
2010-12-16 13:34 ` [PATCH 0/9] TI DMM-TILER driver Arnd Bergmann
2010-12-16 17:25   ` David Sin
2010-12-16 17:37     ` David Sin
2010-12-16 17:43       ` Arnd Bergmann
2010-12-16 19:02         ` David Sin
2010-12-16 23:28           ` Dave Airlie
2010-12-22 14:33             ` David Sin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1291674446-10766-2-git-send-email-davidsin@ti.com \
    --to=davidsin@ti.com \
    --cc=akpm@linux-foundation.org \
    --cc=greg@kroah.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=molnar@ti.com \
    --cc=rmk@arm.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome