1395d00d1SAntti Palosaari /* 2f4df95bcSnibble.max * Montage M88DS3103/M88RS6000 demodulator driver 3395d00d1SAntti Palosaari * 4395d00d1SAntti Palosaari * Copyright (C) 2013 Antti Palosaari <crope@iki.fi> 5395d00d1SAntti Palosaari * 6395d00d1SAntti Palosaari * This program is free software; you can redistribute it and/or modify 7395d00d1SAntti Palosaari * it under the terms of the GNU General Public License as published by 8395d00d1SAntti Palosaari * the Free Software Foundation; either version 2 of the License, or 9395d00d1SAntti Palosaari * (at your option) any later version. 10395d00d1SAntti Palosaari * 11395d00d1SAntti Palosaari * This program is distributed in the hope that it will be useful, 12395d00d1SAntti Palosaari * but WITHOUT ANY WARRANTY; without even the implied warranty of 13395d00d1SAntti Palosaari * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14395d00d1SAntti Palosaari * GNU General Public License for more details. 15395d00d1SAntti Palosaari */ 16395d00d1SAntti Palosaari 17395d00d1SAntti Palosaari #include "m88ds3103_priv.h" 18395d00d1SAntti Palosaari 19395d00d1SAntti Palosaari static struct dvb_frontend_ops m88ds3103_ops; 20395d00d1SAntti Palosaari 21395d00d1SAntti Palosaari /* write multiple registers */ 22395d00d1SAntti Palosaari static int m88ds3103_wr_regs(struct m88ds3103_priv *priv, 23395d00d1SAntti Palosaari u8 reg, const u8 *val, int len) 24395d00d1SAntti Palosaari { 2563c80f70SAntti Palosaari #define MAX_WR_LEN 32 2663c80f70SAntti Palosaari #define MAX_WR_XFER_LEN (MAX_WR_LEN + 1) 27395d00d1SAntti Palosaari int ret; 2863c80f70SAntti Palosaari u8 buf[MAX_WR_XFER_LEN]; 29395d00d1SAntti Palosaari struct i2c_msg msg[1] = { 30395d00d1SAntti Palosaari { 31395d00d1SAntti Palosaari .addr = priv->cfg->i2c_addr, 32395d00d1SAntti Palosaari .flags = 0, 3363c80f70SAntti Palosaari .len = 1 + len, 34395d00d1SAntti Palosaari .buf = buf, 35395d00d1SAntti Palosaari } 36395d00d1SAntti Palosaari }; 37395d00d1SAntti Palosaari 3863c80f70SAntti Palosaari if (WARN_ON(len > MAX_WR_LEN)) 3963c80f70SAntti Palosaari return -EINVAL; 4063c80f70SAntti Palosaari 41395d00d1SAntti Palosaari buf[0] = reg; 42395d00d1SAntti Palosaari memcpy(&buf[1], val, len); 43395d00d1SAntti Palosaari 44395d00d1SAntti Palosaari mutex_lock(&priv->i2c_mutex); 45395d00d1SAntti Palosaari ret = i2c_transfer(priv->i2c, msg, 1); 46395d00d1SAntti Palosaari mutex_unlock(&priv->i2c_mutex); 47395d00d1SAntti Palosaari if (ret == 1) { 48395d00d1SAntti Palosaari ret = 0; 49395d00d1SAntti Palosaari } else { 50395d00d1SAntti Palosaari dev_warn(&priv->i2c->dev, 51395d00d1SAntti Palosaari "%s: i2c wr failed=%d reg=%02x len=%d\n", 52395d00d1SAntti Palosaari KBUILD_MODNAME, ret, reg, len); 53395d00d1SAntti Palosaari ret = -EREMOTEIO; 54395d00d1SAntti Palosaari } 55395d00d1SAntti Palosaari 56395d00d1SAntti Palosaari return ret; 57395d00d1SAntti Palosaari } 58395d00d1SAntti Palosaari 59395d00d1SAntti Palosaari /* read multiple registers */ 60395d00d1SAntti Palosaari static int m88ds3103_rd_regs(struct m88ds3103_priv *priv, 61395d00d1SAntti Palosaari u8 reg, u8 *val, int len) 62395d00d1SAntti Palosaari { 6363c80f70SAntti Palosaari #define MAX_RD_LEN 3 6463c80f70SAntti Palosaari #define MAX_RD_XFER_LEN (MAX_RD_LEN) 65395d00d1SAntti Palosaari int ret; 6663c80f70SAntti Palosaari u8 buf[MAX_RD_XFER_LEN]; 67395d00d1SAntti Palosaari struct i2c_msg msg[2] = { 68395d00d1SAntti Palosaari { 69395d00d1SAntti Palosaari .addr = priv->cfg->i2c_addr, 70395d00d1SAntti Palosaari .flags = 0, 71395d00d1SAntti Palosaari .len = 1, 72395d00d1SAntti Palosaari .buf = ®, 73395d00d1SAntti Palosaari }, { 74395d00d1SAntti Palosaari .addr = priv->cfg->i2c_addr, 75395d00d1SAntti Palosaari .flags = I2C_M_RD, 7663c80f70SAntti Palosaari .len = len, 77395d00d1SAntti Palosaari .buf = buf, 78395d00d1SAntti Palosaari } 79395d00d1SAntti Palosaari }; 80395d00d1SAntti Palosaari 8163c80f70SAntti Palosaari if (WARN_ON(len > MAX_RD_LEN)) 8263c80f70SAntti Palosaari return -EINVAL; 8363c80f70SAntti Palosaari 84395d00d1SAntti Palosaari mutex_lock(&priv->i2c_mutex); 85395d00d1SAntti Palosaari ret = i2c_transfer(priv->i2c, msg, 2); 86395d00d1SAntti Palosaari mutex_unlock(&priv->i2c_mutex); 87395d00d1SAntti Palosaari if (ret == 2) { 88395d00d1SAntti Palosaari memcpy(val, buf, len); 89395d00d1SAntti Palosaari ret = 0; 90395d00d1SAntti Palosaari } else { 91395d00d1SAntti Palosaari dev_warn(&priv->i2c->dev, 92395d00d1SAntti Palosaari "%s: i2c rd failed=%d reg=%02x len=%d\n", 93395d00d1SAntti Palosaari KBUILD_MODNAME, ret, reg, len); 94395d00d1SAntti Palosaari ret = -EREMOTEIO; 95395d00d1SAntti Palosaari } 96395d00d1SAntti Palosaari 97395d00d1SAntti Palosaari return ret; 98395d00d1SAntti Palosaari } 99395d00d1SAntti Palosaari 100395d00d1SAntti Palosaari /* write single register */ 101395d00d1SAntti Palosaari static int m88ds3103_wr_reg(struct m88ds3103_priv *priv, u8 reg, u8 val) 102395d00d1SAntti Palosaari { 103395d00d1SAntti Palosaari return m88ds3103_wr_regs(priv, reg, &val, 1); 104395d00d1SAntti Palosaari } 105395d00d1SAntti Palosaari 106395d00d1SAntti Palosaari /* read single register */ 107395d00d1SAntti Palosaari static int m88ds3103_rd_reg(struct m88ds3103_priv *priv, u8 reg, u8 *val) 108395d00d1SAntti Palosaari { 109395d00d1SAntti Palosaari return m88ds3103_rd_regs(priv, reg, val, 1); 110395d00d1SAntti Palosaari } 111395d00d1SAntti Palosaari 112395d00d1SAntti Palosaari /* write single register with mask */ 113395d00d1SAntti Palosaari static int m88ds3103_wr_reg_mask(struct m88ds3103_priv *priv, 114395d00d1SAntti Palosaari u8 reg, u8 val, u8 mask) 115395d00d1SAntti Palosaari { 116395d00d1SAntti Palosaari int ret; 117395d00d1SAntti Palosaari u8 u8tmp; 118395d00d1SAntti Palosaari 119395d00d1SAntti Palosaari /* no need for read if whole reg is written */ 120395d00d1SAntti Palosaari if (mask != 0xff) { 121395d00d1SAntti Palosaari ret = m88ds3103_rd_regs(priv, reg, &u8tmp, 1); 122395d00d1SAntti Palosaari if (ret) 123395d00d1SAntti Palosaari return ret; 124395d00d1SAntti Palosaari 125395d00d1SAntti Palosaari val &= mask; 126395d00d1SAntti Palosaari u8tmp &= ~mask; 127395d00d1SAntti Palosaari val |= u8tmp; 128395d00d1SAntti Palosaari } 129395d00d1SAntti Palosaari 130395d00d1SAntti Palosaari return m88ds3103_wr_regs(priv, reg, &val, 1); 131395d00d1SAntti Palosaari } 132395d00d1SAntti Palosaari 133395d00d1SAntti Palosaari /* read single register with mask */ 134395d00d1SAntti Palosaari static int m88ds3103_rd_reg_mask(struct m88ds3103_priv *priv, 135395d00d1SAntti Palosaari u8 reg, u8 *val, u8 mask) 136395d00d1SAntti Palosaari { 137395d00d1SAntti Palosaari int ret, i; 138395d00d1SAntti Palosaari u8 u8tmp; 139395d00d1SAntti Palosaari 140395d00d1SAntti Palosaari ret = m88ds3103_rd_regs(priv, reg, &u8tmp, 1); 141395d00d1SAntti Palosaari if (ret) 142395d00d1SAntti Palosaari return ret; 143395d00d1SAntti Palosaari 144395d00d1SAntti Palosaari u8tmp &= mask; 145395d00d1SAntti Palosaari 146395d00d1SAntti Palosaari /* find position of the first bit */ 147395d00d1SAntti Palosaari for (i = 0; i < 8; i++) { 148395d00d1SAntti Palosaari if ((mask >> i) & 0x01) 149395d00d1SAntti Palosaari break; 150395d00d1SAntti Palosaari } 151395d00d1SAntti Palosaari *val = u8tmp >> i; 152395d00d1SAntti Palosaari 153395d00d1SAntti Palosaari return 0; 154395d00d1SAntti Palosaari } 155395d00d1SAntti Palosaari 15606487deeSAntti Palosaari /* write reg val table using reg addr auto increment */ 15706487deeSAntti Palosaari static int m88ds3103_wr_reg_val_tab(struct m88ds3103_priv *priv, 15806487deeSAntti Palosaari const struct m88ds3103_reg_val *tab, int tab_len) 15906487deeSAntti Palosaari { 16006487deeSAntti Palosaari int ret, i, j; 16106487deeSAntti Palosaari u8 buf[83]; 16241b9aa00SAntti Palosaari 16306487deeSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: tab_len=%d\n", __func__, tab_len); 16406487deeSAntti Palosaari 165f4df95bcSnibble.max if (tab_len > 86) { 16606487deeSAntti Palosaari ret = -EINVAL; 16706487deeSAntti Palosaari goto err; 16806487deeSAntti Palosaari } 16906487deeSAntti Palosaari 17006487deeSAntti Palosaari for (i = 0, j = 0; i < tab_len; i++, j++) { 17106487deeSAntti Palosaari buf[j] = tab[i].val; 17206487deeSAntti Palosaari 17306487deeSAntti Palosaari if (i == tab_len - 1 || tab[i].reg != tab[i + 1].reg - 1 || 17406487deeSAntti Palosaari !((j + 1) % (priv->cfg->i2c_wr_max - 1))) { 17506487deeSAntti Palosaari ret = m88ds3103_wr_regs(priv, tab[i].reg - j, buf, j + 1); 17606487deeSAntti Palosaari if (ret) 17706487deeSAntti Palosaari goto err; 17806487deeSAntti Palosaari 17906487deeSAntti Palosaari j = -1; 18006487deeSAntti Palosaari } 18106487deeSAntti Palosaari } 18206487deeSAntti Palosaari 18306487deeSAntti Palosaari return 0; 18406487deeSAntti Palosaari err: 18506487deeSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 18606487deeSAntti Palosaari return ret; 18706487deeSAntti Palosaari } 18806487deeSAntti Palosaari 189395d00d1SAntti Palosaari static int m88ds3103_read_status(struct dvb_frontend *fe, fe_status_t *status) 190395d00d1SAntti Palosaari { 191395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 192395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 193*c1daf651SAntti Palosaari int ret, i, itmp; 194395d00d1SAntti Palosaari u8 u8tmp; 195*c1daf651SAntti Palosaari u8 buf[3]; 196395d00d1SAntti Palosaari 197395d00d1SAntti Palosaari *status = 0; 198395d00d1SAntti Palosaari 199395d00d1SAntti Palosaari if (!priv->warm) { 200395d00d1SAntti Palosaari ret = -EAGAIN; 201395d00d1SAntti Palosaari goto err; 202395d00d1SAntti Palosaari } 203395d00d1SAntti Palosaari 204395d00d1SAntti Palosaari switch (c->delivery_system) { 205395d00d1SAntti Palosaari case SYS_DVBS: 206395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0xd1, &u8tmp, 0x07); 207395d00d1SAntti Palosaari if (ret) 208395d00d1SAntti Palosaari goto err; 209395d00d1SAntti Palosaari 210395d00d1SAntti Palosaari if (u8tmp == 0x07) 211395d00d1SAntti Palosaari *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 212395d00d1SAntti Palosaari FE_HAS_VITERBI | FE_HAS_SYNC | 213395d00d1SAntti Palosaari FE_HAS_LOCK; 214395d00d1SAntti Palosaari break; 215395d00d1SAntti Palosaari case SYS_DVBS2: 216395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0x0d, &u8tmp, 0x8f); 217395d00d1SAntti Palosaari if (ret) 218395d00d1SAntti Palosaari goto err; 219395d00d1SAntti Palosaari 220395d00d1SAntti Palosaari if (u8tmp == 0x8f) 221395d00d1SAntti Palosaari *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 222395d00d1SAntti Palosaari FE_HAS_VITERBI | FE_HAS_SYNC | 223395d00d1SAntti Palosaari FE_HAS_LOCK; 224395d00d1SAntti Palosaari break; 225395d00d1SAntti Palosaari default: 226395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 227395d00d1SAntti Palosaari __func__); 228395d00d1SAntti Palosaari ret = -EINVAL; 229395d00d1SAntti Palosaari goto err; 230395d00d1SAntti Palosaari } 231395d00d1SAntti Palosaari 232395d00d1SAntti Palosaari priv->fe_status = *status; 233395d00d1SAntti Palosaari 234395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: lock=%02x status=%02x\n", 235395d00d1SAntti Palosaari __func__, u8tmp, *status); 236395d00d1SAntti Palosaari 237*c1daf651SAntti Palosaari /* CNR */ 238*c1daf651SAntti Palosaari if (priv->fe_status & FE_HAS_VITERBI) { 239*c1daf651SAntti Palosaari unsigned int cnr, noise, signal, noise_tot, signal_tot; 240*c1daf651SAntti Palosaari 241*c1daf651SAntti Palosaari cnr = 0; 242*c1daf651SAntti Palosaari /* more iterations for more accurate estimation */ 243*c1daf651SAntti Palosaari #define M88DS3103_SNR_ITERATIONS 3 244*c1daf651SAntti Palosaari 245*c1daf651SAntti Palosaari switch (c->delivery_system) { 246*c1daf651SAntti Palosaari case SYS_DVBS: 247*c1daf651SAntti Palosaari itmp = 0; 248*c1daf651SAntti Palosaari 249*c1daf651SAntti Palosaari for (i = 0; i < M88DS3103_SNR_ITERATIONS; i++) { 250*c1daf651SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xff, &buf[0]); 251*c1daf651SAntti Palosaari if (ret) 252*c1daf651SAntti Palosaari goto err; 253*c1daf651SAntti Palosaari 254*c1daf651SAntti Palosaari itmp += buf[0]; 255*c1daf651SAntti Palosaari } 256*c1daf651SAntti Palosaari 257*c1daf651SAntti Palosaari /* use of single register limits max value to 15 dB */ 258*c1daf651SAntti Palosaari /* SNR(X) dB = 10 * ln(X) / ln(10) dB */ 259*c1daf651SAntti Palosaari itmp = DIV_ROUND_CLOSEST(itmp, 8 * M88DS3103_SNR_ITERATIONS); 260*c1daf651SAntti Palosaari if (itmp) 261*c1daf651SAntti Palosaari cnr = div_u64((u64) 10000 * intlog2(itmp), intlog2(10)); 262*c1daf651SAntti Palosaari break; 263*c1daf651SAntti Palosaari case SYS_DVBS2: 264*c1daf651SAntti Palosaari noise_tot = 0; 265*c1daf651SAntti Palosaari signal_tot = 0; 266*c1daf651SAntti Palosaari 267*c1daf651SAntti Palosaari for (i = 0; i < M88DS3103_SNR_ITERATIONS; i++) { 268*c1daf651SAntti Palosaari ret = m88ds3103_rd_regs(priv, 0x8c, buf, 3); 269*c1daf651SAntti Palosaari if (ret) 270*c1daf651SAntti Palosaari goto err; 271*c1daf651SAntti Palosaari 272*c1daf651SAntti Palosaari noise = buf[1] << 6; /* [13:6] */ 273*c1daf651SAntti Palosaari noise |= buf[0] & 0x3f; /* [5:0] */ 274*c1daf651SAntti Palosaari noise >>= 2; 275*c1daf651SAntti Palosaari signal = buf[2] * buf[2]; 276*c1daf651SAntti Palosaari signal >>= 1; 277*c1daf651SAntti Palosaari 278*c1daf651SAntti Palosaari noise_tot += noise; 279*c1daf651SAntti Palosaari signal_tot += signal; 280*c1daf651SAntti Palosaari } 281*c1daf651SAntti Palosaari 282*c1daf651SAntti Palosaari noise = noise_tot / M88DS3103_SNR_ITERATIONS; 283*c1daf651SAntti Palosaari signal = signal_tot / M88DS3103_SNR_ITERATIONS; 284*c1daf651SAntti Palosaari 285*c1daf651SAntti Palosaari /* SNR(X) dB = 10 * log10(X) dB */ 286*c1daf651SAntti Palosaari if (signal > noise) { 287*c1daf651SAntti Palosaari itmp = signal / noise; 288*c1daf651SAntti Palosaari cnr = div_u64((u64) 10000 * intlog10(itmp), (1 << 24)); 289*c1daf651SAntti Palosaari } 290*c1daf651SAntti Palosaari break; 291*c1daf651SAntti Palosaari default: 292*c1daf651SAntti Palosaari dev_dbg(&priv->i2c->dev, 293*c1daf651SAntti Palosaari "%s: invalid delivery_system\n", __func__); 294*c1daf651SAntti Palosaari ret = -EINVAL; 295*c1daf651SAntti Palosaari goto err; 296*c1daf651SAntti Palosaari } 297*c1daf651SAntti Palosaari 298*c1daf651SAntti Palosaari if (cnr) { 299*c1daf651SAntti Palosaari c->cnr.stat[0].scale = FE_SCALE_DECIBEL; 300*c1daf651SAntti Palosaari c->cnr.stat[0].svalue = cnr; 301*c1daf651SAntti Palosaari } else { 302*c1daf651SAntti Palosaari c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 303*c1daf651SAntti Palosaari } 304*c1daf651SAntti Palosaari } else { 305*c1daf651SAntti Palosaari c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 306*c1daf651SAntti Palosaari } 307*c1daf651SAntti Palosaari 308395d00d1SAntti Palosaari return 0; 309395d00d1SAntti Palosaari err: 310395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 311395d00d1SAntti Palosaari return ret; 312395d00d1SAntti Palosaari } 313395d00d1SAntti Palosaari 314395d00d1SAntti Palosaari static int m88ds3103_set_frontend(struct dvb_frontend *fe) 315395d00d1SAntti Palosaari { 316395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 317395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 31806487deeSAntti Palosaari int ret, len; 319395d00d1SAntti Palosaari const struct m88ds3103_reg_val *init; 320b6851419Snibble.max u8 u8tmp, u8tmp1 = 0, u8tmp2 = 0; /* silence compiler warning */ 321f4df95bcSnibble.max u8 buf[3]; 322b6851419Snibble.max u16 u16tmp, divide_ratio = 0; 32379d09330Snibble.max u32 tuner_frequency, target_mclk; 324395d00d1SAntti Palosaari s32 s32tmp; 32541b9aa00SAntti Palosaari 326395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, 327395d00d1SAntti Palosaari "%s: delivery_system=%d modulation=%d frequency=%d symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n", 328395d00d1SAntti Palosaari __func__, c->delivery_system, 329395d00d1SAntti Palosaari c->modulation, c->frequency, c->symbol_rate, 330395d00d1SAntti Palosaari c->inversion, c->pilot, c->rolloff); 331395d00d1SAntti Palosaari 332395d00d1SAntti Palosaari if (!priv->warm) { 333395d00d1SAntti Palosaari ret = -EAGAIN; 334395d00d1SAntti Palosaari goto err; 335395d00d1SAntti Palosaari } 336395d00d1SAntti Palosaari 337f4df95bcSnibble.max /* reset */ 338f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0x80); 339f4df95bcSnibble.max if (ret) 340f4df95bcSnibble.max goto err; 341f4df95bcSnibble.max 342f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0x00); 343f4df95bcSnibble.max if (ret) 344f4df95bcSnibble.max goto err; 345f4df95bcSnibble.max 346f4df95bcSnibble.max /* Disable demod clock path */ 347f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 348f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x06, 0xe0); 349f4df95bcSnibble.max if (ret) 350f4df95bcSnibble.max goto err; 351f4df95bcSnibble.max } 352f4df95bcSnibble.max 353395d00d1SAntti Palosaari /* program tuner */ 354395d00d1SAntti Palosaari if (fe->ops.tuner_ops.set_params) { 355395d00d1SAntti Palosaari ret = fe->ops.tuner_ops.set_params(fe); 356395d00d1SAntti Palosaari if (ret) 357395d00d1SAntti Palosaari goto err; 358395d00d1SAntti Palosaari } 359395d00d1SAntti Palosaari 360395d00d1SAntti Palosaari if (fe->ops.tuner_ops.get_frequency) { 361395d00d1SAntti Palosaari ret = fe->ops.tuner_ops.get_frequency(fe, &tuner_frequency); 362395d00d1SAntti Palosaari if (ret) 363395d00d1SAntti Palosaari goto err; 3642f9dff3fSAntti Palosaari } else { 3652f9dff3fSAntti Palosaari /* 3662f9dff3fSAntti Palosaari * Use nominal target frequency as tuner driver does not provide 3672f9dff3fSAntti Palosaari * actual frequency used. Carrier offset calculation is not 3682f9dff3fSAntti Palosaari * valid. 3692f9dff3fSAntti Palosaari */ 3702f9dff3fSAntti Palosaari tuner_frequency = c->frequency; 371395d00d1SAntti Palosaari } 372395d00d1SAntti Palosaari 373f4df95bcSnibble.max /* select M88RS6000 demod main mclk and ts mclk from tuner die. */ 374f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 375f4df95bcSnibble.max if (c->symbol_rate > 45010000) 376f4df95bcSnibble.max priv->mclk_khz = 110250; 377f4df95bcSnibble.max else 378f4df95bcSnibble.max priv->mclk_khz = 96000; 379395d00d1SAntti Palosaari 380f4df95bcSnibble.max if (c->delivery_system == SYS_DVBS) 381395d00d1SAntti Palosaari target_mclk = 96000; 382f4df95bcSnibble.max else 383f4df95bcSnibble.max target_mclk = 144000; 384395d00d1SAntti Palosaari 385f4df95bcSnibble.max /* Enable demod clock path */ 386f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x06, 0x00); 387f4df95bcSnibble.max if (ret) 388f4df95bcSnibble.max goto err; 389f4df95bcSnibble.max usleep_range(10000, 20000); 390f4df95bcSnibble.max } else { 391f4df95bcSnibble.max /* set M88DS3103 mclk and ts mclk. */ 392f4df95bcSnibble.max priv->mclk_khz = 96000; 393f4df95bcSnibble.max 394395d00d1SAntti Palosaari switch (priv->cfg->ts_mode) { 395395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL: 396395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL_D7: 397b6851419Snibble.max target_mclk = priv->cfg->ts_clk; 398395d00d1SAntti Palosaari break; 399395d00d1SAntti Palosaari case M88DS3103_TS_PARALLEL: 400395d00d1SAntti Palosaari case M88DS3103_TS_CI: 401b6851419Snibble.max if (c->delivery_system == SYS_DVBS) 402b6851419Snibble.max target_mclk = 96000; 403b6851419Snibble.max else { 404395d00d1SAntti Palosaari if (c->symbol_rate < 18000000) 405395d00d1SAntti Palosaari target_mclk = 96000; 406395d00d1SAntti Palosaari else if (c->symbol_rate < 28000000) 407395d00d1SAntti Palosaari target_mclk = 144000; 408395d00d1SAntti Palosaari else 409395d00d1SAntti Palosaari target_mclk = 192000; 410b6851419Snibble.max } 411395d00d1SAntti Palosaari break; 412395d00d1SAntti Palosaari default: 413395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", 414395d00d1SAntti Palosaari __func__); 415395d00d1SAntti Palosaari ret = -EINVAL; 416395d00d1SAntti Palosaari goto err; 417395d00d1SAntti Palosaari } 418f4df95bcSnibble.max 419f4df95bcSnibble.max switch (target_mclk) { 420f4df95bcSnibble.max case 96000: 421f4df95bcSnibble.max u8tmp1 = 0x02; /* 0b10 */ 422f4df95bcSnibble.max u8tmp2 = 0x01; /* 0b01 */ 423f4df95bcSnibble.max break; 424f4df95bcSnibble.max case 144000: 425f4df95bcSnibble.max u8tmp1 = 0x00; /* 0b00 */ 426f4df95bcSnibble.max u8tmp2 = 0x01; /* 0b01 */ 427f4df95bcSnibble.max break; 428f4df95bcSnibble.max case 192000: 429f4df95bcSnibble.max u8tmp1 = 0x03; /* 0b11 */ 430f4df95bcSnibble.max u8tmp2 = 0x00; /* 0b00 */ 431f4df95bcSnibble.max break; 432f4df95bcSnibble.max } 433f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0); 434f4df95bcSnibble.max if (ret) 435f4df95bcSnibble.max goto err; 436f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x24, u8tmp2 << 6, 0xc0); 437f4df95bcSnibble.max if (ret) 438f4df95bcSnibble.max goto err; 439f4df95bcSnibble.max } 440f4df95bcSnibble.max 441f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); 442f4df95bcSnibble.max if (ret) 443f4df95bcSnibble.max goto err; 444f4df95bcSnibble.max 445f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x00, 0x01); 446f4df95bcSnibble.max if (ret) 447f4df95bcSnibble.max goto err; 448f4df95bcSnibble.max 449f4df95bcSnibble.max switch (c->delivery_system) { 450f4df95bcSnibble.max case SYS_DVBS: 451f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 452f4df95bcSnibble.max len = ARRAY_SIZE(m88rs6000_dvbs_init_reg_vals); 453f4df95bcSnibble.max init = m88rs6000_dvbs_init_reg_vals; 454f4df95bcSnibble.max } else { 455f4df95bcSnibble.max len = ARRAY_SIZE(m88ds3103_dvbs_init_reg_vals); 456f4df95bcSnibble.max init = m88ds3103_dvbs_init_reg_vals; 457f4df95bcSnibble.max } 458f4df95bcSnibble.max break; 459f4df95bcSnibble.max case SYS_DVBS2: 460f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 461f4df95bcSnibble.max len = ARRAY_SIZE(m88rs6000_dvbs2_init_reg_vals); 462f4df95bcSnibble.max init = m88rs6000_dvbs2_init_reg_vals; 463f4df95bcSnibble.max } else { 464f4df95bcSnibble.max len = ARRAY_SIZE(m88ds3103_dvbs2_init_reg_vals); 465f4df95bcSnibble.max init = m88ds3103_dvbs2_init_reg_vals; 466f4df95bcSnibble.max } 467395d00d1SAntti Palosaari break; 468395d00d1SAntti Palosaari default: 469395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 470395d00d1SAntti Palosaari __func__); 471395d00d1SAntti Palosaari ret = -EINVAL; 472395d00d1SAntti Palosaari goto err; 473395d00d1SAntti Palosaari } 474395d00d1SAntti Palosaari 475395d00d1SAntti Palosaari /* program init table */ 476395d00d1SAntti Palosaari if (c->delivery_system != priv->delivery_system) { 47706487deeSAntti Palosaari ret = m88ds3103_wr_reg_val_tab(priv, init, len); 478395d00d1SAntti Palosaari if (ret) 479395d00d1SAntti Palosaari goto err; 480395d00d1SAntti Palosaari } 481395d00d1SAntti Palosaari 482f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 483f4df95bcSnibble.max if ((c->delivery_system == SYS_DVBS2) 484f4df95bcSnibble.max && ((c->symbol_rate / 1000) <= 5000)) { 485f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0xc0, 0x04); 486f4df95bcSnibble.max if (ret) 487f4df95bcSnibble.max goto err; 488f4df95bcSnibble.max buf[0] = 0x09; 489f4df95bcSnibble.max buf[1] = 0x22; 490f4df95bcSnibble.max buf[2] = 0x88; 491f4df95bcSnibble.max ret = m88ds3103_wr_regs(priv, 0x8a, buf, 3); 492f4df95bcSnibble.max if (ret) 493f4df95bcSnibble.max goto err; 494f4df95bcSnibble.max } 495f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x9d, 0x08, 0x08); 496f4df95bcSnibble.max if (ret) 497f4df95bcSnibble.max goto err; 498f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0xf1, 0x01); 499f4df95bcSnibble.max if (ret) 500f4df95bcSnibble.max goto err; 501f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x30, 0x80, 0x80); 502f4df95bcSnibble.max if (ret) 503f4df95bcSnibble.max goto err; 504f4df95bcSnibble.max } 505f4df95bcSnibble.max 506395d00d1SAntti Palosaari switch (priv->cfg->ts_mode) { 507395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL: 508395d00d1SAntti Palosaari u8tmp1 = 0x00; 50979d09330Snibble.max u8tmp = 0x06; 510395d00d1SAntti Palosaari break; 511395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL_D7: 512395d00d1SAntti Palosaari u8tmp1 = 0x20; 51379d09330Snibble.max u8tmp = 0x06; 514395d00d1SAntti Palosaari break; 515395d00d1SAntti Palosaari case M88DS3103_TS_PARALLEL: 51679d09330Snibble.max u8tmp = 0x02; 517395d00d1SAntti Palosaari break; 518395d00d1SAntti Palosaari case M88DS3103_TS_CI: 51979d09330Snibble.max u8tmp = 0x03; 520395d00d1SAntti Palosaari break; 521395d00d1SAntti Palosaari default: 522395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", __func__); 523395d00d1SAntti Palosaari ret = -EINVAL; 524395d00d1SAntti Palosaari goto err; 525395d00d1SAntti Palosaari } 526395d00d1SAntti Palosaari 52779d09330Snibble.max if (priv->cfg->ts_clk_pol) 52879d09330Snibble.max u8tmp |= 0x40; 52979d09330Snibble.max 530395d00d1SAntti Palosaari /* TS mode */ 53192676ac9SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp); 532395d00d1SAntti Palosaari if (ret) 533395d00d1SAntti Palosaari goto err; 534395d00d1SAntti Palosaari 535395d00d1SAntti Palosaari switch (priv->cfg->ts_mode) { 536395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL: 537395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL_D7: 538395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x29, u8tmp1, 0x20); 539395d00d1SAntti Palosaari if (ret) 540395d00d1SAntti Palosaari goto err; 541b6851419Snibble.max u8tmp1 = 0; 542b6851419Snibble.max u8tmp2 = 0; 543b6851419Snibble.max break; 544b6851419Snibble.max default: 54579d09330Snibble.max if (priv->cfg->ts_clk) { 54679d09330Snibble.max divide_ratio = DIV_ROUND_UP(target_mclk, priv->cfg->ts_clk); 547395d00d1SAntti Palosaari u8tmp1 = divide_ratio / 2; 548395d00d1SAntti Palosaari u8tmp2 = DIV_ROUND_UP(divide_ratio, 2); 549b6851419Snibble.max } 550395d00d1SAntti Palosaari } 551395d00d1SAntti Palosaari 552395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, 553395d00d1SAntti Palosaari "%s: target_mclk=%d ts_clk=%d divide_ratio=%d\n", 55479d09330Snibble.max __func__, target_mclk, priv->cfg->ts_clk, divide_ratio); 555395d00d1SAntti Palosaari 556395d00d1SAntti Palosaari u8tmp1--; 557395d00d1SAntti Palosaari u8tmp2--; 558395d00d1SAntti Palosaari /* u8tmp1[5:2] => fe[3:0], u8tmp1[1:0] => ea[7:6] */ 559395d00d1SAntti Palosaari u8tmp1 &= 0x3f; 560395d00d1SAntti Palosaari /* u8tmp2[5:0] => ea[5:0] */ 561395d00d1SAntti Palosaari u8tmp2 &= 0x3f; 562395d00d1SAntti Palosaari 563395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xfe, &u8tmp); 564395d00d1SAntti Palosaari if (ret) 565395d00d1SAntti Palosaari goto err; 566395d00d1SAntti Palosaari 567395d00d1SAntti Palosaari u8tmp = ((u8tmp & 0xf0) << 0) | u8tmp1 >> 2; 568395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xfe, u8tmp); 569395d00d1SAntti Palosaari if (ret) 570395d00d1SAntti Palosaari goto err; 571395d00d1SAntti Palosaari 572395d00d1SAntti Palosaari u8tmp = ((u8tmp1 & 0x03) << 6) | u8tmp2 >> 0; 573395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xea, u8tmp); 574395d00d1SAntti Palosaari if (ret) 575395d00d1SAntti Palosaari goto err; 576395d00d1SAntti Palosaari 577395d00d1SAntti Palosaari if (c->symbol_rate <= 3000000) 578395d00d1SAntti Palosaari u8tmp = 0x20; 579395d00d1SAntti Palosaari else if (c->symbol_rate <= 10000000) 580395d00d1SAntti Palosaari u8tmp = 0x10; 581395d00d1SAntti Palosaari else 582395d00d1SAntti Palosaari u8tmp = 0x06; 583395d00d1SAntti Palosaari 584395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc3, 0x08); 585395d00d1SAntti Palosaari if (ret) 586395d00d1SAntti Palosaari goto err; 587395d00d1SAntti Palosaari 588395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc8, u8tmp); 589395d00d1SAntti Palosaari if (ret) 590395d00d1SAntti Palosaari goto err; 591395d00d1SAntti Palosaari 592395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc4, 0x08); 593395d00d1SAntti Palosaari if (ret) 594395d00d1SAntti Palosaari goto err; 595395d00d1SAntti Palosaari 596395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc7, 0x00); 597395d00d1SAntti Palosaari if (ret) 598395d00d1SAntti Palosaari goto err; 599395d00d1SAntti Palosaari 600f4df95bcSnibble.max u16tmp = DIV_ROUND_CLOSEST((c->symbol_rate / 1000) << 15, priv->mclk_khz / 2); 601395d00d1SAntti Palosaari buf[0] = (u16tmp >> 0) & 0xff; 602395d00d1SAntti Palosaari buf[1] = (u16tmp >> 8) & 0xff; 603395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0x61, buf, 2); 604395d00d1SAntti Palosaari if (ret) 605395d00d1SAntti Palosaari goto err; 606395d00d1SAntti Palosaari 607395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x4d, priv->cfg->spec_inv << 1, 0x02); 608395d00d1SAntti Palosaari if (ret) 609395d00d1SAntti Palosaari goto err; 610395d00d1SAntti Palosaari 611395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x30, priv->cfg->agc_inv << 4, 0x10); 612395d00d1SAntti Palosaari if (ret) 613395d00d1SAntti Palosaari goto err; 614395d00d1SAntti Palosaari 615395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0x33, priv->cfg->agc); 616395d00d1SAntti Palosaari if (ret) 617395d00d1SAntti Palosaari goto err; 618395d00d1SAntti Palosaari 619395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: carrier offset=%d\n", __func__, 620395d00d1SAntti Palosaari (tuner_frequency - c->frequency)); 621395d00d1SAntti Palosaari 622395d00d1SAntti Palosaari s32tmp = 0x10000 * (tuner_frequency - c->frequency); 623f4df95bcSnibble.max s32tmp = DIV_ROUND_CLOSEST(s32tmp, priv->mclk_khz); 624395d00d1SAntti Palosaari if (s32tmp < 0) 625395d00d1SAntti Palosaari s32tmp += 0x10000; 626395d00d1SAntti Palosaari 627395d00d1SAntti Palosaari buf[0] = (s32tmp >> 0) & 0xff; 628395d00d1SAntti Palosaari buf[1] = (s32tmp >> 8) & 0xff; 629395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0x5e, buf, 2); 630395d00d1SAntti Palosaari if (ret) 631395d00d1SAntti Palosaari goto err; 632395d00d1SAntti Palosaari 633395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0x00, 0x00); 634395d00d1SAntti Palosaari if (ret) 635395d00d1SAntti Palosaari goto err; 636395d00d1SAntti Palosaari 637395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); 638395d00d1SAntti Palosaari if (ret) 639395d00d1SAntti Palosaari goto err; 640395d00d1SAntti Palosaari 641395d00d1SAntti Palosaari priv->delivery_system = c->delivery_system; 642395d00d1SAntti Palosaari 643395d00d1SAntti Palosaari return 0; 644395d00d1SAntti Palosaari err: 645395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 646395d00d1SAntti Palosaari return ret; 647395d00d1SAntti Palosaari } 648395d00d1SAntti Palosaari 649395d00d1SAntti Palosaari static int m88ds3103_init(struct dvb_frontend *fe) 650395d00d1SAntti Palosaari { 651395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 652*c1daf651SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 653395d00d1SAntti Palosaari int ret, len, remaining; 654395d00d1SAntti Palosaari const struct firmware *fw = NULL; 655f4df95bcSnibble.max u8 *fw_file; 656395d00d1SAntti Palosaari u8 u8tmp; 65741b9aa00SAntti Palosaari 658395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 659395d00d1SAntti Palosaari 660395d00d1SAntti Palosaari /* set cold state by default */ 661395d00d1SAntti Palosaari priv->warm = false; 662395d00d1SAntti Palosaari 663395d00d1SAntti Palosaari /* wake up device from sleep */ 664395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x01, 0x01); 665395d00d1SAntti Palosaari if (ret) 666395d00d1SAntti Palosaari goto err; 667395d00d1SAntti Palosaari 668395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x00, 0x01); 669395d00d1SAntti Palosaari if (ret) 670395d00d1SAntti Palosaari goto err; 671395d00d1SAntti Palosaari 672395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x00, 0x10); 673395d00d1SAntti Palosaari if (ret) 674395d00d1SAntti Palosaari goto err; 675395d00d1SAntti Palosaari 676395d00d1SAntti Palosaari /* firmware status */ 677395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); 678395d00d1SAntti Palosaari if (ret) 679395d00d1SAntti Palosaari goto err; 680395d00d1SAntti Palosaari 681395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: firmware=%02x\n", __func__, u8tmp); 682395d00d1SAntti Palosaari 683395d00d1SAntti Palosaari if (u8tmp) 684395d00d1SAntti Palosaari goto skip_fw_download; 685395d00d1SAntti Palosaari 686f4df95bcSnibble.max /* global reset, global diseqc reset, golbal fec reset */ 687f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0xe0); 688f4df95bcSnibble.max if (ret) 689f4df95bcSnibble.max goto err; 690f4df95bcSnibble.max 691f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0x00); 692f4df95bcSnibble.max if (ret) 693f4df95bcSnibble.max goto err; 694f4df95bcSnibble.max 695395d00d1SAntti Palosaari /* cold state - try to download firmware */ 696395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state\n", 697395d00d1SAntti Palosaari KBUILD_MODNAME, m88ds3103_ops.info.name); 698395d00d1SAntti Palosaari 699f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) 700f4df95bcSnibble.max fw_file = M88RS6000_FIRMWARE; 701f4df95bcSnibble.max else 702f4df95bcSnibble.max fw_file = M88DS3103_FIRMWARE; 703395d00d1SAntti Palosaari /* request the firmware, this will block and timeout */ 704395d00d1SAntti Palosaari ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); 705395d00d1SAntti Palosaari if (ret) { 706a87a4d34SYannick Guerrini dev_err(&priv->i2c->dev, "%s: firmware file '%s' not found\n", 707395d00d1SAntti Palosaari KBUILD_MODNAME, fw_file); 708395d00d1SAntti Palosaari goto err; 709395d00d1SAntti Palosaari } 710395d00d1SAntti Palosaari 711395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: downloading firmware from file '%s'\n", 712395d00d1SAntti Palosaari KBUILD_MODNAME, fw_file); 713395d00d1SAntti Palosaari 714395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); 715395d00d1SAntti Palosaari if (ret) 7165ed0cf88SMarkus Elfring goto error_fw_release; 717395d00d1SAntti Palosaari 718395d00d1SAntti Palosaari for (remaining = fw->size; remaining > 0; 719395d00d1SAntti Palosaari remaining -= (priv->cfg->i2c_wr_max - 1)) { 720395d00d1SAntti Palosaari len = remaining; 721395d00d1SAntti Palosaari if (len > (priv->cfg->i2c_wr_max - 1)) 722395d00d1SAntti Palosaari len = (priv->cfg->i2c_wr_max - 1); 723395d00d1SAntti Palosaari 724395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0xb0, 725395d00d1SAntti Palosaari &fw->data[fw->size - remaining], len); 726395d00d1SAntti Palosaari if (ret) { 727395d00d1SAntti Palosaari dev_err(&priv->i2c->dev, 728395d00d1SAntti Palosaari "%s: firmware download failed=%d\n", 729395d00d1SAntti Palosaari KBUILD_MODNAME, ret); 7305ed0cf88SMarkus Elfring goto error_fw_release; 731395d00d1SAntti Palosaari } 732395d00d1SAntti Palosaari } 733395d00d1SAntti Palosaari 734395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); 735395d00d1SAntti Palosaari if (ret) 7365ed0cf88SMarkus Elfring goto error_fw_release; 737395d00d1SAntti Palosaari 738395d00d1SAntti Palosaari release_firmware(fw); 739395d00d1SAntti Palosaari fw = NULL; 740395d00d1SAntti Palosaari 741395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); 742395d00d1SAntti Palosaari if (ret) 743395d00d1SAntti Palosaari goto err; 744395d00d1SAntti Palosaari 745395d00d1SAntti Palosaari if (!u8tmp) { 746395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: firmware did not run\n", 747395d00d1SAntti Palosaari KBUILD_MODNAME); 748395d00d1SAntti Palosaari ret = -EFAULT; 749395d00d1SAntti Palosaari goto err; 750395d00d1SAntti Palosaari } 751395d00d1SAntti Palosaari 752395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: found a '%s' in warm state\n", 753395d00d1SAntti Palosaari KBUILD_MODNAME, m88ds3103_ops.info.name); 754395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: firmware version %X.%X\n", 755395d00d1SAntti Palosaari KBUILD_MODNAME, (u8tmp >> 4) & 0xf, (u8tmp >> 0 & 0xf)); 756395d00d1SAntti Palosaari 757395d00d1SAntti Palosaari skip_fw_download: 758395d00d1SAntti Palosaari /* warm state */ 759395d00d1SAntti Palosaari priv->warm = true; 760*c1daf651SAntti Palosaari /* init stats here in order signal app which stats are supported */ 761*c1daf651SAntti Palosaari c->cnr.len = 1; 762*c1daf651SAntti Palosaari c->cnr.stat[0].scale = FE_SCALE_NOT_AVAILABLE; 763395d00d1SAntti Palosaari return 0; 764395d00d1SAntti Palosaari 7655ed0cf88SMarkus Elfring error_fw_release: 7665ed0cf88SMarkus Elfring release_firmware(fw); 7675ed0cf88SMarkus Elfring err: 768395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 769395d00d1SAntti Palosaari return ret; 770395d00d1SAntti Palosaari } 771395d00d1SAntti Palosaari 772395d00d1SAntti Palosaari static int m88ds3103_sleep(struct dvb_frontend *fe) 773395d00d1SAntti Palosaari { 774395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 775395d00d1SAntti Palosaari int ret; 776f4df95bcSnibble.max u8 u8tmp; 77741b9aa00SAntti Palosaari 778395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 779395d00d1SAntti Palosaari 780*c1daf651SAntti Palosaari priv->fe_status = 0; 781395d00d1SAntti Palosaari priv->delivery_system = SYS_UNDEFINED; 782395d00d1SAntti Palosaari 783395d00d1SAntti Palosaari /* TS Hi-Z */ 784f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) 785f4df95bcSnibble.max u8tmp = 0x29; 786f4df95bcSnibble.max else 787f4df95bcSnibble.max u8tmp = 0x27; 788f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, u8tmp, 0x00, 0x01); 789395d00d1SAntti Palosaari if (ret) 790395d00d1SAntti Palosaari goto err; 791395d00d1SAntti Palosaari 792395d00d1SAntti Palosaari /* sleep */ 793395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x00, 0x01); 794395d00d1SAntti Palosaari if (ret) 795395d00d1SAntti Palosaari goto err; 796395d00d1SAntti Palosaari 797395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x01, 0x01); 798395d00d1SAntti Palosaari if (ret) 799395d00d1SAntti Palosaari goto err; 800395d00d1SAntti Palosaari 801395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x10, 0x10); 802395d00d1SAntti Palosaari if (ret) 803395d00d1SAntti Palosaari goto err; 804395d00d1SAntti Palosaari 805395d00d1SAntti Palosaari return 0; 806395d00d1SAntti Palosaari err: 807395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 808395d00d1SAntti Palosaari return ret; 809395d00d1SAntti Palosaari } 810395d00d1SAntti Palosaari 811395d00d1SAntti Palosaari static int m88ds3103_get_frontend(struct dvb_frontend *fe) 812395d00d1SAntti Palosaari { 813395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 814395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 815395d00d1SAntti Palosaari int ret; 816395d00d1SAntti Palosaari u8 buf[3]; 81741b9aa00SAntti Palosaari 818395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 819395d00d1SAntti Palosaari 820395d00d1SAntti Palosaari if (!priv->warm || !(priv->fe_status & FE_HAS_LOCK)) { 8219240c384SAntti Palosaari ret = 0; 822395d00d1SAntti Palosaari goto err; 823395d00d1SAntti Palosaari } 824395d00d1SAntti Palosaari 825395d00d1SAntti Palosaari switch (c->delivery_system) { 826395d00d1SAntti Palosaari case SYS_DVBS: 827395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xe0, &buf[0]); 828395d00d1SAntti Palosaari if (ret) 829395d00d1SAntti Palosaari goto err; 830395d00d1SAntti Palosaari 831395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xe6, &buf[1]); 832395d00d1SAntti Palosaari if (ret) 833395d00d1SAntti Palosaari goto err; 834395d00d1SAntti Palosaari 835395d00d1SAntti Palosaari switch ((buf[0] >> 2) & 0x01) { 836395d00d1SAntti Palosaari case 0: 837395d00d1SAntti Palosaari c->inversion = INVERSION_OFF; 838395d00d1SAntti Palosaari break; 839395d00d1SAntti Palosaari case 1: 840395d00d1SAntti Palosaari c->inversion = INVERSION_ON; 841395d00d1SAntti Palosaari break; 842395d00d1SAntti Palosaari } 843395d00d1SAntti Palosaari 844395d00d1SAntti Palosaari switch ((buf[1] >> 5) & 0x07) { 845395d00d1SAntti Palosaari case 0: 846395d00d1SAntti Palosaari c->fec_inner = FEC_7_8; 847395d00d1SAntti Palosaari break; 848395d00d1SAntti Palosaari case 1: 849395d00d1SAntti Palosaari c->fec_inner = FEC_5_6; 850395d00d1SAntti Palosaari break; 851395d00d1SAntti Palosaari case 2: 852395d00d1SAntti Palosaari c->fec_inner = FEC_3_4; 853395d00d1SAntti Palosaari break; 854395d00d1SAntti Palosaari case 3: 855395d00d1SAntti Palosaari c->fec_inner = FEC_2_3; 856395d00d1SAntti Palosaari break; 857395d00d1SAntti Palosaari case 4: 858395d00d1SAntti Palosaari c->fec_inner = FEC_1_2; 859395d00d1SAntti Palosaari break; 860395d00d1SAntti Palosaari default: 861395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fec_inner\n", 862395d00d1SAntti Palosaari __func__); 863395d00d1SAntti Palosaari } 864395d00d1SAntti Palosaari 865395d00d1SAntti Palosaari c->modulation = QPSK; 866395d00d1SAntti Palosaari 867395d00d1SAntti Palosaari break; 868395d00d1SAntti Palosaari case SYS_DVBS2: 869395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0x7e, &buf[0]); 870395d00d1SAntti Palosaari if (ret) 871395d00d1SAntti Palosaari goto err; 872395d00d1SAntti Palosaari 873395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0x89, &buf[1]); 874395d00d1SAntti Palosaari if (ret) 875395d00d1SAntti Palosaari goto err; 876395d00d1SAntti Palosaari 877395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xf2, &buf[2]); 878395d00d1SAntti Palosaari if (ret) 879395d00d1SAntti Palosaari goto err; 880395d00d1SAntti Palosaari 881395d00d1SAntti Palosaari switch ((buf[0] >> 0) & 0x0f) { 882395d00d1SAntti Palosaari case 2: 883395d00d1SAntti Palosaari c->fec_inner = FEC_2_5; 884395d00d1SAntti Palosaari break; 885395d00d1SAntti Palosaari case 3: 886395d00d1SAntti Palosaari c->fec_inner = FEC_1_2; 887395d00d1SAntti Palosaari break; 888395d00d1SAntti Palosaari case 4: 889395d00d1SAntti Palosaari c->fec_inner = FEC_3_5; 890395d00d1SAntti Palosaari break; 891395d00d1SAntti Palosaari case 5: 892395d00d1SAntti Palosaari c->fec_inner = FEC_2_3; 893395d00d1SAntti Palosaari break; 894395d00d1SAntti Palosaari case 6: 895395d00d1SAntti Palosaari c->fec_inner = FEC_3_4; 896395d00d1SAntti Palosaari break; 897395d00d1SAntti Palosaari case 7: 898395d00d1SAntti Palosaari c->fec_inner = FEC_4_5; 899395d00d1SAntti Palosaari break; 900395d00d1SAntti Palosaari case 8: 901395d00d1SAntti Palosaari c->fec_inner = FEC_5_6; 902395d00d1SAntti Palosaari break; 903395d00d1SAntti Palosaari case 9: 904395d00d1SAntti Palosaari c->fec_inner = FEC_8_9; 905395d00d1SAntti Palosaari break; 906395d00d1SAntti Palosaari case 10: 907395d00d1SAntti Palosaari c->fec_inner = FEC_9_10; 908395d00d1SAntti Palosaari break; 909395d00d1SAntti Palosaari default: 910395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fec_inner\n", 911395d00d1SAntti Palosaari __func__); 912395d00d1SAntti Palosaari } 913395d00d1SAntti Palosaari 914395d00d1SAntti Palosaari switch ((buf[0] >> 5) & 0x01) { 915395d00d1SAntti Palosaari case 0: 916395d00d1SAntti Palosaari c->pilot = PILOT_OFF; 917395d00d1SAntti Palosaari break; 918395d00d1SAntti Palosaari case 1: 919395d00d1SAntti Palosaari c->pilot = PILOT_ON; 920395d00d1SAntti Palosaari break; 921395d00d1SAntti Palosaari } 922395d00d1SAntti Palosaari 923395d00d1SAntti Palosaari switch ((buf[0] >> 6) & 0x07) { 924395d00d1SAntti Palosaari case 0: 925395d00d1SAntti Palosaari c->modulation = QPSK; 926395d00d1SAntti Palosaari break; 927395d00d1SAntti Palosaari case 1: 928395d00d1SAntti Palosaari c->modulation = PSK_8; 929395d00d1SAntti Palosaari break; 930395d00d1SAntti Palosaari case 2: 931395d00d1SAntti Palosaari c->modulation = APSK_16; 932395d00d1SAntti Palosaari break; 933395d00d1SAntti Palosaari case 3: 934395d00d1SAntti Palosaari c->modulation = APSK_32; 935395d00d1SAntti Palosaari break; 936395d00d1SAntti Palosaari default: 937395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid modulation\n", 938395d00d1SAntti Palosaari __func__); 939395d00d1SAntti Palosaari } 940395d00d1SAntti Palosaari 941395d00d1SAntti Palosaari switch ((buf[1] >> 7) & 0x01) { 942395d00d1SAntti Palosaari case 0: 943395d00d1SAntti Palosaari c->inversion = INVERSION_OFF; 944395d00d1SAntti Palosaari break; 945395d00d1SAntti Palosaari case 1: 946395d00d1SAntti Palosaari c->inversion = INVERSION_ON; 947395d00d1SAntti Palosaari break; 948395d00d1SAntti Palosaari } 949395d00d1SAntti Palosaari 950395d00d1SAntti Palosaari switch ((buf[2] >> 0) & 0x03) { 951395d00d1SAntti Palosaari case 0: 952395d00d1SAntti Palosaari c->rolloff = ROLLOFF_35; 953395d00d1SAntti Palosaari break; 954395d00d1SAntti Palosaari case 1: 955395d00d1SAntti Palosaari c->rolloff = ROLLOFF_25; 956395d00d1SAntti Palosaari break; 957395d00d1SAntti Palosaari case 2: 958395d00d1SAntti Palosaari c->rolloff = ROLLOFF_20; 959395d00d1SAntti Palosaari break; 960395d00d1SAntti Palosaari default: 961395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid rolloff\n", 962395d00d1SAntti Palosaari __func__); 963395d00d1SAntti Palosaari } 964395d00d1SAntti Palosaari break; 965395d00d1SAntti Palosaari default: 966395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 967395d00d1SAntti Palosaari __func__); 968395d00d1SAntti Palosaari ret = -EINVAL; 969395d00d1SAntti Palosaari goto err; 970395d00d1SAntti Palosaari } 971395d00d1SAntti Palosaari 972395d00d1SAntti Palosaari ret = m88ds3103_rd_regs(priv, 0x6d, buf, 2); 973395d00d1SAntti Palosaari if (ret) 974395d00d1SAntti Palosaari goto err; 975395d00d1SAntti Palosaari 976395d00d1SAntti Palosaari c->symbol_rate = 1ull * ((buf[1] << 8) | (buf[0] << 0)) * 977f4df95bcSnibble.max priv->mclk_khz * 1000 / 0x10000; 978395d00d1SAntti Palosaari 979395d00d1SAntti Palosaari return 0; 980395d00d1SAntti Palosaari err: 981395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 982395d00d1SAntti Palosaari return ret; 983395d00d1SAntti Palosaari } 984395d00d1SAntti Palosaari 985395d00d1SAntti Palosaari static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) 986395d00d1SAntti Palosaari { 987395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 98841b9aa00SAntti Palosaari 989*c1daf651SAntti Palosaari if (c->cnr.stat[0].scale == FE_SCALE_DECIBEL) 990*c1daf651SAntti Palosaari *snr = div_s64(c->cnr.stat[0].svalue, 100); 991395d00d1SAntti Palosaari else 992395d00d1SAntti Palosaari *snr = 0; 993395d00d1SAntti Palosaari 994395d00d1SAntti Palosaari return 0; 995395d00d1SAntti Palosaari } 996395d00d1SAntti Palosaari 9974423a2baSAntti Palosaari static int m88ds3103_read_ber(struct dvb_frontend *fe, u32 *ber) 9984423a2baSAntti Palosaari { 9994423a2baSAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 10004423a2baSAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 10014423a2baSAntti Palosaari int ret; 10024423a2baSAntti Palosaari unsigned int utmp; 10034423a2baSAntti Palosaari u8 buf[3], u8tmp; 100441b9aa00SAntti Palosaari 10054423a2baSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 10064423a2baSAntti Palosaari 10074423a2baSAntti Palosaari switch (c->delivery_system) { 10084423a2baSAntti Palosaari case SYS_DVBS: 10094423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf9, 0x04); 10104423a2baSAntti Palosaari if (ret) 10114423a2baSAntti Palosaari goto err; 10124423a2baSAntti Palosaari 10134423a2baSAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xf8, &u8tmp); 10144423a2baSAntti Palosaari if (ret) 10154423a2baSAntti Palosaari goto err; 10164423a2baSAntti Palosaari 10174423a2baSAntti Palosaari if (!(u8tmp & 0x10)) { 10184423a2baSAntti Palosaari u8tmp |= 0x10; 10194423a2baSAntti Palosaari 10204423a2baSAntti Palosaari ret = m88ds3103_rd_regs(priv, 0xf6, buf, 2); 10214423a2baSAntti Palosaari if (ret) 10224423a2baSAntti Palosaari goto err; 10234423a2baSAntti Palosaari 10244423a2baSAntti Palosaari priv->ber = (buf[1] << 8) | (buf[0] << 0); 10254423a2baSAntti Palosaari 10264423a2baSAntti Palosaari /* restart counters */ 10274423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf8, u8tmp); 10284423a2baSAntti Palosaari if (ret) 10294423a2baSAntti Palosaari goto err; 10304423a2baSAntti Palosaari } 10314423a2baSAntti Palosaari break; 10324423a2baSAntti Palosaari case SYS_DVBS2: 10334423a2baSAntti Palosaari ret = m88ds3103_rd_regs(priv, 0xd5, buf, 3); 10344423a2baSAntti Palosaari if (ret) 10354423a2baSAntti Palosaari goto err; 10364423a2baSAntti Palosaari 10374423a2baSAntti Palosaari utmp = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0); 10384423a2baSAntti Palosaari 10394423a2baSAntti Palosaari if (utmp > 3000) { 10404423a2baSAntti Palosaari ret = m88ds3103_rd_regs(priv, 0xf7, buf, 2); 10414423a2baSAntti Palosaari if (ret) 10424423a2baSAntti Palosaari goto err; 10434423a2baSAntti Palosaari 10444423a2baSAntti Palosaari priv->ber = (buf[1] << 8) | (buf[0] << 0); 10454423a2baSAntti Palosaari 10464423a2baSAntti Palosaari /* restart counters */ 10474423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xd1, 0x01); 10484423a2baSAntti Palosaari if (ret) 10494423a2baSAntti Palosaari goto err; 10504423a2baSAntti Palosaari 10514423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf9, 0x01); 10524423a2baSAntti Palosaari if (ret) 10534423a2baSAntti Palosaari goto err; 10544423a2baSAntti Palosaari 10554423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf9, 0x00); 10564423a2baSAntti Palosaari if (ret) 10574423a2baSAntti Palosaari goto err; 10584423a2baSAntti Palosaari 10594423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xd1, 0x00); 10604423a2baSAntti Palosaari if (ret) 10614423a2baSAntti Palosaari goto err; 10624423a2baSAntti Palosaari } 10634423a2baSAntti Palosaari break; 10644423a2baSAntti Palosaari default: 10654423a2baSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 10664423a2baSAntti Palosaari __func__); 10674423a2baSAntti Palosaari ret = -EINVAL; 10684423a2baSAntti Palosaari goto err; 10694423a2baSAntti Palosaari } 10704423a2baSAntti Palosaari 10714423a2baSAntti Palosaari *ber = priv->ber; 10724423a2baSAntti Palosaari 10734423a2baSAntti Palosaari return 0; 10744423a2baSAntti Palosaari err: 10754423a2baSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 10764423a2baSAntti Palosaari return ret; 10774423a2baSAntti Palosaari } 1078395d00d1SAntti Palosaari 1079395d00d1SAntti Palosaari static int m88ds3103_set_tone(struct dvb_frontend *fe, 1080395d00d1SAntti Palosaari fe_sec_tone_mode_t fe_sec_tone_mode) 1081395d00d1SAntti Palosaari { 1082395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 1083395d00d1SAntti Palosaari int ret; 1084395d00d1SAntti Palosaari u8 u8tmp, tone, reg_a1_mask; 108541b9aa00SAntti Palosaari 1086395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: fe_sec_tone_mode=%d\n", __func__, 1087395d00d1SAntti Palosaari fe_sec_tone_mode); 1088395d00d1SAntti Palosaari 1089395d00d1SAntti Palosaari if (!priv->warm) { 1090395d00d1SAntti Palosaari ret = -EAGAIN; 1091395d00d1SAntti Palosaari goto err; 1092395d00d1SAntti Palosaari } 1093395d00d1SAntti Palosaari 1094395d00d1SAntti Palosaari switch (fe_sec_tone_mode) { 1095395d00d1SAntti Palosaari case SEC_TONE_ON: 1096395d00d1SAntti Palosaari tone = 0; 1097418a97cbSAntti Palosaari reg_a1_mask = 0x47; 1098395d00d1SAntti Palosaari break; 1099395d00d1SAntti Palosaari case SEC_TONE_OFF: 1100395d00d1SAntti Palosaari tone = 1; 1101395d00d1SAntti Palosaari reg_a1_mask = 0x00; 1102395d00d1SAntti Palosaari break; 1103395d00d1SAntti Palosaari default: 1104395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_tone_mode\n", 1105395d00d1SAntti Palosaari __func__); 1106395d00d1SAntti Palosaari ret = -EINVAL; 1107395d00d1SAntti Palosaari goto err; 1108395d00d1SAntti Palosaari } 1109395d00d1SAntti Palosaari 1110395d00d1SAntti Palosaari u8tmp = tone << 7 | priv->cfg->envelope_mode << 5; 1111395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0xe0); 1112395d00d1SAntti Palosaari if (ret) 1113395d00d1SAntti Palosaari goto err; 1114395d00d1SAntti Palosaari 1115395d00d1SAntti Palosaari u8tmp = 1 << 2; 1116395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa1, u8tmp, reg_a1_mask); 1117395d00d1SAntti Palosaari if (ret) 1118395d00d1SAntti Palosaari goto err; 1119395d00d1SAntti Palosaari 1120395d00d1SAntti Palosaari return 0; 1121395d00d1SAntti Palosaari err: 1122395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1123395d00d1SAntti Palosaari return ret; 1124395d00d1SAntti Palosaari } 1125395d00d1SAntti Palosaari 112679d09330Snibble.max static int m88ds3103_set_voltage(struct dvb_frontend *fe, 1127d28677ffSAntti Palosaari fe_sec_voltage_t fe_sec_voltage) 112879d09330Snibble.max { 112979d09330Snibble.max struct m88ds3103_priv *priv = fe->demodulator_priv; 1130d28677ffSAntti Palosaari int ret; 1131d28677ffSAntti Palosaari u8 u8tmp; 1132d28677ffSAntti Palosaari bool voltage_sel, voltage_dis; 113379d09330Snibble.max 1134d28677ffSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: fe_sec_voltage=%d\n", __func__, 1135d28677ffSAntti Palosaari fe_sec_voltage); 113679d09330Snibble.max 1137d28677ffSAntti Palosaari if (!priv->warm) { 1138d28677ffSAntti Palosaari ret = -EAGAIN; 1139d28677ffSAntti Palosaari goto err; 1140d28677ffSAntti Palosaari } 114179d09330Snibble.max 1142d28677ffSAntti Palosaari switch (fe_sec_voltage) { 114379d09330Snibble.max case SEC_VOLTAGE_18: 1144afbd6eb4SMauro Carvalho Chehab voltage_sel = true; 1145afbd6eb4SMauro Carvalho Chehab voltage_dis = false; 114679d09330Snibble.max break; 114779d09330Snibble.max case SEC_VOLTAGE_13: 1148afbd6eb4SMauro Carvalho Chehab voltage_sel = false; 1149afbd6eb4SMauro Carvalho Chehab voltage_dis = false; 115079d09330Snibble.max break; 115179d09330Snibble.max case SEC_VOLTAGE_OFF: 1152afbd6eb4SMauro Carvalho Chehab voltage_sel = false; 1153afbd6eb4SMauro Carvalho Chehab voltage_dis = true; 115479d09330Snibble.max break; 1155d28677ffSAntti Palosaari default: 1156d28677ffSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_voltage\n", 1157d28677ffSAntti Palosaari __func__); 1158d28677ffSAntti Palosaari ret = -EINVAL; 1159d28677ffSAntti Palosaari goto err; 116079d09330Snibble.max } 1161d28677ffSAntti Palosaari 1162d28677ffSAntti Palosaari /* output pin polarity */ 1163d28677ffSAntti Palosaari voltage_sel ^= priv->cfg->lnb_hv_pol; 1164d28677ffSAntti Palosaari voltage_dis ^= priv->cfg->lnb_en_pol; 1165d28677ffSAntti Palosaari 1166d28677ffSAntti Palosaari u8tmp = voltage_dis << 1 | voltage_sel << 0; 1167d28677ffSAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0x03); 1168d28677ffSAntti Palosaari if (ret) 1169d28677ffSAntti Palosaari goto err; 117079d09330Snibble.max 117179d09330Snibble.max return 0; 1172d28677ffSAntti Palosaari err: 1173d28677ffSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1174d28677ffSAntti Palosaari return ret; 117579d09330Snibble.max } 117679d09330Snibble.max 1177395d00d1SAntti Palosaari static int m88ds3103_diseqc_send_master_cmd(struct dvb_frontend *fe, 1178395d00d1SAntti Palosaari struct dvb_diseqc_master_cmd *diseqc_cmd) 1179395d00d1SAntti Palosaari { 1180395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 1181395d00d1SAntti Palosaari int ret, i; 1182395d00d1SAntti Palosaari u8 u8tmp; 118341b9aa00SAntti Palosaari 1184395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: msg=%*ph\n", __func__, 1185395d00d1SAntti Palosaari diseqc_cmd->msg_len, diseqc_cmd->msg); 1186395d00d1SAntti Palosaari 1187395d00d1SAntti Palosaari if (!priv->warm) { 1188395d00d1SAntti Palosaari ret = -EAGAIN; 1189395d00d1SAntti Palosaari goto err; 1190395d00d1SAntti Palosaari } 1191395d00d1SAntti Palosaari 1192395d00d1SAntti Palosaari if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 6) { 1193395d00d1SAntti Palosaari ret = -EINVAL; 1194395d00d1SAntti Palosaari goto err; 1195395d00d1SAntti Palosaari } 1196395d00d1SAntti Palosaari 1197395d00d1SAntti Palosaari u8tmp = priv->cfg->envelope_mode << 5; 1198395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0xe0); 1199395d00d1SAntti Palosaari if (ret) 1200395d00d1SAntti Palosaari goto err; 1201395d00d1SAntti Palosaari 1202395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0xa3, diseqc_cmd->msg, 1203395d00d1SAntti Palosaari diseqc_cmd->msg_len); 1204395d00d1SAntti Palosaari if (ret) 1205395d00d1SAntti Palosaari goto err; 1206395d00d1SAntti Palosaari 1207395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xa1, 1208395d00d1SAntti Palosaari (diseqc_cmd->msg_len - 1) << 3 | 0x07); 1209395d00d1SAntti Palosaari if (ret) 1210395d00d1SAntti Palosaari goto err; 1211395d00d1SAntti Palosaari 1212395d00d1SAntti Palosaari /* DiSEqC message typical period is 54 ms */ 1213395d00d1SAntti Palosaari usleep_range(40000, 60000); 1214395d00d1SAntti Palosaari 1215395d00d1SAntti Palosaari /* wait DiSEqC TX ready */ 1216395d00d1SAntti Palosaari for (i = 20, u8tmp = 1; i && u8tmp; i--) { 1217395d00d1SAntti Palosaari usleep_range(5000, 10000); 1218395d00d1SAntti Palosaari 1219395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0xa1, &u8tmp, 0x40); 1220395d00d1SAntti Palosaari if (ret) 1221395d00d1SAntti Palosaari goto err; 1222395d00d1SAntti Palosaari } 1223395d00d1SAntti Palosaari 1224395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); 1225395d00d1SAntti Palosaari 1226395d00d1SAntti Palosaari if (i == 0) { 1227395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: diseqc tx timeout\n", __func__); 1228395d00d1SAntti Palosaari 1229395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa1, 0x40, 0xc0); 1230395d00d1SAntti Palosaari if (ret) 1231395d00d1SAntti Palosaari goto err; 1232395d00d1SAntti Palosaari } 1233395d00d1SAntti Palosaari 1234395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, 0x80, 0xc0); 1235395d00d1SAntti Palosaari if (ret) 1236395d00d1SAntti Palosaari goto err; 1237395d00d1SAntti Palosaari 1238395d00d1SAntti Palosaari if (i == 0) { 1239395d00d1SAntti Palosaari ret = -ETIMEDOUT; 1240395d00d1SAntti Palosaari goto err; 1241395d00d1SAntti Palosaari } 1242395d00d1SAntti Palosaari 1243395d00d1SAntti Palosaari return 0; 1244395d00d1SAntti Palosaari err: 1245395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1246395d00d1SAntti Palosaari return ret; 1247395d00d1SAntti Palosaari } 1248395d00d1SAntti Palosaari 1249395d00d1SAntti Palosaari static int m88ds3103_diseqc_send_burst(struct dvb_frontend *fe, 1250395d00d1SAntti Palosaari fe_sec_mini_cmd_t fe_sec_mini_cmd) 1251395d00d1SAntti Palosaari { 1252395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 1253395d00d1SAntti Palosaari int ret, i; 1254395d00d1SAntti Palosaari u8 u8tmp, burst; 125541b9aa00SAntti Palosaari 1256395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: fe_sec_mini_cmd=%d\n", __func__, 1257395d00d1SAntti Palosaari fe_sec_mini_cmd); 1258395d00d1SAntti Palosaari 1259395d00d1SAntti Palosaari if (!priv->warm) { 1260395d00d1SAntti Palosaari ret = -EAGAIN; 1261395d00d1SAntti Palosaari goto err; 1262395d00d1SAntti Palosaari } 1263395d00d1SAntti Palosaari 1264395d00d1SAntti Palosaari u8tmp = priv->cfg->envelope_mode << 5; 1265395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0xe0); 1266395d00d1SAntti Palosaari if (ret) 1267395d00d1SAntti Palosaari goto err; 1268395d00d1SAntti Palosaari 1269395d00d1SAntti Palosaari switch (fe_sec_mini_cmd) { 1270395d00d1SAntti Palosaari case SEC_MINI_A: 1271395d00d1SAntti Palosaari burst = 0x02; 1272395d00d1SAntti Palosaari break; 1273395d00d1SAntti Palosaari case SEC_MINI_B: 1274395d00d1SAntti Palosaari burst = 0x01; 1275395d00d1SAntti Palosaari break; 1276395d00d1SAntti Palosaari default: 1277395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_mini_cmd\n", 1278395d00d1SAntti Palosaari __func__); 1279395d00d1SAntti Palosaari ret = -EINVAL; 1280395d00d1SAntti Palosaari goto err; 1281395d00d1SAntti Palosaari } 1282395d00d1SAntti Palosaari 1283395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xa1, burst); 1284395d00d1SAntti Palosaari if (ret) 1285395d00d1SAntti Palosaari goto err; 1286395d00d1SAntti Palosaari 1287395d00d1SAntti Palosaari /* DiSEqC ToneBurst period is 12.5 ms */ 1288395d00d1SAntti Palosaari usleep_range(11000, 20000); 1289395d00d1SAntti Palosaari 1290395d00d1SAntti Palosaari /* wait DiSEqC TX ready */ 1291395d00d1SAntti Palosaari for (i = 5, u8tmp = 1; i && u8tmp; i--) { 1292395d00d1SAntti Palosaari usleep_range(800, 2000); 1293395d00d1SAntti Palosaari 1294395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0xa1, &u8tmp, 0x40); 1295395d00d1SAntti Palosaari if (ret) 1296395d00d1SAntti Palosaari goto err; 1297395d00d1SAntti Palosaari } 1298395d00d1SAntti Palosaari 1299395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); 1300395d00d1SAntti Palosaari 1301395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, 0x80, 0xc0); 1302395d00d1SAntti Palosaari if (ret) 1303395d00d1SAntti Palosaari goto err; 1304395d00d1SAntti Palosaari 1305395d00d1SAntti Palosaari if (i == 0) { 1306395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: diseqc tx timeout\n", __func__); 1307395d00d1SAntti Palosaari ret = -ETIMEDOUT; 1308395d00d1SAntti Palosaari goto err; 1309395d00d1SAntti Palosaari } 1310395d00d1SAntti Palosaari 1311395d00d1SAntti Palosaari return 0; 1312395d00d1SAntti Palosaari err: 1313395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1314395d00d1SAntti Palosaari return ret; 1315395d00d1SAntti Palosaari } 1316395d00d1SAntti Palosaari 1317395d00d1SAntti Palosaari static int m88ds3103_get_tune_settings(struct dvb_frontend *fe, 1318395d00d1SAntti Palosaari struct dvb_frontend_tune_settings *s) 1319395d00d1SAntti Palosaari { 1320395d00d1SAntti Palosaari s->min_delay_ms = 3000; 1321395d00d1SAntti Palosaari 1322395d00d1SAntti Palosaari return 0; 1323395d00d1SAntti Palosaari } 1324395d00d1SAntti Palosaari 132544b9055bSAntti Palosaari static void m88ds3103_release(struct dvb_frontend *fe) 1326395d00d1SAntti Palosaari { 132744b9055bSAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 132841b9aa00SAntti Palosaari 132944b9055bSAntti Palosaari i2c_del_mux_adapter(priv->i2c_adapter); 133044b9055bSAntti Palosaari kfree(priv); 1331395d00d1SAntti Palosaari } 1332395d00d1SAntti Palosaari 133344b9055bSAntti Palosaari static int m88ds3103_select(struct i2c_adapter *adap, void *mux_priv, u32 chan) 1334395d00d1SAntti Palosaari { 133544b9055bSAntti Palosaari struct m88ds3103_priv *priv = mux_priv; 1336395d00d1SAntti Palosaari int ret; 1337395d00d1SAntti Palosaari struct i2c_msg gate_open_msg[1] = { 1338395d00d1SAntti Palosaari { 1339395d00d1SAntti Palosaari .addr = priv->cfg->i2c_addr, 1340395d00d1SAntti Palosaari .flags = 0, 1341395d00d1SAntti Palosaari .len = 2, 1342395d00d1SAntti Palosaari .buf = "\x03\x11", 1343395d00d1SAntti Palosaari } 1344395d00d1SAntti Palosaari }; 1345395d00d1SAntti Palosaari 1346395d00d1SAntti Palosaari mutex_lock(&priv->i2c_mutex); 1347395d00d1SAntti Palosaari 134844b9055bSAntti Palosaari /* open tuner I2C repeater for 1 xfer, closes automatically */ 13494fc57876SAntti Palosaari ret = __i2c_transfer(priv->i2c, gate_open_msg, 1); 1350395d00d1SAntti Palosaari if (ret != 1) { 135144b9055bSAntti Palosaari dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d\n", 1352395d00d1SAntti Palosaari KBUILD_MODNAME, ret); 135344b9055bSAntti Palosaari if (ret >= 0) 1354395d00d1SAntti Palosaari ret = -EREMOTEIO; 1355395d00d1SAntti Palosaari 1356395d00d1SAntti Palosaari return ret; 1357395d00d1SAntti Palosaari } 1358395d00d1SAntti Palosaari 135944b9055bSAntti Palosaari return 0; 136044b9055bSAntti Palosaari } 1361395d00d1SAntti Palosaari 136244b9055bSAntti Palosaari static int m88ds3103_deselect(struct i2c_adapter *adap, void *mux_priv, 136344b9055bSAntti Palosaari u32 chan) 1364395d00d1SAntti Palosaari { 136544b9055bSAntti Palosaari struct m88ds3103_priv *priv = mux_priv; 136644b9055bSAntti Palosaari 136744b9055bSAntti Palosaari mutex_unlock(&priv->i2c_mutex); 136844b9055bSAntti Palosaari 136944b9055bSAntti Palosaari return 0; 1370395d00d1SAntti Palosaari } 1371395d00d1SAntti Palosaari 1372395d00d1SAntti Palosaari struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg, 1373395d00d1SAntti Palosaari struct i2c_adapter *i2c, struct i2c_adapter **tuner_i2c_adapter) 1374395d00d1SAntti Palosaari { 1375395d00d1SAntti Palosaari int ret; 1376395d00d1SAntti Palosaari struct m88ds3103_priv *priv; 1377395d00d1SAntti Palosaari u8 chip_id, u8tmp; 1378395d00d1SAntti Palosaari 1379395d00d1SAntti Palosaari /* allocate memory for the internal priv */ 13808a878dc4SAntti Palosaari priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1381395d00d1SAntti Palosaari if (!priv) { 1382395d00d1SAntti Palosaari ret = -ENOMEM; 1383395d00d1SAntti Palosaari dev_err(&i2c->dev, "%s: kzalloc() failed\n", KBUILD_MODNAME); 1384395d00d1SAntti Palosaari goto err; 1385395d00d1SAntti Palosaari } 1386395d00d1SAntti Palosaari 1387395d00d1SAntti Palosaari priv->cfg = cfg; 1388395d00d1SAntti Palosaari priv->i2c = i2c; 1389395d00d1SAntti Palosaari mutex_init(&priv->i2c_mutex); 1390395d00d1SAntti Palosaari 1391f4df95bcSnibble.max /* 0x00: chip id[6:0], 0x01: chip ver[7:0], 0x02: chip ver[15:8] */ 1392f4df95bcSnibble.max ret = m88ds3103_rd_reg(priv, 0x00, &chip_id); 1393395d00d1SAntti Palosaari if (ret) 1394395d00d1SAntti Palosaari goto err; 1395395d00d1SAntti Palosaari 1396f4df95bcSnibble.max chip_id >>= 1; 1397f4df95bcSnibble.max dev_info(&priv->i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); 1398395d00d1SAntti Palosaari 1399395d00d1SAntti Palosaari switch (chip_id) { 1400f4df95bcSnibble.max case M88RS6000_CHIP_ID: 1401f4df95bcSnibble.max case M88DS3103_CHIP_ID: 1402395d00d1SAntti Palosaari break; 1403395d00d1SAntti Palosaari default: 1404395d00d1SAntti Palosaari goto err; 1405395d00d1SAntti Palosaari } 1406f4df95bcSnibble.max priv->chip_id = chip_id; 1407395d00d1SAntti Palosaari 1408395d00d1SAntti Palosaari switch (priv->cfg->clock_out) { 1409395d00d1SAntti Palosaari case M88DS3103_CLOCK_OUT_DISABLED: 1410395d00d1SAntti Palosaari u8tmp = 0x80; 1411395d00d1SAntti Palosaari break; 1412395d00d1SAntti Palosaari case M88DS3103_CLOCK_OUT_ENABLED: 1413395d00d1SAntti Palosaari u8tmp = 0x00; 1414395d00d1SAntti Palosaari break; 1415395d00d1SAntti Palosaari case M88DS3103_CLOCK_OUT_ENABLED_DIV2: 1416395d00d1SAntti Palosaari u8tmp = 0x10; 1417395d00d1SAntti Palosaari break; 1418395d00d1SAntti Palosaari default: 1419395d00d1SAntti Palosaari goto err; 1420395d00d1SAntti Palosaari } 1421395d00d1SAntti Palosaari 1422f4df95bcSnibble.max /* 0x29 register is defined differently for m88rs6000. */ 1423f4df95bcSnibble.max /* set internal tuner address to 0x21 */ 1424f4df95bcSnibble.max if (chip_id == M88RS6000_CHIP_ID) 1425f4df95bcSnibble.max u8tmp = 0x00; 1426f4df95bcSnibble.max 1427395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0x29, u8tmp); 1428395d00d1SAntti Palosaari if (ret) 1429395d00d1SAntti Palosaari goto err; 1430395d00d1SAntti Palosaari 1431395d00d1SAntti Palosaari /* sleep */ 1432395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x00, 0x01); 1433395d00d1SAntti Palosaari if (ret) 1434395d00d1SAntti Palosaari goto err; 1435395d00d1SAntti Palosaari 1436395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x01, 0x01); 1437395d00d1SAntti Palosaari if (ret) 1438395d00d1SAntti Palosaari goto err; 1439395d00d1SAntti Palosaari 1440395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x10, 0x10); 1441395d00d1SAntti Palosaari if (ret) 1442395d00d1SAntti Palosaari goto err; 1443395d00d1SAntti Palosaari 144444b9055bSAntti Palosaari /* create mux i2c adapter for tuner */ 144544b9055bSAntti Palosaari priv->i2c_adapter = i2c_add_mux_adapter(i2c, &i2c->dev, priv, 0, 0, 0, 144644b9055bSAntti Palosaari m88ds3103_select, m88ds3103_deselect); 144744b9055bSAntti Palosaari if (priv->i2c_adapter == NULL) 144844b9055bSAntti Palosaari goto err; 144944b9055bSAntti Palosaari 145044b9055bSAntti Palosaari *tuner_i2c_adapter = priv->i2c_adapter; 145144b9055bSAntti Palosaari 1452395d00d1SAntti Palosaari /* create dvb_frontend */ 1453395d00d1SAntti Palosaari memcpy(&priv->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops)); 1454f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) 1455f4df95bcSnibble.max strncpy(priv->fe.ops.info.name, 1456f4df95bcSnibble.max "Montage M88RS6000", sizeof(priv->fe.ops.info.name)); 1457395d00d1SAntti Palosaari priv->fe.demodulator_priv = priv; 1458395d00d1SAntti Palosaari 1459395d00d1SAntti Palosaari return &priv->fe; 1460395d00d1SAntti Palosaari err: 1461395d00d1SAntti Palosaari dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); 1462395d00d1SAntti Palosaari kfree(priv); 1463395d00d1SAntti Palosaari return NULL; 1464395d00d1SAntti Palosaari } 1465395d00d1SAntti Palosaari EXPORT_SYMBOL(m88ds3103_attach); 1466395d00d1SAntti Palosaari 1467395d00d1SAntti Palosaari static struct dvb_frontend_ops m88ds3103_ops = { 1468395d00d1SAntti Palosaari .delsys = { SYS_DVBS, SYS_DVBS2 }, 1469395d00d1SAntti Palosaari .info = { 1470395d00d1SAntti Palosaari .name = "Montage M88DS3103", 1471395d00d1SAntti Palosaari .frequency_min = 950000, 1472395d00d1SAntti Palosaari .frequency_max = 2150000, 1473395d00d1SAntti Palosaari .frequency_tolerance = 5000, 1474395d00d1SAntti Palosaari .symbol_rate_min = 1000000, 1475395d00d1SAntti Palosaari .symbol_rate_max = 45000000, 1476395d00d1SAntti Palosaari .caps = FE_CAN_INVERSION_AUTO | 1477395d00d1SAntti Palosaari FE_CAN_FEC_1_2 | 1478395d00d1SAntti Palosaari FE_CAN_FEC_2_3 | 1479395d00d1SAntti Palosaari FE_CAN_FEC_3_4 | 1480395d00d1SAntti Palosaari FE_CAN_FEC_4_5 | 1481395d00d1SAntti Palosaari FE_CAN_FEC_5_6 | 1482395d00d1SAntti Palosaari FE_CAN_FEC_6_7 | 1483395d00d1SAntti Palosaari FE_CAN_FEC_7_8 | 1484395d00d1SAntti Palosaari FE_CAN_FEC_8_9 | 1485395d00d1SAntti Palosaari FE_CAN_FEC_AUTO | 1486395d00d1SAntti Palosaari FE_CAN_QPSK | 1487395d00d1SAntti Palosaari FE_CAN_RECOVER | 1488395d00d1SAntti Palosaari FE_CAN_2G_MODULATION 1489395d00d1SAntti Palosaari }, 1490395d00d1SAntti Palosaari 1491395d00d1SAntti Palosaari .release = m88ds3103_release, 1492395d00d1SAntti Palosaari 1493395d00d1SAntti Palosaari .get_tune_settings = m88ds3103_get_tune_settings, 1494395d00d1SAntti Palosaari 1495395d00d1SAntti Palosaari .init = m88ds3103_init, 1496395d00d1SAntti Palosaari .sleep = m88ds3103_sleep, 1497395d00d1SAntti Palosaari 1498395d00d1SAntti Palosaari .set_frontend = m88ds3103_set_frontend, 1499395d00d1SAntti Palosaari .get_frontend = m88ds3103_get_frontend, 1500395d00d1SAntti Palosaari 1501395d00d1SAntti Palosaari .read_status = m88ds3103_read_status, 1502395d00d1SAntti Palosaari .read_snr = m88ds3103_read_snr, 15034423a2baSAntti Palosaari .read_ber = m88ds3103_read_ber, 1504395d00d1SAntti Palosaari 1505395d00d1SAntti Palosaari .diseqc_send_master_cmd = m88ds3103_diseqc_send_master_cmd, 1506395d00d1SAntti Palosaari .diseqc_send_burst = m88ds3103_diseqc_send_burst, 1507395d00d1SAntti Palosaari 1508395d00d1SAntti Palosaari .set_tone = m88ds3103_set_tone, 150979d09330Snibble.max .set_voltage = m88ds3103_set_voltage, 1510395d00d1SAntti Palosaari }; 1511395d00d1SAntti Palosaari 1512395d00d1SAntti Palosaari MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 1513395d00d1SAntti Palosaari MODULE_DESCRIPTION("Montage M88DS3103 DVB-S/S2 demodulator driver"); 1514395d00d1SAntti Palosaari MODULE_LICENSE("GPL"); 1515395d00d1SAntti Palosaari MODULE_FIRMWARE(M88DS3103_FIRMWARE); 1516f4df95bcSnibble.max MODULE_FIRMWARE(M88RS6000_FIRMWARE); 1517