xref: /openbmc/u-boot/drivers/net/phy/atheros.c (revision 3bddafaa)
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 	return 0;
17 }
18 
19 static int ar8035_config(struct phy_device *phydev)
20 {
21 	int regval;
22 
23 	phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x0007);
24 	phy_write(phydev, MDIO_DEVAD_NONE, 0xe, 0x8016);
25 	phy_write(phydev, MDIO_DEVAD_NONE, 0xd, 0x4007);
26 	regval = phy_read(phydev, MDIO_DEVAD_NONE, 0xe);
27 	phy_write(phydev, MDIO_DEVAD_NONE, 0xe, (regval|0x0018));
28 
29 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x05);
30 	regval = phy_read(phydev, MDIO_DEVAD_NONE, 0x1e);
31 	phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, (regval|0x0100));
32 
33 	genphy_config_aneg(phydev);
34 
35 	phy_reset(phydev);
36 
37 	return 0;
38 }
39 
40 static struct phy_driver AR8021_driver =  {
41 	.name = "AR8021",
42 	.uid = 0x4dd040,
43 	.mask = 0xfffff0,
44 	.features = PHY_GBIT_FEATURES,
45 	.config = ar8021_config,
46 	.startup = genphy_startup,
47 	.shutdown = genphy_shutdown,
48 };
49 
50 static struct phy_driver AR8031_driver =  {
51 	.name = "AR8031",
52 	.uid = 0x4dd074,
53 	.mask = 0xfffff0,
54 	.features = PHY_GBIT_FEATURES,
55 	.config = genphy_config,
56 	.startup = genphy_startup,
57 	.shutdown = genphy_shutdown,
58 };
59 
60 static struct phy_driver AR8035_driver =  {
61 	.name = "AR8035",
62 	.uid = 0x4dd072,
63 	.mask = 0x4fffff,
64 	.features = PHY_GBIT_FEATURES,
65 	.config = ar8035_config,
66 	.startup = genphy_startup,
67 	.shutdown = genphy_shutdown,
68 };
69 
70 int phy_atheros_init(void)
71 {
72 	phy_register(&AR8021_driver);
73 	phy_register(&AR8031_driver);
74 	phy_register(&AR8035_driver);
75 
76 	return 0;
77 }
78