Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _PPC_BOOT_DCR_H_
0003 #define _PPC_BOOT_DCR_H_
0004 
0005 #define mfdcr(rn) \
0006     ({  \
0007         unsigned long rval; \
0008         asm volatile("mfdcr %0,%1" : "=r"(rval) : "i"(rn)); \
0009         rval; \
0010     })
0011 #define mtdcr(rn, val) \
0012     asm volatile("mtdcr %0,%1" : : "i"(rn), "r"(val))
0013 #define mfdcrx(rn) \
0014     ({  \
0015         unsigned long rval; \
0016         asm volatile("mfdcrx %0,%1" : "=r"(rval) : "r"(rn)); \
0017         rval; \
0018     })
0019 #define mtdcrx(rn, val) \
0020     ({  \
0021         asm volatile("mtdcrx %0,%1" : : "r"(rn), "r" (val)); \
0022     })
0023 
0024 /* 440GP/440GX SDRAM controller DCRs */
0025 #define DCRN_SDRAM0_CFGADDR             0x010
0026 #define DCRN_SDRAM0_CFGDATA             0x011
0027 
0028 #define SDRAM0_READ(offset) ({\
0029     mtdcr(DCRN_SDRAM0_CFGADDR, offset); \
0030     mfdcr(DCRN_SDRAM0_CFGDATA); })
0031 #define SDRAM0_WRITE(offset, data) ({\
0032     mtdcr(DCRN_SDRAM0_CFGADDR, offset); \
0033     mtdcr(DCRN_SDRAM0_CFGDATA, data); })
0034 
0035 #define     SDRAM0_B0CR             0x40
0036 #define     SDRAM0_B1CR             0x44
0037 #define     SDRAM0_B2CR             0x48
0038 #define     SDRAM0_B3CR             0x4c
0039 
0040 static const unsigned long sdram_bxcr[] = { SDRAM0_B0CR, SDRAM0_B1CR,
0041                         SDRAM0_B2CR, SDRAM0_B3CR };
0042 
0043 #define         SDRAM_CONFIG_BANK_ENABLE        0x00000001
0044 #define         SDRAM_CONFIG_SIZE_MASK          0x000e0000
0045 #define         SDRAM_CONFIG_BANK_SIZE(reg) \
0046     (0x00400000 << ((reg & SDRAM_CONFIG_SIZE_MASK) >> 17))
0047 
0048 /* 440GP External Bus Controller (EBC) */
0049 #define DCRN_EBC0_CFGADDR               0x012
0050 #define DCRN_EBC0_CFGDATA               0x013
0051 #define   EBC_NUM_BANKS                   8
0052 #define   EBC_B0CR                    0x00
0053 #define   EBC_B1CR                    0x01
0054 #define   EBC_B2CR                    0x02
0055 #define   EBC_B3CR                    0x03
0056 #define   EBC_B4CR                    0x04
0057 #define   EBC_B5CR                    0x05
0058 #define   EBC_B6CR                    0x06
0059 #define   EBC_B7CR                    0x07
0060 #define   EBC_BXCR(n)                     (n)
0061 #define     EBC_BXCR_BAS                    0xfff00000
0062 #define     EBC_BXCR_BS                     0x000e0000
0063 #define     EBC_BXCR_BANK_SIZE(reg) \
0064     (0x100000 << (((reg) & EBC_BXCR_BS) >> 17))
0065 #define     EBC_BXCR_BU                     0x00018000
0066 #define       EBC_BXCR_BU_OFF                     0x00000000
0067 #define       EBC_BXCR_BU_RO                      0x00008000
0068 #define       EBC_BXCR_BU_WO                      0x00010000
0069 #define       EBC_BXCR_BU_RW                      0x00018000
0070 #define     EBC_BXCR_BW                     0x00006000
0071 #define   EBC_B0AP                    0x10
0072 #define   EBC_B1AP                    0x11
0073 #define   EBC_B2AP                    0x12
0074 #define   EBC_B3AP                    0x13
0075 #define   EBC_B4AP                    0x14
0076 #define   EBC_B5AP                    0x15
0077 #define   EBC_B6AP                    0x16
0078 #define   EBC_B7AP                    0x17
0079 #define   EBC_BXAP(n)                     (0x10+(n))
0080 #define   EBC_BEAR                    0x20
0081 #define   EBC_BESR                    0x21
0082 #define   EBC_CFG                     0x23
0083 #define   EBC_CID                     0x24
0084 
0085 /* 440GP Clock, PM, chip control */
0086 #define DCRN_CPC0_SR                    0x0b0
0087 #define DCRN_CPC0_ER                    0x0b1
0088 #define DCRN_CPC0_FR                    0x0b2
0089 #define DCRN_CPC0_SYS0                  0x0e0
0090 #define   CPC0_SYS0_TUNE                  0xffc00000
0091 #define   CPC0_SYS0_FBDV_MASK                 0x003c0000
0092 #define   CPC0_SYS0_FWDVA_MASK                0x00038000
0093 #define   CPC0_SYS0_FWDVB_MASK                0x00007000
0094 #define   CPC0_SYS0_OPDV_MASK                 0x00000c00
0095 #define   CPC0_SYS0_EPDV_MASK                 0x00000300
0096 /* Helper macros to compute the actual clock divider values from the
0097  * encodings in the CPC0 register */
0098 #define   CPC0_SYS0_FBDV(reg) \
0099         ((((((reg) & CPC0_SYS0_FBDV_MASK) >> 18) - 1) & 0xf) + 1)
0100 #define   CPC0_SYS0_FWDVA(reg) \
0101         (8 - (((reg) & CPC0_SYS0_FWDVA_MASK) >> 15))
0102 #define   CPC0_SYS0_FWDVB(reg) \
0103         (8 - (((reg) & CPC0_SYS0_FWDVB_MASK) >> 12))
0104 #define   CPC0_SYS0_OPDV(reg) \
0105         ((((reg) & CPC0_SYS0_OPDV_MASK) >> 10) + 1)
0106 #define   CPC0_SYS0_EPDV(reg) \
0107         ((((reg) & CPC0_SYS0_EPDV_MASK) >> 8) + 1)
0108 #define   CPC0_SYS0_EXTSL                 0x00000080
0109 #define   CPC0_SYS0_RW_MASK               0x00000060
0110 #define   CPC0_SYS0_RL                    0x00000010
0111 #define   CPC0_SYS0_ZMIISL_MASK               0x0000000c
0112 #define   CPC0_SYS0_BYPASS                0x00000002
0113 #define   CPC0_SYS0_NTO1                  0x00000001
0114 #define DCRN_CPC0_SYS1                  0x0e1
0115 #define DCRN_CPC0_CUST0                 0x0e2
0116 #define DCRN_CPC0_CUST1                 0x0e3
0117 #define DCRN_CPC0_STRP0                 0x0e4
0118 #define DCRN_CPC0_STRP1                 0x0e5
0119 #define DCRN_CPC0_STRP2                 0x0e6
0120 #define DCRN_CPC0_STRP3                 0x0e7
0121 #define DCRN_CPC0_GPIO                  0x0e8
0122 #define DCRN_CPC0_PLB                   0x0e9
0123 #define DCRN_CPC0_CR1                   0x0ea
0124 #define DCRN_CPC0_CR0                   0x0eb
0125 #define   CPC0_CR0_SWE                    0x80000000
0126 #define   CPC0_CR0_CETE                   0x40000000
0127 #define   CPC0_CR0_U1FCS                  0x20000000
0128 #define   CPC0_CR0_U0DTE                  0x10000000
0129 #define   CPC0_CR0_U0DRE                  0x08000000
0130 #define   CPC0_CR0_U0DC                   0x04000000
0131 #define   CPC0_CR0_U1DTE                  0x02000000
0132 #define   CPC0_CR0_U1DRE                  0x01000000
0133 #define   CPC0_CR0_U1DC                   0x00800000
0134 #define   CPC0_CR0_U0EC                   0x00400000
0135 #define   CPC0_CR0_U1EC                   0x00200000
0136 #define   CPC0_CR0_UDIV_MASK                  0x001f0000
0137 #define   CPC0_CR0_UDIV(reg) \
0138         ((((reg) & CPC0_CR0_UDIV_MASK) >> 16) + 1)
0139 #define DCRN_CPC0_MIRQ0                 0x0ec
0140 #define DCRN_CPC0_MIRQ1                 0x0ed
0141 #define DCRN_CPC0_JTAGID                0x0ef
0142 
0143 #define DCRN_MAL0_CFG                   0x180
0144 #define MAL_RESET 0x80000000
0145 
0146 /* 440EP Clock/Power-on Reset regs */
0147 #define DCRN_CPR0_ADDR  0xc
0148 #define DCRN_CPR0_DATA  0xd
0149 #define CPR0_PLLD0  0x60
0150 #define CPR0_OPBD0  0xc0
0151 #define CPR0_PERD0  0xe0
0152 #define CPR0_PRIMBD0    0xa0
0153 #define CPR0_SCPID  0x120
0154 #define CPR0_PLLC0  0x40
0155 
0156 /* 405GP Clocking/Power Management/Chip Control regs */
0157 #define DCRN_CPC0_PLLMR 0xb0
0158 #define DCRN_405_CPC0_CR0 0xb1
0159 #define DCRN_405_CPC0_CR1 0xb2
0160 #define DCRN_405_CPC0_PSR 0xb4
0161 
0162 /* 405EP Clocking/Power Management/Chip Control regs */
0163 #define DCRN_CPC0_PLLMR0  0xf0
0164 #define DCRN_CPC0_PLLMR1  0xf4
0165 #define DCRN_CPC0_UCR     0xf5
0166 
0167 /* 440GX/405EX Clock Control reg */
0168 #define DCRN_CPR0_CLKUPD                0x020
0169 #define DCRN_CPR0_PLLC                  0x040
0170 #define DCRN_CPR0_PLLD                  0x060
0171 #define DCRN_CPR0_PRIMAD                0x080
0172 #define DCRN_CPR0_PRIMBD                0x0a0
0173 #define DCRN_CPR0_OPBD                  0x0c0
0174 #define DCRN_CPR0_PERD                  0x0e0
0175 #define DCRN_CPR0_MALD                  0x100
0176 
0177 #define DCRN_SDR0_CONFIG_ADDR   0xe
0178 #define DCRN_SDR0_CONFIG_DATA   0xf
0179 
0180 /* SDR read/write helper macros */
0181 #define SDR0_READ(offset) ({\
0182     mtdcr(DCRN_SDR0_CONFIG_ADDR, offset); \
0183     mfdcr(DCRN_SDR0_CONFIG_DATA); })
0184 #define SDR0_WRITE(offset, data) ({\
0185     mtdcr(DCRN_SDR0_CONFIG_ADDR, offset); \
0186     mtdcr(DCRN_SDR0_CONFIG_DATA, data); })
0187 
0188 #define DCRN_SDR0_UART0     0x0120
0189 #define DCRN_SDR0_UART1     0x0121
0190 #define DCRN_SDR0_UART2     0x0122
0191 #define DCRN_SDR0_UART3     0x0123
0192 
0193 
0194 /* CPRs read/write helper macros - based off include/asm-ppc/ibm44x.h */
0195 
0196 #define DCRN_CPR0_CFGADDR               0xc
0197 #define DCRN_CPR0_CFGDATA               0xd
0198 
0199 #define CPR0_READ(offset) ({\
0200     mtdcr(DCRN_CPR0_CFGADDR, offset); \
0201     mfdcr(DCRN_CPR0_CFGDATA); })
0202 #define CPR0_WRITE(offset, data) ({\
0203     mtdcr(DCRN_CPR0_CFGADDR, offset); \
0204     mtdcr(DCRN_CPR0_CFGDATA, data); })
0205 
0206 
0207 
0208 #endif  /* _PPC_BOOT_DCR_H_ */