@@ -73,6 +73,9 @@ static const char version[] =
73
73
#include <linux/etherdevice.h>
74
74
#include <linux/skbuff.h>
75
75
76
+ #include <linux/dmaengine.h>
77
+ #include <linux/dma/pxa-dma.h>
78
+
76
79
#include <asm/io.h>
77
80
78
81
#include "smc911x.h"
@@ -1174,18 +1177,16 @@ static irqreturn_t smc911x_interrupt(int irq, void *dev_id)
1174
1177
1175
1178
#ifdef SMC_USE_DMA
1176
1179
static void
1177
- smc911x_tx_dma_irq (int dma , void * data )
1180
+ smc911x_tx_dma_irq (void * data )
1178
1181
{
1179
- struct net_device * dev = ( struct net_device * ) data ;
1180
- struct smc911x_local * lp = netdev_priv ( dev ) ;
1182
+ struct smc911x_local * lp = data ;
1183
+ struct net_device * dev = lp -> netdev ;
1181
1184
struct sk_buff * skb = lp -> current_tx_skb ;
1182
1185
unsigned long flags ;
1183
1186
1184
1187
DBG (SMC_DEBUG_FUNC , dev , "--> %s\n" , __func__ );
1185
1188
1186
1189
DBG (SMC_DEBUG_TX | SMC_DEBUG_DMA , dev , "TX DMA irq handler\n" );
1187
- /* Clear the DMA interrupt sources */
1188
- SMC_DMA_ACK_IRQ (dev , dma );
1189
1190
BUG_ON (skb == NULL );
1190
1191
dma_unmap_single (NULL , tx_dmabuf , tx_dmalen , DMA_TO_DEVICE );
1191
1192
dev -> trans_start = jiffies ;
@@ -1208,18 +1209,16 @@ smc911x_tx_dma_irq(int dma, void *data)
1208
1209
"TX DMA irq completed\n" );
1209
1210
}
1210
1211
static void
1211
- smc911x_rx_dma_irq (int dma , void * data )
1212
+ smc911x_rx_dma_irq (void * data )
1212
1213
{
1213
- struct net_device * dev = ( struct net_device * ) data ;
1214
- struct smc911x_local * lp = netdev_priv ( dev ) ;
1214
+ struct smc911x_local * lp = data ;
1215
+ struct net_device * dev = lp -> netdev ;
1215
1216
struct sk_buff * skb = lp -> current_rx_skb ;
1216
1217
unsigned long flags ;
1217
1218
unsigned int pkts ;
1218
1219
1219
1220
DBG (SMC_DEBUG_FUNC , dev , "--> %s\n" , __func__ );
1220
1221
DBG (SMC_DEBUG_RX | SMC_DEBUG_DMA , dev , "RX DMA irq handler\n" );
1221
- /* Clear the DMA interrupt sources */
1222
- SMC_DMA_ACK_IRQ (dev , dma );
1223
1222
dma_unmap_single (NULL , rx_dmabuf , rx_dmalen , DMA_FROM_DEVICE );
1224
1223
BUG_ON (skb == NULL );
1225
1224
lp -> current_rx_skb = NULL ;
@@ -1792,6 +1791,9 @@ static int smc911x_probe(struct net_device *dev)
1792
1791
unsigned int val , chip_id , revision ;
1793
1792
const char * version_string ;
1794
1793
unsigned long irq_flags ;
1794
+ struct dma_slave_config config ;
1795
+ dma_cap_mask_t mask ;
1796
+ struct pxad_param param ;
1795
1797
1796
1798
DBG (SMC_DEBUG_FUNC , dev , "--> %s\n" , __func__ );
1797
1799
@@ -1963,11 +1965,40 @@ static int smc911x_probe(struct net_device *dev)
1963
1965
goto err_out ;
1964
1966
1965
1967
#ifdef SMC_USE_DMA
1966
- lp -> rxdma = SMC_DMA_REQUEST (dev , smc911x_rx_dma_irq );
1967
- lp -> txdma = SMC_DMA_REQUEST (dev , smc911x_tx_dma_irq );
1968
+
1969
+ dma_cap_zero (mask );
1970
+ dma_cap_set (DMA_SLAVE , mask );
1971
+ param .prio = PXAD_PRIO_LOWEST ;
1972
+ param .drcmr = -1UL ;
1973
+
1974
+ lp -> rxdma =
1975
+ dma_request_slave_channel_compat (mask , pxad_filter_fn ,
1976
+ & param , & dev -> dev , "rx" );
1977
+ lp -> txdma =
1978
+ dma_request_slave_channel_compat (mask , pxad_filter_fn ,
1979
+ & param , & dev -> dev , "tx" );
1968
1980
lp -> rxdma_active = 0 ;
1969
1981
lp -> txdma_active = 0 ;
1970
- dev -> dma = lp -> rxdma ;
1982
+
1983
+ memset (& config , 0 , sizeof (config ));
1984
+ config .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES ;
1985
+ config .dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES ;
1986
+ config .src_addr = lp -> physaddr + RX_DATA_FIFO ;
1987
+ config .dst_addr = lp -> physaddr + TX_DATA_FIFO ;
1988
+ config .src_maxburst = 32 ;
1989
+ config .dst_maxburst = 32 ;
1990
+ retval = dmaengine_slave_config (lp -> rxdma , & config );
1991
+ if (retval ) {
1992
+ dev_err (lp -> dev , "dma rx channel configuration failed: %d\n" ,
1993
+ retval );
1994
+ goto err_out ;
1995
+ }
1996
+ retval = dmaengine_slave_config (lp -> txdma , & config );
1997
+ if (retval ) {
1998
+ dev_err (lp -> dev , "dma tx channel configuration failed: %d\n" ,
1999
+ retval );
2000
+ goto err_out ;
2001
+ }
1971
2002
#endif
1972
2003
1973
2004
retval = register_netdev (dev );
@@ -1978,11 +2009,11 @@ static int smc911x_probe(struct net_device *dev)
1978
2009
dev -> base_addr , dev -> irq );
1979
2010
1980
2011
#ifdef SMC_USE_DMA
1981
- if (lp -> rxdma != -1 )
1982
- pr_cont (" RXDMA %d " , lp -> rxdma );
2012
+ if (lp -> rxdma )
2013
+ pr_cont (" RXDMA %p " , lp -> rxdma );
1983
2014
1984
- if (lp -> txdma != -1 )
1985
- pr_cont (" TXDMA %d " , lp -> txdma );
2015
+ if (lp -> txdma )
2016
+ pr_cont (" TXDMA %p " , lp -> txdma );
1986
2017
#endif
1987
2018
pr_cont ("\n" );
1988
2019
if (!is_valid_ether_addr (dev -> dev_addr )) {
@@ -2005,12 +2036,10 @@ static int smc911x_probe(struct net_device *dev)
2005
2036
err_out :
2006
2037
#ifdef SMC_USE_DMA
2007
2038
if (retval ) {
2008
- if (lp -> rxdma != -1 ) {
2009
- SMC_DMA_FREE (dev , lp -> rxdma );
2010
- }
2011
- if (lp -> txdma != -1 ) {
2012
- SMC_DMA_FREE (dev , lp -> txdma );
2013
- }
2039
+ if (lp -> rxdma )
2040
+ dma_release_channel (lp -> rxdma );
2041
+ if (lp -> txdma )
2042
+ dma_release_channel (lp -> txdma );
2014
2043
}
2015
2044
#endif
2016
2045
return retval ;
@@ -2112,12 +2141,10 @@ static int smc911x_drv_remove(struct platform_device *pdev)
2112
2141
2113
2142
#ifdef SMC_USE_DMA
2114
2143
{
2115
- if (lp -> rxdma != -1 ) {
2116
- SMC_DMA_FREE (dev , lp -> rxdma );
2117
- }
2118
- if (lp -> txdma != -1 ) {
2119
- SMC_DMA_FREE (dev , lp -> txdma );
2120
- }
2144
+ if (lp -> rxdma )
2145
+ dma_release_channel (lp -> rxdma );
2146
+ if (lp -> txdma )
2147
+ dma_release_channel (lp -> txdma );
2121
2148
}
2122
2149
#endif
2123
2150
iounmap (lp -> base );
0 commit comments