Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(kernel-rolling) arch: Add LoongArch Old BPI (old-world firmware interface) support #179

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions arch/loongarch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ config LOONGARCH
select ARCH_HAS_KCOV
select ARCH_HAS_NMI_SAFE_THIS_CPU_OPS
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
select ARCH_HAS_PHYS_TO_DMA
select ARCH_HAS_PTE_SPECIAL
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
select ARCH_INLINE_READ_LOCK if !PREEMPTION
Expand Down
16 changes: 10 additions & 6 deletions arch/loongarch/configs/deepin_loongarch_desktop_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ CONFIG_KEXEC=y
CONFIG_CRASH_DUMP=y
CONFIG_HZ_1000=y
CONFIG_16KB_3LEVEL=y
CONFIG_NR_CPUS=256
CONFIG_NUMA=y
CONFIG_ARCH_FORCE_MAX_ORDER=12
CONFIG_ARCH_IOREMAP=y
Expand Down Expand Up @@ -598,7 +599,7 @@ CONFIG_BATMAN_ADV_TRACING=y
CONFIG_OPENVSWITCH=m
CONFIG_VSOCKETS=m
CONFIG_VIRTIO_VSOCKETS=m
CONFIG_NETLINK_DIAG=m
CONFIG_NETLINK_DIAG=y
CONFIG_MPLS_ROUTING=m
CONFIG_MPLS_IPTUNNEL=m
CONFIG_HSR=m
Expand Down Expand Up @@ -715,6 +716,7 @@ CONFIG_NFC_S3FWRN82_UART=m
CONFIG_NFC_ST95HF=m
CONFIG_PAGE_POOL_STATS=y
CONFIG_PCIEAER=y
# CONFIG_PCIEASPM is not set
CONFIG_PCIE_DPC=y
CONFIG_PCIE_PTM=y
CONFIG_PCIE_EDR=y
Expand Down Expand Up @@ -878,7 +880,7 @@ CONFIG_ZRAM_MEMORY_TRACKING=y
CONFIG_BLK_DEV_LOOP=y
CONFIG_BLK_DEV_DRBD=m
CONFIG_BLK_DEV_NBD=m
CONFIG_BLK_DEV_RAM=m
CONFIG_BLK_DEV_RAM=y
CONFIG_ATA_OVER_ETH=m
CONFIG_VIRTIO_BLK=y
CONFIG_BLK_DEV_RBD=m
Expand Down Expand Up @@ -950,7 +952,7 @@ CONFIG_GP_PCI1XXXX=m
CONFIG_BLK_DEV_SD=y
CONFIG_CHR_DEV_ST=m
CONFIG_BLK_DEV_SR=m
CONFIG_CHR_DEV_SG=m
CONFIG_CHR_DEV_SG=y
CONFIG_CHR_DEV_SCH=m
CONFIG_SCSI_ENCLOSURE=m
CONFIG_SCSI_CONSTANTS=y
Expand Down Expand Up @@ -3710,6 +3712,7 @@ CONFIG_BACKLIGHT_BD6107=m
CONFIG_BACKLIGHT_ARCXCNN=m
CONFIG_BACKLIGHT_RAVE_SP=m
CONFIG_BACKLIGHT_LED=m
# CONFIG_VGA_CONSOLE is not set
CONFIG_FRAMEBUFFER_CONSOLE_ROTATION=y
CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y
CONFIG_LOGO=y
Expand Down Expand Up @@ -4730,6 +4733,7 @@ CONFIG_RTC_DRV_DS2404=m
CONFIG_RTC_DRV_DA9052=m
CONFIG_RTC_DRV_DA9055=m
CONFIG_RTC_DRV_DA9063=m
CONFIG_RTC_DRV_EFI=y
CONFIG_RTC_DRV_STK17TA8=m
CONFIG_RTC_DRV_M48T86=m
CONFIG_RTC_DRV_M48T35=m
Expand All @@ -4744,7 +4748,7 @@ CONFIG_RTC_DRV_CADENCE=m
CONFIG_RTC_DRV_FTRTC010=m
CONFIG_RTC_DRV_PCAP=m
CONFIG_RTC_DRV_MC13XXX=m
CONFIG_RTC_DRV_LOONGSON=m
CONFIG_RTC_DRV_LOONGSON=y
CONFIG_RTC_DRV_MT6397=m
CONFIG_RTC_DRV_R7301=m
CONFIG_RTC_DRV_CPCAP=m
Expand Down Expand Up @@ -5610,11 +5614,11 @@ CONFIG_MOST_SND=m
CONFIG_PECI=m
CONFIG_HTE=y
CONFIG_VALIDATE_FS_PARSER=y
CONFIG_EXT2_FS=m
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT2_FS_POSIX_ACL=y
CONFIG_EXT2_FS_SECURITY=y
CONFIG_EXT3_FS=m
CONFIG_EXT3_FS=y
CONFIG_EXT3_FS_POSIX_ACL=y
CONFIG_EXT3_FS_SECURITY=y
CONFIG_EXT4_FS=y
Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/addrspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ extern unsigned long vm_map_base;
#define PCI_IOSIZE SZ_32M
#define ISA_IOSIZE SZ_16K
#define IO_SPACE_LIMIT (PCI_IOSIZE - 1)
#define ISA_PHY_IOBASE LOONGSON_LIO_BASE

#define PHYS_LINK_KADDR PHYSADDR(VMLINUX_LOAD_ADDRESS)

Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/efi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define _ASM_LOONGARCH_EFI_H

#include <linux/efi.h>
#include <asm/early_ioremap.h>

void __init efi_init(void);
void __init efi_runtime_init(void);
Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/irq.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ struct acpi_vector_group {
extern struct acpi_vector_group pch_group[MAX_IO_PICS];
extern struct acpi_vector_group msi_group[MAX_IO_PICS];

#define MAX_CORES_PER_EIO_NODE 256
#define CORES_PER_EIO_NODE 4

#define LOONGSON_CPU_UART0_VEC 10 /* CPU UART0 */
Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/include/asm/loongarch.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
/* IOCSR */
#define iocsr_read32(reg) __iocsrrd_w(reg)
#define iocsr_read64(reg) __iocsrrd_d(reg)
#define iocsr_write8(val, reg) __iocsrwr_b(val, reg)
#define iocsr_write32(val, reg) __iocsrwr_w(val, reg)
#define iocsr_write64(val, reg) __iocsrwr_d(val, reg)

Expand Down
1 change: 1 addition & 0 deletions arch/loongarch/kernel/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ obj-y += head.o cpu-probe.o cacheinfo.o env.o setup.o entry.o genex.o \
traps.o irq.o idle.o process.o dma.o mem.o io.o reset.o switch.o \
elf.o syscall.o signal.o time.o topology.o inst.o ptrace.o vdso.o \
alternative.o unwind.o
obj-y += legacy_boot.o

obj-$(CONFIG_ACPI) += acpi.o
obj-$(CONFIG_EFI) += efi.o
Expand Down
7 changes: 6 additions & 1 deletion arch/loongarch/kernel/acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <asm/io.h>
#include <asm/numa.h>
#include <asm/loongson.h>
#include "legacy_boot.h"

int acpi_disabled;
EXPORT_SYMBOL(acpi_disabled);
Expand Down Expand Up @@ -58,7 +59,7 @@ void __iomem *acpi_os_ioremap(acpi_physical_address phys, acpi_size size)
}

#ifdef CONFIG_SMP
static int set_processor_mask(u32 id, u32 flags)
int set_processor_mask(u32 id, u32 flags)
{

int cpu, cpuid = id;
Expand Down Expand Up @@ -132,6 +133,10 @@ static void __init acpi_process_madt(void)
__cpu_logical_map[i] = -1;
}
#endif

if (efi_bp && bpi_version <= BPI_VERSION_V1)
legacy_madt_table_init();

acpi_table_parse_madt(ACPI_MADT_TYPE_CORE_PIC,
acpi_parse_processor, MAX_CORE_PIC);

Expand Down
27 changes: 27 additions & 0 deletions arch/loongarch/kernel/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,40 @@
*/
#include <linux/acpi.h>
#include <linux/dma-direct.h>
#include <asm/loongson.h>

/*
* We extract 4bit node id (bit 44~47) from Loongson-3's
* 48bit physical address space and embed it into 40bit.
*/

static int node_id_offset;

dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr)
{
long nid = (paddr >> 44) & 0xf;

return ((nid << 44) ^ paddr) | (nid << node_id_offset);
}

phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr)
{
long nid = (daddr >> node_id_offset) & 0xf;

return ((nid << node_id_offset) ^ daddr) | (nid << 44);
}

void acpi_arch_dma_setup(struct device *dev)
{
int ret;
u64 mask, end = 0;
const struct bus_dma_region *map = NULL;

if (node_id_offset == 0) {
node_id_offset = ((readl(LS7A_DMA_CFG) & LS7A_DMA_NODE_MASK) >> LS7A_DMA_NODE_SHF);
node_id_offset += 36;
}

ret = acpi_dma_get_range(dev, &map);
if (!ret && map) {
const struct bus_dma_region *r = map;
Expand Down
Loading