diff options
author | Linaro CI <ci_notify@linaro.org> | 2021-12-10 14:45:38 +0000 |
---|---|---|
committer | Linaro CI <ci_notify@linaro.org> | 2021-12-10 14:45:38 +0000 |
commit | dbc33c8d7928ca7f0d8cc96e00809e2e60cd1d38 (patch) | |
tree | d6bdcc62a8ffcdb65853149463d97ecb9bfdb3a9 | |
parent | 03ffca3d538ae2a0bf475704e4c73cb9cd5afeca (diff) | |
parent | 29b8452f55a39ed00b866bb3024275a9df382683 (diff) |
Merge remote-tracking branch 'sdm845-usb/tracking-qcomlt-usb-renesas' into integration-linux-qcomlt
# Conflicts:
# drivers/usb/host/xhci-pci-renesas.c
-rw-r--r-- | drivers/usb/host/xhci-pci-renesas.c | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c index 52599d96634f..50bdd3f2c4e0 100644 --- a/drivers/usb/host/xhci-pci-renesas.c +++ b/drivers/usb/host/xhci-pci-renesas.c @@ -2,6 +2,7 @@ /* Copyright (C) 2019-2020 Linaro Limited */ #include <linux/acpi.h> +#include <linux/debugfs.h> #include <linux/firmware.h> #include <linux/module.h> #include <linux/pci.h> @@ -50,6 +51,20 @@ #define RENESAS_RETRY 10000 #define RENESAS_DELAY 10 +#define ROM_VALID_01 0x2013 +#define ROM_VALID_02 0x2026 + +static int renesas_verify_fw_version(struct pci_dev *pdev, u32 version) +{ + switch (version) { + case ROM_VALID_01: + case ROM_VALID_02: + return 0; + } + dev_err(&pdev->dev, "FW has invalid version :%d\n", version); + return -EINVAL; +} + static int renesas_fw_download_image(struct pci_dev *dev, const u32 *fw, size_t step, bool rom) { @@ -156,6 +171,8 @@ static int renesas_fw_verify(const void *fw_data, return 0; } +static void debugfs_init(struct pci_dev *pdev); + static bool renesas_check_rom(struct pci_dev *pdev) { u16 rom_status; @@ -169,6 +186,7 @@ static bool renesas_check_rom(struct pci_dev *pdev) rom_status &= RENESAS_ROM_STATUS_ROM_EXISTS; if (rom_status) { dev_dbg(&pdev->dev, "External ROM exists\n"); + debugfs_init(pdev); return true; /* External ROM exists */ } @@ -188,7 +206,10 @@ static int renesas_check_rom_state(struct pci_dev *pdev) version &= RENESAS_FW_VERSION_FIELD; version = version >> RENESAS_FW_VERSION_OFFSET; - dev_dbg(&pdev->dev, "Found ROM version: %x\n", version); + + err = renesas_verify_fw_version(pdev, version); + if (err) + return err; /* * Test if ROM is present and loaded, if so we can skip everything @@ -425,6 +446,34 @@ static void renesas_rom_erase(struct pci_dev *pdev) dev_dbg(&pdev->dev, "ROM Erase... Done success\n"); } +static int debugfs_rom_erase(void *data, u64 value) +{ + struct pci_dev *pdev = data; + + if (value == 1) { + dev_dbg(&pdev->dev, "Userspace requested ROM erase\n"); + renesas_rom_erase(pdev); + return 0; + } + return -EINVAL; +} +DEFINE_DEBUGFS_ATTRIBUTE(rom_erase_ops, NULL, debugfs_rom_erase, "%llu\n"); + +static struct dentry *debugfs_root; + +static void debugfs_init(struct pci_dev *pdev) +{ + debugfs_root = debugfs_create_dir("renesas_usb", NULL); + + debugfs_create_file("rom_erase", 0200, debugfs_root, + pdev, &rom_erase_ops); +} + +static void debugfs_exit(void) +{ + debugfs_remove_recursive(debugfs_root); +} + static bool renesas_setup_rom(struct pci_dev *pdev, const struct firmware *fw) { const u32 *fw_data = (const u32 *)fw->data; |