no-OS
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
no_os_mdio.h
Go to the documentation of this file.
1/***************************************************************************/
33#ifndef _NO_OS_MDIO_H_
34#define _NO_OS_MDIO_H_
35
36#include <stdbool.h>
37#include <stdint.h>
38#include "no_os_util.h"
39
40#define NO_OS_MDIO_C22_REGS 32
41#define NO_OS_MDIO_C45_START 0
42#define NO_OS_MDIO_C22_START 1
43#define NO_OS_MDIO_START_MASK NO_OS_GENMASK(31, 30)
44#define NO_OS_MDIO_OP_ADDRESS 0
45#define NO_OS_MDIO_OP_WRITE 1
46#define NO_OS_MDIO_OP_READ 2
47#define NO_OS_MDIO_OP_MASK NO_OS_GENMASK(29, 28)
48#define NO_OS_MDIO_PHYADDR_MASK NO_OS_GENMASK(27, 23)
49#define NO_OS_MDIO_REGADDR_MASK NO_OS_GENMASK(22, 18)
50#define NO_OS_MDIO_TURNAROUND 2
51#define NO_OS_MDIO_TURNAROUND_MASK NO_OS_GENMASK(17, 16)
52#define NO_OS_MDIO_DATA_MASK NO_OS_GENMASK(15, 0)
53#define NO_OS_MDIO_C45_DEVADDR_MASK NO_OS_GENMASK(20, 16)
54#define NO_OS_MDIO_C45_ADDR(dev, reg) (NO_OS_BIT(31) | no_os_field_prep(NO_OS_MDIO_C45_DEVADDR_MASK, dev) | (uint16_t)reg)
55
62 int id;
65 bool c45;
67 uint8_t addr;
71 void *extra;
72};
73
79 int id;
80 bool c45;
81 uint8_t addr;
83 void *extra;
84};
85
92 int (*init)(struct no_os_mdio_desc **, struct no_os_mdio_init_param *);
94 int (*write)(struct no_os_mdio_desc *, uint32_t, uint16_t);
96 int (*read)(struct no_os_mdio_desc *, uint32_t, uint16_t *);
98 int (*remove)(struct no_os_mdio_desc *);
99};
100
101int no_os_mdio_init(struct no_os_mdio_desc **desc,
102 struct no_os_mdio_init_param *param);
103int no_os_mdio_remove(struct no_os_mdio_desc *desc);
104int no_os_mdio_write(struct no_os_mdio_desc *desc, uint32_t reg, uint16_t val);
105int no_os_mdio_read(struct no_os_mdio_desc *desc, uint32_t reg, uint16_t *val);
106
107#endif
int no_os_mdio_remove(struct no_os_mdio_desc *desc)
Free the resources allocated by no_os_mdio_init().
Definition no_os_mdio.c:70
int no_os_mdio_write(struct no_os_mdio_desc *desc, uint32_t reg, uint16_t val)
Write a register using MDIO.
Definition no_os_mdio.c:90
int no_os_mdio_read(struct no_os_mdio_desc *desc, uint32_t reg, uint16_t *val)
Read a register using MDIO.
Definition no_os_mdio.c:110
int no_os_mdio_init(struct no_os_mdio_desc **desc, struct no_os_mdio_init_param *param)
Initialize the MDIO interface.
Definition no_os_mdio.c:42
Header file of utility functions.
MDIO device descriptor created with no_os_mdio_init().
Definition no_os_mdio.h:78
uint8_t addr
Definition no_os_mdio.h:81
bool c45
Definition no_os_mdio.h:80
int id
Definition no_os_mdio.h:79
void * extra
Definition no_os_mdio.h:83
struct no_os_mdio_ops * ops
Definition no_os_mdio.h:82
Parameters for an MDIO slave.
Definition no_os_mdio.h:60
struct no_os_mdio_ops * ops
Definition no_os_mdio.h:69
uint8_t addr
Definition no_os_mdio.h:67
int id
Definition no_os_mdio.h:62
bool c45
Definition no_os_mdio.h:65
void * extra
Definition no_os_mdio.h:71
Collection of MDIO ops that point to specific implementations.
Definition no_os_mdio.h:90
int(* read)(struct no_os_mdio_desc *, uint32_t, uint16_t *)
Definition no_os_mdio.h:96
int(* write)(struct no_os_mdio_desc *, uint32_t, uint16_t)
Definition no_os_mdio.h:94
int(* remove)(struct no_os_mdio_desc *)
Definition no_os_mdio.h:98
int(* init)(struct no_os_mdio_desc **, struct no_os_mdio_init_param *)
Definition no_os_mdio.h:92