Re: [PATCH 08/15] OMAP: DSS2: RFBI driver

2009-08-05 Thread Tony Lindgren
* Tomi Valkeinen  [090805 17:19]:
> Signed-off-by: Tomi Valkeinen 

Please add description.

Tony
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/15] OMAP: DSS2: RFBI driver

2009-08-05 Thread Tomi Valkeinen
Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/rfbi.c | 1310 
 1 files changed, 1310 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/omap2/dss/rfbi.c

diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
new file mode 100644
index 000..9dd2349
--- /dev/null
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -0,0 +1,1310 @@
+/*
+ * linux/drivers/video/omap2/dss/rfbi.c
+ *
+ * Copyright (C) 2009 Nokia Corporation
+ * Author: Tomi Valkeinen 
+ *
+ * Some code and ideas taken from drivers/video/omap/ driver
+ * by Imre Deak.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#define DSS_SUBSYS_NAME "RFBI"
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include "dss.h"
+
+/*#define MEASURE_PERF*/
+
+#define RFBI_BASE   0x48050800
+
+struct rfbi_reg { u16 idx; };
+
+#define RFBI_REG(idx)  ((const struct rfbi_reg) { idx })
+
+#define RFBI_REVISION  RFBI_REG(0x)
+#define RFBI_SYSCONFIG RFBI_REG(0x0010)
+#define RFBI_SYSSTATUS RFBI_REG(0x0014)
+#define RFBI_CONTROL   RFBI_REG(0x0040)
+#define RFBI_PIXEL_CNT RFBI_REG(0x0044)
+#define RFBI_LINE_NUMBER   RFBI_REG(0x0048)
+#define RFBI_CMD   RFBI_REG(0x004c)
+#define RFBI_PARAM RFBI_REG(0x0050)
+#define RFBI_DATA  RFBI_REG(0x0054)
+#define RFBI_READ  RFBI_REG(0x0058)
+#define RFBI_STATUSRFBI_REG(0x005c)
+
+#define RFBI_CONFIG(n) RFBI_REG(0x0060 + (n)*0x18)
+#define RFBI_ONOFF_TIME(n) RFBI_REG(0x0064 + (n)*0x18)
+#define RFBI_CYCLE_TIME(n) RFBI_REG(0x0068 + (n)*0x18)
+#define RFBI_DATA_CYCLE1(n)RFBI_REG(0x006c + (n)*0x18)
+#define RFBI_DATA_CYCLE2(n)RFBI_REG(0x0070 + (n)*0x18)
+#define RFBI_DATA_CYCLE3(n)RFBI_REG(0x0074 + (n)*0x18)
+
+#define RFBI_VSYNC_WIDTH   RFBI_REG(0x0090)
+#define RFBI_HSYNC_WIDTH   RFBI_REG(0x0094)
+
+#define RFBI_CMD_FIFO_LEN_BYTES (16 * sizeof(struct update_param))
+
+#define REG_FLD_MOD(idx, val, start, end) \
+   rfbi_write_reg(idx, FLD_MOD(rfbi_read_reg(idx), val, start, end))
+
+/* To work around an RFBI transfer rate limitation */
+#define OMAP_RFBI_RATE_LIMIT1
+
+enum omap_rfbi_cycleformat {
+   OMAP_DSS_RFBI_CYCLEFORMAT_1_1 = 0,
+   OMAP_DSS_RFBI_CYCLEFORMAT_2_1 = 1,
+   OMAP_DSS_RFBI_CYCLEFORMAT_3_1 = 2,
+   OMAP_DSS_RFBI_CYCLEFORMAT_3_2 = 3,
+};
+
+enum omap_rfbi_datatype {
+   OMAP_DSS_RFBI_DATATYPE_12 = 0,
+   OMAP_DSS_RFBI_DATATYPE_16 = 1,
+   OMAP_DSS_RFBI_DATATYPE_18 = 2,
+   OMAP_DSS_RFBI_DATATYPE_24 = 3,
+};
+
+enum omap_rfbi_parallelmode {
+   OMAP_DSS_RFBI_PARALLELMODE_8 = 0,
+   OMAP_DSS_RFBI_PARALLELMODE_9 = 1,
+   OMAP_DSS_RFBI_PARALLELMODE_12 = 2,
+   OMAP_DSS_RFBI_PARALLELMODE_16 = 3,
+};
+
+enum update_cmd {
+   RFBI_CMD_UPDATE = 0,
+   RFBI_CMD_SYNC   = 1,
+};
+
+static int rfbi_convert_timings(struct rfbi_timings *t);
+static void rfbi_get_clk_info(u32 *clk_period, u32 *max_clk_div);
+static void process_cmd_fifo(void);
+
+static struct {
+   void __iomem*base;
+
+   unsigned long   l4_khz;
+
+   enum omap_rfbi_datatype datatype;
+   enum omap_rfbi_parallelmode parallelmode;
+
+   enum omap_rfbi_te_mode te_mode;
+   int te_enabled;
+
+   void (*framedone_callback)(void *data);
+   void *framedone_callback_data;
+
+   struct omap_dss_device *dssdev[2];
+
+   struct kfifo  *cmd_fifo;
+   spinlock_tcmd_lock;
+   struct completion cmd_done;
+   atomic_t  cmd_fifo_full;
+   atomic_t  cmd_pending;
+#ifdef MEASURE_PERF
+   unsigned perf_bytes;
+   ktime_t perf_setup_time;
+   ktime_t perf_start_time;
+#endif
+} rfbi;
+
+struct update_region {
+   u16 x;
+   u16 y;
+   u16 w;
+   u16 h;
+};
+
+struct update_param {
+   u8 rfbi_module;
+   u8 cmd;
+
+   union {
+   struct update_region r;
+   struct completion *sync;
+   } par;
+};
+
+static inline void rfbi_write_reg(const struct rfbi_reg idx, u32 val)
+{
+   __raw_writel(val, rfbi.base + idx.idx);
+}
+
+static inline u32 rfbi_read_reg(const struct rfbi_reg idx)
+{
+   return __raw_readl(rfbi.base + idx.idx);
+}
+
+static void rfbi_enable_clocks(bool enable)
+{