Commit e6c0f208 authored by Alessandro Rubini's avatar Alessandro Rubini

modules: added phy read/write ioctl to nic

parent 01e8a02d
......@@ -239,6 +239,19 @@ static int wrn_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
if (put_user(reg, (u32 *)rq->ifr_data) < 0)
return -EFAULT;
return 0;
case PRIV_IOCPHYREG:
/* this command allows to read and write a phy register */
if (get_user(reg, (u32 *)rq->ifr_data) < 0)
return -EFAULT;
if (reg & (1<<31)) {
wrn_phy_write(dev, 0, (reg >> 16) & 0xff,
reg & 0xffff);
return 0;
}
reg = wrn_phy_read(dev, 0, (reg >> 16) & 0xff);
if (put_user(reg, (u32 *)rq->ifr_data) < 0)
return -EFAULT;
return 0;
default:
spin_lock_irq(&ep->lock);
......
......@@ -162,6 +162,15 @@ enum wrn_resnames {
#define PRIV_IOCGCALIBRATE (SIOCDEVPRIVATE + 1)
#define PRIV_IOCGGETPHASE (SIOCDEVPRIVATE + 2)
#define PRIV_IOCREADREG (SIOCDEVPRIVATE + 3)
#define PRIV_IOCPHYREG (SIOCDEVPRIVATE + 4)
#define NIC_READ_PHY_CMD(addr) (((addr) & 0xff) << 16)
#define NIC_RESULT_DATA(val) ((val) & 0xffff)
#define NIC_WRITE_PHY_CMD(addr, value) ((((addr) & 0xff) << 16) \
| (1 << 31) \
| ((value) & 0xffff))
/* Structures straight from wr_minic.c -- should user-space include this? */
struct wrn_calibration_req {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment