From patchwork Wed Nov 18 14:44:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Pasternak X-Patchwork-Id: 327653 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB420C5519F for ; Wed, 18 Nov 2020 14:44:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3F08A221FB for ; Wed, 18 Nov 2020 14:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727012AbgKROoX (ORCPT ); Wed, 18 Nov 2020 09:44:23 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48157 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726869AbgKROoX (ORCPT ); Wed, 18 Nov 2020 09:44:23 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vadimp@nvidia.com) with SMTP; 18 Nov 2020 16:44:21 +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 0AIEiIHs008040; Wed, 18 Nov 2020 16:44:20 +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 1/6] i2c: mux: mlxcpld: Update module license Date: Wed, 18 Nov 2020 16:44:11 +0200 Message-Id: <20201118144416.184120-2-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 Update license to SPDX-License. Signed-off-by: Vadim Pasternak --- drivers/i2c/muxes/i2c-mux-mlxcpld.c | 33 +++------------------------------ 1 file changed, 3 insertions(+), 30 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-mlxcpld.c b/drivers/i2c/muxes/i2c-mux-mlxcpld.c index 5ed55ca4fe93..53bce81cf5c9 100644 --- a/drivers/i2c/muxes/i2c-mux-mlxcpld.c +++ b/drivers/i2c/muxes/i2c-mux-mlxcpld.c @@ -1,35 +1,8 @@ +// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 /* - * drivers/i2c/muxes/i2c-mux-mlxcpld.c - * Copyright (c) 2016 Mellanox Technologies. All rights reserved. - * Copyright (c) 2016 Michael Shych + * Mellanox i2c mux driver * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the names of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Copyright (C) 2016-2020 Mellanox Technologies */ #include From patchwork Wed Nov 18 14:44:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Pasternak X-Patchwork-Id: 327652 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4B73CC63798 for ; Wed, 18 Nov 2020 14:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CBFBE221FE for ; Wed, 18 Nov 2020 14:44:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727010AbgKROo2 (ORCPT ); Wed, 18 Nov 2020 09:44:28 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48208 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727021AbgKROo2 (ORCPT ); Wed, 18 Nov 2020 09:44:28 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from vadimp@nvidia.com) with SMTP; 18 Nov 2020 16:44:22 +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 0AIEiIHt008040; Wed, 18 Nov 2020 16:44:22 +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 2/6] platform/x86: mlxcpld: Update module license Date: Wed, 18 Nov 2020 16:44:12 +0200 Message-Id: <20201118144416.184120-3-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 Update license to SPDX-License. Signed-off-by: Vadim Pasternak --- include/linux/platform_data/x86/mlxcpld.h | 34 +++---------------------------- 1 file changed, 3 insertions(+), 31 deletions(-) diff --git a/include/linux/platform_data/x86/mlxcpld.h b/include/linux/platform_data/x86/mlxcpld.h index b08dcb183fca..e6c18bf017dd 100644 --- a/include/linux/platform_data/x86/mlxcpld.h +++ b/include/linux/platform_data/x86/mlxcpld.h @@ -1,36 +1,8 @@ +/* SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0 */ /* - * mlxcpld.h - Mellanox I2C multiplexer support in CPLD + * Mellanox I2C multiplexer support in CPLD * - * Copyright (c) 2016 Mellanox Technologies. All rights reserved. - * Copyright (c) 2016 Michael Shych - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the names of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * Alternatively, this software may be distributed under the terms of the - * GNU General Public License ("GPL") version 2 as published by the Free - * Software Foundation. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. + * Copyright (C) 2016-2020 Mellanox Technologies */ #ifndef _LINUX_I2C_MLXCPLD_H From patchwork Wed Nov 18 14:44:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Pasternak X-Patchwork-Id: 327650 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E757AC6379F for ; Wed, 18 Nov 2020 14:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5ED8F2168B for ; Wed, 18 Nov 2020 14:44:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727021AbgKROo3 (ORCPT ); Wed, 18 Nov 2020 09:44:29 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:48217 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727023AbgKROo3 (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:24 +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 0AIEiIHw008040; Wed, 18 Nov 2020 16:44:24 +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 5/6] i2c: mux: mlxcpld: Extend driver to support word address space devices Date: Wed, 18 Nov 2020 16:44:15 +0200 Message-Id: <20201118144416.184120-6-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 Extend driver to allow I2C routing control through CPLD devices with word address space. Till now only CPLD devices with byte address space have been supported. Signed-off-by: Vadim Pasternak Reviewed-by: Michael Shych --- drivers/i2c/muxes/i2c-mux-mlxcpld.c | 57 +++++++++++++++++++++++++++-------- include/linux/platform_data/mlxcpld.h | 2 ++ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-mlxcpld.c b/drivers/i2c/muxes/i2c-mux-mlxcpld.c index 6bb8caecf8e8..c76180919fc3 100644 --- a/drivers/i2c/muxes/i2c-mux-mlxcpld.c +++ b/drivers/i2c/muxes/i2c-mux-mlxcpld.c @@ -21,11 +21,13 @@ * @last_chan - last register value * @client - I2C device client * @pdata: platform data + * @sel_buf: I2C message buffer for mux select 16 bits transactions */ struct mlxcpld_mux { u8 last_chan; struct i2c_client *client; struct mlxcpld_mux_plat_data pdata; + u8 sel_buf[3]; }; /* MUX logic description. @@ -60,26 +62,42 @@ struct mlxcpld_mux { * for this as they will try to lock adapter a second time. */ static int mlxcpld_mux_reg_write(struct i2c_adapter *adap, - struct mlxcpld_mux *mux, u8 val) + struct mlxcpld_mux *mux, int chan) { struct i2c_client *client = mux->client; - union i2c_smbus_data data = { .byte = val }; - - return __i2c_smbus_xfer(adap, client->addr, client->flags, - I2C_SMBUS_WRITE, mux->pdata.sel_reg_addr, - I2C_SMBUS_BYTE_DATA, &data); + union i2c_smbus_data data; + struct i2c_msg msg; + + switch (mux->pdata.reg_size) { + case 1: + data.byte = (chan < 0) ? 0 : chan; + return __i2c_smbus_xfer(adap, client->addr, client->flags, + I2C_SMBUS_WRITE, + mux->pdata.sel_reg_addr, + I2C_SMBUS_BYTE_DATA, &data); + case 2: + mux->sel_buf[mux->pdata.reg_size] = (chan < 0) ? 0 : + mux->pdata.adap_ids[chan]; + msg.addr = client->addr; + msg.buf = mux->sel_buf; + msg.len = mux->pdata.reg_size + 1; + msg.flags = 0; + return __i2c_transfer(adap, &msg, 1); + default: + return -EINVAL; + } } static int mlxcpld_mux_select_chan(struct i2c_mux_core *muxc, u32 chan) { struct mlxcpld_mux *mux = i2c_mux_priv(muxc); - u8 regval = chan + 1; int err = 0; /* Only select the channel if its different from the last channel */ - if (mux->last_chan != regval) { - err = mlxcpld_mux_reg_write(muxc->parent, mux, regval); - mux->last_chan = err < 0 ? 0 : regval; + chan++; + if (mux->last_chan != chan) { + err = mlxcpld_mux_reg_write(muxc->parent, mux, chan); + mux->last_chan = err < 0 ? 0 : chan; } return err; @@ -103,13 +121,26 @@ static int mlxcpld_mux_probe(struct platform_device *pdev) struct i2c_mux_core *muxc; int num, force; struct mlxcpld_mux *data; + u16 sel_reg_addr = 0; + u32 func; int err; if (!pdata) return -EINVAL; - if (!i2c_check_functionality(client->adapter, - I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) + switch (pdata->reg_size) { + case 1: + func = I2C_FUNC_SMBUS_WRITE_BYTE_DATA; + break; + case 2: + func = I2C_FUNC_SMBUS_WRITE_WORD_DATA; + sel_reg_addr = cpu_to_be16(pdata->sel_reg_addr); + break; + default: + return -EINVAL; + } + + if (!i2c_check_functionality(client->adapter, func)) return -ENODEV; muxc = i2c_mux_alloc(client->adapter, &pdev->dev, CPLD_MUX_MAX_NCHANS, @@ -122,6 +153,8 @@ static int mlxcpld_mux_probe(struct platform_device *pdev) data = i2c_mux_priv(muxc); data->client = client; memcpy(&data->pdata, pdata, sizeof(*pdata)); + /* Save mux select address for 16 bits transaction size. */ + memcpy(data->sel_buf, &sel_reg_addr, 2); data->last_chan = 0; /* force the first selection */ /* Create an adapter for each channel. */ diff --git a/include/linux/platform_data/mlxcpld.h b/include/linux/platform_data/mlxcpld.h index e6c18bf017dd..da4f7e8f5721 100644 --- a/include/linux/platform_data/mlxcpld.h +++ b/include/linux/platform_data/mlxcpld.h @@ -14,11 +14,13 @@ * @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 *adap_ids; int num_adaps; int sel_reg_addr; + u8 reg_size; }; #endif /* _LINUX_I2C_MLXCPLD_H */ 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: 327651 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91973C64E69 for ; Wed, 18 Nov 2020 14:44:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 313FC2151B for ; Wed, 18 Nov 2020 14:44:56 +0000 (UTC) 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;