]> rtime.felk.cvut.cz Git - zynq/linux.git/commitdiff
Xilinx: PS USB platform specific initialization
authorNaveen Mamindlapalli <naveenm@xhd-epdswlin32re1.(none)>
Tue, 12 Apr 2011 15:02:14 +0000 (20:32 +0530)
committerJohn Linn <john.linn@xilinx.com>
Tue, 12 Apr 2011 19:11:52 +0000 (13:11 -0600)
Removed PS USB Controller platform specific initialization
from devices.c file and added seperate file usb.c.
Updated Makefile to compile usb.c file.

Signed-off-by: Naveen Mamindlapalli <naveenm@xilinx.com>
arch/arm/mach-xilinx/Makefile
arch/arm/mach-xilinx/devices.c
arch/arm/mach-xilinx/usb.c [new file with mode: 0644]
arch/arm/mach-xilinx/xilinx.c

index 78a80f462e92398ca74f2caa8408643d6619a0a6..ea98ad60bad653057a56c6af5e9b8368ceeb5fe3 100644 (file)
@@ -3,7 +3,7 @@
 #
 
 # Common support
-obj-y := time.o devices.o xilinx.o pl330.o clock.o
+obj-y := time.o devices.o xilinx.o pl330.o clock.o usb.o
 
 obj-$(CONFIG_SMP)              += smp.o head_smp.o
 obj-$(CONFIG_LOCAL_TIMERS)     += local_timer.o 
index 21cc63730190d0faee7248575300469292309096..82d9cecb88a9eca27d6ec2f98e85045d417b9db6 100644 (file)
@@ -26,7 +26,6 @@
 #include <linux/mtd/physmap.h>
 #include <linux/spi/flash.h>
 #include <mach/nand.h>
-#include <linux/fsl_devices.h>
 #include <linux/amba/xilinx_dma.h>
 
 /* Create all the platform devices for the BSP */
@@ -855,93 +854,6 @@ struct platform_device xilinx_a9wdt_device = {
        .num_resources = ARRAY_SIZE(xa9wdt_resource),
 };
 
-/*************************PSS USB*********************/
-static struct resource xusbpss_0_resource[] = {
-       {
-               .start  = USB0_BASE,
-               .end    = USB0_BASE + 0xFFF,
-               .flags  = IORESOURCE_MEM
-       },
-       {
-               .start  = IRQ_USB0,
-               .end    = IRQ_USB0,
-               .flags  = IORESOURCE_IRQ
-       },
-};
-
-static struct resource xusbpss_1_resource[] = {
-       {
-               .start  = USB1_BASE,
-               .end    = USB1_BASE + 0xFFF,
-               .flags  = IORESOURCE_MEM
-       },
-       {
-               .start  = IRQ_USB1,
-               .end    = IRQ_USB1,
-               .flags  = IORESOURCE_IRQ
-       },
-};
-
-/* USB Host */
-static struct fsl_usb2_platform_data usb_host_pdata = {
-       .operating_mode = FSL_USB2_DR_HOST,
-       .phy_mode       = FSL_USB2_PHY_ULPI,
-};
-
-static struct platform_device xilinx_usbpss_0_host = {
-       .name = "fsl-ehci",
-       .id = 0,
-       .dev = {
-               .dma_mask               = &dma_mask,
-               .coherent_dma_mask      = 0xFFFFFFFF,
-               .platform_data          = &usb_host_pdata,
-       },
-       .resource = xusbpss_0_resource,
-       .num_resources = ARRAY_SIZE(xusbpss_0_resource),
-};
-
-static struct platform_device xilinx_usbpss_1_host = {
-       .name = "fsl-ehci",
-       .id = 1,
-       .dev = {
-               .dma_mask               = &dma_mask,
-               .coherent_dma_mask      = 0xFFFFFFFF,
-               .platform_data          = &usb_host_pdata,
-       },
-       .resource = xusbpss_1_resource,
-       .num_resources = ARRAY_SIZE(xusbpss_1_resource),
-};
-
-/* USB Device */
-static struct fsl_usb2_platform_data usb_device_pdata = {
-       .operating_mode = FSL_USB2_DR_DEVICE,
-       .phy_mode       = FSL_USB2_PHY_ULPI,
-};
-
-struct platform_device xilinx_usbpss_0_device = {
-       .name = "fsl-usb2-udc",
-       .id   = 0,
-       .dev  = {
-               .dma_mask               = &dma_mask,
-               .coherent_dma_mask      = 0xFFFFFFFF,
-               .platform_data          = &usb_device_pdata,
-       },
-       .resource = xusbpss_0_resource,
-       .num_resources = ARRAY_SIZE(xusbpss_0_resource),
-};
-
-struct platform_device xilinx_usbpss_1_device = {
-       .name = "fsl-usb2-udc",
-       .id   = 1,
-       .dev  = {
-               .dma_mask               = &dma_mask,
-               .coherent_dma_mask      = 0xFFFFFFFF,
-               .platform_data          = &usb_device_pdata,
-       },
-       .resource = xusbpss_1_resource,
-       .num_resources = ARRAY_SIZE(xusbpss_1_resource),
-};
-
 /************************* SLCR ***********************/
 static struct resource xslcr_res[] = {
        {
@@ -1023,8 +935,6 @@ struct platform_device *xilinx_pdevices[] __initdata = {
        &xilinx_nandpss_device,
        &xilinx_sdio0pss_device,
        &xilinx_sdio1pss_device,
-       &xilinx_usbpss_0_device,
-       &xilinx_usbpss_1_host,
        &xilinx_slcr_device,
         &xilinx_devcfg_device,
 };
@@ -1042,7 +952,6 @@ struct platform_device *xilinx_pdevices_amp0[] __initdata = {
        &xilinx_a9wdt_device,
        &xilinx_nandpss_device,
        &xilinx_sdio0pss_device,
-       &xilinx_usbpss_0_device,
 };
 
 struct platform_device *xilinx_pdevices_amp1[] __initdata = {
@@ -1051,7 +960,6 @@ struct platform_device *xilinx_pdevices_amp1[] __initdata = {
        &eth_device1,
        &xilinx_spipss_1_device,
        &xilinx_sdio1pss_device,
-       &xilinx_usbpss_1_host,
 };
 
 /**
diff --git a/arch/arm/mach-xilinx/usb.c b/arch/arm/mach-xilinx/usb.c
new file mode 100644 (file)
index 0000000..b4c2c1f
--- /dev/null
@@ -0,0 +1,228 @@
+ /*
+ * Xilinx PS USB Controller platform level initialization.
+ *
+ * Copyright (C) 2011 Xilinx, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/io.h>
+#include <linux/xilinx_devices.h>
+
+#include <asm/irq.h>
+#include <asm/system.h>
+#include <mach/hardware.h>
+
+static u64 dmamask = ~(u32)0;
+
+static struct resource xusbps_resource0[] = {
+       {
+               .start  = USB0_BASE,
+               .end    = USB0_BASE + 0xFFF,
+               .flags  = IORESOURCE_MEM
+       },
+       {
+               .start  = IRQ_USB0,
+               .end    = IRQ_USB0,
+               .flags  = IORESOURCE_IRQ
+       },
+};
+
+static struct resource xusbps_resource1[] = {
+       {
+               .start  = USB1_BASE,
+               .end    = USB1_BASE + 0xFFF,
+               .flags  = IORESOURCE_MEM
+       },
+       {
+               .start  = IRQ_USB1,
+               .end    = IRQ_USB1,
+               .flags  = IORESOURCE_IRQ
+       },
+};
+
+static struct xusbps_usb2_platform_data usb_pdata0 = {
+       .operating_mode = XUSBPS_USB2_DR_OTG,
+       .phy_mode       = XUSBPS_USB2_PHY_ULPI,
+};
+
+static struct xusbps_usb2_platform_data usb_pdata1 = {
+       .operating_mode = XUSBPS_USB2_DR_OTG,
+       .phy_mode       = XUSBPS_USB2_PHY_ULPI,
+};
+
+/* USB Host Mode */
+static struct platform_device xusbps_0_host = {
+       .name = "xusbps-ehci",
+       .id = 0,
+       .dev = {
+               .dma_mask               = &dmamask,
+               .coherent_dma_mask      = 0xFFFFFFFF,
+               .platform_data          = &usb_pdata0,
+       },
+};
+
+static struct platform_device xusbps_1_host = {
+       .name = "xusbps-ehci",
+       .id = 1,
+       .dev = {
+               .dma_mask               = &dmamask,
+               .coherent_dma_mask      = 0xFFFFFFFF,
+               .platform_data          = &usb_pdata1,
+       },
+};
+
+/* USB Device Mode */
+struct platform_device xusbps_0_device = {
+       .name = "xusbps-udc",
+       .id   = 0,
+       .dev  = {
+               .dma_mask               = &dmamask,
+               .coherent_dma_mask      = 0xFFFFFFFF,
+               .platform_data          = &usb_pdata0,
+       },
+};
+
+struct platform_device xusbps_1_device = {
+       .name = "xusbps-udc",
+       .id   = 1,
+       .dev  = {
+               .dma_mask               = &dmamask,
+               .coherent_dma_mask      = 0xFFFFFFFF,
+               .platform_data          = &usb_pdata1,
+       },
+};
+
+/* USB OTG Mode */
+static struct platform_device xusbps_otg_0_device = {
+       .name           = "xusbps-otg",
+       .id             = 0,
+       .dev  = {
+               .dma_mask               = &dmamask,
+               .coherent_dma_mask      = 0xFFFFFFFF,
+               .platform_data          = &usb_pdata0,
+       },
+       .num_resources  = ARRAY_SIZE(xusbps_resource0),
+       .resource       = xusbps_resource0,
+};
+
+static struct platform_device xusbps_otg_1_device = {
+       .name           = "xusbps-otg",
+       .id             = 1,
+       .dev  = {
+               .dma_mask               = &dmamask,
+               .coherent_dma_mask      = 0xFFFFFFFF,
+               .platform_data          = &usb_pdata1,
+       },
+       .num_resources  = ARRAY_SIZE(xusbps_resource1),
+       .resource       = xusbps_resource1,
+};
+
+/*-------------------------------------------------------------------------*/
+
+int __init
+xusbps_init(void)
+{
+       int     status;
+       struct resource *res;
+       void __iomem *usb0_regs;
+       void __iomem *usb1_regs;
+       int usb0_irq;
+       int usb1_irq;
+
+       /* Allocating resources to platform data */
+       /* USB0 */
+       res = platform_get_resource(&xusbps_otg_0_device, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENXIO;
+
+       if (!request_mem_region(res->start, res->end - res->start + 1,
+                               xusbps_otg_0_device.name))
+               return -EBUSY;
+
+       usb0_regs = ioremap(res->start, resource_size(res));
+       if (!usb0_regs)
+               return -ENOMEM;
+
+       usb0_irq = platform_get_irq(&xusbps_otg_0_device, 0);
+
+       usb_pdata0.regs = usb0_regs;
+       usb_pdata0.irq = usb0_irq;
+
+       /* USB1 */
+       res = platform_get_resource(&xusbps_otg_1_device, IORESOURCE_MEM, 0);
+       if (!res)
+               return -ENXIO;
+
+       if (!request_mem_region(res->start, res->end - res->start + 1,
+                               xusbps_otg_1_device.name))
+               return -EBUSY;
+
+       usb1_regs = ioremap(res->start, resource_size(res));
+       if (!usb0_regs)
+               return -ENOMEM;
+
+       usb1_irq = platform_get_irq(&xusbps_otg_1_device, 0);
+
+       usb_pdata1.regs = usb1_regs;
+       usb_pdata1.irq = usb1_irq;
+
+       /* Registering platform device */
+
+       /* usb device mode */
+       /* USB0 */
+       pr_info("registering platform device '%s' id %d\n",
+                       xusbps_0_device.name,
+                       xusbps_0_device.id);
+       status = platform_device_register(&xusbps_0_device);
+       if (status)
+               pr_info("Unable to register platform device '%s': %d\n",
+                       xusbps_0_device.name, status);
+
+       /* usb host mode */
+#ifdef CONFIG_USB_XUSBPS_OTG
+       /* USB0 */
+       pr_info("registering platform device '%s' id %d\n",
+                       xusbps_0_host.name,
+                       xusbps_0_host.id);
+       status = platform_device_register(&xusbps_0_host);
+       if (status)
+               pr_info("Unable to register platform device '%s': %d\n",
+                       xusbps_0_host.name, status);
+#endif
+
+       /* USB1 */
+       pr_info("registering platform device '%s' id %d\n",
+                       xusbps_1_host.name,
+                       xusbps_1_host.id);
+       status = platform_device_register(&xusbps_1_host);
+       if (status)
+               pr_info("Unable to register platform device '%s': %d\n",
+                       xusbps_1_host.name, status);
+
+       /* usb otg mode */
+#ifdef CONFIG_USB_XUSBPS_OTG
+       /* USB0 */
+       pr_info("registering platform device '%s' id %d\n",
+                       xusbps_otg_0_device.name,
+                       xusbps_otg_0_device.id);
+       status = platform_device_register(&xusbps_otg_0_device);
+       if (status)
+               pr_info("Unable to register platform device '%s': %d\n",
+                       xusbps_otg_0_device.name, status);
+#endif
+
+       return 0;
+}
index 2c5205b231b0e7424a309ab5dbf0c28be37cf73c..9e1d1f93caaa24431ae4bc94c6c0acde486abb60 100644 (file)
@@ -70,6 +70,7 @@
 
 extern struct sys_timer xttcpss_sys_timer;
 extern void platform_device_init(void);
+extern void xusbps_init(void);
 
 /* SRAM base address */
 void __iomem *xsram_base;
@@ -175,6 +176,7 @@ static void __init board_init(void)
        pr_debug("->board_init\n");
 
        platform_device_init();
+       xusbps_init();
 #ifdef CONFIG_OF
        pr_info("Xilinx: using device tree\n");
         of_platform_bus_probe(NULL, xilinx_of_bus_ids, NULL);