Lines Matching +full:dpfe +full:- +full:cpu

1 // SPDX-License-Identifier: GPL-2.0-only
3 * DDR PHY Front End (DPFE) driver for Broadcom set top box SoCs
9 * This driver provides access to the DPFE interface of Broadcom STB SoCs.
21 * - LE kernel + LE firmware image (the most common case)
22 * - LE kernel + BE firmware image
23 * - BE kernel + LE firmware image
24 * - BE kernel + BE firmware image
27 * be in either format. Also, communication between host CPU and DCPU is
38 #define DRVNAME "brcmstb-dpfe"
48 #define DRAM_MSG_ADDR_MASK ((1UL << DRAM_MSG_TYPE_OFFSET) - 1)
50 (BITS_PER_LONG - DRAM_MSG_TYPE_OFFSET)) - 1)
66 #define DRAM_MR4_PPRE 0x4 /* Post-package repair entry/exit */
114 #define ERR_INVALID_MAGIC -1
115 #define ERR_INVALID_SIZE -2
116 #define ERR_INVALID_CHKSUM -3
235 .fw_name = "dpfe.bin",
313 i = ARRAY_SIZE(error_text) - 1; in get_error_text()
322 mutex_lock(&priv->lock); in is_dcpu_enabled()
323 val = readl_relaxed(priv->regs + REG_DCPU_RESET); in is_dcpu_enabled()
324 mutex_unlock(&priv->lock); in is_dcpu_enabled()
336 mutex_lock(&priv->lock); in __disable_dcpu()
339 val = readl_relaxed(priv->regs + REG_DCPU_RESET); in __disable_dcpu()
341 writel_relaxed(val, priv->regs + REG_DCPU_RESET); in __disable_dcpu()
343 mutex_unlock(&priv->lock); in __disable_dcpu()
348 void __iomem *regs = priv->regs; in __enable_dcpu()
351 mutex_lock(&priv->lock); in __enable_dcpu()
367 mutex_unlock(&priv->lock); in __enable_dcpu()
390 if (unlikely(priv->dpfe_api->version >= 3)) in get_msg_ptr()
404 ptr = priv->regs + DCPU_MSG_RAM_START + offset; in get_msg_ptr()
407 ptr = priv->dmem + offset; in get_msg_ptr()
410 dev_emerg(priv->dev, "invalid message reply from DCPU: %#x\n", in get_msg_ptr()
428 release_mbox = (priv->dpfe_api->version < 2) in __finalize_command()
430 writel_relaxed(0, priv->regs + release_mbox); in __finalize_command()
436 void __iomem *regs = priv->regs; in __send_command()
443 return -1; in __send_command()
445 msg = priv->dpfe_api->command[cmd]; in __send_command()
447 mutex_lock(&priv->lock); in __send_command()
457 mutex_unlock(&priv->lock); in __send_command()
458 return -ffs(DCPU_RET_ERR_TIMEDOUT); in __send_command()
487 ret = -ffs(resp); in __send_command()
498 mutex_unlock(&priv->lock); in __send_command()
510 ret = -ffs(resp); in __send_command()
520 const struct dpfe_firmware_header *header = (void *)fw->data; in __verify_firmware()
525 if (header->magic == DPFE_BE_MAGIC) in __verify_firmware()
527 else if (header->magic != DPFE_LE_MAGIC) in __verify_firmware()
531 dmem_size = be32_to_cpu(header->dmem_size); in __verify_firmware()
532 imem_size = be32_to_cpu(header->imem_size); in __verify_firmware()
534 dmem_size = le32_to_cpu(header->dmem_size); in __verify_firmware()
535 imem_size = le32_to_cpu(header->imem_size); in __verify_firmware()
548 if (total_size != fw->size) in __verify_firmware()
552 chksum_ptr = (void *)fw->data + sizeof(*header) + dmem_size + imem_size; in __verify_firmware()
554 init->is_big_endian = is_big_endian; in __verify_firmware()
555 init->dmem_len = dmem_size; in __verify_firmware()
556 init->imem_len = imem_size; in __verify_firmware()
557 init->chksum = (is_big_endian) in __verify_firmware()
563 /* Verify checksum by reading back the firmware from co-processor RAM. */
570 u32 __iomem *dmem = priv->dmem; in __verify_fw_checksum()
571 u32 __iomem *imem = priv->imem; in __verify_fw_checksum()
574 if (init->is_big_endian) { in __verify_fw_checksum()
575 magic = be32_to_cpu(header->magic); in __verify_fw_checksum()
576 sequence = be32_to_cpu(header->sequence); in __verify_fw_checksum()
577 version = be32_to_cpu(header->version); in __verify_fw_checksum()
579 magic = le32_to_cpu(header->magic); in __verify_fw_checksum()
580 sequence = le32_to_cpu(header->sequence); in __verify_fw_checksum()
581 version = le32_to_cpu(header->version); in __verify_fw_checksum()
584 sum = magic + sequence + version + init->dmem_len + init->imem_len; in __verify_fw_checksum()
586 for (i = 0; i < init->dmem_len / sizeof(u32); i++) in __verify_fw_checksum()
589 for (i = 0; i < init->imem_len / sizeof(u32); i++) in __verify_fw_checksum()
592 return (sum == checksum) ? 0 : -1; in __verify_fw_checksum()
600 /* Convert size to 32-bit words. */ in __write_firmware()
623 struct device *dev = priv->dev; in brcmstb_dpfe_download_firmware()
648 if (!priv->dpfe_api->fw_name) in brcmstb_dpfe_download_firmware()
649 return -ENODEV; in brcmstb_dpfe_download_firmware()
651 ret = firmware_request_nowarn(&fw, priv->dpfe_api->fw_name, dev); in brcmstb_dpfe_download_firmware()
657 return (ret == -ENOENT) ? -EPROBE_DEFER : ret; in brcmstb_dpfe_download_firmware()
661 ret = -EFAULT; in brcmstb_dpfe_download_firmware()
672 header = (struct dpfe_firmware_header *)fw->data; in brcmstb_dpfe_download_firmware()
674 fw_blob = fw->data + sizeof(*header); in brcmstb_dpfe_download_firmware()
680 ret = __write_firmware(priv->dmem, dmem, dmem_size, is_big_endian); in brcmstb_dpfe_download_firmware()
683 ret = __write_firmware(priv->imem, imem, imem_size, is_big_endian); in brcmstb_dpfe_download_firmware()
708 return sprintf(buf, "ERROR: %s\n", get_error_text(-ret)); in generic_show()
779 return -EINVAL; in store_refresh()
788 return -EIO; in store_refresh()
859 struct device *dev = &pdev->dev; in brcmstb_dpfe_probe()
865 return -ENOMEM; in brcmstb_dpfe_probe()
867 priv->dev = dev; in brcmstb_dpfe_probe()
869 mutex_init(&priv->lock); in brcmstb_dpfe_probe()
872 priv->regs = devm_platform_ioremap_resource_byname(pdev, "dpfe-cpu"); in brcmstb_dpfe_probe()
873 if (IS_ERR(priv->regs)) { in brcmstb_dpfe_probe()
875 return -ENODEV; in brcmstb_dpfe_probe()
878 priv->dmem = devm_platform_ioremap_resource_byname(pdev, "dpfe-dmem"); in brcmstb_dpfe_probe()
879 if (IS_ERR(priv->dmem)) { in brcmstb_dpfe_probe()
881 return -ENOENT; in brcmstb_dpfe_probe()
884 priv->imem = devm_platform_ioremap_resource_byname(pdev, "dpfe-imem"); in brcmstb_dpfe_probe()
885 if (IS_ERR(priv->imem)) { in brcmstb_dpfe_probe()
887 return -ENOENT; in brcmstb_dpfe_probe()
890 priv->dpfe_api = of_device_get_match_data(dev); in brcmstb_dpfe_probe()
891 if (unlikely(!priv->dpfe_api)) { in brcmstb_dpfe_probe()
897 return -ENOENT; in brcmstb_dpfe_probe()
904 ret = sysfs_create_groups(&pdev->dev.kobj, priv->dpfe_api->sysfs_attrs); in brcmstb_dpfe_probe()
907 priv->dpfe_api->version); in brcmstb_dpfe_probe()
914 struct brcmstb_dpfe_priv *priv = dev_get_drvdata(&pdev->dev); in brcmstb_dpfe_remove()
916 sysfs_remove_groups(&pdev->dev.kobj, priv->dpfe_api->sysfs_attrs); in brcmstb_dpfe_remove()
921 { .compatible = "brcm,bcm7268-dpfe-cpu", .data = &dpfe_api_old_v2 },
922 { .compatible = "brcm,bcm7271-dpfe-cpu", .data = &dpfe_api_old_v2 },
923 { .compatible = "brcm,bcm7278-dpfe-cpu", .data = &dpfe_api_old_v2 },
924 { .compatible = "brcm,bcm7211-dpfe-cpu", .data = &dpfe_api_new_v2 },
926 { .compatible = "brcm,dpfe-cpu", .data = &dpfe_api_v3 },