Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:03

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  *
0006  * @ingroup RTEMSBSPsARMLPC24XX
0007  *
0008  * @brief Ethernet driver configuration.
0009  */
0010 
0011 /*
0012  * Copyright (C) 2009, 2012 embedded brains GmbH & Co. KG
0013  *
0014  * Redistribution and use in source and binary forms, with or without
0015  * modification, are permitted provided that the following conditions
0016  * are met:
0017  * 1. Redistributions of source code must retain the above copyright
0018  *    notice, this list of conditions and the following disclaimer.
0019  * 2. Redistributions in binary form must reproduce the above copyright
0020  *    notice, this list of conditions and the following disclaimer in the
0021  *    documentation and/or other materials provided with the distribution.
0022  *
0023  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0024  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0025  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0026  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0027  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0028  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0029  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0030  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0031  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0032  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0033  * POSSIBILITY OF SUCH DAMAGE.
0034  */
0035 
0036 #ifndef LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H
0037 #define LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H
0038 
0039 #include <bsp.h>
0040 #include <bsp/io.h>
0041 #include <bsp/lpc24xx.h>
0042 
0043 #include <limits.h>
0044 
0045 #ifdef __cplusplus
0046 extern "C" {
0047 #endif /* __cplusplus */
0048 
0049 #define LPC_ETH_CONFIG_INTERRUPT LPC24XX_IRQ_ETHERNET
0050 
0051 #define LPC_ETH_CONFIG_REG_BASE MAC_BASE_ADDR
0052 
0053 #ifdef ARM_MULTILIB_ARCH_V4
0054   #define LPC_ETH_CONFIG_RX_UNIT_COUNT_DEFAULT 16
0055   #define LPC_ETH_CONFIG_RX_UNIT_COUNT_MAX 54
0056 
0057   #define LPC_ETH_CONFIG_TX_UNIT_COUNT_DEFAULT 10
0058   #define LPC_ETH_CONFIG_TX_UNIT_COUNT_MAX 10
0059 
0060   #define LPC_ETH_CONFIG_UNIT_MULTIPLE 1U
0061 
0062   #define LPC24XX_ETH_RAM_BEGIN 0x7fe00000U
0063   #define LPC24XX_ETH_RAM_SIZE (16U * 1024U)
0064 #else
0065   #define LPC_ETH_CONFIG_RX_UNIT_COUNT_DEFAULT 16
0066   #define LPC_ETH_CONFIG_RX_UNIT_COUNT_MAX INT_MAX
0067 
0068   #define LPC_ETH_CONFIG_TX_UNIT_COUNT_DEFAULT 32
0069   #define LPC_ETH_CONFIG_TX_UNIT_COUNT_MAX INT_MAX
0070 
0071   #define LPC_ETH_CONFIG_UNIT_MULTIPLE 8U
0072 
0073   #define LPC_ETH_CONFIG_USE_TRANSMIT_DMA
0074 
0075   #define LPC24XX_ETH_RAM_BEGIN 0x20000000U
0076   #define LPC24XX_ETH_RAM_SIZE (32U * 1024U)
0077 #endif
0078 
0079 #ifdef LPC24XX_ETHERNET_RMII
0080   #define LPC_ETH_CONFIG_RMII
0081 
0082   static void lpc_eth_config_module_enable(void)
0083   {
0084     static const lpc24xx_pin_range pins [] = {
0085       #ifdef LPC24XX_PIN_ETHERNET_POWER_DOWN
0086         LPC24XX_PIN_ETHERNET_POWER_DOWN,
0087       #endif
0088       LPC24XX_PIN_ETHERNET_RMII_0,
0089       LPC24XX_PIN_ETHERNET_RMII_1,
0090       LPC24XX_PIN_ETHERNET_RMII_2,
0091       LPC24XX_PIN_ETHERNET_RMII_3,
0092       LPC24XX_PIN_TERMINAL
0093     };
0094 
0095     lpc24xx_module_enable(LPC24XX_MODULE_ETHERNET, LPC24XX_MODULE_PCLK_DEFAULT);
0096     lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
0097 
0098     #ifdef LPC24XX_PIN_ETHERNET_POWER_DOWN
0099       {
0100         unsigned pin = lpc24xx_pin_get_first_index(&pins[0]);
0101 
0102         lpc24xx_gpio_config(pin, LPC24XX_GPIO_OUTPUT);
0103         lpc24xx_gpio_set(pin);
0104       }
0105     #endif
0106   }
0107 #else
0108   static void lpc_eth_config_module_enable(void)
0109   {
0110     static const lpc24xx_pin_range pins [] = {
0111       LPC24XX_PIN_ETHERNET_MII,
0112       LPC24XX_PIN_TERMINAL
0113     };
0114 
0115     lpc24xx_module_enable(LPC24XX_MODULE_ETHERNET, LPC24XX_MODULE_PCLK_DEFAULT);
0116     lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION);
0117   }
0118 #endif
0119 
0120 static void lpc_eth_config_module_disable(void)
0121 {
0122   lpc24xx_module_disable(LPC24XX_MODULE_ETHERNET);
0123 }
0124 
0125 static char *lpc_eth_config_alloc_table_area(size_t size)
0126 {
0127   if (size < LPC24XX_ETH_RAM_SIZE) {
0128     return (char *) LPC24XX_ETH_RAM_BEGIN;
0129   } else {
0130     return NULL;
0131   }
0132 }
0133 
0134 static void lpc_eth_config_free_table_area(char *table_area)
0135 {
0136   /* Do nothing */
0137 }
0138 
0139 #ifdef __cplusplus
0140 }
0141 #endif /* __cplusplus */
0142 
0143 #endif /* LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H */