From 7606c377f56ab68421aa482b1ded6840d426e197 Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Sat, 11 Feb 2017 10:57:23 -0800 Subject: device: Add a new "SPI" device type Add support for a new "SPI" device type in the devicetree to bind a device on the SPI bus. Allow device to provide chip select number for the device as a parameter. Add spi_bus_operations with operation dev_to_bus which allows SoCs to define a translation method for converting "struct device" into a unique SPI bus number. BUG=chrome-os-partner:59832 BRANCH=None TEST=Compiles successfully. Change-Id: I86f09516d3cddd619fef23a4659c9e4eadbcf3fa Signed-off-by: Furquan Shaikh Reviewed-on: https://review.coreboot.org/18340 Reviewed-by: Duncan Laurie Tested-by: build bot (Jenkins) --- src/device/device_util.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/device') diff --git a/src/device/device_util.c b/src/device/device_util.c index 1a0a60fdb3..e31ade56c0 100644 --- a/src/device/device_util.c +++ b/src/device/device_util.c @@ -250,6 +250,9 @@ u32 dev_path_encode(device_t dev) case DEVICE_PATH_GENERIC: ret |= dev->path.generic.subid << 8 | dev->path.generic.id; break; + case DEVICE_PATH_SPI: + ret |= dev->path.spi.cs; + break; case DEVICE_PATH_NONE: default: break; @@ -319,6 +322,10 @@ const char *dev_path(device_t dev) "GENERIC: %d.%d", dev->path.generic.id, dev->path.generic.subid); break; + case DEVICE_PATH_SPI: + snprintf(buffer, sizeof (buffer), "SPI: %02x", + dev->path.spi.cs); + break; default: printk(BIOS_ERR, "Unknown device path type: %d\n", dev->path.type); @@ -390,6 +397,9 @@ int path_eq(struct device_path *path1, struct device_path *path2) equal = (path1->generic.id == path2->generic.id) && (path1->generic.subid == path2->generic.subid); break; + case DEVICE_PATH_SPI: + equal = (path1->spi.cs == path2->spi.cs); + break; default: printk(BIOS_ERR, "Unknown device type: %d\n", path1->type); break; -- cgit v1.2.3