summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorTroy Kisky <troy.kisky@boundarydevices.com>2014-04-14 17:01:08 -0700
committerTroy Kisky <troy.kisky@boundarydevices.com>2014-04-24 18:59:55 -0700
commitfbf8ba87c9226f2377e1f8e67bec746c5752e182 (patch)
tree524a94739c85d494a8cfca221f3f4b26e9e389c3 /drivers
parent3c46bd58d7db643f30f61a53131bbe9e43b99f35 (diff)
ci_hdrc_imx: add reset-gpios
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index 17ac14ff082b..1d9b57a07228 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -83,6 +83,8 @@ struct ci_hdrc_imx_data {
struct regmap *anatop;
struct pinctrl *pinctrl;
struct pinctrl_state *pinctrl_hsic_active;
+ int reset_gpio;
+ int reset_active_low;
};
/* Common functions shared by usbmisc drivers */
@@ -200,6 +202,31 @@ static int ci_hdrc_imx_notify_event(struct ci_hdrc *ci, unsigned event)
return ret;
}
+static int setup_reset_gpio(struct platform_device *pdev, struct ci_hdrc_imx_data *data)
+{
+ int err = 0;
+ int gpio;
+ enum of_gpio_flags flags;
+ struct device *dev = &pdev->dev;
+ struct device_node *np = dev->of_node;
+
+ data->reset_gpio = -1;
+ gpio = of_get_named_gpio_flags(np, "reset-gpios", 0, &flags);
+ pr_info("%s:%d\n", __func__, gpio);
+ if (!gpio_is_valid(gpio))
+ return 0;
+
+ data->reset_active_low = flags & OF_GPIO_ACTIVE_LOW;
+ err = devm_gpio_request_one(dev, gpio, data->reset_active_low ?
+ GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW,
+ "ehci_reset_gpio");
+ if (err)
+ dev_err(dev, "can't request reset gpio %d", gpio);
+ data->reset_gpio = gpio;
+
+ return err;
+}
+
static int ci_hdrc_imx_probe(struct platform_device *pdev)
{
struct ci_hdrc_imx_data *data;
@@ -224,6 +251,7 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev)
}
platform_set_drvdata(pdev, data);
+ setup_reset_gpio(pdev, data);
data->usbmisc_data = usbmisc_get_init_data(&pdev->dev);
if (IS_ERR(data->usbmisc_data))
@@ -406,6 +434,8 @@ static int ci_hdrc_imx_remove(struct platform_device *pdev)
release_bus_freq(BUS_FREQ_HIGH);
if (data->imx6_usb_charger_detection)
imx6_usb_remove_charger(&data->charger);
+ if (gpio_is_valid(data->reset_gpio))
+ gpio_set_value(data->reset_gpio, data->reset_active_low ? 0 : 1);
return 0;
}