From: Heiko Schocher <hs@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 4/6] drivers/i2c/muxes/pca954x: Add pca9547 I2C mux support
Date: Wed, 7 Jun 2017 06:19:40 +0200 [thread overview]
Message-ID: <59377EDC.102@denx.de> (raw)
In-Reply-To: <20170606120437.26746-5-marek.behun@nic.cz>
Hello Marek,
Am 06.06.2017 um 14:04 schrieb Marek Behun:
> From: Marek Behún <marek.behun@nic.cz>
>
> This I2C mux is found, for example, on the Turris Omnia board.
>
> Signed-off-by: Marek Behun <marek.behun@nic.cz>
Reviewed-by: Heiko Schocher <hs@denx.de>
bye,
Heiko
>
> 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 },
> { }
> };
>
>
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
next prev parent reply other threads:[~2017-06-07 4:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-06 12:04 [U-Boot] [PATCH v3 0/6] Support for the Turris Omnia router Marek Behun
2017-06-06 12:04 ` [U-Boot] [PATCH v3 1/6] driver/ddr: Add support for setting timing in hws_topology_map Marek Behun
2017-06-06 12:19 ` Marek Behún
2017-06-06 12:27 ` Stefan Roese
2017-06-06 12:04 ` [U-Boot] [PATCH v3 2/6] orion_wdt: Support for the Orion Watchdog Marek Behun
2017-06-06 12:04 ` [U-Boot] [PATCH v3 3/6] arch/arm/dts: Add Turris Omnia device tree Marek Behun
2017-06-06 12:04 ` [U-Boot] [PATCH v3 4/6] drivers/i2c/muxes/pca954x: Add pca9547 I2C mux support Marek Behun
2017-06-07 4:19 ` Heiko Schocher [this message]
2017-06-06 12:04 ` [U-Boot] [PATCH v3 5/6] drivers/misc: Add basic support for ATSHA204A Crypto module Marek Behun
2017-06-06 12:04 ` [U-Boot] [PATCH v3 6/6] marvell: armada385: Add the Turris Omnia board Marek Behun
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=59377EDC.102@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox