hc
2024-12-19 9370bb92b2d16684ee45cf24e879c93c509162da
kernel/drivers/dma/dw/pci.c
....@@ -1,12 +1,9 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * PCI driver for the Synopsys DesignWare DMA Controller
34 *
45 * Copyright (C) 2013 Intel Corporation
56 * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118
129 #include <linux/module.h>
....@@ -15,21 +12,10 @@
1512
1613 #include "internal.h"
1714
18
-static struct dw_dma_platform_data mrfld_pdata = {
19
- .nr_channels = 8,
20
- .is_private = true,
21
- .is_memcpy = true,
22
- .is_idma32 = true,
23
- .chan_allocation_order = CHAN_ALLOCATION_ASCENDING,
24
- .chan_priority = CHAN_PRIORITY_ASCENDING,
25
- .block_size = 131071,
26
- .nr_masters = 1,
27
- .data_width = {4},
28
-};
29
-
3015 static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid)
3116 {
32
- const struct dw_dma_platform_data *pdata = (void *)pid->driver_data;
17
+ const struct dw_dma_chip_pdata *drv_data = (void *)pid->driver_data;
18
+ struct dw_dma_chip_pdata *data;
3319 struct dw_dma_chip *chip;
3420 int ret;
3521
....@@ -54,6 +40,10 @@
5440 if (ret)
5541 return ret;
5642
43
+ data = devm_kmemdup(&pdev->dev, drv_data, sizeof(*drv_data), GFP_KERNEL);
44
+ if (!data)
45
+ return -ENOMEM;
46
+
5747 chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL);
5848 if (!chip)
5949 return -ENOMEM;
....@@ -62,23 +52,30 @@
6252 chip->id = pdev->devfn;
6353 chip->regs = pcim_iomap_table(pdev)[0];
6454 chip->irq = pdev->irq;
65
- chip->pdata = pdata;
55
+ chip->pdata = data->pdata;
6656
67
- ret = dw_dma_probe(chip);
57
+ data->chip = chip;
58
+
59
+ ret = data->probe(chip);
6860 if (ret)
6961 return ret;
7062
71
- pci_set_drvdata(pdev, chip);
63
+ dw_dma_acpi_controller_register(chip->dw);
64
+
65
+ pci_set_drvdata(pdev, data);
7266
7367 return 0;
7468 }
7569
7670 static void dw_pci_remove(struct pci_dev *pdev)
7771 {
78
- struct dw_dma_chip *chip = pci_get_drvdata(pdev);
72
+ struct dw_dma_chip_pdata *data = pci_get_drvdata(pdev);
73
+ struct dw_dma_chip *chip = data->chip;
7974 int ret;
8075
81
- ret = dw_dma_remove(chip);
76
+ dw_dma_acpi_controller_free(chip->dw);
77
+
78
+ ret = data->remove(chip);
8279 if (ret)
8380 dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret);
8481 }
....@@ -87,18 +84,18 @@
8784
8885 static int dw_pci_suspend_late(struct device *dev)
8986 {
90
- struct pci_dev *pci = to_pci_dev(dev);
91
- struct dw_dma_chip *chip = pci_get_drvdata(pci);
87
+ struct dw_dma_chip_pdata *data = dev_get_drvdata(dev);
88
+ struct dw_dma_chip *chip = data->chip;
9289
93
- return dw_dma_disable(chip);
90
+ return do_dw_dma_disable(chip);
9491 };
9592
9693 static int dw_pci_resume_early(struct device *dev)
9794 {
98
- struct pci_dev *pci = to_pci_dev(dev);
99
- struct dw_dma_chip *chip = pci_get_drvdata(pci);
95
+ struct dw_dma_chip_pdata *data = dev_get_drvdata(dev);
96
+ struct dw_dma_chip *chip = data->chip;
10097
101
- return dw_dma_enable(chip);
98
+ return do_dw_dma_enable(chip);
10299 };
103100
104101 #endif /* CONFIG_PM_SLEEP */
....@@ -109,24 +106,29 @@
109106
110107 static const struct pci_device_id dw_pci_id_table[] = {
111108 /* Medfield (GPDMA) */
112
- { PCI_VDEVICE(INTEL, 0x0827) },
109
+ { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_dma_chip_pdata },
113110
114111 /* BayTrail */
115
- { PCI_VDEVICE(INTEL, 0x0f06) },
116
- { PCI_VDEVICE(INTEL, 0x0f40) },
112
+ { PCI_VDEVICE(INTEL, 0x0f06), (kernel_ulong_t)&dw_dma_chip_pdata },
113
+ { PCI_VDEVICE(INTEL, 0x0f40), (kernel_ulong_t)&dw_dma_chip_pdata },
117114
118
- /* Merrifield iDMA 32-bit (GPDMA) */
119
- { PCI_VDEVICE(INTEL, 0x11a2), (kernel_ulong_t)&mrfld_pdata },
115
+ /* Merrifield */
116
+ { PCI_VDEVICE(INTEL, 0x11a2), (kernel_ulong_t)&idma32_chip_pdata },
120117
121118 /* Braswell */
122
- { PCI_VDEVICE(INTEL, 0x2286) },
123
- { PCI_VDEVICE(INTEL, 0x22c0) },
119
+ { PCI_VDEVICE(INTEL, 0x2286), (kernel_ulong_t)&dw_dma_chip_pdata },
120
+ { PCI_VDEVICE(INTEL, 0x22c0), (kernel_ulong_t)&dw_dma_chip_pdata },
121
+
122
+ /* Elkhart Lake iDMA 32-bit (PSE DMA) */
123
+ { PCI_VDEVICE(INTEL, 0x4bb4), (kernel_ulong_t)&idma32_chip_pdata },
124
+ { PCI_VDEVICE(INTEL, 0x4bb5), (kernel_ulong_t)&idma32_chip_pdata },
125
+ { PCI_VDEVICE(INTEL, 0x4bb6), (kernel_ulong_t)&idma32_chip_pdata },
124126
125127 /* Haswell */
126
- { PCI_VDEVICE(INTEL, 0x9c60) },
128
+ { PCI_VDEVICE(INTEL, 0x9c60), (kernel_ulong_t)&dw_dma_chip_pdata },
127129
128130 /* Broadwell */
129
- { PCI_VDEVICE(INTEL, 0x9ce0) },
131
+ { PCI_VDEVICE(INTEL, 0x9ce0), (kernel_ulong_t)&dw_dma_chip_pdata },
130132
131133 { }
132134 };