RTEMS 6.1-rc7
Loading...
Searching...
No Matches
lpc-ethernet-config.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause */
2
11/*
12 * Copyright (C) 2009, 2012 embedded brains GmbH & Co. KG
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions
16 * are met:
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above copyright
20 * notice, this list of conditions and the following disclaimer in the
21 * documentation and/or other materials provided with the distribution.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33 * POSSIBILITY OF SUCH DAMAGE.
34 */
35
36#ifndef LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H
37#define LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H
38
39#include <bsp.h>
40#include <bsp/io.h>
41#include <bsp/lpc24xx.h>
42
43#include <limits.h>
44
45#ifdef __cplusplus
46extern "C" {
47#endif /* __cplusplus */
48
49#define LPC_ETH_CONFIG_INTERRUPT LPC24XX_IRQ_ETHERNET
50
51#define LPC_ETH_CONFIG_REG_BASE MAC_BASE_ADDR
52
53#ifdef ARM_MULTILIB_ARCH_V4
54 #define LPC_ETH_CONFIG_RX_UNIT_COUNT_DEFAULT 16
55 #define LPC_ETH_CONFIG_RX_UNIT_COUNT_MAX 54
56
57 #define LPC_ETH_CONFIG_TX_UNIT_COUNT_DEFAULT 10
58 #define LPC_ETH_CONFIG_TX_UNIT_COUNT_MAX 10
59
60 #define LPC_ETH_CONFIG_UNIT_MULTIPLE 1U
61
62 #define LPC24XX_ETH_RAM_BEGIN 0x7fe00000U
63 #define LPC24XX_ETH_RAM_SIZE (16U * 1024U)
64#else
65 #define LPC_ETH_CONFIG_RX_UNIT_COUNT_DEFAULT 16
66 #define LPC_ETH_CONFIG_RX_UNIT_COUNT_MAX INT_MAX
67
68 #define LPC_ETH_CONFIG_TX_UNIT_COUNT_DEFAULT 32
69 #define LPC_ETH_CONFIG_TX_UNIT_COUNT_MAX INT_MAX
70
71 #define LPC_ETH_CONFIG_UNIT_MULTIPLE 8U
72
73 #define LPC_ETH_CONFIG_USE_TRANSMIT_DMA
74
75 #define LPC24XX_ETH_RAM_BEGIN 0x20000000U
76 #define LPC24XX_ETH_RAM_SIZE (32U * 1024U)
77#endif
78
79#ifdef LPC24XX_ETHERNET_RMII
80 #define LPC_ETH_CONFIG_RMII
81
82 static void lpc_eth_config_module_enable(void)
83 {
84 static const lpc24xx_pin_range pins [] = {
85 #ifdef LPC24XX_PIN_ETHERNET_POWER_DOWN
86 LPC24XX_PIN_ETHERNET_POWER_DOWN,
87 #endif
88 LPC24XX_PIN_ETHERNET_RMII_0,
89 LPC24XX_PIN_ETHERNET_RMII_1,
90 LPC24XX_PIN_ETHERNET_RMII_2,
91 LPC24XX_PIN_ETHERNET_RMII_3,
92 LPC24XX_PIN_TERMINAL
93 };
94
95 lpc24xx_module_enable(LPC24XX_MODULE_ETHERNET, LPC24XX_MODULE_PCLK_DEFAULT);
97
98 #ifdef LPC24XX_PIN_ETHERNET_POWER_DOWN
99 {
100 unsigned pin = lpc24xx_pin_get_first_index(&pins[0]);
101
102 lpc24xx_gpio_config(pin, LPC24XX_GPIO_OUTPUT);
103 lpc24xx_gpio_set(pin);
104 }
105 #endif
106 }
107#else
108 static void lpc_eth_config_module_enable(void)
109 {
110 static const lpc24xx_pin_range pins [] = {
111 LPC24XX_PIN_ETHERNET_MII,
112 LPC24XX_PIN_TERMINAL
113 };
114
115 lpc24xx_module_enable(LPC24XX_MODULE_ETHERNET, LPC24XX_MODULE_PCLK_DEFAULT);
117 }
118#endif
119
120static void lpc_eth_config_module_disable(void)
121{
122 lpc24xx_module_disable(LPC24XX_MODULE_ETHERNET);
123}
124
125static char *lpc_eth_config_alloc_table_area(size_t size)
126{
127 if (size < LPC24XX_ETH_RAM_SIZE) {
128 return (char *) LPC24XX_ETH_RAM_BEGIN;
129 } else {
130 return NULL;
131 }
132}
133
134static void lpc_eth_config_free_table_area(char *table_area)
135{
136 /* Do nothing */
137}
138
139#ifdef __cplusplus
140}
141#endif /* __cplusplus */
142
143#endif /* LIBBSP_ARM_LPC24XX_LPC_ETHERNET_CONFIG_H */
rtems_status_code lpc24xx_pin_config(const lpc24xx_pin_range *pins, lpc24xx_pin_action action)
Performs the action with the pins.
Definition: io.c:530
@ LPC24XX_PIN_SET_FUNCTION
Sets the pin function.
Definition: io.h:219
Register definitions.
Definition: io.h:237