svn commit: r300710 - head/sys/dev/spibus

Adrian Chadd adrian at FreeBSD.org
Thu May 26 06:35:13 UTC 2016


Author: adrian
Date: Thu May 26 06:35:11 2016
New Revision: 300710
URL: https://svnweb.freebsd.org/changeset/base/300710

Log:
  [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)

Modified:
  head/sys/dev/spibus/spibus.c
  head/sys/dev/spibus/spibusvar.h

Modified: head/sys/dev/spibus/spibus.c
==============================================================================
--- head/sys/dev/spibus/spibus.c	Thu May 26 03:55:27 2016	(r300709)
+++ head/sys/dev/spibus/spibus.c	Thu May 26 06:35:11 2016	(r300710)
@@ -105,6 +105,7 @@ spibus_print_child(device_t dev, device_
 
 	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, devic
 
 	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 
 	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 
 
 	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

Modified: head/sys/dev/spibus/spibusvar.h
==============================================================================
--- head/sys/dev/spibus/spibusvar.h	Thu May 26 03:55:27 2016	(r300709)
+++ head/sys/dev/spibus/spibusvar.h	Thu May 26 06:35:11 2016	(r300710)
@@ -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;


More information about the svn-src-all mailing list