From: Vinod Koul <vkoul@kernel.org>
To: Mathias Nyman <mathias.nyman@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-arm-msm@vger.kernel.org,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Vinod Koul <vkoul@kernel.org>,
Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>,
Christian Lamparter <chunkeey@googlemail.com>,
linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 4/5] usb: renesas-xhci: allow multiple firmware versions
Date: Mon, 13 Jan 2020 14:10:04 +0530 [thread overview]
Message-ID: <20200113084005.849071-5-vkoul@kernel.org> (raw)
In-Reply-To: <20200113084005.849071-1-vkoul@kernel.org>
Allow multiple firmware file versions in table and load them in
increasing order as we find them in the file system.
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Cc: Christian Lamparter <chunkeey@googlemail.com>
---
drivers/usb/host/xhci-pci-renesas.c | 45 +++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/host/xhci-pci-renesas.c b/drivers/usb/host/xhci-pci-renesas.c
index 1d073c5637c4..fe95487ca888 100644
--- a/drivers/usb/host/xhci-pci-renesas.c
+++ b/drivers/usb/host/xhci-pci-renesas.c
@@ -73,13 +73,20 @@ static const struct renesas_fw_entry {
* - uPD720201 ES 2.0 sample whose revision ID is 2.
* - uPD720201 ES 2.1 sample & CS sample & Mass product, ID is 3.
* - uPD720202 ES 2.0 sample & CS sample & Mass product, ID is 2.
+ *
+ * Entry expected_version should be kept in decreasing order for a
+ * chip, so that driver will pick latest version and if that fails
+ * then next one will be picked
*/
{ "K2013080.mem", 0x0014, 0x02, 0x2013 },
+ { "K2026090.mem", 0x0014, 0x03, 0x2026 },
{ "K2013080.mem", 0x0014, 0x03, 0x2013 },
+ { "K2026090.mem", 0x0015, 0x02, 0x2026 },
{ "K2013080.mem", 0x0015, 0x02, 0x2013 },
};
MODULE_FIRMWARE("K2013080.mem");
+MODULE_FIRMWARE("K2026090.mem");
static const struct renesas_fw_entry *renesas_needs_fw_dl(struct pci_dev *dev)
{
@@ -100,6 +107,24 @@ static const struct renesas_fw_entry *renesas_needs_fw_dl(struct pci_dev *dev)
return NULL;
}
+static const struct
+renesas_fw_entry *renesas_get_next_entry(struct pci_dev *dev,
+ const struct renesas_fw_entry *entry)
+{
+ const struct renesas_fw_entry *next_entry;
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(renesas_fw_table); i++) {
+ next_entry = &renesas_fw_table[i];
+ if (next_entry->device == dev->device &&
+ next_entry->revision == dev->revision &&
+ next_entry->expected_version < entry->expected_version)
+ return next_entry;
+ }
+
+ return NULL;
+}
+
static int renesas_fw_download_image(struct pci_dev *dev,
const u32 *fw,
size_t step)
@@ -700,13 +725,29 @@ static void renesas_fw_callback(const struct firmware *fw,
struct renesas_fw_ctx *ctx = context;
struct pci_dev *pdev = ctx->pdev;
struct device *parent = pdev->dev.parent;
+ const struct renesas_fw_entry *next_entry;
bool rom;
int err;
if (!fw) {
dev_err(&pdev->dev, "firmware failed to load\n");
-
- goto cleanup;
+ /*
+ * we didn't find firmware, check if we have another
+ * entry for this device
+ */
+ next_entry = renesas_get_next_entry(ctx->pdev, ctx->entry);
+ if (next_entry) {
+ ctx->entry = next_entry;
+ dev_dbg(&pdev->dev, "Found next entry, requesting: %s\n",
+ next_entry->firmware_name);
+ request_firmware_nowait(THIS_MODULE, 1,
+ next_entry->firmware_name,
+ &pdev->dev, GFP_KERNEL,
+ ctx, renesas_fw_callback);
+ return;
+ } else {
+ goto cleanup;
+ }
}
err = renesas_fw_verify(pdev, fw->data, fw->size);
--
2.24.1
next prev parent reply other threads:[~2020-01-13 8:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-13 8:40 [PATCH v6 0/5] usb: xhci: Add support for Renesas USB controllers Vinod Koul
2020-01-13 8:40 ` [PATCH v6 1/5] usb: xhci: export few functions Vinod Koul
2020-01-13 8:40 ` [PATCH v6 2/5] usb: renesas-xhci: Add the renesas xhci driver Vinod Koul
2020-01-13 8:40 ` [PATCH v6 3/5] usb: renesas-xhci: Add ROM loader for uPD720201 Vinod Koul
2020-01-13 8:40 ` Vinod Koul [this message]
2020-01-13 8:40 ` [PATCH v6 5/5] usb: xhci: provide a debugfs hook for erasing rom Vinod Koul
2020-01-13 20:09 ` [PATCH v6 0/5] usb: xhci: Add support for Renesas USB controllers John Stultz
2020-01-13 20:33 ` Christian Lamparter
2020-01-21 6:46 ` Vinod Koul
2020-01-21 20:26 ` Christian Lamparter
2020-01-24 21:38 ` Christian Lamparter
2020-01-25 5:32 ` Vinod Koul
2020-01-30 17:07 ` Mathias Nyman
2020-01-31 8:40 ` Vinod Koul
2020-02-04 16:33 ` Mathias Nyman
2020-03-12 6:56 ` Vinod Koul
2020-01-31 15:47 ` Alan Stern
2020-03-10 11:55 ` Vinod Koul
2020-01-26 0:11 ` Andreas Böhler
2020-01-26 13:07 ` Christian Lamparter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200113084005.849071-5-vkoul@kernel.org \
--to=vkoul@kernel.org \
--cc=bjorn.andersson@linaro.org \
--cc=chunkeey@googlemail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mathias.nyman@intel.com \
--cc=yoshihiro.shimoda.uh@renesas.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).