1
0
mirror of https://github.com/DigitalDevices/dddvb.git synced 2023-10-10 13:37:43 +02:00

replace mdio_num with mdio_base

This commit is contained in:
Ralph Metzler 2018-04-11 21:20:25 +02:00
parent bdea58c1b2
commit 67257ce132
4 changed files with 31 additions and 22 deletions

View File

@ -3189,25 +3189,25 @@ int ddbridge_flashread(struct ddb *dev, u32 link, u8 *buf, u32 addr, u32 len)
return flashio(dev, link, cmd, 4, buf, len); return flashio(dev, link, cmd, 4, buf, len);
} }
static int mdio_write(struct ddb *dev, u8 adr, u8 reg, u16 val) static int mdio_write(struct ddb *dev, u8 adr, u8 reg, u16 val, u32 mdio_base)
{ {
ddbwritel(dev, adr, MDIO_ADR); ddbwritel(dev, adr, MDIO_ADR_OFF + mdio_base);
ddbwritel(dev, reg, MDIO_REG); ddbwritel(dev, reg, MDIO_REG_OFF + mdio_base);
ddbwritel(dev, val, MDIO_VAL); ddbwritel(dev, val, MDIO_VAL_OFF + mdio_base);
ddbwritel(dev, 0x03, MDIO_CTRL); ddbwritel(dev, 0x03, MDIO_CTRL_OFF + mdio_base);
while (ddbreadl(dev, MDIO_CTRL) & 0x02) while (ddbreadl(dev, MDIO_CTRL_OFF + mdio_base) & 0x02)
ndelay(500); ndelay(500);
return 0; return 0;
} }
static u16 mdio_read(struct ddb *dev, u8 adr, u8 reg) static u16 mdio_read(struct ddb *dev, u8 adr, u8 reg, u32 mdio_base)
{ {
ddbwritel(dev, adr, MDIO_ADR); ddbwritel(dev, adr, MDIO_ADR_OFF + mdio_base);
ddbwritel(dev, reg, MDIO_REG); ddbwritel(dev, reg, MDIO_REG_OFF + mdio_base);
ddbwritel(dev, 0x07, MDIO_CTRL); ddbwritel(dev, 0x07, MDIO_CTRL_OFF + mdio_base);
while (ddbreadl(dev, MDIO_CTRL) & 0x02) while (ddbreadl(dev, MDIO_CTRL_OFF + mdio_base) & 0x02)
ndelay(500); ndelay(500);
return ddbreadl(dev, MDIO_VAL); return ddbreadl(dev, MDIO_VAL_OFF + mdio_base);
} }
#define DDB_MAGIC 'd' #define DDB_MAGIC 'd'
@ -3383,12 +3383,13 @@ static long ddb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case IOCTL_DDB_READ_MDIO: case IOCTL_DDB_READ_MDIO:
{ {
struct ddb_mdio mdio; struct ddb_mdio mdio;
u32 mdio_base = dev->link[0].info->mdio_base;
if (!dev->link[0].info->mdio_num) if (!mdio_base)
return -EIO; return -EIO;
if (copy_from_user(&mdio, parg, sizeof(mdio))) if (copy_from_user(&mdio, parg, sizeof(mdio)))
return -EFAULT; return -EFAULT;
mdio.val = mdio_read(dev, mdio.adr, mdio.reg); mdio.val = mdio_read(dev, mdio.adr, mdio.reg, mdio_base);
if (copy_to_user(parg, &mdio, sizeof(mdio))) if (copy_to_user(parg, &mdio, sizeof(mdio)))
return -EFAULT; return -EFAULT;
break; break;
@ -3396,12 +3397,13 @@ static long ddb_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
case IOCTL_DDB_WRITE_MDIO: case IOCTL_DDB_WRITE_MDIO:
{ {
struct ddb_mdio mdio; struct ddb_mdio mdio;
u32 mdio_base = dev->link[0].info->mdio_base;
if (!dev->link[0].info->mdio_num) if (!mdio_base)
return -EIO; return -EIO;
if (copy_from_user(&mdio, parg, sizeof(mdio))) if (copy_from_user(&mdio, parg, sizeof(mdio)))
return -EFAULT; return -EFAULT;
mdio_write(dev, mdio.adr, mdio.reg, mdio.val); mdio_write(dev, mdio.adr, mdio.reg, mdio.val, mdio_base);
break; break;
} }
case IOCTL_DDB_READ_MEM: case IOCTL_DDB_READ_MEM:

View File

@ -489,7 +489,7 @@ static const struct ddb_info ddb_octopro_hdin = {
.regmap = &octopro_hdin_map, .regmap = &octopro_hdin_map,
.port_num = 10, .port_num = 10,
.i2c_mask = 0x3ff, .i2c_mask = 0x3ff,
.mdio_num = 1, .mdio_base = 0x10020,
}; };
static const struct ddb_info ddb_octopro = { static const struct ddb_info ddb_octopro = {
@ -498,7 +498,7 @@ static const struct ddb_info ddb_octopro = {
.regmap = &octopro_map, .regmap = &octopro_map,
.port_num = 10, .port_num = 10,
.i2c_mask = 0x3ff, .i2c_mask = 0x3ff,
.mdio_num = 1, .mdio_base = 0x10020,
}; };
static const struct ddb_info ddb_s2_48 = { static const struct ddb_info ddb_s2_48 = {
@ -627,7 +627,7 @@ static const struct ddb_info ddb_octonet = {
.port_num = 4, .port_num = 4,
.i2c_mask = 0x0f, .i2c_mask = 0x0f,
.ns_num = 12, .ns_num = 12,
.mdio_num = 1, .mdio_base = 0x20,
}; };
static const struct ddb_info ddb_octonet_jse = { static const struct ddb_info ddb_octonet_jse = {
@ -637,7 +637,7 @@ static const struct ddb_info ddb_octonet_jse = {
.port_num = 4, .port_num = 4,
.i2c_mask = 0x0f, .i2c_mask = 0x0f,
.ns_num = 15, .ns_num = 15,
.mdio_num = 1, .mdio_base = 0x20,
}; };
static const struct ddb_info ddb_octonet_gtl = { static const struct ddb_info ddb_octonet_gtl = {
@ -647,7 +647,7 @@ static const struct ddb_info ddb_octonet_gtl = {
.port_num = 4, .port_num = 4,
.i2c_mask = 0x05, .i2c_mask = 0x05,
.ns_num = 12, .ns_num = 12,
.mdio_num = 1, .mdio_base = 0x20,
.con_clock = 1, .con_clock = 1,
}; };

View File

@ -44,10 +44,17 @@
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
/* MDIO */ /* MDIO */
#if 0
#define MDIO_CTRL 0x20 #define MDIO_CTRL 0x20
#define MDIO_ADR 0x24 #define MDIO_ADR 0x24
#define MDIO_REG 0x28 #define MDIO_REG 0x28
#define MDIO_VAL 0x2C #define MDIO_VAL 0x2C
#endif
#define MDIO_CTRL_OFF 0x00
#define MDIO_ADR_OFF 0x04
#define MDIO_REG_OFF 0x08
#define MDIO_VAL_OFF 0x0C
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */

View File

@ -165,7 +165,6 @@ struct ddb_info {
u32 board_control; u32 board_control;
u32 board_control_2; u32 board_control_2;
u8 ns_num; u8 ns_num;
u8 mdio_num;
u8 con_clock; /* use a continuous clock */ u8 con_clock; /* use a continuous clock */
u8 ts_quirks; u8 ts_quirks;
#define TS_QUIRK_SERIAL 1 #define TS_QUIRK_SERIAL 1
@ -174,6 +173,7 @@ struct ddb_info {
#define TS_QUIRK_ALT_OSC 8 #define TS_QUIRK_ALT_OSC 8
u32 tempmon_irq; u32 tempmon_irq;
u32 lostlock_irq; u32 lostlock_irq;
u32 mdio_base;
u8 mci; u8 mci;
const struct ddb_regmap *regmap; const struct ddb_regmap *regmap;
}; };