From: Liu Yu Date: Fri, 09 Jan 2009 07:56:48 +0000 Subject: [PATCH 4/5] qemu/kvm: Add MPC85xx support Message-Id: <1231487809-1874-6-git-send-email-yu.liu@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: kvm-ppc@vger.kernel.org As E500 exists in various boards such as MPC8544ds, MPC8572ds, MPC8560ads, = etc.. So I would like to implement a general virtual board MPC85xx to simplify th= e case. When 'cat /proc/cpuinfo' in guest, it will show: processor : 0 cpu : e500v2 clock : 1499.985015MHz revision : 3.0 (pvr 8021 0030) bogomips : 285.69 timebase : 74999250 platform : MPC8572 DS <---- Host platform model : KVM MPC85xx The current method is that change guest dts /compatible=3D"host model", this seems somewhat dirty. It works for 8544, 8572 but not sure for others. I'll change it to search a table next time. Signed-off-by: Liu Yu --- Makefile.target | 2 + hw/boards.h | 1 + hw/ppc.c | 89 +++++++++++ hw/ppc.h | 1 + hw/ppce500_mpc85xx.c | 284 ++++++++++++++++++++++++++++++++++ pc-bios/mpc85xx.dtb | Bin 0 -> 12288 bytes pc-bios/mpc85xx.dts | 361 +++++++++++++++++++++++++++++++++++++++= ++++ target-ppc/cpu.h | 12 ++ target-ppc/machine.c | 1 + target-ppc/translate_init.c | 6 +- 10 files changed, 755 insertions(+), 2 deletions(-) create mode 100644 hw/ppce500_mpc85xx.c create mode 100644 pc-bios/mpc85xx.dtb create mode 100644 pc-bios/mpc85xx.dts diff --git a/Makefile.target b/Makefile.target index b66b699..abf0d59 100644 --- a/Makefile.target +++ b/Makefile.target @@ -657,6 +657,8 @@ OBJS+=3D unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+=3D pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boar= ds.o OBJS+=3D ppc440.o ppc440_bamboo.o +# PowerPC E500 boards +OBJS+=3D ppce500.o ppce500_mpc85xx.o ppce500_pci.o mpic.o ifdef FDT_LIBS OBJS+=3D device_tree.o LIBS+=3D $(FDT_LIBS) diff --git a/hw/boards.h b/hw/boards.h index bff1cf0..35bd5ae 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -39,6 +39,7 @@ extern QEMUMachine heathrow_machine; extern QEMUMachine ref405ep_machine; extern QEMUMachine taihu_machine; extern QEMUMachine bamboo_machine; +extern QEMUMachine mpc85xx_machine; =20 /* mips_r4k.c */ extern QEMUMachine mips_machine; diff --git a/hw/ppc.c b/hw/ppc.c index 60d6e86..fbce211 100644 --- a/hw/ppc.c +++ b/hw/ppc.c @@ -421,6 +421,95 @@ void ppc40x_irq_init (CPUState *env) env, PPC40x_INPUT_NB); } =20 +/* PowerPC E500 internal IRQ controller */ +static void ppce500_set_irq (void *opaque, int pin, int level) +{ + CPUState *env =3D opaque; + int cur_level; + +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: env %p pin %d level %d\n", __func__, + env, pin, level); + } +#endif + cur_level =3D (env->irq_input_state >> pin) & 1; + /* Don't generate spurious events */ + if ((cur_level =3D 1 && level =3D 0) || (cur_level =3D 0 && level !=3D= 0)) { + switch (pin) { + case PPCE500_INPUT_MCK: + if (level) { +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: reset the PowerPC system\n", + __func__); + } +#endif + fprintf(stderr,"PowerPC E500 reset core\n"); + qemu_system_reset_request(); + } + break; + case PPCE500_INPUT_RESET_CORE: + if (level) { +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: reset the PowerPC core\n", __fun= c__); + } +#endif + ppc_set_irq(env, PPC_INTERRUPT_MCK, level); + } + break; + case PPCE500_INPUT_CINT: + /* Level sensitive - active high */ +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: set the critical IRQ state to %d\n", + __func__, level); + } +#endif + ppc_set_irq(env, PPC_INTERRUPT_CEXT, level); + break; + case PPCE500_INPUT_INT: + /* Level sensitive - active high */ +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: set the core IRQ state to %d\n", + __func__, level); + } +#endif + ppc_set_irq(env, PPC_INTERRUPT_EXT, level); + break; + case PPCE500_INPUT_DEBUG: + /* Level sensitive - active high */ +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: set the debug pin state to %d\n", + __func__, level); + } +#endif + ppc_set_irq(env, PPC_INTERRUPT_DEBUG, level); + break; + default: + /* Unknown pin - do nothing */ +#if defined(PPC_DEBUG_IRQ) + if (loglevel & CPU_LOG_INT) { + fprintf(logfile, "%s: unknown IRQ pin %d\n", __func__, pin= ); + } +#endif + return; + } + if (level) + env->irq_input_state |=3D 1 << pin; + else + env->irq_input_state &=3D ~(1 << pin); + } +} + +void ppce500_irq_init (CPUState *env) +{ + env->irq_inputs =3D (void **)qemu_allocate_irqs(&ppce500_set_irq, + env, PPCE500_INPUT_NB); +} /*************************************************************************= ****/ /* PowerPC time base and decrementer emulation */ struct ppc_tb_t { diff --git a/hw/ppc.h b/hw/ppc.h index 297f550..c0c602d 100644 --- a/hw/ppc.h +++ b/hw/ppc.h @@ -31,5 +31,6 @@ extern CPUReadMemoryFunc *PPC_io_read[]; void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val); =20 void ppc40x_irq_init (CPUState *env); +void ppce500_irq_init (CPUState *env); void ppc6xx_irq_init (CPUState *env); void ppc970_irq_init (CPUState *env); diff --git a/hw/ppce500_mpc85xx.c b/hw/ppce500_mpc85xx.c new file mode 100644 index 0000000..a17131d --- /dev/null +++ b/hw/ppce500_mpc85xx.c @@ -0,0 +1,284 @@ +/* + * Qemu PowerPC MPC85xx board emualtion + * + * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved. + * + * Author: Yu Liu, + * + * This file is derived from hw/ppc440_bamboo.c, + * the copyright for that material belongs to the original owners. + * + * This is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include + +#include "config.h" +#include "qemu-common.h" +#include "net.h" +#include "hw.h" +#include "pci.h" +#include "virtio-blk.h" +#include "boards.h" +#include "sysemu.h" +#include "ppce500.h" +#include "kvm.h" +#include "kvm_ppc.h" +#include "device_tree.h" + +#define BINARY_DEVICE_TREE_FILE "mpc85xx.dtb" +#define UIMAGE_LOAD_BASE 0 +#define DTB_LOAD_BASE 0x600000 +#define INITRD_LOAD_BASE 0x2000000 + +#define PPCE500_CCSRBAR_BASE 0xE0000000 +#define PPCE500_PCI_REGS_BASE (PPCE500_CCSRBAR_BASE + 0x8000) +#define PPCE500_PCI_REGS_SIZE 0x1000 +#define PPCE500_PCI_IO 0xE1000000 +#define PPCE500_PCI_IOLEN 0x10000 + +static int mpc85xx_copy_host_cell(void *fdt, const char *node, const char = *prop) +{ + uint32_t cell; + int ret; + + ret =3D kvmppc_read_host_property(node, prop, &cell, sizeof(cell)); + if (ret < 0) { + fprintf(stderr, "couldn't read host %s/%s\n", node, prop); + goto out; + } + + ret =3D qemu_devtree_setprop_cell(fdt, "/cpus/PowerPC,85xx@0", + prop, cell); + if (ret < 0) { + fprintf(stderr, "couldn't set guest /cpus/PowerPC,85xx@0/%s\n", prop); + goto out; + } + +out: + return ret; +} + +static void *mpc85xx_load_device_tree(void *addr, + uint32_t ramsize, + target_phys_addr_t initrd_base, + target_phys_addr_t initrd_size, + const char *kernel_cmdline) +{ + void *fdt =3D NULL; +#ifdef HAVE_FDT + uint32_t mem_reg_property[] =3D {0, ramsize}; + char *path; + int pathlen; + int ret; + + pathlen =3D snprintf(NULL, 0, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FI= LE) + 1; + path =3D qemu_malloc(pathlen); + if (path =3D NULL) + goto out; + + snprintf(path, pathlen, "%s/%s", bios_dir, BINARY_DEVICE_TREE_FILE); + + fdt =3D load_device_tree(path, addr); + free(path); + if (fdt =3D NULL) + goto out; + + /* Manipulate device tree in memory. */ + + ret =3D qemu_devtree_setprop(fdt, "/memory", "reg", mem_reg_property, + sizeof(mem_reg_property)); + if (ret < 0) + fprintf(stderr, "couldn't set /memory/reg\n"); + + ret =3D qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-start", + initrd_base); + if (ret < 0) + fprintf(stderr, "couldn't set /chosen/linux,initrd-start\n"); + + ret =3D qemu_devtree_setprop_cell(fdt, "/chosen", "linux,initrd-end", + (initrd_base + initrd_size)); + if (ret < 0) + fprintf(stderr, "couldn't set /chosen/linux,initrd-end\n"); + + ret =3D qemu_devtree_setprop_string(fdt, "/chosen", "bootargs", + kernel_cmdline); + if (ret < 0) + fprintf(stderr, "couldn't set /chosen/bootargs\n"); + + if (kvm_enabled()) { + FILE *fp; + char *model =3D NULL; + struct dirent *dirp; + DIR *dp; + char buf[128]; + + if ((fp =3D fopen("/proc/cpuinfo", "r")) =3D NULL) { + printf("Can't open file /proc/cpuinfo\n"); + goto out; + } + while (fgets(buf, 128, fp) !=3D NULL) { + if (strncmp(buf, "model", 5) =3D 0) { + model =3D buf + 9; + break; + } + } + fclose(fp); +=09 + if (model =3D NULL) { + printf("unknow host\n"); + goto out; + } +=09 + ret =3D qemu_devtree_setprop_string(fdt, "/", "compatible", model); + if (ret < 0) + fprintf(stderr, "couldn't set /compatible =3D %s\n", model); + + if ((dp =3D opendir("/proc/device-tree/cpus/")) =3D NULL) { + printf("Can't open directory /proc/device-tree/cpus/\n"); + goto out; + } + + buf[0] =3D '\0'; + while ((dirp =3D readdir(dp)) !=3D NULL) { + if (strncmp(dirp->d_name, "PowerPC", 7) =3D 0) { + sprintf(buf, "/proc/device-tree/cpus/%s", dirp->d_name); + break; + } + } + closedir(dp); + if (buf[0] =3D '\0') { + printf("unknow host\n"); + goto out; + } + path =3D buf + 17; +=09 + mpc85xx_copy_host_cell(fdt, path, "clock-frequency"); + mpc85xx_copy_host_cell(fdt, path, "timebase-frequency"); +=09 + } + +out: +#endif + + return fdt; +} + +static void mpc85xx_init(ram_addr_t ram_size, int vga_ram_size, + const char *boot_device, DisplayState *ds, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ + NICInfo *nd; + PCIBus *pci_bus; + CPUState *env; + uint64_t elf_entry; + uint64_t elf_lowaddr; + target_ulong entry=3D0; + target_ulong loadaddr=3DUIMAGE_LOAD_BASE; + target_long kernel_size=3D0; + target_ulong dt_base=3DDTB_LOAD_BASE; + target_ulong initrd_base=3DINITRD_LOAD_BASE; + target_long initrd_size=3D0; + void *fdt; + int i=3D0; + unsigned int pci_irq_nrs[4] =3D {1, 2, 3, 4}; + qemu_irq *mpic, *pci_irqs; + + /* Setup CPU */ + env =3D ppce500_init(&ram_size, &mpic, PPCE500_CCSRBAR_BASE); + + /* PCI */ + pci_irqs =3D qemu_malloc(sizeof(qemu_irq) * 4); + pci_irqs[0] =3D mpic[pci_irq_nrs[0]]; + pci_irqs[1] =3D mpic[pci_irq_nrs[1]]; + pci_irqs[2] =3D mpic[pci_irq_nrs[2]]; + pci_irqs[3] =3D mpic[pci_irq_nrs[3]]; + pci_bus =3D ppce500_pci_init(pci_irqs, PPCE500_PCI_REGS_BASE); + if (!pci_bus) + printf("couldn't create PCI controller!\n"); + + isa_mmio_init(PPCE500_PCI_IO, PPCE500_PCI_IOLEN); + + /* Register mem */ + cpu_register_physical_memory(0, ram_size, 0); + + if (pci_bus) { + int unit_id =3D 0; + + /* Add virtio block devices. */ + while ((i =3D drive_get_index(IF_VIRTIO, 0, unit_id)) !=3D -1) { + virtio_blk_init(pci_bus, drives_table[i].bdrv); + unit_id++; + } + + /* Register network interfaces. */ + for (i =3D 0; i < nb_nics; i++) { + nd =3D &nd_table[i]; + if (!nd->model) + nd->model =3D "virtio"; + pci_nic_init(pci_bus, nd, -1); + } + } + + /* Load kernel. */ + if (kernel_filename) { + kernel_size =3D load_uimage(kernel_filename, &entry, &loadaddr, NU= LL); + if (kernel_size < 0) { + kernel_size =3D load_elf(kernel_filename, 0, &elf_entry, &elf_= lowaddr, + NULL); + entry =3D elf_entry; + loadaddr =3D elf_lowaddr; + } + /* XXX try again as binary */ + if (kernel_size < 0) { + fprintf(stderr, "qemu: could not load kernel '%s'\n", + kernel_filename); + exit(1); + } + } + + /* Load initrd. */ + if (initrd_filename) { + initrd_size =3D load_image(initrd_filename, phys_ram_base + initrd= _base); + + if (initrd_size < 0) { + fprintf(stderr, "qemu: could not load initial ram disk '%s'\n", + initrd_filename); + exit(1); + } + } + + /* If we're loading a kernel directly, we must load the device tree to= o. */ + if (kernel_filename) { + fdt =3D mpc85xx_load_device_tree(phys_ram_base + dt_base, ram_size, + initrd_base, initrd_size, kernel_cmd= line); + if (fdt =3D NULL) { + fprintf(stderr, "couldn't load device tree\n"); + exit(1); + } + + /* Set initial guest state. */ + env->gpr[1] =3D (16<<20) - 8; + env->gpr[3] =3D dt_base; + env->nip =3D entry; + /* XXX we currently depend on KVM to create some initial TLB entri= es. */ + } + + if (kvm_enabled()) + kvmppc_init(); + + return; +} + +QEMUMachine mpc85xx_machine =3D { + .name =3D "mpc85xx", + .desc =3D "mpc85xx", + .init =3D mpc85xx_init, + .ram_require =3D 256<<20 | RAMSIZE_FIXED, +}; diff --git a/pc-bios/mpc85xx.dtb b/pc-bios/mpc85xx.dtb new file mode 100644 index 0000000000000000000000000000000000000000..a10e29d5bd0d65add2faed92143= 4ff3ac2d16cdd GIT binary patch literal 12288 zcmeHL&5z_p6)%%8N%#m$L?XV`(sDpBW_xCPHjCiUD3D7O)Dj}6m59e(Gh?mWc5L@D zgAkenLL5Qd(HuB&T5fP!{s1I$=3DG2=3D6!UZW@5RsyU-|tmDce!UaTC&m#B$xDD_3FKP zAHRC#uU9|*?mvtf8?@gW^UMVOmqDKdT>_y+|1#$3AG`7Y)HU+aJc9mX9KZ0=3Di=3D!83 z&t2a;J|@fgPl2{%ZZi4y_l%cf8|cAbw3B%I%sn2*JKi(Q-;*V>GK|e73b>bO-v92jpg4MKjr5Hn|wD;lk~`L zMiA8O7ofk6;erK_v#F08;;|pcKI9{>!!!9aIhkvWFN%|iXzW-M(Z1G0v~fy(z7hA5 zjr?PvnbYG`7vEOV>|ER1lML4}o9{q{=3D0%S&hV@8%iQQK~K}<&D7A!R;e>VtY(t7$Y zV|pI$9xSHAyxdRnc-dxo)@HVG_c@q#c@i(#+eL-j;N*IIxNO6FiK{E#(boHkarAjy zB#Z{K6s;jEZ)AGk-# ze*@!B2mB12$IVm^RR&pWveY!a8E@{R%SOcNaIkliV62w3Qy! z)pl9gB8CSMiM=3DNpJtA?_c-*8@~Um@Bij|);ybH6`ldf1i_x8ShW_ z@UxIBh6v`K^m~$ggm|Qrf+zYvk!!-li0W_%=3DNAU<0ci``>CF#6QCt0t?m>20G)!1#gy8jxZHc1+mg}L4qGmyBR zIdHG;r^firLVUP}R`J~CW2kF%L)kl!;XbzN1Q@7{-&3%0Hr*8M${sXyNTAbaZ~8Sj6P{qucfd<1t*ZStKE>)!4J7^sZ*V#pruJ@vMC zite8K&H#JO?SHh)vz@(X_oibfB%Tj?|DVFfiXgB(NNib?On0o9VO-qr8Rj_Q`QH0G zp1$mxNh7#oU7T9x*a=3DvS=3DKmwIqz_=3D!0X$)^-j^ijRT3gr4s_lPda|z{N0`WOY zQzMYn1^Tn~_|aGWnEGhlx60FCW*6BPwJv|jk5fLj9v(bT?%O5P&lb_scT0cXbZzhb z6WGZ&4DCwX+4b>ccY1A1XK3D^<~}g}nU3sfud$-P!il@m0+D*caupvC|#$;X3sht~&_UN#1pvPM>vI zZ~DNKfhNT!1MS5cJ=3DPlsU zyi9Kfd|{8);94XX>Q8g+%{>Q;de; + #size-cells =3D <1>; + + aliases { + serial0 =3D &serial0; + serial1 =3D &serial1; + pci0 =3D &pci0; + pci1 =3D &pci1; + pci2 =3D &pci2; + pci3 =3D &pci3; + }; + + cpus { + #address-cells =3D <1>; + #size-cells =3D <0>; + + PowerPC,85xx@0 { + device_type =3D "cpu"; + reg =3D <0x0>; + d-cache-line-size =3D <32>; // 32 bytes + i-cache-line-size =3D <32>; // 32 bytes + d-cache-size =3D <0x8000>; // L1, 32K + i-cache-size =3D <0x8000>; // L1, 32K + timebase-frequency =3D <0>; + bus-frequency =3D <0>; + clock-frequency =3D <0>; + next-level-cache =3D <&L2>; + }; + }; + + memory { + device_type =3D "memory"; + reg =3D <0x0 0x0>; // Filled by U-Boot + }; + + soc85xx@e0000000 { + #address-cells =3D <1>; + #size-cells =3D <1>; + device_type =3D "soc"; + compatible =3D "simple-bus"; + + ranges =3D <0x0 0xe0000000 0x100000>; + reg =3D <0xe0000000 0x1000>; // CCSRBAR 1M + bus-frequency =3D <0>; // Filled out by uboot. + + memory-controller@2000 { + compatible =3D "fsl,8544-memory-controller"; + reg =3D <0x2000 0x1000>; + interrupt-parent =3D <&mpic>; + interrupts =3D <18 2>; + }; + + L2: l2-cache-controller@20000 { + compatible =3D "fsl,8544-l2-cache-controller"; + reg =3D <0x20000 0x1000>; + cache-line-size =3D <32>; // 32 bytes + cache-size =3D <0x40000>; // L2, 256K + interrupt-parent =3D <&mpic>; + interrupts =3D <16 2>; + }; + + serial0: serial@4500 { + cell-index =3D <0>; + device_type =3D "serial"; + compatible =3D "ns16550"; + reg =3D <0x4500 0x100>; + clock-frequency =3D <0>; + interrupts =3D <42 2>; + interrupt-parent =3D <&mpic>; + }; + + serial1: serial@4600 { + cell-index =3D <1>; + device_type =3D "serial"; + compatible =3D "ns16550"; + reg =3D <0x4600 0x100>; + clock-frequency =3D <0>; + interrupts =3D <42 2>; + interrupt-parent =3D <&mpic>; + }; + + global-utilities@e0000 { //global utilities block + compatible =3D "fsl,mpc8548-guts"; + reg =3D <0xe0000 0x1000>; + fsl,has-rstcr; + }; + + crypto@30000 { + compatible =3D "fsl,sec2.1", "fsl,sec2.0"; + reg =3D <0x30000 0x10000>; + interrupts =3D <45 2>; + interrupt-parent =3D <&mpic>; + fsl,num-channels =3D <4>; + fsl,channel-fifo-len =3D <24>; + fsl,exec-units-mask =3D <0xfe>; + fsl,descriptor-types-mask =3D <0x12b0ebf>; + }; + + mpic: pic@40000 { + interrupt-controller; + #address-cells =3D <0>; + #interrupt-cells =3D <2>; + reg =3D <0x40000 0x40000>; + compatible =3D "chrp,open-pic"; + device_type =3D "open-pic"; + }; + + msi@41600 { + compatible =3D "fsl,mpc8544-msi", "fsl,mpic-msi"; + reg =3D <0x41600 0x80>; + msi-available-ranges =3D <0 0x100>; + interrupts =3D < + 0xe0 0 + 0xe1 0 + 0xe2 0 + 0xe3 0 + 0xe4 0 + 0xe5 0 + 0xe6 0 + 0xe7 0>; + interrupt-parent =3D <&mpic>; + }; + }; + + pci0: pci@e0008000 { + cell-index =3D <0>; + compatible =3D "fsl,mpc8540-pci"; + device_type =3D "pci"; + interrupt-map-mask =3D <0xf800 0x0 0x0 0x7>; + interrupt-map =3D < + + /* IDSEL 0x11 J17 Slot 1 */ + 0x8800 0x0 0x0 0x1 &mpic 0x2 0x1 + 0x8800 0x0 0x0 0x2 &mpic 0x3 0x1 + 0x8800 0x0 0x0 0x3 &mpic 0x4 0x1 + 0x8800 0x0 0x0 0x4 &mpic 0x1 0x1 + + /* IDSEL 0x12 J16 Slot 2 */ + + 0x9000 0x0 0x0 0x1 &mpic 0x3 0x1 + 0x9000 0x0 0x0 0x2 &mpic 0x4 0x1 + 0x9000 0x0 0x0 0x3 &mpic 0x2 0x1 + 0x9000 0x0 0x0 0x4 &mpic 0x1 0x1>; + + interrupt-parent =3D <&mpic>; + interrupts =3D <24 2>; + bus-range =3D <0 255>; + ranges =3D <0x2000000 0x0 0xc0000000 0xc0000000 0x0 0x20000000 + 0x1000000 0x0 0x0 0xe1000000 0x0 0x10000>; + clock-frequency =3D <66666666>; + #interrupt-cells =3D <1>; + #size-cells =3D <2>; + #address-cells =3D <3>; + reg =3D <0xe0008000 0x1000>; + }; + + pci1: pcie@e0009000 { + cell-index =3D <1>; + compatible =3D "fsl,mpc8548-pcie"; + device_type =3D "pci"; + #interrupt-cells =3D <1>; + #size-cells =3D <2>; + #address-cells =3D <3>; + reg =3D <0xe0009000 0x1000>; + bus-range =3D <0 255>; + ranges =3D <0x2000000 0x0 0x80000000 0x80000000 0x0 0x20000000 + 0x1000000 0x0 0x0 0xe1010000 0x0 0x10000>; + clock-frequency =3D <33333333>; + interrupt-parent =3D <&mpic>; + interrupts =3D <26 2>; + interrupt-map-mask =3D <0xf800 0x0 0x0 0x7>; + interrupt-map =3D < + /* IDSEL 0x0 */ + 0000 0x0 0x0 0x1 &mpic 0x4 0x1 + 0000 0x0 0x0 0x2 &mpic 0x5 0x1 + 0000 0x0 0x0 0x3 &mpic 0x6 0x1 + 0000 0x0 0x0 0x4 &mpic 0x7 0x1 + >; + pcie@0 { + reg =3D <0x0 0x0 0x0 0x0 0x0>; + #size-cells =3D <2>; + #address-cells =3D <3>; + device_type =3D "pci"; + ranges =3D <0x2000000 0x0 0x80000000 + 0x2000000 0x0 0x80000000 + 0x0 0x20000000 + + 0x1000000 0x0 0x0 + 0x1000000 0x0 0x0 + 0x0 0x10000>; + }; + }; + + pci2: pcie@e000a000 { + cell-index =3D <2>; + compatible =3D "fsl,mpc8548-pcie"; + device_type =3D "pci"; + #interrupt-cells =3D <1>; + #size-cells =3D <2>; + #address-cells =3D <3>; + reg =3D <0xe000a000 0x1000>; + bus-range =3D <0 255>; + ranges =3D <0x2000000 0x0 0xa0000000 0xa0000000 0x0 0x10000000 + 0x1000000 0x0 0x0 0xe1020000 0x0 0x10000>; + clock-frequency =3D <33333333>; + interrupt-parent =3D <&mpic>; + interrupts =3D <25 2>; + interrupt-map-mask =3D <0xf800 0x0 0x0 0x7>; + interrupt-map =3D < + /* IDSEL 0x0 */ + 0000 0x0 0x0 0x1 &mpic 0x0 0x1 + 0000 0x0 0x0 0x2 &mpic 0x1 0x1 + 0000 0x0 0x0 0x3 &mpic 0x2 0x1 + 0000 0x0 0x0 0x4 &mpic 0x3 0x1 + >; + pcie@0 { + reg =3D <0x0 0x0 0x0 0x0 0x0>; + #size-cells =3D <2>; + #address-cells =3D <3>; + device_type =3D "pci"; + ranges =3D <0x2000000 0x0 0xa0000000 + 0x2000000 0x0 0xa0000000 + 0x0 0x10000000 + + 0x1000000 0x0 0x0 + 0x1000000 0x0 0x0 + 0x0 0x10000>; + }; + }; + + pci3: pcie@e000b000 { + cell-index =3D <3>; + compatible =3D "fsl,mpc8548-pcie"; + device_type =3D "pci"; + #interrupt-cells =3D <1>; + #size-cells =3D <2>; + #address-cells =3D <3>; + reg =3D <0xe000b000 0x1000>; + bus-range =3D <0 255>; + ranges =3D <0x2000000 0x0 0xb0000000 0xb0000000 0x0 0x100000 + 0x1000000 0x0 0x0 0xb0100000 0x0 0x100000>; + clock-frequency =3D <33333333>; + interrupt-parent =3D <&mpic>; + interrupts =3D <27 2>; + interrupt-map-mask =3D <0xff00 0x0 0x0 0x1>; + interrupt-map =3D < + // IDSEL 0x1c USB + 0xe000 0x0 0x0 0x1 &i8259 0xc 0x2 + 0xe100 0x0 0x0 0x2 &i8259 0x9 0x2 + 0xe200 0x0 0x0 0x3 &i8259 0xa 0x2 + 0xe300 0x0 0x0 0x4 &i8259 0xb 0x2 + + // IDSEL 0x1d Audio + 0xe800 0x0 0x0 0x1 &i8259 0x6 0x2 + + // IDSEL 0x1e Legacy + 0xf000 0x0 0x0 0x1 &i8259 0x7 0x2 + 0xf100 0x0 0x0 0x1 &i8259 0x7 0x2 + + // IDSEL 0x1f IDE/SATA + 0xf800 0x0 0x0 0x1 &i8259 0xe 0x2 + 0xf900 0x0 0x0 0x1 &i8259 0x5 0x2 + >; + + pcie@0 { + reg =3D <0x0 0x0 0x0 0x0 0x0>; + #size-cells =3D <2>; + #address-cells =3D <3>; + device_type =3D "pci"; + ranges =3D <0x2000000 0x0 0xb0000000 + 0x2000000 0x0 0xb0000000 + 0x0 0x100000 + + 0x1000000 0x0 0x0 + 0x1000000 0x0 0x0 + 0x0 0x100000>; + + uli1575@0 { + reg =3D <0x0 0x0 0x0 0x0 0x0>; + #size-cells =3D <2>; + #address-cells =3D <3>; + ranges =3D <0x2000000 0x0 0xb0000000 + 0x2000000 0x0 0xb0000000 + 0x0 0x100000 + + 0x1000000 0x0 0x0 + 0x1000000 0x0 0x0 + 0x0 0x100000>; + isa@1e { + device_type =3D "isa"; + #interrupt-cells =3D <2>; + #size-cells =3D <1>; + #address-cells =3D <2>; + reg =3D <0xf000 0x0 0x0 0x0 0x0>; + ranges =3D <0x1 0x0 + 0x1000000 0x0 0x0 + 0x1000>; + interrupt-parent =3D <&i8259>; + + i8259: interrupt-controller@20 { + reg =3D <0x1 0x20 0x2 + 0x1 0xa0 0x2 + 0x1 0x4d0 0x2>; + interrupt-controller; + device_type =3D "interrupt-controller"; + #address-cells =3D <0>; + #interrupt-cells =3D <2>; + compatible =3D "chrp,iic"; + interrupts =3D <9 2>; + interrupt-parent =3D <&mpic>; + }; + + i8042@60 { + #size-cells =3D <0>; + #address-cells =3D <1>; + reg =3D <0x1 0x60 0x1 0x1 0x64 0x1>; + interrupts =3D <1 3 12 3>; + interrupt-parent =3D <&i8259>; + + keyboard@0 { + reg =3D <0x0>; + compatible =3D "pnpPNP,303"; + }; + + mouse@1 { + reg =3D <0x1>; + compatible =3D "pnpPNP,f03"; + }; + }; + + rtc@70 { + compatible =3D "pnpPNP,b00"; + reg =3D <0x1 0x70 0x2>; + }; + + gpio@400 { + reg =3D <0x1 0x400 0x80>; + }; + }; + }; + }; + }; + chosen { + linux,stdout-path =3D "/soc85xx@e0000000/serial@4500"; + }; +}; diff --git a/target-ppc/cpu.h b/target-ppc/cpu.h index f7600c4..d64f882 100644 --- a/target-ppc/cpu.h +++ b/target-ppc/cpu.h @@ -1345,6 +1345,18 @@ enum { }; =20 enum { + /* PowerPC E500 input pins */ + PPCE500_INPUT_RESET_CORE =3D 0, + PPCE500_INPUT_MCK =3D 1, + PPCE500_INPUT_RESET_SYS =3D 2, // in order same with 440 + PPCE500_INPUT_CINT =3D 3, + PPCE500_INPUT_INT =3D 4, + PPCE500_INPUT_HALT =3D 5, // in order same with 440 + PPCE500_INPUT_DEBUG =3D 6, + PPCE500_INPUT_NB, +}; + +enum { /* PowerPC 40x input pins */ PPC40x_INPUT_RESET_CORE =3D 0, PPC40x_INPUT_RESET_CHIP =3D 1, diff --git a/target-ppc/machine.c b/target-ppc/machine.c index ea2257b..97a7ee8 100644 --- a/target-ppc/machine.c +++ b/target-ppc/machine.c @@ -9,6 +9,7 @@ void register_machines(void) qemu_register_machine(&ref405ep_machine); qemu_register_machine(&taihu_machine); qemu_register_machine(&bamboo_machine); + qemu_register_machine(&mpc85xx_machine); } =20 void cpu_save(QEMUFile *f, void *opaque) diff --git a/target-ppc/translate_init.c b/target-ppc/translate_init.c index 3f01e66..f20e857 100644 --- a/target-ppc/translate_init.c +++ b/target-ppc/translate_init.c @@ -4154,7 +4154,8 @@ static void init_proc_e300 (CPUPPCState *env) POWERPC_FLAG_BUS_CLK) #define check_pow_e500 check_pow_hid0 =20 -__attribute__ (( unused )) +extern void ppce500_irq_init (CPUState *env); + static void init_proc_e500 (CPUPPCState *env) { /* Time base */ @@ -4256,7 +4257,8 @@ static void init_proc_e500 (CPUPPCState *env) init_excp_e200(env); env->dcache_line_size =3D 32; env->icache_line_size =3D 32; - /* XXX: TODO: allocate internal IRQ controller */ + /* Allocate hardware IRQ controller */ + ppce500_irq_init(env); } =20 /* Non-embedded PowerPC = */ --=20 1.5.4