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; 193395d00d1SAntti Palosaari int ret; 194395d00d1SAntti Palosaari u8 u8tmp; 195395d00d1SAntti Palosaari 196395d00d1SAntti Palosaari *status = 0; 197395d00d1SAntti Palosaari 198395d00d1SAntti Palosaari if (!priv->warm) { 199395d00d1SAntti Palosaari ret = -EAGAIN; 200395d00d1SAntti Palosaari goto err; 201395d00d1SAntti Palosaari } 202395d00d1SAntti Palosaari 203395d00d1SAntti Palosaari switch (c->delivery_system) { 204395d00d1SAntti Palosaari case SYS_DVBS: 205395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0xd1, &u8tmp, 0x07); 206395d00d1SAntti Palosaari if (ret) 207395d00d1SAntti Palosaari goto err; 208395d00d1SAntti Palosaari 209395d00d1SAntti Palosaari if (u8tmp == 0x07) 210395d00d1SAntti Palosaari *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 211395d00d1SAntti Palosaari FE_HAS_VITERBI | FE_HAS_SYNC | 212395d00d1SAntti Palosaari FE_HAS_LOCK; 213395d00d1SAntti Palosaari break; 214395d00d1SAntti Palosaari case SYS_DVBS2: 215395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0x0d, &u8tmp, 0x8f); 216395d00d1SAntti Palosaari if (ret) 217395d00d1SAntti Palosaari goto err; 218395d00d1SAntti Palosaari 219395d00d1SAntti Palosaari if (u8tmp == 0x8f) 220395d00d1SAntti Palosaari *status = FE_HAS_SIGNAL | FE_HAS_CARRIER | 221395d00d1SAntti Palosaari FE_HAS_VITERBI | FE_HAS_SYNC | 222395d00d1SAntti Palosaari FE_HAS_LOCK; 223395d00d1SAntti Palosaari break; 224395d00d1SAntti Palosaari default: 225395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 226395d00d1SAntti Palosaari __func__); 227395d00d1SAntti Palosaari ret = -EINVAL; 228395d00d1SAntti Palosaari goto err; 229395d00d1SAntti Palosaari } 230395d00d1SAntti Palosaari 231395d00d1SAntti Palosaari priv->fe_status = *status; 232395d00d1SAntti Palosaari 233395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: lock=%02x status=%02x\n", 234395d00d1SAntti Palosaari __func__, u8tmp, *status); 235395d00d1SAntti Palosaari 236395d00d1SAntti Palosaari return 0; 237395d00d1SAntti Palosaari err: 238395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 239395d00d1SAntti Palosaari return ret; 240395d00d1SAntti Palosaari } 241395d00d1SAntti Palosaari 242395d00d1SAntti Palosaari static int m88ds3103_set_frontend(struct dvb_frontend *fe) 243395d00d1SAntti Palosaari { 244395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 245395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 24606487deeSAntti Palosaari int ret, len; 247395d00d1SAntti Palosaari const struct m88ds3103_reg_val *init; 248b6851419Snibble.max u8 u8tmp, u8tmp1 = 0, u8tmp2 = 0; /* silence compiler warning */ 249f4df95bcSnibble.max u8 buf[3]; 250b6851419Snibble.max u16 u16tmp, divide_ratio = 0; 25179d09330Snibble.max u32 tuner_frequency, target_mclk; 252395d00d1SAntti Palosaari s32 s32tmp; 25341b9aa00SAntti Palosaari 254395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, 255395d00d1SAntti Palosaari "%s: delivery_system=%d modulation=%d frequency=%d symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n", 256395d00d1SAntti Palosaari __func__, c->delivery_system, 257395d00d1SAntti Palosaari c->modulation, c->frequency, c->symbol_rate, 258395d00d1SAntti Palosaari c->inversion, c->pilot, c->rolloff); 259395d00d1SAntti Palosaari 260395d00d1SAntti Palosaari if (!priv->warm) { 261395d00d1SAntti Palosaari ret = -EAGAIN; 262395d00d1SAntti Palosaari goto err; 263395d00d1SAntti Palosaari } 264395d00d1SAntti Palosaari 265f4df95bcSnibble.max /* reset */ 266f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0x80); 267f4df95bcSnibble.max if (ret) 268f4df95bcSnibble.max goto err; 269f4df95bcSnibble.max 270f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0x00); 271f4df95bcSnibble.max if (ret) 272f4df95bcSnibble.max goto err; 273f4df95bcSnibble.max 274f4df95bcSnibble.max /* Disable demod clock path */ 275f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 276f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x06, 0xe0); 277f4df95bcSnibble.max if (ret) 278f4df95bcSnibble.max goto err; 279f4df95bcSnibble.max } 280f4df95bcSnibble.max 281395d00d1SAntti Palosaari /* program tuner */ 282395d00d1SAntti Palosaari if (fe->ops.tuner_ops.set_params) { 283395d00d1SAntti Palosaari ret = fe->ops.tuner_ops.set_params(fe); 284395d00d1SAntti Palosaari if (ret) 285395d00d1SAntti Palosaari goto err; 286395d00d1SAntti Palosaari } 287395d00d1SAntti Palosaari 288395d00d1SAntti Palosaari if (fe->ops.tuner_ops.get_frequency) { 289395d00d1SAntti Palosaari ret = fe->ops.tuner_ops.get_frequency(fe, &tuner_frequency); 290395d00d1SAntti Palosaari if (ret) 291395d00d1SAntti Palosaari goto err; 2922f9dff3fSAntti Palosaari } else { 2932f9dff3fSAntti Palosaari /* 2942f9dff3fSAntti Palosaari * Use nominal target frequency as tuner driver does not provide 2952f9dff3fSAntti Palosaari * actual frequency used. Carrier offset calculation is not 2962f9dff3fSAntti Palosaari * valid. 2972f9dff3fSAntti Palosaari */ 2982f9dff3fSAntti Palosaari tuner_frequency = c->frequency; 299395d00d1SAntti Palosaari } 300395d00d1SAntti Palosaari 301f4df95bcSnibble.max /* select M88RS6000 demod main mclk and ts mclk from tuner die. */ 302f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 303f4df95bcSnibble.max if (c->symbol_rate > 45010000) 304f4df95bcSnibble.max priv->mclk_khz = 110250; 305f4df95bcSnibble.max else 306f4df95bcSnibble.max priv->mclk_khz = 96000; 307395d00d1SAntti Palosaari 308f4df95bcSnibble.max if (c->delivery_system == SYS_DVBS) 309395d00d1SAntti Palosaari target_mclk = 96000; 310f4df95bcSnibble.max else 311f4df95bcSnibble.max target_mclk = 144000; 312395d00d1SAntti Palosaari 313f4df95bcSnibble.max /* Enable demod clock path */ 314f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x06, 0x00); 315f4df95bcSnibble.max if (ret) 316f4df95bcSnibble.max goto err; 317f4df95bcSnibble.max usleep_range(10000, 20000); 318f4df95bcSnibble.max } else { 319f4df95bcSnibble.max /* set M88DS3103 mclk and ts mclk. */ 320f4df95bcSnibble.max priv->mclk_khz = 96000; 321f4df95bcSnibble.max 322395d00d1SAntti Palosaari switch (priv->cfg->ts_mode) { 323395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL: 324395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL_D7: 325b6851419Snibble.max target_mclk = priv->cfg->ts_clk; 326395d00d1SAntti Palosaari break; 327395d00d1SAntti Palosaari case M88DS3103_TS_PARALLEL: 328395d00d1SAntti Palosaari case M88DS3103_TS_CI: 329b6851419Snibble.max if (c->delivery_system == SYS_DVBS) 330b6851419Snibble.max target_mclk = 96000; 331b6851419Snibble.max else { 332395d00d1SAntti Palosaari if (c->symbol_rate < 18000000) 333395d00d1SAntti Palosaari target_mclk = 96000; 334395d00d1SAntti Palosaari else if (c->symbol_rate < 28000000) 335395d00d1SAntti Palosaari target_mclk = 144000; 336395d00d1SAntti Palosaari else 337395d00d1SAntti Palosaari target_mclk = 192000; 338b6851419Snibble.max } 339395d00d1SAntti Palosaari break; 340395d00d1SAntti Palosaari default: 341395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", 342395d00d1SAntti Palosaari __func__); 343395d00d1SAntti Palosaari ret = -EINVAL; 344395d00d1SAntti Palosaari goto err; 345395d00d1SAntti Palosaari } 346f4df95bcSnibble.max 347f4df95bcSnibble.max switch (target_mclk) { 348f4df95bcSnibble.max case 96000: 349f4df95bcSnibble.max u8tmp1 = 0x02; /* 0b10 */ 350f4df95bcSnibble.max u8tmp2 = 0x01; /* 0b01 */ 351f4df95bcSnibble.max break; 352f4df95bcSnibble.max case 144000: 353f4df95bcSnibble.max u8tmp1 = 0x00; /* 0b00 */ 354f4df95bcSnibble.max u8tmp2 = 0x01; /* 0b01 */ 355f4df95bcSnibble.max break; 356f4df95bcSnibble.max case 192000: 357f4df95bcSnibble.max u8tmp1 = 0x03; /* 0b11 */ 358f4df95bcSnibble.max u8tmp2 = 0x00; /* 0b00 */ 359f4df95bcSnibble.max break; 360f4df95bcSnibble.max } 361f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x22, u8tmp1 << 6, 0xc0); 362f4df95bcSnibble.max if (ret) 363f4df95bcSnibble.max goto err; 364f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x24, u8tmp2 << 6, 0xc0); 365f4df95bcSnibble.max if (ret) 366f4df95bcSnibble.max goto err; 367f4df95bcSnibble.max } 368f4df95bcSnibble.max 369f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); 370f4df95bcSnibble.max if (ret) 371f4df95bcSnibble.max goto err; 372f4df95bcSnibble.max 373f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x00, 0x01); 374f4df95bcSnibble.max if (ret) 375f4df95bcSnibble.max goto err; 376f4df95bcSnibble.max 377f4df95bcSnibble.max switch (c->delivery_system) { 378f4df95bcSnibble.max case SYS_DVBS: 379f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 380f4df95bcSnibble.max len = ARRAY_SIZE(m88rs6000_dvbs_init_reg_vals); 381f4df95bcSnibble.max init = m88rs6000_dvbs_init_reg_vals; 382f4df95bcSnibble.max } else { 383f4df95bcSnibble.max len = ARRAY_SIZE(m88ds3103_dvbs_init_reg_vals); 384f4df95bcSnibble.max init = m88ds3103_dvbs_init_reg_vals; 385f4df95bcSnibble.max } 386f4df95bcSnibble.max break; 387f4df95bcSnibble.max case SYS_DVBS2: 388f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 389f4df95bcSnibble.max len = ARRAY_SIZE(m88rs6000_dvbs2_init_reg_vals); 390f4df95bcSnibble.max init = m88rs6000_dvbs2_init_reg_vals; 391f4df95bcSnibble.max } else { 392f4df95bcSnibble.max len = ARRAY_SIZE(m88ds3103_dvbs2_init_reg_vals); 393f4df95bcSnibble.max init = m88ds3103_dvbs2_init_reg_vals; 394f4df95bcSnibble.max } 395395d00d1SAntti Palosaari break; 396395d00d1SAntti Palosaari default: 397395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 398395d00d1SAntti Palosaari __func__); 399395d00d1SAntti Palosaari ret = -EINVAL; 400395d00d1SAntti Palosaari goto err; 401395d00d1SAntti Palosaari } 402395d00d1SAntti Palosaari 403395d00d1SAntti Palosaari /* program init table */ 404395d00d1SAntti Palosaari if (c->delivery_system != priv->delivery_system) { 40506487deeSAntti Palosaari ret = m88ds3103_wr_reg_val_tab(priv, init, len); 406395d00d1SAntti Palosaari if (ret) 407395d00d1SAntti Palosaari goto err; 408395d00d1SAntti Palosaari } 409395d00d1SAntti Palosaari 410f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) { 411f4df95bcSnibble.max if ((c->delivery_system == SYS_DVBS2) 412f4df95bcSnibble.max && ((c->symbol_rate / 1000) <= 5000)) { 413f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0xc0, 0x04); 414f4df95bcSnibble.max if (ret) 415f4df95bcSnibble.max goto err; 416f4df95bcSnibble.max buf[0] = 0x09; 417f4df95bcSnibble.max buf[1] = 0x22; 418f4df95bcSnibble.max buf[2] = 0x88; 419f4df95bcSnibble.max ret = m88ds3103_wr_regs(priv, 0x8a, buf, 3); 420f4df95bcSnibble.max if (ret) 421f4df95bcSnibble.max goto err; 422f4df95bcSnibble.max } 423f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x9d, 0x08, 0x08); 424f4df95bcSnibble.max if (ret) 425f4df95bcSnibble.max goto err; 426f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0xf1, 0x01); 427f4df95bcSnibble.max if (ret) 428f4df95bcSnibble.max goto err; 429f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, 0x30, 0x80, 0x80); 430f4df95bcSnibble.max if (ret) 431f4df95bcSnibble.max goto err; 432f4df95bcSnibble.max } 433f4df95bcSnibble.max 434395d00d1SAntti Palosaari switch (priv->cfg->ts_mode) { 435395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL: 436395d00d1SAntti Palosaari u8tmp1 = 0x00; 43779d09330Snibble.max u8tmp = 0x06; 438395d00d1SAntti Palosaari break; 439395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL_D7: 440395d00d1SAntti Palosaari u8tmp1 = 0x20; 44179d09330Snibble.max u8tmp = 0x06; 442395d00d1SAntti Palosaari break; 443395d00d1SAntti Palosaari case M88DS3103_TS_PARALLEL: 44479d09330Snibble.max u8tmp = 0x02; 445395d00d1SAntti Palosaari break; 446395d00d1SAntti Palosaari case M88DS3103_TS_CI: 44779d09330Snibble.max u8tmp = 0x03; 448395d00d1SAntti Palosaari break; 449395d00d1SAntti Palosaari default: 450395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid ts_mode\n", __func__); 451395d00d1SAntti Palosaari ret = -EINVAL; 452395d00d1SAntti Palosaari goto err; 453395d00d1SAntti Palosaari } 454395d00d1SAntti Palosaari 45579d09330Snibble.max if (priv->cfg->ts_clk_pol) 45679d09330Snibble.max u8tmp |= 0x40; 45779d09330Snibble.max 458395d00d1SAntti Palosaari /* TS mode */ 45992676ac9SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xfd, u8tmp); 460395d00d1SAntti Palosaari if (ret) 461395d00d1SAntti Palosaari goto err; 462395d00d1SAntti Palosaari 463395d00d1SAntti Palosaari switch (priv->cfg->ts_mode) { 464395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL: 465395d00d1SAntti Palosaari case M88DS3103_TS_SERIAL_D7: 466395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x29, u8tmp1, 0x20); 467395d00d1SAntti Palosaari if (ret) 468395d00d1SAntti Palosaari goto err; 469b6851419Snibble.max u8tmp1 = 0; 470b6851419Snibble.max u8tmp2 = 0; 471b6851419Snibble.max break; 472b6851419Snibble.max default: 47379d09330Snibble.max if (priv->cfg->ts_clk) { 47479d09330Snibble.max divide_ratio = DIV_ROUND_UP(target_mclk, priv->cfg->ts_clk); 475395d00d1SAntti Palosaari u8tmp1 = divide_ratio / 2; 476395d00d1SAntti Palosaari u8tmp2 = DIV_ROUND_UP(divide_ratio, 2); 477b6851419Snibble.max } 478395d00d1SAntti Palosaari } 479395d00d1SAntti Palosaari 480395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, 481395d00d1SAntti Palosaari "%s: target_mclk=%d ts_clk=%d divide_ratio=%d\n", 48279d09330Snibble.max __func__, target_mclk, priv->cfg->ts_clk, divide_ratio); 483395d00d1SAntti Palosaari 484395d00d1SAntti Palosaari u8tmp1--; 485395d00d1SAntti Palosaari u8tmp2--; 486395d00d1SAntti Palosaari /* u8tmp1[5:2] => fe[3:0], u8tmp1[1:0] => ea[7:6] */ 487395d00d1SAntti Palosaari u8tmp1 &= 0x3f; 488395d00d1SAntti Palosaari /* u8tmp2[5:0] => ea[5:0] */ 489395d00d1SAntti Palosaari u8tmp2 &= 0x3f; 490395d00d1SAntti Palosaari 491395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xfe, &u8tmp); 492395d00d1SAntti Palosaari if (ret) 493395d00d1SAntti Palosaari goto err; 494395d00d1SAntti Palosaari 495395d00d1SAntti Palosaari u8tmp = ((u8tmp & 0xf0) << 0) | u8tmp1 >> 2; 496395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xfe, u8tmp); 497395d00d1SAntti Palosaari if (ret) 498395d00d1SAntti Palosaari goto err; 499395d00d1SAntti Palosaari 500395d00d1SAntti Palosaari u8tmp = ((u8tmp1 & 0x03) << 6) | u8tmp2 >> 0; 501395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xea, u8tmp); 502395d00d1SAntti Palosaari if (ret) 503395d00d1SAntti Palosaari goto err; 504395d00d1SAntti Palosaari 505395d00d1SAntti Palosaari if (c->symbol_rate <= 3000000) 506395d00d1SAntti Palosaari u8tmp = 0x20; 507395d00d1SAntti Palosaari else if (c->symbol_rate <= 10000000) 508395d00d1SAntti Palosaari u8tmp = 0x10; 509395d00d1SAntti Palosaari else 510395d00d1SAntti Palosaari u8tmp = 0x06; 511395d00d1SAntti Palosaari 512395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc3, 0x08); 513395d00d1SAntti Palosaari if (ret) 514395d00d1SAntti Palosaari goto err; 515395d00d1SAntti Palosaari 516395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc8, u8tmp); 517395d00d1SAntti Palosaari if (ret) 518395d00d1SAntti Palosaari goto err; 519395d00d1SAntti Palosaari 520395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc4, 0x08); 521395d00d1SAntti Palosaari if (ret) 522395d00d1SAntti Palosaari goto err; 523395d00d1SAntti Palosaari 524395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xc7, 0x00); 525395d00d1SAntti Palosaari if (ret) 526395d00d1SAntti Palosaari goto err; 527395d00d1SAntti Palosaari 528f4df95bcSnibble.max u16tmp = DIV_ROUND_CLOSEST((c->symbol_rate / 1000) << 15, priv->mclk_khz / 2); 529395d00d1SAntti Palosaari buf[0] = (u16tmp >> 0) & 0xff; 530395d00d1SAntti Palosaari buf[1] = (u16tmp >> 8) & 0xff; 531395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0x61, buf, 2); 532395d00d1SAntti Palosaari if (ret) 533395d00d1SAntti Palosaari goto err; 534395d00d1SAntti Palosaari 535395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x4d, priv->cfg->spec_inv << 1, 0x02); 536395d00d1SAntti Palosaari if (ret) 537395d00d1SAntti Palosaari goto err; 538395d00d1SAntti Palosaari 539395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x30, priv->cfg->agc_inv << 4, 0x10); 540395d00d1SAntti Palosaari if (ret) 541395d00d1SAntti Palosaari goto err; 542395d00d1SAntti Palosaari 543395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0x33, priv->cfg->agc); 544395d00d1SAntti Palosaari if (ret) 545395d00d1SAntti Palosaari goto err; 546395d00d1SAntti Palosaari 547395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: carrier offset=%d\n", __func__, 548395d00d1SAntti Palosaari (tuner_frequency - c->frequency)); 549395d00d1SAntti Palosaari 550395d00d1SAntti Palosaari s32tmp = 0x10000 * (tuner_frequency - c->frequency); 551f4df95bcSnibble.max s32tmp = DIV_ROUND_CLOSEST(s32tmp, priv->mclk_khz); 552395d00d1SAntti Palosaari if (s32tmp < 0) 553395d00d1SAntti Palosaari s32tmp += 0x10000; 554395d00d1SAntti Palosaari 555395d00d1SAntti Palosaari buf[0] = (s32tmp >> 0) & 0xff; 556395d00d1SAntti Palosaari buf[1] = (s32tmp >> 8) & 0xff; 557395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0x5e, buf, 2); 558395d00d1SAntti Palosaari if (ret) 559395d00d1SAntti Palosaari goto err; 560395d00d1SAntti Palosaari 561395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0x00, 0x00); 562395d00d1SAntti Palosaari if (ret) 563395d00d1SAntti Palosaari goto err; 564395d00d1SAntti Palosaari 565395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); 566395d00d1SAntti Palosaari if (ret) 567395d00d1SAntti Palosaari goto err; 568395d00d1SAntti Palosaari 569395d00d1SAntti Palosaari priv->delivery_system = c->delivery_system; 570395d00d1SAntti Palosaari 571395d00d1SAntti Palosaari return 0; 572395d00d1SAntti Palosaari err: 573395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 574395d00d1SAntti Palosaari return ret; 575395d00d1SAntti Palosaari } 576395d00d1SAntti Palosaari 577395d00d1SAntti Palosaari static int m88ds3103_init(struct dvb_frontend *fe) 578395d00d1SAntti Palosaari { 579395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 580395d00d1SAntti Palosaari int ret, len, remaining; 581395d00d1SAntti Palosaari const struct firmware *fw = NULL; 582f4df95bcSnibble.max u8 *fw_file; 583395d00d1SAntti Palosaari u8 u8tmp; 58441b9aa00SAntti Palosaari 585395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 586395d00d1SAntti Palosaari 587395d00d1SAntti Palosaari /* set cold state by default */ 588395d00d1SAntti Palosaari priv->warm = false; 589395d00d1SAntti Palosaari 590395d00d1SAntti Palosaari /* wake up device from sleep */ 591395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x01, 0x01); 592395d00d1SAntti Palosaari if (ret) 593395d00d1SAntti Palosaari goto err; 594395d00d1SAntti Palosaari 595395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x00, 0x01); 596395d00d1SAntti Palosaari if (ret) 597395d00d1SAntti Palosaari goto err; 598395d00d1SAntti Palosaari 599395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x00, 0x10); 600395d00d1SAntti Palosaari if (ret) 601395d00d1SAntti Palosaari goto err; 602395d00d1SAntti Palosaari 603395d00d1SAntti Palosaari /* firmware status */ 604395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); 605395d00d1SAntti Palosaari if (ret) 606395d00d1SAntti Palosaari goto err; 607395d00d1SAntti Palosaari 608395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: firmware=%02x\n", __func__, u8tmp); 609395d00d1SAntti Palosaari 610395d00d1SAntti Palosaari if (u8tmp) 611395d00d1SAntti Palosaari goto skip_fw_download; 612395d00d1SAntti Palosaari 613f4df95bcSnibble.max /* global reset, global diseqc reset, golbal fec reset */ 614f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0xe0); 615f4df95bcSnibble.max if (ret) 616f4df95bcSnibble.max goto err; 617f4df95bcSnibble.max 618f4df95bcSnibble.max ret = m88ds3103_wr_reg(priv, 0x07, 0x00); 619f4df95bcSnibble.max if (ret) 620f4df95bcSnibble.max goto err; 621f4df95bcSnibble.max 622395d00d1SAntti Palosaari /* cold state - try to download firmware */ 623395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: found a '%s' in cold state\n", 624395d00d1SAntti Palosaari KBUILD_MODNAME, m88ds3103_ops.info.name); 625395d00d1SAntti Palosaari 626f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) 627f4df95bcSnibble.max fw_file = M88RS6000_FIRMWARE; 628f4df95bcSnibble.max else 629f4df95bcSnibble.max fw_file = M88DS3103_FIRMWARE; 630395d00d1SAntti Palosaari /* request the firmware, this will block and timeout */ 631395d00d1SAntti Palosaari ret = request_firmware(&fw, fw_file, priv->i2c->dev.parent); 632395d00d1SAntti Palosaari if (ret) { 633a87a4d34SYannick Guerrini dev_err(&priv->i2c->dev, "%s: firmware file '%s' not found\n", 634395d00d1SAntti Palosaari KBUILD_MODNAME, fw_file); 635395d00d1SAntti Palosaari goto err; 636395d00d1SAntti Palosaari } 637395d00d1SAntti Palosaari 638395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: downloading firmware from file '%s'\n", 639395d00d1SAntti Palosaari KBUILD_MODNAME, fw_file); 640395d00d1SAntti Palosaari 641395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xb2, 0x01); 642395d00d1SAntti Palosaari if (ret) 6435ed0cf88SMarkus Elfring goto error_fw_release; 644395d00d1SAntti Palosaari 645395d00d1SAntti Palosaari for (remaining = fw->size; remaining > 0; 646395d00d1SAntti Palosaari remaining -= (priv->cfg->i2c_wr_max - 1)) { 647395d00d1SAntti Palosaari len = remaining; 648395d00d1SAntti Palosaari if (len > (priv->cfg->i2c_wr_max - 1)) 649395d00d1SAntti Palosaari len = (priv->cfg->i2c_wr_max - 1); 650395d00d1SAntti Palosaari 651395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0xb0, 652395d00d1SAntti Palosaari &fw->data[fw->size - remaining], len); 653395d00d1SAntti Palosaari if (ret) { 654395d00d1SAntti Palosaari dev_err(&priv->i2c->dev, 655395d00d1SAntti Palosaari "%s: firmware download failed=%d\n", 656395d00d1SAntti Palosaari KBUILD_MODNAME, ret); 6575ed0cf88SMarkus Elfring goto error_fw_release; 658395d00d1SAntti Palosaari } 659395d00d1SAntti Palosaari } 660395d00d1SAntti Palosaari 661395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xb2, 0x00); 662395d00d1SAntti Palosaari if (ret) 6635ed0cf88SMarkus Elfring goto error_fw_release; 664395d00d1SAntti Palosaari 665395d00d1SAntti Palosaari release_firmware(fw); 666395d00d1SAntti Palosaari fw = NULL; 667395d00d1SAntti Palosaari 668395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xb9, &u8tmp); 669395d00d1SAntti Palosaari if (ret) 670395d00d1SAntti Palosaari goto err; 671395d00d1SAntti Palosaari 672395d00d1SAntti Palosaari if (!u8tmp) { 673395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: firmware did not run\n", 674395d00d1SAntti Palosaari KBUILD_MODNAME); 675395d00d1SAntti Palosaari ret = -EFAULT; 676395d00d1SAntti Palosaari goto err; 677395d00d1SAntti Palosaari } 678395d00d1SAntti Palosaari 679395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: found a '%s' in warm state\n", 680395d00d1SAntti Palosaari KBUILD_MODNAME, m88ds3103_ops.info.name); 681395d00d1SAntti Palosaari dev_info(&priv->i2c->dev, "%s: firmware version %X.%X\n", 682395d00d1SAntti Palosaari KBUILD_MODNAME, (u8tmp >> 4) & 0xf, (u8tmp >> 0 & 0xf)); 683395d00d1SAntti Palosaari 684395d00d1SAntti Palosaari skip_fw_download: 685395d00d1SAntti Palosaari /* warm state */ 686395d00d1SAntti Palosaari priv->warm = true; 687395d00d1SAntti Palosaari 688395d00d1SAntti Palosaari return 0; 689395d00d1SAntti Palosaari 6905ed0cf88SMarkus Elfring error_fw_release: 6915ed0cf88SMarkus Elfring release_firmware(fw); 6925ed0cf88SMarkus Elfring err: 693395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 694395d00d1SAntti Palosaari return ret; 695395d00d1SAntti Palosaari } 696395d00d1SAntti Palosaari 697395d00d1SAntti Palosaari static int m88ds3103_sleep(struct dvb_frontend *fe) 698395d00d1SAntti Palosaari { 699395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 700395d00d1SAntti Palosaari int ret; 701f4df95bcSnibble.max u8 u8tmp; 70241b9aa00SAntti Palosaari 703395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 704395d00d1SAntti Palosaari 705395d00d1SAntti Palosaari priv->delivery_system = SYS_UNDEFINED; 706395d00d1SAntti Palosaari 707395d00d1SAntti Palosaari /* TS Hi-Z */ 708f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) 709f4df95bcSnibble.max u8tmp = 0x29; 710f4df95bcSnibble.max else 711f4df95bcSnibble.max u8tmp = 0x27; 712f4df95bcSnibble.max ret = m88ds3103_wr_reg_mask(priv, u8tmp, 0x00, 0x01); 713395d00d1SAntti Palosaari if (ret) 714395d00d1SAntti Palosaari goto err; 715395d00d1SAntti Palosaari 716395d00d1SAntti Palosaari /* sleep */ 717395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x00, 0x01); 718395d00d1SAntti Palosaari if (ret) 719395d00d1SAntti Palosaari goto err; 720395d00d1SAntti Palosaari 721395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x01, 0x01); 722395d00d1SAntti Palosaari if (ret) 723395d00d1SAntti Palosaari goto err; 724395d00d1SAntti Palosaari 725395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x10, 0x10); 726395d00d1SAntti Palosaari if (ret) 727395d00d1SAntti Palosaari goto err; 728395d00d1SAntti Palosaari 729395d00d1SAntti Palosaari return 0; 730395d00d1SAntti Palosaari err: 731395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 732395d00d1SAntti Palosaari return ret; 733395d00d1SAntti Palosaari } 734395d00d1SAntti Palosaari 735395d00d1SAntti Palosaari static int m88ds3103_get_frontend(struct dvb_frontend *fe) 736395d00d1SAntti Palosaari { 737395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 738395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 739395d00d1SAntti Palosaari int ret; 740395d00d1SAntti Palosaari u8 buf[3]; 74141b9aa00SAntti Palosaari 742395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 743395d00d1SAntti Palosaari 744395d00d1SAntti Palosaari if (!priv->warm || !(priv->fe_status & FE_HAS_LOCK)) { 745*9240c384SAntti Palosaari ret = 0; 746395d00d1SAntti Palosaari goto err; 747395d00d1SAntti Palosaari } 748395d00d1SAntti Palosaari 749395d00d1SAntti Palosaari switch (c->delivery_system) { 750395d00d1SAntti Palosaari case SYS_DVBS: 751395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xe0, &buf[0]); 752395d00d1SAntti Palosaari if (ret) 753395d00d1SAntti Palosaari goto err; 754395d00d1SAntti Palosaari 755395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xe6, &buf[1]); 756395d00d1SAntti Palosaari if (ret) 757395d00d1SAntti Palosaari goto err; 758395d00d1SAntti Palosaari 759395d00d1SAntti Palosaari switch ((buf[0] >> 2) & 0x01) { 760395d00d1SAntti Palosaari case 0: 761395d00d1SAntti Palosaari c->inversion = INVERSION_OFF; 762395d00d1SAntti Palosaari break; 763395d00d1SAntti Palosaari case 1: 764395d00d1SAntti Palosaari c->inversion = INVERSION_ON; 765395d00d1SAntti Palosaari break; 766395d00d1SAntti Palosaari } 767395d00d1SAntti Palosaari 768395d00d1SAntti Palosaari switch ((buf[1] >> 5) & 0x07) { 769395d00d1SAntti Palosaari case 0: 770395d00d1SAntti Palosaari c->fec_inner = FEC_7_8; 771395d00d1SAntti Palosaari break; 772395d00d1SAntti Palosaari case 1: 773395d00d1SAntti Palosaari c->fec_inner = FEC_5_6; 774395d00d1SAntti Palosaari break; 775395d00d1SAntti Palosaari case 2: 776395d00d1SAntti Palosaari c->fec_inner = FEC_3_4; 777395d00d1SAntti Palosaari break; 778395d00d1SAntti Palosaari case 3: 779395d00d1SAntti Palosaari c->fec_inner = FEC_2_3; 780395d00d1SAntti Palosaari break; 781395d00d1SAntti Palosaari case 4: 782395d00d1SAntti Palosaari c->fec_inner = FEC_1_2; 783395d00d1SAntti Palosaari break; 784395d00d1SAntti Palosaari default: 785395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fec_inner\n", 786395d00d1SAntti Palosaari __func__); 787395d00d1SAntti Palosaari } 788395d00d1SAntti Palosaari 789395d00d1SAntti Palosaari c->modulation = QPSK; 790395d00d1SAntti Palosaari 791395d00d1SAntti Palosaari break; 792395d00d1SAntti Palosaari case SYS_DVBS2: 793395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0x7e, &buf[0]); 794395d00d1SAntti Palosaari if (ret) 795395d00d1SAntti Palosaari goto err; 796395d00d1SAntti Palosaari 797395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0x89, &buf[1]); 798395d00d1SAntti Palosaari if (ret) 799395d00d1SAntti Palosaari goto err; 800395d00d1SAntti Palosaari 801395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xf2, &buf[2]); 802395d00d1SAntti Palosaari if (ret) 803395d00d1SAntti Palosaari goto err; 804395d00d1SAntti Palosaari 805395d00d1SAntti Palosaari switch ((buf[0] >> 0) & 0x0f) { 806395d00d1SAntti Palosaari case 2: 807395d00d1SAntti Palosaari c->fec_inner = FEC_2_5; 808395d00d1SAntti Palosaari break; 809395d00d1SAntti Palosaari case 3: 810395d00d1SAntti Palosaari c->fec_inner = FEC_1_2; 811395d00d1SAntti Palosaari break; 812395d00d1SAntti Palosaari case 4: 813395d00d1SAntti Palosaari c->fec_inner = FEC_3_5; 814395d00d1SAntti Palosaari break; 815395d00d1SAntti Palosaari case 5: 816395d00d1SAntti Palosaari c->fec_inner = FEC_2_3; 817395d00d1SAntti Palosaari break; 818395d00d1SAntti Palosaari case 6: 819395d00d1SAntti Palosaari c->fec_inner = FEC_3_4; 820395d00d1SAntti Palosaari break; 821395d00d1SAntti Palosaari case 7: 822395d00d1SAntti Palosaari c->fec_inner = FEC_4_5; 823395d00d1SAntti Palosaari break; 824395d00d1SAntti Palosaari case 8: 825395d00d1SAntti Palosaari c->fec_inner = FEC_5_6; 826395d00d1SAntti Palosaari break; 827395d00d1SAntti Palosaari case 9: 828395d00d1SAntti Palosaari c->fec_inner = FEC_8_9; 829395d00d1SAntti Palosaari break; 830395d00d1SAntti Palosaari case 10: 831395d00d1SAntti Palosaari c->fec_inner = FEC_9_10; 832395d00d1SAntti Palosaari break; 833395d00d1SAntti Palosaari default: 834395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fec_inner\n", 835395d00d1SAntti Palosaari __func__); 836395d00d1SAntti Palosaari } 837395d00d1SAntti Palosaari 838395d00d1SAntti Palosaari switch ((buf[0] >> 5) & 0x01) { 839395d00d1SAntti Palosaari case 0: 840395d00d1SAntti Palosaari c->pilot = PILOT_OFF; 841395d00d1SAntti Palosaari break; 842395d00d1SAntti Palosaari case 1: 843395d00d1SAntti Palosaari c->pilot = PILOT_ON; 844395d00d1SAntti Palosaari break; 845395d00d1SAntti Palosaari } 846395d00d1SAntti Palosaari 847395d00d1SAntti Palosaari switch ((buf[0] >> 6) & 0x07) { 848395d00d1SAntti Palosaari case 0: 849395d00d1SAntti Palosaari c->modulation = QPSK; 850395d00d1SAntti Palosaari break; 851395d00d1SAntti Palosaari case 1: 852395d00d1SAntti Palosaari c->modulation = PSK_8; 853395d00d1SAntti Palosaari break; 854395d00d1SAntti Palosaari case 2: 855395d00d1SAntti Palosaari c->modulation = APSK_16; 856395d00d1SAntti Palosaari break; 857395d00d1SAntti Palosaari case 3: 858395d00d1SAntti Palosaari c->modulation = APSK_32; 859395d00d1SAntti Palosaari break; 860395d00d1SAntti Palosaari default: 861395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid modulation\n", 862395d00d1SAntti Palosaari __func__); 863395d00d1SAntti Palosaari } 864395d00d1SAntti Palosaari 865395d00d1SAntti Palosaari switch ((buf[1] >> 7) & 0x01) { 866395d00d1SAntti Palosaari case 0: 867395d00d1SAntti Palosaari c->inversion = INVERSION_OFF; 868395d00d1SAntti Palosaari break; 869395d00d1SAntti Palosaari case 1: 870395d00d1SAntti Palosaari c->inversion = INVERSION_ON; 871395d00d1SAntti Palosaari break; 872395d00d1SAntti Palosaari } 873395d00d1SAntti Palosaari 874395d00d1SAntti Palosaari switch ((buf[2] >> 0) & 0x03) { 875395d00d1SAntti Palosaari case 0: 876395d00d1SAntti Palosaari c->rolloff = ROLLOFF_35; 877395d00d1SAntti Palosaari break; 878395d00d1SAntti Palosaari case 1: 879395d00d1SAntti Palosaari c->rolloff = ROLLOFF_25; 880395d00d1SAntti Palosaari break; 881395d00d1SAntti Palosaari case 2: 882395d00d1SAntti Palosaari c->rolloff = ROLLOFF_20; 883395d00d1SAntti Palosaari break; 884395d00d1SAntti Palosaari default: 885395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid rolloff\n", 886395d00d1SAntti Palosaari __func__); 887395d00d1SAntti Palosaari } 888395d00d1SAntti Palosaari break; 889395d00d1SAntti Palosaari default: 890395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 891395d00d1SAntti Palosaari __func__); 892395d00d1SAntti Palosaari ret = -EINVAL; 893395d00d1SAntti Palosaari goto err; 894395d00d1SAntti Palosaari } 895395d00d1SAntti Palosaari 896395d00d1SAntti Palosaari ret = m88ds3103_rd_regs(priv, 0x6d, buf, 2); 897395d00d1SAntti Palosaari if (ret) 898395d00d1SAntti Palosaari goto err; 899395d00d1SAntti Palosaari 900395d00d1SAntti Palosaari c->symbol_rate = 1ull * ((buf[1] << 8) | (buf[0] << 0)) * 901f4df95bcSnibble.max priv->mclk_khz * 1000 / 0x10000; 902395d00d1SAntti Palosaari 903395d00d1SAntti Palosaari return 0; 904395d00d1SAntti Palosaari err: 905395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 906395d00d1SAntti Palosaari return ret; 907395d00d1SAntti Palosaari } 908395d00d1SAntti Palosaari 909395d00d1SAntti Palosaari static int m88ds3103_read_snr(struct dvb_frontend *fe, u16 *snr) 910395d00d1SAntti Palosaari { 911395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 912395d00d1SAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 913395d00d1SAntti Palosaari int ret, i, tmp; 914395d00d1SAntti Palosaari u8 buf[3]; 915395d00d1SAntti Palosaari u16 noise, signal; 916395d00d1SAntti Palosaari u32 noise_tot, signal_tot; 91741b9aa00SAntti Palosaari 918395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 919395d00d1SAntti Palosaari /* reports SNR in resolution of 0.1 dB */ 920395d00d1SAntti Palosaari 921395d00d1SAntti Palosaari /* more iterations for more accurate estimation */ 922395d00d1SAntti Palosaari #define M88DS3103_SNR_ITERATIONS 3 923395d00d1SAntti Palosaari 924395d00d1SAntti Palosaari switch (c->delivery_system) { 925395d00d1SAntti Palosaari case SYS_DVBS: 926395d00d1SAntti Palosaari tmp = 0; 927395d00d1SAntti Palosaari 928395d00d1SAntti Palosaari for (i = 0; i < M88DS3103_SNR_ITERATIONS; i++) { 929395d00d1SAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xff, &buf[0]); 930395d00d1SAntti Palosaari if (ret) 931395d00d1SAntti Palosaari goto err; 932395d00d1SAntti Palosaari 933395d00d1SAntti Palosaari tmp += buf[0]; 934395d00d1SAntti Palosaari } 935395d00d1SAntti Palosaari 936395d00d1SAntti Palosaari /* use of one register limits max value to 15 dB */ 937395d00d1SAntti Palosaari /* SNR(X) dB = 10 * ln(X) / ln(10) dB */ 938395d00d1SAntti Palosaari tmp = DIV_ROUND_CLOSEST(tmp, 8 * M88DS3103_SNR_ITERATIONS); 939395d00d1SAntti Palosaari if (tmp) 9403ae266f8SAntti Palosaari *snr = div_u64((u64) 100 * intlog2(tmp), intlog2(10)); 941395d00d1SAntti Palosaari else 942395d00d1SAntti Palosaari *snr = 0; 943395d00d1SAntti Palosaari break; 944395d00d1SAntti Palosaari case SYS_DVBS2: 945395d00d1SAntti Palosaari noise_tot = 0; 946395d00d1SAntti Palosaari signal_tot = 0; 947395d00d1SAntti Palosaari 948395d00d1SAntti Palosaari for (i = 0; i < M88DS3103_SNR_ITERATIONS; i++) { 949395d00d1SAntti Palosaari ret = m88ds3103_rd_regs(priv, 0x8c, buf, 3); 950395d00d1SAntti Palosaari if (ret) 951395d00d1SAntti Palosaari goto err; 952395d00d1SAntti Palosaari 953395d00d1SAntti Palosaari noise = buf[1] << 6; /* [13:6] */ 954395d00d1SAntti Palosaari noise |= buf[0] & 0x3f; /* [5:0] */ 955395d00d1SAntti Palosaari noise >>= 2; 956395d00d1SAntti Palosaari signal = buf[2] * buf[2]; 957395d00d1SAntti Palosaari signal >>= 1; 958395d00d1SAntti Palosaari 959395d00d1SAntti Palosaari noise_tot += noise; 960395d00d1SAntti Palosaari signal_tot += signal; 961395d00d1SAntti Palosaari } 962395d00d1SAntti Palosaari 963395d00d1SAntti Palosaari noise = noise_tot / M88DS3103_SNR_ITERATIONS; 964395d00d1SAntti Palosaari signal = signal_tot / M88DS3103_SNR_ITERATIONS; 965395d00d1SAntti Palosaari 966395d00d1SAntti Palosaari /* SNR(X) dB = 10 * log10(X) dB */ 967395d00d1SAntti Palosaari if (signal > noise) { 968395d00d1SAntti Palosaari tmp = signal / noise; 9693ae266f8SAntti Palosaari *snr = div_u64((u64) 100 * intlog10(tmp), (1 << 24)); 9708a878dc4SAntti Palosaari } else { 971395d00d1SAntti Palosaari *snr = 0; 9728a878dc4SAntti Palosaari } 973395d00d1SAntti Palosaari break; 974395d00d1SAntti Palosaari default: 975395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 976395d00d1SAntti Palosaari __func__); 977395d00d1SAntti Palosaari ret = -EINVAL; 978395d00d1SAntti Palosaari goto err; 979395d00d1SAntti Palosaari } 980395d00d1SAntti Palosaari 981395d00d1SAntti Palosaari return 0; 982395d00d1SAntti Palosaari err: 983395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 984395d00d1SAntti Palosaari return ret; 985395d00d1SAntti Palosaari } 986395d00d1SAntti Palosaari 9874423a2baSAntti Palosaari static int m88ds3103_read_ber(struct dvb_frontend *fe, u32 *ber) 9884423a2baSAntti Palosaari { 9894423a2baSAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 9904423a2baSAntti Palosaari struct dtv_frontend_properties *c = &fe->dtv_property_cache; 9914423a2baSAntti Palosaari int ret; 9924423a2baSAntti Palosaari unsigned int utmp; 9934423a2baSAntti Palosaari u8 buf[3], u8tmp; 99441b9aa00SAntti Palosaari 9954423a2baSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s:\n", __func__); 9964423a2baSAntti Palosaari 9974423a2baSAntti Palosaari switch (c->delivery_system) { 9984423a2baSAntti Palosaari case SYS_DVBS: 9994423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf9, 0x04); 10004423a2baSAntti Palosaari if (ret) 10014423a2baSAntti Palosaari goto err; 10024423a2baSAntti Palosaari 10034423a2baSAntti Palosaari ret = m88ds3103_rd_reg(priv, 0xf8, &u8tmp); 10044423a2baSAntti Palosaari if (ret) 10054423a2baSAntti Palosaari goto err; 10064423a2baSAntti Palosaari 10074423a2baSAntti Palosaari if (!(u8tmp & 0x10)) { 10084423a2baSAntti Palosaari u8tmp |= 0x10; 10094423a2baSAntti Palosaari 10104423a2baSAntti Palosaari ret = m88ds3103_rd_regs(priv, 0xf6, buf, 2); 10114423a2baSAntti Palosaari if (ret) 10124423a2baSAntti Palosaari goto err; 10134423a2baSAntti Palosaari 10144423a2baSAntti Palosaari priv->ber = (buf[1] << 8) | (buf[0] << 0); 10154423a2baSAntti Palosaari 10164423a2baSAntti Palosaari /* restart counters */ 10174423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf8, u8tmp); 10184423a2baSAntti Palosaari if (ret) 10194423a2baSAntti Palosaari goto err; 10204423a2baSAntti Palosaari } 10214423a2baSAntti Palosaari break; 10224423a2baSAntti Palosaari case SYS_DVBS2: 10234423a2baSAntti Palosaari ret = m88ds3103_rd_regs(priv, 0xd5, buf, 3); 10244423a2baSAntti Palosaari if (ret) 10254423a2baSAntti Palosaari goto err; 10264423a2baSAntti Palosaari 10274423a2baSAntti Palosaari utmp = (buf[2] << 16) | (buf[1] << 8) | (buf[0] << 0); 10284423a2baSAntti Palosaari 10294423a2baSAntti Palosaari if (utmp > 3000) { 10304423a2baSAntti Palosaari ret = m88ds3103_rd_regs(priv, 0xf7, buf, 2); 10314423a2baSAntti Palosaari if (ret) 10324423a2baSAntti Palosaari goto err; 10334423a2baSAntti Palosaari 10344423a2baSAntti Palosaari priv->ber = (buf[1] << 8) | (buf[0] << 0); 10354423a2baSAntti Palosaari 10364423a2baSAntti Palosaari /* restart counters */ 10374423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xd1, 0x01); 10384423a2baSAntti Palosaari if (ret) 10394423a2baSAntti Palosaari goto err; 10404423a2baSAntti Palosaari 10414423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf9, 0x01); 10424423a2baSAntti Palosaari if (ret) 10434423a2baSAntti Palosaari goto err; 10444423a2baSAntti Palosaari 10454423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xf9, 0x00); 10464423a2baSAntti Palosaari if (ret) 10474423a2baSAntti Palosaari goto err; 10484423a2baSAntti Palosaari 10494423a2baSAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xd1, 0x00); 10504423a2baSAntti Palosaari if (ret) 10514423a2baSAntti Palosaari goto err; 10524423a2baSAntti Palosaari } 10534423a2baSAntti Palosaari break; 10544423a2baSAntti Palosaari default: 10554423a2baSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid delivery_system\n", 10564423a2baSAntti Palosaari __func__); 10574423a2baSAntti Palosaari ret = -EINVAL; 10584423a2baSAntti Palosaari goto err; 10594423a2baSAntti Palosaari } 10604423a2baSAntti Palosaari 10614423a2baSAntti Palosaari *ber = priv->ber; 10624423a2baSAntti Palosaari 10634423a2baSAntti Palosaari return 0; 10644423a2baSAntti Palosaari err: 10654423a2baSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 10664423a2baSAntti Palosaari return ret; 10674423a2baSAntti Palosaari } 1068395d00d1SAntti Palosaari 1069395d00d1SAntti Palosaari static int m88ds3103_set_tone(struct dvb_frontend *fe, 1070395d00d1SAntti Palosaari fe_sec_tone_mode_t fe_sec_tone_mode) 1071395d00d1SAntti Palosaari { 1072395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 1073395d00d1SAntti Palosaari int ret; 1074395d00d1SAntti Palosaari u8 u8tmp, tone, reg_a1_mask; 107541b9aa00SAntti Palosaari 1076395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: fe_sec_tone_mode=%d\n", __func__, 1077395d00d1SAntti Palosaari fe_sec_tone_mode); 1078395d00d1SAntti Palosaari 1079395d00d1SAntti Palosaari if (!priv->warm) { 1080395d00d1SAntti Palosaari ret = -EAGAIN; 1081395d00d1SAntti Palosaari goto err; 1082395d00d1SAntti Palosaari } 1083395d00d1SAntti Palosaari 1084395d00d1SAntti Palosaari switch (fe_sec_tone_mode) { 1085395d00d1SAntti Palosaari case SEC_TONE_ON: 1086395d00d1SAntti Palosaari tone = 0; 1087418a97cbSAntti Palosaari reg_a1_mask = 0x47; 1088395d00d1SAntti Palosaari break; 1089395d00d1SAntti Palosaari case SEC_TONE_OFF: 1090395d00d1SAntti Palosaari tone = 1; 1091395d00d1SAntti Palosaari reg_a1_mask = 0x00; 1092395d00d1SAntti Palosaari break; 1093395d00d1SAntti Palosaari default: 1094395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_tone_mode\n", 1095395d00d1SAntti Palosaari __func__); 1096395d00d1SAntti Palosaari ret = -EINVAL; 1097395d00d1SAntti Palosaari goto err; 1098395d00d1SAntti Palosaari } 1099395d00d1SAntti Palosaari 1100395d00d1SAntti Palosaari u8tmp = tone << 7 | priv->cfg->envelope_mode << 5; 1101395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0xe0); 1102395d00d1SAntti Palosaari if (ret) 1103395d00d1SAntti Palosaari goto err; 1104395d00d1SAntti Palosaari 1105395d00d1SAntti Palosaari u8tmp = 1 << 2; 1106395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa1, u8tmp, reg_a1_mask); 1107395d00d1SAntti Palosaari if (ret) 1108395d00d1SAntti Palosaari goto err; 1109395d00d1SAntti Palosaari 1110395d00d1SAntti Palosaari return 0; 1111395d00d1SAntti Palosaari err: 1112395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1113395d00d1SAntti Palosaari return ret; 1114395d00d1SAntti Palosaari } 1115395d00d1SAntti Palosaari 111679d09330Snibble.max static int m88ds3103_set_voltage(struct dvb_frontend *fe, 1117d28677ffSAntti Palosaari fe_sec_voltage_t fe_sec_voltage) 111879d09330Snibble.max { 111979d09330Snibble.max struct m88ds3103_priv *priv = fe->demodulator_priv; 1120d28677ffSAntti Palosaari int ret; 1121d28677ffSAntti Palosaari u8 u8tmp; 1122d28677ffSAntti Palosaari bool voltage_sel, voltage_dis; 112379d09330Snibble.max 1124d28677ffSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: fe_sec_voltage=%d\n", __func__, 1125d28677ffSAntti Palosaari fe_sec_voltage); 112679d09330Snibble.max 1127d28677ffSAntti Palosaari if (!priv->warm) { 1128d28677ffSAntti Palosaari ret = -EAGAIN; 1129d28677ffSAntti Palosaari goto err; 1130d28677ffSAntti Palosaari } 113179d09330Snibble.max 1132d28677ffSAntti Palosaari switch (fe_sec_voltage) { 113379d09330Snibble.max case SEC_VOLTAGE_18: 1134afbd6eb4SMauro Carvalho Chehab voltage_sel = true; 1135afbd6eb4SMauro Carvalho Chehab voltage_dis = false; 113679d09330Snibble.max break; 113779d09330Snibble.max case SEC_VOLTAGE_13: 1138afbd6eb4SMauro Carvalho Chehab voltage_sel = false; 1139afbd6eb4SMauro Carvalho Chehab voltage_dis = false; 114079d09330Snibble.max break; 114179d09330Snibble.max case SEC_VOLTAGE_OFF: 1142afbd6eb4SMauro Carvalho Chehab voltage_sel = false; 1143afbd6eb4SMauro Carvalho Chehab voltage_dis = true; 114479d09330Snibble.max break; 1145d28677ffSAntti Palosaari default: 1146d28677ffSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_voltage\n", 1147d28677ffSAntti Palosaari __func__); 1148d28677ffSAntti Palosaari ret = -EINVAL; 1149d28677ffSAntti Palosaari goto err; 115079d09330Snibble.max } 1151d28677ffSAntti Palosaari 1152d28677ffSAntti Palosaari /* output pin polarity */ 1153d28677ffSAntti Palosaari voltage_sel ^= priv->cfg->lnb_hv_pol; 1154d28677ffSAntti Palosaari voltage_dis ^= priv->cfg->lnb_en_pol; 1155d28677ffSAntti Palosaari 1156d28677ffSAntti Palosaari u8tmp = voltage_dis << 1 | voltage_sel << 0; 1157d28677ffSAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0x03); 1158d28677ffSAntti Palosaari if (ret) 1159d28677ffSAntti Palosaari goto err; 116079d09330Snibble.max 116179d09330Snibble.max return 0; 1162d28677ffSAntti Palosaari err: 1163d28677ffSAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1164d28677ffSAntti Palosaari return ret; 116579d09330Snibble.max } 116679d09330Snibble.max 1167395d00d1SAntti Palosaari static int m88ds3103_diseqc_send_master_cmd(struct dvb_frontend *fe, 1168395d00d1SAntti Palosaari struct dvb_diseqc_master_cmd *diseqc_cmd) 1169395d00d1SAntti Palosaari { 1170395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 1171395d00d1SAntti Palosaari int ret, i; 1172395d00d1SAntti Palosaari u8 u8tmp; 117341b9aa00SAntti Palosaari 1174395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: msg=%*ph\n", __func__, 1175395d00d1SAntti Palosaari diseqc_cmd->msg_len, diseqc_cmd->msg); 1176395d00d1SAntti Palosaari 1177395d00d1SAntti Palosaari if (!priv->warm) { 1178395d00d1SAntti Palosaari ret = -EAGAIN; 1179395d00d1SAntti Palosaari goto err; 1180395d00d1SAntti Palosaari } 1181395d00d1SAntti Palosaari 1182395d00d1SAntti Palosaari if (diseqc_cmd->msg_len < 3 || diseqc_cmd->msg_len > 6) { 1183395d00d1SAntti Palosaari ret = -EINVAL; 1184395d00d1SAntti Palosaari goto err; 1185395d00d1SAntti Palosaari } 1186395d00d1SAntti Palosaari 1187395d00d1SAntti Palosaari u8tmp = priv->cfg->envelope_mode << 5; 1188395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0xe0); 1189395d00d1SAntti Palosaari if (ret) 1190395d00d1SAntti Palosaari goto err; 1191395d00d1SAntti Palosaari 1192395d00d1SAntti Palosaari ret = m88ds3103_wr_regs(priv, 0xa3, diseqc_cmd->msg, 1193395d00d1SAntti Palosaari diseqc_cmd->msg_len); 1194395d00d1SAntti Palosaari if (ret) 1195395d00d1SAntti Palosaari goto err; 1196395d00d1SAntti Palosaari 1197395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xa1, 1198395d00d1SAntti Palosaari (diseqc_cmd->msg_len - 1) << 3 | 0x07); 1199395d00d1SAntti Palosaari if (ret) 1200395d00d1SAntti Palosaari goto err; 1201395d00d1SAntti Palosaari 1202395d00d1SAntti Palosaari /* DiSEqC message typical period is 54 ms */ 1203395d00d1SAntti Palosaari usleep_range(40000, 60000); 1204395d00d1SAntti Palosaari 1205395d00d1SAntti Palosaari /* wait DiSEqC TX ready */ 1206395d00d1SAntti Palosaari for (i = 20, u8tmp = 1; i && u8tmp; i--) { 1207395d00d1SAntti Palosaari usleep_range(5000, 10000); 1208395d00d1SAntti Palosaari 1209395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0xa1, &u8tmp, 0x40); 1210395d00d1SAntti Palosaari if (ret) 1211395d00d1SAntti Palosaari goto err; 1212395d00d1SAntti Palosaari } 1213395d00d1SAntti Palosaari 1214395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); 1215395d00d1SAntti Palosaari 1216395d00d1SAntti Palosaari if (i == 0) { 1217395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: diseqc tx timeout\n", __func__); 1218395d00d1SAntti Palosaari 1219395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa1, 0x40, 0xc0); 1220395d00d1SAntti Palosaari if (ret) 1221395d00d1SAntti Palosaari goto err; 1222395d00d1SAntti Palosaari } 1223395d00d1SAntti Palosaari 1224395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, 0x80, 0xc0); 1225395d00d1SAntti Palosaari if (ret) 1226395d00d1SAntti Palosaari goto err; 1227395d00d1SAntti Palosaari 1228395d00d1SAntti Palosaari if (i == 0) { 1229395d00d1SAntti Palosaari ret = -ETIMEDOUT; 1230395d00d1SAntti Palosaari goto err; 1231395d00d1SAntti Palosaari } 1232395d00d1SAntti Palosaari 1233395d00d1SAntti Palosaari return 0; 1234395d00d1SAntti Palosaari err: 1235395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1236395d00d1SAntti Palosaari return ret; 1237395d00d1SAntti Palosaari } 1238395d00d1SAntti Palosaari 1239395d00d1SAntti Palosaari static int m88ds3103_diseqc_send_burst(struct dvb_frontend *fe, 1240395d00d1SAntti Palosaari fe_sec_mini_cmd_t fe_sec_mini_cmd) 1241395d00d1SAntti Palosaari { 1242395d00d1SAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 1243395d00d1SAntti Palosaari int ret, i; 1244395d00d1SAntti Palosaari u8 u8tmp, burst; 124541b9aa00SAntti Palosaari 1246395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: fe_sec_mini_cmd=%d\n", __func__, 1247395d00d1SAntti Palosaari fe_sec_mini_cmd); 1248395d00d1SAntti Palosaari 1249395d00d1SAntti Palosaari if (!priv->warm) { 1250395d00d1SAntti Palosaari ret = -EAGAIN; 1251395d00d1SAntti Palosaari goto err; 1252395d00d1SAntti Palosaari } 1253395d00d1SAntti Palosaari 1254395d00d1SAntti Palosaari u8tmp = priv->cfg->envelope_mode << 5; 1255395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, u8tmp, 0xe0); 1256395d00d1SAntti Palosaari if (ret) 1257395d00d1SAntti Palosaari goto err; 1258395d00d1SAntti Palosaari 1259395d00d1SAntti Palosaari switch (fe_sec_mini_cmd) { 1260395d00d1SAntti Palosaari case SEC_MINI_A: 1261395d00d1SAntti Palosaari burst = 0x02; 1262395d00d1SAntti Palosaari break; 1263395d00d1SAntti Palosaari case SEC_MINI_B: 1264395d00d1SAntti Palosaari burst = 0x01; 1265395d00d1SAntti Palosaari break; 1266395d00d1SAntti Palosaari default: 1267395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: invalid fe_sec_mini_cmd\n", 1268395d00d1SAntti Palosaari __func__); 1269395d00d1SAntti Palosaari ret = -EINVAL; 1270395d00d1SAntti Palosaari goto err; 1271395d00d1SAntti Palosaari } 1272395d00d1SAntti Palosaari 1273395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0xa1, burst); 1274395d00d1SAntti Palosaari if (ret) 1275395d00d1SAntti Palosaari goto err; 1276395d00d1SAntti Palosaari 1277395d00d1SAntti Palosaari /* DiSEqC ToneBurst period is 12.5 ms */ 1278395d00d1SAntti Palosaari usleep_range(11000, 20000); 1279395d00d1SAntti Palosaari 1280395d00d1SAntti Palosaari /* wait DiSEqC TX ready */ 1281395d00d1SAntti Palosaari for (i = 5, u8tmp = 1; i && u8tmp; i--) { 1282395d00d1SAntti Palosaari usleep_range(800, 2000); 1283395d00d1SAntti Palosaari 1284395d00d1SAntti Palosaari ret = m88ds3103_rd_reg_mask(priv, 0xa1, &u8tmp, 0x40); 1285395d00d1SAntti Palosaari if (ret) 1286395d00d1SAntti Palosaari goto err; 1287395d00d1SAntti Palosaari } 1288395d00d1SAntti Palosaari 1289395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: loop=%d\n", __func__, i); 1290395d00d1SAntti Palosaari 1291395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0xa2, 0x80, 0xc0); 1292395d00d1SAntti Palosaari if (ret) 1293395d00d1SAntti Palosaari goto err; 1294395d00d1SAntti Palosaari 1295395d00d1SAntti Palosaari if (i == 0) { 1296395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: diseqc tx timeout\n", __func__); 1297395d00d1SAntti Palosaari ret = -ETIMEDOUT; 1298395d00d1SAntti Palosaari goto err; 1299395d00d1SAntti Palosaari } 1300395d00d1SAntti Palosaari 1301395d00d1SAntti Palosaari return 0; 1302395d00d1SAntti Palosaari err: 1303395d00d1SAntti Palosaari dev_dbg(&priv->i2c->dev, "%s: failed=%d\n", __func__, ret); 1304395d00d1SAntti Palosaari return ret; 1305395d00d1SAntti Palosaari } 1306395d00d1SAntti Palosaari 1307395d00d1SAntti Palosaari static int m88ds3103_get_tune_settings(struct dvb_frontend *fe, 1308395d00d1SAntti Palosaari struct dvb_frontend_tune_settings *s) 1309395d00d1SAntti Palosaari { 1310395d00d1SAntti Palosaari s->min_delay_ms = 3000; 1311395d00d1SAntti Palosaari 1312395d00d1SAntti Palosaari return 0; 1313395d00d1SAntti Palosaari } 1314395d00d1SAntti Palosaari 131544b9055bSAntti Palosaari static void m88ds3103_release(struct dvb_frontend *fe) 1316395d00d1SAntti Palosaari { 131744b9055bSAntti Palosaari struct m88ds3103_priv *priv = fe->demodulator_priv; 131841b9aa00SAntti Palosaari 131944b9055bSAntti Palosaari i2c_del_mux_adapter(priv->i2c_adapter); 132044b9055bSAntti Palosaari kfree(priv); 1321395d00d1SAntti Palosaari } 1322395d00d1SAntti Palosaari 132344b9055bSAntti Palosaari static int m88ds3103_select(struct i2c_adapter *adap, void *mux_priv, u32 chan) 1324395d00d1SAntti Palosaari { 132544b9055bSAntti Palosaari struct m88ds3103_priv *priv = mux_priv; 1326395d00d1SAntti Palosaari int ret; 1327395d00d1SAntti Palosaari struct i2c_msg gate_open_msg[1] = { 1328395d00d1SAntti Palosaari { 1329395d00d1SAntti Palosaari .addr = priv->cfg->i2c_addr, 1330395d00d1SAntti Palosaari .flags = 0, 1331395d00d1SAntti Palosaari .len = 2, 1332395d00d1SAntti Palosaari .buf = "\x03\x11", 1333395d00d1SAntti Palosaari } 1334395d00d1SAntti Palosaari }; 1335395d00d1SAntti Palosaari 1336395d00d1SAntti Palosaari mutex_lock(&priv->i2c_mutex); 1337395d00d1SAntti Palosaari 133844b9055bSAntti Palosaari /* open tuner I2C repeater for 1 xfer, closes automatically */ 13394fc57876SAntti Palosaari ret = __i2c_transfer(priv->i2c, gate_open_msg, 1); 1340395d00d1SAntti Palosaari if (ret != 1) { 134144b9055bSAntti Palosaari dev_warn(&priv->i2c->dev, "%s: i2c wr failed=%d\n", 1342395d00d1SAntti Palosaari KBUILD_MODNAME, ret); 134344b9055bSAntti Palosaari if (ret >= 0) 1344395d00d1SAntti Palosaari ret = -EREMOTEIO; 1345395d00d1SAntti Palosaari 1346395d00d1SAntti Palosaari return ret; 1347395d00d1SAntti Palosaari } 1348395d00d1SAntti Palosaari 134944b9055bSAntti Palosaari return 0; 135044b9055bSAntti Palosaari } 1351395d00d1SAntti Palosaari 135244b9055bSAntti Palosaari static int m88ds3103_deselect(struct i2c_adapter *adap, void *mux_priv, 135344b9055bSAntti Palosaari u32 chan) 1354395d00d1SAntti Palosaari { 135544b9055bSAntti Palosaari struct m88ds3103_priv *priv = mux_priv; 135644b9055bSAntti Palosaari 135744b9055bSAntti Palosaari mutex_unlock(&priv->i2c_mutex); 135844b9055bSAntti Palosaari 135944b9055bSAntti Palosaari return 0; 1360395d00d1SAntti Palosaari } 1361395d00d1SAntti Palosaari 1362395d00d1SAntti Palosaari struct dvb_frontend *m88ds3103_attach(const struct m88ds3103_config *cfg, 1363395d00d1SAntti Palosaari struct i2c_adapter *i2c, struct i2c_adapter **tuner_i2c_adapter) 1364395d00d1SAntti Palosaari { 1365395d00d1SAntti Palosaari int ret; 1366395d00d1SAntti Palosaari struct m88ds3103_priv *priv; 1367395d00d1SAntti Palosaari u8 chip_id, u8tmp; 1368395d00d1SAntti Palosaari 1369395d00d1SAntti Palosaari /* allocate memory for the internal priv */ 13708a878dc4SAntti Palosaari priv = kzalloc(sizeof(*priv), GFP_KERNEL); 1371395d00d1SAntti Palosaari if (!priv) { 1372395d00d1SAntti Palosaari ret = -ENOMEM; 1373395d00d1SAntti Palosaari dev_err(&i2c->dev, "%s: kzalloc() failed\n", KBUILD_MODNAME); 1374395d00d1SAntti Palosaari goto err; 1375395d00d1SAntti Palosaari } 1376395d00d1SAntti Palosaari 1377395d00d1SAntti Palosaari priv->cfg = cfg; 1378395d00d1SAntti Palosaari priv->i2c = i2c; 1379395d00d1SAntti Palosaari mutex_init(&priv->i2c_mutex); 1380395d00d1SAntti Palosaari 1381f4df95bcSnibble.max /* 0x00: chip id[6:0], 0x01: chip ver[7:0], 0x02: chip ver[15:8] */ 1382f4df95bcSnibble.max ret = m88ds3103_rd_reg(priv, 0x00, &chip_id); 1383395d00d1SAntti Palosaari if (ret) 1384395d00d1SAntti Palosaari goto err; 1385395d00d1SAntti Palosaari 1386f4df95bcSnibble.max chip_id >>= 1; 1387f4df95bcSnibble.max dev_info(&priv->i2c->dev, "%s: chip_id=%02x\n", __func__, chip_id); 1388395d00d1SAntti Palosaari 1389395d00d1SAntti Palosaari switch (chip_id) { 1390f4df95bcSnibble.max case M88RS6000_CHIP_ID: 1391f4df95bcSnibble.max case M88DS3103_CHIP_ID: 1392395d00d1SAntti Palosaari break; 1393395d00d1SAntti Palosaari default: 1394395d00d1SAntti Palosaari goto err; 1395395d00d1SAntti Palosaari } 1396f4df95bcSnibble.max priv->chip_id = chip_id; 1397395d00d1SAntti Palosaari 1398395d00d1SAntti Palosaari switch (priv->cfg->clock_out) { 1399395d00d1SAntti Palosaari case M88DS3103_CLOCK_OUT_DISABLED: 1400395d00d1SAntti Palosaari u8tmp = 0x80; 1401395d00d1SAntti Palosaari break; 1402395d00d1SAntti Palosaari case M88DS3103_CLOCK_OUT_ENABLED: 1403395d00d1SAntti Palosaari u8tmp = 0x00; 1404395d00d1SAntti Palosaari break; 1405395d00d1SAntti Palosaari case M88DS3103_CLOCK_OUT_ENABLED_DIV2: 1406395d00d1SAntti Palosaari u8tmp = 0x10; 1407395d00d1SAntti Palosaari break; 1408395d00d1SAntti Palosaari default: 1409395d00d1SAntti Palosaari goto err; 1410395d00d1SAntti Palosaari } 1411395d00d1SAntti Palosaari 1412f4df95bcSnibble.max /* 0x29 register is defined differently for m88rs6000. */ 1413f4df95bcSnibble.max /* set internal tuner address to 0x21 */ 1414f4df95bcSnibble.max if (chip_id == M88RS6000_CHIP_ID) 1415f4df95bcSnibble.max u8tmp = 0x00; 1416f4df95bcSnibble.max 1417395d00d1SAntti Palosaari ret = m88ds3103_wr_reg(priv, 0x29, u8tmp); 1418395d00d1SAntti Palosaari if (ret) 1419395d00d1SAntti Palosaari goto err; 1420395d00d1SAntti Palosaari 1421395d00d1SAntti Palosaari /* sleep */ 1422395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x08, 0x00, 0x01); 1423395d00d1SAntti Palosaari if (ret) 1424395d00d1SAntti Palosaari goto err; 1425395d00d1SAntti Palosaari 1426395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x04, 0x01, 0x01); 1427395d00d1SAntti Palosaari if (ret) 1428395d00d1SAntti Palosaari goto err; 1429395d00d1SAntti Palosaari 1430395d00d1SAntti Palosaari ret = m88ds3103_wr_reg_mask(priv, 0x23, 0x10, 0x10); 1431395d00d1SAntti Palosaari if (ret) 1432395d00d1SAntti Palosaari goto err; 1433395d00d1SAntti Palosaari 143444b9055bSAntti Palosaari /* create mux i2c adapter for tuner */ 143544b9055bSAntti Palosaari priv->i2c_adapter = i2c_add_mux_adapter(i2c, &i2c->dev, priv, 0, 0, 0, 143644b9055bSAntti Palosaari m88ds3103_select, m88ds3103_deselect); 143744b9055bSAntti Palosaari if (priv->i2c_adapter == NULL) 143844b9055bSAntti Palosaari goto err; 143944b9055bSAntti Palosaari 144044b9055bSAntti Palosaari *tuner_i2c_adapter = priv->i2c_adapter; 144144b9055bSAntti Palosaari 1442395d00d1SAntti Palosaari /* create dvb_frontend */ 1443395d00d1SAntti Palosaari memcpy(&priv->fe.ops, &m88ds3103_ops, sizeof(struct dvb_frontend_ops)); 1444f4df95bcSnibble.max if (priv->chip_id == M88RS6000_CHIP_ID) 1445f4df95bcSnibble.max strncpy(priv->fe.ops.info.name, 1446f4df95bcSnibble.max "Montage M88RS6000", sizeof(priv->fe.ops.info.name)); 1447395d00d1SAntti Palosaari priv->fe.demodulator_priv = priv; 1448395d00d1SAntti Palosaari 1449395d00d1SAntti Palosaari return &priv->fe; 1450395d00d1SAntti Palosaari err: 1451395d00d1SAntti Palosaari dev_dbg(&i2c->dev, "%s: failed=%d\n", __func__, ret); 1452395d00d1SAntti Palosaari kfree(priv); 1453395d00d1SAntti Palosaari return NULL; 1454395d00d1SAntti Palosaari } 1455395d00d1SAntti Palosaari EXPORT_SYMBOL(m88ds3103_attach); 1456395d00d1SAntti Palosaari 1457395d00d1SAntti Palosaari static struct dvb_frontend_ops m88ds3103_ops = { 1458395d00d1SAntti Palosaari .delsys = { SYS_DVBS, SYS_DVBS2 }, 1459395d00d1SAntti Palosaari .info = { 1460395d00d1SAntti Palosaari .name = "Montage M88DS3103", 1461395d00d1SAntti Palosaari .frequency_min = 950000, 1462395d00d1SAntti Palosaari .frequency_max = 2150000, 1463395d00d1SAntti Palosaari .frequency_tolerance = 5000, 1464395d00d1SAntti Palosaari .symbol_rate_min = 1000000, 1465395d00d1SAntti Palosaari .symbol_rate_max = 45000000, 1466395d00d1SAntti Palosaari .caps = FE_CAN_INVERSION_AUTO | 1467395d00d1SAntti Palosaari FE_CAN_FEC_1_2 | 1468395d00d1SAntti Palosaari FE_CAN_FEC_2_3 | 1469395d00d1SAntti Palosaari FE_CAN_FEC_3_4 | 1470395d00d1SAntti Palosaari FE_CAN_FEC_4_5 | 1471395d00d1SAntti Palosaari FE_CAN_FEC_5_6 | 1472395d00d1SAntti Palosaari FE_CAN_FEC_6_7 | 1473395d00d1SAntti Palosaari FE_CAN_FEC_7_8 | 1474395d00d1SAntti Palosaari FE_CAN_FEC_8_9 | 1475395d00d1SAntti Palosaari FE_CAN_FEC_AUTO | 1476395d00d1SAntti Palosaari FE_CAN_QPSK | 1477395d00d1SAntti Palosaari FE_CAN_RECOVER | 1478395d00d1SAntti Palosaari FE_CAN_2G_MODULATION 1479395d00d1SAntti Palosaari }, 1480395d00d1SAntti Palosaari 1481395d00d1SAntti Palosaari .release = m88ds3103_release, 1482395d00d1SAntti Palosaari 1483395d00d1SAntti Palosaari .get_tune_settings = m88ds3103_get_tune_settings, 1484395d00d1SAntti Palosaari 1485395d00d1SAntti Palosaari .init = m88ds3103_init, 1486395d00d1SAntti Palosaari .sleep = m88ds3103_sleep, 1487395d00d1SAntti Palosaari 1488395d00d1SAntti Palosaari .set_frontend = m88ds3103_set_frontend, 1489395d00d1SAntti Palosaari .get_frontend = m88ds3103_get_frontend, 1490395d00d1SAntti Palosaari 1491395d00d1SAntti Palosaari .read_status = m88ds3103_read_status, 1492395d00d1SAntti Palosaari .read_snr = m88ds3103_read_snr, 14934423a2baSAntti Palosaari .read_ber = m88ds3103_read_ber, 1494395d00d1SAntti Palosaari 1495395d00d1SAntti Palosaari .diseqc_send_master_cmd = m88ds3103_diseqc_send_master_cmd, 1496395d00d1SAntti Palosaari .diseqc_send_burst = m88ds3103_diseqc_send_burst, 1497395d00d1SAntti Palosaari 1498395d00d1SAntti Palosaari .set_tone = m88ds3103_set_tone, 149979d09330Snibble.max .set_voltage = m88ds3103_set_voltage, 1500395d00d1SAntti Palosaari }; 1501395d00d1SAntti Palosaari 1502395d00d1SAntti Palosaari MODULE_AUTHOR("Antti Palosaari <crope@iki.fi>"); 1503395d00d1SAntti Palosaari MODULE_DESCRIPTION("Montage M88DS3103 DVB-S/S2 demodulator driver"); 1504395d00d1SAntti Palosaari MODULE_LICENSE("GPL"); 1505395d00d1SAntti Palosaari MODULE_FIRMWARE(M88DS3103_FIRMWARE); 1506f4df95bcSnibble.max MODULE_FIRMWARE(M88RS6000_FIRMWARE); 1507