pata_pdc2027x: Use 64-bit timekeeping
[deliverable/linux.git] / drivers / ata / libahci_platform.c
CommitLineData
fd990556
BZ
1/*
2 * AHCI SATA platform library
3 *
4 * Copyright 2004-2005 Red Hat, Inc.
5 * Jeff Garzik <jgarzik@pobox.com>
6 * Copyright 2010 MontaVista Software, LLC.
7 * Anton Vorontsov <avorontsov@ru.mvista.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2, or (at your option)
12 * any later version.
13 */
14
15#include <linux/clk.h>
16#include <linux/kernel.h>
17#include <linux/gfp.h>
18#include <linux/module.h>
19#include <linux/pm.h>
20#include <linux/interrupt.h>
21#include <linux/device.h>
22#include <linux/platform_device.h>
23#include <linux/libata.h>
24#include <linux/ahci_platform.h>
25#include <linux/phy/phy.h>
26#include <linux/pm_runtime.h>
c7d7ddee 27#include <linux/of_platform.h>
fd990556
BZ
28#include "ahci.h"
29
30static void ahci_host_stop(struct ata_host *host);
31
32struct ata_port_operations ahci_platform_ops = {
33 .inherits = &ahci_ops,
34 .host_stop = ahci_host_stop,
35};
36EXPORT_SYMBOL_GPL(ahci_platform_ops);
37
38static struct scsi_host_template ahci_platform_sht = {
39 AHCI_SHT("ahci_platform"),
40};
41
b1a9edbd
AT
42/**
43 * ahci_platform_enable_phys - Enable PHYs
44 * @hpriv: host private area to store config values
45 *
46 * This function enables all the PHYs found in hpriv->phys, if any.
47 * If a PHY fails to be enabled, it disables all the PHYs already
48 * enabled in reverse order and returns an error.
49 *
50 * RETURNS:
51 * 0 on success otherwise a negative error code
52 */
6bb86fef 53static int ahci_platform_enable_phys(struct ahci_host_priv *hpriv)
b1a9edbd
AT
54{
55 int rc, i;
56
57 for (i = 0; i < hpriv->nports; i++) {
b1a9edbd
AT
58 rc = phy_init(hpriv->phys[i]);
59 if (rc)
60 goto disable_phys;
61
62 rc = phy_power_on(hpriv->phys[i]);
63 if (rc) {
64 phy_exit(hpriv->phys[i]);
65 goto disable_phys;
66 }
67 }
68
69 return 0;
70
71disable_phys:
72 while (--i >= 0) {
73 phy_power_off(hpriv->phys[i]);
74 phy_exit(hpriv->phys[i]);
75 }
76 return rc;
77}
b1a9edbd
AT
78
79/**
80 * ahci_platform_disable_phys - Disable PHYs
81 * @hpriv: host private area to store config values
82 *
83 * This function disables all PHYs found in hpriv->phys.
84 */
6bb86fef 85static void ahci_platform_disable_phys(struct ahci_host_priv *hpriv)
b1a9edbd
AT
86{
87 int i;
88
89 for (i = 0; i < hpriv->nports; i++) {
b1a9edbd
AT
90 phy_power_off(hpriv->phys[i]);
91 phy_exit(hpriv->phys[i]);
92 }
93}
b1a9edbd 94
fd990556
BZ
95/**
96 * ahci_platform_enable_clks - Enable platform clocks
97 * @hpriv: host private area to store config values
98 *
99 * This function enables all the clks found in hpriv->clks, starting at
100 * index 0. If any clk fails to enable it disables all the clks already
101 * enabled in reverse order, and then returns an error.
102 *
103 * RETURNS:
104 * 0 on success otherwise a negative error code
105 */
106int ahci_platform_enable_clks(struct ahci_host_priv *hpriv)
107{
108 int c, rc;
109
110 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++) {
111 rc = clk_prepare_enable(hpriv->clks[c]);
112 if (rc)
113 goto disable_unprepare_clk;
114 }
115 return 0;
116
117disable_unprepare_clk:
118 while (--c >= 0)
119 clk_disable_unprepare(hpriv->clks[c]);
120 return rc;
121}
122EXPORT_SYMBOL_GPL(ahci_platform_enable_clks);
123
124/**
125 * ahci_platform_disable_clks - Disable platform clocks
126 * @hpriv: host private area to store config values
127 *
128 * This function disables all the clks found in hpriv->clks, in reverse
129 * order of ahci_platform_enable_clks (starting at the end of the array).
130 */
131void ahci_platform_disable_clks(struct ahci_host_priv *hpriv)
132{
133 int c;
134
135 for (c = AHCI_MAX_CLKS - 1; c >= 0; c--)
136 if (hpriv->clks[c])
137 clk_disable_unprepare(hpriv->clks[c]);
138}
139EXPORT_SYMBOL_GPL(ahci_platform_disable_clks);
140
c7d7ddee
GC
141/**
142 * ahci_platform_enable_regulators - Enable regulators
143 * @hpriv: host private area to store config values
144 *
145 * This function enables all the regulators found in
146 * hpriv->target_pwrs, if any. If a regulator fails to be enabled, it
147 * disables all the regulators already enabled in reverse order and
148 * returns an error.
149 *
150 * RETURNS:
151 * 0 on success otherwise a negative error code
152 */
153int ahci_platform_enable_regulators(struct ahci_host_priv *hpriv)
154{
155 int rc, i;
156
157 for (i = 0; i < hpriv->nports; i++) {
158 if (!hpriv->target_pwrs[i])
159 continue;
160
161 rc = regulator_enable(hpriv->target_pwrs[i]);
162 if (rc)
163 goto disable_target_pwrs;
164 }
165
166 return 0;
167
168disable_target_pwrs:
169 while (--i >= 0)
170 if (hpriv->target_pwrs[i])
171 regulator_disable(hpriv->target_pwrs[i]);
172
173 return rc;
174}
175EXPORT_SYMBOL_GPL(ahci_platform_enable_regulators);
176
177/**
178 * ahci_platform_disable_regulators - Disable regulators
179 * @hpriv: host private area to store config values
180 *
181 * This function disables all regulators found in hpriv->target_pwrs.
182 */
183void ahci_platform_disable_regulators(struct ahci_host_priv *hpriv)
184{
185 int i;
186
187 for (i = 0; i < hpriv->nports; i++) {
188 if (!hpriv->target_pwrs[i])
189 continue;
190 regulator_disable(hpriv->target_pwrs[i]);
191 }
192}
193EXPORT_SYMBOL_GPL(ahci_platform_disable_regulators);
fd990556
BZ
194/**
195 * ahci_platform_enable_resources - Enable platform resources
196 * @hpriv: host private area to store config values
197 *
198 * This function enables all ahci_platform managed resources in the
199 * following order:
200 * 1) Regulator
201 * 2) Clocks (through ahci_platform_enable_clks)
b1a9edbd 202 * 3) Phys
fd990556
BZ
203 *
204 * If resource enabling fails at any point the previous enabled resources
205 * are disabled in reverse order.
206 *
207 * RETURNS:
208 * 0 on success otherwise a negative error code
209 */
210int ahci_platform_enable_resources(struct ahci_host_priv *hpriv)
211{
212 int rc;
213
c7d7ddee
GC
214 rc = ahci_platform_enable_regulators(hpriv);
215 if (rc)
216 return rc;
fd990556
BZ
217
218 rc = ahci_platform_enable_clks(hpriv);
219 if (rc)
220 goto disable_regulator;
221
b1a9edbd
AT
222 rc = ahci_platform_enable_phys(hpriv);
223 if (rc)
224 goto disable_clks;
fd990556
BZ
225
226 return 0;
227
228disable_clks:
229 ahci_platform_disable_clks(hpriv);
230
231disable_regulator:
c7d7ddee
GC
232 ahci_platform_disable_regulators(hpriv);
233
fd990556
BZ
234 return rc;
235}
236EXPORT_SYMBOL_GPL(ahci_platform_enable_resources);
237
238/**
239 * ahci_platform_disable_resources - Disable platform resources
240 * @hpriv: host private area to store config values
241 *
242 * This function disables all ahci_platform managed resources in the
243 * following order:
b1a9edbd 244 * 1) Phys
fd990556
BZ
245 * 2) Clocks (through ahci_platform_disable_clks)
246 * 3) Regulator
247 */
248void ahci_platform_disable_resources(struct ahci_host_priv *hpriv)
249{
b1a9edbd 250 ahci_platform_disable_phys(hpriv);
fd990556
BZ
251
252 ahci_platform_disable_clks(hpriv);
253
c7d7ddee 254 ahci_platform_disable_regulators(hpriv);
fd990556
BZ
255}
256EXPORT_SYMBOL_GPL(ahci_platform_disable_resources);
257
258static void ahci_platform_put_resources(struct device *dev, void *res)
259{
260 struct ahci_host_priv *hpriv = res;
261 int c;
262
263 if (hpriv->got_runtime_pm) {
264 pm_runtime_put_sync(dev);
265 pm_runtime_disable(dev);
266 }
267
268 for (c = 0; c < AHCI_MAX_CLKS && hpriv->clks[c]; c++)
269 clk_put(hpriv->clks[c]);
c7d7ddee
GC
270 /*
271 * The regulators are tied to child node device and not to the
272 * SATA device itself. So we can't use devm for automatically
273 * releasing them. We have to do it manually here.
274 */
275 for (c = 0; c < hpriv->nports; c++)
276 if (hpriv->target_pwrs && hpriv->target_pwrs[c])
277 regulator_put(hpriv->target_pwrs[c]);
278
55294150 279 kfree(hpriv->target_pwrs);
c7d7ddee
GC
280}
281
282static int ahci_platform_get_phy(struct ahci_host_priv *hpriv, u32 port,
283 struct device *dev, struct device_node *node)
284{
285 int rc;
286
287 hpriv->phys[port] = devm_of_phy_get(dev, node, NULL);
288
289 if (!IS_ERR(hpriv->phys[port]))
290 return 0;
291
292 rc = PTR_ERR(hpriv->phys[port]);
293 switch (rc) {
294 case -ENOSYS:
295 /* No PHY support. Check if PHY is required. */
296 if (of_find_property(node, "phys", NULL)) {
297 dev_err(dev,
298 "couldn't get PHY in node %s: ENOSYS\n",
299 node->name);
300 break;
301 }
302 case -ENODEV:
303 /* continue normally */
304 hpriv->phys[port] = NULL;
305 rc = 0;
306 break;
307
308 default:
309 dev_err(dev,
310 "couldn't get PHY in node %s: %d\n",
311 node->name, rc);
312
313 break;
314 }
315
316 return rc;
317}
318
319static int ahci_platform_get_regulator(struct ahci_host_priv *hpriv, u32 port,
320 struct device *dev)
321{
322 struct regulator *target_pwr;
323 int rc = 0;
324
325 target_pwr = regulator_get_optional(dev, "target");
326
327 if (!IS_ERR(target_pwr))
328 hpriv->target_pwrs[port] = target_pwr;
329 else
330 rc = PTR_ERR(target_pwr);
331
332 return rc;
fd990556
BZ
333}
334
335/**
336 * ahci_platform_get_resources - Get platform resources
337 * @pdev: platform device to get resources for
338 *
339 * This function allocates an ahci_host_priv struct, and gets the following
340 * resources, storing a reference to them inside the returned struct:
341 *
342 * 1) mmio registers (IORESOURCE_MEM 0, mandatory)
343 * 2) regulator for controlling the targets power (optional)
344 * 3) 0 - AHCI_MAX_CLKS clocks, as specified in the devs devicetree node,
345 * or for non devicetree enabled platforms a single clock
b1a9edbd 346 * 4) phys (optional)
fd990556
BZ
347 *
348 * RETURNS:
349 * The allocated ahci_host_priv on success, otherwise an ERR_PTR value
350 */
351struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev)
352{
353 struct device *dev = &pdev->dev;
354 struct ahci_host_priv *hpriv;
355 struct clk *clk;
b1a9edbd 356 struct device_node *child;
c7d7ddee 357 int i, sz, enabled_ports = 0, rc = -ENOMEM, child_nodes;
b1a9edbd 358 u32 mask_port_map = 0;
fd990556
BZ
359
360 if (!devres_open_group(dev, NULL, GFP_KERNEL))
361 return ERR_PTR(-ENOMEM);
362
363 hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv),
364 GFP_KERNEL);
365 if (!hpriv)
366 goto err_out;
367
368 devres_add(dev, hpriv);
369
370 hpriv->mmio = devm_ioremap_resource(dev,
371 platform_get_resource(pdev, IORESOURCE_MEM, 0));
372 if (IS_ERR(hpriv->mmio)) {
373 dev_err(dev, "no mmio space\n");
374 rc = PTR_ERR(hpriv->mmio);
375 goto err_out;
376 }
377
fd990556
BZ
378 for (i = 0; i < AHCI_MAX_CLKS; i++) {
379 /*
380 * For now we must use clk_get(dev, NULL) for the first clock,
381 * because some platforms (da850, spear13xx) are not yet
382 * converted to use devicetree for clocks. For new platforms
383 * this is equivalent to of_clk_get(dev->of_node, 0).
384 */
385 if (i == 0)
386 clk = clk_get(dev, NULL);
387 else
388 clk = of_clk_get(dev->of_node, i);
389
390 if (IS_ERR(clk)) {
391 rc = PTR_ERR(clk);
392 if (rc == -EPROBE_DEFER)
393 goto err_out;
394 break;
395 }
396 hpriv->clks[i] = clk;
397 }
398
c7d7ddee 399 hpriv->nports = child_nodes = of_get_child_count(dev->of_node);
b1a9edbd 400
c7d7ddee
GC
401 /*
402 * If no sub-node was found, we still need to set nports to
403 * one in order to be able to use the
404 * ahci_platform_[en|dis]able_[phys|regulators] functions.
405 */
406 if (!child_nodes)
407 hpriv->nports = 1;
408
409 sz = hpriv->nports * sizeof(*hpriv->phys);
410 hpriv->phys = devm_kzalloc(dev, sz, GFP_KERNEL);
411 if (!hpriv->phys) {
412 rc = -ENOMEM;
413 goto err_out;
414 }
415 sz = hpriv->nports * sizeof(*hpriv->target_pwrs);
55294150 416 hpriv->target_pwrs = kzalloc(sz, GFP_KERNEL);
c7d7ddee
GC
417 if (!hpriv->target_pwrs) {
418 rc = -ENOMEM;
419 goto err_out;
420 }
b1a9edbd 421
c7d7ddee 422 if (child_nodes) {
b1a9edbd
AT
423 for_each_child_of_node(dev->of_node, child) {
424 u32 port;
c7d7ddee 425 struct platform_device *port_dev;
b1a9edbd
AT
426
427 if (!of_device_is_available(child))
428 continue;
429
430 if (of_property_read_u32(child, "reg", &port)) {
431 rc = -EINVAL;
acbd5733
MP
432 goto err_out;
433 }
fd990556 434
b1a9edbd
AT
435 if (port >= hpriv->nports) {
436 dev_warn(dev, "invalid port number %d\n", port);
437 continue;
438 }
b1a9edbd
AT
439 mask_port_map |= BIT(port);
440
c7d7ddee
GC
441 of_platform_device_create(child, NULL, NULL);
442
443 port_dev = of_find_device_by_node(child);
444
445 if (port_dev) {
446 rc = ahci_platform_get_regulator(hpriv, port,
447 &port_dev->dev);
448 if (rc == -EPROBE_DEFER)
449 goto err_out;
b1a9edbd 450 }
fd990556 451
c7d7ddee
GC
452 rc = ahci_platform_get_phy(hpriv, port, dev, child);
453 if (rc)
454 goto err_out;
455
b1a9edbd
AT
456 enabled_ports++;
457 }
458 if (!enabled_ports) {
459 dev_warn(dev, "No port enabled\n");
460 rc = -ENODEV;
fd990556
BZ
461 goto err_out;
462 }
b1a9edbd
AT
463
464 if (!hpriv->mask_port_map)
465 hpriv->mask_port_map = mask_port_map;
466 } else {
467 /*
468 * If no sub-node was found, keep this for device tree
469 * compatibility
470 */
c7d7ddee
GC
471 rc = ahci_platform_get_phy(hpriv, 0, dev, dev->of_node);
472 if (rc)
473 goto err_out;
b1a9edbd 474
c7d7ddee
GC
475 rc = ahci_platform_get_regulator(hpriv, 0, dev);
476 if (rc == -EPROBE_DEFER)
477 goto err_out;
fd990556 478 }
fd990556
BZ
479 pm_runtime_enable(dev);
480 pm_runtime_get_sync(dev);
481 hpriv->got_runtime_pm = true;
482
483 devres_remove_group(dev, NULL);
484 return hpriv;
485
486err_out:
487 devres_release_group(dev, NULL);
488 return ERR_PTR(rc);
489}
490EXPORT_SYMBOL_GPL(ahci_platform_get_resources);
491
492/**
493 * ahci_platform_init_host - Bring up an ahci-platform host
494 * @pdev: platform device pointer for the host
495 * @hpriv: ahci-host private data for the host
496 * @pi_template: template for the ata_port_info to use
fd990556
BZ
497 *
498 * This function does all the usual steps needed to bring up an
b1a9edbd 499 * ahci-platform host, note any necessary resources (ie clks, phys, etc.)
fd990556
BZ
500 * must be initialized / enabled before calling this.
501 *
502 * RETURNS:
503 * 0 on success otherwise a negative error code
504 */
505int ahci_platform_init_host(struct platform_device *pdev,
506 struct ahci_host_priv *hpriv,
725c7b57 507 const struct ata_port_info *pi_template)
fd990556
BZ
508{
509 struct device *dev = &pdev->dev;
510 struct ata_port_info pi = *pi_template;
511 const struct ata_port_info *ppi[] = { &pi, NULL };
512 struct ata_host *host;
513 int i, irq, n_ports, rc;
514
515 irq = platform_get_irq(pdev, 0);
516 if (irq <= 0) {
517 dev_err(dev, "no irq\n");
518 return -EINVAL;
519 }
520
521 /* prepare host */
c4121c65 522 pi.private_data = (void *)(unsigned long)hpriv->flags;
fd990556 523
725c7b57 524 ahci_save_initial_config(dev, hpriv);
fd990556
BZ
525
526 if (hpriv->cap & HOST_CAP_NCQ)
527 pi.flags |= ATA_FLAG_NCQ;
528
529 if (hpriv->cap & HOST_CAP_PMP)
530 pi.flags |= ATA_FLAG_PMP;
531
532 ahci_set_em_messages(hpriv, &pi);
533
534 /* CAP.NP sometimes indicate the index of the last enabled
535 * port, at other times, that of the last possible port, so
536 * determining the maximum port number requires looking at
537 * both CAP.NP and port_map.
538 */
539 n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
540
541 host = ata_host_alloc_pinfo(dev, ppi, n_ports);
542 if (!host)
543 return -ENOMEM;
544
545 host->private_data = hpriv;
546
547 if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
548 host->flags |= ATA_HOST_PARALLEL_SCAN;
549 else
550 dev_info(dev, "SSS flag set, parallel bus scan disabled\n");
551
552 if (pi.flags & ATA_FLAG_EM)
553 ahci_reset_em(host);
554
555 for (i = 0; i < host->n_ports; i++) {
556 struct ata_port *ap = host->ports[i];
557
558 ata_port_desc(ap, "mmio %pR",
559 platform_get_resource(pdev, IORESOURCE_MEM, 0));
560 ata_port_desc(ap, "port 0x%x", 0x100 + ap->port_no * 0x80);
561
562 /* set enclosure management message type */
563 if (ap->flags & ATA_FLAG_EM)
564 ap->em_message_type = hpriv->em_msg_type;
565
566 /* disabled/not-implemented port */
567 if (!(hpriv->port_map & (1 << i)))
568 ap->ops = &ata_dummy_port_ops;
569 }
570
cc7a9e27
SS
571 if (hpriv->cap & HOST_CAP_64) {
572 rc = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(64));
573 if (rc) {
574 rc = dma_coerce_mask_and_coherent(dev,
575 DMA_BIT_MASK(32));
576 if (rc) {
577 dev_err(dev, "Failed to enable 64-bit DMA.\n");
578 return rc;
579 }
580 dev_warn(dev, "Enable 32-bit DMA instead of 64-bit.\n");
581 }
582 }
583
fd990556
BZ
584 rc = ahci_reset_controller(host);
585 if (rc)
586 return rc;
587
588 ahci_init_controller(host);
589 ahci_print_info(host, "platform");
590
d1028e2f 591 return ahci_host_activate(host, irq, &ahci_platform_sht);
fd990556
BZ
592}
593EXPORT_SYMBOL_GPL(ahci_platform_init_host);
594
595static void ahci_host_stop(struct ata_host *host)
596{
fd990556
BZ
597 struct ahci_host_priv *hpriv = host->private_data;
598
fd990556
BZ
599 ahci_platform_disable_resources(hpriv);
600}
601
602#ifdef CONFIG_PM_SLEEP
603/**
604 * ahci_platform_suspend_host - Suspend an ahci-platform host
605 * @dev: device pointer for the host
606 *
607 * This function does all the usual steps needed to suspend an
b1a9edbd 608 * ahci-platform host, note any necessary resources (ie clks, phys, etc.)
fd990556
BZ
609 * must be disabled after calling this.
610 *
611 * RETURNS:
612 * 0 on success otherwise a negative error code
613 */
614int ahci_platform_suspend_host(struct device *dev)
615{
616 struct ata_host *host = dev_get_drvdata(dev);
617 struct ahci_host_priv *hpriv = host->private_data;
618 void __iomem *mmio = hpriv->mmio;
619 u32 ctl;
620
621 if (hpriv->flags & AHCI_HFLAG_NO_SUSPEND) {
622 dev_err(dev, "firmware update required for suspend/resume\n");
623 return -EIO;
624 }
625
626 /*
627 * AHCI spec rev1.1 section 8.3.3:
628 * Software must disable interrupts prior to requesting a
629 * transition of the HBA to D3 state.
630 */
631 ctl = readl(mmio + HOST_CTL);
632 ctl &= ~HOST_IRQ_EN;
633 writel(ctl, mmio + HOST_CTL);
634 readl(mmio + HOST_CTL); /* flush */
635
636 return ata_host_suspend(host, PMSG_SUSPEND);
637}
638EXPORT_SYMBOL_GPL(ahci_platform_suspend_host);
639
640/**
641 * ahci_platform_resume_host - Resume an ahci-platform host
642 * @dev: device pointer for the host
643 *
644 * This function does all the usual steps needed to resume an ahci-platform
b1a9edbd 645 * host, note any necessary resources (ie clks, phys, etc.) must be
fd990556
BZ
646 * initialized / enabled before calling this.
647 *
648 * RETURNS:
649 * 0 on success otherwise a negative error code
650 */
651int ahci_platform_resume_host(struct device *dev)
652{
653 struct ata_host *host = dev_get_drvdata(dev);
654 int rc;
655
656 if (dev->power.power_state.event == PM_EVENT_SUSPEND) {
657 rc = ahci_reset_controller(host);
658 if (rc)
659 return rc;
660
661 ahci_init_controller(host);
662 }
663
664 ata_host_resume(host);
665
666 return 0;
667}
668EXPORT_SYMBOL_GPL(ahci_platform_resume_host);
669
670/**
671 * ahci_platform_suspend - Suspend an ahci-platform device
672 * @dev: the platform device to suspend
673 *
674 * This function suspends the host associated with the device, followed by
675 * disabling all the resources of the device.
676 *
677 * RETURNS:
678 * 0 on success otherwise a negative error code
679 */
680int ahci_platform_suspend(struct device *dev)
681{
fd990556
BZ
682 struct ata_host *host = dev_get_drvdata(dev);
683 struct ahci_host_priv *hpriv = host->private_data;
684 int rc;
685
686 rc = ahci_platform_suspend_host(dev);
687 if (rc)
688 return rc;
689
fd990556
BZ
690 ahci_platform_disable_resources(hpriv);
691
692 return 0;
fd990556
BZ
693}
694EXPORT_SYMBOL_GPL(ahci_platform_suspend);
695
696/**
697 * ahci_platform_resume - Resume an ahci-platform device
698 * @dev: the platform device to resume
699 *
700 * This function enables all the resources of the device followed by
701 * resuming the host associated with the device.
702 *
703 * RETURNS:
704 * 0 on success otherwise a negative error code
705 */
706int ahci_platform_resume(struct device *dev)
707{
fd990556
BZ
708 struct ata_host *host = dev_get_drvdata(dev);
709 struct ahci_host_priv *hpriv = host->private_data;
710 int rc;
711
712 rc = ahci_platform_enable_resources(hpriv);
713 if (rc)
714 return rc;
715
fd990556
BZ
716 rc = ahci_platform_resume_host(dev);
717 if (rc)
718 goto disable_resources;
719
720 /* We resumed so update PM runtime state */
721 pm_runtime_disable(dev);
722 pm_runtime_set_active(dev);
723 pm_runtime_enable(dev);
724
725 return 0;
726
727disable_resources:
728 ahci_platform_disable_resources(hpriv);
729
730 return rc;
731}
732EXPORT_SYMBOL_GPL(ahci_platform_resume);
733#endif
734
735MODULE_DESCRIPTION("AHCI SATA platform library");
736MODULE_AUTHOR("Anton Vorontsov <avorontsov@ru.mvista.com>");
737MODULE_LICENSE("GPL");
This page took 0.080139 seconds and 5 git commands to generate.