Lines Matching refs:dw

73 static inline struct dw_xdata_regs __iomem *__dw_regs(struct dw_xdata *dw)  in __dw_regs()  argument
75 return dw->rg_region.vaddr; in __dw_regs()
78 static void dw_xdata_stop(struct dw_xdata *dw) in dw_xdata_stop() argument
82 mutex_lock(&dw->mutex); in dw_xdata_stop()
84 burst = readl(&(__dw_regs(dw)->burst_cnt)); in dw_xdata_stop()
88 writel(burst, &(__dw_regs(dw)->burst_cnt)); in dw_xdata_stop()
91 mutex_unlock(&dw->mutex); in dw_xdata_stop()
94 static void dw_xdata_start(struct dw_xdata *dw, bool write) in dw_xdata_start() argument
96 struct device *dev = &dw->pdev->dev; in dw_xdata_start()
100 dw_xdata_stop(dw); in dw_xdata_start()
102 mutex_lock(&dw->mutex); in dw_xdata_start()
105 writel(0x0, &(__dw_regs(dw)->status)); in dw_xdata_start()
108 writel(BURST_REPEAT | BURST_VALUE, &(__dw_regs(dw)->burst_cnt)); in dw_xdata_start()
111 writel(PATTERN_VALUE, &(__dw_regs(dw)->pattern)); in dw_xdata_start()
117 control |= CONTROL_LENGTH(dw->max_wr_len); in dw_xdata_start()
119 control |= CONTROL_LENGTH(dw->max_rd_len); in dw_xdata_start()
121 writel(control, &(__dw_regs(dw)->control)); in dw_xdata_start()
129 status = readl(&(__dw_regs(dw)->status)); in dw_xdata_start()
131 mutex_unlock(&dw->mutex); in dw_xdata_start()
138 static void dw_xdata_perf_meas(struct dw_xdata *dw, u64 *data, bool write) in dw_xdata_perf_meas() argument
141 *data = readl(&(__dw_regs(dw)->wr_cnt_msb)); in dw_xdata_perf_meas()
143 *data |= readl(&(__dw_regs(dw)->wr_cnt_lsb)); in dw_xdata_perf_meas()
145 *data = readl(&(__dw_regs(dw)->rd_cnt_msb)); in dw_xdata_perf_meas()
147 *data |= readl(&(__dw_regs(dw)->rd_cnt_lsb)); in dw_xdata_perf_meas()
162 static void dw_xdata_perf(struct dw_xdata *dw, u64 *rate, bool write) in dw_xdata_perf() argument
164 struct device *dev = &dw->pdev->dev; in dw_xdata_perf()
167 mutex_lock(&dw->mutex); in dw_xdata_perf()
170 writel(0x0, &(__dw_regs(dw)->perf_control)); in dw_xdata_perf()
171 dw_xdata_perf_meas(dw, &data[0], write); in dw_xdata_perf()
173 writel((u32)XPERF_CONTROL_ENABLE, &(__dw_regs(dw)->perf_control)); in dw_xdata_perf()
182 writel(0x0, &(__dw_regs(dw)->perf_control)); in dw_xdata_perf()
183 dw_xdata_perf_meas(dw, &data[1], write); in dw_xdata_perf()
185 writel((u32)XPERF_CONTROL_ENABLE, &(__dw_regs(dw)->perf_control)); in dw_xdata_perf()
195 mutex_unlock(&dw->mutex); in dw_xdata_perf()
210 struct dw_xdata *dw = misc_dev_to_dw(misc_dev); in write_show() local
213 dw_xdata_perf(dw, &rate, true); in write_show()
222 struct dw_xdata *dw = misc_dev_to_dw(misc_dev); in write_store() local
232 dw_xdata_start(dw, true); in write_store()
235 dw_xdata_stop(dw); in write_store()
247 struct dw_xdata *dw = misc_dev_to_dw(misc_dev); in read_show() local
250 dw_xdata_perf(dw, &rate, false); in read_show()
259 struct dw_xdata *dw = misc_dev_to_dw(misc_dev); in read_store() local
269 dw_xdata_start(dw, false); in read_store()
272 dw_xdata_stop(dw); in read_store()
292 struct dw_xdata *dw; in dw_xdata_pcie_probe() local
315 dw = devm_kzalloc(dev, sizeof(*dw), GFP_KERNEL); in dw_xdata_pcie_probe()
316 if (!dw) in dw_xdata_pcie_probe()
320 mutex_init(&dw->mutex); in dw_xdata_pcie_probe()
322 dw->rg_region.vaddr = pcim_iomap_table(pdev)[BAR_0]; in dw_xdata_pcie_probe()
323 if (!dw->rg_region.vaddr) in dw_xdata_pcie_probe()
326 dw->rg_region.paddr = pdev->resource[BAR_0].start; in dw_xdata_pcie_probe()
328 dw->max_wr_len = pcie_get_mps(pdev); in dw_xdata_pcie_probe()
329 dw->max_wr_len >>= 2; in dw_xdata_pcie_probe()
331 dw->max_rd_len = pcie_get_readrq(pdev); in dw_xdata_pcie_probe()
332 dw->max_rd_len >>= 2; in dw_xdata_pcie_probe()
334 dw->pdev = pdev; in dw_xdata_pcie_probe()
343 dw->misc_dev.name = kstrdup(name, GFP_KERNEL); in dw_xdata_pcie_probe()
344 if (!dw->misc_dev.name) { in dw_xdata_pcie_probe()
349 dw->misc_dev.minor = MISC_DYNAMIC_MINOR; in dw_xdata_pcie_probe()
350 dw->misc_dev.parent = dev; in dw_xdata_pcie_probe()
351 dw->misc_dev.groups = xdata_groups; in dw_xdata_pcie_probe()
353 writel(0x0, &(__dw_regs(dw)->RAM_addr)); in dw_xdata_pcie_probe()
354 writel(0x0, &(__dw_regs(dw)->RAM_port)); in dw_xdata_pcie_probe()
356 addr = dw->rg_region.paddr + DW_XDATA_EP_MEM_OFFSET; in dw_xdata_pcie_probe()
357 writel(lower_32_bits(addr), &(__dw_regs(dw)->addr_lsb)); in dw_xdata_pcie_probe()
358 writel(upper_32_bits(addr), &(__dw_regs(dw)->addr_msb)); in dw_xdata_pcie_probe()
362 dw->max_wr_len * 4, dw->max_rd_len * 4); in dw_xdata_pcie_probe()
365 pci_set_drvdata(pdev, dw); in dw_xdata_pcie_probe()
368 err = misc_register(&dw->misc_dev); in dw_xdata_pcie_probe()
377 kfree(dw->misc_dev.name); in dw_xdata_pcie_probe()
387 struct dw_xdata *dw = pci_get_drvdata(pdev); in dw_xdata_pcie_remove() local
390 if (sscanf(dw->misc_dev.name, DW_XDATA_DRIVER_NAME ".%d", &id) != 1) in dw_xdata_pcie_remove()
396 dw_xdata_stop(dw); in dw_xdata_pcie_remove()
397 misc_deregister(&dw->misc_dev); in dw_xdata_pcie_remove()
398 kfree(dw->misc_dev.name); in dw_xdata_pcie_remove()