Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp5688774ybn; Sun, 29 Sep 2019 03:48:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhUmwcTiMDbCeoxJDV0qz5TcATj7hbrldw11boXinBCa0HVtoLo01I3HD34YTKAqFuQVZ0 X-Received: by 2002:aa7:d9d2:: with SMTP id v18mr14051280eds.177.1569754082541; Sun, 29 Sep 2019 03:48:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569754082; cv=none; d=google.com; s=arc-20160816; b=Vk7QbHY2D3xNwfYbS14hXESTtsjYw5XqkpKDRz1uadQX7CQMePeCO6SLwblA931ZnD 2Lo3dhXf5didRMwwvqCGAy7wCQar7ExETAa9LMPfi/fBEezzhUFIVwp+Suv2XhZ8TYvk iFNMdVKRmckRvQIRpOVPamufzCMWErTEZ9sNggm76VBnTUqgH6mOk9g01VfW17t2lOTr tWZMN1dfYufK+/p2u20RzPlXHNWZ+Zkf9To58wbFsLo0dXt+dtu/TPpa9hxI0aBkkyfn Ajd7ryGO7ulGGs7D4Q5bq8bZXbGzbqIHV16+Ny+XPUIlhRq7dkoJl0YsJw1VnVb/2uyd 0gWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=UE94w/If4iaRPI3er1ytieWuROUtpQdvzgYKXbCjHbM=; b=kl4wtccveZpb67o93yzP6vIC1h/77B1A1OlKqh+qV0lFUaAsHxrA3jS7F7NEfQ3Vfp J5uNL6/J+YJpPAK3CPXie+Y/vWWjk9XPORW1qf3S0SEypkT68LhQDb+2k9aeeupcj+NX 9LAtD2p+l1I+2mWQPAuuSLqKMUypuDEEukBxeCldd2l0bnaXQZfTAnoBCrUNbpVnj70f U5Ga4CC3iw6K0Qe0xx1TtauuafUcNsM7yCOMyWugcounhYP1G2zE52EBvsrzjz/HQHju IjeaVyiVGh88b74FBFoHfw2A3pVUYYkTO7CUbsDlWUJiQ7IyjKRuKUEZre3rRnv0sOiE MOEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r26si5302012edx.61.2019.09.29.03.47.38; Sun, 29 Sep 2019 03:48:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728880AbfI2KrV (ORCPT + 99 others); Sun, 29 Sep 2019 06:47:21 -0400 Received: from inva020.nxp.com ([92.121.34.13]:50862 "EHLO inva020.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726149AbfI2KrV (ORCPT ); Sun, 29 Sep 2019 06:47:21 -0400 Received: from inva020.nxp.com (localhost [127.0.0.1]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 185221A019F; Sun, 29 Sep 2019 12:47:18 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva020.eu-rdc02.nxp.com (Postfix) with ESMTP id 811E61A0179; Sun, 29 Sep 2019 12:47:15 +0200 (CEST) Received: from titan.ap.freescale.net (TITAN.ap.freescale.net [10.192.208.233]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id E42CA4029A; Sun, 29 Sep 2019 18:47:11 +0800 (SGT) From: Biwen Li To: peda@axentia.se, leoyang.li@nxp.com Cc: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org, Biwen Li Subject: [PATCH] i2c: pca954x: Add property to skip disabling PCA954x MUX device Date: Sun, 29 Sep 2019 18:36:38 +0800 Message-Id: <20190929103638.46038-1-biwen.li@nxp.com> X-Mailer: git-send-email 2.9.5 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On some Layerscape boards like LS2085ARDB and LS2088ARDB, input pull-up resistors on PCA954x MUX device are missing on board, So, if MUX are disabled after powered-on, input lines will float leading to incorrect functionality. Hence, PCA954x MUX device should never be turned-off after power-on. Add property to skip disabling PCA954x MUX device if device tree contains "i2c-mux-never-disable" for PCA954x device node. Errata ID: E-00013 on board LS2085ARDB and LS2088ARDB (Board revision found on Rev.B, Rev.C and Rev.D) Signed-off-by: Biwen Li --- drivers/i2c/muxes/i2c-mux-pca954x.c | 33 +++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/drivers/i2c/muxes/i2c-mux-pca954x.c b/drivers/i2c/muxes/i2c-mux-pca954x.c index 923aa3a5a3dc..ea8aca54d572 100644 --- a/drivers/i2c/muxes/i2c-mux-pca954x.c +++ b/drivers/i2c/muxes/i2c-mux-pca954x.c @@ -93,6 +93,7 @@ struct pca954x { struct irq_domain *irq; unsigned int irq_mask; raw_spinlock_t lock; + u8 disable_mux; /* do not disable mux if val not 0 */ }; /* Provide specs for the PCA954x types we know about */ @@ -258,6 +259,11 @@ static int pca954x_deselect_mux(struct i2c_mux_core *muxc, u32 chan) struct i2c_client *client = data->client; s8 idle_state; + if (data->disable_mux != 0) { + data->last_chan = data->chip->nchans; + return pca954x_reg_write(muxc->parent, client, data->disable_mux); + } + idle_state = READ_ONCE(data->idle_state); if (idle_state >= 0) /* Set the mux back to a predetermined channel */ @@ -462,16 +468,32 @@ static int pca954x_probe(struct i2c_client *client, } } + /* Errata ID E-00013 on board LS2088ARDB and LS2088ARDB: + * The point here is that you must not disable a mux if there + * are no pullups on the input or you mess up the I2C. This + * needs to be put into the DTS really as the kernel cannot + * know this otherwise. + */ + + data->disable_mux = np && + of_property_read_bool(np, "i2c-mux-never-disable") && + data->chip->muxtype == pca954x_ismux ? + data->chip->enable : 0; + /* Write the mux register at addr to verify * that the mux is in fact present. This also * initializes the mux to disconnected state. */ - if (i2c_smbus_write_byte(client, 0) < 0) { + if (i2c_smbus_write_byte(client, data->disable_mux) < 0) { dev_warn(dev, "probe failed\n"); return -ENODEV; } - data->last_chan = 0; /* force the first selection */ + if (data->disable_mux != 0) + data->last_chan = data->chip->nchans; + else + data->last_chan = 0; /* force the first selection */ + data->idle_state = MUX_IDLE_AS_IS; idle_disconnect_dt = np && @@ -531,8 +553,11 @@ static int pca954x_resume(struct device *dev) struct i2c_mux_core *muxc = i2c_get_clientdata(client); struct pca954x *data = i2c_mux_priv(muxc); - data->last_chan = 0; - return i2c_smbus_write_byte(client, 0); + if (data->disable_mux != 0) + data->last_chan = data->chip->nchans; + else + data->last_chan = 0; + return i2c_smbus_write_byte(client, data->disable_mux); } #endif -- 2.17.1