layerscape: add patches-5.4
[openwrt/openwrt.git] / target / linux / layerscape / patches-5.4 / 815-sata-0001-ahci-qoriq-enable-acpi-support-in-qoriq-ahci-driver.patch
1 From 8f0baa717e7854b795567678415bc7173d66bc13 Mon Sep 17 00:00:00 2001
2 From: Peng Ma <peng.ma@nxp.com>
3 Date: Wed, 15 May 2019 05:45:35 +0000
4 Subject: [PATCH] ahci: qoriq: enable acpi support in qoriq ahci driver
5
6 This patch enables ACPI support in qoriq ahci driver.
7
8 Signed-off-by: Udit Kumar <udit.kumar@nxp.com>
9 Signed-off-by: Peng Ma <peng.ma@nxp.com>
10 ---
11 drivers/ata/ahci_qoriq.c | 20 +++++++++++++++++---
12 1 file changed, 17 insertions(+), 3 deletions(-)
13
14 --- a/drivers/ata/ahci_qoriq.c
15 +++ b/drivers/ata/ahci_qoriq.c
16 @@ -6,6 +6,7 @@
17 * Tang Yuantian <Yuantian.Tang@freescale.com>
18 */
19
20 +#include <linux/acpi.h>
21 #include <linux/kernel.h>
22 #include <linux/module.h>
23 #include <linux/pm.h>
24 @@ -80,6 +81,12 @@ static const struct of_device_id ahci_qo
25 };
26 MODULE_DEVICE_TABLE(of, ahci_qoriq_of_match);
27
28 +static const struct acpi_device_id ahci_qoriq_acpi_match[] = {
29 + {"NXP0004", .driver_data = (kernel_ulong_t)AHCI_LX2160A},
30 + { }
31 +};
32 +MODULE_DEVICE_TABLE(acpi, ahci_qoriq_acpi_match);
33 +
34 static int ahci_qoriq_hardreset(struct ata_link *link, unsigned int *class,
35 unsigned long deadline)
36 {
37 @@ -255,6 +262,7 @@ static int ahci_qoriq_phy_init(struct ah
38 static int ahci_qoriq_probe(struct platform_device *pdev)
39 {
40 struct device_node *np = pdev->dev.of_node;
41 + const struct acpi_device_id *acpi_id;
42 struct device *dev = &pdev->dev;
43 struct ahci_host_priv *hpriv;
44 struct ahci_qoriq_priv *qoriq_priv;
45 @@ -267,14 +275,18 @@ static int ahci_qoriq_probe(struct platf
46 return PTR_ERR(hpriv);
47
48 of_id = of_match_node(ahci_qoriq_of_match, np);
49 - if (!of_id)
50 + acpi_id = acpi_match_device(ahci_qoriq_acpi_match, &pdev->dev);
51 + if (!(of_id || acpi_id))
52 return -ENODEV;
53
54 qoriq_priv = devm_kzalloc(dev, sizeof(*qoriq_priv), GFP_KERNEL);
55 if (!qoriq_priv)
56 return -ENOMEM;
57
58 - qoriq_priv->type = (enum ahci_qoriq_type)of_id->data;
59 + if (of_id)
60 + qoriq_priv->type = (enum ahci_qoriq_type)of_id->data;
61 + else
62 + qoriq_priv->type = (enum ahci_qoriq_type)acpi_id->driver_data;
63
64 if (unlikely(!ecc_initialized)) {
65 res = platform_get_resource_byname(pdev,
66 @@ -288,7 +300,8 @@ static int ahci_qoriq_probe(struct platf
67 }
68 }
69
70 - qoriq_priv->is_dmacoherent = of_dma_is_coherent(np);
71 + if (device_get_dma_attr(&pdev->dev) == DEV_DMA_COHERENT)
72 + qoriq_priv->is_dmacoherent = true;
73
74 rc = ahci_platform_enable_resources(hpriv);
75 if (rc)
76 @@ -354,6 +367,7 @@ static struct platform_driver ahci_qoriq
77 .driver = {
78 .name = DRV_NAME,
79 .of_match_table = ahci_qoriq_of_match,
80 + .acpi_match_table = ahci_qoriq_acpi_match,
81 .pm = &ahci_qoriq_pm_ops,
82 },
83 };