no-OS
max24287.h
Go to the documentation of this file.
1 #ifndef _MAX24287_H_
2 #define _MAX24287_H_
3 
4 #include <stdint.h>
5 #include "no_os_util.h"
6 #include "no_os_mdio.h"
7 
8 #define MAX24287_REG(page, addr) (((page) << 5) | ((addr) & 0x1f))
9 #define MAX24287_PAGE(addr) ((addr) >> 5)
10 #define MAX24287_ADDR(addr) ((addr) & 0x1f)
11 
12 #define MAX24287_BMCR 0
13 #define MAX24287_DP_RST_MASK NO_OS_BIT(15)
14 #define MAX24287_AN_EN_MASK NO_OS_BIT(12)
15 #define MAX24287_AN_START_MASK NO_OS_BIT(9)
16 
17 #define MAX24287_BMSR 1
18 #define MAX24287_LINK_ST_MASK NO_OS_BIT(2)
19 
20 #define MAX24287_ID1 2
21 #define MAX24287_ID2 3
22 
23 #define MAX24287_AN_ADV 4
24 #define MAX24287_AN_ADV_W_MASK NO_OS_BIT(0)
25 #define MAX24287_LK_MASK NO_OS_BIT(15)
26 #define MAX24287_DPLX_MASK NO_OS_BIT(12)
27 #define MAX24287_SPD_MASK NO_OS_GENMASK(11, 10)
28 
29 #define MAX24287_AN_RX 5
30 
31 #define MAX24287_AN_EXP 6
32 #define MAX24287_AN_RX_PAGE NO_OS_BIT(1)
33 
34 #define MAX24287_EXT_STAT 15
35 #define MAX24287_JIT_DIAG 16
36 
37 #define MAX24287_PCSCR 17
38 #define MAX24287_WD_DIS_MASK NO_OS_BIT(6)
39 #define MAX24287_BASEX_MASK NO_OS_BIT(4)
40 #define MAX24287_EN_CDET_MASK NO_OS_BIT(0)
41 
42 #define MAX24287_GMIICR 18
43 #define MAX24287_GMIICR_W_MASK NO_OS_BIT(7)
44 #define MAX24287_GMIICR_SPD_MASK NO_OS_GENMASK(15, 14)
45 #define MAX24287_GMIICR_DTE_DCE_MASK NO_OS_BIT(12)
46 #define MAX24287_GMIICR_DDR_MASK NO_OS_BIT(11)
47 #define MAX24287_GMIICR_TXCLK_EN_MASK NO_OS_BIT(10)
48 
49 #define MAX24287_CR 19
50 
51 #define MAX24287_IR 20
52 #define MAX24287_PAGE_IE NO_OS_BIT(10)
53 
54 #define MAX24287_ID MAX24287_REG(1, 16)
55 
56 #define MAX24287_GPIOCR1 MAX24287_REG(1, 17)
57 #define MAX24287_RST_MASK NO_OS_BIT(15)
58 #define MAX24287_GPO1_SEL NO_OS_GENMASK(14, 12)
59 #define MAX24287_GPO2_SEL NO_OS_GENMASK(11, 9)
60 #define MAX24287_GPIO1_SEL NO_OS_GENMASK(8, 6)
61 #define MAX24287_GPIO2_SEL NO_OS_GENMASK(5, 3)
62 #define MAX24287_GPIO3_SEL NO_OS_GENMASK(2, 0)
63 
64 #define MAX24287_GPIOCR2 MAX24287_REG(1, 18)
65 #define MAX24287_GPIOSR MAX24287_REG(1, 19)
66 
67 #define MAX24287_PTPCR1 MAX24287_REG(2, 16)
68 #define MAX24287_PTPCR1_W_MASK NO_OS_BIT(14)
69 #define MAX24287_PLL_PWDN_MASK NO_OS_BIT(5)
70 #define MAX24287_TX_PWDN_MASK NO_OS_BIT(3)
71 #define MAX24287_RX_PWDN_MASK NO_OS_BIT(2)
72 
73 #define MAX24287_PAGESEL 31
74 #define MAX24287_PAGE_MASK NO_OS_GENMASK(1, 0)
75 
82 };
83 
87 };
88 
98 };
99 
107 };
108 
112 };
113 
114 int max24287_init(struct max24287_desc **dev,
115  struct max24287_init_param *param);
116 int max24287_remove(struct max24287_desc *dev);
117 int max24287_write(struct max24287_desc *dev, uint8_t addr, uint16_t val);
118 int max24287_read(struct max24287_desc *dev, uint8_t addr, uint16_t *val);
119 int max24287_write_bits(struct max24287_desc *dev, uint8_t addr, uint16_t val,
120  uint16_t bitmask);
121 int max24287_hard_reset(struct max24287_desc *dev);
122 int max24287_soft_reset(struct max24287_desc *dev);
124  enum max24287_parallel par, enum max24287_speed speed);
126  enum max24287_parallel *par, enum max24287_speed *speed);
127 int max24287_config_serial(struct max24287_desc *dev, enum max24287_serial ser,
128  enum max24287_speed speed);
130  enum max24287_serial *ser, enum max24287_speed *speed);
131 int max24287_config_link(struct max24287_desc *dev, bool up);
132 bool max24287_link_is_up(struct max24287_desc *dev);
133 void max24287_regmap(struct max24287_desc *dev);
134 
135 #endif
MAX24287_JIT_DIAG
#define MAX24287_JIT_DIAG
Definition: max24287.h:35
MAX24287_100_HALFDUPLEX
@ MAX24287_100_HALFDUPLEX
Definition: max24287.h:92
max24287_link_is_up
bool max24287_link_is_up(struct max24287_desc *dev)
Definition: max24287.c:258
MAX24287_AN_RX
#define MAX24287_AN_RX
Definition: max24287.h:29
no_os_alloc.h
MAX24287_BMSR
#define MAX24287_BMSR
Definition: max24287.h:17
no_os_gpio_init_param
Structure holding the parameters for GPIO initialization.
Definition: no_os_gpio.h:79
no_os_mdio_init_param
Parameters for an MDIO slave.
Definition: no_os_mdio.h:60
no_os_mdio_desc::addr
uint8_t addr
Definition: no_os_mdio.h:81
MAX24287_1250_FULLDUPLEX
@ MAX24287_1250_FULLDUPLEX
Definition: max24287.h:97
max24287_get_config_parallel
int max24287_get_config_parallel(struct max24287_desc *dev, enum max24287_parallel *par, enum max24287_speed *speed)
Definition: max24287.c:183
max24287_link_is_up
bool max24287_link_is_up(struct max24287_desc *dev)
Definition: max24287.c:258
max24287_config_link
int max24287_config_link(struct max24287_desc *dev, bool up)
Definition: max24287.c:249
max24287_get_config_parallel
int max24287_get_config_parallel(struct max24287_desc *dev, enum max24287_parallel *par, enum max24287_speed *speed)
Definition: max24287.c:183
MAX24287_GMIICR
#define MAX24287_GMIICR
Definition: max24287.h:42
MAX24287_100_FULLDUPLEX
@ MAX24287_100_FULLDUPLEX
Definition: max24287.h:93
max24287_desc::mdio
struct no_os_mdio_desc * mdio
Definition: max24287.h:111
max24287_read
int max24287_read(struct max24287_desc *dev, uint8_t addr, uint16_t *val)
Definition: max24287.c:129
MAX24287_SGMII
@ MAX24287_SGMII
Definition: max24287.h:85
max24287_desc::reset_gpio
struct no_os_gpio_desc * reset_gpio
Definition: max24287.h:110
no_os_delay.h
Header file of Delay functions.
max24287_write
int max24287_write(struct max24287_desc *dev, uint8_t addr, uint16_t val)
Definition: max24287.c:112
max24287_config_serial
int max24287_config_serial(struct max24287_desc *dev, enum max24287_serial ser, enum max24287_speed speed)
Definition: max24287.c:200
MAX24287_GMIICR_SPD_MASK
#define MAX24287_GMIICR_SPD_MASK
Definition: max24287.h:44
max24287_remove
int max24287_remove(struct max24287_desc *dev)
MAX24287_TBI
@ MAX24287_TBI
Definition: max24287.h:77
max24287_init_param::serial
enum max24287_serial serial
Definition: max24287.h:105
MAX24287_1000_FULLDUPLEX
@ MAX24287_1000_FULLDUPLEX
Definition: max24287.h:95
max24287_write
int max24287_write(struct max24287_desc *dev, uint8_t addr, uint16_t val)
Definition: max24287.c:112
NO_OS_GPIO_HIGH
@ NO_OS_GPIO_HIGH
Definition: no_os_gpio.h:117
max24287_speed
max24287_speed
Definition: max24287.h:89
MAX24287_GMII
@ MAX24287_GMII
Definition: max24287.h:79
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
MAX24287_1000BASEX
@ MAX24287_1000BASEX
Definition: max24287.h:86
MAX24287_10_HALFDUPLEX
@ MAX24287_10_HALFDUPLEX
Definition: max24287.h:90
NO_OS_GPIO_LOW
@ NO_OS_GPIO_LOW
Definition: no_os_gpio.h:115
MAX24287_RST_MASK
#define MAX24287_RST_MASK
Definition: max24287.h:57
no_os_mdelay
void no_os_mdelay(uint32_t msecs)
Wait until msecs milliseconds passed.
Definition: aducm3029_delay.c:126
no_os_field_prep
uint32_t no_os_field_prep(uint32_t mask, uint32_t val)
max24287_read
int max24287_read(struct max24287_desc *dev, uint8_t addr, uint16_t *val)
Definition: max24287.c:129
MAX24287_GPIOCR1
#define MAX24287_GPIOCR1
Definition: max24287.h:56
no_os_mdio_init
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
MAX24287_RGMII
@ MAX24287_RGMII
Definition: max24287.h:80
max24287_init_param::parallel
enum max24287_parallel parallel
Definition: max24287.h:103
no_os_mdio_write
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
MAX24287_LK_MASK
#define MAX24287_LK_MASK
Definition: max24287.h:25
MAX24287_10_FULLDUPLEX
@ MAX24287_10_FULLDUPLEX
Definition: max24287.h:91
max24287_regmap
void max24287_regmap(struct max24287_desc *dev)
Definition: max24287.c:271
max24287_soft_reset
int max24287_soft_reset(struct max24287_desc *dev)
Definition: max24287.c:81
max24287_parallel
max24287_parallel
Definition: max24287.h:76
MAX24287_RTBI
@ MAX24287_RTBI
Definition: max24287.h:78
MAX24287_PAGE
#define MAX24287_PAGE(addr)
Definition: max24287.h:9
no_os_mdio.h
Header file for MDIO interface driver.
max24287_init_param
Definition: max24287.h:100
no_os_gpio_remove
int32_t no_os_gpio_remove(struct no_os_gpio_desc *desc)
Free the resources allocated by no_os_gpio_get().
Definition: no_os_gpio.c:104
MAX24287_AN_ADV
#define MAX24287_AN_ADV
Definition: max24287.h:23
max24287_init
int max24287_init(struct max24287_desc **dev, struct max24287_init_param *param)
Definition: max24287.c:9
MAX24287_ADDR
#define MAX24287_ADDR(addr)
Definition: max24287.h:10
max24287_init_param::reset_param
struct no_os_gpio_init_param * reset_param
Definition: max24287.h:101
max24287_hard_reset
int max24287_hard_reset(struct max24287_desc *dev)
Definition: max24287.c:95
MAX24287_ID
#define MAX24287_ID
Definition: max24287.h:54
MAX24287_ID1
#define MAX24287_ID1
Definition: max24287.h:20
max24287_config_parallel
int max24287_config_parallel(struct max24287_desc *dev, enum max24287_parallel par, enum max24287_speed speed)
Definition: max24287.c:162
no_os_gpio_desc
Structure holding the GPIO descriptor.
Definition: no_os_gpio.h:96
max24287_desc
Definition: max24287.h:109
no_os_mdio_remove
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
max24287_init
int max24287_init(struct max24287_desc **dev, struct max24287_init_param *param)
Definition: max24287.c:9
MAX24287_GPIOSR
#define MAX24287_GPIOSR
Definition: max24287.h:65
MAX24287_IR
#define MAX24287_IR
Definition: max24287.h:51
no_os_gpio_get
int32_t no_os_gpio_get(struct no_os_gpio_desc **desc, const struct no_os_gpio_init_param *param)
Obtain the GPIO decriptor.
Definition: no_os_gpio.c:49
no_os_field_get
uint32_t no_os_field_get(uint32_t mask, uint32_t word)
MAX24287_BMCR
#define MAX24287_BMCR
Definition: max24287.h:12
max24287_config_link
int max24287_config_link(struct max24287_desc *dev, bool up)
Definition: max24287.c:249
MAX24287_ID2
#define MAX24287_ID2
Definition: max24287.h:21
no_os_mdio_desc
MDIO device descriptor created with no_os_mdio_init().
Definition: no_os_mdio.h:78
MAX24287_LINK_ST_MASK
#define MAX24287_LINK_ST_MASK
Definition: max24287.h:18
MAX24287_DP_RST_MASK
#define MAX24287_DP_RST_MASK
Definition: max24287.h:13
max24287_regmap
void max24287_regmap(struct max24287_desc *dev)
Definition: max24287.c:271
max24287_soft_reset
int max24287_soft_reset(struct max24287_desc *dev)
Definition: max24287.c:81
MAX24287_EXT_STAT
#define MAX24287_EXT_STAT
Definition: max24287.h:34
MAX24287_BASEX_MASK
#define MAX24287_BASEX_MASK
Definition: max24287.h:39
max24287_config_parallel
int max24287_config_parallel(struct max24287_desc *dev, enum max24287_parallel par, enum max24287_speed speed)
Definition: max24287.c:162
MAX24287_AN_ADV_W_MASK
#define MAX24287_AN_ADV_W_MASK
Definition: max24287.h:24
no_os_udelay
void no_os_udelay(uint32_t usecs)
Wait until usecs microseconds passed.
Definition: aducm3029_delay.c:114
MAX24287_PTPCR1
#define MAX24287_PTPCR1
Definition: max24287.h:67
mdio_bitbang.h
Header file for MDIO implementation using gpio bit banging.
MAX24287_GMIICR_DDR_MASK
#define MAX24287_GMIICR_DDR_MASK
Definition: max24287.h:46
MAX24287_PTPCR1_W_MASK
#define MAX24287_PTPCR1_W_MASK
Definition: max24287.h:68
max24287_get_config_serial
int max24287_get_config_serial(struct max24287_desc *dev, enum max24287_serial *ser, enum max24287_speed *speed)
Definition: max24287.c:226
max24287_write_bits
int max24287_write_bits(struct max24287_desc *dev, uint8_t addr, uint16_t val, uint16_t bitmask)
Definition: max24287.c:146
MAX24287_PCSCR
#define MAX24287_PCSCR
Definition: max24287.h:37
MAX24287_CR
#define MAX24287_CR
Definition: max24287.h:49
max24287_hard_reset
int max24287_hard_reset(struct max24287_desc *dev)
Definition: max24287.c:95
no_os_mdio_read
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
MAX24287_GPIOCR2
#define MAX24287_GPIOCR2
Definition: max24287.h:64
MAX24287_1250_HALFDUPLEX
@ MAX24287_1250_HALFDUPLEX
Definition: max24287.h:96
max24287_get_config_serial
int max24287_get_config_serial(struct max24287_desc *dev, enum max24287_serial *ser, enum max24287_speed *speed)
Definition: max24287.c:226
MAX24287_GMIICR_W_MASK
#define MAX24287_GMIICR_W_MASK
Definition: max24287.h:43
max24287_write_bits
int max24287_write_bits(struct max24287_desc *dev, uint8_t addr, uint16_t val, uint16_t bitmask)
Definition: max24287.c:146
no_os_gpio.h
Header file of GPIO Interface.
max24287_init_param::serspeed
enum max24287_speed serspeed
Definition: max24287.h:106
max24287_init_param::mdio_param
struct no_os_mdio_init_param mdio_param
Definition: max24287.h:102
MAX24287_1000_HALFDUPLEX
@ MAX24287_1000_HALFDUPLEX
Definition: max24287.h:94
no_os_util.h
Header file of utility functions.
MAX24287_MII
@ MAX24287_MII
Definition: max24287.h:81
max24287.h
MAX24287_DPLX_MASK
#define MAX24287_DPLX_MASK
Definition: max24287.h:26
MAX24287_PAGESEL
#define MAX24287_PAGESEL
Definition: max24287.h:73
MAX24287_RX_PWDN_MASK
#define MAX24287_RX_PWDN_MASK
Definition: max24287.h:71
no_os_gpio_direction_output
int32_t no_os_gpio_direction_output(struct no_os_gpio_desc *desc, uint8_t value)
Enable the output direction of the specified GPIO.
Definition: no_os_gpio.c:147
max24287_serial
max24287_serial
Definition: max24287.h:84
MAX24287_SPD_MASK
#define MAX24287_SPD_MASK
Definition: max24287.h:27
errno.h
Error macro definition for ARM Compiler.
max24287_config_serial
int max24287_config_serial(struct max24287_desc *dev, enum max24287_serial ser, enum max24287_speed speed)
Definition: max24287.c:200
max24287_init_param::parspeed
enum max24287_speed parspeed
Definition: max24287.h:104