source: rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c @ 677cf05f

4.104.114.95
Last change on this file since 677cf05f was 677cf05f, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/17/08 at 14:39:17

bugfixes for mpc8349eamds BSP

  • Property mode set to 100644
File size: 5.1 KB
Line 
1/*===============================================================*\
2| Project: RTEMS support for MPC83xx                              |
3+-----------------------------------------------------------------+
4|                    Copyright (c) 2007                           |
5|                    Embedded Brains GmbH                         |
6|                    Obere Lagerstr. 30                           |
7|                    D-82178 Puchheim                             |
8|                    Germany                                      |
9|                    rtems@embedded-brains.de                     |
10+-----------------------------------------------------------------+
11| The license and distribution terms for this file may be         |
12| found in the file LICENSE in this distribution or at            |
13|                                                                 |
14| http://www.rtems.com/license/LICENSE.                           |
15|                                                                 |
16+-----------------------------------------------------------------+
17| this file contains the board specific portion                   |
18| of the network interface driver                                 |
19\*===============================================================*/
20
21#include <rtems.h>
22#include <rtems/rtems_bsdnet.h>
23#include <rtems/rtems_bsdnet_internal.h>
24#include <bsp.h>
25#include <mpc83xx/tsec.h>
26#include <mpc83xx/mpc83xx.h>
27#include <stdio.h>
28
29#define TSEC_IFMODE_RGMII 0
30#define TSEC_IFMODE_GMII  1
31
32#if defined( MPC8313ERDB)
33
34#define TSEC_IFMODE TSEC_IFMODE_RGMII
35
36#elif defined( MPC8349EAMDS)
37
38#define TSEC_IFMODE TSEC_IFMODE_GMII
39
40#elif defined( HSC_CM01)
41
42#define TSEC_IFMODE TSEC_IFMODE_RGMII
43
44#else
45
46#warning No TSEC configuration available
47
48#endif
49
50/*=========================================================================*\
51| Function:                                                                 |
52\*-------------------------------------------------------------------------*/
53int BSP_tsec_attach
54(
55/*-------------------------------------------------------------------------*\
56| Purpose:                                                                  |
57|   attach or detach the driver                                             |
58+---------------------------------------------------------------------------+
59| Input Parameters:                                                         |
60\*-------------------------------------------------------------------------*/
61 struct rtems_bsdnet_ifconfig *config, /* interface configuration          */
62 int attaching                         /* 0 = detach, else attach          */
63)
64/*-------------------------------------------------------------------------*\
65| Return Value:                                                             |
66|    1, if success                                                       |
67\*=========================================================================*/
68{
69  int    unitNumber;
70  char   *unitName;
71
72  /*
73   * Parse driver name
74   */
75  if((unitNumber = rtems_bsdnet_parse_driver_name(config, &unitName)) < 0) {
76    return 0;
77  }
78  if (attaching) {
79#if (TSEC_IFMODE==TSEC_IFMODE_GMII)
80    if (unitNumber == 1) {
81      /*
82       * init system I/O configuration registers
83       * to ensure proper pin functions for TSEC1_RX_ER and TSEC1_TX_ER
84       */
85      mpc83xx.syscon.sicrh = mpc83xx.syscon.sicrh & ~0x02800000;
86      /*
87       * init port registers (GPIO2DIR) for TSEC1
88       */
89      mpc83xx.gpio[1].gpdir = ((mpc83xx.gpio[1].gpdir & ~0x00000FFF)
90                               |                         0x0000001f);
91    }
92    if (unitNumber == 2) {
93      /*
94       * init port registers (GPIO2DIR) for TSEC2
95       */
96      mpc83xx.gpio[0].gpdir = ((mpc83xx.gpio[0].gpdir & ~0x000FFFFF)
97                               |                         0x00087881);
98    }
99#endif
100#if (TSEC_IFMODE==TSEC_IFMODE_RGMII)
101
102    /*
103     * Nothing special needed for TSEC1 operation
104     */
105#endif   
106  }
107  /*
108   * add MAC address into config->hardware_adderss
109   * FIXME: get the real address we need
110   */
111  if (config->hardware_address == NULL) {
112
113#ifdef HAS_UBOOT
114
115    switch (unitNumber) {
116      case 1:
117        config->hardware_address = mpc83xx_uboot_board_info.bi_enetaddr;
118        break;
119
120#ifdef CONFIG_HAS_ETH1
121      case 2:
122        config->hardware_address = mpc83xx_uboot_board_info.bi_enet1addr;
123        break;
124#endif /* CONFIG_HAS_ETH1 */
125
126#ifdef CONFIG_HAS_ETH2
127      case 3:
128        config->hardware_address = mpc83xx_uboot_board_info.bi_enet2addr;
129        break;
130#endif /* CONFIG_HAS_ETH2 */
131
132#ifdef CONFIG_HAS_ETH3
133      case 4:
134        config->hardware_address = mpc83xx_uboot_board_info.bi_enet3addr;
135        break;
136#endif /* CONFIG_HAS_ETH3 */
137
138      default:
139        return 0;
140    }
141
142#else /* HAS_UBOOT */
143
144    char hw_addr [6] = { 0x00, 0x04, 0x9f, 0x00, 0x2f, 0xcb};
145
146    config->hardware_address = hw_addr;
147
148#endif /* HAS_UBOOT */
149
150  }
151  /*
152   * set interrupt number for given interface
153   */
154  config->irno = ((unitNumber == 1)
155                  ? BSP_IPIC_IRQ_TSEC1_TX
156                  : BSP_IPIC_IRQ_TSEC2_TX);
157  /*
158   * call attach function of board independent driver
159   */
160  if (0 == rtems_mpc83xx_tsec_driver_attach_detach(config,attaching)) {
161    return 0;
162  }
163  return 1;
164}
Note: See TracBrowser for help on using the repository browser.