Blackfin: bfin_mac: cleanup MII/PHY functions
[platform/kernel/u-boot.git] / drivers / net / bfin_mac.h
1 /*
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
12 #define PHYADDR                 0x01
13 #define RECV_BUFSIZE            (0x614)
14
15 typedef struct ADI_DMA_CONFIG_REG {
16         u16 b_DMA_EN:1;         /* 0    Enabled                         */
17         u16 b_WNR:1;            /* 1    Direction                       */
18         u16 b_WDSIZE:2;         /* 2:3  Transfer word size              */
19         u16 b_DMA2D:1;          /* 4    DMA mode                        */
20         u16 b_RESTART:1;        /* 5    Retain FIFO                     */
21         u16 b_DI_SEL:1;         /* 6    Data interrupt timing select    */
22         u16 b_DI_EN:1;          /* 7    Data interrupt enabled          */
23         u16 b_NDSIZE:4;         /* 8:11 Flex descriptor size            */
24         u16 b_FLOW:3;           /* 12:14Flow                            */
25 } ADI_DMA_CONFIG_REG;
26
27 typedef struct adi_ether_frame_buffer {
28         u16 NoBytes;            /* the no. of following bytes   */
29         u8 Dest[6];             /* destination MAC address      */
30         u8 Srce[6];             /* source MAC address           */
31         u16 LTfield;            /* length/type field            */
32         u8 Data[0];             /* payload bytes                */
33 } ADI_ETHER_FRAME_BUFFER;
34 /* 16 bytes/struct      */
35
36 typedef struct dma_descriptor {
37         struct dma_descriptor *NEXT_DESC_PTR;
38         u32 START_ADDR;
39         ADI_DMA_CONFIG_REG CONFIG;
40 } DMA_DESCRIPTOR;
41 /* 10 bytes/struct in 12 bytes */
42
43 typedef struct adi_ether_buffer {
44         DMA_DESCRIPTOR Dma[2];          /* first for the frame, second for the status */
45         ADI_ETHER_FRAME_BUFFER *FrmData;/* pointer to data */
46         struct adi_ether_buffer *pNext; /* next buffer */
47         struct adi_ether_buffer *pPrev; /* prev buffer */
48         u16 IPHdrChksum;                /* the IP header checksum */
49         u16 IPPayloadChksum;            /* the IP header and payload checksum */
50         volatile u32 StatusWord;        /* the frame status word */
51 } ADI_ETHER_BUFFER;
52 /* 40 bytes/struct in 44 bytes */
53
54 static ADI_ETHER_BUFFER *SetupRxBuffer(int no);
55 static ADI_ETHER_BUFFER *SetupTxBuffer(int no);
56
57 static int bfin_EMAC_init(struct eth_device *dev, bd_t *bd);
58 static void bfin_EMAC_halt(struct eth_device *dev);
59 static int bfin_EMAC_send(struct eth_device *dev, volatile void *packet, int length);
60 static int bfin_EMAC_recv(struct eth_device *dev);
61
62 static void bfin_EMAC_setup_addr(bd_t *bd);
63
64 #endif