+ struct eth_pdata *pdata = dev_get_platdata(dev);
+ struct altera_tse_priv *priv = dev_get_priv(dev);
+ void *blob = (void *)gd->fdt_blob;
+ int node = dev_of_offset(dev);
+ const char *list, *end;
+ const fdt32_t *cell;
+ void *base, *desc_mem = NULL;
+ unsigned long addr, size;
+ int parent, addrc, sizec;
+ int len, idx;
+ int ret;
+
+ priv->dma_type = dev_get_driver_data(dev);
+ if (priv->dma_type == ALT_SGDMA)
+ priv->ops = &tse_sgdma_ops;
+ else
+ priv->ops = &tse_msgdma_ops;
+ /*
+ * decode regs. there are multiple reg tuples, and they need to
+ * match with reg-names.
+ */
+ parent = fdt_parent_offset(blob, node);
+ fdt_support_default_count_cells(blob, parent, &addrc, &sizec);
+ list = fdt_getprop(blob, node, "reg-names", &len);
+ if (!list)
+ return -ENOENT;
+ end = list + len;
+ cell = fdt_getprop(blob, node, "reg", &len);
+ if (!cell)
+ return -ENOENT;
+ idx = 0;
+ while (list < end) {
+ addr = fdt_translate_address((void *)blob,
+ node, cell + idx);
+ size = fdt_addr_to_cpu(cell[idx + addrc]);
+ base = map_physmem(addr, size, MAP_NOCACHE);
+ len = strlen(list);
+ if (strcmp(list, "control_port") == 0)
+ priv->mac_dev = base;
+ else if (strcmp(list, "rx_csr") == 0)
+ priv->sgdma_rx = base;
+ else if (strcmp(list, "rx_desc") == 0)
+ priv->rx_desc = base;
+ else if (strcmp(list, "rx_resp") == 0)
+ priv->rx_resp = base;
+ else if (strcmp(list, "tx_csr") == 0)
+ priv->sgdma_tx = base;
+ else if (strcmp(list, "tx_desc") == 0)
+ priv->tx_desc = base;
+ else if (strcmp(list, "s1") == 0)
+ desc_mem = base;
+ idx += addrc + sizec;
+ list += (len + 1);
+ }
+ /* decode fifo depth */
+ priv->rx_fifo_depth = fdtdec_get_int(blob, node,
+ "rx-fifo-depth", 0);
+ priv->tx_fifo_depth = fdtdec_get_int(blob, node,
+ "tx-fifo-depth", 0);
+ /* decode phy */
+ addr = fdtdec_get_int(blob, node,
+ "phy-handle", 0);
+ addr = fdt_node_offset_by_phandle(blob, addr);
+ priv->phyaddr = fdtdec_get_int(blob, addr,
+ "reg", 0);
+ /* init desc */
+ if (priv->dma_type == ALT_SGDMA) {
+ len = sizeof(struct alt_sgdma_descriptor) * 4;
+ if (!desc_mem) {
+ desc_mem = dma_alloc_coherent(len, &addr);
+ if (!desc_mem)
+ return -ENOMEM;
+ }
+ memset(desc_mem, 0, len);
+ priv->tx_desc = desc_mem;
+ priv->rx_desc = priv->tx_desc +
+ 2 * sizeof(struct alt_sgdma_descriptor);
+ }
+ /* allocate recv packet buffer */
+ priv->rx_buf = malloc_cache_aligned(PKTSIZE_ALIGN);
+ if (!priv->rx_buf)
+ return -ENOMEM;