From patchwork Wed Nov 18 14:44:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Pasternak X-Patchwork-Id: 1402273 X-Patchwork-Delegate: patchwork@peda.user.lysator.liu.se Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=23.128.96.18; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by ozlabs.org (Postfix) with ESMTP id 4CblvQ2whrz9sTv for ; Thu, 19 Nov 2020 01:44:34 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727022AbgKROo3 (ORCPT ); Wed, 18 Nov 2020 09:44:29 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48223 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727021AbgKROo3 (ORCPT ); Wed, 18 Nov 2020 09:44:29 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vadimp@nvidia.com) with SMTP; 18 Nov 2020 16:44:25 +0200 Received: from r-build-lowlevel.mtr.labs.mlnx. (r-build-lowlevel.mtr.labs.mlnx [10.209.0.190]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 0AIEiIHx008040; Wed, 18 Nov 2020 16:44:25 +0200 From: Vadim Pasternak To: wsa@the-dreams.de Cc: peda@axentia.se, linux-i2c@vger.kernel.org, Vadim Pasternak Subject: [Re-send: PATCH i2c-next 6/6] i2c: mux: mlxcpld: Extend supported mux number Date: Wed, 18 Nov 2020 16:44:16 +0200 Message-Id: <20201118144416.184120-7-vadimp@nvidia.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20201118144416.184120-1-vadimp@nvidia.com> References: <20201118144416.184120-1-vadimp@nvidia.com> Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org Allow to extend mux number supported by driver. Currently it is limited by eight, which is not enough for new coming Mellanox modular system with line cards, which require up to 64 mux support. Signed-off-by: Vadim Pasternak Reviewed-by: Michael Shych --- drivers/i2c/muxes/i2c-mux-mlxcpld.c | 17 +++++------------ include/linux/platform_data/mlxcpld.h | 3 +++ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-mlxcpld.c b/drivers/i2c/muxes/i2c-mux-mlxcpld.c index c76180919fc3..760636b507fa 100644 --- a/drivers/i2c/muxes/i2c-mux-mlxcpld.c +++ b/drivers/i2c/muxes/i2c-mux-mlxcpld.c @@ -15,8 +15,6 @@ #include #include -#define CPLD_MUX_MAX_NCHANS 8 - /* mlxcpld_mux - mux control structure: * @last_chan - last register value * @client - I2C device client @@ -24,7 +22,7 @@ * @sel_buf: I2C message buffer for mux select 16 bits transactions */ struct mlxcpld_mux { - u8 last_chan; + int last_chan; struct i2c_client *client; struct mlxcpld_mux_plat_data pdata; u8 sel_buf[3]; @@ -94,7 +92,6 @@ static int mlxcpld_mux_select_chan(struct i2c_mux_core *muxc, u32 chan) int err = 0; /* Only select the channel if its different from the last channel */ - chan++; if (mux->last_chan != chan) { err = mlxcpld_mux_reg_write(muxc->parent, mux, chan); mux->last_chan = err < 0 ? 0 : chan; @@ -143,7 +140,7 @@ static int mlxcpld_mux_probe(struct platform_device *pdev) if (!i2c_check_functionality(client->adapter, func)) return -ENODEV; - muxc = i2c_mux_alloc(client->adapter, &pdev->dev, CPLD_MUX_MAX_NCHANS, + muxc = i2c_mux_alloc(client->adapter, &pdev->dev, pdata->num_adaps, sizeof(*data), 0, mlxcpld_mux_select_chan, mlxcpld_mux_deselect); if (!muxc) @@ -158,13 +155,9 @@ static int mlxcpld_mux_probe(struct platform_device *pdev) data->last_chan = 0; /* force the first selection */ /* Create an adapter for each channel. */ - for (num = 0; num < CPLD_MUX_MAX_NCHANS; num++) { - if (num >= pdata->num_adaps) - /* discard unconfigured channels */ - break; - - force = pdata->adap_ids[num]; - + for (num = 0; num < pdata->num_adaps; num++) { + force = pdata->base_nr ? (pdata->base_nr + + pdata->adap_ids[num]) : pdata->adap_ids[num]; err = i2c_mux_add_adapter(muxc, force, num, 0); if (err) goto virt_reg_failed; diff --git a/include/linux/platform_data/mlxcpld.h b/include/linux/platform_data/mlxcpld.h index da4f7e8f5721..ea88817b3b35 100644 --- a/include/linux/platform_data/mlxcpld.h +++ b/include/linux/platform_data/mlxcpld.h @@ -11,12 +11,15 @@ /* Platform data for the CPLD I2C multiplexers */ /* mlxcpld_mux_plat_data - per mux data, used with i2c_register_board_info + * @base_nr: base I2C bus number to number adapters from or zero for setting + * to adap_ids vector * @adap_ids - adapter array * @num_adaps - number of adapters * @sel_reg_addr - mux select register offset in CPLD space * @reg_size: register size in bytes (default 0 - 1 byte data, 1 - 2 bytes data */ struct mlxcpld_mux_plat_data { + int base_nr; int *adap_ids; int num_adaps; int sel_reg_addr;