usb: langwell_udc: Init SRAM on S0i3 resume
authorSundar Iyer <sundar.iyer@intel.com>
Thu, 25 Aug 2011 11:20:34 +0000 (12:20 +0100)
committermgross <mark.gross@intel.com>
Wed, 9 Nov 2011 20:38:21 +0000 (12:38 -0800)
On an exit from S0i3, the USB stack tries to access the SRAM
without initializing. Add SRAM initialization code to avoid
ECC error. This patch is for langwell_udc controller driver.

Change-Id: I92c80eed95094706020b8659a3db6585bdd8fca3
Signed-off-by: Sundar Iyer <sundar.iyer@intel.com>
Signed-off-by: Hao Wu <hao.wu@intel.com>
Signed-off-by: Dirk Brandewie <dirk.brandewie@gmail.com>
drivers/usb/gadget/langwell_udc.c

index 262d120..5e2e575 100644 (file)
@@ -2968,6 +2968,8 @@ static void gadget_release(struct device *_dev)
 static void sram_init(struct langwell_udc *dev)
 {
        struct pci_dev          *pdev = dev->pdev;
+       void __iomem            *base = NULL;
+       void __iomem            *addr = NULL;
 
        dev_dbg(&dev->pdev->dev, "---> %s()\n", __func__);
 
@@ -2975,6 +2977,23 @@ static void sram_init(struct langwell_udc *dev)
        dev->sram_size = pci_resource_len(pdev, 1);
        dev_info(&dev->pdev->dev, "Found private SRAM at %x size:%x\n",
                        dev->sram_addr, dev->sram_size);
+
+       /* initialize SRAM to 0 to avoid ECC errors */
+       base = ioremap_nocache(dev->sram_addr, dev->sram_size);
+       if (base == NULL) {
+               dev_err(&dev->pdev->dev, "SRAM init: ioremap failed\n");
+               return;
+       }
+
+       addr = base;
+
+       while (addr < base + dev->sram_size) {
+               writel(0x0, addr);
+               addr = addr + 4;
+       }
+
+       iounmap(base);
+
        dev->got_sram = 1;
 
        if (pci_request_region(pdev, 1, kobject_name(&pdev->dev.kobj))) {