save/load vmstate support in omap3 hsusb host & clean-ups
authorJuha Riihimäki <juhriihi@LX9900438.local>
Mon, 30 Mar 2009 08:15:18 +0000 (11:15 +0300)
committerJuha Riihimäki <juhriihi@LX9900438.local>
Mon, 30 Mar 2009 08:15:18 +0000 (11:15 +0300)
hw/omap.h
hw/omap2.c
hw/omap3.c
hw/omap3_usb.c
hw/usb-ohci.c

index 28d9406..68ce030 100644 (file)
--- a/hw/omap.h
+++ b/hw/omap.h
@@ -76,7 +76,6 @@ struct omap_l3_s;
 struct omap_l4_s *omap_l4_init(target_phys_addr_t base, int ta_num);
 
 struct omap_target_agent_s;
-struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus, int cs);
 target_phys_addr_t omap_l4_attach(struct omap_target_agent_s *ta, int region,
                 int iotype);
 target_phys_addr_t omap_l4_base(struct omap_target_agent_s *ta, int region);
@@ -99,16 +98,6 @@ struct omap_prcm_s *omap_prcm_init(struct omap_target_agent_s *ta,
                 qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int,
                 struct omap_mpu_state_s *mpu);
 
-struct omap3_prm_s;
-struct omap3_prm_s *omap3_prm_init(struct omap_target_agent_s *ta,
-                                   qemu_irq mpu_int, qemu_irq iva_int,
-                                   struct omap_mpu_state_s *mpu);
-
-struct omap3_cm_s;
-struct omap3_cm_s *omap3_cm_init(struct omap_target_agent_s *ta,
-                qemu_irq mpu_int, qemu_irq dsp_int, qemu_irq iva_int,
-                struct omap_mpu_state_s *mpu);
-
 struct omap_sysctl_s;
 struct omap_sysctl_s *omap_sysctl_init(struct omap_target_agent_s *ta,
                 omap_clk iclk, struct omap_mpu_state_s *mpu);
index b4895d3..895a1c7 100644 (file)
@@ -2470,7 +2470,7 @@ static struct omap_l4_agent_info_s omap_l4_agent_info[54] = {
 #define omap_l4ta(bus, cs)     omap_l4ta_get(bus, L4TA(cs))
 #define omap_l4tao(bus, cs)    omap_l4ta_get(bus, L4TAO(cs))
 
-struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus, int cs)
+static struct omap_target_agent_s *omap_l4ta_get(struct omap_l4_s *bus, int cs)
 {
     int i, iomemtype;
     struct omap_target_agent_s *ta = 0;
index 2cdd764..281a650 100644 (file)
@@ -2065,9 +2065,9 @@ static CPUWriteMemoryFunc *omap3_prm_writefn[] = {
     omap3_prm_write,
 };
 
-struct omap3_prm_s *omap3_prm_init(struct omap_target_agent_s *ta,
-                                   qemu_irq mpu_int, qemu_irq iva_int,
-                                   struct omap_mpu_state_s *mpu)
+static struct omap3_prm_s *omap3_prm_init(struct omap_target_agent_s *ta,
+                                          qemu_irq mpu_int, qemu_irq iva_int,
+                                          struct omap_mpu_state_s *mpu)
 {
     int iomemtype;
     struct omap3_prm_s *s = (struct omap3_prm_s *) qemu_mallocz(sizeof(*s));
@@ -3312,9 +3312,10 @@ static CPUWriteMemoryFunc *omap3_cm_writefn[] = {
     omap3_cm_write,
 };
 
-struct omap3_cm_s *omap3_cm_init(struct omap_target_agent_s *ta,
-                                 qemu_irq mpu_int, qemu_irq dsp_int,
-                                 qemu_irq iva_int, struct omap_mpu_state_s *mpu)
+static struct omap3_cm_s *omap3_cm_init(struct omap_target_agent_s *ta,
+                                        qemu_irq mpu_int, qemu_irq dsp_int,
+                                        qemu_irq iva_int,
+                                        struct omap_mpu_state_s *mpu)
 {
     int iomemtype;
     struct omap3_cm_s *s = (struct omap3_cm_s *) qemu_mallocz(sizeof(*s));
index 1e3bcb6..0d17ab0 100644 (file)
@@ -59,7 +59,8 @@ static void omap3_hsusb_otg_save_state(QEMUFile *f, void *opaque)
     qemu_put_byte(f, s->forcestdby);
 }
 
-static int omap3_hsusb_otg_load_state(QEMUFile *f, void *opaque, int version_id)
+static int omap3_hsusb_otg_load_state(QEMUFile *f, void *opaque,
+                                      int version_id)
 {
     struct omap3_hsusb_otg_s *s = (struct omap3_hsusb_otg_s *)opaque;
     
@@ -192,7 +193,8 @@ static void omap3_hsusb_otg_write(void *opaque, target_phys_addr_t addr,
             break;
         case 0x410: /* OTG_SIMENABLE */
             TRACE("OTG_SIMENABLE = 0x%08x", value);
-            cpu_abort(cpu_single_env, "%s: USB simulation mode not supported\n",
+            cpu_abort(cpu_single_env,
+                      "%s: USB simulation mode not supported\n",
                       __FUNCTION__);
             break;
         case 0x414: /* OTG_FORCESTDBY */
@@ -248,10 +250,13 @@ static void omap3_hsusb_otg_init(struct omap_target_agent_s *otg_ta,
     s->mc_irq = mc_irq;
     s->dma_irq = dma_irq;
     
-    omap_l4_attach(otg_ta, 0, l4_register_io_memory(0, omap3_hsusb_otg_readfn,
-                                                    omap3_hsusb_otg_writefn, s));
+    omap_l4_attach(otg_ta, 0, l4_register_io_memory(0,
+                                                    omap3_hsusb_otg_readfn,
+                                                    omap3_hsusb_otg_writefn,
+                                                    s));
     
-    s->musb = musb_init(qemu_allocate_irqs(omap3_hsusb_musb_core_intr, s, __musb_irq_max));
+    s->musb = musb_init(qemu_allocate_irqs(omap3_hsusb_musb_core_intr, s,
+                                           __musb_irq_max));
     omap3_hsusb_otg_reset(s);
     
     register_savevm("omap3_hsusb_otg", -1, 0,
@@ -269,6 +274,30 @@ struct omap3_hsusb_host_s {
     uint32_t uhh_debug_csr;
 };
 
+static void omap3_hsusb_host_save_state(QEMUFile *f, void *opaque)
+{
+    struct omap3_hsusb_host_s *s = (struct omap3_hsusb_host_s *)opaque;
+    
+    qemu_put_be32(f, s->uhh_sysconfig);
+    qemu_put_be32(f, s->uhh_hostconfig);
+    qemu_put_be32(f, s->uhh_debug_csr);
+}
+
+static int omap3_hsusb_host_load_state(QEMUFile *f, void *opaque,
+                                       int version_id)
+{
+    struct omap3_hsusb_host_s *s = (struct omap3_hsusb_host_s *)opaque;
+    
+    if (version_id)
+        return -EINVAL;
+    
+    s->uhh_sysconfig = qemu_get_be32(f);
+    s->uhh_hostconfig = qemu_get_be32(f);
+    s->uhh_debug_csr = qemu_get_be32(f);
+    
+    return 0;
+}
+
 static void omap3_hsusb_host_reset(struct omap3_hsusb_host_s *s)
 {
     s->uhh_sysconfig = 1;
@@ -414,6 +443,10 @@ static void omap3_hsusb_host_init(struct omap_target_agent_s *host_ta,
                                                      s));
     
     omap3_hsusb_host_reset(s);
+    
+    register_savevm("omap3_hsusb_host", -1, 0,
+                    omap3_hsusb_host_save_state,
+                    omap3_hsusb_host_load_state, s);
 }
 
 struct omap3_hsusb_s {
@@ -432,7 +465,9 @@ struct omap3_hsusb_s *omap3_hsusb_init(struct omap_target_agent_s *otg_ta,
 {
     struct omap3_hsusb_s *s = qemu_mallocz(sizeof(struct omap3_hsusb_s));
     omap3_hsusb_otg_init(otg_ta, mc_irq, dma_irq, &s->otg);
-    omap3_hsusb_host_init(host_ta, tll_ta, ohci_irq, ehci_irq, tll_irq, &s->host);
+    omap3_hsusb_host_init(host_ta, tll_ta,
+                          ohci_irq, ehci_irq, tll_irq,
+                          &s->host);
     return s;
 }
 
index f9da20e..3766a76 100644 (file)
@@ -1713,4 +1713,4 @@ int usb_ohci_init_omap(target_phys_addr_t base, uint32_t region_size,
     
     usb_ohci_init(ohci, num_ports, -1, irq, OHCI_TYPE_OMAP, "OHCI USB");
     return ohci->mem;
-}
\ No newline at end of file
+}