~ubuntu-branches/ubuntu/raring/ipxe/raring

« back to all changes in this revision

Viewing changes to src/include/ipxe/mii.h

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2012-11-14 15:47:31 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20121114154731-jhuy5d1h2jw75qe9
Tags: 1.0.0+git-4.d6b0b76-0ubuntu1
* New upstream snapshot:
  - d/p/iscsi*.patch: Dropped - included in snapshot.
  - Refreshed all other patches.
* d/p/enable-https.patch: Enable HTTPS support (LP: #1025239).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _IPXE_MII_H
 
2
#define _IPXE_MII_H
 
3
 
 
4
/** @file
 
5
 *
 
6
 * Media Independent Interface
 
7
 *
 
8
 */
 
9
 
 
10
FILE_LICENCE ( GPL2_OR_LATER );
 
11
 
 
12
#include <mii.h>
 
13
#include <ipxe/netdevice.h>
 
14
 
 
15
struct mii_interface;
 
16
 
 
17
/** MII interface operations */
 
18
struct mii_operations {
 
19
        /**
 
20
         * Read from MII register
 
21
         *
 
22
         * @v mii               MII interface
 
23
         * @v reg               Register address
 
24
         * @ret data            Data read, or negative error
 
25
         */
 
26
        int ( * read ) ( struct mii_interface *mii, unsigned int reg );
 
27
        /**
 
28
         * Write to MII register
 
29
         *
 
30
         * @v mii               MII interface
 
31
         * @v reg               Register address
 
32
         * @v data              Data to write
 
33
         * @ret rc              Return status code
 
34
         */
 
35
        int ( * write ) ( struct mii_interface *mii, unsigned int reg,
 
36
                          unsigned int data );
 
37
};
 
38
 
 
39
/** An MII interface */
 
40
struct mii_interface {
 
41
        /** Interface operations */
 
42
        struct mii_operations *op;
 
43
};
 
44
 
 
45
/**
 
46
 * Initialise MII interface
 
47
 *
 
48
 * @v mii               MII interface
 
49
 * @v op                MII interface operations
 
50
 */
 
51
static inline __attribute__ (( always_inline )) void
 
52
mii_init ( struct mii_interface *mii, struct mii_operations *op ) {
 
53
        mii->op = op;
 
54
}
 
55
 
 
56
/**
 
57
 * Read from MII register
 
58
 *
 
59
 * @v mii               MII interface
 
60
 * @v reg               Register address
 
61
 * @ret data            Data read, or negative error
 
62
 */
 
63
static inline __attribute__ (( always_inline )) int
 
64
mii_read ( struct mii_interface *mii, unsigned int reg ) {
 
65
        return mii->op->read ( mii, reg );
 
66
}
 
67
 
 
68
/**
 
69
 * Write to MII register
 
70
 *
 
71
 * @v mii               MII interface
 
72
 * @v reg               Register address
 
73
 * @v data              Data to write
 
74
 * @ret rc              Return status code
 
75
 */
 
76
static inline __attribute__ (( always_inline )) int
 
77
mii_write ( struct mii_interface *mii, unsigned int reg, unsigned int data ) {
 
78
        return mii->op->write ( mii, reg, data );
 
79
}
 
80
 
 
81
/** Maximum time to wait for a reset, in milliseconds */
 
82
#define MII_RESET_MAX_WAIT_MS 500
 
83
 
 
84
extern int mii_restart ( struct mii_interface *mii );
 
85
extern int mii_reset ( struct mii_interface *mii );
 
86
 
 
87
#endif /* _IPXE_MII_H */