Commit a630d54d authored by Thierry Reding's avatar Thierry Reding Committed by Kishon Vijay Abraham I

phy: tegra: xusb: Add support for power supplies

Support enabling various supplies needed to provide power to the PLLs
and logic used to drive the USB, PCI and SATA pads.
Reviewed-by: default avatarJC Kuo <jckuo@nvidia.com>
Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parent 5311a7b8
...@@ -864,6 +864,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) ...@@ -864,6 +864,7 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
struct tegra_xusb_padctl *padctl; struct tegra_xusb_padctl *padctl;
const struct of_device_id *match; const struct of_device_id *match;
struct resource *res; struct resource *res;
unsigned int i;
int err; int err;
/* for backwards compatibility with old device trees */ /* for backwards compatibility with old device trees */
...@@ -901,14 +902,38 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) ...@@ -901,14 +902,38 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
goto remove; goto remove;
} }
padctl->supplies = devm_kcalloc(&pdev->dev, padctl->soc->num_supplies,
sizeof(*padctl->supplies), GFP_KERNEL);
if (!padctl->supplies) {
err = -ENOMEM;
goto remove;
}
for (i = 0; i < padctl->soc->num_supplies; i++)
padctl->supplies[i].supply = padctl->soc->supply_names[i];
err = devm_regulator_bulk_get(&pdev->dev, padctl->soc->num_supplies,
padctl->supplies);
if (err < 0) {
dev_err(&pdev->dev, "failed to get regulators: %d\n", err);
goto remove;
}
err = reset_control_deassert(padctl->rst); err = reset_control_deassert(padctl->rst);
if (err < 0) if (err < 0)
goto remove; goto remove;
err = regulator_bulk_enable(padctl->soc->num_supplies,
padctl->supplies);
if (err < 0) {
dev_err(&pdev->dev, "failed to enable supplies: %d\n", err);
goto reset;
}
err = tegra_xusb_setup_pads(padctl); err = tegra_xusb_setup_pads(padctl);
if (err < 0) { if (err < 0) {
dev_err(&pdev->dev, "failed to setup pads: %d\n", err); dev_err(&pdev->dev, "failed to setup pads: %d\n", err);
goto reset; goto power_down;
} }
err = tegra_xusb_setup_ports(padctl); err = tegra_xusb_setup_ports(padctl);
...@@ -921,6 +946,8 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev) ...@@ -921,6 +946,8 @@ static int tegra_xusb_padctl_probe(struct platform_device *pdev)
remove_pads: remove_pads:
tegra_xusb_remove_pads(padctl); tegra_xusb_remove_pads(padctl);
power_down:
regulator_bulk_disable(padctl->soc->num_supplies, padctl->supplies);
reset: reset:
reset_control_assert(padctl->rst); reset_control_assert(padctl->rst);
remove: remove:
...@@ -936,6 +963,11 @@ static int tegra_xusb_padctl_remove(struct platform_device *pdev) ...@@ -936,6 +963,11 @@ static int tegra_xusb_padctl_remove(struct platform_device *pdev)
tegra_xusb_remove_ports(padctl); tegra_xusb_remove_ports(padctl);
tegra_xusb_remove_pads(padctl); tegra_xusb_remove_pads(padctl);
err = regulator_bulk_disable(padctl->soc->num_supplies,
padctl->supplies);
if (err < 0)
dev_err(&pdev->dev, "failed to disable supplies: %d\n", err);
err = reset_control_assert(padctl->rst); err = reset_control_assert(padctl->rst);
if (err < 0) if (err < 0)
dev_err(&pdev->dev, "failed to assert reset: %d\n", err); dev_err(&pdev->dev, "failed to assert reset: %d\n", err);
......
...@@ -370,6 +370,9 @@ struct tegra_xusb_padctl_soc { ...@@ -370,6 +370,9 @@ struct tegra_xusb_padctl_soc {
} ports; } ports;
const struct tegra_xusb_padctl_ops *ops; const struct tegra_xusb_padctl_ops *ops;
const char * const *supply_names;
unsigned int num_supplies;
}; };
struct tegra_xusb_padctl { struct tegra_xusb_padctl {
...@@ -393,6 +396,8 @@ struct tegra_xusb_padctl { ...@@ -393,6 +396,8 @@ struct tegra_xusb_padctl {
unsigned int enable; unsigned int enable;
struct clk *clk; struct clk *clk;
struct regulator_bulk_data *supplies;
}; };
static inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value, static inline void padctl_writel(struct tegra_xusb_padctl *padctl, u32 value,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment