From: Magnus Damm Date: Fri, 6 Jun 2014 10:44:26 +0000 (+0900) Subject: staging: emxx_udc: I/O memory and IRQ resource support X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=96b29cacc7afebec8476759ece29eb6519ef152a;p=openwrt%2Fstaging%2Fblogic.git staging: emxx_udc: I/O memory and IRQ resource support Adjust the emxx_udc driver to make use of the standard driver model to pass I/O memory and IRQ as resources instead of hard coding those things in the driver. Needs more work - the VBUS signal is yet not handled. Signed-off-by: Magnus Damm Acked-by: Simon Horman Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index b89c4115e570..c92ded8b5b3e 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -3356,37 +3356,38 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) { int status = -ENODEV; struct nbu2ss_udc *udc; + struct resource *r; + int irq; + void __iomem *mmio_base; udc = &udc_controller; memset(udc, 0, sizeof(struct nbu2ss_udc)); platform_set_drvdata(pdev, udc); - /* IO Memory Region */ - if (!request_mem_region(USB_BASE_ADDRESS, USB_BASE_SIZE - , driver_name)) { + /* require I/O memory and IRQ to be provided as resources */ + r = platform_get_resource(pdev, IORESOURCE_MEM, 0); + mmio_base = devm_request_and_ioremap(&pdev->dev, r); + if (IS_ERR(mmio_base)) { + dev_err(&pdev->dev, "failed to map I/O memory\n"); + return PTR_ERR(mmio_base); + } - ERR("request_mem_region failed\n"); - return -EBUSY; + irq = platform_get_irq(pdev, 0); + if (irq < 0) { + dev_err(&pdev->dev, "failed to get IRQ\n"); + return irq; } + status = devm_request_irq(&pdev->dev, irq, _nbu2ss_udc_irq, + 0, driver_name, udc); /* IO Memory */ - udc->p_regs = (PT_FC_REGS)ioremap(USB_BASE_ADDRESS, USB_BASE_SIZE); - if (!udc->p_regs) { - ERR("request_io_mem failed\n"); - goto cleanup3; - } + udc->p_regs = (PT_FC_REGS)mmio_base; /* USB Function Controller Interrupt */ - status = request_irq(USB_UDC_IRQ_1, - _nbu2ss_udc_irq, - IRQF_DISABLED, - driver_name, - udc); - if (status != 0) { ERR("request_irq(USB_UDC_IRQ_1) failed\n"); - goto cleanup2; + goto cleanup1; } /* Driver Initialization */ @@ -3412,18 +3413,6 @@ static int nbu2ss_drv_probe(struct platform_device *pdev) return status; cleanup1: - /* Interrupt Handler - Release */ - free_irq(USB_UDC_IRQ_1, udc); - -cleanup2: - /* IO Memory - Release */ - if (udc->p_regs) - iounmap(udc->p_regs); - -cleanup3: - /* IO Memory Region - Release */ - release_mem_region(USB_BASE_ADDRESS, USB_BASE_SIZE); - return status; } @@ -3455,19 +3444,9 @@ static int __exit nbu2ss_drv_remove(struct platform_device *pdev) (void *)ep->virt_buf, ep->phys_buf); } - /* Interrupt Handler - Release */ - free_irq(USB_UDC_IRQ_1, udc); - /* Interrupt Handler - Release */ free_irq(INT_VBUS, udc); - /* IO Memory - Release */ - if (udc->p_regs) - iounmap(udc->p_regs); - - /* IO Memory Region - Release */ - release_mem_region(USB_BASE_ADDRESS, USB_BASE_SIZE); - return 0; } diff --git a/drivers/staging/emxx_udc/emxx_udc.h b/drivers/staging/emxx_udc/emxx_udc.h index cc5a7d88048d..578fdcfed5e9 100644 --- a/drivers/staging/emxx_udc/emxx_udc.h +++ b/drivers/staging/emxx_udc/emxx_udc.h @@ -47,20 +47,11 @@ /*------------ Board dependence(Resource) */ -#define USB_BASE_ADDRESS EMXX_USBS1_BASE -#define USB_BASE_SIZE 0x2000 - -#define USB_UDC_IRQ_0 INT_USBF0 -#define USB_UDC_IRQ_1 INT_USBF1 #define VBUS_VALUE GPIO_VBUS /* below hacked up for staging integration */ #define GPIO_VBUS 0 /* GPIO_P153 on KZM9D */ #define INT_VBUS 0 /* IRQ for GPIO_P153 */ -#define INT_USBF0 158 -#define INT_USBF1 159 -#define EMXX_USBS0_BASE 0xe2700000 -#define EMXX_USBS1_BASE 0xe2800000 /*------------ Board dependence(Wait) */