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