]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/net/eth/lwip-eth/arch/TARGET_NXP/lpc_phy.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / net / eth / lwip-eth / arch / TARGET_NXP / lpc_phy.h
1 /**********************************************************************
2 * $Id$          lpc_phy.h                       2011-11-20
3 *//**
4 * @file         lpc_phy.h
5 * @brief        Common PHY definitions used with all PHYs
6 * @version      1.0
7 * @date         20 Nov. 2011
8 * @author       NXP MCU SW Application Team
9
10 * Copyright(C) 2011, NXP Semiconductor
11 * All rights reserved.
12 *
13 ***********************************************************************
14 * Software that is described herein is for illustrative purposes only
15 * which provides customers with programming information regarding the
16 * products. This software is supplied "AS IS" without any warranties.
17 * NXP Semiconductors assumes no responsibility or liability for the
18 * use of the software, conveys no license or title under any patent,
19 * copyright, or mask work right to the product. NXP Semiconductors
20 * reserves the right to make changes in the software without
21 * notification. NXP Semiconductors also make no representation or
22 * warranty that such application will be suitable for the specified
23 * use without further testing or modification.
24 **********************************************************************/
25
26 #ifndef __LPC_PHY_H_
27 #define __LPC_PHY_H_
28
29 #include "lwip/opt.h"
30 #include "lwip/err.h"
31 #include "lwip/netif.h"
32
33 #ifdef __cplusplus
34 extern "C"
35 {
36 #endif
37
38 /* These PHY functions are usually part of the EMAC driver */
39
40 /** \brief  Phy status update state machine
41  *
42  *  This function provides a state machine for maintaining the PHY
43  *  status without blocking. It must be occasionally called for the
44  *  PHY status to be maintained.
45  *
46  *  \param[in]     netif   NETIF structure
47  */
48 s32_t lpc_phy_sts_sm(struct netif *netif);
49
50 /** \brief  Initialize the PHY
51  *
52  *  This function initializes the PHY. It will block until complete.
53  *  This function is called as part of the EMAC driver
54  *  initialization. Configuration of the PHY at startup is
55  *  controlled by setting up configuration defines in lpc_phy.h.
56  *
57  *  \param[in]     netif   NETIF structure
58  *  \param[in]     rmii    If set, configures the PHY for RMII mode
59  *  \return         ERR_OK if the setup was successful, otherwise ERR_TIMEOUT
60  */
61 err_t lpc_phy_init(struct netif *netif, int rmii);
62
63 /** \brief  Write a value via the MII link (non-blocking)
64  *
65  *  This function will write a value on the MII link interface to a PHY
66  *  or a connected device. The function will return immediately without
67  *  a status. Status needs to be polled later to determine if the write
68  *  was successful.
69  *
70  *  \param[in]      PhyReg  PHY register to write to
71  *  \param[in]      Value   Value to write
72  */
73 void lpc_mii_write_noblock(u32_t PhyReg, u32_t Value);
74
75 /** \brief  Write a value via the MII link (blocking)
76  *
77  *  This function will write a value on the MII link interface to a PHY
78  *  or a connected device. The function will block until complete.
79  *
80  *  \param[in]      PhyReg  PHY register to write to
81  *  \param[in]      Value   Value to write
82  * \returns         0 if the write was successful, otherwise !0
83  */
84 err_t lpc_mii_write(u32_t PhyReg, u32_t Value);
85
86 /** \brief  Reads current MII link busy status
87  *
88  *  This function will return the current MII link busy status and is meant to
89  *  be used with non-blocking functions for monitor PHY status such as
90  *  connection state.
91  *
92  *  \returns         !0 if the MII link is busy, otherwise 0
93  */
94 u32_t lpc_mii_is_busy(void);
95
96 /** \brief  Starts a read operation via the MII link (non-blocking)
97  *
98  *  This function returns the current value in the MII data register. It is
99  *  meant to be used with the non-blocking oeprations. This value should
100  *  only be read after a non-block read command has been issued and the
101  *  MII status has been determined to be good.
102  *
103  *  \returns          The current value in the MII value register
104  */
105 u32_t lpc_mii_read_data(void);
106
107 /** \brief  Starts a read operation via the MII link (non-blocking)
108  *
109  *  This function will start a read operation on the MII link interface
110  *  from a PHY or a connected device. The function will not block and
111  *  the status mist be polled until complete. Once complete, the data
112  *  can be read.
113  *
114  *  \param[in]      PhyReg  PHY register to read from
115  */
116 err_t lpc_mii_read(u32_t PhyReg, u32_t *data);
117
118 /** \brief  Read a value via the MII link (blocking)
119  *
120  *  This function will read a value on the MII link interface from a PHY
121  *  or a connected device. The function will block until complete.
122  * 
123  *  \param[in]      PhyReg  PHY register to read from
124  *  \param[in]      data    Pointer to where to save data read via MII
125  *  \returns         0 if the read was successful, otherwise !0
126  */
127 void lpc_mii_read_noblock(u32_t PhyReg);
128
129 /**
130  * This function provides a method for the PHY to setup the EMAC
131  * for the PHY negotiated duplex mode.
132  *
133  * @param[in] full_duplex 0 = half duplex, 1 = full duplex
134  */
135 void lpc_emac_set_duplex(int full_duplex);
136
137 /**
138  * This function provides a method for the PHY to setup the EMAC
139  * for the PHY negotiated bit rate.
140  *
141  * @param[in] mbs_100     0 = 10mbs mode, 1 = 100mbs mode
142  */
143 void lpc_emac_set_speed(int mbs_100);
144
145 #ifdef __cplusplus
146 }
147 #endif
148
149 #endif /* __LPC_PHY_H_ */
150
151 /* --------------------------------- End Of File ------------------------------ */