Files
OpenCellular/chip/g/sps.h
Vadim Bendebury 36ed861be8 cr50: sps: allow receive registration function set FIFO threshold
The default receive FIFO threshold of 8 (meaning that 9 bytes need to
be received before receive IRQ fires) is good for high volume
transfers, when the amount of transferred data greatly exceeds the
threshold.

But in case of TPM transactions, which start with a 4 byte header and
then stall while the device processes it, the default threshold
guarantees delays on every transaction, as the receiver does not start
processing the header until 5 idle bytes are transferred to bring the
total number to nine.

The suggested solution is to allow to specify the receive FIFO
interrupt request threshold at run time, by adding this value to the
receive function registration API.

BRANCH=none
BUG=chrome-os-partner:43025
TEST=verified that spstest still works fine.

Change-Id: I92517205a7d0d47893b702efa188eb524fb18a49
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/289331
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
2015-08-13 23:34:05 +00:00

56 lines
1.6 KiB
C

/*
* Copyright 2015 The Chromium OS Authors. All rights reserved.
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef __CROS_EC_INCLUDE_SPS_H
#define __CROS_EC_INCLUDE_SPS_H
#include "spi.h"
#include "util.h"
/* SPS Control Mode */
enum sps_mode {
SPS_GENERIC_MODE = 0,
SPS_SWETLAND_MODE = 1,
SPS_ROM_MODE = 2,
SPS_UNDEF_MODE = 3,
};
/* Receive and transmit FIFO size and mask. */
#define SPS_FIFO_SIZE (1 << 10)
#define SPS_FIFO_MASK (SPS_FIFO_SIZE - 1)
/*
* Tx interrupt callback function prototype. This function returns a portion
* of the received SPI data and current status of the CS line. When CS is
* deasserted, this function is called with data_size of zero and a non-zero
* cs_status. This allows the recipient to delineate the SPS frames.
*/
typedef void (*rx_handler_f)(uint8_t *data, size_t data_size, int cs_disabled);
/*
* Push data to the SPS TX FIFO
* @param data Pointer to 8-bit data
* @param data_size Number of bytes to transmit
* @return : actual number of bytes placed into tx fifo
*/
int sps_transmit(uint8_t *data, size_t data_size);
/*
* These functions return zero on success or non-zero on failure (attempt to
* register a callback on top of existing one, or attempt to unregister
* non-exitisng callback.
*
* rx_fifo_threshold value of zero means 'default'.
*/
int sps_register_rx_handler(enum sps_mode mode,
rx_handler_f rx_handler,
unsigned rx_fifo_threshold);
int sps_unregister_rx_handler(void);
void sps_tx_status(uint8_t byte);
unsigned sps_rx_fifo_wrptr(void);
#endif