2 * Copyright (C) 2015 - 2016 Xilinx, Inc.
3 * Written by Michal Simek
5 * SPDX-License-Identifier: GPL-2.0+
14 DECLARE_GLOBAL_DATA_PTR;
17 u32 addr; /* I2C mux address */
18 u32 width; /* I2C mux width - number of busses */
21 static int pca954x_deselect(struct udevice *mux, struct udevice *bus,
24 struct pca954x_priv *priv = dev_get_priv(mux);
27 return dm_i2c_write(mux, priv->addr, &byte, 1);
30 static int pca954x_select(struct udevice *mux, struct udevice *bus,
33 struct pca954x_priv *priv = dev_get_priv(mux);
34 uchar byte = 1 << channel;
36 return dm_i2c_write(mux, priv->addr, &byte, 1);
39 static const struct i2c_mux_ops pca954x_ops = {
40 .select = pca954x_select,
41 .deselect = pca954x_deselect,
44 static const struct udevice_id pca954x_ids[] = {
45 { .compatible = "nxp,pca9548", .data = (ulong)8 },
46 { .compatible = "nxp,pca9544", .data = (ulong)4 },
50 static int pca954x_ofdata_to_platdata(struct udevice *dev)
52 struct pca954x_priv *priv = dev_get_priv(dev);
54 priv->addr = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev), "reg", 0);
56 debug("MUX not found\n");
59 priv->width = dev_get_driver_data(dev);
62 debug("No I2C MUX width specified\n");
66 debug("Device %s at 0x%x with width %d\n",
67 dev->name, priv->addr, priv->width);
72 U_BOOT_DRIVER(pca954x) = {
75 .of_match = pca954x_ids,
77 .ofdata_to_platdata = pca954x_ofdata_to_platdata,
78 .priv_auto_alloc_size = sizeof(struct pca954x_priv),