Allow the EEPROM size to be specified in the kernel configuration by

using flags.
Add the flags values, and configuration examples to the manual page.
This commit is contained in:
jdc 2013-10-25 14:23:15 +00:00
parent 01c3389f26
commit 2b2120bf58
2 changed files with 38 additions and 9 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: seeprom.4,v 1.4 2013/02/08 15:18:44 jdc Exp $
.\" $NetBSD: seeprom.4,v 1.5 2013/10/25 14:23:15 jdc Exp $
.\"
.\" Copyright (c) 2007 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -24,21 +24,45 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd February 7, 2013
.Dd October 25, 2013
.Dt SEEPROM 4
.Os
.Sh NAME
.Nm seeprom
.Nd 24-series I2C EEPROM driver
.Sh SYNOPSIS
.Cd "seeprom0 at iic0 addr 0x50 size 128"
.Cd "seeprom0 at iic0 addr 0x51: AT24Cxx or compatible EEPROM: size 256"
.Cd "seeprom16 at iic1 addr 0x57: power-supply: size 8192"
.Sh DESCRIPTION
The
.Nm
driver provides support for the 24-series of I2C EEPROMs,
available from a variety of vendors.
driver provides support for the ATMEL 24-series of I2C EEPROMs, and
compatables, available from a variety of vendors. The Philips PCF8582
is also supported, as compatable with the AT24C02.
.Pp
Access to the contents of the memory is through a character device.
.Pp
The size of the EEPROM is either read from the firmware, or can be set
using the flags keyword in the kernel configuration.
The value of the flag represents the EEPROM size in Kbit.
.Bl -column -offset indent "flags" "EEPROM size in bytes"
.It Sy flags Ta Sy EEPROM size in bytes
.It Li 1 Ta 128
.It Li 2 Ta 256
.It Li 4 Ta 512
.It Li 8 Ta 1024
.It Li 16 Ta 2048
.It Li 32 Ta 4096
.It Li 64 Ta 8192
.It Li 128 Ta 16384
.It Li 256 Ta 32768
.It Li 512 Ta 65536
.El
.Sh EXAMPLES
Indirect configuration:
.Dl seeprom* at iic? addr 0x51 flags 0x2
Direct configuration:
.Dl seeprom* at iic? addr?
.Sh SEE ALSO
.Xr iic 4
.Sh HISTORY
@ -49,6 +73,8 @@ device appeared in
.Sh BUGS
AT24C1024 EEPROM's are not supported.
.Pp
Software write protection on the AT34Cxx EEPROM's is not supported.
.Pp
The
.Nm
driver reads and writes one byte at a time to be compatible with all

View File

@ -1,4 +1,4 @@
/* $NetBSD: at24cxx.c,v 1.14 2013/08/07 19:38:45 soren Exp $ */
/* $NetBSD: at24cxx.c,v 1.15 2013/10/25 14:23:15 jdc Exp $ */
/*
* Copyright (c) 2003 Wasabi Systems, Inc.
@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.14 2013/08/07 19:38:45 soren Exp $");
__KERNEL_RCSID(0, "$NetBSD: at24cxx.c,v 1.15 2013/10/25 14:23:15 jdc Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -136,7 +136,7 @@ seeprom_attach(device_t parent, device_t self, void *aux)
aprint_normal(": %s", ia->ia_name);
} else {
aprint_naive(": EEPROM");
aprint_normal(": AT24Cxx EEPROM");
aprint_normal(": AT24Cxx or compatible EEPROM");
}
/*
@ -153,7 +153,10 @@ seeprom_attach(device_t parent, device_t self, void *aux)
* switching to select the proper super-page. This isn't
* supported by this driver.
*/
sc->sc_size = ia->ia_size;
if (device_cfdata(self)->cf_flags)
sc->sc_size = (device_cfdata(self)->cf_flags << 7);
else
sc->sc_size = ia->ia_size;
switch (sc->sc_size) {
case 128: /* 1Kbit */
case 256: /* 2Kbit */