Lines Matching refs:cobalt

86 static void cobalt_set_interrupt(struct cobalt *cobalt, bool enable)  in cobalt_set_interrupt()  argument
103 if (cobalt->have_hsma_rx) in cobalt_set_interrupt()
108 if (cobalt->have_hsma_tx) in cobalt_set_interrupt()
113 cobalt_write_bar1(cobalt, COBALT_SYS_STAT_EDGE, 0xffffffff); in cobalt_set_interrupt()
116 cobalt_write_bar1(cobalt, COBALT_SYS_STAT_MASK, irqs); in cobalt_set_interrupt()
119 cobalt_write_bar1(cobalt, COBALT_SYS_STAT_MASK, 0); in cobalt_set_interrupt()
125 struct cobalt *cobalt = to_cobalt(sd->v4l2_dev); in cobalt_get_sd_nr() local
129 if (sd == cobalt->streams[i].sd) in cobalt_get_sd_nr()
138 struct cobalt *cobalt = to_cobalt(sd->v4l2_dev); in cobalt_notify() local
140 struct cobalt_stream *s = &cobalt->streams[sd_nr]; in cobalt_notify()
148 cobalt_s_bit_sysctrl(cobalt, in cobalt_notify()
185 void cobalt_pcie_status_show(struct cobalt *cobalt) in cobalt_pcie_status_show() argument
187 struct pci_dev *pci_dev = cobalt->pci_dev; in cobalt_pcie_status_show()
188 struct pci_dev *pci_bus_dev = cobalt->pci_dev->bus->self; in cobalt_pcie_status_show()
234 static unsigned pcie_link_get_lanes(struct cobalt *cobalt) in pcie_link_get_lanes() argument
236 struct pci_dev *pci_dev = cobalt->pci_dev; in pcie_link_get_lanes()
245 static unsigned pcie_bus_link_get_lanes(struct cobalt *cobalt) in pcie_bus_link_get_lanes() argument
247 struct pci_dev *pci_dev = cobalt->pci_dev->bus->self; in pcie_bus_link_get_lanes()
256 static void msi_config_show(struct cobalt *cobalt, struct pci_dev *pci_dev) in msi_config_show() argument
278 static void cobalt_pci_iounmap(struct cobalt *cobalt, struct pci_dev *pci_dev) in cobalt_pci_iounmap() argument
280 if (cobalt->bar0) { in cobalt_pci_iounmap()
281 pci_iounmap(pci_dev, cobalt->bar0); in cobalt_pci_iounmap()
282 cobalt->bar0 = NULL; in cobalt_pci_iounmap()
284 if (cobalt->bar1) { in cobalt_pci_iounmap()
285 pci_iounmap(pci_dev, cobalt->bar1); in cobalt_pci_iounmap()
286 cobalt->bar1 = NULL; in cobalt_pci_iounmap()
290 static void cobalt_free_msi(struct cobalt *cobalt, struct pci_dev *pci_dev) in cobalt_free_msi() argument
292 free_irq(pci_dev->irq, (void *)cobalt); in cobalt_free_msi()
296 static int cobalt_setup_pci(struct cobalt *cobalt, struct pci_dev *pci_dev, in cobalt_setup_pci() argument
310 pci_read_config_byte(pci_dev, PCI_CLASS_REVISION, &cobalt->card_rev); in cobalt_setup_pci()
311 pci_read_config_word(pci_dev, PCI_DEVICE_ID, &cobalt->device_id); in cobalt_setup_pci()
313 switch (cobalt->device_id) { in cobalt_setup_pci()
322 if (pcie_link_get_lanes(cobalt) != 8) { in cobalt_setup_pci()
324 pcie_link_get_lanes(cobalt)); in cobalt_setup_pci()
325 if (pcie_bus_link_get_lanes(cobalt) < 8) in cobalt_setup_pci()
327 pcie_bus_link_get_lanes(cobalt)); in cobalt_setup_pci()
328 if (pcie_link_get_lanes(cobalt) != pcie_bus_link_get_lanes(cobalt)) { in cobalt_setup_pci()
349 cobalt_pcie_status_show(cobalt); in cobalt_setup_pci()
351 cobalt->bar0 = pci_iomap(pci_dev, 0, 0); in cobalt_setup_pci()
352 cobalt->bar1 = pci_iomap(pci_dev, 1, 0); in cobalt_setup_pci()
353 if (cobalt->bar1 == NULL) { in cobalt_setup_pci()
354 cobalt->bar1 = pci_iomap(pci_dev, 2, 0); in cobalt_setup_pci()
357 if (!cobalt->bar0 || !cobalt->bar1) { in cobalt_setup_pci()
363 ctrl = cobalt_read_bar1(cobalt, COBALT_SYS_CTRL_BASE); in cobalt_setup_pci()
364 cobalt_write_bar1(cobalt, COBALT_SYS_CTRL_BASE, ctrl & ~0xf00); in cobalt_setup_pci()
368 cobalt_set_interrupt(cobalt, false); in cobalt_setup_pci()
375 msi_config_show(cobalt, pci_dev); in cobalt_setup_pci()
379 cobalt->v4l2_dev.name, (void *)cobalt)) { in cobalt_setup_pci()
385 omni_sg_dma_init(cobalt); in cobalt_setup_pci()
392 cobalt_pci_iounmap(cobalt, pci_dev); in cobalt_setup_pci()
396 pci_disable_device(cobalt->pci_dev); in cobalt_setup_pci()
400 static int cobalt_hdl_info_get(struct cobalt *cobalt) in cobalt_hdl_info_get() argument
405 cobalt->hdl_info[i] = in cobalt_hdl_info_get()
406 ioread8(cobalt->bar1 + COBALT_HDL_INFO_BASE + i); in cobalt_hdl_info_get()
407 cobalt->hdl_info[COBALT_HDL_INFO_SIZE - 1] = '\0'; in cobalt_hdl_info_get()
408 if (strstr(cobalt->hdl_info, COBALT_HDL_SEARCH_STR)) in cobalt_hdl_info_get()
414 static void cobalt_stream_struct_init(struct cobalt *cobalt) in cobalt_stream_struct_init() argument
419 struct cobalt_stream *s = &cobalt->streams[i]; in cobalt_stream_struct_init()
421 s->cobalt = cobalt; in cobalt_stream_struct_init()
432 s->dma_channel = i + cobalt->first_fifo_channel; in cobalt_stream_struct_init()
467 static int cobalt_subdevs_init(struct cobalt *cobalt) in cobalt_subdevs_init() argument
489 struct cobalt_stream *s = cobalt->streams; in cobalt_subdevs_init()
507 s[i].i2c_adap = &cobalt->i2c_adap[i]; in cobalt_subdevs_init()
510 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_init()
512 s[i].sd = v4l2_i2c_new_subdev_board(&cobalt->v4l2_dev, in cobalt_subdevs_init()
532 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_init()
535 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_init()
539 cobalt->streams[i + COBALT_AUDIO_IN_STREAM].is_dummy = false; in cobalt_subdevs_init()
544 static int cobalt_subdevs_hsma_init(struct cobalt *cobalt) in cobalt_subdevs_hsma_init() argument
597 struct cobalt_stream *s = &cobalt->streams[COBALT_HSMA_IN_NODE]; in cobalt_subdevs_hsma_init()
599 s->i2c_adap = &cobalt->i2c_adap[COBALT_NUM_ADAPTERS - 1]; in cobalt_subdevs_hsma_init()
602 cobalt_s_bit_sysctrl(cobalt, COBALT_SYS_CTRL_NRESET_TO_HDMI_BIT(4), 1); in cobalt_subdevs_hsma_init()
604 s->sd = v4l2_i2c_new_subdev_board(&cobalt->v4l2_dev, in cobalt_subdevs_hsma_init()
615 cobalt->have_hsma_rx = true; in cobalt_subdevs_hsma_init()
618 cobalt->streams[4 + COBALT_AUDIO_IN_STREAM].is_dummy = false; in cobalt_subdevs_hsma_init()
620 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_hsma_init()
623 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_hsma_init()
628 cobalt_s_bit_sysctrl(cobalt, COBALT_SYS_CTRL_NRESET_TO_HDMI_BIT(4), 0); in cobalt_subdevs_hsma_init()
629 cobalt_s_bit_sysctrl(cobalt, COBALT_SYS_CTRL_PWRDN0_TO_HSMA_TX_BIT, 0); in cobalt_subdevs_hsma_init()
631 s->i2c_adap = &cobalt->i2c_adap[COBALT_NUM_ADAPTERS - 1]; in cobalt_subdevs_hsma_init()
632 s->sd = v4l2_i2c_new_subdev_board(&cobalt->v4l2_dev, in cobalt_subdevs_hsma_init()
636 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_hsma_init()
638 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_hsma_init()
640 cobalt_s_bit_sysctrl(cobalt, in cobalt_subdevs_hsma_init()
642 cobalt->have_hsma_tx = true; in cobalt_subdevs_hsma_init()
649 cobalt->streams[COBALT_AUDIO_OUT_STREAM].is_dummy = false; in cobalt_subdevs_hsma_init()
658 struct cobalt *cobalt; in cobalt_probe() local
665 cobalt = kzalloc(sizeof(struct cobalt), GFP_KERNEL); in cobalt_probe()
666 if (cobalt == NULL) in cobalt_probe()
668 cobalt->pci_dev = pci_dev; in cobalt_probe()
669 cobalt->instance = i; in cobalt_probe()
670 mutex_init(&cobalt->pci_lock); in cobalt_probe()
672 retval = v4l2_device_register(&pci_dev->dev, &cobalt->v4l2_dev); in cobalt_probe()
675 cobalt->instance); in cobalt_probe()
676 kfree(cobalt); in cobalt_probe()
679 snprintf(cobalt->v4l2_dev.name, sizeof(cobalt->v4l2_dev.name), in cobalt_probe()
680 "cobalt-%d", cobalt->instance); in cobalt_probe()
681 cobalt->v4l2_dev.notify = cobalt_notify; in cobalt_probe()
682 cobalt_info("Initializing card %d\n", cobalt->instance); in cobalt_probe()
684 cobalt->irq_work_queues = in cobalt_probe()
685 create_singlethread_workqueue(cobalt->v4l2_dev.name); in cobalt_probe()
686 if (cobalt->irq_work_queues == NULL) { in cobalt_probe()
692 INIT_WORK(&cobalt->irq_work_queue, cobalt_irq_work_handler); in cobalt_probe()
695 retval = cobalt_setup_pci(cobalt, pci_dev, pci_id); in cobalt_probe()
700 if (cobalt_hdl_info_get(cobalt)) in cobalt_probe()
703 cobalt_info("%s", cobalt->hdl_info); in cobalt_probe()
705 retval = cobalt_i2c_init(cobalt); in cobalt_probe()
709 cobalt_stream_struct_init(cobalt); in cobalt_probe()
711 retval = cobalt_subdevs_init(cobalt); in cobalt_probe()
715 if (!(cobalt_read_bar1(cobalt, COBALT_SYS_STAT_BASE) & in cobalt_probe()
717 retval = cobalt_subdevs_hsma_init(cobalt); in cobalt_probe()
722 retval = cobalt_nodes_register(cobalt); in cobalt_probe()
727 cobalt_set_interrupt(cobalt, true); in cobalt_probe()
728 v4l2_device_call_all(&cobalt->v4l2_dev, 0, core, in cobalt_probe()
733 cobalt_flash_probe(cobalt); in cobalt_probe()
738 cobalt_i2c_exit(cobalt); in cobalt_probe()
739 cobalt_s_bit_sysctrl(cobalt, COBALT_SYS_CTRL_HSMA_TX_ENABLE_BIT, 0); in cobalt_probe()
741 cobalt_free_msi(cobalt, pci_dev); in cobalt_probe()
742 cobalt_pci_iounmap(cobalt, pci_dev); in cobalt_probe()
743 pci_release_regions(cobalt->pci_dev); in cobalt_probe()
744 pci_disable_device(cobalt->pci_dev); in cobalt_probe()
746 destroy_workqueue(cobalt->irq_work_queues); in cobalt_probe()
750 v4l2_device_unregister(&cobalt->v4l2_dev); in cobalt_probe()
751 kfree(cobalt); in cobalt_probe()
758 struct cobalt *cobalt = to_cobalt(v4l2_dev); in cobalt_remove() local
761 cobalt_flash_remove(cobalt); in cobalt_remove()
762 cobalt_set_interrupt(cobalt, false); in cobalt_remove()
763 flush_workqueue(cobalt->irq_work_queues); in cobalt_remove()
764 cobalt_nodes_unregister(cobalt); in cobalt_remove()
766 struct v4l2_subdev *sd = cobalt->streams[i].sd; in cobalt_remove()
775 cobalt_i2c_exit(cobalt); in cobalt_remove()
776 cobalt_free_msi(cobalt, pci_dev); in cobalt_remove()
777 cobalt_s_bit_sysctrl(cobalt, COBALT_SYS_CTRL_HSMA_TX_ENABLE_BIT, 0); in cobalt_remove()
778 cobalt_pci_iounmap(cobalt, pci_dev); in cobalt_remove()
779 pci_release_regions(cobalt->pci_dev); in cobalt_remove()
780 pci_disable_device(cobalt->pci_dev); in cobalt_remove()
781 destroy_workqueue(cobalt->irq_work_queues); in cobalt_remove()
786 kfree(cobalt); in cobalt_remove()