]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/freescale/c29xpcie/c29xpcie.c
powerpc/c29xpcie: add support for C29XPCIE board
[karo-tx-uboot.git] / board / freescale / c29xpcie / c29xpcie.c
1 /*
2  * Copyright 2013 Freescale Semiconductor, Inc.
3  *
4  * This program is free software; you can redistribute it and/or modify it
5  * under the terms of the GNU General Public License as published by the Free
6  * Software Foundation; either version 2 of the License, or (at your option)
7  * any later version.
8  */
9
10 #include <common.h>
11 #include <asm/processor.h>
12 #include <asm/mmu.h>
13 #include <asm/cache.h>
14 #include <asm/immap_85xx.h>
15 #include <asm/io.h>
16 #include <miiphy.h>
17 #include <libfdt.h>
18 #include <fdt_support.h>
19 #include <fsl_mdio.h>
20 #include <tsec.h>
21 #include <mmc.h>
22 #include <netdev.h>
23 #include <pci.h>
24 #include <asm/fsl_ifc.h>
25 #include <asm/fsl_pci.h>
26
27 #include "cpld.h"
28
29 DECLARE_GLOBAL_DATA_PTR;
30
31 int checkboard(void)
32 {
33         struct cpu_type *cpu = gd->arch.cpu;
34         struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
35
36         printf("Board: %sPCIe, ", cpu->name);
37         printf("CPLD Ver: 0x%02x\n", in_8(&cpld_data->cpldver));
38
39         return 0;
40 }
41
42 int board_early_init_f(void)
43 {
44         struct fsl_ifc *ifc = (void *)CONFIG_SYS_IFC_ADDR;
45
46         /* Clock configuration to access CPLD using IFC(GPCM) */
47         setbits_be32(&ifc->ifc_gcr, 1 << IFC_GCR_TBCTL_TRN_TIME_SHIFT);
48
49         return 0;
50 }
51
52 int board_early_init_r(void)
53 {
54         const unsigned long flashbase = CONFIG_SYS_FLASH_BASE;
55         const u8 flash_esel = find_tlb_idx((void *)flashbase, 1);
56
57         /*
58          * Remap Boot flash region to caching-inhibited
59          * so that flash can be erased properly.
60          */
61
62         /* Flush d-cache and invalidate i-cache of any FLASH data */
63         flush_dcache();
64         invalidate_icache();
65
66         /* invalidate existing TLB entry for flash */
67         disable_tlb(flash_esel);
68
69         set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS,
70                         MAS3_SW|MAS3_SR, MAS2_I|MAS2_G,
71                         0, flash_esel, BOOKE_PAGESZ_64M, 1);
72
73         return 0;
74 }
75
76 #ifdef CONFIG_PCI
77 void pci_init_board(void)
78 {
79         fsl_pcie_init_board(0);
80 }
81 #endif /* ifdef CONFIG_PCI */
82
83 #ifdef CONFIG_TSEC_ENET
84 int board_eth_init(bd_t *bis)
85 {
86         struct fsl_pq_mdio_info mdio_info;
87         struct tsec_info_struct tsec_info[2];
88         int num = 0;
89
90 #ifdef CONFIG_TSEC1
91         SET_STD_TSEC_INFO(tsec_info[num], 1);
92         num++;
93 #endif
94 #ifdef CONFIG_TSEC2
95         SET_STD_TSEC_INFO(tsec_info[num], 2);
96         num++;
97 #endif
98         if (!num) {
99                 printf("No TSECs initialized\n");
100                 return 0;
101         }
102
103         /* Register 1G MDIO bus */
104         mdio_info.regs = (struct tsec_mii_mng *)CONFIG_SYS_MDIO_BASE_ADDR;
105         mdio_info.name = DEFAULT_MII_NAME;
106
107         fsl_pq_mdio_init(bis, &mdio_info);
108
109         tsec_eth_init(bis, tsec_info, num);
110
111         return pci_eth_init(bis);
112 }
113 #endif
114
115 #if defined(CONFIG_OF_BOARD_SETUP)
116 void fdt_del_sec(void *blob, int offset)
117 {
118         int nodeoff = 0;
119
120         while ((nodeoff = fdt_node_offset_by_compat_reg(blob, "fsl,sec-v6.0",
121                         CONFIG_SYS_CCSRBAR_PHYS + CONFIG_SYS_FSL_SEC_OFFSET
122                         + offset * 0x20000)) >= 0) {
123                 fdt_del_node(blob, nodeoff);
124                 offset++;
125         }
126 }
127
128 void ft_board_setup(void *blob, bd_t *bd)
129 {
130         phys_addr_t base;
131         phys_size_t size;
132         struct cpu_type *cpu;
133
134         cpu = gd->arch.cpu;
135
136         ft_cpu_setup(blob, bd);
137
138         base = getenv_bootm_low();
139         size = getenv_bootm_size();
140
141 #if defined(CONFIG_PCI)
142         FT_FSL_PCI_SETUP;
143 #endif
144
145         fdt_fixup_memory(blob, (u64)base, (u64)size);
146         if (cpu->soc_ver == SVR_C291)
147                 fdt_del_sec(blob, 1);
148         else if (cpu->soc_ver == SVR_C292)
149                 fdt_del_sec(blob, 2);
150 }
151 #endif