aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/usb/gadget/s3c2410_udc.c34
1 files changed, 22 insertions, 12 deletions
diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c
index c7e255636803..9a2b8920532d 100644
--- a/drivers/usb/gadget/s3c2410_udc.c
+++ b/drivers/usb/gadget/s3c2410_udc.c
@@ -36,6 +36,7 @@
36#include <linux/interrupt.h> 36#include <linux/interrupt.h>
37#include <linux/platform_device.h> 37#include <linux/platform_device.h>
38#include <linux/clk.h> 38#include <linux/clk.h>
39#include <linux/gpio.h>
39 40
40#include <linux/debugfs.h> 41#include <linux/debugfs.h>
41#include <linux/seq_file.h> 42#include <linux/seq_file.h>
@@ -51,7 +52,6 @@
51#include <mach/irqs.h> 52#include <mach/irqs.h>
52 53
53#include <mach/hardware.h> 54#include <mach/hardware.h>
54#include <mach/regs-gpio.h>
55 55
56#include <plat/regs-udc.h> 56#include <plat/regs-udc.h>
57#include <plat/udc.h> 57#include <plat/udc.h>
@@ -1510,11 +1510,7 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev)
1510 1510
1511 dprintk(DEBUG_NORMAL, "%s()\n", __func__); 1511 dprintk(DEBUG_NORMAL, "%s()\n", __func__);
1512 1512
1513 /* some cpus cannot read from an line configured to IRQ! */ 1513 value = gpio_get_value(udc_info->vbus_pin) ? 1 : 0;
1514 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_INPUT);
1515 value = s3c2410_gpio_getpin(udc_info->vbus_pin);
1516 s3c2410_gpio_cfgpin(udc_info->vbus_pin, S3C2410_GPIO_SFN2);
1517
1518 if (udc_info->vbus_pin_inverted) 1514 if (udc_info->vbus_pin_inverted)
1519 value = !value; 1515 value = !value;
1520 1516
@@ -1802,7 +1798,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1802 struct s3c2410_udc *udc = &memory; 1798 struct s3c2410_udc *udc = &memory;
1803 struct device *dev = &pdev->dev; 1799 struct device *dev = &pdev->dev;
1804 int retval; 1800 int retval;
1805 unsigned int irq; 1801 int irq;
1806 1802
1807 dev_dbg(dev, "%s()\n", __func__); 1803 dev_dbg(dev, "%s()\n", __func__);
1808 1804
@@ -1861,7 +1857,7 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1861 1857
1862 /* irq setup after old hardware state is cleaned up */ 1858 /* irq setup after old hardware state is cleaned up */
1863 retval = request_irq(IRQ_USBD, s3c2410_udc_irq, 1859 retval = request_irq(IRQ_USBD, s3c2410_udc_irq,
1864 IRQF_DISABLED, gadget_name, udc); 1860 IRQF_DISABLED, gadget_name, udc);
1865 1861
1866 if (retval != 0) { 1862 if (retval != 0) {
1867 dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval); 1863 dev_err(dev, "cannot get irq %i, err %d\n", IRQ_USBD, retval);
@@ -1872,17 +1868,28 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1872 dev_dbg(dev, "got irq %i\n", IRQ_USBD); 1868 dev_dbg(dev, "got irq %i\n", IRQ_USBD);
1873 1869
1874 if (udc_info && udc_info->vbus_pin > 0) { 1870 if (udc_info && udc_info->vbus_pin > 0) {
1875 irq = s3c2410_gpio_getirq(udc_info->vbus_pin); 1871 retval = gpio_request(udc_info->vbus_pin, "udc vbus");
1872 if (retval < 0) {
1873 dev_err(dev, "cannot claim vbus pin\n");
1874 goto err_int;
1875 }
1876
1877 irq = gpio_to_irq(udc_info->vbus_pin);
1878 if (irq < 0) {
1879 dev_err(dev, "no irq for gpio vbus pin\n");
1880 goto err_gpio_claim;
1881 }
1882
1876 retval = request_irq(irq, s3c2410_udc_vbus_irq, 1883 retval = request_irq(irq, s3c2410_udc_vbus_irq,
1877 IRQF_DISABLED | IRQF_TRIGGER_RISING 1884 IRQF_DISABLED | IRQF_TRIGGER_RISING
1878 | IRQF_TRIGGER_FALLING | IRQF_SHARED, 1885 | IRQF_TRIGGER_FALLING | IRQF_SHARED,
1879 gadget_name, udc); 1886 gadget_name, udc);
1880 1887
1881 if (retval != 0) { 1888 if (retval != 0) {
1882 dev_err(dev, "can't get vbus irq %i, err %d\n", 1889 dev_err(dev, "can't get vbus irq %d, err %d\n",
1883 irq, retval); 1890 irq, retval);
1884 retval = -EBUSY; 1891 retval = -EBUSY;
1885 goto err_int; 1892 goto err_gpio_claim;
1886 } 1893 }
1887 1894
1888 dev_dbg(dev, "got irq %i\n", irq); 1895 dev_dbg(dev, "got irq %i\n", irq);
@@ -1902,6 +1909,9 @@ static int s3c2410_udc_probe(struct platform_device *pdev)
1902 1909
1903 return 0; 1910 return 0;
1904 1911
1912err_gpio_claim:
1913 if (udc_info && udc_info->vbus_pin > 0)
1914 gpio_free(udc_info->vbus_pin);
1905err_int: 1915err_int:
1906 free_irq(IRQ_USBD, udc); 1916 free_irq(IRQ_USBD, udc);
1907err_map: 1917err_map:
@@ -1927,7 +1937,7 @@ static int s3c2410_udc_remove(struct platform_device *pdev)
1927 debugfs_remove(udc->regs_info); 1937 debugfs_remove(udc->regs_info);
1928 1938
1929 if (udc_info && udc_info->vbus_pin > 0) { 1939 if (udc_info && udc_info->vbus_pin > 0) {
1930 irq = s3c2410_gpio_getirq(udc_info->vbus_pin); 1940 irq = gpio_to_irq(udc_info->vbus_pin);
1931 free_irq(irq, udc); 1941 free_irq(irq, udc);
1932 } 1942 }
1933 1943