[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)
This commit is contained in:
parent
183d468536
commit
f3e8760ff5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=300710
@ -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, "<unknown card>");
|
||||
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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user