Skip to content

Commit 4d9113f

Browse files
author
Wayne Ren
authored
Merge pull request #72 from foss-for-synopsys-dwc-arc-processors/feature/emsdp
add the support of EM Software Development Platform(EMSDP)
2 parents 56c7685 + 6589cfd commit 4d9113f

File tree

514 files changed

+133075
-13455
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+133075
-13455
lines changed

arc/arc_udma.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ static void _dmac_fill_descriptor(uint32_t channel, dma_desc_t * desc)
411411

412412
int32_t dmac_init(dma_state_t * state)
413413
{
414-
#if UDMA_CHECK_ERRORS
414+
#ifdef UDMA_CHECK_ERRORS
415415
if (state == NULL) {
416416
return -1;
417417
}
@@ -493,7 +493,7 @@ static void _dmac_process_desc(dma_desc_t * desc, uint32_t int_enable)
493493
} while (desc != 0);
494494
}
495495

496-
#if UDMA_CHECK_ERRORS
496+
#ifdef UDMA_CHECK_ERRORS
497497
static int32_t dmac_valid_channel(int32_t channel, dma_desc_t * desc)
498498
{
499499
#if CORE_DMAC_INTERNAL_VERSION == 1
@@ -615,7 +615,7 @@ void dmac_close(void)
615615
int32_t dmac_config_desc(dma_desc_t * desc, void *src, void *dst, uint32_t size,
616616
dma_ctrl_t * ctrl)
617617
{
618-
#if UDMA_CHECK_ERRORS
618+
#ifdef UDMA_CHECK_ERRORS
619619
if (_arc_rarely(desc == NULL)) {
620620
return -1;
621621
}
@@ -637,7 +637,7 @@ int32_t dmac_desc_add_linked(dma_desc_t * head, dma_desc_t * next)
637637

638638
int32_t dmac_init_channel(dma_channel_t * dma_chn)
639639
{
640-
#if UDMA_CHECK_ERRORS
640+
#ifdef UDMA_CHECK_ERRORS
641641
if (_arc_rarely(dma_chn == NULL)) {
642642
return -1;
643643
}
@@ -652,7 +652,7 @@ int32_t dmac_init_channel(dma_channel_t * dma_chn)
652652

653653
int32_t dmac_config_channel(dma_channel_t * dma_chn, dma_desc_t * desc)
654654
{
655-
#if UDMA_CHECK_ERRORS
655+
#ifdef UDMA_CHECK_ERRORS
656656
if (_arc_rarely(dma_chn == NULL)) {
657657
return -1;
658658
}
@@ -700,7 +700,7 @@ int32_t dmac_start_channel(dma_channel_t * dma_chn, dma_callback_t callback,
700700
uint32_t priority)
701701
{
702702
int32_t channel;
703-
#if UDMA_CHECK_ERRORS
703+
#ifdef UDMA_CHECK_ERRORS
704704
if (_arc_rarely(dma_chn == NULL)) {
705705
return -1;
706706
}
@@ -710,7 +710,7 @@ int32_t dmac_start_channel(dma_channel_t * dma_chn, dma_callback_t callback,
710710
#endif
711711
channel = dma_chn->channel;
712712

713-
#if UDMA_CHECK_ERRORS
713+
#ifdef UDMA_CHECK_ERRORS
714714
if (_arc_rarely(!((uint32_t) channel < DMA_ALL_CHANNEL_NUM))) {
715715
return -1;
716716
}
@@ -719,7 +719,7 @@ int32_t dmac_start_channel(dma_channel_t * dma_chn, dma_callback_t callback,
719719
return -1;
720720
}
721721
/** Check if aux based registers and linked transfer is not supported */
722-
#if UDMA_CHECK_ERRORS
722+
#ifdef UDMA_CHECK_ERRORS
723723
if (_arc_rarely(dmac_valid_channel(channel, dma_chn->desc) != 0)) {
724724
return -2;
725725
}
@@ -763,7 +763,7 @@ int32_t dmac_start_channel(dma_channel_t * dma_chn, dma_callback_t callback,
763763
int32_t dmac_stop_channel(dma_channel_t * dma_chn)
764764
{
765765
int32_t channel;
766-
#if UDMA_CHECK_ERRORS
766+
#ifdef UDMA_CHECK_ERRORS
767767
if (_arc_rarely(dma_chn == NULL)) {
768768
return -1;
769769
}
@@ -772,7 +772,7 @@ int32_t dmac_stop_channel(dma_channel_t * dma_chn)
772772
}
773773
#endif
774774
channel = dma_chn->channel;
775-
#if UDMA_CHECK_ERRORS
775+
#ifdef UDMA_CHECK_ERRORS
776776
if (_arc_rarely(!((uint32_t) channel < DMA_ALL_CHANNEL_NUM))) {
777777
return -1;
778778
}
@@ -789,7 +789,7 @@ int32_t dmac_stop_channel(dma_channel_t * dma_chn)
789789
int32_t dmac_clear_channel(dma_channel_t * dma_chn)
790790
{
791791
int32_t channel;
792-
#if UDMA_CHECK_ERRORS
792+
#ifdef UDMA_CHECK_ERRORS
793793
if (_arc_rarely(dma_chn == NULL)) {
794794
return -1;
795795
}
@@ -799,7 +799,7 @@ int32_t dmac_clear_channel(dma_channel_t * dma_chn)
799799
#endif
800800
channel = dma_chn->channel;
801801

802-
#if UDMA_CHECK_ERRORS
802+
#ifdef UDMA_CHECK_ERRORS
803803
if (_arc_rarely(!((uint32_t) channel < DMA_ALL_CHANNEL_NUM))) {
804804
return -1;
805805
}
@@ -816,7 +816,7 @@ int32_t dmac_clear_channel(dma_channel_t * dma_chn)
816816
int32_t dmac_release_channel(dma_channel_t * dma_chn)
817817
{
818818
int32_t channel;
819-
#if UDMA_CHECK_ERRORS
819+
#ifdef UDMA_CHECK_ERRORS
820820
if (_arc_rarely(dma_chn == NULL)) {
821821
return -1;
822822
}
@@ -826,7 +826,7 @@ int32_t dmac_release_channel(dma_channel_t * dma_chn)
826826
#endif
827827
channel = dma_chn->channel;
828828

829-
#if UDMA_CHECK_ERRORS
829+
#ifdef UDMA_CHECK_ERRORS
830830
if (_arc_rarely(!((uint32_t) channel < DMA_ALL_CHANNEL_NUM))) {
831831
return -1;
832832
}
@@ -843,7 +843,7 @@ int32_t dmac_release_channel(dma_channel_t * dma_chn)
843843
int32_t dmac_wait_channel(dma_channel_t * dma_chn)
844844
{
845845
int32_t channel;
846-
#if UDMA_CHECK_ERRORS
846+
#ifdef UDMA_CHECK_ERRORS
847847
if (_arc_rarely(dma_chn == NULL)) {
848848
return -1;
849849
}
@@ -853,7 +853,7 @@ int32_t dmac_wait_channel(dma_channel_t * dma_chn)
853853
#endif
854854
channel = dma_chn->channel;
855855

856-
#if UDMA_CHECK_ERRORS
856+
#ifdef UDMA_CHECK_ERRORS
857857
if (_arc_rarely(!((uint32_t) channel < DMA_ALL_CHANNEL_NUM))) {
858858
return -1;
859859
}
@@ -869,7 +869,7 @@ int32_t dmac_wait_channel(dma_channel_t * dma_chn)
869869
int32_t dmac_check_channel(dma_channel_t * dma_chn)
870870
{
871871
int32_t channel;
872-
#if UDMA_CHECK_ERRORS
872+
#ifdef UDMA_CHECK_ERRORS
873873
if (_arc_rarely(dma_chn == NULL)) {
874874
return -1;
875875
}
@@ -879,7 +879,7 @@ int32_t dmac_check_channel(dma_channel_t * dma_chn)
879879
#endif
880880
channel = dma_chn->channel;
881881

882-
#if UDMA_CHECK_ERRORS
882+
#ifdef UDMA_CHECK_ERRORS
883883
if (_arc_rarely(!((uint32_t) channel < DMA_ALL_CHANNEL_NUM))) {
884884
return -1;
885885
}

board/axs/configs/core_configs.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Core Configuation Folder ##
1+
## Core Configuration Folder ##
22
CORE_TCF_DIR = $(BOARD_CORE_DIR)/tcf
33
CORE_CONFIG_MK = $(BOARD_CORE_DIR)/core_config.mk
44
CORE_DEBUG_MK = $(BOARD_CORE_DIR)/core_debug.mk
@@ -37,7 +37,7 @@ override VALID_CUR_CORE := $(TCFFILE_NAME)
3737
endif
3838
endif
3939

40-
## Check Core Configuation Supported
40+
## Check Core Configuration Supported
4141
ifneq ($(TCFFILE_IS_VALID),1)
4242
ifeq ($(VALID_CUR_CORE),)
4343
$(info BOARD $(BOARD)-$(BD_VER) Core Configurations - $(SUPPORTED_CORES) are supported)

board/board.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@
7575
#include "iotdk/iotdk.h"
7676
#endif /* BOARD_IOTDK */
7777

78+
#ifdef BOARD_EMSDP
79+
#include "emsdp/emsdp.h"
80+
#endif /* BOARD_EMDK */
81+
7882
#endif /* _EMBARC_BOARD_H_ */
7983

8084
/** @} end of group BOARD_COMMON */

board/emsdp/common/emsdp_init.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* ------------------------------------------
2+
* Copyright (c) 2018, Synopsys, Inc. All rights reserved.
3+
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
7+
* 1) Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
10+
* 2) Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation and/or
12+
* other materials provided with the distribution.
13+
14+
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
15+
* be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
--------------------------------------------- */
30+
#include "arc_timer.h"
31+
#include "board.h"
32+
#include "emsdp_timer.h"
33+
#include "dev_pinmux.h"
34+
35+
36+
/**
37+
* \brief Board init routine MUST be called in each application
38+
* \note It is better to disable interrupts when calling this function
39+
* remember to enable interrupt when you want to use them
40+
*/
41+
void board_init(void)
42+
{
43+
timer_init();
44+
io_mux_init();
45+
emsdp_timer_init();
46+
emsdp_io_init();
47+
}

board/emsdp/common/emsdp_io.c

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
/* ------------------------------------------
2+
* Copyright (c) 2018, Synopsys, Inc. All rights reserved.
3+
4+
* Redistribution and use in source and binary forms, with or without modification,
5+
* are permitted provided that the following conditions are met:
6+
7+
* 1) Redistributions of source code must retain the above copyright notice, this
8+
* list of conditions and the following disclaimer.
9+
10+
* 2) Redistributions in binary form must reproduce the above copyright notice,
11+
* this list of conditions and the following disclaimer in the documentation and/or
12+
* other materials provided with the distribution.
13+
14+
* 3) Neither the name of the Synopsys, Inc., nor the names of its contributors may
15+
* be used to endorse or promote products derived from this software without
16+
* specific prior written permission.
17+
18+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
22+
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
25+
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
*
29+
--------------------------------------------- */
30+
#include "embARC_toolchain.h"
31+
#include "embARC_error.h"
32+
33+
#include "emsdp_io.h"
34+
#include "emsdp/emsdp.h"
35+
36+
static DEV_GPIO *led_port;
37+
static DEV_GPIO *switch_port;
38+
39+
#define EMSDP_GPIO_CHECK_EXP_NORTN(EXPR) CHECK_EXP_NOERCD(EXPR, error_exit)
40+
41+
/** emsdp on board gpio init */
42+
void emsdp_io_init(void)
43+
{
44+
emsdp_led_init();
45+
emsdp_switch_init();
46+
}
47+
48+
/** emsdp on-board led init, led default off */
49+
void emsdp_led_init(void)
50+
{
51+
led_port = gpio_get_dev(EMSDP_LED_PORT);
52+
53+
EMSDP_GPIO_CHECK_EXP_NORTN(led_port != NULL);
54+
55+
if (led_port->gpio_open(EMSDP_LED_DIR) == E_OPNED) {
56+
led_port->gpio_control(GPIO_CMD_SET_BIT_DIR_OUTPUT, (void *)(EMSDP_LED_MASK));
57+
led_port->gpio_control(GPIO_CMD_DIS_BIT_INT, (void *)(EMSDP_LED_MASK));
58+
}
59+
60+
led_write(0, BOARD_LED_MASK);
61+
62+
error_exit:
63+
return;
64+
}
65+
66+
/** emsdp on-board switch init */
67+
void emsdp_switch_init(void)
68+
{
69+
switch_port = gpio_get_dev(EMSDP_SWITCH_PORT);
70+
71+
EMSDP_GPIO_CHECK_EXP_NORTN(switch_port != NULL);
72+
73+
if (switch_port->gpio_open(EMSDP_SWITCH_DIR) == E_OPNED) {
74+
switch_port->gpio_control(GPIO_CMD_SET_BIT_DIR_INPUT, (void *)(EMSDP_SWITCH_MASK));
75+
switch_port->gpio_control(GPIO_CMD_DIS_BIT_INT, (void *)(EMSDP_SWITCH_MASK));
76+
}
77+
78+
error_exit:
79+
return;
80+
}
81+
82+
/** write 1 to light on led bit, else light off led */
83+
void led_write(uint32_t led_val, uint32_t mask)
84+
{
85+
EMSDP_GPIO_CHECK_EXP_NORTN(led_port != NULL);
86+
87+
led_val = (~led_val) & mask;
88+
led_val = led_val << EMSDP_LED_OFFSET;
89+
mask = (mask << EMSDP_LED_OFFSET) & EMSDP_LED_MASK;
90+
led_port->gpio_write(led_val, mask);
91+
92+
error_exit:
93+
return;
94+
}
95+
96+
/** toggle masked led */
97+
void led_toggle(uint32_t mask)
98+
{
99+
EMSDP_GPIO_CHECK_EXP_NORTN(led_port != NULL);
100+
led_port->gpio_control(GPIO_CMD_TOGGLE_BITS, CONV2VOID(mask));
101+
102+
error_exit:
103+
return;
104+
}
105+
106+
/** read led value, on for 1, off for 0 */
107+
uint32_t led_read(uint32_t mask)
108+
{
109+
uint32_t value;
110+
111+
EMSDP_GPIO_CHECK_EXP_NORTN(led_port != NULL);
112+
113+
mask = (mask << EMSDP_LED_OFFSET) & EMSDP_LED_MASK;
114+
led_port->gpio_read(&value, mask);
115+
value = (~value) & EMSDP_LED_MASK;
116+
117+
return (value >> EMSDP_LED_OFFSET);
118+
119+
error_exit:
120+
return 0;
121+
}
122+
123+
/** turn on switch return 1, else 0 */
124+
uint32_t switch_read(uint32_t mask)
125+
{
126+
uint32_t value;
127+
128+
EMSDP_GPIO_CHECK_EXP_NORTN(switch_port != NULL);
129+
130+
mask = (mask << EMSDP_SWITCH_OFFSET) & EMSDP_SWITCH_MASK;
131+
switch_port->gpio_read(&value, mask);
132+
value = (~value) & mask;
133+
134+
return (value >> EMSDP_SWITCH_OFFSET);
135+
136+
error_exit:
137+
return 0;
138+
}

0 commit comments

Comments
 (0)