GPIO CS for AR9331/carambola2

Hi there,

I'm trying to upgrade a device I have running a very old kernel (3 something) which has an external SPI device.
In the previous kernel, I could add a device to the bus by adding information like so:

static struct ath79_spi_controller_data ath79_spi3_cdata =
{
        .cs_type = ATH79_SPI_CS_TYPE_GPIO,
        .cs_line = 15,
        .is_flash = false,
};

But now with the device-tree overlays I can't seem to select a GPIO line as chip-select for this SOC.

I've tried:

&spi {
	status = "okay";

	cs-gpios =  <0>, <0>, <0>, <&gpio 15 GPIO_ACTIVE_LOW>
	unused-native-cs = <2>;
	max-native-cs = <3>;
	num-cs = <4>;
        flash@0 {
		compatible = "jedec,spi-nor";
		spi-max-frequency = <50000000>;
		reg = <0>;

		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;

			uboot: partition@0 {
				label = "u-boot";
				reg = <0x000000 0x040000>;
				read-only;
			};

			partition@40000 {
				label = "u-boot-env";
				reg = <0x040000 0x010000>;
				read-only;
			};

			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0xfa0000>;
			};

			art: partition@ff0000 {
				label = "art";
				reg = <0xff0000 0x010000>;
				read-only;
			};
		};
	};
        rtc: rtc@3 {
		compatible = "nxp,pcf2123";
		reg = <3>;
		spi-cs-high;
	};
};

And variations of this but I just can't seem to get the CS working.

Watching the given GPIO's using a scope doesn't show any changes, to trigger the SPI device I usually change it from RTC to generic spi device (which shows up correctly in /dev/) I run the following commands to keep that device busy:

spi-pipe -d /dev/spidev0.3 -b 4 -n 400 < /dev/zero | hexdump -C

Am I missing something or has the driver lost this capability since the older kernels?

Thanks in advance :slight_smile:

Solved the issue...
Adding compatible = "qca,ar7100-spi"; to the device's &spi devicetree fixes the issue. Now all partitions work and the cs-gpios do as well.
The final device-tree block for the SPI part looks like this:

&spi {
	status = "okay";
	compatible = "qca,ar7100-spi";
	cs-gpios =  <0>, <0>, <0>, <&gpio 15 GPIO_ACTIVE_LOW>, <&gpio 22 GPIO_ACTIVE_LOW>, <&gpio 1 GPIO_ACTIVE_LOW>;
	num-cs = <6>;
	flash@0 {
		compatible = "jedec,spi-nor";
		spi-max-frequency = <50000000>;
		reg = <0>;
		partitions {
			compatible = "fixed-partitions";
			#address-cells = <1>;
			#size-cells = <1>;
			uboot: partition@0 {
				label = "u-boot";
				reg = <0x000000 0x040000>;
				read-only;
			};
			partition@40000 {
				label = "u-boot-env";
				reg = <0x040000 0x010000>;
				read-only;
			};
			partition@50000 {
				compatible = "denx,uimage";
				label = "firmware";
				reg = <0x50000 0xfa0000>;
			};
			art: partition@ff0000 {
				label = "art";
				reg = <0xff0000 0x010000>;
				read-only;
			};
		};
	};

	rtc: rtc@3 {
		compatible = "nxp,pcf2123";
		reg = <3>;
		spi-cs-high;
	};
	flash@4 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "spansion,s25fl512s", "jedec,spi-nor";
		spi-max-frequency = <25000000>;
		reg = <4>;
		partition@00000 {
			label = "dataflash_partition1";
			reg = <0x000000 0x04000000>;
		};
	};
	flash@5 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "spansion,s25fl512s", "jedec,spi-nor";
		spi-max-frequency = <25000000>;
		reg = <5>;
		partition@00000 {
			label = "dataflash_partition2";
			reg = <0x000000 0x04000000>;
		};
	};
};

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.