All of lore.kernel.org
 help / color / mirror / Atom feed
From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 4/4] i2c: muxes: Add support for TI PCA954X mux
Date: Mon, 18 Apr 2016 09:27:21 +0200	[thread overview]
Message-ID: <57148C59.90901@denx.de> (raw)
In-Reply-To: <78605bb6b60148dc1fe68567708769fdcda71eb0.1460636146.git.michal.simek@xilinx.com>

Hello Michal,

Am 14.04.2016 um 14:15 schrieb Michal Simek:
> Add support for common TI i2c mux which is available on ZynqMP zcu102
> board.
> DM i2c mux core code is selecting/deselecting bus before/after
> every command is performed that's why only one channel is active at a
> time. That's also the reason why deselect is just disable all available
> channels.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
>   drivers/i2c/muxes/Kconfig   |  7 ++++
>   drivers/i2c/muxes/Makefile  |  1 +
>   drivers/i2c/muxes/pca954x.c | 79 +++++++++++++++++++++++++++++++++++++++++++++
>   3 files changed, 87 insertions(+)
>   create mode 100644 drivers/i2c/muxes/pca954x.c

Thanks for your work!

I added Simon to CC, as he is the DM expert ;-)

from my side, your patch looks fine, so:

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
> diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig
> index f959d9de9e8b..e16b902f9611 100644
> --- a/drivers/i2c/muxes/Kconfig
> +++ b/drivers/i2c/muxes/Kconfig
> @@ -24,3 +24,10 @@ config I2C_ARB_GPIO_CHALLENGE
>   	  I2C multimaster arbitration scheme using GPIOs and a challenge &
>   	  response mechanism where masters have to claim the bus by asserting
>   	  a GPIO.
> +
> +config I2C_MUX_PCA954X
> +        tristate "TI PCA954x I2C Mux/switches"
> +        depends on I2C_MUX
> +        help
> +          If you say yes here you get support for the TI PCA954x
> +          I2C mux/switch devices.
> diff --git a/drivers/i2c/muxes/Makefile b/drivers/i2c/muxes/Makefile
> index 47c1240d7e9e..fb2d67ec9a97 100644
> --- a/drivers/i2c/muxes/Makefile
> +++ b/drivers/i2c/muxes/Makefile
> @@ -5,3 +5,4 @@
>   #
>   obj-$(CONFIG_I2C_ARB_GPIO_CHALLENGE) += i2c-arb-gpio-challenge.o
>   obj-$(CONFIG_$(SPL_)I2C_MUX) += i2c-mux-uclass.o
> +obj-$(CONFIG_I2C_MUX_PCA954X) += pca954x.o
> diff --git a/drivers/i2c/muxes/pca954x.c b/drivers/i2c/muxes/pca954x.c
> new file mode 100644
> index 000000000000..206581d3d908
> --- /dev/null
> +++ b/drivers/i2c/muxes/pca954x.c
> @@ -0,0 +1,79 @@
> +/*
> + * Copyright (C) 2015 - 2016 Xilinx, Inc.
> + * Written by Michal Simek
> + *
> + * SPDX-License-Identifier:	GPL-2.0+
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <errno.h>
> +#include <i2c.h>
> +#include <asm/gpio.h>
> +
> +DECLARE_GLOBAL_DATA_PTR;
> +
> +struct pca95xx_priv {
> +	u32 addr;
> +	u32 width;
> +};
> +
> +static int pca95xx_deselect(struct udevice *mux, struct udevice *bus,
> +			    uint channel)
> +{
> +	struct pca95xx_priv *priv = dev_get_priv(mux);
> +	uchar byte = 0;
> +
> +	return dm_i2c_write(mux, priv->addr, &byte, 1);
> +}
> +
> +static int pca95xx_select(struct udevice *mux, struct udevice *bus,
> +			  uint channel)
> +{
> +	struct pca95xx_priv *priv = dev_get_priv(mux);
> +	uchar byte = 1 << channel;
> +
> +	return dm_i2c_write(mux, priv->addr, &byte, 1);
> +}
> +
> +static const struct i2c_mux_ops pca95xx_ops = {
> +	.select = pca95xx_select,
> +	.deselect = pca95xx_deselect,
> +};
> +
> +static const struct udevice_id pca95xx_ids[] = {
> +	{ .compatible = "nxp,pca9548", .data = (ulong)8 },
> +	{ .compatible = "nxp,pca9544", .data = (ulong)4 },
> +	{ }
> +};
> +
> +static int pca95xx_ofdata_to_platdata(struct udevice *dev)
> +{
> +	struct pca95xx_priv *priv = dev_get_priv(dev);
> +
> +	priv->addr = dev_get_addr(dev);
> +	if (!priv->addr) {
> +		debug("MUX not found\n");
> +		return -ENOSYS;
> +	}
> +	priv->width = dev_get_driver_data(dev);
> +
> +	if (!priv->width) {
> +		debug("No I2C MUX width specified\n");
> +		return -ENOSYS;
> +	}
> +
> +	debug("Device %s at 0x%x with width %d\n",
> +	      dev->name, priv->addr, priv->width);
> +
> +	return 0;
> +}
> +
> +U_BOOT_DRIVER(pca95xx) = {
> +	.name = "pca95xx",
> +	.id = UCLASS_I2C_MUX,
> +	.of_match = pca95xx_ids,
> +	.ops = &pca95xx_ops,
> +	.ofdata_to_platdata = pca95xx_ofdata_to_platdata,
> +	.priv_auto_alloc_size = sizeof(struct pca95xx_priv),
> +};
>

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

  reply	other threads:[~2016-04-18  7:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-14 12:15 [U-Boot] [PATCH 1/4] i2c: cdns: Read address from DT in ofdata_to_platdata Michal Simek
2016-04-14 12:15 ` [U-Boot] [PATCH 2/4] i2c: cdns: Moving speed setup from probe to set_bus_speed function Michal Simek
2016-04-18  6:48   ` Heiko Schocher
2016-04-14 12:15 ` [U-Boot] [PATCH 3/4] i2c: cdns: Support different bus speeds Michal Simek
2016-04-18  7:08   ` Heiko Schocher
2016-04-18 11:09     ` Michal Simek
2016-04-14 12:15 ` [U-Boot] [PATCH 4/4] i2c: muxes: Add support for TI PCA954X mux Michal Simek
2016-04-18  7:27   ` Heiko Schocher [this message]
2016-04-20 14:41   ` Simon Glass
2016-04-25  8:36     ` Michal Simek
2016-04-18  6:47 ` [U-Boot] [PATCH 1/4] i2c: cdns: Read address from DT in ofdata_to_platdata Heiko Schocher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57148C59.90901@denx.de \
    --to=hs@denx.de \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.