[39c8fdb] | 1 | /** |
---|
| 2 | * @file |
---|
| 3 | * |
---|
| 4 | * @ingroup lpc24xx |
---|
| 5 | * |
---|
| 6 | * @brief Ethernet driver configuration. |
---|
| 7 | */ |
---|
| 8 | |
---|
| 9 | /* |
---|
[e7395c7] | 10 | * Copyright (c) 2009-2012 embedded brains GmbH. All rights reserved. |
---|
[d74ed4a] | 11 | * |
---|
| 12 | * embedded brains GmbH |
---|
| 13 | * Obere Lagerstr. 30 |
---|
| 14 | * 82178 Puchheim |
---|
| 15 | * Germany |
---|
| 16 | * <rtems@embedded-brains.de> |
---|
[39c8fdb] | 17 | * |
---|
| 18 | * The license and distribution terms for this file may be |
---|
| 19 | * found in the file LICENSE in this distribution or at |
---|
[c499856] | 20 | * http://www.rtems.org/license/LICENSE. |
---|
[39c8fdb] | 21 | */ |
---|
| 22 | |
---|
| 23 | #ifndef LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H |
---|
| 24 | #define LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H |
---|
| 25 | |
---|
| 26 | #include <bsp.h> |
---|
| 27 | #include <bsp/io.h> |
---|
| 28 | #include <bsp/lpc24xx.h> |
---|
| 29 | |
---|
[e7395c7] | 30 | #include <limits.h> |
---|
| 31 | |
---|
[39c8fdb] | 32 | #ifdef __cplusplus |
---|
| 33 | extern "C" { |
---|
| 34 | #endif /* __cplusplus */ |
---|
| 35 | |
---|
| 36 | #define LPC_ETH_CONFIG_INTERRUPT LPC24XX_IRQ_ETHERNET |
---|
| 37 | |
---|
| 38 | #define LPC_ETH_CONFIG_REG_BASE MAC_BASE_ADDR |
---|
| 39 | |
---|
[e7395c7] | 40 | #ifdef ARM_MULTILIB_ARCH_V4 |
---|
| 41 | #define LPC_ETH_CONFIG_RX_UNIT_COUNT_DEFAULT 16 |
---|
| 42 | #define LPC_ETH_CONFIG_RX_UNIT_COUNT_MAX 54 |
---|
| 43 | |
---|
| 44 | #define LPC_ETH_CONFIG_TX_UNIT_COUNT_DEFAULT 10 |
---|
| 45 | #define LPC_ETH_CONFIG_TX_UNIT_COUNT_MAX 10 |
---|
| 46 | |
---|
| 47 | #define LPC_ETH_CONFIG_UNIT_MULTIPLE 1U |
---|
| 48 | |
---|
| 49 | #define LPC24XX_ETH_RAM_BEGIN 0x7fe00000U |
---|
| 50 | #define LPC24XX_ETH_RAM_SIZE (16U * 1024U) |
---|
| 51 | #else |
---|
| 52 | #define LPC_ETH_CONFIG_RX_UNIT_COUNT_DEFAULT 16 |
---|
| 53 | #define LPC_ETH_CONFIG_RX_UNIT_COUNT_MAX INT_MAX |
---|
[39c8fdb] | 54 | |
---|
[e7395c7] | 55 | #define LPC_ETH_CONFIG_TX_UNIT_COUNT_DEFAULT 32 |
---|
| 56 | #define LPC_ETH_CONFIG_TX_UNIT_COUNT_MAX INT_MAX |
---|
[39c8fdb] | 57 | |
---|
[e7395c7] | 58 | #define LPC_ETH_CONFIG_UNIT_MULTIPLE 8U |
---|
| 59 | |
---|
| 60 | #define LPC_ETH_CONFIG_USE_TRANSMIT_DMA |
---|
| 61 | |
---|
| 62 | #define LPC24XX_ETH_RAM_BEGIN 0x20000000U |
---|
| 63 | #define LPC24XX_ETH_RAM_SIZE (32U * 1024U) |
---|
| 64 | #endif |
---|
[39c8fdb] | 65 | |
---|
| 66 | #ifdef LPC24XX_ETHERNET_RMII |
---|
| 67 | #define LPC_ETH_CONFIG_RMII |
---|
| 68 | |
---|
| 69 | static void lpc_eth_config_module_enable(void) |
---|
| 70 | { |
---|
[d74ed4a] | 71 | static const lpc24xx_pin_range pins [] = { |
---|
[810815c4] | 72 | #ifdef LPC24XX_PIN_ETHERNET_POWER_DOWN |
---|
| 73 | LPC24XX_PIN_ETHERNET_POWER_DOWN, |
---|
| 74 | #endif |
---|
[d74ed4a] | 75 | LPC24XX_PIN_ETHERNET_RMII_0, |
---|
| 76 | LPC24XX_PIN_ETHERNET_RMII_1, |
---|
| 77 | LPC24XX_PIN_ETHERNET_RMII_2, |
---|
| 78 | LPC24XX_PIN_ETHERNET_RMII_3, |
---|
| 79 | LPC24XX_PIN_TERMINAL |
---|
| 80 | }; |
---|
| 81 | |
---|
[39c8fdb] | 82 | lpc24xx_module_enable(LPC24XX_MODULE_ETHERNET, LPC24XX_MODULE_PCLK_DEFAULT); |
---|
[d74ed4a] | 83 | lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION); |
---|
[810815c4] | 84 | |
---|
| 85 | #ifdef LPC24XX_PIN_ETHERNET_POWER_DOWN |
---|
| 86 | { |
---|
| 87 | unsigned pin = lpc24xx_pin_get_first_index(&pins[0]); |
---|
| 88 | |
---|
| 89 | lpc24xx_gpio_config(pin, LPC24XX_GPIO_OUTPUT); |
---|
| 90 | lpc24xx_gpio_set(pin); |
---|
| 91 | } |
---|
| 92 | #endif |
---|
[39c8fdb] | 93 | } |
---|
| 94 | #else |
---|
| 95 | static void lpc_eth_config_module_enable(void) |
---|
| 96 | { |
---|
[d74ed4a] | 97 | static const lpc24xx_pin_range pins [] = { |
---|
| 98 | LPC24XX_PIN_ETHERNET_MII, |
---|
| 99 | LPC24XX_PIN_TERMINAL |
---|
| 100 | }; |
---|
| 101 | |
---|
[39c8fdb] | 102 | lpc24xx_module_enable(LPC24XX_MODULE_ETHERNET, LPC24XX_MODULE_PCLK_DEFAULT); |
---|
[d74ed4a] | 103 | lpc24xx_pin_config(&pins [0], LPC24XX_PIN_SET_FUNCTION); |
---|
[39c8fdb] | 104 | } |
---|
| 105 | #endif |
---|
| 106 | |
---|
[2cd48da] | 107 | static void lpc_eth_config_module_disable(void) |
---|
| 108 | { |
---|
| 109 | lpc24xx_module_disable(LPC24XX_MODULE_ETHERNET); |
---|
| 110 | } |
---|
| 111 | |
---|
[39c8fdb] | 112 | static char *lpc_eth_config_alloc_table_area(size_t size) |
---|
| 113 | { |
---|
| 114 | if (size < LPC24XX_ETH_RAM_SIZE) { |
---|
| 115 | return (char *) LPC24XX_ETH_RAM_BEGIN; |
---|
| 116 | } else { |
---|
| 117 | return NULL; |
---|
| 118 | } |
---|
| 119 | } |
---|
| 120 | |
---|
| 121 | static void lpc_eth_config_free_table_area(char *table_area) |
---|
| 122 | { |
---|
| 123 | /* Do nothing */ |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | #ifdef __cplusplus |
---|
| 127 | } |
---|
| 128 | #endif /* __cplusplus */ |
---|
| 129 | |
---|
| 130 | #endif /* LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H */ |
---|