iicbb.c (46743) | iicbb.c (49195) |
---|---|
1/*- 2 * Copyright (c) 1998 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Nicolas Souchu 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: iicbb.c,v 1.3 1999/01/28 15:50:24 roger Exp $ | 26 * $Id: iicbb.c,v 1.4 1999/05/08 21:59:04 dfr Exp $ |
27 * 28 */ 29 30/* 31 * Generic I2C bit-banging code 32 * 33 * Example: 34 * --- 30 unchanged lines hidden (view full) --- 65#include "iicbb_if.h" 66 67struct iicbb_softc { 68 int dummy; 69}; 70 71static int iicbb_probe(device_t); 72static int iicbb_attach(device_t); | 27 * 28 */ 29 30/* 31 * Generic I2C bit-banging code 32 * 33 * Example: 34 * --- 30 unchanged lines hidden (view full) --- 65#include "iicbb_if.h" 66 67struct iicbb_softc { 68 int dummy; 69}; 70 71static int iicbb_probe(device_t); 72static int iicbb_attach(device_t); |
73static void iicbb_print_child(device_t, device_t); | 73static int iicbb_print_child(device_t, device_t); |
74 75static int iicbb_callback(device_t, int, caddr_t); 76static int iicbb_start(device_t, u_char, int); 77static int iicbb_stop(device_t); 78static int iicbb_write(device_t, char *, int, int *, int); 79static int iicbb_read(device_t, char *, int, int *, int, int); 80static int iicbb_reset(device_t, u_char, u_char, u_char *); 81 --- 32 unchanged lines hidden (view full) --- 114 return (0); 115} 116 117static int iicbb_attach(device_t dev) 118{ 119 return (0); 120} 121 | 74 75static int iicbb_callback(device_t, int, caddr_t); 76static int iicbb_start(device_t, u_char, int); 77static int iicbb_stop(device_t); 78static int iicbb_write(device_t, char *, int, int *, int); 79static int iicbb_read(device_t, char *, int, int *, int, int); 80static int iicbb_reset(device_t, u_char, u_char, u_char *); 81 --- 32 unchanged lines hidden (view full) --- 114 return (0); 115} 116 117static int iicbb_attach(device_t dev) 118{ 119 return (0); 120} 121 |
122static void | 122static int |
123iicbb_print_child(device_t bus, device_t dev) 124{ 125 int error; | 123iicbb_print_child(device_t bus, device_t dev) 124{ 125 int error; |
126 int retval = 0; |
|
126 u_char oldaddr; 127 | 127 u_char oldaddr; 128 |
129 retval += bus_print_child_header(bus, dev); |
|
128 /* retrieve the interface I2C address */ 129 error = IICBB_RESET(device_get_parent(bus), IIC_FASTEST, 0, &oldaddr); 130 if (error == IIC_ENOADDR) { | 130 /* retrieve the interface I2C address */ 131 error = IICBB_RESET(device_get_parent(bus), IIC_FASTEST, 0, &oldaddr); 132 if (error == IIC_ENOADDR) { |
131 printf(" on %s%d master-only", device_get_name(bus), 132 device_get_unit(bus)); 133 | 133 retval += printf(" on %s master-only\n", 134 device_get_nameunit(bus)); |
134 } else { 135 /* restore the address */ 136 IICBB_RESET(device_get_parent(bus), IIC_FASTEST, oldaddr, NULL); 137 | 135 } else { 136 /* restore the address */ 137 IICBB_RESET(device_get_parent(bus), IIC_FASTEST, oldaddr, NULL); 138 |
138 printf(" on %s%d addr 0x%x", device_get_name(bus), 139 device_get_unit(bus), oldaddr & 0xff); | 139 retval += printf(" on %s addr 0x%x\n", 140 device_get_nameunit(bus), oldaddr & 0xff); |
140 } 141 | 141 } 142 |
142 return; | 143 return (retval); |
143} 144 145#define I2C_SET(dev,ctrl,data) \ 146 IICBB_SETLINES(device_get_parent(dev), ctrl, data) 147 148#define I2C_GET(dev) (IICBB_GETDATALINE(device_get_parent(dev))) 149 150static int i2c_debug = 0; --- 172 unchanged lines hidden --- | 144} 145 146#define I2C_SET(dev,ctrl,data) \ 147 IICBB_SETLINES(device_get_parent(dev), ctrl, data) 148 149#define I2C_GET(dev) (IICBB_GETDATALINE(device_get_parent(dev))) 150 151static int i2c_debug = 0; --- 172 unchanged lines hidden --- |