mirror of
https://github.com/torvalds/linux.git
synced 2026-03-14 02:06:15 +01:00
usb: xhci: tegra: Support USB wakeup function for Tegra234
When the system is suspended, USB hot-plugging/unplugging can trigger wake events of the Tegra USB host controller. Enable support for USB wake-up events by parsing device-tree to see if the interrupts for the wake-up events are present and if so configure those interrupts. Note that if wake-up events are not present, still allow the USB host controller to probe as normal. Signed-off-by: Haotien Hsu <haotienh@nvidia.com> Link: https://lore.kernel.org/r/20250811074558.1062048-5-haotienh@nvidia.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7bf1158514
commit
5df186e2ef
1 changed files with 80 additions and 2 deletions
|
|
@ -155,6 +155,8 @@
|
||||||
#define FW_IOCTL_TYPE_SHIFT 24
|
#define FW_IOCTL_TYPE_SHIFT 24
|
||||||
#define FW_IOCTL_CFGTBL_READ 17
|
#define FW_IOCTL_CFGTBL_READ 17
|
||||||
|
|
||||||
|
#define WAKE_IRQ_START_INDEX 2
|
||||||
|
|
||||||
struct tegra_xusb_fw_header {
|
struct tegra_xusb_fw_header {
|
||||||
__le32 boot_loadaddr_in_imem;
|
__le32 boot_loadaddr_in_imem;
|
||||||
__le32 boot_codedfi_offset;
|
__le32 boot_codedfi_offset;
|
||||||
|
|
@ -228,6 +230,7 @@ struct tegra_xusb_soc {
|
||||||
unsigned int num_supplies;
|
unsigned int num_supplies;
|
||||||
const struct tegra_xusb_phy_type *phy_types;
|
const struct tegra_xusb_phy_type *phy_types;
|
||||||
unsigned int num_types;
|
unsigned int num_types;
|
||||||
|
unsigned int max_num_wakes;
|
||||||
const struct tegra_xusb_context_soc *context;
|
const struct tegra_xusb_context_soc *context;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -263,6 +266,7 @@ struct tegra_xusb {
|
||||||
int xhci_irq;
|
int xhci_irq;
|
||||||
int mbox_irq;
|
int mbox_irq;
|
||||||
int padctl_irq;
|
int padctl_irq;
|
||||||
|
int *wake_irqs;
|
||||||
|
|
||||||
void __iomem *ipfs_base;
|
void __iomem *ipfs_base;
|
||||||
void __iomem *fpci_base;
|
void __iomem *fpci_base;
|
||||||
|
|
@ -313,6 +317,7 @@ struct tegra_xusb {
|
||||||
bool suspended;
|
bool suspended;
|
||||||
struct tegra_xusb_context context;
|
struct tegra_xusb_context context;
|
||||||
u8 lp0_utmi_pad_mask;
|
u8 lp0_utmi_pad_mask;
|
||||||
|
int num_wakes;
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct hc_driver __read_mostly tegra_xhci_hc_driver;
|
static struct hc_driver __read_mostly tegra_xhci_hc_driver;
|
||||||
|
|
@ -1537,6 +1542,58 @@ static void tegra_xusb_deinit_usb_phy(struct tegra_xusb *tegra)
|
||||||
otg_set_host(tegra->usbphy[i]->otg, NULL);
|
otg_set_host(tegra->usbphy[i]->otg, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tegra_xusb_setup_wakeup(struct platform_device *pdev, struct tegra_xusb *tegra)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
if (tegra->soc->max_num_wakes == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
tegra->wake_irqs = devm_kcalloc(tegra->dev,
|
||||||
|
tegra->soc->max_num_wakes,
|
||||||
|
sizeof(*tegra->wake_irqs), GFP_KERNEL);
|
||||||
|
if (!tegra->wake_irqs)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* USB wake events are independent of each other, so it is not necessary for a platform
|
||||||
|
* to utilize all wake-up events supported for a given device. The USB host can operate
|
||||||
|
* even if wake-up events are not defined or fail to be configured. Therefore, we only
|
||||||
|
* return critical errors, such as -ENOMEM.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < tegra->soc->max_num_wakes; i++) {
|
||||||
|
struct irq_data *data;
|
||||||
|
|
||||||
|
tegra->wake_irqs[i] = platform_get_irq(pdev, i + WAKE_IRQ_START_INDEX);
|
||||||
|
if (tegra->wake_irqs[i] < 0)
|
||||||
|
break;
|
||||||
|
|
||||||
|
data = irq_get_irq_data(tegra->wake_irqs[i]);
|
||||||
|
if (!data) {
|
||||||
|
dev_warn(tegra->dev, "get wake event %d irq data fail\n", i);
|
||||||
|
irq_dispose_mapping(tegra->wake_irqs[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
irq_set_irq_type(tegra->wake_irqs[i], irqd_get_trigger_type(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
tegra->num_wakes = i;
|
||||||
|
dev_dbg(tegra->dev, "setup %d wake events\n", tegra->num_wakes);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tegra_xusb_dispose_wake(struct tegra_xusb *tegra)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
for (i = 0; i < tegra->num_wakes; i++)
|
||||||
|
irq_dispose_mapping(tegra->wake_irqs[i]);
|
||||||
|
|
||||||
|
tegra->num_wakes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int tegra_xusb_probe(struct platform_device *pdev)
|
static int tegra_xusb_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
struct tegra_xusb *tegra;
|
struct tegra_xusb *tegra;
|
||||||
|
|
@ -1587,9 +1644,15 @@ static int tegra_xusb_probe(struct platform_device *pdev)
|
||||||
if (tegra->mbox_irq < 0)
|
if (tegra->mbox_irq < 0)
|
||||||
return tegra->mbox_irq;
|
return tegra->mbox_irq;
|
||||||
|
|
||||||
|
err = tegra_xusb_setup_wakeup(pdev, tegra);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
tegra->padctl = tegra_xusb_padctl_get(&pdev->dev);
|
tegra->padctl = tegra_xusb_padctl_get(&pdev->dev);
|
||||||
if (IS_ERR(tegra->padctl))
|
if (IS_ERR(tegra->padctl)) {
|
||||||
return PTR_ERR(tegra->padctl);
|
err = PTR_ERR(tegra->padctl);
|
||||||
|
goto dispose_wake;
|
||||||
|
}
|
||||||
|
|
||||||
np = of_parse_phandle(pdev->dev.of_node, "nvidia,xusb-padctl", 0);
|
np = of_parse_phandle(pdev->dev.of_node, "nvidia,xusb-padctl", 0);
|
||||||
if (!np) {
|
if (!np) {
|
||||||
|
|
@ -1913,6 +1976,8 @@ put_powerdomains:
|
||||||
put_padctl:
|
put_padctl:
|
||||||
of_node_put(np);
|
of_node_put(np);
|
||||||
tegra_xusb_padctl_put(tegra->padctl);
|
tegra_xusb_padctl_put(tegra->padctl);
|
||||||
|
dispose_wake:
|
||||||
|
tegra_xusb_dispose_wake(tegra);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1945,6 +2010,8 @@ static void tegra_xusb_remove(struct platform_device *pdev)
|
||||||
if (tegra->padctl_irq)
|
if (tegra->padctl_irq)
|
||||||
pm_runtime_disable(&pdev->dev);
|
pm_runtime_disable(&pdev->dev);
|
||||||
|
|
||||||
|
tegra_xusb_dispose_wake(tegra);
|
||||||
|
|
||||||
pm_runtime_put(&pdev->dev);
|
pm_runtime_put(&pdev->dev);
|
||||||
|
|
||||||
tegra_xusb_disable(tegra);
|
tegra_xusb_disable(tegra);
|
||||||
|
|
@ -2355,8 +2422,13 @@ out:
|
||||||
pm_runtime_disable(dev);
|
pm_runtime_disable(dev);
|
||||||
|
|
||||||
if (device_may_wakeup(dev)) {
|
if (device_may_wakeup(dev)) {
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
if (enable_irq_wake(tegra->padctl_irq))
|
if (enable_irq_wake(tegra->padctl_irq))
|
||||||
dev_err(dev, "failed to enable padctl wakes\n");
|
dev_err(dev, "failed to enable padctl wakes\n");
|
||||||
|
|
||||||
|
for (i = 0; i < tegra->num_wakes; i++)
|
||||||
|
enable_irq_wake(tegra->wake_irqs[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2384,8 +2456,13 @@ static __maybe_unused int tegra_xusb_resume(struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (device_may_wakeup(dev)) {
|
if (device_may_wakeup(dev)) {
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
if (disable_irq_wake(tegra->padctl_irq))
|
if (disable_irq_wake(tegra->padctl_irq))
|
||||||
dev_err(dev, "failed to disable padctl wakes\n");
|
dev_err(dev, "failed to disable padctl wakes\n");
|
||||||
|
|
||||||
|
for (i = 0; i < tegra->num_wakes; i++)
|
||||||
|
disable_irq_wake(tegra->wake_irqs[i]);
|
||||||
}
|
}
|
||||||
tegra->suspended = false;
|
tegra->suspended = false;
|
||||||
mutex_unlock(&tegra->lock);
|
mutex_unlock(&tegra->lock);
|
||||||
|
|
@ -2636,6 +2713,7 @@ static const struct tegra_xusb_soc tegra234_soc = {
|
||||||
.num_supplies = ARRAY_SIZE(tegra194_supply_names),
|
.num_supplies = ARRAY_SIZE(tegra194_supply_names),
|
||||||
.phy_types = tegra194_phy_types,
|
.phy_types = tegra194_phy_types,
|
||||||
.num_types = ARRAY_SIZE(tegra194_phy_types),
|
.num_types = ARRAY_SIZE(tegra194_phy_types),
|
||||||
|
.max_num_wakes = 7,
|
||||||
.context = &tegra186_xusb_context,
|
.context = &tegra186_xusb_context,
|
||||||
.ports = {
|
.ports = {
|
||||||
.usb3 = { .offset = 0, .count = 4, },
|
.usb3 = { .offset = 0, .count = 4, },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue