Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
mdio.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2021 IP-Logix Inc.
9 * Copyright 2023 NXP
10 *
11 * SPDX-License-Identifier: Apache-2.0
12 */
13#ifndef ZEPHYR_INCLUDE_DRIVERS_MDIO_H_
14#define ZEPHYR_INCLUDE_DRIVERS_MDIO_H_
15
22#include <zephyr/types.h>
23#include <zephyr/device.h>
24#include <errno.h>
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
36__subsystem struct mdio_driver_api {
38 void (*bus_enable)(const struct device *dev);
39
41 void (*bus_disable)(const struct device *dev);
42
44 int (*read)(const struct device *dev, uint8_t prtad, uint8_t regad,
45 uint16_t *data);
46
48 int (*write)(const struct device *dev, uint8_t prtad, uint8_t regad,
49 uint16_t data);
50
52 int (*read_c45)(const struct device *dev, uint8_t prtad, uint8_t devad,
53 uint16_t regad, uint16_t *data);
54
56 int (*write_c45)(const struct device *dev, uint8_t prtad, uint8_t devad,
57 uint16_t regad, uint16_t data);
58};
69__syscall void mdio_bus_enable(const struct device *dev);
70
71static inline void z_impl_mdio_bus_enable(const struct device *dev)
72{
73 const struct mdio_driver_api *api =
74 (const struct mdio_driver_api *)dev->api;
75
76 if (api->bus_enable != NULL) {
77 api->bus_enable(dev);
78 }
79}
80
87__syscall void mdio_bus_disable(const struct device *dev);
88
89static inline void z_impl_mdio_bus_disable(const struct device *dev)
90{
91 const struct mdio_driver_api *api =
92 (const struct mdio_driver_api *)dev->api;
93
94 if (api->bus_disable != NULL) {
95 api->bus_disable(dev);
96 }
97}
98
115__syscall int mdio_read(const struct device *dev, uint8_t prtad, uint8_t regad,
116 uint16_t *data);
117
118static inline int z_impl_mdio_read(const struct device *dev, uint8_t prtad,
119 uint8_t regad, uint16_t *data)
120{
121 const struct mdio_driver_api *api =
122 (const struct mdio_driver_api *)dev->api;
123
124 if (api->read == NULL) {
125 return -ENOSYS;
126 }
127
128 return api->read(dev, prtad, regad, data);
129}
130
131
148__syscall int mdio_write(const struct device *dev, uint8_t prtad, uint8_t regad,
149 uint16_t data);
150
151static inline int z_impl_mdio_write(const struct device *dev, uint8_t prtad,
152 uint8_t regad, uint16_t data)
153{
154 const struct mdio_driver_api *api =
155 (const struct mdio_driver_api *)dev->api;
156
157 if (api->write == NULL) {
158 return -ENOSYS;
159 }
160
161 return api->write(dev, prtad, regad, data);
162}
163
181__syscall int mdio_read_c45(const struct device *dev, uint8_t prtad,
182 uint8_t devad, uint16_t regad, uint16_t *data);
183
184static inline int z_impl_mdio_read_c45(const struct device *dev, uint8_t prtad,
185 uint8_t devad, uint16_t regad,
186 uint16_t *data)
187{
188 const struct mdio_driver_api *api =
189 (const struct mdio_driver_api *)dev->api;
190
191 if (api->read_c45 == NULL) {
192 return -ENOSYS;
193 }
194
195 return api->read_c45(dev, prtad, devad, regad, data);
196}
197
215__syscall int mdio_write_c45(const struct device *dev, uint8_t prtad,
216 uint8_t devad, uint16_t regad, uint16_t data);
217
218static inline int z_impl_mdio_write_c45(const struct device *dev, uint8_t prtad,
219 uint8_t devad, uint16_t regad,
220 uint16_t data)
221{
222 const struct mdio_driver_api *api =
223 (const struct mdio_driver_api *)dev->api;
224
225 if (api->write_c45 == NULL) {
226 return -ENOSYS;
227 }
228
229 return api->write_c45(dev, prtad, devad, regad, data);
230}
231
232#ifdef __cplusplus
233}
234#endif
235
240#include <zephyr/syscalls/mdio.h>
241
242#endif /* ZEPHYR_INCLUDE_DRIVERS_MDIO_H_ */
System error numbers.
int mdio_write(const struct device *dev, uint8_t prtad, uint8_t regad, uint16_t data)
Write to MDIO bus.
void mdio_bus_enable(const struct device *dev)
Enable MDIO bus.
int mdio_read_c45(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t regad, uint16_t *data)
Read from MDIO Bus using Clause 45 access.
void mdio_bus_disable(const struct device *dev)
Disable MDIO bus and tri-state drivers.
int mdio_write_c45(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t regad, uint16_t data)
Write to MDIO bus using Clause 45 access.
int mdio_read(const struct device *dev, uint8_t prtad, uint8_t regad, uint16_t *data)
Read from MDIO Bus.
#define ENOSYS
Function not implemented.
Definition errno.h:82
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
__UINT16_TYPE__ uint16_t
Definition stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
const void * api
Address of the API structure exposed by the device instance.
Definition device.h:418