From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Wed, 7 Jun 2017 06:19:40 +0200 Subject: [U-Boot] [PATCH v3 4/6] drivers/i2c/muxes/pca954x: Add pca9547 I2C mux support In-Reply-To: <20170606120437.26746-5-marek.behun@nic.cz> References: <20170606120437.26746-1-marek.behun@nic.cz> <20170606120437.26746-5-marek.behun@nic.cz> Message-ID: <59377EDC.102@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de Hello Marek, Am 06.06.2017 um 14:04 schrieb Marek Behun: > From: Marek Beh=C3=BAn > > This I2C mux is found, for example, on the Turris Omnia board. > > Signed-off-by: Marek Behun Reviewed-by: Heiko Schocher 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 =3D 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[] =3D { > + [PCA9544] =3D { > + .enable =3D 0x4, > + .muxtype =3D pca954x_ismux, > + }, > + [PCA9547] =3D { > + .enable =3D 0x8, > + .muxtype =3D pca954x_ismux, > + }, > + [PCA9548] =3D { > + .enable =3D 0x8, > + .muxtype =3D 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 =3D dev_get_priv(mux); > - uchar byte =3D 1 << channel; > + const struct chip_desc *chip =3D &chips[dev_get_driver_data(mux)]; > + uchar byte; > + > + if (chip->muxtype =3D=3D pca954x_ismux) > + byte =3D channel | chip->enable; > + else > + byte =3D 1 << channel; > > return dm_i2c_write(mux, priv->addr, &byte, 1); > } > @@ -42,8 +77,9 @@ static const struct i2c_mux_ops pca954x_ops =3D { > }; > > static const struct udevice_id pca954x_ids[] =3D { > - { .compatible =3D "nxp,pca9548", .data =3D (ulong)8 }, > - { .compatible =3D "nxp,pca9544", .data =3D (ulong)4 }, > + { .compatible =3D "nxp,pca9544", .data =3D PCA9544 }, > + { .compatible =3D "nxp,pca9547", .data =3D PCA9547 }, > + { .compatible =3D "nxp,pca9548", .data =3D PCA9548 }, > { } > }; > > --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany