| .. | .. |
|---|
| 35 | 35 | #include <linux/platform_device.h> |
|---|
| 36 | 36 | #include <linux/dma-mapping.h> |
|---|
| 37 | 37 | #include <linux/slab.h> |
|---|
| 38 | +#include <linux/pgtable.h> |
|---|
| 38 | 39 | |
|---|
| 39 | 40 | #include <asm/io.h> |
|---|
| 40 | | -#include <asm/pgtable.h> |
|---|
| 41 | 41 | #include <asm/dma.h> |
|---|
| 42 | 42 | |
|---|
| 43 | 43 | static char xtsonic_string[] = "xtsonic"; |
|---|
| .. | .. |
|---|
| 167 | 167 | dev->dev_addr[i*2+1] = val >> 8; |
|---|
| 168 | 168 | } |
|---|
| 169 | 169 | |
|---|
| 170 | | - /* Initialize the device structure. */ |
|---|
| 171 | | - |
|---|
| 172 | 170 | lp->dma_bitmode = SONIC_BITMODE32; |
|---|
| 173 | 171 | |
|---|
| 174 | | - /* |
|---|
| 175 | | - * Allocate local private descriptor areas in uncached space. |
|---|
| 176 | | - * The entire structure must be located within the same 64kb segment. |
|---|
| 177 | | - * A simple way to ensure this is to allocate twice the |
|---|
| 178 | | - * size of the structure -- given that the structure is |
|---|
| 179 | | - * much less than 64 kB, at least one of the halves of |
|---|
| 180 | | - * the allocated area will be contained entirely in 64 kB. |
|---|
| 181 | | - * We also allocate extra space for a pointer to allow freeing |
|---|
| 182 | | - * this structure later on (in xtsonic_cleanup_module()). |
|---|
| 183 | | - */ |
|---|
| 184 | | - lp->descriptors = dma_alloc_coherent(lp->device, |
|---|
| 185 | | - SIZEOF_SONIC_DESC * |
|---|
| 186 | | - SONIC_BUS_SCALE(lp->dma_bitmode), |
|---|
| 187 | | - &lp->descriptors_laddr, |
|---|
| 188 | | - GFP_KERNEL); |
|---|
| 189 | | - if (lp->descriptors == NULL) { |
|---|
| 190 | | - err = -ENOMEM; |
|---|
| 172 | + err = sonic_alloc_descriptors(dev); |
|---|
| 173 | + if (err) |
|---|
| 191 | 174 | goto out; |
|---|
| 192 | | - } |
|---|
| 193 | | - |
|---|
| 194 | | - lp->cda = lp->descriptors; |
|---|
| 195 | | - lp->tda = lp->cda + (SIZEOF_SONIC_CDA |
|---|
| 196 | | - * SONIC_BUS_SCALE(lp->dma_bitmode)); |
|---|
| 197 | | - lp->rda = lp->tda + (SIZEOF_SONIC_TD * SONIC_NUM_TDS |
|---|
| 198 | | - * SONIC_BUS_SCALE(lp->dma_bitmode)); |
|---|
| 199 | | - lp->rra = lp->rda + (SIZEOF_SONIC_RD * SONIC_NUM_RDS |
|---|
| 200 | | - * SONIC_BUS_SCALE(lp->dma_bitmode)); |
|---|
| 201 | | - |
|---|
| 202 | | - /* get the virtual dma address */ |
|---|
| 203 | | - |
|---|
| 204 | | - lp->cda_laddr = lp->descriptors_laddr; |
|---|
| 205 | | - lp->tda_laddr = lp->cda_laddr + (SIZEOF_SONIC_CDA |
|---|
| 206 | | - * SONIC_BUS_SCALE(lp->dma_bitmode)); |
|---|
| 207 | | - lp->rda_laddr = lp->tda_laddr + (SIZEOF_SONIC_TD * SONIC_NUM_TDS |
|---|
| 208 | | - * SONIC_BUS_SCALE(lp->dma_bitmode)); |
|---|
| 209 | | - lp->rra_laddr = lp->rda_laddr + (SIZEOF_SONIC_RD * SONIC_NUM_RDS |
|---|
| 210 | | - * SONIC_BUS_SCALE(lp->dma_bitmode)); |
|---|
| 211 | 175 | |
|---|
| 212 | 176 | dev->netdev_ops = &xtsonic_netdev_ops; |
|---|
| 213 | 177 | dev->watchdog_timeo = TX_TIMEOUT; |
|---|