diff options
author | Laurent Vivier <laurent@vivier.eu> | 2022-04-06 23:15:23 +0300 |
---|---|---|
committer | Geert Uytterhoeven <geert@linux-m68k.org> | 2022-04-11 12:48:01 +0300 |
commit | 05d51e42df06f0211c7029ab9aa46c492ee85043 (patch) | |
tree | 0eaaad4386f25f382cdcf62e17090707d0e3f304 /arch/m68k/virt/platform.c | |
parent | c92e7ef16400bf035e8b49c7dd091bfce4f99773 (diff) | |
download | linux-05d51e42df06f0211c7029ab9aa46c492ee85043.tar.xz |
m68k: Introduce a virtual m68k machine
This machine allows to have up to 3.2 GiB and 128 Virtio devices.
It is based on android goldfish devices.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Link: https://lore.kernel.org/r/20220406201523.243733-5-laurent@vivier.eu
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Diffstat (limited to 'arch/m68k/virt/platform.c')
-rw-r--r-- | arch/m68k/virt/platform.c | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/m68k/virt/platform.c b/arch/m68k/virt/platform.c new file mode 100644 index 000000000000..cb820f19a221 --- /dev/null +++ b/arch/m68k/virt/platform.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/platform_device.h> +#include <linux/interrupt.h> +#include <linux/memblock.h> +#include <asm/virt.h> +#include <asm/irq.h> + +#define VIRTIO_BUS_NB 128 + +static int __init virt_virtio_init(unsigned int id) +{ + const struct resource res[] = { + DEFINE_RES_MEM(virt_bi_data.virtio.mmio + id * 0x200, 0x200), + DEFINE_RES_IRQ(virt_bi_data.virtio.irq + id), + }; + struct platform_device *pdev; + + pdev = platform_device_register_simple("virtio-mmio", id, + res, ARRAY_SIZE(res)); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + return 0; +} + +static int __init virt_platform_init(void) +{ + const struct resource goldfish_tty_res[] = { + DEFINE_RES_MEM(virt_bi_data.tty.mmio, 1), + DEFINE_RES_IRQ(virt_bi_data.tty.irq), + }; + /* this is the second gf-rtc, the first one is used by the scheduler */ + const struct resource goldfish_rtc_res[] = { + DEFINE_RES_MEM(virt_bi_data.rtc.mmio + 0x1000, 0x1000), + DEFINE_RES_IRQ(virt_bi_data.rtc.irq + 1), + }; + struct platform_device *pdev; + unsigned int i; + + if (!MACH_IS_VIRT) + return -ENODEV; + + /* We need this to have DMA'able memory provided to goldfish-tty */ + min_low_pfn = 0; + + pdev = platform_device_register_simple("goldfish_tty", + PLATFORM_DEVID_NONE, + goldfish_tty_res, + ARRAY_SIZE(goldfish_tty_res)); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + pdev = platform_device_register_simple("goldfish_rtc", + PLATFORM_DEVID_NONE, + goldfish_rtc_res, + ARRAY_SIZE(goldfish_rtc_res)); + if (IS_ERR(pdev)) + return PTR_ERR(pdev); + + for (i = 0; i < VIRTIO_BUS_NB; i++) { + int err; + + err = virt_virtio_init(i); + if (err) + return err; + } + + return 0; +} + +arch_initcall(virt_platform_init); |