aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnurag Kumar Vulisha <anurag.kumar.vulisha@xilinx.com>2017-08-21 07:17:17 -0400
committerTejun Heo <tj@kernel.org>2017-10-23 10:09:26 -0400
commitfe8365bbf8ac58f98a9a85105a6df468e1a4d489 (patch)
tree308ae078367e875090119cbc26c21ed47d3597c8
parent9053f4b9855c91f8905114c2108d5397be83bcf3 (diff)
ata: ceva: Move sata port phy oob settings to device-tree
In SATA Speed negotiation happens with OOB(Out of Band) signals. These OOB signal timing values are configured through vendor specific registers in the SATA controller. These OOB timings depends on the generator and detector clock frequency, which varies from board to board (ex: ep108 and zc1751 has different clock frequencies). To avoid maintaing these OOB settings in the driver, it is better to move these settings to the device-tree node and read from the device-tree. This patch does the same. Signed-off-by: Anurag Kumar Vulisha <anuragku@xilinx.com> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--drivers/ata/ahci_ceva.c84
1 files changed, 61 insertions, 23 deletions
diff --git a/drivers/ata/ahci_ceva.c b/drivers/ata/ahci_ceva.c
index 207649d323c5..59de2ca1885c 100644
--- a/drivers/ata/ahci_ceva.c
+++ b/drivers/ata/ahci_ceva.c
@@ -50,21 +50,6 @@
50#define PPCFG_PSS_EN (1 << 29) 50#define PPCFG_PSS_EN (1 << 29)
51#define PPCFG_ESDF_EN (1 << 31) 51#define PPCFG_ESDF_EN (1 << 31)
52 52
53#define PP2C_CIBGMN 0x0F
54#define PP2C_CIBGMX (0x25 << 8)
55#define PP2C_CIBGN (0x18 << 16)
56#define PP2C_CINMP (0x29 << 24)
57
58#define PP3C_CWBGMN 0x04
59#define PP3C_CWBGMX (0x0B << 8)
60#define PP3C_CWBGN (0x08 << 16)
61#define PP3C_CWNMP (0x0F << 24)
62
63#define PP4C_BMX 0x0a
64#define PP4C_BNM (0x08 << 8)
65#define PP4C_SFD (0x4a << 16)
66#define PP4C_PTST (0x06 << 24)
67
68#define PP5C_RIT 0x60216 53#define PP5C_RIT 0x60216
69#define PP5C_RCT (0x7f0 << 20) 54#define PP5C_RCT (0x7f0 << 20)
70 55
@@ -87,6 +72,11 @@
87 72
88struct ceva_ahci_priv { 73struct ceva_ahci_priv {
89 struct platform_device *ahci_pdev; 74 struct platform_device *ahci_pdev;
75 /* Port Phy2Cfg Register */
76 u32 pp2c[NR_PORTS];
77 u32 pp3c[NR_PORTS];
78 u32 pp4c[NR_PORTS];
79 u32 pp5c[NR_PORTS];
90 int flags; 80 int flags;
91}; 81};
92 82
@@ -131,20 +121,16 @@ static void ahci_ceva_setup(struct ahci_host_priv *hpriv)
131 writel(tmp, mmio + AHCI_VEND_PPCFG); 121 writel(tmp, mmio + AHCI_VEND_PPCFG);
132 122
133 /* Phy Control OOB timing parameters COMINIT */ 123 /* Phy Control OOB timing parameters COMINIT */
134 tmp = PP2C_CIBGMN | PP2C_CIBGMX | PP2C_CIBGN | PP2C_CINMP; 124 writel(cevapriv->pp2c[i], mmio + AHCI_VEND_PP2C);
135 writel(tmp, mmio + AHCI_VEND_PP2C);
136 125
137 /* Phy Control OOB timing parameters COMWAKE */ 126 /* Phy Control OOB timing parameters COMWAKE */
138 tmp = PP3C_CWBGMN | PP3C_CWBGMX | PP3C_CWBGN | PP3C_CWNMP; 127 writel(cevapriv->pp3c[i], mmio + AHCI_VEND_PP3C);
139 writel(tmp, mmio + AHCI_VEND_PP3C);
140 128
141 /* Phy Control Burst timing setting */ 129 /* Phy Control Burst timing setting */
142 tmp = PP4C_BMX | PP4C_BNM | PP4C_SFD | PP4C_PTST; 130 writel(cevapriv->pp4c[i], mmio + AHCI_VEND_PP4C);
143 writel(tmp, mmio + AHCI_VEND_PP4C);
144 131
145 /* Rate Change Timer and Retry Interval Timer setting */ 132 /* Rate Change Timer and Retry Interval Timer setting */
146 tmp = PP5C_RIT | PP5C_RCT; 133 writel(cevapriv->pp5c[i], mmio + AHCI_VEND_PP5C);
147 writel(tmp, mmio + AHCI_VEND_PP5C);
148 134
149 /* Rx Watermark setting */ 135 /* Rx Watermark setting */
150 tmp = PTC_RX_WM_VAL | PTC_RSVD; 136 tmp = PTC_RX_WM_VAL | PTC_RSVD;
@@ -187,6 +173,58 @@ static int ceva_ahci_probe(struct platform_device *pdev)
187 if (of_property_read_bool(np, "ceva,broken-gen2")) 173 if (of_property_read_bool(np, "ceva,broken-gen2"))
188 cevapriv->flags = CEVA_FLAG_BROKEN_GEN2; 174 cevapriv->flags = CEVA_FLAG_BROKEN_GEN2;
189 175
176 /* Read OOB timing value for COMINIT from device-tree */
177 if (of_property_read_u8_array(np, "ceva,p0-cominit-params",
178 (u8 *)&cevapriv->pp2c[0], 4) < 0) {
179 dev_warn(dev, "ceva,p0-cominit-params property not defined\n");
180 return -EINVAL;
181 }
182
183 if (of_property_read_u8_array(np, "ceva,p1-cominit-params",
184 (u8 *)&cevapriv->pp2c[1], 4) < 0) {
185 dev_warn(dev, "ceva,p1-cominit-params property not defined\n");
186 return -EINVAL;
187 }
188
189 /* Read OOB timing value for COMWAKE from device-tree*/
190 if (of_property_read_u8_array(np, "ceva,p0-comwake-params",
191 (u8 *)&cevapriv->pp3c[0], 4) < 0) {
192 dev_warn(dev, "ceva,p0-comwake-params property not defined\n");
193 return -EINVAL;
194 }
195
196 if (of_property_read_u8_array(np, "ceva,p1-comwake-params",
197 (u8 *)&cevapriv->pp3c[1], 4) < 0) {
198 dev_warn(dev, "ceva,p1-comwake-params property not defined\n");
199 return -EINVAL;
200 }
201
202 /* Read phy BURST timing value from device-tree */
203 if (of_property_read_u8_array(np, "ceva,p0-burst-params",
204 (u8 *)&cevapriv->pp4c[0], 4) < 0) {
205 dev_warn(dev, "ceva,p0-burst-params property not defined\n");
206 return -EINVAL;
207 }
208
209 if (of_property_read_u8_array(np, "ceva,p1-burst-params",
210 (u8 *)&cevapriv->pp4c[1], 4) < 0) {
211 dev_warn(dev, "ceva,p1-burst-params property not defined\n");
212 return -EINVAL;
213 }
214
215 /* Read phy RETRY interval timing value from device-tree */
216 if (of_property_read_u16_array(np, "ceva,p0-retry-params",
217 (u16 *)&cevapriv->pp5c[0], 2) < 0) {
218 dev_warn(dev, "ceva,p0-retry-params property not defined\n");
219 return -EINVAL;
220 }
221
222 if (of_property_read_u16_array(np, "ceva,p1-retry-params",
223 (u16 *)&cevapriv->pp5c[1], 2) < 0) {
224 dev_warn(dev, "ceva,p1-retry-params property not defined\n");
225 return -EINVAL;
226 }
227
190 hpriv->plat_data = cevapriv; 228 hpriv->plat_data = cevapriv;
191 229
192 /* CEVA specific initialization */ 230 /* CEVA specific initialization */