1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Allegro A8293 SEC driver
5 * Copyright (C) 2011 Antti Palosaari <crope@iki.fi>
11 struct i2c_client
*client
;
15 static int a8293_set_voltage(struct dvb_frontend
*fe
,
16 enum fe_sec_voltage fe_sec_voltage
)
18 struct a8293_dev
*dev
= fe
->sec_priv
;
19 struct i2c_client
*client
= dev
->client
;
23 dev_dbg(&client
->dev
, "fe_sec_voltage=%d\n", fe_sec_voltage
);
25 switch (fe_sec_voltage
) {
31 /* VSEL0=1, VSEL1=0, VSEL2=0, VSEL3=0, ENB=1*/
35 /* VSEL0=0, VSEL1=0, VSEL2=0, VSEL3=1, ENB=1*/
42 if (reg0
!= dev
->reg
[0]) {
43 ret
= i2c_master_send(client
, ®0
, 1);
49 /* TMODE=0, TGATE=1 */
51 if (reg1
!= dev
->reg
[1]) {
52 ret
= i2c_master_send(client
, ®1
, 1);
58 usleep_range(1500, 50000);
61 dev_dbg(&client
->dev
, "failed=%d\n", ret
);
65 static int a8293_probe(struct i2c_client
*client
,
66 const struct i2c_device_id
*id
)
68 struct a8293_dev
*dev
;
69 struct a8293_platform_data
*pdata
= client
->dev
.platform_data
;
70 struct dvb_frontend
*fe
= pdata
->dvb_frontend
;
74 dev
= kzalloc(sizeof(*dev
), GFP_KERNEL
);
82 /* check if the SEC is there */
83 ret
= i2c_master_recv(client
, buf
, 2);
87 /* override frontend ops */
88 fe
->ops
.set_voltage
= a8293_set_voltage
;
90 i2c_set_clientdata(client
, dev
);
92 dev_info(&client
->dev
, "Allegro A8293 SEC successfully attached\n");
97 dev_dbg(&client
->dev
, "failed=%d\n", ret
);
101 static int a8293_remove(struct i2c_client
*client
)
103 struct a8293_dev
*dev
= i2c_get_clientdata(client
);
105 dev_dbg(&client
->dev
, "\n");
111 static const struct i2c_device_id a8293_id_table
[] = {
115 MODULE_DEVICE_TABLE(i2c
, a8293_id_table
);
117 static struct i2c_driver a8293_driver
= {
120 .suppress_bind_attrs
= true,
122 .probe
= a8293_probe
,
123 .remove
= a8293_remove
,
124 .id_table
= a8293_id_table
,
127 module_i2c_driver(a8293_driver
);
129 MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>");
130 MODULE_DESCRIPTION("Allegro A8293 SEC driver");
131 MODULE_LICENSE("GPL");