blob: a1d97ce0565bc52dd3d46ebd6b15028e2119af57 [file] [log] [blame]
developer5e9bfbf2023-09-01 13:53:52 +08001/* SPDX-License-Identifier: GPL-2.0 */
2/*************************************************
3 * FILE NAME: air_en8811h_api.h
4 * PURPOSE:
5 * EN8811H PHY Driver for Linux
6 * NOTES:
7 *
8 * Copyright (C) 2023 Airoha Technology Corp.
9 *************************************************/
10#ifndef __EN8811H_API_H
11#define __EN8811H_API_H
12#include <linux/version.h>
13
14#if (KERNEL_VERSION(4, 5, 0) > LINUX_VERSION_CODE)
15#define phydev_mdio_bus(_dev) (_dev->bus)
16#define phydev_addr(_dev) (_dev->addr)
17#define phydev_dev(_dev) (&_dev->dev)
18#else
19#define phydev_mdio_bus(_dev) (_dev->mdio.bus)
20#define phydev_addr(_dev) (_dev->mdio.addr)
21#define phydev_dev(_dev) (&_dev->mdio.dev)
22#endif
23
24#define BUFFER_LENGTH 512
25
26#define DEBUGFS_COUNTER "counter"
27#define DEBUGFS_DRIVER_INFO "drvinfo"
28#define DEBUGFS_PORT_MODE "port_mode"
29#define DEBUGFS_BUCKPBUS_OP "buckpbus_op"
30#define DEBUGFS_PBUS_OP "pbus_op"
31#define DEBUGFS_POLARITY "polarity"
32#define DEBUGFS_LINK_STATUS "link_status"
33#define DEBUGFS_DBG_REG_SHOW "dbg_regs_show"
34
35enum air_port_mode {
36 AIR_PORT_MODE_FORCE_100,
37 AIR_PORT_MODE_FORCE_1000,
38 AIR_PORT_MODE_FORCE_2500,
39 AIR_PORT_MODE_AUTONEGO,
40 AIR_PORT_MODE_POWER_DOWN,
41 AIR_PORT_MODE_POWER_UP,
42 AIR_PORT_MODE_FC_UNSUPPORT,
43 AIR_PORT_MODE_FC_SUPPORT,
44 AIR_PORT_MODE_FC_DIS,
45 AIR_PORT_MODE_FC_EN,
46 AIR_PORT_MODE_LAST = 0xFF,
47};
48
49enum air_polarity {
50 AIR_POL_TX_REV_RX_NOR,
51 AIR_POL_TX_NOR_RX_NOR,
52 AIR_POL_TX_REV_RX_REV,
53 AIR_POL_TX_NOR_RX_REV,
54 AIR_POL_TX_NOR_RX_LAST = 0xff,
55};
56
57/* Link mode bit indices */
58enum air_link_mode_bit {
59 AIR_LINK_MODE_10baseT_Half_BIT = 0,
60 AIR_LINK_MODE_10baseT_Full_BIT = 1,
61 AIR_LINK_MODE_100baseT_Half_BIT = 2,
62 AIR_LINK_MODE_100baseT_Full_BIT = 3,
63 AIR_LINK_MODE_1000baseT_Full_BIT = 4,
64 AIR_LINK_MODE_2500baseT_Full_BIT = 5,
65};
66
67#ifndef unlikely
68# define unlikely(x) (x)
69#endif
70int air_pbus_reg_write(struct phy_device *phydev,
71 unsigned int pbus_address, unsigned int pbus_data);
72int air_mii_cl22_write(struct mii_bus *ebus, int addr,
73 unsigned int phy_register, unsigned int write_data);
74int air_mii_cl22_read(struct mii_bus *ebus,
75 int addr, unsigned int phy_register);
76int air_mii_cl45_read(struct phy_device *phydev, int devad, u16 reg);
77int air_mii_cl45_write(struct phy_device *phydev,
78 int devad, u16 reg, u16 write_data);
79unsigned int air_buckpbus_reg_read(struct phy_device *phydev,
80 unsigned int pbus_address);
81int air_buckpbus_reg_write(struct phy_device *phydev,
82 unsigned int pbus_address, unsigned int pbus_data);
83#ifdef CONFIG_AIROHA_EN8811H_PHY_DEBUGFS
84int airphy_debugfs_init(struct phy_device *phydev);
85void air_debugfs_remove(struct phy_device *phydev);
86#endif /*CONFIG_AIROHA_EN8811H_PHY_DEBUGFS*/
87#endif /* End of __EN8811H_API_H */