diff options
author | Abylay Ospan <aospan@netup.ru> | 2009-03-03 08:55:38 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2009-03-30 11:43:04 -0400 |
commit | c253a17126d6e841720d5926c6d426745693676b (patch) | |
tree | 5f5a8a91c95e85e6ae7a228b3f1041df2e3dade3 | |
parent | 9cfb6a3f1b16e82fab97831265858aa2d1983883 (diff) |
V4L/DVB (10796): Add init code for NetUP Dual DVB-S2 CI card
Add init code for NetUP Dual DVB-S2 CI card
The card based on cx23885 PCI-e bridge, CiMax SP2 Common Interface chips,
STM lnbh24 LNB power chip, stv6110 tuners and stv0900 demodulator.
Signed-off-by: Abylay Ospan <aospan@netup.ru>
Signed-off-by: Igor M. Liplianin <liplianin@netup.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r-- | drivers/media/video/cx23885/netup-init.c | 125 | ||||
-rw-r--r-- | drivers/media/video/cx23885/netup-init.h | 25 |
2 files changed, 150 insertions, 0 deletions
diff --git a/drivers/media/video/cx23885/netup-init.c b/drivers/media/video/cx23885/netup-init.c new file mode 100644 index 000000000000..f4893e69cd89 --- /dev/null +++ b/drivers/media/video/cx23885/netup-init.c | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * netup-init.c | ||
3 | * | ||
4 | * NetUP Dual DVB-S2 CI driver | ||
5 | * | ||
6 | * Copyright (C) 2009 NetUP Inc. | ||
7 | * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru> | ||
8 | * Copyright (C) 2009 Abylay Ospan <aospan@netup.ru> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | */ | ||
25 | |||
26 | #include "cx23885.h" | ||
27 | |||
28 | static void i2c_av_write(struct i2c_adapter *i2c, u16 reg, u8 val) | ||
29 | { | ||
30 | int ret; | ||
31 | u8 buf[3]; | ||
32 | struct i2c_msg msg = { | ||
33 | .addr = 0x88 >> 1, | ||
34 | .flags = 0, | ||
35 | .buf = buf, | ||
36 | .len = 3 | ||
37 | }; | ||
38 | |||
39 | buf[0] = reg >> 8; | ||
40 | buf[1] = reg & 0xff; | ||
41 | buf[2] = val; | ||
42 | |||
43 | ret = i2c_transfer(i2c, &msg, 1); | ||
44 | |||
45 | if (ret != 1) | ||
46 | printk(KERN_ERR "%s: i2c write error!\n", __func__); | ||
47 | } | ||
48 | |||
49 | static void i2c_av_write4(struct i2c_adapter *i2c, u16 reg, u32 val) | ||
50 | { | ||
51 | int ret; | ||
52 | u8 buf[6]; | ||
53 | struct i2c_msg msg = { | ||
54 | .addr = 0x88 >> 1, | ||
55 | .flags = 0, | ||
56 | .buf = buf, | ||
57 | .len = 6 | ||
58 | }; | ||
59 | |||
60 | buf[0] = reg >> 8; | ||
61 | buf[1] = reg & 0xff; | ||
62 | buf[2] = val & 0xff; | ||
63 | buf[3] = (val >> 8) & 0xff; | ||
64 | buf[4] = (val >> 16) & 0xff; | ||
65 | buf[5] = val >> 24; | ||
66 | |||
67 | ret = i2c_transfer(i2c, &msg, 1); | ||
68 | |||
69 | if (ret != 1) | ||
70 | printk(KERN_ERR "%s: i2c write error!\n", __func__); | ||
71 | } | ||
72 | |||
73 | static u8 i2c_av_read(struct i2c_adapter *i2c, u16 reg) | ||
74 | { | ||
75 | int ret; | ||
76 | u8 buf[2]; | ||
77 | struct i2c_msg msg = { | ||
78 | .addr = 0x88 >> 1, | ||
79 | .flags = 0, | ||
80 | .buf = buf, | ||
81 | .len = 2 | ||
82 | }; | ||
83 | |||
84 | buf[0] = reg >> 8; | ||
85 | buf[1] = reg & 0xff; | ||
86 | |||
87 | ret = i2c_transfer(i2c, &msg, 1); | ||
88 | |||
89 | if (ret != 1) | ||
90 | printk(KERN_ERR "%s: i2c write error!\n", __func__); | ||
91 | |||
92 | msg.flags = I2C_M_RD; | ||
93 | msg.len = 1; | ||
94 | |||
95 | ret = i2c_transfer(i2c, &msg, 1); | ||
96 | |||
97 | if (ret != 1) | ||
98 | printk(KERN_ERR "%s: i2c read error!\n", __func__); | ||
99 | |||
100 | return buf[0]; | ||
101 | } | ||
102 | |||
103 | static void i2c_av_and_or(struct i2c_adapter *i2c, u16 reg, unsigned and_mask, | ||
104 | u8 or_value) | ||
105 | { | ||
106 | i2c_av_write(i2c, reg, (i2c_av_read(i2c, reg) & and_mask) | or_value); | ||
107 | } | ||
108 | /* set 27MHz on AUX_CLK */ | ||
109 | void netup_initialize(struct cx23885_dev *dev) | ||
110 | { | ||
111 | struct cx23885_i2c *i2c_bus = &dev->i2c_bus[2]; | ||
112 | struct i2c_adapter *i2c = &i2c_bus->i2c_adap; | ||
113 | |||
114 | /* Stop microcontroller */ | ||
115 | i2c_av_and_or(i2c, 0x803, ~0x10, 0x00); | ||
116 | |||
117 | /* Aux PLL frac for 27 MHz */ | ||
118 | i2c_av_write4(i2c, 0x114, 0xea0eb3); | ||
119 | |||
120 | /* Aux PLL int for 27 MHz */ | ||
121 | i2c_av_write4(i2c, 0x110, 0x090319); | ||
122 | |||
123 | /* start microcontroller */ | ||
124 | i2c_av_and_or(i2c, 0x803, ~0x10, 0x10); | ||
125 | } | ||
diff --git a/drivers/media/video/cx23885/netup-init.h b/drivers/media/video/cx23885/netup-init.h new file mode 100644 index 000000000000..d26ae4b1590e --- /dev/null +++ b/drivers/media/video/cx23885/netup-init.h | |||
@@ -0,0 +1,25 @@ | |||
1 | /* | ||
2 | * netup-init.h | ||
3 | * | ||
4 | * NetUP Dual DVB-S2 CI driver | ||
5 | * | ||
6 | * Copyright (C) 2009 NetUP Inc. | ||
7 | * Copyright (C) 2009 Igor M. Liplianin <liplianin@netup.ru> | ||
8 | * Copyright (C) 2009 Abylay Ospan <aospan@netup.ru> | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or modify | ||
11 | * it under the terms of the GNU General Public License as published by | ||
12 | * the Free Software Foundation; either version 2 of the License, or | ||
13 | * (at your option) any later version. | ||
14 | * | ||
15 | * This program is distributed in the hope that it will be useful, | ||
16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
18 | * | ||
19 | * GNU General Public License for more details. | ||
20 | * | ||
21 | * You should have received a copy of the GNU General Public License | ||
22 | * along with this program; if not, write to the Free Software | ||
23 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
24 | */ | ||
25 | extern void netup_initialize(struct cx23885_dev *dev); | ||