Skip to content

Commit b4aba6f

Browse files
committed
soc: microblaze: add demo SoC with timer, interrupt_controller and uart
Internal references: FWRIVERHD-5063 Signed-off-by: Alp Sayin <alpsayin@gmail.com>
1 parent 0ba9b23 commit b4aba6f

File tree

10 files changed

+291
-0
lines changed

10 files changed

+291
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
9+
#include "skeleton.dtsi"
10+
#include "mem.h"
11+
#include "xparam_helper.h"
12+
13+
/ {
14+
15+
microblazeclk: microblaze-clock {
16+
compatible = "fixed-clock";
17+
clock-frequency = <200000000>;
18+
#clock-cells = <0>;
19+
};
20+
21+
peripheralclk: peripheral-clock {
22+
compatible = "fixed-clock";
23+
clock-frequency = <50000000>;
24+
#clock-cells = <0>;
25+
};
26+
27+
cpus {
28+
#address-cells = <1>;
29+
#size-cells = <0>;
30+
31+
cpu: cpu@0 {
32+
device_type = "cpu";
33+
compatible = "xlnx,microblaze";
34+
reg = <0>;
35+
clock-frequency = <200000000>;
36+
37+
i-cache-base = <0x00000000>;
38+
i-cache-size = <0x800>;
39+
i-cache-line-size = <16>;
40+
41+
d-cache-base = <0x00000000>;
42+
d-cache-size = <0x2000>;
43+
d-cache-line-size = <16>;
44+
d-cache-use-writeback = <0>;
45+
};
46+
};
47+
48+
ddr0: memory@0 {
49+
compatible = "mmio-sram";
50+
reg = <0x00000000 DT_SIZE_M(256)>;
51+
};
52+
53+
soc {
54+
interrupt-parent = <&intc0>;
55+
ranges;
56+
#address-cells = <1>;
57+
#size-cells = <1>;
58+
compatible = "simple-bus";
59+
60+
intc0: interrupt-controller@fe010000 {
61+
compatible = "xlnx,intc";
62+
interrupt-controller;
63+
#interrupt-cells = <2>;
64+
reg = <0xfe010000 DT_SIZE_K(128)>;
65+
};
66+
67+
tmrctr0: timer@fe00c000 {
68+
compatible = "xlnx,tmrctr";
69+
reg = <0xfe00c000 DT_SIZE_K(4)>;
70+
interrupts = <15 15>;
71+
clock-frequency = <50000000>;
72+
};
73+
74+
uart0: uart@fe020000 {
75+
compatible = "xlnx,xps-uartlite-1.00.a";
76+
reg = <0xfe020000 DT_SIZE_K(64)>;
77+
interrupts = <14 14>;
78+
clock-frequency = <50000000>;
79+
parity = "none";
80+
status = "disabled";
81+
};
82+
83+
};
84+
};
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
zephyr_include_directories(include)
6+
7+
zephyr_sources(
8+
soc.c
9+
)
10+
11+
set(SOC_LINKER_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/linker.ld CACHE INTERNAL "")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
config SOC_XLNX_MICROBLAZE_DEMO
7+
select MICROBLAZE
8+
select XLNX_INTC
9+
select XLNX_TMRCTR
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
if SOC_XLNX_MICROBLAZE_DEMO
7+
8+
config SYS_CLOCK_HW_CYCLES_PER_SEC
9+
default 200000000
10+
11+
config SYS_CLOCK_TICKS_PER_SEC
12+
default 100
13+
14+
config NUM_IRQS
15+
default 32
16+
17+
endif # SOC_XLNX_MICROBLAZE_DEMO
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
2+
# Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
6+
config SOC_XLNX_MICROBLAZE_DEMO
7+
bool
8+
9+
config SOC
10+
default "microblaze_demo" if SOC_XLNX_MICROBLAZE_DEMO
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
9+
#ifndef ZEPHYR_SOC_MICROBLAZE_SOC_INCLUDE_LAYOUT_H_
10+
#define ZEPHYR_SOC_MICROBLAZE_SOC_INCLUDE_LAYOUT_H_
11+
12+
#include <zephyr/devicetree.h>
13+
14+
#define _DDR_NODE DT_CHOSEN(zephyr_sram)
15+
#define _LAYOUT_DDR_LOC DT_REG_ADDR(_DDR_NODE)
16+
#define _LAYOUT_DDR_SIZE DT_REG_SIZE(_DDR_NODE)
17+
18+
#define _RESET_VECTOR (_LAYOUT_DDR_LOC)
19+
#define _USER_VECTOR (_RESET_VECTOR + 0x8)
20+
#define _INTR_VECTOR (_RESET_VECTOR + 0x10)
21+
#define _EXC_VECTOR (_RESET_VECTOR + 0x20)
22+
23+
#endif /* ZEPHYR_SOC_MICROBLAZE_SOC_INCLUDE_LAYOUT_H_ */
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
9+
#ifndef __SOC_H_
10+
#define __SOC_H_
11+
12+
#include <stdint.h>
13+
#include "layout.h"
14+
15+
#ifdef CONFIG_XLNX_INTC
16+
17+
extern void xlnx_intc_irq_enable(uint32_t irq);
18+
extern void xlnx_intc_irq_disable(uint32_t irq);
19+
extern void xlnx_intc_irq_acknowledge(uint32_t mask);
20+
extern uint32_t xlnx_intc_irq_pending(void);
21+
extern uint32_t xlnx_intc_irq_get_enabled(void);
22+
extern uint32_t xlnx_intc_irq_pending_vector(void);
23+
24+
#endif /* CONFIG_XLNX_INTC */
25+
26+
#endif /* __SOC_H_ */
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
9+
#include <layout.h>
10+
11+
_DDR_LOC = _LAYOUT_DDR_LOC;
12+
_DDR_SIZE = _LAYOUT_DDR_SIZE;
13+
14+
MEMORY
15+
{
16+
app_ram (RX) : ORIGIN = _DDR_LOC, LENGTH = _DDR_SIZE
17+
18+
/* Used by and documented in include/linker/intlist.ld */
19+
IDT_LIST (wx) : ORIGIN = 0xFFFFF7FF, LENGTH = 2K
20+
}
21+
22+
#include <zephyr/arch/microblaze/linker.ld>

soc/microblaze/microblaze_demo/soc.c

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/*
2+
* Copyright (c) 2023 Advanced Micro Devices, Inc. (AMD)
3+
* Copyright (c) 2023 Alp Sayin <alpsayin@gmail.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
9+
#include "soc.h"
10+
11+
#include <zephyr/device.h>
12+
#include <zephyr/init.h>
13+
#include <zephyr/kernel.h>
14+
15+
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
16+
#include <zephyr/logging/log.h>
17+
LOG_MODULE_REGISTER(soc);
18+
19+
#ifdef CONFIG_XLNX_INTC
20+
21+
/**
22+
* @brief Override arch_irq_enable with a call to Xintc driver
23+
*
24+
* @param irq irq number to enable
25+
*/
26+
void arch_irq_enable(uint32_t irq)
27+
{
28+
xlnx_intc_irq_enable(irq);
29+
}
30+
31+
/**
32+
* @brief Override arch_irq_disable with a call to Xintc driver
33+
*
34+
* @param irq irq number to disable
35+
*/
36+
void arch_irq_disable(uint32_t irq)
37+
{
38+
xlnx_intc_irq_disable(irq);
39+
}
40+
41+
/**
42+
* @brief Override arch_irq_is_enabled with a call to Xintc driver
43+
*
44+
* @param irq irq number to see if enabled
45+
*/
46+
int arch_irq_is_enabled(unsigned int irq)
47+
{
48+
return BIT(irq) & xlnx_intc_irq_get_enabled();
49+
}
50+
51+
/**
52+
* @brief Returns the currently pending interrupts.
53+
*
54+
* @return Pending IRQ bitmask. Pending IRQs will have their bitfield set to 1. 0 if no interrupt is
55+
* pending.
56+
*/
57+
uint32_t arch_irq_pending(void)
58+
{
59+
return xlnx_intc_irq_pending();
60+
};
61+
62+
/**
63+
* @brief Returns the vector for highest pending interrupt.
64+
*
65+
* @return Returns the vector for (i.e. index) for highest-prio/lowest-num pending interrupt to be
66+
* used in a jump table. This is used used for sw_isr_table.
67+
*/
68+
uint32_t arch_irq_pending_vector(uint32_t ipending)
69+
{
70+
ARG_UNUSED(ipending);
71+
return xlnx_intc_irq_pending_vector();
72+
}
73+
74+
#endif /* #ifdef CONFIG_XLNX_INTC */
75+
76+
/**
77+
*
78+
* @brief Perform basic hardware initialization
79+
*
80+
* @return 0
81+
*/
82+
static int soc_init(void)
83+
{
84+
return 0;
85+
}
86+
87+
SYS_INIT(soc_init, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
socs:
2+
- name: microblaze_demo

0 commit comments

Comments
 (0)