blob: 8354f2de37c317846398b2c5a0aa62aec141c649 [file] [log] [blame]
Brian Norris766a2d92015-05-12 16:28:21 -07001/*
2 * Broadcom SATA3 AHCI Controller Driver
3 *
4 * Copyright © 2009-2015 Broadcom Corporation
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 */
16
17#include <linux/ahci_platform.h>
18#include <linux/compiler.h>
19#include <linux/device.h>
20#include <linux/init.h>
21#include <linux/interrupt.h>
22#include <linux/io.h>
23#include <linux/kernel.h>
24#include <linux/libata.h>
25#include <linux/module.h>
26#include <linux/of.h>
27#include <linux/platform_device.h>
Florian Fainelli40680532018-10-01 10:33:00 -070028#include <linux/reset.h>
Brian Norris766a2d92015-05-12 16:28:21 -070029#include <linux/string.h>
30
31#include "ahci.h"
32
33#define DRV_NAME "brcm-ahci"
34
35#define SATA_TOP_CTRL_VERSION 0x0
36#define SATA_TOP_CTRL_BUS_CTRL 0x4
37 #define MMIO_ENDIAN_SHIFT 0 /* CPU->AHCI */
38 #define DMADESC_ENDIAN_SHIFT 2 /* AHCI->DDR */
39 #define DMADATA_ENDIAN_SHIFT 4 /* AHCI->DDR */
40 #define PIODATA_ENDIAN_SHIFT 6
41 #define ENDIAN_SWAP_NONE 0
42 #define ENDIAN_SWAP_FULL 2
43 #define OVERRIDE_HWINIT BIT(16)
44#define SATA_TOP_CTRL_TP_CTRL 0x8
45#define SATA_TOP_CTRL_PHY_CTRL 0xc
46 #define SATA_TOP_CTRL_PHY_CTRL_1 0x0
47 #define SATA_TOP_CTRL_1_PHY_DEFAULT_POWER_STATE BIT(14)
48 #define SATA_TOP_CTRL_PHY_CTRL_2 0x4
49 #define SATA_TOP_CTRL_2_SW_RST_MDIOREG BIT(0)
50 #define SATA_TOP_CTRL_2_SW_RST_OOB BIT(1)
51 #define SATA_TOP_CTRL_2_SW_RST_RX BIT(2)
52 #define SATA_TOP_CTRL_2_SW_RST_TX BIT(3)
53 #define SATA_TOP_CTRL_2_PHY_GLOBAL_RESET BIT(14)
54 #define SATA_TOP_CTRL_PHY_OFFS 0x8
55 #define SATA_TOP_MAX_PHYS 2
Brian Norris766a2d92015-05-12 16:28:21 -070056
Danesh Petigara6863caa2016-01-07 16:03:30 -080057#define SATA_FIRST_PORT_CTRL 0x700
58#define SATA_NEXT_PORT_CTRL_OFFSET 0x80
59#define SATA_PORT_PCTRL6(reg_base) (reg_base + 0x18)
60
Brian Norris766a2d92015-05-12 16:28:21 -070061/* On big-endian MIPS, buses are reversed to big endian, so switch them back */
62#if defined(CONFIG_MIPS) && defined(__BIG_ENDIAN)
63#define DATA_ENDIAN 2 /* AHCI->DDR inbound accesses */
64#define MMIO_ENDIAN 2 /* CPU->AHCI outbound accesses */
65#else
66#define DATA_ENDIAN 0
67#define MMIO_ENDIAN 0
68#endif
69
70#define BUS_CTRL_ENDIAN_CONF \
71 ((DATA_ENDIAN << DMADATA_ENDIAN_SHIFT) | \
72 (DATA_ENDIAN << DMADESC_ENDIAN_SHIFT) | \
73 (MMIO_ENDIAN << MMIO_ENDIAN_SHIFT))
74
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -040075enum brcm_ahci_version {
76 BRCM_SATA_BCM7425 = 1,
77 BRCM_SATA_BCM7445,
78 BRCM_SATA_NSP,
79};
80
Jaedon Shin7de32442015-11-26 11:56:30 +090081enum brcm_ahci_quirks {
82 BRCM_AHCI_QUIRK_NO_NCQ = BIT(0),
Jaedon Shinb46f79b2015-11-26 11:56:31 +090083 BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE = BIT(1),
Jaedon Shin7de32442015-11-26 11:56:30 +090084};
85
Brian Norris766a2d92015-05-12 16:28:21 -070086struct brcm_ahci_priv {
87 struct device *dev;
88 void __iomem *top_ctrl;
89 u32 port_mask;
Jaedon Shin7de32442015-11-26 11:56:30 +090090 u32 quirks;
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -040091 enum brcm_ahci_version version;
Florian Fainelli40680532018-10-01 10:33:00 -070092 struct reset_control *rcdev;
Brian Norris766a2d92015-05-12 16:28:21 -070093};
94
95static const struct ata_port_info ahci_brcm_port_info = {
Danesh Petigara6ca92dd2016-01-07 16:03:31 -080096 .flags = AHCI_FLAG_COMMON | ATA_FLAG_NO_DIPM,
Danesh Petigarae39b2bb2016-01-07 16:03:33 -080097 .link_flags = ATA_LFLAG_NO_DB_DELAY,
Brian Norris766a2d92015-05-12 16:28:21 -070098 .pio_mask = ATA_PIO4,
99 .udma_mask = ATA_UDMA6,
100 .port_ops = &ahci_platform_ops,
101};
102
103static inline u32 brcm_sata_readreg(void __iomem *addr)
104{
105 /*
106 * MIPS endianness is configured by boot strap, which also reverses all
107 * bus endianness (i.e., big-endian CPU + big endian bus ==> native
108 * endian I/O).
109 *
110 * Other architectures (e.g., ARM) either do not support big endian, or
111 * else leave I/O in little endian mode.
112 */
Axel Linf9114d32015-08-06 12:28:18 +0800113 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
Brian Norris766a2d92015-05-12 16:28:21 -0700114 return __raw_readl(addr);
115 else
116 return readl_relaxed(addr);
117}
118
119static inline void brcm_sata_writereg(u32 val, void __iomem *addr)
120{
121 /* See brcm_sata_readreg() comments */
Axel Linf9114d32015-08-06 12:28:18 +0800122 if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN))
Brian Norris766a2d92015-05-12 16:28:21 -0700123 __raw_writel(val, addr);
124 else
125 writel_relaxed(val, addr);
126}
127
Danesh Petigara6863caa2016-01-07 16:03:30 -0800128static void brcm_sata_alpm_init(struct ahci_host_priv *hpriv)
129{
130 struct brcm_ahci_priv *priv = hpriv->plat_data;
131 u32 bus_ctrl, port_ctrl, host_caps;
132 int i;
133
134 /* Enable support for ALPM */
135 bus_ctrl = brcm_sata_readreg(priv->top_ctrl +
136 SATA_TOP_CTRL_BUS_CTRL);
137 brcm_sata_writereg(bus_ctrl | OVERRIDE_HWINIT,
138 priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL);
139 host_caps = readl(hpriv->mmio + HOST_CAP);
140 writel(host_caps | HOST_CAP_ALPM, hpriv->mmio);
141 brcm_sata_writereg(bus_ctrl, priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL);
142
143 /*
144 * Adjust timeout to allow PLL sufficient time to lock while waking
145 * up from slumber mode.
146 */
147 for (i = 0, port_ctrl = SATA_FIRST_PORT_CTRL;
148 i < SATA_TOP_MAX_PHYS;
149 i++, port_ctrl += SATA_NEXT_PORT_CTRL_OFFSET) {
150 if (priv->port_mask & BIT(i))
151 writel(0xff1003fc,
152 hpriv->mmio + SATA_PORT_PCTRL6(port_ctrl));
153 }
154}
155
Brian Norris766a2d92015-05-12 16:28:21 -0700156static void brcm_sata_phy_enable(struct brcm_ahci_priv *priv, int port)
157{
158 void __iomem *phyctrl = priv->top_ctrl + SATA_TOP_CTRL_PHY_CTRL +
159 (port * SATA_TOP_CTRL_PHY_OFFS);
160 void __iomem *p;
161 u32 reg;
162
Jaedon Shinb46f79b2015-11-26 11:56:31 +0900163 if (priv->quirks & BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE)
164 return;
165
Brian Norris766a2d92015-05-12 16:28:21 -0700166 /* clear PHY_DEFAULT_POWER_STATE */
167 p = phyctrl + SATA_TOP_CTRL_PHY_CTRL_1;
168 reg = brcm_sata_readreg(p);
169 reg &= ~SATA_TOP_CTRL_1_PHY_DEFAULT_POWER_STATE;
170 brcm_sata_writereg(reg, p);
171
172 /* reset the PHY digital logic */
173 p = phyctrl + SATA_TOP_CTRL_PHY_CTRL_2;
174 reg = brcm_sata_readreg(p);
175 reg &= ~(SATA_TOP_CTRL_2_SW_RST_MDIOREG | SATA_TOP_CTRL_2_SW_RST_OOB |
176 SATA_TOP_CTRL_2_SW_RST_RX);
177 reg |= SATA_TOP_CTRL_2_SW_RST_TX;
178 brcm_sata_writereg(reg, p);
179 reg = brcm_sata_readreg(p);
180 reg |= SATA_TOP_CTRL_2_PHY_GLOBAL_RESET;
181 brcm_sata_writereg(reg, p);
182 reg = brcm_sata_readreg(p);
183 reg &= ~SATA_TOP_CTRL_2_PHY_GLOBAL_RESET;
184 brcm_sata_writereg(reg, p);
185 (void)brcm_sata_readreg(p);
186}
187
188static void brcm_sata_phy_disable(struct brcm_ahci_priv *priv, int port)
189{
190 void __iomem *phyctrl = priv->top_ctrl + SATA_TOP_CTRL_PHY_CTRL +
191 (port * SATA_TOP_CTRL_PHY_OFFS);
192 void __iomem *p;
193 u32 reg;
194
Jaedon Shinb46f79b2015-11-26 11:56:31 +0900195 if (priv->quirks & BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE)
196 return;
197
Brian Norris766a2d92015-05-12 16:28:21 -0700198 /* power-off the PHY digital logic */
199 p = phyctrl + SATA_TOP_CTRL_PHY_CTRL_2;
200 reg = brcm_sata_readreg(p);
201 reg |= (SATA_TOP_CTRL_2_SW_RST_MDIOREG | SATA_TOP_CTRL_2_SW_RST_OOB |
202 SATA_TOP_CTRL_2_SW_RST_RX | SATA_TOP_CTRL_2_SW_RST_TX |
203 SATA_TOP_CTRL_2_PHY_GLOBAL_RESET);
204 brcm_sata_writereg(reg, p);
205
206 /* set PHY_DEFAULT_POWER_STATE */
207 p = phyctrl + SATA_TOP_CTRL_PHY_CTRL_1;
208 reg = brcm_sata_readreg(p);
209 reg |= SATA_TOP_CTRL_1_PHY_DEFAULT_POWER_STATE;
210 brcm_sata_writereg(reg, p);
211}
212
213static void brcm_sata_phys_enable(struct brcm_ahci_priv *priv)
214{
215 int i;
216
217 for (i = 0; i < SATA_TOP_MAX_PHYS; i++)
218 if (priv->port_mask & BIT(i))
219 brcm_sata_phy_enable(priv, i);
220}
221
222static void brcm_sata_phys_disable(struct brcm_ahci_priv *priv)
223{
224 int i;
225
226 for (i = 0; i < SATA_TOP_MAX_PHYS; i++)
227 if (priv->port_mask & BIT(i))
228 brcm_sata_phy_disable(priv, i);
229}
230
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800231static u32 brcm_ahci_get_portmask(struct ahci_host_priv *hpriv,
Brian Norris766a2d92015-05-12 16:28:21 -0700232 struct brcm_ahci_priv *priv)
233{
Brian Norris766a2d92015-05-12 16:28:21 -0700234 u32 impl;
235
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800236 impl = readl(hpriv->mmio + HOST_PORTS_IMPL);
Brian Norris766a2d92015-05-12 16:28:21 -0700237
238 if (fls(impl) > SATA_TOP_MAX_PHYS)
239 dev_warn(priv->dev, "warning: more ports than PHYs (%#x)\n",
240 impl);
241 else if (!impl)
242 dev_info(priv->dev, "no ports found\n");
243
Brian Norris766a2d92015-05-12 16:28:21 -0700244 return impl;
245}
246
247static void brcm_sata_init(struct brcm_ahci_priv *priv)
248{
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -0400249 void __iomem *ctrl = priv->top_ctrl + SATA_TOP_CTRL_BUS_CTRL;
250
Brian Norris766a2d92015-05-12 16:28:21 -0700251 /* Configure endianness */
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -0400252 if (priv->version == BRCM_SATA_NSP) {
253 u32 data = brcm_sata_readreg(ctrl);
254
255 data &= ~((0x03 << DMADATA_ENDIAN_SHIFT) |
256 (0x03 << DMADESC_ENDIAN_SHIFT));
257 data |= (0x02 << DMADATA_ENDIAN_SHIFT) |
258 (0x02 << DMADESC_ENDIAN_SHIFT);
259 brcm_sata_writereg(data, ctrl);
260 } else
261 brcm_sata_writereg(BUS_CTRL_ENDIAN_CONF, ctrl);
Brian Norris766a2d92015-05-12 16:28:21 -0700262}
263
Florian Fainelli8b34fe52015-07-14 13:03:33 -0700264#ifdef CONFIG_PM_SLEEP
Brian Norris766a2d92015-05-12 16:28:21 -0700265static int brcm_ahci_suspend(struct device *dev)
266{
267 struct ata_host *host = dev_get_drvdata(dev);
268 struct ahci_host_priv *hpriv = host->private_data;
269 struct brcm_ahci_priv *priv = hpriv->plat_data;
Brian Norris766a2d92015-05-12 16:28:21 -0700270
Brian Norris766a2d92015-05-12 16:28:21 -0700271 brcm_sata_phys_disable(priv);
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800272
273 return ahci_platform_suspend(dev);
Brian Norris766a2d92015-05-12 16:28:21 -0700274}
275
276static int brcm_ahci_resume(struct device *dev)
277{
278 struct ata_host *host = dev_get_drvdata(dev);
279 struct ahci_host_priv *hpriv = host->private_data;
280 struct brcm_ahci_priv *priv = hpriv->plat_data;
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800281 int ret;
282
283 /* Make sure clocks are turned on before re-configuration */
284 ret = ahci_platform_enable_clks(hpriv);
285 if (ret)
286 return ret;
Brian Norris766a2d92015-05-12 16:28:21 -0700287
Florian Fainelliafe83722021-01-29 10:28:45 -0800288 ret = ahci_platform_enable_regulators(hpriv);
289 if (ret)
290 goto out_disable_clks;
291
Brian Norris766a2d92015-05-12 16:28:21 -0700292 brcm_sata_init(priv);
293 brcm_sata_phys_enable(priv);
Danesh Petigara6863caa2016-01-07 16:03:30 -0800294 brcm_sata_alpm_init(hpriv);
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800295
296 /* Since we had to enable clocks earlier on, we cannot use
297 * ahci_platform_resume() as-is since a second call to
298 * ahci_platform_enable_resources() would bump up the resources
299 * (regulators, clocks, PHYs) count artificially so we copy the part
300 * after ahci_platform_enable_resources().
301 */
302 ret = ahci_platform_enable_phys(hpriv);
303 if (ret)
304 goto out_disable_phys;
305
306 ret = ahci_platform_resume_host(dev);
307 if (ret)
308 goto out_disable_platform_phys;
309
310 /* We resumed so update PM runtime state */
311 pm_runtime_disable(dev);
312 pm_runtime_set_active(dev);
313 pm_runtime_enable(dev);
314
315 return 0;
316
317out_disable_platform_phys:
318 ahci_platform_disable_phys(hpriv);
319out_disable_phys:
320 brcm_sata_phys_disable(priv);
Florian Fainelliafe83722021-01-29 10:28:45 -0800321 ahci_platform_disable_regulators(hpriv);
322out_disable_clks:
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800323 ahci_platform_disable_clks(hpriv);
324 return ret;
Brian Norris766a2d92015-05-12 16:28:21 -0700325}
Florian Fainelli8b34fe52015-07-14 13:03:33 -0700326#endif
Brian Norris766a2d92015-05-12 16:28:21 -0700327
328static struct scsi_host_template ahci_platform_sht = {
329 AHCI_SHT(DRV_NAME),
330};
331
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -0400332static const struct of_device_id ahci_of_match[] = {
333 {.compatible = "brcm,bcm7425-ahci", .data = (void *)BRCM_SATA_BCM7425},
334 {.compatible = "brcm,bcm7445-ahci", .data = (void *)BRCM_SATA_BCM7445},
335 {.compatible = "brcm,bcm-nsp-ahci", .data = (void *)BRCM_SATA_NSP},
336 {},
337};
338MODULE_DEVICE_TABLE(of, ahci_of_match);
339
Brian Norris766a2d92015-05-12 16:28:21 -0700340static int brcm_ahci_probe(struct platform_device *pdev)
341{
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -0400342 const struct of_device_id *of_id;
Brian Norris766a2d92015-05-12 16:28:21 -0700343 struct device *dev = &pdev->dev;
344 struct brcm_ahci_priv *priv;
345 struct ahci_host_priv *hpriv;
346 struct resource *res;
347 int ret;
348
349 priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
350 if (!priv)
351 return -ENOMEM;
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -0400352
353 of_id = of_match_node(ahci_of_match, pdev->dev.of_node);
354 if (!of_id)
355 return -ENODEV;
356
357 priv->version = (enum brcm_ahci_version)of_id->data;
Brian Norris766a2d92015-05-12 16:28:21 -0700358 priv->dev = dev;
359
360 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "top-ctrl");
361 priv->top_ctrl = devm_ioremap_resource(dev, res);
362 if (IS_ERR(priv->top_ctrl))
363 return PTR_ERR(priv->top_ctrl);
364
Florian Fainelli40680532018-10-01 10:33:00 -0700365 /* Reset is optional depending on platform */
366 priv->rcdev = devm_reset_control_get(&pdev->dev, "ahci");
367 if (!IS_ERR_OR_NULL(priv->rcdev))
368 reset_control_deassert(priv->rcdev);
369
Yendapally Reddy Dhananjaya Reddy3ee2e6d2016-06-16 09:53:33 -0400370 if ((priv->version == BRCM_SATA_BCM7425) ||
371 (priv->version == BRCM_SATA_NSP)) {
Jaedon Shin7de32442015-11-26 11:56:30 +0900372 priv->quirks |= BRCM_AHCI_QUIRK_NO_NCQ;
Jaedon Shinb46f79b2015-11-26 11:56:31 +0900373 priv->quirks |= BRCM_AHCI_QUIRK_SKIP_PHY_ENABLE;
374 }
Jaedon Shin7de32442015-11-26 11:56:30 +0900375
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800376 hpriv = ahci_platform_get_resources(pdev);
377 if (IS_ERR(hpriv)) {
378 ret = PTR_ERR(hpriv);
379 goto out_reset;
380 }
381
382 ret = ahci_platform_enable_clks(hpriv);
383 if (ret)
384 goto out_reset;
385
Florian Fainelliafe83722021-01-29 10:28:45 -0800386 ret = ahci_platform_enable_regulators(hpriv);
387 if (ret)
388 goto out_disable_clks;
389
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800390 /* Must be first so as to configure endianness including that
391 * of the standard AHCI register space.
392 */
Brian Norris766a2d92015-05-12 16:28:21 -0700393 brcm_sata_init(priv);
394
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800395 /* Initializes priv->port_mask which is used below */
396 priv->port_mask = brcm_ahci_get_portmask(hpriv, priv);
397 if (!priv->port_mask) {
398 ret = -ENODEV;
Florian Fainelliafe83722021-01-29 10:28:45 -0800399 goto out_disable_regulators;
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800400 }
Brian Norris766a2d92015-05-12 16:28:21 -0700401
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800402 /* Must be done before ahci_platform_enable_phys() */
Brian Norris766a2d92015-05-12 16:28:21 -0700403 brcm_sata_phys_enable(priv);
404
Brian Norris766a2d92015-05-12 16:28:21 -0700405 hpriv->plat_data = priv;
Danesh Petigarafb329632016-01-11 13:22:26 -0800406 hpriv->flags = AHCI_HFLAG_WAKE_BEFORE_STOP;
Brian Norris766a2d92015-05-12 16:28:21 -0700407
Danesh Petigara6863caa2016-01-07 16:03:30 -0800408 brcm_sata_alpm_init(hpriv);
409
Jaedon Shin7de32442015-11-26 11:56:30 +0900410 if (priv->quirks & BRCM_AHCI_QUIRK_NO_NCQ)
411 hpriv->flags |= AHCI_HFLAG_NO_NCQ;
412
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800413 ret = ahci_platform_enable_phys(hpriv);
414 if (ret)
415 goto out_disable_phys;
416
Brian Norris766a2d92015-05-12 16:28:21 -0700417 ret = ahci_platform_init_host(pdev, hpriv, &ahci_brcm_port_info,
418 &ahci_platform_sht);
419 if (ret)
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800420 goto out_disable_platform_phys;
Brian Norris766a2d92015-05-12 16:28:21 -0700421
422 dev_info(dev, "Broadcom AHCI SATA3 registered\n");
423
424 return 0;
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800425
426out_disable_platform_phys:
427 ahci_platform_disable_phys(hpriv);
428out_disable_phys:
429 brcm_sata_phys_disable(priv);
Florian Fainelliafe83722021-01-29 10:28:45 -0800430out_disable_regulators:
431 ahci_platform_disable_regulators(hpriv);
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800432out_disable_clks:
433 ahci_platform_disable_clks(hpriv);
434out_reset:
435 if (!IS_ERR_OR_NULL(priv->rcdev))
436 reset_control_assert(priv->rcdev);
437 return ret;
Brian Norris766a2d92015-05-12 16:28:21 -0700438}
439
440static int brcm_ahci_remove(struct platform_device *pdev)
441{
442 struct ata_host *host = dev_get_drvdata(&pdev->dev);
443 struct ahci_host_priv *hpriv = host->private_data;
444 struct brcm_ahci_priv *priv = hpriv->plat_data;
445 int ret;
446
Florian Fainelli59d8bff2019-12-10 10:53:45 -0800447 brcm_sata_phys_disable(priv);
448
Brian Norris766a2d92015-05-12 16:28:21 -0700449 ret = ata_platform_remove_one(pdev);
450 if (ret)
451 return ret;
452
Brian Norris766a2d92015-05-12 16:28:21 -0700453 return 0;
454}
455
Brian Norris766a2d92015-05-12 16:28:21 -0700456static SIMPLE_DEV_PM_OPS(ahci_brcm_pm_ops, brcm_ahci_suspend, brcm_ahci_resume);
457
458static struct platform_driver brcm_ahci_driver = {
459 .probe = brcm_ahci_probe,
460 .remove = brcm_ahci_remove,
461 .driver = {
462 .name = DRV_NAME,
463 .of_match_table = ahci_of_match,
464 .pm = &ahci_brcm_pm_ops,
465 },
466};
467module_platform_driver(brcm_ahci_driver);
468
469MODULE_DESCRIPTION("Broadcom SATA3 AHCI Controller Driver");
470MODULE_AUTHOR("Brian Norris");
471MODULE_LICENSE("GPL");
472MODULE_ALIAS("platform:sata-brcmstb");