forked from Mirrors/opensbi
		
	all: run clang-format and update checked-in files
Noisy commit, no functional changes. Generated with an current upstream clang-format and: clang-format -i $(find . -name \*.[ch]) Signed-off-by: Olof Johansson <olof@lixom.net>
This commit is contained in:
		
				
					committed by
					
						
						Anup Patel
					
				
			
			
				
	
			
			
			
						parent
						
							fbf986ac2a
						
					
				
				
					commit
					10baa64c02
				
			@@ -14,10 +14,8 @@
 | 
			
		||||
 | 
			
		||||
void plic_fdt_fixup(void *fdt, const char *compat);
 | 
			
		||||
 | 
			
		||||
int plic_warm_irqchip_init(u32 target_hart,
 | 
			
		||||
			   int m_cntx_id, int s_cntx_id);
 | 
			
		||||
int plic_warm_irqchip_init(u32 target_hart, int m_cntx_id, int s_cntx_id);
 | 
			
		||||
 | 
			
		||||
int plic_cold_irqchip_init(unsigned long base,
 | 
			
		||||
			   u32 num_sources, u32 hart_count);
 | 
			
		||||
int plic_cold_irqchip_init(unsigned long base, u32 num_sources, u32 hart_count);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,6 @@ void sifive_uart_putc(char ch);
 | 
			
		||||
 | 
			
		||||
int sifive_uart_getc(void);
 | 
			
		||||
 | 
			
		||||
int sifive_uart_init(unsigned long base,
 | 
			
		||||
		     u32 in_freq, u32 baudrate);
 | 
			
		||||
int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,7 @@ void uart8250_putc(char ch);
 | 
			
		||||
 | 
			
		||||
int uart8250_getc(void);
 | 
			
		||||
 | 
			
		||||
int uart8250_init(unsigned long base,
 | 
			
		||||
		  u32 in_freq, u32 baudrate,
 | 
			
		||||
		  u32 reg_shift, u32 reg_width);
 | 
			
		||||
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
 | 
			
		||||
		  u32 reg_width);
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,7 @@ size_t strlen(const char *str);
 | 
			
		||||
 | 
			
		||||
size_t strnlen(const char *str, size_t count);
 | 
			
		||||
 | 
			
		||||
char *strcpy(char *dest,const char *src);
 | 
			
		||||
char *strcpy(char *dest, const char *src);
 | 
			
		||||
 | 
			
		||||
char *strncpy(char *dest, const char *src, size_t count);
 | 
			
		||||
 | 
			
		||||
@@ -26,13 +26,13 @@ char *strchr(const char *s, int c);
 | 
			
		||||
 | 
			
		||||
char *strrchr(const char *s, int c);
 | 
			
		||||
 | 
			
		||||
void *memset(void *s,int c,size_t count);
 | 
			
		||||
void *memset(void *s, int c, size_t count);
 | 
			
		||||
 | 
			
		||||
void *memcpy(void *dest, const void *src, size_t count);
 | 
			
		||||
 | 
			
		||||
void *memmove(void *dest,const void *src, size_t count);
 | 
			
		||||
void *memmove(void *dest, const void *src, size_t count);
 | 
			
		||||
 | 
			
		||||
int memcmp(const void *s1,const void *s2, size_t count);
 | 
			
		||||
int memcmp(const void *s1, const void *s2, size_t count);
 | 
			
		||||
 | 
			
		||||
void *memchr(const void *s, int c, size_t count);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -38,33 +38,27 @@ ulong fdt_strlen(const char *str);
 | 
			
		||||
int fdt_strcmp(const char *a, const char *b);
 | 
			
		||||
 | 
			
		||||
/* Find index of matching string from a list of strings */
 | 
			
		||||
int fdt_prop_string_index(const struct fdt_prop *prop,
 | 
			
		||||
			      const char *str);
 | 
			
		||||
int fdt_prop_string_index(const struct fdt_prop *prop, const char *str);
 | 
			
		||||
 | 
			
		||||
/* Iterate over each property of matching node */
 | 
			
		||||
int fdt_match_node_prop(void *fdt,
 | 
			
		||||
			int (*match)(const struct fdt_node *node,
 | 
			
		||||
				     const struct fdt_prop *prop,
 | 
			
		||||
				     void *priv),
 | 
			
		||||
				     const struct fdt_prop *prop, void *priv),
 | 
			
		||||
			void *match_priv,
 | 
			
		||||
			void (*fn)(const struct fdt_node *node,
 | 
			
		||||
				   const struct fdt_prop *prop,
 | 
			
		||||
				   void *priv),
 | 
			
		||||
				   const struct fdt_prop *prop, void *priv),
 | 
			
		||||
			void *fn_priv);
 | 
			
		||||
 | 
			
		||||
/* Iterate over each property of compatible node */
 | 
			
		||||
int fdt_compat_node_prop(void *fdt,
 | 
			
		||||
			 const char *compat,
 | 
			
		||||
int fdt_compat_node_prop(void *fdt, const char *compat,
 | 
			
		||||
			 void (*fn)(const struct fdt_node *node,
 | 
			
		||||
				    const struct fdt_prop *prop,
 | 
			
		||||
				    void *priv),
 | 
			
		||||
				    const struct fdt_prop *prop, void *priv),
 | 
			
		||||
			 void *fn_priv);
 | 
			
		||||
 | 
			
		||||
/* Iterate over each node and property */
 | 
			
		||||
int fdt_walk(void *fdt,
 | 
			
		||||
	     void (*fn)(const struct fdt_node *node,
 | 
			
		||||
		 	const struct fdt_prop *prop,
 | 
			
		||||
			void *priv),
 | 
			
		||||
			const struct fdt_prop *prop, void *priv),
 | 
			
		||||
	     void *fn_priv);
 | 
			
		||||
 | 
			
		||||
/* Get size of FDT */
 | 
			
		||||
 
 | 
			
		||||
@@ -14,12 +14,12 @@
 | 
			
		||||
#include <plat/tinyfdt.h>
 | 
			
		||||
#include <plat/irqchip/plic.h>
 | 
			
		||||
 | 
			
		||||
#define PLIC_PRIORITY_BASE		0x0
 | 
			
		||||
#define PLIC_PENDING_BASE		0x1000
 | 
			
		||||
#define PLIC_ENABLE_BASE		0x2000
 | 
			
		||||
#define PLIC_ENABLE_STRIDE		0x80
 | 
			
		||||
#define PLIC_CONTEXT_BASE		0x200000
 | 
			
		||||
#define PLIC_CONTEXT_STRIDE		0x1000
 | 
			
		||||
#define PLIC_PRIORITY_BASE 0x0
 | 
			
		||||
#define PLIC_PENDING_BASE 0x1000
 | 
			
		||||
#define PLIC_ENABLE_BASE 0x2000
 | 
			
		||||
#define PLIC_ENABLE_STRIDE 0x80
 | 
			
		||||
#define PLIC_CONTEXT_BASE 0x200000
 | 
			
		||||
#define PLIC_CONTEXT_STRIDE 0x1000
 | 
			
		||||
 | 
			
		||||
static u32 plic_hart_count;
 | 
			
		||||
static u32 plic_num_sources;
 | 
			
		||||
@@ -27,31 +27,27 @@ static volatile void *plic_base;
 | 
			
		||||
 | 
			
		||||
static void plic_set_priority(u32 source, u32 val)
 | 
			
		||||
{
 | 
			
		||||
	volatile void *plic_priority = plic_base +
 | 
			
		||||
				PLIC_PRIORITY_BASE +
 | 
			
		||||
				4 * source;
 | 
			
		||||
	volatile void *plic_priority =
 | 
			
		||||
		plic_base + PLIC_PRIORITY_BASE + 4 * source;
 | 
			
		||||
	writel(val, plic_priority);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void plic_set_thresh(u32 cntxid, u32 val)
 | 
			
		||||
{
 | 
			
		||||
	volatile void *plic_thresh = plic_base +
 | 
			
		||||
				PLIC_CONTEXT_BASE +
 | 
			
		||||
				PLIC_CONTEXT_STRIDE * cntxid;
 | 
			
		||||
	volatile void *plic_thresh =
 | 
			
		||||
		plic_base + PLIC_CONTEXT_BASE + PLIC_CONTEXT_STRIDE * cntxid;
 | 
			
		||||
	writel(val, plic_thresh);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void plic_set_ie(u32 cntxid, u32 word_index, u32 val)
 | 
			
		||||
{
 | 
			
		||||
	volatile void *plic_ie = plic_base +
 | 
			
		||||
				PLIC_ENABLE_BASE +
 | 
			
		||||
				PLIC_ENABLE_STRIDE * cntxid;
 | 
			
		||||
	volatile void *plic_ie =
 | 
			
		||||
		plic_base + PLIC_ENABLE_BASE + PLIC_ENABLE_STRIDE * cntxid;
 | 
			
		||||
	writel(val, plic_ie + word_index * 4);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void plic_fdt_fixup_prop(const struct fdt_node *node,
 | 
			
		||||
				const struct fdt_prop *prop,
 | 
			
		||||
				void *priv)
 | 
			
		||||
				const struct fdt_prop *prop, void *priv)
 | 
			
		||||
{
 | 
			
		||||
	u32 *cells;
 | 
			
		||||
	u32 i, cells_count;
 | 
			
		||||
@@ -61,15 +57,15 @@ static void plic_fdt_fixup_prop(const struct fdt_node *node,
 | 
			
		||||
	if (strcmp(prop->name, "interrupts-extended"))
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	cells = prop->value;
 | 
			
		||||
	cells	    = prop->value;
 | 
			
		||||
	cells_count = prop->len / sizeof(u32);
 | 
			
		||||
 | 
			
		||||
	if (!cells_count)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < (cells_count/2); i++) {
 | 
			
		||||
		if (fdt_rev32(cells[2*i+1]) == IRQ_M_EXT)
 | 
			
		||||
			cells[2*i+1] = fdt_rev32(0xffffffff);
 | 
			
		||||
	for (i = 0; i < (cells_count / 2); i++) {
 | 
			
		||||
		if (fdt_rev32(cells[2 * i + 1]) == IRQ_M_EXT)
 | 
			
		||||
			cells[2 * i + 1] = fdt_rev32(0xffffffff);
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -78,14 +74,13 @@ void plic_fdt_fixup(void *fdt, const char *compat)
 | 
			
		||||
	fdt_compat_node_prop(fdt, compat, plic_fdt_fixup_prop, NULL);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int plic_warm_irqchip_init(u32 target_hart,
 | 
			
		||||
			   int m_cntx_id, int s_cntx_id)
 | 
			
		||||
int plic_warm_irqchip_init(u32 target_hart, int m_cntx_id, int s_cntx_id)
 | 
			
		||||
{
 | 
			
		||||
	size_t i, ie_words = plic_num_sources / 32 + 1;
 | 
			
		||||
 | 
			
		||||
	if (plic_hart_count <= target_hart)
 | 
			
		||||
		return -1;
 | 
			
		||||
	
 | 
			
		||||
 | 
			
		||||
	/* By default, disable all IRQs for M-mode of target HART */
 | 
			
		||||
	if (m_cntx_id > -1) {
 | 
			
		||||
		for (i = 0; i < ie_words; i++)
 | 
			
		||||
@@ -109,14 +104,13 @@ int plic_warm_irqchip_init(u32 target_hart,
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int plic_cold_irqchip_init(unsigned long base,
 | 
			
		||||
			   u32 num_sources, u32 hart_count)
 | 
			
		||||
int plic_cold_irqchip_init(unsigned long base, u32 num_sources, u32 hart_count)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	plic_hart_count = hart_count;
 | 
			
		||||
	plic_hart_count	 = hart_count;
 | 
			
		||||
	plic_num_sources = num_sources;
 | 
			
		||||
	plic_base = (void *)base;
 | 
			
		||||
	plic_base	 = (void *)base;
 | 
			
		||||
 | 
			
		||||
	/* Configure default priorities of all IRQs */
 | 
			
		||||
	for (i = 1; i <= plic_num_sources; i++)
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,8 @@
 | 
			
		||||
int strcmp(const char *a, const char *b)
 | 
			
		||||
{
 | 
			
		||||
	/* search first diff or end of string */
 | 
			
		||||
	for (; *a == *b && *a != '\0'; a++, b++);
 | 
			
		||||
	for (; *a == *b && *a != '\0'; a++, b++)
 | 
			
		||||
		;
 | 
			
		||||
 | 
			
		||||
	return *a - *b;
 | 
			
		||||
}
 | 
			
		||||
@@ -51,7 +52,7 @@ char *strcpy(char *dest, const char *src)
 | 
			
		||||
{
 | 
			
		||||
	char *ret = dest;
 | 
			
		||||
 | 
			
		||||
	while(*src != '\0') {
 | 
			
		||||
	while (*src != '\0') {
 | 
			
		||||
		*dest++ = *src++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -62,7 +63,7 @@ char *strncpy(char *dest, const char *src, size_t count)
 | 
			
		||||
{
 | 
			
		||||
	char *ret = dest;
 | 
			
		||||
 | 
			
		||||
	while(count-- && *src != '\0') {
 | 
			
		||||
	while (count-- && *src != '\0') {
 | 
			
		||||
		*dest++ = *src++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@@ -71,7 +72,7 @@ char *strncpy(char *dest, const char *src, size_t count)
 | 
			
		||||
 | 
			
		||||
char *strchr(const char *s, int c)
 | 
			
		||||
{
 | 
			
		||||
	while(*s != '\0' && *s != (char)c)
 | 
			
		||||
	while (*s != '\0' && *s != (char)c)
 | 
			
		||||
		s++;
 | 
			
		||||
 | 
			
		||||
	if (*s == '\0')
 | 
			
		||||
@@ -96,7 +97,7 @@ void *memset(void *s, int c, size_t count)
 | 
			
		||||
{
 | 
			
		||||
	char *temp = s;
 | 
			
		||||
 | 
			
		||||
	while(count > 0 ){
 | 
			
		||||
	while (count > 0) {
 | 
			
		||||
		count--;
 | 
			
		||||
		*temp++ = c;
 | 
			
		||||
	}
 | 
			
		||||
@@ -106,7 +107,7 @@ void *memset(void *s, int c, size_t count)
 | 
			
		||||
 | 
			
		||||
void *memcpy(void *dest, const void *src, size_t count)
 | 
			
		||||
{
 | 
			
		||||
	char *temp1 = dest;
 | 
			
		||||
	char *temp1	  = dest;
 | 
			
		||||
	const char *temp2 = src;
 | 
			
		||||
 | 
			
		||||
	while (count > 0) {
 | 
			
		||||
@@ -119,14 +120,14 @@ void *memcpy(void *dest, const void *src, size_t count)
 | 
			
		||||
 | 
			
		||||
void *memmove(void *dest, const void *src, size_t count)
 | 
			
		||||
{
 | 
			
		||||
	char *temp1 = (char *)dest;
 | 
			
		||||
	char *temp1	  = (char *)dest;
 | 
			
		||||
	const char *temp2 = (char *)src;
 | 
			
		||||
 | 
			
		||||
	if (src == dest)
 | 
			
		||||
		return dest;
 | 
			
		||||
 | 
			
		||||
	if (dest < src) {
 | 
			
		||||
		while(count > 0) {
 | 
			
		||||
		while (count > 0) {
 | 
			
		||||
			*temp1++ = *temp2++;
 | 
			
		||||
			count--;
 | 
			
		||||
		}
 | 
			
		||||
@@ -134,7 +135,7 @@ void *memmove(void *dest, const void *src, size_t count)
 | 
			
		||||
		temp1 = dest + count - 1;
 | 
			
		||||
		temp2 = src + count - 1;
 | 
			
		||||
 | 
			
		||||
		while(count > 0) {
 | 
			
		||||
		while (count > 0) {
 | 
			
		||||
			*temp1-- = *temp2--;
 | 
			
		||||
			count--;
 | 
			
		||||
		}
 | 
			
		||||
@@ -165,7 +166,7 @@ void *memchr(const void *s, int c, size_t count)
 | 
			
		||||
 | 
			
		||||
	while (count > 0) {
 | 
			
		||||
		if ((unsigned char)c == *temp++) {
 | 
			
		||||
			return (void *)(temp-1);
 | 
			
		||||
			return (void *)(temp - 1);
 | 
			
		||||
		}
 | 
			
		||||
		count--;
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
@@ -51,8 +51,8 @@
 | 
			
		||||
 *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <libfdt_env.h>
 | 
			
		||||
#include <fdt.h>
 | 
			
		||||
#include <libfdt_env.h>
 | 
			
		||||
 | 
			
		||||
#define FDT_FIRST_SUPPORTED_VERSION	0x02
 | 
			
		||||
#define FDT_LAST_SUPPORTED_VERSION	0x11
 | 
			
		||||
 
 | 
			
		||||
@@ -52,8 +52,8 @@
 | 
			
		||||
 *     EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
#include <sbi/sbi_types.h>
 | 
			
		||||
#include <plat/string.h>
 | 
			
		||||
#include <sbi/sbi_types.h>
 | 
			
		||||
 | 
			
		||||
#define INT_MAX		((int)(~0U >> 1))
 | 
			
		||||
#define UINT_MAX	((unsigned int)~0U)
 | 
			
		||||
 
 | 
			
		||||
@@ -68,7 +68,8 @@ static void set_reg(u32 num, u32 val)
 | 
			
		||||
 | 
			
		||||
void sifive_uart_putc(char ch)
 | 
			
		||||
{
 | 
			
		||||
	while (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL);
 | 
			
		||||
	while (get_reg(UART_REG_TXFIFO) & UART_TXFIFO_FULL)
 | 
			
		||||
		;
 | 
			
		||||
 | 
			
		||||
	set_reg(UART_REG_TXFIFO, ch);
 | 
			
		||||
}
 | 
			
		||||
@@ -81,11 +82,10 @@ int sifive_uart_getc(void)
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int sifive_uart_init(unsigned long base,
 | 
			
		||||
		     u32 in_freq, u32 baudrate)
 | 
			
		||||
int sifive_uart_init(unsigned long base, u32 in_freq, u32 baudrate)
 | 
			
		||||
{
 | 
			
		||||
	uart_base = (volatile void *)base;
 | 
			
		||||
	uart_in_freq = in_freq;
 | 
			
		||||
	uart_base     = (volatile void *)base;
 | 
			
		||||
	uart_in_freq  = in_freq;
 | 
			
		||||
	uart_baudrate = baudrate;
 | 
			
		||||
 | 
			
		||||
	/* Configure baudrate */
 | 
			
		||||
 
 | 
			
		||||
@@ -70,7 +70,8 @@ static void set_reg(u32 num, u32 val)
 | 
			
		||||
 | 
			
		||||
void uart8250_putc(char ch)
 | 
			
		||||
{
 | 
			
		||||
	while ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0);
 | 
			
		||||
	while ((get_reg(UART_LSR_OFFSET) & UART_LSR_THRE) == 0)
 | 
			
		||||
		;
 | 
			
		||||
 | 
			
		||||
	set_reg(UART_THR_OFFSET, ch);
 | 
			
		||||
}
 | 
			
		||||
@@ -82,17 +83,16 @@ int uart8250_getc(void)
 | 
			
		||||
	return -1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int uart8250_init(unsigned long base,
 | 
			
		||||
		  u32 in_freq, u32 baudrate,
 | 
			
		||||
		  u32 reg_shift, u32 reg_width)
 | 
			
		||||
int uart8250_init(unsigned long base, u32 in_freq, u32 baudrate, u32 reg_shift,
 | 
			
		||||
		  u32 reg_width)
 | 
			
		||||
{
 | 
			
		||||
	u16 bdiv;
 | 
			
		||||
 | 
			
		||||
	uart8250_base = (volatile void *)base;
 | 
			
		||||
	uart8250_base	   = (volatile void *)base;
 | 
			
		||||
	uart8250_reg_shift = reg_shift;
 | 
			
		||||
	uart8250_reg_width = reg_width;
 | 
			
		||||
	uart8250_in_freq = in_freq;
 | 
			
		||||
	uart8250_baudrate = baudrate;
 | 
			
		||||
	uart8250_in_freq   = in_freq;
 | 
			
		||||
	uart8250_baudrate  = baudrate;
 | 
			
		||||
 | 
			
		||||
	bdiv = uart8250_in_freq / (16 * uart8250_baudrate);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -74,8 +74,8 @@ int clint_cold_ipi_init(unsigned long base, u32 hart_count)
 | 
			
		||||
{
 | 
			
		||||
	/* Figure-out CLINT IPI register address */
 | 
			
		||||
	clint_ipi_hart_count = hart_count;
 | 
			
		||||
	clint_ipi_base = (void *)base;
 | 
			
		||||
	clint_ipi = (u32 *)clint_ipi_base;
 | 
			
		||||
	clint_ipi_base	     = (void *)base;
 | 
			
		||||
	clint_ipi	     = (u32 *)clint_ipi_base;
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -105,7 +105,7 @@ void clint_timer_event_stop(void)
 | 
			
		||||
	if (clint_time_hart_count <= target_hart)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* Clear CLINT Time Compare */
 | 
			
		||||
		/* Clear CLINT Time Compare */
 | 
			
		||||
#if __riscv_xlen == 64
 | 
			
		||||
	writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]);
 | 
			
		||||
#else
 | 
			
		||||
@@ -121,13 +121,14 @@ void clint_timer_event_start(u64 next_event)
 | 
			
		||||
	if (clint_time_hart_count <= target_hart)
 | 
			
		||||
		return;
 | 
			
		||||
 | 
			
		||||
	/* Program CLINT Time Compare */
 | 
			
		||||
		/* Program CLINT Time Compare */
 | 
			
		||||
#if __riscv_xlen == 64
 | 
			
		||||
	writeq_relaxed(next_event, &clint_time_cmp[target_hart]);
 | 
			
		||||
#else
 | 
			
		||||
	u32 mask = -1UL;
 | 
			
		||||
	writel_relaxed(next_event & mask, &clint_time_cmp[target_hart]);
 | 
			
		||||
	writel_relaxed(next_event >> 32, (void *)(&clint_time_cmp[target_hart]) + 0x04);
 | 
			
		||||
	writel_relaxed(next_event >> 32,
 | 
			
		||||
		       (void *)(&clint_time_cmp[target_hart]) + 0x04);
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -135,11 +136,10 @@ int clint_warm_timer_init(void)
 | 
			
		||||
{
 | 
			
		||||
	u32 target_hart = sbi_current_hartid();
 | 
			
		||||
 | 
			
		||||
	if (clint_time_hart_count <= target_hart ||
 | 
			
		||||
	    !clint_time_base)
 | 
			
		||||
	if (clint_time_hart_count <= target_hart || !clint_time_base)
 | 
			
		||||
		return -1;
 | 
			
		||||
 | 
			
		||||
	/* Clear CLINT Time Compare */
 | 
			
		||||
		/* Clear CLINT Time Compare */
 | 
			
		||||
#if __riscv_xlen == 64
 | 
			
		||||
	writeq_relaxed(-1ULL, &clint_time_cmp[target_hart]);
 | 
			
		||||
#else
 | 
			
		||||
@@ -154,9 +154,9 @@ int clint_cold_timer_init(unsigned long base, u32 hart_count)
 | 
			
		||||
{
 | 
			
		||||
	/* Figure-out CLINT Time register address */
 | 
			
		||||
	clint_time_hart_count = hart_count;
 | 
			
		||||
	clint_time_base = (void *)base;
 | 
			
		||||
	clint_time_val = (u64 *)(clint_time_base + 0xbff8);
 | 
			
		||||
	clint_time_cmp = (u64 *)(clint_time_base + 0x4000);
 | 
			
		||||
	clint_time_base	      = (void *)base;
 | 
			
		||||
	clint_time_val	      = (u64 *)(clint_time_base + 0xbff8);
 | 
			
		||||
	clint_time_cmp	      = (u64 *)(clint_time_base + 0x4000);
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -10,8 +10,8 @@
 | 
			
		||||
#include <plat/string.h>
 | 
			
		||||
#include <plat/tinyfdt.h>
 | 
			
		||||
 | 
			
		||||
#define FDT_MAGIC	0xd00dfeed
 | 
			
		||||
#define FDT_VERSION	17
 | 
			
		||||
#define FDT_MAGIC 0xd00dfeed
 | 
			
		||||
#define FDT_VERSION 17
 | 
			
		||||
 | 
			
		||||
struct fdt_header {
 | 
			
		||||
	u32 magic;
 | 
			
		||||
@@ -26,28 +26,25 @@ struct fdt_header {
 | 
			
		||||
	u32 size_dt_struct;
 | 
			
		||||
} __attribute__((packed));
 | 
			
		||||
 | 
			
		||||
#define FDT_BEGIN_NODE	1
 | 
			
		||||
#define FDT_END_NODE	2
 | 
			
		||||
#define FDT_PROP	3
 | 
			
		||||
#define FDT_NOP		4
 | 
			
		||||
#define FDT_END		9
 | 
			
		||||
#define FDT_BEGIN_NODE 1
 | 
			
		||||
#define FDT_END_NODE 2
 | 
			
		||||
#define FDT_PROP 3
 | 
			
		||||
#define FDT_NOP 4
 | 
			
		||||
#define FDT_END 9
 | 
			
		||||
 | 
			
		||||
u32 fdt_rev32(u32 v)
 | 
			
		||||
{
 | 
			
		||||
	return ((v & 0x000000FF) << 24) |
 | 
			
		||||
	       ((v & 0x0000FF00) << 8) |
 | 
			
		||||
	       ((v & 0x00FF0000) >> 8) |
 | 
			
		||||
	       ((v & 0xFF000000) >> 24);
 | 
			
		||||
	return ((v & 0x000000FF) << 24) | ((v & 0x0000FF00) << 8) |
 | 
			
		||||
	       ((v & 0x00FF0000) >> 8) | ((v & 0xFF000000) >> 24);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int fdt_prop_string_index(const struct fdt_prop *prop,
 | 
			
		||||
			  const char *str)
 | 
			
		||||
int fdt_prop_string_index(const struct fdt_prop *prop, const char *str)
 | 
			
		||||
{
 | 
			
		||||
	int i;
 | 
			
		||||
	ulong l = 0;
 | 
			
		||||
	const char *p, *end;
 | 
			
		||||
 | 
			
		||||
	p = prop->value;
 | 
			
		||||
	p   = prop->value;
 | 
			
		||||
	end = p + prop->len;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; p < end; i++, p += l) {
 | 
			
		||||
@@ -62,14 +59,13 @@ int fdt_prop_string_index(const struct fdt_prop *prop,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct recursive_iter_info {
 | 
			
		||||
	void (*fn)(const struct fdt_node *node,
 | 
			
		||||
		   const struct fdt_prop *prop,
 | 
			
		||||
	void (*fn)(const struct fdt_node *node, const struct fdt_prop *prop,
 | 
			
		||||
		   void *priv);
 | 
			
		||||
	void *fn_priv;
 | 
			
		||||
	const char *str;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#define DATA32(ptr)	fdt_rev32(*((u32*)ptr))
 | 
			
		||||
#define DATA32(ptr) fdt_rev32(*((u32 *)ptr))
 | 
			
		||||
 | 
			
		||||
static void recursive_iter(char **data, struct recursive_iter_info *info,
 | 
			
		||||
			   const struct fdt_node *parent)
 | 
			
		||||
@@ -85,7 +81,7 @@ static void recursive_iter(char **data, struct recursive_iter_info *info,
 | 
			
		||||
	(*data) += sizeof(u32);
 | 
			
		||||
 | 
			
		||||
	node.parent = parent;
 | 
			
		||||
	node.name = *data;
 | 
			
		||||
	node.name   = *data;
 | 
			
		||||
 | 
			
		||||
	*data += strlen(*data) + 1;
 | 
			
		||||
	while ((ulong)(*data) % sizeof(u32) != 0)
 | 
			
		||||
@@ -95,7 +91,7 @@ static void recursive_iter(char **data, struct recursive_iter_info *info,
 | 
			
		||||
 | 
			
		||||
	/* Default cell counts, as per the FDT spec */
 | 
			
		||||
	node.address_cells = 2;
 | 
			
		||||
	node.size_cells = 1;
 | 
			
		||||
	node.size_cells	   = 1;
 | 
			
		||||
 | 
			
		||||
	info->fn(&node, NULL, info->fn_priv);
 | 
			
		||||
 | 
			
		||||
@@ -129,19 +125,16 @@ static void recursive_iter(char **data, struct recursive_iter_info *info,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct match_iter_info {
 | 
			
		||||
	int (*match)(const struct fdt_node *node,
 | 
			
		||||
		     const struct fdt_prop *prop,
 | 
			
		||||
	int (*match)(const struct fdt_node *node, const struct fdt_prop *prop,
 | 
			
		||||
		     void *priv);
 | 
			
		||||
	void *match_priv;
 | 
			
		||||
	void (*fn)(const struct fdt_node *node,
 | 
			
		||||
		   const struct fdt_prop *prop,
 | 
			
		||||
	void (*fn)(const struct fdt_node *node, const struct fdt_prop *prop,
 | 
			
		||||
		   void *priv);
 | 
			
		||||
	void *fn_priv;
 | 
			
		||||
	const char *str;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static void match_iter(const struct fdt_node *node,
 | 
			
		||||
		       const struct fdt_prop *prop,
 | 
			
		||||
static void match_iter(const struct fdt_node *node, const struct fdt_prop *prop,
 | 
			
		||||
		       void *priv)
 | 
			
		||||
{
 | 
			
		||||
	char *data;
 | 
			
		||||
@@ -185,12 +178,10 @@ static void match_iter(const struct fdt_node *node,
 | 
			
		||||
 | 
			
		||||
int fdt_match_node_prop(void *fdt,
 | 
			
		||||
			int (*match)(const struct fdt_node *node,
 | 
			
		||||
				     const struct fdt_prop *prop,
 | 
			
		||||
				     void *priv),
 | 
			
		||||
				     const struct fdt_prop *prop, void *priv),
 | 
			
		||||
			void *match_priv,
 | 
			
		||||
			void (*fn)(const struct fdt_node *node,
 | 
			
		||||
				   const struct fdt_prop *prop,
 | 
			
		||||
				   void *priv),
 | 
			
		||||
				   const struct fdt_prop *prop, void *priv),
 | 
			
		||||
			void *fn_priv)
 | 
			
		||||
{
 | 
			
		||||
	char *data;
 | 
			
		||||
@@ -201,23 +192,23 @@ int fdt_match_node_prop(void *fdt,
 | 
			
		||||
 | 
			
		||||
	if (!fdt || !match)
 | 
			
		||||
		return -1;
 | 
			
		||||
 
 | 
			
		||||
 | 
			
		||||
	header = fdt;
 | 
			
		||||
	if (fdt_rev32(header->magic) != FDT_MAGIC ||
 | 
			
		||||
	    fdt_rev32(header->last_comp_version) > FDT_VERSION)
 | 
			
		||||
		return -1;
 | 
			
		||||
	string_offset = fdt_rev32(header->off_dt_strings);
 | 
			
		||||
	data_offset = fdt_rev32(header->off_dt_struct);
 | 
			
		||||
	data_offset   = fdt_rev32(header->off_dt_struct);
 | 
			
		||||
 | 
			
		||||
	minfo.match = match;
 | 
			
		||||
	minfo.match	 = match;
 | 
			
		||||
	minfo.match_priv = match_priv;
 | 
			
		||||
	minfo.fn = fn;
 | 
			
		||||
	minfo.fn_priv = fn_priv;
 | 
			
		||||
	minfo.str = (const char *)(fdt + string_offset);
 | 
			
		||||
	minfo.fn	 = fn;
 | 
			
		||||
	minfo.fn_priv	 = fn_priv;
 | 
			
		||||
	minfo.str	 = (const char *)(fdt + string_offset);
 | 
			
		||||
 | 
			
		||||
	rinfo.fn = match_iter;
 | 
			
		||||
	rinfo.fn      = match_iter;
 | 
			
		||||
	rinfo.fn_priv = &minfo;
 | 
			
		||||
	rinfo.str = minfo.str;
 | 
			
		||||
	rinfo.str     = minfo.str;
 | 
			
		||||
 | 
			
		||||
	data = (char *)(fdt + data_offset);
 | 
			
		||||
	recursive_iter(&data, &rinfo, NULL);
 | 
			
		||||
@@ -230,8 +221,7 @@ struct match_compat_info {
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
static int match_compat(const struct fdt_node *node,
 | 
			
		||||
			const struct fdt_prop *prop,
 | 
			
		||||
			void *priv)
 | 
			
		||||
			const struct fdt_prop *prop, void *priv)
 | 
			
		||||
{
 | 
			
		||||
	struct match_compat_info *cinfo = priv;
 | 
			
		||||
 | 
			
		||||
@@ -247,21 +237,17 @@ static int match_compat(const struct fdt_node *node,
 | 
			
		||||
	return 1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int fdt_compat_node_prop(void *fdt,
 | 
			
		||||
			 const char *compat,
 | 
			
		||||
int fdt_compat_node_prop(void *fdt, const char *compat,
 | 
			
		||||
			 void (*fn)(const struct fdt_node *node,
 | 
			
		||||
				    const struct fdt_prop *prop,
 | 
			
		||||
				    void *priv),
 | 
			
		||||
				    const struct fdt_prop *prop, void *priv),
 | 
			
		||||
			 void *fn_priv)
 | 
			
		||||
{
 | 
			
		||||
	struct match_compat_info cinfo = { .compat = compat };
 | 
			
		||||
 | 
			
		||||
	return fdt_match_node_prop(fdt, match_compat, &cinfo,
 | 
			
		||||
				       fn, fn_priv);
 | 
			
		||||
	return fdt_match_node_prop(fdt, match_compat, &cinfo, fn, fn_priv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static int match_walk(const struct fdt_node *node,
 | 
			
		||||
		      const struct fdt_prop *prop,
 | 
			
		||||
static int match_walk(const struct fdt_node *node, const struct fdt_prop *prop,
 | 
			
		||||
		      void *priv)
 | 
			
		||||
{
 | 
			
		||||
	if (!prop)
 | 
			
		||||
@@ -272,12 +258,10 @@ static int match_walk(const struct fdt_node *node,
 | 
			
		||||
 | 
			
		||||
int fdt_walk(void *fdt,
 | 
			
		||||
	     void (*fn)(const struct fdt_node *node,
 | 
			
		||||
			const struct fdt_prop *prop,
 | 
			
		||||
			void *priv),
 | 
			
		||||
			const struct fdt_prop *prop, void *priv),
 | 
			
		||||
	     void *fn_priv)
 | 
			
		||||
{
 | 
			
		||||
	return fdt_match_node_prop(fdt, match_walk, NULL,
 | 
			
		||||
				       fn, fn_priv);
 | 
			
		||||
	return fdt_match_node_prop(fdt, match_walk, NULL, fn, fn_priv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
u32 fdt_size(void *fdt)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user