1 From 5f62951fba63a9f9cfff564209426bdea5fcc371 Mon Sep 17 00:00:00 2001
2 From: Alex Marginean <alexandru.marginean@nxp.com>
3 Date: Tue, 27 Aug 2019 15:16:56 +0300
4 Subject: [PATCH] drivers: net: phy: aquantia: enable AQR112 and AQR412
6 Adds support for AQR112 and AQR412 which is mostly based on existing code
7 with the addition of code configuring the protocol on system side.
8 This allows changing the system side protocol without having to deploy a
9 different firmware on the PHY.
11 Signed-off-by: Alex Marginean <alexandru.marginean@nxp.com>
13 drivers/net/phy/aquantia_main.c | 88 +++++++++++++++++++++++++++++++++++++++++
14 1 file changed, 88 insertions(+)
16 --- a/drivers/net/phy/aquantia_main.c
17 +++ b/drivers/net/phy/aquantia_main.c
19 #define PHY_ID_AQR107 0x03a1b4e0
20 #define PHY_ID_AQCS109 0x03a1b5c2
21 #define PHY_ID_AQR405 0x03a1b4b0
22 +#define PHY_ID_AQR112 0x03a1b662
23 +#define PHY_ID_AQR412 0x03a1b712
25 #define MDIO_PHYXS_VEND_IF_STATUS 0xe812
26 #define MDIO_PHYXS_VEND_IF_STATUS_TYPE_MASK GENMASK(7, 3)
28 #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL2 BIT(1)
29 #define VEND1_GLOBAL_INT_VEND_MASK_GLOBAL3 BIT(0)
31 +/* registers in MDIO_MMD_VEND1 region */
32 +#define AQUANTIA_VND1_GLOBAL_SC 0x000
33 +#define AQUANTIA_VND1_GLOBAL_SC_LP BIT(0xb)
35 +/* global start rate, the protocol associated with this speed is used by default
38 +#define AQUANTIA_VND1_GSTART_RATE 0x31a
39 +#define AQUANTIA_VND1_GSTART_RATE_OFF 0
40 +#define AQUANTIA_VND1_GSTART_RATE_100M 1
41 +#define AQUANTIA_VND1_GSTART_RATE_1G 2
42 +#define AQUANTIA_VND1_GSTART_RATE_10G 3
43 +#define AQUANTIA_VND1_GSTART_RATE_2_5G 4
44 +#define AQUANTIA_VND1_GSTART_RATE_5G 5
46 +/* SYSCFG registers for 100M, 1G, 2.5G, 5G, 10G */
47 +#define AQUANTIA_VND1_GSYSCFG_BASE 0x31b
48 +#define AQUANTIA_VND1_GSYSCFG_100M 0
49 +#define AQUANTIA_VND1_GSYSCFG_1G 1
50 +#define AQUANTIA_VND1_GSYSCFG_2_5G 2
51 +#define AQUANTIA_VND1_GSYSCFG_5G 3
52 +#define AQUANTIA_VND1_GSYSCFG_10G 4
54 struct aqr107_hw_stat {
57 @@ -241,6 +266,51 @@ static int aqr_config_aneg(struct phy_de
58 return genphy_c45_check_and_restart_aneg(phydev, changed);
65 +} aquantia_syscfg[PHY_INTERFACE_MODE_MAX] = {
66 + [PHY_INTERFACE_MODE_SGMII] = {0x04b, AQUANTIA_VND1_GSYSCFG_1G,
67 + AQUANTIA_VND1_GSTART_RATE_1G},
68 + [PHY_INTERFACE_MODE_2500BASEX] = {0x144, AQUANTIA_VND1_GSYSCFG_2_5G,
69 + AQUANTIA_VND1_GSTART_RATE_2_5G},
70 + [PHY_INTERFACE_MODE_XGMII] = {0x100, AQUANTIA_VND1_GSYSCFG_10G,
71 + AQUANTIA_VND1_GSTART_RATE_10G},
72 + [PHY_INTERFACE_MODE_USXGMII] = {0x080, AQUANTIA_VND1_GSYSCFG_10G,
73 + AQUANTIA_VND1_GSTART_RATE_10G},
76 +/* Sets up protocol on system side before calling aqr_config_aneg */
77 +static int aqr_config_aneg_set_prot(struct phy_device *phydev)
79 + int if_type = phydev->interface;
82 + if (!aquantia_syscfg[if_type].cnt)
85 + /* set PHY in low power mode so we can configure protocols */
86 + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC,
87 + AQUANTIA_VND1_GLOBAL_SC_LP);
90 + /* set the default rate to enable the SI link */
91 + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GSTART_RATE,
92 + aquantia_syscfg[if_type].start_rate);
94 + for (i = 0; i <= aquantia_syscfg[if_type].cnt; i++)
95 + phy_write_mmd(phydev, MDIO_MMD_VEND1,
96 + AQUANTIA_VND1_GSYSCFG_BASE + i,
97 + aquantia_syscfg[if_type].syscfg);
99 + /* wake PHY back up */
100 + phy_write_mmd(phydev, MDIO_MMD_VEND1, AQUANTIA_VND1_GLOBAL_SC, 0);
103 + return aqr_config_aneg(phydev);
106 static int aqr_config_intr(struct phy_device *phydev)
108 bool en = phydev->interrupts == PHY_INTERRUPT_ENABLED;
109 @@ -682,6 +752,22 @@ static struct phy_driver aqr_driver[] =
110 .ack_interrupt = aqr_ack_interrupt,
111 .read_status = aqr_read_status,
114 + PHY_ID_MATCH_MODEL(PHY_ID_AQR112),
115 + .name = "Aquantia AQR112",
116 + .config_aneg = aqr_config_aneg_set_prot,
117 + .config_intr = aqr_config_intr,
118 + .ack_interrupt = aqr_ack_interrupt,
119 + .read_status = aqr_read_status,
122 + PHY_ID_MATCH_MODEL(PHY_ID_AQR412),
123 + .name = "Aquantia AQR412",
124 + .config_aneg = aqr_config_aneg_set_prot,
125 + .config_intr = aqr_config_intr,
126 + .ack_interrupt = aqr_ack_interrupt,
127 + .read_status = aqr_read_status,
131 module_phy_driver(aqr_driver);
132 @@ -694,6 +780,8 @@ static struct mdio_device_id __maybe_unu
133 { PHY_ID_MATCH_MODEL(PHY_ID_AQR107) },
134 { PHY_ID_MATCH_MODEL(PHY_ID_AQCS109) },
135 { PHY_ID_MATCH_MODEL(PHY_ID_AQR405) },
136 + { PHY_ID_MATCH_MODEL(PHY_ID_AQR112) },
137 + { PHY_ID_MATCH_MODEL(PHY_ID_AQR412) },