Wed Jan 19 05:21:44 2022 UTC ()
Pass the device_t into spi_configure(), and make the API contract that
spi_configure() will print errors if they occur; the driver is off the
hook.


(thorpej)
diff -r1.8 -r1.9 src/sys/arch/evbarm/mpcsa/mpcsa_leds.c
diff -r1.19 -r1.20 src/sys/dev/spi/m25p.c
diff -r1.19 -r1.20 src/sys/dev/spi/spi.c
diff -r1.3 -r1.4 src/sys/dev/spi/mcp23xxxgpio_spi.c
diff -r1.3 -r1.4 src/sys/dev/spi/mcp3k.c
diff -r1.2 -r1.3 src/sys/dev/spi/mcp48x1.c
diff -r1.2 -r1.3 src/sys/dev/spi/scmdspi.c
diff -r1.10 -r1.11 src/sys/dev/spi/oj6sh.c
diff -r1.10 -r1.11 src/sys/dev/spi/spivar.h
diff -r1.12 -r1.13 src/sys/dev/spi/ssdfb_spi.c
diff -r1.6 -r1.7 src/sys/dev/spi/tmp121.c

cvs diff -r1.8 -r1.9 src/sys/arch/evbarm/mpcsa/mpcsa_leds.c (expand / switch to unified diff)

--- src/sys/arch/evbarm/mpcsa/mpcsa_leds.c 2022/01/19 05:05:45 1.8
+++ src/sys/arch/evbarm/mpcsa/mpcsa_leds.c 2022/01/19 05:21:44 1.9
@@ -1,15 +1,15 @@ @@ -1,15 +1,15 @@
1/* $Id: mpcsa_leds.c,v 1.8 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $Id: mpcsa_leds.c,v 1.9 2022/01/19 05:21:44 thorpej Exp $ */
2/* $NetBSD: mpcsa_leds.c,v 1.8 2022/01/19 05:05:45 thorpej Exp $ */ 2/* $NetBSD: mpcsa_leds.c,v 1.9 2022/01/19 05:21:44 thorpej Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2007 Embedtronics Oy. All rights reserved. 5 * Copyright (c) 2007 Embedtronics Oy. All rights reserved.
6 * 6 *
7 * Based on arch/arm/ep93xx/epgpio.c, 7 * Based on arch/arm/ep93xx/epgpio.c,
8 * Copyright (c) 2005 HAMAJIMA Katsuomi. All rights reserved. 8 * Copyright (c) 2005 HAMAJIMA Katsuomi. All rights reserved.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: mpcsa_leds.c,v 1.8 2022/01/19 05:05:45 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: mpcsa_leds.c,v 1.9 2022/01/19 05:21:44 thorpej Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/systm.h> 36#include <sys/systm.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <sys/device.h> 38#include <sys/device.h>
39#include <sys/lock.h> 39#include <sys/lock.h>
40#include <sys/gpio.h> 40#include <sys/gpio.h>
41#include <dev/spi/spivar.h> 41#include <dev/spi/spivar.h>
42#include <dev/gpio/gpiovar.h> 42#include <dev/gpio/gpiovar.h>
43#include <evbarm/mpcsa/mpcsa_leds_var.h> 43#include <evbarm/mpcsa/mpcsa_leds_var.h>
44#include <evbarm/mpcsa/mpcsa_io.h> 44#include <evbarm/mpcsa/mpcsa_io.h>
45#include "gpio.h" 45#include "gpio.h"
46#if NGPIO > 0 46#if NGPIO > 0
@@ -129,30 +129,28 @@ static void @@ -129,30 +129,28 @@ static void
129mpcsa_leds_attach(device_t parent, device_t self, void *aux) 129mpcsa_leds_attach(device_t parent, device_t self, void *aux)
130{ 130{
131 struct mpcsa_leds_softc *sc = device_private(self); 131 struct mpcsa_leds_softc *sc = device_private(self);
132 struct spi_attach_args *sa = aux; 132 struct spi_attach_args *sa = aux;
133#if NGPIO > 0 133#if NGPIO > 0
134 struct gpiobus_attach_args gba; 134 struct gpiobus_attach_args gba;
135#endif 135#endif
136 int n; 136 int n;
137 int error; 137 int error;
138 138
139 aprint_naive(": output buffer\n"); 139 aprint_naive(": output buffer\n");
140 aprint_normal(": 74HC595 or compatible shift register(s)\n"); 140 aprint_normal(": 74HC595 or compatible shift register(s)\n");
141 141
142 error = spi_configure(sa->sa_handle, SPI_MODE_0, 10000000); 142 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 10000000);
143 if (error) { 143 if (error) {
144 aprint_error_dev(self, 
145 "failed to set Mode 0 @ 10MHz, error=%d\n", error); 
146 return; 144 return;
147 } 145 }
148 146
149 sc->sc_sh = sa->sa_handle; 147 sc->sc_sh = sa->sa_handle;
150 sc->sc_pinstate = 0xffff; 148 sc->sc_pinstate = 0xffff;
151 callout_init(&sc->sc_c, 0); 149 callout_init(&sc->sc_c, 0);
152 150
153#if NGPIO > 0 151#if NGPIO > 0
154 /* initialize and attach gpio(4) */ 152 /* initialize and attach gpio(4) */
155 for (n = 0; n < MPCSA_LEDS_NPINS; n++) { 153 for (n = 0; n < MPCSA_LEDS_NPINS; n++) {
156 sc->sc_pins[n].pin_num = n; 154 sc->sc_pins[n].pin_num = n;
157 sc->sc_pins[n].pin_caps = (GPIO_PIN_OUTPUT 155 sc->sc_pins[n].pin_caps = (GPIO_PIN_OUTPUT
158 | GPIO_PIN_PUSHPULL); 156 | GPIO_PIN_PUSHPULL);

cvs diff -r1.19 -r1.20 src/sys/dev/spi/m25p.c (expand / switch to unified diff)

--- src/sys/dev/spi/m25p.c 2022/01/19 05:05:45 1.19
+++ src/sys/dev/spi/m25p.c 2022/01/19 05:21:44 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: m25p.c,v 1.19 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: m25p.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center. 4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
5 * Copyright (c) 2006 Garrett D'Amore. 5 * Copyright (c) 2006 Garrett D'Amore.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Portions of this code were written by Garrett D'Amore for the 8 * Portions of this code were written by Garrett D'Amore for the
9 * Champaign-Urbana Community Wireless Network Project. 9 * Champaign-Urbana Community Wireless Network Project.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or 11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following 12 * without modification, are permitted provided that the following
13 * conditions are met: 13 * conditions are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT
34 * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, 34 * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.19 2022/01/19 05:05:45 thorpej Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: m25p.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $");
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/device.h> 49#include <sys/device.h>
50#include <sys/kernel.h> 50#include <sys/kernel.h>
51 51
52#include <dev/sysmon/sysmonvar.h> 52#include <dev/sysmon/sysmonvar.h>
53 53
54#include <dev/spi/spivar.h> 54#include <dev/spi/spivar.h>
55#include <dev/spi/spiflash.h> 55#include <dev/spi/spiflash.h>
56 56
57/* 57/*
58 * Device driver for STMicroelectronics M25P Family SPI Flash Devices 58 * Device driver for STMicroelectronics M25P Family SPI Flash Devices
@@ -132,30 +132,28 @@ m25p_match(device_t parent, cfdata_t cf, @@ -132,30 +132,28 @@ m25p_match(device_t parent, cfdata_t cf,
132static void 132static void
133m25p_attach(device_t parent, device_t self, void *aux) 133m25p_attach(device_t parent, device_t self, void *aux)
134{ 134{
135 struct m25p_softc *sc = device_private(self); 135 struct m25p_softc *sc = device_private(self);
136 struct spi_attach_args *sa = aux; 136 struct spi_attach_args *sa = aux;
137 int error; 137 int error;
138 138
139 sc->sc_sh = sa->sa_handle; 139 sc->sc_sh = sa->sa_handle;
140 140
141 aprint_normal("\n"); 141 aprint_normal("\n");
142 aprint_naive("\n"); 142 aprint_naive("\n");
143 143
144 /* configure for 20MHz, which is the max for normal reads */ 144 /* configure for 20MHz, which is the max for normal reads */
145 error = spi_configure(sa->sa_handle, SPI_MODE_0, 20000000); 145 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 20000000);
146 if (error) { 146 if (error) {
147 aprint_error_dev(self, 
148 "failed to set Mode 0 @ 20MHz, error=%d\n", error); 
149 return; 147 return;
150 } 148 }
151 149
152 config_interrupts(self, m25p_doattach); 150 config_interrupts(self, m25p_doattach);
153} 151}
154 152
155static void 153static void
156m25p_doattach(device_t self) 154m25p_doattach(device_t self)
157{ 155{
158 struct m25p_softc *sc = device_private(self); 156 struct m25p_softc *sc = device_private(self);
159 const struct m25p_info *info; 157 const struct m25p_info *info;
160 uint8_t buf[4]; 158 uint8_t buf[4];
161 uint8_t cmd; 159 uint8_t cmd;

cvs diff -r1.19 -r1.20 src/sys/dev/spi/spi.c (expand / switch to unified diff)

--- src/sys/dev/spi/spi.c 2021/08/07 16:19:16 1.19
+++ src/sys/dev/spi/spi.c 2022/01/19 05:21:44 1.20
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: spi.c,v 1.19 2021/08/07 16:19:16 thorpej Exp $ */ 1/* $NetBSD: spi.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center. 4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
5 * Copyright (c) 2006 Garrett D'Amore. 5 * Copyright (c) 2006 Garrett D'Amore.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Portions of this code were written by Garrett D'Amore for the 8 * Portions of this code were written by Garrett D'Amore for the
9 * Champaign-Urbana Community Wireless Network Project. 9 * Champaign-Urbana Community Wireless Network Project.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or 11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following 12 * without modification, are permitted provided that the following
13 * conditions are met: 13 * conditions are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT
34 * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, 34 * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.19 2021/08/07 16:19:16 thorpej Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: spi.c,v 1.20 2022/01/19 05:21:44 thorpej Exp $");
46 46
47#include "locators.h" 47#include "locators.h"
48 48
49#include <sys/param.h> 49#include <sys/param.h>
50#include <sys/systm.h> 50#include <sys/systm.h>
51#include <sys/device.h> 51#include <sys/device.h>
52#include <sys/conf.h> 52#include <sys/conf.h>
53#include <sys/malloc.h> 53#include <sys/malloc.h>
54#include <sys/mutex.h> 54#include <sys/mutex.h>
55#include <sys/condvar.h> 55#include <sys/condvar.h>
56#include <sys/errno.h> 56#include <sys/errno.h>
57 57
58#include <dev/spi/spivar.h> 58#include <dev/spi/spivar.h>
@@ -418,31 +418,34 @@ spi_ioctl(dev_t dev, u_long cmd, void *d @@ -418,31 +418,34 @@ spi_ioctl(dev_t dev, u_long cmd, void *d
418CFATTACH_DECL_NEW(spi, sizeof(struct spi_softc), 418CFATTACH_DECL_NEW(spi, sizeof(struct spi_softc),
419 spi_match, spi_attach, NULL, NULL); 419 spi_match, spi_attach, NULL, NULL);
420 420
421/* 421/*
422 * Configure. This should be the first thing that the SPI driver 422 * Configure. This should be the first thing that the SPI driver
423 * should do, to configure which mode (e.g. SPI_MODE_0, which is the 423 * should do, to configure which mode (e.g. SPI_MODE_0, which is the
424 * same as Philips Microwire mode), and speed. If the bus driver 424 * same as Philips Microwire mode), and speed. If the bus driver
425 * cannot run fast enough, then it should just configure the fastest 425 * cannot run fast enough, then it should just configure the fastest
426 * mode that it can support. If the bus driver cannot run slow 426 * mode that it can support. If the bus driver cannot run slow
427 * enough, then the device is incompatible and an error should be 427 * enough, then the device is incompatible and an error should be
428 * returned. 428 * returned.
429 */ 429 */
430int 430int
431spi_configure(struct spi_handle *sh, int mode, int speed) 431spi_configure(device_t dev __unused, struct spi_handle *sh, int mode, int speed)
432{ 432{
433 433
434 sh->sh_mode = mode; 434 sh->sh_mode = mode;
435 sh->sh_speed = speed; 435 sh->sh_speed = speed;
 436
 437 /* No need to report errors; no failures. */
 438
436 return 0; 439 return 0;
437} 440}
438 441
439/* 442/*
440 * Acquire controller 443 * Acquire controller
441 */ 444 */
442static void 445static void
443spi_acquire(struct spi_handle *sh) 446spi_acquire(struct spi_handle *sh)
444{ 447{
445 struct spi_softc *sc = sh->sh_sc; 448 struct spi_softc *sc = sh->sh_sc;
446 449
447 mutex_enter(&sc->sc_lock); 450 mutex_enter(&sc->sc_lock);
448 while ((sc->sc_flags & SPIC_BUSY) != 0) 451 while ((sc->sc_flags & SPIC_BUSY) != 0)

cvs diff -r1.3 -r1.4 src/sys/dev/spi/mcp23xxxgpio_spi.c (expand / switch to unified diff)

--- src/sys/dev/spi/mcp23xxxgpio_spi.c 2022/01/19 05:05:45 1.3
+++ src/sys/dev/spi/mcp23xxxgpio_spi.c 2022/01/19 05:21:44 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mcp23xxxgpio_spi.c,v 1.3 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: mcp23xxxgpio_spi.c,v 1.4 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2014, 2022 The NetBSD Foundation, Inc. 4 * Copyright (c) 2014, 2022 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank Kardel, and by Jason R. Thorpe. 8 * by Frank Kardel, and by Jason R. Thorpe.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: mcp23xxxgpio_spi.c,v 1.3 2022/01/19 05:05:45 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: mcp23xxxgpio_spi.c,v 1.4 2022/01/19 05:21:44 thorpej Exp $");
34 34
35/*  35/*
36 * Driver for Microchip serial I/O expanders: 36 * Driver for Microchip serial I/O expanders:
37 * 37 *
38 * MCP23S08 8-bit, SPI interface 38 * MCP23S08 8-bit, SPI interface
39 * MCP23S17 16-bit, SPI interface 39 * MCP23S17 16-bit, SPI interface
40 * MCP23S18 16-bit (open-drain outputs), SPI interface 40 * MCP23S18 16-bit (open-drain outputs), SPI interface
41 * 41 *
42 * Data sheet: 42 * Data sheet:
43 * 43 *
44 * https://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf 44 * https://ww1.microchip.com/downloads/en/DeviceDoc/20001952C.pdf
45 */ 45 */
46 46
@@ -193,30 +193,28 @@ mcpgpio_spi_attach(device_t parent, devi @@ -193,30 +193,28 @@ mcpgpio_spi_attach(device_t parent, devi
193 mutex_init(&ssc->sc_mutex, MUTEX_DEFAULT, IPL_NONE); 193 mutex_init(&ssc->sc_mutex, MUTEX_DEFAULT, IPL_NONE);
194 ssc->sc_sh = sa->sa_handle; 194 ssc->sc_sh = sa->sa_handle;
195 195
196 sc->sc_dev = self; 196 sc->sc_dev = self;
197 sc->sc_variant = &mcp23s17; /* XXX */ 197 sc->sc_variant = &mcp23s17; /* XXX */
198 sc->sc_iocon = IOCON_HAEN | IOCON_SEQOP; 198 sc->sc_iocon = IOCON_HAEN | IOCON_SEQOP;
199 sc->sc_npins = MCP23x17_GPIO_NPINS; 199 sc->sc_npins = MCP23x17_GPIO_NPINS;
200 sc->sc_accessops = &mcpgpio_spi_accessops; 200 sc->sc_accessops = &mcpgpio_spi_accessops;
201 201
202 aprint_naive("\n");  202 aprint_naive("\n");
203 aprint_normal(": %s I/O Expander\n", sc->sc_variant->name); 203 aprint_normal(": %s I/O Expander\n", sc->sc_variant->name);
204 204
205 /* run at 10MHz */ 205 /* run at 10MHz */
206 error = spi_configure(sa->sa_handle, SPI_MODE_0, 10000000); 206 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 10000000);
207 if (error) { 207 if (error) {
208 aprint_error_dev(self, 
209 "failed to set Mode 0 @ 10MHz, error=%d\n", error); 
210 return; 208 return;
211 } 209 }
212 210
213 /* 211 /*
214 * Before we decode the topology information, ensure each 212 * Before we decode the topology information, ensure each
215 * chip has IOCON.HAEN set so that it will actually decode 213 * chip has IOCON.HAEN set so that it will actually decode
216 * the address bits. 214 * the address bits.
217 * 215 *
218 * XXX Going on blind faith that IOCON.BANK is already 0. 216 * XXX Going on blind faith that IOCON.BANK is already 0.
219 */ 217 */
220 if (sc->sc_variant->type == MCPGPIO_TYPE_23x08) { 218 if (sc->sc_variant->type == MCPGPIO_TYPE_23x08) {
221 error = mcpgpio_spi_write(sc, 0, REG_IOCON, sc->sc_iocon); 219 error = mcpgpio_spi_write(sc, 0, REG_IOCON, sc->sc_iocon);
222 } else { 220 } else {

cvs diff -r1.3 -r1.4 src/sys/dev/spi/mcp3k.c (expand / switch to unified diff)

--- src/sys/dev/spi/mcp3k.c 2022/01/19 05:05:45 1.3
+++ src/sys/dev/spi/mcp3k.c 2022/01/19 05:21:44 1.4
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mcp3k.c,v 1.3 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: mcp3k.c,v 1.4 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2015 The NetBSD Foundation, Inc. 4 * Copyright (c) 2015 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Frank Wille. 8 * by Frank Wille.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -195,30 +195,28 @@ mcp3kadc_attach(device_t parent, device_ @@ -195,30 +195,28 @@ mcp3kadc_attach(device_t parent, device_
195 sc->sc_dev = self; 195 sc->sc_dev = self;
196 sc->sc_sh = sa->sa_handle; 196 sc->sc_sh = sa->sa_handle;
197 197
198 /* device flags define the model */ 198 /* device flags define the model */
199 sc->sc_model = device_cfdata(sc->sc_dev)->cf_flags; 199 sc->sc_model = device_cfdata(sc->sc_dev)->cf_flags;
200 model = &mcp3k_models[sc->sc_model]; 200 model = &mcp3k_models[sc->sc_model];
201 201
202 aprint_naive(": Analog to Digital converter\n"); 202 aprint_naive(": Analog to Digital converter\n");
203 aprint_normal(": MCP%u %u-channel %u-bit ADC\n", 203 aprint_normal(": MCP%u %u-channel %u-bit ADC\n",
204 (unsigned)model->name, (unsigned)model->channels, 204 (unsigned)model->name, (unsigned)model->channels,
205 (unsigned)model->bits); 205 (unsigned)model->bits);
206 206
207 /* configure for 1MHz */ 207 /* configure for 1MHz */
208 error = spi_configure(sa->sa_handle, SPI_MODE_0, 1000000); 208 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 1000000);
209 if (error) { 209 if (error) {
210 aprint_error_dev(self, 
211 "failed to set Mode 0 @ 1MHz, error=%d\n", error); 
212 return; 210 return;
213 } 211 }
214 212
215 /* set a default Vref in mV according to the chip's ADC resolution */ 213 /* set a default Vref in mV according to the chip's ADC resolution */
216 sc->sc_vref_mv = 1 << ((model->flags & M3K_SIGNED) ? 214 sc->sc_vref_mv = 1 << ((model->flags & M3K_SIGNED) ?
217 model->bits - 1 : model->bits); 215 model->bits - 1 : model->bits);
218 216
219 /* remember maximum value for this ADC - also used for masking */ 217 /* remember maximum value for this ADC - also used for masking */
220 sc->sc_adc_max = (1 << model->bits) - 1; 218 sc->sc_adc_max = (1 << model->bits) - 1;
221 219
222 /* attach voltage sensors to envsys */ 220 /* attach voltage sensors to envsys */
223 sc->sc_sme = sysmon_envsys_create(); 221 sc->sc_sme = sysmon_envsys_create();
224 222

cvs diff -r1.2 -r1.3 src/sys/dev/spi/mcp48x1.c (expand / switch to unified diff)

--- src/sys/dev/spi/mcp48x1.c 2022/01/19 05:05:45 1.2
+++ src/sys/dev/spi/mcp48x1.c 2022/01/19 05:21:44 1.3
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: mcp48x1.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: mcp48x1.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc. 4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Radoslaw Kujawa. 8 * by Radoslaw Kujawa.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: mcp48x1.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: mcp48x1.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $");
34 34
35/*  35/*
36 * Driver for Microchip MCP4801/MCP4811/MCP4821 DAC.  36 * Driver for Microchip MCP4801/MCP4811/MCP4821 DAC.
37 * 37 *
38 * XXX: needs more testing. 38 * XXX: needs more testing.
39 */ 39 */
40 40
41#include <sys/param.h> 41#include <sys/param.h>
42#include <sys/systm.h> 42#include <sys/systm.h>
43#include <sys/device.h> 43#include <sys/device.h>
44#include <sys/kernel.h> 44#include <sys/kernel.h>
45#include <sys/types.h> 45#include <sys/types.h>
46#include <sys/sysctl.h> 46#include <sys/sysctl.h>
@@ -129,30 +129,28 @@ mcp48x1dac_attach(device_t parent, devic @@ -129,30 +129,28 @@ mcp48x1dac_attach(device_t parent, devic
129 int error, cf_flags; 129 int error, cf_flags;
130 130
131 aprint_naive(": Digital to Analog converter\n");  131 aprint_naive(": Digital to Analog converter\n");
132 aprint_normal(": MCP48x1 DAC\n"); 132 aprint_normal(": MCP48x1 DAC\n");
133 133
134 sa = aux; 134 sa = aux;
135 sc = device_private(self); 135 sc = device_private(self);
136 sc->sc_dev = self; 136 sc->sc_dev = self;
137 sc->sc_sh = sa->sa_handle; 137 sc->sc_sh = sa->sa_handle;
138 cf_flags = device_cfdata(sc->sc_dev)->cf_flags; 138 cf_flags = device_cfdata(sc->sc_dev)->cf_flags;
139 139
140 sc->sc_dm = &mcp48x1_models[cf_flags]; /* flag value defines model */ 140 sc->sc_dm = &mcp48x1_models[cf_flags]; /* flag value defines model */
141 141
142 error = spi_configure(sa->sa_handle, SPI_MODE_0, 20000000); 142 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 20000000);
143 if (error) { 143 if (error) {
144 aprint_error_dev(self, 
145 "failed to set Mode 0 @ 20MHz, error=%d\n", error); 
146 return; 144 return;
147 } 145 }
148 146
149 if(!mcp48x1dac_envsys_attach(sc)) { 147 if(!mcp48x1dac_envsys_attach(sc)) {
150 aprint_error_dev(sc->sc_dev, "failed to attach envsys\n"); 148 aprint_error_dev(sc->sc_dev, "failed to attach envsys\n");
151 return; 149 return;
152 }; 150 };
153 151
154 sc->sc_dac_data = 0; 152 sc->sc_dac_data = 0;
155 sc->sc_dac_gain = false; 153 sc->sc_dac_gain = false;
156 sc->sc_dac_shutdown = false; 154 sc->sc_dac_shutdown = false;
157 mcp48x1dac_write(sc); 155 mcp48x1dac_write(sc);
158 156

cvs diff -r1.2 -r1.3 src/sys/dev/spi/scmdspi.c (expand / switch to unified diff)

--- src/sys/dev/spi/scmdspi.c 2022/01/19 05:05:45 1.2
+++ src/sys/dev/spi/scmdspi.c 2022/01/19 05:21:44 1.3
@@ -1,34 +1,34 @@ @@ -1,34 +1,34 @@
1 1
2/* $NetBSD: scmdspi.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $ */ 2/* $NetBSD: scmdspi.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $ */
3 3
4/* 4/*
5 * Copyright (c) 2021 Brad Spencer <brad@anduin.eldar.org> 5 * Copyright (c) 2021 Brad Spencer <brad@anduin.eldar.org>
6 * 6 *
7 * Permission to use, copy, modify, and distribute this software for any 7 * Permission to use, copy, modify, and distribute this software for any
8 * purpose with or without fee is hereby granted, provided that the above 8 * purpose with or without fee is hereby granted, provided that the above
9 * copyright notice and this permission notice appear in all copies. 9 * copyright notice and this permission notice appear in all copies.
10 * 10 *
11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 */ 18 */
19 19
20#include <sys/cdefs.h> 20#include <sys/cdefs.h>
21__KERNEL_RCSID(0, "$NetBSD: scmdspi.c,v 1.2 2022/01/19 05:05:45 thorpej Exp $"); 21__KERNEL_RCSID(0, "$NetBSD: scmdspi.c,v 1.3 2022/01/19 05:21:44 thorpej Exp $");
22 22
23/* 23/*
24 * SPI driver for the Sparkfun Serial motor controller. 24 * SPI driver for the Sparkfun Serial motor controller.
25 * Uses the common scmd driver to do the real work. 25 * Uses the common scmd driver to do the real work.
26*/ 26*/
27 27
28#include <sys/param.h> 28#include <sys/param.h>
29#include <sys/systm.h> 29#include <sys/systm.h>
30#include <sys/kernel.h> 30#include <sys/kernel.h>
31#include <sys/device.h> 31#include <sys/device.h>
32#include <sys/module.h> 32#include <sys/module.h>
33#include <sys/conf.h> 33#include <sys/conf.h>
34#include <sys/sysctl.h> 34#include <sys/sysctl.h>
@@ -195,30 +195,28 @@ scmdspi_attach(device_t parent, device_t @@ -195,30 +195,28 @@ scmdspi_attach(device_t parent, device_t
195 sc->sc_dying = false; 195 sc->sc_dying = false;
196 sc->sc_func_acquire_bus = &scmdspi_acquire_bus; 196 sc->sc_func_acquire_bus = &scmdspi_acquire_bus;
197 sc->sc_func_release_bus = &scmdspi_release_bus; 197 sc->sc_func_release_bus = &scmdspi_release_bus;
198 sc->sc_func_read_register = &scmdspi_read_reg; 198 sc->sc_func_read_register = &scmdspi_read_reg;
199 sc->sc_func_write_register = &scmdspi_write_reg; 199 sc->sc_func_write_register = &scmdspi_write_reg;
200 200
201 mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_NONE); 201 mutex_init(&sc->sc_mutex, MUTEX_DEFAULT, IPL_NONE);
202 mutex_init(&sc->sc_condmutex, MUTEX_DEFAULT, IPL_NONE); 202 mutex_init(&sc->sc_condmutex, MUTEX_DEFAULT, IPL_NONE);
203 mutex_init(&sc->sc_dying_mutex, MUTEX_DEFAULT, IPL_NONE); 203 mutex_init(&sc->sc_dying_mutex, MUTEX_DEFAULT, IPL_NONE);
204 cv_init(&sc->sc_condvar, "scmdspicv"); 204 cv_init(&sc->sc_condvar, "scmdspicv");
205 cv_init(&sc->sc_cond_dying, "scmdspidc"); 205 cv_init(&sc->sc_cond_dying, "scmdspidc");
206 206
207 /* configure for 1MHz and SPI mode 0 according to the data sheet */ 207 /* configure for 1MHz and SPI mode 0 according to the data sheet */
208 error = spi_configure(sa->sa_handle, SPI_MODE_0, 1000000); 208 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 1000000);
209 if (error) { 209 if (error) {
210 aprint_error(": failed to set Mode 0 @ 1MHz, error=%d\n", 
211 error); 
212 return; 210 return;
213 } 211 }
214 212
215 /* Please note that if the pins are not set up for SPI, the attachment 213 /* Please note that if the pins are not set up for SPI, the attachment
216 * will work, but it will not figure out that there are slave modules. 214 * will work, but it will not figure out that there are slave modules.
217 * It is likely required that a re-enumeration be performed after the pins 215 * It is likely required that a re-enumeration be performed after the pins
218 * are set. This can be done from userland later. 216 * are set. This can be done from userland later.
219 */ 217 */
220 scmd_attach(sc); 218 scmd_attach(sc);
221 219
222 return; 220 return;
223} 221}
224 222

cvs diff -r1.10 -r1.11 src/sys/dev/spi/oj6sh.c (expand / switch to unified diff)

--- src/sys/dev/spi/oj6sh.c 2022/01/19 05:05:45 1.10
+++ src/sys/dev/spi/oj6sh.c 2022/01/19 05:21:44 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: oj6sh.c,v 1.10 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: oj6sh.c,v 1.11 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2014 Genetec Corporation. All rights reserved. 4 * Copyright (c) 2014 Genetec Corporation. All rights reserved.
5 * Written by Hashimoto Kenichi for Genetec Corporation. 5 * Written by Hashimoto Kenichi for Genetec Corporation.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * Sharp NetWalker's Optical Joystick 30 * Sharp NetWalker's Optical Joystick
31 */ 31 */
32 32
33#include <sys/cdefs.h> 33#include <sys/cdefs.h>
34__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.10 2022/01/19 05:05:45 thorpej Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: oj6sh.c,v 1.11 2022/01/19 05:21:44 thorpej Exp $");
35 35
36#include "opt_oj6sh.h" 36#include "opt_oj6sh.h"
37 37
38#include <sys/param.h> 38#include <sys/param.h>
39#include <sys/systm.h> 39#include <sys/systm.h>
40#include <sys/kernel.h> 40#include <sys/kernel.h>
41#include <sys/device.h> 41#include <sys/device.h>
42#include <sys/lock.h> 42#include <sys/lock.h>
43#include <sys/callout.h> 43#include <sys/callout.h>
44#include <sys/bus.h> 44#include <sys/bus.h>
45#include <sys/mutex.h> 45#include <sys/mutex.h>
46#include <sys/workqueue.h> 46#include <sys/workqueue.h>
47 47
@@ -177,30 +177,28 @@ oj6sh_doattach(device_t self) @@ -177,30 +177,28 @@ oj6sh_doattach(device_t self)
177} 177}
178 178
179static void 179static void
180oj6sh_attach(device_t parent, device_t self, void *aux) 180oj6sh_attach(device_t parent, device_t self, void *aux)
181{ 181{
182 struct oj6sh_softc *sc = device_private(self); 182 struct oj6sh_softc *sc = device_private(self);
183 struct spi_attach_args *sa = aux; 183 struct spi_attach_args *sa = aux;
184 struct wsmousedev_attach_args a; 184 struct wsmousedev_attach_args a;
185 int error; 185 int error;
186 186
187 aprint_naive("\n"); 187 aprint_naive("\n");
188 aprint_normal(": OJ6SH-T25 Optical Joystick\n"); 188 aprint_normal(": OJ6SH-T25 Optical Joystick\n");
189 189
190 error = spi_configure(sa->sa_handle, SPI_MODE_0, 2500000); 190 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 2500000);
191 if (error) { 191 if (error) {
192 aprint_error_dev(self, 
193 "failed to set Mode 0 @ 2.5MHz, error=%d\n", error); 
194 return; 192 return;
195 } 193 }
196 194
197 mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE); 195 mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
198 196
199 sc->sc_dev = self; 197 sc->sc_dev = self;
200 sc->sc_enabled = 0; 198 sc->sc_enabled = 0;
201 199
202 callout_init(&sc->sc_c, 0); 200 callout_init(&sc->sc_c, 0);
203 workqueue_create(&sc->sc_wq, "oj6sh", 201 workqueue_create(&sc->sc_wq, "oj6sh",
204 oj6sh_cb, sc, PRI_NONE, IPL_BIO, 0); 202 oj6sh_cb, sc, PRI_NONE, IPL_BIO, 0);
205 203
206 sc->sc_sh = sa->sa_handle; 204 sc->sc_sh = sa->sa_handle;

cvs diff -r1.10 -r1.11 src/sys/dev/spi/spivar.h (expand / switch to unified diff)

--- src/sys/dev/spi/spivar.h 2020/08/04 13:20:45 1.10
+++ src/sys/dev/spi/spivar.h 2022/01/19 05:21:44 1.11
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: spivar.h,v 1.10 2020/08/04 13:20:45 kardel Exp $ */ 1/* $NetBSD: spivar.h,v 1.11 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center. 4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
5 * Copyright (c) 2006 Garrett D'Amore. 5 * Copyright (c) 2006 Garrett D'Amore.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Portions of this code were written by Garrett D'Amore for the 8 * Portions of this code were written by Garrett D'Amore for the
9 * Champaign-Urbana Community Wireless Network Project. 9 * Champaign-Urbana Community Wireless Network Project.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or 11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following 12 * without modification, are permitted provided that the following
13 * conditions are met: 13 * conditions are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -132,27 +132,27 @@ SIMPLEQ_HEAD(spi_transq, spi_transfer); @@ -132,27 +132,27 @@ SIMPLEQ_HEAD(spi_transq, spi_transfer);
132 SIMPLEQ_INSERT_TAIL(q, trans, st_chain) 132 SIMPLEQ_INSERT_TAIL(q, trans, st_chain)
133 133
134#define spi_transq_dequeue(q) \ 134#define spi_transq_dequeue(q) \
135 SIMPLEQ_REMOVE_HEAD(q, st_chain) 135 SIMPLEQ_REMOVE_HEAD(q, st_chain)
136 136
137#define spi_transq_first(q) \ 137#define spi_transq_first(q) \
138 SIMPLEQ_FIRST(q) 138 SIMPLEQ_FIRST(q)
139 139
140#define SPI_F_DONE 0x0001 140#define SPI_F_DONE 0x0001
141#define SPI_F_ERROR 0x0002 141#define SPI_F_ERROR 0x0002
142 142
143int spi_compatible_match(const struct spi_attach_args *, const cfdata_t, 143int spi_compatible_match(const struct spi_attach_args *, const cfdata_t,
144 const struct device_compatible_entry *); 144 const struct device_compatible_entry *);
145int spi_configure(struct spi_handle *, int, int); 145int spi_configure(device_t, struct spi_handle *, int, int);
146int spi_transfer(struct spi_handle *, struct spi_transfer *); 146int spi_transfer(struct spi_handle *, struct spi_transfer *);
147void spi_transfer_init(struct spi_transfer *); 147void spi_transfer_init(struct spi_transfer *);
148void spi_chunk_init(struct spi_chunk *, int, const uint8_t *, uint8_t *); 148void spi_chunk_init(struct spi_chunk *, int, const uint8_t *, uint8_t *);
149void spi_transfer_add(struct spi_transfer *, struct spi_chunk *); 149void spi_transfer_add(struct spi_transfer *, struct spi_chunk *);
150void spi_wait(struct spi_transfer *); 150void spi_wait(struct spi_transfer *);
151void spi_done(struct spi_transfer *, int); 151void spi_done(struct spi_transfer *, int);
152 152
153/* convenience wrappers */ 153/* convenience wrappers */
154int spi_send(struct spi_handle *, int, const uint8_t *); 154int spi_send(struct spi_handle *, int, const uint8_t *);
155int spi_recv(struct spi_handle *, int, uint8_t *); 155int spi_recv(struct spi_handle *, int, uint8_t *);
156int spi_send_recv(struct spi_handle *, int, const uint8_t *, int, uint8_t *); 156int spi_send_recv(struct spi_handle *, int, const uint8_t *, int, uint8_t *);
157 157
158#endif /* _DEV_SPI_SPIVAR_H_ */ 158#endif /* _DEV_SPI_SPIVAR_H_ */

cvs diff -r1.12 -r1.13 src/sys/dev/spi/ssdfb_spi.c (expand / switch to unified diff)

--- src/sys/dev/spi/ssdfb_spi.c 2022/01/19 05:05:45 1.12
+++ src/sys/dev/spi/ssdfb_spi.c 2022/01/19 05:21:44 1.13
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: ssdfb_spi.c,v 1.12 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: ssdfb_spi.c,v 1.13 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2019 The NetBSD Foundation, Inc. 4 * Copyright (c) 2019 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tobias Nygren. 8 * by Tobias Nygren.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -20,27 +20,27 @@ @@ -20,27 +20,27 @@
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.12 2022/01/19 05:05:45 thorpej Exp $"); 33__KERNEL_RCSID(0, "$NetBSD: ssdfb_spi.c,v 1.13 2022/01/19 05:21:44 thorpej Exp $");
34 34
35#include <sys/param.h> 35#include <sys/param.h>
36#include <sys/device.h> 36#include <sys/device.h>
37#include <sys/kernel.h> 37#include <sys/kernel.h>
38#include <dev/wscons/wsdisplayvar.h> 38#include <dev/wscons/wsdisplayvar.h>
39#include <dev/rasops/rasops.h> 39#include <dev/rasops/rasops.h>
40#include <dev/spi/spivar.h> 40#include <dev/spi/spivar.h>
41#include <dev/ic/ssdfbvar.h> 41#include <dev/ic/ssdfbvar.h>
42#include "opt_fdt.h" 42#include "opt_fdt.h"
43#ifdef FDT 43#ifdef FDT
44#include <dev/fdt/fdtvar.h> 44#include <dev/fdt/fdtvar.h>
45#endif 45#endif
46 46
@@ -120,30 +120,28 @@ ssdfb_spi_attach(device_t parent, device @@ -120,30 +120,28 @@ ssdfb_spi_attach(device_t parent, device
120 sc->sc.sc_cookie = (void *)sc; 120 sc->sc.sc_cookie = (void *)sc;
121 if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN) { 121 if ((flags & SSDFB_ATTACH_FLAG_PRODUCT_MASK) == SSDFB_PRODUCT_UNKNOWN) {
122 const struct device_compatible_entry *dce = 122 const struct device_compatible_entry *dce =
123 device_compatible_lookup(sa->sa_compat, sa->sa_ncompat, compat_data); 123 device_compatible_lookup(sa->sa_compat, sa->sa_ncompat, compat_data);
124 if (dce) 124 if (dce)
125 flags |= (int)dce->value; 125 flags |= (int)dce->value;
126 else 126 else
127 flags |= SSDFB_PRODUCT_SSD1322_GENERIC; 127 flags |= SSDFB_PRODUCT_SSD1322_GENERIC;
128 } 128 }
129 129
130 /* 130 /*
131 * SSD1306 and SSD1322 data sheets specify 100ns cycle time. 131 * SSD1306 and SSD1322 data sheets specify 100ns cycle time.
132 */ 132 */
133 error = spi_configure(sa->sa_handle, SPI_MODE_0, 10000000); 133 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 10000000);
134 if (error) { 134 if (error) {
135 aprint_error(": failed to set Mode 0 @ 10MHz, error=%d\n", 
136 error); 
137 return; 135 return;
138 } 136 }
139 137
140 /* 138 /*
141 * Note on interface modes. 139 * Note on interface modes.
142 * 140 *
143 * 3 wire mode sends 9 bit sequences over the MOSI, MSB contains 141 * 3 wire mode sends 9 bit sequences over the MOSI, MSB contains
144 * the bit that determines if the lower 8 bits are command or data. 142 * the bit that determines if the lower 8 bits are command or data.
145 * 143 *
146 * 4 wire mode sends 8 bit sequences and requires an auxiliary GPIO 144 * 4 wire mode sends 8 bit sequences and requires an auxiliary GPIO
147 * pin for the command/data bit. 145 * pin for the command/data bit.
148 */ 146 */
149#ifdef FDT 147#ifdef FDT

cvs diff -r1.6 -r1.7 src/sys/dev/spi/tmp121.c (expand / switch to unified diff)

--- src/sys/dev/spi/tmp121.c 2022/01/19 05:05:45 1.6
+++ src/sys/dev/spi/tmp121.c 2022/01/19 05:21:44 1.7
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: tmp121.c,v 1.6 2022/01/19 05:05:45 thorpej Exp $ */ 1/* $NetBSD: tmp121.c,v 1.7 2022/01/19 05:21:44 thorpej Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center. 4 * Copyright (c) 2006 Urbana-Champaign Independent Media Center.
5 * Copyright (c) 2006 Garrett D'Amore. 5 * Copyright (c) 2006 Garrett D'Amore.
6 * All rights reserved. 6 * All rights reserved.
7 * 7 *
8 * Portions of this code were written by Garrett D'Amore for the 8 * Portions of this code were written by Garrett D'Amore for the
9 * Champaign-Urbana Community Wireless Network Project. 9 * Champaign-Urbana Community Wireless Network Project.
10 * 10 *
11 * Redistribution and use in source and binary forms, with or 11 * Redistribution and use in source and binary forms, with or
12 * without modification, are permitted provided that the following 12 * without modification, are permitted provided that the following
13 * conditions are met: 13 * conditions are met:
14 * 1. Redistributions of source code must retain the above copyright 14 * 1. Redistributions of source code must retain the above copyright
@@ -32,27 +32,27 @@ @@ -32,27 +32,27 @@
32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 32 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
33 * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT 33 * ARE DISCLAIMED. IN NO EVENT SHALL THE URBANA-CHAMPAIGN INDEPENDENT
34 * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT, 34 * MEDIA CENTER OR GARRETT D'AMORE BE LIABLE FOR ANY DIRECT, INDIRECT,
35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 35 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 36 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 37 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 38 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 40 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */ 42 */
43 43
44#include <sys/cdefs.h> 44#include <sys/cdefs.h>
45__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.6 2022/01/19 05:05:45 thorpej Exp $"); 45__KERNEL_RCSID(0, "$NetBSD: tmp121.c,v 1.7 2022/01/19 05:21:44 thorpej Exp $");
46 46
47#include <sys/param.h> 47#include <sys/param.h>
48#include <sys/systm.h> 48#include <sys/systm.h>
49#include <sys/device.h> 49#include <sys/device.h>
50#include <sys/kernel.h> 50#include <sys/kernel.h>
51 51
52#include <dev/sysmon/sysmonvar.h> 52#include <dev/sysmon/sysmonvar.h>
53 53
54#include <dev/spi/spivar.h> 54#include <dev/spi/spivar.h>
55 55
56struct tmp121temp_softc { 56struct tmp121temp_softc {
57 struct spi_handle *sc_sh; 57 struct spi_handle *sc_sh;
58  58
@@ -75,30 +75,28 @@ tmp121temp_match(device_t parent, cfdata @@ -75,30 +75,28 @@ tmp121temp_match(device_t parent, cfdata
75} 75}
76 76
77static void 77static void
78tmp121temp_attach(device_t parent, device_t self, void *aux) 78tmp121temp_attach(device_t parent, device_t self, void *aux)
79{ 79{
80 struct tmp121temp_softc *sc = device_private(self); 80 struct tmp121temp_softc *sc = device_private(self);
81 struct spi_attach_args *sa = aux; 81 struct spi_attach_args *sa = aux;
82 int error; 82 int error;
83 83
84 aprint_naive(": Temperature Sensor\n");  84 aprint_naive(": Temperature Sensor\n");
85 aprint_normal(": TI TMP121 Temperature Sensor\n"); 85 aprint_normal(": TI TMP121 Temperature Sensor\n");
86 86
87 /* configure for 10MHz */ 87 /* configure for 10MHz */
88 error = spi_configure(sa->sa_handle, SPI_MODE_0, 1000000); 88 error = spi_configure(self, sa->sa_handle, SPI_MODE_0, 1000000);
89 if (error) { 89 if (error) {
90 aprint_error_dev(self, 
91 "failed to set Mode 0 @ 10MHz, error=%d\n", error); 
92 return; 90 return;
93 } 91 }
94 92
95 sc->sc_sh = sa->sa_handle; 93 sc->sc_sh = sa->sa_handle;
96 94
97 sc->sc_sme = sysmon_envsys_create(); 95 sc->sc_sme = sysmon_envsys_create();
98 sc->sc_sensor.units = ENVSYS_STEMP; 96 sc->sc_sensor.units = ENVSYS_STEMP;
99 sc->sc_sensor.state = ENVSYS_SINVALID; 97 sc->sc_sensor.state = ENVSYS_SINVALID;
100 strlcpy(sc->sc_sensor.desc, device_xname(self), 98 strlcpy(sc->sc_sensor.desc, device_xname(self),
101 sizeof(sc->sc_sensor.desc)); 99 sizeof(sc->sc_sensor.desc));
102 if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) { 100 if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
103 sysmon_envsys_destroy(sc->sc_sme); 101 sysmon_envsys_destroy(sc->sc_sme);
104 return; 102 return;