crypto: qce - add dependancy to Kconfig
[linux-2.6/btrfs-unstable.git] / drivers / ata / ahci_mvebu.c
blobfd3dfd733b8436b24fb55c5be4c686f01f8ba1bb
1 /*
2 * AHCI glue platform driver for Marvell EBU SOCs
4 * Copyright (C) 2014 Marvell
6 * Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
7 * Marcin Wojtas <mw@semihalf.com>
9 * This file is licensed under the terms of the GNU General Public
10 * License version 2. This program is licensed "as is" without any
11 * warranty of any kind, whether express or implied.
14 #include <linux/ahci_platform.h>
15 #include <linux/kernel.h>
16 #include <linux/mbus.h>
17 #include <linux/module.h>
18 #include <linux/of_device.h>
19 #include <linux/platform_device.h>
20 #include "ahci.h"
22 #define AHCI_VENDOR_SPECIFIC_0_ADDR 0xa0
23 #define AHCI_VENDOR_SPECIFIC_0_DATA 0xa4
25 #define AHCI_WINDOW_CTRL(win) (0x60 + ((win) << 4))
26 #define AHCI_WINDOW_BASE(win) (0x64 + ((win) << 4))
27 #define AHCI_WINDOW_SIZE(win) (0x68 + ((win) << 4))
29 static void ahci_mvebu_mbus_config(struct ahci_host_priv *hpriv,
30 const struct mbus_dram_target_info *dram)
32 int i;
34 for (i = 0; i < 4; i++) {
35 writel(0, hpriv->mmio + AHCI_WINDOW_CTRL(i));
36 writel(0, hpriv->mmio + AHCI_WINDOW_BASE(i));
37 writel(0, hpriv->mmio + AHCI_WINDOW_SIZE(i));
40 for (i = 0; i < dram->num_cs; i++) {
41 const struct mbus_dram_window *cs = dram->cs + i;
43 writel((cs->mbus_attr << 8) |
44 (dram->mbus_dram_target_id << 4) | 1,
45 hpriv->mmio + AHCI_WINDOW_CTRL(i));
46 writel(cs->base, hpriv->mmio + AHCI_WINDOW_BASE(i));
47 writel(((cs->size - 1) & 0xffff0000),
48 hpriv->mmio + AHCI_WINDOW_SIZE(i));
52 static void ahci_mvebu_regret_option(struct ahci_host_priv *hpriv)
55 * Enable the regret bit to allow the SATA unit to regret a
56 * request that didn't receive an acknowlegde and avoid a
57 * deadlock
59 writel(0x4, hpriv->mmio + AHCI_VENDOR_SPECIFIC_0_ADDR);
60 writel(0x80, hpriv->mmio + AHCI_VENDOR_SPECIFIC_0_DATA);
63 static const struct ata_port_info ahci_mvebu_port_info = {
64 .flags = AHCI_FLAG_COMMON,
65 .pio_mask = ATA_PIO4,
66 .udma_mask = ATA_UDMA6,
67 .port_ops = &ahci_platform_ops,
70 static int ahci_mvebu_probe(struct platform_device *pdev)
72 struct ahci_host_priv *hpriv;
73 const struct mbus_dram_target_info *dram;
74 int rc;
76 hpriv = ahci_platform_get_resources(pdev);
77 if (IS_ERR(hpriv))
78 return PTR_ERR(hpriv);
80 rc = ahci_platform_enable_resources(hpriv);
81 if (rc)
82 return rc;
84 dram = mv_mbus_dram_info();
85 if (!dram)
86 return -ENODEV;
88 ahci_mvebu_mbus_config(hpriv, dram);
89 ahci_mvebu_regret_option(hpriv);
91 rc = ahci_platform_init_host(pdev, hpriv, &ahci_mvebu_port_info,
92 0, 0, 0);
93 if (rc)
94 goto disable_resources;
96 return 0;
98 disable_resources:
99 ahci_platform_disable_resources(hpriv);
100 return rc;
103 static const struct of_device_id ahci_mvebu_of_match[] = {
104 { .compatible = "marvell,armada-380-ahci", },
105 { },
107 MODULE_DEVICE_TABLE(of, ahci_mvebu_of_match);
110 * We currently don't provide power management related operations,
111 * since there is no suspend/resume support at the platform level for
112 * Armada 38x for the moment.
114 static struct platform_driver ahci_mvebu_driver = {
115 .probe = ahci_mvebu_probe,
116 .remove = ata_platform_remove_one,
117 .driver = {
118 .name = "ahci-mvebu",
119 .owner = THIS_MODULE,
120 .of_match_table = ahci_mvebu_of_match,
123 module_platform_driver(ahci_mvebu_driver);
125 MODULE_DESCRIPTION("Marvell EBU AHCI SATA driver");
126 MODULE_AUTHOR("Thomas Petazzoni <thomas.petazzoni@free-electrons.com>, Marcin Wojtas <mw@semihalf.com>");
127 MODULE_LICENSE("GPL");
128 MODULE_ALIAS("platform:ahci_mvebu");