2009-09-15 08:33:54 -06:00
|
|
|
/*
|
|
|
|
* Driver for the Conexant CX25821 PCIe bridge
|
|
|
|
*
|
2009-09-13 08:25:45 -06:00
|
|
|
* Copyright (C) 2009 Conexant Systems Inc.
|
2009-09-15 08:33:54 -06:00
|
|
|
* Authors <shu.lin@conexant.com>, <hiep.huynh@conexant.com>
|
|
|
|
* Based on Steven Toth <stoth@linuxtv.org> cx23885 driver
|
|
|
|
*
|
|
|
|
* 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; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
|
2009-09-15 08:33:54 -06:00
|
|
|
#include <linux/i2c.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 02:04:11 -06:00
|
|
|
#include <linux/slab.h>
|
2009-09-15 08:33:54 -06:00
|
|
|
#include "cx25821.h"
|
|
|
|
#include "cx25821-sram.h"
|
|
|
|
#include "cx25821-video.h"
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION("Driver for Athena cards");
|
|
|
|
MODULE_AUTHOR("Shu Lin - Hiep Huynh");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
static unsigned int debug;
|
|
|
|
module_param(debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(debug, "enable debug messages");
|
|
|
|
|
2009-09-13 08:39:12 -06:00
|
|
|
static unsigned int card[] = {[0 ... (CX25821_MAXBOARDS - 1)] = UNSET };
|
2009-09-13 08:30:11 -06:00
|
|
|
module_param_array(card, int, NULL, 0444);
|
2009-09-15 08:33:54 -06:00
|
|
|
MODULE_PARM_DESC(card, "card type");
|
|
|
|
|
2013-04-13 03:28:54 -06:00
|
|
|
const struct sram_channel cx25821_sram_channels[] = {
|
2009-09-13 08:30:11 -06:00
|
|
|
[SRAM_CH00] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH00,
|
|
|
|
.name = "VID A",
|
|
|
|
.cmds_start = VID_A_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_A_IQ,
|
|
|
|
.cdt = VID_A_CDT,
|
|
|
|
.fifo_start = VID_A_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA1_PTR1,
|
|
|
|
.ptr2_reg = DMA1_PTR2,
|
|
|
|
.cnt1_reg = DMA1_CNT1,
|
|
|
|
.cnt2_reg = DMA1_CNT2,
|
|
|
|
.int_msk = VID_A_INT_MSK,
|
|
|
|
.int_stat = VID_A_INT_STAT,
|
|
|
|
.int_mstat = VID_A_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_A_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_A_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_A_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_A_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_A_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH01] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH01,
|
|
|
|
.name = "VID B",
|
|
|
|
.cmds_start = VID_B_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_B_IQ,
|
|
|
|
.cdt = VID_B_CDT,
|
|
|
|
.fifo_start = VID_B_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA2_PTR1,
|
|
|
|
.ptr2_reg = DMA2_PTR2,
|
|
|
|
.cnt1_reg = DMA2_CNT1,
|
|
|
|
.cnt2_reg = DMA2_CNT2,
|
|
|
|
.int_msk = VID_B_INT_MSK,
|
|
|
|
.int_stat = VID_B_INT_STAT,
|
|
|
|
.int_mstat = VID_B_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_B_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_B_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_B_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_B_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_B_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH02] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH02,
|
|
|
|
.name = "VID C",
|
|
|
|
.cmds_start = VID_C_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_C_IQ,
|
|
|
|
.cdt = VID_C_CDT,
|
|
|
|
.fifo_start = VID_C_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA3_PTR1,
|
|
|
|
.ptr2_reg = DMA3_PTR2,
|
|
|
|
.cnt1_reg = DMA3_CNT1,
|
|
|
|
.cnt2_reg = DMA3_CNT2,
|
|
|
|
.int_msk = VID_C_INT_MSK,
|
|
|
|
.int_stat = VID_C_INT_STAT,
|
|
|
|
.int_mstat = VID_C_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_C_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_C_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_C_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_C_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_C_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH03] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH03,
|
|
|
|
.name = "VID D",
|
|
|
|
.cmds_start = VID_D_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_D_IQ,
|
|
|
|
.cdt = VID_D_CDT,
|
|
|
|
.fifo_start = VID_D_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA4_PTR1,
|
|
|
|
.ptr2_reg = DMA4_PTR2,
|
|
|
|
.cnt1_reg = DMA4_CNT1,
|
|
|
|
.cnt2_reg = DMA4_CNT2,
|
|
|
|
.int_msk = VID_D_INT_MSK,
|
|
|
|
.int_stat = VID_D_INT_STAT,
|
|
|
|
.int_mstat = VID_D_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_D_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_D_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_D_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_D_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_D_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH04] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH04,
|
|
|
|
.name = "VID E",
|
|
|
|
.cmds_start = VID_E_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_E_IQ,
|
|
|
|
.cdt = VID_E_CDT,
|
|
|
|
.fifo_start = VID_E_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA5_PTR1,
|
|
|
|
.ptr2_reg = DMA5_PTR2,
|
|
|
|
.cnt1_reg = DMA5_CNT1,
|
|
|
|
.cnt2_reg = DMA5_CNT2,
|
|
|
|
.int_msk = VID_E_INT_MSK,
|
|
|
|
.int_stat = VID_E_INT_STAT,
|
|
|
|
.int_mstat = VID_E_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_E_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_E_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_E_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_E_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_E_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH05] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH05,
|
|
|
|
.name = "VID F",
|
|
|
|
.cmds_start = VID_F_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_F_IQ,
|
|
|
|
.cdt = VID_F_CDT,
|
|
|
|
.fifo_start = VID_F_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA6_PTR1,
|
|
|
|
.ptr2_reg = DMA6_PTR2,
|
|
|
|
.cnt1_reg = DMA6_CNT1,
|
|
|
|
.cnt2_reg = DMA6_CNT2,
|
|
|
|
.int_msk = VID_F_INT_MSK,
|
|
|
|
.int_stat = VID_F_INT_STAT,
|
|
|
|
.int_mstat = VID_F_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_F_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_F_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_F_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_F_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_F_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH06] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH06,
|
|
|
|
.name = "VID G",
|
|
|
|
.cmds_start = VID_G_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_G_IQ,
|
|
|
|
.cdt = VID_G_CDT,
|
|
|
|
.fifo_start = VID_G_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA7_PTR1,
|
|
|
|
.ptr2_reg = DMA7_PTR2,
|
|
|
|
.cnt1_reg = DMA7_CNT1,
|
|
|
|
.cnt2_reg = DMA7_CNT2,
|
|
|
|
.int_msk = VID_G_INT_MSK,
|
|
|
|
.int_stat = VID_G_INT_STAT,
|
|
|
|
.int_mstat = VID_G_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_G_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_G_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_G_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_G_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_G_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH07] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH07,
|
|
|
|
.name = "VID H",
|
|
|
|
.cmds_start = VID_H_DOWN_CMDS,
|
|
|
|
.ctrl_start = VID_H_IQ,
|
|
|
|
.cdt = VID_H_CDT,
|
|
|
|
.fifo_start = VID_H_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA8_PTR1,
|
|
|
|
.ptr2_reg = DMA8_PTR2,
|
|
|
|
.cnt1_reg = DMA8_CNT1,
|
|
|
|
.cnt2_reg = DMA8_CNT2,
|
|
|
|
.int_msk = VID_H_INT_MSK,
|
|
|
|
.int_stat = VID_H_INT_STAT,
|
|
|
|
.int_mstat = VID_H_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_DST_H_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_DST_H_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_DST_H_GPCNT,
|
|
|
|
.vip_ctl = VID_DST_H_VIP_CTL,
|
|
|
|
.pix_frmt = VID_DST_H_PIX_FRMT,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH08] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.name = "audio from",
|
|
|
|
.cmds_start = AUD_A_DOWN_CMDS,
|
|
|
|
.ctrl_start = AUD_A_IQ,
|
|
|
|
.cdt = AUD_A_CDT,
|
|
|
|
.fifo_start = AUD_A_DOWN_CLUSTER_1,
|
|
|
|
.fifo_size = AUDIO_CLUSTER_SIZE * 3,
|
|
|
|
.ptr1_reg = DMA17_PTR1,
|
|
|
|
.ptr2_reg = DMA17_PTR2,
|
|
|
|
.cnt1_reg = DMA17_CNT1,
|
|
|
|
.cnt2_reg = DMA17_CNT2,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH09] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH09,
|
|
|
|
.name = "VID Upstream I",
|
|
|
|
.cmds_start = VID_I_UP_CMDS,
|
|
|
|
.ctrl_start = VID_I_IQ,
|
|
|
|
.cdt = VID_I_CDT,
|
|
|
|
.fifo_start = VID_I_UP_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA15_PTR1,
|
|
|
|
.ptr2_reg = DMA15_PTR2,
|
|
|
|
.cnt1_reg = DMA15_CNT1,
|
|
|
|
.cnt2_reg = DMA15_CNT2,
|
|
|
|
.int_msk = VID_I_INT_MSK,
|
|
|
|
.int_stat = VID_I_INT_STAT,
|
|
|
|
.int_mstat = VID_I_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_SRC_I_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_SRC_I_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_SRC_I_GPCNT,
|
|
|
|
|
|
|
|
.vid_fmt_ctl = VID_SRC_I_FMT_CTL,
|
|
|
|
.vid_active_ctl1 = VID_SRC_I_ACTIVE_CTL1,
|
|
|
|
.vid_active_ctl2 = VID_SRC_I_ACTIVE_CTL2,
|
|
|
|
.vid_cdt_size = VID_SRC_I_CDT_SZ,
|
|
|
|
.irq_bit = 8,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH10] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH10,
|
|
|
|
.name = "VID Upstream J",
|
|
|
|
.cmds_start = VID_J_UP_CMDS,
|
|
|
|
.ctrl_start = VID_J_IQ,
|
|
|
|
.cdt = VID_J_CDT,
|
|
|
|
.fifo_start = VID_J_UP_CLUSTER_1,
|
|
|
|
.fifo_size = (VID_CLUSTER_SIZE << 2),
|
|
|
|
.ptr1_reg = DMA16_PTR1,
|
|
|
|
.ptr2_reg = DMA16_PTR2,
|
|
|
|
.cnt1_reg = DMA16_CNT1,
|
|
|
|
.cnt2_reg = DMA16_CNT2,
|
|
|
|
.int_msk = VID_J_INT_MSK,
|
|
|
|
.int_stat = VID_J_INT_STAT,
|
|
|
|
.int_mstat = VID_J_INT_MSTAT,
|
|
|
|
.dma_ctl = VID_SRC_J_DMA_CTL,
|
|
|
|
.gpcnt_ctl = VID_SRC_J_GPCNT_CTL,
|
|
|
|
.gpcnt = VID_SRC_J_GPCNT,
|
|
|
|
|
|
|
|
.vid_fmt_ctl = VID_SRC_J_FMT_CTL,
|
|
|
|
.vid_active_ctl1 = VID_SRC_J_ACTIVE_CTL1,
|
|
|
|
.vid_active_ctl2 = VID_SRC_J_ACTIVE_CTL2,
|
|
|
|
.vid_cdt_size = VID_SRC_J_CDT_SZ,
|
|
|
|
.irq_bit = 9,
|
|
|
|
},
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
[SRAM_CH11] = {
|
2011-09-01 21:55:35 -06:00
|
|
|
.i = SRAM_CH11,
|
|
|
|
.name = "Audio Upstream Channel B",
|
|
|
|
.cmds_start = AUD_B_UP_CMDS,
|
|
|
|
.ctrl_start = AUD_B_IQ,
|
|
|
|
.cdt = AUD_B_CDT,
|
|
|
|
.fifo_start = AUD_B_UP_CLUSTER_1,
|
|
|
|
.fifo_size = (AUDIO_CLUSTER_SIZE * 3),
|
|
|
|
.ptr1_reg = DMA22_PTR1,
|
|
|
|
.ptr2_reg = DMA22_PTR2,
|
|
|
|
.cnt1_reg = DMA22_CNT1,
|
|
|
|
.cnt2_reg = DMA22_CNT2,
|
|
|
|
.int_msk = AUD_B_INT_MSK,
|
|
|
|
.int_stat = AUD_B_INT_STAT,
|
|
|
|
.int_mstat = AUD_B_INT_MSTAT,
|
|
|
|
.dma_ctl = AUD_INT_DMA_CTL,
|
|
|
|
.gpcnt_ctl = AUD_B_GPCNT_CTL,
|
|
|
|
.gpcnt = AUD_B_GPCNT,
|
|
|
|
.aud_length = AUD_B_LNGTH,
|
|
|
|
.aud_cfg = AUD_B_CFG,
|
|
|
|
.fld_aud_fifo_en = FLD_AUD_SRC_B_FIFO_EN,
|
|
|
|
.fld_aud_risc_en = FLD_AUD_SRC_B_RISC_EN,
|
|
|
|
.irq_bit = 11,
|
|
|
|
},
|
2009-09-15 08:33:54 -06:00
|
|
|
};
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_sram_channels);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
|
|
|
static int cx25821_risc_decode(u32 risc)
|
|
|
|
{
|
2010-11-07 13:48:21 -07:00
|
|
|
static const char * const instr[16] = {
|
2009-09-13 08:30:11 -06:00
|
|
|
[RISC_SYNC >> 28] = "sync",
|
|
|
|
[RISC_WRITE >> 28] = "write",
|
|
|
|
[RISC_WRITEC >> 28] = "writec",
|
|
|
|
[RISC_READ >> 28] = "read",
|
|
|
|
[RISC_READC >> 28] = "readc",
|
|
|
|
[RISC_JUMP >> 28] = "jump",
|
|
|
|
[RISC_SKIP >> 28] = "skip",
|
|
|
|
[RISC_WRITERM >> 28] = "writerm",
|
|
|
|
[RISC_WRITECM >> 28] = "writecm",
|
|
|
|
[RISC_WRITECR >> 28] = "writecr",
|
|
|
|
};
|
2010-11-07 13:48:21 -07:00
|
|
|
static const int incr[16] = {
|
2009-09-13 08:30:11 -06:00
|
|
|
[RISC_WRITE >> 28] = 3,
|
|
|
|
[RISC_JUMP >> 28] = 3,
|
|
|
|
[RISC_SKIP >> 28] = 1,
|
|
|
|
[RISC_SYNC >> 28] = 1,
|
|
|
|
[RISC_WRITERM >> 28] = 3,
|
|
|
|
[RISC_WRITECM >> 28] = 3,
|
|
|
|
[RISC_WRITECR >> 28] = 4,
|
|
|
|
};
|
2010-11-07 13:48:21 -07:00
|
|
|
static const char * const bits[] = {
|
2009-09-13 08:30:11 -06:00
|
|
|
"12", "13", "14", "resync",
|
|
|
|
"cnt0", "cnt1", "18", "19",
|
|
|
|
"20", "21", "22", "23",
|
|
|
|
"irq1", "irq2", "eol", "sol",
|
|
|
|
};
|
|
|
|
int i;
|
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont("0x%08x [ %s",
|
|
|
|
risc, instr[risc >> 28] ? instr[risc >> 28] : "INVALID");
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = ARRAY_SIZE(bits) - 1; i >= 0; i--) {
|
|
|
|
if (risc & (1 << (i + 12)))
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont(" %s", bits[i]);
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont(" count=%d ]\n", risc & 0xfff);
|
2009-09-13 08:30:11 -06:00
|
|
|
return incr[risc >> 28] ? incr[risc >> 28] : 1;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline int i2c_slave_did_ack(struct i2c_adapter *i2c_adap)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct cx25821_i2c *bus = i2c_adap->algo_data;
|
|
|
|
struct cx25821_dev *dev = bus->dev;
|
|
|
|
return cx_read(bus->reg_stat) & 0x01;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cx25821_registers_init(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
u32 tmp;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* enable RUN_RISC in Pecos */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(DEV_CNTRL2, 0x20);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* Set the master PCI interrupt masks to enable video, audio, MBIF,
|
|
|
|
* and GPIO interrupts
|
|
|
|
* I2C interrupt masking is handled by the I2C objects themselves. */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PCI_INT_MSK, 0x2001FFFF);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(RDR_TLCTL0);
|
2010-03-21 11:18:19 -06:00
|
|
|
tmp &= ~FLD_CFG_RCB_CK_EN; /* Clear the RCB_CK_EN bit */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(RDR_TLCTL0, tmp);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL-A setting for the Audio Master Clock */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_A_INT_FRAC, 0x9807A58B);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL_A_POST = 0x1C, PLL_A_OUT_TO_PIN = 0x1 */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_A_POST_STAT_BIST, 0x8000019C);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* clear reset bit [31] */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(PLL_A_INT_FRAC);
|
|
|
|
cx_write(PLL_A_INT_FRAC, tmp & 0x7FFFFFFF);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL-B setting for Mobilygen Host Bus Interface */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_B_INT_FRAC, 0x9883A86F);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL_B_POST = 0xD, PLL_B_OUT_TO_PIN = 0x0 */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_B_POST_STAT_BIST, 0x8000018D);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* clear reset bit [31] */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(PLL_B_INT_FRAC);
|
|
|
|
cx_write(PLL_B_INT_FRAC, tmp & 0x7FFFFFFF);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL-C setting for video upstream channel */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_C_INT_FRAC, 0x96A0EA3F);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL_C_POST = 0x3, PLL_C_OUT_TO_PIN = 0x0 */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_C_POST_STAT_BIST, 0x80000103);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* clear reset bit [31] */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(PLL_C_INT_FRAC);
|
|
|
|
cx_write(PLL_C_INT_FRAC, tmp & 0x7FFFFFFF);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL-D setting for audio upstream channel */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_D_INT_FRAC, 0x98757F5B);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* PLL_D_POST = 0x13, PLL_D_OUT_TO_PIN = 0x0 */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PLL_D_POST_STAT_BIST, 0x80000113);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* clear reset bit [31] */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(PLL_D_INT_FRAC);
|
|
|
|
cx_write(PLL_D_INT_FRAC, tmp & 0x7FFFFFFF);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* This selects the PLL C clock source for the video upstream channel
|
|
|
|
* I and J */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(VID_CH_CLK_SEL);
|
|
|
|
cx_write(VID_CH_CLK_SEL, (tmp & 0x00FFFFFF) | 0x24000000);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* 656/VIP SRC Upstream Channel I & J and 7 - Host Bus Interface for
|
|
|
|
* channel A-C
|
|
|
|
* select 656/VIP DST for downstream Channel A - C */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(VID_CH_MODE_SEL);
|
2010-03-21 11:18:19 -06:00
|
|
|
/* cx_write( VID_CH_MODE_SEL, tmp | 0x1B0001FF); */
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(VID_CH_MODE_SEL, tmp & 0xFFFFFE00);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* enables 656 port I and J as output */
|
2009-09-13 08:30:11 -06:00
|
|
|
tmp = cx_read(CLK_RST);
|
2010-03-21 11:18:19 -06:00
|
|
|
/* use external ALT_PLL_REF pin as its reference clock instead */
|
|
|
|
tmp |= FLD_USE_ALT_PLL_REF;
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(CLK_RST, tmp & ~(FLD_VID_I_CLK_NOE | FLD_VID_J_CLK_NOE));
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
mdelay(100);
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
int cx25821_sram_channel_setup(struct cx25821_dev *dev,
|
2013-04-13 03:28:54 -06:00
|
|
|
const struct sram_channel *ch,
|
2009-09-13 08:30:11 -06:00
|
|
|
unsigned int bpl, u32 risc)
|
|
|
|
{
|
|
|
|
unsigned int i, lines;
|
|
|
|
u32 cdt;
|
|
|
|
|
|
|
|
if (ch->cmds_start == 0) {
|
|
|
|
cx_write(ch->ptr1_reg, 0);
|
|
|
|
cx_write(ch->ptr2_reg, 0);
|
|
|
|
cx_write(ch->cnt2_reg, 0);
|
|
|
|
cx_write(ch->cnt1_reg, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
bpl = (bpl + 7) & ~7; /* alignment */
|
|
|
|
cdt = ch->cdt;
|
|
|
|
lines = ch->fifo_size / bpl;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
if (lines > 4)
|
2009-09-13 08:30:11 -06:00
|
|
|
lines = 4;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
BUG_ON(lines < 2);
|
|
|
|
|
|
|
|
cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
|
|
|
|
cx_write(8 + 4, 8);
|
|
|
|
cx_write(8 + 8, 0);
|
|
|
|
|
|
|
|
/* write CDT */
|
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
cx_write(cdt + 16 * i, ch->fifo_start + bpl * i);
|
|
|
|
cx_write(cdt + 16 * i + 4, 0);
|
|
|
|
cx_write(cdt + 16 * i + 8, 0);
|
|
|
|
cx_write(cdt + 16 * i + 12, 0);
|
|
|
|
}
|
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* init the first cdt buffer */
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < 128; i++)
|
|
|
|
cx_write(ch->fifo_start + 4 * i, i);
|
|
|
|
|
|
|
|
/* write CMDS */
|
2010-03-21 11:18:19 -06:00
|
|
|
if (ch->jumponly)
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->cmds_start + 0, 8);
|
2010-03-21 11:18:19 -06:00
|
|
|
else
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->cmds_start + 0, risc);
|
|
|
|
|
|
|
|
cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */
|
|
|
|
cx_write(ch->cmds_start + 8, cdt);
|
|
|
|
cx_write(ch->cmds_start + 12, (lines * 16) >> 3);
|
|
|
|
cx_write(ch->cmds_start + 16, ch->ctrl_start);
|
|
|
|
|
|
|
|
if (ch->jumponly)
|
|
|
|
cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2));
|
|
|
|
else
|
|
|
|
cx_write(ch->cmds_start + 20, 64 >> 2);
|
|
|
|
|
|
|
|
for (i = 24; i < 80; i += 4)
|
|
|
|
cx_write(ch->cmds_start + i, 0);
|
|
|
|
|
|
|
|
/* fill registers */
|
|
|
|
cx_write(ch->ptr1_reg, ch->fifo_start);
|
|
|
|
cx_write(ch->ptr2_reg, cdt);
|
|
|
|
cx_write(ch->cnt2_reg, (lines * 16) >> 3);
|
|
|
|
cx_write(ch->cnt1_reg, (bpl >> 3) - 1);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:25:45 -06:00
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int cx25821_sram_channel_setup_audio(struct cx25821_dev *dev,
|
2013-04-13 03:28:54 -06:00
|
|
|
const struct sram_channel *ch,
|
2009-09-13 08:30:11 -06:00
|
|
|
unsigned int bpl, u32 risc)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
unsigned int i, lines;
|
|
|
|
u32 cdt;
|
|
|
|
|
|
|
|
if (ch->cmds_start == 0) {
|
|
|
|
cx_write(ch->ptr1_reg, 0);
|
|
|
|
cx_write(ch->ptr2_reg, 0);
|
|
|
|
cx_write(ch->cnt2_reg, 0);
|
|
|
|
cx_write(ch->cnt1_reg, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bpl = (bpl + 7) & ~7; /* alignment */
|
|
|
|
cdt = ch->cdt;
|
|
|
|
lines = ch->fifo_size / bpl;
|
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
if (lines > 3)
|
|
|
|
lines = 3; /* for AUDIO */
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
BUG_ON(lines < 2);
|
|
|
|
|
|
|
|
cx_write(8 + 0, RISC_JUMP | RISC_IRQ1 | RISC_CNT_INC);
|
|
|
|
cx_write(8 + 4, 8);
|
|
|
|
cx_write(8 + 8, 0);
|
|
|
|
|
|
|
|
/* write CDT */
|
|
|
|
for (i = 0; i < lines; i++) {
|
|
|
|
cx_write(cdt + 16 * i, ch->fifo_start + bpl * i);
|
|
|
|
cx_write(cdt + 16 * i + 4, 0);
|
|
|
|
cx_write(cdt + 16 * i + 8, 0);
|
|
|
|
cx_write(cdt + 16 * i + 12, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* write CMDS */
|
2010-03-21 11:18:19 -06:00
|
|
|
if (ch->jumponly)
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->cmds_start + 0, 8);
|
2010-03-21 11:18:19 -06:00
|
|
|
else
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->cmds_start + 0, risc);
|
|
|
|
|
|
|
|
cx_write(ch->cmds_start + 4, 0); /* 64 bits 63-32 */
|
|
|
|
cx_write(ch->cmds_start + 8, cdt);
|
|
|
|
cx_write(ch->cmds_start + 12, (lines * 16) >> 3);
|
|
|
|
cx_write(ch->cmds_start + 16, ch->ctrl_start);
|
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* IQ size */
|
|
|
|
if (ch->jumponly)
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->cmds_start + 20, 0x80000000 | (64 >> 2));
|
2010-03-21 11:18:19 -06:00
|
|
|
else
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->cmds_start + 20, 64 >> 2);
|
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* zero out */
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 24; i < 80; i += 4)
|
|
|
|
cx_write(ch->cmds_start + i, 0);
|
|
|
|
|
|
|
|
/* fill registers */
|
|
|
|
cx_write(ch->ptr1_reg, ch->fifo_start);
|
|
|
|
cx_write(ch->ptr2_reg, cdt);
|
|
|
|
cx_write(ch->cnt2_reg, (lines * 16) >> 3);
|
|
|
|
cx_write(ch->cnt1_reg, (bpl >> 3) - 1);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:25:45 -06:00
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_sram_channel_setup_audio);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2013-04-13 03:28:54 -06:00
|
|
|
void cx25821_sram_channel_dump(struct cx25821_dev *dev, const struct sram_channel *ch)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
static char *name[] = {
|
|
|
|
"init risc lo",
|
|
|
|
"init risc hi",
|
|
|
|
"cdt base",
|
|
|
|
"cdt size",
|
|
|
|
"iq base",
|
|
|
|
"iq size",
|
|
|
|
"risc pc lo",
|
|
|
|
"risc pc hi",
|
|
|
|
"iq wr ptr",
|
|
|
|
"iq rd ptr",
|
|
|
|
"cdt current",
|
|
|
|
"pci target lo",
|
|
|
|
"pci target hi",
|
|
|
|
"line / byte",
|
|
|
|
};
|
|
|
|
u32 risc;
|
|
|
|
unsigned int i, j, n;
|
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("%s: %s - dma channel status dump\n", dev->name, ch->name);
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(name); i++)
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("cmds + 0x%2x: %-15s: 0x%08x\n",
|
|
|
|
i * 4, name[i], cx_read(ch->cmds_start + 4 * i));
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
j = i * 4;
|
|
|
|
for (i = 0; i < 4;) {
|
|
|
|
risc = cx_read(ch->cmds_start + 4 * (i + 14));
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("cmds + 0x%2x: risc%d: ", j + i * 4, i);
|
2009-09-13 08:30:11 -06:00
|
|
|
i += cx25821_risc_decode(risc);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < (64 >> 2); i += n) {
|
|
|
|
risc = cx_read(ch->ctrl_start + 4 * i);
|
|
|
|
/* No consideration for bits 63-32 */
|
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("ctrl + 0x%2x (0x%08x): iq %x: ",
|
|
|
|
i * 4, ch->ctrl_start + 4 * i, i);
|
2009-09-13 08:30:11 -06:00
|
|
|
n = cx25821_risc_decode(risc);
|
|
|
|
for (j = 1; j < n; j++) {
|
|
|
|
risc = cx_read(ch->ctrl_start + 4 * (i + j));
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("ctrl + 0x%2x : iq %x: 0x%08x [ arg #%d ]\n",
|
|
|
|
4 * (i + j), i + j, risc, j);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
2009-09-13 08:30:11 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn(" : fifo: 0x%08x -> 0x%x\n",
|
|
|
|
ch->fifo_start, ch->fifo_start + ch->fifo_size);
|
|
|
|
pr_warn(" : ctrl: 0x%08x -> 0x%x\n",
|
|
|
|
ch->ctrl_start, ch->ctrl_start + 6 * 16);
|
|
|
|
pr_warn(" : ptr1_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->ptr1_reg));
|
|
|
|
pr_warn(" : ptr2_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->ptr2_reg));
|
|
|
|
pr_warn(" : cnt1_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->cnt1_reg));
|
|
|
|
pr_warn(" : cnt2_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->cnt2_reg));
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
void cx25821_sram_channel_dump_audio(struct cx25821_dev *dev,
|
2013-04-13 03:28:54 -06:00
|
|
|
const struct sram_channel *ch)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2010-11-07 13:48:21 -07:00
|
|
|
static const char * const name[] = {
|
2009-09-13 08:30:11 -06:00
|
|
|
"init risc lo",
|
|
|
|
"init risc hi",
|
|
|
|
"cdt base",
|
|
|
|
"cdt size",
|
|
|
|
"iq base",
|
|
|
|
"iq size",
|
|
|
|
"risc pc lo",
|
|
|
|
"risc pc hi",
|
|
|
|
"iq wr ptr",
|
|
|
|
"iq rd ptr",
|
|
|
|
"cdt current",
|
|
|
|
"pci target lo",
|
|
|
|
"pci target hi",
|
|
|
|
"line / byte",
|
|
|
|
};
|
2009-09-13 08:25:45 -06:00
|
|
|
|
|
|
|
u32 risc, value, tmp;
|
2009-09-13 08:30:11 -06:00
|
|
|
unsigned int i, j, n;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("\n%s: %s - dma Audio channel status dump\n",
|
|
|
|
dev->name, ch->name);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < ARRAY_SIZE(name); i++)
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("%s: cmds + 0x%2x: %-15s: 0x%08x\n",
|
|
|
|
dev->name, i * 4, name[i],
|
|
|
|
cx_read(ch->cmds_start + 4 * i));
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
j = i * 4;
|
|
|
|
for (i = 0; i < 4;) {
|
|
|
|
risc = cx_read(ch->cmds_start + 4 * (i + 14));
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("cmds + 0x%2x: risc%d: ", j + i * 4, i);
|
2009-09-13 08:30:11 -06:00
|
|
|
i += cx25821_risc_decode(risc);
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < (64 >> 2); i += n) {
|
|
|
|
risc = cx_read(ch->ctrl_start + 4 * i);
|
|
|
|
/* No consideration for bits 63-32 */
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("ctrl + 0x%2x (0x%08x): iq %x: ",
|
|
|
|
i * 4, ch->ctrl_start + 4 * i, i);
|
2009-09-13 08:30:11 -06:00
|
|
|
n = cx25821_risc_decode(risc);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
for (j = 1; j < n; j++) {
|
|
|
|
risc = cx_read(ch->ctrl_start + 4 * (i + j));
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("ctrl + 0x%2x : iq %x: 0x%08x [ arg #%d ]\n",
|
|
|
|
4 * (i + j), i + j, risc, j);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn(" : fifo: 0x%08x -> 0x%x\n",
|
|
|
|
ch->fifo_start, ch->fifo_start + ch->fifo_size);
|
|
|
|
pr_warn(" : ctrl: 0x%08x -> 0x%x\n",
|
|
|
|
ch->ctrl_start, ch->ctrl_start + 6 * 16);
|
|
|
|
pr_warn(" : ptr1_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->ptr1_reg));
|
|
|
|
pr_warn(" : ptr2_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->ptr2_reg));
|
|
|
|
pr_warn(" : cnt1_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->cnt1_reg));
|
|
|
|
pr_warn(" : cnt2_reg: 0x%08x\n",
|
|
|
|
cx_read(ch->cnt2_reg));
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
risc = cx_read(ch->cmds_start + 56 + (i * 4));
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("instruction %d = 0x%x\n", i, risc);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* read data from the first cdt buffer */
|
2009-09-13 08:30:11 -06:00
|
|
|
risc = cx_read(AUD_A_CDT);
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_warn("\nread cdt loc=0x%x\n", risc);
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
n = cx_read(risc + i * 4);
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont("0x%x ", n);
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont("\n\n");
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
value = cx_read(CLK_RST);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" CLK_RST = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
value = cx_read(PLL_A_POST_STAT_BIST);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_A_POST_STAT_BIST = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx_read(PLL_A_INT_FRAC);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_A_INT_FRAC = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
value = cx_read(PLL_B_POST_STAT_BIST);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_B_POST_STAT_BIST = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx_read(PLL_B_INT_FRAC);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_B_INT_FRAC = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
value = cx_read(PLL_C_POST_STAT_BIST);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_C_POST_STAT_BIST = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx_read(PLL_C_INT_FRAC);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_C_INT_FRAC = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
value = cx_read(PLL_D_POST_STAT_BIST);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_D_POST_STAT_BIST = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
value = cx_read(PLL_D_INT_FRAC);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" PLL_D_INT_FRAC = 0x%x\n\n", value);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
value = cx25821_i2c_read(&dev->i2c_bus[0], AFE_AB_DIAG_CTRL, &tmp);
|
2010-03-21 11:18:19 -06:00
|
|
|
CX25821_INFO(" AFE_AB_DIAG_CTRL (0x10900090) = 0x%x\n\n", value);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_sram_channel_dump_audio);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
|
|
|
static void cx25821_shutdown(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int i;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* disable RISC controller */
|
|
|
|
cx_write(DEV_CNTRL2, 0);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* Disable Video A/B activity */
|
|
|
|
for (i = 0; i < VID_CHANNEL_NUM; i++) {
|
2010-09-27 07:01:36 -06:00
|
|
|
cx_write(dev->channels[i].sram_channels->dma_ctl, 0);
|
|
|
|
cx_write(dev->channels[i].sram_channels->int_msk, 0);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-09-27 07:01:36 -06:00
|
|
|
for (i = VID_UPSTREAM_SRAM_CHANNEL_I;
|
|
|
|
i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) {
|
|
|
|
cx_write(dev->channels[i].sram_channels->dma_ctl, 0);
|
|
|
|
cx_write(dev->channels[i].sram_channels->int_msk, 0);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* Disable Audio activity */
|
|
|
|
cx_write(AUD_INT_DMA_CTL, 0);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* Disable Serial port */
|
|
|
|
cx_write(UART_CTL, 0);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* Disable Interrupts */
|
|
|
|
cx_write(PCI_INT_MSK, 0);
|
|
|
|
cx_write(AUD_A_INT_MSK, 0);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
void cx25821_set_pixel_format(struct cx25821_dev *dev, int channel_select,
|
|
|
|
u32 format)
|
2009-09-13 08:25:45 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
if (channel_select <= 7 && channel_select >= 0) {
|
2011-10-21 22:43:33 -06:00
|
|
|
cx_write(dev->channels[channel_select].sram_channels->pix_frmt,
|
|
|
|
format);
|
2010-09-27 07:01:36 -06:00
|
|
|
dev->channels[channel_select].pixel_formats = format;
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
static void cx25821_set_vip_mode(struct cx25821_dev *dev,
|
2013-04-13 03:28:54 -06:00
|
|
|
const struct sram_channel *ch)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(ch->pix_frmt, PIXEL_FRMT_422);
|
|
|
|
cx_write(ch->vip_ctl, PIXEL_ENGINE_VIP1);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cx25821_initialize(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int i;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
dprintk(1, "%s()\n", __func__);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_shutdown(dev);
|
|
|
|
cx_write(PCI_INT_STAT, 0xffffffff);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < VID_CHANNEL_NUM; i++)
|
2010-09-27 07:01:36 -06:00
|
|
|
cx_write(dev->channels[i].sram_channels->int_stat, 0xffffffff);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(AUD_A_INT_STAT, 0xffffffff);
|
|
|
|
cx_write(AUD_B_INT_STAT, 0xffffffff);
|
|
|
|
cx_write(AUD_C_INT_STAT, 0xffffffff);
|
|
|
|
cx_write(AUD_D_INT_STAT, 0xffffffff);
|
|
|
|
cx_write(AUD_E_INT_STAT, 0xffffffff);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(CLK_DELAY, cx_read(CLK_DELAY) & 0x80000000);
|
2010-03-21 11:18:19 -06:00
|
|
|
cx_write(PAD_CTRL, 0x12); /* for I2C */
|
|
|
|
cx25821_registers_init(dev); /* init Pecos registers */
|
2009-09-13 08:30:11 -06:00
|
|
|
mdelay(100);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < VID_CHANNEL_NUM; i++) {
|
2010-09-27 07:01:36 -06:00
|
|
|
cx25821_set_vip_mode(dev, dev->channels[i].sram_channels);
|
|
|
|
cx25821_sram_channel_setup(dev, dev->channels[i].sram_channels,
|
|
|
|
1440, 0);
|
|
|
|
dev->channels[i].pixel_formats = PIXEL_FRMT_422;
|
2013-04-14 08:13:43 -06:00
|
|
|
dev->channels[i].use_cif_resolution = 0;
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
/* Probably only affect Downstream */
|
2010-09-27 07:01:36 -06:00
|
|
|
for (i = VID_UPSTREAM_SRAM_CHANNEL_I;
|
|
|
|
i <= VID_UPSTREAM_SRAM_CHANNEL_J; i++) {
|
|
|
|
cx25821_set_vip_mode(dev, dev->channels[i].sram_channels);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-09-27 07:01:36 -06:00
|
|
|
cx25821_sram_channel_setup_audio(dev,
|
2011-10-21 22:43:33 -06:00
|
|
|
dev->channels[SRAM_CH08].sram_channels, 128, 0);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_gpio_init(dev);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2010-03-24 13:33:40 -06:00
|
|
|
static int cx25821_get_resources(struct cx25821_dev *dev)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2011-10-21 22:43:33 -06:00
|
|
|
if (request_mem_region(pci_resource_start(dev->pci, 0),
|
|
|
|
pci_resource_len(dev->pci, 0), dev->name))
|
2009-09-13 08:30:11 -06:00
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_err("%s: can't get MMIO memory @ 0x%llx\n",
|
2011-10-21 22:43:32 -06:00
|
|
|
dev->name, (unsigned long long)pci_resource_start(dev->pci, 0));
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
return -EBUSY;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cx25821_dev_checkrevision(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
dev->hwrevision = cx_read(RDR_CFG2) & 0xff;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2013-04-13 05:18:00 -06:00
|
|
|
pr_info("Hardware revision = 0x%02x\n", dev->hwrevision);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void cx25821_iounmap(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
if (dev == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Releasing IO memory */
|
|
|
|
if (dev->lmmio != NULL) {
|
|
|
|
iounmap(dev->lmmio);
|
|
|
|
dev->lmmio = NULL;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static int cx25821_dev_setup(struct cx25821_dev *dev)
|
2009-09-13 08:25:45 -06:00
|
|
|
{
|
2013-04-13 04:07:40 -06:00
|
|
|
static unsigned int cx25821_devcount;
|
2012-04-20 03:26:19 -06:00
|
|
|
int i;
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
mutex_init(&dev->lock);
|
|
|
|
|
|
|
|
dev->nr = ++cx25821_devcount;
|
|
|
|
sprintf(dev->name, "cx25821[%d]", dev->nr);
|
|
|
|
|
|
|
|
if (dev->pci->device != 0x8210) {
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("%s(): Exiting. Incorrect Hardware device = 0x%02x\n",
|
|
|
|
__func__, dev->pci->device);
|
2009-09-13 08:30:11 -06:00
|
|
|
return -1;
|
|
|
|
} else {
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("Athena Hardware device = 0x%02x\n", dev->pci->device);
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* Apply a sensible clock frequency for the PCIe bridge */
|
|
|
|
dev->clk_freq = 28000000;
|
2013-04-13 05:38:14 -06:00
|
|
|
for (i = 0; i < MAX_VID_CHANNEL_NUM; i++) {
|
|
|
|
dev->channels[i].dev = dev;
|
|
|
|
dev->channels[i].id = i;
|
2010-09-27 07:01:36 -06:00
|
|
|
dev->channels[i].sram_channels = &cx25821_sram_channels[i];
|
2013-04-13 05:38:14 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
if (dev->nr > 1)
|
2009-09-13 08:30:11 -06:00
|
|
|
CX25821_INFO("dev->nr > 1!");
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* board config */
|
2010-03-21 11:18:19 -06:00
|
|
|
dev->board = 1; /* card[dev->nr]; */
|
2009-09-13 08:30:11 -06:00
|
|
|
dev->_max_num_decoders = MAX_DECODERS;
|
|
|
|
|
|
|
|
dev->pci_bus = dev->pci->bus->number;
|
|
|
|
dev->pci_slot = PCI_SLOT(dev->pci->devfn);
|
|
|
|
dev->pci_irqmask = 0x001f00;
|
|
|
|
|
|
|
|
/* External Master 1 Bus */
|
|
|
|
dev->i2c_bus[0].nr = 0;
|
|
|
|
dev->i2c_bus[0].dev = dev;
|
|
|
|
dev->i2c_bus[0].reg_stat = I2C1_STAT;
|
|
|
|
dev->i2c_bus[0].reg_ctrl = I2C1_CTRL;
|
|
|
|
dev->i2c_bus[0].reg_addr = I2C1_ADDR;
|
|
|
|
dev->i2c_bus[0].reg_rdata = I2C1_RDATA;
|
|
|
|
dev->i2c_bus[0].reg_wdata = I2C1_WDATA;
|
|
|
|
dev->i2c_bus[0].i2c_period = (0x07 << 24); /* 1.95MHz */
|
|
|
|
|
2010-03-24 13:33:40 -06:00
|
|
|
if (cx25821_get_resources(dev) < 0) {
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_err("%s: No more PCIe resources for subsystem: %04x:%04x\n",
|
2009-09-13 08:30:11 -06:00
|
|
|
dev->name, dev->pci->subsystem_vendor,
|
|
|
|
dev->pci->subsystem_device);
|
|
|
|
|
|
|
|
cx25821_devcount--;
|
2010-08-06 13:52:57 -06:00
|
|
|
return -EBUSY;
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* PCIe stuff */
|
|
|
|
dev->base_io_addr = pci_resource_start(dev->pci, 0);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (!dev->base_io_addr) {
|
|
|
|
CX25821_ERR("No PCI Memory resources, exiting!\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
dev->lmmio = ioremap(dev->base_io_addr, pci_resource_len(dev->pci, 0));
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (!dev->lmmio) {
|
2011-10-21 22:43:33 -06:00
|
|
|
CX25821_ERR("ioremap failed, maybe increasing __VMALLOC_RESERVE in page.h\n");
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_iounmap(dev);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
dev->bmmio = (u8 __iomem *) dev->lmmio;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("%s: subsystem: %04x:%04x, board: %s [card=%d,%s]\n",
|
|
|
|
dev->name, dev->pci->subsystem_vendor,
|
|
|
|
dev->pci->subsystem_device, cx25821_boards[dev->board].name,
|
|
|
|
dev->board, card[dev->nr] == dev->board ?
|
|
|
|
"insmod option" : "autodetected");
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* init hardware */
|
|
|
|
cx25821_initialize(dev);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_i2c_register(&dev->i2c_bus[0]);
|
2010-03-21 11:18:19 -06:00
|
|
|
/* cx25821_i2c_register(&dev->i2c_bus[1]);
|
|
|
|
* cx25821_i2c_register(&dev->i2c_bus[2]); */
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-09-27 07:01:36 -06:00
|
|
|
if (medusa_video_init(dev) < 0)
|
2010-11-07 13:48:21 -07:00
|
|
|
CX25821_ERR("%s(): Failed to initialize medusa!\n", __func__);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-09-27 07:01:36 -06:00
|
|
|
cx25821_video_register(dev);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_dev_checkrevision(dev);
|
|
|
|
return 0;
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
|
|
|
void cx25821_dev_unregister(struct cx25821_dev *dev)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
int i;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (!dev->base_io_addr)
|
|
|
|
return;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_free_mem_upstream_audio(dev);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
release_mem_region(dev->base_io_addr, pci_resource_len(dev->pci, 0));
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2013-04-14 08:07:02 -06:00
|
|
|
for (i = 0; i < MAX_VID_CHANNEL_NUM - 1; i++) {
|
|
|
|
if (i == SRAM_CH08) /* audio channel */
|
|
|
|
continue;
|
2013-04-14 09:10:32 -06:00
|
|
|
if (i == SRAM_CH09 || i == SRAM_CH10)
|
|
|
|
cx25821_free_mem_upstream(&dev->channels[i]);
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_video_unregister(dev, i);
|
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_i2c_unregister(&dev->i2c_bus[0]);
|
|
|
|
cx25821_iounmap(dev);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_dev_unregister);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
static __le32 *cx25821_risc_field(__le32 * rp, struct scatterlist *sglist,
|
|
|
|
unsigned int offset, u32 sync_line,
|
|
|
|
unsigned int bpl, unsigned int padding,
|
|
|
|
unsigned int lines)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct scatterlist *sg;
|
|
|
|
unsigned int line, todo;
|
|
|
|
|
|
|
|
/* sync instruction */
|
2010-03-21 11:18:19 -06:00
|
|
|
if (sync_line != NO_SYNC_LINE)
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* scan lines */
|
|
|
|
sg = sglist;
|
|
|
|
for (line = 0; line < lines; line++) {
|
|
|
|
while (offset && offset >= sg_dma_len(sg)) {
|
|
|
|
offset -= sg_dma_len(sg);
|
|
|
|
sg++;
|
|
|
|
}
|
|
|
|
if (bpl <= sg_dma_len(sg) - offset) {
|
|
|
|
/* fits into current chunk */
|
2011-10-21 22:43:33 -06:00
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE | RISC_SOL | RISC_EOL |
|
|
|
|
bpl);
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
offset += bpl;
|
|
|
|
} else {
|
|
|
|
/* scanline needs to be split */
|
|
|
|
todo = bpl;
|
2011-10-21 22:43:33 -06:00
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE | RISC_SOL |
|
2009-09-13 08:30:11 -06:00
|
|
|
(sg_dma_len(sg) - offset));
|
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
todo -= (sg_dma_len(sg) - offset);
|
|
|
|
offset = 0;
|
|
|
|
sg++;
|
|
|
|
while (todo > sg_dma_len(sg)) {
|
2011-10-21 22:43:33 -06:00
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE |
|
|
|
|
sg_dma_len(sg));
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg));
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
todo -= sg_dma_len(sg);
|
|
|
|
sg++;
|
|
|
|
}
|
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo);
|
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg));
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
offset += todo;
|
|
|
|
}
|
|
|
|
|
|
|
|
offset += padding;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
return rp;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int cx25821_risc_buffer(struct pci_dev *pci, struct btcx_riscmem *risc,
|
2009-09-13 08:30:11 -06:00
|
|
|
struct scatterlist *sglist, unsigned int top_offset,
|
|
|
|
unsigned int bottom_offset, unsigned int bpl,
|
|
|
|
unsigned int padding, unsigned int lines)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
u32 instructions;
|
|
|
|
u32 fields;
|
|
|
|
__le32 *rp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
fields = 0;
|
|
|
|
if (UNSET != top_offset)
|
|
|
|
fields++;
|
|
|
|
if (UNSET != bottom_offset)
|
|
|
|
fields++;
|
|
|
|
|
|
|
|
/* estimate risc mem: worst case is one write per page border +
|
|
|
|
one write per scan line + syncs + jump (all 2 dwords). Padding
|
|
|
|
can cause next bpl to start close to a page border. First DMA
|
|
|
|
region may be smaller than PAGE_SIZE */
|
|
|
|
/* write and jump need and extra dword */
|
2011-10-21 22:43:33 -06:00
|
|
|
instructions = fields * (1 + ((bpl + padding) * lines) / PAGE_SIZE +
|
|
|
|
lines);
|
2009-09-13 08:30:11 -06:00
|
|
|
instructions += 2;
|
|
|
|
rc = btcx_riscmem_alloc(pci, risc, instructions * 12);
|
|
|
|
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* write risc instructions */
|
|
|
|
rp = risc->cpu;
|
|
|
|
|
|
|
|
if (UNSET != top_offset) {
|
|
|
|
rp = cx25821_risc_field(rp, sglist, top_offset, 0, bpl, padding,
|
|
|
|
lines);
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (UNSET != bottom_offset) {
|
|
|
|
rp = cx25821_risc_field(rp, sglist, bottom_offset, 0x200, bpl,
|
|
|
|
padding, lines);
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* save pointer to jmp instruction address */
|
|
|
|
risc->jmp = rp;
|
|
|
|
BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static __le32 *cx25821_risc_field_audio(__le32 * rp, struct scatterlist *sglist,
|
|
|
|
unsigned int offset, u32 sync_line,
|
|
|
|
unsigned int bpl, unsigned int padding,
|
|
|
|
unsigned int lines, unsigned int lpi)
|
|
|
|
{
|
|
|
|
struct scatterlist *sg;
|
|
|
|
unsigned int line, todo, sol;
|
|
|
|
|
|
|
|
/* sync instruction */
|
|
|
|
if (sync_line != NO_SYNC_LINE)
|
|
|
|
*(rp++) = cpu_to_le32(RISC_RESYNC | sync_line);
|
|
|
|
|
|
|
|
/* scan lines */
|
|
|
|
sg = sglist;
|
|
|
|
for (line = 0; line < lines; line++) {
|
|
|
|
while (offset && offset >= sg_dma_len(sg)) {
|
|
|
|
offset -= sg_dma_len(sg);
|
|
|
|
sg++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lpi && line > 0 && !(line % lpi))
|
|
|
|
sol = RISC_SOL | RISC_IRQ1 | RISC_CNT_INC;
|
|
|
|
else
|
|
|
|
sol = RISC_SOL;
|
|
|
|
|
|
|
|
if (bpl <= sg_dma_len(sg) - offset) {
|
|
|
|
/* fits into current chunk */
|
2011-10-21 22:43:33 -06:00
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE | sol | RISC_EOL |
|
|
|
|
bpl);
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
offset += bpl;
|
|
|
|
} else {
|
|
|
|
/* scanline needs to be split */
|
|
|
|
todo = bpl;
|
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE | sol |
|
2011-10-21 22:43:32 -06:00
|
|
|
(sg_dma_len(sg) - offset));
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg) + offset);
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
todo -= (sg_dma_len(sg) - offset);
|
|
|
|
offset = 0;
|
|
|
|
sg++;
|
|
|
|
while (todo > sg_dma_len(sg)) {
|
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE |
|
2011-10-21 22:43:32 -06:00
|
|
|
sg_dma_len(sg));
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg));
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
todo -= sg_dma_len(sg);
|
|
|
|
sg++;
|
|
|
|
}
|
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITE | RISC_EOL | todo);
|
|
|
|
*(rp++) = cpu_to_le32(sg_dma_address(sg));
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
offset += todo;
|
|
|
|
}
|
|
|
|
offset += padding;
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
return rp;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int cx25821_risc_databuffer_audio(struct pci_dev *pci,
|
2009-09-13 08:30:11 -06:00
|
|
|
struct btcx_riscmem *risc,
|
|
|
|
struct scatterlist *sglist,
|
|
|
|
unsigned int bpl,
|
|
|
|
unsigned int lines, unsigned int lpi)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
u32 instructions;
|
|
|
|
__le32 *rp;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
/* estimate risc mem: worst case is one write per page border +
|
|
|
|
one write per scan line + syncs + jump (all 2 dwords). Here
|
|
|
|
there is no padding and no sync. First DMA region may be smaller
|
|
|
|
than PAGE_SIZE */
|
|
|
|
/* Jump and write need an extra dword */
|
|
|
|
instructions = 1 + (bpl * lines) / PAGE_SIZE + lines;
|
|
|
|
instructions += 1;
|
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
rc = btcx_riscmem_alloc(pci, risc, instructions * 12);
|
|
|
|
if (rc < 0)
|
2009-09-13 08:30:11 -06:00
|
|
|
return rc;
|
|
|
|
|
|
|
|
/* write risc instructions */
|
|
|
|
rp = risc->cpu;
|
|
|
|
rp = cx25821_risc_field_audio(rp, sglist, 0, NO_SYNC_LINE, bpl, 0,
|
|
|
|
lines, lpi);
|
|
|
|
|
|
|
|
/* save pointer to jmp instruction address */
|
|
|
|
risc->jmp = rp;
|
|
|
|
BUG_ON((risc->jmp - risc->cpu + 2) * sizeof(*risc->cpu) > risc->size);
|
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_risc_databuffer_audio);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
int cx25821_risc_stopper(struct pci_dev *pci, struct btcx_riscmem *risc,
|
|
|
|
u32 reg, u32 mask, u32 value)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
__le32 *rp;
|
|
|
|
int rc;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
rc = btcx_riscmem_alloc(pci, risc, 4 * 16);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* write risc instructions */
|
|
|
|
rp = risc->cpu;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
*(rp++) = cpu_to_le32(RISC_WRITECR | RISC_IRQ1);
|
|
|
|
*(rp++) = cpu_to_le32(reg);
|
|
|
|
*(rp++) = cpu_to_le32(value);
|
|
|
|
*(rp++) = cpu_to_le32(mask);
|
|
|
|
*(rp++) = cpu_to_le32(RISC_JUMP);
|
|
|
|
*(rp++) = cpu_to_le32(risc->dma);
|
|
|
|
*(rp++) = cpu_to_le32(0); /* bits 63-32 */
|
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void cx25821_free_buffer(struct videobuf_queue *q, struct cx25821_buffer *buf)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct videobuf_dmabuf *dma = videobuf_to_dma(&buf->vb);
|
|
|
|
|
|
|
|
BUG_ON(in_interrupt());
|
2010-09-26 06:01:26 -06:00
|
|
|
videobuf_waiton(q, &buf->vb, 0, 0);
|
2010-05-11 07:36:30 -06:00
|
|
|
videobuf_dma_unmap(q->dev, dma);
|
2009-09-13 08:30:11 -06:00
|
|
|
videobuf_dma_free(dma);
|
|
|
|
btcx_riscmem_free(to_pci_dev(q->dev), &buf->risc);
|
|
|
|
buf->vb.state = VIDEOBUF_NEEDS_INIT;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t cx25821_irq(int irq, void *dev_id)
|
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct cx25821_dev *dev = dev_id;
|
2012-04-20 03:26:19 -06:00
|
|
|
u32 pci_status;
|
2009-09-13 08:30:11 -06:00
|
|
|
u32 vid_status;
|
|
|
|
int i, handled = 0;
|
|
|
|
u32 mask[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
pci_status = cx_read(PCI_INT_STAT);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (pci_status == 0)
|
|
|
|
goto out;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
for (i = 0; i < VID_CHANNEL_NUM; i++) {
|
|
|
|
if (pci_status & mask[i]) {
|
2010-09-27 07:01:36 -06:00
|
|
|
vid_status = cx_read(dev->channels[i].
|
|
|
|
sram_channels->int_stat);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (vid_status)
|
2011-10-21 22:43:33 -06:00
|
|
|
handled += cx25821_video_irq(dev, i,
|
|
|
|
vid_status);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx_write(PCI_INT_STAT, mask[i]);
|
|
|
|
}
|
2009-09-13 08:25:45 -06:00
|
|
|
}
|
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
out:
|
2009-09-13 08:30:11 -06:00
|
|
|
return IRQ_RETVAL(handled);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void cx25821_print_irqbits(char *name, char *tag, char **strings,
|
2009-09-13 08:25:45 -06:00
|
|
|
int len, u32 bits, u32 mask)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
unsigned int i;
|
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
printk(KERN_DEBUG pr_fmt("%s: %s [0x%x]"), name, tag, bits);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
if (!(bits & (1 << i)))
|
|
|
|
continue;
|
|
|
|
if (strings[i])
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont(" %s", strings[i]);
|
2009-09-13 08:30:11 -06:00
|
|
|
else
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont(" %d", i);
|
2009-09-13 08:30:11 -06:00
|
|
|
if (!(mask & (1 << i)))
|
|
|
|
continue;
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont("*");
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_cont("\n");
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_print_irqbits);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
struct cx25821_dev *cx25821_dev_get(struct pci_dev *pci)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct cx25821_dev *dev = pci_get_drvdata(pci);
|
|
|
|
return dev;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
2010-03-21 11:18:19 -06:00
|
|
|
EXPORT_SYMBOL(cx25821_dev_get);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2012-12-21 14:17:53 -07:00
|
|
|
static int cx25821_initdev(struct pci_dev *pci_dev,
|
|
|
|
const struct pci_device_id *pci_id)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct cx25821_dev *dev;
|
|
|
|
int err = 0;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
|
|
|
|
if (NULL == dev)
|
|
|
|
return -ENOMEM;
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
err = v4l2_device_register(&pci_dev->dev, &dev->v4l2_dev);
|
|
|
|
if (err < 0)
|
|
|
|
goto fail_free;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* pci init */
|
|
|
|
dev->pci = pci_dev;
|
|
|
|
if (pci_enable_device(pci_dev)) {
|
|
|
|
err = -EIO;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("pci enable failed!\n");
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
goto fail_unregister_device;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-08-06 13:52:57 -06:00
|
|
|
err = cx25821_dev_setup(dev);
|
|
|
|
if (err) {
|
|
|
|
if (err == -EBUSY)
|
|
|
|
goto fail_unregister_device;
|
|
|
|
else
|
|
|
|
goto fail_unregister_pci;
|
2009-09-13 08:30:11 -06:00
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* print pci info */
|
|
|
|
pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &dev->pci_rev);
|
|
|
|
pci_read_config_byte(pci_dev, PCI_LATENCY_TIMER, &dev->pci_lat);
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("%s/0: found at %s, rev: %d, irq: %d, latency: %d, mmio: 0x%llx\n",
|
|
|
|
dev->name, pci_name(pci_dev), dev->pci_rev, pci_dev->irq,
|
|
|
|
dev->pci_lat, (unsigned long long)dev->base_io_addr);
|
2009-09-13 08:30:11 -06:00
|
|
|
|
|
|
|
pci_set_master(pci_dev);
|
|
|
|
if (!pci_dma_supported(pci_dev, 0xffffffff)) {
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_err("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
|
2009-09-13 08:30:11 -06:00
|
|
|
err = -EIO;
|
|
|
|
goto fail_irq;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2011-10-21 22:43:33 -06:00
|
|
|
err = request_irq(pci_dev->irq, cx25821_irq,
|
|
|
|
IRQF_SHARED, dev->name, dev);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
if (err < 0) {
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_err("%s: can't get IRQ %d\n", dev->name, pci_dev->irq);
|
2009-09-13 08:30:11 -06:00
|
|
|
goto fail_irq;
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
return 0;
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
fail_irq:
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("cx25821_initdev() can't get IRQ !\n");
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_dev_unregister(dev);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-08-06 13:52:57 -06:00
|
|
|
fail_unregister_pci:
|
|
|
|
pci_disable_device(pci_dev);
|
2010-03-21 11:18:19 -06:00
|
|
|
fail_unregister_device:
|
2009-09-13 08:30:11 -06:00
|
|
|
v4l2_device_unregister(&dev->v4l2_dev);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2010-03-21 11:18:19 -06:00
|
|
|
fail_free:
|
2009-09-13 08:30:11 -06:00
|
|
|
kfree(dev);
|
|
|
|
return err;
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2012-12-21 14:17:53 -07:00
|
|
|
static void cx25821_finidev(struct pci_dev *pci_dev)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
struct v4l2_device *v4l2_dev = pci_get_drvdata(pci_dev);
|
|
|
|
struct cx25821_dev *dev = get_cx25821(v4l2_dev);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_shutdown(dev);
|
|
|
|
pci_disable_device(pci_dev);
|
2009-09-15 08:33:54 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
/* unregister stuff */
|
|
|
|
if (pci_dev->irq)
|
|
|
|
free_irq(pci_dev->irq, dev);
|
2009-09-13 08:25:45 -06:00
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
cx25821_dev_unregister(dev);
|
|
|
|
v4l2_device_unregister(v4l2_dev);
|
|
|
|
kfree(dev);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2011-09-01 21:55:33 -06:00
|
|
|
static DEFINE_PCI_DEVICE_TABLE(cx25821_pci_tbl) = {
|
2009-09-13 08:30:11 -06:00
|
|
|
{
|
2011-09-01 21:55:35 -06:00
|
|
|
/* CX25821 Athena */
|
|
|
|
.vendor = 0x14f1,
|
|
|
|
.device = 0x8210,
|
|
|
|
.subvendor = 0x14f1,
|
|
|
|
.subdevice = 0x0920,
|
2012-02-24 10:49:42 -07:00
|
|
|
}, {
|
|
|
|
/* CX25821 No Brand */
|
|
|
|
.vendor = 0x14f1,
|
|
|
|
.device = 0x8210,
|
|
|
|
.subvendor = 0x0000,
|
|
|
|
.subdevice = 0x0000,
|
|
|
|
}, {
|
2011-09-01 21:55:35 -06:00
|
|
|
/* --- end of list --- */
|
|
|
|
}
|
2009-09-15 08:33:54 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(pci, cx25821_pci_tbl);
|
|
|
|
|
2009-09-13 08:30:11 -06:00
|
|
|
static struct pci_driver cx25821_pci_driver = {
|
|
|
|
.name = "cx25821",
|
|
|
|
.id_table = cx25821_pci_tbl,
|
|
|
|
.probe = cx25821_initdev,
|
2012-12-21 14:17:53 -07:00
|
|
|
.remove = cx25821_finidev,
|
2009-09-13 08:30:11 -06:00
|
|
|
/* TODO */
|
|
|
|
.suspend = NULL,
|
|
|
|
.resume = NULL,
|
2009-09-15 08:33:54 -06:00
|
|
|
};
|
|
|
|
|
2009-09-28 17:40:59 -06:00
|
|
|
static int __init cx25821_init(void)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2010-11-07 13:48:21 -07:00
|
|
|
pr_info("driver version %d.%d.%d loaded\n",
|
|
|
|
(CX25821_VERSION_CODE >> 16) & 0xff,
|
|
|
|
(CX25821_VERSION_CODE >> 8) & 0xff,
|
|
|
|
CX25821_VERSION_CODE & 0xff);
|
2009-09-13 08:30:11 -06:00
|
|
|
return pci_register_driver(&cx25821_pci_driver);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
2009-09-28 17:40:59 -06:00
|
|
|
static void __exit cx25821_fini(void)
|
2009-09-15 08:33:54 -06:00
|
|
|
{
|
2009-09-13 08:30:11 -06:00
|
|
|
pci_unregister_driver(&cx25821_pci_driver);
|
2009-09-15 08:33:54 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
module_init(cx25821_init);
|
|
|
|
module_exit(cx25821_fini);
|