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