Commit 74cfbcc6 authored by Tristan Gingold's avatar Tristan Gingold

libwr2rf: add an API to read the MAC address

parent c6e996f3
......@@ -60,6 +60,19 @@ libwr2rf_be_write32(struct libwr2rf_dev *dev, unsigned off, uint32_t val)
libwr2rf_write16 (dev, off + 2, val & 0xffff);
}
uint32_t
libwr2rf_wrc_read32(struct libwr2rf_dev *dev, unsigned off)
{
return libwr2rf_16x32_read32(dev, WR2RF_VME_REGS_INIT + WR2RF_INIT_REGS_WRPC + off);
}
void
libwr2rf_wrc_write32(struct libwr2rf_dev *dev, unsigned off, uint32_t val)
{
libwr2rf_16x32_write32(dev, WR2RF_VME_REGS_INIT + WR2RF_INIT_REGS_WRPC + off, val);
}
void libwr2rf_pll_spi_init(struct libwr2rf_dev *dev)
{
/* Min period is 25+25ns, so max freq is 20Mhz. */
......@@ -251,6 +264,23 @@ int libwr2rf_check_link_time(struct libwr2rf_dev *dev)
&& (status & WR2RF_INIT_REGS_WRC_STATUS_TIME_VALID);
}
int libwr2rf_get_mac(struct libwr2rf_dev *dev, unsigned char *mac)
{
unsigned h, l;
libwr2rf_be_write32(dev, WR2RF_VME_REGS_INIT + WR2RF_INIT_REGS_WRC_PAGE1,
040000);
h = libwr2rf_wrc_read32(dev, 0x100 + 0x24);
mac[0] = (h >> 8) & 0xff;
mac[1] = (h >> 0) & 0xff;
l = libwr2rf_wrc_read32(dev, 0x100 + 0x28);
mac[2] = (l >> 24) & 0xff;
mac[3] = (l >> 16) & 0xff;
mac[4] = (l >> 8) & 0xff;
mac[5] = (l >> 0) & 0xff;
return 0;
}
int libwr2rf_set_rf_out(struct libwr2rf_dev *dev, unsigned ch, unsigned cfg)
{
unsigned rf;
......
......@@ -47,6 +47,9 @@ void libwr2rf_clock_init(struct libwr2rf_dev *dev);
/* Return true if both the WR link and time are OK. */
int libwr2rf_check_link_time(struct libwr2rf_dev *dev);
/* Read the mac address (6 bytes). Can be used as unique id. */
int libwr2rf_get_mac(struct libwr2rf_dev *dev, unsigned char *mac);
/* DAC IQ set points. */
int libwr2rf_dac_iqsetpoint(struct libwr2rf_dev *dev, unsigned ch, unsigned igain, unsigned qgain);
......
......@@ -54,4 +54,8 @@ void libwr2rf_be_write32(struct libwr2rf_dev *dev, unsigned off, uint32_t val);
uint64_t libwr2rf_be_read64(struct libwr2rf_dev *dev, unsigned off);
void libwr2rf_be_write64(struct libwr2rf_dev *dev, unsigned off, uint64_t val);
/* A WR core register. Atomic but require to set the page. */
uint32_t libwr2rf_wrc_read32(struct libwr2rf_dev *dev, unsigned off);
void libwr2rf_wrc_write32(struct libwr2rf_dev *dev, unsigned off, uint32_t val);
#endif /* __BOARD_H_ */
......@@ -21,18 +21,6 @@
/* [0x10]: REG Hardware Info Register */
#define SYSC_REG_HWIR 0x00000010
static uint32_t
libwr2rf_wrc_read32(struct libwr2rf_dev *dev, unsigned off)
{
return libwr2rf_16x32_read32(dev, WR2RF_VME_REGS_INIT + WR2RF_INIT_REGS_WRPC + off);
}
static void
libwr2rf_wrc_write32(struct libwr2rf_dev *dev, unsigned off, uint32_t val)
{
libwr2rf_16x32_write32(dev, WR2RF_VME_REGS_INIT + WR2RF_INIT_REGS_WRPC + off, val);
}
static uint32_t
libwr2rf_framerxtx_read32(struct libwr2rf_dev *dev, unsigned off)
{
......
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