Thomas Gleixner | c942fdd | 2019-05-27 08:55:06 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
Antti Palosaari | 711615d | 2014-04-14 21:55:12 -0300 | [diff] [blame] | 2 | /* |
| 3 | * Silicon Labs Si2168 DVB-T/T2/C demodulator driver |
| 4 | * |
| 5 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> |
Antti Palosaari | 711615d | 2014-04-14 21:55:12 -0300 | [diff] [blame] | 6 | */ |
| 7 | |
Ron Economos | 380a6c8 | 2017-12-11 19:51:53 -0500 | [diff] [blame] | 8 | #include <linux/delay.h> |
| 9 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 10 | #include "si2168_priv.h" |
| 11 | |
| 12 | static const struct dvb_frontend_ops si2168_ops; |
| 13 | |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 14 | /* execute firmware command */ |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 15 | static int si2168_cmd_execute(struct i2c_client *client, struct si2168_cmd *cmd) |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 16 | { |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 17 | struct si2168_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 18 | int ret; |
| 19 | unsigned long timeout; |
| 20 | |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 21 | mutex_lock(&dev->i2c_mutex); |
| 22 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 23 | if (cmd->wlen) { |
| 24 | /* write cmd and args for firmware */ |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 25 | ret = i2c_master_send(client, cmd->args, cmd->wlen); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 26 | if (ret < 0) { |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 27 | goto err_mutex_unlock; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 28 | } else if (ret != cmd->wlen) { |
| 29 | ret = -EREMOTEIO; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 30 | goto err_mutex_unlock; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 31 | } |
| 32 | } |
| 33 | |
| 34 | if (cmd->rlen) { |
| 35 | /* wait cmd execution terminate */ |
Jurgen Kramer | 551c33e | 2014-12-08 05:30:44 -0300 | [diff] [blame] | 36 | #define TIMEOUT 70 |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 37 | timeout = jiffies + msecs_to_jiffies(TIMEOUT); |
| 38 | while (!time_after(jiffies, timeout)) { |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 39 | ret = i2c_master_recv(client, cmd->args, cmd->rlen); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 40 | if (ret < 0) { |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 41 | goto err_mutex_unlock; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 42 | } else if (ret != cmd->rlen) { |
| 43 | ret = -EREMOTEIO; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 44 | goto err_mutex_unlock; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | /* firmware ready? */ |
| 48 | if ((cmd->args[0] >> 7) & 0x01) |
| 49 | break; |
| 50 | } |
| 51 | |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 52 | dev_dbg(&client->dev, "cmd execution took %d ms\n", |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 53 | jiffies_to_msecs(jiffies) - |
| 54 | (jiffies_to_msecs(timeout) - TIMEOUT)); |
| 55 | |
Olli Salonen | 7adf99d | 2015-05-05 13:54:16 -0300 | [diff] [blame] | 56 | /* error bit set? */ |
| 57 | if ((cmd->args[0] >> 6) & 0x01) { |
| 58 | ret = -EREMOTEIO; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 59 | goto err_mutex_unlock; |
Olli Salonen | 7adf99d | 2015-05-05 13:54:16 -0300 | [diff] [blame] | 60 | } |
| 61 | |
Antti Palosaari | eefae30 | 2014-06-13 11:08:25 -0300 | [diff] [blame] | 62 | if (!((cmd->args[0] >> 7) & 0x01)) { |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 63 | ret = -ETIMEDOUT; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 64 | goto err_mutex_unlock; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 65 | } |
| 66 | } |
| 67 | |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 68 | mutex_unlock(&dev->i2c_mutex); |
Antti Palosaari | 4affbe1 | 2014-12-05 14:30:44 -0300 | [diff] [blame] | 69 | return 0; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 70 | err_mutex_unlock: |
| 71 | mutex_unlock(&dev->i2c_mutex); |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 72 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 73 | return ret; |
| 74 | } |
| 75 | |
Brad Love | 1844f49 | 2018-02-12 15:19:04 -0500 | [diff] [blame] | 76 | static int si2168_ts_bus_ctrl(struct dvb_frontend *fe, int acquire) |
| 77 | { |
| 78 | struct i2c_client *client = fe->demodulator_priv; |
| 79 | struct si2168_dev *dev = i2c_get_clientdata(client); |
| 80 | struct si2168_cmd cmd; |
| 81 | int ret = 0; |
| 82 | |
| 83 | dev_dbg(&client->dev, "%s acquire: %d\n", __func__, acquire); |
| 84 | |
| 85 | /* set TS_MODE property */ |
| 86 | memcpy(cmd.args, "\x14\x00\x01\x10\x10\x00", 6); |
| 87 | if (acquire) |
| 88 | cmd.args[4] |= dev->ts_mode; |
| 89 | else |
| 90 | cmd.args[4] |= SI2168_TS_TRISTATE; |
| 91 | if (dev->ts_clock_gapped) |
| 92 | cmd.args[4] |= 0x40; |
| 93 | cmd.wlen = 6; |
| 94 | cmd.rlen = 4; |
| 95 | ret = si2168_cmd_execute(client, &cmd); |
| 96 | |
| 97 | return ret; |
| 98 | } |
| 99 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 100 | static int si2168_read_status(struct dvb_frontend *fe, enum fe_status *status) |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 101 | { |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 102 | struct i2c_client *client = fe->demodulator_priv; |
| 103 | struct si2168_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 104 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Antti Palosaari | 8393c00 | 2016-12-08 22:19:19 -0200 | [diff] [blame] | 105 | int ret, i; |
| 106 | unsigned int utmp, utmp1, utmp2; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 107 | struct si2168_cmd cmd; |
| 108 | |
| 109 | *status = 0; |
| 110 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 111 | if (!dev->active) { |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 112 | ret = -EAGAIN; |
| 113 | goto err; |
| 114 | } |
| 115 | |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 116 | switch (c->delivery_system) { |
| 117 | case SYS_DVBT: |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 118 | memcpy(cmd.args, "\xa0\x01", 2); |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 119 | cmd.wlen = 2; |
| 120 | cmd.rlen = 13; |
| 121 | break; |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 122 | case SYS_DVBC_ANNEX_A: |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 123 | memcpy(cmd.args, "\x90\x01", 2); |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 124 | cmd.wlen = 2; |
| 125 | cmd.rlen = 9; |
| 126 | break; |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 127 | case SYS_DVBT2: |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 128 | memcpy(cmd.args, "\x50\x01", 2); |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 129 | cmd.wlen = 2; |
| 130 | cmd.rlen = 14; |
| 131 | break; |
| 132 | default: |
| 133 | ret = -EINVAL; |
| 134 | goto err; |
| 135 | } |
| 136 | |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 137 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 138 | if (ret) |
| 139 | goto err; |
| 140 | |
Antti Palosaari | 722a042 | 2014-04-22 21:36:32 -0300 | [diff] [blame] | 141 | switch ((cmd.args[2] >> 1) & 0x03) { |
| 142 | case 0x01: |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 143 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER; |
| 144 | break; |
Antti Palosaari | 722a042 | 2014-04-22 21:36:32 -0300 | [diff] [blame] | 145 | case 0x03: |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 146 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | FE_HAS_VITERBI | |
| 147 | FE_HAS_SYNC | FE_HAS_LOCK; |
| 148 | break; |
| 149 | } |
| 150 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 151 | dev->fe_status = *status; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 152 | |
Antti Palosaari | 88ac8f8 | 2014-07-09 20:22:27 -0300 | [diff] [blame] | 153 | if (*status & FE_HAS_LOCK) { |
| 154 | c->cnr.len = 1; |
| 155 | c->cnr.stat[0].scale = FE_SCALE_DECIBEL; |
| 156 | c->cnr.stat[0].svalue = cmd.args[3] * 1000 / 4; |
| 157 | } else { |
| 158 | c->cnr.len = 1; |
| 159 | c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
| 160 | } |
| 161 | |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 162 | dev_dbg(&client->dev, "status=%02x args=%*ph\n", |
Olli Salonen | 37b4e43 | 2014-08-05 08:54:08 -0300 | [diff] [blame] | 163 | *status, cmd.rlen, cmd.args); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 164 | |
Antti Palosaari | 8393c00 | 2016-12-08 22:19:19 -0200 | [diff] [blame] | 165 | /* BER */ |
| 166 | if (*status & FE_HAS_VITERBI) { |
| 167 | memcpy(cmd.args, "\x82\x00", 2); |
| 168 | cmd.wlen = 2; |
| 169 | cmd.rlen = 3; |
| 170 | ret = si2168_cmd_execute(client, &cmd); |
| 171 | if (ret) |
| 172 | goto err; |
| 173 | |
| 174 | /* |
| 175 | * Firmware returns [0, 255] mantissa and [0, 8] exponent. |
| 176 | * Convert to DVB API: mantissa * 10^(8 - exponent) / 10^8 |
| 177 | */ |
| 178 | utmp = clamp(8 - cmd.args[1], 0, 8); |
| 179 | for (i = 0, utmp1 = 1; i < utmp; i++) |
| 180 | utmp1 = utmp1 * 10; |
| 181 | |
| 182 | utmp1 = cmd.args[2] * utmp1; |
| 183 | utmp2 = 100000000; /* 10^8 */ |
| 184 | |
| 185 | dev_dbg(&client->dev, |
| 186 | "post_bit_error=%u post_bit_count=%u ber=%u*10^-%u\n", |
| 187 | utmp1, utmp2, cmd.args[2], cmd.args[1]); |
| 188 | |
| 189 | c->post_bit_error.stat[0].scale = FE_SCALE_COUNTER; |
| 190 | c->post_bit_error.stat[0].uvalue += utmp1; |
| 191 | c->post_bit_count.stat[0].scale = FE_SCALE_COUNTER; |
| 192 | c->post_bit_count.stat[0].uvalue += utmp2; |
| 193 | } else { |
| 194 | c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
| 195 | c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
| 196 | } |
| 197 | |
Antti Palosaari | c62d29c | 2016-12-09 11:11:32 -0200 | [diff] [blame] | 198 | /* UCB */ |
| 199 | if (*status & FE_HAS_SYNC) { |
| 200 | memcpy(cmd.args, "\x84\x01", 2); |
| 201 | cmd.wlen = 2; |
| 202 | cmd.rlen = 3; |
| 203 | ret = si2168_cmd_execute(client, &cmd); |
| 204 | if (ret) |
| 205 | goto err; |
| 206 | |
| 207 | utmp1 = cmd.args[2] << 8 | cmd.args[1] << 0; |
| 208 | dev_dbg(&client->dev, "block_error=%u\n", utmp1); |
| 209 | |
| 210 | /* Sometimes firmware returns bogus value */ |
| 211 | if (utmp1 == 0xffff) |
| 212 | utmp1 = 0; |
| 213 | |
| 214 | c->block_error.stat[0].scale = FE_SCALE_COUNTER; |
| 215 | c->block_error.stat[0].uvalue += utmp1; |
| 216 | } else { |
| 217 | c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
| 218 | } |
| 219 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 220 | return 0; |
| 221 | err: |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 222 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 223 | return ret; |
| 224 | } |
| 225 | |
| 226 | static int si2168_set_frontend(struct dvb_frontend *fe) |
| 227 | { |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 228 | struct i2c_client *client = fe->demodulator_priv; |
| 229 | struct si2168_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 230 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 231 | int ret; |
| 232 | struct si2168_cmd cmd; |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 233 | u8 bandwidth, delivery_system; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 234 | |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 235 | dev_dbg(&client->dev, |
Antti Palosaari | e5dd110 | 2014-12-05 15:57:03 -0300 | [diff] [blame] | 236 | "delivery_system=%u modulation=%u frequency=%u bandwidth_hz=%u symbol_rate=%u inversion=%u stream_id=%u\n", |
| 237 | c->delivery_system, c->modulation, c->frequency, |
| 238 | c->bandwidth_hz, c->symbol_rate, c->inversion, |
| 239 | c->stream_id); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 240 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 241 | if (!dev->active) { |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 242 | ret = -EAGAIN; |
| 243 | goto err; |
| 244 | } |
| 245 | |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 246 | switch (c->delivery_system) { |
| 247 | case SYS_DVBT: |
| 248 | delivery_system = 0x20; |
| 249 | break; |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 250 | case SYS_DVBC_ANNEX_A: |
| 251 | delivery_system = 0x30; |
| 252 | break; |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 253 | case SYS_DVBT2: |
| 254 | delivery_system = 0x70; |
| 255 | break; |
| 256 | default: |
| 257 | ret = -EINVAL; |
| 258 | goto err; |
| 259 | } |
| 260 | |
Olli Salonen | 683e98b | 2015-01-16 09:35:19 -0300 | [diff] [blame] | 261 | if (c->bandwidth_hz == 0) { |
| 262 | ret = -EINVAL; |
| 263 | goto err; |
Olli Salonen | 17d4d6a | 2015-01-16 09:35:20 -0300 | [diff] [blame] | 264 | } else if (c->bandwidth_hz <= 2000000) |
| 265 | bandwidth = 0x02; |
| 266 | else if (c->bandwidth_hz <= 5000000) |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 267 | bandwidth = 0x05; |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 268 | else if (c->bandwidth_hz <= 6000000) |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 269 | bandwidth = 0x06; |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 270 | else if (c->bandwidth_hz <= 7000000) |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 271 | bandwidth = 0x07; |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 272 | else if (c->bandwidth_hz <= 8000000) |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 273 | bandwidth = 0x08; |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 274 | else if (c->bandwidth_hz <= 9000000) |
| 275 | bandwidth = 0x09; |
| 276 | else if (c->bandwidth_hz <= 10000000) |
| 277 | bandwidth = 0x0a; |
| 278 | else |
| 279 | bandwidth = 0x0f; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 280 | |
| 281 | /* program tuner */ |
| 282 | if (fe->ops.tuner_ops.set_params) { |
| 283 | ret = fe->ops.tuner_ops.set_params(fe); |
| 284 | if (ret) |
| 285 | goto err; |
| 286 | } |
| 287 | |
| 288 | memcpy(cmd.args, "\x88\x02\x02\x02\x02", 5); |
| 289 | cmd.wlen = 5; |
| 290 | cmd.rlen = 5; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 291 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 292 | if (ret) |
| 293 | goto err; |
| 294 | |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 295 | /* that has no big effect */ |
| 296 | if (c->delivery_system == SYS_DVBT) |
| 297 | memcpy(cmd.args, "\x89\x21\x06\x11\xff\x98", 6); |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 298 | else if (c->delivery_system == SYS_DVBC_ANNEX_A) |
| 299 | memcpy(cmd.args, "\x89\x21\x06\x11\x89\xf0", 6); |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 300 | else if (c->delivery_system == SYS_DVBT2) |
| 301 | memcpy(cmd.args, "\x89\x21\x06\x11\x89\x20", 6); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 302 | cmd.wlen = 6; |
| 303 | cmd.rlen = 3; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 304 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 305 | if (ret) |
| 306 | goto err; |
| 307 | |
CrazyCat | e395e57 | 2014-08-16 18:33:14 -0300 | [diff] [blame] | 308 | if (c->delivery_system == SYS_DVBT2) { |
| 309 | /* select PLP */ |
| 310 | cmd.args[0] = 0x52; |
| 311 | cmd.args[1] = c->stream_id & 0xff; |
| 312 | cmd.args[2] = c->stream_id == NO_STREAM_ID_FILTER ? 0 : 1; |
| 313 | cmd.wlen = 3; |
| 314 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 315 | ret = si2168_cmd_execute(client, &cmd); |
CrazyCat | e395e57 | 2014-08-16 18:33:14 -0300 | [diff] [blame] | 316 | if (ret) |
| 317 | goto err; |
| 318 | } |
| 319 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 320 | memcpy(cmd.args, "\x51\x03", 2); |
| 321 | cmd.wlen = 2; |
| 322 | cmd.rlen = 12; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 323 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 324 | if (ret) |
| 325 | goto err; |
| 326 | |
| 327 | memcpy(cmd.args, "\x12\x08\x04", 3); |
| 328 | cmd.wlen = 3; |
| 329 | cmd.rlen = 3; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 330 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 331 | if (ret) |
| 332 | goto err; |
| 333 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 334 | memcpy(cmd.args, "\x14\x00\x0c\x10\x12\x00", 6); |
| 335 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 336 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 337 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 338 | if (ret) |
| 339 | goto err; |
| 340 | |
| 341 | memcpy(cmd.args, "\x14\x00\x06\x10\x24\x00", 6); |
| 342 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 343 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 344 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 345 | if (ret) |
| 346 | goto err; |
| 347 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 348 | memcpy(cmd.args, "\x14\x00\x07\x10\x00\x24", 6); |
| 349 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 350 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 351 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 352 | if (ret) |
| 353 | goto err; |
| 354 | |
| 355 | memcpy(cmd.args, "\x14\x00\x0a\x10\x00\x00", 6); |
Antti Palosaari | bffab93 | 2014-04-11 20:35:27 -0300 | [diff] [blame] | 356 | cmd.args[4] = delivery_system | bandwidth; |
Brad Love | d4c779b | 2018-01-17 17:31:58 -0500 | [diff] [blame] | 357 | if (dev->spectral_inversion) |
| 358 | cmd.args[5] |= 1; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 359 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 360 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 361 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 362 | if (ret) |
| 363 | goto err; |
| 364 | |
Luis Alves | 32bf881 | 2014-07-17 14:31:28 -0300 | [diff] [blame] | 365 | /* set DVB-C symbol rate */ |
| 366 | if (c->delivery_system == SYS_DVBC_ANNEX_A) { |
| 367 | memcpy(cmd.args, "\x14\x00\x02\x11", 4); |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 368 | cmd.args[4] = ((c->symbol_rate / 1000) >> 0) & 0xff; |
Luis Alves | 32bf881 | 2014-07-17 14:31:28 -0300 | [diff] [blame] | 369 | cmd.args[5] = ((c->symbol_rate / 1000) >> 8) & 0xff; |
| 370 | cmd.wlen = 6; |
| 371 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 372 | ret = si2168_cmd_execute(client, &cmd); |
Luis Alves | 32bf881 | 2014-07-17 14:31:28 -0300 | [diff] [blame] | 373 | if (ret) |
| 374 | goto err; |
| 375 | } |
| 376 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 377 | memcpy(cmd.args, "\x14\x00\x0f\x10\x10\x00", 6); |
| 378 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 379 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 380 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 381 | if (ret) |
| 382 | goto err; |
| 383 | |
CrazyCat | 5279197 | 2014-11-14 18:22:10 -0300 | [diff] [blame] | 384 | memcpy(cmd.args, "\x14\x00\x09\x10\xe3\x08", 6); |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 385 | cmd.args[5] |= dev->ts_clock_inv ? 0x00 : 0x10; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 386 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 387 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 388 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 389 | if (ret) |
| 390 | goto err; |
| 391 | |
CrazyCat | 5279197 | 2014-11-14 18:22:10 -0300 | [diff] [blame] | 392 | memcpy(cmd.args, "\x14\x00\x08\x10\xd7\x05", 6); |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 393 | cmd.args[5] |= dev->ts_clock_inv ? 0x00 : 0x10; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 394 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 395 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 396 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 397 | if (ret) |
| 398 | goto err; |
| 399 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 400 | memcpy(cmd.args, "\x14\x00\x01\x12\x00\x00", 6); |
| 401 | cmd.wlen = 6; |
Antti Palosaari | 1d518c2 | 2014-07-11 10:40:29 -0300 | [diff] [blame] | 402 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 403 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 404 | if (ret) |
| 405 | goto err; |
| 406 | |
Olli Salonen | 4391177 | 2014-07-17 15:43:27 -0300 | [diff] [blame] | 407 | memcpy(cmd.args, "\x14\x00\x01\x03\x0c\x00", 6); |
| 408 | cmd.wlen = 6; |
| 409 | cmd.rlen = 4; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 410 | ret = si2168_cmd_execute(client, &cmd); |
Olli Salonen | 4391177 | 2014-07-17 15:43:27 -0300 | [diff] [blame] | 411 | if (ret) |
| 412 | goto err; |
| 413 | |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 414 | memcpy(cmd.args, "\x85", 1); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 415 | cmd.wlen = 1; |
| 416 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 417 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 418 | if (ret) |
| 419 | goto err; |
| 420 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 421 | dev->delivery_system = c->delivery_system; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 422 | |
Brad Love | 1844f49 | 2018-02-12 15:19:04 -0500 | [diff] [blame] | 423 | /* enable ts bus */ |
| 424 | ret = si2168_ts_bus_ctrl(fe, 1); |
| 425 | if (ret) |
| 426 | goto err; |
| 427 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 428 | return 0; |
| 429 | err: |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 430 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 431 | return ret; |
| 432 | } |
| 433 | |
| 434 | static int si2168_init(struct dvb_frontend *fe) |
| 435 | { |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 436 | struct i2c_client *client = fe->demodulator_priv; |
| 437 | struct si2168_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | 8393c00 | 2016-12-08 22:19:19 -0200 | [diff] [blame] | 438 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 439 | int ret, len, remaining; |
Antti Palosaari | 58f6693 | 2014-12-05 17:22:42 -0300 | [diff] [blame] | 440 | const struct firmware *fw; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 441 | struct si2168_cmd cmd; |
| 442 | |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 443 | dev_dbg(&client->dev, "\n"); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 444 | |
Olli Salonen | 8e41722 | 2014-08-25 15:07:04 -0300 | [diff] [blame] | 445 | /* initialize */ |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 446 | memcpy(cmd.args, "\xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00", 13); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 447 | cmd.wlen = 13; |
| 448 | cmd.rlen = 0; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 449 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 450 | if (ret) |
| 451 | goto err; |
| 452 | |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 453 | if (dev->warm) { |
Olli Salonen | 8e41722 | 2014-08-25 15:07:04 -0300 | [diff] [blame] | 454 | /* resume */ |
| 455 | memcpy(cmd.args, "\xc0\x06\x08\x0f\x00\x20\x21\x01", 8); |
| 456 | cmd.wlen = 8; |
| 457 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 458 | ret = si2168_cmd_execute(client, &cmd); |
Olli Salonen | 8e41722 | 2014-08-25 15:07:04 -0300 | [diff] [blame] | 459 | if (ret) |
| 460 | goto err; |
| 461 | |
Ron Economos | 380a6c8 | 2017-12-11 19:51:53 -0500 | [diff] [blame] | 462 | udelay(100); |
Olli Salonen | 8e41722 | 2014-08-25 15:07:04 -0300 | [diff] [blame] | 463 | memcpy(cmd.args, "\x85", 1); |
| 464 | cmd.wlen = 1; |
| 465 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 466 | ret = si2168_cmd_execute(client, &cmd); |
Olli Salonen | 8e41722 | 2014-08-25 15:07:04 -0300 | [diff] [blame] | 467 | if (ret) |
| 468 | goto err; |
| 469 | |
| 470 | goto warm; |
| 471 | } |
| 472 | |
| 473 | /* power up */ |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 474 | memcpy(cmd.args, "\xc0\x06\x01\x0f\x00\x20\x20\x01", 8); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 475 | cmd.wlen = 8; |
| 476 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 477 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 478 | if (ret) |
| 479 | goto err; |
| 480 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 481 | /* request the firmware, this will block and timeout */ |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 482 | ret = request_firmware(&fw, dev->firmware_name, &client->dev); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 483 | if (ret) { |
Antti Palosaari | b6b6fd6 | 2014-07-13 19:22:19 -0300 | [diff] [blame] | 484 | /* fallback mechanism to handle old name for Si2168 B40 fw */ |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 485 | if (dev->chip_id == SI2168_CHIP_ID_B40) { |
| 486 | dev->firmware_name = SI2168_B40_FIRMWARE_FALLBACK; |
| 487 | ret = request_firmware(&fw, dev->firmware_name, |
| 488 | &client->dev); |
Olli Salonen | c9cb082 | 2014-07-13 10:52:18 -0300 | [diff] [blame] | 489 | } |
Antti Palosaari | b6b6fd6 | 2014-07-13 19:22:19 -0300 | [diff] [blame] | 490 | |
| 491 | if (ret == 0) { |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 492 | dev_notice(&client->dev, |
Olli Salonen | 37b4e43 | 2014-08-05 08:54:08 -0300 | [diff] [blame] | 493 | "please install firmware file '%s'\n", |
| 494 | SI2168_B40_FIRMWARE); |
Antti Palosaari | b6b6fd6 | 2014-07-13 19:22:19 -0300 | [diff] [blame] | 495 | } else { |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 496 | dev_err(&client->dev, |
Olli Salonen | 37b4e43 | 2014-08-05 08:54:08 -0300 | [diff] [blame] | 497 | "firmware file '%s' not found\n", |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 498 | dev->firmware_name); |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 499 | goto err_release_firmware; |
Olli Salonen | c9cb082 | 2014-07-13 10:52:18 -0300 | [diff] [blame] | 500 | } |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 501 | } |
| 502 | |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 503 | dev_info(&client->dev, "downloading firmware from file '%s'\n", |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 504 | dev->firmware_name); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 505 | |
Olli Salonen | 1b97dc9 | 2014-11-27 16:42:23 -0300 | [diff] [blame] | 506 | if ((fw->size % 17 == 0) && (fw->data[0] > 5)) { |
| 507 | /* firmware is in the new format */ |
| 508 | for (remaining = fw->size; remaining > 0; remaining -= 17) { |
| 509 | len = fw->data[fw->size - remaining]; |
Laura Abbott | 47810b4 | 2015-09-29 21:10:09 -0300 | [diff] [blame] | 510 | if (len > SI2168_ARGLEN) { |
| 511 | ret = -EINVAL; |
| 512 | break; |
| 513 | } |
Olli Salonen | 1b97dc9 | 2014-11-27 16:42:23 -0300 | [diff] [blame] | 514 | memcpy(cmd.args, &fw->data[(fw->size - remaining) + 1], len); |
| 515 | cmd.wlen = len; |
| 516 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 517 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 68c16a7 | 2014-12-05 17:08:22 -0300 | [diff] [blame] | 518 | if (ret) |
| 519 | break; |
Olli Salonen | 1b97dc9 | 2014-11-27 16:42:23 -0300 | [diff] [blame] | 520 | } |
Antti Palosaari | 68c16a7 | 2014-12-05 17:08:22 -0300 | [diff] [blame] | 521 | } else if (fw->size % 8 == 0) { |
Olli Salonen | 1b97dc9 | 2014-11-27 16:42:23 -0300 | [diff] [blame] | 522 | /* firmware is in the old format */ |
Antti Palosaari | 68c16a7 | 2014-12-05 17:08:22 -0300 | [diff] [blame] | 523 | for (remaining = fw->size; remaining > 0; remaining -= 8) { |
| 524 | len = 8; |
Olli Salonen | 1b97dc9 | 2014-11-27 16:42:23 -0300 | [diff] [blame] | 525 | memcpy(cmd.args, &fw->data[fw->size - remaining], len); |
| 526 | cmd.wlen = len; |
| 527 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 528 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 68c16a7 | 2014-12-05 17:08:22 -0300 | [diff] [blame] | 529 | if (ret) |
| 530 | break; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 531 | } |
Antti Palosaari | 68c16a7 | 2014-12-05 17:08:22 -0300 | [diff] [blame] | 532 | } else { |
| 533 | /* bad or unknown firmware format */ |
| 534 | ret = -EINVAL; |
| 535 | } |
| 536 | |
| 537 | if (ret) { |
| 538 | dev_err(&client->dev, "firmware download failed %d\n", ret); |
| 539 | goto err_release_firmware; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | release_firmware(fw); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 543 | |
Antti Palosaari | 888680f | 2014-07-09 19:36:58 -0300 | [diff] [blame] | 544 | memcpy(cmd.args, "\x01\x01", 2); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 545 | cmd.wlen = 2; |
| 546 | cmd.rlen = 1; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 547 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 548 | if (ret) |
| 549 | goto err; |
| 550 | |
Olli Salonen | a594cf2 | 2014-11-27 16:42:22 -0300 | [diff] [blame] | 551 | /* query firmware version */ |
| 552 | memcpy(cmd.args, "\x11", 1); |
| 553 | cmd.wlen = 1; |
| 554 | cmd.rlen = 10; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 555 | ret = si2168_cmd_execute(client, &cmd); |
Olli Salonen | a594cf2 | 2014-11-27 16:42:22 -0300 | [diff] [blame] | 556 | if (ret) |
| 557 | goto err; |
| 558 | |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 559 | dev->version = (cmd.args[9] + '@') << 24 | (cmd.args[6] - '0') << 16 | |
| 560 | (cmd.args[7] - '0') << 8 | (cmd.args[8]) << 0; |
| 561 | dev_info(&client->dev, "firmware version: %c %d.%d.%d\n", |
| 562 | dev->version >> 24 & 0xff, dev->version >> 16 & 0xff, |
| 563 | dev->version >> 8 & 0xff, dev->version >> 0 & 0xff); |
Olli Salonen | a594cf2 | 2014-11-27 16:42:22 -0300 | [diff] [blame] | 564 | |
Brad Love | 1844f49 | 2018-02-12 15:19:04 -0500 | [diff] [blame] | 565 | /* set ts mode */ |
Brad Love | 4458777 | 2018-01-12 11:19:39 -0500 | [diff] [blame] | 566 | ret = si2168_ts_bus_ctrl(fe, 1); |
Olli Salonen | 389ce39 | 2014-08-11 16:58:10 -0300 | [diff] [blame] | 567 | if (ret) |
| 568 | goto err; |
| 569 | |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 570 | dev->warm = true; |
Antti Palosaari | 45c3cbb | 2014-11-03 18:28:39 -0300 | [diff] [blame] | 571 | warm: |
Antti Palosaari | 8393c00 | 2016-12-08 22:19:19 -0200 | [diff] [blame] | 572 | /* Init stats here to indicate which stats are supported */ |
| 573 | c->cnr.len = 1; |
| 574 | c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
| 575 | c->post_bit_error.len = 1; |
| 576 | c->post_bit_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
| 577 | c->post_bit_count.len = 1; |
| 578 | c->post_bit_count.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
Antti Palosaari | c62d29c | 2016-12-09 11:11:32 -0200 | [diff] [blame] | 579 | c->block_error.len = 1; |
| 580 | c->block_error.stat[0].scale = FE_SCALE_NOT_AVAILABLE; |
Antti Palosaari | 8393c00 | 2016-12-08 22:19:19 -0200 | [diff] [blame] | 581 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 582 | dev->active = true; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 583 | |
| 584 | return 0; |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 585 | err_release_firmware: |
Markus Elfring | 034e1ec | 2014-11-19 19:23:15 -0300 | [diff] [blame] | 586 | release_firmware(fw); |
| 587 | err: |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 588 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 589 | return ret; |
| 590 | } |
| 591 | |
| 592 | static int si2168_sleep(struct dvb_frontend *fe) |
| 593 | { |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 594 | struct i2c_client *client = fe->demodulator_priv; |
| 595 | struct si2168_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | 4de0ed7 | 2014-07-09 18:45:31 -0300 | [diff] [blame] | 596 | int ret; |
| 597 | struct si2168_cmd cmd; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 598 | |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 599 | dev_dbg(&client->dev, "\n"); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 600 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 601 | dev->active = false; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 602 | |
Brad Love | 4458777 | 2018-01-12 11:19:39 -0500 | [diff] [blame] | 603 | /* tri-state data bus */ |
Brad Love | 1844f49 | 2018-02-12 15:19:04 -0500 | [diff] [blame] | 604 | ret = si2168_ts_bus_ctrl(fe, 0); |
| 605 | if (ret) |
| 606 | goto err; |
Brad Love | 4458777 | 2018-01-12 11:19:39 -0500 | [diff] [blame] | 607 | |
Mauro Carvalho Chehab | fce61d1 | 2018-03-07 08:57:05 -0500 | [diff] [blame] | 608 | /* Firmware later than B 4.0-11 loses warm state during sleep */ |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 609 | if (dev->version > ('B' << 24 | 4 << 16 | 0 << 8 | 11 << 0)) |
| 610 | dev->warm = false; |
| 611 | |
Antti Palosaari | 4de0ed7 | 2014-07-09 18:45:31 -0300 | [diff] [blame] | 612 | memcpy(cmd.args, "\x13", 1); |
| 613 | cmd.wlen = 1; |
| 614 | cmd.rlen = 0; |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 615 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | 4de0ed7 | 2014-07-09 18:45:31 -0300 | [diff] [blame] | 616 | if (ret) |
| 617 | goto err; |
| 618 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 619 | return 0; |
Antti Palosaari | 4de0ed7 | 2014-07-09 18:45:31 -0300 | [diff] [blame] | 620 | err: |
Antti Palosaari | 3de3583 | 2014-11-25 17:53:21 -0300 | [diff] [blame] | 621 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 4de0ed7 | 2014-07-09 18:45:31 -0300 | [diff] [blame] | 622 | return ret; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | static int si2168_get_tune_settings(struct dvb_frontend *fe, |
| 626 | struct dvb_frontend_tune_settings *s) |
| 627 | { |
| 628 | s->min_delay_ms = 900; |
| 629 | |
| 630 | return 0; |
| 631 | } |
| 632 | |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 633 | static int si2168_select(struct i2c_mux_core *muxc, u32 chan) |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 634 | { |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 635 | struct i2c_client *client = i2c_mux_priv(muxc); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 636 | int ret; |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 637 | struct si2168_cmd cmd; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 638 | |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 639 | /* open I2C gate */ |
| 640 | memcpy(cmd.args, "\xc0\x0d\x01", 3); |
| 641 | cmd.wlen = 3; |
| 642 | cmd.rlen = 0; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 643 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 644 | if (ret) |
| 645 | goto err; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 646 | |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 647 | return 0; |
| 648 | err: |
| 649 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 650 | return ret; |
| 651 | } |
| 652 | |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 653 | static int si2168_deselect(struct i2c_mux_core *muxc, u32 chan) |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 654 | { |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 655 | struct i2c_client *client = i2c_mux_priv(muxc); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 656 | int ret; |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 657 | struct si2168_cmd cmd; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 658 | |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 659 | /* close I2C gate */ |
| 660 | memcpy(cmd.args, "\xc0\x0d\x00", 3); |
| 661 | cmd.wlen = 3; |
| 662 | cmd.rlen = 0; |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 663 | ret = si2168_cmd_execute(client, &cmd); |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 664 | if (ret) |
| 665 | goto err; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 666 | |
Antti Palosaari | d2b72f6 | 2015-05-29 16:42:33 -0300 | [diff] [blame] | 667 | return 0; |
| 668 | err: |
| 669 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 670 | return ret; |
| 671 | } |
| 672 | |
| 673 | static const struct dvb_frontend_ops si2168_ops = { |
Antti Palosaari | c790885 | 2014-04-12 01:58:32 -0300 | [diff] [blame] | 674 | .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A}, |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 675 | .info = { |
| 676 | .name = "Silicon Labs Si2168", |
Antti Palosaari | f1ecc5d | 2014-11-25 16:26:49 -0300 | [diff] [blame] | 677 | .symbol_rate_min = 1000000, |
| 678 | .symbol_rate_max = 7200000, |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 679 | .caps = FE_CAN_FEC_1_2 | |
| 680 | FE_CAN_FEC_2_3 | |
| 681 | FE_CAN_FEC_3_4 | |
| 682 | FE_CAN_FEC_5_6 | |
| 683 | FE_CAN_FEC_7_8 | |
| 684 | FE_CAN_FEC_AUTO | |
| 685 | FE_CAN_QPSK | |
| 686 | FE_CAN_QAM_16 | |
| 687 | FE_CAN_QAM_32 | |
| 688 | FE_CAN_QAM_64 | |
| 689 | FE_CAN_QAM_128 | |
| 690 | FE_CAN_QAM_256 | |
| 691 | FE_CAN_QAM_AUTO | |
| 692 | FE_CAN_TRANSMISSION_MODE_AUTO | |
| 693 | FE_CAN_GUARD_INTERVAL_AUTO | |
| 694 | FE_CAN_HIERARCHY_AUTO | |
| 695 | FE_CAN_MUTE_TS | |
Olli Salonen | 327eeb3 | 2014-09-23 13:53:09 -0300 | [diff] [blame] | 696 | FE_CAN_2G_MODULATION | |
| 697 | FE_CAN_MULTISTREAM |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 698 | }, |
| 699 | |
| 700 | .get_tune_settings = si2168_get_tune_settings, |
| 701 | |
| 702 | .init = si2168_init, |
| 703 | .sleep = si2168_sleep, |
| 704 | |
| 705 | .set_frontend = si2168_set_frontend, |
| 706 | |
| 707 | .read_status = si2168_read_status, |
| 708 | }; |
| 709 | |
| 710 | static int si2168_probe(struct i2c_client *client, |
| 711 | const struct i2c_device_id *id) |
| 712 | { |
| 713 | struct si2168_config *config = client->dev.platform_data; |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 714 | struct si2168_dev *dev; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 715 | int ret; |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 716 | struct si2168_cmd cmd; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 717 | |
Olli Salonen | 37b4e43 | 2014-08-05 08:54:08 -0300 | [diff] [blame] | 718 | dev_dbg(&client->dev, "\n"); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 719 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 720 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 721 | if (!dev) { |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 722 | ret = -ENOMEM; |
Antti Palosaari | 1ee5e7d | 2014-12-05 16:02:42 -0300 | [diff] [blame] | 723 | goto err; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 724 | } |
| 725 | |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 726 | i2c_set_clientdata(client, dev); |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 727 | mutex_init(&dev->i2c_mutex); |
| 728 | |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 729 | /* Initialize */ |
| 730 | memcpy(cmd.args, "\xc0\x12\x00\x0c\x00\x0d\x16\x00\x00\x00\x00\x00\x00", 13); |
| 731 | cmd.wlen = 13; |
| 732 | cmd.rlen = 0; |
| 733 | ret = si2168_cmd_execute(client, &cmd); |
| 734 | if (ret) |
| 735 | goto err_kfree; |
| 736 | |
| 737 | /* Power up */ |
| 738 | memcpy(cmd.args, "\xc0\x06\x01\x0f\x00\x20\x20\x01", 8); |
| 739 | cmd.wlen = 8; |
| 740 | cmd.rlen = 1; |
| 741 | ret = si2168_cmd_execute(client, &cmd); |
| 742 | if (ret) |
| 743 | goto err_kfree; |
| 744 | |
| 745 | /* Query chip revision */ |
| 746 | memcpy(cmd.args, "\x02", 1); |
| 747 | cmd.wlen = 1; |
| 748 | cmd.rlen = 13; |
| 749 | ret = si2168_cmd_execute(client, &cmd); |
| 750 | if (ret) |
| 751 | goto err_kfree; |
| 752 | |
| 753 | dev->chip_id = cmd.args[1] << 24 | cmd.args[2] << 16 | |
| 754 | cmd.args[3] << 8 | cmd.args[4] << 0; |
| 755 | |
| 756 | switch (dev->chip_id) { |
| 757 | case SI2168_CHIP_ID_A20: |
| 758 | dev->firmware_name = SI2168_A20_FIRMWARE; |
| 759 | break; |
| 760 | case SI2168_CHIP_ID_A30: |
| 761 | dev->firmware_name = SI2168_A30_FIRMWARE; |
| 762 | break; |
| 763 | case SI2168_CHIP_ID_B40: |
| 764 | dev->firmware_name = SI2168_B40_FIRMWARE; |
| 765 | break; |
Evgeny Plehov | 50d6446 | 2017-02-07 19:33:47 -0200 | [diff] [blame] | 766 | case SI2168_CHIP_ID_D60: |
| 767 | dev->firmware_name = SI2168_D60_FIRMWARE; |
| 768 | break; |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 769 | default: |
| 770 | dev_dbg(&client->dev, "unknown chip version Si21%d-%c%c%c\n", |
| 771 | cmd.args[2], cmd.args[1], cmd.args[3], cmd.args[4]); |
| 772 | ret = -ENODEV; |
| 773 | goto err_kfree; |
| 774 | } |
| 775 | |
| 776 | dev->version = (cmd.args[1]) << 24 | (cmd.args[3] - '0') << 16 | |
| 777 | (cmd.args[4] - '0') << 8 | (cmd.args[5]) << 0; |
| 778 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 779 | /* create mux i2c adapter for tuner */ |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 780 | dev->muxc = i2c_mux_alloc(client->adapter, &client->dev, |
Antti Palosaari | e6d7ffc | 2016-05-04 22:15:32 +0200 | [diff] [blame] | 781 | 1, 0, I2C_MUX_LOCKED, |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 782 | si2168_select, si2168_deselect); |
| 783 | if (!dev->muxc) { |
| 784 | ret = -ENOMEM; |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 785 | goto err_kfree; |
Luis Alves | 4d6efc7 | 2014-07-17 16:38:08 -0300 | [diff] [blame] | 786 | } |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 787 | dev->muxc->priv = client; |
| 788 | ret = i2c_mux_add_adapter(dev->muxc, 0, 0, 0); |
| 789 | if (ret) |
| 790 | goto err_kfree; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 791 | |
| 792 | /* create dvb_frontend */ |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 793 | memcpy(&dev->fe.ops, &si2168_ops, sizeof(struct dvb_frontend_ops)); |
Antti Palosaari | 6307b56 | 2014-11-25 17:31:43 -0300 | [diff] [blame] | 794 | dev->fe.demodulator_priv = client; |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 795 | *config->i2c_adapter = dev->muxc->adapter[0]; |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 796 | *config->fe = &dev->fe; |
| 797 | dev->ts_mode = config->ts_mode; |
| 798 | dev->ts_clock_inv = config->ts_clock_inv; |
Olli Salonen | 8117a31 | 2015-05-05 13:54:14 -0300 | [diff] [blame] | 799 | dev->ts_clock_gapped = config->ts_clock_gapped; |
Brad Love | d4c779b | 2018-01-17 17:31:58 -0500 | [diff] [blame] | 800 | dev->spectral_inversion = config->spectral_inversion; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 801 | |
Antti Palosaari | 6ab1e94 | 2016-06-29 20:38:17 -0300 | [diff] [blame] | 802 | dev_info(&client->dev, "Silicon Labs Si2168-%c%d%d successfully identified\n", |
| 803 | dev->version >> 24 & 0xff, dev->version >> 16 & 0xff, |
| 804 | dev->version >> 8 & 0xff); |
| 805 | dev_info(&client->dev, "firmware version: %c %d.%d.%d\n", |
| 806 | dev->version >> 24 & 0xff, dev->version >> 16 & 0xff, |
| 807 | dev->version >> 8 & 0xff, dev->version >> 0 & 0xff); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 808 | |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 809 | return 0; |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 810 | err_kfree: |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 811 | kfree(dev); |
Antti Palosaari | 1ee5e7d | 2014-12-05 16:02:42 -0300 | [diff] [blame] | 812 | err: |
Brad Love | 3061df0 | 2018-01-12 11:19:40 -0500 | [diff] [blame] | 813 | dev_warn(&client->dev, "probe failed = %d\n", ret); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 814 | return ret; |
| 815 | } |
| 816 | |
| 817 | static int si2168_remove(struct i2c_client *client) |
| 818 | { |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 819 | struct si2168_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 820 | |
Olli Salonen | 37b4e43 | 2014-08-05 08:54:08 -0300 | [diff] [blame] | 821 | dev_dbg(&client->dev, "\n"); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 822 | |
Peter Rosin | 58d7b54 | 2016-04-20 08:41:36 +0200 | [diff] [blame] | 823 | i2c_mux_del_adapters(dev->muxc); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 824 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 825 | dev->fe.ops.release = NULL; |
| 826 | dev->fe.demodulator_priv = NULL; |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 827 | |
Antti Palosaari | bd01c76 | 2014-11-25 16:46:16 -0300 | [diff] [blame] | 828 | kfree(dev); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 829 | |
| 830 | return 0; |
| 831 | } |
| 832 | |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 833 | static const struct i2c_device_id si2168_id_table[] = { |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 834 | {"si2168", 0}, |
| 835 | {} |
| 836 | }; |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 837 | MODULE_DEVICE_TABLE(i2c, si2168_id_table); |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 838 | |
| 839 | static struct i2c_driver si2168_driver = { |
| 840 | .driver = { |
Antti Palosaari | e06be1d | 2016-06-29 20:38:18 -0300 | [diff] [blame] | 841 | .name = "si2168", |
| 842 | .suppress_bind_attrs = true, |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 843 | }, |
| 844 | .probe = si2168_probe, |
| 845 | .remove = si2168_remove, |
Antti Palosaari | 346d490 | 2014-12-05 14:54:14 -0300 | [diff] [blame] | 846 | .id_table = si2168_id_table, |
Antti Palosaari | 845f350 | 2014-04-10 22:00:50 -0300 | [diff] [blame] | 847 | }; |
| 848 | |
| 849 | module_i2c_driver(si2168_driver); |
| 850 | |
| 851 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
| 852 | MODULE_DESCRIPTION("Silicon Labs Si2168 DVB-T/T2/C demodulator driver"); |
| 853 | MODULE_LICENSE("GPL"); |
Luis Alves | 635a90c | 2014-07-17 19:43:37 -0300 | [diff] [blame] | 854 | MODULE_FIRMWARE(SI2168_A20_FIRMWARE); |
Antti Palosaari | 668aa63 | 2014-07-13 16:09:03 -0300 | [diff] [blame] | 855 | MODULE_FIRMWARE(SI2168_A30_FIRMWARE); |
Olli Salonen | c9cb082 | 2014-07-13 10:52:18 -0300 | [diff] [blame] | 856 | MODULE_FIRMWARE(SI2168_B40_FIRMWARE); |
Evgeny Plehov | 50d6446 | 2017-02-07 19:33:47 -0200 | [diff] [blame] | 857 | MODULE_FIRMWARE(SI2168_D60_FIRMWARE); |