Lines Matching +full:non +full:- +full:flash
1 // SPDX-License-Identifier: GPL-2.0
48 * struct tb_dma_port - DMA control port
68 u64 route = tb_cfg_get_route(pkg->buffer) & ~BIT_ULL(63); in dma_port_match()
70 if (pkg->frame.eof == TB_CFG_PKG_ERROR) in dma_port_match()
72 if (pkg->frame.eof != req->response_type) in dma_port_match()
74 if (route != tb_cfg_get_route(req->request)) in dma_port_match()
76 if (pkg->frame.size != req->response_size) in dma_port_match()
84 memcpy(req->response, pkg->buffer, req->response_size); in dma_port_copy()
107 return -ENOMEM; in dma_port_read()
109 req->match = dma_port_match; in dma_port_read()
110 req->copy = dma_port_copy; in dma_port_read()
111 req->request = &request; in dma_port_read()
112 req->request_size = sizeof(request); in dma_port_read()
113 req->request_type = TB_CFG_PKG_READ; in dma_port_read()
114 req->response = &reply; in dma_port_read()
115 req->response_size = 12 + 4 * length; in dma_port_read()
116 req->response_type = TB_CFG_PKG_READ; in dma_port_read()
150 return -ENOMEM; in dma_port_write()
152 req->match = dma_port_match; in dma_port_write()
153 req->copy = dma_port_copy; in dma_port_write()
154 req->request = &request; in dma_port_write()
155 req->request_size = 12 + 4 * length; in dma_port_write()
156 req->request_type = TB_CFG_PKG_WRITE; in dma_port_write()
157 req->response = &reply; in dma_port_write()
158 req->response_size = sizeof(reply); in dma_port_write()
159 req->response_type = TB_CFG_PKG_WRITE; in dma_port_write()
181 ret = dma_port_read(sw->tb->ctl, &type, tb_route(sw), ports[i], in dma_find_port()
187 return -ENODEV; in dma_find_port()
191 * dma_port_alloc() - Finds DMA control port from a switch pointed by route
214 dma->buf = kmalloc_array(MAIL_DATA_DWORDS, sizeof(u32), GFP_KERNEL); in dma_port_alloc()
215 if (!dma->buf) { in dma_port_alloc()
220 dma->sw = sw; in dma_port_alloc()
221 dma->port = port; in dma_port_alloc()
222 dma->base = DMA_PORT_CAP; in dma_port_alloc()
228 * dma_port_free() - Release DMA control port structure
234 kfree(dma->buf); in dma_port_free()
243 struct tb_switch *sw = dma->sw; in dma_port_wait_for_completion()
249 ret = dma_port_read(sw->tb->ctl, &in, tb_route(sw), dma->port, in dma_port_wait_for_completion()
250 dma->base + MAIL_IN, 1, 50); in dma_port_wait_for_completion()
252 if (ret != -ETIMEDOUT) in dma_port_wait_for_completion()
261 return -ETIMEDOUT; in dma_port_wait_for_completion()
270 return -EINVAL; in status_to_errno()
272 return -EACCES; in status_to_errno()
275 return -EIO; in status_to_errno()
281 struct tb_switch *sw = dma->sw; in dma_port_request()
285 ret = dma_port_write(sw->tb->ctl, &in, tb_route(sw), dma->port, in dma_port_request()
286 dma->base + MAIL_IN, 1, DMA_PORT_TIMEOUT); in dma_port_request()
294 ret = dma_port_read(sw->tb->ctl, &out, tb_route(sw), dma->port, in dma_port_request()
295 dma->base + MAIL_OUT, 1, DMA_PORT_TIMEOUT); in dma_port_request()
306 struct tb_switch *sw = dma->sw; in dma_port_flash_read_block()
320 return dma_port_read(sw->tb->ctl, buf, tb_route(sw), dma->port, in dma_port_flash_read_block()
321 dma->base + MAIL_DATA, dwords, DMA_PORT_TIMEOUT); in dma_port_flash_read_block()
328 struct tb_switch *sw = dma->sw; in dma_port_flash_write_block()
333 ret = dma_port_write(sw->tb->ctl, buf, tb_route(sw), dma->port, in dma_port_flash_write_block()
334 dma->base + MAIL_DATA, dwords, DMA_PORT_TIMEOUT); in dma_port_flash_write_block()
344 in |= ((dwords - 1) << MAIL_IN_DWORDS_SHIFT) & MAIL_IN_DWORDS_MASK; in dma_port_flash_write_block()
352 * dma_port_flash_read() - Read from active flash region
366 * dma_port_flash_write() - Write to non-active flash region
368 * @address: Address relative to the start of non-active region
372 * Writes block of data to the non-active flash region of the switch. If
380 return -E2BIG; in dma_port_flash_write()
387 * dma_port_flash_update_auth() - Starts flash authenticate cycle
390 * Starts the flash update authentication cycle. If the image in the
391 * non-active area was valid, the switch starts upgrade process where
392 * active and non-active area get swapped in the end. Caller should call
408 * dma_port_flash_update_auth_status() - Reads status of update auth command
422 struct tb_switch *sw = dma->sw; in dma_port_flash_update_auth_status()
426 ret = dma_port_read(sw->tb->ctl, &out, tb_route(sw), dma->port, in dma_port_flash_update_auth_status()
427 dma->base + MAIL_OUT, 1, DMA_PORT_TIMEOUT); in dma_port_flash_update_auth_status()
431 /* Check if the status relates to flash update auth */ in dma_port_flash_update_auth_status()
445 * dma_port_power_cycle() - Power cycles the switch