source: rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c @ 48593d7

4.104.114.84.95
Last change on this file since 48593d7 was 3df08660, checked in by Joel Sherrill <joel.sherrill@…>, on 07/11/07 at 14:24:20

2007-07-11 Joel Sherrill <joel.sherrill@…>

  • network/network.c: Removed warning.
  • Property mode set to 100644
File size: 4.0 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_BITRATE 1000
30#define TSEC_IFMODE_RGMII 0
31#define TSEC_IFMODE_GMII  1
32#define TSEC_IFMODE TSEC_IFMODE_RGMII
33
34/*=========================================================================*\
35| Function:                                                                 |
36\*-------------------------------------------------------------------------*/
37int BSP_tsec_attach
38(
39/*-------------------------------------------------------------------------*\
40| Purpose:                                                                  |
41|   attach or detach the driver                                             |
42+---------------------------------------------------------------------------+
43| Input Parameters:                                                         |
44\*-------------------------------------------------------------------------*/
45 struct rtems_bsdnet_ifconfig *config, /* interface configuration          */
46 int attaching                         /* 0 = detach, else attach          */
47)
48/*-------------------------------------------------------------------------*\
49| Return Value:                                                             |
50|    1, if success                                                       |
51\*=========================================================================*/
52{
53  char hw_addr[6] = {0x00,0x04,0x9F,0x00,0x2f,0xcb};
54  int    unitNumber;
55  char   *unitName;
56
57  /*
58   * Parse driver name
59   */
60  if((unitNumber = rtems_bsdnet_parse_driver_name(config, &unitName)) < 0) {
61    return 0;
62  }
63  if (attaching) {
64    if (unitNumber == 1) {
65      /*
66       * init system I/O configuration registers
67       * to ensure proper pin functions
68       */
69      mpc83xx.syscon.sicrh = mpc83xx.syscon.sicrh & ~0x1f800000;
70      /*
71       * init port registers (GPIO2DIR) for TSEC1
72       */
73      mpc83xx.gpio[1].gpdir = ((mpc83xx.gpio[1].gpdir & ~0x00000FFF)
74                               |                         0x0000001f);
75    }
76  }
77  if (unitNumber == 2) {
78    /*
79     * init port registers (GPIO2DIR) for TSEC2
80     */
81    mpc83xx.gpio[0].gpdir = ((mpc83xx.gpio[0].gpdir & ~0x000FFFFF)
82                             |                         0x00087881);
83  }
84  /*
85   * add MAC address into config->hardware_adderss
86   * FIXME: get the real address we need
87   */
88  if (config->hardware_address == NULL) {
89    config->hardware_address = hw_addr;
90  }
91  /*
92   * set interrupt number for given interface
93   */
94  config->irno = ((unitNumber == 1)
95                  ? BSP_IPIC_IRQ_TSEC1_TX
96                  : BSP_IPIC_IRQ_TSEC2_TX);
97  /*
98   * call attach function of board independent driver
99   */
100  if (0 == rtems_mpc83xx_tsec_driver_attach_detach(config,attaching)) {
101    return 0;
102  }
103  return 1;
104}
Note: See TracBrowser for help on using the repository browser.