| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * PCI driver for the Synopsys DesignWare DMA Controller |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2013 Intel Corporation |
|---|
| 5 | 6 | * 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. |
|---|
| 10 | 7 | */ |
|---|
| 11 | 8 | |
|---|
| 12 | 9 | #include <linux/module.h> |
|---|
| .. | .. |
|---|
| 15 | 12 | |
|---|
| 16 | 13 | #include "internal.h" |
|---|
| 17 | 14 | |
|---|
| 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 | | - |
|---|
| 30 | 15 | static int dw_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid) |
|---|
| 31 | 16 | { |
|---|
| 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; |
|---|
| 33 | 19 | struct dw_dma_chip *chip; |
|---|
| 34 | 20 | int ret; |
|---|
| 35 | 21 | |
|---|
| .. | .. |
|---|
| 54 | 40 | if (ret) |
|---|
| 55 | 41 | return ret; |
|---|
| 56 | 42 | |
|---|
| 43 | + data = devm_kmemdup(&pdev->dev, drv_data, sizeof(*drv_data), GFP_KERNEL); |
|---|
| 44 | + if (!data) |
|---|
| 45 | + return -ENOMEM; |
|---|
| 46 | + |
|---|
| 57 | 47 | chip = devm_kzalloc(&pdev->dev, sizeof(*chip), GFP_KERNEL); |
|---|
| 58 | 48 | if (!chip) |
|---|
| 59 | 49 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 62 | 52 | chip->id = pdev->devfn; |
|---|
| 63 | 53 | chip->regs = pcim_iomap_table(pdev)[0]; |
|---|
| 64 | 54 | chip->irq = pdev->irq; |
|---|
| 65 | | - chip->pdata = pdata; |
|---|
| 55 | + chip->pdata = data->pdata; |
|---|
| 66 | 56 | |
|---|
| 67 | | - ret = dw_dma_probe(chip); |
|---|
| 57 | + data->chip = chip; |
|---|
| 58 | + |
|---|
| 59 | + ret = data->probe(chip); |
|---|
| 68 | 60 | if (ret) |
|---|
| 69 | 61 | return ret; |
|---|
| 70 | 62 | |
|---|
| 71 | | - pci_set_drvdata(pdev, chip); |
|---|
| 63 | + dw_dma_acpi_controller_register(chip->dw); |
|---|
| 64 | + |
|---|
| 65 | + pci_set_drvdata(pdev, data); |
|---|
| 72 | 66 | |
|---|
| 73 | 67 | return 0; |
|---|
| 74 | 68 | } |
|---|
| 75 | 69 | |
|---|
| 76 | 70 | static void dw_pci_remove(struct pci_dev *pdev) |
|---|
| 77 | 71 | { |
|---|
| 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; |
|---|
| 79 | 74 | int ret; |
|---|
| 80 | 75 | |
|---|
| 81 | | - ret = dw_dma_remove(chip); |
|---|
| 76 | + dw_dma_acpi_controller_free(chip->dw); |
|---|
| 77 | + |
|---|
| 78 | + ret = data->remove(chip); |
|---|
| 82 | 79 | if (ret) |
|---|
| 83 | 80 | dev_warn(&pdev->dev, "can't remove device properly: %d\n", ret); |
|---|
| 84 | 81 | } |
|---|
| .. | .. |
|---|
| 87 | 84 | |
|---|
| 88 | 85 | static int dw_pci_suspend_late(struct device *dev) |
|---|
| 89 | 86 | { |
|---|
| 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; |
|---|
| 92 | 89 | |
|---|
| 93 | | - return dw_dma_disable(chip); |
|---|
| 90 | + return do_dw_dma_disable(chip); |
|---|
| 94 | 91 | }; |
|---|
| 95 | 92 | |
|---|
| 96 | 93 | static int dw_pci_resume_early(struct device *dev) |
|---|
| 97 | 94 | { |
|---|
| 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; |
|---|
| 100 | 97 | |
|---|
| 101 | | - return dw_dma_enable(chip); |
|---|
| 98 | + return do_dw_dma_enable(chip); |
|---|
| 102 | 99 | }; |
|---|
| 103 | 100 | |
|---|
| 104 | 101 | #endif /* CONFIG_PM_SLEEP */ |
|---|
| .. | .. |
|---|
| 109 | 106 | |
|---|
| 110 | 107 | static const struct pci_device_id dw_pci_id_table[] = { |
|---|
| 111 | 108 | /* Medfield (GPDMA) */ |
|---|
| 112 | | - { PCI_VDEVICE(INTEL, 0x0827) }, |
|---|
| 109 | + { PCI_VDEVICE(INTEL, 0x0827), (kernel_ulong_t)&dw_dma_chip_pdata }, |
|---|
| 113 | 110 | |
|---|
| 114 | 111 | /* 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 }, |
|---|
| 117 | 114 | |
|---|
| 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 }, |
|---|
| 120 | 117 | |
|---|
| 121 | 118 | /* 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 }, |
|---|
| 124 | 126 | |
|---|
| 125 | 127 | /* Haswell */ |
|---|
| 126 | | - { PCI_VDEVICE(INTEL, 0x9c60) }, |
|---|
| 128 | + { PCI_VDEVICE(INTEL, 0x9c60), (kernel_ulong_t)&dw_dma_chip_pdata }, |
|---|
| 127 | 129 | |
|---|
| 128 | 130 | /* Broadwell */ |
|---|
| 129 | | - { PCI_VDEVICE(INTEL, 0x9ce0) }, |
|---|
| 131 | + { PCI_VDEVICE(INTEL, 0x9ce0), (kernel_ulong_t)&dw_dma_chip_pdata }, |
|---|
| 130 | 132 | |
|---|
| 131 | 133 | { } |
|---|
| 132 | 134 | }; |
|---|