diff options
author | Andrew de Quincey <adq_dvb@lidskialf.net> | 2006-04-27 20:45:09 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-06-25 00:59:44 -0400 |
commit | 21c2858235a81ce4fa1862432eb0c98d8dbdee1e (patch) | |
tree | 7a06d90877c8379bb373b15f916d8f591c5df7ec /drivers | |
parent | d020542fdaaa69e3061e15d096f11fbc4aeeb93f (diff) |
V4L/DVB (3933): Add isl6421 module
Driver for the ISL6421 LNB chip
Signed-off-by: Andrew de Quincey <adq_dvb@lidskialf.net>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/frontends/Kconfig | 6 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/Makefile | 1 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/isl6421.c | 149 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/isl6421.h | 46 |
4 files changed, 202 insertions, 0 deletions
diff --git a/drivers/media/dvb/frontends/Kconfig b/drivers/media/dvb/frontends/Kconfig index 64cd63623b0b..0ef361f0309b 100644 --- a/drivers/media/dvb/frontends/Kconfig +++ b/drivers/media/dvb/frontends/Kconfig | |||
@@ -226,4 +226,10 @@ config DVB_LNBP21 | |||
226 | help | 226 | help |
227 | An SEC control chip. | 227 | An SEC control chip. |
228 | 228 | ||
229 | config DVB_ISL6421 | ||
230 | tristate "ISL6421 SEC controller" | ||
231 | depends on DVB_CORE | ||
232 | help | ||
233 | An SEC control chip. | ||
234 | |||
229 | endmenu | 235 | endmenu |
diff --git a/drivers/media/dvb/frontends/Makefile b/drivers/media/dvb/frontends/Makefile index 7238e6ef2f22..5222245c7f59 100644 --- a/drivers/media/dvb/frontends/Makefile +++ b/drivers/media/dvb/frontends/Makefile | |||
@@ -32,3 +32,4 @@ obj-$(CONFIG_DVB_S5H1420) += s5h1420.o | |||
32 | obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o | 32 | obj-$(CONFIG_DVB_LGDT330X) += lgdt330x.o |
33 | obj-$(CONFIG_DVB_CX24123) += cx24123.o | 33 | obj-$(CONFIG_DVB_CX24123) += cx24123.o |
34 | obj-$(CONFIG_DVB_LNBP21) += lnbp21.o | 34 | obj-$(CONFIG_DVB_LNBP21) += lnbp21.o |
35 | obj-$(CONFIG_DVB_ISL6421) += isl6421.o | ||
diff --git a/drivers/media/dvb/frontends/isl6421.c b/drivers/media/dvb/frontends/isl6421.c new file mode 100644 index 000000000000..36992077aaf0 --- /dev/null +++ b/drivers/media/dvb/frontends/isl6421.c | |||
@@ -0,0 +1,149 @@ | |||
1 | /* | ||
2 | * isl6421.h - driver for lnb supply and control ic ISL6421 | ||
3 | * | ||
4 | * Copyright (C) 2006 Andrew de Quincey | ||
5 | * Copyright (C) 2006 Oliver Endriss | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html | ||
23 | * | ||
24 | * | ||
25 | * the project's page is at http://www.linuxtv.org | ||
26 | */ | ||
27 | #include <linux/delay.h> | ||
28 | #include <linux/errno.h> | ||
29 | #include <linux/init.h> | ||
30 | #include <linux/kernel.h> | ||
31 | #include <linux/module.h> | ||
32 | #include <linux/moduleparam.h> | ||
33 | #include <linux/string.h> | ||
34 | #include <linux/slab.h> | ||
35 | |||
36 | #include "dvb_frontend.h" | ||
37 | #include "isl6421.h" | ||
38 | |||
39 | struct isl6421 { | ||
40 | u8 config; | ||
41 | u8 override_or; | ||
42 | u8 override_and; | ||
43 | struct i2c_adapter *i2c; | ||
44 | u8 i2c_addr; | ||
45 | void (*release_chain)(struct dvb_frontend* fe); | ||
46 | }; | ||
47 | |||
48 | static int isl6421_set_voltage(struct dvb_frontend *fe, fe_sec_voltage_t voltage) | ||
49 | { | ||
50 | struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; | ||
51 | struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, | ||
52 | .buf = &isl6421->config, | ||
53 | .len = sizeof(isl6421->config) }; | ||
54 | |||
55 | isl6421->config &= ~(ISL6421_VSEL1 | ISL6421_EN1); | ||
56 | |||
57 | switch(voltage) { | ||
58 | case SEC_VOLTAGE_OFF: | ||
59 | break; | ||
60 | case SEC_VOLTAGE_13: | ||
61 | isl6421->config |= ISL6421_EN1; | ||
62 | break; | ||
63 | case SEC_VOLTAGE_18: | ||
64 | isl6421->config |= (ISL6421_EN1 | ISL6421_VSEL1); | ||
65 | break; | ||
66 | default: | ||
67 | return -EINVAL; | ||
68 | }; | ||
69 | |||
70 | isl6421->config |= isl6421->override_or; | ||
71 | isl6421->config &= isl6421->override_and; | ||
72 | |||
73 | return (i2c_transfer(isl6421->i2c, &msg, 1) == 1) ? 0 : -EIO; | ||
74 | } | ||
75 | |||
76 | static int isl6421_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg) | ||
77 | { | ||
78 | struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; | ||
79 | struct i2c_msg msg = { .addr = isl6421->i2c_addr, .flags = 0, | ||
80 | .buf = &isl6421->config, | ||
81 | .len = sizeof(isl6421->config) }; | ||
82 | |||
83 | if (arg) | ||
84 | isl6421->config |= ISL6421_LLC1; | ||
85 | else | ||
86 | isl6421->config &= ~ISL6421_LLC1; | ||
87 | |||
88 | isl6421->config |= isl6421->override_or; | ||
89 | isl6421->config &= isl6421->override_and; | ||
90 | |||
91 | return (i2c_transfer(isl6421->i2c, &msg, 1) == 1) ? 0 : -EIO; | ||
92 | } | ||
93 | |||
94 | static void isl6421_release(struct dvb_frontend *fe) | ||
95 | { | ||
96 | struct isl6421 *isl6421 = (struct isl6421 *) fe->misc_priv; | ||
97 | |||
98 | /* power off */ | ||
99 | isl6421_set_voltage(fe, SEC_VOLTAGE_OFF); | ||
100 | |||
101 | /* free data & call next release routine */ | ||
102 | fe->ops->release = isl6421->release_chain; | ||
103 | kfree(fe->misc_priv); | ||
104 | fe->misc_priv = NULL; | ||
105 | if (fe->ops->release) | ||
106 | fe->ops->release(fe); | ||
107 | } | ||
108 | |||
109 | int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, | ||
110 | u8 override_set, u8 override_clear) | ||
111 | { | ||
112 | struct isl6421 *isl6421 = kmalloc(sizeof(struct isl6421), GFP_KERNEL); | ||
113 | if (!isl6421) | ||
114 | return -ENOMEM; | ||
115 | |||
116 | /* default configuration */ | ||
117 | isl6421->config = ISL6421_ISEL1; | ||
118 | isl6421->i2c = i2c; | ||
119 | isl6421->i2c_addr = i2c_addr; | ||
120 | fe->misc_priv = isl6421; | ||
121 | |||
122 | /* bits which should be forced to '1' */ | ||
123 | isl6421->override_or = override_set; | ||
124 | |||
125 | /* bits which should be forced to '0' */ | ||
126 | isl6421->override_and = ~override_clear; | ||
127 | |||
128 | /* detect if it is present or not */ | ||
129 | if (isl6421_set_voltage(fe, SEC_VOLTAGE_OFF)) { | ||
130 | kfree(isl6421); | ||
131 | fe->misc_priv = NULL; | ||
132 | return -EIO; | ||
133 | } | ||
134 | |||
135 | /* install release callback */ | ||
136 | isl6421->release_chain = fe->ops->release; | ||
137 | fe->ops->release = isl6421_release; | ||
138 | |||
139 | /* override frontend ops */ | ||
140 | fe->ops->set_voltage = isl6421_set_voltage; | ||
141 | fe->ops->enable_high_lnb_voltage = isl6421_enable_high_lnb_voltage; | ||
142 | |||
143 | return 0; | ||
144 | } | ||
145 | EXPORT_SYMBOL(isl6421_attach); | ||
146 | |||
147 | MODULE_DESCRIPTION("Driver for lnb supply and control ic isl6421"); | ||
148 | MODULE_AUTHOR("Andrew de Quincey & Oliver Endriss"); | ||
149 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/media/dvb/frontends/isl6421.h b/drivers/media/dvb/frontends/isl6421.h new file mode 100644 index 000000000000..675f80a19b99 --- /dev/null +++ b/drivers/media/dvb/frontends/isl6421.h | |||
@@ -0,0 +1,46 @@ | |||
1 | /* | ||
2 | * isl6421.h - driver for lnb supply and control ic ISL6421 | ||
3 | * | ||
4 | * Copyright (C) 2006 Andrew de Quincey | ||
5 | * Copyright (C) 2006 Oliver Endriss | ||
6 | * | ||
7 | * This program is free software; you can redistribute it and/or | ||
8 | * modify it under the terms of the GNU General Public License | ||
9 | * as published by the Free Software Foundation; either version 2 | ||
10 | * of the License, or (at your option) any later version. | ||
11 | * | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, | ||
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
16 | * GNU General Public License for more details. | ||
17 | * | ||
18 | * | ||
19 | * You should have received a copy of the GNU General Public License | ||
20 | * along with this program; if not, write to the Free Software | ||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
22 | * Or, point your browser to http://www.gnu.org/copyleft/gpl.html | ||
23 | * | ||
24 | * | ||
25 | * the project's page is at http://www.linuxtv.org | ||
26 | */ | ||
27 | |||
28 | #ifndef _ISL6421_H | ||
29 | #define _ISL6421_H | ||
30 | |||
31 | #include <linux/dvb/frontend.h> | ||
32 | |||
33 | /* system register bits */ | ||
34 | #define ISL6421_OLF1 0x01 | ||
35 | #define ISL6421_EN1 0x02 | ||
36 | #define ISL6421_VSEL1 0x04 | ||
37 | #define ISL6421_LLC1 0x08 | ||
38 | #define ISL6421_ENT1 0x10 | ||
39 | #define ISL6421_ISEL1 0x20 | ||
40 | #define ISL6421_DCL 0x40 | ||
41 | |||
42 | /* override_set and override_clear control which system register bits (above) to always set & clear */ | ||
43 | extern int isl6421_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c, u8 i2c_addr, | ||
44 | u8 override_set, u8 override_clear); | ||
45 | |||
46 | #endif | ||