SPI_MIN_DMA can cause a request for greater than the number
of bytes needed to complete a packet. Limit the number of bytes
copied into the rx buffer by the rx buffer length.
Bug: 35804737
Change-Id: Ibb02272fa549879f716519f541bff656104f8a1c
Signed-off-by: Ben Fennema <fennema@google.com>
Signed-off-by: Siqi Lin <siqilin@google.com>
wakeup signal management was not correct for IRQ2-enabled
systems. Unwanted transitions on wakeup line were causing
IRQ1 in response, and blocking suspend operation.
wakeup signal management is reworked, so that it is
controlled by pair of counters:
lock counter keeps track of all wakeup requests, and
wakeup counter keeps track of only those requests who
need to wakeup MCU by driving wakeup low.
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: Ie7c2cd3b8927976fbd20177a76d77fea7205293d
Bug: 28271752
Don't issue a read request when no pending interrupts.
Bump up the read kthread priority
Bug: 27815143
Change-Id: I810865aaaf5d08e858d66c4ede1e6a703b4e8d38
Signed-off-by: Ben Fennema <fennema@google.com>
platforms with IRQ2 available are not able to suspend,
if non-wakeup events are flowing quite often.
To fix it, we acquire lock on wakeup signal, before
attempting to check for IO activity.
We no longer need to check the activity of worker thread,
because if we have the lock, thread has nothing to do but wait
for us, however it may not yet reach the IDLE state, and
we don't want to lose time waiting for this to happen.
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: Id9c661ec022b8a6b1b53ebdcd7392006d74e40d5
Bug: 28271752
Older versions of sensorhub hang while triyng to
communicate with FW, because FW upload did not
succeed.
This behavior was introduced by
commit 3eaf0d1025d2 ("ANDROID: nanohub: fix error handling on probe path")
This change is removing requirement for
interrupt handshake as precondition for FW upload,
hence resolves the issue. It also adds timeout on
write as extra precausion.
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Change-Id: I1e6a39f7c43c0a083b89fb6e48ea30006ce96f4a
Bug: 27421260
this fixes resource leaks in case of failures at probe
time. fixes leaks on module unload as well.
removes some code duplication. minor logic cleanup.
Signed-off-by: Alexey Polyudov <apolyudov@google.com>
Bug: 27810219
Change-Id: I1f3ebdf78fe44b3ac97a64717819d75a485b6470
add /dev/nanohub_comms for context hub hal to communicate through
Change-Id: Idc02b3a0be7c85bc86ce95671c031f0ed56c0e37
Signed-off-by: Ben Fennema <fennema@google.com>
The spacing between spi transactions can vary greatly, so time
out based on elapsed time instead of number of transactions.
Change-Id: I21ef1f5f0e7a1946871c0614d438ec9b7c91275f
Signed-off-by: Ben Fennema <fennema@google.com>
Timeout and log an error instead of waiting forever for the sensorhub to
wake up.
Bug: 27373474
Change-Id: If4a200490846ee303a4177ebca8c31824ce34199
Signed-off-by: Ben Fennema <fennema@google.com>
error path:
thread1:
release_wakeup:
dec wakeup_cnt, new value is 0:
<schedule occurs> (prior to setting wakeup gpio to inactive)
thread2:
request_wakeup:
inc wakeup_cnt, new value is 1:
set wakeup gpio to active
...
thread1:
set wakeup gpio to inactive
Bug: 27336006
Change-Id: I72b5e408207c7cef18153c93f041eb734c17adec
Signed-off-by: Ben Fennema <fennema@google.com>
Adds nanohub kernel driver files as well as device tree configuration to
use nanohub instead of contexthub (spich)
Change-Id: I089dd5c3a08968a002e965e8d1ed260b93e32ce3
Signed-off-by: Ben Fennema <fennema@google.com>