Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 261127
b: refs/heads/master
c: 4157ef1
h: refs/heads/master
i:
  261125: e7f0dc8
  261123: 195bc01
  261119: c7ba6ce
v: v3
  • Loading branch information
Shawn Guo committed Jul 27, 2011
1 parent 65945c8 commit 029b812
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 42 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 6ca1a113791eb09dac8c48b2b264c4d72aab410f
refs/heads/master: 4157ef1b8779b34581ee8b9dc8f7f95188008eca
33 changes: 4 additions & 29 deletions trunk/drivers/net/ibm_newemac/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <linux/bitops.h>
#include <linux/workqueue.h>
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/slab.h>

#include <asm/processor.h>
Expand Down Expand Up @@ -2506,18 +2507,6 @@ static int __devinit emac_init_config(struct emac_instance *dev)
{
struct device_node *np = dev->ofdev->dev.of_node;
const void *p;
unsigned int plen;
const char *pm, *phy_modes[] = {
[PHY_MODE_NA] = "",
[PHY_MODE_MII] = "mii",
[PHY_MODE_RMII] = "rmii",
[PHY_MODE_SMII] = "smii",
[PHY_MODE_RGMII] = "rgmii",
[PHY_MODE_TBI] = "tbi",
[PHY_MODE_GMII] = "gmii",
[PHY_MODE_RTBI] = "rtbi",
[PHY_MODE_SGMII] = "sgmii",
};

/* Read config from device-tree */
if (emac_read_uint_prop(np, "mal-device", &dev->mal_ph, 1))
Expand Down Expand Up @@ -2566,23 +2555,9 @@ static int __devinit emac_init_config(struct emac_instance *dev)
dev->mal_burst_size = 256;

/* PHY mode needs some decoding */
dev->phy_mode = PHY_MODE_NA;
pm = of_get_property(np, "phy-mode", &plen);
if (pm != NULL) {
int i;
for (i = 0; i < ARRAY_SIZE(phy_modes); i++)
if (!strcasecmp(pm, phy_modes[i])) {
dev->phy_mode = i;
break;
}
}

/* Backward compat with non-final DT */
if (dev->phy_mode == PHY_MODE_NA && pm != NULL && plen == 4) {
u32 nmode = *(const u32 *)pm;
if (nmode > PHY_MODE_NA && nmode <= PHY_MODE_SGMII)
dev->phy_mode = nmode;
}
dev->phy_mode = of_get_phy_mode(np);
if (dev->phy_mode < 0)
dev->phy_mode = PHY_MODE_NA;

/* Check EMAC version */
if (of_device_is_compatible(np, "ibm,emac4sync")) {
Expand Down
19 changes: 10 additions & 9 deletions trunk/drivers/net/ibm_newemac/emac.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#define __IBM_NEWEMAC_H

#include <linux/types.h>
#include <linux/phy.h>

/* EMAC registers Write Access rules */
struct emac_regs {
Expand Down Expand Up @@ -106,15 +107,15 @@ struct emac_regs {
/*
* PHY mode settings (EMAC <-> ZMII/RGMII bridge <-> PHY)
*/
#define PHY_MODE_NA 0
#define PHY_MODE_MII 1
#define PHY_MODE_RMII 2
#define PHY_MODE_SMII 3
#define PHY_MODE_RGMII 4
#define PHY_MODE_TBI 5
#define PHY_MODE_GMII 6
#define PHY_MODE_RTBI 7
#define PHY_MODE_SGMII 8
#define PHY_MODE_NA PHY_INTERFACE_MODE_NA
#define PHY_MODE_MII PHY_INTERFACE_MODE_MII
#define PHY_MODE_RMII PHY_INTERFACE_MODE_RMII
#define PHY_MODE_SMII PHY_INTERFACE_MODE_SMII
#define PHY_MODE_RGMII PHY_INTERFACE_MODE_RGMII
#define PHY_MODE_TBI PHY_INTERFACE_MODE_TBI
#define PHY_MODE_GMII PHY_INTERFACE_MODE_GMII
#define PHY_MODE_RTBI PHY_INTERFACE_MODE_RTBI
#define PHY_MODE_SGMII PHY_INTERFACE_MODE_SGMII

/* EMACx_MR0 */
#define EMAC_MR0_RXI 0x80000000
Expand Down
7 changes: 5 additions & 2 deletions trunk/drivers/net/ibm_newemac/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
#include "emac.h"
#include "phy.h"

static inline int phy_read(struct mii_phy *phy, int reg)
#define phy_read _phy_read
#define phy_write _phy_write

static inline int _phy_read(struct mii_phy *phy, int reg)
{
return phy->mdio_read(phy->dev, phy->address, reg);
}

static inline void phy_write(struct mii_phy *phy, int reg, int val)
static inline void _phy_write(struct mii_phy *phy, int reg, int val)
{
phy->mdio_write(phy->dev, phy->address, reg, val);
}
Expand Down
2 changes: 2 additions & 0 deletions trunk/drivers/of/of_net.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* device driver can get phy interface from device tree.
*/
static const char *phy_modes[] = {
[PHY_INTERFACE_MODE_NA] = "",
[PHY_INTERFACE_MODE_MII] = "mii",
[PHY_INTERFACE_MODE_GMII] = "gmii",
[PHY_INTERFACE_MODE_SGMII] = "sgmii",
Expand All @@ -26,6 +27,7 @@ static const char *phy_modes[] = {
[PHY_INTERFACE_MODE_RGMII_RXID] = "rgmii-rxid",
[PHY_INTERFACE_MODE_RGMII_TXID] = "rgmii-txid",
[PHY_INTERFACE_MODE_RTBI] = "rtbi",
[PHY_INTERFACE_MODE_SMII] = "smii",
};

/**
Expand Down
4 changes: 3 additions & 1 deletion trunk/include/linux/phy.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@

/* Interface Mode definitions */
typedef enum {
PHY_INTERFACE_MODE_NA,
PHY_INTERFACE_MODE_MII,
PHY_INTERFACE_MODE_GMII,
PHY_INTERFACE_MODE_SGMII,
Expand All @@ -62,7 +63,8 @@ typedef enum {
PHY_INTERFACE_MODE_RGMII_ID,
PHY_INTERFACE_MODE_RGMII_RXID,
PHY_INTERFACE_MODE_RGMII_TXID,
PHY_INTERFACE_MODE_RTBI
PHY_INTERFACE_MODE_RTBI,
PHY_INTERFACE_MODE_SMII,
} phy_interface_t;


Expand Down

0 comments on commit 029b812

Please sign in to comment.