forked from raspberrypi/linux
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RISC-V: Add support to build the ACPI core
Enable ACPI core for RISC-V after adding architecture-specific interfaces and header files required to build the ACPI core. 1) Couple of header files are required unconditionally by the ACPI core. Add empty acenv.h and cpu.h header files. 2) If CONFIG_PCI is enabled, a few PCI related interfaces need to be provided by the architecture. Define dummy interfaces for now so that build succeeds. Actual implementation will be added when PCI support is added for ACPI along with external interrupt controller support. 3) A few globals and memory mapping related functions specific to the architecture need to be provided. Signed-off-by: Sunil V L <[email protected]> Acked-by: Rafael J. Wysocki <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Reviewed-by: Palmer Dabbelt <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
- Loading branch information
1 parent
214c236
commit a91a9ff
Showing
6 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* RISC-V specific ACPICA environments and implementation | ||
*/ | ||
|
||
#ifndef _ASM_ACENV_H | ||
#define _ASM_ACENV_H | ||
|
||
/* This header is required unconditionally by the ACPI core */ | ||
|
||
#endif /* _ASM_ACENV_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
/* | ||
* Copyright (C) 2013-2014, Linaro Ltd. | ||
* Author: Al Stone <[email protected]> | ||
* Author: Graeme Gregory <[email protected]> | ||
* Author: Hanjun Guo <[email protected]> | ||
* | ||
* Copyright (C) 2021-2023, Ventana Micro Systems Inc. | ||
* Author: Sunil V L <[email protected]> | ||
*/ | ||
|
||
#ifndef _ASM_ACPI_H | ||
#define _ASM_ACPI_H | ||
|
||
/* Basic configuration for ACPI */ | ||
#ifdef CONFIG_ACPI | ||
|
||
/* ACPI table mapping after acpi_permanent_mmap is set */ | ||
void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size); | ||
#define acpi_os_ioremap acpi_os_ioremap | ||
|
||
#define acpi_strict 1 /* No out-of-spec workarounds on RISC-V */ | ||
extern int acpi_disabled; | ||
extern int acpi_noirq; | ||
extern int acpi_pci_disabled; | ||
|
||
static inline void disable_acpi(void) | ||
{ | ||
acpi_disabled = 1; | ||
acpi_pci_disabled = 1; | ||
acpi_noirq = 1; | ||
} | ||
|
||
static inline void enable_acpi(void) | ||
{ | ||
acpi_disabled = 0; | ||
acpi_pci_disabled = 0; | ||
acpi_noirq = 0; | ||
} | ||
|
||
/* | ||
* The ACPI processor driver for ACPI core code needs this macro | ||
* to find out whether this cpu was already mapped (mapping from CPU hardware | ||
* ID to CPU logical ID) or not. | ||
*/ | ||
#define cpu_physical_id(cpu) cpuid_to_hartid_map(cpu) | ||
|
||
/* | ||
* Since MADT must provide at least one RINTC structure, the | ||
* CPU will be always available in MADT on RISC-V. | ||
*/ | ||
static inline bool acpi_has_cpu_in_madt(void) | ||
{ | ||
return true; | ||
} | ||
|
||
static inline void arch_fix_phys_package_id(int num, u32 slot) { } | ||
|
||
#endif /* CONFIG_ACPI */ | ||
|
||
#endif /*_ASM_ACPI_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* SPDX-License-Identifier: GPL-2.0-only */ | ||
|
||
#ifndef _ASM_CPU_H | ||
#define _ASM_CPU_H | ||
|
||
/* This header is required unconditionally by the ACPI core */ | ||
|
||
#endif /* _ASM_CPU_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// SPDX-License-Identifier: GPL-2.0-only | ||
/* | ||
* RISC-V Specific Low-Level ACPI Boot Support | ||
* | ||
* Copyright (C) 2013-2014, Linaro Ltd. | ||
* Author: Al Stone <[email protected]> | ||
* Author: Graeme Gregory <[email protected]> | ||
* Author: Hanjun Guo <[email protected]> | ||
* Author: Tomasz Nowicki <[email protected]> | ||
* Author: Naresh Bhat <[email protected]> | ||
* | ||
* Copyright (C) 2021-2023, Ventana Micro Systems Inc. | ||
* Author: Sunil V L <[email protected]> | ||
*/ | ||
|
||
#include <linux/acpi.h> | ||
#include <linux/io.h> | ||
#include <linux/pci.h> | ||
|
||
int acpi_noirq = 1; /* skip ACPI IRQ initialization */ | ||
int acpi_disabled = 1; | ||
EXPORT_SYMBOL(acpi_disabled); | ||
|
||
int acpi_pci_disabled = 1; /* skip ACPI PCI scan and IRQ initialization */ | ||
EXPORT_SYMBOL(acpi_pci_disabled); | ||
|
||
/* | ||
* __acpi_map_table() will be called before paging_init(), so early_ioremap() | ||
* or early_memremap() should be called here to for ACPI table mapping. | ||
*/ | ||
void __init __iomem *__acpi_map_table(unsigned long phys, unsigned long size) | ||
{ | ||
if (!size) | ||
return NULL; | ||
|
||
return early_memremap(phys, size); | ||
} | ||
|
||
void __init __acpi_unmap_table(void __iomem *map, unsigned long size) | ||
{ | ||
if (!map || !size) | ||
return; | ||
|
||
early_memunmap(map, size); | ||
} | ||
|
||
void *acpi_os_ioremap(acpi_physical_address phys, acpi_size size) | ||
{ | ||
return memremap(phys, size, MEMREMAP_WB); | ||
} | ||
|
||
#ifdef CONFIG_PCI | ||
|
||
/* | ||
* These interfaces are defined just to enable building ACPI core. | ||
* TODO: Update it with actual implementation when external interrupt | ||
* controller support is added in RISC-V ACPI. | ||
*/ | ||
int raw_pci_read(unsigned int domain, unsigned int bus, unsigned int devfn, | ||
int reg, int len, u32 *val) | ||
{ | ||
return PCIBIOS_DEVICE_NOT_FOUND; | ||
} | ||
|
||
int raw_pci_write(unsigned int domain, unsigned int bus, unsigned int devfn, | ||
int reg, int len, u32 val) | ||
{ | ||
return PCIBIOS_DEVICE_NOT_FOUND; | ||
} | ||
|
||
int acpi_pci_bus_find_domain_nr(struct pci_bus *bus) | ||
{ | ||
return -1; | ||
} | ||
|
||
struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root) | ||
{ | ||
return NULL; | ||
} | ||
#endif /* CONFIG_PCI */ |