kernel: backport bcma patches queued for 3.20
[openwrt/svn-archive/archive.git] / target / linux / ipq806x / patches / 0142-ata-Add-Qualcomm-ARM-SoC-AHCI-SATA-host-controller-d.patch
1 From c5ea64dcf7b5d45e402e78b9f291d521669b7b80 Mon Sep 17 00:00:00 2001
2 From: Kumar Gala <galak@codeaurora.org>
3 Date: Fri, 30 May 2014 15:35:40 -0500
4 Subject: [PATCH 142/182] ata: Add Qualcomm ARM SoC AHCI SATA host controller
5 driver
6
7 Add support for the Qualcomm AHCI SATA controller that exists on several
8 SoC and specifically the IPQ806x family of chips. The IPQ806x SATA support
9 requires the associated IPQ806x SATA PHY Driver to be enabled as well.
10
11 Signed-off-by: Kumar Gala <galak@codeaurora.org>
12 ---
13 drivers/ata/Kconfig | 10 ++++++
14 drivers/ata/Makefile | 1 +
15 drivers/ata/ahci_qcom.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++
16 3 files changed, 97 insertions(+)
17 create mode 100644 drivers/ata/ahci_qcom.c
18
19 --- a/drivers/ata/Kconfig
20 +++ b/drivers/ata/Kconfig
21 @@ -122,6 +122,16 @@ config AHCI_IMX
22
23 If unsure, say N.
24
25 +config AHCI_QCOM
26 + tristate "Qualcomm AHCI SATA support"
27 + depends on ARCH_QCOM
28 + help
29 + This option enables support for AHCI SATA controller
30 + integrated into Qualcomm ARM SoC chipsets. For more
31 + information please refer to http://www.qualcomm.com/chipsets.
32 +
33 + If unsure, say N.
34 +
35 config SATA_FSL
36 tristate "Freescale 3.0Gbps SATA support"
37 depends on FSL_SOC
38 --- a/drivers/ata/Makefile
39 +++ b/drivers/ata/Makefile
40 @@ -11,6 +11,7 @@ obj-$(CONFIG_SATA_SIL24) += sata_sil24.o
41 obj-$(CONFIG_SATA_DWC) += sata_dwc_460ex.o
42 obj-$(CONFIG_SATA_HIGHBANK) += sata_highbank.o libahci.o
43 obj-$(CONFIG_AHCI_IMX) += ahci_imx.o libahci.o libahci_platform.o
44 +obj-$(CONFIG_AHCI_QCOM) += ahci_qcom.o libahci.o libahci_platform.o
45
46 # SFF w/ custom DMA
47 obj-$(CONFIG_PDC_ADMA) += pdc_adma.o
48 --- /dev/null
49 +++ b/drivers/ata/ahci_qcom.c
50 @@ -0,0 +1,86 @@
51 +/*
52 + * Qualcomm ARM SoC AHCI SATA platform driver
53 + *
54 + * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov
55 + *
56 + * Copyright (c) 2014, The Linux Foundation. All rights reserved.
57 + *
58 + * This program is free software; you can redistribute it and/or modify
59 + * it under the terms of the GNU General Public License version 2 and
60 + * only version 2 as published by the Free Software Foundation.
61 + *
62 + * This program is distributed in the hope that it will be useful,
63 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
64 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
65 + * GNU General Public License for more details.
66 + */
67 +
68 +#include <linux/kernel.h>
69 +#include <linux/module.h>
70 +#include <linux/pm.h>
71 +#include <linux/device.h>
72 +#include <linux/platform_device.h>
73 +#include <linux/libata.h>
74 +#include <linux/ahci_platform.h>
75 +#include "ahci.h"
76 +
77 +static const struct ata_port_info qcom_ahci_port_info = {
78 + .flags = AHCI_FLAG_COMMON,
79 + .pio_mask = ATA_PIO4,
80 + .udma_mask = ATA_UDMA6,
81 + .port_ops = &ahci_platform_ops,
82 +};
83 +
84 +static int qcom_ahci_probe(struct platform_device *pdev)
85 +{
86 + struct ahci_host_priv *hpriv;
87 + struct clk *rxoob_clk;
88 + int rc;
89 +
90 + hpriv = ahci_platform_get_resources(pdev);
91 + if (IS_ERR(hpriv))
92 + return PTR_ERR(hpriv);
93 +
94 + /* Try and set the rxoob clk to 100Mhz */
95 + rxoob_clk = of_clk_get_by_name(pdev->dev.of_node, "rxoob");
96 + if (IS_ERR(rxoob_clk))
97 + return PTR_ERR(rxoob_clk);
98 +
99 + rc = clk_set_rate(rxoob_clk, 100000000);
100 + if (rc)
101 + return rc;
102 +
103 + rc = ahci_platform_enable_resources(hpriv);
104 + if (rc)
105 + return rc;
106 +
107 + rc = ahci_platform_init_host(pdev, hpriv, &qcom_ahci_port_info, 0, 0);
108 + if (rc)
109 + goto disable_resources;
110 +
111 + return 0;
112 +disable_resources:
113 + ahci_platform_disable_resources(hpriv);
114 + return rc;
115 +}
116 +
117 +static const struct of_device_id qcom_ahci_of_match[] = {
118 + { .compatible = "qcom,msm-ahci", },
119 + {},
120 +};
121 +MODULE_DEVICE_TABLE(of, qcom_ahci_of_match);
122 +
123 +static struct platform_driver qcom_ahci_driver = {
124 + .probe = qcom_ahci_probe,
125 + .remove = ata_platform_remove_one,
126 + .driver = {
127 + .name = "qcom_ahci_qcom",
128 + .owner = THIS_MODULE,
129 + .of_match_table = qcom_ahci_of_match,
130 + },
131 +};
132 +module_platform_driver(qcom_ahci_driver);
133 +
134 +MODULE_DESCRIPTION("Qualcomm AHCI SATA platform driver");
135 +MODULE_LICENSE("GPL v2");
136 +MODULE_ALIAS("ahci:qcom");