blob: c731c179b53e7da5cdd70f92505a5ef9a304669b [file] [log] [blame]
Mike Frysinger395bce42008-02-24 23:58:13 -05001/*
2 * bfin_mac.h - some defines/structures for the Blackfin on-chip MAC.
3 *
4 * Copyright (c) 2005-2008 Analog Device, Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#ifndef __BFIN_MAC_H__
10#define __BFIN_MAC_H__
11
Aubrey Li26bf7de2007-03-19 01:24:52 +080012#define RECV_BUFSIZE (0x614)
13
Aubrey Li26bf7de2007-03-19 01:24:52 +080014typedef struct ADI_DMA_CONFIG_REG {
15 u16 b_DMA_EN:1; /* 0 Enabled */
16 u16 b_WNR:1; /* 1 Direction */
17 u16 b_WDSIZE:2; /* 2:3 Transfer word size */
18 u16 b_DMA2D:1; /* 4 DMA mode */
19 u16 b_RESTART:1; /* 5 Retain FIFO */
20 u16 b_DI_SEL:1; /* 6 Data interrupt timing select */
21 u16 b_DI_EN:1; /* 7 Data interrupt enabled */
22 u16 b_NDSIZE:4; /* 8:11 Flex descriptor size */
23 u16 b_FLOW:3; /* 12:14Flow */
24} ADI_DMA_CONFIG_REG;
25
26typedef struct adi_ether_frame_buffer {
27 u16 NoBytes; /* the no. of following bytes */
28 u8 Dest[6]; /* destination MAC address */
29 u8 Srce[6]; /* source MAC address */
30 u16 LTfield; /* length/type field */
31 u8 Data[0]; /* payload bytes */
32} ADI_ETHER_FRAME_BUFFER;
33/* 16 bytes/struct */
34
35typedef struct dma_descriptor {
36 struct dma_descriptor *NEXT_DESC_PTR;
37 u32 START_ADDR;
Mike Frysinger6d7d4802009-01-08 11:57:57 -050038 union {
39 u16 CONFIG_DATA;
40 ADI_DMA_CONFIG_REG CONFIG;
41 };
Aubrey Li26bf7de2007-03-19 01:24:52 +080042} DMA_DESCRIPTOR;
43/* 10 bytes/struct in 12 bytes */
44
45typedef struct adi_ether_buffer {
46 DMA_DESCRIPTOR Dma[2]; /* first for the frame, second for the status */
47 ADI_ETHER_FRAME_BUFFER *FrmData;/* pointer to data */
48 struct adi_ether_buffer *pNext; /* next buffer */
49 struct adi_ether_buffer *pPrev; /* prev buffer */
50 u16 IPHdrChksum; /* the IP header checksum */
51 u16 IPPayloadChksum; /* the IP header and payload checksum */
52 volatile u32 StatusWord; /* the frame status word */
53} ADI_ETHER_BUFFER;
54/* 40 bytes/struct in 44 bytes */
55
Mike Frysinger395bce42008-02-24 23:58:13 -050056static ADI_ETHER_BUFFER *SetupRxBuffer(int no);
57static ADI_ETHER_BUFFER *SetupTxBuffer(int no);
Aubrey Li26bf7de2007-03-19 01:24:52 +080058
Mike Frysinger395bce42008-02-24 23:58:13 -050059static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd);
60static void bfin_EMAC_halt(struct eth_device *dev);
61static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet, int length);
62static int bfin_EMAC_recv(struct eth_device *dev);
Mike Frysinger4324dc72010-04-27 14:15:28 -040063static int bfin_EMAC_setup_addr(struct eth_device *dev);
Mike Frysinger395bce42008-02-24 23:58:13 -050064
65#endif