summaryrefslogtreecommitdiff
path: root/src/device/device_util.c
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@chromium.org>2017-02-11 10:57:23 -0800
committerFurquan Shaikh <furquan@google.com>2017-02-16 08:41:28 +0100
commit7606c377f56ab68421aa482b1ded6840d426e197 (patch)
treee25c60cc8e33127ce9193c7190ff8e1299d173fd /src/device/device_util.c
parente67002968b6ebc69c5a94fb2cee17af3845268c9 (diff)
downloadcoreboot-7606c377f56ab68421aa482b1ded6840d426e197.tar.xz
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 <furquan@chromium.org> Reviewed-on: https://review.coreboot.org/18340 Reviewed-by: Duncan Laurie <dlaurie@chromium.org> Tested-by: build bot (Jenkins)
Diffstat (limited to 'src/device/device_util.c')
-rw-r--r--src/device/device_util.c10
1 files changed, 10 insertions, 0 deletions
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;