]> git.sur5r.net Git - u-boot/blob - arch/powerpc/cpu/mpc85xx/c29x_serdes.c
powerpc/85xx: Add C29x SoC support
[u-boot] / arch / powerpc / cpu / mpc85xx / c29x_serdes.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 <config.h>
11 #include <common.h>
12 #include <asm/io.h>
13 #include <asm/immap_85xx.h>
14 #include <asm/fsl_serdes.h>
15
16 #define SRDS1_MAX_LANES         4
17
18 static u32 serdes1_prtcl_map;
19
20 struct serdes_config {
21         u32 protocol;
22         u8 lanes[SRDS1_MAX_LANES];
23 };
24
25 static const struct serdes_config serdes1_cfg_tbl[] = {
26         /* SerDes 1 */
27         {1, {PCIE1, PCIE1, PCIE1, PCIE1} },
28         {2, {PCIE1, PCIE1, PCIE1, PCIE1} },
29         {3, {PCIE1, PCIE1, NONE, NONE} },
30         {4, {PCIE1, PCIE1, NONE, NONE} },
31         {5, {PCIE1, NONE, NONE, NONE} },
32         {6, {PCIE1, NONE, NONE, NONE} },
33         {}
34 };
35
36 int is_serdes_configured(enum srds_prtcl device)
37 {
38         return (1 << device) & serdes1_prtcl_map;
39 }
40
41 void fsl_serdes_init(void)
42 {
43         ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
44         u32 pordevsr = in_be32(&gur->pordevsr);
45         u32 srds_cfg = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >>
46                                 MPC85xx_PORDEVSR_IO_SEL_SHIFT;
47         const struct serdes_config *ptr;
48         int lane;
49
50         debug("PORDEVSR[IO_SEL_SRDS] = %x\n", srds_cfg);
51
52         if (srds_cfg > ARRAY_SIZE(serdes1_cfg_tbl)) {
53                 printf("Invalid PORDEVSR[IO_SEL_SRDS] = %d\n", srds_cfg);
54                 return;
55         }
56
57         ptr = &serdes1_cfg_tbl[srds_cfg];
58         if (!ptr->protocol)
59                 return;
60
61         for (lane = 0; lane < SRDS1_MAX_LANES; lane++) {
62                 enum srds_prtcl lane_prtcl = ptr->lanes[lane];
63                 serdes1_prtcl_map |= (1 << lane_prtcl);
64         }
65 }