Skip to content

Commit

Permalink
mlxsw: i2c: Extend initialization by querying resources data
Browse files Browse the repository at this point in the history
Extend initialization flow by query requests for chip resources data in
order to obtain chip's specific capabilities, like the number of ports.

Signed-off-by: Vadim Pasternak <[email protected]>
Acked-by: Jiri Pirko <[email protected]>
Signed-off-by: Ido Schimmel <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
mellanoxbmc authored and davem330 committed Mar 4, 2019
1 parent 95b75cb commit 6a98699
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
12 changes: 11 additions & 1 deletion drivers/net/ethernet/mellanox/mlxsw/i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "cmd.h"
#include "core.h"
#include "i2c.h"
#include "resources.h"

#define MLXSW_I2C_CIR2_BASE 0x72000
#define MLXSW_I2C_CIR_STATUS_OFF 0x18
Expand Down Expand Up @@ -499,10 +500,19 @@ mlxsw_i2c_init(void *bus_priv, struct mlxsw_core *mlxsw_core,
struct mlxsw_res *res)
{
struct mlxsw_i2c *mlxsw_i2c = bus_priv;
char *mbox;
int err;

mlxsw_i2c->core = mlxsw_core;

return 0;
mbox = mlxsw_cmd_mbox_alloc();
if (!mbox)
return -ENOMEM;

err = mlxsw_core_resources_query(mlxsw_core, mbox, res);

mlxsw_cmd_mbox_free(mbox);
return err;
}

static void mlxsw_i2c_fini(void *bus_priv)
Expand Down
11 changes: 6 additions & 5 deletions drivers/net/ethernet/mellanox/mlxsw/minimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,12 @@ static void mlxsw_m_fini(struct mlxsw_core *mlxsw_core)
static const struct mlxsw_config_profile mlxsw_m_config_profile;

static struct mlxsw_driver mlxsw_m_driver = {
.kind = mlxsw_m_driver_name,
.priv_size = sizeof(struct mlxsw_m),
.init = mlxsw_m_init,
.fini = mlxsw_m_fini,
.profile = &mlxsw_m_config_profile,
.kind = mlxsw_m_driver_name,
.priv_size = sizeof(struct mlxsw_m),
.init = mlxsw_m_init,
.fini = mlxsw_m_fini,
.profile = &mlxsw_m_config_profile,
.res_query_enabled = true,
};

static const struct i2c_device_id mlxsw_m_i2c_id[] = {
Expand Down

0 comments on commit 6a98699

Please sign in to comment.