/******************************************************************************
 *
 * Copyright 2017, Lattice Semiconductor, Inc. All rights reserved.
 * No part of this work may be reproduced, modified, distributed, transmitted,
 * transcribed, or translated into any language or computer format, in any form
 * or by any means without written permission of Lattice Semiconductor Inc.,
 * 111 SW 5th Ave, Suite 700, Portland, OR 97204.
 *
 *****************************************************************************/
/**
 * @file sii_drv_cra_api.h
 *
 * @brief Chip Register Access Driver
 *
 *****************************************************************************/

#ifndef SII_DRV_CRA_API_H
#define SII_DRV_CRA_API_H

/***** #include statements ***************************************************/

#include "sii_datatypes.h"

/***** public functions ******************************************************/

void sii_drv_cra_create(uint32_t dev_id);
void sii_drv_cra_delete(uint32_t dev_id);

void sii_drv_cra_write8(uint32_t dev_id, uint16_t addr, uint8_t val);
uint8_t sii_drv_cra_read8(uint32_t dev_id, uint16_t addr);
void sii_drv_cra_bits_set8(uint32_t dev_id, uint16_t addr,
	uint8_t mask, bool_t set);
void sii_drv_cra_bits_mod8(uint32_t dev_id, uint16_t addr,
	uint8_t mask, uint8_t val);

void sii_drv_cra_write16(uint32_t dev_id, uint16_t addr, uint16_t val);
uint16_t sii_drv_cra_read16(uint32_t dev_id, uint16_t addr);
void sii_drv_cra_bits_set16(uint32_t dev_id, uint16_t addr,
	uint16_t mask, bool_t set);
void sii_drv_cra_bits_mod16(uint32_t dev_id, uint16_t addr,
	uint16_t mask, uint16_t val);

void sii_drv_cra_write24(uint32_t dev_id, uint16_t addr, uint32_t val);
uint32_t sii_drv_cra_read24(uint32_t dev_id, uint16_t addr);
void sii_drv_cra_bits_set24(uint32_t dev_id, uint16_t addr,
	uint32_t mask, bool_t set);
void sii_drv_cra_bits_mod24(uint32_t dev_id, uint16_t addr,
	uint32_t mask, uint32_t val);

void sii_drv_cra_write32(uint32_t dev_id, uint16_t addr, uint32_t val);
uint32_t sii_drv_cra_read32(uint32_t dev_id, uint16_t addr);
void sii_drv_cra_bits_set32(uint32_t dev_id, uint16_t addr,
	uint32_t mask, bool_t set);
void sii_drv_cra_bits_mod32(uint32_t dev_id, uint16_t addr,
	uint32_t mask, uint32_t val);

void sii_drv_cra_fifo_write8(uint32_t dev_id, uint16_t addr,
	const uint8_t *p_data, uint16_t size);
void sii_drv_cra_fifo_read8(uint32_t dev_id, uint16_t addr,
	uint8_t *p_data, uint16_t size);
void sii_drv_cra_block_write8(uint32_t dev_id, uint16_t addr,
	const uint8_t *p_data, uint16_t size);
void sii_drv_cra_block_read8(uint32_t dev_id, uint16_t addr,
	uint8_t *p_data, uint16_t size);

#endif /* SII_DRV_CRA_API_H */
