Skip to contentSkip to conversation

x86: Add SPI slaves to PCIe SPI master?

DISCUSSION Alexander Stein 3 participants 5 messages Jan 11, 2017 – Jan 12, 2017 2 messages not in the archive SPI

lore
Share & tools
lore
#0 lore raw

Hi,

I have a customer board using Baytrail E3805 CPU. I want to access a chip attached to SPI using spidev. but for this the slave has to be attached. This is the corresponding lspci entry:

Quoted 1 line

00:1e.5 Serial bus controller [0c80]: Intel Corporation Atom Processor

Z36xxx/Z37xxx Series LPIO1 SPI Controller (rev 11) PCIe vendor and product ID is 8086:0f0e

I tried using the following entry in APCI DSDT as a subnode to the SPI device:

Quoted 21 lines

Device (TAMP)

{
    Name (_ADR, 1)
    Name (_CID, "SPT0001") // Dummy name for spidev
    Method (_CRS, 0, Serialized)  // _CRS: Current Resource Settings
    {
        Name (UBUF, ResourceTemplate ()
        {
            SPISerialBus
            (
                1,          //Slave select CS0 (_ADR)
                PolarityLow,        //Polarity of CS0 output(_DPL)
                FourWireMode,       //(_MOD)
                8,          //8-bit frame(_LEN)
                ControllerInitiated,    //(_SLV)
                2000000,       //Speed Hz (_SPE)
                ClockPolarityLow,  //(_POL)
                ClockPhaseFirst,   //(_PHA)
                "\\_SB.SPI1",          //Controller
            )
        })
Quoted 8 lines
        Return (UBUF)
    }
    
    Method (_STA, 0, NotSerialized)  // _STA: Status
    {
        Return (0x0F)
    }
}

Apparently this only works when the device is probed by ACPI but not when using PCIe (driver: pxa2xx_spi_pci). So I am wondering: How can I add a slave to this PCIe spi master.

Best regards,
Alexander

Signature · 22 lines
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org

Legal and Commercial Address:
Am Windrad 2
08468 Heinsdorfergrund
Germany

Office: +49 (0) 3765 38600-0
Fax:    +49 (0) 3765 38600-4100
 
Managing Directors:
	Director Technology/CEO: Dipl.-Phys. Siegmar Schmidt;
	Director Commercial Affairs/COO: Dipl. Ing. (FH) Armin von Collrepp
Commercial Registry:
	Amtsgericht Chemnitz, HRB 28082; USt.-Id Nr. DE150534010

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#1 lore raw
Quoted 4 lines · Alexander Stein

Hi,

I have a customer board using Baytrail E3805 CPU. I want to access a chip attached to SPI using spidev.

First of all, this is wrong approach. Do you have a driver for the chip? Are going to develop one?
Elaborate, please.

Quoted 5 lines

but for this the slave has to be attached.
This is the corresponding lspci entry:

Quoted 1 line

00:1e.5 Serial bus controller [0c80]: Intel Corporation Atom Processor

Z36xxx/Z37xxx Series LPIO1 SPI Controller (rev 11) PCIe vendor and product ID is 8086:0f0e

It's not what we are interested to see :-)

Basically you need
a) not ancient kernel (what's version of yours?);
b) check proper ACPI node for the PCIe device (something like _SB.PCI0.SPI1).

If there is no such node, just incorporate it using ACPI upgrade table mechanism.

Quoted 31 lines

I tried using the following entry in APCI DSDT as a subnode to the SPI device:

Quoted 21 lines

Device (TAMP)

{
    Name (_ADR, 1)
    Name (_CID, "SPT0001") // Dummy name for spidev
    Method (_CRS, 0, Serialized)  // _CRS: Current Resource Settings
    {
        Name (UBUF, ResourceTemplate ()
        {
            SPISerialBus
            (
                1,          //Slave select CS0 (_ADR)
                PolarityLow,        //Polarity of CS0 output(_DPL)
                FourWireMode,       //(_MOD)
                8,          //8-bit frame(_LEN)
                ControllerInitiated,    //(_SLV)
                2000000,       //Speed Hz (_SPE)
                ClockPolarityLow,  //(_POL)
                ClockPhaseFirst,   //(_PHA)
                "\\_SB.SPI1",          //Controller
            )
        })
Quoted 8 lines
        Return (UBUF)
    }

    Method (_STA, 0, NotSerialized)  // _STA: Status
    {
        Return (0x0F)
    }
}
Quoted 3 lines

Apparently this only works when the device is probed by ACPI but not when using PCIe (driver: pxa2xx_spi_pci). So I am wondering: How can I add a slave to this PCIe spi master.

Adding Mika to Cc list he might have some additional information to share.

Signature · 6 lines
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#3 lore raw
In reply to a message not in the archive
Quoted 14 lines · Andy Shevchenko
Quoted 4 lines · Alexander Stein

Hi,

I have a customer board using Baytrail E3805 CPU. I want to access a chip attached to SPI using spidev.

First of all, this is wrong approach. Do you have a driver for the chip? Are going to develop one?
Elaborate, please.

Quoted 3 lines

but for this the slave has to be attached.
This is the corresponding lspci entry:

Quoted 1 line

00:1e.5 Serial bus controller [0c80]: Intel Corporation Atom Processor

Quoted 8 lines
Quoted 2 lines

Z36xxx/Z37xxx Series LPIO1 SPI Controller (rev 11) PCIe vendor and product ID is 8086:0f0e

It's not what we are interested to see :-)

Basically you need
a) not ancient kernel (what's version of yours?);
b) check proper ACPI node for the PCIe device (something like _SB.PCI0.SPI1).

You can find the node by running following command

 # cat /sys/bus/pci/devices/0000:00:1e.5/firmware_node/path
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#5 lore raw
In reply to a message not in the archive
Quoted 6 lines · Mika Westerberg
Quoted 5 lines · Andy Shevchenko

On Wed, Jan 11, 2017 at 5:08 PM, Alexander Stein

Quoted 2 lines · <alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org> wrote:

Hi,

Quoted 7 lines
Quoted 7 lines
Quoted 3 lines

I have a customer board using Baytrail E3805 CPU. I want to access a chip
attached to SPI using spidev.

First of all, this is wrong approach. Do you have a driver for the chip? Are going to develop one?
Elaborate, please.

There is no driver and I won't do any either. Can't say much more about that, sorry.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

but for this the slave has to be attached.

This is the corresponding lspci entry:

Quoted 1 line

00:1e.5 Serial bus controller [0c80]: Intel Corporation Atom Processor

Quoted 7 lines
Quoted 7 lines
Quoted 2 lines

Z36xxx/Z37xxx Series LPIO1 SPI Controller (rev 11) PCIe vendor and product ID is 8086:0f0e

It's not what we are interested to see :-)

Basically you need
a) not ancient kernel (what's version of yours?);

This is a up-to-date archlinux, so I'm running 4.8.13-1-ARCH kernel.

Quoted 5 lines
Quoted 2 lines

b) check proper ACPI node for the PCIe device (something like _SB.PCI0.SPI1).

You can find the node by running following command

 # cat /sys/bus/pci/devices/0000:00:1e.5/firmware_node/path

result: \_SB_.PCI0.D023

The node itself is just:

Quoted 4 lines

Device (D023)

{
    Name (_ADR, 0x001E0005)  // _ADR: Address
}

Well, I'm not experienced with ACPI tables at all, but adding a device like in the 1st post I got my spi slave device, to my surprise I have to admit.

Thanks for that hint about the, kinda dummy, node for the PCIe device node. I didn't expect adding a slave device there would result in having a linux device too.

Best regards,
Alexander

Signature · 22 lines
Dipl.-Inf. Alexander Stein
SYS TEC electronic GmbH
alexander.stein-93q1YBGzJSMe9JSWTWOYM3xStJ4P+DSV@public.gmane.org

Legal and Commercial Address:
Am Windrad 2
08468 Heinsdorfergrund
Germany

Office: +49 (0) 3765 38600-0
Fax:    +49 (0) 3765 38600-4100
 
Managing Directors:
	Director Technology/CEO: Dipl.-Phys. Siegmar Schmidt;
	Director Commercial Affairs/COO: Dipl. Ing. (FH) Armin von Collrepp
Commercial Registry:
	Amtsgericht Chemnitz, HRB 28082; USt.-Id Nr. DE150534010

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#6 lore raw
Quoted 8 lines · Alexander Stein

result: \_SB_.PCI0.D023

The node itself is just:

Quoted 4 lines

Device (D023)

{
    Name (_ADR, 0x001E0005)  // _ADR: Address
}
Quoted 6 lines

Well, I'm not experienced with ACPI tables at all, but adding a device like in the 1st post I got my spi slave device, to my surprise I have to admit.

Thanks for that hint about the, kinda dummy, node for the PCIe device node. I didn't expect adding a slave device there would result in having a linux device too.

That node is needed because it provides _ADR that ACPI core uses to bind the PCI device to the ACPI node. This further allows the SPI core ACPI enumeration code to find your slave device under \_SB_.PCI0.D023. --
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html