summaryrefslogtreecommitdiffstats
path: root/arch/mips/include/asm/mach-pnx833x/pnx833x.h
blob: e6fc3a9d594a52d456b1154645491f14ca4dafee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 *  pnx833x.h: Register mappings for PNX833X.
 *
 *  Copyright 2008 NXP Semiconductors
 *	  Chris Steel <chris.steel@nxp.com>
 *    Daniel Laird <daniel.j.laird@nxp.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
#ifndef __ASM_MIPS_MACH_PNX833X_PNX833X_H
#define __ASM_MIPS_MACH_PNX833X_PNX833X_H

/* All regs are accessed in KSEG1 */
#define PNX833X_BASE		(0xa0000000ul + 0x17E00000ul)

#define PNX833X_REG(offs)	(*((volatile unsigned long *)(PNX833X_BASE + offs)))

/* Registers are named exactly as in PNX833X docs, just with PNX833X_ prefix */

/* Read access to multibit fields */
#define PNX833X_BIT(val, reg, field)	((val) & PNX833X_##reg##_##field)
#define PNX833X_REGBIT(reg, field)	PNX833X_BIT(PNX833X_##reg, reg, field)

/* Use PNX833X_FIELD to extract a field from val */
#define PNX_FIELD(cpu, val, reg, field) \
		(((val) & PNX##cpu##_##reg##_##field##_MASK) >> \
			PNX##cpu##_##reg##_##field##_SHIFT)
#define PNX833X_FIELD(val, reg, field)	PNX_FIELD(833X, val, reg, field)
#define PNX8330_FIELD(val, reg, field)	PNX_FIELD(8330, val, reg, field)
#define PNX8335_FIELD(val, reg, field)	PNX_FIELD(8335, val, reg, field)

/* Use PNX833X_REGFIELD to extract a field from a register */
#define PNX833X_REGFIELD(reg, field)	PNX833X_FIELD(PNX833X_##reg, reg, field)
#define PNX8330_REGFIELD(reg, field)	PNX8330_FIELD(PNX8330_##reg, reg, field)
#define PNX8335_REGFIELD(reg, field)	PNX8335_FIELD(PNX8335_##reg, reg, field)


#define PNX_WRITEFIELD(cpu, val, reg, field) \
	(PNX##cpu##_##reg = (PNX##cpu##_##reg & ~(PNX##cpu##_##reg##_##field##_MASK)) | \
						((val) << PNX##cpu##_##reg##_##field##_SHIFT))
#define PNX833X_WRITEFIELD(val, reg, field) \
					PNX_WRITEFIELD(833X, val, reg, field)
#define PNX8330_WRITEFIELD(val, reg, field) \
					PNX_WRITEFIELD(8330, val, reg, field)
#define PNX8335_WRITEFIELD(val, reg, field) \
					PNX_WRITEFIELD(8335, val, reg, field)


/* Macros to detect CPU type */

#define PNX833X_CONFIG_MODULE_ID		PNX833X_REG(0x7FFC)
#define PNX833X_CONFIG_MODULE_ID_MAJREV_MASK	0x0000f000
#define PNX833X_CONFIG_MODULE_ID_MAJREV_SHIFT	12
#define PNX8330_CONFIG_MODULE_MAJREV		4
#define PNX8335_CONFIG_MODULE_MAJREV		5
#define CPU_IS_PNX8330	(PNX833X_REGFIELD(CONFIG_MODULE_ID, MAJREV) == \
					PNX8330_CONFIG_MODULE_MAJREV)
#define CPU_IS_PNX8335	(PNX833X_REGFIELD(CONFIG_MODULE_ID, MAJREV) == \
					PNX8335_CONFIG_MODULE_MAJREV)



#define PNX833X_RESET_CONTROL		PNX833X_REG(0x8004)
#define PNX833X_RESET_CONTROL_2		PNX833X_REG(0x8014)

#define PNX833X_PIC_REG(offs)		PNX833X_REG(0x01000 + (offs))
#define PNX833X_PIC_INT_PRIORITY	PNX833X_PIC_REG(0x0)
#define PNX833X_PIC_INT_SRC		PNX833X_PIC_REG(0x4)
#define PNX833X_PIC_INT_SRC_INT_SRC_MASK	0x00000FF8ul	/* bits 11:3 */
#define PNX833X_PIC_INT_SRC_INT_SRC_SHIFT	3
#define PNX833X_PIC_INT_REG(irq)	PNX833X_PIC_REG(0x10 + 4*(irq))

#define PNX833X_CLOCK_CPUCP_CTL PNX833X_REG(0x9228)
#define PNX833X_CLOCK_CPUCP_CTL_EXIT_RESET	0x00000002ul	/* bit 1 */
#define PNX833X_CLOCK_CPUCP_CTL_DIV_CLOCK_MASK	0x00000018ul	/* bits 4:3 */
#define PNX833X_CLOCK_CPUCP_CTL_DIV_CLOCK_SHIFT 3

#define PNX8335_CLOCK_PLL_CPU_CTL		PNX833X_REG(0x9020)
#define PNX8335_CLOCK_PLL_CPU_CTL_FREQ_MASK	0x1f
#define PNX8335_CLOCK_PLL_CPU_CTL_FREQ_SHIFT	0

#define PNX833X_CONFIG_MUX		PNX833X_REG(0x7004)
#define PNX833X_CONFIG_MUX_IDE_MUX	0x00000080		/* bit 7 */

#define PNX8330_CONFIG_POLYFUSE_7	PNX833X_REG(0x7040)
#define PNX8330_CONFIG_POLYFUSE_7_BOOT_MODE_MASK	0x00180000
#define PNX8330_CONFIG_POLYFUSE_7_BOOT_MODE_SHIFT	19

#define PNX833X_PIO_IN		PNX833X_REG(0xF000)
#define PNX833X_PIO_OUT		PNX833X_REG(0xF004)
#define PNX833X_PIO_DIR		PNX833X_REG(0xF008)
#define PNX833X_PIO_SEL		PNX833X_REG(0xF014)
#define PNX833X_PIO_INT_EDGE	PNX833X_REG(0xF020)
#define PNX833X_PIO_INT_HI	PNX833X_REG(0xF024)
#define PNX833X_PIO_INT_LO	PNX833X_REG(0xF028)
#define PNX833X_PIO_INT_STATUS	PNX833X_REG(0xFFE0)
#define PNX833X_PIO_INT_ENABLE	PNX833X_REG(0xFFE4)
#define PNX833X_PIO_INT_CLEAR	PNX833X_REG(0xFFE8)
#define PNX833X_PIO_IN2		PNX833X_REG(0xF05C)
#define PNX833X_PIO_OUT2	PNX833X_REG(0xF060)
#define PNX833X_PIO_DIR2	PNX833X_REG(0xF064)
#define PNX833X_PIO_SEL2	PNX833X_REG(0xF068)

#define PNX833X_UART0_PORTS_START	(PNX833X_BASE + 0xB000)
#define PNX833X_UART0_PORTS_END		(PNX833X_BASE + 0xBFFF)
#define PNX833X_UART1_PORTS_START	(PNX833X_BASE + 0xC000)
#define PNX833X_UART1_PORTS_END		(PNX833X_BASE + 0xCFFF)

#define PNX833X_USB_PORTS_START		(PNX833X_BASE + 0x19000)
#define PNX833X_USB_PORTS_END		(PNX833X_BASE + 0x19FFF)

#define PNX833X_CONFIG_USB		PNX833X_REG(0x7008)

#define PNX833X_I2C0_PORTS_START	(PNX833X_BASE + 0xD000)
#define PNX833X_I2C0_PORTS_END		(PNX833X_BASE + 0xDFFF)
#define PNX833X_I2C1_PORTS_START	(PNX833X_BASE + 0xE000)
#define PNX833X_I2C1_PORTS_END		(PNX833X_BASE + 0xEFFF)

#define PNX833X_IDE_PORTS_START		(PNX833X_BASE + 0x1A000)
#define PNX833X_IDE_PORTS_END		(PNX833X_BASE + 0x1AFFF)
#define PNX833X_IDE_MODULE_ID		PNX833X_REG(0x1AFFC)

#define PNX833X_IDE_MODULE_ID_MODULE_ID_MASK	0xFFFF0000
#define PNX833X_IDE_MODULE_ID_MODULE_ID_SHIFT	16
#define PNX833X_IDE_MODULE_ID_VALUE		0xA009


#define PNX833X_MIU_SEL0			PNX833X_REG(0x2004)
#define PNX833X_MIU_SEL0_TIMING		PNX833X_REG(0x2008)
#define PNX833X_MIU_SEL1			PNX833X_REG(0x200C)
#define PNX833X_MIU_SEL1_TIMING		PNX833X_REG(0x2010)
#define PNX833X_MIU_SEL2			PNX833X_REG(0x2014)
#define PNX833X_MIU_SEL2_TIMING		PNX833X_REG(0x2018)
#define PNX833X_MIU_SEL3			PNX833X_REG(0x201C)
#define PNX833X_MIU_SEL3_TIMING		PNX833X_REG(0x2020)

#define PNX833X_MIU_SEL0_SPI_MODE_ENABLE_MASK	(1 << 14)
#define PNX833X_MIU_SEL0_SPI_MODE_ENABLE_SHIFT	14

#define PNX833X_MIU_SEL0_BURST_MODE_ENABLE_MASK (1 << 7)
#define PNX833X_MIU_SEL0_BURST_MODE_ENABLE_SHIFT	7

#define PNX833X_MIU_SEL0_BURST_PAGE_LEN_MASK	(0xF << 9)
#define PNX833X_MIU_SEL0_BURST_PAGE_LEN_SHIFT	9

#define PNX833X_MIU_CONFIG_SPI		PNX833X_REG(0x2000)

#define PNX833X_MIU_CONFIG_SPI_OPCODE_MASK	(0xFF << 3)
#define PNX833X_MIU_CONFIG_SPI_OPCODE_SHIFT	3

#define PNX833X_MIU_CONFIG_SPI_DATA_ENABLE_MASK (1 << 2)
#define PNX833X_MIU_CONFIG_SPI_DATA_ENABLE_SHIFT	2

#define PNX833X_MIU_CONFIG_SPI_ADDR_ENABLE_MASK (1 << 1)
#define PNX833X_MIU_CONFIG_SPI_ADDR_ENABLE_SHIFT	1

#define PNX833X_MIU_CONFIG_SPI_SYNC_MASK	(1 << 0)
#define PNX833X_MIU_CONFIG_SPI_SYNC_SHIFT	0

#define PNX833X_WRITE_CONFIG_SPI(opcode, data_enable, addr_enable, sync) \
   (PNX833X_MIU_CONFIG_SPI =						\
    ((opcode) << PNX833X_MIU_CONFIG_SPI_OPCODE_SHIFT) |			\
    ((data_enable) << PNX833X_MIU_CONFIG_SPI_DATA_ENABLE_SHIFT) |	\
    ((addr_enable) << PNX833X_MIU_CONFIG_SPI_ADDR_ENABLE_SHIFT) |	\
    ((sync) << PNX833X_MIU_CONFIG_SPI_SYNC_SHIFT))

#define PNX8335_IP3902_PORTS_START		(PNX833X_BASE + 0x2F000)
#define PNX8335_IP3902_PORTS_END		(PNX833X_BASE + 0x2FFFF)
#define PNX8335_IP3902_MODULE_ID		PNX833X_REG(0x2FFFC)

#define PNX8335_IP3902_MODULE_ID_MODULE_ID_MASK		0xFFFF0000
#define PNX8335_IP3902_MODULE_ID_MODULE_ID_SHIFT	16
#define PNX8335_IP3902_MODULE_ID_VALUE			0x3902

 /* I/O location(gets remapped)*/
#define PNX8335_NAND_BASE	    0x18000000
/* I/O location with CLE high */
#define PNX8335_NAND_CLE_MASK	0x00100000
/* I/O location with ALE high */
#define PNX8335_NAND_ALE_MASK	0x00010000

#define PNX8335_SATA_PORTS_START	(PNX833X_BASE + 0x2E000)
#define PNX8335_SATA_PORTS_END		(PNX833X_BASE + 0x2EFFF)
#define PNX8335_SATA_MODULE_ID		PNX833X_REG(0x2EFFC)

#define PNX8335_SATA_MODULE_ID_MODULE_ID_MASK	0xFFFF0000
#define PNX8335_SATA_MODULE_ID_MODULE_ID_SHIFT	16
#define PNX8335_SATA_MODULE_ID_VALUE		0xA099

#endif
OpenPOWER on IntegriCloud