Lines Matching +full:am654 +full:- +full:hbmc

1 // SPDX-License-Identifier: GPL-2.0
3 // Copyright (C) 2019 Texas Instruments Incorporated - https://www.ti.com/
7 #include <linux/dma-direction.h>
8 #include <linux/dma-mapping.h>
40 struct map_info *map = &hbdev->map; in am654_hbmc_calibrate()
51 while (count--) { in am654_hbmc_calibrate()
70 complete(&priv->rx_dma_complete); in am654_hbmc_dma_callback()
78 struct dma_chan *rx_chan = priv->rx_chan; in am654_hbmc_dma_read()
84 if (!priv->rx_chan || !virt_addr_valid(to) || object_is_on_stack(to)) in am654_hbmc_dma_read()
85 return -EINVAL; in am654_hbmc_dma_read()
87 dma_dst = dma_map_single(rx_chan->device->dev, to, len, DMA_FROM_DEVICE); in am654_hbmc_dma_read()
88 if (dma_mapping_error(rx_chan->device->dev, dma_dst)) { in am654_hbmc_dma_read()
89 dev_dbg(priv->ctlr->dev, "DMA mapping failed\n"); in am654_hbmc_dma_read()
90 return -EIO; in am654_hbmc_dma_read()
93 dma_src = priv->device_base + from; in am654_hbmc_dma_read()
96 dev_err(priv->ctlr->dev, "device_prep_dma_memcpy error\n"); in am654_hbmc_dma_read()
97 ret = -EIO; in am654_hbmc_dma_read()
101 reinit_completion(&priv->rx_dma_complete); in am654_hbmc_dma_read()
102 tx->callback = am654_hbmc_dma_callback; in am654_hbmc_dma_read()
103 tx->callback_param = priv; in am654_hbmc_dma_read()
108 dev_err(priv->ctlr->dev, "dma_submit_error %d\n", cookie); in am654_hbmc_dma_read()
113 if (!wait_for_completion_timeout(&priv->rx_dma_complete, msecs_to_jiffies(len + 1000))) { in am654_hbmc_dma_read()
115 dev_err(priv->ctlr->dev, "DMA wait_for_completion_timeout\n"); in am654_hbmc_dma_read()
116 ret = -ETIMEDOUT; in am654_hbmc_dma_read()
120 dma_unmap_single(rx_chan->device->dev, dma_dst, len, DMA_FROM_DEVICE); in am654_hbmc_dma_read()
127 struct am654_hbmc_device_priv *priv = hbdev->priv; in am654_hbmc_read()
130 memcpy_fromio(to, hbdev->map.virt + from, len); in am654_hbmc_read()
148 if (PTR_ERR(rx_chan) == -EPROBE_DEFER) in am654_hbmc_request_mmap_dma()
149 return -EPROBE_DEFER; in am654_hbmc_request_mmap_dma()
150 dev_dbg(priv->ctlr->dev, "No DMA channel available\n"); in am654_hbmc_request_mmap_dma()
153 priv->rx_chan = rx_chan; in am654_hbmc_request_mmap_dma()
154 init_completion(&priv->rx_dma_complete); in am654_hbmc_request_mmap_dma()
161 struct device_node *np = pdev->dev.of_node; in am654_hbmc_probe()
163 struct device *dev = &pdev->dev; in am654_hbmc_probe()
170 return -ENOMEM; in am654_hbmc_probe()
174 priv->hbdev.np = of_get_next_child(np, NULL); in am654_hbmc_probe()
175 ret = of_address_to_resource(priv->hbdev.np, 0, &res); in am654_hbmc_probe()
179 if (of_property_read_bool(dev->of_node, "mux-controls")) { in am654_hbmc_probe()
187 dev_err(dev, "Failed to select HBMC mux\n"); in am654_hbmc_probe()
190 priv->mux_ctrl = control; in am654_hbmc_probe()
193 priv->hbdev.map.size = resource_size(&res); in am654_hbmc_probe()
194 priv->hbdev.map.virt = devm_ioremap_resource(dev, &res); in am654_hbmc_probe()
195 if (IS_ERR(priv->hbdev.map.virt)) in am654_hbmc_probe()
196 return PTR_ERR(priv->hbdev.map.virt); in am654_hbmc_probe()
198 priv->ctlr.dev = dev; in am654_hbmc_probe()
199 priv->ctlr.ops = &am654_hbmc_ops; in am654_hbmc_probe()
200 priv->hbdev.ctlr = &priv->ctlr; in am654_hbmc_probe()
204 ret = -ENOMEM; in am654_hbmc_probe()
208 priv->hbdev.priv = dev_priv; in am654_hbmc_probe()
209 dev_priv->device_base = res.start; in am654_hbmc_probe()
210 dev_priv->ctlr = &priv->ctlr; in am654_hbmc_probe()
216 ret = hyperbus_register_device(&priv->hbdev); in am654_hbmc_probe()
224 if (dev_priv->rx_chan) in am654_hbmc_probe()
225 dma_release_channel(dev_priv->rx_chan); in am654_hbmc_probe()
227 if (priv->mux_ctrl) in am654_hbmc_probe()
228 mux_control_deselect(priv->mux_ctrl); in am654_hbmc_probe()
235 struct am654_hbmc_device_priv *dev_priv = priv->hbdev.priv; in am654_hbmc_remove()
237 hyperbus_unregister_device(&priv->hbdev); in am654_hbmc_remove()
239 if (priv->mux_ctrl) in am654_hbmc_remove()
240 mux_control_deselect(priv->mux_ctrl); in am654_hbmc_remove()
242 if (dev_priv->rx_chan) in am654_hbmc_remove()
243 dma_release_channel(dev_priv->rx_chan); in am654_hbmc_remove()
248 .compatible = "ti,am654-hbmc",
259 .name = "hbmc-am654",
266 MODULE_DESCRIPTION("HBMC driver for AM654 SoC");
268 MODULE_ALIAS("platform:hbmc-am654");