/*-----------------------------------------------------------------------------------
!
!                              COPYRIGHT 2015 BY
!                            MegaChips Corporation
!
!------------------------------------------------------------------------------------
! These coded instructions, statements, and computer programs include
! intellectual property and know-how belonging to MegaChips
! Corporaiton ("MCC") and its partner companies.
! Therefore, do not use these specifications for any purpose other than
! the purpose
! expressly agreed to by MCCs customer and MCC.  Also, do not duplicate,
! copy,
! or reproduce these specifications, nor reveal these specifications to
! any third party
! without MCCs prior written consent.
!
*/
/*-----------------------------------------------------------------------------------
  FILE        : otp_reg.h
  DESCRIPTION : OTP Register
  Revision    : $Rev: 4 $
  Author      : $Author
  Date        : $Date: 2015-09-09 15:19:58 +0900 (水, 09 9 2015) $
-----------------------------------------------------------------------------------*/
#ifndef ___OTP_REG_H_INCLUDED___
#define ___OTP_REG_H_INCLUDED___

#include <stdint.h>

#define OTP_REG_BASE (0x40002000u)

typedef union {
	uint64_t u64;
	struct {
		uint64_t version       : 62;
		uint64_t type          :  2;
	}bit;	
}MTP;

typedef struct _tagOtpReg {
	uint32_t otp_en;
	uint32_t otp_mask;
	uint32_t otp_mode;
	uint32_t otp_status;
	MTP rdata;
	MTP wdata;
} OtpReg;

#define OTPR (*(volatile OtpReg*)(OTP_REG_BASE))


#define OTPR_START       (0x00000001u)
#define OTPR_KILL        (0x00000001u)
#define OTPR_IDLE        (0x00000000u)
#define OTPR_MODE_READ   (0x00000000u)
#define OTPR_MODE_WRITE  (0x00000001u)

#define MTP_VERSION_MASK  (0x3FFFFFFFFFFFFFFFul)
#define DEV_FLAG_MASK     (0x4000000000000000ul)
#define REWIND_FLAG_MASK  (0x8000000000000000ul)

#define REWIND_BLOCK_FLGA_ON (0x02u)

#endif // ___BOL_REG_H_INCLUDED___
