46 dev_warn(&priv->
i2c->dev,
"%s: i2c wr failed=%d reg=%02x " \
47 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
78 dev_warn(&priv->
i2c->dev,
"%s: i2c rd failed=%d reg=%02x " \
79 "len=%d\n", KBUILD_MODNAME, ret, reg, len);
92 u8 reg = (reginfo >> 0) & 0xff;
93 u8 bank = (reginfo >> 8) & 0xff;
94 u8 i2c = (reginfo >> 16) & 0x01;
98 i2c_addr = priv->
cfg.i2c_address | (1 << 1);
100 i2c_addr = priv->
cfg.i2c_address;
103 if (bank != priv->
bank[i2c]) {
104 ret = cxd2820r_wr_regs_i2c(priv, i2c_addr, 0x00, &bank, 1);
107 priv->
bank[i2c] = bank;
109 return cxd2820r_wr_regs_i2c(priv, i2c_addr, reg, val, len);
118 u8 reg = (reginfo >> 0) & 0xff;
119 u8 bank = (reginfo >> 8) & 0xff;
120 u8 i2c = (reginfo >> 16) & 0x01;
124 i2c_addr = priv->
cfg.i2c_address | (1 << 1);
126 i2c_addr = priv->
cfg.i2c_address;
129 if (bank != priv->
bank[i2c]) {
130 ret = cxd2820r_wr_regs_i2c(priv, i2c_addr, 0x00, &bank, 1);
133 priv->
bank[i2c] = bank;
135 return cxd2820r_rd_regs_i2c(priv, i2c_addr, reg, val, len);
177 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
186 for (i = 0; i <
sizeof(priv->
gpio); i++) {
189 tmp0 |= (2 << 6) >> (2 * i);
191 tmp0 |= (1 << 6) >> (2 * i);
195 tmp1 |= (1 << (3 +
i));
197 tmp1 |= (0 << (3 +
i));
201 tmp1 |= (1 << (0 +
i));
203 tmp1 |= (0 << (0 +
i));
205 dev_dbg(&priv->
i2c->dev,
"%s: gpio i=%d %02x %02x\n", __func__,
209 dev_dbg(&priv->
i2c->dev,
"%s: wr gpio=%02x %02x\n", __func__, tmp0,
226 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
233 return div_u64(dividend + (divisor / 2), divisor);
242 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
271 dev_dbg(&priv->
i2c->dev,
"%s: error state=%d\n", __func__,
284 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
304 static int cxd2820r_get_frontend(
struct dvb_frontend *fe)
309 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
337 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
357 static int cxd2820r_read_signal_strength(
struct dvb_frontend *fe,
u16 *strength)
362 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
387 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
407 static int cxd2820r_read_ucblocks(
struct dvb_frontend *fe,
u32 *ucblocks)
412 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
442 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
462 static int cxd2820r_get_tune_settings(
struct dvb_frontend *fe,
468 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
495 dev_dbg(&priv->
i2c->dev,
"%s: delsys=%d\n", __func__,
516 ret = cxd2820r_set_frontend(fe);
538 dev_dbg(&priv->
i2c->dev,
"%s: loop=%d\n", __func__, i);
540 ret = cxd2820r_read_status(fe, &status);
558 dev_dbg(&priv->
i2c->dev,
"%s: failed=%d\n", __func__, ret);
562 static int cxd2820r_get_frontend_algo(
struct dvb_frontend *fe)
574 #ifdef CONFIG_GPIOLIB
576 if (priv->gpio_chip.label) {
579 dev_err(&priv->
i2c->dev,
"%s: gpiochip_remove() " \
580 "failed=%d\n", KBUILD_MODNAME, ret);
591 dev_dbg(&priv->
i2c->dev,
"%s: %d\n", __func__, enable);
597 #ifdef CONFIG_GPIOLIB
598 static int cxd2820r_gpio_direction_output(
struct gpio_chip *
chip,
unsigned nr,
605 dev_dbg(&priv->
i2c->dev,
"%s: nr=%d val=%d\n", __func__, nr, val);
613 static void cxd2820r_gpio_set(
struct gpio_chip *
chip,
unsigned nr,
int val)
619 dev_dbg(&priv->
i2c->dev,
"%s: nr=%d val=%d\n", __func__, nr, val);
629 static int cxd2820r_gpio_get(
struct gpio_chip *chip,
unsigned nr)
634 dev_dbg(&priv->
i2c->dev,
"%s: nr=%d\n", __func__, nr);
636 return (priv->
gpio[nr] >> 2) & 0x01;
644 .name =
"Sony CXD2820R",
666 .release = cxd2820r_release,
667 .init = cxd2820r_init,
668 .sleep = cxd2820r_sleep,
670 .get_tune_settings = cxd2820r_get_tune_settings,
671 .i2c_gate_ctrl = cxd2820r_i2c_gate_ctrl,
673 .get_frontend = cxd2820r_get_frontend,
675 .get_frontend_algo = cxd2820r_get_frontend_algo,
676 .search = cxd2820r_search,
678 .read_status = cxd2820r_read_status,
679 .read_snr = cxd2820r_read_snr,
680 .read_ber = cxd2820r_read_ber,
681 .read_ucblocks = cxd2820r_read_ucblocks,
682 .read_signal_strength = cxd2820r_read_signal_strength,
704 priv->
fe.demodulator_priv =
priv;
706 priv->
bank[0] = priv->
bank[1] = 0xff;
708 dev_dbg(&priv->
i2c->dev,
"%s: chip id=%02x\n", __func__, tmp);
709 if (ret || tmp != 0xe1)
712 if (gpio_chip_base) {
713 #ifdef CONFIG_GPIOLIB
715 priv->gpio_chip.label = KBUILD_MODNAME;
716 priv->gpio_chip.dev = &priv->
i2c->dev;
718 priv->gpio_chip.direction_output =
719 cxd2820r_gpio_direction_output;
720 priv->gpio_chip.set = cxd2820r_gpio_set;
721 priv->gpio_chip.get = cxd2820r_gpio_get;
722 priv->gpio_chip.base = -1;
724 priv->gpio_chip.can_sleep = 1;
729 dev_dbg(&priv->
i2c->dev,
"%s: gpio_chip.base=%d\n", __func__,
730 priv->gpio_chip.base);
732 *gpio_chip_base = priv->gpio_chip.base;
739 gpio[0] = (*gpio_chip_base >> 0) & 0x07;
740 gpio[1] = (*gpio_chip_base >> 3) & 0x07;
750 dev_dbg(&i2c->
dev,
"%s: failed=%d\n", __func__, ret);