annotate packages/devs/eth/phy/current/include/eth_phy.h @ 2729:74dbf4c3f2e1 after-copyright-change-20090129

Update all copyright banners to reflect FSF ownership; fix and improve licence text.
author jlarmour
date Thu, 29 Jan 2009 17:47:46 +0000
parents 970f455a2397
children 31c9ab39babe
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
1 #ifndef CYGONCE_DEVS_ETH_PHY_H_
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
2 #define CYGONCE_DEVS_ETH_PHY_H_
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
3 //==========================================================================
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
4 //
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
5 // eth_phy.h
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
6 //
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
7 // User API for ethernet transciever (PHY) support
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
8 //
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
9 //==========================================================================
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
10 // ####ECOSGPLCOPYRIGHTBEGIN####
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
11 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
12 // This file is part of eCos, the Embedded Configurable Operating System.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
13 // Copyright (C) 2003 Free Software Foundation, Inc.
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
14 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
15 // eCos is free software; you can redistribute it and/or modify it under
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
16 // the terms of the GNU General Public License as published by the Free
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
17 // Software Foundation; either version 2 or (at your option) any later
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
18 // version.
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
19 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
20 // eCos is distributed in the hope that it will be useful, but WITHOUT
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
21 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
23 // for more details.
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
24 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
25 // You should have received a copy of the GNU General Public License
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
26 // along with eCos; if not, write to the Free Software Foundation, Inc.,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
27 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
28 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
29 // As a special exception, if other files instantiate templates or use
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
30 // macros or inline functions from this file, or you compile this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
31 // and link it with other works to produce a work based on this file,
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
32 // this file does not by itself cause the resulting work to be covered by
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
33 // the GNU General Public License. However the source code for this file
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
34 // must still be made available in accordance with section (3) of the GNU
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
35 // General Public License v2.
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
36 //
2729
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
37 // This exception does not invalidate any other reasons why a work based
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
38 // on this file might be covered by the GNU General Public License.
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
39 // -------------------------------------------
74dbf4c3f2e1 Update all copyright banners to reflect FSF ownership; fix and improve licence text.
jlarmour
parents: 2177
diff changeset
40 // ####ECOSGPLCOPYRIGHTEND####
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
41 //==========================================================================
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
42 //#####DESCRIPTIONBEGIN####
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
43 //
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
44 // Author(s): gthomas
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
45 // Contributors: gthomas
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
46 // Date: 2003-08-01
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
47 // Purpose:
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
48 // Description:
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
49 //
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
50 //####DESCRIPTIONEND####
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
51 //
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
52 //==========================================================================
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
53
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
54 #define PHY_BIT_LEVEL_ACCESS_TYPE 0
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
55 #define PHY_REG_LEVEL_ACCESS_TYPE 1
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
56
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
57 // Physical device access - defined by hardware instance
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
58 typedef struct {
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
59 int ops_type; // 0 => bit level, 1 => register level
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
60 bool init_done;
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
61 void (*init)(void);
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
62 void (*reset)(void);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
63 union {
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
64 struct {
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
65 void (*set_data)(int);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
66 int (*get_data)(void);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
67 void (*set_clock)(int);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
68 void (*set_dir)(int);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
69 } bit_level_ops;
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
70 struct {
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
71 void (*put_reg)(int reg, int unit, unsigned short data);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
72 bool (*get_reg)(int reg, int unit, unsigned short *data);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
73 } reg_level_ops;
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
74 } ops;
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
75 int phy_addr;
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
76 struct _eth_phy_dev_entry *dev; // Chip access functions
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
77 } eth_phy_access_t;
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
78
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
79 #define ETH_PHY_BIT_LEVEL_ACCESS_FUNS(_l,_init,_reset,_set_data,_get_data,_set_clock,_set_dir) \
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
80 static eth_phy_access_t _l = {PHY_BIT_LEVEL_ACCESS_TYPE, false, _init, _reset, \
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
81 {.bit_level_ops = {_set_data, _get_data, _set_clock, _set_dir}}}
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
82
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
83 #define ETH_PHY_REG_LEVEL_ACCESS_FUNS(_l,_init,_reset,_put_reg,_get_reg) \
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
84 static eth_phy_access_t _l = {PHY_REG_LEVEL_ACCESS_TYPE, false, _init, _reset, \
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
85 {.reg_level_ops = {_put_reg, _get_reg}}}
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
86
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
87 #define ETH_PHY_STAT_LINK 0x0001 // Link up/down
1211
4c8e032983ae Add documentation for ethernet PHY drivers
gthomas
parents: 1178
diff changeset
88 #define ETH_PHY_STAT_100MB 0x0002 // Connection is 100Mb/10Mb
4c8e032983ae Add documentation for ethernet PHY drivers
gthomas
parents: 1178
diff changeset
89 #define ETH_PHY_STAT_FDX 0x0004 // Connection is full/half duplex
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
90
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
91 externC bool _eth_phy_init(eth_phy_access_t *f);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
92 externC void _eth_phy_reset(eth_phy_access_t *f);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
93 externC int _eth_phy_state(eth_phy_access_t *f);
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
94 externC int _eth_phy_cfg(eth_phy_access_t *f, int mode);
2177
970f455a2397 Add support for ICS189X, better debug handling - from Jay Foster
gthomas
parents: 1211
diff changeset
95 #define ETH_PHY_MODE_DEFAULT 0
970f455a2397 Add support for ICS189X, better debug handling - from Jay Foster
gthomas
parents: 1211
diff changeset
96
1178
0832585993c1 New abstractions to handle device specifics
gthomas
parents: 1170
diff changeset
97 // Internal routines
1170
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
98 externC void _eth_phy_write(eth_phy_access_t *f, int reg, int unit, unsigned short data);
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
99 externC bool _eth_phy_read(eth_phy_access_t *f, int reg, int unit, unsigned short *val);
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
100
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
101 #endif // CYGONCE_DEVS_ETH_PHY_H_
719dd033d039 New API for handling ethernet PHY devices
gthomas
parents:
diff changeset
102 // ------------------------------------------------------------------------