diff options
Diffstat (limited to 'drivers/rapidio/rio.c')
| -rw-r--r-- | drivers/rapidio/rio.c | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/drivers/rapidio/rio.c b/drivers/rapidio/rio.c index 86c9a091a2ff..c40665a4fa33 100644 --- a/drivers/rapidio/rio.c +++ b/drivers/rapidio/rio.c | |||
| @@ -1121,6 +1121,87 @@ int rio_std_route_clr_table(struct rio_mport *mport, u16 destid, u8 hopcount, | |||
| 1121 | return 0; | 1121 | return 0; |
| 1122 | } | 1122 | } |
| 1123 | 1123 | ||
| 1124 | #ifdef CONFIG_RAPIDIO_DMA_ENGINE | ||
| 1125 | |||
| 1126 | static bool rio_chan_filter(struct dma_chan *chan, void *arg) | ||
| 1127 | { | ||
| 1128 | struct rio_dev *rdev = arg; | ||
| 1129 | |||
| 1130 | /* Check that DMA device belongs to the right MPORT */ | ||
| 1131 | return (rdev->net->hport == | ||
| 1132 | container_of(chan->device, struct rio_mport, dma)); | ||
| 1133 | } | ||
| 1134 | |||
| 1135 | /** | ||
| 1136 | * rio_request_dma - request RapidIO capable DMA channel that supports | ||
| 1137 | * specified target RapidIO device. | ||
| 1138 | * @rdev: RIO device control structure | ||
| 1139 | * | ||
| 1140 | * Returns pointer to allocated DMA channel or NULL if failed. | ||
| 1141 | */ | ||
| 1142 | struct dma_chan *rio_request_dma(struct rio_dev *rdev) | ||
| 1143 | { | ||
| 1144 | dma_cap_mask_t mask; | ||
| 1145 | struct dma_chan *dchan; | ||
| 1146 | |||
| 1147 | dma_cap_zero(mask); | ||
| 1148 | dma_cap_set(DMA_SLAVE, mask); | ||
| 1149 | dchan = dma_request_channel(mask, rio_chan_filter, rdev); | ||
| 1150 | |||
| 1151 | return dchan; | ||
| 1152 | } | ||
| 1153 | EXPORT_SYMBOL_GPL(rio_request_dma); | ||
| 1154 | |||
| 1155 | /** | ||
| 1156 | * rio_release_dma - release specified DMA channel | ||
| 1157 | * @dchan: DMA channel to release | ||
| 1158 | */ | ||
| 1159 | void rio_release_dma(struct dma_chan *dchan) | ||
| 1160 | { | ||
| 1161 | dma_release_channel(dchan); | ||
| 1162 | } | ||
| 1163 | EXPORT_SYMBOL_GPL(rio_release_dma); | ||
| 1164 | |||
| 1165 | /** | ||
| 1166 | * rio_dma_prep_slave_sg - RapidIO specific wrapper | ||
| 1167 | * for device_prep_slave_sg callback defined by DMAENGINE. | ||
| 1168 | * @rdev: RIO device control structure | ||
| 1169 | * @dchan: DMA channel to configure | ||
| 1170 | * @data: RIO specific data descriptor | ||
| 1171 | * @direction: DMA data transfer direction (TO or FROM the device) | ||
| 1172 | * @flags: dmaengine defined flags | ||
| 1173 | * | ||
| 1174 | * Initializes RapidIO capable DMA channel for the specified data transfer. | ||
| 1175 | * Uses DMA channel private extension to pass information related to remote | ||
| 1176 | * target RIO device. | ||
| 1177 | * Returns pointer to DMA transaction descriptor or NULL if failed. | ||
| 1178 | */ | ||
| 1179 | struct dma_async_tx_descriptor *rio_dma_prep_slave_sg(struct rio_dev *rdev, | ||
| 1180 | struct dma_chan *dchan, struct rio_dma_data *data, | ||
| 1181 | enum dma_transfer_direction direction, unsigned long flags) | ||
| 1182 | { | ||
| 1183 | struct dma_async_tx_descriptor *txd = NULL; | ||
| 1184 | struct rio_dma_ext rio_ext; | ||
| 1185 | |||
| 1186 | if (dchan->device->device_prep_slave_sg == NULL) { | ||
| 1187 | pr_err("%s: prep_rio_sg == NULL\n", __func__); | ||
| 1188 | return NULL; | ||
| 1189 | } | ||
| 1190 | |||
| 1191 | rio_ext.destid = rdev->destid; | ||
| 1192 | rio_ext.rio_addr_u = data->rio_addr_u; | ||
| 1193 | rio_ext.rio_addr = data->rio_addr; | ||
| 1194 | rio_ext.wr_type = data->wr_type; | ||
| 1195 | |||
| 1196 | txd = dmaengine_prep_rio_sg(dchan, data->sg, data->sg_len, | ||
| 1197 | direction, flags, &rio_ext); | ||
| 1198 | |||
| 1199 | return txd; | ||
| 1200 | } | ||
| 1201 | EXPORT_SYMBOL_GPL(rio_dma_prep_slave_sg); | ||
| 1202 | |||
| 1203 | #endif /* CONFIG_RAPIDIO_DMA_ENGINE */ | ||
| 1204 | |||
| 1124 | static void rio_fixup_device(struct rio_dev *dev) | 1205 | static void rio_fixup_device(struct rio_dev *dev) |
| 1125 | { | 1206 | { |
| 1126 | } | 1207 | } |
