-
Notifications
You must be signed in to change notification settings - Fork 0
/
chry_phy.h
76 lines (64 loc) · 1.82 KB
/
chry_phy.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (c) 2024, sakumisu
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef CHRY_PHY_H
#define CHRY_PHY_H
#include <stdbool.h>
#include <string.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include "chry_mii.h"
struct chry_phy_config {
bool loopback;
bool auto_negotiation;
bool duplex;
uint16_t speed;
};
struct chry_phy_status {
bool link;
bool duplex;
uint16_t speed;
};
struct chry_phy_device;
struct chry_phy_driver {
char *phy_name;
char *phy_desc;
uint32_t phy_id;
uint32_t phy_id_mask;
void (*phy_init)(struct chry_phy_device *phydev, struct chry_phy_config *config);
void (*phy_get_status)(struct chry_phy_device *phydev, struct chry_phy_status *status);
};
struct chry_phy_support {
uint32_t support_100base_t4 : 1;
uint32_t support_1000base_tx_full : 1;
uint32_t support_1000base_tx_half : 1;
uint32_t support_100base_tx_full : 1;
uint32_t support_100base_tx_half : 1;
uint32_t support_10base_tx_full : 1;
uint32_t support_10base_tx_half : 1;
uint32_t support_asym_pause : 1;
uint32_t support_pause : 1;
uint32_t support_autoeng : 1;
uint32_t reserved : 22;
};
struct chry_phy_device {
uint16_t phy_addr;
uint32_t phy_id;
struct chry_phy_support support;
const struct chry_phy_driver *driver;
void (*mdio_write)(struct chry_phy_device *phydev, uint16_t phy_addr, uint16_t regnum, uint16_t val);
uint16_t (*mdio_read)(struct chry_phy_device *phydev, uint16_t phy_addr, uint16_t regnum);
void *user_data;
};
#ifdef __cplusplus
extern "C" {
#endif
int chry_phy_init(struct chry_phy_device *phydev, struct chry_phy_config *config);
void chry_phy_get_status(struct chry_phy_device *phydev, struct chry_phy_status *status);
#ifdef __cplusplus
}
#endif
#endif