]> git.ipfire.org Git - thirdparty/u-boot.git/blame - board/freescale/common/i2c_mux.c
Revert "Merge patch series "arm: dts: am62-beagleplay: Fix Beagleplay Ethernet""
[thirdparty/u-boot.git] / board / freescale / common / i2c_mux.c
CommitLineData
15347d2d
SC
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2014 Freescale Semiconductor, Inc.
4 * Copyright 2020-21 NXP
5 * Copyright 2021 Microsoft Corporation
6 */
7
d678a59d 8#include <common.h>
15347d2d
SC
9#include <i2c.h>
10#include "i2c_common.h"
11#include "i2c_mux.h"
12
13/*
14 * A new Kconfig option for something that used to always be built should be
81f3a665 15 * "default y".
15347d2d
SC
16 */
17#ifdef CONFIG_FSL_USE_PCA9547_MUX
18
19int select_i2c_ch_pca9547(u8 ch, int bus)
20{
21 int ret;
22 DEVICE_HANDLE_T dev;
23
24 /* Open device handle */
25 ret = fsl_i2c_get_device(I2C_MUX_PCA_ADDR_PRI, bus, &dev);
26 if (ret) {
27 printf("PCA: No PCA9547 device found\n");
28 return ret;
29 }
30
31 ret = I2C_WRITE(dev, 0, &ch, sizeof(ch));
32 if (ret) {
33 printf("PCA: Unable to select channel %d (%d)\n", (int)ch, ret);
34 return ret;
35 }
36
37 return 0;
38}
39
40#endif