source: rtems/c/src/lib/libbsp/powerpc/gen83xx/network/network.c @ 55a1cc9c

4.104.114.84.95
Last change on this file since 55a1cc9c was f610e83f, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/10/07 at 16:00:28

compilable release of virtex/gen83xx/gen5200 powerpc adaptations. Merged many different versions of new exception handling code to shared sources.

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