Lines Matching refs:dev

24 void	ishtp_cl_alloc_dma_buf(struct ishtp_device *dev)  in ishtp_cl_alloc_dma_buf()  argument
28 if (dev->ishtp_host_dma_tx_buf) in ishtp_cl_alloc_dma_buf()
31 dev->ishtp_host_dma_tx_buf_size = 1024*1024; in ishtp_cl_alloc_dma_buf()
32 dev->ishtp_host_dma_rx_buf_size = 1024*1024; in ishtp_cl_alloc_dma_buf()
35 dev->ishtp_host_dma_tx_buf = dma_alloc_coherent(dev->devc, in ishtp_cl_alloc_dma_buf()
36 dev->ishtp_host_dma_tx_buf_size, in ishtp_cl_alloc_dma_buf()
38 if (dev->ishtp_host_dma_tx_buf) in ishtp_cl_alloc_dma_buf()
39 dev->ishtp_host_dma_tx_buf_phys = h; in ishtp_cl_alloc_dma_buf()
41 dev->ishtp_dma_num_slots = dev->ishtp_host_dma_tx_buf_size / in ishtp_cl_alloc_dma_buf()
44 dev->ishtp_dma_tx_map = kcalloc(dev->ishtp_dma_num_slots, in ishtp_cl_alloc_dma_buf()
47 spin_lock_init(&dev->ishtp_dma_tx_lock); in ishtp_cl_alloc_dma_buf()
50 dev->ishtp_host_dma_rx_buf = dma_alloc_coherent(dev->devc, in ishtp_cl_alloc_dma_buf()
51 dev->ishtp_host_dma_rx_buf_size, in ishtp_cl_alloc_dma_buf()
54 if (dev->ishtp_host_dma_rx_buf) in ishtp_cl_alloc_dma_buf()
55 dev->ishtp_host_dma_rx_buf_phys = h; in ishtp_cl_alloc_dma_buf()
66 void ishtp_cl_free_dma_buf(struct ishtp_device *dev) in ishtp_cl_free_dma_buf() argument
70 if (dev->ishtp_host_dma_tx_buf) { in ishtp_cl_free_dma_buf()
71 h = dev->ishtp_host_dma_tx_buf_phys; in ishtp_cl_free_dma_buf()
72 dma_free_coherent(dev->devc, dev->ishtp_host_dma_tx_buf_size, in ishtp_cl_free_dma_buf()
73 dev->ishtp_host_dma_tx_buf, h); in ishtp_cl_free_dma_buf()
76 if (dev->ishtp_host_dma_rx_buf) { in ishtp_cl_free_dma_buf()
77 h = dev->ishtp_host_dma_rx_buf_phys; in ishtp_cl_free_dma_buf()
78 dma_free_coherent(dev->devc, dev->ishtp_host_dma_rx_buf_size, in ishtp_cl_free_dma_buf()
79 dev->ishtp_host_dma_rx_buf, h); in ishtp_cl_free_dma_buf()
82 kfree(dev->ishtp_dma_tx_map); in ishtp_cl_free_dma_buf()
83 dev->ishtp_host_dma_tx_buf = NULL; in ishtp_cl_free_dma_buf()
84 dev->ishtp_host_dma_rx_buf = NULL; in ishtp_cl_free_dma_buf()
85 dev->ishtp_dma_tx_map = NULL; in ishtp_cl_free_dma_buf()
98 void *ishtp_cl_get_dma_send_buf(struct ishtp_device *dev, in ishtp_cl_get_dma_send_buf() argument
107 if (!dev->ishtp_dma_tx_map) { in ishtp_cl_get_dma_send_buf()
108 dev_err(dev->devc, "Fail to allocate Tx map\n"); in ishtp_cl_get_dma_send_buf()
112 spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags); in ishtp_cl_get_dma_send_buf()
113 for (i = 0; i <= (dev->ishtp_dma_num_slots - required_slots); i++) { in ishtp_cl_get_dma_send_buf()
116 if (dev->ishtp_dma_tx_map[i+j]) { in ishtp_cl_get_dma_send_buf()
124 dev->ishtp_dma_tx_map[i+j] = 1; in ishtp_cl_get_dma_send_buf()
125 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags); in ishtp_cl_get_dma_send_buf()
127 (unsigned char *)dev->ishtp_host_dma_tx_buf; in ishtp_cl_get_dma_send_buf()
130 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags); in ishtp_cl_get_dma_send_buf()
131 dev_err(dev->devc, "No free DMA buffer to send msg\n"); in ishtp_cl_get_dma_send_buf()
144 void ishtp_cl_release_dma_acked_mem(struct ishtp_device *dev, in ishtp_cl_release_dma_acked_mem() argument
153 if ((msg_addr - dev->ishtp_host_dma_tx_buf) % DMA_SLOT_SIZE) { in ishtp_cl_release_dma_acked_mem()
154 dev_err(dev->devc, "Bad DMA Tx ack address\n"); in ishtp_cl_release_dma_acked_mem()
158 if (!dev->ishtp_dma_tx_map) { in ishtp_cl_release_dma_acked_mem()
159 dev_err(dev->devc, "Fail to allocate Tx map\n"); in ishtp_cl_release_dma_acked_mem()
163 i = (msg_addr - dev->ishtp_host_dma_tx_buf) / DMA_SLOT_SIZE; in ishtp_cl_release_dma_acked_mem()
164 spin_lock_irqsave(&dev->ishtp_dma_tx_lock, flags); in ishtp_cl_release_dma_acked_mem()
166 if ((i + j) >= dev->ishtp_dma_num_slots || in ishtp_cl_release_dma_acked_mem()
167 !dev->ishtp_dma_tx_map[i+j]) { in ishtp_cl_release_dma_acked_mem()
169 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags); in ishtp_cl_release_dma_acked_mem()
170 dev_err(dev->devc, "Bad DMA Tx ack address\n"); in ishtp_cl_release_dma_acked_mem()
173 dev->ishtp_dma_tx_map[i+j] = 0; in ishtp_cl_release_dma_acked_mem()
175 spin_unlock_irqrestore(&dev->ishtp_dma_tx_lock, flags); in ishtp_cl_release_dma_acked_mem()