qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

omap-gpio: remove PROP_PTR

Since clocks are not QOM objects, replace PROP_PTR of clocks with
setters methods.

Move/adapt the existing TODO comment about a clock framework.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

+52 -38
+1 -1
hw/arm/omap1.c
··· 4012 4012 4013 4013 s->gpio = qdev_create(NULL, "omap-gpio"); 4014 4014 qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model); 4015 - qdev_prop_set_ptr(s->gpio, "clk", omap_findclk(s, "arm_gpio_ck")); 4015 + omap_gpio_set_clk(OMAP1_GPIO(s->gpio), omap_findclk(s, "arm_gpio_ck")); 4016 4016 qdev_init_nofail(s->gpio); 4017 4017 sysbus_connect_irq(SYS_BUS_DEVICE(s->gpio), 0, 4018 4018 qdev_get_gpio_in(s->ih[0], OMAP_INT_GPIO_BANK1));
+7 -6
hw/arm/omap2.c
··· 2449 2449 2450 2450 s->gpio = qdev_create(NULL, "omap2-gpio"); 2451 2451 qdev_prop_set_int32(s->gpio, "mpu_model", s->mpu_model); 2452 - qdev_prop_set_ptr(s->gpio, "iclk", omap_findclk(s, "gpio_iclk")); 2453 - qdev_prop_set_ptr(s->gpio, "fclk0", omap_findclk(s, "gpio1_dbclk")); 2454 - qdev_prop_set_ptr(s->gpio, "fclk1", omap_findclk(s, "gpio2_dbclk")); 2455 - qdev_prop_set_ptr(s->gpio, "fclk2", omap_findclk(s, "gpio3_dbclk")); 2456 - qdev_prop_set_ptr(s->gpio, "fclk3", omap_findclk(s, "gpio4_dbclk")); 2452 + omap2_gpio_set_iclk(OMAP2_GPIO(s->gpio), omap_findclk(s, "gpio_iclk")); 2453 + omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 0, omap_findclk(s, "gpio1_dbclk")); 2454 + omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 1, omap_findclk(s, "gpio2_dbclk")); 2455 + omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 2, omap_findclk(s, "gpio3_dbclk")); 2456 + omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 3, omap_findclk(s, "gpio4_dbclk")); 2457 2457 if (s->mpu_model == omap2430) { 2458 - qdev_prop_set_ptr(s->gpio, "fclk4", omap_findclk(s, "gpio5_dbclk")); 2458 + omap2_gpio_set_fclk(OMAP2_GPIO(s->gpio), 4, 2459 + omap_findclk(s, "gpio5_dbclk")); 2459 2460 } 2460 2461 qdev_init_nofail(s->gpio); 2461 2462 busdev = SYS_BUS_DEVICE(s->gpio);
+15 -27
hw/gpio/omap_gpio.c
··· 40 40 uint16_t pins; 41 41 }; 42 42 43 - #define TYPE_OMAP1_GPIO "omap-gpio" 44 - #define OMAP1_GPIO(obj) \ 45 - OBJECT_CHECK(struct omap_gpif_s, (obj), TYPE_OMAP1_GPIO) 46 - 47 43 struct omap_gpif_s { 48 44 SysBusDevice parent_obj; 49 45 ··· 211 207 uint32_t debounce; 212 208 uint8_t delay; 213 209 }; 214 - 215 - #define TYPE_OMAP2_GPIO "omap2-gpio" 216 - #define OMAP2_GPIO(obj) \ 217 - OBJECT_CHECK(struct omap2_gpif_s, (obj), TYPE_OMAP2_GPIO) 218 210 219 211 struct omap2_gpif_s { 220 212 SysBusDevice parent_obj; ··· 747 739 } 748 740 } 749 741 750 - /* Using qdev pointer properties for the clocks is not ideal. 751 - * qdev should support a generic means of defining a 'port' with 752 - * an arbitrary interface for connecting two devices. Then we 753 - * could reframe the omap clock API in terms of clock ports, 754 - * and get some type safety. For now the best qdev provides is 755 - * passing an arbitrary pointer. 756 - * (It's not possible to pass in the string which is the clock 757 - * name, because this device does not have the necessary information 758 - * (ie the struct omap_mpu_state_s*) to do the clockname to pointer 759 - * translation.) 760 - */ 742 + void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk) 743 + { 744 + gpio->clk = clk; 745 + } 761 746 762 747 static Property omap_gpio_properties[] = { 763 748 DEFINE_PROP_INT32("mpu_model", struct omap_gpif_s, mpu_model, 0), 764 - DEFINE_PROP_PTR("clk", struct omap_gpif_s, clk), 765 749 DEFINE_PROP_END_OF_LIST(), 766 750 }; 767 751 ··· 784 768 .class_init = omap_gpio_class_init, 785 769 }; 786 770 771 + void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk) 772 + { 773 + gpio->iclk = clk; 774 + } 775 + 776 + void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk) 777 + { 778 + assert(i <= 5); 779 + gpio->fclk[i] = clk; 780 + } 781 + 787 782 static Property omap2_gpio_properties[] = { 788 783 DEFINE_PROP_INT32("mpu_model", struct omap2_gpif_s, mpu_model, 0), 789 - DEFINE_PROP_PTR("iclk", struct omap2_gpif_s, iclk), 790 - DEFINE_PROP_PTR("fclk0", struct omap2_gpif_s, fclk[0]), 791 - DEFINE_PROP_PTR("fclk1", struct omap2_gpif_s, fclk[1]), 792 - DEFINE_PROP_PTR("fclk2", struct omap2_gpif_s, fclk[2]), 793 - DEFINE_PROP_PTR("fclk3", struct omap2_gpif_s, fclk[3]), 794 - DEFINE_PROP_PTR("fclk4", struct omap2_gpif_s, fclk[4]), 795 - DEFINE_PROP_PTR("fclk5", struct omap2_gpif_s, fclk[5]), 796 784 DEFINE_PROP_END_OF_LIST(), 797 785 }; 798 786
+29 -4
include/hw/arm/omap.h
··· 77 77 /* 78 78 * TODO: Ideally we should have a clock framework that 79 79 * let us wire these clocks up with QOM properties or links. 80 + * 81 + * qdev should support a generic means of defining a 'port' with 82 + * an arbitrary interface for connecting two devices. Then we 83 + * could reframe the omap clock API in terms of clock ports, 84 + * and get some type safety. For now the best qdev provides is 85 + * passing an arbitrary pointer. 86 + * (It's not possible to pass in the string which is the clock 87 + * name, because this device does not have the necessary information 88 + * (ie the struct omap_mpu_state_s*) to do the clockname to pointer 89 + * translation.) 80 90 */ 81 91 void omap_intc_set_iclk(omap_intr_handler *intc, omap_clk clk); 82 92 void omap_intc_set_fclk(omap_intr_handler *intc, omap_clk clk); ··· 87 97 88 98 typedef struct OMAPI2CState OMAPI2CState; 89 99 90 - /* 91 - * TODO: Ideally we should have a clock framework that 92 - * let us wire these clocks up with QOM properties or links. 93 - */ 100 + /* TODO: clock framework (see above) */ 94 101 void omap_i2c_set_iclk(OMAPI2CState *i2c, omap_clk clk); 95 102 void omap_i2c_set_fclk(OMAPI2CState *i2c, omap_clk clk); 103 + 104 + /* omap_gpio.c */ 105 + #define TYPE_OMAP1_GPIO "omap-gpio" 106 + #define OMAP1_GPIO(obj) \ 107 + OBJECT_CHECK(struct omap_gpif_s, (obj), TYPE_OMAP1_GPIO) 108 + 109 + #define TYPE_OMAP2_GPIO "omap2-gpio" 110 + #define OMAP2_GPIO(obj) \ 111 + OBJECT_CHECK(struct omap2_gpif_s, (obj), TYPE_OMAP2_GPIO) 112 + 113 + typedef struct omap_gpif_s omap_gpif; 114 + typedef struct omap2_gpif_s omap2_gpif; 115 + 116 + /* TODO: clock framework (see above) */ 117 + void omap_gpio_set_clk(omap_gpif *gpio, omap_clk clk); 118 + 119 + void omap2_gpio_set_iclk(omap2_gpif *gpio, omap_clk clk); 120 + void omap2_gpio_set_fclk(omap2_gpif *gpio, uint8_t i, omap_clk clk); 96 121 97 122 /* OMAP2 l4 Interconnect */ 98 123 struct omap_l4_s;