mirror of
https://github.com/corundum/corundum.git
synced 2025-01-30 08:32:52 +08:00
Rename BMC-related methods
This commit is contained in:
parent
a644d6dd3f
commit
3a503cc6aa
@ -457,27 +457,27 @@ static struct mqnic_board_ops generic_board_ops = {
|
|||||||
.deinit = mqnic_generic_board_deinit
|
.deinit = mqnic_generic_board_deinit
|
||||||
};
|
};
|
||||||
|
|
||||||
static u32 mqnic_read_alveo_bmc_reg(struct mqnic_dev *mqnic, u32 reg)
|
static u32 mqnic_alveo_bmc_reg_read(struct mqnic_dev *mqnic, u32 reg)
|
||||||
{
|
{
|
||||||
iowrite32(reg, mqnic->hw_addr+0x180);
|
iowrite32(reg, mqnic->hw_addr+0x180);
|
||||||
ioread32(mqnic->hw_addr+0x184); // dummy read
|
ioread32(mqnic->hw_addr+0x184); // dummy read
|
||||||
return ioread32(mqnic->hw_addr+0x184);
|
return ioread32(mqnic->hw_addr+0x184);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mqnic_write_alveo_bmc_reg(struct mqnic_dev *mqnic, u32 reg, u32 val)
|
static void mqnic_alveo_bmc_reg_write(struct mqnic_dev *mqnic, u32 reg, u32 val)
|
||||||
{
|
{
|
||||||
iowrite32(reg, mqnic->hw_addr+0x180);
|
iowrite32(reg, mqnic->hw_addr+0x180);
|
||||||
iowrite32(val, mqnic->hw_addr+0x184);
|
iowrite32(val, mqnic->hw_addr+0x184);
|
||||||
ioread32(mqnic->hw_addr+0x184); // dummy read
|
ioread32(mqnic->hw_addr+0x184); // dummy read
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mqnic_read_mac_from_alveo_bmc(struct mqnic_dev *mqnic, int offset, char *mac)
|
static int mqnic_alveo_bmc_read_mac(struct mqnic_dev *mqnic, int offset, char *mac)
|
||||||
{
|
{
|
||||||
uint32_t reg = 0x0281a0 + offset;
|
uint32_t reg = 0x0281a0 + offset;
|
||||||
uint32_t val = mqnic_read_alveo_bmc_reg(mqnic, reg);
|
uint32_t val = mqnic_alveo_bmc_reg_read(mqnic, reg);
|
||||||
mac[0] = (val >> 8) & 0xff;
|
mac[0] = (val >> 8) & 0xff;
|
||||||
mac[1] = val & 0xff;
|
mac[1] = val & 0xff;
|
||||||
val = mqnic_read_alveo_bmc_reg(mqnic, reg+4);
|
val = mqnic_alveo_bmc_reg_read(mqnic, reg+4);
|
||||||
mac[2] = (val >> 24) & 0xff;
|
mac[2] = (val >> 24) & 0xff;
|
||||||
mac[3] = (val >> 16) & 0xff;
|
mac[3] = (val >> 16) & 0xff;
|
||||||
mac[4] = (val >> 8) & 0xff;
|
mac[4] = (val >> 8) & 0xff;
|
||||||
@ -486,7 +486,7 @@ static int mqnic_read_mac_from_alveo_bmc(struct mqnic_dev *mqnic, int offset, ch
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mqnic_init_mac_list_from_alveo_bmc(struct mqnic_dev *mqnic, int offset, int count)
|
static int mqnic_alveo_bmc_read_mac_list(struct mqnic_dev *mqnic, int count)
|
||||||
{
|
{
|
||||||
int ret, k;
|
int ret, k;
|
||||||
char mac[ETH_ALEN];
|
char mac[ETH_ALEN];
|
||||||
@ -496,7 +496,7 @@ static int mqnic_init_mac_list_from_alveo_bmc(struct mqnic_dev *mqnic, int offse
|
|||||||
mqnic->mac_count = 0;
|
mqnic->mac_count = 0;
|
||||||
for (k = 0; k < count; k++)
|
for (k = 0; k < count; k++)
|
||||||
{
|
{
|
||||||
ret = mqnic_read_mac_from_alveo_bmc(mqnic, k*8, mac);
|
ret = mqnic_alveo_bmc_read_mac(mqnic, k*8, mac);
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
dev_warn(mqnic->dev, "Failed to read MAC from Alveo BMC");
|
dev_warn(mqnic->dev, "Failed to read MAC from Alveo BMC");
|
||||||
@ -570,23 +570,23 @@ static int mqnic_alveo_board_init(struct mqnic_dev *mqnic)
|
|||||||
case MQNIC_BOARD_ID_AU280:
|
case MQNIC_BOARD_ID_AU280:
|
||||||
// init BMC
|
// init BMC
|
||||||
|
|
||||||
if (mqnic_read_alveo_bmc_reg(mqnic, 0x020000) == 0 ||
|
if (mqnic_alveo_bmc_reg_read(mqnic, 0x020000) == 0 ||
|
||||||
mqnic_read_alveo_bmc_reg(mqnic, 0x028000) != 0x74736574)
|
mqnic_alveo_bmc_reg_read(mqnic, 0x028000) != 0x74736574)
|
||||||
{
|
{
|
||||||
dev_info(mqnic->dev, "Resetting Alveo CMS");
|
dev_info(mqnic->dev, "Resetting Alveo CMS");
|
||||||
|
|
||||||
mqnic_write_alveo_bmc_reg(mqnic, 0x020000, 0);
|
mqnic_alveo_bmc_reg_write(mqnic, 0x020000, 0);
|
||||||
mqnic_write_alveo_bmc_reg(mqnic, 0x020000, 1);
|
mqnic_alveo_bmc_reg_write(mqnic, 0x020000, 1);
|
||||||
msleep(100);
|
msleep(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mqnic_read_alveo_bmc_reg(mqnic, 0x028000) != 0x74736574)
|
if (mqnic_alveo_bmc_reg_read(mqnic, 0x028000) != 0x74736574)
|
||||||
{
|
{
|
||||||
dev_warn(mqnic->dev, "Alveo CMS not responding");
|
dev_warn(mqnic->dev, "Alveo CMS not responding");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mqnic_init_mac_list_from_alveo_bmc(mqnic, 0, 8);
|
mqnic_alveo_bmc_read_mac_list(mqnic, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -47,18 +47,18 @@ static void usage(char *name)
|
|||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t mqnic_read_bmc_reg(struct mqnic *dev, uint32_t reg)
|
uint32_t mqnic_alveo_bmc_reg_read(struct mqnic *dev, uint32_t reg)
|
||||||
{
|
{
|
||||||
mqnic_reg_write32(dev->regs, 0x0180, reg);
|
mqnic_reg_write32(dev->regs, 0x0180, reg);
|
||||||
mqnic_reg_read32(dev->regs, 0x0184);
|
mqnic_reg_read32(dev->regs, 0x0184); // dummy read
|
||||||
return mqnic_reg_read32(dev->regs, 0x0184);
|
return mqnic_reg_read32(dev->regs, 0x0184);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mqnic_write_bmc_reg(struct mqnic *dev, uint32_t reg, uint32_t val)
|
void mqnic_alveo_bmc_reg_write(struct mqnic *dev, uint32_t reg, uint32_t val)
|
||||||
{
|
{
|
||||||
mqnic_reg_write32(dev->regs, 0x0180, reg);
|
mqnic_reg_write32(dev->regs, 0x0180, reg);
|
||||||
mqnic_reg_write32(dev->regs, 0x0184, val);
|
mqnic_reg_write32(dev->regs, 0x0184, val);
|
||||||
usleep(10);
|
mqnic_reg_read32(dev->regs, 0x0184); // dummy read
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sensor_channel {
|
struct sensor_channel {
|
||||||
@ -181,17 +181,17 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
printf("Attempt to communicate with CMS microblaze...\n");
|
printf("Attempt to communicate with CMS microblaze...\n");
|
||||||
|
|
||||||
if (mqnic_read_bmc_reg(dev, 0x020000) == 0 || mqnic_read_bmc_reg(dev, 0x028000) == 0)
|
if (mqnic_alveo_bmc_reg_read(dev, 0x020000) == 0 || mqnic_alveo_bmc_reg_read(dev, 0x028000) == 0)
|
||||||
{
|
{
|
||||||
printf("Resetting CMS...\n");
|
printf("Resetting CMS...\n");
|
||||||
|
|
||||||
// reset CMS
|
// reset CMS
|
||||||
mqnic_write_bmc_reg(dev, 0x020000, 0);
|
mqnic_alveo_bmc_reg_write(dev, 0x020000, 0);
|
||||||
mqnic_write_bmc_reg(dev, 0x020000, 1);
|
mqnic_alveo_bmc_reg_write(dev, 0x020000, 1);
|
||||||
usleep(100000);
|
usleep(100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mqnic_read_bmc_reg(dev, 0x028000) != 0x74736574)
|
if (mqnic_alveo_bmc_reg_read(dev, 0x028000) != 0x74736574)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "CMS not responding\n");
|
fprintf(stderr, "CMS not responding\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@ -203,9 +203,9 @@ int main(int argc, char *argv[])
|
|||||||
for (const struct sensor_channel *ptr = alveo_bmc_sensors; ptr->reg; ptr++)
|
for (const struct sensor_channel *ptr = alveo_bmc_sensors; ptr->reg; ptr++)
|
||||||
{
|
{
|
||||||
uint32_t reg = 0x028000 + ptr->reg;
|
uint32_t reg = 0x028000 + ptr->reg;
|
||||||
uint32_t val_max = mqnic_read_bmc_reg(dev, reg);
|
uint32_t val_max = mqnic_alveo_bmc_reg_read(dev, reg);
|
||||||
uint32_t val_avg = mqnic_read_bmc_reg(dev, reg+4);
|
uint32_t val_avg = mqnic_alveo_bmc_reg_read(dev, reg+4);
|
||||||
uint32_t val_ins = mqnic_read_bmc_reg(dev, reg+8);
|
uint32_t val_ins = mqnic_alveo_bmc_reg_read(dev, reg+8);
|
||||||
|
|
||||||
printf("%s: %d %s (%d %s avg, %d %s max)\n", ptr->name,
|
printf("%s: %d %s (%d %s avg, %d %s max)\n", ptr->name,
|
||||||
val_ins, ptr->unit, val_avg, ptr->unit, val_max, ptr->unit);
|
val_ins, ptr->unit, val_avg, ptr->unit, val_max, ptr->unit);
|
||||||
@ -217,10 +217,10 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
uint8_t mac[6];
|
uint8_t mac[6];
|
||||||
uint32_t reg = 0x0281a0 + k*8;
|
uint32_t reg = 0x0281a0 + k*8;
|
||||||
uint32_t val = mqnic_read_bmc_reg(dev, reg);
|
uint32_t val = mqnic_alveo_bmc_reg_read(dev, reg);
|
||||||
mac[0] = (val >> 8) & 0xff;
|
mac[0] = (val >> 8) & 0xff;
|
||||||
mac[1] = val & 0xff;
|
mac[1] = val & 0xff;
|
||||||
val = mqnic_read_bmc_reg(dev, reg+4);
|
val = mqnic_alveo_bmc_reg_read(dev, reg+4);
|
||||||
mac[2] = (val >> 24) & 0xff;
|
mac[2] = (val >> 24) & 0xff;
|
||||||
mac[3] = (val >> 16) & 0xff;
|
mac[3] = (val >> 16) & 0xff;
|
||||||
mac[4] = (val >> 8) & 0xff;
|
mac[4] = (val >> 8) & 0xff;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user