Re: [PATCH 1/3] hw/gpio: Allwinner A10 GPIO emulation
Jack Wang <[email protected]>
| Newsgroups | org.nongnu.qemu-arm,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
Hi,jankovic,I read datasheet of Allwinner and confirm basic address and most function do well. But there are still some place needing improvement.
> +static inline bool gpio_is_output(AWPortMap *port, uint32_t pin)
> +{
> + uint32_t cfg_n = pin / CFG_PINS_PER_REG;
> + uint32_t pin_shift = (pin % CFG_PINS_PER_REG) * CFG_PIN_STRIDE;
> + return (extract32(port->cfg[cfg_n], pin_shift, CFG_PIN_STRIDE - 1) ==
> + CFG_OUTPUT_MASK);
> +}
> +
> +static inline bool gpio_is_input(AWPortMap *port, uint32_t pin)
> +{
> + uint32_t cfg_n = pin / CFG_PINS_PER_REG;
> + uint32_t pin_shift = (pin % CFG_PINS_PER_REG) * CFG_PIN_STRIDE;
> + return (extract32(port->cfg[cfg_n], pin_shift, CFG_PIN_STRIDE - 1) ==
> + CFG_INPUT_MASK);
> +}
> +
> +static inline int int_ctl_cfg(AWGPIOState *s, int irq_line)
> +{
> + unsigned int_cfg_n = s->regs[REG_INDEX(GPIO_INT_CFG0) + irq_line / 8];
> + return extract32(int_cfg_n,
> + (irq_line % INT_CFG_IRQ_PER_REG) * INT_CFG_IRQ_STRIDE,
> + INT_CFG_IRQ_STRIDE - 1);
> +}
> +
there you use 'INT_CFG_IRQ_STRIDE - 1’ as stride for both two function。For int_ctl_cfg the stride is supposed to be 4 https://linux-sunxi.org/images/1/1e/Allwinner_A10_User_manual_V1.5.pdf in page 333 you can find it, now all qtest pass because double edge do not be designed in qtest(better add this test). But for input and output function it is right due to byte 3 is reserved.
Jack Wang