1 From d6e220fb600a6b1f73155b541aa9826ec75d4559 Mon Sep 17 00:00:00 2001
2 From: Vinod Koul <vkoul@kernel.org>
3 Date: Mon, 13 Jan 2020 14:10:05 +0530
4 Subject: [PATCH 104/104] usb: xhci: provide a debugfs hook for erasing rom
6 run "echo 1 > /sys/kernel/debug/renesas-usb/rom_erase" to erase firmware
9 Subsequent init of driver shall reload the firmware
11 Signed-off-by: Vinod Koul <vkoul@kernel.org>
12 Signed-off-by: Christian Lamparter <chunkeey@gmail.com> [5.4 backport]
14 drivers/usb/host/xhci-pci-renesas.c | 35 +++++++++++++++++++++++++++++
15 1 file changed, 35 insertions(+)
17 --- a/drivers/usb/host/xhci-pci-renesas.c
18 +++ b/drivers/usb/host/xhci-pci-renesas.c
20 /* Copyright (C) 2019-2020 Linaro Limited */
22 #include <linux/acpi.h>
23 +#include <linux/debugfs.h>
24 #include <linux/firmware.h>
25 #include <linux/module.h>
26 #include <linux/pci.h>
27 @@ -229,6 +230,9 @@ static int renesas_fw_verify(struct pci_
32 +static void debugfs_init(struct pci_dev *pdev);
34 static int renesas_check_rom_state(struct pci_dev *pdev)
36 const struct renesas_fw_entry *entry;
37 @@ -252,6 +256,7 @@ static int renesas_check_rom_state(struc
38 if (version == entry->expected_version) {
39 dev_dbg(&pdev->dev, "Detected valid ROM version..\n");
44 if (valid_version == false)
45 @@ -536,6 +541,34 @@ static void renesas_rom_erase(struct pci
46 dev_dbg(&pdev->dev, "ROM Erase... Done success\n");
49 +static int debugfs_rom_erase(void *data, u64 value)
51 + struct pci_dev *pdev = data;
54 + dev_dbg(&pdev->dev, "Userspace requested ROM erase\n");
55 + renesas_rom_erase(pdev);
60 +DEFINE_DEBUGFS_ATTRIBUTE(rom_erase_ops, NULL, debugfs_rom_erase, "%llu\n");
62 +static struct dentry *debugfs_root;
64 +static void debugfs_init(struct pci_dev *pdev)
66 + debugfs_root = debugfs_create_dir("renesas-usb", NULL);
68 + debugfs_create_file("rom_erase", 0200, debugfs_root,
69 + pdev, &rom_erase_ops);
72 +static void debugfs_exit(void)
74 + debugfs_remove_recursive(debugfs_root);
77 static bool renesas_download_rom(struct pci_dev *pdev,
78 const u32 *fw, size_t step)
80 @@ -889,6 +922,8 @@ static int renesas_xhci_pci_probe(struct
82 static void renesas_xhci_pci_remove(struct pci_dev *dev)
86 if (renesas_fw_alive_check(dev)) {
88 * bail out early, if this was a renesas device w/o FW.