]> git.ipfire.org Git - people/ms/u-boot.git/blob - arch/powerpc/cpu/mpc8xxx/srio.c
e46d328067df71ae3b4e100d2656f707e30fae10
[people/ms/u-boot.git] / arch / powerpc / cpu / mpc8xxx / srio.c
1 /*
2 * Copyright 2011 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 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
17 * MA 02111-1307 USA
18 */
19
20 #include <common.h>
21 #include <config.h>
22 #include <asm/fsl_law.h>
23 #include <asm/fsl_serdes.h>
24
25 #if defined(CONFIG_FSL_CORENET)
26 #define _DEVDISR_SRIO1 FSL_CORENET_DEVDISR_SRIO1
27 #define _DEVDISR_SRIO2 FSL_CORENET_DEVDISR_SRIO2
28 #define _DEVDISR_RMU FSL_CORENET_DEVDISR_RMU
29 #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR
30 #elif defined(CONFIG_MPC85xx)
31 #define _DEVDISR_SRIO1 MPC85xx_DEVDISR_SRIO
32 #define _DEVDISR_SRIO2 MPC85xx_DEVDISR_SRIO
33 #define _DEVDISR_RMU MPC85xx_DEVDISR_RMSG
34 #define CONFIG_SYS_MPC8xxx_GUTS_ADDR CONFIG_SYS_MPC85xx_GUTS_ADDR
35 #elif defined(CONFIG_MPC86xx)
36 #define _DEVDISR_SRIO1 MPC86xx_DEVDISR_SRIO
37 #define _DEVDISR_SRIO2 MPC86xx_DEVDISR_SRIO
38 #define _DEVDISR_RMU MPC86xx_DEVDISR_RMSG
39 #define CONFIG_SYS_MPC8xxx_GUTS_ADDR \
40 (&((immap_t *)CONFIG_SYS_IMMR)->im_gur)
41 #else
42 #error "No defines for DEVDISR_SRIO"
43 #endif
44
45 void srio_init(void)
46 {
47 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC8xxx_GUTS_ADDR;
48 int srio1_used = 0, srio2_used = 0;
49
50 if (is_serdes_configured(SRIO1)) {
51 set_next_law(CONFIG_SYS_SRIO1_MEM_PHYS,
52 law_size_bits(CONFIG_SYS_SRIO1_MEM_SIZE),
53 LAW_TRGT_IF_RIO_1);
54 srio1_used = 1;
55 printf("SRIO1: enabled\n");
56 } else {
57 printf("SRIO1: disabled\n");
58 }
59
60 #ifdef CONFIG_SRIO2
61 if (is_serdes_configured(SRIO2)) {
62 set_next_law(CONFIG_SYS_SRIO2_MEM_PHYS,
63 law_size_bits(CONFIG_SYS_SRIO2_MEM_SIZE),
64 LAW_TRGT_IF_RIO_2);
65 srio2_used = 1;
66 printf("SRIO2: enabled\n");
67 } else {
68 printf("SRIO2: disabled\n");
69 }
70 #endif
71
72 #ifdef CONFIG_FSL_CORENET
73 /* On FSL_CORENET devices we can disable individual ports */
74 if (!srio1_used)
75 setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO1);
76 if (!srio2_used)
77 setbits_be32(&gur->devdisr, FSL_CORENET_DEVDISR_SRIO2);
78 #endif
79
80 /* neither port is used - disable everything */
81 if (!srio1_used && !srio2_used) {
82 setbits_be32(&gur->devdisr, _DEVDISR_SRIO1);
83 setbits_be32(&gur->devdisr, _DEVDISR_SRIO2);
84 setbits_be32(&gur->devdisr, _DEVDISR_RMU);
85 }
86 }