Lines Matching +full:bypass +full:- +full:slot +full:- +full:no

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2010-2013 Digital Devices GmbH
24 static int read_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount);
57 if (ci->lastaddress != adr) in read_block()
58 status = regmap_write(ci->regmap, 0, adr); in read_block()
60 ci->lastaddress = adr; in read_block()
65 if (ci->cfg.max_i2c && len > ci->cfg.max_i2c) in read_block()
66 len = ci->cfg.max_i2c; in read_block()
67 status = regmap_raw_read(ci->regmap, 1, data, len); in read_block()
71 n -= len; in read_block()
87 status = regmap_raw_write(ci->regmap, 2, addr, 2); in read_pccard()
89 status = regmap_raw_read(ci->regmap, 3, data, n); in read_pccard()
98 status = regmap_raw_write(ci->regmap, 2, addr, 2); in write_pccard()
103 status = regmap_raw_write(ci->regmap, 3, buf, n); in write_pccard()
113 status = regmap_raw_write(ci->regmap, 2, addr, 2); in read_io()
115 status = regmap_read(ci->regmap, 3, val); in read_io()
124 status = regmap_raw_write(ci->regmap, 2, addr, 2); in write_io()
126 status = regmap_write(ci->regmap, 3, val); in write_io()
135 if (ci->lastaddress != reg) in write_regm()
136 status = regmap_write(ci->regmap, 0, reg); in write_regm()
138 status = regmap_read(ci->regmap, 1, &regval); in write_regm()
139 ci->regs[reg] = regval; in write_regm()
141 ci->lastaddress = reg; in write_regm()
142 ci->regs[reg] = (ci->regs[reg] & (~mask)) | val; in write_regm()
144 status = regmap_write(ci->regmap, 1, ci->regs[reg]); in write_regm()
146 ci->regs[reg] &= 0x7f; in write_regm()
158 u8 *buf = ci->wbuf; in write_block()
160 if (ci->lastaddress != adr) in write_block()
161 status = regmap_write(ci->regmap, 0, adr); in write_block()
165 ci->lastaddress = adr; in write_block()
169 if (ci->cfg.max_i2c && (len + 1 > ci->cfg.max_i2c)) in write_block()
170 len = ci->cfg.max_i2c - 1; in write_block()
172 status = regmap_raw_write(ci->regmap, 1, buf, len); in write_block()
175 n -= len; in write_block()
183 if (mode == ci->mode) in set_mode()
196 ci->mode = mode; in set_mode()
203 if (mode == ci->cammode) in cam_mode()
211 if (!ci->en.read_data) in cam_mode()
213 ci->write_busy = 0; in cam_mode()
214 dev_info(&ci->client->dev, "enable cam buffer mode\n"); in cam_mode()
224 ci->cammode = mode; in cam_mode()
231 mutex_lock(&ci->lock); in init()
232 ci->mode = -1; in init()
279 status = write_reg(ci, 0x15, ci->clk_reg_b); in init()
285 status = write_reg(ci, 0x17, ci->clk_reg_f); in init()
289 if (ci->cfg.clock_mode == 2) { in init()
291 u32 reg = ((ci->cfg.bitrate << 13) + 71999) / 72000; in init()
293 if (ci->cfg.polarity) { in init()
311 } else if (ci->cfg.clock_mode == 1) { in init()
312 if (ci->cfg.polarity) { in init()
331 if (ci->cfg.polarity) { in init()
364 /* Put TS in bypass */ in init()
368 ci->cammode = -1; in init()
371 mutex_unlock(&ci->lock); in init()
377 int slot, int address) in read_attribute_mem() argument
379 struct cxd *ci = ca->data; in read_attribute_mem()
382 mutex_lock(&ci->lock); in read_attribute_mem()
385 mutex_unlock(&ci->lock); in read_attribute_mem()
389 static int write_attribute_mem(struct dvb_ca_en50221 *ca, int slot, in write_attribute_mem() argument
392 struct cxd *ci = ca->data; in write_attribute_mem()
394 mutex_lock(&ci->lock); in write_attribute_mem()
397 mutex_unlock(&ci->lock); in write_attribute_mem()
402 int slot, u8 address) in read_cam_control() argument
404 struct cxd *ci = ca->data; in read_cam_control()
407 mutex_lock(&ci->lock); in read_cam_control()
410 mutex_unlock(&ci->lock); in read_cam_control()
414 static int write_cam_control(struct dvb_ca_en50221 *ca, int slot, in write_cam_control() argument
417 struct cxd *ci = ca->data; in write_cam_control()
419 mutex_lock(&ci->lock); in write_cam_control()
422 mutex_unlock(&ci->lock); in write_cam_control()
426 static int slot_reset(struct dvb_ca_en50221 *ca, int slot) in slot_reset() argument
428 struct cxd *ci = ca->data; in slot_reset()
430 if (ci->cammode) in slot_reset()
431 read_data(ca, slot, ci->rbuf, 0); in slot_reset()
433 mutex_lock(&ci->lock); in slot_reset()
440 ci->ready = 0; in slot_reset()
441 ci->mode = -1; in slot_reset()
447 if (ci->ready) in slot_reset()
451 mutex_unlock(&ci->lock); in slot_reset()
455 static int slot_shutdown(struct dvb_ca_en50221 *ca, int slot) in slot_shutdown() argument
457 struct cxd *ci = ca->data; in slot_shutdown()
459 dev_dbg(&ci->client->dev, "%s\n", __func__); in slot_shutdown()
460 if (ci->cammode) in slot_shutdown()
461 read_data(ca, slot, ci->rbuf, 0); in slot_shutdown()
462 mutex_lock(&ci->lock); in slot_shutdown()
471 ci->mode = -1; in slot_shutdown()
472 ci->write_busy = 0; in slot_shutdown()
473 mutex_unlock(&ci->lock); in slot_shutdown()
477 static int slot_ts_enable(struct dvb_ca_en50221 *ca, int slot) in slot_ts_enable() argument
479 struct cxd *ci = ca->data; in slot_ts_enable()
481 mutex_lock(&ci->lock); in slot_ts_enable()
485 mutex_unlock(&ci->lock); in slot_ts_enable()
499 ci->dr = 1; in campoll()
501 ci->write_busy = 0; in campoll()
508 if (!ci->slot_stat) { in campoll()
509 ci->slot_stat |= in campoll()
515 if (ci->slot_stat) { in campoll()
516 ci->slot_stat = 0; in campoll()
518 dev_info(&ci->client->dev, "NO CAM\n"); in campoll()
519 ci->ready = 0; in campoll()
523 ci->slot_stat == DVB_CA_EN50221_POLL_CAM_PRESENT) { in campoll()
524 ci->ready = 1; in campoll()
525 ci->slot_stat |= DVB_CA_EN50221_POLL_CAM_READY; in campoll()
531 static int poll_slot_status(struct dvb_ca_en50221 *ca, int slot, int open) in poll_slot_status() argument
533 struct cxd *ci = ca->data; in poll_slot_status()
536 mutex_lock(&ci->lock); in poll_slot_status()
539 mutex_unlock(&ci->lock); in poll_slot_status()
541 return ci->slot_stat; in poll_slot_status()
544 static int read_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount) in read_data() argument
546 struct cxd *ci = ca->data; in read_data()
550 mutex_lock(&ci->lock); in read_data()
552 mutex_unlock(&ci->lock); in read_data()
554 if (!ci->dr) in read_data()
557 mutex_lock(&ci->lock); in read_data()
563 read_block(ci, 0x12, ci->rbuf, len); in read_data()
564 mutex_unlock(&ci->lock); in read_data()
565 return -EIO; in read_data()
568 ci->dr = 0; in read_data()
569 mutex_unlock(&ci->lock); in read_data()
573 static int write_data(struct dvb_ca_en50221 *ca, int slot, u8 *ebuf, int ecount) in write_data() argument
575 struct cxd *ci = ca->data; in write_data()
577 if (ci->write_busy) in write_data()
578 return -EAGAIN; in write_data()
579 mutex_lock(&ci->lock); in write_data()
583 ci->write_busy = 1; in write_data()
584 mutex_unlock(&ci->lock); in write_data()
604 struct cxd2099_cfg *cfg = client->dev.platform_data; in cxd2099_probe()
614 ret = -ENOMEM; in cxd2099_probe()
618 ci->client = client; in cxd2099_probe()
619 memcpy(&ci->cfg, cfg, sizeof(ci->cfg)); in cxd2099_probe()
621 ci->regmap = regmap_init_i2c(client, &rm_cfg); in cxd2099_probe()
622 if (IS_ERR(ci->regmap)) { in cxd2099_probe()
623 ret = PTR_ERR(ci->regmap); in cxd2099_probe()
627 ret = regmap_read(ci->regmap, 0x00, &val); in cxd2099_probe()
629 dev_info(&client->dev, "No CXD2099AR detected at 0x%02x\n", in cxd2099_probe()
630 client->addr); in cxd2099_probe()
634 mutex_init(&ci->lock); in cxd2099_probe()
635 ci->lastaddress = 0xff; in cxd2099_probe()
636 ci->clk_reg_b = 0x4a; in cxd2099_probe()
637 ci->clk_reg_f = 0x1b; in cxd2099_probe()
639 ci->en = en_templ; in cxd2099_probe()
640 ci->en.data = ci; in cxd2099_probe()
642 dev_info(&client->dev, "Attached CXD2099AR at 0x%02x\n", client->addr); in cxd2099_probe()
644 *cfg->en = &ci->en; in cxd2099_probe()
647 ci->en.read_data = NULL; in cxd2099_probe()
648 ci->en.write_data = NULL; in cxd2099_probe()
650 dev_info(&client->dev, "Using CXD2099AR buffer mode"); in cxd2099_probe()
658 regmap_exit(ci->regmap); in cxd2099_probe()
670 regmap_exit(ci->regmap); in cxd2099_remove()