Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Topcliff PCH DMA controller driver |
| 4 | * Copyright (c) 2010 Intel Corporation |
Tomoya MORINAGA | e79e72b | 2011-11-17 16:14:22 +0900 | [diff] [blame] | 5 | * Copyright (C) 2011 LAPIS Semiconductor Co., Ltd. |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <linux/dmaengine.h> |
| 9 | #include <linux/dma-mapping.h> |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/pci.h> |
Vinod Koul | a15783c | 2014-05-22 18:50:49 +0530 | [diff] [blame] | 12 | #include <linux/slab.h> |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 13 | #include <linux/interrupt.h> |
| 14 | #include <linux/module.h> |
| 15 | #include <linux/pch_dma.h> |
| 16 | |
Russell King - ARM Linux | d2ebfb3 | 2012-03-06 22:34:26 +0000 | [diff] [blame] | 17 | #include "dmaengine.h" |
| 18 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 19 | #define DRV_NAME "pch-dma" |
| 20 | |
| 21 | #define DMA_CTL0_DISABLE 0x0 |
| 22 | #define DMA_CTL0_SG 0x1 |
| 23 | #define DMA_CTL0_ONESHOT 0x2 |
| 24 | #define DMA_CTL0_MODE_MASK_BITS 0x3 |
| 25 | #define DMA_CTL0_DIR_SHIFT_BITS 2 |
| 26 | #define DMA_CTL0_BITS_PER_CH 4 |
| 27 | |
| 28 | #define DMA_CTL2_START_SHIFT_BITS 8 |
| 29 | #define DMA_CTL2_IRQ_ENABLE_MASK ((1UL << DMA_CTL2_START_SHIFT_BITS) - 1) |
| 30 | |
| 31 | #define DMA_STATUS_IDLE 0x0 |
| 32 | #define DMA_STATUS_DESC_READ 0x1 |
| 33 | #define DMA_STATUS_WAIT 0x2 |
| 34 | #define DMA_STATUS_ACCESS 0x3 |
| 35 | #define DMA_STATUS_BITS_PER_CH 2 |
| 36 | #define DMA_STATUS_MASK_BITS 0x3 |
| 37 | #define DMA_STATUS_SHIFT_BITS 16 |
| 38 | #define DMA_STATUS_IRQ(x) (0x1 << (x)) |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 39 | #define DMA_STATUS0_ERR(x) (0x1 << ((x) + 8)) |
| 40 | #define DMA_STATUS2_ERR(x) (0x1 << (x)) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 41 | |
| 42 | #define DMA_DESC_WIDTH_SHIFT_BITS 12 |
| 43 | #define DMA_DESC_WIDTH_1_BYTE (0x3 << DMA_DESC_WIDTH_SHIFT_BITS) |
| 44 | #define DMA_DESC_WIDTH_2_BYTES (0x2 << DMA_DESC_WIDTH_SHIFT_BITS) |
| 45 | #define DMA_DESC_WIDTH_4_BYTES (0x0 << DMA_DESC_WIDTH_SHIFT_BITS) |
| 46 | #define DMA_DESC_MAX_COUNT_1_BYTE 0x3FF |
| 47 | #define DMA_DESC_MAX_COUNT_2_BYTES 0x3FF |
| 48 | #define DMA_DESC_MAX_COUNT_4_BYTES 0x7FF |
| 49 | #define DMA_DESC_END_WITHOUT_IRQ 0x0 |
| 50 | #define DMA_DESC_END_WITH_IRQ 0x1 |
| 51 | #define DMA_DESC_FOLLOW_WITHOUT_IRQ 0x2 |
| 52 | #define DMA_DESC_FOLLOW_WITH_IRQ 0x3 |
| 53 | |
Tomoya MORINAGA | c43f150 | 2011-10-11 21:43:21 +0900 | [diff] [blame] | 54 | #define MAX_CHAN_NR 12 |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 55 | |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 56 | #define DMA_MASK_CTL0_MODE 0x33333333 |
| 57 | #define DMA_MASK_CTL2_MODE 0x00003333 |
| 58 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 59 | static unsigned int init_nr_desc_per_channel = 64; |
| 60 | module_param(init_nr_desc_per_channel, uint, 0644); |
| 61 | MODULE_PARM_DESC(init_nr_desc_per_channel, |
| 62 | "initial descriptors per channel (default: 64)"); |
| 63 | |
| 64 | struct pch_dma_desc_regs { |
| 65 | u32 dev_addr; |
| 66 | u32 mem_addr; |
| 67 | u32 size; |
| 68 | u32 next; |
| 69 | }; |
| 70 | |
| 71 | struct pch_dma_regs { |
| 72 | u32 dma_ctl0; |
| 73 | u32 dma_ctl1; |
| 74 | u32 dma_ctl2; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 75 | u32 dma_ctl3; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 76 | u32 dma_sts0; |
| 77 | u32 dma_sts1; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 78 | u32 dma_sts2; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 79 | u32 reserved3; |
Tomoya MORINAGA | 26d890f | 2011-02-18 10:01:21 +0530 | [diff] [blame] | 80 | struct pch_dma_desc_regs desc[MAX_CHAN_NR]; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 81 | }; |
| 82 | |
| 83 | struct pch_dma_desc { |
| 84 | struct pch_dma_desc_regs regs; |
| 85 | struct dma_async_tx_descriptor txd; |
| 86 | struct list_head desc_node; |
| 87 | struct list_head tx_list; |
| 88 | }; |
| 89 | |
| 90 | struct pch_dma_chan { |
| 91 | struct dma_chan chan; |
| 92 | void __iomem *membase; |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 93 | enum dma_transfer_direction dir; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 94 | struct tasklet_struct tasklet; |
| 95 | unsigned long err_status; |
| 96 | |
| 97 | spinlock_t lock; |
| 98 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 99 | struct list_head active_list; |
| 100 | struct list_head queue; |
| 101 | struct list_head free_list; |
| 102 | unsigned int descs_allocated; |
| 103 | }; |
| 104 | |
| 105 | #define PDC_DEV_ADDR 0x00 |
| 106 | #define PDC_MEM_ADDR 0x04 |
| 107 | #define PDC_SIZE 0x08 |
| 108 | #define PDC_NEXT 0x0C |
| 109 | |
| 110 | #define channel_readl(pdc, name) \ |
| 111 | readl((pdc)->membase + PDC_##name) |
| 112 | #define channel_writel(pdc, name, val) \ |
| 113 | writel((val), (pdc)->membase + PDC_##name) |
| 114 | |
| 115 | struct pch_dma { |
| 116 | struct dma_device dma; |
| 117 | void __iomem *membase; |
Romain Perier | 10c191a | 2017-10-23 19:59:55 +0200 | [diff] [blame] | 118 | struct dma_pool *pool; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 119 | struct pch_dma_regs regs; |
| 120 | struct pch_dma_desc_regs ch_regs[MAX_CHAN_NR]; |
Tomoya MORINAGA | 26d890f | 2011-02-18 10:01:21 +0530 | [diff] [blame] | 121 | struct pch_dma_chan channels[MAX_CHAN_NR]; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 122 | }; |
| 123 | |
| 124 | #define PCH_DMA_CTL0 0x00 |
| 125 | #define PCH_DMA_CTL1 0x04 |
| 126 | #define PCH_DMA_CTL2 0x08 |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 127 | #define PCH_DMA_CTL3 0x0C |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 128 | #define PCH_DMA_STS0 0x10 |
| 129 | #define PCH_DMA_STS1 0x14 |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 130 | #define PCH_DMA_STS2 0x18 |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 131 | |
| 132 | #define dma_readl(pd, name) \ |
Yong Wang | 61cd220 | 2010-08-05 10:38:43 +0800 | [diff] [blame] | 133 | readl((pd)->membase + PCH_DMA_##name) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 134 | #define dma_writel(pd, name, val) \ |
Yong Wang | 61cd220 | 2010-08-05 10:38:43 +0800 | [diff] [blame] | 135 | writel((val), (pd)->membase + PCH_DMA_##name) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 136 | |
Tomoya MORINAGA | 08645fd | 2011-05-09 16:09:36 +0900 | [diff] [blame] | 137 | static inline |
| 138 | struct pch_dma_desc *to_pd_desc(struct dma_async_tx_descriptor *txd) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 139 | { |
| 140 | return container_of(txd, struct pch_dma_desc, txd); |
| 141 | } |
| 142 | |
| 143 | static inline struct pch_dma_chan *to_pd_chan(struct dma_chan *chan) |
| 144 | { |
| 145 | return container_of(chan, struct pch_dma_chan, chan); |
| 146 | } |
| 147 | |
| 148 | static inline struct pch_dma *to_pd(struct dma_device *ddev) |
| 149 | { |
| 150 | return container_of(ddev, struct pch_dma, dma); |
| 151 | } |
| 152 | |
| 153 | static inline struct device *chan2dev(struct dma_chan *chan) |
| 154 | { |
| 155 | return &chan->dev->device; |
| 156 | } |
| 157 | |
| 158 | static inline struct device *chan2parent(struct dma_chan *chan) |
| 159 | { |
| 160 | return chan->dev->device.parent; |
| 161 | } |
| 162 | |
Tomoya MORINAGA | 08645fd | 2011-05-09 16:09:36 +0900 | [diff] [blame] | 163 | static inline |
| 164 | struct pch_dma_desc *pdc_first_active(struct pch_dma_chan *pd_chan) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 165 | { |
| 166 | return list_first_entry(&pd_chan->active_list, |
| 167 | struct pch_dma_desc, desc_node); |
| 168 | } |
| 169 | |
Tomoya MORINAGA | 08645fd | 2011-05-09 16:09:36 +0900 | [diff] [blame] | 170 | static inline |
| 171 | struct pch_dma_desc *pdc_first_queued(struct pch_dma_chan *pd_chan) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 172 | { |
| 173 | return list_first_entry(&pd_chan->queue, |
| 174 | struct pch_dma_desc, desc_node); |
| 175 | } |
| 176 | |
| 177 | static void pdc_enable_irq(struct dma_chan *chan, int enable) |
| 178 | { |
| 179 | struct pch_dma *pd = to_pd(chan->device); |
| 180 | u32 val; |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 181 | int pos; |
| 182 | |
| 183 | if (chan->chan_id < 8) |
| 184 | pos = chan->chan_id; |
| 185 | else |
| 186 | pos = chan->chan_id + 8; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 187 | |
| 188 | val = dma_readl(pd, CTL2); |
| 189 | |
| 190 | if (enable) |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 191 | val |= 0x1 << pos; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 192 | else |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 193 | val &= ~(0x1 << pos); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 194 | |
| 195 | dma_writel(pd, CTL2, val); |
| 196 | |
| 197 | dev_dbg(chan2dev(chan), "pdc_enable_irq: chan %d -> %x\n", |
| 198 | chan->chan_id, val); |
| 199 | } |
| 200 | |
| 201 | static void pdc_set_dir(struct dma_chan *chan) |
| 202 | { |
| 203 | struct pch_dma_chan *pd_chan = to_pd_chan(chan); |
| 204 | struct pch_dma *pd = to_pd(chan->device); |
| 205 | u32 val; |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 206 | u32 mask_mode; |
| 207 | u32 mask_ctl; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 208 | |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 209 | if (chan->chan_id < 8) { |
| 210 | val = dma_readl(pd, CTL0); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 211 | |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 212 | mask_mode = DMA_CTL0_MODE_MASK_BITS << |
| 213 | (DMA_CTL0_BITS_PER_CH * chan->chan_id); |
| 214 | mask_ctl = DMA_MASK_CTL0_MODE & ~(DMA_CTL0_MODE_MASK_BITS << |
| 215 | (DMA_CTL0_BITS_PER_CH * chan->chan_id)); |
| 216 | val &= mask_mode; |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 217 | if (pd_chan->dir == DMA_MEM_TO_DEV) |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 218 | val |= 0x1 << (DMA_CTL0_BITS_PER_CH * chan->chan_id + |
| 219 | DMA_CTL0_DIR_SHIFT_BITS); |
| 220 | else |
| 221 | val &= ~(0x1 << (DMA_CTL0_BITS_PER_CH * chan->chan_id + |
| 222 | DMA_CTL0_DIR_SHIFT_BITS)); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 223 | |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 224 | val |= mask_ctl; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 225 | dma_writel(pd, CTL0, val); |
| 226 | } else { |
| 227 | int ch = chan->chan_id - 8; /* ch8-->0 ch9-->1 ... ch11->3 */ |
| 228 | val = dma_readl(pd, CTL3); |
| 229 | |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 230 | mask_mode = DMA_CTL0_MODE_MASK_BITS << |
| 231 | (DMA_CTL0_BITS_PER_CH * ch); |
| 232 | mask_ctl = DMA_MASK_CTL2_MODE & ~(DMA_CTL0_MODE_MASK_BITS << |
| 233 | (DMA_CTL0_BITS_PER_CH * ch)); |
| 234 | val &= mask_mode; |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 235 | if (pd_chan->dir == DMA_MEM_TO_DEV) |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 236 | val |= 0x1 << (DMA_CTL0_BITS_PER_CH * ch + |
| 237 | DMA_CTL0_DIR_SHIFT_BITS); |
| 238 | else |
| 239 | val &= ~(0x1 << (DMA_CTL0_BITS_PER_CH * ch + |
| 240 | DMA_CTL0_DIR_SHIFT_BITS)); |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 241 | val |= mask_ctl; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 242 | dma_writel(pd, CTL3, val); |
| 243 | } |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 244 | |
| 245 | dev_dbg(chan2dev(chan), "pdc_set_dir: chan %d -> %x\n", |
| 246 | chan->chan_id, val); |
| 247 | } |
| 248 | |
| 249 | static void pdc_set_mode(struct dma_chan *chan, u32 mode) |
| 250 | { |
| 251 | struct pch_dma *pd = to_pd(chan->device); |
| 252 | u32 val; |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 253 | u32 mask_ctl; |
| 254 | u32 mask_dir; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 255 | |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 256 | if (chan->chan_id < 8) { |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 257 | mask_ctl = DMA_MASK_CTL0_MODE & ~(DMA_CTL0_MODE_MASK_BITS << |
| 258 | (DMA_CTL0_BITS_PER_CH * chan->chan_id)); |
| 259 | mask_dir = 1 << (DMA_CTL0_BITS_PER_CH * chan->chan_id +\ |
| 260 | DMA_CTL0_DIR_SHIFT_BITS); |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 261 | val = dma_readl(pd, CTL0); |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 262 | val &= mask_dir; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 263 | val |= mode << (DMA_CTL0_BITS_PER_CH * chan->chan_id); |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 264 | val |= mask_ctl; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 265 | dma_writel(pd, CTL0, val); |
| 266 | } else { |
| 267 | int ch = chan->chan_id - 8; /* ch8-->0 ch9-->1 ... ch11->3 */ |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 268 | mask_ctl = DMA_MASK_CTL2_MODE & ~(DMA_CTL0_MODE_MASK_BITS << |
| 269 | (DMA_CTL0_BITS_PER_CH * ch)); |
| 270 | mask_dir = 1 << (DMA_CTL0_BITS_PER_CH * ch +\ |
| 271 | DMA_CTL0_DIR_SHIFT_BITS); |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 272 | val = dma_readl(pd, CTL3); |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 273 | val &= mask_dir; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 274 | val |= mode << (DMA_CTL0_BITS_PER_CH * ch); |
Tomoya MORINAGA | 0b052f4 | 2011-07-14 09:52:38 +0900 | [diff] [blame] | 275 | val |= mask_ctl; |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 276 | dma_writel(pd, CTL3, val); |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 277 | } |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 278 | |
| 279 | dev_dbg(chan2dev(chan), "pdc_set_mode: chan %d -> %x\n", |
| 280 | chan->chan_id, val); |
| 281 | } |
| 282 | |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 283 | static u32 pdc_get_status0(struct pch_dma_chan *pd_chan) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 284 | { |
| 285 | struct pch_dma *pd = to_pd(pd_chan->chan.device); |
| 286 | u32 val; |
| 287 | |
| 288 | val = dma_readl(pd, STS0); |
| 289 | return DMA_STATUS_MASK_BITS & (val >> (DMA_STATUS_SHIFT_BITS + |
| 290 | DMA_STATUS_BITS_PER_CH * pd_chan->chan.chan_id)); |
| 291 | } |
| 292 | |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 293 | static u32 pdc_get_status2(struct pch_dma_chan *pd_chan) |
| 294 | { |
| 295 | struct pch_dma *pd = to_pd(pd_chan->chan.device); |
| 296 | u32 val; |
| 297 | |
| 298 | val = dma_readl(pd, STS2); |
| 299 | return DMA_STATUS_MASK_BITS & (val >> (DMA_STATUS_SHIFT_BITS + |
| 300 | DMA_STATUS_BITS_PER_CH * (pd_chan->chan.chan_id - 8))); |
| 301 | } |
| 302 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 303 | static bool pdc_is_idle(struct pch_dma_chan *pd_chan) |
| 304 | { |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 305 | u32 sts; |
| 306 | |
| 307 | if (pd_chan->chan.chan_id < 8) |
| 308 | sts = pdc_get_status0(pd_chan); |
| 309 | else |
| 310 | sts = pdc_get_status2(pd_chan); |
| 311 | |
| 312 | |
| 313 | if (sts == DMA_STATUS_IDLE) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 314 | return true; |
| 315 | else |
| 316 | return false; |
| 317 | } |
| 318 | |
| 319 | static void pdc_dostart(struct pch_dma_chan *pd_chan, struct pch_dma_desc* desc) |
| 320 | { |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 321 | if (!pdc_is_idle(pd_chan)) { |
| 322 | dev_err(chan2dev(&pd_chan->chan), |
| 323 | "BUG: Attempt to start non-idle channel\n"); |
| 324 | return; |
| 325 | } |
| 326 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 327 | dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> dev_addr: %x\n", |
| 328 | pd_chan->chan.chan_id, desc->regs.dev_addr); |
| 329 | dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> mem_addr: %x\n", |
| 330 | pd_chan->chan.chan_id, desc->regs.mem_addr); |
| 331 | dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> size: %x\n", |
| 332 | pd_chan->chan.chan_id, desc->regs.size); |
| 333 | dev_dbg(chan2dev(&pd_chan->chan), "chan %d -> next: %x\n", |
| 334 | pd_chan->chan.chan_id, desc->regs.next); |
| 335 | |
Tomoya MORINAGA | 943d8d8 | 2010-12-01 19:49:48 +0900 | [diff] [blame] | 336 | if (list_empty(&desc->tx_list)) { |
| 337 | channel_writel(pd_chan, DEV_ADDR, desc->regs.dev_addr); |
| 338 | channel_writel(pd_chan, MEM_ADDR, desc->regs.mem_addr); |
| 339 | channel_writel(pd_chan, SIZE, desc->regs.size); |
| 340 | channel_writel(pd_chan, NEXT, desc->regs.next); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 341 | pdc_set_mode(&pd_chan->chan, DMA_CTL0_ONESHOT); |
Tomoya MORINAGA | 943d8d8 | 2010-12-01 19:49:48 +0900 | [diff] [blame] | 342 | } else { |
| 343 | channel_writel(pd_chan, NEXT, desc->txd.phys); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 344 | pdc_set_mode(&pd_chan->chan, DMA_CTL0_SG); |
Tomoya MORINAGA | 943d8d8 | 2010-12-01 19:49:48 +0900 | [diff] [blame] | 345 | } |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 346 | } |
| 347 | |
| 348 | static void pdc_chain_complete(struct pch_dma_chan *pd_chan, |
| 349 | struct pch_dma_desc *desc) |
| 350 | { |
| 351 | struct dma_async_tx_descriptor *txd = &desc->txd; |
Dave Jiang | 5c066f7 | 2016-07-20 13:12:29 -0700 | [diff] [blame] | 352 | struct dmaengine_desc_callback cb; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 353 | |
Dave Jiang | 5c066f7 | 2016-07-20 13:12:29 -0700 | [diff] [blame] | 354 | dmaengine_desc_get_callback(txd, &cb); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 355 | list_splice_init(&desc->tx_list, &pd_chan->free_list); |
| 356 | list_move(&desc->desc_node, &pd_chan->free_list); |
| 357 | |
Dave Jiang | 5c066f7 | 2016-07-20 13:12:29 -0700 | [diff] [blame] | 358 | dmaengine_desc_callback_invoke(&cb, NULL); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | static void pdc_complete_all(struct pch_dma_chan *pd_chan) |
| 362 | { |
| 363 | struct pch_dma_desc *desc, *_d; |
| 364 | LIST_HEAD(list); |
| 365 | |
| 366 | BUG_ON(!pdc_is_idle(pd_chan)); |
| 367 | |
| 368 | if (!list_empty(&pd_chan->queue)) |
| 369 | pdc_dostart(pd_chan, pdc_first_queued(pd_chan)); |
| 370 | |
| 371 | list_splice_init(&pd_chan->active_list, &list); |
| 372 | list_splice_init(&pd_chan->queue, &pd_chan->active_list); |
| 373 | |
| 374 | list_for_each_entry_safe(desc, _d, &list, desc_node) |
| 375 | pdc_chain_complete(pd_chan, desc); |
| 376 | } |
| 377 | |
| 378 | static void pdc_handle_error(struct pch_dma_chan *pd_chan) |
| 379 | { |
| 380 | struct pch_dma_desc *bad_desc; |
| 381 | |
| 382 | bad_desc = pdc_first_active(pd_chan); |
| 383 | list_del(&bad_desc->desc_node); |
| 384 | |
| 385 | list_splice_init(&pd_chan->queue, pd_chan->active_list.prev); |
| 386 | |
| 387 | if (!list_empty(&pd_chan->active_list)) |
| 388 | pdc_dostart(pd_chan, pdc_first_active(pd_chan)); |
| 389 | |
| 390 | dev_crit(chan2dev(&pd_chan->chan), "Bad descriptor submitted\n"); |
| 391 | dev_crit(chan2dev(&pd_chan->chan), "descriptor cookie: %d\n", |
| 392 | bad_desc->txd.cookie); |
| 393 | |
| 394 | pdc_chain_complete(pd_chan, bad_desc); |
| 395 | } |
| 396 | |
| 397 | static void pdc_advance_work(struct pch_dma_chan *pd_chan) |
| 398 | { |
| 399 | if (list_empty(&pd_chan->active_list) || |
| 400 | list_is_singular(&pd_chan->active_list)) { |
| 401 | pdc_complete_all(pd_chan); |
| 402 | } else { |
| 403 | pdc_chain_complete(pd_chan, pdc_first_active(pd_chan)); |
| 404 | pdc_dostart(pd_chan, pdc_first_active(pd_chan)); |
| 405 | } |
| 406 | } |
| 407 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 408 | static dma_cookie_t pd_tx_submit(struct dma_async_tx_descriptor *txd) |
| 409 | { |
| 410 | struct pch_dma_desc *desc = to_pd_desc(txd); |
| 411 | struct pch_dma_chan *pd_chan = to_pd_chan(txd->chan); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 412 | |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 413 | spin_lock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 414 | |
| 415 | if (list_empty(&pd_chan->active_list)) { |
| 416 | list_add_tail(&desc->desc_node, &pd_chan->active_list); |
| 417 | pdc_dostart(pd_chan, desc); |
| 418 | } else { |
| 419 | list_add_tail(&desc->desc_node, &pd_chan->queue); |
| 420 | } |
| 421 | |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 422 | spin_unlock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 423 | return 0; |
| 424 | } |
| 425 | |
| 426 | static struct pch_dma_desc *pdc_alloc_desc(struct dma_chan *chan, gfp_t flags) |
| 427 | { |
| 428 | struct pch_dma_desc *desc = NULL; |
| 429 | struct pch_dma *pd = to_pd(chan->device); |
| 430 | dma_addr_t addr; |
| 431 | |
Romain Perier | 10c191a | 2017-10-23 19:59:55 +0200 | [diff] [blame] | 432 | desc = dma_pool_zalloc(pd->pool, flags, &addr); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 433 | if (desc) { |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 434 | INIT_LIST_HEAD(&desc->tx_list); |
| 435 | dma_async_tx_descriptor_init(&desc->txd, chan); |
| 436 | desc->txd.tx_submit = pd_tx_submit; |
| 437 | desc->txd.flags = DMA_CTRL_ACK; |
| 438 | desc->txd.phys = addr; |
| 439 | } |
| 440 | |
| 441 | return desc; |
| 442 | } |
| 443 | |
| 444 | static struct pch_dma_desc *pdc_desc_get(struct pch_dma_chan *pd_chan) |
| 445 | { |
| 446 | struct pch_dma_desc *desc, *_d; |
| 447 | struct pch_dma_desc *ret = NULL; |
Liu Yuan | 364de77 | 2011-04-02 14:20:47 +0800 | [diff] [blame] | 448 | int i = 0; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 449 | |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 450 | spin_lock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 451 | list_for_each_entry_safe(desc, _d, &pd_chan->free_list, desc_node) { |
| 452 | i++; |
| 453 | if (async_tx_test_ack(&desc->txd)) { |
| 454 | list_del(&desc->desc_node); |
| 455 | ret = desc; |
| 456 | break; |
| 457 | } |
| 458 | dev_dbg(chan2dev(&pd_chan->chan), "desc %p not ACKed\n", desc); |
| 459 | } |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 460 | spin_unlock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 461 | dev_dbg(chan2dev(&pd_chan->chan), "scanned %d descriptors\n", i); |
| 462 | |
| 463 | if (!ret) { |
Tomoya MORINAGA | 5c1ef59 | 2013-02-12 11:25:33 +0900 | [diff] [blame] | 464 | ret = pdc_alloc_desc(&pd_chan->chan, GFP_ATOMIC); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 465 | if (ret) { |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 466 | spin_lock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 467 | pd_chan->descs_allocated++; |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 468 | spin_unlock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 469 | } else { |
| 470 | dev_err(chan2dev(&pd_chan->chan), |
| 471 | "failed to alloc desc\n"); |
| 472 | } |
| 473 | } |
| 474 | |
| 475 | return ret; |
| 476 | } |
| 477 | |
| 478 | static void pdc_desc_put(struct pch_dma_chan *pd_chan, |
| 479 | struct pch_dma_desc *desc) |
| 480 | { |
| 481 | if (desc) { |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 482 | spin_lock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 483 | list_splice_init(&desc->tx_list, &pd_chan->free_list); |
| 484 | list_add(&desc->desc_node, &pd_chan->free_list); |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 485 | spin_unlock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 486 | } |
| 487 | } |
| 488 | |
| 489 | static int pd_alloc_chan_resources(struct dma_chan *chan) |
| 490 | { |
| 491 | struct pch_dma_chan *pd_chan = to_pd_chan(chan); |
| 492 | struct pch_dma_desc *desc; |
| 493 | LIST_HEAD(tmp_list); |
| 494 | int i; |
| 495 | |
| 496 | if (!pdc_is_idle(pd_chan)) { |
| 497 | dev_dbg(chan2dev(chan), "DMA channel not idle ?\n"); |
| 498 | return -EIO; |
| 499 | } |
| 500 | |
| 501 | if (!list_empty(&pd_chan->free_list)) |
| 502 | return pd_chan->descs_allocated; |
| 503 | |
| 504 | for (i = 0; i < init_nr_desc_per_channel; i++) { |
| 505 | desc = pdc_alloc_desc(chan, GFP_KERNEL); |
| 506 | |
| 507 | if (!desc) { |
| 508 | dev_warn(chan2dev(chan), |
| 509 | "Only allocated %d initial descriptors\n", i); |
| 510 | break; |
| 511 | } |
| 512 | |
| 513 | list_add_tail(&desc->desc_node, &tmp_list); |
| 514 | } |
| 515 | |
Alexander Stein | 70f1891 | 2011-06-22 17:05:33 +0200 | [diff] [blame] | 516 | spin_lock_irq(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 517 | list_splice(&tmp_list, &pd_chan->free_list); |
| 518 | pd_chan->descs_allocated = i; |
Russell King - ARM Linux | d3ee98cdc | 2012-03-06 22:35:47 +0000 | [diff] [blame] | 519 | dma_cookie_init(chan); |
Alexander Stein | 70f1891 | 2011-06-22 17:05:33 +0200 | [diff] [blame] | 520 | spin_unlock_irq(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 521 | |
| 522 | pdc_enable_irq(chan, 1); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 523 | |
| 524 | return pd_chan->descs_allocated; |
| 525 | } |
| 526 | |
| 527 | static void pd_free_chan_resources(struct dma_chan *chan) |
| 528 | { |
| 529 | struct pch_dma_chan *pd_chan = to_pd_chan(chan); |
| 530 | struct pch_dma *pd = to_pd(chan->device); |
| 531 | struct pch_dma_desc *desc, *_d; |
| 532 | LIST_HEAD(tmp_list); |
| 533 | |
| 534 | BUG_ON(!pdc_is_idle(pd_chan)); |
| 535 | BUG_ON(!list_empty(&pd_chan->active_list)); |
| 536 | BUG_ON(!list_empty(&pd_chan->queue)); |
| 537 | |
Alexander Stein | 70f1891 | 2011-06-22 17:05:33 +0200 | [diff] [blame] | 538 | spin_lock_irq(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 539 | list_splice_init(&pd_chan->free_list, &tmp_list); |
| 540 | pd_chan->descs_allocated = 0; |
Alexander Stein | 70f1891 | 2011-06-22 17:05:33 +0200 | [diff] [blame] | 541 | spin_unlock_irq(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 542 | |
| 543 | list_for_each_entry_safe(desc, _d, &tmp_list, desc_node) |
Romain Perier | 10c191a | 2017-10-23 19:59:55 +0200 | [diff] [blame] | 544 | dma_pool_free(pd->pool, desc, desc->txd.phys); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 545 | |
| 546 | pdc_enable_irq(chan, 0); |
| 547 | } |
| 548 | |
| 549 | static enum dma_status pd_tx_status(struct dma_chan *chan, dma_cookie_t cookie, |
| 550 | struct dma_tx_state *txstate) |
| 551 | { |
Andy Shevchenko | da0a908 | 2013-05-27 15:14:38 +0300 | [diff] [blame] | 552 | return dma_cookie_status(chan, cookie, txstate); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 553 | } |
| 554 | |
| 555 | static void pd_issue_pending(struct dma_chan *chan) |
| 556 | { |
| 557 | struct pch_dma_chan *pd_chan = to_pd_chan(chan); |
| 558 | |
| 559 | if (pdc_is_idle(pd_chan)) { |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 560 | spin_lock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 561 | pdc_advance_work(pd_chan); |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 562 | spin_unlock(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 563 | } |
| 564 | } |
| 565 | |
| 566 | static struct dma_async_tx_descriptor *pd_prep_slave_sg(struct dma_chan *chan, |
| 567 | struct scatterlist *sgl, unsigned int sg_len, |
Alexandre Bounine | 185ecb5 | 2012-03-08 15:35:13 -0500 | [diff] [blame] | 568 | enum dma_transfer_direction direction, unsigned long flags, |
| 569 | void *context) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 570 | { |
| 571 | struct pch_dma_chan *pd_chan = to_pd_chan(chan); |
| 572 | struct pch_dma_slave *pd_slave = chan->private; |
| 573 | struct pch_dma_desc *first = NULL; |
| 574 | struct pch_dma_desc *prev = NULL; |
| 575 | struct pch_dma_desc *desc = NULL; |
| 576 | struct scatterlist *sg; |
| 577 | dma_addr_t reg; |
| 578 | int i; |
| 579 | |
| 580 | if (unlikely(!sg_len)) { |
| 581 | dev_info(chan2dev(chan), "prep_slave_sg: length is zero!\n"); |
| 582 | return NULL; |
| 583 | } |
| 584 | |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 585 | if (direction == DMA_DEV_TO_MEM) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 586 | reg = pd_slave->rx_reg; |
Vinod Koul | db8196d | 2011-10-13 22:34:23 +0530 | [diff] [blame] | 587 | else if (direction == DMA_MEM_TO_DEV) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 588 | reg = pd_slave->tx_reg; |
| 589 | else |
| 590 | return NULL; |
| 591 | |
Tomoya MORINAGA | c8fcba6 | 2011-05-09 16:09:35 +0900 | [diff] [blame] | 592 | pd_chan->dir = direction; |
| 593 | pdc_set_dir(chan); |
| 594 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 595 | for_each_sg(sgl, sg, sg_len, i) { |
| 596 | desc = pdc_desc_get(pd_chan); |
| 597 | |
| 598 | if (!desc) |
| 599 | goto err_desc_get; |
| 600 | |
| 601 | desc->regs.dev_addr = reg; |
Lars-Peter Clausen | cbb796c | 2012-04-25 20:50:51 +0200 | [diff] [blame] | 602 | desc->regs.mem_addr = sg_dma_address(sg); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 603 | desc->regs.size = sg_dma_len(sg); |
| 604 | desc->regs.next = DMA_DESC_FOLLOW_WITHOUT_IRQ; |
| 605 | |
| 606 | switch (pd_slave->width) { |
| 607 | case PCH_DMA_WIDTH_1_BYTE: |
| 608 | if (desc->regs.size > DMA_DESC_MAX_COUNT_1_BYTE) |
| 609 | goto err_desc_get; |
| 610 | desc->regs.size |= DMA_DESC_WIDTH_1_BYTE; |
| 611 | break; |
| 612 | case PCH_DMA_WIDTH_2_BYTES: |
| 613 | if (desc->regs.size > DMA_DESC_MAX_COUNT_2_BYTES) |
| 614 | goto err_desc_get; |
| 615 | desc->regs.size |= DMA_DESC_WIDTH_2_BYTES; |
| 616 | break; |
| 617 | case PCH_DMA_WIDTH_4_BYTES: |
| 618 | if (desc->regs.size > DMA_DESC_MAX_COUNT_4_BYTES) |
| 619 | goto err_desc_get; |
| 620 | desc->regs.size |= DMA_DESC_WIDTH_4_BYTES; |
| 621 | break; |
| 622 | default: |
| 623 | goto err_desc_get; |
| 624 | } |
| 625 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 626 | if (!first) { |
| 627 | first = desc; |
| 628 | } else { |
| 629 | prev->regs.next |= desc->txd.phys; |
| 630 | list_add_tail(&desc->desc_node, &first->tx_list); |
| 631 | } |
| 632 | |
| 633 | prev = desc; |
| 634 | } |
| 635 | |
| 636 | if (flags & DMA_PREP_INTERRUPT) |
| 637 | desc->regs.next = DMA_DESC_END_WITH_IRQ; |
| 638 | else |
| 639 | desc->regs.next = DMA_DESC_END_WITHOUT_IRQ; |
| 640 | |
| 641 | first->txd.cookie = -EBUSY; |
| 642 | desc->txd.flags = flags; |
| 643 | |
| 644 | return &first->txd; |
| 645 | |
| 646 | err_desc_get: |
| 647 | dev_err(chan2dev(chan), "failed to get desc or wrong parameters\n"); |
| 648 | pdc_desc_put(pd_chan, first); |
| 649 | return NULL; |
| 650 | } |
| 651 | |
Maxime Ripard | c91781b | 2014-11-17 14:42:40 +0100 | [diff] [blame] | 652 | static int pd_device_terminate_all(struct dma_chan *chan) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 653 | { |
| 654 | struct pch_dma_chan *pd_chan = to_pd_chan(chan); |
| 655 | struct pch_dma_desc *desc, *_d; |
| 656 | LIST_HEAD(list); |
| 657 | |
Alexander Stein | 70f1891 | 2011-06-22 17:05:33 +0200 | [diff] [blame] | 658 | spin_lock_irq(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 659 | |
| 660 | pdc_set_mode(&pd_chan->chan, DMA_CTL0_DISABLE); |
| 661 | |
| 662 | list_splice_init(&pd_chan->active_list, &list); |
| 663 | list_splice_init(&pd_chan->queue, &list); |
| 664 | |
| 665 | list_for_each_entry_safe(desc, _d, &list, desc_node) |
| 666 | pdc_chain_complete(pd_chan, desc); |
| 667 | |
Alexander Stein | 70f1891 | 2011-06-22 17:05:33 +0200 | [diff] [blame] | 668 | spin_unlock_irq(&pd_chan->lock); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 669 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 670 | return 0; |
| 671 | } |
| 672 | |
Allen Pais | 88ff509 | 2020-08-31 16:05:26 +0530 | [diff] [blame] | 673 | static void pdc_tasklet(struct tasklet_struct *t) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 674 | { |
Allen Pais | 88ff509 | 2020-08-31 16:05:26 +0530 | [diff] [blame] | 675 | struct pch_dma_chan *pd_chan = from_tasklet(pd_chan, t, tasklet); |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 676 | unsigned long flags; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 677 | |
| 678 | if (!pdc_is_idle(pd_chan)) { |
| 679 | dev_err(chan2dev(&pd_chan->chan), |
| 680 | "BUG: handle non-idle channel in tasklet\n"); |
| 681 | return; |
| 682 | } |
| 683 | |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 684 | spin_lock_irqsave(&pd_chan->lock, flags); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 685 | if (test_and_clear_bit(0, &pd_chan->err_status)) |
| 686 | pdc_handle_error(pd_chan); |
| 687 | else |
| 688 | pdc_advance_work(pd_chan); |
Tomoya MORINAGA | c5a9f9d | 2011-02-18 10:01:20 +0530 | [diff] [blame] | 689 | spin_unlock_irqrestore(&pd_chan->lock, flags); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | static irqreturn_t pd_irq(int irq, void *devid) |
| 693 | { |
| 694 | struct pch_dma *pd = (struct pch_dma *)devid; |
| 695 | struct pch_dma_chan *pd_chan; |
| 696 | u32 sts0; |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 697 | u32 sts2; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 698 | int i; |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 699 | int ret0 = IRQ_NONE; |
| 700 | int ret2 = IRQ_NONE; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 701 | |
| 702 | sts0 = dma_readl(pd, STS0); |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 703 | sts2 = dma_readl(pd, STS2); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 704 | |
| 705 | dev_dbg(pd->dma.dev, "pd_irq sts0: %x\n", sts0); |
| 706 | |
| 707 | for (i = 0; i < pd->dma.chancnt; i++) { |
| 708 | pd_chan = &pd->channels[i]; |
| 709 | |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 710 | if (i < 8) { |
| 711 | if (sts0 & DMA_STATUS_IRQ(i)) { |
| 712 | if (sts0 & DMA_STATUS0_ERR(i)) |
| 713 | set_bit(0, &pd_chan->err_status); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 714 | |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 715 | tasklet_schedule(&pd_chan->tasklet); |
| 716 | ret0 = IRQ_HANDLED; |
| 717 | } |
| 718 | } else { |
| 719 | if (sts2 & DMA_STATUS_IRQ(i - 8)) { |
| 720 | if (sts2 & DMA_STATUS2_ERR(i)) |
| 721 | set_bit(0, &pd_chan->err_status); |
| 722 | |
| 723 | tasklet_schedule(&pd_chan->tasklet); |
| 724 | ret2 = IRQ_HANDLED; |
| 725 | } |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 726 | } |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 727 | } |
| 728 | |
| 729 | /* clear interrupt bits in status register */ |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 730 | if (ret0) |
| 731 | dma_writel(pd, STS0, sts0); |
| 732 | if (ret2) |
| 733 | dma_writel(pd, STS2, sts2); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 734 | |
Tomoya MORINAGA | c3d4913 | 2011-05-31 10:34:45 +0900 | [diff] [blame] | 735 | return ret0 | ret2; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 736 | } |
| 737 | |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 738 | static void __maybe_unused pch_dma_save_regs(struct pch_dma *pd) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 739 | { |
| 740 | struct pch_dma_chan *pd_chan; |
| 741 | struct dma_chan *chan, *_c; |
| 742 | int i = 0; |
| 743 | |
| 744 | pd->regs.dma_ctl0 = dma_readl(pd, CTL0); |
| 745 | pd->regs.dma_ctl1 = dma_readl(pd, CTL1); |
| 746 | pd->regs.dma_ctl2 = dma_readl(pd, CTL2); |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 747 | pd->regs.dma_ctl3 = dma_readl(pd, CTL3); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 748 | |
| 749 | list_for_each_entry_safe(chan, _c, &pd->dma.channels, device_node) { |
| 750 | pd_chan = to_pd_chan(chan); |
| 751 | |
| 752 | pd->ch_regs[i].dev_addr = channel_readl(pd_chan, DEV_ADDR); |
| 753 | pd->ch_regs[i].mem_addr = channel_readl(pd_chan, MEM_ADDR); |
| 754 | pd->ch_regs[i].size = channel_readl(pd_chan, SIZE); |
| 755 | pd->ch_regs[i].next = channel_readl(pd_chan, NEXT); |
| 756 | |
| 757 | i++; |
| 758 | } |
| 759 | } |
| 760 | |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 761 | static void __maybe_unused pch_dma_restore_regs(struct pch_dma *pd) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 762 | { |
| 763 | struct pch_dma_chan *pd_chan; |
| 764 | struct dma_chan *chan, *_c; |
| 765 | int i = 0; |
| 766 | |
| 767 | dma_writel(pd, CTL0, pd->regs.dma_ctl0); |
| 768 | dma_writel(pd, CTL1, pd->regs.dma_ctl1); |
| 769 | dma_writel(pd, CTL2, pd->regs.dma_ctl2); |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 770 | dma_writel(pd, CTL3, pd->regs.dma_ctl3); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 771 | |
| 772 | list_for_each_entry_safe(chan, _c, &pd->dma.channels, device_node) { |
| 773 | pd_chan = to_pd_chan(chan); |
| 774 | |
| 775 | channel_writel(pd_chan, DEV_ADDR, pd->ch_regs[i].dev_addr); |
| 776 | channel_writel(pd_chan, MEM_ADDR, pd->ch_regs[i].mem_addr); |
| 777 | channel_writel(pd_chan, SIZE, pd->ch_regs[i].size); |
| 778 | channel_writel(pd_chan, NEXT, pd->ch_regs[i].next); |
| 779 | |
| 780 | i++; |
| 781 | } |
| 782 | } |
| 783 | |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 784 | static int __maybe_unused pch_dma_suspend(struct device *dev) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 785 | { |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 786 | struct pch_dma *pd = dev_get_drvdata(dev); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 787 | |
| 788 | if (pd) |
| 789 | pch_dma_save_regs(pd); |
| 790 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 791 | return 0; |
| 792 | } |
| 793 | |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 794 | static int __maybe_unused pch_dma_resume(struct device *dev) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 795 | { |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 796 | struct pch_dma *pd = dev_get_drvdata(dev); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 797 | |
| 798 | if (pd) |
| 799 | pch_dma_restore_regs(pd); |
| 800 | |
| 801 | return 0; |
| 802 | } |
| 803 | |
Bill Pemberton | 463a1f8 | 2012-11-19 13:22:55 -0500 | [diff] [blame] | 804 | static int pch_dma_probe(struct pci_dev *pdev, |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 805 | const struct pci_device_id *id) |
| 806 | { |
| 807 | struct pch_dma *pd; |
| 808 | struct pch_dma_regs *regs; |
| 809 | unsigned int nr_channels; |
| 810 | int err; |
| 811 | int i; |
| 812 | |
| 813 | nr_channels = id->driver_data; |
Tomoya MORINAGA | 01631243d | 2011-10-12 09:38:35 +0900 | [diff] [blame] | 814 | pd = kzalloc(sizeof(*pd), GFP_KERNEL); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 815 | if (!pd) |
| 816 | return -ENOMEM; |
| 817 | |
| 818 | pci_set_drvdata(pdev, pd); |
| 819 | |
| 820 | err = pci_enable_device(pdev); |
| 821 | if (err) { |
| 822 | dev_err(&pdev->dev, "Cannot enable PCI device\n"); |
| 823 | goto err_free_mem; |
| 824 | } |
| 825 | |
| 826 | if (!(pci_resource_flags(pdev, 1) & IORESOURCE_MEM)) { |
| 827 | dev_err(&pdev->dev, "Cannot find proper base address\n"); |
Wei Yongjun | 27abb2f | 2013-07-17 08:34:59 +0800 | [diff] [blame] | 828 | err = -ENODEV; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 829 | goto err_disable_pdev; |
| 830 | } |
| 831 | |
| 832 | err = pci_request_regions(pdev, DRV_NAME); |
| 833 | if (err) { |
| 834 | dev_err(&pdev->dev, "Cannot obtain PCI resources\n"); |
| 835 | goto err_disable_pdev; |
| 836 | } |
| 837 | |
| 838 | err = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); |
| 839 | if (err) { |
| 840 | dev_err(&pdev->dev, "Cannot set proper DMA config\n"); |
| 841 | goto err_free_res; |
| 842 | } |
| 843 | |
| 844 | regs = pd->membase = pci_iomap(pdev, 1, 0); |
| 845 | if (!pd->membase) { |
| 846 | dev_err(&pdev->dev, "Cannot map MMIO registers\n"); |
| 847 | err = -ENOMEM; |
| 848 | goto err_free_res; |
| 849 | } |
| 850 | |
| 851 | pci_set_master(pdev); |
Madhuparna Bhowmik | 2e45676 | 2020-04-16 11:53:35 +0530 | [diff] [blame] | 852 | pd->dma.dev = &pdev->dev; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 853 | |
| 854 | err = request_irq(pdev->irq, pd_irq, IRQF_SHARED, DRV_NAME, pd); |
| 855 | if (err) { |
| 856 | dev_err(&pdev->dev, "Failed to request IRQ\n"); |
| 857 | goto err_iounmap; |
| 858 | } |
| 859 | |
Romain Perier | 10c191a | 2017-10-23 19:59:55 +0200 | [diff] [blame] | 860 | pd->pool = dma_pool_create("pch_dma_desc_pool", &pdev->dev, |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 861 | sizeof(struct pch_dma_desc), 4, 0); |
| 862 | if (!pd->pool) { |
| 863 | dev_err(&pdev->dev, "Failed to alloc DMA descriptors\n"); |
| 864 | err = -ENOMEM; |
| 865 | goto err_free_irq; |
| 866 | } |
| 867 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 868 | |
| 869 | INIT_LIST_HEAD(&pd->dma.channels); |
| 870 | |
| 871 | for (i = 0; i < nr_channels; i++) { |
| 872 | struct pch_dma_chan *pd_chan = &pd->channels[i]; |
| 873 | |
| 874 | pd_chan->chan.device = &pd->dma; |
Russell King - ARM Linux | d3ee98cdc | 2012-03-06 22:35:47 +0000 | [diff] [blame] | 875 | dma_cookie_init(&pd_chan->chan); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 876 | |
| 877 | pd_chan->membase = ®s->desc[i]; |
| 878 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 879 | spin_lock_init(&pd_chan->lock); |
| 880 | |
| 881 | INIT_LIST_HEAD(&pd_chan->active_list); |
| 882 | INIT_LIST_HEAD(&pd_chan->queue); |
| 883 | INIT_LIST_HEAD(&pd_chan->free_list); |
| 884 | |
Allen Pais | 88ff509 | 2020-08-31 16:05:26 +0530 | [diff] [blame] | 885 | tasklet_setup(&pd_chan->tasklet, pdc_tasklet); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 886 | list_add_tail(&pd_chan->chan.device_node, &pd->dma.channels); |
| 887 | } |
| 888 | |
| 889 | dma_cap_zero(pd->dma.cap_mask); |
| 890 | dma_cap_set(DMA_PRIVATE, pd->dma.cap_mask); |
| 891 | dma_cap_set(DMA_SLAVE, pd->dma.cap_mask); |
| 892 | |
| 893 | pd->dma.device_alloc_chan_resources = pd_alloc_chan_resources; |
| 894 | pd->dma.device_free_chan_resources = pd_free_chan_resources; |
| 895 | pd->dma.device_tx_status = pd_tx_status; |
| 896 | pd->dma.device_issue_pending = pd_issue_pending; |
| 897 | pd->dma.device_prep_slave_sg = pd_prep_slave_sg; |
Maxime Ripard | c91781b | 2014-11-17 14:42:40 +0100 | [diff] [blame] | 898 | pd->dma.device_terminate_all = pd_device_terminate_all; |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 899 | |
| 900 | err = dma_async_device_register(&pd->dma); |
| 901 | if (err) { |
| 902 | dev_err(&pdev->dev, "Failed to register DMA device\n"); |
| 903 | goto err_free_pool; |
| 904 | } |
| 905 | |
| 906 | return 0; |
| 907 | |
| 908 | err_free_pool: |
Romain Perier | 10c191a | 2017-10-23 19:59:55 +0200 | [diff] [blame] | 909 | dma_pool_destroy(pd->pool); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 910 | err_free_irq: |
| 911 | free_irq(pdev->irq, pd); |
| 912 | err_iounmap: |
| 913 | pci_iounmap(pdev, pd->membase); |
| 914 | err_free_res: |
| 915 | pci_release_regions(pdev); |
| 916 | err_disable_pdev: |
| 917 | pci_disable_device(pdev); |
| 918 | err_free_mem: |
Alexey Khoroshilov | 12d7b7a | 2015-04-11 01:28:41 +0300 | [diff] [blame] | 919 | kfree(pd); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 920 | return err; |
| 921 | } |
| 922 | |
Greg Kroah-Hartman | 4bf27b8 | 2012-12-21 15:09:59 -0800 | [diff] [blame] | 923 | static void pch_dma_remove(struct pci_dev *pdev) |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 924 | { |
| 925 | struct pch_dma *pd = pci_get_drvdata(pdev); |
| 926 | struct pch_dma_chan *pd_chan; |
| 927 | struct dma_chan *chan, *_c; |
| 928 | |
| 929 | if (pd) { |
| 930 | dma_async_device_unregister(&pd->dma); |
| 931 | |
Vinod Koul | 9068b03 | 2014-03-06 12:24:08 +0530 | [diff] [blame] | 932 | free_irq(pdev->irq, pd); |
| 933 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 934 | list_for_each_entry_safe(chan, _c, &pd->dma.channels, |
| 935 | device_node) { |
| 936 | pd_chan = to_pd_chan(chan); |
| 937 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 938 | tasklet_kill(&pd_chan->tasklet); |
| 939 | } |
| 940 | |
Romain Perier | 10c191a | 2017-10-23 19:59:55 +0200 | [diff] [blame] | 941 | dma_pool_destroy(pd->pool); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 942 | pci_iounmap(pdev, pd->membase); |
| 943 | pci_release_regions(pdev); |
| 944 | pci_disable_device(pdev); |
| 945 | kfree(pd); |
| 946 | } |
| 947 | } |
| 948 | |
| 949 | /* PCI Device ID of DMA device */ |
Tomoya MORINAGA | 2cdf245 | 2011-01-05 17:43:52 +0900 | [diff] [blame] | 950 | #define PCI_DEVICE_ID_EG20T_PCH_DMA_8CH 0x8810 |
| 951 | #define PCI_DEVICE_ID_EG20T_PCH_DMA_4CH 0x8815 |
| 952 | #define PCI_DEVICE_ID_ML7213_DMA1_8CH 0x8026 |
| 953 | #define PCI_DEVICE_ID_ML7213_DMA2_8CH 0x802B |
| 954 | #define PCI_DEVICE_ID_ML7213_DMA3_4CH 0x8034 |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 955 | #define PCI_DEVICE_ID_ML7213_DMA4_12CH 0x8032 |
Tomoya MORINAGA | c0dfc04 | 2011-05-09 16:09:39 +0900 | [diff] [blame] | 956 | #define PCI_DEVICE_ID_ML7223_DMA1_4CH 0x800B |
| 957 | #define PCI_DEVICE_ID_ML7223_DMA2_4CH 0x800E |
| 958 | #define PCI_DEVICE_ID_ML7223_DMA3_4CH 0x8017 |
| 959 | #define PCI_DEVICE_ID_ML7223_DMA4_4CH 0x803B |
Tomoya MORINAGA | ca7fe2d | 2011-11-17 16:14:23 +0900 | [diff] [blame] | 960 | #define PCI_DEVICE_ID_ML7831_DMA1_8CH 0x8810 |
| 961 | #define PCI_DEVICE_ID_ML7831_DMA2_4CH 0x8815 |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 962 | |
Michele Curti | 345e312 | 2014-12-02 18:07:56 +0100 | [diff] [blame] | 963 | static const struct pci_device_id pch_dma_id_table[] = { |
Tomoya MORINAGA | 2cdf245 | 2011-01-05 17:43:52 +0900 | [diff] [blame] | 964 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_EG20T_PCH_DMA_8CH), 8 }, |
| 965 | { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_EG20T_PCH_DMA_4CH), 4 }, |
| 966 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_DMA1_8CH), 8}, /* UART Video */ |
| 967 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_DMA2_8CH), 8}, /* PCMIF SPI */ |
| 968 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_DMA3_4CH), 4}, /* FPGA */ |
Tomoya MORINAGA | 194f5f2 | 2011-05-09 16:09:38 +0900 | [diff] [blame] | 969 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7213_DMA4_12CH), 12}, /* I2S */ |
Tomoya MORINAGA | c0dfc04 | 2011-05-09 16:09:39 +0900 | [diff] [blame] | 970 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA1_4CH), 4}, /* UART */ |
| 971 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA2_4CH), 4}, /* Video SPI */ |
| 972 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA3_4CH), 4}, /* Security */ |
| 973 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7223_DMA4_4CH), 4}, /* FPGA */ |
Tomoya MORINAGA | ca7fe2d | 2011-11-17 16:14:23 +0900 | [diff] [blame] | 974 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_DMA1_8CH), 8}, /* UART */ |
| 975 | { PCI_VDEVICE(ROHM, PCI_DEVICE_ID_ML7831_DMA2_4CH), 4}, /* SPI */ |
Dzianis Kahanovich | 87acf5a | 2010-10-27 20:33:05 -0600 | [diff] [blame] | 976 | { 0, }, |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 977 | }; |
| 978 | |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 979 | static SIMPLE_DEV_PM_OPS(pch_dma_pm_ops, pch_dma_suspend, pch_dma_resume); |
| 980 | |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 981 | static struct pci_driver pch_dma_driver = { |
| 982 | .name = DRV_NAME, |
| 983 | .id_table = pch_dma_id_table, |
| 984 | .probe = pch_dma_probe, |
Bill Pemberton | a7d6e3e | 2012-11-19 13:20:04 -0500 | [diff] [blame] | 985 | .remove = pch_dma_remove, |
Vaibhav Gupta | 7db7f8e | 2020-07-20 17:07:41 +0530 | [diff] [blame] | 986 | .driver.pm = &pch_dma_pm_ops, |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 987 | }; |
| 988 | |
Wei Yongjun | 53b9989 | 2012-10-10 21:04:58 +0800 | [diff] [blame] | 989 | module_pci_driver(pch_dma_driver); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 990 | |
Tomoya MORINAGA | ca7fe2d | 2011-11-17 16:14:23 +0900 | [diff] [blame] | 991 | MODULE_DESCRIPTION("Intel EG20T PCH / LAPIS Semicon ML7213/ML7223/ML7831 IOH " |
Tomoya MORINAGA | 2cdf245 | 2011-01-05 17:43:52 +0900 | [diff] [blame] | 992 | "DMA controller driver"); |
Yong Wang | 0c42bd0 | 2010-07-30 16:23:03 +0800 | [diff] [blame] | 993 | MODULE_AUTHOR("Yong Wang <yong.y.wang@intel.com>"); |
| 994 | MODULE_LICENSE("GPL v2"); |
Ben Hutchings | 58ddff2 | 2013-09-02 00:02:06 +0100 | [diff] [blame] | 995 | MODULE_DEVICE_TABLE(pci, pch_dma_id_table); |