OpenWrt Forum Archive

Topic: Pogoplug Mobile: Unable to make SPI work

The content of this topic has been archived on 6 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

I wish to access an SPI flash IC at reasonable speed. The pogo mobile is the one device I possess where the hardware SPI bus is accessible by pin header. But it doesn't work!

My setup is:
MX25L6405D SOIC in a socket on a breadboard. The signal pins are all brought out to a convenient tie point and have indicator LEDs weakly pulled to ground. ~CS is pulled up with a 10K resistor.

Machine 1: Pogoplug Mobile with pin headers installed at J11 (UART) and J17 (SPI).
Machine 2: Guruplug Server Plus with jump wire connected to (U-SNAP).
Software: OpenWRT r44597, Kirkwood generic/FDT, initramfs, build patches. spi-gpio-custom, spidev, flashrom. The same build and physical medium is used to boot both devices.

Known Good: Guruplug, using spi-gpio-custom, flashrom is able to successfully perform all functions.

You may need to add code to the kernel to let it be aware of the existence of spidev. Snippet code:

static struct spi_board_info pogo_spi_info[] = {
    {
        .bus_num    = 0,
        .chip_select    = 1,
        .mode        = 0,
        .max_speed_hz    = 781000,
        .modalias    = "spidev",
    },
};

snippet code for registering the the spi driver

    .spis = pogo_spi_info,
    .num_spis = ARRAY_SIZE(pogo_spi_info),

No idea at wich kernel file you should introduce this code, or check if already exists. I tested this succesfully in my own router HG556a, but I prefer to define a spi flash memory instead of spidev

static struct mtd_partition epc_partitions[] = {
    [0] = {
        .name        = "external-flash",
        .offset        = 0x0,
    },
};

static struct flash_platform_data blue5g_spiflash_data = {
    .parts        = epc_partitions,
    .nr_parts    = ARRAY_SIZE(epc_partitions),
    .max_transfer_len = 44,
};


static struct spi_board_info blue5g_spi_info[] = {
    {
        .bus_num    = 0,
        .chip_select    = 0,
        .mode        = 0,
        .max_speed_hz    = 781000,
        .modalias    = "m25p80",
        .platform_data    = &blue5g_spiflash_data,
    },
};

this way I simply use mtd.

Also remember to instal spidev kernel modules, or CONFIG_MTD_M25P80 enabled in the kernel for the last driver.

And check if you are using an slave select different to 0, or if pinmux needs  to be enabled.

You should provide the patch file instead of the above snippet codes that no one knows to which file(s) they should be applied.

Ah, it looks like I'm missing a pinctrl setting. FWIW, my current device tree file:

/dts-v1/;

#include "kirkwood.dtsi"
#include "kirkwood-6192.dtsi"
/* kirkwood 6192 */
/ {
    model = "Cloud Engines Pogoplug Mobile";
    compatible = "cloudengines,pogov4a1", "marvell,kirkwood-88f6192", "marvell,kirkwood";

    memory {
        device_type = "memory";
        reg = <0x00000000 0x10000000>;
    };

    chosen {
        bootargs = "console=ttyS0,115200n8 earlyprintk";
    };

    ocp@f1000000 {
        pinctrl: pinctrl@10000 {
            pmx_led_green: pmx-led_green {
                marvell,pins = "mpp22";
                marvell,function = "gpio";
            };
            pmx_led_red: pmx-led_red {
                marvell,pins = "mpp24";
                marvell,function = "gpio";
            };
            pmx_sdio_cd: pmx_sdio_cd {
                marvell,pins = "mpp27";
                marvell,function = "gpio";
            };
            pmx_sdio_wp: pmx_sdio_wp {
                marvell,pins = "mpp28";
                marvell,function = "gpio";
            };
                        pmx_eject_button: pmx_eject_button {
                                marvell,pins = "mpp29";
                                marvell,function = "gpio";
                        };
            pmx_nand: pmx-nand {
                marvell,pins = "";
                marvell,function = "nand";
            };
            pmx_spi: pmx-spi {
                marvell,pins = "mpp7", "mpp1", "mpp2", "mpp3";
                marvell,function = "spi";
            };
        };
        uart0: serial@12000 {
            status = "okay";
        };
        uart1: serial@12100 {
            status = "disabled";
        };
        i2c0: i2c@11000 {
            status = "okay";
        };
        spi0: spi@10600 {
            status = "okay";
            spidev@0 {
                compatible = "spidev";
                spi-max-frequency = <10000000>;
                reg = <0>;
                mode = <0>;
            };
        };
        nand0: nand@0012f {
            chip-delay = <40>;
            status = "disabled";
        };
        rtc@10300 {
            status = "disabled";
        };
        sata@80000 {
            status = "disabled";
        };
        mvsdio@90000 {
            pinctrl-0 = <&pmx_sdio &pmx_sdio_cd &pmx_sdio_wp>;
            pinctrl-names = "default";
            cd-gpios = <&gpio0 27 1>;
            wp-gpios = <&gpio0 28 0>;
            status = "okay";
        };

    };
        gpio-keys {
                compatible = "gpio-keys";
                #address-cells = <1>;
                #size-cells = <0>;
        pinctrl-0 = <&pmx_eject_button>;
                pinctrl-names = "default";

                button@1 {
                        label = "Eject button";
                        linux,code = <KEY_EJECTCD>;
                        gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
                };
        };
    gpio-leds {
        compatible = "gpio-leds";
        pinctrl-0 = < &pmx_led_red &pmx_led_green >;
        pinctrl-names = "default";

        health {
            label = "status:green:health";
            gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
            default-state = "keep";
        };
        fault {
            label = "status:red:fault";
            gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
        };
    };
};

&mdio {
    status = "okay";

    ethphy0: ethernet-phy@0 {
        reg = <0>;
    };
};

&eth0 {
    status = "okay";
    ethernet0-port@0 {
        phy-handle = <&ethphy0>;
    };
};

The discussion might have continued from here.