]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - drivers/net/phy/micrel.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[karo-tx-uboot.git] / drivers / net / phy / micrel.c
index 2a8b6cb9479c716dd61ff8046dd38c27729fb77d..a7450f832646d6d3e85a4f3026659611c83f0245 100644 (file)
@@ -1,25 +1,11 @@
 /*
  * Micrel PHY drivers
  *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  *
  * Copyright 2010-2011 Freescale Semiconductor, Inc.
  * author Andy Fleming
  * (C) 2012 NetModule AG, David Andrey, added KSZ9031
- *
  */
 #include <config.h>
 #include <common.h>
@@ -148,9 +134,43 @@ static struct phy_driver ksz9021_driver = {
 };
 #endif
 
-/*
+/**
  * KSZ9031
  */
+/* PHY Registers */
+#define MII_KSZ9031_MMD_ACCES_CTRL     0x0d
+#define MII_KSZ9031_MMD_REG_DATA       0x0e
+
+/* Accessors to extended registers*/
+int ksz9031_phy_extended_write(struct phy_device *phydev,
+                              int devaddr, int regnum, u16 mode, u16 val)
+{
+       /*select register addr for mmd*/
+       phy_write(phydev, MDIO_DEVAD_NONE,
+                 MII_KSZ9031_MMD_ACCES_CTRL, devaddr);
+       /*select register for mmd*/
+       phy_write(phydev, MDIO_DEVAD_NONE,
+                 MII_KSZ9031_MMD_REG_DATA, regnum);
+       /*setup mode*/
+       phy_write(phydev, MDIO_DEVAD_NONE,
+                 MII_KSZ9031_MMD_ACCES_CTRL, (mode | devaddr));
+       /*write the value*/
+       return  phy_write(phydev, MDIO_DEVAD_NONE,
+               MII_KSZ9031_MMD_REG_DATA, val);
+}
+
+int ksz9031_phy_extended_read(struct phy_device *phydev, int devaddr,
+                             int regnum, u16 mode)
+{
+       phy_write(phydev, MDIO_DEVAD_NONE,
+                 MII_KSZ9031_MMD_ACCES_CTRL, devaddr);
+       phy_write(phydev, MDIO_DEVAD_NONE,
+                 MII_KSZ9031_MMD_REG_DATA, regnum);
+       phy_write(phydev, MDIO_DEVAD_NONE,
+                 MII_KSZ9031_MMD_ACCES_CTRL, (devaddr | mode));
+       return phy_read(phydev, MDIO_DEVAD_NONE, MII_KSZ9031_MMD_REG_DATA);
+}
+
 static struct phy_driver ksz9031_driver = {
        .name = "Micrel ksz9031",
        .uid  = 0x221620,