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)
This commit is contained in:
Furquan Shaikh
2017-02-11 10:57:23 -08:00
committed by Furquan Shaikh
parent e67002968b
commit 7606c377f5
4 changed files with 51 additions and 1 deletions

View File

@@ -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;