From owner-freebsd-arm@freebsd.org Mon Dec 30 21:13:57 2019 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8A2FC1EA4DE for ; Mon, 30 Dec 2019 21:13:57 +0000 (UTC) (envelope-from gdotten@gmail.com) Received: from mail-qv1-xf31.google.com (mail-qv1-xf31.google.com [IPv6:2607:f8b0:4864:20::f31]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47mqtD5Rn6z4VGf for ; Mon, 30 Dec 2019 21:13:56 +0000 (UTC) (envelope-from gdotten@gmail.com) Received: by mail-qv1-xf31.google.com with SMTP id z3so12811851qvn.0 for ; Mon, 30 Dec 2019 13:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=PVR2d7pD7L3KGqmDnE+oTQqFzG8lTLMGounXEIZyY8E=; b=a4FjYI0j+Jf1mgF2tr0RkcNGNx88n8Pzl319DTIkOO+AjYDAc//vya92P5rcO8feG2 8GwZHidqo/e3mxxknpAJ/6cEehOXVmRyDBEC1F1Ke5cnC5Yuo/XPFRmwtOizEuh9W5kA Zw6SLr4fcADm80rGj+b7GdwT6swEk+plHe//xMST9F4eq1VFrz8pso02PdzOIrv/myu6 e2k94QfGxZqXNtBb1CZhrK0s/welH7slBxaC2b2/M4Z+XXL7M0Z+DDjebkYxLQfKf6Gv m+nHMm0ujXddT1UjCb/y5eTOJJ2tICph8mG68SudADO/YyxgMjI6Mccdg7hcoO5tFPo+ gZKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=PVR2d7pD7L3KGqmDnE+oTQqFzG8lTLMGounXEIZyY8E=; b=Nw8CTT8f5sCufcEnPqXdF1/8RNUgeb6WRpc1vskGa5onOhJfL08UOXJdneH3h96zi/ dn1knQpMekopNecrNctQK+LgdztVz1kosLJxh2HJDZTvK797pk9TY7uoDyTYxpMfJV74 BBtinC0qXWnWGd7LPY8ifnigvJv3mbhxuFZlelKQap655SP+3LIfJDpbBydSpnfwgQKA HpWdDc8q8DhxYMHAQCs1Nn9HDPd9NBiOqHV8JjHX5bS2rW1vRaTYzqNARPdaNE4jnKHZ ahEPnWkoxYelH+LgXeMh91PUEJyVswZ0b0f4+B4BLxVugX23xEEVt4LAhgAigRiwHsQl oftQ== X-Gm-Message-State: APjAAAUfLpdFkk3djkW54RbrHYa5Q7Cay/MIz3Y6St+Vl9VoFEl5+tAk zlntWEclaYT2XbBb4+7j7NBuHaKZoxbBCkRagTzkuK8l X-Google-Smtp-Source: APXvYqxyow5Vwa1IxJwxB1HyVdXCDo9uk5xrr4GuhPEyETAqD4CtUmjlI9MR7cuin8juGG0ca8e0pmHt+ngCZwqnv4g= X-Received: by 2002:a05:6214:1348:: with SMTP id b8mr52879789qvw.137.1577740430509; Mon, 30 Dec 2019 13:13:50 -0800 (PST) MIME-Version: 1.0 References: <20191228161726.9efb08df5b69eaa0a0ff478f@bidouilliste.com> <20191230123322.fa579638df66e3eac3e16c91@bidouilliste.com> In-Reply-To: <20191230123322.fa579638df66e3eac3e16c91@bidouilliste.com> From: Gary Otten Date: Mon, 30 Dec 2019 16:13:41 -0500 Message-ID: Subject: Re: SPI support for A64-OLinuXino board Allwinner A64 processor To: Emmanuel Vadot , freebsd-arm@freebsd.org X-Rspamd-Queue-Id: 47mqtD5Rn6z4VGf X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20161025 header.b=a4FjYI0j; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of gdotten@gmail.com designates 2607:f8b0:4864:20::f31 as permitted sender) smtp.mailfrom=gdotten@gmail.com X-Spamd-Result: default: False [-3.00 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20161025]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_SPF_ALLOW(-0.20)[+ip6:2607:f8b0:4000::/36]; FREEMAIL_FROM(0.00)[gmail.com]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-arm@freebsd.org]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; IP_SCORE_FREEMAIL(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; DKIM_TRACE(0.00)[gmail.com:+]; RCPT_COUNT_TWO(0.00)[2]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; IP_SCORE(0.00)[ip: (-6.70), ipnet: 2607:f8b0::/32(-2.15), asn: 15169(-1.87), country: US(-0.05)]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; FREEMAIL_ENVFROM(0.00)[gmail.com]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com.dwl.dnswl.org : 127.0.5.0] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Dec 2019 21:13:57 -0000 On Mon, Dec 30, 2019 at 6:33 AM Emmanuel Vadot wrote: > On Sun, 29 Dec 2019 23:40:19 -0500 > Gary Otten wrote: > > > Thanks, Ian Lepore mentioned this too, spigen wasn't loaded. I have now > > loaded spigen. The driver appears to be working, but I am not seeing > any > > output. > > > > I can toggle pins PC0,PC1,PC2, PC3 with gpioctl, but I don't get > anything > > with spi. > > You mean settings them as gpio, toggling them and check the pins on > the uext port ? > Yes that is correct, toggling them with gpioctl and seeing the voltage swing after setting that pin to OUT with gpioctl. > > > I also had another odd behavior with BANK E. not having any output, using > > gpoictl, I was not able to get any pin on Bank E to toggle. I did turn on > > the voltage regulator as suggested. > > The SPI pins for SPI0 are on BANKC which is always powered on. > OK, I was mentioning this on the chance that the gpioctl doesn't work with BANK E because Bank E is set to work with the csi function on the A64-OLinuXino board. > > > I wonder if FreeBSD is properly setting the configuration registers for > > each port/pin of the the A64. > > I'll not say that the code is bug free but this really should be ok, > especially for such basic pin setting like spi0 where you only have one > pin group. > > > Basically letting the A64 know to use alt > > function or general gpio in/out in the proper way for each pin, maybe > some > > of the (default?) settings for the more popular pine boards work, but > > don't work correctly for the Olimex A64 board, or maybe there is some > > setting in the overlays that I am overlooking that need to be set to use > an > > alt function or gpio in/out to get the pins to function properly. If in > > the overlay I have spi0 enabled, should I still be able to toggle the > pins > > with gpioctl? Thanks for the help. > > Yes unfortunately the gpio/pinmux code is shared on allwinner and > doesn't have all the needed "protection" so you can toggle a pin even > if it's not in gpio mode. I don't remember if the value is still output > on the physical pin or not. > Yes with SPI enabled in the overlay after a boot, I am still able to set the pins to output with gpioctl and see the voltage swing. I must set the pins to output to see the voltage swing. Reloading gpio_aw.ko or running spi after that doesn't appear to change the fact that the pins are set to output as I am still able to run gpioctl and see the toggle. Are you using the -sXM version on the board (where you have an spi > flash present on the board) or did you wire something via the uext > port ? If the later what's wired and how ? > On my board the flash isn't populated. I wasn't aware of the uext port so I just soldered wires on to the pads where the flash would have been, and a ground. These wires go to my logic analyzer setup to edge detect. For testing I used a loopback (short between) MOSI (PC0) /MISO(PC1) > I have this board but I will not have time to do a proper setup to > test something for some time. > Ok that would be great. I will also order a pine board today to have another board to test on. Any help or advice would be appreciated. I could be making a simple mistake or have the most basic of settings wrong, it could be something simple I am overlooking. Is there anyway to read back the configuration of a pin from user land? I wonder if anyone else can use GPIO pins on bank E on the Olimex A64 board, or has a working SPI on this board. Thanks > > My diagnostics > > ****************************************** > > root@:/dev # spi -i > > Device name: /dev/spigen0.0 > > Device mode: 2 > > Device speed: 500000 > > root@:/dev # spi -d r -m 0 -C '9F 00' -v -c 2 > > Binary output of 2 bytes > > 2 command bytes and 2 data bytes read from SPI device > > | 0 1 2 3 4 5 6 7 8 9 A B C D E F | > > | > > 0 | 00 00 00 00 | .... > > | > > > > I > > > > > > > > On Sat, Dec 28, 2019 at 10:44 AM Emmanuel Vadot > > wrote: > > > > > On Wed, 25 Dec 2019 19:12:28 -0500 > > > Gary Otten wrote: > > > > > > > Thanks, I have created the following overlay and tried a variety of > > > other > > > > things but I haven't been able to get spigen0.0 to appear in /dev. > > > > > > > > > > > > > > > > /* $FreeBSD$ */ > > > > /dts-v1/; > > > > /plugin/; > > > > > > > > / { > > > > compatible = "allwinner,sun50i-a64"; > > > > }; > > > > > > > > &{/soc/spi@1c68000} { > > > > > > > > status = "okay"; > > > > > > > > spigen0: spigen0 { > > > > compatible = "freebsd,spigen"; > > > > reg = <0>; > > > > spi-max-frequency = <500000>; > > > > status = "okay"; > > > > }; > > > > > > > > }; > > > > > > > > > > > > > > > > Some diagnostics > > > > > > > > ------------------------------------------------------- > > > > On Boot > > > > > > > > Loading DTB overlays: 'sun50i-a64-spi-spidev' > > > > /boot/dtb/overlays/sun50i-a64-spi-spidev.dtbo size=0x15c > > > > applying DTB overlay '/boot/dtb/overlays/sun50i-a64-spi-spidev.dtbo' > > > > .. > > > > .... > > > > ..... > > > > > > > > Autoloading module: aw_spi.ko > > > > aw_spi0: mem 0x1c68000-0x1c68fff irq 29 on simplebus0 > > > > spibus0: on aw_spi0 > > > > spibus0: at cs 0 mode 0 > > > > > > > > > > > > ------------------------------------------------------- > > > > root@:/boot/dtb/overlays # kldstat > > > > Id Refs Address Size Name > > > > 1 5 0xffff000000000000 144dda8 kernel > > > > 2 1 0xffff000054c00000 41000 aw_spi.ko > > > > > > > > ------------------------------------------------------- > > > > root@:/boot/dtb/overlays # devinfo > > > > .. > > > > ... > > > > aw_spi0 > > > > spibus0 > > > > > > > > ------------------------------------------------------- > > > > root@:/boot/dtb/overlays # devinfo > > > > > > > > .... > > > > ...... > > > > Node 0x2f60: spi@1c68000 > > > > Node 0x309c: spigen0 > > > > _______________________________________________ > > > > freebsd-arm@freebsd.org mailing list > > > > https://lists.freebsd.org/mailman/listinfo/freebsd-arm > > > > To unsubscribe, send any mail to " > freebsd-arm-unsubscribe@freebsd.org" > > > > > > Hi Gary, > > > > > > You overlay worked for me on the pine64-lts. Here is what I did : > > > - Use https://github.com/evadot/freebsd/commits/aw_spigen > > > - aw_spi is autoloaded via devmatch > > > - kldload spigen (it's not in GENERIC for arm64, maybe we should add > it > > > or do some devmatch magic) > > > - root@pine64-lts:~ # spi -i > > > Device name: /dev/spigen0.0 > > > Device mode: 0 > > > Device speed: 500000 > > > root@pine64-lts:~ # spi -d r -m 0 -C '9F 00' -v -c 2 > > > Binary output of 2 bytes > > > 2 command bytes and 2 data bytes read from SPI device > > > | 0 1 2 3 4 5 6 7 8 9 A B C D E F > > > | | 0 | 00 ef 40 18 > | > > > ..@. | > > > > > > Maybe you just forgot to load spigen ? > > > > > > -- > > > Emmanuel Vadot > > > > > > -- > Emmanuel Vadot >