Update the Netduino 2 Machine
v2 cover Update the Netduino 2 Machine
This patchset continues with the Netduino 2 and STM32F205 SoC work.
This patch series makes a small change to the STM32F2xx SoC to tidy up the code.
Next a feature is added to the STM32F2xx timer to display the PWM duty cycle, when debugging is enabled.
Then the STM32F2xx SPI and ADC devices are added and connected to the STM32F205 SoC.
Finally the maintainers file is updated to add myself as the maintainer for the Netdunio 2 and STM32F2xx.
V2:
- Update based on Peter C's coments
- Rebase
- Create an ADC folder for the ADC device
Alistair Francis (7):
STM32F205: Remove the individual device variables
STM32F2xx: Display PWM duty cycle from timer
STM32F2xx: Add the ADC device
STM32F2xx: Add the SPI device
STM32F205: Connect the ADC devices
STM32F205: Connect the SPI devices
MAINTAINERS: Add Alistair to the maintainers list
MAINTAINERS | 15 +++ default-configs/arm-softmmu.mak | 2 + hw/Makefile.objs | 1 + hw/adc/Makefile.objs | 1 + hw/adc/stm32f2xx_adc.c | 283 ++++++++++++++++++++++++++++++++++++++++ hw/arm/stm32f205_soc.c | 74 ++++++++--- hw/ssi/Makefile.objs | 1 + hw/ssi/stm32f2xx_spi.c | 205 +++++++++++++++++++++++++++++ hw/timer/stm32f2xx_timer.c | 9 ++ include/hw/adc/stm32f2xx_adc.h | 94 +++++++++++++ include/hw/arm/stm32f205_soc.h | 6 + include/hw/ssi/stm32f2xx_spi.h | 72 ++++++++++ 12 files changed, 748 insertions(+), 15 deletions(-) create mode 100644 hw/adc/Makefile.objs create mode 100644 hw/adc/stm32f2xx_adc.c create mode 100644 hw/ssi/stm32f2xx_spi.c create mode 100644 include/hw/adc/stm32f2xx_adc.h create mode 100644 include/hw/ssi/stm32f2xx_spi.h
Signature · 1 line
2.1.4
PATCH v2 1/7 STM32F205: Remove the individual device variables
Cleanup the individual DeviceState and SysBusDevice variables to re-use the same variable for each device.
---
hw/arm/stm32f205_soc.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
hw/arm/stm32f205_soc.c +15 -15
@@ -59,8 +59,8 @@ static void stm32f205_soc_initfn(Object *obj)static void stm32f205_soc_realize (DeviceState *dev_soc,Error **errp) {STM32F205State *s =STM32F205_SOC (dev_soc); -DeviceState *syscfgdev, *usartdev, *timerdev; -SysBusDevice *syscfgbusdev, *usartbusdev, *timerbusdev; +DeviceState *dev; +SysBusDevice *busdev;qemu_irq *pic;Error *err =NULL ;int i;
@@ -92,41 +92,41 @@ static void stm32f205_soc_realize(DeviceState *dev_soc, Error **errp) s->kernel_filename, s->cpu_model);/* System configuration controller */ - syscfgdev =DEVICE (&s->syscfg); + dev =DEVICE (&s->syscfg);object_property_set_bool (OBJECT (&s->syscfg), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);return ; } - syscfgbusdev =SYS_BUS_DEVICE (syscfgdev); -sysbus_mmio_map (syscfgbusdev,0 ,0x40013800 ); -sysbus_connect_irq (syscfgbusdev,0 , pic[71 ]); + busdev =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (busdev,0 ,0x40013800 ); +sysbus_connect_irq (busdev,0 , pic[71 ]);/* Attach UART (uses USART registers) and USART controllers */ for (i =0 ; i <STM_NUM_USARTS ; i++) { - usartdev =DEVICE (&(s->usart[i])); + dev =DEVICE (&(s->usart[i]));object_property_set_bool (OBJECT (&s->usart[i]), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);return ; } - usartbusdev =SYS_BUS_DEVICE (usartdev); -sysbus_mmio_map (usartbusdev,0 , usart_addr[i]); -sysbus_connect_irq (usartbusdev,0 , pic[usart_irq[i]]); + busdev =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (busdev,0 , usart_addr[i]); +sysbus_connect_irq (busdev,0 , pic[usart_irq[i]]); }/* Timer 2 to 5 */ for (i =0 ; i <STM_NUM_TIMERS ; i++) { - timerdev =DEVICE (&(s->timer[i])); -qdev_prop_set_uint64 (timerdev,"clock-frequency" ,1000000000 ); + dev =DEVICE (&(s->timer[i])); +qdev_prop_set_uint64 (dev,"clock-frequency" ,1000000000 );object_property_set_bool (OBJECT (&s->timer[i]), true,"realized" , &err);if (err !=NULL ) {error_propagate (errp, err);return ; } - timerbusdev =SYS_BUS_DEVICE (timerdev); -sysbus_mmio_map (timerbusdev,0 , timer_addr[i]); -sysbus_connect_irq (timerbusdev,0 , pic[timer_irq[i]]); + busdev =SYS_BUS_DEVICE (dev); +sysbus_mmio_map (busdev,0 , timer_addr[i]); +sysbus_connect_irq (busdev,0 , pic[timer_irq[i]]); } }
Signature · 1 line
2.1.4
PATCH v2 2/7 STM32F2xx: Display PWM duty cycle from timer
In reply to Alistair FrancisIf correctly configured allow the STM32F2xx timer to print out the PWM duty cycle information.
---
V2:
- Fix up if statement braces
- Remove stm32f2xx_timer_set_alarm() call
hw/timer/stm32f2xx_timer.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/timer/stm32f2xx_timer.c +9 -0
@@ -49,6 +49,15 @@ static void stm32f2xx_timer_interrupt(void *opaque)qemu_irq_pulse (s->irq);stm32f2xx_timer_set_alarm (s, s->hit_time); } + +if (s->tim_ccmr1 & (TIM_CCMR1_OC2M2 +TIM_CCMR1_OC2M1 ) && + !(s->tim_ccmr1 &TIM_CCMR1_OC2M0 ) && + s->tim_ccmr1 &TIM_CCMR1_OC2PE && + s->tim_ccer &TIM_CCER_CC2E ) { +/* PWM 2 - Mode 1 */ +DB_PRINT ("Duty Cycle: %d%%\n" , + s->tim_ccr2 / (100 * (s->tim_psc +1 ))); + } }static inline int64_t stm32f2xx_ns_to_ticks (STM32F2XXTimerState *s,int64_t t)
Signature · 1 line
2.1.4
Re: [Qemu-devel] [PATCH v2 2/7] STM32F2xx: Display PWM duty cycle from timer
Quoted 17 lines · Alistair Francis
If correctly configured allow the STM32F2xx timer to print out the PWM duty cycle information.
Signed-off-by Alistair Francis <[email protected]>---
V2:
- Fix up if statement braces
- Removestm32f2xx_timer_set_alarm()callhw/timer/stm32f2xx_timer.c | 9 +++++++++ 1 file changed, 9 insertions(+)hw/timer/stm32f2xx_timer.c +0
-0
hw/timer/stm32f2xx_timer.c static void stm32f2xx_timer_interrupt(void *opaque) · line 53
Quoted 5 lines
hw/timer/stm32f2xx_timer.c +2
-0@@ -49,6 +49,15 @@ static void stm32f2xx_timer_interrupt(void *opaque)qemu_irq_pulse (s->irq);stm32f2xx_timer_set_alarm (s, s->hit_time); } + + if (s->tim_ccmr1 & (TIM_CCMR1_OC2M2 + TIM_CCMR1_OC2M1) &&
Use | to combine multiple masks together (to show you are doing bit operations rather than arithmetic).
hw/timer/stm32f2xx_timer.c static void stm32f2xx_timer_interrupt(void *opaque) · line 59
Quoted 6 lines
hw/timer/stm32f2xx_timer.c +6
-0+ !(s->tim_ccmr1 & TIM_CCMR1_OC2M0) && + s->tim_ccmr1 & TIM_CCMR1_OC2PE && + s->tim_ccer & TIM_CCER_CC2E) { +/* PWM 2 - Mode 1 */ +DB_PRINT ("Duty Cycle: %d%%\n" , + s->tim_ccr2 / (100 * (s->tim_psc +1 )));
You should be more descriptive and give more context to the print. Add the timer name and "PWM" in there.
Otherwise:
Regards,
Peter
Quoted 8 lines
hw/timer/stm32f2xx_timer.c +1
-1+ } }static inline int64_t stm32f2xx_ns_to_ticks (STM32F2XXTimerState *s,int64_t t) --2.1.4
PATCH v2 3/7 STM32F2xx: Add the ADC device
In reply to Alistair FrancisAdd the STM32F2xx ADC device. This device randomly generates values on each read.
This also includes creating a hw/adc directory.
---
V2:
- Address Peter C's comments
- Create a ADC folder and move the file in there
- Move some of the registers into arrays
default-configs/arm-softmmu.mak | 1 + hw/Makefile.objs | 1 + hw/adc/Makefile.objs | 1 + hw/adc/stm32f2xx_adc.c | 283 ++++++++++++++++++++++++++++++++++++++++ include/hw/adc/stm32f2xx_adc.h | 94 +++++++++++++ 5 files changed, 380 insertions(+) create mode 100644 hw/adc/Makefile.objs create mode 100644 hw/adc/stm32f2xx_adc.c create mode 100644 include/hw/adc/stm32f2xx_adc.h
default-configs/arm-softmmu.mak +1 -0
@@ -84,6 +84,7 @@ CONFIG_ZYNQ=y CONFIG_STM32F2XX_TIMER=y CONFIG_STM32F2XX_USART=y CONFIG_STM32F2XX_SYSCFG=y +CONFIG_STM32F2XX_ADC=y CONFIG_STM32F205_SOC=y CONFIG_VERSATILE_PCI=y
hw/Makefile.objs +1 -0
@@ -1,5 +1,6 @@ devices-dirs-$(call land, $(CONFIG_VIRTIO),$(call land,$(CONFIG_VIRTFS),$(CONFIG_PCI))) += 9pfs/ devices-dirs-$(CONFIG_ACPI) += acpi/ +devices-dirs-$(CONFIG_SOFTMMU) += adc/ devices-dirs-$(CONFIG_SOFTMMU) += audio/ devices-dirs-$(CONFIG_SOFTMMU) += block/ devices-dirs-$(CONFIG_SOFTMMU) += bt/
hw/adc/Makefile.objs new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_STM32F2XX_ADC) += stm32f2xx_adc.o
hw/adc/stm32f2xx_adc.c new file +283 -0
283 lines not on this page · raw message
include/hw/adc/stm32f2xx_adc.h new file +94 -0
94 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 4/7 STM32F2xx: Add the SPI device
In reply to Alistair FrancisAdd the STM32F2xx SPI device.
---
V2:
- Address Peter C's comments
default-configs/arm-softmmu.mak | 1 + hw/ssi/Makefile.objs | 1 + hw/ssi/stm32f2xx_spi.c | 205 ++++++++++++++++++++++++++++++++++++++++ include/hw/ssi/stm32f2xx_spi.h | 72 ++++++++++++++ 4 files changed, 279 insertions(+) create mode 100644 hw/ssi/stm32f2xx_spi.c create mode 100644 include/hw/ssi/stm32f2xx_spi.h
default-configs/arm-softmmu.mak +1 -0
@@ -85,6 +85,7 @@ CONFIG_STM32F2XX_TIMER=y CONFIG_STM32F2XX_USART=y CONFIG_STM32F2XX_SYSCFG=y CONFIG_STM32F2XX_ADC=y +CONFIG_STM32F2XX_SPI=y CONFIG_STM32F205_SOC=y CONFIG_VERSATILE_PCI=y
hw/ssi/Makefile.objs +1 -0
@@ -2,5 +2,6 @@ common-obj-$(CONFIG_PL022) += pl022.o common-obj-$(CONFIG_SSI) += ssi.o common-obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o common-obj-$(CONFIG_XILINX_SPIPS) += xilinx_spips.o +common-obj-$(CONFIG_STM32F2XX_SPI) += stm32f2xx_spi.o obj-$(CONFIG_OMAP) += omap_spi.o
hw/ssi/stm32f2xx_spi.c new file +205 -0
205 lines not on this page · raw message
include/hw/ssi/stm32f2xx_spi.h new file +72 -0
72 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v2 7/7 MAINTAINERS: Add Alistair to the maintainers list
In reply to Alistair FrancisAdd Alistair Francis as the maintainer for the Netduino 2 and SMM32F205 SoC.
---
MAINTAINERS | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
MAINTAINERS +15 -0
@@ -356,6 +356,21 @@ F: hw/misc/zynq_slcr.c F: hw/*/cadence_* F: hw/ssi/xilinx_spips.c +STM32F205 +M: Alistair Francis <[email protected]> +S: Maintained +F: hw/arm/stm32f205_soc.c +F: hw/misc/stm32f2xx_syscfg.c +F: hw/char/stm32f2xx_usart.c +F: hw/timer/stm32f2xx_timer.c +F: hw/adc/* +F: hw/ssi/stm32f2xx_spi.c + +Netduino 2 +M: Alistair Francis <[email protected]> +S: Maintained +F: hw/arm/netduino2.c + CRIS Machines ------------- Axis Dev88
Signature · 1 line
2.1.4