From patchwork Fri Jun 9 17:28:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marek_Beh=C3=BAn?= X-Patchwork-Id: 774088 X-Patchwork-Delegate: sr@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 3wkq7z1pzTz9sN5 for ; Sat, 10 Jun 2017 03:30:55 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=nic.cz header.i=@nic.cz header.b="Nn9NdzcV"; dkim-atps=neutral Received: by lists.denx.de (Postfix, from userid 105) id DE851C21C6D; Fri, 9 Jun 2017 17:30:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7E182C21CA3; Fri, 9 Jun 2017 17:29:02 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 305C6C21C2A; Fri, 9 Jun 2017 17:28:58 +0000 (UTC) Received: from mail.nic.cz (mail.nic.cz [217.31.204.67]) by lists.denx.de (Postfix) with ESMTPS id 659A5C21C3E for ; Fri, 9 Jun 2017 17:28:58 +0000 (UTC) Received: from dellmb.labs.office.nic.cz (unknown [IPv6:2001:1488:fffe:6:8982:ed8c:62b1:c0c8]) by mail.nic.cz (Postfix) with ESMTP id 1EC8162244; Fri, 9 Jun 2017 19:28:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=nic.cz; s=default; t=1497029338; bh=aNE2w+IKhUu+iIFf8lYpHiwt88elFV/XDhh5L8jWiPw=; h=From:To:Date; b=Nn9NdzcV4/QVVJqNcPQUWZKw03edE1loeuYJhAlu2TpoV1PZSpA20U0vzKiTxM2Ds fbONXtfQNS0CW9bXobhHxaxl6r0qHdNpjdgYnhqTmrju3zSb1ej3wMUwcHXAZ30byP eXqcWRu6CclnUXewHWA9FlEAHC8o+CYa9tIN6Uug= From: =?UTF-8?q?Marek=20Beh=C3=BAn?= To: u-boot@lists.denx.de Date: Fri, 9 Jun 2017 19:28:43 +0200 Message-Id: <20170609172845.10238-5-marek.behun@nic.cz> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170609172845.10238-1-marek.behun@nic.cz> References: <20170609172845.10238-1-marek.behun@nic.cz> X-Virus-Scanned: clamav-milter 0.99.2 at mail X-Virus-Status: Clean Cc: Tomas Hlavacek , Stefan Roese , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [U-Boot] [PATCH v4 4/7] drivers/i2c/muxes/pca954x: Add pca9547 I2C mux support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This I2C mux is found, for example, on the Turris Omnia board. Signed-off-by: Marek Behun Reviewed-by: Heiko Schocher diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c index 1a6761858c..383f72f552 100644 --- a/drivers/i2c/muxes/pca954x.c +++ b/drivers/i2c/muxes/pca954x.c @@ -13,11 +13,40 @@ DECLARE_GLOBAL_DATA_PTR; +enum pca_type { + PCA9544, + PCA9547, + PCA9548 +}; + +struct chip_desc { + u8 enable; + enum muxtype { + pca954x_ismux = 0, + pca954x_isswi, + } muxtype; +}; + struct pca954x_priv { u32 addr; /* I2C mux address */ u32 width; /* I2C mux width - number of busses */ }; +static const struct chip_desc chips[] = { + [PCA9544] = { + .enable = 0x4, + .muxtype = pca954x_ismux, + }, + [PCA9547] = { + .enable = 0x8, + .muxtype = pca954x_ismux, + }, + [PCA9548] = { + .enable = 0x8, + .muxtype = pca954x_isswi, + }, +}; + static int pca954x_deselect(struct udevice *mux, struct udevice *bus, uint channel) { @@ -31,7 +60,13 @@ static int pca954x_select(struct udevice *mux, struct udevice *bus, uint channel) { struct pca954x_priv *priv = dev_get_priv(mux); - uchar byte = 1 << channel; + const struct chip_desc *chip = &chips[dev_get_driver_data(mux)]; + uchar byte; + + if (chip->muxtype == pca954x_ismux) + byte = channel | chip->enable; + else + byte = 1 << channel; return dm_i2c_write(mux, priv->addr, &byte, 1); } @@ -42,8 +77,9 @@ static const struct i2c_mux_ops pca954x_ops = { }; static const struct udevice_id pca954x_ids[] = { - { .compatible = "nxp,pca9548", .data = (ulong)8 }, - { .compatible = "nxp,pca9544", .data = (ulong)4 }, + { .compatible = "nxp,pca9544", .data = PCA9544 }, + { .compatible = "nxp,pca9547", .data = PCA9547 }, + { .compatible = "nxp,pca9548", .data = PCA9548 }, { } };