forked from Mirrors/opensbi

This driver is for T-HEAD test chip, fpga. It could work with all T-HEAD riscv processors: C9xx series. example1: (Using io-regs for reset) reset: reset-sample { compatible = "thead,reset-sample"; plic-delegate = <0xff 0xd81ffffc>; entry-reg = <0xff 0xff019050>; entry-cnt = <4>; control-reg = <0xff 0xff015004>; control-val = <0x1c>; csr-copy = <0x7f3 0x7c0 0x7c1 0x7c2 0x7c3 0x7c5 0x7cc>; }; example2: (Using csr-regs for reset) reset: reset-sample { compatible = "thead,reset-sample"; plic-delegate = <0xff 0xd81ffffc>; using-csr-reset; csr-copy = <0x7c0 0x7c1 0x7c2 0x7c3 0x7c5 0x7cc 0x3b0 0x3b1 0x3b2 0x3b3 0x3b4 0x3b5 0x3b6 0x3b7 0x3a0>; }; example3: (Only delegate plic enable to S-mode) reset: reset-sample { compatible = "thead,reset-sample"; plic-delegate = <0xff 0xd81ffffc>; }; After this patch, all T-HEAD c9xx would use platform/generic with fw_dynamic as default: CROSS_COMPILE=riscv64-linux-gnu- PLATFORM=generic FW_PIC=y /usr/bin/make The platform/thead will be deprecated. Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
/*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2019 Western Digital Corporation or its affiliates.
|
|
*
|
|
* Authors:
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
*/
|
|
|
|
#ifndef __RISCV_BARRIER_H__
|
|
#define __RISCV_BARRIER_H__
|
|
|
|
/* clang-format off */
|
|
|
|
#define RISCV_ACQUIRE_BARRIER "\tfence r , rw\n"
|
|
#define RISCV_RELEASE_BARRIER "\tfence rw, w\n"
|
|
|
|
#define RISCV_FENCE(p, s) \
|
|
__asm__ __volatile__ ("fence " #p "," #s : : : "memory")
|
|
|
|
#define RISCV_FENCE_I \
|
|
__asm__ __volatile__ ("fence.i" : : : "memory")
|
|
|
|
/* Read & Write Memory barrier */
|
|
#define mb() RISCV_FENCE(iorw,iorw)
|
|
|
|
/* Read Memory barrier */
|
|
#define rmb() RISCV_FENCE(ir,ir)
|
|
|
|
/* Write Memory barrier */
|
|
#define wmb() RISCV_FENCE(ow,ow)
|
|
|
|
/* SMP Read & Write Memory barrier */
|
|
#define smp_mb() RISCV_FENCE(rw,rw)
|
|
|
|
/* SMP Read Memory barrier */
|
|
#define smp_rmb() RISCV_FENCE(r,r)
|
|
|
|
/* SMP Write Memory barrier */
|
|
#define smp_wmb() RISCV_FENCE(w,w)
|
|
|
|
/* CPU relax for busy loop */
|
|
#define cpu_relax() asm volatile ("" : : : "memory")
|
|
|
|
/* clang-format on */
|
|
|
|
#define __smp_store_release(p, v) \
|
|
do { \
|
|
RISCV_FENCE(rw, w); \
|
|
*(p) = (v); \
|
|
} while (0)
|
|
|
|
#define __smp_load_acquire(p) \
|
|
({ \
|
|
typeof(*p) ___p1 = *(p); \
|
|
RISCV_FENCE(r, rw); \
|
|
___p1; \
|
|
})
|
|
|
|
#endif
|