Lines Matching +full:burst +full:- +full:read
1 // SPDX-License-Identifier: GPL-2.0-only
5 * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
17 #include <linux/dma-mapping.h>
45 "maximum write burst (default: ACPI/DT value)");
50 "maximum read burst (default: ACPI/DT value)");
60 "maximum number of read transactions (default: ACPI/DT value)");
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()
72 return -EINVAL; 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()
80 return -EINVAL; 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()
87 return -EINVAL; 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()
94 return -EINVAL; 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()
101 return -EINVAL; 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()
108 return -EINVAL; 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()
168 pm_runtime_set_autosuspend_delay(&pdev->dev, HIDMA_AUTOSUSPEND_TIMEOUT); in hidma_mgmt_probe()
169 pm_runtime_use_autosuspend(&pdev->dev); in hidma_mgmt_probe()
170 pm_runtime_set_active(&pdev->dev); in hidma_mgmt_probe()
171 pm_runtime_enable(&pdev->dev); in hidma_mgmt_probe()
172 pm_runtime_get_sync(&pdev->dev); in hidma_mgmt_probe()
186 mgmtdev = devm_kzalloc(&pdev->dev, sizeof(*mgmtdev), GFP_KERNEL); in hidma_mgmt_probe()
188 rc = -ENOMEM; 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()
196 rc = device_property_read_u32(&pdev->dev, "dma-channels", in hidma_mgmt_probe()
197 &mgmtdev->dma_channels); in hidma_mgmt_probe()
199 dev_err(&pdev->dev, "number of channels missing\n"); in hidma_mgmt_probe()
203 rc = device_property_read_u32(&pdev->dev, in hidma_mgmt_probe()
204 "channel-reset-timeout-cycles", in hidma_mgmt_probe()
205 &mgmtdev->chreset_timeout_cycles); in hidma_mgmt_probe()
207 dev_err(&pdev->dev, "channel reset timeout missing\n"); in hidma_mgmt_probe()
211 rc = device_property_read_u32(&pdev->dev, "max-write-burst-bytes", in hidma_mgmt_probe()
212 &mgmtdev->max_write_request); in hidma_mgmt_probe()
214 dev_err(&pdev->dev, "max-write-burst-bytes missing\n"); in hidma_mgmt_probe()
219 (max_write_request != mgmtdev->max_write_request)) { in hidma_mgmt_probe()
220 dev_info(&pdev->dev, "overriding max-write-burst-bytes: %d\n", 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()
226 rc = device_property_read_u32(&pdev->dev, "max-read-burst-bytes", in hidma_mgmt_probe()
227 &mgmtdev->max_read_request); in hidma_mgmt_probe()
229 dev_err(&pdev->dev, "max-read-burst-bytes missing\n"); in hidma_mgmt_probe()
233 (max_read_request != mgmtdev->max_read_request)) { in hidma_mgmt_probe()
234 dev_info(&pdev->dev, "overriding max-read-burst-bytes: %d\n", 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()
240 rc = device_property_read_u32(&pdev->dev, "max-write-transactions", in hidma_mgmt_probe()
241 &mgmtdev->max_wr_xactions); in hidma_mgmt_probe()
243 dev_err(&pdev->dev, "max-write-transactions missing\n"); in hidma_mgmt_probe()
247 (max_wr_xactions != mgmtdev->max_wr_xactions)) { in hidma_mgmt_probe()
248 dev_info(&pdev->dev, "overriding max-write-transactions: %d\n", 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()
254 rc = device_property_read_u32(&pdev->dev, "max-read-transactions", in hidma_mgmt_probe()
255 &mgmtdev->max_rd_xactions); in hidma_mgmt_probe()
257 dev_err(&pdev->dev, "max-read-transactions missing\n"); in hidma_mgmt_probe()
261 (max_rd_xactions != mgmtdev->max_rd_xactions)) { in hidma_mgmt_probe()
262 dev_info(&pdev->dev, "overriding max-read-transactions: %d\n", 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()
273 rc = -ENOMEM; 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()
281 rc = -ENOMEM; in hidma_mgmt_probe()
287 dev_err(&pdev->dev, "setup failed\n"); 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()
298 dev_err(&pdev->dev, "sysfs setup failed\n"); in hidma_mgmt_probe()
302 dev_info(&pdev->dev, 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()
308 pm_runtime_mark_last_busy(&pdev->dev); in hidma_mgmt_probe()
309 pm_runtime_put_autosuspend(&pdev->dev); in hidma_mgmt_probe()
312 pm_runtime_put_sync_suspend(&pdev->dev); in hidma_mgmt_probe()
313 pm_runtime_disable(&pdev->dev); in hidma_mgmt_probe()
328 .name = "hidma-mgmt",