Allow to access phy registers via ioctl().

This commit is contained in:
Hidetoshi Shimokawa 2003-08-19 08:47:49 +00:00
parent 9fbc7f7255
commit f9c8c31d33
2 changed files with 18 additions and 1 deletions

View File

@ -381,6 +381,8 @@ struct fw_crom_buf {
#define FWOHCI_RDREG _IOWR('S', 80, struct fw_reg_req_t)
#define FWOHCI_WRREG _IOWR('S', 81, struct fw_reg_req_t)
#define FWOHCI_RDPHYREG _IOWR('S', 82, struct fw_reg_req_t)
#define FWOHCI_WRPHYREG _IOWR('S', 83, struct fw_reg_req_t)
#define DUMPDMA _IOWR('S', 82, u_int32_t)

View File

@ -332,7 +332,7 @@ fwphy_rddata(struct fwohci_softc *sc, u_int addr)
}
if (bootverbose || retry >= MAX_RETRY)
device_printf(sc->fc.dev,
"fwphy_rddata: loop=%d, retry=%d\n", i, retry);
"fwphy_rddata: 0x%x loop=%d, retry=%d\n", addr, i, retry);
#undef MAX_RETRY
return((fun >> PHYDEV_RDDATA )& 0xff);
}
@ -382,7 +382,22 @@ fwohci_ioctl (dev_t dev, u_long cmd, caddr_t data, int flag, fw_proc *td)
err = EINVAL;
}
break;
/* Read/Write Phy registers */
#define OHCI_MAX_PHY_REG 0xf
case FWOHCI_RDPHYREG:
if (reg->addr <= OHCI_MAX_PHY_REG)
reg->data = fwphy_rddata(fc, reg->addr);
else
err = EINVAL;
break;
case FWOHCI_WRPHYREG:
if (reg->addr <= OHCI_MAX_PHY_REG)
reg->data = fwphy_wrdata(fc, reg->addr, reg->data);
else
err = EINVAL;
break;
default:
err = EINVAL;
break;
}
return err;