Lines Matching +full:cell +full:- +full:count

1 // SPDX-License-Identifier: GPL-2.0+
22 #define DRV_NAME "hisi-lpc"
50 #define LPC_REG_OP_LEN 0x10 /* LPC cycles count per start */
84 return (status & LPC_REG_OP_STATUS_FINISHED) ? 0 : -EIO; in wait_lpc_idle()
86 } while (--waitcnt); in wait_lpc_idle()
88 return -ETIMEDOUT; in wait_lpc_idle()
92 * hisi_lpc_target_in - trigger a series of LPC cycles for read operation
99 * Returns 0 on success, non-zero on fail.
110 if (!buf || !opcnt || !para || !para->csize || !lpcdev) in hisi_lpc_target_in()
111 return -EINVAL; in hisi_lpc_target_in()
115 if (!(para->opflags & FG_INCRADDR_LPC)) { in hisi_lpc_target_in()
121 spin_lock_irqsave(&lpcdev->cycle_lock, flags); in hisi_lpc_target_in()
123 writel_relaxed(opcnt, lpcdev->membase + LPC_REG_OP_LEN); in hisi_lpc_target_in()
124 writel_relaxed(cmd_word, lpcdev->membase + LPC_REG_CMD); in hisi_lpc_target_in()
125 writel_relaxed(addr, lpcdev->membase + LPC_REG_ADDR); in hisi_lpc_target_in()
128 lpcdev->membase + LPC_REG_STARTUP_SIGNAL); in hisi_lpc_target_in()
131 ret = wait_lpc_idle(lpcdev->membase, waitcnt); in hisi_lpc_target_in()
133 spin_unlock_irqrestore(&lpcdev->cycle_lock, flags); in hisi_lpc_target_in()
137 readsb(lpcdev->membase + LPC_REG_RDATA, buf, opcnt); in hisi_lpc_target_in()
139 spin_unlock_irqrestore(&lpcdev->cycle_lock, flags); in hisi_lpc_target_in()
145 * hisi_lpc_target_out - trigger a series of LPC cycles for write operation
152 * Returns 0 on success, non-zero on fail.
164 return -EINVAL; in hisi_lpc_target_out()
169 if (!(para->opflags & FG_INCRADDR_LPC)) { in hisi_lpc_target_out()
174 spin_lock_irqsave(&lpcdev->cycle_lock, flags); in hisi_lpc_target_out()
176 writel_relaxed(opcnt, lpcdev->membase + LPC_REG_OP_LEN); in hisi_lpc_target_out()
177 writel_relaxed(cmd_word, lpcdev->membase + LPC_REG_CMD); in hisi_lpc_target_out()
178 writel_relaxed(addr, lpcdev->membase + LPC_REG_ADDR); in hisi_lpc_target_out()
180 writesb(lpcdev->membase + LPC_REG_WDATA, buf, opcnt); in hisi_lpc_target_out()
183 lpcdev->membase + LPC_REG_STARTUP_SIGNAL); in hisi_lpc_target_out()
186 ret = wait_lpc_idle(lpcdev->membase, waitcnt); in hisi_lpc_target_out()
188 spin_unlock_irqrestore(&lpcdev->cycle_lock, flags); in hisi_lpc_target_out()
196 return pio - lpcdev->io_host->io_start + lpcdev->io_host->hw_start; in hisi_lpc_pio_to_addr()
200 * hisi_lpc_comm_in - input the data in a single operation
232 * hisi_lpc_comm_out - output the data in a single operation
262 * hisi_lpc_comm_ins - input the data in the buffer in multiple operations
267 * @count: how many data units whose length is dwidth will be read
270 * Returns 0 on success, -errno otherwise.
273 size_t dwidth, unsigned int count) in hisi_lpc_comm_ins() argument
280 if (!lpcdev || !buf || !count || !dwidth || dwidth > LPC_MAX_DWIDTH) in hisi_lpc_comm_ins()
281 return -EINVAL; in hisi_lpc_comm_ins()
297 } while (--count); in hisi_lpc_comm_ins()
303 * hisi_lpc_comm_outs - output the data in the buffer in multiple operations
308 * @count: how many data units whose length is dwidth will be written
312 unsigned int count) in hisi_lpc_comm_outs() argument
319 if (!lpcdev || !buf || !count || !dwidth || dwidth > LPC_MAX_DWIDTH) in hisi_lpc_comm_outs()
332 } while (--count); in hisi_lpc_comm_outs()
350 sys_port = logic_pio_trans_hwaddr(acpi_fwnode_handle(host), res->start, len); in hisi_lpc_acpi_xlat_io_res()
352 return -EFAULT; in hisi_lpc_acpi_xlat_io_res()
354 res->start = sys_port; in hisi_lpc_acpi_xlat_io_res()
355 res->end = sys_port + len; in hisi_lpc_acpi_xlat_io_res()
368 if (r->end != 0x3fff) in hisi_lpc_acpi_fixup_child_resource()
371 if (r->start == 0xe4) in hisi_lpc_acpi_fixup_child_resource()
372 r->end = 0xe4 + 0x04 - 1; in hisi_lpc_acpi_fixup_child_resource()
373 else if (r->start == 0x2f8) in hisi_lpc_acpi_fixup_child_resource()
374 r->end = 0x2f8 + 0x08 - 1; in hisi_lpc_acpi_fixup_child_resource()
381 * hisi_lpc_acpi_set_io_res - set the resources for a child
390 * host-relative address resource. This function will return the translated
397 struct acpi_device *host = to_acpi_device(adev->dev.parent); in hisi_lpc_acpi_set_io_res()
401 int count; in hisi_lpc_acpi_set_io_res() local
404 if (!adev->status.present) { in hisi_lpc_acpi_set_io_res()
405 dev_dbg(&adev->dev, "device is not present\n"); in hisi_lpc_acpi_set_io_res()
406 return -EIO; in hisi_lpc_acpi_set_io_res()
410 dev_dbg(&adev->dev, "has been enumerated\n"); in hisi_lpc_acpi_set_io_res()
411 return -EIO; in hisi_lpc_acpi_set_io_res()
419 count = acpi_dev_get_resources(adev, &resource_list, NULL, NULL); in hisi_lpc_acpi_set_io_res()
420 if (count <= 0) { in hisi_lpc_acpi_set_io_res()
421 dev_dbg(&adev->dev, "failed to get resources\n"); in hisi_lpc_acpi_set_io_res()
422 return count ? count : -EIO; in hisi_lpc_acpi_set_io_res()
425 resources = devm_kcalloc(hostdev, count, sizeof(*resources), in hisi_lpc_acpi_set_io_res()
429 count); in hisi_lpc_acpi_set_io_res()
431 return -ENOMEM; in hisi_lpc_acpi_set_io_res()
433 count = 0; in hisi_lpc_acpi_set_io_res()
435 resources[count] = *rentry->res; in hisi_lpc_acpi_set_io_res()
436 hisi_lpc_acpi_fixup_child_resource(hostdev, &resources[count]); in hisi_lpc_acpi_set_io_res()
437 count++; in hisi_lpc_acpi_set_io_res()
443 for (i = 0; i < count; i++) { in hisi_lpc_acpi_set_io_res()
450 dev_err(&adev->dev, "translate IO range %pR failed (%d)\n", in hisi_lpc_acpi_set_io_res()
456 *num_res = count; in hisi_lpc_acpi_set_io_res()
489 const struct hisi_lpc_acpi_cell *cell; in hisi_lpc_acpi_add_child() local
502 cell = (struct hisi_lpc_acpi_cell []){ in hisi_lpc_acpi_add_child()
510 .name = "hisi-lpc-ipmi", in hisi_lpc_acpi_add_child()
517 /* 8250-compatible uart */ in hisi_lpc_acpi_add_child()
530 .iobase = res->start, in hisi_lpc_acpi_add_child()
544 for (; cell && cell->hid; cell++) { in hisi_lpc_acpi_add_child()
545 if (!strcmp(cell->hid, hid)) { in hisi_lpc_acpi_add_child()
553 "could not find cell for child device (%s), discarding\n", in hisi_lpc_acpi_add_child()
558 pdev = platform_device_register_full(cell->pdevinfo); in hisi_lpc_acpi_add_child()
567 * hisi_lpc_acpi_probe - probe children for ACPI FW
591 return -ENODEV; in hisi_lpc_acpi_probe()
600 * hisi_lpc_probe - the probe callback function for hisi lpc host,
604 * Returns 0 on success, non-zero on fail.
608 struct device *dev = &pdev->dev; in hisi_lpc_probe()
616 return -ENOMEM; in hisi_lpc_probe()
618 spin_lock_init(&lpcdev->cycle_lock); in hisi_lpc_probe()
620 lpcdev->membase = devm_platform_ioremap_resource(pdev, 0); in hisi_lpc_probe()
621 if (IS_ERR(lpcdev->membase)) in hisi_lpc_probe()
622 return PTR_ERR(lpcdev->membase); in hisi_lpc_probe()
626 return -ENOMEM; in hisi_lpc_probe()
628 range->fwnode = dev_fwnode(dev); in hisi_lpc_probe()
629 range->flags = LOGIC_PIO_INDIRECT; in hisi_lpc_probe()
630 range->size = PIO_INDIRECT_SIZE; in hisi_lpc_probe()
631 range->hostdata = lpcdev; in hisi_lpc_probe()
632 range->ops = &hisi_lpc_ops; in hisi_lpc_probe()
633 lpcdev->io_host = range; in hisi_lpc_probe()
642 if (is_acpi_device_node(range->fwnode)) in hisi_lpc_probe()
645 ret = of_platform_populate(dev->of_node, NULL, NULL, dev); in hisi_lpc_probe()
653 io_end = lpcdev->io_host->io_start + lpcdev->io_host->size; in hisi_lpc_probe()
654 dev_info(dev, "registered range [%pa - %pa]\n", in hisi_lpc_probe()
655 &lpcdev->io_host->io_start, &io_end); in hisi_lpc_probe()
662 struct device *dev = &pdev->dev; in hisi_lpc_remove()
664 struct logic_pio_hwaddr *range = lpcdev->io_host; in hisi_lpc_remove()
666 if (is_acpi_device_node(range->fwnode)) in hisi_lpc_remove()
675 { .compatible = "hisilicon,hip06-lpc", },
676 { .compatible = "hisilicon,hip07-lpc", },