提交 640e95ab 编写于 作者: E Eirik Aanonsen 提交者: Greg Kroah-Hartman

USB: atmel uaba: Adding invert vbus_pin

Adding vbus_pin_inverted so that the usb detect pin can be active high
or low depending on HW implementation also replaced the
gpio_get_value(udc->vbus_pin); with a call to vbus_is_present(udc); This
allows the driver to be loaded and save about 0,15W on the consumption.
Signed-off-by: NEirik Aanonsen <eaa@wprmedical.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@suse.de>
上级 90f79768
...@@ -1770,10 +1770,13 @@ at32_add_device_usba(unsigned int id, struct usba_platform_data *data) ...@@ -1770,10 +1770,13 @@ at32_add_device_usba(unsigned int id, struct usba_platform_data *data)
ARRAY_SIZE(usba0_resource))) ARRAY_SIZE(usba0_resource)))
goto out_free_pdev; goto out_free_pdev;
if (data) if (data) {
usba_data.pdata.vbus_pin = data->vbus_pin; usba_data.pdata.vbus_pin = data->vbus_pin;
else usba_data.pdata.vbus_pin_inverted = data->vbus_pin_inverted;
} else {
usba_data.pdata.vbus_pin = -EINVAL; usba_data.pdata.vbus_pin = -EINVAL;
usba_data.pdata.vbus_pin_inverted = -EINVAL;
}
data = &usba_data.pdata; data = &usba_data.pdata;
data->num_ep = ARRAY_SIZE(at32_usba_ep); data->num_ep = ARRAY_SIZE(at32_usba_ep);
......
...@@ -320,7 +320,7 @@ static inline void usba_cleanup_debugfs(struct usba_udc *udc) ...@@ -320,7 +320,7 @@ static inline void usba_cleanup_debugfs(struct usba_udc *udc)
static int vbus_is_present(struct usba_udc *udc) static int vbus_is_present(struct usba_udc *udc)
{ {
if (gpio_is_valid(udc->vbus_pin)) if (gpio_is_valid(udc->vbus_pin))
return gpio_get_value(udc->vbus_pin); return gpio_get_value(udc->vbus_pin) ^ udc->vbus_pin_inverted;
/* No Vbus detection: Assume always present */ /* No Vbus detection: Assume always present */
return 1; return 1;
...@@ -1763,7 +1763,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid) ...@@ -1763,7 +1763,7 @@ static irqreturn_t usba_vbus_irq(int irq, void *devid)
if (!udc->driver) if (!udc->driver)
goto out; goto out;
vbus = gpio_get_value(udc->vbus_pin); vbus = vbus_is_present(udc);
if (vbus != udc->vbus_prev) { if (vbus != udc->vbus_prev) {
if (vbus) { if (vbus) {
toggle_bias(1); toggle_bias(1);
...@@ -2000,6 +2000,7 @@ static int __init usba_udc_probe(struct platform_device *pdev) ...@@ -2000,6 +2000,7 @@ static int __init usba_udc_probe(struct platform_device *pdev)
if (gpio_is_valid(pdata->vbus_pin)) { if (gpio_is_valid(pdata->vbus_pin)) {
if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) { if (!gpio_request(pdata->vbus_pin, "atmel_usba_udc")) {
udc->vbus_pin = pdata->vbus_pin; udc->vbus_pin = pdata->vbus_pin;
udc->vbus_pin_inverted = pdata->vbus_pin_inverted;
ret = request_irq(gpio_to_irq(udc->vbus_pin), ret = request_irq(gpio_to_irq(udc->vbus_pin),
usba_vbus_irq, 0, usba_vbus_irq, 0,
......
...@@ -323,6 +323,7 @@ struct usba_udc { ...@@ -323,6 +323,7 @@ struct usba_udc {
struct platform_device *pdev; struct platform_device *pdev;
int irq; int irq;
int vbus_pin; int vbus_pin;
int vbus_pin_inverted;
struct clk *pclk; struct clk *pclk;
struct clk *hclk; struct clk *hclk;
......
...@@ -15,6 +15,7 @@ struct usba_ep_data { ...@@ -15,6 +15,7 @@ struct usba_ep_data {
struct usba_platform_data { struct usba_platform_data {
int vbus_pin; int vbus_pin;
int vbus_pin_inverted;
int num_ep; int num_ep;
struct usba_ep_data ep[0]; struct usba_ep_data ep[0];
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册