aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/staging/crystalhd/crystalhd_misc.h
diff options
context:
space:
mode:
authorJarod Wilson <jarod@redhat.com>2010-01-04 18:02:27 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2010-03-03 16:42:34 -0800
commit7963eb432be2ebbf7e740bcdf6b385cc68fb7627 (patch)
treebe31cb0fdac96726e5bfe983f85f6874d97f4cba /drivers/staging/crystalhd/crystalhd_misc.h
parentca1f29c01aaa37d522dc6ce311769731f5f1919e (diff)
downloadkernel_samsung_smdk4412-7963eb432be2ebbf7e740bcdf6b385cc68fb7627.zip
kernel_samsung_smdk4412-7963eb432be2ebbf7e740bcdf6b385cc68fb7627.tar.gz
kernel_samsung_smdk4412-7963eb432be2ebbf7e740bcdf6b385cc68fb7627.tar.bz2
staging: add Broadcom Crystal HD driver
This patch supersedes the earlier ones sent by Manu Abraham to add the Broadcom Crystal HD driver to the staging tree, per discussion with him about it. I've been working with Broadcom's Naren Sankar on this driver for a number of months, and had already talked Naren about submitting this on Broadcom's behalf, didn't expect anyone else to jump on submitting it as quickly as Manu did. ;) This version is a one-shot deal, incorporating the original driver, Manu's coding style clean-ups, udev device creation support from Edgar 'gimli' Hucek, and a number of other small tweaks from myself and Scott Davilla, the other individual who has been working closely on this code with Naren and I. I've tested this iteration of the code lightly on a mini pci-e board in a ThinkPad T61p running x86_64 Fedora 12, with the expected results, and will test further on other systems with other variants of the card (I have three varieties of this device currently in hand). Scott has also tested on assorted primarily i686 varieties of Ubuntu, and Naren has tested with both Fedora and Ubuntu, iirc. Note: only the 70012 is currently supported by this driver, 70015 support will follow later. Also note that Blu-Ray support isn't enabled (at the firmware level), due to misc fun related to the BD encryption scheme, DRM, etc. :\ I *do* have a git tree containing the driver, lib, gst plugin and firmware that I'm working from at the moment[*], as there are inter- dependencies between the driver and lib, and the driver can be used with kernels going a ways back (I've only tested back to 2.6.18 as it exists in Red Hat Enterprise Linux 5). I'm exporting from there, into a linux-next tree, then generating patches from there. The goal is to feed everything upstream as quickly as possible, but there are users who want this code for earlier kernels too... The firmware will be submitted for inclusion in dwmw2's linux-firmware tree once there is a suitable redistribution-no-modification type of license on it (I believe Naren is working with Broadcom legal to get that in place). Changelog from initial Broadcom release to here: commit d20475d444610c5683d09e63f707f5bb22359062 Author: Jarod Wilson <jarod@redhat.com> Date: Mon Jan 4 13:55:16 2010 -0500 include: lib doesn't build w/o the removed stdint include So add it back... Signed-off-by: Jarod Wilson <jarod@redhat.com> commit c181070a330530b792d2b80e3ec6ab12a5a57394 Author: Scott Davilla <davilla@4pi.com> Date: Mon Jan 4 13:38:37 2010 -0500 include: don't define VOID if its already defined Signed-off-by: Scott Davilla <davilla@4pi.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> commit 33d8a2b691e81212e398f53770578d79650bf0bc Author: Jarod Wilson <jarod@redhat.com> Date: Mon Jan 4 13:12:10 2010 -0500 driver: create crystalhd device using udev Based on: http://sourceforge.net/apps/trac/archvdr/browser/trunk/archvdr/crystalhd/use_udev.patch Signed-off-by: Edgar ( gimli ) Hucek <ebsi4711 at gmail dot com> Formatting tweaks, error-handling path fixups and any bugs added by Jarod. Signed-off-by: Jarod Wilson <jarod@redhat.com> commit c44c64dea5537814796fcbe2d9db0209383c78b9 Author: Manu Abraham <abraham.manu@gmail.com> Date: Mon Jan 4 10:32:47 2010 -0500 crystalhd: coding style cleanups Signed-off-by: Manu Abraham <abraham.manu@gmail.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> commit cffa6da7467ff697a656d1dfff54bb0513a053dc Author: Jarod Wilson <jarod@redhat.com> Date: Mon Jan 4 10:17:27 2010 -0500 crystalhd: run dos2unix over everything, this is linux source... Signed-off-by: Jarod Wilson <jarod@redhat.com> commit 7fa38a282db7af5a5746055f7c6cef8a9b8ee138 Author: Jarod Wilson <jarod@redhat.com> Date: Mon Jan 4 10:02:33 2010 -0500 crystalhd: initial import of released Broadcom code Straight import of: http://www.broadcom.com/docs/support/crystalhd/crystalhd_linux_20091229.zip Unfortunately, we're unable to publicly publish all the history that got us from the initial internal code to what was released here, but such is life, we can just be happy we've got this open-sourced now. :) Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Naren Sankar <nsankar@broadcom.com> Signed-off-by: Scott Davilla <davilla@4pi.com> Signed-off-by: Manu Abraham <abraham.manu@gmail.com> Signed-off-by: Jarod Wilson <jarod@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/crystalhd/crystalhd_misc.h')
-rw-r--r--drivers/staging/crystalhd/crystalhd_misc.h229
1 files changed, 229 insertions, 0 deletions
diff --git a/drivers/staging/crystalhd/crystalhd_misc.h b/drivers/staging/crystalhd/crystalhd_misc.h
new file mode 100644
index 0000000..a2aa6ad
--- /dev/null
+++ b/drivers/staging/crystalhd/crystalhd_misc.h
@@ -0,0 +1,229 @@
+/***************************************************************************
+ * Copyright (c) 2005-2009, Broadcom Corporation.
+ *
+ * Name: crystalhd_misc . h
+ *
+ * Description:
+ * BCM70012 Linux driver general purpose routines.
+ * Includes reg/mem read and write routines.
+ *
+ * HISTORY:
+ *
+ **********************************************************************
+ * This file is part of the crystalhd device driver.
+ *
+ * This driver 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 of the License.
+ *
+ * This driver 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 driver. If not, see <http://www.gnu.org/licenses/>.
+ **********************************************************************/
+
+#ifndef _CRYSTALHD_MISC_H_
+#define _CRYSTALHD_MISC_H_
+
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/errno.h>
+#include <linux/string.h>
+#include <linux/ioctl.h>
+#include <linux/dma-mapping.h>
+#include <linux/version.h>
+#include <linux/sched.h>
+#include <asm/system.h>
+#include "bc_dts_glob_lnx.h"
+
+/* Global log level variable defined in crystal_misc.c file */
+extern uint32_t g_linklog_level;
+
+/* Global element pool for all Queue management.
+ * TX: Active = BC_TX_LIST_CNT, Free = BC_TX_LIST_CNT.
+ * RX: Free = BC_RX_LIST_CNT, Active = 2
+ * FW-CMD: 4
+ */
+#define BC_LINK_ELEM_POOL_SZ ((BC_TX_LIST_CNT * 2) + BC_RX_LIST_CNT + 2 + 4)
+
+/* Driver's IODATA pool count */
+#define CHD_IODATA_POOL_SZ (BC_IOCTL_DATA_POOL_SIZE * BC_LINK_MAX_OPENS)
+
+/* Scatter Gather memory pool size for Tx and Rx */
+#define BC_LINK_SG_POOL_SZ (BC_TX_LIST_CNT + BC_RX_LIST_CNT)
+
+enum _crystalhd_dio_sig {
+ crystalhd_dio_inv = 0,
+ crystalhd_dio_locked,
+ crystalhd_dio_sg_mapped,
+};
+
+struct crystalhd_dio_user_info {
+ void *xfr_buff;
+ uint32_t xfr_len;
+ uint32_t uv_offset;
+ bool dir_tx;
+
+ uint32_t uv_sg_ix;
+ uint32_t uv_sg_off;
+ int comp_sts;
+ int ev_sts;
+ uint32_t y_done_sz;
+ uint32_t uv_done_sz;
+ uint32_t comp_flags;
+ bool b422mode;
+};
+
+typedef struct _crystalhd_dio_req {
+ uint32_t sig;
+ uint32_t max_pages;
+ struct page **pages;
+ struct scatterlist *sg;
+ int sg_cnt;
+ int page_cnt;
+ int direction;
+ struct crystalhd_dio_user_info uinfo;
+ void *fb_va;
+ uint32_t fb_size;
+ dma_addr_t fb_pa;
+ struct _crystalhd_dio_req *next;
+} crystalhd_dio_req;
+
+#define BC_LINK_DIOQ_SIG (0x09223280)
+
+typedef struct _crystalhd_elem_s {
+ struct _crystalhd_elem_s *flink;
+ struct _crystalhd_elem_s *blink;
+ void *data;
+ uint32_t tag;
+} crystalhd_elem_t;
+
+typedef void (*crystalhd_data_free_cb)(void *context, void *data);
+
+typedef struct _crystalhd_dioq_s {
+ uint32_t sig;
+ struct crystalhd_adp *adp;
+ crystalhd_elem_t *head;
+ crystalhd_elem_t *tail;
+ uint32_t count;
+ spinlock_t lock;
+ wait_queue_head_t event;
+ crystalhd_data_free_cb data_rel_cb;
+ void *cb_context;
+} crystalhd_dioq_t;
+
+typedef void (*hw_comp_callback)(crystalhd_dio_req *,
+ wait_queue_head_t *event, BC_STATUS sts);
+
+/*========= Decoder (7412) register access routines.================= */
+uint32_t bc_dec_reg_rd(struct crystalhd_adp *, uint32_t);
+void bc_dec_reg_wr(struct crystalhd_adp *, uint32_t, uint32_t);
+
+/*========= Link (70012) register access routines.. =================*/
+uint32_t crystalhd_reg_rd(struct crystalhd_adp *, uint32_t);
+void crystalhd_reg_wr(struct crystalhd_adp *, uint32_t, uint32_t);
+
+/*========= Decoder (7412) memory access routines..=================*/
+BC_STATUS crystalhd_mem_rd(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t *);
+BC_STATUS crystalhd_mem_wr(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t *);
+
+/*==========Link (70012) PCIe Config access routines.================*/
+BC_STATUS crystalhd_pci_cfg_rd(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t *);
+BC_STATUS crystalhd_pci_cfg_wr(struct crystalhd_adp *, uint32_t, uint32_t, uint32_t);
+
+/*========= Linux Kernel Interface routines. ======================= */
+void *bc_kern_dma_alloc(struct crystalhd_adp *, uint32_t, dma_addr_t *);
+void bc_kern_dma_free(struct crystalhd_adp *, uint32_t,
+ void *, dma_addr_t);
+#define crystalhd_create_event(_ev) init_waitqueue_head(_ev)
+#define crystalhd_set_event(_ev) wake_up_interruptible(_ev)
+#define crystalhd_wait_on_event(ev, condition, timeout, ret, nosig) \
+do { \
+ DECLARE_WAITQUEUE(entry, current); \
+ unsigned long end = jiffies + ((timeout * HZ) / 1000); \
+ ret = 0; \
+ add_wait_queue(ev, &entry); \
+ for (;;) { \
+ __set_current_state(TASK_INTERRUPTIBLE); \
+ if (condition) { \
+ break; \
+ } \
+ if (time_after_eq(jiffies, end)) { \
+ ret = -EBUSY; \
+ break; \
+ } \
+ schedule_timeout((HZ / 100 > 1) ? HZ / 100 : 1); \
+ if (!nosig && signal_pending(current)) { \
+ ret = -EINTR; \
+ break; \
+ } \
+ } \
+ __set_current_state(TASK_RUNNING); \
+ remove_wait_queue(ev, &entry); \
+} while (0)
+
+/*================ Direct IO mapping routines ==================*/
+extern int crystalhd_create_dio_pool(struct crystalhd_adp *, uint32_t);
+extern void crystalhd_destroy_dio_pool(struct crystalhd_adp *);
+extern BC_STATUS crystalhd_map_dio(struct crystalhd_adp *, void *, uint32_t,
+ uint32_t, bool, bool, crystalhd_dio_req**);
+
+extern BC_STATUS crystalhd_unmap_dio(struct crystalhd_adp *, crystalhd_dio_req*);
+#define crystalhd_get_sgle_paddr(_dio, _ix) (cpu_to_le64(sg_dma_address(&_dio->sg[_ix])))
+#define crystalhd_get_sgle_len(_dio, _ix) (cpu_to_le32(sg_dma_len(&_dio->sg[_ix])))
+
+/*================ General Purpose Queues ==================*/
+extern BC_STATUS crystalhd_create_dioq(struct crystalhd_adp *, crystalhd_dioq_t **, crystalhd_data_free_cb , void *);
+extern void crystalhd_delete_dioq(struct crystalhd_adp *, crystalhd_dioq_t *);
+extern BC_STATUS crystalhd_dioq_add(crystalhd_dioq_t *ioq, void *data, bool wake, uint32_t tag);
+extern void *crystalhd_dioq_fetch(crystalhd_dioq_t *ioq);
+extern void *crystalhd_dioq_find_and_fetch(crystalhd_dioq_t *ioq, uint32_t tag);
+extern void *crystalhd_dioq_fetch_wait(crystalhd_dioq_t *ioq, uint32_t to_secs, uint32_t *sig_pend);
+
+#define crystalhd_dioq_count(_ioq) ((_ioq) ? _ioq->count : 0)
+
+extern int crystalhd_create_elem_pool(struct crystalhd_adp *, uint32_t);
+extern void crystalhd_delete_elem_pool(struct crystalhd_adp *);
+
+
+/*================ Debug routines/macros .. ================================*/
+extern void crystalhd_show_buffer(uint32_t off, uint8_t *buff, uint32_t dwcount);
+
+enum _chd_log_levels {
+ BCMLOG_ERROR = 0x80000000, /* Don't disable this option */
+ BCMLOG_DATA = 0x40000000, /* Data, enable by default */
+ BCMLOG_SPINLOCK = 0x20000000, /* Spcial case for Spin locks*/
+
+ /* Following are allowed only in debug mode */
+ BCMLOG_INFO = 0x00000001, /* Generic informational */
+ BCMLOG_DBG = 0x00000002, /* First level Debug info */
+ BCMLOG_SSTEP = 0x00000004, /* Stepping information */
+ BCMLOG_ENTER_LEAVE = 0x00000008, /* stack tracking */
+};
+
+#define BCMLOG_ENTER \
+if (g_linklog_level & BCMLOG_ENTER_LEAVE) { \
+ printk("Entered %s\n", __func__); \
+}
+
+#define BCMLOG_LEAVE \
+if (g_linklog_level & BCMLOG_ENTER_LEAVE) { \
+ printk("Leaving %s\n", __func__); \
+}
+
+#define BCMLOG(trace, fmt, args...) \
+if (g_linklog_level & trace) { \
+ printk(fmt, ##args); \
+}
+
+#define BCMLOG_ERR(fmt, args...) \
+do { \
+ if (g_linklog_level & BCMLOG_ERROR) { \
+ printk("*ERR*:%s:%d: "fmt, __FILE__, __LINE__, ##args); \
+ } \
+} while (0);
+
+#endif