diff --git a/sys/dev/spibus/spibus.c b/sys/dev/spibus/spibus.c index bb3ad9342bdb..aced1b0f37e9 100644 --- a/sys/dev/spibus/spibus.c +++ b/sys/dev/spibus/spibus.c @@ -105,6 +105,7 @@ spibus_print_child(device_t dev, device_t child) retval += bus_print_child_header(dev, child); retval += printf(" at cs %d", devi->cs); + retval += printf(" mode %d", devi->mode); retval += bus_print_child_footer(dev, child); return (retval); @@ -117,6 +118,7 @@ spibus_probe_nomatch(device_t bus, device_t child) device_printf(bus, ""); printf(" at cs %d\n", devi->cs); + printf(" mode %d", devi->mode); return; } @@ -149,6 +151,11 @@ spibus_read_ivar(device_t bus, device_t child, int which, uintptr_t *result) case SPIBUS_IVAR_CS: *(uint32_t *)result = devi->cs; break; + case SPIBUS_IVAR_MODE: + *(uint32_t *)result = devi->mode; + break; + case SPIBUS_IVAR_CLOCK: + *(uint32_t *)result = devi->clock; } return (0); } @@ -179,7 +186,9 @@ spibus_hinted_child(device_t bus, const char *dname, int dunit) child = BUS_ADD_CHILD(bus, 0, dname, dunit); devi = SPIBUS_IVAR(child); + devi->mode = SPIBUS_MODE_NONE; resource_int_value(dname, dunit, "cs", &devi->cs); + resource_int_value(dname, dunit, "mode", &devi->mode); } static int diff --git a/sys/dev/spibus/spibusvar.h b/sys/dev/spibus/spibusvar.h index 9d4d4837cef2..33605f2b843d 100644 --- a/sys/dev/spibus/spibusvar.h +++ b/sys/dev/spibus/spibusvar.h @@ -34,13 +34,22 @@ struct spibus_softc device_t dev; }; +#define SPIBUS_MODE_NONE 0 +#define SPIBUS_MODE_CPHA 1 +#define SPIBUS_MODE_CPOL 2 +#define SPIBUS_MODE_CPOL_CPHA 3 + struct spibus_ivar { uint32_t cs; + uint32_t mode; + uint32_t clock; }; enum { - SPIBUS_IVAR_CS /* chip select that we're on */ + SPIBUS_IVAR_CS, /* chip select that we're on */ + SPIBUS_IVAR_MODE, /* SPI mode (0-3) */ + SPIBUS_IVAR_CLOCK, /* maximum clock freq for device */ }; #define SPIBUS_ACCESSOR(A, B, T) \ @@ -52,6 +61,8 @@ spibus_get_ ## A(device_t dev, T *t) \ } SPIBUS_ACCESSOR(cs, CS, uint32_t) +SPIBUS_ACCESSOR(mode, MODE, uint32_t) +SPIBUS_ACCESSOR(clock, CLOCK, uint32_t) extern driver_t spibus_driver; extern devclass_t spibus_devclass;