2 Intersil ISL6423 SEC and LNB Power supply controller
4 Copyright (C) Manu Abraham <abraham.manu@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <linux/delay.h>
22 #include <linux/errno.h>
23 #include <linux/init.h>
24 #include <linux/kernel.h>
25 #include <linux/module.h>
26 #include <linux/string.h>
27 #include <linux/slab.h>
29 #include "dvb_frontend.h"
32 static unsigned int verbose
;
33 module_param(verbose
, int, 0644);
34 MODULE_PARM_DESC(verbose
, "Set Verbosity level");
42 #define dprintk(__y, __z, format, arg...) do { \
44 if ((verbose > FE_ERROR) && (verbose > __y)) \
45 printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
46 else if ((verbose > FE_NOTICE) && (verbose > __y)) \
47 printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
48 else if ((verbose > FE_INFO) && (verbose > __y)) \
49 printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
50 else if ((verbose > FE_DEBUG) && (verbose > __y)) \
51 printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
54 printk(format, ##arg); \
59 const struct isl6423_config
*config
;
60 struct i2c_adapter
*i2c
;
68 static int isl6423_write(struct isl6423_dev
*isl6423
, u8 reg
)
70 struct i2c_adapter
*i2c
= isl6423
->i2c
;
71 u8 addr
= isl6423
->config
->addr
;
74 struct i2c_msg msg
= { .addr
= addr
, .flags
= 0, .buf
= ®
, .len
= 1 };
76 dprintk(FE_DEBUG
, 1, "write reg %02X", reg
);
77 err
= i2c_transfer(i2c
, &msg
, 1);
83 dprintk(FE_ERROR
, 1, "I/O error <%d>", err
);
87 static int isl6423_set_modulation(struct dvb_frontend
*fe
)
89 struct isl6423_dev
*isl6423
= (struct isl6423_dev
*) fe
->sec_priv
;
90 const struct isl6423_config
*config
= isl6423
->config
;
96 if (config
->mod_extern
)
101 err
= isl6423_write(isl6423
, reg_2
);
107 dprintk(FE_ERROR
, 1, "I/O error <%d>", err
);
111 static int isl6423_voltage_boost(struct dvb_frontend
*fe
, long arg
)
113 struct isl6423_dev
*isl6423
= (struct isl6423_dev
*) fe
->sec_priv
;
114 u8 reg_3
= isl6423
->reg_3
;
115 u8 reg_4
= isl6423
->reg_4
;
119 /* EN = 1, VSPEN = 1, VBOT = 1 */
124 /* EN = 1, VSPEN = 1, VBOT = 0 */
129 err
= isl6423_write(isl6423
, reg_3
);
133 err
= isl6423_write(isl6423
, reg_4
);
137 isl6423
->reg_3
= reg_3
;
138 isl6423
->reg_4
= reg_4
;
142 dprintk(FE_ERROR
, 1, "I/O error <%d>", err
);
147 static int isl6423_set_voltage(struct dvb_frontend
*fe
,
148 enum fe_sec_voltage voltage
)
150 struct isl6423_dev
*isl6423
= (struct isl6423_dev
*) fe
->sec_priv
;
151 u8 reg_3
= isl6423
->reg_3
;
152 u8 reg_4
= isl6423
->reg_4
;
156 case SEC_VOLTAGE_OFF
:
162 /* EN = 1, VSPEN = 1, VTOP = 0, VBOT = 0 */
169 /* EN = 1, VSPEN = 1, VTOP = 1, VBOT = 0 */
179 err
= isl6423_write(isl6423
, reg_3
);
183 err
= isl6423_write(isl6423
, reg_4
);
187 isl6423
->reg_3
= reg_3
;
188 isl6423
->reg_4
= reg_4
;
192 dprintk(FE_ERROR
, 1, "I/O error <%d>", err
);
196 static int isl6423_set_current(struct dvb_frontend
*fe
)
198 struct isl6423_dev
*isl6423
= (struct isl6423_dev
*) fe
->sec_priv
;
199 u8 reg_3
= isl6423
->reg_3
;
200 const struct isl6423_config
*config
= isl6423
->config
;
203 switch (config
->current_max
) {
204 case SEC_CURRENT_275m
:
206 /* ISELH = 0, ISELL = 0 */
210 case SEC_CURRENT_515m
:
212 /* ISELH = 0, ISELL = 1 */
217 case SEC_CURRENT_635m
:
219 /* ISELH = 1, ISELL = 0 */
224 case SEC_CURRENT_800m
:
226 /* ISELH = 1, ISELL = 1 */
231 err
= isl6423_write(isl6423
, reg_3
);
235 switch (config
->curlim
) {
236 case SEC_CURRENT_LIM_ON
:
241 case SEC_CURRENT_LIM_OFF
:
247 err
= isl6423_write(isl6423
, reg_3
);
251 isl6423
->reg_3
= reg_3
;
255 dprintk(FE_ERROR
, 1, "I/O error <%d>", err
);
259 static void isl6423_release(struct dvb_frontend
*fe
)
261 isl6423_set_voltage(fe
, SEC_VOLTAGE_OFF
);
267 struct dvb_frontend
*isl6423_attach(struct dvb_frontend
*fe
,
268 struct i2c_adapter
*i2c
,
269 const struct isl6423_config
*config
)
271 struct isl6423_dev
*isl6423
;
273 isl6423
= kzalloc(sizeof(struct isl6423_dev
), GFP_KERNEL
);
277 isl6423
->config
= config
;
279 fe
->sec_priv
= isl6423
;
281 /* SR3H = 0, SR3M = 1, SR3L = 0 */
282 isl6423
->reg_3
= 0x02 << 5;
283 /* SR4H = 0, SR4M = 1, SR4L = 1 */
284 isl6423
->reg_4
= 0x03 << 5;
286 if (isl6423_set_current(fe
))
289 if (isl6423_set_modulation(fe
))
292 fe
->ops
.release_sec
= isl6423_release
;
293 fe
->ops
.set_voltage
= isl6423_set_voltage
;
294 fe
->ops
.enable_high_lnb_voltage
= isl6423_voltage_boost
;
295 isl6423
->verbose
= verbose
;
304 EXPORT_SYMBOL(isl6423_attach
);
306 MODULE_DESCRIPTION("ISL6423 SEC");
307 MODULE_AUTHOR("Manu Abraham");
308 MODULE_LICENSE("GPL");