Skip to content

Commit

Permalink
net/at91_ether/macb: absorb at91_private in to macb private struct
Browse files Browse the repository at this point in the history
This will make it easier to share code between the drivers and
eventually merge them into one driver.

Signed-off-by: Joachim Eastwood <manabian@gmail.com>
  • Loading branch information
Joachim Eastwood authored and David S. Miller committed Oct 19, 2012
1 parent a723b98 commit b85008b
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 79 deletions.
70 changes: 35 additions & 35 deletions drivers/net/ethernet/cadence/at91_ether.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
* When not called from an interrupt-handler, access to the PHY must be
* protected by a spinlock.
*/
static void enable_mdi(struct at91_private *lp)
static void enable_mdi(struct macb *lp)
{
unsigned long ctl;

Expand All @@ -65,7 +65,7 @@ static void enable_mdi(struct at91_private *lp)
/*
* Disable the MDIO bit in the MAC control register
*/
static void disable_mdi(struct at91_private *lp)
static void disable_mdi(struct macb *lp)
{
unsigned long ctl;

Expand All @@ -76,7 +76,7 @@ static void disable_mdi(struct at91_private *lp)
/*
* Wait until the PHY operation is complete.
*/
static inline void at91_phy_wait(struct at91_private *lp)
static inline void at91_phy_wait(struct macb *lp)
{
unsigned long timeout = jiffies + 2;

Expand All @@ -93,7 +93,7 @@ static inline void at91_phy_wait(struct at91_private *lp)
* Write value to the a PHY register
* Note: MDI interface is assumed to already have been enabled.
*/
static void write_phy(struct at91_private *lp, unsigned char phy_addr, unsigned char address, unsigned int value)
static void write_phy(struct macb *lp, unsigned char phy_addr, unsigned char address, unsigned int value)
{
macb_writel(lp, MAN, MACB_BF(SOF, MACB_MAN_SOF) | MACB_BF(CODE, MACB_MAN_CODE)
| MACB_BF(RW, MACB_MAN_WRITE) | ((phy_addr & 0x1f) << 23)
Expand All @@ -107,7 +107,7 @@ static void write_phy(struct at91_private *lp, unsigned char phy_addr, unsigned
* Read value stored in a PHY register.
* Note: MDI interface is assumed to already have been enabled.
*/
static void read_phy(struct at91_private *lp, unsigned char phy_addr, unsigned char address, unsigned int *value)
static void read_phy(struct macb *lp, unsigned char phy_addr, unsigned char address, unsigned int *value)
{
macb_writel(lp, MAN, MACB_BF(SOF, MACB_MAN_SOF) | MACB_BF(CODE, MACB_MAN_CODE)
| MACB_BF(RW, MACB_MAN_READ) | ((phy_addr & 0x1f) << 23)
Expand All @@ -128,7 +128,7 @@ static void read_phy(struct at91_private *lp, unsigned char phy_addr, unsigned c
*/
static void update_linkspeed(struct net_device *dev, int silent)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned int bmsr, bmcr, lpa, mac_cfg;
unsigned int speed, duplex;

Expand Down Expand Up @@ -181,7 +181,7 @@ static void update_linkspeed(struct net_device *dev, int silent)
static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned int phy;

/*
Expand Down Expand Up @@ -234,7 +234,7 @@ static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id)
*/
static void enable_phyirq(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned int dsintr, irq_number;
int status;

Expand Down Expand Up @@ -298,7 +298,7 @@ static void enable_phyirq(struct net_device *dev)
*/
static void disable_phyirq(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned int dsintr;
unsigned int irq_number;

Expand Down Expand Up @@ -357,7 +357,7 @@ static void disable_phyirq(struct net_device *dev)
#if 0
static void reset_phy(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned int bmcr;

spin_lock_irq(&lp->lock);
Expand All @@ -379,7 +379,7 @@ static void reset_phy(struct net_device *dev)
static void at91ether_check_link(unsigned long dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);

enable_mdi(lp);
update_linkspeed(dev, 1);
Expand All @@ -391,7 +391,7 @@ static void at91ether_check_link(unsigned long dev_id)
/*
* Perform any PHY-specific initialization.
*/
static void __init initialize_phy(struct at91_private *lp)
static void __init initialize_phy(struct macb *lp)
{
unsigned int val;

Expand Down Expand Up @@ -460,7 +460,7 @@ static short __init unpack_mac_address(struct net_device *dev, unsigned int hi,
*/
static void __init get_mac_address(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);

/* Check Specific-Address 1 */
if (unpack_mac_address(dev, macb_readl(lp, SA1T), macb_readl(lp, SA1B)))
Expand All @@ -483,7 +483,7 @@ static void __init get_mac_address(struct net_device *dev)
*/
static void update_mac_address(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);

macb_writel(lp, SA1B, (dev->dev_addr[3] << 24) | (dev->dev_addr[2] << 16)
| (dev->dev_addr[1] << 8) | (dev->dev_addr[0]));
Expand Down Expand Up @@ -570,7 +570,7 @@ static int hash_get_index(__u8 *addr)
*/
static void at91ether_sethashtable(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
struct netdev_hw_addr *ha;
unsigned long mc_filter[2];
unsigned int bitnr;
Expand All @@ -591,7 +591,7 @@ static void at91ether_sethashtable(struct net_device *dev)
*/
static void at91ether_set_multicast_list(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned long cfg;

cfg = macb_readl(lp, NCFGR);
Expand Down Expand Up @@ -621,7 +621,7 @@ static void at91ether_set_multicast_list(struct net_device *dev)

static int mdio_read(struct net_device *dev, int phy_id, int location)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned int value;

read_phy(lp, phy_id, location, &value);
Expand All @@ -630,14 +630,14 @@ static int mdio_read(struct net_device *dev, int phy_id, int location)

static void mdio_write(struct net_device *dev, int phy_id, int location, int value)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);

write_phy(lp, phy_id, location, value);
}

static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
int ret;

spin_lock_irq(&lp->lock);
Expand All @@ -658,7 +658,7 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm

static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
int ret;

spin_lock_irq(&lp->lock);
Expand All @@ -674,7 +674,7 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm

static int at91ether_nwayreset(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
int ret;

spin_lock_irq(&lp->lock);
Expand Down Expand Up @@ -705,7 +705,7 @@ static const struct ethtool_ops at91ether_ethtool_ops = {

static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
int res;

if (!netif_running(dev))
Expand All @@ -727,7 +727,7 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
*/
static void at91ether_start(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
struct recv_desc_bufs *dlist, *dlist_phys;
int i;
unsigned long ctl;
Expand Down Expand Up @@ -759,7 +759,7 @@ static void at91ether_start(struct net_device *dev)
*/
static int at91ether_open(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned long ctl;

if (!is_valid_ether_addr(dev->dev_addr))
Expand Down Expand Up @@ -799,7 +799,7 @@ static int at91ether_open(struct net_device *dev)
*/
static int at91ether_close(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned long ctl;

/* Disable Receiver and Transmitter */
Expand Down Expand Up @@ -827,7 +827,7 @@ static int at91ether_close(struct net_device *dev)
*/
static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);

if (macb_readl(lp, TSR) & MACB_BIT(RM9200_BNQ)) {
netif_stop_queue(dev);
Expand Down Expand Up @@ -858,7 +858,7 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev)
*/
static struct net_device_stats *at91ether_stats(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
int ale, lenerr, seqe, lcol, ecol;

if (netif_running(dev)) {
Expand Down Expand Up @@ -894,7 +894,7 @@ static struct net_device_stats *at91ether_stats(struct net_device *dev)
*/
static void at91ether_rx(struct net_device *dev)
{
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
struct recv_desc_bufs *dlist;
unsigned char *p_recv;
struct sk_buff *skb;
Expand Down Expand Up @@ -935,7 +935,7 @@ static void at91ether_rx(struct net_device *dev)
static irqreturn_t at91ether_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *) dev_id;
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);
unsigned long intstatus, ctl;

/* MAC Interrupt Status register indicates what interrupts are pending.
Expand Down Expand Up @@ -1000,7 +1000,7 @@ static const struct net_device_ops at91ether_netdev_ops = {
/*
* Detect the PHY type, and its address.
*/
static int __init at91ether_phy_detect(struct at91_private *lp)
static int __init at91ether_phy_detect(struct macb *lp)
{
unsigned int phyid1, phyid2;
unsigned long phy_id;
Expand Down Expand Up @@ -1047,14 +1047,14 @@ static int __init at91ether_probe(struct platform_device *pdev)
struct macb_platform_data *board_data = pdev->dev.platform_data;
struct resource *regs;
struct net_device *dev;
struct at91_private *lp;
struct macb *lp;
int res;

regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!regs)
return -ENOENT;

dev = alloc_etherdev(sizeof(struct at91_private));
dev = alloc_etherdev(sizeof(struct macb));
if (!dev)
return -ENOMEM;

Expand Down Expand Up @@ -1196,7 +1196,7 @@ static int __init at91ether_probe(struct platform_device *pdev)
static int __devexit at91ether_remove(struct platform_device *pdev)
{
struct net_device *dev = platform_get_drvdata(pdev);
struct at91_private *lp = netdev_priv(dev);
struct macb *lp = netdev_priv(dev);

if (gpio_is_valid(lp->board_data.phy_irq_pin))
gpio_free(lp->board_data.phy_irq_pin);
Expand All @@ -1216,7 +1216,7 @@ static int __devexit at91ether_remove(struct platform_device *pdev)
static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
{
struct net_device *net_dev = platform_get_drvdata(pdev);
struct at91_private *lp = netdev_priv(net_dev);
struct macb *lp = netdev_priv(net_dev);

if (netif_running(net_dev)) {
if (gpio_is_valid(lp->board_data.phy_irq_pin)) {
Expand All @@ -1235,7 +1235,7 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg)
static int at91ether_resume(struct platform_device *pdev)
{
struct net_device *net_dev = platform_get_drvdata(pdev);
struct at91_private *lp = netdev_priv(net_dev);
struct macb *lp = netdev_priv(net_dev);

if (netif_running(net_dev)) {
clk_enable(lp->ether_clk);
Expand Down
44 changes: 0 additions & 44 deletions drivers/net/ethernet/cadence/at91_ether.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,48 +58,4 @@
/* SMSC LAN83C185 */
#define MII_LAN83C185_ID 0x0007C0A0

/* ........................................................................ */

#define MAX_RBUFF_SZ 0x600 /* 1518 rounded up */
#define MAX_RX_DESCR 9 /* max number of receive buffers */

struct rbf_t
{
unsigned int addr;
unsigned long size;
};

struct recv_desc_bufs
{
struct rbf_t descriptors[MAX_RX_DESCR]; /* must be on sizeof (rbf_t) boundary */
char recv_buf[MAX_RX_DESCR][MAX_RBUFF_SZ]; /* must be on long boundary */
};

struct at91_private
{
struct mii_if_info mii; /* ethtool support */
struct macb_platform_data board_data; /* board-specific
* configuration (shared with
* macb for common data */
void __iomem *regs; /* base register address */
struct clk *ether_clk; /* clock */

/* PHY */
unsigned long phy_type; /* type of PHY (PHY_ID) */
spinlock_t lock; /* lock for MDI interface */
short phy_media; /* media interface type */
unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */
struct timer_list check_timer; /* Poll link status */

/* Transmit */
struct sk_buff *skb; /* holds skb until xmit interrupt completes */
dma_addr_t skb_physaddr; /* phys addr from pci_map_single */
int skb_length; /* saved skb length for pci_unmap_single */

/* Receive */
int rxBuffIndex; /* index into receive descriptor list */
struct recv_desc_bufs *dlist; /* descriptor list address */
struct recv_desc_bufs *dlist_phys; /* descriptor list physical address */
};

#endif
Loading

0 comments on commit b85008b

Please sign in to comment.