Skip to content

Commit be66fcc

Browse files
hkallweitdavem330
authored andcommitted
net: phy: meson-gxl: reuse functionality of the SMSC PHY driver
The Amlogic Meson internal PHY's have the same register layout as certain SMSC PHY's (also for non-c22-standard registers). This seems to be more than just coincidence. Apparently they also need the same workaround for EDPD mode (energy detect power down). Therefore let's reuse SMSC PHY driver functionality in the meson-gxl PHY driver. Tested with a G12A internal PHY. I don't have GXL test hw, therefore I replace only the callbacks that are identical in the SMSC PHY driver. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent a69e332 commit be66fcc

File tree

2 files changed

+9
-69
lines changed

2 files changed

+9
-69
lines changed

drivers/net/phy/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ config AMD_PHY
7070
config MESON_GXL_PHY
7171
tristate "Amlogic Meson GXL Internal PHY"
7272
depends on ARCH_MESON || COMPILE_TEST
73+
select SMSC_PHY
7374
help
7475
Currently has a driver for the Amlogic Meson GXL Internal PHY
7576

drivers/net/phy/meson-gxl.c

Lines changed: 8 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/phy.h>
1414
#include <linux/netdevice.h>
1515
#include <linux/bitfield.h>
16+
#include <linux/smscphy.h>
1617

1718
#define TSTCNTL 20
1819
#define TSTCNTL_READ BIT(15)
@@ -23,18 +24,6 @@
2324
#define TSTCNTL_WRITE_ADDRESS GENMASK(4, 0)
2425
#define TSTREAD1 21
2526
#define TSTWRITE 23
26-
#define INTSRC_FLAG 29
27-
#define INTSRC_ANEG_PR BIT(1)
28-
#define INTSRC_PARALLEL_FAULT BIT(2)
29-
#define INTSRC_ANEG_LP_ACK BIT(3)
30-
#define INTSRC_LINK_DOWN BIT(4)
31-
#define INTSRC_REMOTE_FAULT BIT(5)
32-
#define INTSRC_ANEG_COMPLETE BIT(6)
33-
#define INTSRC_ENERGY_DETECT BIT(7)
34-
#define INTSRC_MASK 30
35-
36-
#define INT_SOURCES (INTSRC_LINK_DOWN | INTSRC_ANEG_COMPLETE | \
37-
INTSRC_ENERGY_DETECT)
3827

3928
#define BANK_ANALOG_DSP 0
4029
#define BANK_WOL 1
@@ -195,59 +184,6 @@ static int meson_gxl_read_status(struct phy_device *phydev)
195184
return genphy_read_status(phydev);
196185
}
197186

198-
static int meson_gxl_ack_interrupt(struct phy_device *phydev)
199-
{
200-
int ret = phy_read(phydev, INTSRC_FLAG);
201-
202-
return ret < 0 ? ret : 0;
203-
}
204-
205-
static int meson_gxl_config_intr(struct phy_device *phydev)
206-
{
207-
int ret;
208-
209-
if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
210-
/* Ack any pending IRQ */
211-
ret = meson_gxl_ack_interrupt(phydev);
212-
if (ret)
213-
return ret;
214-
215-
ret = phy_write(phydev, INTSRC_MASK, INT_SOURCES);
216-
} else {
217-
ret = phy_write(phydev, INTSRC_MASK, 0);
218-
219-
/* Ack any pending IRQ */
220-
ret = meson_gxl_ack_interrupt(phydev);
221-
}
222-
223-
return ret;
224-
}
225-
226-
static irqreturn_t meson_gxl_handle_interrupt(struct phy_device *phydev)
227-
{
228-
int irq_status;
229-
230-
irq_status = phy_read(phydev, INTSRC_FLAG);
231-
if (irq_status < 0) {
232-
phy_error(phydev);
233-
return IRQ_NONE;
234-
}
235-
236-
irq_status &= INT_SOURCES;
237-
238-
if (irq_status == 0)
239-
return IRQ_NONE;
240-
241-
/* Aneg-complete interrupt is used for link-up detection */
242-
if (phydev->autoneg == AUTONEG_ENABLE &&
243-
irq_status == INTSRC_ENERGY_DETECT)
244-
return IRQ_HANDLED;
245-
246-
phy_trigger_machine(phydev);
247-
248-
return IRQ_HANDLED;
249-
}
250-
251187
static struct phy_driver meson_gxl_phy[] = {
252188
{
253189
PHY_ID_MATCH_EXACT(0x01814400),
@@ -257,8 +193,8 @@ static struct phy_driver meson_gxl_phy[] = {
257193
.soft_reset = genphy_soft_reset,
258194
.config_init = meson_gxl_config_init,
259195
.read_status = meson_gxl_read_status,
260-
.config_intr = meson_gxl_config_intr,
261-
.handle_interrupt = meson_gxl_handle_interrupt,
196+
.config_intr = smsc_phy_config_intr,
197+
.handle_interrupt = smsc_phy_handle_interrupt,
262198
.suspend = genphy_suspend,
263199
.resume = genphy_resume,
264200
.read_mmd = genphy_read_mmd_unsupported,
@@ -268,9 +204,12 @@ static struct phy_driver meson_gxl_phy[] = {
268204
.name = "Meson G12A Internal PHY",
269205
/* PHY_BASIC_FEATURES */
270206
.flags = PHY_IS_INTERNAL,
207+
.probe = smsc_phy_probe,
208+
.config_init = smsc_phy_config_init,
271209
.soft_reset = genphy_soft_reset,
272-
.config_intr = meson_gxl_config_intr,
273-
.handle_interrupt = meson_gxl_handle_interrupt,
210+
.read_status = lan87xx_read_status,
211+
.config_intr = smsc_phy_config_intr,
212+
.handle_interrupt = smsc_phy_handle_interrupt,
274213
.suspend = genphy_suspend,
275214
.resume = genphy_resume,
276215
.read_mmd = genphy_read_mmd_unsupported,

0 commit comments

Comments
 (0)