Skip to contentSkip to conversation

Ask for help on SPI slave side driver support

DISCUSSION YouShenghui 3 participants 8 messages Sep 29, 2013 – Oct 14, 2013 2 messages not in the archive Arm Samsung Exynos

lore
Share & tools
lore
#0 lore raw

Hi Samsung expert,
I am working a project that need spi slave side driver support in smdk6410 in linux.
I am connecting two 6410 board with spi bus, one side as master, the other as slave. Data is passed from one side to the other. I looked over spi related code in kernel and only find spi master support.
I see http://www.spinics.net/lists/arm-kernel/msg73403.html that said there was already spi slave support in Samsungs current code. Could you give me a suggestion where I could find that code? I would like to port slave side support code to my code though it's not upstream yet.

thanks
ysh

#1 lore raw

Hi,

[Ccing Mark Brown, maintainer of Linux SPI subsystem]

Quoted 10 lines · On Monday 30 of September 2013 00:23:32 YouShenghui wrote:

Hi Samsung expert,
I am working a project that need spi slave side driver support in smdk6410 in linux. I am connecting two 6410 board with spi bus, one side as master, the other as slave. Data is passed from one side to the other. I looked over spi related code in kernel and only find spi master support. I see
http://www.spinics.net/lists/arm-kernel/msg73403.html that said there was already spi slave support in Samsungs current code. Could you give me a suggestion where I could find that code? I would like to port slave side support code to my code though it's not upstream yet.

Mark will probably know better, but AFAIK there is no API for slave mode SPI available in Linux kernel. Please correct me if I'm wrong.

The code mentioned in the post from your link was some internal vendor code, which is unlikely to be available publicly. However support for slave mode from hardware side seems more or less similar to master mode, which means that assuming you can add some kernel API for it, the modification to the spi-s3c64xx wouldn't be too big.

Best regards,
Tomasz

#2 lore raw

At 2013-09-30 07:20:42,"Tomasz Figa" <[email protected]> wrote: >Hi, > >[Ccing Mark Brown, maintainer of Linux SPI subsystem] > >On Monday 30 of September 2013 00:23:32 YouShenghui wrote: >> Hi Samsung expert, >> I am working a project that need spi slave side driver support in >> smdk6410 in linux. I am connecting two 6410 board with spi bus, one >> side as master, the other as slave. Data is passed from one side to the >> other. I looked over spi related code in kernel and only find spi >> master support. I see >> http://www.spinics.net/lists/arm-kernel/msg73403.html that said there >> was already spi slave support in Samsungs current code. Could you give >> me a suggestion where I could find that code? I would like to port >> slave side support code to my code though it's not upstre
am yet. > >Mark will probably know better, but AFAIK there is no API for slave mode >SPI available in Linux kernel. Please correct me if I'm wrong. > >The code mentioned in the post from your link was some internal vendor >code, which is unlikely to be available publicly. However support for >slave mode from hardware side seems more or less similar to master mode, >which means that assuming you can add some kernel API for it, the >modification to the spi-s3c64xx wouldn't be too big. > >Best regards, >Tomasz >
Thanks for your answer.
Yes, It will not be a big patch. But I feel hard to add the support as a application developer so I want if they could send me a small patch to make it work.
ysh

#3 lore raw
In reply to Tomasz Figa
Quoted 2 lines · Tomasz Figa

Mark will probably know better, but AFAIK there is no API for slave mode SPI available in Linux kernel. Please correct me if I'm wrong.

That's correct.

Quoted 5 lines

The code mentioned in the post from your link was some internal vendor code, which is unlikely to be available publicly. However support for slave mode from hardware side seems more or less similar to master mode, which means that assuming you can add some kernel API for it, the modification to the spi-s3c64xx wouldn't be too big.

There were some people working on slave mode (or at least talking about it) but I don't think they ever sent it. It'd probably just be the same as master mode but with transfers triggered from /CS instead of from driver action. The biggest trick would be making sure the transfer is running before the master actually starts sending data.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 1 line · YouShenghui

At 2013-09-30 17:33:17,"Mark Brown" <[email protected]> wrote: >On Mon, Sep 30, 2013 at 01:20:42AM +0200, Tomasz Figa wrote: > >> Mark will probably know better, but AFAIK there is no API for slave mode >> SPI available in Linux kernel. Please correct me if I'm wrong. > >That's correct. > >> The code mentioned in the post from your link was some internal vendor >> code, which is unlikely to be available publicly. However support for >> slave mode from hardware side seems more or less similar to master mode, >> which means that assuming you can add some kernel API for it, the >> modification to the spi-s3c64xx wouldn't be too big. > >There were some people working on slave mode (or at least talking about >it) but I don't think they ever sent it. It'd probably just be the same >as master mode but with transfers triggered from /CS instead of from >driver action. The biggest trick would be making sure the transfer is >running before the master actually starts sending data

The formatting of your mail is really bad, I can barely read it. Please check the configuration of your mail program, there are some suggstions for common clients in Documentation/email-clients.txt.

Quoted 2 lines

Thanks for Mark for your answer.
But how could I trigger from /CS? Could I enable transfer in open syscall?

I'd expect this to be done in-kernel, at least in the first instance.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

On Mon, Oct 14, 2013 at 03:05:58AM +0800, YouShenghui wrote:

Please fix your mailer to word wrap within paragraphs, your messages are very hard to read.

Quoted 4 lines

Ok, I have one question when reading drivers/spi/spi-s3c64xx.c
In s3c64xx_spi_setup, cs->line(S3C64XX_GPC(3)) is set to GPIOF_OUT_INIT_HIGH, that means an general output pin. But the other three(clk, mosi, miso) was set to 2 by s3c64xx_spi0_cfg_gpio. This is just what is needed by SPI. My question is why wasn't cs->line also set to 2 to use SPI CS0?

In common with many drivers this driver controls the chp select as a GPIO. Generally the hardware is less flexible than Linux can be if it implements automatic chip select handling at all.

Quoted 1 line

When I want to use spi as slave side, should I set S3C64XX_GPC(3)'s cfg of to 0(input) or 2?

I don't think the controller has any slave support natively so you'd probably need to put it into GPIO mode.

author
#8 lore raw
Quoted 10 lines · Mark Brown

On Mon, Oct 14, 2013 at 03:05:58AM +0800, YouShenghui wrote:

Please fix your mailer to word wrap within paragraphs, your messages are very hard to read.

Quoted 4 lines

Ok, I have one question when reading drivers/spi/spi-s3c64xx.c
In s3c64xx_spi_setup, cs->line(S3C64XX_GPC(3)) is set to GPIOF_OUT_INIT_HIGH, that means an general output pin. But the other three(clk, mosi, miso) was set to 2 by s3c64xx_spi0_cfg_gpio. This is just what is needed by SPI. My question is why wasn't cs->line also set to 2 to use SPI CS0?

Quoted 8 lines

In common with many drivers this driver controls the chp select as a GPIO. Generally the hardware is less flexible than Linux can be if it implements automatic chip select handling at all.

Quoted 1 line

When I want to use spi as slave side, should I set S3C64XX_GPC(3)'s cfg of to 0(input) or 2?

I don't think the controller has any slave support natively so you'd probably need to put it into GPIO mode.

Got it, then what about the setting of clk, mosi, miso pin in slave mode? Do you mean I need to simulate spi slave side using four gpios?

thanks
zduan

#9 lore raw
Quoted 2 lines · ysh

Got it, then what about the setting of clk, mosi, miso pin in slave mode? Do you mean I need to simulate spi slave side using four gpios?

Hrm, now I think about it clock is going to be a problem... you're probably stuck with bitbanging unless there's some controller support which won't be awesome.