2 * Allegro A8293 SEC driver
4 * Copyright (C) 2011 Antti Palosaari <crope@iki.fi>
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.
20 struct i2c_client
*client
;
24 static int a8293_set_voltage(struct dvb_frontend
*fe
,
25 enum fe_sec_voltage fe_sec_voltage
)
27 struct a8293_dev
*dev
= fe
->sec_priv
;
28 struct i2c_client
*client
= dev
->client
;
32 dev_dbg(&client
->dev
, "fe_sec_voltage=%d\n", fe_sec_voltage
);
34 switch (fe_sec_voltage
) {
40 /* VSEL0=1, VSEL1=0, VSEL2=0, VSEL3=0, ENB=1*/
44 /* VSEL0=0, VSEL1=0, VSEL2=0, VSEL3=1, ENB=1*/
51 if (reg0
!= dev
->reg
[0]) {
52 ret
= i2c_master_send(client
, ®0
, 1);
58 /* TMODE=0, TGATE=1 */
60 if (reg1
!= dev
->reg
[1]) {
61 ret
= i2c_master_send(client
, ®1
, 1);
67 usleep_range(1500, 50000);
70 dev_dbg(&client
->dev
, "failed=%d\n", ret
);
74 static int a8293_probe(struct i2c_client
*client
,
75 const struct i2c_device_id
*id
)
77 struct a8293_dev
*dev
;
78 struct a8293_platform_data
*pdata
= client
->dev
.platform_data
;
79 struct dvb_frontend
*fe
= pdata
->dvb_frontend
;
83 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
91 /* check if the SEC is there */
92 ret
= i2c_master_recv(client
, buf
, 2);
96 /* override frontend ops */
97 fe
->ops
.set_voltage
= a8293_set_voltage
;
99 i2c_set_clientdata(client
, dev
);
101 dev_info(&client
->dev
, "Allegro A8293 SEC successfully attached\n");
106 dev_dbg(&client
->dev
, "failed=%d\n", ret
);
110 static int a8293_remove(struct i2c_client
*client
)
112 struct a8293_dev
*dev
= i2c_get_clientdata(client
);
114 dev_dbg(&client
->dev
, "\n");
120 static const struct i2c_device_id a8293_id_table
[] = {
124 MODULE_DEVICE_TABLE(i2c
, a8293_id_table
);
126 static struct i2c_driver a8293_driver
= {
129 .suppress_bind_attrs
= true,
131 .probe
= a8293_probe
,
132 .remove
= a8293_remove
,
133 .id_table
= a8293_id_table
,
136 module_i2c_driver(a8293_driver
);
138 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
139 MODULE_DESCRIPTION("Allegro A8293 SEC driver");
140 MODULE_LICENSE("GPL");