Lines Matching refs:devinfo
351 u16 (*read_ptr)(struct brcmf_pciedev_info *devinfo, u32 mem_offset);
352 void (*write_ptr)(struct brcmf_pciedev_info *devinfo, u32 mem_offset,
368 struct brcmf_pciedev_info *devinfo; member
460 brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo);
462 brcmf_pcie_fwcon_timer(struct brcmf_pciedev_info *devinfo, bool active);
466 brcmf_pcie_read_reg16(struct brcmf_pciedev_info *devinfo, u32 reg_offset) in brcmf_pcie_read_reg16() argument
468 void __iomem *address = devinfo->regs + reg_offset; in brcmf_pcie_read_reg16()
474 brcmf_pcie_read_reg32(struct brcmf_pciedev_info *devinfo, u32 reg_offset) in brcmf_pcie_read_reg32() argument
476 void __iomem *address = devinfo->regs + reg_offset; in brcmf_pcie_read_reg32()
483 brcmf_pcie_write_reg32(struct brcmf_pciedev_info *devinfo, u32 reg_offset, in brcmf_pcie_write_reg32() argument
486 void __iomem *address = devinfo->regs + reg_offset; in brcmf_pcie_write_reg32()
493 brcmf_pcie_read_tcm8(struct brcmf_pciedev_info *devinfo, u32 mem_offset) in brcmf_pcie_read_tcm8() argument
495 void __iomem *address = devinfo->tcm + mem_offset; in brcmf_pcie_read_tcm8()
502 brcmf_pcie_read_tcm16(struct brcmf_pciedev_info *devinfo, u32 mem_offset) in brcmf_pcie_read_tcm16() argument
504 void __iomem *address = devinfo->tcm + mem_offset; in brcmf_pcie_read_tcm16()
511 brcmf_pcie_write_tcm16(struct brcmf_pciedev_info *devinfo, u32 mem_offset, in brcmf_pcie_write_tcm16() argument
514 void __iomem *address = devinfo->tcm + mem_offset; in brcmf_pcie_write_tcm16()
521 brcmf_pcie_read_idx(struct brcmf_pciedev_info *devinfo, u32 mem_offset) in brcmf_pcie_read_idx() argument
523 u16 *address = devinfo->idxbuf + mem_offset; in brcmf_pcie_read_idx()
530 brcmf_pcie_write_idx(struct brcmf_pciedev_info *devinfo, u32 mem_offset, in brcmf_pcie_write_idx() argument
533 u16 *address = devinfo->idxbuf + mem_offset; in brcmf_pcie_write_idx()
540 brcmf_pcie_read_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset) in brcmf_pcie_read_tcm32() argument
542 void __iomem *address = devinfo->tcm + mem_offset; in brcmf_pcie_read_tcm32()
549 brcmf_pcie_write_tcm32(struct brcmf_pciedev_info *devinfo, u32 mem_offset, in brcmf_pcie_write_tcm32() argument
552 void __iomem *address = devinfo->tcm + mem_offset; in brcmf_pcie_write_tcm32()
559 brcmf_pcie_read_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset) in brcmf_pcie_read_ram32() argument
561 void __iomem *addr = devinfo->tcm + devinfo->ci->rambase + mem_offset; in brcmf_pcie_read_ram32()
568 brcmf_pcie_write_ram32(struct brcmf_pciedev_info *devinfo, u32 mem_offset, in brcmf_pcie_write_ram32() argument
571 void __iomem *addr = devinfo->tcm + devinfo->ci->rambase + mem_offset; in brcmf_pcie_write_ram32()
578 brcmf_pcie_copy_dev_tomem(struct brcmf_pciedev_info *devinfo, u32 mem_offset, in brcmf_pcie_copy_dev_tomem() argument
581 void __iomem *address = devinfo->tcm + mem_offset; in brcmf_pcie_copy_dev_tomem()
618 #define READCC32(devinfo, reg) brcmf_pcie_read_reg32(devinfo, \ argument
620 #define WRITECC32(devinfo, reg, value) brcmf_pcie_write_reg32(devinfo, \ argument
625 brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid) in brcmf_pcie_select_core() argument
627 const struct pci_dev *pdev = devinfo->pdev; in brcmf_pcie_select_core()
632 core = brcmf_chip_get_core(devinfo->ci, coreid); in brcmf_pcie_select_core()
651 static void brcmf_pcie_reset_device(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_reset_device() argument
669 if (!devinfo->ci) in brcmf_pcie_reset_device()
673 brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); in brcmf_pcie_reset_device()
674 pci_read_config_dword(devinfo->pdev, BRCMF_PCIE_REG_LINK_STATUS_CTRL, in brcmf_pcie_reset_device()
677 pci_write_config_dword(devinfo->pdev, BRCMF_PCIE_REG_LINK_STATUS_CTRL, in brcmf_pcie_reset_device()
681 brcmf_pcie_select_core(devinfo, BCMA_CORE_CHIPCOMMON); in brcmf_pcie_reset_device()
682 WRITECC32(devinfo, watchdog, 4); in brcmf_pcie_reset_device()
686 brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); in brcmf_pcie_reset_device()
687 pci_write_config_dword(devinfo->pdev, BRCMF_PCIE_REG_LINK_STATUS_CTRL, in brcmf_pcie_reset_device()
690 core = brcmf_chip_get_core(devinfo->ci, BCMA_CORE_PCIE2); in brcmf_pcie_reset_device()
693 brcmf_pcie_write_reg32(devinfo, in brcmf_pcie_reset_device()
696 val = brcmf_pcie_read_reg32(devinfo, in brcmf_pcie_reset_device()
700 brcmf_pcie_write_reg32(devinfo, in brcmf_pcie_reset_device()
708 static void brcmf_pcie_attach(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_attach() argument
713 brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); in brcmf_pcie_attach()
714 brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_CONFIGADDR, 0x4e0); in brcmf_pcie_attach()
715 config = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_CONFIGDATA); in brcmf_pcie_attach()
716 brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_CONFIGDATA, config); in brcmf_pcie_attach()
718 device_wakeup_enable(&devinfo->pdev->dev); in brcmf_pcie_attach()
722 static int brcmf_pcie_enter_download_state(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_enter_download_state() argument
724 if (devinfo->ci->chip == BRCM_CC_43602_CHIP_ID) { in brcmf_pcie_enter_download_state()
725 brcmf_pcie_select_core(devinfo, BCMA_CORE_ARM_CR4); in brcmf_pcie_enter_download_state()
726 brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_ARMCR4REG_BANKIDX, in brcmf_pcie_enter_download_state()
728 brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_ARMCR4REG_BANKPDA, in brcmf_pcie_enter_download_state()
730 brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_ARMCR4REG_BANKIDX, in brcmf_pcie_enter_download_state()
732 brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_ARMCR4REG_BANKPDA, in brcmf_pcie_enter_download_state()
739 static int brcmf_pcie_exit_download_state(struct brcmf_pciedev_info *devinfo, in brcmf_pcie_exit_download_state() argument
744 if (devinfo->ci->chip == BRCM_CC_43602_CHIP_ID) { in brcmf_pcie_exit_download_state()
745 core = brcmf_chip_get_core(devinfo->ci, BCMA_CORE_INTERNAL_MEM); in brcmf_pcie_exit_download_state()
749 if (!brcmf_chip_set_active(devinfo->ci, resetintr)) in brcmf_pcie_exit_download_state()
756 brcmf_pcie_send_mb_data(struct brcmf_pciedev_info *devinfo, u32 htod_mb_data) in brcmf_pcie_send_mb_data() argument
764 shared = &devinfo->shared; in brcmf_pcie_send_mb_data()
766 cur_htod_mb_data = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_send_mb_data()
778 cur_htod_mb_data = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_send_mb_data()
781 brcmf_pcie_write_tcm32(devinfo, addr, htod_mb_data); in brcmf_pcie_send_mb_data()
782 pci_write_config_dword(devinfo->pdev, BRCMF_PCIE_REG_SBMBX, 1); in brcmf_pcie_send_mb_data()
785 core = brcmf_chip_get_core(devinfo->ci, BCMA_CORE_PCIE2); in brcmf_pcie_send_mb_data()
787 pci_write_config_dword(devinfo->pdev, BRCMF_PCIE_REG_SBMBX, 1); in brcmf_pcie_send_mb_data()
793 static void brcmf_pcie_handle_mb_data(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_handle_mb_data() argument
799 shared = &devinfo->shared; in brcmf_pcie_handle_mb_data()
801 dtoh_mb_data = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_handle_mb_data()
806 brcmf_pcie_write_tcm32(devinfo, addr, 0); in brcmf_pcie_handle_mb_data()
811 brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_DS_ACK); in brcmf_pcie_handle_mb_data()
818 devinfo->mbdata_completed = true; in brcmf_pcie_handle_mb_data()
819 wake_up(&devinfo->mbdata_resp_wait); in brcmf_pcie_handle_mb_data()
823 brcmf_fw_crashed(&devinfo->pdev->dev); in brcmf_pcie_handle_mb_data()
828 static void brcmf_pcie_bus_console_init(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_bus_console_init() argument
834 shared = &devinfo->shared; in brcmf_pcie_bus_console_init()
837 console->base_addr = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_bus_console_init()
840 console->buf_addr = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_bus_console_init()
842 console->bufsize = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_bus_console_init()
854 static void brcmf_pcie_bus_console_read(struct brcmf_pciedev_info *devinfo, in brcmf_pcie_bus_console_read() argument
857 struct pci_dev *pdev = devinfo->pdev; in brcmf_pcie_bus_console_read()
867 console = &devinfo->shared.console; in brcmf_pcie_bus_console_read()
871 newidx = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_bus_console_read()
874 ch = brcmf_pcie_read_tcm8(devinfo, addr); in brcmf_pcie_bus_console_read()
901 static void brcmf_pcie_intr_disable(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_intr_disable() argument
903 brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxmask, 0); in brcmf_pcie_intr_disable()
907 static void brcmf_pcie_intr_enable(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_intr_enable() argument
909 brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxmask, in brcmf_pcie_intr_enable()
910 devinfo->reginfo->int_d2h_db | in brcmf_pcie_intr_enable()
911 devinfo->reginfo->int_fn0); in brcmf_pcie_intr_enable()
914 static void brcmf_pcie_hostready(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_hostready() argument
916 if (devinfo->shared.flags & BRCMF_PCIE_SHARED_HOSTRDY_DB1) in brcmf_pcie_hostready()
917 brcmf_pcie_write_reg32(devinfo, in brcmf_pcie_hostready()
918 devinfo->reginfo->h2d_mailbox_1, 1); in brcmf_pcie_hostready()
923 struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)arg; in brcmf_pcie_quick_check_isr() local
925 if (brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->mailboxint)) { in brcmf_pcie_quick_check_isr()
926 brcmf_pcie_intr_disable(devinfo); in brcmf_pcie_quick_check_isr()
936 struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)arg; in brcmf_pcie_isr_thread() local
939 devinfo->in_irq = true; in brcmf_pcie_isr_thread()
940 status = brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->mailboxint); in brcmf_pcie_isr_thread()
943 brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxint, in brcmf_pcie_isr_thread()
945 if (status & devinfo->reginfo->int_fn0) in brcmf_pcie_isr_thread()
946 brcmf_pcie_handle_mb_data(devinfo); in brcmf_pcie_isr_thread()
947 if (status & devinfo->reginfo->int_d2h_db) { in brcmf_pcie_isr_thread()
948 if (devinfo->state == BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_isr_thread()
950 &devinfo->pdev->dev); in brcmf_pcie_isr_thread()
953 brcmf_pcie_bus_console_read(devinfo, false); in brcmf_pcie_isr_thread()
954 if (devinfo->state == BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_isr_thread()
955 brcmf_pcie_intr_enable(devinfo); in brcmf_pcie_isr_thread()
956 devinfo->in_irq = false; in brcmf_pcie_isr_thread()
961 static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_request_irq() argument
963 struct pci_dev *pdev = devinfo->pdev; in brcmf_pcie_request_irq()
966 brcmf_pcie_intr_disable(devinfo); in brcmf_pcie_request_irq()
973 "brcmf_pcie_intr", devinfo)) { in brcmf_pcie_request_irq()
978 devinfo->irq_allocated = true; in brcmf_pcie_request_irq()
983 static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_release_irq() argument
985 struct pci_dev *pdev = devinfo->pdev; in brcmf_pcie_release_irq()
990 if (!devinfo->irq_allocated) in brcmf_pcie_release_irq()
993 brcmf_pcie_intr_disable(devinfo); in brcmf_pcie_release_irq()
994 free_irq(pdev->irq, devinfo); in brcmf_pcie_release_irq()
999 while ((devinfo->in_irq) && (count < 20)) { in brcmf_pcie_release_irq()
1003 if (devinfo->in_irq) in brcmf_pcie_release_irq()
1006 status = brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->mailboxint); in brcmf_pcie_release_irq()
1007 brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->mailboxint, status); in brcmf_pcie_release_irq()
1009 devinfo->irq_allocated = false; in brcmf_pcie_release_irq()
1016 struct brcmf_pciedev_info *devinfo = ring->devinfo; in brcmf_pcie_ring_mb_write_rptr() local
1019 if (devinfo->state != BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_ring_mb_write_rptr()
1025 devinfo->write_ptr(devinfo, ring->r_idx_addr, commonring->r_ptr); in brcmf_pcie_ring_mb_write_rptr()
1034 struct brcmf_pciedev_info *devinfo = ring->devinfo; in brcmf_pcie_ring_mb_write_wptr() local
1037 if (devinfo->state != BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_ring_mb_write_wptr()
1043 devinfo->write_ptr(devinfo, ring->w_idx_addr, commonring->w_ptr); in brcmf_pcie_ring_mb_write_wptr()
1052 struct brcmf_pciedev_info *devinfo = ring->devinfo; in brcmf_pcie_ring_mb_ring_bell() local
1054 if (devinfo->state != BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_ring_mb_ring_bell()
1059 brcmf_pcie_write_reg32(devinfo, devinfo->reginfo->h2d_mailbox_0, 1); in brcmf_pcie_ring_mb_ring_bell()
1068 struct brcmf_pciedev_info *devinfo = ring->devinfo; in brcmf_pcie_ring_mb_update_rptr() local
1071 if (devinfo->state != BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_ring_mb_update_rptr()
1074 commonring->r_ptr = devinfo->read_ptr(devinfo, ring->r_idx_addr); in brcmf_pcie_ring_mb_update_rptr()
1086 struct brcmf_pciedev_info *devinfo = ring->devinfo; in brcmf_pcie_ring_mb_update_wptr() local
1089 if (devinfo->state != BRCMFMAC_PCIE_STATE_UP) in brcmf_pcie_ring_mb_update_wptr()
1092 commonring->w_ptr = devinfo->read_ptr(devinfo, ring->w_idx_addr); in brcmf_pcie_ring_mb_update_wptr()
1102 brcmf_pcie_init_dmabuffer_for_device(struct brcmf_pciedev_info *devinfo, in brcmf_pcie_init_dmabuffer_for_device() argument
1109 ring = dma_alloc_coherent(&devinfo->pdev->dev, size, dma_handle, in brcmf_pcie_init_dmabuffer_for_device()
1115 brcmf_pcie_write_tcm32(devinfo, tcm_dma_phys_addr, in brcmf_pcie_init_dmabuffer_for_device()
1117 brcmf_pcie_write_tcm32(devinfo, tcm_dma_phys_addr + 4, address >> 32); in brcmf_pcie_init_dmabuffer_for_device()
1124 brcmf_pcie_alloc_dma_and_ring(struct brcmf_pciedev_info *devinfo, u32 ring_id, in brcmf_pcie_alloc_dma_and_ring() argument
1134 if (devinfo->shared.version < BRCMF_PCIE_SHARED_VERSION_7) in brcmf_pcie_alloc_dma_and_ring()
1140 dma_buf = brcmf_pcie_init_dmabuffer_for_device(devinfo, size, in brcmf_pcie_alloc_dma_and_ring()
1147 brcmf_pcie_write_tcm16(devinfo, addr, brcmf_ring_max_item[ring_id]); in brcmf_pcie_alloc_dma_and_ring()
1149 brcmf_pcie_write_tcm16(devinfo, addr, ring_itemsize_array[ring_id]); in brcmf_pcie_alloc_dma_and_ring()
1153 dma_free_coherent(&devinfo->pdev->dev, size, dma_buf, in brcmf_pcie_alloc_dma_and_ring()
1160 ring->devinfo = devinfo; in brcmf_pcie_alloc_dma_and_ring()
1190 static void brcmf_pcie_release_ringbuffers(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_release_ringbuffers() argument
1195 brcmf_pcie_release_ringbuffer(&devinfo->pdev->dev, in brcmf_pcie_release_ringbuffers()
1196 devinfo->shared.commonrings[i]); in brcmf_pcie_release_ringbuffers()
1197 devinfo->shared.commonrings[i] = NULL; in brcmf_pcie_release_ringbuffers()
1199 kfree(devinfo->shared.flowrings); in brcmf_pcie_release_ringbuffers()
1200 devinfo->shared.flowrings = NULL; in brcmf_pcie_release_ringbuffers()
1201 if (devinfo->idxbuf) { in brcmf_pcie_release_ringbuffers()
1202 dma_free_coherent(&devinfo->pdev->dev, in brcmf_pcie_release_ringbuffers()
1203 devinfo->idxbuf_sz, in brcmf_pcie_release_ringbuffers()
1204 devinfo->idxbuf, in brcmf_pcie_release_ringbuffers()
1205 devinfo->idxbuf_dmahandle); in brcmf_pcie_release_ringbuffers()
1206 devinfo->idxbuf = NULL; in brcmf_pcie_release_ringbuffers()
1211 static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_init_ringbuffers() argument
1213 struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); in brcmf_pcie_init_ringbuffers()
1230 memcpy_fromio(&ringinfo, devinfo->tcm + devinfo->shared.ring_info_addr, in brcmf_pcie_init_ringbuffers()
1232 if (devinfo->shared.version >= 6) { in brcmf_pcie_init_ringbuffers()
1247 if (devinfo->dma_idx_sz != 0) { in brcmf_pcie_init_ringbuffers()
1249 devinfo->dma_idx_sz * 2; in brcmf_pcie_init_ringbuffers()
1250 devinfo->idxbuf = dma_alloc_coherent(&devinfo->pdev->dev, bufsz, in brcmf_pcie_init_ringbuffers()
1251 &devinfo->idxbuf_dmahandle, in brcmf_pcie_init_ringbuffers()
1253 if (!devinfo->idxbuf) in brcmf_pcie_init_ringbuffers()
1254 devinfo->dma_idx_sz = 0; in brcmf_pcie_init_ringbuffers()
1257 if (devinfo->dma_idx_sz == 0) { in brcmf_pcie_init_ringbuffers()
1263 devinfo->write_ptr = brcmf_pcie_write_tcm16; in brcmf_pcie_init_ringbuffers()
1264 devinfo->read_ptr = brcmf_pcie_read_tcm16; in brcmf_pcie_init_ringbuffers()
1267 memset(devinfo->idxbuf, 0, bufsz); in brcmf_pcie_init_ringbuffers()
1268 devinfo->idxbuf_sz = bufsz; in brcmf_pcie_init_ringbuffers()
1269 idx_offset = devinfo->dma_idx_sz; in brcmf_pcie_init_ringbuffers()
1270 devinfo->write_ptr = brcmf_pcie_write_idx; in brcmf_pcie_init_ringbuffers()
1271 devinfo->read_ptr = brcmf_pcie_read_idx; in brcmf_pcie_init_ringbuffers()
1274 address = (u64)devinfo->idxbuf_dmahandle; in brcmf_pcie_init_ringbuffers()
1304 memcpy_toio(devinfo->tcm + devinfo->shared.ring_info_addr, in brcmf_pcie_init_ringbuffers()
1312 ring = brcmf_pcie_alloc_dma_and_ring(devinfo, i, ring_mem_ptr); in brcmf_pcie_init_ringbuffers()
1318 devinfo->shared.commonrings[i] = ring; in brcmf_pcie_init_ringbuffers()
1327 ring = brcmf_pcie_alloc_dma_and_ring(devinfo, i, ring_mem_ptr); in brcmf_pcie_init_ringbuffers()
1333 devinfo->shared.commonrings[i] = ring; in brcmf_pcie_init_ringbuffers()
1340 devinfo->shared.max_flowrings = max_flowrings; in brcmf_pcie_init_ringbuffers()
1341 devinfo->shared.max_submissionrings = max_submissionrings; in brcmf_pcie_init_ringbuffers()
1342 devinfo->shared.max_completionrings = max_completionrings; in brcmf_pcie_init_ringbuffers()
1351 ring->devinfo = devinfo; in brcmf_pcie_init_ringbuffers()
1365 devinfo->shared.flowrings = rings; in brcmf_pcie_init_ringbuffers()
1371 brcmf_pcie_release_ringbuffers(devinfo); in brcmf_pcie_init_ringbuffers()
1377 brcmf_pcie_release_scratchbuffers(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_release_scratchbuffers() argument
1379 if (devinfo->shared.scratch) in brcmf_pcie_release_scratchbuffers()
1380 dma_free_coherent(&devinfo->pdev->dev, in brcmf_pcie_release_scratchbuffers()
1382 devinfo->shared.scratch, in brcmf_pcie_release_scratchbuffers()
1383 devinfo->shared.scratch_dmahandle); in brcmf_pcie_release_scratchbuffers()
1384 if (devinfo->shared.ringupd) in brcmf_pcie_release_scratchbuffers()
1385 dma_free_coherent(&devinfo->pdev->dev, in brcmf_pcie_release_scratchbuffers()
1387 devinfo->shared.ringupd, in brcmf_pcie_release_scratchbuffers()
1388 devinfo->shared.ringupd_dmahandle); in brcmf_pcie_release_scratchbuffers()
1391 static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_init_scratchbuffers() argument
1393 struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); in brcmf_pcie_init_scratchbuffers()
1397 devinfo->shared.scratch = in brcmf_pcie_init_scratchbuffers()
1398 dma_alloc_coherent(&devinfo->pdev->dev, in brcmf_pcie_init_scratchbuffers()
1400 &devinfo->shared.scratch_dmahandle, in brcmf_pcie_init_scratchbuffers()
1402 if (!devinfo->shared.scratch) in brcmf_pcie_init_scratchbuffers()
1405 addr = devinfo->shared.tcm_base_address + in brcmf_pcie_init_scratchbuffers()
1407 address = (u64)devinfo->shared.scratch_dmahandle; in brcmf_pcie_init_scratchbuffers()
1408 brcmf_pcie_write_tcm32(devinfo, addr, address & 0xffffffff); in brcmf_pcie_init_scratchbuffers()
1409 brcmf_pcie_write_tcm32(devinfo, addr + 4, address >> 32); in brcmf_pcie_init_scratchbuffers()
1410 addr = devinfo->shared.tcm_base_address + in brcmf_pcie_init_scratchbuffers()
1412 brcmf_pcie_write_tcm32(devinfo, addr, BRCMF_DMA_D2H_SCRATCH_BUF_LEN); in brcmf_pcie_init_scratchbuffers()
1414 devinfo->shared.ringupd = in brcmf_pcie_init_scratchbuffers()
1415 dma_alloc_coherent(&devinfo->pdev->dev, in brcmf_pcie_init_scratchbuffers()
1417 &devinfo->shared.ringupd_dmahandle, in brcmf_pcie_init_scratchbuffers()
1419 if (!devinfo->shared.ringupd) in brcmf_pcie_init_scratchbuffers()
1422 addr = devinfo->shared.tcm_base_address + in brcmf_pcie_init_scratchbuffers()
1424 address = (u64)devinfo->shared.ringupd_dmahandle; in brcmf_pcie_init_scratchbuffers()
1425 brcmf_pcie_write_tcm32(devinfo, addr, address & 0xffffffff); in brcmf_pcie_init_scratchbuffers()
1426 brcmf_pcie_write_tcm32(devinfo, addr + 4, address >> 32); in brcmf_pcie_init_scratchbuffers()
1427 addr = devinfo->shared.tcm_base_address + in brcmf_pcie_init_scratchbuffers()
1429 brcmf_pcie_write_tcm32(devinfo, addr, BRCMF_DMA_D2H_RINGUPD_BUF_LEN); in brcmf_pcie_init_scratchbuffers()
1434 brcmf_pcie_release_scratchbuffers(devinfo); in brcmf_pcie_init_scratchbuffers()
1443 struct brcmf_pciedev_info *devinfo = pcie_bus_dev->devinfo; in brcmf_pcie_down() local
1445 brcmf_pcie_fwcon_timer(devinfo, false); in brcmf_pcie_down()
1455 brcmf_pcie_intr_enable(buspub->devinfo); in brcmf_pcie_preinit()
1456 brcmf_pcie_hostready(buspub->devinfo); in brcmf_pcie_preinit()
1485 struct brcmf_pciedev_info *devinfo = buspub->devinfo; in brcmf_pcie_wowl_config() local
1488 devinfo->wowl_enabled = enabled; in brcmf_pcie_wowl_config()
1496 struct brcmf_pciedev_info *devinfo = buspub->devinfo; in brcmf_pcie_get_ramsize() local
1498 return devinfo->ci->ramsize - devinfo->ci->srsize; in brcmf_pcie_get_ramsize()
1506 struct brcmf_pciedev_info *devinfo = buspub->devinfo; in brcmf_pcie_get_memdump() local
1508 brcmf_dbg(PCIE, "dump at 0x%08X: len=%zu\n", devinfo->ci->rambase, len); in brcmf_pcie_get_memdump()
1509 brcmf_pcie_copy_dev_tomem(devinfo, devinfo->ci->rambase, data, len); in brcmf_pcie_get_memdump()
1518 struct brcmf_pciedev_info *devinfo = buspub->devinfo; in brcmf_pcie_get_blob() local
1522 *fw = devinfo->clm_fw; in brcmf_pcie_get_blob()
1523 devinfo->clm_fw = NULL; in brcmf_pcie_get_blob()
1526 *fw = devinfo->txcap_fw; in brcmf_pcie_get_blob()
1527 devinfo->txcap_fw = NULL; in brcmf_pcie_get_blob()
1543 struct brcmf_pciedev_info *devinfo = buspub->devinfo; in brcmf_pcie_reset() local
1547 brcmf_pcie_intr_disable(devinfo); in brcmf_pcie_reset()
1549 brcmf_pcie_bus_console_read(devinfo, true); in brcmf_pcie_reset()
1553 brcmf_pcie_release_irq(devinfo); in brcmf_pcie_reset()
1554 brcmf_pcie_release_scratchbuffers(devinfo); in brcmf_pcie_reset()
1555 brcmf_pcie_release_ringbuffers(devinfo); in brcmf_pcie_reset()
1556 brcmf_pcie_reset_device(devinfo); in brcmf_pcie_reset()
1558 fwreq = brcmf_pcie_prepare_fw_request(devinfo); in brcmf_pcie_reset()
1589 brcmf_pcie_adjust_ramsize(struct brcmf_pciedev_info *devinfo, u8 *data, in brcmf_pcie_adjust_ramsize() argument
1606 devinfo->ci->ramsize = newsize; in brcmf_pcie_adjust_ramsize()
1611 brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo, in brcmf_pcie_init_share_ram_info() argument
1614 struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); in brcmf_pcie_init_share_ram_info()
1618 shared = &devinfo->shared; in brcmf_pcie_init_share_ram_info()
1621 shared->flags = brcmf_pcie_read_tcm32(devinfo, sharedram_addr); in brcmf_pcie_init_share_ram_info()
1634 devinfo->dma_idx_sz = sizeof(u16); in brcmf_pcie_init_share_ram_info()
1636 devinfo->dma_idx_sz = sizeof(u32); in brcmf_pcie_init_share_ram_info()
1640 shared->max_rxbufpost = brcmf_pcie_read_tcm16(devinfo, addr); in brcmf_pcie_init_share_ram_info()
1645 shared->rx_dataoffset = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_init_share_ram_info()
1648 shared->htod_mb_data_addr = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_init_share_ram_info()
1651 shared->dtoh_mb_data_addr = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_init_share_ram_info()
1654 shared->ring_info_addr = brcmf_pcie_read_tcm32(devinfo, addr); in brcmf_pcie_init_share_ram_info()
1659 brcmf_pcie_bus_console_init(devinfo); in brcmf_pcie_init_share_ram_info()
1660 brcmf_pcie_bus_console_read(devinfo, false); in brcmf_pcie_init_share_ram_info()
1674 brcmf_pcie_provide_random_bytes(struct brcmf_pciedev_info *devinfo, u32 address) in brcmf_pcie_provide_random_bytes() argument
1679 memcpy_toio(devinfo->tcm + address, randbuf, BRCMF_RANDOM_SEED_LENGTH); in brcmf_pcie_provide_random_bytes()
1682 static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo, in brcmf_pcie_download_fw_nvram() argument
1686 struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev); in brcmf_pcie_download_fw_nvram()
1695 err = brcmf_pcie_enter_download_state(devinfo); in brcmf_pcie_download_fw_nvram()
1699 brcmf_dbg(PCIE, "Download FW %s\n", devinfo->fw_name); in brcmf_pcie_download_fw_nvram()
1700 memcpy_toio(devinfo->tcm + devinfo->ci->rambase, in brcmf_pcie_download_fw_nvram()
1709 brcmf_pcie_write_ram32(devinfo, devinfo->ci->ramsize - 4, 0); in brcmf_pcie_download_fw_nvram()
1712 brcmf_dbg(PCIE, "Download NVRAM %s\n", devinfo->nvram_name); in brcmf_pcie_download_fw_nvram()
1713 address = devinfo->ci->rambase + devinfo->ci->ramsize - in brcmf_pcie_download_fw_nvram()
1715 memcpy_toio(devinfo->tcm + address, nvram, nvram_len); in brcmf_pcie_download_fw_nvram()
1718 if (devinfo->otp.valid) { in brcmf_pcie_download_fw_nvram()
1731 memcpy_toio(devinfo->tcm + address, &footer, in brcmf_pcie_download_fw_nvram()
1735 brcmf_pcie_provide_random_bytes(devinfo, address); in brcmf_pcie_download_fw_nvram()
1739 devinfo->nvram_name); in brcmf_pcie_download_fw_nvram()
1742 sharedram_addr_written = brcmf_pcie_read_ram32(devinfo, in brcmf_pcie_download_fw_nvram()
1743 devinfo->ci->ramsize - in brcmf_pcie_download_fw_nvram()
1746 err = brcmf_pcie_exit_download_state(devinfo, resetintr); in brcmf_pcie_download_fw_nvram()
1755 sharedram_addr = brcmf_pcie_read_ram32(devinfo, in brcmf_pcie_download_fw_nvram()
1756 devinfo->ci->ramsize - in brcmf_pcie_download_fw_nvram()
1764 if (sharedram_addr < devinfo->ci->rambase || in brcmf_pcie_download_fw_nvram()
1765 sharedram_addr >= devinfo->ci->rambase + devinfo->ci->ramsize) { in brcmf_pcie_download_fw_nvram()
1772 return (brcmf_pcie_init_share_ram_info(devinfo, sharedram_addr)); in brcmf_pcie_download_fw_nvram()
1776 static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_get_resource() argument
1778 struct pci_dev *pdev = devinfo->pdev; in brcmf_pcie_get_resource()
1804 devinfo->regs = ioremap(bar0_addr, BRCMF_PCIE_REG_MAP_SIZE); in brcmf_pcie_get_resource()
1805 devinfo->tcm = ioremap(bar1_addr, bar1_size); in brcmf_pcie_get_resource()
1807 if (!devinfo->regs || !devinfo->tcm) { in brcmf_pcie_get_resource()
1808 brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs, in brcmf_pcie_get_resource()
1809 devinfo->tcm); in brcmf_pcie_get_resource()
1813 devinfo->regs, (unsigned long long)bar0_addr); in brcmf_pcie_get_resource()
1815 devinfo->tcm, (unsigned long long)bar1_addr, in brcmf_pcie_get_resource()
1822 static void brcmf_pcie_release_resource(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_release_resource() argument
1824 if (devinfo->tcm) in brcmf_pcie_release_resource()
1825 iounmap(devinfo->tcm); in brcmf_pcie_release_resource()
1826 if (devinfo->regs) in brcmf_pcie_release_resource()
1827 iounmap(devinfo->regs); in brcmf_pcie_release_resource()
1829 pci_disable_device(devinfo->pdev); in brcmf_pcie_release_resource()
1847 struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)ctx; in brcmf_pcie_buscore_read32() local
1849 addr = brcmf_pcie_buscore_prep_addr(devinfo->pdev, addr); in brcmf_pcie_buscore_read32()
1850 return brcmf_pcie_read_reg32(devinfo, addr); in brcmf_pcie_buscore_read32()
1856 struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)ctx; in brcmf_pcie_buscore_write32() local
1858 addr = brcmf_pcie_buscore_prep_addr(devinfo->pdev, addr); in brcmf_pcie_buscore_write32()
1859 brcmf_pcie_write_reg32(devinfo, addr, value); in brcmf_pcie_buscore_write32()
1871 struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)ctx; in brcmf_pcie_buscore_reset() local
1875 devinfo->ci = chip; in brcmf_pcie_buscore_reset()
1876 brcmf_pcie_reset_device(devinfo); in brcmf_pcie_buscore_reset()
1885 val = brcmf_pcie_read_reg32(devinfo, reg); in brcmf_pcie_buscore_reset()
1887 brcmf_pcie_write_reg32(devinfo, reg, val); in brcmf_pcie_buscore_reset()
1896 struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)ctx; in brcmf_pcie_buscore_activate() local
1898 brcmf_pcie_write_tcm32(devinfo, 0, rstvec); in brcmf_pcie_buscore_activate()
1916 brcmf_pcie_parse_otp_sys_vendor(struct brcmf_pciedev_info *devinfo, in brcmf_pcie_parse_otp_sys_vendor() argument
1969 strscpy(devinfo->otp.module, p, len + 1); in brcmf_pcie_parse_otp_sys_vendor()
1972 strscpy(devinfo->otp.vendor, p, len + 1); in brcmf_pcie_parse_otp_sys_vendor()
1975 strscpy(devinfo->otp.version, p, len + 1); in brcmf_pcie_parse_otp_sys_vendor()
1984 devinfo->otp.module, devinfo->otp.vendor, in brcmf_pcie_parse_otp_sys_vendor()
1985 devinfo->otp.version); in brcmf_pcie_parse_otp_sys_vendor()
1987 if (!devinfo->otp.module[0] || in brcmf_pcie_parse_otp_sys_vendor()
1988 !devinfo->otp.vendor[0] || in brcmf_pcie_parse_otp_sys_vendor()
1989 !devinfo->otp.version[0]) in brcmf_pcie_parse_otp_sys_vendor()
1992 devinfo->otp.valid = true; in brcmf_pcie_parse_otp_sys_vendor()
1997 brcmf_pcie_parse_otp(struct brcmf_pciedev_info *devinfo, u8 *otp, size_t size) in brcmf_pcie_parse_otp() argument
2018 ret = brcmf_pcie_parse_otp_sys_vendor(devinfo, in brcmf_pcie_parse_otp()
2038 static int brcmf_pcie_read_otp(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_read_otp() argument
2040 const struct pci_dev *pdev = devinfo->pdev; in brcmf_pcie_read_otp()
2047 switch (devinfo->ci->chip) { in brcmf_pcie_read_otp()
2074 core = brcmf_chip_get_core(devinfo->ci, coreid); in brcmf_pcie_read_otp()
2084 brcmf_pcie_select_core(devinfo, coreid); in brcmf_pcie_read_otp()
2085 sromctl = READCC32(devinfo, sromcontrol); in brcmf_pcie_read_otp()
2095 WRITECC32(devinfo, sromcontrol, in brcmf_pcie_read_otp()
2104 base = brcmf_pcie_buscore_prep_addr(devinfo->pdev, base + core->base); in brcmf_pcie_read_otp()
2108 otp[idx] = brcmf_pcie_read_reg16(devinfo, base + 2 * idx); in brcmf_pcie_read_otp()
2113 brcmf_pcie_select_core(devinfo, coreid); in brcmf_pcie_read_otp()
2114 WRITECC32(devinfo, sromcontrol, sromctl); in brcmf_pcie_read_otp()
2117 ret = brcmf_pcie_parse_otp(devinfo, (u8 *)otp, 2 * words); in brcmf_pcie_read_otp()
2135 struct brcmf_pciedev_info *devinfo; in brcmf_pcie_setup() local
2141 devinfo = pcie_bus_dev->devinfo; in brcmf_pcie_setup()
2147 brcmf_pcie_attach(devinfo); in brcmf_pcie_setup()
2152 devinfo->clm_fw = fwreq->items[BRCMF_PCIE_FW_CLM].binary; in brcmf_pcie_setup()
2153 devinfo->txcap_fw = fwreq->items[BRCMF_PCIE_FW_TXCAP].binary; in brcmf_pcie_setup()
2156 ret = brcmf_chip_get_raminfo(devinfo->ci); in brcmf_pcie_setup()
2169 brcmf_pcie_adjust_ramsize(devinfo, (u8 *)fw->data, fw->size); in brcmf_pcie_setup()
2171 ret = brcmf_pcie_download_fw_nvram(devinfo, fw, nvram, nvram_len); in brcmf_pcie_setup()
2175 devinfo->state = BRCMFMAC_PCIE_STATE_UP; in brcmf_pcie_setup()
2177 ret = brcmf_pcie_init_ringbuffers(devinfo); in brcmf_pcie_setup()
2181 ret = brcmf_pcie_init_scratchbuffers(devinfo); in brcmf_pcie_setup()
2185 brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); in brcmf_pcie_setup()
2186 ret = brcmf_pcie_request_irq(devinfo); in brcmf_pcie_setup()
2193 &devinfo->shared.commonrings[i]->commonring; in brcmf_pcie_setup()
2195 flowrings = kcalloc(devinfo->shared.max_flowrings, sizeof(*flowrings), in brcmf_pcie_setup()
2200 for (i = 0; i < devinfo->shared.max_flowrings; i++) in brcmf_pcie_setup()
2201 flowrings[i] = &devinfo->shared.flowrings[i].commonring; in brcmf_pcie_setup()
2204 bus->msgbuf->rx_dataoffset = devinfo->shared.rx_dataoffset; in brcmf_pcie_setup()
2205 bus->msgbuf->max_rxbufpost = devinfo->shared.max_rxbufpost; in brcmf_pcie_setup()
2206 bus->msgbuf->max_flowrings = devinfo->shared.max_flowrings; in brcmf_pcie_setup()
2208 init_waitqueue_head(&devinfo->mbdata_resp_wait); in brcmf_pcie_setup()
2210 ret = brcmf_attach(&devinfo->pdev->dev); in brcmf_pcie_setup()
2214 brcmf_pcie_bus_console_read(devinfo, false); in brcmf_pcie_setup()
2216 brcmf_pcie_fwcon_timer(devinfo, true); in brcmf_pcie_setup()
2222 brcmf_pcie_bus_console_read(devinfo, true); in brcmf_pcie_setup()
2228 brcmf_pcie_prepare_fw_request(struct brcmf_pciedev_info *devinfo) in brcmf_pcie_prepare_fw_request() argument
2232 { ".bin", devinfo->fw_name }, in brcmf_pcie_prepare_fw_request()
2233 { ".txt", devinfo->nvram_name }, in brcmf_pcie_prepare_fw_request()
2234 { ".clm_blob", devinfo->clm_name }, in brcmf_pcie_prepare_fw_request()
2235 { ".txcap_blob", devinfo->txcap_name }, in brcmf_pcie_prepare_fw_request()
2238 fwreq = brcmf_fw_alloc_request(devinfo->ci->chip, devinfo->ci->chiprev, in brcmf_pcie_prepare_fw_request()
2253 fwreq->domain_nr = pci_domain_nr(devinfo->pdev->bus) + 1; in brcmf_pcie_prepare_fw_request()
2254 fwreq->bus_nr = devinfo->pdev->bus->number; in brcmf_pcie_prepare_fw_request()
2257 if (devinfo->settings->board_type && in brcmf_pcie_prepare_fw_request()
2258 devinfo->settings->antenna_sku && in brcmf_pcie_prepare_fw_request()
2259 devinfo->otp.valid) { in brcmf_pcie_prepare_fw_request()
2260 const struct brcmf_otp_params *otp = &devinfo->otp; in brcmf_pcie_prepare_fw_request()
2261 struct device *dev = &devinfo->pdev->dev; in brcmf_pcie_prepare_fw_request()
2265 devinfo->settings->board_type); in brcmf_pcie_prepare_fw_request()
2269 devinfo->settings->board_type, in brcmf_pcie_prepare_fw_request()
2271 devinfo->settings->antenna_sku); in brcmf_pcie_prepare_fw_request()
2273 devinfo->settings->board_type, in brcmf_pcie_prepare_fw_request()
2276 devinfo->settings->board_type, in brcmf_pcie_prepare_fw_request()
2279 devinfo->settings->board_type, in brcmf_pcie_prepare_fw_request()
2282 devinfo->settings->board_type, in brcmf_pcie_prepare_fw_request()
2283 devinfo->settings->antenna_sku); in brcmf_pcie_prepare_fw_request()
2284 bt[5] = devinfo->settings->board_type; in brcmf_pcie_prepare_fw_request()
2291 brcmf_dbg(PCIE, "Board: %s\n", devinfo->settings->board_type); in brcmf_pcie_prepare_fw_request()
2292 fwreq->board_types[0] = devinfo->settings->board_type; in brcmf_pcie_prepare_fw_request()
2300 brcmf_pcie_fwcon_timer(struct brcmf_pciedev_info *devinfo, bool active) in brcmf_pcie_fwcon_timer() argument
2303 if (devinfo->console_active) { in brcmf_pcie_fwcon_timer()
2304 del_timer_sync(&devinfo->timer); in brcmf_pcie_fwcon_timer()
2305 devinfo->console_active = false; in brcmf_pcie_fwcon_timer()
2311 if (devinfo->state != BRCMFMAC_PCIE_STATE_UP || in brcmf_pcie_fwcon_timer()
2312 !devinfo->console_interval || !BRCMF_FWCON_ON()) in brcmf_pcie_fwcon_timer()
2315 if (!devinfo->console_active) { in brcmf_pcie_fwcon_timer()
2316 devinfo->timer.expires = jiffies + devinfo->console_interval; in brcmf_pcie_fwcon_timer()
2317 add_timer(&devinfo->timer); in brcmf_pcie_fwcon_timer()
2318 devinfo->console_active = true; in brcmf_pcie_fwcon_timer()
2321 mod_timer(&devinfo->timer, jiffies + devinfo->console_interval); in brcmf_pcie_fwcon_timer()
2328 struct brcmf_pciedev_info *devinfo = from_timer(devinfo, t, timer); in brcmf_pcie_fwcon() local
2330 if (!devinfo->console_active) in brcmf_pcie_fwcon()
2333 brcmf_pcie_bus_console_read(devinfo, false); in brcmf_pcie_fwcon()
2336 mod_timer(&devinfo->timer, jiffies + devinfo->console_interval); in brcmf_pcie_fwcon()
2341 struct brcmf_pciedev_info *devinfo = data; in brcmf_pcie_console_interval_get() local
2343 *val = devinfo->console_interval; in brcmf_pcie_console_interval_get()
2350 struct brcmf_pciedev_info *devinfo = data; in brcmf_pcie_console_interval_set() local
2355 devinfo->console_interval = val; in brcmf_pcie_console_interval_set()
2357 if (!val && devinfo->console_active) in brcmf_pcie_console_interval_set()
2358 brcmf_pcie_fwcon_timer(devinfo, false); in brcmf_pcie_console_interval_set()
2360 brcmf_pcie_fwcon_timer(devinfo, true); in brcmf_pcie_console_interval_set()
2375 struct brcmf_pciedev_info *devinfo = pcie_bus_dev->devinfo; in brcmf_pcie_debugfs_create() local
2381 devinfo->console_interval = BRCMF_CONSOLE; in brcmf_pcie_debugfs_create()
2383 debugfs_create_file("console_interval", 0644, dentry, devinfo, in brcmf_pcie_debugfs_create()
2388 void brcmf_pcie_fwcon_timer(struct brcmf_pciedev_info *devinfo, bool active) in brcmf_pcie_fwcon_timer() argument
2405 struct brcmf_pciedev_info *devinfo; in brcmf_pcie_probe() local
2421 devinfo = kzalloc(sizeof(*devinfo), GFP_KERNEL); in brcmf_pcie_probe()
2422 if (devinfo == NULL) in brcmf_pcie_probe()
2425 devinfo->pdev = pdev; in brcmf_pcie_probe()
2427 devinfo->ci = brcmf_chip_attach(devinfo, pdev->device, in brcmf_pcie_probe()
2429 if (IS_ERR(devinfo->ci)) { in brcmf_pcie_probe()
2430 ret = PTR_ERR(devinfo->ci); in brcmf_pcie_probe()
2431 devinfo->ci = NULL; in brcmf_pcie_probe()
2435 core = brcmf_chip_get_core(devinfo->ci, BCMA_CORE_PCIE2); in brcmf_pcie_probe()
2437 devinfo->reginfo = &brcmf_reginfo_64; in brcmf_pcie_probe()
2439 devinfo->reginfo = &brcmf_reginfo_default; in brcmf_pcie_probe()
2447 devinfo->settings = brcmf_get_module_param(&devinfo->pdev->dev, in brcmf_pcie_probe()
2449 devinfo->ci->chip, in brcmf_pcie_probe()
2450 devinfo->ci->chiprev); in brcmf_pcie_probe()
2451 if (!devinfo->settings) { in brcmf_pcie_probe()
2469 pcie_bus_dev->devinfo = devinfo; in brcmf_pcie_probe()
2476 bus->chip = devinfo->coreid; in brcmf_pcie_probe()
2480 ret = brcmf_alloc(&devinfo->pdev->dev, devinfo->settings); in brcmf_pcie_probe()
2484 ret = brcmf_pcie_read_otp(devinfo); in brcmf_pcie_probe()
2492 timer_setup(&devinfo->timer, brcmf_pcie_fwcon, 0); in brcmf_pcie_probe()
2495 fwreq = brcmf_pcie_prepare_fw_request(devinfo); in brcmf_pcie_probe()
2509 brcmf_free(&devinfo->pdev->dev); in brcmf_pcie_probe()
2515 brcmf_pcie_release_resource(devinfo); in brcmf_pcie_probe()
2516 if (devinfo->ci) in brcmf_pcie_probe()
2517 brcmf_chip_detach(devinfo->ci); in brcmf_pcie_probe()
2518 if (devinfo->settings) in brcmf_pcie_probe()
2519 brcmf_release_module_param(devinfo->settings); in brcmf_pcie_probe()
2521 kfree(devinfo); in brcmf_pcie_probe()
2529 struct brcmf_pciedev_info *devinfo; in brcmf_pcie_remove() local
2538 devinfo = bus->bus_priv.pcie->devinfo; in brcmf_pcie_remove()
2539 brcmf_pcie_bus_console_read(devinfo, false); in brcmf_pcie_remove()
2540 brcmf_pcie_fwcon_timer(devinfo, false); in brcmf_pcie_remove()
2542 devinfo->state = BRCMFMAC_PCIE_STATE_DOWN; in brcmf_pcie_remove()
2543 if (devinfo->ci) in brcmf_pcie_remove()
2544 brcmf_pcie_intr_disable(devinfo); in brcmf_pcie_remove()
2554 brcmf_pcie_release_irq(devinfo); in brcmf_pcie_remove()
2555 brcmf_pcie_release_scratchbuffers(devinfo); in brcmf_pcie_remove()
2556 brcmf_pcie_release_ringbuffers(devinfo); in brcmf_pcie_remove()
2557 brcmf_pcie_reset_device(devinfo); in brcmf_pcie_remove()
2558 brcmf_pcie_release_resource(devinfo); in brcmf_pcie_remove()
2559 release_firmware(devinfo->clm_fw); in brcmf_pcie_remove()
2560 release_firmware(devinfo->txcap_fw); in brcmf_pcie_remove()
2562 if (devinfo->ci) in brcmf_pcie_remove()
2563 brcmf_chip_detach(devinfo->ci); in brcmf_pcie_remove()
2564 if (devinfo->settings) in brcmf_pcie_remove()
2565 brcmf_release_module_param(devinfo->settings); in brcmf_pcie_remove()
2567 kfree(devinfo); in brcmf_pcie_remove()
2577 struct brcmf_pciedev_info *devinfo; in brcmf_pcie_pm_enter_D3() local
2583 devinfo = bus->bus_priv.pcie->devinfo; in brcmf_pcie_pm_enter_D3()
2585 brcmf_pcie_fwcon_timer(devinfo, false); in brcmf_pcie_pm_enter_D3()
2588 devinfo->mbdata_completed = false; in brcmf_pcie_pm_enter_D3()
2589 brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_D3_INFORM); in brcmf_pcie_pm_enter_D3()
2591 wait_event_timeout(devinfo->mbdata_resp_wait, devinfo->mbdata_completed, in brcmf_pcie_pm_enter_D3()
2593 if (!devinfo->mbdata_completed) { in brcmf_pcie_pm_enter_D3()
2599 devinfo->state = BRCMFMAC_PCIE_STATE_DOWN; in brcmf_pcie_pm_enter_D3()
2607 struct brcmf_pciedev_info *devinfo; in brcmf_pcie_pm_leave_D3() local
2615 devinfo = bus->bus_priv.pcie->devinfo; in brcmf_pcie_pm_leave_D3()
2619 if (brcmf_pcie_read_reg32(devinfo, devinfo->reginfo->intmask) != 0) { in brcmf_pcie_pm_leave_D3()
2621 if (brcmf_pcie_send_mb_data(devinfo, BRCMF_H2D_HOST_D0_INFORM)) in brcmf_pcie_pm_leave_D3()
2624 devinfo->state = BRCMFMAC_PCIE_STATE_UP; in brcmf_pcie_pm_leave_D3()
2625 brcmf_pcie_select_core(devinfo, BCMA_CORE_PCIE2); in brcmf_pcie_pm_leave_D3()
2627 brcmf_pcie_intr_enable(devinfo); in brcmf_pcie_pm_leave_D3()
2628 brcmf_pcie_hostready(devinfo); in brcmf_pcie_pm_leave_D3()
2629 brcmf_pcie_fwcon_timer(devinfo, true); in brcmf_pcie_pm_leave_D3()
2634 brcmf_chip_detach(devinfo->ci); in brcmf_pcie_pm_leave_D3()
2635 devinfo->ci = NULL; in brcmf_pcie_pm_leave_D3()
2636 pdev = devinfo->pdev; in brcmf_pcie_pm_leave_D3()