xref: /openbmc/u-boot/drivers/net/phy/atheros.c (revision 08592136)
1 /*
2  * Atheros PHY drivers
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  *
6  * Copyright 2011, 2013 Freescale Semiconductor, Inc.
7  * author Andy Fleming
8  */
9 #include <phy.h>
10 
11 static int ar8021_config(struct phy_device *phydev)
12 {
13 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
14 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x3D47);
15 
16 	phydev->supported = phydev->drv->features;
17 	return 0;
18 }
19 
20 static int ar8035_config(struct phy_device *phydev)
21 {
22 	int regval;
23 
24 	phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x0007);
25 	phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016);
26 	phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007);
27 	regval = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
28 	phy_write(phydev, MDIO_DEVAD_NONE, 0xe, (regval|0x0018));
29 
30 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
31 	regval = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
32 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, (regval|0x0100));
33 
34 	phydev->supported = phydev->drv->features;
35 
36 	genphy_config_aneg(phydev);
37 	genphy_restart_aneg(phydev);
38 
39 	return 0;
40 }
41 
42 static struct phy_driver AR8021_driver =  {
43 	.name = "AR8021",
44 	.uid = 0x4dd040,
45 	.mask = 0x4ffff0,
46 	.features = PHY_GBIT_FEATURES,
47 	.config = ar8021_config,
48 	.startup = genphy_startup,
49 	.shutdown = genphy_shutdown,
50 };
51 
52 static struct phy_driver AR8031_driver =  {
53 	.name = "AR8031/AR8033",
54 	.uid = 0x4dd074,
55 	.mask = 0xffffffef,
56 	.features = PHY_GBIT_FEATURES,
57 	.config = ar8035_config,
58 	.startup = genphy_startup,
59 	.shutdown = genphy_shutdown,
60 };
61 
62 static struct phy_driver AR8035_driver =  {
63 	.name = "AR8035",
64 	.uid = 0x4dd072,
65 	.mask = 0xffffffef,
66 	.features = PHY_GBIT_FEATURES,
67 	.config = ar8035_config,
68 	.startup = genphy_startup,
69 	.shutdown = genphy_shutdown,
70 };
71 
72 int phy_atheros_init(void)
73 {
74 	phy_register(&AR8021_driver);
75 	phy_register(&AR8031_driver);
76 	phy_register(&AR8035_driver);
77 
78 	return 0;
79 }
80