2018-12-11 21:54:06 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018 Western Digital Corporation or its affiliates.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Anup Patel <anup.patel@wdc.com>
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __SBI_PLATFORM_H__
|
|
|
|
#define __SBI_PLATFORM_H__
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Offset of name in struct sbi_platform */
|
2018-12-31 14:00:55 +08:00
|
|
|
#define SBI_PLATFORM_NAME_OFFSET (0x0)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Offset of features in struct sbi_platform */
|
2018-12-31 14:00:55 +08:00
|
|
|
#define SBI_PLATFORM_FEATURES_OFFSET (0x40)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Offset of hart_count in struct sbi_platform */
|
2018-12-31 14:00:55 +08:00
|
|
|
#define SBI_PLATFORM_HART_COUNT_OFFSET (0x48)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Offset of hart_stack_size in struct sbi_platform */
|
2018-12-31 14:00:55 +08:00
|
|
|
#define SBI_PLATFORM_HART_STACK_SIZE_OFFSET (0x4c)
|
|
|
|
|
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
|
2018-12-11 21:54:06 +08:00
|
|
|
#include <sbi/sbi_scratch.h>
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Possible feature flags of a platform */
|
2018-12-11 21:54:06 +08:00
|
|
|
enum sbi_platform_features {
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform has MMIO based timer */
|
2018-12-21 08:13:37 +08:00
|
|
|
SBI_PLATFORM_HAS_MMIO_TIMER_VALUE = (1 << 0),
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform has HART hotplug support */
|
2018-12-21 08:13:37 +08:00
|
|
|
SBI_PLATFORM_HAS_HART_HOTPLUG = (1 << 1),
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform has PMP support */
|
2018-12-21 08:13:37 +08:00
|
|
|
SBI_PLATFORM_HAS_PMP = (1 << 2),
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform has S-mode counter enable */
|
2018-12-21 08:13:37 +08:00
|
|
|
SBI_PLATFORM_HAS_SCOUNTEREN = (1 << 3),
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform has M-mode counter enable */
|
2018-12-21 08:13:37 +08:00
|
|
|
SBI_PLATFORM_HAS_MCOUNTEREN = (1 << 4),
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform has fault delegation support */
|
2018-12-21 18:19:54 +08:00
|
|
|
SBI_PLATFORM_HAS_MFAULTS_DELEGATION = (1 << 5),
|
2018-12-11 21:54:06 +08:00
|
|
|
};
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Default feature set for a platform */
|
2018-12-21 08:13:37 +08:00
|
|
|
#define SBI_PLATFORM_DEFAULT_FEATURES \
|
|
|
|
(SBI_PLATFORM_HAS_MMIO_TIMER_VALUE | \
|
|
|
|
SBI_PLATFORM_HAS_PMP | \
|
|
|
|
SBI_PLATFORM_HAS_SCOUNTEREN | \
|
2018-12-21 18:19:54 +08:00
|
|
|
SBI_PLATFORM_HAS_MCOUNTEREN | \
|
|
|
|
SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
|
2018-12-21 08:13:37 +08:00
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Representation of a platform */
|
2018-12-11 21:54:06 +08:00
|
|
|
struct sbi_platform {
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Name of the platform */
|
2018-12-11 21:54:06 +08:00
|
|
|
char name[64];
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Supported features */
|
2018-12-11 21:54:06 +08:00
|
|
|
u64 features;
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Total number of HARTs */
|
2018-12-11 21:54:06 +08:00
|
|
|
u32 hart_count;
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Per-HART stack size for exception/interrupt handling */
|
2018-12-11 21:54:06 +08:00
|
|
|
u32 hart_stack_size;
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Mask representing the set of disabled HARTs */
|
2018-12-22 03:29:28 +08:00
|
|
|
u64 disabled_hart_mask;
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Platform early initialization */
|
2019-01-22 16:22:25 +08:00
|
|
|
int (*early_init)(bool cold_boot);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Platform final initialization */
|
2019-01-22 16:22:25 +08:00
|
|
|
int (*final_init)(bool cold_boot);
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Get number of PMP regions for given HART */
|
2018-12-26 21:19:55 +08:00
|
|
|
u32 (*pmp_region_count)(u32 hartid);
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Get PMP regions details (namely: protection, base address,
|
|
|
|
* and size) for given HART
|
|
|
|
*/
|
2018-12-26 21:19:55 +08:00
|
|
|
int (*pmp_region_info)(u32 hartid, u32 index,
|
2018-12-11 21:54:06 +08:00
|
|
|
ulong *prot, ulong *addr, ulong *log2size);
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Write a character to the platform console output */
|
2018-12-11 21:54:06 +08:00
|
|
|
void (*console_putc)(char ch);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Read a character from the platform console input */
|
2018-12-11 21:54:06 +08:00
|
|
|
char (*console_getc)(void);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Initialize the platform console */
|
2018-12-11 21:54:06 +08:00
|
|
|
int (*console_init)(void);
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Initialize the platform interrupt controller */
|
2019-01-22 17:03:41 +08:00
|
|
|
int (*irqchip_init)(bool cold_boot);
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Inject IPI to a target HART */
|
2019-01-22 16:50:59 +08:00
|
|
|
void (*ipi_inject)(u32 target_hart);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Wait for target HART to acknowledge IPI */
|
2019-01-22 16:50:59 +08:00
|
|
|
void (*ipi_sync)(u32 target_hart);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Clear IPI for a target HART */
|
2018-12-11 21:54:06 +08:00
|
|
|
void (*ipi_clear)(u32 target_hart);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Initialize IPI for given HART */
|
2019-01-22 16:50:59 +08:00
|
|
|
int (*ipi_init)(bool cold_boot);
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Get MMIO timer value */
|
2018-12-11 21:54:06 +08:00
|
|
|
u64 (*timer_value)(void);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Start MMIO timer event for a target HART */
|
2018-12-11 21:54:06 +08:00
|
|
|
void (*timer_event_start)(u32 target_hart, u64 next_event);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Stop MMIO timer event for a target HART */
|
|
|
|
void (*timer_event_stop)(u32 target_hart);
|
|
|
|
/** Initialize MMIO timer for given HART */
|
2018-12-26 21:14:54 +08:00
|
|
|
int (*timer_init)(u32 hartid, bool cold_boot);
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/** Reboot the platform */
|
2018-12-11 21:54:06 +08:00
|
|
|
int (*system_reboot)(u32 type);
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Shutdown or poweroff the platform */
|
2018-12-11 21:54:06 +08:00
|
|
|
int (*system_shutdown)(u32 type);
|
2019-01-22 01:53:23 +08:00
|
|
|
} __packed;
|
2018-12-11 21:54:06 +08:00
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Get pointer to sbi_platform for sbi_scratch pointer */
|
2018-12-21 08:13:37 +08:00
|
|
|
#define sbi_platform_ptr(__s) \
|
|
|
|
((struct sbi_platform *)((__s)->platform_addr))
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Get pointer to sbi_platform for current HART */
|
2018-12-21 08:13:37 +08:00
|
|
|
#define sbi_platform_thishart_ptr() \
|
|
|
|
((struct sbi_platform *)(sbi_scratch_thishart_ptr()->platform_addr))
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Check whether the platform supports MMIO timer */
|
2018-12-11 21:54:06 +08:00
|
|
|
#define sbi_platform_has_mmio_timer_value(__p) \
|
2018-12-21 08:13:37 +08:00
|
|
|
((__p)->features & SBI_PLATFORM_HAS_MMIO_TIMER_VALUE)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Check whether the platform supports HART hotplug */
|
2018-12-11 21:54:06 +08:00
|
|
|
#define sbi_platform_has_hart_hotplug(__p) \
|
2018-12-21 08:13:37 +08:00
|
|
|
((__p)->features & SBI_PLATFORM_HAS_HART_HOTPLUG)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Check whether the platform has PMP support */
|
2018-12-21 08:13:37 +08:00
|
|
|
#define sbi_platform_has_pmp(__p) \
|
|
|
|
((__p)->features & SBI_PLATFORM_HAS_PMP)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Check whether the platform supports scounteren CSR */
|
2018-12-21 08:13:37 +08:00
|
|
|
#define sbi_platform_has_scounteren(__p) \
|
|
|
|
((__p)->features & SBI_PLATFORM_HAS_SCOUNTEREN)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Check whether the platform supports mcounteren CSR */
|
2018-12-21 08:13:37 +08:00
|
|
|
#define sbi_platform_has_mcounteren(__p) \
|
|
|
|
((__p)->features & SBI_PLATFORM_HAS_MCOUNTEREN)
|
2019-01-22 01:53:23 +08:00
|
|
|
/** Check whether the platform supports fault delegation */
|
2018-12-21 18:19:54 +08:00
|
|
|
#define sbi_platform_has_mfaults_delegation(__p) \
|
|
|
|
((__p)->features & SBI_PLATFORM_HAS_MFAULTS_DELEGATION)
|
2018-12-11 21:54:06 +08:00
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Get name of the platform
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
*
|
|
|
|
* @return pointer to platform name on success and NULL on failure
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline const char *sbi_platform_name(struct sbi_platform *plat)
|
|
|
|
{
|
|
|
|
if (plat)
|
|
|
|
return plat->name;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Check whether the given HART is disabled
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param hartid HART ID
|
|
|
|
*
|
|
|
|
* @return TRUE if HART is disabled and FALSE otherwise
|
|
|
|
*/
|
2019-01-22 16:22:25 +08:00
|
|
|
static inline bool sbi_platform_hart_disabled(struct sbi_platform *plat,
|
|
|
|
u32 hartid)
|
2018-12-22 03:29:28 +08:00
|
|
|
{
|
|
|
|
if (plat && (plat->disabled_hart_mask & (1 << hartid)))
|
|
|
|
return 1;
|
2019-01-22 16:22:25 +08:00
|
|
|
return 0;
|
2018-12-22 03:29:28 +08:00
|
|
|
}
|
2019-01-22 01:53:23 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get total number of HARTs supported by the platform
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
*
|
|
|
|
* @return total number of HARTs
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline u32 sbi_platform_hart_count(struct sbi_platform *plat)
|
|
|
|
{
|
|
|
|
if (plat)
|
|
|
|
return plat->hart_count;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Get per-HART stack size for exception/interrupt handling
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
*
|
|
|
|
* @return stack size in bytes
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline u32 sbi_platform_hart_stack_size(struct sbi_platform *plat)
|
|
|
|
{
|
|
|
|
if (plat)
|
|
|
|
return plat->hart_stack_size;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Early initialization of a given HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-26 20:51:22 +08:00
|
|
|
static inline int sbi_platform_early_init(struct sbi_platform *plat,
|
2019-01-22 16:22:25 +08:00
|
|
|
bool cold_boot)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
2018-12-26 20:51:22 +08:00
|
|
|
if (plat && plat->early_init)
|
2019-01-22 16:22:25 +08:00
|
|
|
return plat->early_init(cold_boot);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Final initialization of a HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-26 20:51:22 +08:00
|
|
|
static inline int sbi_platform_final_init(struct sbi_platform *plat,
|
2019-01-22 16:22:25 +08:00
|
|
|
bool cold_boot)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
2018-12-26 20:51:22 +08:00
|
|
|
if (plat && plat->final_init)
|
2019-01-22 16:22:25 +08:00
|
|
|
return plat->final_init(cold_boot);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Get the number of PMP regions of a HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param hartid HART ID
|
|
|
|
*
|
|
|
|
* @return number of PMP regions
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline u32 sbi_platform_pmp_region_count(struct sbi_platform *plat,
|
2018-12-26 21:19:55 +08:00
|
|
|
u32 hartid)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
|
|
|
if (plat && plat->pmp_region_count)
|
2018-12-26 21:19:55 +08:00
|
|
|
return plat->pmp_region_count(hartid);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Get PMP regions details (namely: protection, base address,
|
|
|
|
* and size) of a HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param hartid HART ID
|
|
|
|
* @param index index of PMP region for which we want details
|
|
|
|
* @param prot output pointer for PMP region protection
|
|
|
|
* @param addr output pointer for PMP region base address
|
|
|
|
* @param log2size output pointer for log-of-2 PMP region size
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline int sbi_platform_pmp_region_info(struct sbi_platform *plat,
|
2018-12-26 21:19:55 +08:00
|
|
|
u32 hartid, u32 index,
|
2018-12-11 21:54:06 +08:00
|
|
|
ulong *prot, ulong *addr,
|
|
|
|
ulong *log2size)
|
|
|
|
{
|
|
|
|
if (plat && plat->pmp_region_info)
|
2018-12-26 21:19:55 +08:00
|
|
|
return plat->pmp_region_info(hartid, index,
|
|
|
|
prot, addr, log2size);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Write a character to the platform console output
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param ch character to write
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline void sbi_platform_console_putc(struct sbi_platform *plat,
|
|
|
|
char ch)
|
|
|
|
{
|
|
|
|
if (plat && plat->console_putc)
|
|
|
|
plat->console_putc(ch);
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Read a character from the platform console input
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
*
|
|
|
|
* @return character read from console input
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline char sbi_platform_console_getc(struct sbi_platform *plat)
|
|
|
|
{
|
|
|
|
if (plat && plat->console_getc)
|
|
|
|
return plat->console_getc();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Initialize the platform console
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline int sbi_platform_console_init(struct sbi_platform *plat)
|
|
|
|
{
|
|
|
|
if (plat && plat->console_init)
|
|
|
|
return plat->console_init();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Initialize the platform interrupt controller for given HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-26 20:57:35 +08:00
|
|
|
static inline int sbi_platform_irqchip_init(struct sbi_platform *plat,
|
2019-01-22 17:03:41 +08:00
|
|
|
bool cold_boot)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
2018-12-26 20:57:35 +08:00
|
|
|
if (plat && plat->irqchip_init)
|
2019-01-22 17:03:41 +08:00
|
|
|
return plat->irqchip_init(cold_boot);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Inject IPI to a target HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param target_hart HART ID of IPI target
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline void sbi_platform_ipi_inject(struct sbi_platform *plat,
|
2019-01-22 16:50:59 +08:00
|
|
|
u32 target_hart)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
|
|
|
if (plat && plat->ipi_inject)
|
2019-01-22 16:50:59 +08:00
|
|
|
plat->ipi_inject(target_hart);
|
2018-12-11 21:54:06 +08:00
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Wait for target HART to acknowledge IPI
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param target_hart HART ID of IPI target
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline void sbi_platform_ipi_sync(struct sbi_platform *plat,
|
2019-01-22 16:50:59 +08:00
|
|
|
u32 target_hart)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
|
|
|
if (plat && plat->ipi_sync)
|
2019-01-22 16:50:59 +08:00
|
|
|
plat->ipi_sync(target_hart);
|
2018-12-11 21:54:06 +08:00
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Clear IPI for a target HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param target_hart HART ID of IPI target
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline void sbi_platform_ipi_clear(struct sbi_platform *plat,
|
|
|
|
u32 target_hart)
|
|
|
|
{
|
|
|
|
if (plat && plat->ipi_clear)
|
|
|
|
plat->ipi_clear(target_hart);
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Initialize the platform IPI support for given HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-26 21:06:11 +08:00
|
|
|
static inline int sbi_platform_ipi_init(struct sbi_platform *plat,
|
2019-01-22 16:50:59 +08:00
|
|
|
bool cold_boot)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
2018-12-26 21:06:11 +08:00
|
|
|
if (plat && plat->ipi_init)
|
2019-01-22 16:50:59 +08:00
|
|
|
return plat->ipi_init(cold_boot);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Get MMIO timer value
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
*
|
|
|
|
* @return 64bit timer value
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline u64 sbi_platform_timer_value(struct sbi_platform *plat)
|
|
|
|
{
|
|
|
|
if (plat && plat->timer_value)
|
|
|
|
return plat->timer_value();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Start MMIO timer event for a target HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct struct sbi_platform
|
|
|
|
* @param target_hart HART ID of timer event target
|
|
|
|
* @param next_event timer value when timer event will happen
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline void sbi_platform_timer_event_start(struct sbi_platform *plat,
|
|
|
|
u32 target_hart,
|
|
|
|
u64 next_event)
|
|
|
|
{
|
|
|
|
if (plat && plat->timer_event_start)
|
|
|
|
plat->timer_event_start(target_hart, next_event);
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Stop MMIO timer event for a target HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param target_hart HART ID of timer event target
|
|
|
|
*/
|
|
|
|
static inline void sbi_platform_timer_event_stop(struct sbi_platform *plat,
|
|
|
|
u32 target_hart)
|
|
|
|
{
|
|
|
|
if (plat && plat->timer_event_stop)
|
|
|
|
plat->timer_event_stop(target_hart);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize the platform MMIO timer for given HART
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param hartid HART ID
|
|
|
|
* @param cold_boot whether cold boot (TRUE) or warm_boot (FALSE)
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-26 21:14:54 +08:00
|
|
|
static inline int sbi_platform_timer_init(struct sbi_platform *plat,
|
|
|
|
u32 hartid, bool cold_boot)
|
2018-12-11 21:54:06 +08:00
|
|
|
{
|
2018-12-26 21:14:54 +08:00
|
|
|
if (plat && plat->timer_init)
|
|
|
|
return plat->timer_init(hartid, cold_boot);
|
2018-12-11 21:54:06 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Reboot the platform
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param type type of reboot
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline int sbi_platform_system_reboot(struct sbi_platform *plat,
|
|
|
|
u32 type)
|
|
|
|
{
|
|
|
|
if (plat && plat->system_reboot)
|
|
|
|
return plat->system_reboot(type);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-01-22 01:53:23 +08:00
|
|
|
/**
|
|
|
|
* Shutdown or poweroff the platform
|
|
|
|
*
|
|
|
|
* @param plat pointer to struct sbi_platform
|
|
|
|
* @param type type of shutdown or poweroff
|
|
|
|
*
|
|
|
|
* @return 0 on success and negative error code on failure
|
|
|
|
*/
|
2018-12-11 21:54:06 +08:00
|
|
|
static inline int sbi_platform_system_shutdown(struct sbi_platform *plat,
|
|
|
|
u32 type)
|
|
|
|
{
|
|
|
|
if (plat && plat->system_shutdown)
|
|
|
|
return plat->system_shutdown(type);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2018-12-31 14:00:55 +08:00
|
|
|
|
|
|
|
#endif
|