aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2016-05-13 17:20:48 -0400
committerTejun Heo <tj@kernel.org>2016-05-13 17:20:48 -0400
commitf8d1a93930a754c4ea27238ae1c0fb2356d12e9a (patch)
tree4331184b9aa1f0b66ec6b5f103c46e418e27d315
parent26f588308efc7f1834b7ee0b1dd4f9a904f555a3 (diff)
parent535dac4ab5f42e040e8405b31e309a6b6d4eee57 (diff)
Merge branch 'for-4.6-fixes' into for-4.7
-rw-r--r--Documentation/devicetree/bindings/ata/ahci-platform.txt4
-rw-r--r--arch/arm/boot/dts/qcom-apq8064.dtsi3
-rw-r--r--drivers/ata/Kconfig8
-rw-r--r--drivers/ata/Makefile1
-rw-r--r--drivers/ata/ahci_platform.c3
-rw-r--r--drivers/ata/ahci_seattle.c210
-rw-r--r--drivers/ata/libahci.c1
7 files changed, 229 insertions, 1 deletions
diff --git a/Documentation/devicetree/bindings/ata/ahci-platform.txt b/Documentation/devicetree/bindings/ata/ahci-platform.txt
index 30df832a6f2f..87adfb227ca9 100644
--- a/Documentation/devicetree/bindings/ata/ahci-platform.txt
+++ b/Documentation/devicetree/bindings/ata/ahci-platform.txt
@@ -32,6 +32,10 @@ Optional properties:
32- target-supply : regulator for SATA target power 32- target-supply : regulator for SATA target power
33- phys : reference to the SATA PHY node 33- phys : reference to the SATA PHY node
34- phy-names : must be "sata-phy" 34- phy-names : must be "sata-phy"
35- ports-implemented : Mask that indicates which ports that the HBA supports
36 are available for software to use. Useful if PORTS_IMPL
37 is not programmed by the BIOS, which is true with
38 some embedded SOC's.
35 39
36Required properties when using sub-nodes: 40Required properties when using sub-nodes:
37- #address-cells : number of cells to encode an address 41- #address-cells : number of cells to encode an address
diff --git a/arch/arm/boot/dts/qcom-apq8064.dtsi b/arch/arm/boot/dts/qcom-apq8064.dtsi
index 65d0e8d98259..04f541bffbdd 100644
--- a/arch/arm/boot/dts/qcom-apq8064.dtsi
+++ b/arch/arm/boot/dts/qcom-apq8064.dtsi
@@ -666,7 +666,7 @@
666 }; 666 };
667 667
668 sata0: sata@29000000 { 668 sata0: sata@29000000 {
669 compatible = "generic-ahci"; 669 compatible = "qcom,apq8064-ahci", "generic-ahci";
670 status = "disabled"; 670 status = "disabled";
671 reg = <0x29000000 0x180>; 671 reg = <0x29000000 0x180>;
672 interrupts = <GIC_SPI 209 IRQ_TYPE_NONE>; 672 interrupts = <GIC_SPI 209 IRQ_TYPE_NONE>;
@@ -688,6 +688,7 @@
688 688
689 phys = <&sata_phy0>; 689 phys = <&sata_phy0>;
690 phy-names = "sata-phy"; 690 phy-names = "sata-phy";
691 ports-implemented = <0x1>;
691 }; 692 };
692 693
693 /* Temporary fixed regulator */ 694 /* Temporary fixed regulator */
diff --git a/drivers/ata/Kconfig b/drivers/ata/Kconfig
index 5083f85efea7..cfa936a32513 100644
--- a/drivers/ata/Kconfig
+++ b/drivers/ata/Kconfig
@@ -202,6 +202,14 @@ config SATA_FSL
202 202
203 If unsure, say N. 203 If unsure, say N.
204 204
205config SATA_AHCI_SEATTLE
206 tristate "AMD Seattle 6.0Gbps AHCI SATA host controller support"
207 depends on ARCH_SEATTLE
208 help
209 This option enables support for AMD Seattle SATA host controller.
210
211 If unsure, say N
212
205config SATA_INIC162X 213config SATA_INIC162X
206 tristate "Initio 162x SATA support (Very Experimental)" 214 tristate "Initio 162x SATA support (Very Experimental)"
207 depends on PCI 215 depends on PCI
diff --git a/drivers/ata/Makefile b/drivers/ata/Makefile
index 18579521464e..0b2afb7e5f35 100644
--- a/drivers/ata/Makefile
+++ b/drivers/ata/Makefile
@@ -4,6 +4,7 @@ obj-$(CONFIG_ATA) += libata.o
4# non-SFF interface 4# non-SFF interface
5obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o 5obj-$(CONFIG_SATA_AHCI) += ahci.o libahci.o
6obj-$(CONFIG_SATA_ACARD_AHCI) += acard-ahci.o libahci.o 6obj-$(CONFIG_SATA_ACARD_AHCI) += acard-ahci.o libahci.o
7obj-$(CONFIG_SATA_AHCI_SEATTLE) += ahci_seattle.o libahci.o libahci_platform.o
7obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o 8obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o libahci_platform.o
8obj-$(CONFIG_SATA_FSL) += sata_fsl.o 9obj-$(CONFIG_SATA_FSL) += sata_fsl.o
9obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o 10obj-$(CONFIG_SATA_INIC162X) += sata_inic162x.o
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c
index 40442332bfa7..62a04c8fb5c9 100644
--- a/drivers/ata/ahci_platform.c
+++ b/drivers/ata/ahci_platform.c
@@ -51,6 +51,9 @@ static int ahci_probe(struct platform_device *pdev)
51 if (rc) 51 if (rc)
52 return rc; 52 return rc;
53 53
54 of_property_read_u32(dev->of_node,
55 "ports-implemented", &hpriv->force_port_map);
56
54 if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) 57 if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci"))
55 hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; 58 hpriv->flags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ;
56 59
diff --git a/drivers/ata/ahci_seattle.c b/drivers/ata/ahci_seattle.c
new file mode 100644
index 000000000000..6e702ab57220
--- /dev/null
+++ b/drivers/ata/ahci_seattle.c
@@ -0,0 +1,210 @@
1/*
2 * AMD Seattle AHCI SATA driver
3 *
4 * Copyright (c) 2015, Advanced Micro Devices
5 * Author: Brijesh Singh <brijesh.singh@amd.com>
6 *
7 * based on the AHCI SATA platform driver by Jeff Garzik and Anton Vorontsov
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 of the License.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/pm.h>
22#include <linux/device.h>
23#include <linux/of_device.h>
24#include <linux/platform_device.h>
25#include <linux/libata.h>
26#include <linux/ahci_platform.h>
27#include <linux/acpi.h>
28#include <linux/pci_ids.h>
29#include "ahci.h"
30
31/* SGPIO Control Register definition
32 *
33 * Bit Type Description
34 * 31 RW OD7.2 (activity)
35 * 30 RW OD7.1 (locate)
36 * 29 RW OD7.0 (fault)
37 * 28...8 RW OD6.2...OD0.0 (3bits per port, 1 bit per LED)
38 * 7 RO SGPIO feature flag
39 * 6:4 RO Reserved
40 * 3:0 RO Number of ports (0 means no port supported)
41 */
42#define ACTIVITY_BIT_POS(x) (8 + (3 * x))
43#define LOCATE_BIT_POS(x) (ACTIVITY_BIT_POS(x) + 1)
44#define FAULT_BIT_POS(x) (LOCATE_BIT_POS(x) + 1)
45
46#define ACTIVITY_MASK 0x00010000
47#define LOCATE_MASK 0x00080000
48#define FAULT_MASK 0x00400000
49
50#define DRV_NAME "ahci-seattle"
51
52static ssize_t seattle_transmit_led_message(struct ata_port *ap, u32 state,
53 ssize_t size);
54
55struct seattle_plat_data {
56 void __iomem *sgpio_ctrl;
57};
58
59static struct ata_port_operations ahci_port_ops = {
60 .inherits = &ahci_ops,
61};
62
63static const struct ata_port_info ahci_port_info = {
64 .flags = AHCI_FLAG_COMMON,
65 .pio_mask = ATA_PIO4,
66 .udma_mask = ATA_UDMA6,
67 .port_ops = &ahci_port_ops,
68};
69
70static struct ata_port_operations ahci_seattle_ops = {
71 .inherits = &ahci_ops,
72 .transmit_led_message = seattle_transmit_led_message,
73};
74
75static const struct ata_port_info ahci_port_seattle_info = {
76 .flags = AHCI_FLAG_COMMON | ATA_FLAG_EM | ATA_FLAG_SW_ACTIVITY,
77 .link_flags = ATA_LFLAG_SW_ACTIVITY,
78 .pio_mask = ATA_PIO4,
79 .udma_mask = ATA_UDMA6,
80 .port_ops = &ahci_seattle_ops,
81};
82
83static struct scsi_host_template ahci_platform_sht = {
84 AHCI_SHT(DRV_NAME),
85};
86
87static ssize_t seattle_transmit_led_message(struct ata_port *ap, u32 state,
88 ssize_t size)
89{
90 struct ahci_host_priv *hpriv = ap->host->private_data;
91 struct ahci_port_priv *pp = ap->private_data;
92 struct seattle_plat_data *plat_data = hpriv->plat_data;
93 unsigned long flags;
94 int pmp;
95 struct ahci_em_priv *emp;
96 u32 val;
97
98 /* get the slot number from the message */
99 pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
100 if (pmp >= EM_MAX_SLOTS)
101 return -EINVAL;
102 emp = &pp->em_priv[pmp];
103
104 val = ioread32(plat_data->sgpio_ctrl);
105 if (state & ACTIVITY_MASK)
106 val |= 1 << ACTIVITY_BIT_POS((ap->port_no));
107 else
108 val &= ~(1 << ACTIVITY_BIT_POS((ap->port_no)));
109
110 if (state & LOCATE_MASK)
111 val |= 1 << LOCATE_BIT_POS((ap->port_no));
112 else
113 val &= ~(1 << LOCATE_BIT_POS((ap->port_no)));
114
115 if (state & FAULT_MASK)
116 val |= 1 << FAULT_BIT_POS((ap->port_no));
117 else
118 val &= ~(1 << FAULT_BIT_POS((ap->port_no)));
119
120 iowrite32(val, plat_data->sgpio_ctrl);
121
122 spin_lock_irqsave(ap->lock, flags);
123
124 /* save off new led state for port/slot */
125 emp->led_state = state;
126
127 spin_unlock_irqrestore(ap->lock, flags);
128
129 return size;
130}
131
132static const struct ata_port_info *ahci_seattle_get_port_info(
133 struct platform_device *pdev, struct ahci_host_priv *hpriv)
134{
135 struct device *dev = &pdev->dev;
136 struct seattle_plat_data *plat_data;
137 u32 val;
138
139 plat_data = devm_kzalloc(dev, sizeof(*plat_data), GFP_KERNEL);
140 if (IS_ERR(plat_data))
141 return &ahci_port_info;
142
143 plat_data->sgpio_ctrl = devm_ioremap_resource(dev,
144 platform_get_resource(pdev, IORESOURCE_MEM, 1));
145 if (IS_ERR(plat_data->sgpio_ctrl))
146 return &ahci_port_info;
147
148 val = ioread32(plat_data->sgpio_ctrl);
149
150 if (!(val & 0xf))
151 return &ahci_port_info;
152
153 hpriv->em_loc = 0;
154 hpriv->em_buf_sz = 4;
155 hpriv->em_msg_type = EM_MSG_TYPE_LED;
156 hpriv->plat_data = plat_data;
157
158 dev_info(dev, "SGPIO LED control is enabled.\n");
159 return &ahci_port_seattle_info;
160}
161
162static int ahci_seattle_probe(struct platform_device *pdev)
163{
164 int rc;
165 struct ahci_host_priv *hpriv;
166
167 hpriv = ahci_platform_get_resources(pdev);
168 if (IS_ERR(hpriv))
169 return PTR_ERR(hpriv);
170
171 rc = ahci_platform_enable_resources(hpriv);
172 if (rc)
173 return rc;
174
175 rc = ahci_platform_init_host(pdev, hpriv,
176 ahci_seattle_get_port_info(pdev, hpriv),
177 &ahci_platform_sht);
178 if (rc)
179 goto disable_resources;
180
181 return 0;
182disable_resources:
183 ahci_platform_disable_resources(hpriv);
184 return rc;
185}
186
187static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend,
188 ahci_platform_resume);
189
190static const struct acpi_device_id ahci_acpi_match[] = {
191 { "AMDI0600", 0 },
192 {}
193};
194MODULE_DEVICE_TABLE(acpi, ahci_acpi_match);
195
196static struct platform_driver ahci_seattle_driver = {
197 .probe = ahci_seattle_probe,
198 .remove = ata_platform_remove_one,
199 .driver = {
200 .name = DRV_NAME,
201 .acpi_match_table = ahci_acpi_match,
202 .pm = &ahci_pm_ops,
203 },
204};
205module_platform_driver(ahci_seattle_driver);
206
207MODULE_DESCRIPTION("Seattle AHCI SATA platform driver");
208MODULE_AUTHOR("Brijesh Singh <brijesh.singh@amd.com>");
209MODULE_LICENSE("GPL");
210MODULE_ALIAS("platform:" DRV_NAME);
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index e13ba72234dc..71b07198e207 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -507,6 +507,7 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
507 dev_info(dev, "forcing port_map 0x%x -> 0x%x\n", 507 dev_info(dev, "forcing port_map 0x%x -> 0x%x\n",
508 port_map, hpriv->force_port_map); 508 port_map, hpriv->force_port_map);
509 port_map = hpriv->force_port_map; 509 port_map = hpriv->force_port_map;
510 hpriv->saved_port_map = port_map;
510 } 511 }
511 512
512 if (hpriv->mask_port_map) { 513 if (hpriv->mask_port_map) {