Skip to content

Commit

Permalink
nvram_spi: Make nvram_spi_read/write static.
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Gebart committed Jan 27, 2015
1 parent b0dd382 commit f524173
Showing 1 changed file with 64 additions and 4 deletions.
68 changes: 64 additions & 4 deletions drivers/nvram_spi/nvram-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,66 @@ typedef enum {
* removed. */
#define NVRAM_SPI_CS_TOGGLE_TICKS 1

/**
* @brief Copy data from system memory to NVRAM.
*
* @param[in] dev Pointer to NVRAM device descriptor
* @param[in] src Pointer to the first byte in the system memory address space
* @param[in] dst Starting address in the NVRAM device address space
* @param[in] len Number of bytes to copy
*
* @return Number of bytes written on success
* @return <0 on errors
*/
static int nvram_spi_write(nvram_t *dev, uint8_t *src, uint32_t dst, size_t len);

/**
* @brief Copy data from NVRAM to system memory.
*
* @param[in] dev Pointer to NVRAM device descriptor
* @param[out] dst Pointer to the first byte in the system memory address space
* @param[in] src Starting address in the NVRAM device address space
* @param[in] len Number of bytes to copy
*
* @return Number of bytes written on success
* @return <0 on errors
*/
static int nvram_spi_read(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len);

/**
* @brief Copy data from system memory to NVRAM.
*
* This is a special form of the WRITE command used by some Ramtron/Cypress
* 4Kbit FRAM devices which puts the 9th address bit inside the command byte to
* be able to use one byte for addressing instead of two.
*
* @param[in] dev Pointer to NVRAM device descriptor
* @param[in] src Pointer to the first byte in the system memory address space
* @param[in] dst Starting address in the NVRAM device address space
* @param[in] len Number of bytes to copy
*
* @return Number of bytes written on success
* @return <0 on errors
*/
static int nvram_spi_write_9bit_addr(nvram_t *dev, uint8_t *src, uint32_t dst, size_t len);

/**
* @brief Copy data from NVRAM to system memory.
*
* This is a special form of the READ command used by some Ramtron/Cypress 4Kbit
* FRAM devices which puts the 9th address bit inside the command byte to be
* able to use one byte for addressing instead of two.
*
* @param[in] dev Pointer to NVRAM device descriptor
* @param[out] dst Pointer to the first byte in the system memory address space
* @param[in] src Starting address in the NVRAM device address space
* @param[in] len Number of bytes to copy
*
* @return Number of bytes written on success
* @return <0 on errors
*/
static int nvram_spi_read_9bit_addr(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len);

int nvram_spi_init(nvram_t *dev, nvram_spi_params_t *spi_params, size_t size)
{
dev->size = size;
Expand All @@ -60,7 +120,7 @@ int nvram_spi_init(nvram_t *dev, nvram_spi_params_t *spi_params, size_t size)
return 0;
}

int nvram_spi_write(nvram_t *dev, uint32_t dst, uint8_t *src, size_t len)
static int nvram_spi_write(nvram_t *dev, uint8_t *src, uint32_t dst, size_t len)
{
nvram_spi_params_t *spi_dev = (nvram_spi_params_t *) dev->extra;
int status;
Expand Down Expand Up @@ -107,7 +167,7 @@ int nvram_spi_write(nvram_t *dev, uint32_t dst, uint8_t *src, size_t len)
return status;
}

int nvram_spi_read(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len)
static int nvram_spi_read(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len)
{
nvram_spi_params_t *spi_dev = (nvram_spi_params_t *) dev->extra;
int status;
Expand Down Expand Up @@ -145,7 +205,7 @@ int nvram_spi_read(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len)
}


int nvram_spi_write_9bit_addr(nvram_t *dev, uint32_t dst, uint8_t *src, size_t len)
static int nvram_spi_write_9bit_addr(nvram_t *dev, uint8_t *src, uint32_t dst, size_t len)
{
nvram_spi_params_t *spi_dev = (nvram_spi_params_t *) dev->extra;
int status;
Expand Down Expand Up @@ -188,7 +248,7 @@ int nvram_spi_write_9bit_addr(nvram_t *dev, uint32_t dst, uint8_t *src, size_t l
return status;
}

int nvram_spi_read_9bit_addr(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len)
static int nvram_spi_read_9bit_addr(nvram_t *dev, uint8_t *dst, uint32_t src, size_t len)
{
nvram_spi_params_t *spi_dev = (nvram_spi_params_t *) dev->extra;
int status;
Expand Down

0 comments on commit f524173

Please sign in to comment.