Skip to content

Commit eec4fae

Browse files
AnhVoRVCNhi Nguyen
authored and
Nhi Nguyen
committed
rcar: scif: Implement SCIF driver
Currently, this flow is IMSG --> console_putc(). If we want to use SCIF, please enable CFG_SCIF=y. But, logging function will be turned off if CFG_SCIF=y. Signed-off-by: Anh Vo <anh.vo.vx@renesas.com>
1 parent e9869ab commit eec4fae

File tree

5 files changed

+27
-12
lines changed

5 files changed

+27
-12
lines changed

core/arch/arm/plat-rcar/conf.mk

-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ endif
106106
core-platform-cflags += -DPLATFORM_RCAR
107107
core-platform-cflags += -DMMU_DIRECT_MAPPING
108108

109-
# Not covered by compile - /core/arch/arm/kernel/trace_ext.c
110-
WITH_TRACE_EXT := n
111-
112109
# Compiler switch - Debug log(Linux terminal log)
113110
RCAR_DEBUG_LOG ?= 0
114111
ifneq ($(RCAR_DEBUG_LOG),0)

core/arch/arm/plat-rcar/main.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,10 @@ register_ddr(NSEC_DDR_3_BASE, NSEC_DDR_3_SIZE);
251251
#endif /* !CFG_CORE_RESERVED_SHM */
252252
// #endif
253253

254-
// static struct scif_uart_data console_data __nex_bss; //use rcar_logging feature instead
254+
#ifdef CFG_SCIF
255+
static struct scif_uart_data console_data __nex_bss;
256+
#endif
257+
255258
static void main_hook_gic_add(struct itr_chip *chip, size_t it, uint32_t type, uint32_t prio)
256259
{
257260
uint32_t exceptions;
@@ -274,9 +277,12 @@ uint32_t rcar_prr_value __nex_bss;
274277

275278
void plat_console_init(void)
276279
{
277-
/* No Operation */
278-
// scif_uart_init(&console_data, CONSOLE_UART_BASE);
279-
// register_serial_console(&console_data.chip);
280+
#ifdef CFG_SCIF
281+
scif_uart_init(&console_data, SCIF2_BASE);
282+
/* Register struct chip (handler func) to framework (console.c)*/
283+
register_serial_console(&console_data.chip);
284+
IMSG("Init SCIF driver before mmu enable");
285+
#endif
280286
}
281287

282288
#ifdef CFG_RCAR_ROMAPI
@@ -307,7 +313,9 @@ void boot_primary_init_intc(void)
307313
gic_data.chip.ops = (const struct itr_ops *)&main_itr_ops;
308314

309315
// Initialize logging feature
316+
#ifndef CFG_SCIF
310317
log_buf_init();
318+
#endif
311319
}
312320

313321
void boot_secondary_init_intc(void)

core/arch/arm/plat-rcar/platform_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
#define ROMAPI_BASE (0xEB100000U) /* MaskROM API address */
9696
#define RPC_BASE (0xEE200000U) /* RPC address */
9797
// #define PRR_BASE (0xFFF00000U) /* Product Register address */
98+
#define SCIF2_BASE (0xE6E88000U) /* SCIF2 base address */
9899
#define RPC_ADDR_MAP_BASE (0x08000000U) /* RPC Internal address */
99100
#define RPC_ADDR_MAP_SIZE (0x04000000U) /* RPC Address Map size */
100101

core/arch/arm/plat-rcar/sub.mk

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,12 @@ srcs-y += rcar_maskrom.c
1515
srcs-y += rcar_suspend_to_ram.c
1616
srcs-y += rcar_mutex.c
1717

18-
# Copy the base file - /core/arch/arm/kernel/
18+
ifneq ($(CFG_SCIF),y)
1919
srcs-y += trace_ext.c
20+
WITH_TRACE_EXT := n
21+
else
22+
WITH_TRACE_EXT := y
23+
endif
2024

2125
subdirs-y += drivers
2226
subdirs-y += tee

core/drivers/scif.c

+9-4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
#define SCSCR_TE BIT(5)
4141
#define SCFSR_TDFE BIT(5)
4242
#define SCFSR_TEND BIT(6)
43+
#define TRANS_END_CHECK (uint16_t)(SCFSR_TEND | SCFSR_TDFE)
4344

4445
#define SCFDR_T_SHIFT 8
4546

@@ -57,18 +58,22 @@ static void scif_uart_flush(struct serial_chip *chip)
5758
{
5859
vaddr_t base = chip_to_base(chip);
5960

60-
while (!(io_read16(base + SCIF_SCFSR) & SCFSR_TEND))
61+
while ((TRANS_END_CHECK & io_read16(base + SCIF_SCFSR)) != TRANS_END_CHECK)
62+
{
6163
;
64+
}
6265
}
6366

6467
static void scif_uart_putc(struct serial_chip *chip, int ch)
6568
{
6669
vaddr_t base = chip_to_base(chip);
6770

68-
/* Wait until there is space in the FIFO */
69-
while ((io_read16(base + SCIF_SCFDR) >> SCFDR_T_SHIFT) >=
70-
SCIF_TX_FIFO_SIZE)
71+
/* Check that transfer is completed */
72+
while ((TRANS_END_CHECK & io_read16(base + SCIF_SCFSR)) != TRANS_END_CHECK)
73+
{
7174
;
75+
}
76+
7277
io_write8(base + SCIF_SCFTDR, ch);
7378
io_clrbits16(base + SCIF_SCFSR, SCFSR_TEND | SCFSR_TDFE);
7479
}

0 commit comments

Comments
 (0)