Its a quirk of the SPI hardware as far as I can tell, even on the original Beagleboard the SPI_CLK pinmux has to be set as an input.
I have been trying to get SPI1 working on my new BB-Black, the output works but the input always reads 0.
The first thing I discovered is that SPI1 is used by the HDMI interface. I created a modified am335x-bone-common.dtsi with the hdmi sections removed. Putting the new am335x-boneblack.dtb into /boot and rebooting got rid of the SPI1 signals. I then loaded a new device tree that enables spidev (See bone-test.dts below). /dev/spidev1.0 appeared.
I tried running a test program that transferred a few bytes with spi1_d0 connected to spi_d1. The output of this program on my old BB White loaded with Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img, using /dev/spidev2.0 was:
cmd: 0x02 0x12 0x34 0x56
rsp: 0x02 0x12 0x34 0x56
with Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.04.13.img on my BB Black it's always:
cmd: 0x02 0x12 0x34 0x56
rsp: 0x00 0x00 0x00 0x00
Looking at the signals with a logic analyser showed that the output (SPI1_D0) is correct.
I then moved the micro SD card from my BB Black to my BB White and discovered that it does the same thing, so the problem is not the Black but in the 2012.11.22 image (the only one that supports the Black). The problem seems to me be in the spidev driver or in the underlying hardware driver.
Any ideas?
bone-test.dts
spi-test.c
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
/* identification */
part-number = "BB-SPI1-01";
/* version */
version = "00A0";
/* state the resources this cape uses */
exclusive-use =
/* the pin header uses */
"P9.31",
"P9.29",
"P9.30",
"P9.28",
// "P9.13",
// "P9.12",
"spi1";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
pinctrl_spi1: pinctrl_spi1_pins {
pinctrl-single,pins = <
0x190 0x33 /* P9_31 = mcasp0_aclkx.spi1_sclk , INPUT_PULLUP | MODE3 */
0x194 0x33 /* P9_29 = mcasp0_fsx.spi1_d0 , INPUT_PULLUP | MODE3 */
0x198 0x13 /* P9_30 = mcasp0_axr0.spi1_d1 , OUTPUT_PULLUP | MODE3 */
0x19c 0x13 /* P9_28 = mcasp0_ahclkr.spi1_cs0 , OUTPUT_PULLUP | MODE3 */
// 0x164 0x12 /* P9_42 = GPIO0_7 = eCAP0_in_PWM0_out.gpio0[7] , OUTPUT_PULLUP | MODE2 */
>;
};
};
};
fragment@1 {
target = <&spi1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_spi1>;
cs-gpios = <&gpio4 17 0>, <&gpio1 7 0>;
spi1_0{
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <0>;
spi-max-frequency = <16000000>;
spi-cpha;
};
/*spi1_1{
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <1>;
spi-max-frequency = <16000000>;
// Mode 0 (CPOL = 0, CPHA = 0)
};*/
};
};
};
/* * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. *//dts-v1/;
/include/ "am33xx.dtsi"
/include/ "am335x-bone-common.dtsi"
&am33xx_pinmux { rstctl_pins: pinmux_rstctl_pins { pinctrl-single,pins = < /* eMMC_RSTn */ 0x50 0x17 /* gpmc_a4.gpio1_20, OUTPUT | MODE7 | PULLUP */ >; };
bone_replicape_spi1_pins: pinmux_replicape_spi1_pins { pinctrl-single,pins = < 0x190 0x13 /* P9_31 = mcasp0_aclkx.spi1_sclk , OUTPUT_PULLUP | MODE3 */
0x194 0x33 /* P9_29 = mcasp0_fsx.spi1_d0 , INPUT_PULLUP | MODE3 */ 0x198 0x13 /* P9_30 = mcasp0_axr0.spi1_d1 , OUTPUT_PULLUP | MODE3 */ 0x19c 0x13 /* P9_28 = mcasp0_ahclkr.spi1_cs0 , OUTPUT_PULLUP | MODE3 */
>; };
};
&ldo3_reg { regulator-min-microvolt = <1800000>; regulator-max-microvolt = <1800000>; regulator-always-on;};
&rstctl { status = "okay"; compatible = "gpio-rctrl"; pinctrl-names = "default"; pinctrl-0 = <&rstctl_pins>;
#reset-cells = <2>;
gpios = <&gpio2 20 0x00>; gpio-names = "eMMC_RSTn";};
&mmc1 { vmmc-supply = <&vmmcsd_fixed>;};
&mmc2 { vmmc-supply = <&vmmcsd_fixed>; bus-width = <8>; ti,non-removable; status = "okay";
reset = <&rstctl 0 0>; reset-names = "eMMC_RSTn-CONSUMER";};
&cpu { /* * To consider voltage drop between PMIC and SoC, * tolerance value is reduced to 2% from 4% and * voltage value is increased as a precaution. */ operating-points = < /* kHz uV */ 1000000 1350000 800000 1300000 600000 1112000 300000 969000 >;};
&spi1 {
#address-cells = <1>; #size-cells = <0>; status = "okay"; pinctrl-names = "default";
pinctrl-0 = <&bone_replicape_spi1_pins>;
cs-gpios = <&gpio4 17 0>, <&gpio1 7 0>;
cs0-device {
#address-cells = <1>; #size-cells = <0>; compatible = "spidev"; reg = <0>; spi-max-frequency = <16000000>;
};
};
dtc -O dtb -o am335x-boneblack.dtb -b 0 -@ am335x-boneblack.dts
--
AM335x ARM® Cortex™-A8 Microprocessors(MPUs)
Technical Reference Manual - SPRUH73H
SPI serial clock (output when master, input when slave)
(1)This output signal is also used as a re-timing input. The associated CONF_<module>_<pin>_RXACTIVE bit for the output clock
must be set to 1 to enable the clock input back to the module.
Its a quirk of the SPI hardware as far as I can tell, even on the original Beagleboard the SPI_CLK pinmux has to be set as an input.
I agree it doesn't seem "logical".
On Tuesday, May 7, 2013 10:29:07 AM UTC-5, ky...@cranehome.info wrote:Isn't that the serial clock? Isn't it generated by the host and thus an output? Or is it generated by some hardware and taking it over as an output is clobbering that?
On Tuesday, May 7, 2013 8:27:01 AM UTC-5, Alan Backlund wrote:Changing SCLK to an input works.
Thank You
I have been trying to get SPI1 working on my new BB-Black, the output works but the input always reads 0.
The first thing I discovered is that SPI1 is used by the HDMI interface. I created a modified am335x-bone-common.dtsi with the hdmi sections removed. Putting the new am335x-boneblack.dtb into /boot and rebooting got rid of the SPI1 signals. I then loaded a new device tree that enables spidev (See bone-test.dts below). /dev/spidev1.0 appeared.
I tried running a test program that transferred a few bytes with spi1_d0 connected to spi_d1. The output of this program on my old BB White loaded with Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.05-beaglebone-2012.11.22.img, using /dev/spidev2.0 was:
cmd: 0x02 0x12 0x34 0x56
rsp: 0x02 0x12 0x34 0x56
with Angstrom-Cloud9-IDE-GNOME-eglibc-ipk-v2012.12-beaglebone-2013.04.13.img on my BB Black it's always:
cmd: 0x02 0x12 0x34 0x56
rsp: 0x00 0x00 0x00 0x00
Looking at the signals with a logic analyser showed that the output (SPI1_D0) is correct.
I then moved the micro SD card from my BB Black to my BB White and discovered that it does the same thing, so the problem is not the Black but in the 2012.11.22 image (the only one that supports the Black). The problem seems to me be in the spidev driver or in the underlying hardware driver.
Any ideas?
bone-test.dts
/*
* Copyright (C) 2013 Alan Backlund
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
/dts-v1/;
/plugin/;
/ {
compatible = "ti,beaglebone", "ti,beaglebone-black";
part-number = "BB-BONE-TEST-01";
version = "00A0";
fragment@0 {
target = <&am33xx_pinmux>;
__overlay__ {
bone_replicape_spi1_pins: pinmux_replicape_spi1_pins {
pinctrl-single,pins = <
0x190 0x13 /* P9_31 = mcasp0_aclkx.spi1_sclk , OUTPUT_PULLUP | MODE3 */
0x194 0x33 /* P9_29 = mcasp0_fsx.spi1_d0 , INPUT_PULLUP | MODE3 */
0x198 0x13 /* P9_30 = mcasp0_axr0.spi1_d1 , OUTPUT_PULLUP | MODE3 */
0x19c 0x13 /* P9_28 = mcasp0_ahclkr.spi1_cs0 , OUTPUT_PULLUP | MODE3 */
>;
};
};
};
fragment@1 {
target = <&spi1>;
__overlay__ {
#address-cells = <1>;
#size-cells = <0>;
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&bone_replicape_spi1_pins>;
cs-gpios = <&gpio4 17 0>, <&gpio1 7 0>;
cs0-device {
#address-cells = <1>;
#size-cells = <0>;
compatible = "spidev";
reg = <0>;
spi-max-frequency = <16000000>;
};
};
};
};
spi-test.c
/*
* Copyright (C) 2013 Alan Backlund
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/
Ok at least I'm not that stupid then. ;)
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/6138aa63-d406-4679-a0ab-8bf32189a8d2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.