]> git.sur5r.net Git - u-boot/blob - board/freescale/p1022ds/p1022ds.c
ppc/85xx: Convert MPC8572DS to using board common ICS307 code
[u-boot] / board / freescale / p1022ds / p1022ds.c
1 /*
2  * Copyright 2010 Freescale Semiconductor, Inc.
3  * Authors: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
4  *          Timur Tabi <timur@freescale.com>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; either version 2 of the License, or (at your option)
9  * any later version.
10  */
11
12 #include <common.h>
13 #include <command.h>
14 #include <pci.h>
15 #include <asm/processor.h>
16 #include <asm/mmu.h>
17 #include <asm/cache.h>
18 #include <asm/immap_85xx.h>
19 #include <asm/fsl_pci.h>
20 #include <asm/fsl_ddr_sdram.h>
21 #include <asm/fsl_serdes.h>
22 #include <asm/io.h>
23 #include <libfdt.h>
24 #include <fdt_support.h>
25 #include <tsec.h>
26 #include <asm/fsl_law.h>
27 #include <asm/mp.h>
28 #include <netdev.h>
29 #include <i2c.h>
30
31 #include "../common/ngpixis.h"
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 int board_early_init_f(void)
36 {
37         ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
38
39         /* Set pmuxcr to allow both i2c1 and i2c2 */
40         setbits_be32(&gur->pmuxcr, 0x1000);
41
42         /* Read back the register to synchronize the write. */
43         in_be32(&gur->pmuxcr);
44
45         /* Set the pin muxing to enable ETSEC2. */
46         clrbits_be32(&gur->pmuxcr2, 0x001F8000);
47
48         return 0;
49 }
50
51 int checkboard(void)
52 {
53         u8 sw;
54
55         puts("Board: P1022DS ");
56
57         printf("Sys ID: 0x%02x, Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ",
58                 in_8(&pixis->id), in_8(&pixis->arch), in_8(&pixis->scver));
59
60         sw = in_8(&PIXIS_SW(PIXIS_LBMAP_SWITCH));
61
62         switch ((sw & PIXIS_LBMAP_MASK) >> 6) {
63         case 0:
64                 printf ("vBank: %u\n", ((sw & 0x30) >> 4));
65                 break;
66         case 1:
67                 printf ("NAND\n");
68                 break;
69         case 2:
70         case 3:
71                 puts ("Promjet\n");
72                 break;
73         }
74
75         return 0;
76 }
77
78 phys_size_t initdram(int board_type)
79 {
80         phys_size_t dram_size = 0;
81
82         puts("Initializing....\n");
83
84         dram_size = fsl_ddr_sdram();
85         dram_size = setup_ddr_tlbs(dram_size / 0x100000) * 0x100000;
86
87         puts("    DDR: ");
88         return dram_size;
89 }
90
91 #define CONFIG_TFP410_I2C_ADDR  0x38
92
93 int misc_init_r(void)
94 {
95         u8 temp;
96
97         /*  Enable the TFP410 Encoder */
98
99         temp = 0xBF;
100         if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
101                 return -1;
102
103         /* Verify if enabled */
104         temp = 0;
105         if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x08, 1, &temp, sizeof(temp)) < 0)
106                 return -1;
107
108         debug("DVI Encoder Read: 0x%02x\n", temp);
109
110         temp = 0x10;
111         if (i2c_write(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
112                 return -1;
113
114         /* Verify if enabled */
115         temp = 0;
116         if (i2c_read(CONFIG_TFP410_I2C_ADDR, 0x0A, 1, &temp, sizeof(temp)) < 0)
117                 return -1;
118
119         debug("DVI Encoder Read: 0x%02x\n",temp);
120
121         return 0;
122 }
123
124 static void configure_pcie(struct fsl_pci_info *info,
125                            struct pci_controller *hose,
126                            const char *connected)
127 {
128         static int bus_number = 0;
129         int is_endpoint;
130
131         set_next_law(info->mem_phys, law_size_bits(info->mem_size), info->law);
132         set_next_law(info->io_phys, law_size_bits(info->io_size), info->law);
133         is_endpoint = fsl_setup_hose(hose, info->regs);
134         printf("    PCIE%u connected to %s as %s (base addr %lx)\n",
135                info->pci_num, connected,
136                is_endpoint ? "Endpoint" : "Root Complex", info->regs);
137         bus_number = fsl_pci_init_port(info, hose, bus_number);
138 }
139
140 #ifdef CONFIG_PCIE1
141 static struct pci_controller pcie1_hose;
142 #endif
143
144 #ifdef CONFIG_PCIE2
145 static struct pci_controller pcie2_hose;
146 #endif
147
148 #ifdef CONFIG_PCIE3
149 static struct pci_controller pcie3_hose;
150 #endif
151
152 #ifdef CONFIG_PCI
153 void pci_init_board(void)
154 {
155         ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
156         struct fsl_pci_info pci_info;
157         u32 devdisr = in_be32(&gur->devdisr);
158
159 #ifdef CONFIG_PCIE1
160         if (is_serdes_configured(PCIE1) && !(devdisr & MPC85xx_DEVDISR_PCIE)) {
161                 SET_STD_PCIE_INFO(pci_info, 1);
162                 configure_pcie(&pci_info, &pcie1_hose, serdes_slot_name(PCIE1));
163         } else {
164                 printf("    PCIE1: disabled\n");
165         }
166 #else
167         setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */
168 #endif
169
170 #ifdef CONFIG_PCIE2
171         if (is_serdes_configured(PCIE2) && !(devdisr & MPC85xx_DEVDISR_PCIE2)) {
172                 SET_STD_PCIE_INFO(pci_info, 2);
173                 configure_pcie(&pci_info, &pcie2_hose, serdes_slot_name(PCIE2));
174         } else {
175                 printf("    PCIE2: disabled\n");
176         }
177 #else
178         setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */
179 #endif
180
181 #ifdef CONFIG_PCIE3
182         if (is_serdes_configured(PCIE3) && !(devdisr & MPC85xx_DEVDISR_PCIE3)) {
183                 SET_STD_PCIE_INFO(pci_info, 3);
184                 configure_pcie(&pci_info, &pcie3_hose, serdes_slot_name(PCIE3));
185         } else {
186                 printf("    PCIE3: disabled\n");
187         }
188 #else
189         setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */
190 #endif
191 }
192 #endif
193
194 int board_early_init_r(void)
195 {
196         const unsigned int flashbase = CONFIG_SYS_FLASH_BASE;
197         const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
198
199         /*
200          * Remap Boot flash + PROMJET region to caching-inhibited
201          * so that flash can be erased properly.
202          */
203
204         /* Flush d-cache and invalidate i-cache of any FLASH data */
205         flush_dcache();
206         invalidate_icache();
207
208         /* invalidate existing TLB entry for flash + promjet */
209         disable_tlb(flash_esel);
210
211         set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
212                         MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
213                         0, flash_esel, BOOKE_PAGESZ_256M, 1);
214
215         return 0;
216 }
217
218 /*
219  * Initialize on-board and/or PCI Ethernet devices
220  *
221  * Returns:
222  *      <0, error
223  *       0, no ethernet devices found
224  *      >0, number of ethernet devices initialized
225  */
226 int board_eth_init(bd_t *bis)
227 {
228         struct tsec_info_struct tsec_info[2];
229         unsigned int num = 0;
230
231 #ifdef CONFIG_TSEC1
232         SET_STD_TSEC_INFO(tsec_info[num], 1);
233         num++;
234 #endif
235 #ifdef CONFIG_TSEC2
236         SET_STD_TSEC_INFO(tsec_info[num], 2);
237         num++;
238 #endif
239
240         return tsec_eth_init(bis, tsec_info, num) + pci_eth_init(bis);
241 }
242
243 #ifdef CONFIG_OF_BOARD_SETUP
244 void ft_board_setup(void *blob, bd_t *bd)
245 {
246         phys_addr_t base;
247         phys_size_t size;
248
249         ft_cpu_setup(blob, bd);
250
251         base = getenv_bootm_low();
252         size = getenv_bootm_size();
253
254         fdt_fixup_memory(blob, (u64)base, (u64)size);
255
256 #ifdef CONFIG_PCIE1
257         ft_fsl_pci_setup(blob, "pci0", &pcie1_hose);
258 #else
259         ft_fsl_pci_setup(blob, "pci0", NULL);
260 #endif
261
262 #ifdef CONFIG_PCIE2
263         ft_fsl_pci_setup(blob, "pci1", &pcie2_hose);
264 #else
265         ft_fsl_pci_setup(blob, "pci1", NULL);
266 #endif
267
268 #ifdef CONFIG_PCIE3
269         ft_fsl_pci_setup(blob, "pci2", &pcie3_hose);
270 #else
271         ft_fsl_pci_setup(blob, "pci2", NULL);
272 #endif
273
274 #ifdef CONFIG_FSL_SGMII_RISER
275         fsl_sgmii_riser_fdt_fixup(blob);
276 #endif
277 }
278 #endif
279
280 #ifdef CONFIG_MP
281 void board_lmb_reserve(struct lmb *lmb)
282 {
283         cpu_mp_lmb_reserve(lmb);
284 }
285 #endif