Commit 08354809d6c73eb73973e132502a0a4e53250971

Authored by Jassi Brar
Committed by Jeff Garzik
1 parent 9fe6206f40

ahci_platform: Provide for vendor specific init

Some AHCI implementations may use Vendor Specific HBA[A0h, FFh]
and/or Port[70h, 7Fh] registers to 'prepare' for initialization.
For that, the platform needs memory mapped address of AHCI registers.

This patch adds the 'mmio' argument and reorders the call to
platform init function.

Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>

Showing 2 changed files with 18 additions and 11 deletions Side-by-side Diff

drivers/ata/ahci_platform.c
... ... @@ -54,19 +54,13 @@
54 54 return -EINVAL;
55 55 }
56 56  
57   - if (pdata && pdata->init) {
58   - rc = pdata->init(dev);
59   - if (rc)
60   - return rc;
61   - }
62   -
63 57 if (pdata && pdata->ata_port_info)
64 58 pi = *pdata->ata_port_info;
65 59  
66 60 hpriv = devm_kzalloc(dev, sizeof(*hpriv), GFP_KERNEL);
67 61 if (!hpriv) {
68   - rc = -ENOMEM;
69   - goto err0;
  62 + dev_err(dev, "can't alloc ahci_host_priv\n");
  63 + return -ENOMEM;
70 64 }
71 65  
72 66 hpriv->flags |= (unsigned long)pi.private_data;
... ... @@ -74,8 +68,19 @@
74 68 hpriv->mmio = devm_ioremap(dev, mem->start, resource_size(mem));
75 69 if (!hpriv->mmio) {
76 70 dev_err(dev, "can't map %pR\n", mem);
77   - rc = -ENOMEM;
78   - goto err0;
  71 + return -ENOMEM;
  72 + }
  73 +
  74 + /*
  75 + * Some platforms might need to prepare for mmio region access,
  76 + * which could be done in the following init call. So, the mmio
  77 + * region shouldn't be accessed before init (if provided) has
  78 + * returned successfully.
  79 + */
  80 + if (pdata && pdata->init) {
  81 + rc = pdata->init(dev, hpriv->mmio);
  82 + if (rc)
  83 + return rc;
79 84 }
80 85  
81 86 ahci_save_initial_config(dev, hpriv,
include/linux/ahci_platform.h
... ... @@ -15,11 +15,13 @@
15 15 #ifndef _AHCI_PLATFORM_H
16 16 #define _AHCI_PLATFORM_H
17 17  
  18 +#include <linux/compiler.h>
  19 +
18 20 struct device;
19 21 struct ata_port_info;
20 22  
21 23 struct ahci_platform_data {
22   - int (*init)(struct device *dev);
  24 + int (*init)(struct device *dev, void __iomem *addr);
23 25 void (*exit)(struct device *dev);
24 26 const struct ata_port_info *ata_port_info;
25 27 unsigned int force_port_map;