From: Andy Pugh <[email protected]>
Date: 10 August 2011 00:54
Subject: [PATCH 1/3] Add support for second user register in Smart
Serial, and improve the handling of errors.
To: [email protected]
Cc: Andy Pugh <[email protected]>


Signed-off-by: Andy Pugh <[email protected]>
---
 docs/man/man9/hostmot2.9                           |   42 ++++++--
 src/hal/drivers/mesa-hostmot2/hostmot2.h           |    9 ++
 src/hal/drivers/mesa-hostmot2/mesa_other_sserial.c |   56 +++++++++-
 src/hal/drivers/mesa-hostmot2/sserial.c            |  117 ++++++++++++++++++-
 4 files changed, 207 insertions(+), 17 deletions(-)

diff --git a/docs/man/man9/hostmot2.9 b/docs/man/man9/hostmot2.9
index d047f81..660c62c 100644
--- a/docs/man/man9/hostmot2.9
+++ b/docs/man/man9/hostmot2.9
@@ -53,8 +53,9 @@ the board.
 Each I/O pin can be configured, at board-driver load time, to serve
 one of two purposes: either as a particular I/O pin of a particular
 Module instance (encoder, pwmgen, or stepgen), or as a general purpose
-digital I/O pin.  By default all Module instances are enabled, and all
-the board's pins are used by the Module instances.
+digital I/O pin.  By default all Module instances with the exception of
+SmartSerial are enabled, and all the board's pins are used by the Module
+instances.

 The user can disable Module instances at board-driver load time, by
 specifying a hostmot2 config string modparam.  Any pins which belong to
@@ -154,12 +155,12 @@ The "." character is optional and any characters
other than space and comma are
 OK. However, do not put a leading 0 in front of a digit or it will be read as a
 zero value.
 The ports and channels are numbered in the C-style, starting at 0, so
-num_sserial=8 will activate channels 0 to 7 of port 0.
+num_sserials=8 will activate channels 0 to 7 of port 0.
 The sserial driver will auto-detect the devices. This parameter
determines which
 of the the 8 channels of each port should be searched for devices.
 The channels are activated in ascending order. Pins allocated
 to Smart Serial by the firmware but not connected to a Smart Serial device may
-be used for GPIO. pins activated but on which no devices are found can also be
+be used for GPIO. Pins activated but on which no devices are found can also be
 used for GPIO, but this is not recommended as the pin values and
directions will
 change randomly during the device interogation stage.
 For this reason the feature defaults to all channels disabled.
@@ -474,11 +475,12 @@ The driver auto-detects the connected hardware
port, channel and device type.
 Devices can be connected in any order to any active channel of an active port.
 (see the config modparam definition above).

-In addition to the per-channel/device pins detailed below there are
two per-port
-pins and a further 7 pins shared between all ports used for setting on-device
-parameters.
+In addition to the per-channel/device pins detailed below there are three per-
+port pins, three parameters and a further 7 pins shared between all ports used
+for changing on-device settings.

 Pins:
+
 (bit, in) .sserial.port-N.run: Enables the specific Smart Serial module.
 Setting this pin low will disable all boards on the port and puts the port in a
 pass-through mode where device parameter setting is possible.
@@ -486,10 +488,13 @@ This pin defaults to TRUE and can be left
unconnected. However, toggling the pin
 low-to-high will re-enable a faulted drive so the pin could usefully be
 connected to the iocontrol.0.user-enable-out pin.

-(u32, ro) run_state: Shows the state of the sserial communications
state-machine.
-This pin will generally show  value of 0x03 in normal operation, 0x07 in
+(u32, ro) .run_state: Shows the state of the sserial communications
state-machine.
+This pin will generally show a value of 0x03 in normal operation, 0x07 in
 setup mode and 0x00 when the "run" pin is false.

+(u32, ro) .error-count: Indicates the state of the Smart Serial error handler,
+see the parameters sections for more details.
+
 (u32, in) .sserial.port: When programming device parameters, this pin sets the
 active port.

@@ -514,6 +519,25 @@ pin will return to zero (if not connected in HAL)
 typically takes many servo cycles). See the source code if the precise meanings
 are important to your application.

+Parameters:
+
+(u32 r/w) .fault-inc: Any over-run or handshaking error in the SmartSerial
+communications will increment the .fault-count pin by the amount specified by
+this parameter. Default = 10.
+
+(u32 r/w) .fault-dec: Every successful read/write cycle decrements the fault
+counter by this amount. Default = 1.
+
+(u32 r/w) .fault-lim: When the fault counter reaches this threshold the Smart
+Serial interface on the corresponding port will be stopped and an error printed
+in dmesg. Together these three pins allow for control over the degree of fault-
+tolerance allowed in the interface. The default values mean that if more than
+one transaction in ten fails, more than 20 times, then a hard error will be
+raised. If the increment were to be set to zero then no error would ever be
+raised, and the system would carry on regardless. Conversely setting
decrement to
+zero, threshold to 1 and limit to 1 means that absolutely no errors will be
+tolerated. (This structure is copied directly from vehicle ECU practice)
+
 The other pins and parameters created in HAL depend on the devices detected.
 .TP
 .SH \fB8i20\fR
diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.h
b/src/hal/drivers/mesa-hostmot2/hostmot2.h
index fe67d5d..4e6463b 100644
--- a/src/hal/drivers/mesa-hostmot2/hostmot2.h
+++ b/src/hal/drivers/mesa-hostmot2/hostmot2.h
@@ -516,8 +516,10 @@ typedef struct {
    struct{
        hal_u32_t *hm2_reg_0_read;
        hal_u32_t *hm2_reg_1_read;
+        hal_u32_t *hm2_reg_2_read;
        hal_u32_t *hm2_reg_0_write;
        hal_u32_t *hm2_reg_1_write;
+        hal_u32_t *hm2_reg_2_write;
    }pin;
    int card_type;
    hal_u32_t hm2_serialnumber;
@@ -530,9 +532,12 @@ typedef struct {
    u32 *reg_0_write;
    u32 *reg_1_read;
    u32 *reg_1_write;
+    u32 *reg_2_read;
+    u32 *reg_2_write;
    u32 reg_cs_addr;
    u32 reg_0_addr;
    u32 reg_1_addr;
+    u32 reg_2_addr;
    u32 tag;
    u32 reg_command_addr; // a duplicate so that a single channel can be passed
    u32 reg_data_addr;
@@ -563,6 +568,10 @@ typedef struct {
    u32 data_reg_addr;
    u32 *data_reg_read;
    u32 *data_reg_write;
+    hal_u32_t *fault_count;
+    hal_u32_t fault_inc;
+    hal_u32_t fault_dec;
+    hal_u32_t fault_lim;

    hal_bit_t *run;
    hal_u32_t *state;
diff --git a/src/hal/drivers/mesa-hostmot2/mesa_other_sserial.c
b/src/hal/drivers/mesa-hostmot2/mesa_other_sserial.c
index 6b49f44..2eaad4a 100755
--- a/src/hal/drivers/mesa-hostmot2/mesa_other_sserial.c
+++ b/src/hal/drivers/mesa-hostmot2/mesa_other_sserial.c
@@ -100,6 +100,22 @@ int hm2_other_create(hostmot2_t *hm2,
hm2_module_descriptor_t *md) {
                            c);
                    goto fail1;
                }
+
+                r = hal_pin_u32_newf(HAL_IN, &(hal->pin.hm2_reg_2_write),
+
hm2->llio->comp_id,"%s.BoardID-%X.%1d.%1d.reg-2-write",
+                                     hm2->llio->name,
+                                     hal->card_type,
+                                     inst->module_index,
+                                     c);
+                if (r < 0) {
+                    HM2_ERR("error adding pin
%s.BoardID-%X.%1d.%1d.reg-2-write. aborting\n",
+                            hm2->llio->name,
+                            hal->card_type,
+                            inst->module_index,
+                            c);
+                    goto fail1;
+                }
+
                r = hal_pin_u32_newf(HAL_OUT, &(hal->pin.hm2_reg_0_read),

hm2->llio->comp_id,"%s.BoardID-%X.%1d.%1d.reg-0-read",
                                     hm2->llio->name,
@@ -129,6 +145,21 @@ int hm2_other_create(hostmot2_t *hm2,
hm2_module_descriptor_t *md) {
                            c);
                    goto fail1;
                }
+                r = hal_pin_u32_newf(HAL_OUT, &(hal->pin.hm2_reg_2_read),
+
hm2->llio->comp_id,"%s.BoardID-%X.%1d.%1d.reg-2-read",
+                                     hm2->llio->name,
+                                     hal->card_type,
+                                     inst->module_index,
+                                     c);
+                if (r < 0) {
+                    HM2_ERR("error adding pin
%s.BoardID-%X.%1d.%1d.reg-2-read. aborting\n",
+                            hm2->llio->name,
+                            hal->card_type,
+                            inst->module_index,
+                            c);
+                    goto fail1;
+                }
+
                // Register the TRAM values and store the register addresses for
                // other functions to use

@@ -169,6 +200,19 @@ int hm2_other_create(hostmot2_t *hm2,
hm2_module_descriptor_t *md) {
                            "interface 1 register (%d)\n", r);
                    goto fail1;
                }
+
+                tram->reg_2_addr = md->base_address + 5 * md->register_stride
+                + inst->module_index * md->instance_stride
+                + c * sizeof(u32);
+                r = hm2_register_tram_read_region(hm2,
+                                                  tram->reg_2_addr,
+                                                  sizeof(u32),
+                                                  &tram->reg_2_read);
+                if (r < 0) {
+                    HM2_ERR("error registering tram read region for sserial "
+                            "interface 2 register (%d)\n", r);
+                    goto fail1;
+                }

                r = hm2_register_tram_write_region(hm2,
                                                   tram->reg_0_addr,
@@ -188,7 +232,15 @@ int hm2_other_create(hostmot2_t *hm2,
hm2_module_descriptor_t *md) {
                            "interface 1 register (%d)\n", r);
                    goto fail1;
                }
-
+                r = hm2_register_tram_write_region(hm2,
+                                                   tram->reg_2_addr,
+                                                   sizeof(u32),
+                                                   &(tram->reg_2_write));
+                if (r < 0) {
+                    HM2_ERR("error registering tram write region for sserial"
+                            "interface 2 register (%d)\n", r);
+                    goto fail1;
+                }
            }
        }
    }
@@ -228,6 +280,7 @@ void hm2_other_prepare_tram_write(hostmot2_t *hm2){
            hm2_sserial_tram_t *tram = &inst->tram_other[c];
            *tram->reg_0_write = *hal->pin.hm2_reg_0_write;
            *tram->reg_1_write = *hal->pin.hm2_reg_1_write;
+            *tram->reg_2_write = *hal->pin.hm2_reg_2_write;
        }
    }
 }
@@ -247,6 +300,7 @@ void hm2_other_process_tram_read(hostmot2_t *hm2){
            hm2_sserial_tram_t *tram = &inst->tram_other[c];
            *hal->pin.hm2_reg_0_read = *tram->reg_0_read;
            *hal->pin.hm2_reg_1_read = *tram->reg_1_read;
+            *hal->pin.hm2_reg_2_read = *tram->reg_2_read;
        }
    }
 }
diff --git a/src/hal/drivers/mesa-hostmot2/sserial.c
b/src/hal/drivers/mesa-hostmot2/sserial.c
index a9eea4c..0bd5ac7 100644
--- a/src/hal/drivers/mesa-hostmot2/sserial.c
+++ b/src/hal/drivers/mesa-hostmot2/sserial.c
@@ -44,7 +44,14 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
    // some standard sanity checks
    //

-    if (!hm2_md_is_consistent_or_complain(hm2, md_index, 0, 5, 0x40, 0x001F)) {
+    if (hm2_md_is_consistent(hm2, md_index, 0, 5, 0x40, 0x001F)) {
+        HM2_ERR("The bitfile contains Smart Serial modules for a firmware "
+                "revision < rev22. This Driver now requires rev22 or newer "
+                "firmwares\n");
+        return -EINVAL;
+    }
+
+    if (!hm2_md_is_consistent_or_complain(hm2, md_index, 0, 6, 0x40, 0x003C)) {
        HM2_ERR("inconsistent Module Descriptor!\n");
        return -EINVAL;
    }
@@ -209,7 +216,8 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
        }
        if (inst->num_all > 0){
            r = hal_pin_bit_newf(HAL_IN, &(inst->run),
-                                 hm2->llio->comp_id, "%s.sserial.port-%1d.run",
+                                 hm2->llio->comp_id,
+                                 "%s.sserial.port-%1d.run",
                                 hm2->llio->name, i);
            if (r < 0) {
                HM2_ERR("error adding pin %s.sserial.%1d.run. aborting\n",
@@ -217,22 +225,65 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
                goto fail0;
            }
            r = hal_pin_u32_newf(HAL_OUT, &(inst->state),
-                                 hm2->llio->comp_id,
"%s.sserial.port-%1d.port_state",
+                                 hm2->llio->comp_id,
+                                 "%s.sserial.port-%1d.port_state",
                                 hm2->llio->name, i);
            if (r < 0) {
                HM2_ERR("error adding pin %s.sserial.%1d.port_state.
aborting\n",
                        hm2->llio->name, i);
                goto fail0;
            }
+            r = hal_pin_u32_newf(HAL_OUT, &(inst->fault_count),
+                                 hm2->llio->comp_id,
+                                 "%s.sserial.port-%1d.fault-count",
+                                 hm2->llio->name, i);
+            if (r < 0) {
+                HM2_ERR("error adding pin %s.sserial.%1d.fault-count.
aborting\n",
+                        hm2->llio->name, i);
+                goto fail0;
+            }
+            r = hal_param_u32_newf(HAL_RW, &(inst->fault_inc),
+                                   hm2->llio->comp_id,
+                                   "%s.sserial.port-%1d.fault-inc",
+                                   hm2->llio->name, i);
+            if (r < 0) {
+                HM2_ERR("error adding parameter %s.sserial.port-%1d.fault-inc"
+                        " aborting\n",hm2->llio->name, i);
+                goto fail0;
+            }

+            r = hal_param_u32_newf(HAL_RW, &(inst->fault_dec),
+                                   hm2->llio->comp_id,
+                                   "%s.sserial.port-%1d.fault-dec",
+                                   hm2->llio->name, i);
+            if (r < 0) {
+                HM2_ERR("error adding parameter %s.sserial.port-%1d.fault-dec"
+                        " aborting\n",hm2->llio->name, i);
+                goto fail0;
+            }
+
+            r = hal_param_u32_newf(HAL_RW, &(inst->fault_lim),
+                                   hm2->llio->comp_id,
+                                   "%s.sserial.port-%1d.fault-lim",
+                                   hm2->llio->name, i);
+            if (r < 0) {
+                HM2_ERR("error adding parameter %s.sserial.port-%1d.fault-lim"
+                        " aborting\n",hm2->llio->name, i);
+                goto fail0;
+            }
+            //parameter defaults;
+            inst->fault_dec = 1;
+            inst->fault_inc = 10;
+            inst->fault_lim = 200;
+
            //only move to the next instance if this one contains things.
            //hm2->sserial.instance[0] will be the lowest numbered module
            //with attached hardware.
-
+
            count++ ;
        }
    }
-
+

    hm2->sserial.num_instances = count; // because of the extra increment

@@ -306,7 +357,8 @@ void hm2_sserial_prepare_tram_write(hostmot2_t
*hm2, long period){
    // smart-serial modules. Useful for restarting broken comms.
    // Actual tram setup is handled by the sub-drivers

-    int i;
+    static int doit_err_count, comm_err_flag; // to avoid repeating
error messages
+    int i,f;

    if (hm2->sserial.num_instances <= 0) return;

@@ -327,15 +379,63 @@ void hm2_sserial_prepare_tram_write(hostmot2_t
*hm2, long period){
                *inst->state = 0x11;
                inst->timer = 0;
                *inst->command_reg_write = 0x900 | inst->tag_all;
+                *inst->fault_count = 0;
+                doit_err_count = 0;
+                comm_err_flag = 0;
                break;
            case 0x01: // normal running
                if (!*inst->run){
                     *inst->state = 0x02;
                    break;
                }
+                if (*inst->fault_count > inst->fault_lim) {
+                    // If there have been a large percentage of
misses, for quite
+                    // a long time, it's time to take it seriously.
+                    HM2_ERR("Smart Serial Comms Error: "
+                            "There have been more than %i errors in %i "
+                            "thread executions at least %i times. "
+                            "See other error messages for details.\n",
+                            inst->fault_dec,
+                            inst->fault_inc,
+                            inst->fault_lim);
+                    HM2_ERR("***Smart Serial Port %i will be stopped***\n",i);
+                    *inst->state = 0x20;
+                    *inst->command_reg_write = 0x800; // stop command
+                }
                if (*inst->command_reg_read) {
-                    HM2_ERR("DoIt not cleared from previous servo thread");
+                    if (doit_err_count < 6){ doit_err_count++; }
+                    if (doit_err_count == 4 ){ // ignore 4 errors at startup
+                        HM2_ERR("Smart Serial port %i: DoIt not
cleared from previous "
+                                "servo thread. Servo thread rate
probably too fast. "
+                                "This message will not be repeated, but the "
+                                "%s.sserial.%1d.fault-count pin will indicate "
+                                "if this is happening frequently.\n",
+                                i, hm2->llio->name, i);
+                    }
+                    *inst->fault_count += inst->fault_inc;
+                    break; // give the register chance to clear
+                }
+                if (*inst->data_reg_read & 0xff){ // indicates a
failed transfer
+                    *inst->fault_count += inst->fault_inc;
+                    f = (*inst->data_reg_read & (comm_err_flag ^ 0xFF));
+                    if (f != 0 && f != 0xFF){
+                        comm_err_flag |= (f & -f); //mask LSb
+                        HM2_ERR("Smart Serial data transfer failure
on port %i, "
+                                "channel %i. This error is probably caused by "
+                                "a problem with the attached card. This error "
+                                "message will not repeat for this channel.\n",
+                                i, ffs(f) - 1);
+                    }
                }
+
+                if (*inst->fault_count > inst->fault_dec) {
+                    *inst->fault_count -= inst->fault_dec;
+                }
+                else
+                {
+                    *inst->fault_count = 0;
+                }
+
                *inst->command_reg_write = 0x1000 | inst->tag_all;
                break;

@@ -358,6 +458,9 @@ void hm2_sserial_prepare_tram_write(hostmot2_t
*hm2, long period){
                *inst->state &= 0x0F;
                *inst->command_reg_write = 0x80000000; // mask pointless writes
                break;
+            case 0x20:// Do-nothing state for serious errors. require
run pin to cycle
+                if ( ! *inst->run){*inst->state = 0x02;}
+                break;
            default: // Should never happen
                HM2_ERR("Unhandled run/stop configuration in \n"
                        "hm2_sserial_write (%x)\n",
--
1.7.0.4


>From 18553272786ca369bc397d1651a15f9236f12a94 Mon Sep 17 00:00:00 2001
From: Andy Pugh <[email protected]>
Date: Thu, 28 Jul 2011 02:58:29 +0100
Subject: [PATCH 2/3] Switch to config strings.

Signed-off-by: Andy Pugh <[email protected]>
---
 src/hal/drivers/mesa-hostmot2/mesa_8i20.c |    4 ++--
 src/hal/drivers/mesa-hostmot2/sserial.c   |   15 ++++++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/hal/drivers/mesa-hostmot2/mesa_8i20.c
b/src/hal/drivers/mesa-hostmot2/mesa_8i20.c
index 51008a4..efbeb3b 100644
--- a/src/hal/drivers/mesa-hostmot2/mesa_8i20.c
+++ b/src/hal/drivers/mesa-hostmot2/mesa_8i20.c
@@ -242,7 +242,7 @@ void hm2_8i20_prepare_tram_write(hostmot2_t *hm2){

            if (hal->param.hm2_max_current > hal->param.hm2_nv_max_current) {
                HM2_ERR("8i20 %X EEPROM Max Curent is %f.\n You asked for %f."
-                        "Resetting to EEPROM max.",
+                        "Resetting to EEPROM max.\n",
                        hal->param.hm2_serialnumber,
                        hal->param.hm2_nv_max_current,
                        hal->param.hm2_max_current);
@@ -250,7 +250,7 @@ void hm2_8i20_prepare_tram_write(hostmot2_t *hm2){
            }
            if (hal->param.hm2_max_current < 0){
                HM2_ERR("8i20 minimum setting for max_current
parameter is zero."
-                        "Resetting to zero");
+                        "Resetting to zero\n");
                hal->param.hm2_max_current = 0;
            }

diff --git a/src/hal/drivers/mesa-hostmot2/sserial.c
b/src/hal/drivers/mesa-hostmot2/sserial.c
index 0bd5ac7..c2b71e1 100644
--- a/src/hal/drivers/mesa-hostmot2/sserial.c
+++ b/src/hal/drivers/mesa-hostmot2/sserial.c
@@ -164,7 +164,7 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
            r = -EINVAL;
            goto fail0;
        }
-        // start up the card in setup mode so any sub-drivers can
read parameters out
+        // start up the card so any sub-drivers can read parameters out
        buff=0xF00 | (0xFF >> (8 - hm2->config.num_sserial_chans[i]));
        hm2->llio->write(hm2->llio, inst->command_reg_addr, &buff, sizeof(u32));
        if (hm2_sserial_waitfor(hm2, inst->command_reg_addr,
0xFFFFFFFF, 8000) < 0){
@@ -177,12 +177,11 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
        inst->num_7i64 = 0;
        inst->tag_all = 0;
        inst->num_all = 0;
-
        for (c = 0 ; c < inst->num_channels ; c++) {
-            addr = md->base_address + 2 * md->register_stride
+            addr = md->base_address + 4 * md->register_stride
            + i * md->instance_stride + c * sizeof(u32);
            hm2->llio->read(hm2->llio, addr, &buff, sizeof(u32));
-            buff >>= 24;
+            //buff >>= 24;
            HM2_DBG("Device Code %X at addr %x\n",buff, addr);
            switch (buff) {
                case 0x0: // nothing connected, or masked by config
@@ -194,13 +193,15 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
                        }
                    }
                    break;
-                case HM2_SSERIAL_TYPE_8I20: // 8i20 found
+                //case HM2_SSERIAL_TYPE_8I20: // 8i20 found
+                case 0x30324938:
                    inst->tag_8i20 |= (1 << c);
                    inst->tag_all |= (1 << c);
                    inst->num_8i20 += 1;
                    inst->num_all += 1;
                    break;
-                case HM2_SSERIAL_TYPE_7I64: // 7i64 found
+                //case HM2_SSERIAL_TYPE_7I64: // 7i64 found
+                case 0x34364937:
                    inst->tag_7i64 |= (1 << c);
                    inst->tag_all |= (1 << c);
                    inst->num_7i64 += 1;
@@ -344,7 +345,6 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
        hm2->llio->write(hm2->llio, hm2->ioport.alt_source_addr + 4 * port,
                         &src_reg, sizeof(u32));
    }
-
    return hm2->sserial.num_instances;
 fail0:
    hm2->sserial.num_instances = 0;
@@ -413,6 +413,7 @@ void hm2_sserial_prepare_tram_write(hostmot2_t
*hm2, long period){
                                i, hm2->llio->name, i);
                    }
                    *inst->fault_count += inst->fault_inc;
+                    *inst->command_reg_write = 0x80000000; // set
bit31 for ignored cmd
                    break; // give the register chance to clear
                }
                if (*inst->data_reg_read & 0xff){ // indicates a failed transfer
--
1.7.0.4


>From 421f70e496cb53a4ff7db55c8f30b92f16c08c8e Mon Sep 17 00:00:00 2001
From: Andy Pugh <[email protected]>
Date: Wed, 10 Aug 2011 00:37:17 +0100
Subject: [PATCH 3/3] Tidy up 8i20 fault handling and support second
user register

Signed-off-by: Andy Pugh <[email protected]>
---
 src/hal/drivers/mesa-hostmot2/hostmot2.h |    4 ++--
 src/hal/drivers/mesa-hostmot2/sserial.c  |   10 +++-------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.h
b/src/hal/drivers/mesa-hostmot2/hostmot2.h
index 4e6463b..88f0840 100644
--- a/src/hal/drivers/mesa-hostmot2/hostmot2.h
+++ b/src/hal/drivers/mesa-hostmot2/hostmot2.h
@@ -472,8 +472,8 @@ typedef struct {
 // sserial (Smart Serial Interface)
 //

-#define HM2_SSERIAL_TYPE_8I20               0x80  // this is the
magic cookie returned by this module type
-#define HM2_SSERIAL_TYPE_7I64               0x74  // More to be added later.
+#define HM2_SSERIAL_TYPE_8I20               0x30324938  // '8i20' as 4 ascii
+#define HM2_SSERIAL_TYPE_7I64               0x34364937  // More to be
added later.


 typedef struct {
diff --git a/src/hal/drivers/mesa-hostmot2/sserial.c
b/src/hal/drivers/mesa-hostmot2/sserial.c
index c2b71e1..2816c8a 100644
--- a/src/hal/drivers/mesa-hostmot2/sserial.c
+++ b/src/hal/drivers/mesa-hostmot2/sserial.c
@@ -164,7 +164,7 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
            r = -EINVAL;
            goto fail0;
        }
-        // start up the card so any sub-drivers can read parameters out
+        // start up the card in setup mode so any sub-drivers can
read parameters out
        buff=0xF00 | (0xFF >> (8 - hm2->config.num_sserial_chans[i]));
        hm2->llio->write(hm2->llio, inst->command_reg_addr, &buff, sizeof(u32));
        if (hm2_sserial_waitfor(hm2, inst->command_reg_addr,
0xFFFFFFFF, 8000) < 0){
@@ -181,8 +181,6 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
            addr = md->base_address + 4 * md->register_stride
            + i * md->instance_stride + c * sizeof(u32);
            hm2->llio->read(hm2->llio, addr, &buff, sizeof(u32));
-            //buff >>= 24;
-            HM2_DBG("Device Code %X at addr %x\n",buff, addr);
            switch (buff) {
                case 0x0: // nothing connected, or masked by config
                    for (pin = 0 ; pin < hm2->num_pins ; pin++){
@@ -193,15 +191,13 @@ int hm2_sserial_parse_md(hostmot2_t *hm2, int md_index) {
                        }
                    }
                    break;
-                //case HM2_SSERIAL_TYPE_8I20: // 8i20 found
-                case 0x30324938:
+                case HM2_SSERIAL_TYPE_8I20: // 8i20 found
                    inst->tag_8i20 |= (1 << c);
                    inst->tag_all |= (1 << c);
                    inst->num_8i20 += 1;
                    inst->num_all += 1;
                    break;
-                //case HM2_SSERIAL_TYPE_7I64: // 7i64 found
-                case 0x34364937:
+                case HM2_SSERIAL_TYPE_7I64: // 7i64 found
                    inst->tag_7i64 |= (1 << c);
                    inst->tag_all |= (1 << c);
                    inst->num_7i64 += 1;
--
1.7.0.4




-- 
atp

------------------------------------------------------------------------------
Get a FREE DOWNLOAD! and learn more about uberSVN rich system, 
user administration capabilities and model configuration. Take 
the hassle out of deploying and managing Subversion and the 
tools developers use with it. 
http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Emc-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to