1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * isl6405.c - driver for dual lnb supply and control ic ISL6405
5 * Copyright (C) 2008 Hartmut Hackmann
6 * Copyright (C) 2006 Oliver Endriss
8 * the project's page is at https://linuxtv.org
10 #include <linux/delay.h>
11 #include <linux/errno.h>
12 #include <linux/init.h>
13 #include <linux/kernel.h>
14 #include <linux/module.h>
15 #include <linux/string.h>
16 #include <linux/slab.h>
18 #include <media/dvb_frontend.h>
25 struct i2c_adapter *i2c;
29 static int isl6405_set_voltage(struct dvb_frontend *fe,
30 enum fe_sec_voltage voltage)
32 struct isl6405 *isl6405 = (struct isl6405 *) fe->sec_priv;
33 struct i2c_msg msg = { .addr = isl6405->i2c_addr, .flags = 0,
34 .buf = &isl6405->config,
35 .len = sizeof(isl6405->config) };
37 if (isl6405->override_or & 0x80) {
38 isl6405->config &= ~(ISL6405_VSEL2 | ISL6405_EN2);
43 isl6405->config |= ISL6405_EN2;
46 isl6405->config |= (ISL6405_EN2 | ISL6405_VSEL2);
52 isl6405->config &= ~(ISL6405_VSEL1 | ISL6405_EN1);
57 isl6405->config |= ISL6405_EN1;
60 isl6405->config |= (ISL6405_EN1 | ISL6405_VSEL1);
66 isl6405->config |= isl6405->override_or;
67 isl6405->config &= isl6405->override_and;
69 return (i2c_transfer(isl6405->i2c, &msg, 1) == 1) ? 0 : -EIO;
72 static int isl6405_enable_high_lnb_voltage(struct dvb_frontend *fe, long arg)
74 struct isl6405 *isl6405 = (struct isl6405 *) fe->sec_priv;
75 struct i2c_msg msg = { .addr = isl6405->i2c_addr, .flags = 0,
76 .buf = &isl6405->config,
77 .len = sizeof(isl6405->config) };
79 if (isl6405->override_or & 0x80) {
81 isl6405->config |= ISL6405_LLC2;
83 isl6405->config &= ~ISL6405_LLC2;
86 isl6405->config |= ISL6405_LLC1;
88 isl6405->config &= ~ISL6405_LLC1;
90 isl6405->config |= isl6405->override_or;
91 isl6405->config &= isl6405->override_and;
93 return (i2c_transfer(isl6405->i2c, &msg, 1) == 1) ? 0 : -EIO;
96 static void isl6405_release(struct dvb_frontend *fe)
99 isl6405_set_voltage(fe, SEC_VOLTAGE_OFF);
106 struct dvb_frontend *isl6405_attach(struct dvb_frontend *fe, struct i2c_adapter *i2c,
107 u8 i2c_addr, u8 override_set, u8 override_clear)
109 struct isl6405 *isl6405 = kmalloc(sizeof(struct isl6405), GFP_KERNEL);
113 /* default configuration */
114 if (override_set & 0x80)
115 isl6405->config = ISL6405_ISEL2;
117 isl6405->config = ISL6405_ISEL1;
119 isl6405->i2c_addr = i2c_addr;
120 fe->sec_priv = isl6405;
122 /* bits which should be forced to '1' */
123 isl6405->override_or = override_set;
125 /* bits which should be forced to '0' */
126 isl6405->override_and = ~override_clear;
128 /* detect if it is present or not */
129 if (isl6405_set_voltage(fe, SEC_VOLTAGE_OFF)) {
135 /* install release callback */
136 fe->ops.release_sec = isl6405_release;
138 /* override frontend ops */
139 fe->ops.set_voltage = isl6405_set_voltage;
140 fe->ops.enable_high_lnb_voltage = isl6405_enable_high_lnb_voltage;
144 EXPORT_SYMBOL(isl6405_attach);
146 MODULE_DESCRIPTION("Driver for lnb supply and control ic isl6405");
147 MODULE_AUTHOR("Hartmut Hackmann & Oliver Endriss");
148 MODULE_LICENSE("GPL");