1 #ifndef _PSCLOC_H
2 #define _PSCLOC_H
3 /*************************************************************************************
4 * FILE PURPOSE: Local Power Saver Controller definitions
5 *************************************************************************************
6 * FILE NAME: pscloc.h
7 *
8 * DESCRIPTION: Provides local definitions for the power saver controller
9 *
10 *************************************************************************************/
13 #define BOOTBITMASK(x,y) ( ( ( ((uint32)1 << (((uint32)x)-((uint32)y)+(uint32)1) ) - (uint32)1 ) ) << ((uint32)y) )
14 #define BOOT_READ_BITFIELD(z,x,y) (((uint32)z) & BOOTBITMASK(x,y)) >> (y)
15 #define BOOT_SET_BITFIELD(z,f,x,y) (((uint32)z) & ~BOOTBITMASK(x,y)) | ( (((uint32)f) << (y)) & BOOTBITMASK(x,y) )
17 /* Register offsets */
18 #define PSC_REG_PTCMD 0x120
19 #define PSC_REG_PSTAT 0x128
20 #define PSC_REG_PDSTAT(x) (0x200 + (4*(x)))
21 #define PSC_REG_PDCTL(x) (0x300 + (4*(x)))
22 #define PSC_REG_MDCFG(x) (0x600 + (4*(x)))
23 #define PSC_REG_MDSTAT(x) (0x800 + (4*(x)))
24 #define PSC_REG_MDCTL(x) (0xa00 + (4*(x)))
27 /* Macros to access register fields */
28 /* PDCTL */
29 #define PSC_REG_PDCTL_SET_NEXT(x,y) BOOT_SET_BITFIELD((x),(y),0,0)
30 #define PSC_REG_PDCTL_SET_PDMODE(x,y) BOOT_SET_BITFIELD((x),(y),15,12)
32 /* PDSTAT */
33 #define PSC_REG_PDSTAT_GET_STATE(x) BOOT_READ_BITFIELD((x),4,0))
35 /* MDCFG */
36 #define PSC_REG_MDCFG_GET_PD(x) BOOT_READ_BITFIELD((x),20,16)
37 #define PSC_REG_MDCFG_GET_RESET_ISO(x) BOOT_READ_BITFIELD((x),14,14)
39 /* MDCTL */
40 #define PSC_REG_MDCTL_SET_NEXT(x,y) BOOT_SET_BITFIELD((x),(y),4,0)
41 #define PSC_REG_MDCTL_SET_LRSTZ(x,y) BOOT_SET_BITFIELD((x),(y),8,8)
42 #define PSC_REG_MDCTL_GET_LRSTZ(x) BOOT_READ_BITFIELD((x),8,8)
43 #define PSC_REG_MDCTL_SET_RESET_ISO(x,y) BOOT_SET_BITFIELD((x),(y),12,12)
46 /* MDSTAT */
47 #define PSC_REG_MDSTAT_GET_STATUS(x) BOOT_READ_BITFIELD((x),5,0)
48 #define PSC_REG_MDSTAT_GET_LRSTZ(x) BOOT_READ_BITFIELD((x),8,8)
49 #define PSC_REG_MDSTAT_GET_LRSTDONE(x) BOOT_READ_BITFIELD((x),9,9)
51 /* PDCTL states */
52 #define PSC_REG_VAL_PDCTL_NEXT_ON 1
53 #define PSC_REG_VAL_PDCTL_NEXT_OFF 0
55 #define PSC_REG_VAL_PDCTL_PDMODE_SLEEP 0
57 /* MDCTL states */
58 #define PSC_REG_VAL_MDCTL_NEXT_SWRSTDISABLE 0
59 #define PSC_REG_VAL_MDCTL_NEXT_OFF 2
60 #define PSC_REG_VAL_MDCTL_NEXT_ON 3 /* Yes, 3 is the on state command */
63 /* MDSTAT states */
64 #define PSC_REG_VAL_MDSTAT_STATE_ON 3
65 #define PSC_REG_VAL_MDSTAT_STATE_ENABLE_IN_PROG 0x24
66 #define PSC_REG_VAL_MDSTAT_STATE_OFF 2
67 #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG1 0x20
68 #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG2 0x21
69 #define PSC_REG_VAL_MDSTAT_STATE_DISABLE_IN_PROG3 0x22
72 /* Timeout limit on checking PTSTAT. This is the number of times the
73 * wait function will be called before giving up. */
74 #define PSC_PTSTAT_TIMEOUT_LIMIT 100
80 #endif /* _PSCLOC_H */