iicbus.c (119418) | iicbus.c (129152) |
---|---|
1/*- 2 * Copyright (c) 1998, 2001 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 --- 11 unchanged lines hidden (view full) --- 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 27#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998, 2001 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 --- 11 unchanged lines hidden (view full) --- 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 27#include <sys/cdefs.h> |
28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iicbus.c 119418 2003-08-24 17:55:58Z obrien $"); | 28__FBSDID("$FreeBSD: head/sys/dev/iicbus/iicbus.c 129152 2004-05-12 13:43:41Z joerg $"); |
29 30/* 31 * Autoconfiguration and support routines for the Philips serial I2C bus 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> --- 5 unchanged lines hidden (view full) --- 42#include <dev/iicbus/iicbus.h> 43 44#include "iicbus_if.h" 45 46#define DEVTOIICBUS(dev) ((struct iicbus_device*)device_get_ivars(dev)) 47 48static devclass_t iicbus_devclass; 49 | 29 30/* 31 * Autoconfiguration and support routines for the Philips serial I2C bus 32 */ 33 34#include <sys/param.h> 35#include <sys/systm.h> 36#include <sys/kernel.h> --- 5 unchanged lines hidden (view full) --- 42#include <dev/iicbus/iicbus.h> 43 44#include "iicbus_if.h" 45 46#define DEVTOIICBUS(dev) ((struct iicbus_device*)device_get_ivars(dev)) 47 48static devclass_t iicbus_devclass; 49 |
50/* See comments below for why auto-scanning is a bad idea. */ 51#define SCAN_IICBUS 0 52 |
|
50/* 51 * Device methods 52 */ 53static int iicbus_probe(device_t); 54static int iicbus_attach(device_t); 55static int iicbus_detach(device_t); 56static int iicbus_add_child(device_t dev, int order, const char *name, int unit); 57 --- 20 unchanged lines hidden (view full) --- 78static int 79iicbus_probe(device_t dev) 80{ 81 device_set_desc(dev, "Philips I2C bus"); 82 83 return (0); 84} 85 | 53/* 54 * Device methods 55 */ 56static int iicbus_probe(device_t); 57static int iicbus_attach(device_t); 58static int iicbus_detach(device_t); 59static int iicbus_add_child(device_t dev, int order, const char *name, int unit); 60 --- 20 unchanged lines hidden (view full) --- 81static int 82iicbus_probe(device_t dev) 83{ 84 device_set_desc(dev, "Philips I2C bus"); 85 86 return (0); 87} 88 |
86#if 0 | 89#if SCAN_IICBUS |
87static int 88iic_probe_device(device_t dev, u_char addr) 89{ 90 int count; 91 char byte; 92 93 if ((addr & 1) == 0) { 94 /* is device writable? */ --- 13 unchanged lines hidden (view full) --- 108 109/* 110 * We add all the devices which we know about. 111 * The generic attach routine will attach them if they are alive. 112 */ 113static int 114iicbus_attach(device_t dev) 115{ | 90static int 91iic_probe_device(device_t dev, u_char addr) 92{ 93 int count; 94 char byte; 95 96 if ((addr & 1) == 0) { 97 /* is device writable? */ --- 13 unchanged lines hidden (view full) --- 111 112/* 113 * We add all the devices which we know about. 114 * The generic attach routine will attach them if they are alive. 115 */ 116static int 117iicbus_attach(device_t dev) 118{ |
119#if SCAN_IICBUS 120 unsigned char addr; 121#endif 122 |
|
116 iicbus_reset(dev, IIC_FASTEST, 0, NULL); 117 118 /* device probing is meaningless since the bus is supposed to be 119 * hot-plug. Moreover, some I2C chips do not appreciate random 120 * accesses like stop after start to fast, reads for less than 121 * x bytes... 122 */ | 123 iicbus_reset(dev, IIC_FASTEST, 0, NULL); 124 125 /* device probing is meaningless since the bus is supposed to be 126 * hot-plug. Moreover, some I2C chips do not appreciate random 127 * accesses like stop after start to fast, reads for less than 128 * x bytes... 129 */ |
123#if 0 | 130#if SCAN_IICBUS |
124 printf("Probing for devices on iicbus%d:", device_get_unit(dev)); 125 126 /* probe any devices */ | 131 printf("Probing for devices on iicbus%d:", device_get_unit(dev)); 132 133 /* probe any devices */ |
127 for (addr = FIRST_SLAVE_ADDR; addr <= LAST_SLAVE_ADDR; addr++) { | 134 for (addr = 16; addr < 240; addr++) { |
128 if (iic_probe_device(dev, (u_char)addr)) { 129 printf(" <%x>", addr); 130 } 131 } 132 printf("\n"); 133#endif 134 135 /* attach any known device */ --- 49 unchanged lines hidden --- | 135 if (iic_probe_device(dev, (u_char)addr)) { 136 printf(" <%x>", addr); 137 } 138 } 139 printf("\n"); 140#endif 141 142 /* attach any known device */ --- 49 unchanged lines hidden --- |