/*************************************************************************** * * Copyright 2015-2019 BES. * All rights reserved. All unpublished rights reserved. * * No part of this work may be used or reproduced in any form or by any * means, or stored in a database or retrieval system, without prior written * permission of BES. * * Use of this work is governed by a license granted by BES. * This work contains confidential and proprietary information of * BES. which is protected by copyright, trade secret, * trademark and other intellectual property rights. * ****************************************************************************/ #ifndef __HAL_SPDIFIP_H__ #define __HAL_SPDIFIP_H__ #ifdef __cplusplus extern "C" { #endif #include "plat_types.h" #include "reg_spdifip.h" #define spdifip_read32(b,a) \ (*(volatile uint32_t *)(b+a)) #define spdifip_write32(v,b,a) \ ((*(volatile uint32_t *)(b+a)) = v) static inline void spdifip_w_enable_spdifip(uint32_t reg_base, uint32_t v) { uint32_t val = 0; val = spdifip_read32(reg_base, SPDIFIP_ENABLE_REG_REG_OFFSET); if (v) val |= SPDIFIP_ENABLE_REG_SPDIF_ENABLE_MASK; else val &= ~SPDIFIP_ENABLE_REG_SPDIF_ENABLE_MASK; spdifip_write32(val, reg_base, SPDIFIP_ENABLE_REG_REG_OFFSET); } #if 0 static inline void spdifip_w_enable_clk_gen(uint32_t reg_base, uint32_t v) { if (v) spdifip_write32(1, reg_base, SPDIFIP_CLK_GEN_ENABLE_REG_REG_OFFSET); else spdifip_write32(0, reg_base, SPDIFIP_CLK_GEN_ENABLE_REG_REG_OFFSET); } #endif #if 0 static inline void spdifip_w_enable_rx_block(uint32_t reg_base, uint32_t v) { if (v) spdifip_write32(1, reg_base, SPDIFIP_RX_BLOCK_ENABLE_REG_REG_OFFSET); else spdifip_write32(0, reg_base, SPDIFIP_RX_BLOCK_ENABLE_REG_REG_OFFSET); } #endif static inline void spdifip_w_sample_en(uint32_t reg_base, uint32_t v) { uint32_t val = 0; val = spdifip_read32(reg_base, SPDIFIP_RX_CFG_REG_OFFSET); if (v) val |= SPDIFIP_RX_CFG_SAMPLEEN_MASK; else val &= ~SPDIFIP_RX_CFG_SAMPLEEN_MASK; spdifip_write32(val, reg_base, SPDIFIP_RX_CFG_REG_OFFSET); } static inline void spdifip_w_enable_rx(uint32_t reg_base, uint32_t v) { uint32_t val = 0; val = spdifip_read32(reg_base, SPDIFIP_RX_CFG_REG_OFFSET); if (v) val |= SPDIFIP_RX_CFG_RXEN_MASK; else val &= ~SPDIFIP_RX_CFG_RXEN_MASK; spdifip_write32(val, reg_base, SPDIFIP_RX_CFG_REG_OFFSET); } static inline void spdifip_w_rx_format_cfg_reg(uint32_t reg_base, uint32_t v) { uint32_t val = 0; val = spdifip_read32(reg_base, SPDIFIP_RX_CFG_REG_OFFSET); val &= ~SPDIFIP_RX_CFG_FORMAT_MASK; val |= v<