1/*
2 * MDIO used to interact with the PHY when using GMII/MII
3 */
4#ifndef _TITAN_MDIO_H
5#define _TITAN_MDIO_H
6
7#include <linux/netdevice.h>
8#include <linux/workqueue.h>
9#include <linux/delay.h>
10#include "titan_ge.h"
11
12
13#define	TITAN_GE_MDIO_ERROR	(-9000)
14#define	TITAN_GE_MDIO_GOOD	0
15
16#define	TITAN_GE_MDIO_BASE		titan_ge_base
17
18#define	TITAN_GE_MDIO_READ(offset)	\
19	*(volatile u32 *)(titan_ge_base + (offset))
20
21#define	TITAN_GE_MDIO_WRITE(offset, data)	\
22	*(volatile u32 *)(titan_ge_base + (offset)) = (data)
23
24
25/* GMII specific registers */
26#define	TITAN_GE_MARVEL_PHY_ID		0x00
27#define	TITAN_PHY_AUTONEG_ADV		0x04
28#define	TITAN_PHY_LP_ABILITY		0x05
29#define	TITAN_GE_MDIO_MII_CTRL		0x09
30#define	TITAN_GE_MDIO_MII_EXTENDED	0x0f
31#define	TITAN_GE_MDIO_PHY_CTRL		0x10
32#define	TITAN_GE_MDIO_PHY_STATUS	0x11
33#define	TITAN_GE_MDIO_PHY_IE		0x12
34#define	TITAN_GE_MDIO_PHY_IS		0x13
35#define	TITAN_GE_MDIO_PHY_LED		0x18
36#define	TITAN_GE_MDIO_PHY_LED_OVER	0x19
37#define	PHY_ANEG_TIME_WAIT		45	/* 45 seconds wait time */
38
39/*
40 * MDIO Config Structure
41 */
42typedef struct {
43	unsigned int		clka;
44	int			mdio_spre;
45	int			mdio_mode;
46} titan_ge_mdio_config;
47
48/*
49 * Function Prototypes
50 */
51int titan_ge_mdio_setup(titan_ge_mdio_config *);
52int titan_ge_mdio_inaddrs(int, int);
53int titan_ge_mdio_read(int, int, unsigned int *);
54int titan_ge_mdio_write(int, int, unsigned int);
55
56#endif /* _TITAN_MDIO_H */
57