/**
 * @file  gpio-mst.c
 * @brief set tzpc (mst)
 *
 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
 *
 * This software is proprietary of Samsung Electronics.
 * No part of this software, either material or conceptual may be copied
 * or distributed, transmitted, transcribed, stored in a retrieval system
 * or translated into any human or computer language in any form by any means,
 * electronic, mechanical, manual or otherwise, or disclosed to third parties
 * without the express written permission of Samsung Electronics.
 */

#include <stdbool.h>
#include <stdint.h>
#include "handler.h"
#include "kernel_api.h"

#include "gpio-mst.h"

#if defined(CONFIG_MST_TZ_CONTROL)
uint32_t set_tzpc_mst_secure(uint32_t pin_conf)
{
	uint32_t ret = 0;
	uint32_t is_secure;
	uint32_t target_port;

	printf("[set_tzpc_mst_secure] pin_conf : %d\n", pin_conf);

	target_port = (~(GPIO_MST_DATA | GPIO_MST_EN));

	//write_sfr_value((uint32_t)tzpc_peric_va + MST_OFFSET, read_sfr_value((uint32_t)tzpc_peric_va + MST_OFFSET) & target_port);
	WRITE_SFR((uint32_t)TZPC_PERIC_BASE, MST_OFFSET, READ_SFR((uint32_t)TZPC_PERIC_BASE, MST_OFFSET) & target_port);

	is_secure = READ_SFR((uint32_t)TZPC_PERIC_BASE, MST_OFFSET) & ~target_port;

	if (is_secure != TZPC_SECURE) {
		ret = -1;
	}

	return ret;
}
#endif
