Commit c70c71d8334216e272c33c35aff39e42d7c5185e

Authored by Simon Glass
1 parent 63656b762e

dm: i2c: Add I2C emulation driver for sandbox

In order to test I2C we need some sort of emulation interface. Add hooks
to allow a driver to emulate an I2C device for sandbox.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Heiko Schocher <hs@denx.de>
Reviewed-by: Masahiro Yamada <yamada.m@jp.panasonic.com>

Showing 3 changed files with 16 additions and 0 deletions Side-by-side Diff

drivers/i2c/Makefile
... ... @@ -27,6 +27,7 @@
27 27 obj-$(CONFIG_SYS_I2C_PPC4XX) += ppc4xx_i2c.o
28 28 obj-$(CONFIG_SYS_I2C_RCAR) += rcar_i2c.o
29 29 obj-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o
  30 +obj-$(CONFIG_SYS_I2C_SANDBOX) += i2c-emul-uclass.o
30 31 obj-$(CONFIG_SYS_I2C_SH) += sh_i2c.o
31 32 obj-$(CONFIG_SYS_I2C_SOFT) += soft_i2c.o
32 33 obj-$(CONFIG_SYS_I2C_TEGRA) += tegra_i2c.o
drivers/i2c/i2c-emul-uclass.c
  1 +/*
  2 + * Copyright (c) 2014 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + */
  6 +
  7 +#include <common.h>
  8 +#include <dm.h>
  9 +#include <i2c.h>
  10 +
  11 +UCLASS_DRIVER(i2c_emul) = {
  12 + .id = UCLASS_I2C_EMUL,
  13 + .name = "i2c_emul",
  14 +};
include/dm/uclass-id.h
... ... @@ -19,6 +19,7 @@
19 19 UCLASS_TEST_FDT,
20 20 UCLASS_TEST_BUS,
21 21 UCLASS_SPI_EMUL, /* sandbox SPI device emulator */
  22 + UCLASS_I2C_EMUL, /* sandbox I2C device emulator */
22 23 UCLASS_SIMPLE_BUS,
23 24  
24 25 /* U-Boot uclasses start here */