Lines Matching +full:idma +full:- +full:addr
1 // SPDX-License-Identifier: GPL-2.0
3 * ddbridge-core.c: Digital Devices bridge core functions
5 * Copyright (C) 2010-2017 Digital Devices GmbH
25 #include "ddbridge-i2c.h"
26 #include "ddbridge-regs.h"
27 #include "ddbridge-max.h"
28 #include "ddbridge-ci.h"
29 #include "ddbridge-io.h"
44 #include "ddbridge-dummy-fe.h"
57 "0-one adapter per io, 1-one per tab with io, 2-one per tab, 3-one for all");
63 static int ts_loop = -1;
89 MODULE_PARM_DESC(dma_buf_num, "Number of DMA buffers, possible values: 8-32");
94 "DMA buffer size as multiple of 128*47, possible values: 1-43");
116 struct ddb_irq *irq = &dev->link[link].irq[nr]; in ddb_irq_set()
118 irq->handler = handler; in ddb_irq_set()
119 irq->data = data; in ddb_irq_set()
125 struct ddb *dev = io->port->dev; in ddb_set_dma_table()
126 struct ddb_dma *dma = io->dma; in ddb_set_dma_table()
132 for (i = 0; i < dma->num; i++) { in ddb_set_dma_table()
133 mem = dma->pbuf[i]; in ddb_set_dma_table()
134 ddbwritel(dev, mem & 0xffffffff, dma->bufregs + i * 8); in ddb_set_dma_table()
135 ddbwritel(dev, mem >> 32, dma->bufregs + i * 8 + 4); in ddb_set_dma_table()
137 dma->bufval = ((dma->div & 0x0f) << 16) | in ddb_set_dma_table()
138 ((dma->num & 0x1f) << 11) | in ddb_set_dma_table()
139 ((dma->size >> 7) & 0x7ff); in ddb_set_dma_table()
147 if (dev->port[i].input[0]) in ddb_set_dma_tables()
148 ddb_set_dma_table(dev->port[i].input[0]); in ddb_set_dma_tables()
149 if (dev->port[i].input[1]) in ddb_set_dma_tables()
150 ddb_set_dma_table(dev->port[i].input[1]); in ddb_set_dma_tables()
151 if (dev->port[i].output) in ddb_set_dma_tables()
152 ddb_set_dma_table(dev->port[i].output); in ddb_set_dma_tables()
167 sdma->bufval = ddma->bufval; in ddb_redirect_dma()
168 base = sdma->bufregs; in ddb_redirect_dma()
169 for (i = 0; i < ddma->num; i++) { in ddb_redirect_dma()
170 mem = ddma->pbuf[i]; in ddb_redirect_dma()
181 /* dev_info(port->dev->dev, in ddb_unredirect()
182 * "unredirect %d.%d\n", port->dev->nr, port->nr); in ddb_unredirect()
185 if (port->output->dma->running) { in ddb_unredirect()
187 return -EBUSY; in ddb_unredirect()
189 oredi = port->output->redi; in ddb_unredirect()
192 if (port->input[0]) { in ddb_unredirect()
193 iredi = port->input[0]->redi; in ddb_unredirect()
194 iredo = port->input[0]->redo; in ddb_unredirect()
197 iredo->port->output->redi = oredi; in ddb_unredirect()
198 if (iredo->port->input[0]) { in ddb_unredirect()
199 iredo->port->input[0]->redi = iredi; in ddb_unredirect()
200 ddb_redirect_dma(oredi->port->dev, in ddb_unredirect()
201 oredi->dma, iredo->dma); in ddb_unredirect()
203 port->input[0]->redo = NULL; in ddb_unredirect()
204 ddb_set_dma_table(port->input[0]); in ddb_unredirect()
206 oredi->redi = iredi; in ddb_unredirect()
207 port->input[0]->redi = NULL; in ddb_unredirect()
209 oredi->redo = NULL; in ddb_unredirect()
210 port->output->redi = NULL; in ddb_unredirect()
226 return -EINVAL; in ddb_redirect()
227 if (!idev->has_dma || !pdev->has_dma) in ddb_redirect()
228 return -EINVAL; in ddb_redirect()
230 port = &pdev->port[p & 0x0f]; in ddb_redirect()
231 if (!port->output) in ddb_redirect()
232 return -EINVAL; in ddb_redirect()
234 return -EBUSY; in ddb_redirect()
239 input = &idev->input[i & 7]; in ddb_redirect()
241 return -EINVAL; in ddb_redirect()
244 if (port->output->dma->running || input->dma->running) { in ddb_redirect()
246 return -EBUSY; in ddb_redirect()
248 input2 = port->input[0]; in ddb_redirect()
250 if (input->redi) { in ddb_redirect()
251 input2->redi = input->redi; in ddb_redirect()
252 input->redi = NULL; in ddb_redirect()
254 input2->redi = input; in ddb_redirect()
257 input->redo = port->output; in ddb_redirect()
258 port->output->redi = input; in ddb_redirect()
260 ddb_redirect_dma(input->port->dev, input->dma, port->output->dma); in ddb_redirect()
275 for (i = 0; i < dma->num; i++) { in dma_free()
276 if (dma->vbuf[i]) { in dma_free()
278 dma_unmap_single(&pdev->dev, dma->pbuf[i], in dma_free()
279 dma->size, in dma_free()
282 kfree(dma->vbuf[i]); in dma_free()
283 dma->vbuf[i] = NULL; in dma_free()
285 dma_free_coherent(&pdev->dev, dma->size, in dma_free()
286 dma->vbuf[i], dma->pbuf[i]); in dma_free()
289 dma->vbuf[i] = NULL; in dma_free()
300 for (i = 0; i < dma->num; i++) { in dma_alloc()
302 dma->vbuf[i] = kmalloc(dma->size, __GFP_RETRY_MAYFAIL); in dma_alloc()
303 if (!dma->vbuf[i]) in dma_alloc()
304 return -ENOMEM; in dma_alloc()
305 dma->pbuf[i] = dma_map_single(&pdev->dev, in dma_alloc()
306 dma->vbuf[i], in dma_alloc()
307 dma->size, in dma_alloc()
310 if (dma_mapping_error(&pdev->dev, dma->pbuf[i])) { in dma_alloc()
311 kfree(dma->vbuf[i]); in dma_alloc()
312 dma->vbuf[i] = NULL; in dma_alloc()
313 return -ENOMEM; in dma_alloc()
316 dma->vbuf[i] = dma_alloc_coherent(&pdev->dev, in dma_alloc()
317 dma->size, in dma_alloc()
318 &dma->pbuf[i], in dma_alloc()
320 if (!dma->vbuf[i]) in dma_alloc()
321 return -ENOMEM; in dma_alloc()
332 for (i = 0; i < dev->port_num; i++) { in ddb_buffers_alloc()
333 port = &dev->port[i]; in ddb_buffers_alloc()
334 switch (port->class) { in ddb_buffers_alloc()
336 if (port->input[0]->dma) in ddb_buffers_alloc()
337 if (dma_alloc(dev->pdev, port->input[0]->dma, 0) in ddb_buffers_alloc()
339 return -1; in ddb_buffers_alloc()
340 if (port->input[1]->dma) in ddb_buffers_alloc()
341 if (dma_alloc(dev->pdev, port->input[1]->dma, 0) in ddb_buffers_alloc()
343 return -1; in ddb_buffers_alloc()
347 if (port->input[0]->dma) in ddb_buffers_alloc()
348 if (dma_alloc(dev->pdev, port->input[0]->dma, 0) in ddb_buffers_alloc()
350 return -1; in ddb_buffers_alloc()
351 if (port->output->dma) in ddb_buffers_alloc()
352 if (dma_alloc(dev->pdev, port->output->dma, 1) in ddb_buffers_alloc()
354 return -1; in ddb_buffers_alloc()
369 for (i = 0; i < dev->port_num; i++) { in ddb_buffers_free()
370 port = &dev->port[i]; in ddb_buffers_free()
372 if (port->input[0] && port->input[0]->dma) in ddb_buffers_free()
373 dma_free(dev->pdev, port->input[0]->dma, 0); in ddb_buffers_free()
374 if (port->input[1] && port->input[1]->dma) in ddb_buffers_free()
375 dma_free(dev->pdev, port->input[1]->dma, 0); in ddb_buffers_free()
376 if (port->output && port->output->dma) in ddb_buffers_free()
377 dma_free(dev->pdev, port->output->dma, 1); in ddb_buffers_free()
383 struct ddb *dev = output->port->dev; in calc_con()
384 u32 bitrate = output->port->obr, max_bitrate = 72000; in calc_con()
388 if (output->port->gap != 0xffffffff) { in calc_con()
390 gap = output->port->gap; in calc_con()
393 if (dev->link[0].info->type == DDB_OCTOPUS_CI && output->port->nr > 1) { in calc_con()
395 if (dev->link[0].ids.regmapid >= 0x10003 && !(flags & 1)) { in calc_con()
436 gap = ((max_bitrate - bitrate) * 94) / bitrate; in calc_con()
440 gap -= 2; in calc_con()
450 struct ddb *dev = output->port->dev; in ddb_output_start()
453 spin_lock_irq(&output->dma->lock); in ddb_output_start()
454 output->dma->cbuf = 0; in ddb_output_start()
455 output->dma->coff = 0; in ddb_output_start()
456 output->dma->stat = 0; in ddb_output_start()
457 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma)); in ddb_output_start()
459 if (output->port->input[0]->port->class == DDB_PORT_LOOP) in ddb_output_start()
470 ddbwritel(dev, output->dma->bufval, in ddb_output_start()
471 DMA_BUFFER_SIZE(output->dma)); in ddb_output_start()
472 ddbwritel(dev, 0, DMA_BUFFER_ACK(output->dma)); in ddb_output_start()
474 ddbwritel(dev, 7, DMA_BUFFER_CONTROL(output->dma)); in ddb_output_start()
478 output->dma->running = 1; in ddb_output_start()
479 spin_unlock_irq(&output->dma->lock); in ddb_output_start()
484 struct ddb *dev = output->port->dev; in ddb_output_stop()
486 spin_lock_irq(&output->dma->lock); in ddb_output_stop()
490 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(output->dma)); in ddb_output_stop()
491 output->dma->running = 0; in ddb_output_stop()
492 spin_unlock_irq(&output->dma->lock); in ddb_output_stop()
497 struct ddb *dev = input->port->dev; in ddb_input_stop()
498 u32 tag = DDB_LINK_TAG(input->port->lnr); in ddb_input_stop()
500 spin_lock_irq(&input->dma->lock); in ddb_input_stop()
504 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(input->dma)); in ddb_input_stop()
505 input->dma->running = 0; in ddb_input_stop()
506 spin_unlock_irq(&input->dma->lock); in ddb_input_stop()
511 struct ddb *dev = input->port->dev; in ddb_input_start()
513 spin_lock_irq(&input->dma->lock); in ddb_input_start()
514 input->dma->cbuf = 0; in ddb_input_start()
515 input->dma->coff = 0; in ddb_input_start()
516 input->dma->stat = 0; in ddb_input_start()
517 ddbwritel(dev, 0, DMA_BUFFER_CONTROL(input->dma)); in ddb_input_start()
523 ddbwritel(dev, input->dma->bufval, in ddb_input_start()
524 DMA_BUFFER_SIZE(input->dma)); in ddb_input_start()
525 ddbwritel(dev, 0, DMA_BUFFER_ACK(input->dma)); in ddb_input_start()
527 ddbwritel(dev, 3, DMA_BUFFER_CONTROL(input->dma)); in ddb_input_start()
531 if (input->port->type == DDB_TUNER_DUMMY) in ddb_input_start()
534 input->dma->running = 1; in ddb_input_start()
535 spin_unlock_irq(&input->dma->lock); in ddb_input_start()
544 while (i && (o = i->redo)) { in ddb_input_start_all()
546 i = o->port->input[0]; in ddb_input_start_all()
561 while (i && (o = i->redo)) { in ddb_input_stop_all()
563 i = o->port->input[0]; in ddb_input_stop_all()
572 u32 idx, off, stat = output->dma->stat; in ddb_output_free()
578 if (output->dma->cbuf != idx) { in ddb_output_free()
579 if ((((output->dma->cbuf + 1) % output->dma->num) == idx) && in ddb_output_free()
580 (output->dma->size - output->dma->coff <= (2 * 188))) in ddb_output_free()
584 diff = off - output->dma->coff; in ddb_output_free()
593 struct ddb *dev = output->port->dev; in ddb_output_write()
594 u32 idx, off, stat = output->dma->stat; in ddb_output_write()
601 len = output->dma->size - output->dma->coff; in ddb_output_write()
602 if ((((output->dma->cbuf + 1) % output->dma->num) == idx) && in ddb_output_write()
606 len -= 188; in ddb_output_write()
608 if (output->dma->cbuf == idx) { in ddb_output_write()
609 if (off > output->dma->coff) { in ddb_output_write()
610 len = off - output->dma->coff; in ddb_output_write()
611 len -= (len % 188); in ddb_output_write()
614 len -= 188; in ddb_output_write()
619 if (copy_from_user(output->dma->vbuf[output->dma->cbuf] + in ddb_output_write()
620 output->dma->coff, in ddb_output_write()
622 return -EIO; in ddb_output_write()
625 dev->dev, in ddb_output_write()
626 output->dma->pbuf[output->dma->cbuf], in ddb_output_write()
627 output->dma->size, DMA_TO_DEVICE); in ddb_output_write()
628 left -= len; in ddb_output_write()
630 output->dma->coff += len; in ddb_output_write()
631 if (output->dma->coff == output->dma->size) { in ddb_output_write()
632 output->dma->coff = 0; in ddb_output_write()
633 output->dma->cbuf = ((output->dma->cbuf + 1) % in ddb_output_write()
634 output->dma->num); in ddb_output_write()
637 (output->dma->cbuf << 11) | in ddb_output_write()
638 (output->dma->coff >> 7), in ddb_output_write()
639 DMA_BUFFER_ACK(output->dma)); in ddb_output_write()
641 return count - left; in ddb_output_write()
646 struct ddb *dev = input->port->dev; in ddb_input_avail()
647 u32 idx, off, stat = input->dma->stat; in ddb_input_avail()
648 u32 ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(input->dma)); in ddb_input_avail()
654 dev_err(dev->dev, "IA %d %d %08x\n", idx, off, ctrl); in ddb_input_avail()
655 ddbwritel(dev, stat, DMA_BUFFER_ACK(input->dma)); in ddb_input_avail()
658 if (input->dma->cbuf != idx) in ddb_input_avail()
666 struct ddb *dev = input->port->dev; in ddb_input_read()
668 u32 idx, free, stat = input->dma->stat; in ddb_input_read()
674 if (input->dma->cbuf == idx) in ddb_input_read()
675 return count - left; in ddb_input_read()
676 free = input->dma->size - input->dma->coff; in ddb_input_read()
681 dev->dev, in ddb_input_read()
682 input->dma->pbuf[input->dma->cbuf], in ddb_input_read()
683 input->dma->size, DMA_FROM_DEVICE); in ddb_input_read()
684 ret = copy_to_user(buf, input->dma->vbuf[input->dma->cbuf] + in ddb_input_read()
685 input->dma->coff, free); in ddb_input_read()
687 return -EFAULT; in ddb_input_read()
688 input->dma->coff += free; in ddb_input_read()
689 if (input->dma->coff == input->dma->size) { in ddb_input_read()
690 input->dma->coff = 0; in ddb_input_read()
691 input->dma->cbuf = (input->dma->cbuf + 1) % in ddb_input_read()
692 input->dma->num; in ddb_input_read()
694 left -= free; in ddb_input_read()
697 (input->dma->cbuf << 11) | (input->dma->coff >> 7), in ddb_input_read()
698 DMA_BUFFER_ACK(input->dma)); in ddb_input_read()
709 struct dvb_device *dvbdev = file->private_data; in ts_write()
710 struct ddb_output *output = dvbdev->priv; in ts_write()
711 struct ddb *dev = output->port->dev; in ts_write()
715 if (!dev->has_dma) in ts_write()
716 return -EINVAL; in ts_write()
719 if (file->f_flags & O_NONBLOCK) in ts_write()
722 output->dma->wq, in ts_write()
730 left -= stat; in ts_write()
732 return (left == count) ? -EAGAIN : (count - left); in ts_write()
738 struct dvb_device *dvbdev = file->private_data; in ts_read()
739 struct ddb_output *output = dvbdev->priv; in ts_read()
740 struct ddb_input *input = output->port->input[0]; in ts_read()
741 struct ddb *dev = output->port->dev; in ts_read()
745 if (!dev->has_dma) in ts_read()
746 return -EINVAL; in ts_read()
749 if (file->f_flags & O_NONBLOCK) in ts_read()
752 input->dma->wq, in ts_read()
759 left -= stat; in ts_read()
762 return (count && (left == count)) ? -EAGAIN : (count - left); in ts_read()
767 struct dvb_device *dvbdev = file->private_data; in ts_poll()
768 struct ddb_output *output = dvbdev->priv; in ts_poll()
769 struct ddb_input *input = output->port->input[0]; in ts_poll()
773 poll_wait(file, &input->dma->wq, wait); in ts_poll()
774 poll_wait(file, &output->dma->wq, wait); in ts_poll()
784 struct dvb_device *dvbdev = file->private_data; in ts_release()
789 output = dvbdev->priv; in ts_release()
790 input = output->port->input[0]; in ts_release()
793 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { in ts_release()
795 return -EINVAL; in ts_release()
797 } else if ((file->f_flags & O_ACCMODE) == O_WRONLY) { in ts_release()
799 return -EINVAL; in ts_release()
808 struct dvb_device *dvbdev = file->private_data; in ts_open()
813 output = dvbdev->priv; in ts_open()
814 input = output->port->input[0]; in ts_open()
817 if ((file->f_flags & O_ACCMODE) == O_RDONLY) { in ts_open()
819 return -EINVAL; in ts_open()
820 if (input->redo || input->redi) in ts_open()
821 return -EBUSY; in ts_open()
822 } else if ((file->f_flags & O_ACCMODE) == O_WRONLY) { in ts_open()
824 return -EINVAL; in ts_open()
826 return -EINVAL; in ts_open()
832 if ((file->f_flags & O_ACCMODE) == O_RDONLY) in ts_open()
834 else if ((file->f_flags & O_ACCMODE) == O_WRONLY) in ts_open()
862 struct ddb_input *input = fe->sec_priv; in locked_gate_ctrl()
863 struct ddb_port *port = input->port; in locked_gate_ctrl()
864 struct ddb_dvb *dvb = &port->dvb[input->nr & 1]; in locked_gate_ctrl()
868 mutex_lock(&port->i2c_gate_lock); in locked_gate_ctrl()
869 status = dvb->i2c_gate_ctrl(fe, 1); in locked_gate_ctrl()
871 status = dvb->i2c_gate_ctrl(fe, 0); in locked_gate_ctrl()
872 mutex_unlock(&port->i2c_gate_lock); in locked_gate_ctrl()
879 struct i2c_adapter *i2c = &input->port->i2c->adap; in demod_attach_drxk()
880 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in demod_attach_drxk()
881 struct device *dev = input->port->dev->dev; in demod_attach_drxk()
885 config.adr = 0x29 + (input->nr & 1); in demod_attach_drxk()
888 dvb->fe = dvb_attach(drxk_attach, &config, i2c); in demod_attach_drxk()
889 if (!dvb->fe) { in demod_attach_drxk()
891 return -ENODEV; in demod_attach_drxk()
893 dvb->fe->sec_priv = input; in demod_attach_drxk()
894 dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl; in demod_attach_drxk()
895 dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl; in demod_attach_drxk()
901 struct i2c_adapter *i2c = &input->port->i2c->adap; in tuner_attach_tda18271()
902 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in tuner_attach_tda18271()
903 struct device *dev = input->port->dev->dev; in tuner_attach_tda18271()
906 if (dvb->fe->ops.i2c_gate_ctrl) in tuner_attach_tda18271()
907 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 1); in tuner_attach_tda18271()
908 fe = dvb_attach(tda18271c2dd_attach, dvb->fe, i2c, 0x60); in tuner_attach_tda18271()
909 if (dvb->fe->ops.i2c_gate_ctrl) in tuner_attach_tda18271()
910 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 0); in tuner_attach_tda18271()
913 return -ENODEV; in tuner_attach_tda18271()
942 struct i2c_adapter *i2c = &input->port->i2c->adap; in demod_attach_stv0367()
943 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in demod_attach_stv0367()
944 struct device *dev = input->port->dev->dev; in demod_attach_stv0367()
947 dvb->fe = dvb_attach(stv0367ddb_attach, in demod_attach_stv0367()
948 &ddb_stv0367_config[(input->nr & 1)], i2c); in demod_attach_stv0367()
950 if (!dvb->fe) { in demod_attach_stv0367()
952 return -ENODEV; in demod_attach_stv0367()
954 dvb->fe->sec_priv = input; in demod_attach_stv0367()
955 dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl; in demod_attach_stv0367()
956 dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl; in demod_attach_stv0367()
962 struct i2c_adapter *adapter = &input->port->i2c->adap; in tuner_tda18212_ping()
963 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in tuner_tda18212_ping()
964 struct device *dev = input->port->dev->dev; in tuner_tda18212_ping()
968 dev_dbg(dev, "stv0367-tda18212 tuner ping\n"); in tuner_tda18212_ping()
969 if (dvb->fe->ops.i2c_gate_ctrl) in tuner_tda18212_ping()
970 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 1); in tuner_tda18212_ping()
977 if (dvb->fe->ops.i2c_gate_ctrl) in tuner_tda18212_ping()
978 dvb->fe->ops.i2c_gate_ctrl(dvb->fe, 0); in tuner_tda18212_ping()
985 struct i2c_adapter *i2c = &input->port->i2c->adap; in demod_attach_cxd28xx()
986 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in demod_attach_cxd28xx()
987 struct device *dev = input->port->dev->dev; in demod_attach_cxd28xx()
991 cfg.i2c_addr = ((input->nr & 1) ? 0x6d : 0x6c) << 1; in demod_attach_cxd28xx()
1002 dvb->fe = dvb_attach(cxd2841er_attach_t_c, &cfg, i2c); in demod_attach_cxd28xx()
1004 if (!dvb->fe) { in demod_attach_cxd28xx()
1006 return -ENODEV; in demod_attach_cxd28xx()
1008 dvb->fe->sec_priv = input; in demod_attach_cxd28xx()
1009 dvb->i2c_gate_ctrl = dvb->fe->ops.i2c_gate_ctrl; in demod_attach_cxd28xx()
1010 dvb->fe->ops.i2c_gate_ctrl = locked_gate_ctrl; in demod_attach_cxd28xx()
1016 struct i2c_adapter *adapter = &input->port->i2c->adap; in tuner_attach_tda18212()
1017 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in tuner_attach_tda18212()
1018 struct device *dev = input->port->dev->dev; in tuner_attach_tda18212()
1021 .fe = dvb->fe, in tuner_attach_tda18212()
1030 u8 addr = (input->nr & 1) ? 0x63 : 0x60; in tuner_attach_tda18212() local
1037 tuner_tda18212_ping(input, addr); in tuner_attach_tda18212()
1040 client = dvb_module_probe("tda18212", NULL, adapter, addr, &config); in tuner_attach_tda18212()
1044 dvb->i2c_client[0] = client; in tuner_attach_tda18212()
1048 return -ENODEV; in tuner_attach_tda18212()
1100 .addr = 0x60,
1106 .addr = 0x63,
1113 struct i2c_adapter *i2c = &input->port->i2c->adap; in demod_attach_stv0900()
1115 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in demod_attach_stv0900()
1116 struct device *dev = input->port->dev->dev; in demod_attach_stv0900()
1118 dvb->fe = dvb_attach(stv090x_attach, feconf, i2c, in demod_attach_stv0900()
1119 (input->nr & 1) ? STV090x_DEMODULATOR_1 in demod_attach_stv0900()
1121 if (!dvb->fe) { in demod_attach_stv0900()
1123 return -ENODEV; in demod_attach_stv0900()
1125 if (!dvb_attach(lnbh24_attach, dvb->fe, i2c, 0, in demod_attach_stv0900()
1126 0, (input->nr & 1) ? in demod_attach_stv0900()
1127 (0x09 - type) : (0x0b - type))) { in demod_attach_stv0900()
1129 dvb_frontend_detach(dvb->fe); in demod_attach_stv0900()
1130 return -ENODEV; in demod_attach_stv0900()
1137 struct i2c_adapter *i2c = &input->port->i2c->adap; in tuner_attach_stv6110()
1138 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in tuner_attach_stv6110()
1139 struct device *dev = input->port->dev->dev; in tuner_attach_stv6110()
1141 struct stv6110x_config *tunerconf = (input->nr & 1) ? in tuner_attach_stv6110()
1145 ctl = dvb_attach(stv6110x_attach, dvb->fe, tunerconf, i2c); in tuner_attach_stv6110()
1148 return -ENODEV; in tuner_attach_stv6110()
1151 input->nr, tunerconf->addr); in tuner_attach_stv6110()
1153 feconf->tuner_init = ctl->tuner_init; in tuner_attach_stv6110()
1154 feconf->tuner_sleep = ctl->tuner_sleep; in tuner_attach_stv6110()
1155 feconf->tuner_set_mode = ctl->tuner_set_mode; in tuner_attach_stv6110()
1156 feconf->tuner_set_frequency = ctl->tuner_set_frequency; in tuner_attach_stv6110()
1157 feconf->tuner_get_frequency = ctl->tuner_get_frequency; in tuner_attach_stv6110()
1158 feconf->tuner_set_bandwidth = ctl->tuner_set_bandwidth; in tuner_attach_stv6110()
1159 feconf->tuner_get_bandwidth = ctl->tuner_get_bandwidth; in tuner_attach_stv6110()
1160 feconf->tuner_set_bbgain = ctl->tuner_set_bbgain; in tuner_attach_stv6110()
1161 feconf->tuner_get_bbgain = ctl->tuner_get_bbgain; in tuner_attach_stv6110()
1162 feconf->tuner_set_refclk = ctl->tuner_set_refclk; in tuner_attach_stv6110()
1163 feconf->tuner_get_status = ctl->tuner_get_status; in tuner_attach_stv6110()
1190 struct i2c_adapter *i2c = &input->port->i2c->adap; in demod_attach_stv0910()
1191 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in demod_attach_stv0910()
1192 struct device *dev = input->port->dev->dev; in demod_attach_stv0910()
1207 dvb->fe = dvb_attach(stv0910_attach, i2c, &cfg, (input->nr & 1)); in demod_attach_stv0910()
1208 if (!dvb->fe) { in demod_attach_stv0910()
1210 dvb->fe = dvb_attach(stv0910_attach, i2c, in demod_attach_stv0910()
1211 &cfg, (input->nr & 1)); in demod_attach_stv0910()
1213 if (!dvb->fe) { in demod_attach_stv0910()
1215 return -ENODEV; in demod_attach_stv0910()
1218 /* attach lnbh25 - leftshift by one as the lnbh25 driver expects 8bit in demod_attach_stv0910()
1222 lnbcfg.i2c_address = (((input->nr & 1) ? 0x0d : 0x0c) << 1); in demod_attach_stv0910()
1224 lnbcfg.i2c_address = (((input->nr & 1) ? 0x09 : 0x08) << 1); in demod_attach_stv0910()
1226 if (!dvb_attach(lnbh25_attach, dvb->fe, &lnbcfg, i2c)) { in demod_attach_stv0910()
1228 dvb_frontend_detach(dvb->fe); in demod_attach_stv0910()
1229 return -ENODEV; in demod_attach_stv0910()
1237 struct i2c_adapter *i2c = &input->port->i2c->adap; in tuner_attach_stv6111()
1238 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in tuner_attach_stv6111()
1239 struct device *dev = input->port->dev->dev; in tuner_attach_stv6111()
1241 u8 adr = (type ? 0 : 4) + ((input->nr & 1) ? 0x63 : 0x60); in tuner_attach_stv6111()
1243 fe = dvb_attach(stv6111_attach, dvb->fe, i2c, adr); in tuner_attach_stv6111()
1245 fe = dvb_attach(stv6111_attach, dvb->fe, i2c, adr & ~4); in tuner_attach_stv6111()
1248 return -ENODEV; in tuner_attach_stv6111()
1256 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in demod_attach_dummy()
1257 struct device *dev = input->port->dev->dev; in demod_attach_dummy()
1259 dvb->fe = dvb_attach(ddbridge_dummy_fe_qam_attach); in demod_attach_dummy()
1260 if (!dvb->fe) { in demod_attach_dummy()
1262 return -ENODEV; in demod_attach_dummy()
1270 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; in start_feed()
1271 struct ddb_input *input = dvbdmx->priv; in start_feed()
1272 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in start_feed()
1274 if (!dvb->users) in start_feed()
1277 return ++dvb->users; in start_feed()
1282 struct dvb_demux *dvbdmx = dvbdmxfeed->demux; in stop_feed()
1283 struct ddb_input *input = dvbdmx->priv; in stop_feed()
1284 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in stop_feed()
1286 if (--dvb->users) in stop_feed()
1287 return dvb->users; in stop_feed()
1295 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in dvb_input_detach()
1296 struct dvb_demux *dvbdemux = &dvb->demux; in dvb_input_detach()
1298 switch (dvb->attached) { in dvb_input_detach()
1300 if (dvb->fe2) in dvb_input_detach()
1301 dvb_unregister_frontend(dvb->fe2); in dvb_input_detach()
1302 if (dvb->fe) in dvb_input_detach()
1303 dvb_unregister_frontend(dvb->fe); in dvb_input_detach()
1306 dvb_module_release(dvb->i2c_client[0]); in dvb_input_detach()
1307 dvb->i2c_client[0] = NULL; in dvb_input_detach()
1309 if (dvb->fe2) in dvb_input_detach()
1310 dvb_frontend_detach(dvb->fe2); in dvb_input_detach()
1311 if (dvb->fe) in dvb_input_detach()
1312 dvb_frontend_detach(dvb->fe); in dvb_input_detach()
1313 dvb->fe = NULL; in dvb_input_detach()
1314 dvb->fe2 = NULL; in dvb_input_detach()
1317 dvb_net_release(&dvb->dvbnet); in dvb_input_detach()
1320 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, in dvb_input_detach()
1321 &dvb->hw_frontend); in dvb_input_detach()
1322 dvbdemux->dmx.remove_frontend(&dvbdemux->dmx, in dvb_input_detach()
1323 &dvb->mem_frontend); in dvb_input_detach()
1326 dvb_dmxdev_release(&dvb->dmxdev); in dvb_input_detach()
1329 dvb_dmx_release(&dvb->demux); in dvb_input_detach()
1334 dvb->attached = 0x00; in dvb_input_detach()
1344 port = &dev->port[0]; in dvb_register_adapters()
1345 adap = port->dvb[0].adap; in dvb_register_adapters()
1347 port->dev->dev, in dvb_register_adapters()
1351 port->dvb[0].adap_registered = 1; in dvb_register_adapters()
1352 for (i = 0; i < dev->port_num; i++) { in dvb_register_adapters()
1353 port = &dev->port[i]; in dvb_register_adapters()
1354 port->dvb[0].adap = adap; in dvb_register_adapters()
1355 port->dvb[1].adap = adap; in dvb_register_adapters()
1360 for (i = 0; i < dev->port_num; i++) { in dvb_register_adapters()
1361 port = &dev->port[i]; in dvb_register_adapters()
1362 switch (port->class) { in dvb_register_adapters()
1364 adap = port->dvb[0].adap; in dvb_register_adapters()
1367 port->dev->dev, in dvb_register_adapters()
1371 port->dvb[0].adap_registered = 1; in dvb_register_adapters()
1374 port->dvb[1].adap = port->dvb[0].adap; in dvb_register_adapters()
1377 adap = port->dvb[1].adap; in dvb_register_adapters()
1380 port->dev->dev, in dvb_register_adapters()
1384 port->dvb[1].adap_registered = 1; in dvb_register_adapters()
1389 adap = port->dvb[0].adap; in dvb_register_adapters()
1392 port->dev->dev, in dvb_register_adapters()
1396 port->dvb[0].adap_registered = 1; in dvb_register_adapters()
1401 adap = port->dvb[0].adap; in dvb_register_adapters()
1404 port->dev->dev, in dvb_register_adapters()
1408 port->dvb[0].adap_registered = 1; in dvb_register_adapters()
1421 for (i = 0; i < dev->link[0].info->port_num; i++) { in dvb_unregister_adapters()
1422 port = &dev->port[i]; in dvb_unregister_adapters()
1424 dvb = &port->dvb[0]; in dvb_unregister_adapters()
1425 if (dvb->adap_registered) in dvb_unregister_adapters()
1426 dvb_unregister_adapter(dvb->adap); in dvb_unregister_adapters()
1427 dvb->adap_registered = 0; in dvb_unregister_adapters()
1429 dvb = &port->dvb[1]; in dvb_unregister_adapters()
1430 if (dvb->adap_registered) in dvb_unregister_adapters()
1431 dvb_unregister_adapter(dvb->adap); in dvb_unregister_adapters()
1432 dvb->adap_registered = 0; in dvb_unregister_adapters()
1439 struct ddb_dvb *dvb = &input->port->dvb[input->nr & 1]; in dvb_input_attach()
1440 struct ddb_port *port = input->port; in dvb_input_attach()
1441 struct dvb_adapter *adap = dvb->adap; in dvb_input_attach()
1442 struct dvb_demux *dvbdemux = &dvb->demux; in dvb_input_attach()
1443 struct ddb_ids *devids = &input->port->dev->link[input->port->lnr].ids; in dvb_input_attach()
1455 if (port->nr == 0 && in dvb_input_attach()
1456 (port->type == DDB_TUNER_DVBS_STV0910_PR || in dvb_input_attach()
1457 port->type == DDB_TUNER_DVBS_STV0910_P)) { in dvb_input_attach()
1459 if ((devids->hwid & 0x00ffffff) >= 0x00010007) in dvb_input_attach()
1463 dvb->attached = 0x01; in dvb_input_attach()
1465 dvbdemux->priv = input; in dvb_input_attach()
1466 dvbdemux->dmx.capabilities = DMX_TS_FILTERING | in dvb_input_attach()
1468 dvbdemux->start_feed = start_feed; in dvb_input_attach()
1469 dvbdemux->stop_feed = stop_feed; in dvb_input_attach()
1470 dvbdemux->filternum = 256; in dvb_input_attach()
1471 dvbdemux->feednum = 256; in dvb_input_attach()
1475 dvb->attached = 0x10; in dvb_input_attach()
1477 dvb->dmxdev.filternum = 256; in dvb_input_attach()
1478 dvb->dmxdev.demux = &dvbdemux->dmx; in dvb_input_attach()
1479 ret = dvb_dmxdev_init(&dvb->dmxdev, adap); in dvb_input_attach()
1482 dvb->attached = 0x11; in dvb_input_attach()
1484 dvb->mem_frontend.source = DMX_MEMORY_FE; in dvb_input_attach()
1485 dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->mem_frontend); in dvb_input_attach()
1486 dvb->hw_frontend.source = DMX_FRONTEND_0; in dvb_input_attach()
1487 dvb->demux.dmx.add_frontend(&dvb->demux.dmx, &dvb->hw_frontend); in dvb_input_attach()
1488 ret = dvbdemux->dmx.connect_frontend(&dvbdemux->dmx, &dvb->hw_frontend); in dvb_input_attach()
1491 dvb->attached = 0x12; in dvb_input_attach()
1493 ret = dvb_net_init(adap, &dvb->dvbnet, dvb->dmxdev.demux); in dvb_input_attach()
1496 dvb->attached = 0x20; in dvb_input_attach()
1498 dvb->fe = NULL; in dvb_input_attach()
1499 dvb->fe2 = NULL; in dvb_input_attach()
1500 switch (port->type) { in dvb_input_attach()
1544 if (tuner_attach_tda18212(input, port->type) < 0) in dvb_input_attach()
1548 if (input->port->dev->link[input->port->lnr].info->ts_quirks & in dvb_input_attach()
1557 if (input->port->dev->link[input->port->lnr].info->ts_quirks in dvb_input_attach()
1564 if (tuner_attach_tda18212(input, port->type) < 0) in dvb_input_attach()
1575 if (tuner_attach_tda18212(input, port->type) < 0) in dvb_input_attach()
1583 if (ddb_fe_attach_mci(input, port->type) < 0) in dvb_input_attach()
1589 dvb->attached = 0x30; in dvb_input_attach()
1591 if (dvb->fe) { in dvb_input_attach()
1592 if (dvb_register_frontend(adap, dvb->fe) < 0) in dvb_input_attach()
1595 if (dvb->fe2) { in dvb_input_attach()
1596 if (dvb_register_frontend(adap, dvb->fe2) < 0) { in dvb_input_attach()
1597 dvb_unregister_frontend(dvb->fe); in dvb_input_attach()
1600 dvb->fe2->tuner_priv = dvb->fe->tuner_priv; in dvb_input_attach()
1601 memcpy(&dvb->fe2->ops.tuner_ops, in dvb_input_attach()
1602 &dvb->fe->ops.tuner_ops, in dvb_input_attach()
1607 dvb->attached = 0x31; in dvb_input_attach()
1611 dev_err(port->dev->dev, "tuner attach failed!\n"); in dvb_input_attach()
1613 if (dvb->fe2) in dvb_input_attach()
1614 dvb_frontend_detach(dvb->fe2); in dvb_input_attach()
1615 if (dvb->fe) in dvb_input_attach()
1616 dvb_frontend_detach(dvb->fe); in dvb_input_attach()
1624 return -ENODEV; in dvb_input_attach()
1629 struct device *dev = port->dev->dev; in port_has_encti()
1631 int ret = i2c_read_reg(&port->i2c->adap, 0x20, 0, &val); in port_has_encti()
1642 struct i2c_msg msgs[2] = {{ .addr = 0x40, .flags = 0, in port_has_cxd()
1644 { .addr = 0x40, .flags = I2C_M_RD, in port_has_cxd()
1646 val = i2c_transfer(&port->i2c->adap, msgs, 2); in port_has_cxd()
1661 if (i2c_io(&port->i2c->adap, 0x10, probe, 1, data, 4)) in port_has_xo2()
1680 if (i2c_read_reg16(&port->i2c->adap, 0x69, 0xf100, &val) < 0) in port_has_stv0900()
1687 if (i2c_read_reg16(&port->i2c->adap, 0x68, 0xf100, id) < 0) in port_has_stv0900_aa()
1696 if (i2c_read(&port->i2c->adap, 0x29, &val) < 0) in port_has_drxks()
1698 if (i2c_read(&port->i2c->adap, 0x2a, &val) < 0) in port_has_drxks()
1707 if (i2c_read_reg16(&port->i2c->adap, 0x1e, 0xf000, &val) < 0) in port_has_stv0367()
1711 if (i2c_read_reg16(&port->i2c->adap, 0x1f, 0xf000, &val) < 0) in port_has_stv0367()
1720 struct i2c_adapter *i2c = &port->i2c->adap; in init_xo2()
1721 struct ddb *dev = port->dev; in init_xo2()
1730 dev_info(dev->dev, "Port %d: invalid XO2\n", port->nr); in init_xo2()
1731 return -1; in init_xo2()
1748 if (dev->link[port->lnr].info->con_clock) { in init_xo2()
1749 dev_info(dev->dev, "Setting continuous clock for XO2\n"); in init_xo2()
1766 struct i2c_adapter *i2c = &port->i2c->adap; in init_xo2_ci()
1767 struct ddb *dev = port->dev; in init_xo2_ci()
1776 dev_info(dev->dev, "Port %d: invalid XO2 CI %02x\n", in init_xo2_ci()
1777 port->nr, data[0]); in init_xo2_ci()
1778 return -1; in init_xo2_ci()
1780 dev_info(dev->dev, "Port %d: DuoFlex CI %u.%u\n", in init_xo2_ci()
1781 port->nr, data[0], data[1]); in init_xo2_ci()
1798 if (dev->link[port->lnr].info->con_clock) { in init_xo2_ci()
1799 dev_info(dev->dev, "Setting continuous clock for DuoFlex CI\n"); in init_xo2_ci()
1811 struct i2c_adapter *i2c = &port->i2c->adap; in port_has_cxd28xx()
1814 status = i2c_write_reg(&port->i2c->adap, 0x6e, 0, 0); in port_has_cxd28xx()
1824 "DUAL DVB-S2", "DUAL DVB-C/T/T2",
1825 "DUAL DVB-ISDBT", "DUAL DVB-C/C2/T/T2",
1826 "DUAL ATSC", "DUAL DVB-C/C2/T/T2,ISDB-T",
1838 struct ddb *dev = port->dev; in ddb_port_probe()
1839 u32 l = port->lnr; in ddb_port_probe()
1840 struct ddb_link *link = &dev->link[l]; in ddb_port_probe()
1843 port->name = "NO MODULE"; in ddb_port_probe()
1844 port->type_name = "NONE"; in ddb_port_probe()
1845 port->class = DDB_PORT_NONE; in ddb_port_probe()
1849 if (dummy_tuner && !port->nr && in ddb_port_probe()
1850 link->ids.device == 0x0005) { in ddb_port_probe()
1851 port->name = "DUMMY"; in ddb_port_probe()
1852 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1853 port->type = DDB_TUNER_DUMMY; in ddb_port_probe()
1854 port->type_name = "DUMMY"; in ddb_port_probe()
1858 if (port->nr == ts_loop) { in ddb_port_probe()
1859 port->name = "TS LOOP"; in ddb_port_probe()
1860 port->class = DDB_PORT_LOOP; in ddb_port_probe()
1864 if (port->nr == 1 && link->info->type == DDB_OCTOPUS_CI && in ddb_port_probe()
1865 link->info->i2c_mask == 1) { in ddb_port_probe()
1866 port->name = "NO TAB"; in ddb_port_probe()
1867 port->class = DDB_PORT_NONE; in ddb_port_probe()
1871 if (link->info->type == DDB_OCTOPUS_MAX) { in ddb_port_probe()
1872 port->name = "DUAL DVB-S2 MAX"; in ddb_port_probe()
1873 port->type_name = "MXL5XX"; in ddb_port_probe()
1874 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1875 port->type = DDB_TUNER_MXL5XX; in ddb_port_probe()
1876 if (port->i2c) in ddb_port_probe()
1878 port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1882 if (link->info->type == DDB_OCTOPUS_MCI) { in ddb_port_probe()
1883 if (port->nr >= link->info->mci_ports) in ddb_port_probe()
1885 port->name = "DUAL MCI"; in ddb_port_probe()
1886 port->type_name = "MCI"; in ddb_port_probe()
1887 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1888 port->type = DDB_TUNER_MCI + link->info->mci_type; in ddb_port_probe()
1892 if (port->nr > 1 && link->info->type == DDB_OCTOPUS_CI) { in ddb_port_probe()
1893 port->name = "CI internal"; in ddb_port_probe()
1894 port->type_name = "INTERNAL"; in ddb_port_probe()
1895 port->class = DDB_PORT_CI; in ddb_port_probe()
1896 port->type = DDB_CI_INTERNAL; in ddb_port_probe()
1899 if (!port->i2c) in ddb_port_probe()
1906 port->name = "CI"; in ddb_port_probe()
1907 port->type_name = "CXD2099"; in ddb_port_probe()
1908 port->class = DDB_PORT_CI; in ddb_port_probe()
1909 port->type = DDB_CI_EXTERNAL_SONY; in ddb_port_probe()
1911 port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1913 dev_info(dev->dev, "Port %d: Uninitialized DuoFlex\n", in ddb_port_probe()
1914 port->nr); in ddb_port_probe()
1918 ddbwritel(dev, I2C_SPEED_400, port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1919 /*dev_info(dev->dev, "XO2 ID %02x\n", id);*/ in ddb_port_probe()
1921 port->name = "DuoFlex CI"; in ddb_port_probe()
1922 port->class = DDB_PORT_CI; in ddb_port_probe()
1923 port->type = DDB_CI_EXTERNAL_XO2; in ddb_port_probe()
1924 port->type_name = "CI_XO2"; in ddb_port_probe()
1930 port->name = "unknown XO2 DuoFlex"; in ddb_port_probe()
1931 port->type_name = "UNKNOWN"; in ddb_port_probe()
1933 port->name = xo2names[id]; in ddb_port_probe()
1934 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1935 port->type = DDB_TUNER_XO2 + id; in ddb_port_probe()
1936 port->type_name = xo2types[id]; in ddb_port_probe()
1942 port->name = "DUAL DVB-C2T2 CXD2843"; in ddb_port_probe()
1943 port->type = DDB_TUNER_DVBC2T2_SONY_P; in ddb_port_probe()
1944 port->type_name = "DVBC2T2_SONY"; in ddb_port_probe()
1947 port->name = "DUAL DVB-CT2 CXD2837"; in ddb_port_probe()
1948 port->type = DDB_TUNER_DVBCT2_SONY_P; in ddb_port_probe()
1949 port->type_name = "DVBCT2_SONY"; in ddb_port_probe()
1952 port->name = "DUAL ISDB-T CXD2838"; in ddb_port_probe()
1953 port->type = DDB_TUNER_ISDBT_SONY_P; in ddb_port_probe()
1954 port->type_name = "ISDBT_SONY"; in ddb_port_probe()
1957 port->name = "DUAL DVB-C2T2 ISDB-T CXD2854"; in ddb_port_probe()
1958 port->type = DDB_TUNER_DVBC2T2I_SONY_P; in ddb_port_probe()
1959 port->type_name = "DVBC2T2I_ISDBT_SONY"; in ddb_port_probe()
1964 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1965 ddbwritel(dev, I2C_SPEED_400, port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1967 port->name = "DUAL DVB-S2"; in ddb_port_probe()
1968 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1969 port->type = DDB_TUNER_DVBS_ST; in ddb_port_probe()
1970 port->type_name = "DVBS_ST"; in ddb_port_probe()
1971 ddbwritel(dev, I2C_SPEED_100, port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1973 port->name = "DUAL DVB-S2"; in ddb_port_probe()
1974 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1976 if (port->nr == 0 && in ddb_port_probe()
1977 link->info->ts_quirks & TS_QUIRK_REVERSED) in ddb_port_probe()
1978 port->type = DDB_TUNER_DVBS_STV0910_PR; in ddb_port_probe()
1980 port->type = DDB_TUNER_DVBS_STV0910_P; in ddb_port_probe()
1981 port->type_name = "DVBS_ST_0910"; in ddb_port_probe()
1983 port->type = DDB_TUNER_DVBS_ST_AA; in ddb_port_probe()
1984 port->type_name = "DVBS_ST_AA"; in ddb_port_probe()
1986 ddbwritel(dev, I2C_SPEED_100, port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1988 port->name = "DUAL DVB-C/T"; in ddb_port_probe()
1989 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1990 port->type = DDB_TUNER_DVBCT_TR; in ddb_port_probe()
1991 port->type_name = "DVBCT_TR"; in ddb_port_probe()
1992 ddbwritel(dev, I2C_SPEED_400, port->i2c->regs + I2C_TIMING); in ddb_port_probe()
1994 port->name = "DUAL DVB-C/T"; in ddb_port_probe()
1995 port->class = DDB_PORT_TUNER; in ddb_port_probe()
1996 port->type = DDB_TUNER_DVBCT_ST; in ddb_port_probe()
1997 port->type_name = "DVBCT_ST"; in ddb_port_probe()
1998 ddbwritel(dev, I2C_SPEED_100, port->i2c->regs + I2C_TIMING); in ddb_port_probe()
2000 port->name = "ENCTI"; in ddb_port_probe()
2001 port->class = DDB_PORT_LOOP; in ddb_port_probe()
2013 switch (port->class) { in ddb_port_attach()
2015 ret = dvb_input_attach(port->input[0]); in ddb_port_attach()
2018 ret = dvb_input_attach(port->input[1]); in ddb_port_attach()
2020 dvb_input_detach(port->input[0]); in ddb_port_attach()
2023 port->input[0]->redi = port->input[0]; in ddb_port_attach()
2024 port->input[1]->redi = port->input[1]; in ddb_port_attach()
2032 ret = dvb_register_device(port->dvb[0].adap, in ddb_port_attach()
2033 &port->dvb[0].dev, in ddb_port_attach()
2034 &dvbdev_ci, (void *)port->output, in ddb_port_attach()
2041 dev_err(port->dev->dev, "port_attach on port %d failed\n", in ddb_port_attach()
2042 port->nr); in ddb_port_attach()
2051 if (dev->port_num) { in ddb_ports_attach()
2054 dev_err(dev->dev, "Registering adapters failed. Check DVB_MAX_ADAPTERS in config.\n"); in ddb_ports_attach()
2059 numports = dev->port_num; in ddb_ports_attach()
2061 for (i = 0; i < dev->port_num; i++) { in ddb_ports_attach()
2062 port = &dev->port[i]; in ddb_ports_attach()
2063 if (port->class != DDB_PORT_NONE) { in ddb_ports_attach()
2068 numports--; in ddb_ports_attach()
2074 dev_err(dev->dev, "All connected ports failed to initialise!\n"); in ddb_ports_attach()
2075 return -ENODEV; in ddb_ports_attach()
2078 dev_warn(dev->dev, "%d of %d connected ports failed to initialise!\n", in ddb_ports_attach()
2090 for (i = 0; i < dev->port_num; i++) { in ddb_ports_detach()
2091 port = &dev->port[i]; in ddb_ports_detach()
2093 switch (port->class) { in ddb_ports_detach()
2095 dvb_input_detach(port->input[1]); in ddb_ports_detach()
2096 dvb_input_detach(port->input[0]); in ddb_ports_detach()
2112 ddbwritel(output->port->dev, in input_write_output()
2113 input->dma->stat, DMA_BUFFER_ACK(output->dma)); in input_write_output()
2114 output->dma->cbuf = (input->dma->stat >> 11) & 0x1f; in input_write_output()
2115 output->dma->coff = (input->dma->stat & 0x7ff) << 7; in input_write_output()
2121 ddbwritel(input->port->dev, in output_ack_input()
2122 output->dma->stat, DMA_BUFFER_ACK(input->dma)); in output_ack_input()
2128 struct ddb_dvb *dvb = &input2->port->dvb[input2->nr & 1]; in input_write_dvb()
2130 struct ddb *dev = input->port->dev; in input_write_dvb()
2133 dma = input->dma; in input_write_dvb()
2134 dma2 = input->dma; in input_write_dvb()
2139 if (input->redo) { in input_write_dvb()
2140 dma2 = input->redo->dma; in input_write_dvb()
2143 while (dma->cbuf != ((dma->stat >> 11) & 0x1f) || in input_write_dvb()
2144 (4 & dma->ctrl)) { in input_write_dvb()
2145 if (4 & dma->ctrl) { in input_write_dvb()
2146 /* dev_err(dev->dev, "Overflow dma %d\n", dma->nr); */ in input_write_dvb()
2150 dma_sync_single_for_cpu(dev->dev, dma2->pbuf[dma->cbuf], in input_write_dvb()
2151 dma2->size, DMA_FROM_DEVICE); in input_write_dvb()
2152 dvb_dmx_swfilter_packets(&dvb->demux, in input_write_dvb()
2153 dma2->vbuf[dma->cbuf], in input_write_dvb()
2154 dma2->size / 188); in input_write_dvb()
2155 dma->cbuf = (dma->cbuf + 1) % dma2->num; in input_write_dvb()
2157 ddbwritel(dev, (dma->cbuf << 11), in input_write_dvb()
2159 dma->stat = safe_ddbreadl(dev, DMA_BUFFER_CURRENT(dma)); in input_write_dvb()
2160 dma->ctrl = safe_ddbreadl(dev, DMA_BUFFER_CONTROL(dma)); in input_write_dvb()
2167 struct ddb_input *input = (struct ddb_input *)dma->io; in input_work()
2168 struct ddb *dev = input->port->dev; in input_work()
2171 spin_lock_irqsave(&dma->lock, flags); in input_work()
2172 if (!dma->running) { in input_work()
2173 spin_unlock_irqrestore(&dma->lock, flags); in input_work()
2176 dma->stat = ddbreadl(dev, DMA_BUFFER_CURRENT(dma)); in input_work()
2177 dma->ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(dma)); in input_work()
2179 if (input->redi) in input_work()
2180 input_write_dvb(input, input->redi); in input_work()
2181 if (input->redo) in input_work()
2182 input_write_output(input, input->redo); in input_work()
2183 wake_up(&dma->wq); in input_work()
2184 spin_unlock_irqrestore(&dma->lock, flags); in input_work()
2190 struct ddb_dma *dma = input->dma; in input_handler()
2192 queue_work(ddb_wq, &dma->work); in input_handler()
2198 struct ddb_output *output = (struct ddb_output *)dma->io; in output_work()
2199 struct ddb *dev = output->port->dev; in output_work()
2202 spin_lock_irqsave(&dma->lock, flags); in output_work()
2203 if (!dma->running) in output_work()
2205 dma->stat = ddbreadl(dev, DMA_BUFFER_CURRENT(dma)); in output_work()
2206 dma->ctrl = ddbreadl(dev, DMA_BUFFER_CONTROL(dma)); in output_work()
2207 if (output->redi) in output_work()
2208 output_ack_input(output, output->redi); in output_work()
2209 wake_up(&dma->wq); in output_work()
2211 spin_unlock_irqrestore(&dma->lock, flags); in output_work()
2217 struct ddb_dma *dma = output->dma; in output_handler()
2219 queue_work(ddb_wq, &dma->work); in output_handler()
2230 info = io->port->dev->link[io->port->lnr].info; in io_regmap()
2232 info = io->port->dev->link[0].info; in io_regmap()
2237 return info->regmap; in io_regmap()
2245 dma = out ? &io->port->dev->odma[nr] : &io->port->dev->idma[nr]; in ddb_dma_init()
2246 io->dma = dma; in ddb_dma_init()
2247 dma->io = io; in ddb_dma_init()
2249 spin_lock_init(&dma->lock); in ddb_dma_init()
2250 init_waitqueue_head(&dma->wq); in ddb_dma_init()
2252 INIT_WORK(&dma->work, output_work); in ddb_dma_init()
2253 dma->regs = rm->odma->base + rm->odma->size * nr; in ddb_dma_init()
2254 dma->bufregs = rm->odma_buf->base + rm->odma_buf->size * nr; in ddb_dma_init()
2255 dma->num = dma_buf_num; in ddb_dma_init()
2256 dma->size = dma_buf_size * 128 * 47; in ddb_dma_init()
2257 dma->div = 1; in ddb_dma_init()
2259 INIT_WORK(&dma->work, input_work); in ddb_dma_init()
2260 dma->regs = rm->idma->base + rm->idma->size * nr; in ddb_dma_init()
2261 dma->bufregs = rm->idma_buf->base + rm->idma_buf->size * nr; in ddb_dma_init()
2262 dma->num = dma_buf_num; in ddb_dma_init()
2263 dma->size = dma_buf_size * 128 * 47; in ddb_dma_init()
2264 dma->div = 1; in ddb_dma_init()
2266 ddbwritel(io->port->dev, 0, DMA_BUFFER_ACK(dma)); in ddb_dma_init()
2267 dev_dbg(io->port->dev->dev, "init link %u, io %u, dma %u, dmaregs %08x bufregs %08x\n", in ddb_dma_init()
2268 io->port->lnr, io->nr, nr, dma->regs, dma->bufregs); in ddb_dma_init()
2273 struct ddb *dev = port->dev; in ddb_input_init()
2274 struct ddb_input *input = &dev->input[anr]; in ddb_input_init()
2277 port->input[pnr] = input; in ddb_input_init()
2278 input->nr = nr; in ddb_input_init()
2279 input->port = port; in ddb_input_init()
2281 input->regs = DDB_LINK_TAG(port->lnr) | in ddb_input_init()
2282 (rm->input->base + rm->input->size * nr); in ddb_input_init()
2283 dev_dbg(dev->dev, "init link %u, input %u, regs %08x\n", in ddb_input_init()
2284 port->lnr, nr, input->regs); in ddb_input_init()
2286 if (dev->has_dma) { in ddb_input_init()
2288 u32 base = rm0->irq_base_idma; in ddb_input_init()
2291 if (port->lnr) in ddb_input_init()
2292 dma_nr += 32 + (port->lnr - 1) * 8; in ddb_input_init()
2294 dev_dbg(dev->dev, "init link %u, input %u, handler %u\n", in ddb_input_init()
2295 port->lnr, nr, dma_nr + base); in ddb_input_init()
2304 struct ddb *dev = port->dev; in ddb_output_init()
2305 struct ddb_output *output = &dev->output[nr]; in ddb_output_init()
2308 port->output = output; in ddb_output_init()
2309 output->nr = nr; in ddb_output_init()
2310 output->port = port; in ddb_output_init()
2312 output->regs = DDB_LINK_TAG(port->lnr) | in ddb_output_init()
2313 (rm->output->base + rm->output->size * nr); in ddb_output_init()
2315 dev_dbg(dev->dev, "init link %u, output %u, regs %08x\n", in ddb_output_init()
2316 port->lnr, nr, output->regs); in ddb_output_init()
2318 if (dev->has_dma) { in ddb_output_init()
2320 u32 base = rm0->irq_base_odma; in ddb_output_init()
2329 struct ddb *dev = port->dev; in ddb_port_match_i2c()
2332 for (i = 0; i < dev->i2c_num; i++) { in ddb_port_match_i2c()
2333 if (dev->i2c[i].link == port->lnr && in ddb_port_match_i2c()
2334 dev->i2c[i].nr == port->nr) { in ddb_port_match_i2c()
2335 port->i2c = &dev->i2c[i]; in ddb_port_match_i2c()
2344 struct ddb *dev = port->dev; in ddb_port_match_link_i2c()
2347 for (i = 0; i < dev->i2c_num; i++) { in ddb_port_match_link_i2c()
2348 if (dev->i2c[i].link == port->lnr) { in ddb_port_match_link_i2c()
2349 port->i2c = &dev->i2c[i]; in ddb_port_match_link_i2c()
2364 info = dev->link[l].info; in ddb_ports_init()
2367 rm = info->regmap; in ddb_ports_init()
2370 for (i = 0; i < info->port_num; i++, p++) { in ddb_ports_init()
2371 port = &dev->port[p]; in ddb_ports_init()
2372 port->dev = dev; in ddb_ports_init()
2373 port->nr = i; in ddb_ports_init()
2374 port->lnr = l; in ddb_ports_init()
2375 port->pnr = p; in ddb_ports_init()
2376 port->gap = 0xffffffff; in ddb_ports_init()
2377 port->obr = ci_bitrate; in ddb_ports_init()
2378 mutex_init(&port->i2c_gate_lock); in ddb_ports_init()
2381 if (info->type == DDB_OCTOPUS_MAX) in ddb_ports_init()
2387 port->dvb[0].adap = &dev->adap[2 * p]; in ddb_ports_init()
2388 port->dvb[1].adap = &dev->adap[2 * p + 1]; in ddb_ports_init()
2390 if (port->class == DDB_PORT_NONE && i && p && in ddb_ports_init()
2391 dev->port[p - 1].type == DDB_CI_EXTERNAL_XO2) { in ddb_ports_init()
2392 port->class = DDB_PORT_CI; in ddb_ports_init()
2393 port->type = DDB_CI_EXTERNAL_XO2_B; in ddb_ports_init()
2394 port->name = "DuoFlex CI_B"; in ddb_ports_init()
2395 port->i2c = dev->port[p - 1].i2c; in ddb_ports_init()
2398 dev_info(dev->dev, "Port %u: Link %u, Link Port %u (TAB %u): %s\n", in ddb_ports_init()
2399 port->pnr, port->lnr, port->nr, port->nr + 1, in ddb_ports_init()
2400 port->name); in ddb_ports_init()
2402 if (port->class == DDB_PORT_CI && in ddb_ports_init()
2403 port->type == DDB_CI_EXTERNAL_XO2) { in ddb_ports_init()
2409 if (port->class == DDB_PORT_CI && in ddb_ports_init()
2410 port->type == DDB_CI_EXTERNAL_XO2_B) { in ddb_ports_init()
2411 ddb_input_init(port, 2 * i - 1, 0, 2 * i - 1); in ddb_ports_init()
2416 if (port->class == DDB_PORT_NONE) in ddb_ports_init()
2419 switch (dev->link[l].info->type) { in ddb_ports_init()
2444 dev->port_num = p; in ddb_ports_init()
2452 for (i = 0; i < dev->port_num; i++) { in ddb_ports_release()
2453 port = &dev->port[i]; in ddb_ports_release()
2454 if (port->input[0] && port->input[0]->dma) in ddb_ports_release()
2455 cancel_work_sync(&port->input[0]->dma->work); in ddb_ports_release()
2456 if (port->input[1] && port->input[1]->dma) in ddb_ports_release()
2457 cancel_work_sync(&port->input[1]->dma->work); in ddb_ports_release()
2458 if (port->output && port->output->dma) in ddb_ports_release()
2459 cancel_work_sync(&port->output->dma->work); in ddb_ports_release()
2469 dev->link[0].irq[_nr].handler) \
2470 dev->link[0].irq[_nr].handler(dev->link[0].irq[_nr].data); } \
2497 dev->i2c_irq++; in irq_handle_msg()
2503 dev->ts_irq++; in irq_handle_io()
2579 return -1; in reg_wait()
2589 struct ddb_link *link = &dev->link[lnr]; in flashio()
2591 mutex_lock(&link->flash_mutex); in flashio()
2595 /* FIXME: check for big-endian */ in flashio()
2598 wlen -= 4; in flashio()
2611 shift = ((4 - wlen) * 8); in flashio()
2615 wlen--; in flashio()
2638 rlen -= 4; in flashio()
2650 data <<= ((4 - rlen) * 8); in flashio()
2656 rlen--; in flashio()
2659 mutex_unlock(&link->flash_mutex); in flashio()
2662 mutex_unlock(&link->flash_mutex); in flashio()
2663 return -1; in flashio()
2666 int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len) in ddbridge_flashread() argument
2668 u8 cmd[4] = {0x03, (addr >> 16) & 0xff, in ddbridge_flashread()
2669 (addr >> 8) & 0xff, addr & 0xff}; in ddbridge_flashread()
2686 struct ddb *dev = file->private_data; in ddb_release()
2688 dev->ddb_dev_users--; in ddb_release()
2696 if (dev->ddb_dev_users) in ddb_open()
2697 return -EBUSY; in ddb_open()
2698 dev->ddb_dev_users++; in ddb_open()
2699 file->private_data = dev; in ddb_open()
2705 struct ddb *dev = file->private_data; in ddb_ioctl()
2707 dev_warn(dev->dev, "DDB IOCTLs unsupported (cmd: %d, arg: %lu)\n", in ddb_ioctl()
2710 return -ENOTTY; in ddb_ioctl()
2723 return kasprintf(GFP_KERNEL, "ddbridge/card%d", dev->nr); in ddb_devnode()
2741 return sprintf(buf, "%d\n", dev->port_num); in ports_show()
2749 return sprintf(buf, "%d\n", dev->ts_irq); in ts_irq_show()
2757 return sprintf(buf, "%d\n", dev->i2c_irq); in i2c_irq_show()
2777 return -EINVAL; in fan_store()
2787 int num = attr->attr.name[8] - 0x30; in fanspeed_show()
2788 struct ddb_link *link = &dev->link[num]; in fanspeed_show()
2799 struct ddb_link *link = &dev->link[0]; in temp_show()
2804 if (!link->info->temp_num) in temp_show()
2806 adap = &dev->i2c[link->info->temp_bus].adap; in temp_show()
2811 if (link->info->temp_num == 2) { in temp_show()
2828 int num = attr->attr.name[4] - 0x30; in ctemp_show()
2830 adap = &dev->i2c[num].adap; in ctemp_show()
2844 int num = attr->attr.name[3] - 0x30; in led_show()
2846 return sprintf(buf, "%d\n", dev->leds & (1 << num) ? 1 : 0); in led_show()
2851 if (!dev->link[0].info->led_num) in ddb_set_led()
2853 switch (dev->port[num].class) { in ddb_set_led()
2855 switch (dev->port[num].type) { in ddb_set_led()
2857 i2c_write_reg16(&dev->i2c[num].adap, in ddb_set_led()
2861 i2c_write_reg16(&dev->i2c[num].adap, in ddb_set_led()
2863 i2c_write_reg16(&dev->i2c[num].adap, in ddb_set_led()
2870 i2c_read_reg(&dev->i2c[num].adap, 0x10, 0x08, &v); in ddb_set_led()
2872 i2c_write_reg(&dev->i2c[num].adap, 0x10, 0x08, v); in ddb_set_led()
2887 int num = attr->attr.name[3] - 0x30; in led_store()
2891 return -EINVAL; in led_store()
2893 dev->leds |= (1 << num); in led_store()
2895 dev->leds &= ~(1 << num); in led_store()
2905 int num = attr->attr.name[3] - 0x30; in snr_show()
2907 if (dev->port[num].type >= DDB_TUNER_XO2) { in snr_show()
2908 if (i2c_read_regs(&dev->i2c[num].adap, 0x10, 0x10, snr, 16) < 0) in snr_show()
2912 /* serial number at 0x100-0x11f */ in snr_show()
2913 if (i2c_read_regs16(&dev->i2c[num].adap, in snr_show()
2915 if (i2c_read_regs16(&dev->i2c[num].adap, in snr_show()
2940 if (!dev->i2c_num) in bpsnr_show()
2943 if (i2c_read_regs16(&dev->i2c[0].adap, in bpsnr_show()
2965 return -EINVAL; in redirect_store()
2977 int num = attr->attr.name[3] - 0x30; in gap_show()
2979 return sprintf(buf, "%d\n", dev->port[num].gap); in gap_show()
2986 int num = attr->attr.name[3] - 0x30; in gap_store()
2990 return -EINVAL; in gap_store()
2992 return -EINVAL; in gap_store()
2995 dev->port[num].gap = val; in gap_store()
3005 dev->link[0].ids.hwid, dev->link[0].ids.regmapid); in version_show()
3013 return sprintf(buf, "0x%08X\n", dev->link[0].ids.hwid); in hwid_show()
3021 return sprintf(buf, "0x%08X\n", dev->link[0].ids.regmapid); in regmap_show()
3027 int num = attr->attr.name[5] - 0x30; in fmode_show()
3030 return sprintf(buf, "%u\n", dev->link[num].lnb.fmode); in fmode_show()
3036 int num = attr->attr.name[5] - 0x30; in devid_show()
3039 return sprintf(buf, "%08x\n", dev->link[num].ids.devid); in devid_show()
3046 int num = attr->attr.name[5] - 0x30; in fmode_store()
3050 return -EINVAL; in fmode_store()
3052 return -EINVAL; in fmode_store()
3053 ddb_lnb_init_fmode(dev, &dev->link[num], val); in fmode_store()
3129 return -1; in ddb_class_create()
3144 if (dev->link[i].info && dev->link[i].info->tempmon_irq) in ddb_device_attrs_del()
3145 device_remove_file(dev->ddb_dev, in ddb_device_attrs_del()
3147 for (i = 0; i < dev->link[0].info->temp_num; i++) in ddb_device_attrs_del()
3148 device_remove_file(dev->ddb_dev, &ddb_attrs_temp[i]); in ddb_device_attrs_del()
3149 for (i = 0; i < dev->link[0].info->fan_num; i++) in ddb_device_attrs_del()
3150 device_remove_file(dev->ddb_dev, &ddb_attrs_fan[i]); in ddb_device_attrs_del()
3151 for (i = 0; i < dev->i2c_num && i < 4; i++) { in ddb_device_attrs_del()
3152 if (dev->link[0].info->led_num) in ddb_device_attrs_del()
3153 device_remove_file(dev->ddb_dev, &ddb_attrs_led[i]); in ddb_device_attrs_del()
3154 device_remove_file(dev->ddb_dev, &ddb_attrs_snr[i]); in ddb_device_attrs_del()
3155 device_remove_file(dev->ddb_dev, &ddb_attrs_ctemp[i]); in ddb_device_attrs_del()
3158 device_remove_file(dev->ddb_dev, &ddb_attrs[i]); in ddb_device_attrs_del()
3166 if (device_create_file(dev->ddb_dev, &ddb_attrs[i])) in ddb_device_attrs_add()
3168 for (i = 0; i < dev->link[0].info->temp_num; i++) in ddb_device_attrs_add()
3169 if (device_create_file(dev->ddb_dev, &ddb_attrs_temp[i])) in ddb_device_attrs_add()
3171 for (i = 0; i < dev->link[0].info->fan_num; i++) in ddb_device_attrs_add()
3172 if (device_create_file(dev->ddb_dev, &ddb_attrs_fan[i])) in ddb_device_attrs_add()
3174 for (i = 0; (i < dev->i2c_num) && (i < 4); i++) { in ddb_device_attrs_add()
3175 if (device_create_file(dev->ddb_dev, &ddb_attrs_snr[i])) in ddb_device_attrs_add()
3177 if (device_create_file(dev->ddb_dev, &ddb_attrs_ctemp[i])) in ddb_device_attrs_add()
3179 if (dev->link[0].info->led_num) in ddb_device_attrs_add()
3180 if (device_create_file(dev->ddb_dev, in ddb_device_attrs_add()
3185 if (dev->link[i].info && dev->link[i].info->tempmon_irq) in ddb_device_attrs_add()
3186 if (device_create_file(dev->ddb_dev, in ddb_device_attrs_add()
3191 return -1; in ddb_device_attrs_add()
3199 return -ENOMEM; in ddb_device_create()
3201 dev->nr = ddb_num; in ddb_device_create()
3202 ddbs[dev->nr] = dev; in ddb_device_create()
3203 dev->ddb_dev = device_create(&ddb_class, dev->dev, in ddb_device_create()
3204 MKDEV(ddb_major, dev->nr), in ddb_device_create()
3205 dev, "ddbridge%d", dev->nr); in ddb_device_create()
3206 if (IS_ERR(dev->ddb_dev)) { in ddb_device_create()
3207 res = PTR_ERR(dev->ddb_dev); in ddb_device_create()
3208 dev_info(dev->dev, "Could not create ddbridge%d\n", dev->nr); in ddb_device_create()
3214 device_destroy(&ddb_class, MKDEV(ddb_major, dev->nr)); in ddb_device_create()
3215 ddbs[dev->nr] = NULL; in ddb_device_create()
3216 dev->ddb_dev = ERR_PTR(-ENODEV); in ddb_device_create()
3227 if (IS_ERR(dev->ddb_dev)) in ddb_device_destroy()
3230 device_destroy(&ddb_class, MKDEV(ddb_major, dev->nr)); in ddb_device_destroy()
3243 dev_info(link->dev->dev, "Over temperature condition\n"); in tempmon_setfan()
3244 link->overtemperature_error = 1; in tempmon_setfan()
3259 if (temp >= link->temp_tab[pwm]) { in tempmon_setfan()
3260 while (pwm < 10 && temp >= link->temp_tab[pwm + 1]) in tempmon_setfan()
3263 while (pwm > 1 && temp < link->temp_tab[pwm - 2]) in tempmon_setfan()
3264 pwm -= 1; in tempmon_setfan()
3273 spin_lock(&link->temp_lock); in temp_handler()
3275 spin_unlock(&link->temp_lock); in temp_handler()
3280 struct ddb *dev = link->dev; in tempmon_init()
3282 u32 l = link->nr; in tempmon_init()
3284 spin_lock_irq(&link->temp_lock); in tempmon_init()
3289 memcpy(link->temp_tab, temperature_table, in tempmon_init()
3292 ddb_irq_set(dev, l, link->info->tempmon_irq, temp_handler, link); in tempmon_init()
3298 link->overtemperature_error = in tempmon_init()
3301 if (link->overtemperature_error) { in tempmon_init()
3302 dev_info(link->dev->dev, "Over temperature condition\n"); in tempmon_init()
3303 status = -1; in tempmon_init()
3306 spin_unlock_irq(&link->temp_lock); in tempmon_init()
3312 const struct ddb_info *info = link->info; in ddb_init_tempmon()
3314 if (!info->tempmon_irq) in ddb_init_tempmon()
3316 if (info->type == DDB_OCTOPUS_MAX_CT) in ddb_init_tempmon()
3317 if (link->ids.regmapid < 0x00010002) in ddb_init_tempmon()
3319 spin_lock_init(&link->temp_lock); in ddb_init_tempmon()
3320 dev_dbg(link->dev->dev, "init_tempmon\n"); in ddb_init_tempmon()
3335 link = &dev->link[l]; in ddb_init_boards()
3336 info = link->info; in ddb_init_boards()
3340 if (info->board_control) { in ddb_init_boards()
3343 ddbwritel(dev, info->board_control_2, in ddb_init_boards()
3347 info->board_control_2 | info->board_control, in ddb_init_boards()
3358 mutex_init(&dev->link[0].lnb.lock); in ddb_init()
3359 mutex_init(&dev->link[0].flash_mutex); in ddb_init()
3371 dev_info(dev->dev, "Could not allocate buffer memory\n"); in ddb_init()
3379 if (dev->link[0].info->fan_num) { in ddb_init()
3386 dev_err(dev->dev, "fail3\n"); in ddb_init()
3390 dev_err(dev->dev, "fail2\n"); in ddb_init()
3394 dev_err(dev->dev, "fail1\n"); in ddb_init()
3395 return -1; in ddb_init()
3400 if (dev->regs) in ddb_unmap()
3401 iounmap(dev->regs); in ddb_unmap()
3432 return -1; in ddb_init_ddbridge()
3435 return ddb_exit_ddbridge(1, -1); in ddb_init_ddbridge()