Commit 6ebda772 authored by Lucas Russo's avatar Lucas Russo

sm_io/protocols/*: export protocol option to user

parent 8fa46d2a
......@@ -16,7 +16,7 @@ extern "C" {
/* Creates a new instance of the SMCH 24AA64 */
smch_24aa64_t * smch_24aa64_new (smio_t *parent, uint64_t base, uint32_t addr,
int verbose);
const smpr_proto_ops_t *reg_ops, int verbose);
/* Destroy an instance of the SMCH 24AA64 */
smch_err_e smch_24aa64_destroy (smch_24aa64_t **self_p);
......
......@@ -16,7 +16,7 @@ extern "C" {
/* Creates a new instance of the SMCH AD9510 */
smch_ad9510_t * smch_ad9510_new (smio_t *parent, uint64_t base, uint32_t ss,
int verbose);
const smpr_proto_ops_t *reg_ops, int verbose);
/* Destroy an instance of the SMCH AD9510 */
smch_err_e smch_ad9510_destroy (smch_ad9510_t **self_p);
......
......@@ -16,7 +16,7 @@ extern "C" {
/* Creates a new instance of the SMCH ISLA216P */
smch_isla216p_t * smch_isla216p_new (smio_t *parent, uint64_t base, uint32_t ss,
int verbose);
const smpr_proto_ops_t *reg_ops, int verbose);
/* Destroy an instance of the SMCH ISLA216P */
smch_err_e smch_isla216p_destroy (smch_isla216p_t **self_p);
......
......@@ -18,7 +18,7 @@ extern "C" {
/* Creates a new instance of the SMCH PCA9547 */
smch_pca9547_t * smch_pca9547_new (smio_t *parent, uint64_t base, uint32_t addr,
int verbose);
const smpr_proto_ops_t *reg_ops, int verbose);
/* Destroy an instance of the SMCH PCA9547 */
smch_err_e smch_pca9547_destroy (smch_pca9547_t **self_p);
......
......@@ -15,7 +15,7 @@ extern "C" {
/***************** Our methods *****************/
/* Creates a new instance of the SMCH RFFE */
smch_rffe_t * smch_rffe_new (smio_t *parent, int verbose);
smch_rffe_t * smch_rffe_new (smio_t *parent, const smpr_proto_ops_t *reg_ops, int verbose);
/* Destroy an instance of the SMCH RFFE */
smch_err_e smch_rffe_destroy (smch_rffe_t **self_p);
......
......@@ -16,7 +16,7 @@ extern "C" {
/* Creates a new instance of the SMCH SI57X */
smch_si57x_t * smch_si57x_new (smio_t *parent, uint64_t base, uint32_t addr,
int verbose);
const smpr_proto_ops_t *reg_ops, int verbose);
/* Destroy an instance of the SMCH SI57X */
smch_err_e smch_si57x_destroy (smch_si57x_t **self_p);
......
......@@ -54,7 +54,7 @@ static ssize_t _smch_24aa64_read_generic (smch_24aa64_t *self, uint16_t addr,
/* Creates a new instance of the SMCH 24AA64 */
smch_24aa64_t * smch_24aa64_new (smio_t *parent, uint64_t base, uint32_t addr,
int verbose)
const smpr_proto_ops_t *reg_ops, int verbose)
{
(void) verbose;
assert (parent);
......@@ -62,7 +62,7 @@ smch_24aa64_t * smch_24aa64_new (smio_t *parent, uint64_t base, uint32_t addr,
smch_24aa64_t *self = (smch_24aa64_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->i2c = smpr_new (SMCH_24AA64_NAME, parent, &smpr_proto_ops_i2c, verbose);
self->i2c = smpr_new (SMCH_24AA64_NAME, parent, reg_ops, verbose);
ASSERT_ALLOC(self->i2c, err_i2c_alloc);
/* Initalize the I2C protocol */
......
......@@ -57,7 +57,7 @@ static smch_err_e _smch_ad9510_reg_update (smch_ad9510_t *self);
/* Creates a new instance of the SMCH AD9510 */
smch_ad9510_t * smch_ad9510_new (smio_t *parent, uint64_t base, uint32_t ss,
int verbose)
const smpr_proto_ops_t *reg_ops, int verbose)
{
(void) verbose;
assert (parent);
......@@ -65,7 +65,7 @@ smch_ad9510_t * smch_ad9510_new (smio_t *parent, uint64_t base, uint32_t ss,
smch_ad9510_t *self = (smch_ad9510_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->spi = smpr_new (SMCH_AD9510_NAME, parent, &smpr_proto_ops_spi, verbose);
self->spi = smpr_new (SMCH_AD9510_NAME, parent, reg_ops, verbose);
ASSERT_ALLOC(self->spi, err_spi_alloc);
/* Initalize the SPI protocol */
......
......@@ -50,7 +50,7 @@ static ssize_t _smch_isla216p_read_8 (smch_isla216p_t *self, uint8_t addr,
/* Creates a new instance of the SMCH ISLA216P */
smch_isla216p_t * smch_isla216p_new (smio_t *parent, uint64_t base, uint32_t ss,
int verbose)
const smpr_proto_ops_t *reg_ops, int verbose)
{
(void) verbose;
assert (parent);
......@@ -58,7 +58,7 @@ smch_isla216p_t * smch_isla216p_new (smio_t *parent, uint64_t base, uint32_t ss,
smch_isla216p_t *self = (smch_isla216p_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->spi = smpr_new (SMCH_ISLA216P_NAME, parent, &smpr_proto_ops_spi, verbose);
self->spi = smpr_new (SMCH_ISLA216P_NAME, parent, reg_ops, verbose);
ASSERT_ALLOC(self->spi, err_spi_alloc);
/* Initalize the SPI protocol */
......
......@@ -44,7 +44,7 @@ static smch_err_e _smch_pca9547_read_8 (smch_pca9547_t *self, uint8_t *data);
/* Creates a new instance of the SMCH PCA9547 */
smch_pca9547_t * smch_pca9547_new (smio_t *parent, uint64_t base, uint32_t addr,
int verbose)
const smpr_proto_ops_t *reg_ops, int verbose)
{
(void) verbose;
assert (parent);
......@@ -52,7 +52,7 @@ smch_pca9547_t * smch_pca9547_new (smio_t *parent, uint64_t base, uint32_t addr,
smch_pca9547_t *self = (smch_pca9547_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->i2c = smpr_new (SMCH_PCA9547_NAME, parent, &smpr_proto_ops_i2c, verbose);
self->i2c = smpr_new (SMCH_PCA9547_NAME, parent, reg_ops, verbose);
ASSERT_ALLOC(self->i2c, err_i2c_alloc);
/* Initalize the I2C protocol */
......
......@@ -46,7 +46,7 @@ struct _smch_rffe_t {
};
/* Creates a new instance of the SMCH RFFE */
smch_rffe_t * smch_rffe_new (smio_t *parent, int verbose)
smch_rffe_t * smch_rffe_new (smio_t *parent, const smpr_proto_ops_t *reg_ops, int verbose)
{
(void) verbose;
assert (parent);
......@@ -54,7 +54,7 @@ smch_rffe_t * smch_rffe_new (smio_t *parent, int verbose)
smch_rffe_t *self = (smch_rffe_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->bsmp = smpr_new (SMCH_RFFE_NAME, parent, &smpr_proto_ops_bsmp, verbose);
self->bsmp = smpr_new (SMCH_RFFE_NAME, parent, reg_ops, verbose);
ASSERT_ALLOC(self->bsmp, err_bsmp_alloc);
/* Initalize the BSMP protocol */
......
......@@ -77,7 +77,7 @@ static smch_err_e _smch_si57x_wait_new_freq (smch_si57x_t *self);
/* Creates a new instance of the SMCH SI57X */
smch_si57x_t * smch_si57x_new (smio_t *parent, uint64_t base, uint32_t addr,
int verbose)
const smpr_proto_ops_t *reg_ops, int verbose)
{
(void) verbose;
assert (parent);
......@@ -85,7 +85,7 @@ smch_si57x_t * smch_si57x_new (smio_t *parent, uint64_t base, uint32_t addr,
smch_si57x_t *self = (smch_si57x_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->i2c = smpr_new (SMCH_SI57X_NAME, parent, &smpr_proto_ops_i2c, verbose);
self->i2c = smpr_new (SMCH_SI57X_NAME, parent, reg_ops, verbose);
ASSERT_ALLOC(self->i2c, err_i2c_alloc);
/* Initalize the I2C protocol */
......
......@@ -57,7 +57,7 @@ smio_fmc130m_4ch_t * smio_fmc130m_4ch_new (smio_t *parent)
inst_id);
/* FPGA I2C Switch */
self->smch_pca9547 = smch_pca9547_new (parent, FMC_130M_EEPROM_I2C_OFFS,
fmc130m_4ch_pca9547_addr[inst_id], 0);
fmc130m_4ch_pca9547_addr[inst_id], &smpr_proto_ops_i2c, 0);
ASSERT_ALLOC(self->smch_pca9547, err_smch_pca9547_alloc);
/* Enable default I2C channel */
......@@ -72,7 +72,7 @@ smio_fmc130m_4ch_t * smio_fmc130m_4ch_new (smio_t *parent)
inst_id);
/* EEPROM is on the same I2C bus as the LM75A */
self->smch_24aa64 = smch_24aa64_new (parent, FMC_130M_LM75A_I2C_OFFS,
fmc130m_4ch_24aa64_addr[inst_id], 0);
fmc130m_4ch_24aa64_addr[inst_id], &smpr_proto_ops_i2c, 0);
ASSERT_ALLOC(self->smch_24aa64, err_smch_24aa64_alloc);
uint32_t data_24aa64;
......
......@@ -58,7 +58,7 @@ smio_fmc250m_4ch_t * smio_fmc250m_4ch_new (smio_t *parent)
/* FPGA I2C Switch */
#if 0
self->smch_pca9547 = smch_pca9547_new (parent, FMC_250M_EEPROM_I2C_OFFS,
fmc250m_4ch_pca9547_addr[inst_id], 0);
fmc250m_4ch_pca9547_addr[inst_id], &smpr_proto_ops_i2c, 0);
ASSERT_ALLOC(self->smch_pca9547, err_smch_pca9547_alloc);
/* Enable default I2C channel */
......@@ -77,7 +77,7 @@ smio_fmc250m_4ch_t * smio_fmc250m_4ch_new (smio_t *parent)
#if 0
/* EEPROM is on the same I2C bus as the LM75A */
self->smch_24aa64 = smch_24aa64_new (parent, FMC_250M_EEPROM_I2C_OFFS,
fmc250m_4ch_24aa64_addr[inst_id], 0);
fmc250m_4ch_24aa64_addr[inst_id], &smpr_proto_ops_i2c, 0);
DBE_DEBUG (DBG_SM_IO | DBG_LVL_INFO,
"[sm_io:fmc250m_4ch_core] post new 24AA64 data: 0x%08X\n", 0);
ASSERT_ALLOC(self->smch_24aa64, err_smch_24aa64_alloc);
......@@ -120,8 +120,8 @@ smio_fmc250m_4ch_t * smio_fmc250m_4ch_new (smio_t *parent)
_smio_fmc250m_4ch_set_type (self, 0x0);
/* FIXME: We need to be sure that, if the board is ACTIVE, the FMC_ACTIVE_CLK
* component has been sucseddfully initialized so that the ADCs has clock.
* Otherwise, we won't be able to RESET the ADCs, leading to undefined
* component has been sucseddfully initialized so that the ADCs has clock.
* Otherwise, we won't be able to RESET the ADCs, leading to undefined
* behavior */
sleep (5);
......@@ -130,7 +130,7 @@ smio_fmc250m_4ch_t * smio_fmc250m_4ch_new (smio_t *parent)
for (i = 0; i < NUM_FMC250M_4CH_ISLA216P; ++i) {
self->smch_isla216p_adc[i] = NULL;
self->smch_isla216p_adc[i] = smch_isla216p_new (parent, FMC_250M_ISLA216P_SPI_OFFS,
fmc250m_4ch_isla216p_addr[inst_id][i], 0);
fmc250m_4ch_isla216p_addr[inst_id][i], &smpr_proto_ops_spi, 0);
ASSERT_ALLOC(self->smch_isla216p_adc[i], err_smch_isla216p_adc);
uint8_t chipid = 0;
......
......@@ -46,14 +46,14 @@ smio_fmc_active_clk_t * smio_fmc_active_clk_new (smio_t *parent)
"addr: 0x%08X, Inst ID: %u\n", fmc_active_clk_ad9510_addr,
inst_id);
self->smch_ad9510 = smch_ad9510_new (parent, FMC_ACTIVE_CLK_AD9510_SPI_OFFS,
fmc_active_clk_ad9510_addr, 0);
fmc_active_clk_ad9510_addr, &smpr_proto_ops_spi, 0);
ASSERT_ALLOC(self->smch_ad9510, err_smch_ad9510_alloc);
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:fmc_active_clk_core] SI571 initializing, "
"addr: 0x%08X, Inst ID: %u\n", fmc_active_clk_si571_addr,
inst_id);
self->smch_si571 = smch_si57x_new (parent, FMC_ACTIVE_CLK_SI571_I2C_OFFS,
fmc_active_clk_si571_addr, 0);
fmc_active_clk_si571_addr, &smpr_proto_ops_i2c, 0);
ASSERT_ALLOC(self->smch_si571, err_smch_si571_alloc);
return self;
......
......@@ -40,7 +40,7 @@ smio_rffe_t * smio_rffe_new (smio_t *parent)
smio_rffe_t *self = (smio_rffe_t *) zmalloc (sizeof *self);
ASSERT_ALLOC(self, err_self_alloc);
self->ctl = smch_rffe_new (parent, 0);
self->ctl = smch_rffe_new (parent, &smpr_proto_ops_bsmp, 0);
ASSERT_ALLOC(self->ctl, err_rffe_alloc);
return self;
......
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