Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Aug 2019 09:10:19 +0200
From:      Milan Obuch <freebsd-arm@dino.sk>
To:        freebsd-arm@freebsd.org
Subject:   Attempt to use uart0 on Zybo Z7
Message-ID:  <20190803091019.2d067756@zeta.dino.sk>

next in thread | raw e-mail | index | archive | help
Hi,

Zynq SoC has several peripherals available on its PS/ARM side of thing.
Currently supported list contains UART, USB, ethernet, SDIO and GPIO.
No driver yet for SPI, I2C and CAN.

Available GPIO pins are on JF6 (MIO pmod connector), I tested them as
inputs and they are working as expected. All other peripherals are
present in pairs, so I decided to try the simplest one - UART.

On Zybo Z7 we use uart1 as console for both u-boot and kernel, so the
unused one is uart0. In order to create its driver instance, it was
necessary to add just

&uart0 {status = "okay";};

into dts, create dtb from it and use it for boot. This is enough for
uart0 to present itself as

uart0: <Cadence UART> mem 0-0xfff irq 6 on simplebus1

in dmesg (or

uart0: <Cadence UART> mem 0-0xfff irq 6 on simplebus1
uart0: fast interrupt
uart0: PPS capture mode: DCD

in verbose boot dmesg).

That was really easy. Now we need uart0 interface (rx and tx) to appear
on some available pins. According to MIO-at-a-glance table in Zynq TRM
(section 2.5.4) there are two possibilities - MIO10 and MIO11 or MIO14
and MIO15.

I played a bit with zy7_slcr_attach() function in arm/xilinx/zy7_slcr.c
file. With some printf and RD4 calls I can see MIO pin configuration -
currently we have no pinmux for Zynq, so I decided to try register
access to check and eventually program. Studying existing configuration
and Zynq TRM, appendix B.28 for registers detail of slcr leads me to
believe I need something like

WR4(sc, ZY7_SLCR_MIO_PIN(14), 0x16E0);
WR4(sc, ZY7_SLCR_MIO_PIN(15), 0x16E1);

to do the necessary pinmuxing. As access to slcr register is locked, it
was necessary to add call

zy7_slcr_unlock(sc);

before in order for write to be executed at all, which I verified with
values being read back correctly. Without this call no change to
registers was done.

Unfortunatelly, I am still missing something - I tried to create
physical loop connecting pins MIO14 and MIO15 (on my board connected to
JF9 and JF10 pins) but nothing - typing anything to 'cu -l /dev/cuau0'
does not make to read it back.

Did anybody any clue what I am missing? I verified I am connecting the
right pins, but I see nothing arriving back when typing...

Regards,
Milan



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190803091019.2d067756>