1 /***********************************************************************************************
2 * FILE PURPOSE: Configure the cpsw
3 ***********************************************************************************************
4 * FILE NAME: cpsw.c
5 *
6 * DESCRIPTION: The common platform ethernet switch driver
7 *
8 ************************************************************************************************/
9 #include "types.h"
10 #include "cpsw_loc.h"
11 #include "cpsw_api.h"
12 #include "device.h"
16 /************************************************************************************************
17 * FUNCTION PURPOSE: Configure the switch
18 ************************************************************************************************
19 * DESCRIPTION: The switch is setup without respect to its current state. The ALE
20 * is reset during the configuration.
21 ************************************************************************************************/
22 SINT16 hwCpswConfig (UINT32 ctl, UINT32 maxPktSize)
23 {
24 UINT32 i;
26 /* Max length register */
27 DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_MAXLEN, maxPktSize);
29 /* Control register */
30 DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_CTL, ctl);
32 /* All statistics enabled by default */
33 DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_STAT_PORT_EN, CPSW_REG_VAL_STAT_ENABLE_ALL);
35 /* Reset and enable the ALE */
36 DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_ALE_CONTROL, CPSW_REG_VAL_ALE_CTL_RESET_AND_ENABLE);
38 /* All ports put into forward mode */
39 for (i = 0; i < DEVICE_CPSW_NUM_PORTS; i++)
40 DEVICE_REG32_W (DEVICE_CPSW_BASE + CPSW_REG_ALE_PORTCTL(i), CPSW_REG_VAL_PORTCTL_FORWARD_MODE);
43 return (0);
45 } /* hwCpswConfig */