bionic: Add memset to header file

We define this function.  Add its signature to the header file to fix a
warning in gg.c.

Signed-off-by: Sean Cross <xobs@kosagi.com>
README: Rework I2C register layout

Now that we have a clearer idea of what the Senoko I2C device will do,
rework the I2C layout to a more optimal configuration.

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko: Attempt to print out reason for crash

When the board halts, there's usually a reason associated.  Try to
print out the reason for the crash.

Signed-off-by: Sean Cross <xobs@kosagi.com>
cmd-uptime: Add command to show 32-bit uptime

The builtin "systime" command is limited to the precision of the MCU,
which on this part is 16-bits.  This causes it to overflow at 65536 ticks,
or after about one minute.

There is now a global senoko_uptime that is 32-bits.  The cmd-uptime
command simply prints out this value.

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko: chconf: Set periodic ticks, add senoko_uptime

In order to be more precise, we now use periodic ticks rather than
freerunning mode.  This may not actually affect anything, and may
not be a good idea, but it's what we're running with now.

At 1000 Hz, the timer will tick and we'll increment the senoko_uptime
variable.  This gives us more bits to work with, and prevents the
uptime from overflowing every 65 seconds.

Signed-off-by: Sean Cross <xobs@kosagi.com>
chg: Run thread once every 2500 ms

Run the thread more often, because there's no reason not to.

Signed-off-by: Sean Cross <xobs@kosagi.com>
chg: Add mark_line macro

It's currently unused, but might be used in the future.

Signed-off-by: Sean Cross <xobs@kosagi.com>
chg: Correct cell capacity in mWh

Sometimes the gas gauge reports values in mWh.  Previously the value
was incorrect.  Load in the correct value now.

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko: Add senoko_uptime variable to main.c

This variable is global, and is exported in senoko.h.

Signed-off-by: Sean Cross <xobs@kosagi.com>
main: Add gg and chg to recognized mark_line files

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko-slave: Update header file with new layout

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko-slave: Update source file with new layout

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko: Add senoko_uptime to global header file

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko-i2c: Try many more times (50x)

If a chip fails to respond, it seems as though the OS is more likely
to lock up.  While we're still tracking this down, try many more times
to perform the I2C operation before giving up.

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko-slave: Implement uptime, reorder registers slightly

The "uptime" field has now been implemented.  In order to put the uptime
on a 32-bit boundary, registers have been reordered slightly.

Signed-off-by: Sean Cross <xobs@kosagi.com>
README: Add board_type register documentation

Signed-off-by: Sean Cross <xobs@kosagi.com>
chg: Add slop for capacity detection

We detect boards that need programming by looking at the "capacity" field.
Sometimes the mainboard will ask to view data in mWh instead of mAh, in
which case the numbers will be different.  Also, due to voltages and
rounding, the capacity can change.

Add a slop value so that we read a range of values.

Signed-off-by: Sean Cross <xobs@kosagi.com>
debug: Add panic and vsprintf commands

We now break panic code into its own file, so that we can do some
pretty gnarly hacks when the board crashes.

Signed-off-by: Sean Cross <xobs@kosagi.com>
bionic: Add strlen functions

These are used by the new printf code, and in a few other places.

Signed-off-by: Sean Cross <xobs@kosagi.com>
senoko-events: Add power on/off events

These will be broadcast when power state changes.

Signed-off-by: Sean Cross <xobs@kosagi.com>