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
31 MODULE_PARM_DESC(buffermode, "Enable CXD2099AR buffer mode (default: disabled)");
36 struct dvb_ca_en50221 en; member
46 int mode; member
66 if (ci->lastaddress != adr) in read_block()
67 status = regmap_write(ci->regmap, 0, adr); in read_block()
68 if (!status) { in read_block()
69 ci->lastaddress = adr; in read_block()
74 if (ci->cfg.max_i2c && len > ci->cfg.max_i2c) in read_block()
75 len = ci->cfg.max_i2c; in read_block()
76 status = regmap_raw_read(ci->regmap, 1, data, len); in read_block()
77 if (status) in read_block()
80 n -= len; in read_block()
96 status = regmap_raw_write(ci->regmap, 2, addr, 2); in read_pccard()
97 if (!status) in read_pccard()
98 status = regmap_raw_read(ci->regmap, 3, data, n); in read_pccard()
107 status = regmap_raw_write(ci->regmap, 2, addr, 2); in write_pccard()
108 if (!status) { in write_pccard()
112 status = regmap_raw_write(ci->regmap, 3, buf, n); in write_pccard()
122 status = regmap_raw_write(ci->regmap, 2, addr, 2); in read_io()
123 if (!status) in read_io()
124 status = regmap_read(ci->regmap, 3, val); in read_io()
133 status = regmap_raw_write(ci->regmap, 2, addr, 2); in write_io()
134 if (!status) in write_io()
135 status = regmap_write(ci->regmap, 3, val); in write_io()
144 if (ci->lastaddress != reg) in write_regm()
145 status = regmap_write(ci->regmap, 0, reg); in write_regm()
146 if (!status && reg >= 6 && reg <= 8 && mask != 0xff) { in write_regm()
147 status = regmap_read(ci->regmap, 1, ®val); in write_regm()
148 ci->regs[reg] = regval; in write_regm()
150 ci->lastaddress = reg; in write_regm()
151 ci->regs[reg] = (ci->regs[reg] & (~mask)) | val; in write_regm()
152 if (!status) in write_regm()
153 status = regmap_write(ci->regmap, 1, ci->regs[reg]); in write_regm()
154 if (reg == 0x20) in write_regm()
155 ci->regs[reg] &= 0x7f; in write_regm()
167 u8 *buf = ci->wbuf; in write_block()
169 if (ci->lastaddress != adr) in write_block()
170 status = regmap_write(ci->regmap, 0, adr); in write_block()
171 if (status) in write_block()
174 ci->lastaddress = adr; in write_block()
178 if (ci->cfg.max_i2c && (len + 1 > ci->cfg.max_i2c)) in write_block()
179 len = ci->cfg.max_i2c - 1; in write_block()
181 status = regmap_raw_write(ci->regmap, 1, buf, len); in write_block()
182 if (status) in write_block()
184 n -= len; in write_block()
190 static void set_mode(struct cxd *ci, int mode) in set_mode() argument
192 if (mode == ci->mode) in set_mode()
195 switch (mode) { in set_mode()
205 ci->mode = mode; in set_mode()
208 static void cam_mode(struct cxd *ci, int mode) in cam_mode() argument
212 if (mode == ci->cammode) in cam_mode()
215 switch (mode) { in cam_mode()
220 if (!ci->en.read_data) in cam_mode()
222 ci->write_busy = 0; in cam_mode()
223 dev_info(&ci->client->dev, "enable cam buffer mode\n"); in cam_mode()
233 ci->cammode = mode; in cam_mode()
240 mutex_lock(&ci->lock); in init()
241 ci->mode = -1; 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 if (status < 0) in init()
265 if (status < 0) in init()
268 if (status < 0) in init()
271 /* TOSTRT = 8, Mode B (gated clock), falling Edge, in init()
275 if (status < 0) in init()
279 if (status < 0) in init()
282 if (status < 0) in init()
286 if (status < 0) in init()
288 status = write_reg(ci, 0x15, ci->clk_reg_b); in init()
289 if (status < 0) in init()
292 if (status < 0) in init()
294 status = write_reg(ci, 0x17, ci->clk_reg_f); in init()
295 if (status < 0) in init()
298 if (ci->cfg.clock_mode == 2) { in init()
300 u32 reg = ((ci->cfg.bitrate << 13) + 71999) / 72000; in init()
302 if (ci->cfg.polarity) { in init()
304 if (status < 0) in init()
308 if (status < 0) in init()
312 if (status < 0) in init()
315 if (status < 0) in init()
318 if (status < 0) in init()
320 } else if (ci->cfg.clock_mode == 1) { in init()
321 if (ci->cfg.polarity) { in init()
323 if (status < 0) in init()
327 if (status < 0) in init()
331 if (status < 0) in init()
334 if (status < 0) in init()
337 if (status < 0) in init()
340 if (ci->cfg.polarity) { in init()
342 if (status < 0) in init()
346 if (status < 0) in init()
350 if (status < 0) in init()
353 if (status < 0) in init()
356 if (status < 0) in init()
361 if (status < 0) in init()
364 if (status < 0) in init()
367 if (status < 0) in init()
370 if (status < 0) in init()
375 if (status < 0) in init()
377 ci->cammode = -1; in init()
380 mutex_unlock(&ci->lock); in init()
388 struct cxd *ci = ca->data; in read_attribute_mem()
391 mutex_lock(&ci->lock); in read_attribute_mem()
394 mutex_unlock(&ci->lock); in read_attribute_mem()
401 struct cxd *ci = ca->data; in write_attribute_mem()
403 mutex_lock(&ci->lock); in write_attribute_mem()
406 mutex_unlock(&ci->lock); in write_attribute_mem()
413 struct cxd *ci = ca->data; in read_cam_control()
416 mutex_lock(&ci->lock); in read_cam_control()
419 mutex_unlock(&ci->lock); in read_cam_control()
426 struct cxd *ci = ca->data; in write_cam_control()
428 mutex_lock(&ci->lock); in write_cam_control()
431 mutex_unlock(&ci->lock); in write_cam_control()
437 struct cxd *ci = ca->data; in slot_reset()
439 if (ci->cammode) in slot_reset()
440 read_data(ca, slot, ci->rbuf, 0); in slot_reset()
442 mutex_lock(&ci->lock); in slot_reset()
449 ci->ready = 0; in slot_reset()
450 ci->mode = -1; in slot_reset()
456 if (ci->ready) in slot_reset()
460 mutex_unlock(&ci->lock); in slot_reset()
466 struct cxd *ci = ca->data; in slot_shutdown()
468 dev_dbg(&ci->client->dev, "%s\n", __func__); in slot_shutdown()
469 if (ci->cammode) in slot_shutdown()
470 read_data(ca, slot, ci->rbuf, 0); in slot_shutdown()
471 mutex_lock(&ci->lock); in slot_shutdown()
477 write_regm(ci, 0x20, 0x80, 0x80); /* Reset CAM Mode */ in slot_shutdown()
478 write_regm(ci, 0x06, 0x07, 0x07); /* Clear IO Mode */ in slot_shutdown()
480 ci->mode = -1; in slot_shutdown()
481 ci->write_busy = 0; in slot_shutdown()
482 mutex_unlock(&ci->lock); in slot_shutdown()
488 struct cxd *ci = ca->data; in slot_ts_enable()
490 mutex_lock(&ci->lock); in slot_ts_enable()
494 mutex_unlock(&ci->lock); in slot_ts_enable()
503 if (!istat) in campoll()
507 if (istat & 0x40) in campoll()
508 ci->dr = 1; in campoll()
509 if (istat & 0x20) in campoll()
510 ci->write_busy = 0; in campoll()
512 if (istat & 2) { in campoll()
516 if (!(2 & slotstat)) { in campoll()
517 if (!ci->slot_stat) { in campoll()
518 ci->slot_stat |= in campoll()
524 if (ci->slot_stat) { in campoll()
525 ci->slot_stat = 0; in campoll()
527 dev_info(&ci->client->dev, "NO CAM\n"); in campoll()
528 ci->ready = 0; in campoll()
531 if ((istat & 8) && in campoll()
532 ci->slot_stat == DVB_CA_EN50221_POLL_CAM_PRESENT) { in campoll()
533 ci->ready = 1; in campoll()
534 ci->slot_stat |= DVB_CA_EN50221_POLL_CAM_READY; in campoll()
542 struct cxd *ci = ca->data; in poll_slot_status()
545 mutex_lock(&ci->lock); in poll_slot_status()
548 mutex_unlock(&ci->lock); in poll_slot_status()
550 return ci->slot_stat; in poll_slot_status()
555 struct cxd *ci = ca->data; in read_data()
559 mutex_lock(&ci->lock); in read_data()
561 mutex_unlock(&ci->lock); in read_data()
563 if (!ci->dr) in read_data()
566 mutex_lock(&ci->lock); in read_data()
570 if (len > ecount || len < 2) { in read_data()
572 read_block(ci, 0x12, ci->rbuf, len); in read_data()
573 mutex_unlock(&ci->lock); in read_data()
574 return -EIO; in read_data()
577 ci->dr = 0; in read_data()
578 mutex_unlock(&ci->lock); in read_data()
584 struct cxd *ci = ca->data; in write_data()
586 if (ci->write_busy) in write_data()
587 return -EAGAIN; in write_data()
588 mutex_lock(&ci->lock); in write_data()
592 ci->write_busy = 1; in write_data()
593 mutex_unlock(&ci->lock); in write_data()
614 struct cxd2099_cfg *cfg = client->dev.platform_data; in cxd2099_probe()
623 if (!ci) { in cxd2099_probe()
624 ret = -ENOMEM; in cxd2099_probe()
628 ci->client = client; in cxd2099_probe()
629 memcpy(&ci->cfg, cfg, sizeof(ci->cfg)); in cxd2099_probe()
631 ci->regmap = regmap_init_i2c(client, &rm_cfg); in cxd2099_probe()
632 if (IS_ERR(ci->regmap)) { in cxd2099_probe()
633 ret = PTR_ERR(ci->regmap); in cxd2099_probe()
637 ret = regmap_read(ci->regmap, 0x00, &val); in cxd2099_probe()
638 if (ret < 0) { in cxd2099_probe()
639 dev_info(&client->dev, "No CXD2099AR detected at 0x%02x\n", in cxd2099_probe()
640 client->addr); in cxd2099_probe()
644 mutex_init(&ci->lock); in cxd2099_probe()
645 ci->lastaddress = 0xff; in cxd2099_probe()
646 ci->clk_reg_b = 0x4a; in cxd2099_probe()
647 ci->clk_reg_f = 0x1b; in cxd2099_probe()
649 ci->en = en_templ; in cxd2099_probe()
650 ci->en.data = ci; in cxd2099_probe()
652 dev_info(&client->dev, "Attached CXD2099AR at 0x%02x\n", client->addr); in cxd2099_probe()
654 *cfg->en = &ci->en; in cxd2099_probe()
656 if (!buffermode) { in cxd2099_probe()
657 ci->en.read_data = NULL; in cxd2099_probe()
658 ci->en.write_data = NULL; in cxd2099_probe()
660 dev_info(&client->dev, "Using CXD2099AR buffer mode"); in cxd2099_probe()
668 regmap_exit(ci->regmap); in cxd2099_probe()
680 regmap_exit(ci->regmap); in cxd2099_remove()