#ifndef BREWMPU_H
#define BREWMPU_H
/*===========================================================================

     B R E W   M P U   C O N F I G U R A T I O N   H E A D E R   F I L E

DESCRIPTION
  BREW MPU configuration for MSM-6050/6200

  Copyright (c) 2003 by QUALCOMM Incorporated. All Rights Reserved.
===========================================================================*/
#include "comdef.h"
#include "target.h"
#include "customer.h"

//----------------------------------------------------------------------
//   MPU Region sizes
//----------------------------------------------------------------------
#define MPU_REGION_1K                                  0
#define MPU_REGION_2K                                  1
#define MPU_REGION_4K                                  2
#define MPU_REGION_8K                                  3
#define MPU_REGION_16K                                 4
#define MPU_REGION_32K                                 5
#define MPU_REGION_64K                                 6
#define MPU_REGION_128K                                7
#define MPU_REGION_256K                                8
#define MPU_REGION_512K                                9
#define MPU_REGION_1M                                 10
#define MPU_REGION_2M                                 11
#define MPU_REGION_4M                                 12
#define MPU_REGION_8M                                 13
#define MPU_REGION_16M                                14
#define MPU_REGION_32M                                15
#define MPU_REGION_64M                                16
#define MPU_REGION_128M                               17
#define MPU_REGION_256M                               18
#define MPU_REGION_512M                               19

//----------------------------------------------------------------------
//   MPU permissions
//----------------------------------------------------------------------
#define MPU_PERM_SVC_RW_USER_NA                        1
#define MPU_PERM_SVC_RW_USER_RO                        2
#define MPU_PERM_SVC_RW_USER_RW                        3

//----------------------------------------------------------------------
//   MPU Regions. The MSM 6050/6200 MPU architecture
//   allows a max. of 16 regions.
//----------------------------------------------------------------------
#define MPU_REGION_0                                   0
#define MPU_REGION_1                                   1
#define MPU_REGION_2                                   2
#define MPU_REGION_3                                   3
#define MPU_REGION_4                                   4
#define MPU_REGION_5                                   5
#define MPU_REGION_6                                   6
#define MPU_REGION_7                                   7
#define MPU_REGION_8                                   8
#define MPU_REGION_9                                   9
#define MPU_REGION_10                                 10
#define MPU_REGION_11                                 11
#define MPU_REGION_12                                 12
#define MPU_REGION_13                                 13
#define MPU_REGION_14                                 14
#define MPU_REGION_15                                 15
#define MPU_REGION_MAX                                16

//----------------------------------------------------------------------
//   MPU Registers
//----------------------------------------------------------------------
#define MPU_REGION_CONFIG_REG                 0x0a000180
#define MPU_CONFIG_REG                        0x0a000184
#define MPU_ABORT_STATUS_REG                  0x0a0001a0
#define MPU_ABORT_ADDRESS_REG                 0x0a0001a4

//----------------------------------------------------------------------
//   Shifts and masks to get/set parameters in the MPU registers
//----------------------------------------------------------------------
#define MPU_REGION_CONFIG_MASK                0xffffffff

#define MPU_REGION_START_MASK                 0xfffff000
#define MPU_REGION_START_SHFT                       0x02 

#define MPU_REGION_SIZE_MASK                      0x0f80
#define MPU_REGION_SIZE_SHFT                        0x07

#define MPU_REGION_PERM_MASK                        0x60
#define MPU_REGION_PERM_SHFT                        0x05

#define MPU_REGION_EN_MASK                          0x10
#define MPU_REGION_EN_SHFT                          0x04

#define MPU_REGION_NO_MASK                          0x0f
#define MPU_REGION_NO_SHFT                             0

#define MPU_CONFIG_MASK                              0x1

#define MPU_ENABLE                                  0x01
#define MPU_DISABLE                                    0

#define MPU_ENABLE_REGION                           0x01
#define MPU_DISABLE_REGION                             0

#define MPU_ABORT_STATUS_MASK                       0x3f

#define MPU_ABORT_TYPE_MASK                         0x03

#define MPU_ABORT_REGION_MASK                       0x3c
#define MPU_ABORT_REGION_SHFT                       0x02


typedef struct mpu_config_tag
{ 
   uint32  region_start;    /* MPU region start address */
   uint16  region_size;     /* MPU region size */
   uint8   region_perm;     /* MPU Region permission */
   uint8   region_enable;   /* MPU region enable/disable */
   uint8   region_number;   /* MPU region number (0-15) */
   uint8   reserved1;
   uint16  reserved2;
} mpu_config; 

#endif //BREWMPU_H
