Lines Matching +full:if +full:- +full:mode +full:- +full:en
1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (C) 2010-2013 Digital Devices GmbH
22 MODULE_PARM_DESC(buffermode, "Enable CXD2099AR buffer mode (default: disabled)");
27 struct dvb_ca_en50221 en; member
37 int mode; member
57 if (ci->lastaddress != adr) in read_block()
58 status = regmap_write(ci->regmap, 0, adr); in read_block()
59 if (!status) { 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()
68 if (status) in read_block()
71 n -= len; in read_block()
87 status = regmap_raw_write(ci->regmap, 2, addr, 2); in read_pccard()
88 if (!status) 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()
99 if (!status) { 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()
114 if (!status) 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()
125 if (!status) 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()
137 if (!status && reg >= 6 && reg <= 8 && mask != 0xff) { in write_regm()
138 status = regmap_read(ci->regmap, 1, ®val); 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()
143 if (!status) in write_regm()
144 status = regmap_write(ci->regmap, 1, ci->regs[reg]); in write_regm()
145 if (reg == 0x20) 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()
162 if (status) 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()
173 if (status) in write_block()
175 n -= len; in write_block()
181 static void set_mode(struct cxd *ci, int mode) in set_mode() argument
183 if (mode == ci->mode) in set_mode()
186 switch (mode) { in set_mode()
196 ci->mode = mode; in set_mode()
199 static void cam_mode(struct cxd *ci, int mode) in cam_mode() argument
203 if (mode == ci->cammode) in cam_mode()
206 switch (mode) { 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()
235 if (status < 0) in init()
238 if (status < 0) in init()
241 if (status < 0) in init()
244 if (status < 0) in init()
247 if (status < 0) in init()
250 if (status < 0) in init()
253 if (status < 0) in init()
256 if (status < 0) in init()
259 if (status < 0) in init()
262 /* TOSTRT = 8, Mode B (gated clock), falling Edge, in init()
266 if (status < 0) in init()
270 if (status < 0) in init()
273 if (status < 0) in init()
277 if (status < 0) in init()
279 status = write_reg(ci, 0x15, ci->clk_reg_b); in init()
280 if (status < 0) in init()
283 if (status < 0) in init()
285 status = write_reg(ci, 0x17, ci->clk_reg_f); in init()
286 if (status < 0) 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()
295 if (status < 0) in init()
299 if (status < 0) in init()
303 if (status < 0) in init()
306 if (status < 0) in init()
309 if (status < 0) in init()
311 } else if (ci->cfg.clock_mode == 1) { in init()
312 if (ci->cfg.polarity) { in init()
314 if (status < 0) in init()
318 if (status < 0) in init()
322 if (status < 0) in init()
325 if (status < 0) in init()
328 if (status < 0) in init()
331 if (ci->cfg.polarity) { in init()
333 if (status < 0) in init()
337 if (status < 0) in init()
341 if (status < 0) in init()
344 if (status < 0) in init()
347 if (status < 0) in init()
352 if (status < 0) in init()
355 if (status < 0) in init()
358 if (status < 0) in init()
361 if (status < 0) in init()
366 if (status < 0) in init()
368 ci->cammode = -1; in init()
371 mutex_unlock(&ci->lock); in init()
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()
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()
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()
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()
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()
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()
468 write_regm(ci, 0x20, 0x80, 0x80); /* Reset CAM Mode */ in slot_shutdown()
469 write_regm(ci, 0x06, 0x07, 0x07); /* Clear IO Mode */ 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()
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()
494 if (!istat) in campoll()
498 if (istat & 0x40) in campoll()
499 ci->dr = 1; in campoll()
500 if (istat & 0x20) in campoll()
501 ci->write_busy = 0; in campoll()
503 if (istat & 2) { in campoll()
507 if (!(2 & slotstat)) { 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()
522 if ((istat & 8) && 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()
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()
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()
561 if (len > ecount || len < 2) { 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()
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()
605 struct cxd2099_cfg *cfg = client->dev.platform_data; in cxd2099_probe()
614 if (!ci) { in cxd2099_probe()
615 ret = -ENOMEM; in cxd2099_probe()
619 ci->client = client; in cxd2099_probe()
620 memcpy(&ci->cfg, cfg, sizeof(ci->cfg)); in cxd2099_probe()
622 ci->regmap = regmap_init_i2c(client, &rm_cfg); in cxd2099_probe()
623 if (IS_ERR(ci->regmap)) { in cxd2099_probe()
624 ret = PTR_ERR(ci->regmap); in cxd2099_probe()
628 ret = regmap_read(ci->regmap, 0x00, &val); in cxd2099_probe()
629 if (ret < 0) { in cxd2099_probe()
630 dev_info(&client->dev, "No CXD2099AR detected at 0x%02x\n", in cxd2099_probe()
631 client->addr); in cxd2099_probe()
635 mutex_init(&ci->lock); in cxd2099_probe()
636 ci->lastaddress = 0xff; in cxd2099_probe()
637 ci->clk_reg_b = 0x4a; in cxd2099_probe()
638 ci->clk_reg_f = 0x1b; in cxd2099_probe()
640 ci->en = en_templ; in cxd2099_probe()
641 ci->en.data = ci; in cxd2099_probe()
643 dev_info(&client->dev, "Attached CXD2099AR at 0x%02x\n", client->addr); in cxd2099_probe()
645 *cfg->en = &ci->en; in cxd2099_probe()
647 if (!buffermode) { in cxd2099_probe()
648 ci->en.read_data = NULL; in cxd2099_probe()
649 ci->en.write_data = NULL; in cxd2099_probe()
651 dev_info(&client->dev, "Using CXD2099AR buffer mode"); in cxd2099_probe()
659 regmap_exit(ci->regmap); in cxd2099_probe()
671 regmap_exit(ci->regmap); in cxd2099_remove()