2 * (C) Copyright 2009 Wolfgang Denk <wd@denx.de>
3 * (C) Copyright 2009 Dave Srl www.dave.eu
4 * (C) Copyright 2009 Stefan Roese <sr@denx.de>
6 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm/bitops.h>
13 #include <asm/processor.h>
14 #include <asm/mpc512x.h>
15 #include <fdt_support.h>
17 DECLARE_GLOBAL_DATA_PTR;
19 int eeprom_write_enable(unsigned dev_addr, int state)
21 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
23 if (dev_addr != CONFIG_SYS_I2C_EEPROM_ADDR)
27 setbits_be32(&im->gpio.gpdat, 0x00100000);
29 clrbits_be32(&im->gpio.gpdat, 0x00100000);
34 int board_early_init_f(void)
36 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
40 * Initialize Local Window for boot access
42 out_be32(&im->sysconf.lpbaw,
43 CSAW_START(0xffb00000) | CSAW_STOP(0xffb00000, 0x00010000));
44 sync_law(&im->sysconf.lpbaw);
47 * Configure MSCAN clocks
50 out_be32(&im->clk.msccr[i], 0x00300000);
51 out_be32(&im->clk.msccr[i], 0x00310000);
57 clrbits_be32(&im->gpio.gpodr, 0x000000e0);
58 clrbits_be32(&im->gpio.gpdir, 0x00ef0000);
59 setbits_be32(&im->gpio.gpdir, 0x001000e0);
60 setbits_be32(&im->gpio.gpdat, 0x00100000);
67 gd->ram_size = get_ram_size(0, fixed_sdram(NULL, NULL, 0));
74 volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR;
78 * Optimize access to profibus chip (VPC3) on the local bus
82 * Select 1:1 for LPC_DIV
84 val = in_be32(&im->clk.scfr[0]) & ~SCFR1_LPC_DIV_MASK;
85 out_be32(&im->clk.scfr[0], val | (0x1 << SCFR1_LPC_DIV_SHIFT));
88 * Configure LPC Chips Select Deadcycle Control Register
89 * CS0 - device can drive data 2 clock cycle(s) after CS deassertion
90 * CS1 - device can drive data 1 clock cycle(s) after CS deassertion
92 clrbits_be32(&im->lpc.cs_dccr, 0x000000ff);
93 setbits_be32(&im->lpc.cs_dccr, (0x00 << 4) | (0x01 << 0));
96 * Configure LPC Chips Select Holdcycle Control Register
97 * CS0 - data is valid 2 clock cycle(s) after CS deassertion
98 * CS1 - data is valid 1 clock cycle(s) after CS deassertion
100 clrbits_be32(&im->lpc.cs_hccr, 0x000000ff);
101 setbits_be32(&im->lpc.cs_hccr, (0x00 << 4) | (0x01 << 0));
106 static iopin_t ioregs_init[] = {
107 /* FUNC1=FEC_RX_DV Sets Next 3 to FEC pads */
109 offsetof(struct ioctrl512x, io_control_spdif_txclk), 3, 0,
110 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
111 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
113 /* FUNC1=FEC_COL Sets Next 15 to FEC pads */
115 offsetof(struct ioctrl512x, io_control_psc0_0), 15, 0,
116 IO_PIN_FMUX(1) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
117 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
119 /* FUNC1=SELECT LPC_CS1 */
121 offsetof(struct ioctrl512x, io_control_lpc_cs1), 1, 0,
122 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
123 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
125 /* FUNC3=SELECT PSC5_2 */
127 offsetof(struct ioctrl512x, io_control_psc5_2), 1, 0,
128 IO_PIN_FMUX(2) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
129 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
131 /* FUNC3=SELECT PSC5_3 */
133 offsetof(struct ioctrl512x, io_control_psc5_3), 1, 0,
134 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
135 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
137 /* FUNC3=SELECT PSC7_3 */
139 offsetof(struct ioctrl512x, io_control_psc7_3), 1, 0,
140 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
141 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
143 /* FUNC3=SELECT PSC9_0 */
145 offsetof(struct ioctrl512x, io_control_psc9_0), 3, 0,
146 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
147 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
149 /* FUNC3=SELECT PSC10_0 */
151 offsetof(struct ioctrl512x, io_control_psc10_0), 3, 0,
152 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
153 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
155 /* FUNC3=SELECT PSC10_3 */
157 offsetof(struct ioctrl512x, io_control_psc10_3), 1, 0,
158 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
159 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
161 /* FUNC3=SELECT PSC11_0 */
163 offsetof(struct ioctrl512x, io_control_psc11_0), 4, 0,
164 IO_PIN_FMUX(3) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
165 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
167 /* FUNC0=SELECT IRQ0 */
169 offsetof(struct ioctrl512x, io_control_irq0), 4, 0,
170 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_PUD(0) |
171 IO_PIN_PUE(0) | IO_PIN_ST(0) | IO_PIN_DS(3)
175 static iopin_t rev2_silicon_pci_ioregs_init[] = {
176 /* FUNC0=PCI Sets next 54 to PCI pads */
178 offsetof(struct ioctrl512x, io_control_pci_ad31), 54, 0,
179 IO_PIN_FMUX(0) | IO_PIN_HOLD(0) | IO_PIN_DS(0)
185 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
188 puts("Board: MECP_5123\n");
191 * Initialize function mux & slew rate IO inter alia on IO
194 iopin_initialize(ioregs_init, ARRAY_SIZE(ioregs_init));
196 spridr = in_be32(&im->sysconf.spridr);
197 if (SVR_MJREV(spridr) >= 2)
198 iopin_initialize(rev2_silicon_pci_ioregs_init, 1);
203 #ifdef CONFIG_OF_BOARD_SETUP
204 int ft_board_setup(void *blob, bd_t *bd)
206 ft_cpu_setup(blob, bd);
210 #endif /* CONFIG_OF_BOARD_SETUP */