PERFORCE change 110617 for review
Warner Losh
imp at FreeBSD.org
Tue Nov 28 00:23:52 PST 2006
http://perforce.freebsd.org/chv.cgi?CH=110617
Change 110617 by imp at imp_lighthouse on 2006/11/28 08:23:09
Make the page read and write parameters tunable
Affected files ...
.. //depot/projects/arm/src/sys/arm/conf/TSC4370.hints#4 edit
.. //depot/projects/arm/src/sys/dev/iicbus/icee.c#3 edit
Differences ...
==== //depot/projects/arm/src/sys/arm/conf/TSC4370.hints#4 (text+ko) ====
@@ -7,16 +7,22 @@
hint.icee.0.addr=0x40
hint.icee.0.type=8
hint.icee.0.size=2048
+hint.icee.0.rd_sz=256
+hint.icee.0.wr_sz=16
# Config Eeprom
hint.icee.1.at="iicbus0"
hint.icee.1.addr=0x48
hint.icee.1.type=8
hint.icee.1.size=2048
+hint.icee.1.rd_sz=256
+hint.icee.1.wr_sz=16
# spf eeprom
hint.icee.2.at="iicbus0"
hint.icee.2.addr=0x50
hint.icee.2.type=8
hint.icee.2.size=128
+hint.icee.2.rd_sz=128
+hint.icee.2.wr_sz=8
# input card ltc4305: 0x58
# daughter card ltc4305: 0x59
# ps eeprom
@@ -24,18 +30,26 @@
hint.icee.3.addr=0x60
hint.icee.3.type=8
hint.icee.3.size=2048
+hint.icee.3.rd_sz=256
+hint.icee.3.wr_sz=16
# daughter ID eeprom
hint.icee.4.at="iicbus0"
hint.icee.4.addr=0x68
hint.icee.4.type=8
hint.icee.4.size=2048
+hint.icee.4.rd_sz=256
+hint.icee.4.wr_sz=16
# RU/GPS board ID eeprom
hint.icee.5.at="iicbus0"
hint.icee.5.addr=0x70
hint.icee.5.type=8
hint.icee.5.size=2048
+hint.icee.5.rd_sz=256
+hint.icee.5.wr_sz=16
# Input Card ID eeprom
hint.icee.6.at="iicbus0"
hint.icee.6.addr=0x78
hint.icee.6.type=8
hint.icee.6.size=2048
+hint.icee.6.rd_sz=256
+hint.icee.6.wr_sz=16
==== //depot/projects/arm/src/sys/dev/iicbus/icee.c#3 (text+ko) ====
@@ -43,6 +43,8 @@
#include "iicbus_if.h"
#define IIC_M_WR 0 /* write operation */
+#define MAX_RD_SZ 256 /* Largest read size we support */
+#define MAX_WR_SZ 16 /* Largest write size we support */
struct icee_softc {
device_t sc_dev; /* Myself */
@@ -53,6 +55,8 @@
#define OPENED 1
int size; /* How big am I? */
int type; /* What type 8 or 16 bit? */
+ int rd_sz; /* What's the read page size */
+ int wr_sz; /* What's the write page size */
};
#define ICEE_LOCK(_sc) mtx_lock_spin(&(_sc)->sc_mtx)
@@ -101,6 +105,10 @@
dunit = device_get_unit(dev);
resource_int_value(dname, dunit, "size", &sc->size);
resource_int_value(dname, dunit, "type", &sc->type);
+ resource_int_value(dname, dunit, "rd_sz", &sc->rd_sz);
+ if (sc->rd_sz > MAX_RD_SZ)
+ sc->rd_sz = MAX_RD_SZ;
+ resource_int_value(dname, dunit, "wr_sz", &sc->wr_sz);
device_printf(dev, "size: %d bytes bus_width: %d-bits\n", sc->size,
sc->type);
sc->cdev = make_dev(&icee_cdevsw, device_get_unit(dev), UID_ROOT,
@@ -145,7 +153,7 @@
{
struct icee_softc *sc;
uint8_t addr[2];
- uint8_t data[256];
+ uint8_t data[MAX_RD_SZ];
int error, i, len;
struct iic_msg msgs[2] = {
{ 0, IIC_M_WR, 1, addr },
@@ -162,7 +170,8 @@
while (uio->uio_resid > 0) {
if (uio->uio_offset >= sc->size)
break;
- len = MIN(256 - (uio->uio_offset & 0xff), uio->uio_resid);
+ len = MIN(sc->rd_sz - (uio->uio_offset & (sc->rd_sz - 1)),
+ uio->uio_resid);
switch (sc->type) {
case 8:
for (i = 0; i < 2; i++)
@@ -202,7 +211,7 @@
{
struct icee_softc *sc;
int error, len, i;
- uint8_t data[16 + 2];
+ uint8_t data[MAX_WR_SZ + 2];
struct iic_msg msgs[3] = {
{ 0, IIC_M_WR, 0, data },
{ 0, IIC_M_WR, 0, data },
@@ -219,7 +228,8 @@
while (uio->uio_resid > 0) {
if (uio->uio_offset >= sc->size)
break;
- len = MIN(16 - (uio->uio_offset & 0xf), uio->uio_resid);
+ len = MIN(sc->wr_sz - (uio->uio_offset & (sc->wr_sz - 1)),
+ uio->uio_resid);
error = uiomove(data + sc->type / 8, len, uio);
if (error)
break;
@@ -229,7 +239,7 @@
msgs[i].slave = uio->uio_offset >> 8 | sc->addr;
msgs[0].len = 1 + len;
msgs[1].len = 1;
- msgs[2].len = len;
+ msgs[2].len = 1;
msgs[2].buf = data + 1;
data[0] = uio->uio_offset & 0xff;
break;
@@ -238,7 +248,7 @@
msgs[i].slave = sc->addr;
msgs[0].len = 2 + len;
msgs[1].len = 2;
- msgs[2].len = len;
+ msgs[2].len = 1;
msgs[2].buf = data + 2;
data[0] = uio->uio_offset & 0xff;
data[1] = (uio->uio_offset >> 8) & 0xff;
More information about the p4-projects
mailing list