1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup QorIQ |
---|
5 | * |
---|
6 | * @brief Network configuration. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2010-2015 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Dornierstr. 4 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.org/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #define __INSIDE_RTEMS_BSD_TCPIP_STACK__ 1 |
---|
24 | #define __BSD_VISIBLE 1 |
---|
25 | |
---|
26 | #include <assert.h> |
---|
27 | #include <string.h> |
---|
28 | |
---|
29 | #include <rtems/rtems_bsdnet.h> |
---|
30 | #include <rtems/rtems_bsdnet_internal.h> |
---|
31 | |
---|
32 | #include <libcpu/powerpc-utility.h> |
---|
33 | |
---|
34 | #include <bsp.h> |
---|
35 | #include <bsp/tsec.h> |
---|
36 | #include <bsp/qoriq.h> |
---|
37 | |
---|
38 | #if QORIQ_CHIP_VARIANT == QORIQ_CHIP_P1020 |
---|
39 | |
---|
40 | int BSP_tsec_attach( |
---|
41 | struct rtems_bsdnet_ifconfig *config, |
---|
42 | int attaching |
---|
43 | ) |
---|
44 | { |
---|
45 | char *unit_name = NULL; |
---|
46 | int unit_number = rtems_bsdnet_parse_driver_name(config, &unit_name); |
---|
47 | tsec_config tsec_cfg; |
---|
48 | bool has_groups = false; |
---|
49 | |
---|
50 | memset(&tsec_cfg, 0, sizeof(tsec_cfg)); |
---|
51 | config->drv_ctrl = &tsec_cfg; |
---|
52 | |
---|
53 | if (unit_number <= 0 || unit_number > TSEC_COUNT) { |
---|
54 | return 0; |
---|
55 | } |
---|
56 | |
---|
57 | switch (ppc_fsl_system_version_sid(ppc_fsl_system_version())) { |
---|
58 | /* P1010 and P1020 */ |
---|
59 | case 0x0ec: |
---|
60 | case 0x0e4: |
---|
61 | case 0x0ed: |
---|
62 | case 0x0e5: |
---|
63 | has_groups = true; |
---|
64 | break; |
---|
65 | } |
---|
66 | |
---|
67 | if (config->hardware_address == NULL) { |
---|
68 | #ifdef HAS_UBOOT |
---|
69 | switch (unit_number) { |
---|
70 | case 1: |
---|
71 | config->hardware_address = bsp_uboot_board_info.bi_enetaddr; |
---|
72 | break; |
---|
73 | case 2: |
---|
74 | config->hardware_address = bsp_uboot_board_info.bi_enet1addr; |
---|
75 | break; |
---|
76 | case 3: |
---|
77 | config->hardware_address = bsp_uboot_board_info.bi_enet2addr; |
---|
78 | break; |
---|
79 | default: |
---|
80 | assert(0); |
---|
81 | break; |
---|
82 | } |
---|
83 | #else |
---|
84 | assert(0); |
---|
85 | #endif |
---|
86 | } |
---|
87 | |
---|
88 | switch (unit_number) { |
---|
89 | case 1: |
---|
90 | if (has_groups) { |
---|
91 | tsec_cfg.reg_ptr = &qoriq.tsec_1_group_0; |
---|
92 | } else { |
---|
93 | tsec_cfg.reg_ptr = &qoriq.tsec_1; |
---|
94 | } |
---|
95 | tsec_cfg.mdio_ptr = &qoriq.tsec_1; |
---|
96 | tsec_cfg.irq_num_tx = QORIQ_IRQ_ETSEC_TX_1; |
---|
97 | tsec_cfg.irq_num_rx = QORIQ_IRQ_ETSEC_RX_1; |
---|
98 | tsec_cfg.irq_num_err = QORIQ_IRQ_ETSEC_ER_1; |
---|
99 | tsec_cfg.phy_default = QORIQ_ETSEC_1_PHY_ADDR; |
---|
100 | break; |
---|
101 | case 2: |
---|
102 | if (has_groups) { |
---|
103 | tsec_cfg.reg_ptr = &qoriq.tsec_2_group_0; |
---|
104 | } else { |
---|
105 | tsec_cfg.reg_ptr = &qoriq.tsec_2; |
---|
106 | } |
---|
107 | tsec_cfg.mdio_ptr = &qoriq.tsec_1; |
---|
108 | tsec_cfg.irq_num_tx = QORIQ_IRQ_ETSEC_TX_2; |
---|
109 | tsec_cfg.irq_num_rx = QORIQ_IRQ_ETSEC_RX_2; |
---|
110 | tsec_cfg.irq_num_err = QORIQ_IRQ_ETSEC_ER_2; |
---|
111 | tsec_cfg.phy_default = QORIQ_ETSEC_2_PHY_ADDR; |
---|
112 | break; |
---|
113 | case 3: |
---|
114 | if (has_groups) { |
---|
115 | tsec_cfg.reg_ptr = &qoriq.tsec_3_group_0; |
---|
116 | } else { |
---|
117 | tsec_cfg.reg_ptr = &qoriq.tsec_3; |
---|
118 | } |
---|
119 | tsec_cfg.mdio_ptr = &qoriq.tsec_1; |
---|
120 | tsec_cfg.irq_num_tx = QORIQ_IRQ_ETSEC_TX_3; |
---|
121 | tsec_cfg.irq_num_rx = QORIQ_IRQ_ETSEC_RX_3; |
---|
122 | tsec_cfg.irq_num_err = QORIQ_IRQ_ETSEC_ER_3; |
---|
123 | tsec_cfg.phy_default = QORIQ_ETSEC_3_PHY_ADDR; |
---|
124 | break; |
---|
125 | default: |
---|
126 | assert(0); |
---|
127 | break; |
---|
128 | } |
---|
129 | |
---|
130 | tsec_cfg.unit_number = unit_number; |
---|
131 | tsec_cfg.unit_name = unit_name; |
---|
132 | |
---|
133 | return tsec_driver_attach_detach(config, attaching); |
---|
134 | } |
---|
135 | |
---|
136 | #endif /* QORIQ_CHIP_VARIANT */ |
---|