Sam460ex emulation
v2 cover Sam460ex emulation
Resending those patches that were reviewed and did not need any changes or only rebasing to latest master so these could go in now. I'll get back to the other patches that need more changes later.
BALATON Zoltan (4):
ohci: Allow sysbus version to be used as a companion
ehci: Add ppc4xx-ehci for the USB 2.0 controller in embedded PPC SoCs
ppc4xx: Add more PLB registers
ppc: Add 460EX embedded CPU
hw/ppc/ppc405_uc.c | 12 +++++++++--- hw/usb/hcd-ehci-sysbus.c | 25 +++++++++++++++++++++++++ hw/usb/hcd-ehci.h | 1 + hw/usb/hcd-ohci.c | 15 ++++++++++++--- target/ppc/cpu-models.c | 3 +++ target/ppc/cpu-models.h | 1 + target/ppc/translate_init.c | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 89 insertions(+), 6 deletions(-)
Signature · 1 line
2.7.6
PATCH v2 1/4 ohci: Allow sysbus version to be used as a companion
Some PPC SoCs have an EHCI with OHCI companion USB controller. To emulate this allow the sysbus version of OHCI to be used as a companion.
---
v2: Added R-b from http://lists.nongnu.org/archive/html/qemu-ppc/2017-08/msg00346.html
hw/usb/hcd-ohci.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
hw/usb/hcd-ohci.c +12 -3
@@ -1999,7 +1999,9 @@ typedef struct {/*< public >*/ OHCIState ohci; +char *masterbus;uint32_t num_ports; +uint32_t firstport;dma_addr_t dma_offset; } OHCISysBusState;
@@ -2007,10 +2009,15 @@ static void ohci_realize_pxa(DeviceState *dev, Error **errp) {OHCISysBusState *s =SYSBUS_OHCI (dev);SysBusDevice *sbd =SYS_BUS_DEVICE (dev); +Error *err =NULL ; -/* Cannot fail as we pass NULL for masterbus */ -usb_ohci_init (&s->ohci, dev, s->num_ports, s->dma_offset,NULL ,0 , - &address_space_memory, &error_abort); +usb_ohci_init (&s->ohci, dev, s->num_ports, s->dma_offset, + s->masterbus, s->firstport, + &address_space_memory, &err); +if (err) { +error_propagate (errp, err); +return ; + }sysbus_init_irq (sbd, &s->ohci.irq);sysbus_init_mmio (sbd, &s->ohci.mem); }
@@ -2142,7 +2149,9 @@ static const TypeInfo ohci_pci_info = { };static Property ohci_sysbus_properties[] = { +DEFINE_PROP_STRING ("masterbus" , OHCISysBusState, masterbus),DEFINE_PROP_UINT32 ("num-ports" , OHCISysBusState, num_ports,3 ), +DEFINE_PROP_UINT32 ("firstport" , OHCISysBusState, firstport,0 ),DEFINE_PROP_DMAADDR ("dma-offset" , OHCISysBusState, dma_offset,0 ),DEFINE_PROP_END_OF_LIST (), };
Signature · 1 line
2.7.6
PATCH v2 2/4 ehci: Add ppc4xx-ehci for the USB 2.0 controller in embedded PPC SoCs
In reply to BALATON ZoltanSome PPC SoCs have an EHCI with OHCI companion USB controller. Add a new type for this similar to types used for other embedded SoCs.
---
v2: Added R-b from: http://lists.nongnu.org/archive/html/qemu-ppc/2017-08/msg00345.html
hw/usb/hcd-ehci-sysbus.c | 25 +++++++++++++++++++++++++ hw/usb/hcd-ehci.h | 1 + 2 files changed, 26 insertions(+)
hw/usb/hcd-ehci-sysbus.c +25 -0
@@ -142,6 +142,30 @@ static const TypeInfo ehci_tegra2_type_info = { .class_init = ehci_tegra2_class_init, }; +static void ehci_ppc4xx_init (Object *o) +{ +EHCISysBusState *s =SYS_BUS_EHCI (o); + + s->ehci.companion_enable = true; +} + +static void ehci_ppc4xx_class_init (ObjectClass *oc,void *data) +{ +SysBusEHCIClass *sec =SYS_BUS_EHCI_CLASS (oc); +DeviceClass *dc =DEVICE_CLASS (oc); + + sec->capsbase =0x0 ; + sec->opregbase =0x10 ; +set_bit (DEVICE_CATEGORY_USB , dc->categories); +} + +static const TypeInfo ehci_ppc4xx_type_info = { + .name = TYPE_PPC4xx_EHCI, + .parent =TYPE_SYS_BUS_EHCI , + .class_init = ehci_ppc4xx_class_init, + .instance_init = ehci_ppc4xx_init, +}; +/* * Faraday FUSBH200 USB 2.0 EHCI */
@@ -224,6 +248,7 @@ static void ehci_sysbus_register_types(void)type_register_static (&ehci_xlnx_type_info);type_register_static (&ehci_exynos4210_type_info);type_register_static (&ehci_tegra2_type_info); +type_register_static (&ehci_ppc4xx_type_info);type_register_static (&ehci_fusbh200_type_info); }
hw/usb/hcd-ehci.h +1 -0
@@ -344,6 +344,7 @@ typedef struct EHCIPCIState {#define TYPE_SYS_BUS_EHCI "sysbus-ehci-usb"#define TYPE_EXYNOS4210_EHCI "exynos4210-ehci-usb"#define TYPE_TEGRA2_EHCI "tegra2-ehci-usb" +#define TYPE_PPC4xx_EHCI "ppc4xx-ehci-usb"#define TYPE_FUSBH200_EHCI "fusbh200-ehci-usb"#define SYS_BUS_EHCI (obj) \
Signature · 1 line
2.7.6
PATCH v2 3/4 ppc4xx: Add more PLB registers
In reply to BALATON ZoltanThese registers are present in 440 SoCs (and maybe in others too) and U-Boot accesses them when printing register info. We don't emulate these but add them to avoid crashing when they are read or written.
---
v2: No change, discussed in: http://lists.nongnu.org/archive/html/qemu-ppc/2017-08/msg00385.html
hw/ppc/ppc405_uc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
hw/ppc/ppc405_uc.c +9 -3
@@ -105,9 +105,12 @@ ram_addr_t ppc405_set_bootinfo (CPUPPCState *env, ppc4xx_bd_info_t *bd,/*****************************************************************************/ /* Peripheral local bus arbitrer */ enum { -PLB0_BESR =0x084 , -PLB0_BEAR =0x086 , -PLB0_ACR =0x087 , +PLB3A0_ACR =0x077 , +PLB4A0_ACR =0x081 , +PLB0_BESR =0x084 , +PLB0_BEAR =0x086 , +PLB0_ACR =0x087 , +PLB4A1_ACR =0x089 , };typedef struct ppc4xx_plb_t ppc4xx_plb_t ;
@@ -179,9 +182,12 @@ void ppc4xx_plb_init(CPUPPCState *env)ppc4xx_plb_t *plb; plb =g_malloc0 (sizeof (ppc4xx_plb_t)); +ppc_dcr_register (env,PLB3A0_ACR , plb, &dcr_read_plb, &dcr_write_plb); +ppc_dcr_register (env,PLB4A0_ACR , plb, &dcr_read_plb, &dcr_write_plb);ppc_dcr_register (env,PLB0_ACR , plb, &dcr_read_plb, &dcr_write_plb);ppc_dcr_register (env,PLB0_BEAR , plb, &dcr_read_plb, &dcr_write_plb);ppc_dcr_register (env,PLB0_BESR , plb, &dcr_read_plb, &dcr_write_plb); +ppc_dcr_register (env,PLB4A1_ACR , plb, &dcr_read_plb, &dcr_write_plb);qemu_register_reset (ppc4xx_plb_reset, plb); }
Signature · 1 line
2.7.6
PATCH v2 4/4 ppc: Add 460EX embedded CPU
In reply to BALATON ZoltanDespite its name it is a 440 core CPU
---
v2: Rebased to latest changes on master
target/ppc/cpu-models.c | 3 +++ target/ppc/cpu-models.h | 1 + target/ppc/translate_init.c | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+)
target/ppc/cpu-models.c +3 -0
@@ -167,6 +167,8 @@ "PowerPC 440 EPb") POWERPC_DEF("440epx", CPU_POWERPC_440EPX, 440EP, "PowerPC 440 EPX") + POWERPC_DEF("460exb", CPU_POWERPC_460EXb, 460EX, + "PowerPC 460 EXb")#if defined(TODO_USER_ONLY ) POWERPC_DEF("440gpb", CPU_POWERPC_440GPb, 440GP,"PowerPC 440 GPb" )
@@ -786,6 +788,7 @@ PowerPCCPUAlias ppc_cpu_aliases[] = { { "x2vp50", "x2vp20" }, { "440ep", "440epb" }, + { "460ex", "460exb" }, #if defined(TODO_USER_ONLY) { "440gp", "440gpc" }, { "440gr", "440gra" },
target/ppc/cpu-models.h +1 -0
@@ -240,6 +240,7 @@ enum {CPU_POWERPC_440SP =0x53221850 ,CPU_POWERPC_440SP2 =0x53221891 ,CPU_POWERPC_440SPE =0x53421890 , + CPU_POWERPC_460EXb =0x130218A4 ,/* called 460 but 440 core */ /* PowerPC 460 family */ #if 0/* Generic PowerPC 464 */
target/ppc/translate_init.c +38 -0
@@ -3833,6 +3833,44 @@ POWERPC_FAMILY(440EP)(ObjectClass *oc, void *data)POWERPC_FLAG_DE |POWERPC_FLAG_BUS_CLK ; } +POWERPC_FAMILY(460EX)(ObjectClass *oc, void *data) +{ +DeviceClass *dc =DEVICE_CLASS (oc); +PowerPCCPUClass *pcc =POWERPC_CPU_CLASS (oc); + + dc->desc ="PowerPC 460 EX" ; + pcc->init_proc = init_proc_440EP; + pcc->check_pow = check_pow_nocheck; + pcc->insns_flags =PPC_INSNS_BASE |PPC_STRING | +PPC_FLOAT |PPC_FLOAT_FRES |PPC_FLOAT_FSEL | +PPC_FLOAT_FSQRT |PPC_FLOAT_FRSQRTE | +PPC_FLOAT_STFIWX | +PPC_DCR |PPC_DCRX |PPC_WRTEE |PPC_RFMCI | +PPC_CACHE |PPC_CACHE_ICBI | +PPC_CACHE_DCBZ |PPC_CACHE_DCBA | +PPC_MEM_TLBSYNC |PPC_MFTB | +PPC_BOOKE | PPC_4xx_COMMON |PPC_405_MAC | +PPC_440_SPEC ; + pcc->msr_mask = (1ull <<MSR_POW ) | + (1ull <<MSR_CE ) | + (1ull <<MSR_EE ) | + (1ull <<MSR_PR ) | + (1ull <<MSR_FP ) | + (1ull <<MSR_ME ) | + (1ull <<MSR_FE0 ) | + (1ull <<MSR_DWE ) | + (1ull <<MSR_DE ) | + (1ull <<MSR_FE1 ) | + (1ull <<MSR_IR ) | + (1ull <<MSR_DR ); + pcc->mmu_model =POWERPC_MMU_BOOKE ; + pcc->excp_model =POWERPC_EXCP_BOOKE ; + pcc->bus_model = PPC_FLAGS_INPUT_BookE; + pcc->bfd_mach = bfd_mach_ppc_403; + pcc->flags =POWERPC_FLAG_CE |POWERPC_FLAG_DWE | +POWERPC_FLAG_DE |POWERPC_FLAG_BUS_CLK ; +} +static void init_proc_440GP (CPUPPCState *env) {/* Time base */
Signature · 1 line
2.7.6
David Gibson
AppliedQuoted 3 lines · BALATON Zoltan
Resending those patches that were reviewed and did not need any changes or only rebasing to latest master so these could go in now. I'll get back to the other patches that need more changes later.
Applied to ppc-for-2.11, thanks.
Quoted 15 lines
BALATON Zoltan (4):
ohci: Allow sysbus version to be used as a companion
ehci: Add ppc4xx-ehci for the USB 2.0 controller in embedded PPC SoCs
ppc4xx: Add more PLB registers
ppc: Add 460EX embedded CPUhw/ppc/ppc405_uc.c | 12 +++++++++--- hw/usb/hcd-ehci-sysbus.c | 25 +++++++++++++++++++++++++ hw/usb/hcd-ehci.h | 1 + hw/usb/hcd-ohci.c | 15 ++++++++++++--- target/ppc/cpu-models.c | 3 +++ target/ppc/cpu-models.h | 1 + target/ppc/translate_init.c | 38 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 89 insertions(+), 6 deletions(-)
Signature · 4 lines
David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson