]> git.sur5r.net Git - u-boot/blobdiff - drivers/net/phy/miiphybb.c
Prepare v2018.07-rc2
[u-boot] / drivers / net / phy / miiphybb.c
index 2768c7584e2fa10be57d867a3befed7cdc162c1d..ba97a54c0676fd159a236254c38b9ec6bbce6340 100644 (file)
@@ -1,27 +1,10 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2009 Industrie Dial Face S.p.A.
  * Luigi 'Comio' Mantellini <luigi.mantellini@idf-hit.com>
  *
  * (C) Copyright 2001
  * Gerald Van Baren, Custom IDEAS, vanbaren@cideas.com.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * 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
  */
 
 /*
@@ -127,7 +110,7 @@ void bb_miiphy_init(void)
        int i;
 
        for (i = 0; i < bb_miiphy_buses_num; i++) {
-#if !defined(CONFIG_RELOC_FIXUP_WORKS)
+#if defined(CONFIG_NEEDS_MANUAL_RELOC)
                /* Relocate the hook pointers*/
                BB_MII_RELOCATE(bb_miiphy_buses[i].init, gd->reloc_off);
                BB_MII_RELOCATE(bb_miiphy_buses[i].mdio_active, gd->reloc_off);
@@ -143,7 +126,7 @@ void bb_miiphy_init(void)
        }
 }
 
-static inline struct bb_miiphy_bus *bb_miiphy_getbus(char *devname)
+static inline struct bb_miiphy_bus *bb_miiphy_getbus(const char *devname)
 {
 #ifdef CONFIG_BITBANGMII_MULTI
        int i;
@@ -246,24 +229,18 @@ static void miiphy_pre(struct bb_miiphy_bus *bus, char read,
  * Returns:
  *   0 on success
  */
-int bb_miiphy_read(char *devname, unsigned char addr,
-                  unsigned char reg, unsigned short *value)
+int bb_miiphy_read(struct mii_dev *miidev, int addr, int devad, int reg)
 {
-       short rdreg; /* register working value */
+       unsigned short rdreg; /* register working value */
        int v;
        int j; /* counter */
        struct bb_miiphy_bus *bus;
 
-       bus = bb_miiphy_getbus(devname);
+       bus = bb_miiphy_getbus(miidev->name);
        if (bus == NULL) {
                return -1;
        }
 
-       if (value == NULL) {
-               puts("NULL value pointer\n");
-               return -1;
-       }
-
        miiphy_pre (bus, 1, addr, reg);
 
        /* tri-state our MDIO I/O pin so we can read */
@@ -283,8 +260,7 @@ int bb_miiphy_read(char *devname, unsigned char addr,
                        bus->set_mdc(bus, 1);
                        bus->delay(bus);
                }
-               /* There is no PHY, set value to 0xFFFF and return */
-               *value = 0xFFFF;
+               /* There is no PHY, return */
                return -1;
        }
 
@@ -310,13 +286,11 @@ int bb_miiphy_read(char *devname, unsigned char addr,
        bus->set_mdc(bus, 1);
        bus->delay(bus);
 
-       *value = rdreg;
-
 #ifdef DEBUG
-       printf ("miiphy_read(0x%x) @ 0x%x = 0x%04x\n", reg, addr, *value);
+       printf("miiphy_read(0x%x) @ 0x%x = 0x%04x\n", reg, addr, rdreg);
 #endif
 
-       return 0;
+       return rdreg;
 }
 
 
@@ -327,13 +301,13 @@ int bb_miiphy_read(char *devname, unsigned char addr,
  * Returns:
  *   0 on success
  */
-int bb_miiphy_write (char *devname, unsigned char addr,
-                    unsigned char reg, unsigned short value)
+int bb_miiphy_write(struct mii_dev *miidev, int addr, int devad, int reg,
+                   u16 value)
 {
        struct bb_miiphy_bus *bus;
        int j;                  /* counter */
 
-       bus = bb_miiphy_getbus(devname);
+       bus = bb_miiphy_getbus(miidev->name);
        if (bus == NULL) {
                /* Bus not found! */
                return -1;