Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
mdio.h
Go to the documentation of this file.
1
7/*
8 * Copyright (c) 2021 IP-Logix Inc.
9 *
10 * SPDX-License-Identifier: Apache-2.0
11 */
12#ifndef ZEPHYR_INCLUDE_DRIVERS_MDIO_H_
13#define ZEPHYR_INCLUDE_DRIVERS_MDIO_H_
14
21#include <zephyr/types.h>
22#include <device.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
36enum MDIO_PROTOCOL {
37 CLAUSE_22 = 0,
38 CLAUSE_45 = 1,
39 MICREL_SMI = 2,
40};
41
42__subsystem struct mdio_driver_api {
44 void (*bus_enable)(const struct device *dev);
45
47 void (*bus_disable)(const struct device *dev);
48
50 int (*read)(const struct device *dev, uint8_t prtad, uint8_t devad,
51 uint16_t *data);
52
54 int (*write)(const struct device *dev, uint8_t prtad, uint8_t devad,
56};
67__syscall void mdio_bus_enable(const struct device *dev);
68
69static inline void z_impl_mdio_bus_enable(const struct device *dev)
70{
71 const struct mdio_driver_api *api =
72 (const struct mdio_driver_api *)dev->api;
73
74 return api->bus_enable(dev);
75}
76
83__syscall void mdio_bus_disable(const struct device *dev);
84
85static inline void z_impl_mdio_bus_disable(const struct device *dev)
86{
87 const struct mdio_driver_api *api =
88 (const struct mdio_driver_api *)dev->api;
89
90 return api->bus_disable(dev);
91}
92
108__syscall int mdio_read(const struct device *dev, uint8_t prtad, uint8_t devad,
109 uint16_t *data);
110
111static inline int z_impl_mdio_read(const struct device *dev, uint8_t prtad,
112 uint8_t devad, uint16_t *data)
113{
114 const struct mdio_driver_api *api =
115 (const struct mdio_driver_api *)dev->api;
116
117 return api->read(dev, prtad, devad, data);
118}
119
120
136__syscall int mdio_write(const struct device *dev, uint8_t prtad, uint8_t devad,
137 uint16_t data);
138
139static inline int z_impl_mdio_write(const struct device *dev, uint8_t prtad,
140 uint8_t devad, uint16_t data)
141{
142 const struct mdio_driver_api *api =
143 (const struct mdio_driver_api *)dev->api;
144
145 return api->write(dev, prtad, devad, data);
146}
147
148#ifdef __cplusplus
149}
150#endif
151
156#include <syscalls/mdio.h>
157
158#endif /* ZEPHYR_INCLUDE_DRIVERS_MDIO_H_ */
void
Definition: eswifi_shell.c:15
void mdio_bus_enable(const struct device *dev)
Enable MDIO bus.
void mdio_bus_disable(const struct device *dev)
Disable MDIO bus and tri-state drivers.
int mdio_write(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t data)
Write to MDIO bus.
int mdio_read(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t *data)
Read from MDIO Bus.
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Runtime device structure (in ROM) per driver instance.
Definition: device.h:367
const void * api
Definition: device.h:373
static fdata_t data[2]
Definition: test_fifo_contexts.c:15