From f3e8760ff54e2cacf386be021ce90e96eddc2de4 Mon Sep 17 00:00:00 2001 From: Adrian Chadd Date: Thu, 26 May 2016 06:35:11 +0000 Subject: [PATCH] [spibus] add initial placeholders for transfer mode and frequency. This doesn't yet implement it in the controllers or the transfer calls, but it's a start. Obtained from: loos (frequency), ray/zrouter (transfer mode) --- sys/dev/spibus/spibus.c | 9 +++++++++ sys/dev/spibus/spibusvar.h | 13 ++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) 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;