Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 1 | /* |
| 2 | * Panasonic MN88473 DVB-T/T2/C demodulator driver |
| 3 | * |
| 4 | * Copyright (C) 2014 Antti Palosaari <crope@iki.fi> |
| 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | */ |
| 16 | |
| 17 | #include "mn88473_priv.h" |
| 18 | |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 19 | static int mn88473_get_tune_settings(struct dvb_frontend *fe, |
Katie Dunne | b4c2c31 | 2015-02-18 18:05:40 -0800 | [diff] [blame] | 20 | struct dvb_frontend_tune_settings *s) |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 21 | { |
| 22 | s->min_delay_ms = 1000; |
| 23 | return 0; |
| 24 | } |
| 25 | |
| 26 | static int mn88473_set_frontend(struct dvb_frontend *fe) |
| 27 | { |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 28 | struct i2c_client *client = fe->demodulator_priv; |
| 29 | struct mn88473_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 30 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 31 | int ret, i; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 32 | unsigned int uitmp; |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 33 | u32 if_frequency; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 34 | u8 delivery_system_val, if_val[3], *conf_val_ptr; |
| 35 | u8 reg_bank2_2d_val, reg_bank0_d2_val; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 36 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 37 | dev_dbg(&client->dev, |
Katie Dunne | b4c2c31 | 2015-02-18 18:05:40 -0800 | [diff] [blame] | 38 | "delivery_system=%u modulation=%u frequency=%u bandwidth_hz=%u symbol_rate=%u inversion=%d stream_id=%d\n", |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 39 | c->delivery_system, c->modulation, c->frequency, |
| 40 | c->bandwidth_hz, c->symbol_rate, c->inversion, c->stream_id); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 41 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 42 | if (!dev->active) { |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 43 | ret = -EAGAIN; |
| 44 | goto err; |
| 45 | } |
| 46 | |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 47 | switch (c->delivery_system) { |
Antti Palosaari | 6ebbe22 | 2014-09-30 19:56:22 -0300 | [diff] [blame] | 48 | case SYS_DVBT: |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 49 | delivery_system_val = 0x02; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 50 | reg_bank2_2d_val = 0x23; |
| 51 | reg_bank0_d2_val = 0x2a; |
Antti Palosaari | 6ebbe22 | 2014-09-30 19:56:22 -0300 | [diff] [blame] | 52 | break; |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 53 | case SYS_DVBT2: |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 54 | delivery_system_val = 0x03; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 55 | reg_bank2_2d_val = 0x3b; |
| 56 | reg_bank0_d2_val = 0x29; |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 57 | break; |
| 58 | case SYS_DVBC_ANNEX_A: |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 59 | delivery_system_val = 0x04; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 60 | reg_bank2_2d_val = 0x3b; |
| 61 | reg_bank0_d2_val = 0x29; |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 62 | break; |
| 63 | default: |
| 64 | ret = -EINVAL; |
| 65 | goto err; |
| 66 | } |
| 67 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 68 | switch (c->delivery_system) { |
| 69 | case SYS_DVBT: |
| 70 | case SYS_DVBT2: |
| 71 | switch (c->bandwidth_hz) { |
| 72 | case 6000000: |
| 73 | conf_val_ptr = "\xe9\x55\x55\x1c\x29\x1c\x29"; |
| 74 | break; |
| 75 | case 7000000: |
| 76 | conf_val_ptr = "\xc8\x00\x00\x17\x0a\x17\x0a"; |
| 77 | break; |
| 78 | case 8000000: |
| 79 | conf_val_ptr = "\xaf\x00\x00\x11\xec\x11\xec"; |
| 80 | break; |
| 81 | default: |
| 82 | ret = -EINVAL; |
| 83 | goto err; |
| 84 | } |
| 85 | break; |
| 86 | case SYS_DVBC_ANNEX_A: |
| 87 | conf_val_ptr = "\x10\xab\x0d\xae\x1d\x9d"; |
| 88 | break; |
| 89 | default: |
| 90 | break; |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 91 | } |
| 92 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 93 | /* Program tuner */ |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 94 | if (fe->ops.tuner_ops.set_params) { |
| 95 | ret = fe->ops.tuner_ops.set_params(fe); |
| 96 | if (ret) |
| 97 | goto err; |
| 98 | } |
| 99 | |
| 100 | if (fe->ops.tuner_ops.get_if_frequency) { |
| 101 | ret = fe->ops.tuner_ops.get_if_frequency(fe, &if_frequency); |
| 102 | if (ret) |
| 103 | goto err; |
| 104 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 105 | dev_dbg(&client->dev, "get_if_frequency=%u\n", if_frequency); |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 106 | } else { |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 107 | ret = -EINVAL; |
| 108 | goto err; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 109 | } |
| 110 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 111 | /* Calculate IF registers */ |
| 112 | uitmp = DIV_ROUND_CLOSEST_ULL((u64) if_frequency * 0x1000000, dev->clk); |
| 113 | if_val[0] = (uitmp >> 16) & 0xff; |
| 114 | if_val[1] = (uitmp >> 8) & 0xff; |
| 115 | if_val[2] = (uitmp >> 0) & 0xff; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 116 | |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 117 | ret = regmap_write(dev->regmap[2], 0x05, 0x00); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 118 | if (ret) |
| 119 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 120 | ret = regmap_write(dev->regmap[2], 0xfb, 0x13); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 121 | if (ret) |
| 122 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 123 | ret = regmap_write(dev->regmap[2], 0xef, 0x13); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 124 | if (ret) |
| 125 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 126 | ret = regmap_write(dev->regmap[2], 0xf9, 0x13); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 127 | if (ret) |
| 128 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 129 | ret = regmap_write(dev->regmap[2], 0x00, 0x18); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 130 | if (ret) |
| 131 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 132 | ret = regmap_write(dev->regmap[2], 0x01, 0x01); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 133 | if (ret) |
| 134 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 135 | ret = regmap_write(dev->regmap[2], 0x02, 0x21); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 136 | if (ret) |
| 137 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 138 | ret = regmap_write(dev->regmap[2], 0x03, delivery_system_val); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 139 | if (ret) |
| 140 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 141 | ret = regmap_write(dev->regmap[2], 0x0b, 0x00); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 142 | if (ret) |
| 143 | goto err; |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 144 | |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 145 | for (i = 0; i < sizeof(if_val); i++) { |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 146 | ret = regmap_write(dev->regmap[2], 0x10 + i, if_val[i]); |
Antti Palosaari | df810e8 | 2014-09-30 23:19:30 -0300 | [diff] [blame] | 147 | if (ret) |
| 148 | goto err; |
| 149 | } |
| 150 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 151 | switch (c->delivery_system) { |
| 152 | case SYS_DVBT: |
| 153 | case SYS_DVBT2: |
| 154 | for (i = 0; i < 7; i++) { |
| 155 | ret = regmap_write(dev->regmap[2], 0x13 + i, |
| 156 | conf_val_ptr[i]); |
| 157 | if (ret) |
| 158 | goto err; |
| 159 | } |
| 160 | break; |
| 161 | case SYS_DVBC_ANNEX_A: |
| 162 | ret = regmap_bulk_write(dev->regmap[1], 0x10, conf_val_ptr, 6); |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 163 | if (ret) |
| 164 | goto err; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 165 | break; |
| 166 | default: |
| 167 | break; |
Antti Palosaari | c00a6b9 | 2014-09-30 17:52:03 -0300 | [diff] [blame] | 168 | } |
| 169 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 170 | ret = regmap_write(dev->regmap[2], 0x2d, reg_bank2_2d_val); |
| 171 | if (ret) |
| 172 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 173 | ret = regmap_write(dev->regmap[2], 0x2e, 0x00); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 174 | if (ret) |
| 175 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 176 | ret = regmap_write(dev->regmap[2], 0x56, 0x0d); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 177 | if (ret) |
| 178 | goto err; |
| 179 | ret = regmap_bulk_write(dev->regmap[0], 0x01, |
| 180 | "\xba\x13\x80\xba\x91\xdd\xe7\x28", 8); |
| 181 | if (ret) |
| 182 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 183 | ret = regmap_write(dev->regmap[0], 0x0a, 0x1a); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 184 | if (ret) |
| 185 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 186 | ret = regmap_write(dev->regmap[0], 0x13, 0x1f); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 187 | if (ret) |
| 188 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 189 | ret = regmap_write(dev->regmap[0], 0x19, 0x03); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 190 | if (ret) |
| 191 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 192 | ret = regmap_write(dev->regmap[0], 0x1d, 0xb0); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 193 | if (ret) |
| 194 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 195 | ret = regmap_write(dev->regmap[0], 0x2a, 0x72); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 196 | if (ret) |
| 197 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 198 | ret = regmap_write(dev->regmap[0], 0x2d, 0x00); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 199 | if (ret) |
| 200 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 201 | ret = regmap_write(dev->regmap[0], 0x3c, 0x00); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 202 | if (ret) |
| 203 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 204 | ret = regmap_write(dev->regmap[0], 0x3f, 0xf8); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 205 | if (ret) |
| 206 | goto err; |
| 207 | ret = regmap_bulk_write(dev->regmap[0], 0x40, "\xf4\x08", 2); |
| 208 | if (ret) |
| 209 | goto err; |
| 210 | ret = regmap_write(dev->regmap[0], 0xd2, reg_bank0_d2_val); |
| 211 | if (ret) |
| 212 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 213 | ret = regmap_write(dev->regmap[0], 0xd4, 0x55); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 214 | if (ret) |
| 215 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 216 | ret = regmap_write(dev->regmap[1], 0xbe, 0x08); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 217 | if (ret) |
| 218 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 219 | ret = regmap_write(dev->regmap[0], 0xb2, 0x37); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 220 | if (ret) |
| 221 | goto err; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 222 | ret = regmap_write(dev->regmap[0], 0xd7, 0x04); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 223 | if (ret) |
| 224 | goto err; |
| 225 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 226 | /* Reset FSM */ |
| 227 | ret = regmap_write(dev->regmap[2], 0xf8, 0x9f); |
| 228 | if (ret) |
| 229 | goto err; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 230 | |
| 231 | return 0; |
| 232 | err: |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 233 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 234 | return ret; |
| 235 | } |
| 236 | |
Mauro Carvalho Chehab | 0df289a | 2015-06-07 14:53:52 -0300 | [diff] [blame] | 237 | static int mn88473_read_status(struct dvb_frontend *fe, enum fe_status *status) |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 238 | { |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 239 | struct i2c_client *client = fe->demodulator_priv; |
| 240 | struct mn88473_dev *dev = i2c_get_clientdata(client); |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 241 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 242 | int ret; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 243 | unsigned int uitmp; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 244 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 245 | if (!dev->active) { |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 246 | ret = -EAGAIN; |
| 247 | goto err; |
| 248 | } |
| 249 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 250 | *status = 0; |
| 251 | |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 252 | switch (c->delivery_system) { |
| 253 | case SYS_DVBT: |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 254 | ret = regmap_read(dev->regmap[0], 0x62, &uitmp); |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 255 | if (ret) |
| 256 | goto err; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 257 | |
| 258 | if (!(uitmp & 0xa0)) { |
| 259 | if ((uitmp & 0x0f) >= 0x09) |
| 260 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | |
| 261 | FE_HAS_VITERBI | FE_HAS_SYNC | |
| 262 | FE_HAS_LOCK; |
| 263 | else if ((uitmp & 0x0f) >= 0x03) |
| 264 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER; |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 265 | } |
| 266 | break; |
| 267 | case SYS_DVBT2: |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 268 | ret = regmap_read(dev->regmap[2], 0x8b, &uitmp); |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 269 | if (ret) |
| 270 | goto err; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 271 | |
| 272 | if (!(uitmp & 0x40)) { |
| 273 | if ((uitmp & 0x0f) >= 0x0d) |
| 274 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | |
| 275 | FE_HAS_VITERBI | FE_HAS_SYNC | |
| 276 | FE_HAS_LOCK; |
| 277 | else if ((uitmp & 0x0f) >= 0x0a) |
| 278 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | |
| 279 | FE_HAS_VITERBI; |
| 280 | else if ((uitmp & 0x0f) >= 0x07) |
| 281 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER; |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 282 | } |
| 283 | break; |
| 284 | case SYS_DVBC_ANNEX_A: |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 285 | ret = regmap_read(dev->regmap[1], 0x85, &uitmp); |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 286 | if (ret) |
| 287 | goto err; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 288 | |
| 289 | if (!(uitmp & 0x40)) { |
| 290 | ret = regmap_read(dev->regmap[1], 0x89, &uitmp); |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 291 | if (ret) |
| 292 | goto err; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 293 | |
| 294 | if (uitmp & 0x01) |
| 295 | *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | |
| 296 | FE_HAS_VITERBI | FE_HAS_SYNC | |
| 297 | FE_HAS_LOCK; |
Benjamin Larsson | 0aa83bb | 2015-03-21 07:18:07 -0300 | [diff] [blame] | 298 | } |
| 299 | break; |
| 300 | default: |
| 301 | ret = -EINVAL; |
| 302 | goto err; |
| 303 | } |
| 304 | |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 305 | return 0; |
| 306 | err: |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 307 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 308 | return ret; |
| 309 | } |
| 310 | |
| 311 | static int mn88473_init(struct dvb_frontend *fe) |
| 312 | { |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 313 | struct i2c_client *client = fe->demodulator_priv; |
| 314 | struct mn88473_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 315 | int ret, len, remain; |
| 316 | unsigned int uitmp; |
| 317 | const struct firmware *fw; |
| 318 | const char *name = MN88473_FIRMWARE; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 319 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 320 | dev_dbg(&client->dev, "\n"); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 321 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 322 | /* Check if firmware is already running */ |
| 323 | ret = regmap_read(dev->regmap[0], 0xf5, &uitmp); |
Benjamin Larsson | 567627b | 2015-03-15 19:57:53 -0300 | [diff] [blame] | 324 | if (ret) |
| 325 | goto err; |
| 326 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 327 | if (!(uitmp & 0x01)) |
| 328 | goto warm; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 329 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 330 | /* Request the firmware, this will block and timeout */ |
| 331 | ret = request_firmware(&fw, name, &client->dev); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 332 | if (ret) { |
Julia Lawall | c5ee19c | 2016-05-17 11:38:41 -0300 | [diff] [blame] | 333 | dev_err(&client->dev, "firmware file '%s' not found\n", name); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 334 | goto err; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 335 | } |
| 336 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 337 | dev_info(&client->dev, "downloading firmware from file '%s'\n", name); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 338 | |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 339 | ret = regmap_write(dev->regmap[0], 0xf5, 0x03); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 340 | if (ret) |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 341 | goto err_release_firmware; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 342 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 343 | for (remain = fw->size; remain > 0; remain -= (dev->i2c_wr_max - 1)) { |
| 344 | len = min(dev->i2c_wr_max - 1, remain); |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 345 | ret = regmap_bulk_write(dev->regmap[0], 0xf6, |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 346 | &fw->data[fw->size - remain], len); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 347 | if (ret) { |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 348 | dev_err(&client->dev, "firmware download failed %d\n", |
Katie Dunne | b4c2c31 | 2015-02-18 18:05:40 -0800 | [diff] [blame] | 349 | ret); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 350 | goto err_release_firmware; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 351 | } |
| 352 | } |
| 353 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 354 | release_firmware(fw); |
| 355 | |
| 356 | /* Parity check of firmware */ |
| 357 | ret = regmap_read(dev->regmap[0], 0xf8, &uitmp); |
| 358 | if (ret) |
| 359 | goto err; |
| 360 | |
| 361 | if (uitmp & 0x10) { |
| 362 | dev_err(&client->dev, "firmware parity check failed\n"); |
| 363 | ret = -EINVAL; |
Benjamin Larsson | 0f21ac7 | 2015-03-15 19:57:52 -0300 | [diff] [blame] | 364 | goto err; |
| 365 | } |
Benjamin Larsson | 0f21ac7 | 2015-03-15 19:57:52 -0300 | [diff] [blame] | 366 | |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 367 | ret = regmap_write(dev->regmap[0], 0xf5, 0x00); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 368 | if (ret) |
| 369 | goto err; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 370 | warm: |
| 371 | /* TS config */ |
| 372 | ret = regmap_write(dev->regmap[2], 0x09, 0x08); |
| 373 | if (ret) |
| 374 | goto err; |
| 375 | ret = regmap_write(dev->regmap[2], 0x08, 0x1d); |
| 376 | if (ret) |
| 377 | goto err; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 378 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 379 | dev->active = true; |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 380 | |
| 381 | return 0; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 382 | err_release_firmware: |
Markus Elfring | b591138 | 2014-12-01 18:55:29 -0300 | [diff] [blame] | 383 | release_firmware(fw); |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 384 | err: |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 385 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 386 | return ret; |
| 387 | } |
| 388 | |
| 389 | static int mn88473_sleep(struct dvb_frontend *fe) |
| 390 | { |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 391 | struct i2c_client *client = fe->demodulator_priv; |
| 392 | struct mn88473_dev *dev = i2c_get_clientdata(client); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 393 | int ret; |
| 394 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 395 | dev_dbg(&client->dev, "\n"); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 396 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 397 | dev->active = false; |
| 398 | |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 399 | ret = regmap_write(dev->regmap[2], 0x05, 0x3e); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 400 | if (ret) |
| 401 | goto err; |
| 402 | |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 403 | return 0; |
| 404 | err: |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 405 | dev_dbg(&client->dev, "failed=%d\n", ret); |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 406 | return ret; |
| 407 | } |
| 408 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 409 | static const struct dvb_frontend_ops mn88473_ops = { |
| 410 | .delsys = {SYS_DVBT, SYS_DVBT2, SYS_DVBC_ANNEX_A}, |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 411 | .info = { |
| 412 | .name = "Panasonic MN88473", |
Antti Palosaari | 8459e41 | 2015-03-16 18:56:21 -0300 | [diff] [blame] | 413 | .symbol_rate_min = 1000000, |
| 414 | .symbol_rate_max = 7200000, |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 415 | .caps = FE_CAN_FEC_1_2 | |
| 416 | FE_CAN_FEC_2_3 | |
| 417 | FE_CAN_FEC_3_4 | |
| 418 | FE_CAN_FEC_5_6 | |
| 419 | FE_CAN_FEC_7_8 | |
| 420 | FE_CAN_FEC_AUTO | |
| 421 | FE_CAN_QPSK | |
| 422 | FE_CAN_QAM_16 | |
| 423 | FE_CAN_QAM_32 | |
| 424 | FE_CAN_QAM_64 | |
| 425 | FE_CAN_QAM_128 | |
| 426 | FE_CAN_QAM_256 | |
| 427 | FE_CAN_QAM_AUTO | |
| 428 | FE_CAN_TRANSMISSION_MODE_AUTO | |
| 429 | FE_CAN_GUARD_INTERVAL_AUTO | |
| 430 | FE_CAN_HIERARCHY_AUTO | |
| 431 | FE_CAN_MUTE_TS | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 432 | FE_CAN_2G_MODULATION |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 433 | }, |
| 434 | |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 435 | .get_tune_settings = mn88473_get_tune_settings, |
| 436 | |
| 437 | .init = mn88473_init, |
| 438 | .sleep = mn88473_sleep, |
| 439 | |
| 440 | .set_frontend = mn88473_set_frontend, |
| 441 | |
| 442 | .read_status = mn88473_read_status, |
| 443 | }; |
| 444 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 445 | static int mn88473_probe(struct i2c_client *client, |
Katie Dunne | b4c2c31 | 2015-02-18 18:05:40 -0800 | [diff] [blame] | 446 | const struct i2c_device_id *id) |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 447 | { |
| 448 | struct mn88473_config *config = client->dev.platform_data; |
| 449 | struct mn88473_dev *dev; |
| 450 | int ret; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 451 | unsigned int uitmp; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 452 | static const struct regmap_config regmap_config = { |
| 453 | .reg_bits = 8, |
| 454 | .val_bits = 8, |
| 455 | }; |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 456 | |
| 457 | dev_dbg(&client->dev, "\n"); |
| 458 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 459 | /* Caller really need to provide pointer for frontend we create */ |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 460 | if (config->fe == NULL) { |
| 461 | dev_err(&client->dev, "frontend pointer not defined\n"); |
| 462 | ret = -EINVAL; |
| 463 | goto err; |
| 464 | } |
| 465 | |
| 466 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 467 | if (dev == NULL) { |
| 468 | ret = -ENOMEM; |
| 469 | goto err; |
| 470 | } |
| 471 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 472 | if (config->i2c_wr_max) |
| 473 | dev->i2c_wr_max = config->i2c_wr_max; |
Benjamin Larsson | 3b786f1 | 2015-01-12 20:23:25 -0300 | [diff] [blame] | 474 | else |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 475 | dev->i2c_wr_max = ~0; |
| 476 | |
| 477 | if (config->xtal) |
| 478 | dev->clk = config->xtal; |
| 479 | else |
| 480 | dev->clk = 25000000; |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 481 | dev->client[0] = client; |
| 482 | dev->regmap[0] = regmap_init_i2c(dev->client[0], ®map_config); |
| 483 | if (IS_ERR(dev->regmap[0])) { |
| 484 | ret = PTR_ERR(dev->regmap[0]); |
| 485 | goto err_kfree; |
| 486 | } |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 487 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 488 | /* Check demod answers with correct chip id */ |
| 489 | ret = regmap_read(dev->regmap[0], 0xff, &uitmp); |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 490 | if (ret) |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 491 | goto err_regmap_0_regmap_exit; |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 492 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 493 | dev_dbg(&client->dev, "chip id=%02x\n", uitmp); |
| 494 | |
| 495 | if (uitmp != 0x03) { |
| 496 | ret = -ENODEV; |
| 497 | goto err_regmap_0_regmap_exit; |
| 498 | } |
| 499 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 500 | /* |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 501 | * Chip has three I2C addresses for different register banks. Used |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 502 | * addresses are 0x18, 0x1a and 0x1c. We register two dummy clients, |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 503 | * 0x1a and 0x1c, in order to get own I2C client for each register bank. |
| 504 | * |
| 505 | * Also, register bank 2 do not support sequential I/O. Only single |
| 506 | * register write or read is allowed to that bank. |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 507 | */ |
| 508 | dev->client[1] = i2c_new_dummy(client->adapter, 0x1a); |
| 509 | if (dev->client[1] == NULL) { |
| 510 | ret = -ENODEV; |
| 511 | dev_err(&client->dev, "I2C registration failed\n"); |
| 512 | if (ret) |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 513 | goto err_regmap_0_regmap_exit; |
| 514 | } |
| 515 | dev->regmap[1] = regmap_init_i2c(dev->client[1], ®map_config); |
| 516 | if (IS_ERR(dev->regmap[1])) { |
| 517 | ret = PTR_ERR(dev->regmap[1]); |
| 518 | goto err_client_1_i2c_unregister_device; |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 519 | } |
| 520 | i2c_set_clientdata(dev->client[1], dev); |
| 521 | |
| 522 | dev->client[2] = i2c_new_dummy(client->adapter, 0x1c); |
| 523 | if (dev->client[2] == NULL) { |
| 524 | ret = -ENODEV; |
| 525 | dev_err(&client->dev, "2nd I2C registration failed\n"); |
| 526 | if (ret) |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 527 | goto err_regmap_1_regmap_exit; |
| 528 | } |
| 529 | dev->regmap[2] = regmap_init_i2c(dev->client[2], ®map_config); |
| 530 | if (IS_ERR(dev->regmap[2])) { |
| 531 | ret = PTR_ERR(dev->regmap[2]); |
| 532 | goto err_client_2_i2c_unregister_device; |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 533 | } |
| 534 | i2c_set_clientdata(dev->client[2], dev); |
| 535 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 536 | /* Sleep because chip is active by default */ |
| 537 | ret = regmap_write(dev->regmap[2], 0x05, 0x3e); |
| 538 | if (ret) |
Antti Palosaari | 37cf9b2 | 2016-05-14 02:29:21 -0300 | [diff] [blame] | 539 | goto err_regmap_2_regmap_exit; |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 540 | |
| 541 | /* Create dvb frontend */ |
| 542 | memcpy(&dev->frontend.ops, &mn88473_ops, sizeof(dev->frontend.ops)); |
| 543 | dev->frontend.demodulator_priv = client; |
| 544 | *config->fe = &dev->frontend; |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 545 | i2c_set_clientdata(client, dev); |
| 546 | |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 547 | dev_info(&client->dev, "Panasonic MN88473 successfully identified\n"); |
| 548 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 549 | return 0; |
Antti Palosaari | 37cf9b2 | 2016-05-14 02:29:21 -0300 | [diff] [blame] | 550 | err_regmap_2_regmap_exit: |
| 551 | regmap_exit(dev->regmap[2]); |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 552 | err_client_2_i2c_unregister_device: |
| 553 | i2c_unregister_device(dev->client[2]); |
| 554 | err_regmap_1_regmap_exit: |
| 555 | regmap_exit(dev->regmap[1]); |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 556 | err_client_1_i2c_unregister_device: |
| 557 | i2c_unregister_device(dev->client[1]); |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 558 | err_regmap_0_regmap_exit: |
| 559 | regmap_exit(dev->regmap[0]); |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 560 | err_kfree: |
| 561 | kfree(dev); |
| 562 | err: |
| 563 | dev_dbg(&client->dev, "failed=%d\n", ret); |
| 564 | return ret; |
| 565 | } |
| 566 | |
| 567 | static int mn88473_remove(struct i2c_client *client) |
| 568 | { |
| 569 | struct mn88473_dev *dev = i2c_get_clientdata(client); |
| 570 | |
| 571 | dev_dbg(&client->dev, "\n"); |
| 572 | |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 573 | regmap_exit(dev->regmap[2]); |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 574 | i2c_unregister_device(dev->client[2]); |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 575 | |
| 576 | regmap_exit(dev->regmap[1]); |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 577 | i2c_unregister_device(dev->client[1]); |
| 578 | |
Antti Palosaari | 97de6e8 | 2014-10-03 00:28:18 -0300 | [diff] [blame] | 579 | regmap_exit(dev->regmap[0]); |
| 580 | |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 581 | kfree(dev); |
| 582 | |
| 583 | return 0; |
| 584 | } |
| 585 | |
| 586 | static const struct i2c_device_id mn88473_id_table[] = { |
| 587 | {"mn88473", 0}, |
| 588 | {} |
| 589 | }; |
| 590 | MODULE_DEVICE_TABLE(i2c, mn88473_id_table); |
| 591 | |
| 592 | static struct i2c_driver mn88473_driver = { |
| 593 | .driver = { |
Antti Palosaari | 7908fad | 2016-02-04 17:01:51 -0200 | [diff] [blame] | 594 | .name = "mn88473", |
| 595 | .suppress_bind_attrs = true, |
Antti Palosaari | 01b4be1 | 2014-10-02 22:41:26 -0300 | [diff] [blame] | 596 | }, |
| 597 | .probe = mn88473_probe, |
| 598 | .remove = mn88473_remove, |
| 599 | .id_table = mn88473_id_table, |
| 600 | }; |
| 601 | |
| 602 | module_i2c_driver(mn88473_driver); |
| 603 | |
Antti Palosaari | dadb5bb | 2014-09-30 01:01:47 -0300 | [diff] [blame] | 604 | MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); |
| 605 | MODULE_DESCRIPTION("Panasonic MN88473 DVB-T/T2/C demodulator driver"); |
| 606 | MODULE_LICENSE("GPL"); |
| 607 | MODULE_FIRMWARE(MN88473_FIRMWARE); |