Lines Matching +full:tx +full:- +full:device

1 // SPDX-License-Identifier: GPL-2.0-only
69 /* Device Specific Completion Code (CC) Definition */
90 return req->rx.buf[0]; in peci_request_data_cc()
94 * peci_request_status() - return -errno based on PECI completion code
97 * It can't be used for Ping(), GetDIB() and GetTemp() - for those commands we
100 * Return: -errno
107 dev_dbg(&req->device->dev, "ret: %#02x\n", cc); in peci_request_status()
115 return -EAGAIN; in peci_request_status()
117 return -EINVAL; in peci_request_status()
124 return -EIO; in peci_request_status()
129 return -EIO; in peci_request_status()
135 struct peci_device *device = req->device; in peci_request_xfer() local
136 struct peci_controller *controller = to_peci_controller(device->dev.parent); in peci_request_xfer()
139 mutex_lock(&controller->bus_lock); in peci_request_xfer()
140 ret = controller->ops->xfer(controller, device->addr, req); in peci_request_xfer()
141 mutex_unlock(&controller->bus_lock); in peci_request_xfer()
149 struct peci_device *device = req->device; in peci_request_xfer_retry() local
150 struct peci_controller *controller = to_peci_controller(device->dev.parent); in peci_request_xfer_retry()
155 if (WARN_ON(req->tx.len == 0)) in peci_request_xfer_retry()
161 dev_dbg(&controller->dev, "xfer error: %d\n", ret); in peci_request_xfer_retry()
165 if (peci_request_status(req) != -EAGAIN) in peci_request_xfer_retry()
169 req->tx.buf[1] |= PECI_RETRY_BIT; in peci_request_xfer_retry()
172 return -ERESTARTSYS; in peci_request_xfer_retry()
177 dev_dbg(&controller->dev, "request timed out\n"); in peci_request_xfer_retry()
179 return -ETIMEDOUT; in peci_request_xfer_retry()
183 * peci_request_alloc() - allocate &struct peci_requests
184 * @device: PECI device to which request is going to be sent
185 * @tx_len: TX length
190 struct peci_request *peci_request_alloc(struct peci_device *device, u8 tx_len, u8 rx_len) in peci_request_alloc() argument
195 * TX and RX buffers are fixed length members of peci_request, this is in peci_request_alloc()
210 req->device = device; in peci_request_alloc()
211 req->tx.len = tx_len; in peci_request_alloc()
212 req->rx.len = rx_len; in peci_request_alloc()
219 * peci_request_free() - free peci_request
228 struct peci_request *peci_xfer_get_dib(struct peci_device *device) in peci_xfer_get_dib() argument
233 req = peci_request_alloc(device, PECI_GET_DIB_WR_LEN, PECI_GET_DIB_RD_LEN); in peci_xfer_get_dib()
235 return ERR_PTR(-ENOMEM); in peci_xfer_get_dib()
237 req->tx.buf[0] = PECI_GET_DIB_CMD; in peci_xfer_get_dib()
249 struct peci_request *peci_xfer_get_temp(struct peci_device *device) in peci_xfer_get_temp() argument
254 req = peci_request_alloc(device, PECI_GET_TEMP_WR_LEN, PECI_GET_TEMP_RD_LEN); in peci_xfer_get_temp()
256 return ERR_PTR(-ENOMEM); in peci_xfer_get_temp()
258 req->tx.buf[0] = PECI_GET_TEMP_CMD; in peci_xfer_get_temp()
271 __pkg_cfg_read(struct peci_device *device, u8 index, u16 param, u8 len) in __pkg_cfg_read() argument
276 req = peci_request_alloc(device, PECI_RDPKGCFG_WR_LEN, PECI_RDPKGCFG_RD_LEN_BASE + len); in __pkg_cfg_read()
278 return ERR_PTR(-ENOMEM); in __pkg_cfg_read()
280 req->tx.buf[0] = PECI_RDPKGCFG_CMD; in __pkg_cfg_read()
281 req->tx.buf[1] = 0; in __pkg_cfg_read()
282 req->tx.buf[2] = index; in __pkg_cfg_read()
283 put_unaligned_le16(param, &req->tx.buf[3]); in __pkg_cfg_read()
300 __pci_cfg_local_read(struct peci_device *device, u8 bus, u8 dev, u8 func, u16 reg, u8 len) in __pci_cfg_local_read() argument
306 req = peci_request_alloc(device, PECI_RDPCICFGLOCAL_WR_LEN, in __pci_cfg_local_read()
309 return ERR_PTR(-ENOMEM); in __pci_cfg_local_read()
313 req->tx.buf[0] = PECI_RDPCICFGLOCAL_CMD; in __pci_cfg_local_read()
314 req->tx.buf[1] = 0; in __pci_cfg_local_read()
315 put_unaligned_le24(pci_addr, &req->tx.buf[2]); in __pci_cfg_local_read()
327 __ep_pci_cfg_read(struct peci_device *device, u8 msg_type, u8 seg, in __ep_pci_cfg_read() argument
334 req = peci_request_alloc(device, PECI_RDENDPTCFG_PCI_WR_LEN, in __ep_pci_cfg_read()
337 return ERR_PTR(-ENOMEM); in __ep_pci_cfg_read()
341 req->tx.buf[0] = PECI_RDENDPTCFG_CMD; in __ep_pci_cfg_read()
342 req->tx.buf[1] = 0; in __ep_pci_cfg_read()
343 req->tx.buf[2] = msg_type; in __ep_pci_cfg_read()
344 req->tx.buf[3] = 0; in __ep_pci_cfg_read()
345 req->tx.buf[4] = 0; in __ep_pci_cfg_read()
346 req->tx.buf[5] = 0; in __ep_pci_cfg_read()
347 req->tx.buf[6] = PECI_ENDPTCFG_ADDR_TYPE_PCI; in __ep_pci_cfg_read()
348 req->tx.buf[7] = seg; /* PCI Segment */ in __ep_pci_cfg_read()
349 put_unaligned_le32(pci_addr, &req->tx.buf[8]); in __ep_pci_cfg_read()
361 __ep_mmio_read(struct peci_device *device, u8 bar, u8 addr_type, u8 seg, in __ep_mmio_read() argument
367 req = peci_request_alloc(device, tx_len, PECI_RDENDPTCFG_RD_LEN_BASE + len); in __ep_mmio_read()
369 return ERR_PTR(-ENOMEM); in __ep_mmio_read()
371 req->tx.buf[0] = PECI_RDENDPTCFG_CMD; in __ep_mmio_read()
372 req->tx.buf[1] = 0; in __ep_mmio_read()
373 req->tx.buf[2] = PECI_ENDPTCFG_TYPE_MMIO; in __ep_mmio_read()
374 req->tx.buf[3] = 0; /* Endpoint ID */ in __ep_mmio_read()
375 req->tx.buf[4] = 0; /* Reserved */ in __ep_mmio_read()
376 req->tx.buf[5] = bar; in __ep_mmio_read()
377 req->tx.buf[6] = addr_type; in __ep_mmio_read()
378 req->tx.buf[7] = seg; /* PCI Segment */ in __ep_mmio_read()
379 req->tx.buf[8] = PCI_DEVFN(dev, func); in __ep_mmio_read()
380 req->tx.buf[9] = bus; /* PCI Bus */ in __ep_mmio_read()
383 put_unaligned_le32(offset, &req->tx.buf[10]); in __ep_mmio_read()
385 put_unaligned_le64(offset, &req->tx.buf[10]); in __ep_mmio_read()
398 return req->rx.buf[1]; in peci_request_data_readb()
404 return get_unaligned_le16(&req->rx.buf[1]); in peci_request_data_readw()
410 return get_unaligned_le32(&req->rx.buf[1]); in peci_request_data_readl()
416 return get_unaligned_le64(&req->rx.buf[1]); in peci_request_data_readq()
422 return get_unaligned_le64(&req->rx.buf[0]); in peci_request_dib_read()
428 return get_unaligned_le16(&req->rx.buf[0]); in peci_request_temp_read()
433 struct peci_request *peci_xfer_pkg_cfg_##x(struct peci_device *device, u8 index, u16 param) \
435 return __pkg_cfg_read(device, index, param, sizeof(type)); \
446 peci_xfer_pci_cfg_local_##x(struct peci_device *device, u8 bus, u8 dev, u8 func, u16 reg) \
448 return __pci_cfg_local_read(device, bus, dev, func, reg, sizeof(type)); \
458 peci_xfer_ep_pci_cfg_##x(struct peci_device *device, u8 seg, u8 bus, u8 dev, u8 func, u16 reg) \
460 return __ep_pci_cfg_read(device, msg_type, seg, bus, dev, func, reg, sizeof(type)); \
472 struct peci_request *peci_xfer_ep_mmio##y##_##x(struct peci_device *device, u8 bar, u8 seg, \
475 return __ep_mmio_read(device, bar, addr_type, seg, bus, dev, func, \