mv643xx_eth: remove force_phy_addr field
authorLennert Buytenhek <buytenh@wantstofly.org>
Tue, 26 Aug 2008 12:06:47 +0000 (14:06 +0200)
committerLennert Buytenhek <buytenh@marvell.com>
Fri, 5 Sep 2008 04:33:59 +0000 (06:33 +0200)
Currently, there are two different fields in the
mv643xx_eth_platform_data struct that together describe the PHY
address -- one field (phy_addr) has the address of the PHY, but if
that address is zero, a second field (force_phy_addr) needs to be
set to distinguish the actual address zero from a zero due to not
having filled in the PHY address explicitly (which should mean
'use the default PHY address').

If we are a bit smarter about the encoding of the phy_addr field,
we can avoid the need for a second field -- this patch does that.

Signed-off-by: Lennert Buytenhek <buytenh@marvell.com>
20 files changed:
arch/arm/mach-kirkwood/db88f6281-bp-setup.c
arch/arm/mach-kirkwood/rd88f6192-nas-setup.c
arch/arm/mach-kirkwood/rd88f6281-setup.c
arch/arm/mach-loki/lb88rc8480-setup.c
arch/arm/mach-mv78xx0/db78x00-bp-setup.c
arch/arm/mach-orion5x/db88f5281-setup.c
arch/arm/mach-orion5x/dns323-setup.c
arch/arm/mach-orion5x/kurobox_pro-setup.c
arch/arm/mach-orion5x/mss2-setup.c
arch/arm/mach-orion5x/mv2120-setup.c
arch/arm/mach-orion5x/rd88f5181l-fxo-setup.c
arch/arm/mach-orion5x/rd88f5181l-ge-setup.c
arch/arm/mach-orion5x/rd88f5182-setup.c
arch/arm/mach-orion5x/ts78xx-setup.c
arch/arm/mach-orion5x/tsx09-common.c
arch/arm/mach-orion5x/wnr854t-setup.c
arch/arm/mach-orion5x/wrt350n-v2-setup.c
arch/powerpc/sysdev/mv64x60_dev.c
drivers/net/mv643xx_eth.c
include/linux/mv643xx_eth.h

index 610fb24d8ae2ed4fcbc7e9220a5849508ef5a5cb..cd317795f3559779e3ac788fff66028b243b3cd6 100644 (file)
@@ -25,7 +25,7 @@
 #include "common.h"
 
 static struct mv643xx_eth_platform_data db88f6281_ge00_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 static struct mv_sata_platform_data db88f6281_sata_data = {
index a3012d4459714c7932d533bd73a805523465ac36..b1d1a87a6821f9b3e53d819fd31cdefc1b8b491d 100644 (file)
@@ -30,7 +30,7 @@
 #define RD88F6192_GPIO_USB_VBUS                10
 
 static struct mv643xx_eth_platform_data rd88f6192_ge00_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 static struct mv_sata_platform_data rd88f6192_sata_data = {
index d96487a0f18bfabe9fbca93a5ba24962e64262a3..b6416615c0b9c0667157c257f733c4cfce30c0b4 100644 (file)
@@ -69,7 +69,7 @@ static struct platform_device rd88f6281_nand_flash = {
 };
 
 static struct mv643xx_eth_platform_data rd88f6281_ge00_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
        .speed          = SPEED_1000,
        .duplex         = DUPLEX_FULL,
 };
index 2cc9ac9b488f24cb8b87a72f50530cd6a34a4be5..85f9c1296aa02675d7c131a85e8c12161a437919 100644 (file)
@@ -67,7 +67,7 @@ static struct platform_device lb88rc8480_boot_flash = {
 };
 
 static struct mv643xx_eth_platform_data lb88rc8480_ge0_data = {
-       .phy_addr       = 1,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(1),
        .mac_addr       = { 0x00, 0x50, 0x43, 0x11, 0x22, 0x33 },
 };
 
index a2d0c97836047441ccf486a5629f1b5a20c9e27b..49f434c39eb76e539f46e81be52d9735f7ca5145 100644 (file)
 #include "common.h"
 
 static struct mv643xx_eth_platform_data db78x00_ge00_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 static struct mv643xx_eth_platform_data db78x00_ge01_data = {
-       .phy_addr       = 9,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(9),
 };
 
 static struct mv643xx_eth_platform_data db78x00_ge10_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
 };
 
 static struct mv643xx_eth_platform_data db78x00_ge11_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
 };
 
 static struct mv_sata_platform_data db78x00_sata_data = {
index ff13e9060b180a9f83c6b0ed2ab5cf4f9d43c205..d318bea2af91bbb5e9ec46a57813d6ef5add40e7 100644 (file)
@@ -285,7 +285,7 @@ subsys_initcall(db88f5281_pci_init);
  * Ethernet
  ****************************************************************************/
 static struct mv643xx_eth_platform_data db88f5281_eth_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 /*****************************************************************************
index b38c65ccfb154b63b584b310ca1539e4c886b08f..3e66098340a538b146c357d51d0fab4218ee313a 100644 (file)
@@ -79,7 +79,7 @@ subsys_initcall(dns323_pci_init);
  */
 
 static struct mv643xx_eth_platform_data dns323_eth_data = {
-       .phy_addr = 8,
+       .phy_addr = MV643XX_ETH_PHY_ADDR(8),
 };
 
 /****************************************************************************
index e321ec331839c1f8e68959bbe8a3ff1e44030f54..610f2a6297f87c893df7a637fa6a7aabcdf4552e 100644 (file)
@@ -161,7 +161,7 @@ subsys_initcall(kurobox_pro_pci_init);
  ****************************************************************************/
 
 static struct mv643xx_eth_platform_data kurobox_pro_eth_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 /*****************************************************************************
index 53ff1893b8835e111406affb4dea47d8b835c6d4..68acca98e638e62efa25b2d3ae12e558a6eec570 100644 (file)
@@ -109,7 +109,7 @@ subsys_initcall(mss2_pci_init);
  ****************************************************************************/
 
 static struct mv643xx_eth_platform_data mss2_eth_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 /*****************************************************************************
index 978d4d5993964f93baa09bf387c55881d52494cb..97c9ccb2ac60f7713bc076e38b3b23b8dff94c04 100644 (file)
@@ -39,7 +39,7 @@
  * Ethernet
  ****************************************************************************/
 static struct mv643xx_eth_platform_data mv2120_eth_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 static struct mv_sata_platform_data mv2120_sata_data = {
index e72fe1e065e825069547e166763f33adaf32b3b1..500cdadaf09c8e160f566b37a1fb785e39437cce 100644 (file)
@@ -88,7 +88,7 @@ static struct orion5x_mpp_mode rd88f5181l_fxo_mpp_modes[] __initdata = {
 };
 
 static struct mv643xx_eth_platform_data rd88f5181l_fxo_eth_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
        .speed          = SPEED_1000,
        .duplex         = DUPLEX_FULL,
 };
index a1fe3257320d77732c121eeb9b7c07b25557909e..ebde8141649935058d7a701b485e7a6b412cccd7 100644 (file)
@@ -89,7 +89,7 @@ static struct orion5x_mpp_mode rd88f5181l_ge_mpp_modes[] __initdata = {
 };
 
 static struct mv643xx_eth_platform_data rd88f5181l_ge_eth_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
        .speed          = SPEED_1000,
        .duplex         = DUPLEX_FULL,
 };
index 4c3bcd76ac85ba0ca55f1b40510ac0e93ef04f62..a04f9e4b633a409a10a80cfb5c63da32f4ce3793 100644 (file)
@@ -221,7 +221,7 @@ subsys_initcall(rd88f5182_pci_init);
  ****************************************************************************/
 
 static struct mv643xx_eth_platform_data rd88f5182_eth_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 /*****************************************************************************
index ae0a5dccd2a1f465ae9ce4cd3a657d1ffe4a878f..1368e9fd1a06806d629d21db2667086fe3c7b7ae 100644 (file)
@@ -103,8 +103,7 @@ static struct platform_device ts78xx_nor_boot_flash = {
  * Ethernet
  ****************************************************************************/
 static struct mv643xx_eth_platform_data ts78xx_eth_data = {
-       .phy_addr       = 0,
-       .force_phy_addr = 1,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(0),
 };
 
 /*****************************************************************************
index 83feac3147a60d257da59957e2b40d67d632c3dc..19cde24fbfdf91a6bec33d628ebe510de20f1d64 100644 (file)
@@ -48,7 +48,7 @@ void qnap_tsx09_power_off(void)
  ****************************************************************************/
 
 struct mv643xx_eth_platform_data qnap_tsx09_eth_data = {
-       .phy_addr       = 8,
+       .phy_addr       = MV643XX_ETH_PHY_ADDR(8),
 };
 
 static int __init qnap_tsx09_parse_hex_nibble(char n)
index b6bc43e07eed1cce12d21dd0cfdb8cadeb4537ae..7ddc22c2bb5480d17455fe533023ddd36d66a58f 100644 (file)
@@ -92,7 +92,7 @@ static struct platform_device wnr854t_nor_flash = {
 };
 
 static struct mv643xx_eth_platform_data wnr854t_eth_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
        .speed          = SPEED_1000,
        .duplex         = DUPLEX_FULL,
 };
index b10da17b3fbdc0dc8842df785a23f7dbcc5db089..9a4fd5256462e8686b81643e47fe9c8987165f10 100644 (file)
@@ -100,7 +100,7 @@ static struct platform_device wrt350n_v2_nor_flash = {
 };
 
 static struct mv643xx_eth_platform_data wrt350n_v2_eth_data = {
-       .phy_addr       = -1,
+       .phy_addr       = MV643XX_ETH_PHY_NONE,
        .speed          = SPEED_1000,
        .duplex         = DUPLEX_FULL,
 };
index 32e0ad0ebea8286af9b5b3b8cc1bd18ac1a42ed0..b6bd775d2e222d765e5bbad2e986c5d9ac19def3 100644 (file)
@@ -293,10 +293,8 @@ static int __init mv64x60_eth_device_setup(struct device_node *np, int id,
                return -ENODEV;
 
        prop = of_get_property(phy, "reg", NULL);
-       if (prop) {
-               pdata.force_phy_addr = 1;
-               pdata.phy_addr = *prop;
-       }
+       if (prop)
+               pdata.phy_addr = MV643XX_ETH_PHY_ADDR(*prop);
 
        of_node_put(phy);
 
index 6d3da78b7ad547b652adea7daffd4726922640b0..b4850cf2a8ce096fdc9855e7fde6decf9dd20a19 100644 (file)
@@ -2412,10 +2412,10 @@ static void set_params(struct mv643xx_eth_private *mp,
        else
                uc_addr_get(mp, dev->dev_addr);
 
-       if (pd->phy_addr == -1) {
+       if (pd->phy_addr == MV643XX_ETH_PHY_NONE) {
                mp->phy_addr = -1;
        } else {
-               if (pd->force_phy_addr || pd->phy_addr) {
+               if (pd->phy_addr != MV643XX_ETH_PHY_ADDR_DEFAULT) {
                        mp->phy_addr = pd->phy_addr & 0x3f;
                        phy_addr_set(mp, mp->phy_addr);
                } else {
index 12339eb65704cf9e1b25b6f36eb868cd465b9db8..cbbbe9bfecad0652334963de2cd8363c43e6b28a 100644 (file)
@@ -21,6 +21,10 @@ struct mv643xx_eth_shared_platform_data {
        unsigned int            t_clk;
 };
 
+#define MV643XX_ETH_PHY_ADDR_DEFAULT   0
+#define MV643XX_ETH_PHY_ADDR(x)                (0x80 | (x))
+#define MV643XX_ETH_PHY_NONE           0xff
+
 struct mv643xx_eth_platform_data {
        /*
         * Pointer back to our parent instance, and our port number.
@@ -31,7 +35,6 @@ struct mv643xx_eth_platform_data {
        /*
         * Whether a PHY is present, and if yes, at which address.
         */
-       int                     force_phy_addr;
        int                     phy_addr;
 
        /*