From patchwork Mon Jan 21 16:47:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Shearman X-Patchwork-Id: 1028761 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=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="N95WEkTC"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43jyCj4Js3z9s7T for ; Tue, 22 Jan 2019 03:48:01 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730171AbfAUQsA (ORCPT ); Mon, 21 Jan 2019 11:48:00 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:36813 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729940AbfAUQr7 (ORCPT ); Mon, 21 Jan 2019 11:47:59 -0500 Received: by mail-wr1-f68.google.com with SMTP id u4so24197106wrp.3; Mon, 21 Jan 2019 08:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sHbgmgpwNDM8hyU0ywe19gF8jTaoNhxjen0iEn2P3T0=; b=N95WEkTCjPk0VnsyEtFS1P74UoJFU90eGoRbipal8+Q2SucuWUH8YW8NvBKmH2Rb3/ 4wmGGTiRjznpJbulAUyBX+c/FotTsZ7nEOv8dGoX9z/R0t+HfBGbM81W1Se1LTKBInJQ vbNkkDsbDJ+Q3K91XhO8+TuA/8xUsugiHWlKx0abtX1e753HSkIbM9yZygdnWdlABZBL DAris+CqxCrXM1wS2ino9XEohpfMhYvTr9/RyA+FlnsBWWPLIXimJMRv+jtR8x23ZPg2 OBaA3es6xfEIZI36ephmFfKCDRguADraNQ8Hjp0DAsCMod4NTHRdO5aXvref0omIzCp8 M6Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=sHbgmgpwNDM8hyU0ywe19gF8jTaoNhxjen0iEn2P3T0=; b=RgWPBfgBbBztegh+nf6pwnIYxv6H1SY4sm7pO8TJxC0bEnNFQXkv8bFUmsg6woebOc 2aEt7CgGCHcrni8xQxgsi/wK2JUar3P4FV/V59cjwKI6HQ6dJJRj4WJliP5PzoVWngsA 0xPsj0Erb+9wHiLF1icW/RSVUjZIL5VO37DDEN7/z/WrzGiMA6rUqIL/pubUBFhp3zz+ Kw13caF+uCnJ4KykTFGvMhMCIuwRGUkRDJBfWfDYTPDedjw8ccBX+b37xoxkSsi9UQ5B OBa8qCi83pi6BL25+7cSuuGzVdDpVhP0MbwoHYiHXAm5dvV18uV2wjTXlS429+RxJxRJ 1p9g== X-Gm-Message-State: AJcUukcNC59WjohcQgfaJy1oCk5zeFP2ifeuXcq+OMWRVq27rihhSXG+ BAtxA5WJVgf36gYApK3TmnM= X-Google-Smtp-Source: ALg8bN6MAaBOi+B5D4Ii5SvqELRf9kPG6GS3coQ1HXXpEwUQ+GyecGUbYnT1bMmPQFSBLPN8pbTxWA== X-Received: by 2002:adf:e247:: with SMTP id n7mr27625828wri.205.1548089277892; Mon, 21 Jan 2019 08:47:57 -0800 (PST) Received: from uks1.vyatta.net ([137.221.143.78]) by smtp.gmail.com with ESMTPSA id b18sm81681003wrw.83.2019.01.21.08.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 08:47:57 -0800 (PST) From: Robert Shearman To: Peter Rosin , Rob Herring , Mark Rutland Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, Robert Shearman Subject: [PATCH 1/2] i2c: mux: pca954x: change the default to deselect after each transfer Date: Mon, 21 Jan 2019 16:47:41 +0000 Message-Id: <20190121164742.35718-1-robertshearman@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Robert Shearman The behaviour, by default, to not deselect after each transfer is not safe/correct when there is a device with an address that conflicts with another device either on the parent bus, or on another pca954x mux on the same parent bus. Therefore, default to the least surprising mode, where the mux channels are deselected after each transaction, which is safe in the face of one or more devices hanging off the mux with addresses that conflict with other devices on different muxes, or on the parent bus. On systems where it is guaranteed that this is not the case, then the i2c-mux-no-idle-disconnect devicetree or no_deselect_on_exit platform data options can be used to improve the performance. Signed-off-by: Robert Shearman --- drivers/i2c/muxes/i2c-mux-pca954x.c | 16 +++++++++------- include/linux/platform_data/pca954x.h | 6 +++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index bfabf985e830..c2b6cff4ba3c 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -351,7 +351,7 @@ static int pca954x_probe(struct i2c_client *client, struct pca954x_platform_data *pdata = dev_get_platdata(&client->dev); struct device *dev = &client->dev; struct device_node *np = dev->of_node; - bool idle_disconnect_dt; + bool no_idle_disconnect_dt; struct gpio_desc *gpio; int num, force, class; struct i2c_mux_core *muxc; @@ -412,9 +412,10 @@ static int pca954x_probe(struct i2c_client *client, } data->last_chan = 0; /* force the first selection */ + data->deselect = GENMASK(data->chip->nchans, 0); - idle_disconnect_dt = np && - of_property_read_bool(np, "i2c-mux-idle-disconnect"); + no_idle_disconnect_dt = np && + of_property_read_bool(np, "i2c-mux-no-idle-disconnect"); ret = pca954x_irq_setup(muxc); if (ret) @@ -422,7 +423,7 @@ static int pca954x_probe(struct i2c_client *client, /* Now create an adapter for each channel */ for (num = 0; num < data->chip->nchans; num++) { - bool idle_disconnect_pd = false; + bool no_idle_disconnect_pd = false; force = 0; /* dynamic adap number */ class = 0; /* no class by default */ @@ -434,10 +435,11 @@ static int pca954x_probe(struct i2c_client *client, } else /* discard unconfigured channels */ break; - idle_disconnect_pd = pdata->modes[num].deselect_on_exit; + no_idle_disconnect_pd = + pdata->modes[num].no_deselect_on_exit; } - data->deselect |= (idle_disconnect_pd || - idle_disconnect_dt) << num; + data->deselect &= ~((no_idle_disconnect_pd || + no_idle_disconnect_dt) << num); ret = i2c_mux_add_adapter(muxc, force, num, class); if (ret) diff --git a/include/linux/platform_data/pca954x.h b/include/linux/platform_data/pca954x.h index 1712677d5904..cb5359797867 100644 --- a/include/linux/platform_data/pca954x.h +++ b/include/linux/platform_data/pca954x.h @@ -29,13 +29,13 @@ /* Per channel initialisation data: * @adap_id: bus number for the adapter. 0 = don't care - * @deselect_on_exit: set this entry to 1, if your H/W needs deselection - * of this channel after transaction. + * @no_deselect_on_exit: set this entry to 1, if your H/W doesn't need + * deselection of this channel after transaction. * */ struct pca954x_platform_mode { int adap_id; - unsigned int deselect_on_exit:1; + unsigned int no_deselect_on_exit:1; unsigned int class; }; From patchwork Mon Jan 21 16:47:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robert Shearman X-Patchwork-Id: 1028762 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=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-i2c-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="GKwPMnlw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 43jyCl0wLKz9s7T for ; Tue, 22 Jan 2019 03:48:03 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729940AbfAUQsB (ORCPT ); Mon, 21 Jan 2019 11:48:01 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35797 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729974AbfAUQsA (ORCPT ); Mon, 21 Jan 2019 11:48:00 -0500 Received: by mail-wm1-f66.google.com with SMTP id t200so11553969wmt.0; Mon, 21 Jan 2019 08:47:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6PGyJmqrTBAEA/g/NgTfciMLpJlDF5jYR6POS0gvJiE=; b=GKwPMnlwKWzK7rFr7RR8O4pi8Vi4IlV8q9C8YzoZDxsufAEHORB0PnRayZoyI+vHFu tXYYKtJUMQ/pKb5UsfYjyl4fg4k21222DX7USgg2ceValN9n637TThqCkp6Zl5EreiVL pY984K6V/yVxKGe830lK4Zf8x2Wf/iX6VpBqQWj1qVRubg+ArEWUyscrJ5uZXi6hT/rm WxtNm/Y42KiHkt/JZI53S9a3HH6HYYk6Q2Aaw4YwRNqTp+rO9vif9EJsjmRKuHi5e7Yz /blQPVX7ubgt4uFCdjOekkE++Cc3gyIWwXW/HxAVMGpQL2uFFJDWsdvuqPn+Y91MxPlu BorA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6PGyJmqrTBAEA/g/NgTfciMLpJlDF5jYR6POS0gvJiE=; b=ST5QgNj9QJQolqIoPHmwHJ77Y3wthoQrqogDQTH1YcsHw/hzkedUoHanjtiGULxAsn 0/yCADi+Zy2yRXm61iI4I1MGDua1YnXcELjEhaJZfAknWNEaZL733wypgtaA8nlHMbcw xY1ObmaAR3w5qP98WPB2l0ZNgY5Y+AVHUt1ipCUEHj3qRff3D2QNDokNl/MYHMT8ROB5 lqe+sxZYaYnfiNynH7r/Kr06izs46TiJ+pLoh+lRcWEgvOJFh4QVXhgspW2kskrEXTSj mieZZxcgB0TX0OgcDwaKBo37sapdUIwmCVeQhMc0Rem/Jkrd6ScnyHRyIVQ0kkd/aNd0 wWXA== X-Gm-Message-State: AJcUukerVFr7hXh9Vp096XjZLWteiwcyP5sNadUGblGjYcggybhgCjcU ntkQPcKQaIbO5ehPGTJya5c= X-Google-Smtp-Source: ALg8bN5wvv6y/IEE3Mf5lksa5FPx0jOqK5X0AC+vtMi38Q2IWroXVGU7/gWaPk7F72ZE2SwpaFW0FA== X-Received: by 2002:a7b:c04e:: with SMTP id u14mr147944wmc.113.1548089278789; Mon, 21 Jan 2019 08:47:58 -0800 (PST) Received: from uks1.vyatta.net ([137.221.143.78]) by smtp.gmail.com with ESMTPSA id b18sm81681003wrw.83.2019.01.21.08.47.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 08:47:58 -0800 (PST) From: Robert Shearman To: Peter Rosin , Rob Herring , Mark Rutland Cc: linux-i2c@vger.kernel.org, devicetree@vger.kernel.org, Robert Shearman Subject: [PATCH 2/2] dt-bindings: i2c-mux-pca954x: Invert i2c-mux-idle-disconnect property Date: Mon, 21 Jan 2019 16:47:42 +0000 Message-Id: <20190121164742.35718-2-robertshearman@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190121164742.35718-1-robertshearman@gmail.com> References: <20190121164742.35718-1-robertshearman@gmail.com> MIME-Version: 1.0 Sender: linux-i2c-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-i2c@vger.kernel.org From: Robert Shearman Update the binding docs for i2c-mux-pca954x to reflect that the driver now defaults to idle-disconnect behaviour by removing the documentation of the previous i2c-mux-idle-disconnect property and introducing a new inverse i2c-mux-no-idle-disconnect property. Signed-off-by: Robert Shearman --- Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt index 30ac6a60f041..c3a94de8b3ef 100644 --- a/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt +++ b/Documentation/devicetree/bindings/i2c/i2c-mux-pca954x.txt @@ -25,9 +25,11 @@ Required Properties: Optional Properties: - reset-gpios: Reference to the GPIO connected to the reset input. - - i2c-mux-idle-disconnect: Boolean; if defined, forces mux to disconnect all - children in idle state. This is necessary for example, if there are several - multiplexers on the bus and the devices behind them use same I2C addresses. + - i2c-mux-no-idle-disconnect: Boolean; if defined, asks mux to not + disconnect children in idle state. This optimises I2C parent + operations and is useful if it is guaranteed that there are no + multiplexers on the bus with devices behind them using the same + I2C address. - interrupts: Interrupt mapping for IRQ. - interrupt-controller: Marks the device node as an interrupt controller. - #interrupt-cells : Should be two.