Lines Matching refs:mgmtdev

62 int hidma_mgmt_setup(struct hidma_mgmt_dev *mgmtdev)  in hidma_mgmt_setup()  argument
67 if (!is_power_of_2(mgmtdev->max_write_request) || in hidma_mgmt_setup()
68 (mgmtdev->max_write_request < 128) || in hidma_mgmt_setup()
69 (mgmtdev->max_write_request > 1024)) { in hidma_mgmt_setup()
70 dev_err(&mgmtdev->pdev->dev, "invalid write request %d\n", in hidma_mgmt_setup()
71 mgmtdev->max_write_request); in hidma_mgmt_setup()
75 if (!is_power_of_2(mgmtdev->max_read_request) || in hidma_mgmt_setup()
76 (mgmtdev->max_read_request < 128) || in hidma_mgmt_setup()
77 (mgmtdev->max_read_request > 1024)) { in hidma_mgmt_setup()
78 dev_err(&mgmtdev->pdev->dev, "invalid read request %d\n", in hidma_mgmt_setup()
79 mgmtdev->max_read_request); in hidma_mgmt_setup()
83 if (mgmtdev->max_wr_xactions > HIDMA_MAX_WR_XACTIONS_MASK) { in hidma_mgmt_setup()
84 dev_err(&mgmtdev->pdev->dev, in hidma_mgmt_setup()
90 if (mgmtdev->max_rd_xactions > HIDMA_MAX_RD_XACTIONS_MASK) { in hidma_mgmt_setup()
91 dev_err(&mgmtdev->pdev->dev, in hidma_mgmt_setup()
97 for (i = 0; i < mgmtdev->dma_channels; i++) { in hidma_mgmt_setup()
98 if (mgmtdev->priority[i] > 1) { in hidma_mgmt_setup()
99 dev_err(&mgmtdev->pdev->dev, in hidma_mgmt_setup()
104 if (mgmtdev->weight[i] > HIDMA_MAX_CHANNEL_WEIGHT) { in hidma_mgmt_setup()
105 dev_err(&mgmtdev->pdev->dev, in hidma_mgmt_setup()
112 if (mgmtdev->weight[i] == 0) in hidma_mgmt_setup()
113 mgmtdev->weight[i] = 1; in hidma_mgmt_setup()
116 pm_runtime_get_sync(&mgmtdev->pdev->dev); in hidma_mgmt_setup()
117 val = readl(mgmtdev->virtaddr + HIDMA_MAX_BUS_REQ_LEN_OFFSET); in hidma_mgmt_setup()
119 val |= mgmtdev->max_write_request << HIDMA_MAX_BUS_WR_REQ_BIT_POS; in hidma_mgmt_setup()
121 val |= mgmtdev->max_read_request; in hidma_mgmt_setup()
122 writel(val, mgmtdev->virtaddr + HIDMA_MAX_BUS_REQ_LEN_OFFSET); in hidma_mgmt_setup()
124 val = readl(mgmtdev->virtaddr + HIDMA_MAX_XACTIONS_OFFSET); in hidma_mgmt_setup()
126 val |= mgmtdev->max_wr_xactions << HIDMA_MAX_WR_XACTIONS_BIT_POS; in hidma_mgmt_setup()
128 val |= mgmtdev->max_rd_xactions; in hidma_mgmt_setup()
129 writel(val, mgmtdev->virtaddr + HIDMA_MAX_XACTIONS_OFFSET); in hidma_mgmt_setup()
131 mgmtdev->hw_version = in hidma_mgmt_setup()
132 readl(mgmtdev->virtaddr + HIDMA_HW_VERSION_OFFSET); in hidma_mgmt_setup()
133 mgmtdev->hw_version_major = (mgmtdev->hw_version >> 28) & 0xF; in hidma_mgmt_setup()
134 mgmtdev->hw_version_minor = (mgmtdev->hw_version >> 16) & 0xF; in hidma_mgmt_setup()
136 for (i = 0; i < mgmtdev->dma_channels; i++) { in hidma_mgmt_setup()
137 u32 weight = mgmtdev->weight[i]; in hidma_mgmt_setup()
138 u32 priority = mgmtdev->priority[i]; in hidma_mgmt_setup()
140 val = readl(mgmtdev->virtaddr + HIDMA_QOS_N_OFFSET + (4 * i)); in hidma_mgmt_setup()
145 writel(val, mgmtdev->virtaddr + HIDMA_QOS_N_OFFSET + (4 * i)); in hidma_mgmt_setup()
148 val = readl(mgmtdev->virtaddr + HIDMA_CHRESET_TIMEOUT_OFFSET); in hidma_mgmt_setup()
150 val |= mgmtdev->chreset_timeout_cycles & HIDMA_CHRESET_TIMEOUT_MASK; in hidma_mgmt_setup()
151 writel(val, mgmtdev->virtaddr + HIDMA_CHRESET_TIMEOUT_OFFSET); in hidma_mgmt_setup()
153 pm_runtime_mark_last_busy(&mgmtdev->pdev->dev); in hidma_mgmt_setup()
154 pm_runtime_put_autosuspend(&mgmtdev->pdev->dev); in hidma_mgmt_setup()
161 struct hidma_mgmt_dev *mgmtdev; in hidma_mgmt_probe() local
186 mgmtdev = devm_kzalloc(&pdev->dev, sizeof(*mgmtdev), GFP_KERNEL); in hidma_mgmt_probe()
187 if (!mgmtdev) { in hidma_mgmt_probe()
192 mgmtdev->pdev = pdev; in hidma_mgmt_probe()
193 mgmtdev->addrsize = resource_size(res); in hidma_mgmt_probe()
194 mgmtdev->virtaddr = virtaddr; in hidma_mgmt_probe()
197 &mgmtdev->dma_channels); in hidma_mgmt_probe()
205 &mgmtdev->chreset_timeout_cycles); in hidma_mgmt_probe()
212 &mgmtdev->max_write_request); in hidma_mgmt_probe()
219 (max_write_request != mgmtdev->max_write_request)) { in hidma_mgmt_probe()
222 mgmtdev->max_write_request = max_write_request; in hidma_mgmt_probe()
224 max_write_request = mgmtdev->max_write_request; in hidma_mgmt_probe()
227 &mgmtdev->max_read_request); in hidma_mgmt_probe()
233 (max_read_request != mgmtdev->max_read_request)) { in hidma_mgmt_probe()
236 mgmtdev->max_read_request = max_read_request; in hidma_mgmt_probe()
238 max_read_request = mgmtdev->max_read_request; in hidma_mgmt_probe()
241 &mgmtdev->max_wr_xactions); in hidma_mgmt_probe()
247 (max_wr_xactions != mgmtdev->max_wr_xactions)) { in hidma_mgmt_probe()
250 mgmtdev->max_wr_xactions = max_wr_xactions; in hidma_mgmt_probe()
252 max_wr_xactions = mgmtdev->max_wr_xactions; in hidma_mgmt_probe()
255 &mgmtdev->max_rd_xactions); in hidma_mgmt_probe()
261 (max_rd_xactions != mgmtdev->max_rd_xactions)) { in hidma_mgmt_probe()
264 mgmtdev->max_rd_xactions = max_rd_xactions; in hidma_mgmt_probe()
266 max_rd_xactions = mgmtdev->max_rd_xactions; in hidma_mgmt_probe()
268 mgmtdev->priority = devm_kcalloc(&pdev->dev, in hidma_mgmt_probe()
269 mgmtdev->dma_channels, in hidma_mgmt_probe()
270 sizeof(*mgmtdev->priority), in hidma_mgmt_probe()
272 if (!mgmtdev->priority) { in hidma_mgmt_probe()
277 mgmtdev->weight = devm_kcalloc(&pdev->dev, in hidma_mgmt_probe()
278 mgmtdev->dma_channels, in hidma_mgmt_probe()
279 sizeof(*mgmtdev->weight), GFP_KERNEL); in hidma_mgmt_probe()
280 if (!mgmtdev->weight) { in hidma_mgmt_probe()
285 rc = hidma_mgmt_setup(mgmtdev); in hidma_mgmt_probe()
292 val = readl(mgmtdev->virtaddr + HIDMA_CFG_OFFSET); in hidma_mgmt_probe()
294 writel(val, mgmtdev->virtaddr + HIDMA_CFG_OFFSET); in hidma_mgmt_probe()
296 rc = hidma_mgmt_init_sys(mgmtdev); in hidma_mgmt_probe()
304 mgmtdev->hw_version_major, mgmtdev->hw_version_minor, in hidma_mgmt_probe()
305 &res->start, mgmtdev->dma_channels); in hidma_mgmt_probe()
307 platform_set_drvdata(pdev, mgmtdev); in hidma_mgmt_probe()