9216badba92a8cb18969541aaa8bc6016f3fc0ad
[vuplus_openvuplus_3.0] / meta-bsp / common / recipes / linux / linux-vuplus-3.1.1 / linux-sata_brcm.patch
1 diff --git a/drivers/ata/sata_brcmstb.c b/drivers/ata/sata_brcmstb.c
2 index 7ba20e0..ca02cdf 100644
3 --- a/drivers/ata/sata_brcmstb.c
4 +++ b/drivers/ata/sata_brcmstb.c
5 @@ -53,9 +53,7 @@
6  #include <linux/pm.h>
7  #include <linux/clk.h>
8  #include <linux/version.h>
9 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
10  #include <linux/pm_runtime.h>
11 -#endif
12  
13  #ifdef CONFIG_PPC_OF
14  #include <asm/prom.h>
15 @@ -127,7 +125,7 @@ enum {
16         K2_SATA_TF_LBAM_OFFSET          = 0x10,
17         K2_SATA_TF_LBAH_OFFSET          = 0x14,
18         K2_SATA_TF_DEVICE_OFFSET        = 0x18,
19 -       K2_SATA_TF_CMDSTAT_OFFSET       = 0x1c,
20 +       K2_SATA_TF_CMDSTAT_OFFSET       = 0x1c,
21         K2_SATA_TF_CTL_OFFSET           = 0x20,
22  
23         /* DMA base */
24 @@ -142,7 +140,7 @@ enum {
25         /* Others */
26         K2_SATA_SICR1_OFFSET            = 0x80,
27         K2_SATA_SICR2_OFFSET            = 0x84,
28 -       K2_SATA_SIMR_OFFSET             = 0x88, /* SATA interrupt mask register */
29 +       K2_SATA_SIMR_OFFSET             = 0x88, /* SATA intr mask register */
30         K2_SATA_MDIO_OFFSET             = 0x8c, /* SATA MDIO access register */
31         K2_SATA_SCQR_OFFSET             = 0x94, /* SATA command queue depth */
32         K2_SATA_QAL_OFFSET              = 0xa0, /* QDMA ring address lower */
33 @@ -330,6 +328,22 @@ static void brcm_EnableOOBWindowFix(void __iomem *mmio_base, int port)
34         mdio_write_reg(mmio_base, port, 0x0D, sval);
35  }
36  
37 +static void brcm_Enable256AlignDetection(void __iomem *mmio_base, int port)
38 +{
39 +       uint32_t tmp32;
40 +       void __iomem *port_mmio;
41 +
42 +       port_mmio = PORT_BASE(mmio_base, port);
43 +
44 +       tmp32 = readl(port_mmio + K2_SATA_SICR1_OFFSET);
45 +       tmp32 |= 0x08000000;
46 +       writel(tmp32, port_mmio + K2_SATA_SICR1_OFFSET);
47 +
48 +       tmp32 = readl(port_mmio + K2_SATA_SICR2_OFFSET);
49 +       tmp32 |= 0x00800000;
50 +       writel(tmp32, port_mmio + K2_SATA_SICR2_OFFSET);
51 +}
52 +
53  static void brcm_AnalogReset(void __iomem *mmio_base, int port)
54  {
55         /* do analog reset */
56 @@ -385,6 +399,8 @@ static void brcm_InitSata_1_5Gb(void __iomem *mmio_base, int port)
57         brcm_SetPllTxRxCtrl(mmio_base, port);
58         brcm_EnableOOBWindowFix(mmio_base, port);
59  
60 +       brcm_Enable256AlignDetection(mmio_base, port);
61 +
62         if (!port) {
63  #ifdef CONFIG_BRCM_SATA_75MHZ_PLL
64                 /* use 75Mhz PLL clock */
65 @@ -446,6 +462,8 @@ static void brcm_InitSata2_3Gb(void __iomem *mmio_base, int port)
66         brcm_SetPllTxRxCtrl(mmio_base, port);
67         brcm_EnableOOBWindowFix(mmio_base, port);
68  
69 +       brcm_Enable256AlignDetection(mmio_base, port);
70 +
71         if (!port) {
72  #ifdef CONFIG_BRCM_SATA_75MHZ_PLL
73                 /* use 75Mhz PLL clock */
74 @@ -758,11 +776,7 @@ static void k2_bmdma_setup_mmio(struct ata_queued_cmd *qc)
75         void __iomem *mmio = (void __iomem *) ap->ioaddr.bmdma_addr;
76         /* load PRD table addr. */
77         mb();   /* make sure PRD table writes are visible to controller */
78 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
79         writel(ap->bmdma_prd_dma, mmio + ATA_DMA_TABLE_OFS);
80 -#else
81 -       writel(ap->prd_dma, mmio + ATA_DMA_TABLE_OFS);
82 -#endif
83  
84         /* specify data direction, triple-check start bit is clear */
85         dmactl = readb(mmio + ATA_DMA_CMD);
86 @@ -819,11 +833,7 @@ static void k2_bmdma_start_mmio(struct ata_queued_cmd *qc)
87  
88  static int k2_sata_port_start(struct ata_port *ap)
89  {
90 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
91         ata_bmdma_port_start(ap);
92 -#else
93 -       ata_port_start(ap);
94 -#endif
95         return 0;
96  }
97  
98 @@ -848,8 +858,7 @@ static irqreturn_t k2_sata_interrupt(int irq, void *dev_instance)
99  
100                 ap = host->ports[i];
101  
102 -               ata_for_each_link(link, ap, EDGE)
103 -               {
104 +               ata_for_each_link(link, ap, EDGE) {
105                         int rc;
106                         unsigned int serror;
107  
108 @@ -887,11 +896,7 @@ static irqreturn_t k2_sata_interrupt(int irq, void *dev_instance)
109         if (handled & IRQ_HANDLED)
110                 return handled;
111  
112 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
113         return ata_bmdma_interrupt(irq, dev_instance);
114 -#else
115 -       return  ata_sff_interrupt(irq, dev_instance);
116 -#endif
117  }
118  
119  /*
120 @@ -1044,10 +1049,7 @@ static void k2_sata_remove_one(struct pci_dev *pdev)
121         struct k2_host_priv *hp = host->private_data;
122  
123         brcm_pm_unregister_cb("sata");
124 -
125 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
126         pm_runtime_get_noresume(&pdev->dev);
127 -#endif
128  
129         K2_POWER_ON(host);
130         ata_pci_remove_one(pdev);
131 @@ -1135,7 +1137,9 @@ static int k2_sata_resume(struct device *dev)
132                 ap = host->ports[i];
133  
134                 ata_for_each_link(link, ap, EDGE) {
135 +                       spin_unlock_irqrestore(&hp->lock, flags);
136                         sata_std_hardreset(link, NULL, 1000);
137 +                       spin_lock_irqsave(&hp->lock, flags);
138                 }
139         }
140  
141 @@ -1144,7 +1148,6 @@ static int k2_sata_resume(struct device *dev)
142         return 0;
143  }
144  
145 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
146  static int k2_sata_runtime_suspend(struct device *dev)
147  {
148         return k2_sata_suspend(dev);
149 @@ -1162,8 +1165,6 @@ static int k2_sata_runtime_idle(struct device *dev)
150         return 0; /* ignored by pm core */
151  }
152  
153 -#endif
154 -
155  /*
156   * Driver initialization
157   */
158 @@ -1206,25 +1207,25 @@ static struct ata_port_operations k2_sata_ops = {
159  };
160  
161  static const struct ata_port_info k2_port_info[] = {
162 -       /* chip_sata1 */
163 -       {
164 -               .flags          = ATA_FLAG_SATA |
165 -                                 K2_FLAG_NO_ATAPI_DMA,
166 -               .pio_mask       = 0x1f,
167 -               .mwdma_mask     = 0x07,
168 -               .udma_mask      = ATA_UDMA7,
169 -               .port_ops       = &k2_sata_ops,
170 -       },
171 -       /* chip_sata2 */
172 -       {
173 -               .flags          = ATA_FLAG_SATA |
174 -                                 K2_FLAG_NO_ATAPI_DMA |
175 -                                 K2_FLAG_BRCM_SATA2,
176 -               .pio_mask       = 0x1f,
177 -               .mwdma_mask     = 0x07,
178 -               .udma_mask      = ATA_UDMA7,
179 -               .port_ops       = &k2_sata_ops,
180 -       },
181 +        /* chip_sata1 */
182 +        {
183 +                .flags          = ATA_FLAG_SATA |
184 +                                  K2_FLAG_NO_ATAPI_DMA,
185 +                .pio_mask       = 0x1f,
186 +                .mwdma_mask     = 0x07,
187 +                .udma_mask      = ATA_UDMA7,
188 +                .port_ops       = &k2_sata_ops,
189 +        },
190 +        /* chip_sata2 */
191 +        {
192 +                .flags          = ATA_FLAG_SATA |
193 +                                  K2_FLAG_NO_ATAPI_DMA |
194 +                                  K2_FLAG_BRCM_SATA2,
195 +                .pio_mask       = 0x1f,
196 +                .mwdma_mask     = 0x07,
197 +                .udma_mask      = ATA_UDMA7,
198 +                .port_ops       = &k2_sata_ops,
199 +        },
200  };
201  
202  static void k2_sata_setup_port(struct ata_ioports *port, void __iomem *base)
203 @@ -1250,8 +1251,8 @@ static int k2_sata_init_one(struct pci_dev *pdev,
204                                 const struct pci_device_id *ent)
205  {
206         static int printed_version;
207 -       const struct ata_port_info *ppi[] =
208 -               { &k2_port_info[ent->driver_data], NULL };
209 +       const struct ata_port_info *ppi[] = {
210 +               &k2_port_info[ent->driver_data], NULL };
211         struct ata_host *host;
212         void __iomem *mmio_base;
213         int n_ports, i, rc, bar_pos;
214 @@ -1358,13 +1359,10 @@ static int k2_sata_init_one(struct pci_dev *pdev,
215  
216         brcm_pm_register_cb("sata", k2_sata_pm_cb, host);
217  
218 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
219         /* pci core incremented pm counter before calling probe,
220          * we are decrementing it to enable runtime pm */
221         pm_runtime_put_noidle(&pdev->dev);
222  
223 -#endif
224 -
225         return 0;
226  }
227  
228 @@ -1374,14 +1372,12 @@ static const struct pci_device_id k2_sata_pci_tbl[] = {
229         { }
230  };
231  
232 -static struct dev_pm_ops k2_sata_pm_ops = {
233 +static const struct dev_pm_ops k2_sata_pm_ops = {
234         .suspend_noirq          = k2_sata_suspend,
235         .resume_noirq           = k2_sata_resume,
236 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32)
237         .runtime_suspend        = k2_sata_runtime_suspend,
238         .runtime_resume         = k2_sata_runtime_resume,
239         .runtime_idle           = k2_sata_runtime_idle,
240 -#endif
241  };
242  
243  static struct pci_driver k2_sata_pci_driver = {