Skip to content

Commit

Permalink
usb: host: xhci-tegra: Extract firmware enable helper
Browse files Browse the repository at this point in the history
Extract a helper that enables message generation from the firmware. This
removes clutter from tegra_xusb_probe() and will also come in useful for
subsequent patches that introduce suspend/resume support.

Based on work by JC Kuo <jckuo@nvidia.com>.

Signed-off-by: Thierry Reding <treding@nvidia.com>
Link: https://lore.kernel.org/r/20191206140653.2085561-6-thierry.reding@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Thierry Reding authored and Greg Kroah-Hartman committed Dec 10, 2019
1 parent 482ba7a commit 96d8f62
Showing 1 changed file with 29 additions and 12 deletions.
41 changes: 29 additions & 12 deletions drivers/usb/host/xhci-tegra.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,11 +993,37 @@ static int tegra_xusb_powerdomain_init(struct device *dev,
return 0;
}

static int tegra_xusb_probe(struct platform_device *pdev)
static int __tegra_xusb_enable_firmware_messages(struct tegra_xusb *tegra)
{
struct tegra_xusb_mbox_msg msg;
struct resource *regs;
int err;

/* Enable firmware messages from controller. */
msg.cmd = MBOX_CMD_MSG_ENABLED;
msg.data = 0;

err = tegra_xusb_mbox_send(tegra, &msg);
if (err < 0)
dev_err(tegra->dev, "failed to enable messages: %d\n", err);

return err;
}

static int tegra_xusb_enable_firmware_messages(struct tegra_xusb *tegra)
{
int err;

mutex_lock(&tegra->lock);
err = __tegra_xusb_enable_firmware_messages(tegra);
mutex_unlock(&tegra->lock);

return err;
}

static int tegra_xusb_probe(struct platform_device *pdev)
{
struct tegra_xusb *tegra;
struct resource *regs;
struct xhci_hcd *xhci;
unsigned int i, j, k;
struct phy *phy;
Expand Down Expand Up @@ -1277,21 +1303,12 @@ static int tegra_xusb_probe(struct platform_device *pdev)
goto put_usb3;
}

mutex_lock(&tegra->lock);

/* Enable firmware messages from controller. */
msg.cmd = MBOX_CMD_MSG_ENABLED;
msg.data = 0;

err = tegra_xusb_mbox_send(tegra, &msg);
err = tegra_xusb_enable_firmware_messages(tegra);
if (err < 0) {
dev_err(&pdev->dev, "failed to enable messages: %d\n", err);
mutex_unlock(&tegra->lock);
goto remove_usb3;
}

mutex_unlock(&tegra->lock);

err = devm_request_threaded_irq(&pdev->dev, tegra->mbox_irq,
tegra_xusb_mbox_irq,
tegra_xusb_mbox_thread, 0,
Expand Down

0 comments on commit 96d8f62

Please sign in to comment.