Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 291620
b: refs/heads/master
c: 4909912
h: refs/heads/master
v: v3
  • Loading branch information
Heiko Schocher authored and David S. Miller committed Mar 19, 2012
1 parent 31e5fe7 commit 97fcfd5
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 58a3de0592454c216c68427fa3c31a34823f5115
refs/heads/master: 49099122a403b907dc12a5e66033678a07c68ba3
5 changes: 5 additions & 0 deletions trunk/drivers/net/phy/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ if PHYLIB

comment "MII PHY device drivers"

config AMD_PHY
tristate "Drivers for the AMD PHYs"
---help---
Currently supports the am79c874

config MARVELL_PHY
tristate "Drivers for Marvell PHYs"
---help---
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/net/phy/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ obj-$(CONFIG_STE10XP) += ste10Xp.o
obj-$(CONFIG_MICREL_PHY) += micrel.o
obj-$(CONFIG_MDIO_OCTEON) += mdio-octeon.o
obj-$(CONFIG_MICREL_KS8995MA) += spi_ks8995.o
obj-$(CONFIG_AMD_PHY) += amd.o
102 changes: 102 additions & 0 deletions trunk/drivers/net/phy/amd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Driver for AMD am79c PHYs
*
* Author: Heiko Schocher <hs@denx.de>
*
* Copyright (c) 2011 DENX Software Engineering GmbH
*
* 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.
*
*/
#include <linux/kernel.h>
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/mii.h>
#include <linux/phy.h>

#define PHY_ID_AM79C874 0x0022561b

#define MII_AM79C_IR 17 /* Interrupt Status/Control Register */
#define MII_AM79C_IR_EN_LINK 0x0400 /* IR enable Linkstate */
#define MII_AM79C_IR_EN_ANEG 0x0100 /* IR enable Aneg Complete */
#define MII_AM79C_IR_IMASK_INIT (MII_AM79C_IR_EN_LINK | MII_AM79C_IR_EN_ANEG)

MODULE_DESCRIPTION("AMD PHY driver");
MODULE_AUTHOR("Heiko Schocher <hs@denx.de>");
MODULE_LICENSE("GPL");

static int am79c_ack_interrupt(struct phy_device *phydev)
{
int err;

err = phy_read(phydev, MII_BMSR);
if (err < 0)
return err;

err = phy_read(phydev, MII_AM79C_IR);
if (err < 0)
return err;

return 0;
}

static int am79c_config_init(struct phy_device *phydev)
{
return 0;
}

static int am79c_config_intr(struct phy_device *phydev)
{
int err;

if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
err = phy_write(phydev, MII_AM79C_IR, MII_AM79C_IR_IMASK_INIT);
else
err = phy_write(phydev, MII_AM79C_IR, 0);

return err;
}

static struct phy_driver am79c_driver = {
.phy_id = PHY_ID_AM79C874,
.name = "AM79C874",
.phy_id_mask = 0xfffffff0,
.features = PHY_BASIC_FEATURES,
.flags = PHY_HAS_INTERRUPT,
.config_init = am79c_config_init,
.config_aneg = genphy_config_aneg,
.read_status = genphy_read_status,
.ack_interrupt = am79c_ack_interrupt,
.config_intr = am79c_config_intr,
.driver = { .owner = THIS_MODULE,},
};

static int __init am79c_init(void)
{
int ret;

ret = phy_driver_register(&am79c_driver);
if (ret)
return ret;

return 0;
}

static void __exit am79c_exit(void)
{
phy_driver_unregister(&am79c_driver);
}

module_init(am79c_init);
module_exit(am79c_exit);

static struct mdio_device_id __maybe_unused amd_tbl[] = {
{ PHY_ID_AM79C874, 0xfffffff0 },
{ }
};

MODULE_DEVICE_TABLE(mdio, amd_tbl);

0 comments on commit 97fcfd5

Please sign in to comment.