Analog.com Analog Dialogue Wiki English 简体中文 日本語
EngineerZone
EngineerZone
  • Log In
  • Site
  • Search
  • User
  • Forums

    Popular Forums

    • RF and Microwave
    • Power Management
    • Video
    • FPGA Reference Designs
    • Precision ADCs
    • Linux Software Drivers
    • SigmaDSP Processors & SigmaStudio Dev. Tool

    Product Forums

    • A2B
    • Amplifiers
    • Analog Microcontrollers
    • Clock and Timing
    • Data Converters
    • Direct Digital Synthesis (DDS)
    • Energy Monitoring and Metering
    • Interface and Isolation
    • MEMS Inertial Sensors
    • Processors and DSP
    • Switches/Multiplexers
    • Temperature Sensors
    • Voltage References
    View All

    Application Forums

    • Audio
    • Automated Test Equipment (ATE)
    • Condition-Based Monitoring
    • Depth, Perception & Ranging Technologies
    • Embedded Vision Sensing Library
    • Motor Control Hardware Platforms
    • Optical Sensing
    • Precision Technology Signal Chains Library
    • Video
    • Wireless Sensor Networks Reference Library

    Design Center Forums

    • ACE Evaluation Software
    • ADEF System Platforms
    • Design Tools and Calculators
    • FPGA Reference Designs
    • Linux Software Drivers
    • Microcontroller no-OS Drivers
    • Reference Designs
    • Signal Chain Power (SCP)
    • Software Interface Tools
    • System Demonstration Platform (SDP) Support
  • Learn

    Highlighted Webinar

    Maximize the Benefits of High Bandwidth Current Sense Amplifiers for Space Constrained Applications

    Recent Discussions

    • Pluto is not receiving data
    • ADALM-pluto sampling frequency
    • ADALM PLUTO SDR
    • Bad FIT image format and MSD mounting errors in firmware built for Sidekiq Z2
    • set the sample rate to 30MHz or the maximum that usb2.0 allows

    Places

    • ADI Education Home
    • ADI Webinars
    • StudentZone (Analog Dialogue)
    • Video Annex
    • Virtual Classroom

    Latest Webinars

    • Maximize the Benefits of High Bandwidth Current Sense Amplifiers for Space Constrained Applications
    • Design Efficient Power Solutions for Battery-powered Applications
    • Shunt-based Energy Metering in High-Power Applications
    • Isolating GigaSpeed: Unlocking Data Integrity for USB and HDMI Communication
    • Extend Battery Life and Maximize Performance - Let Supervisors Do The Work
    View All Webinars
  • Community Hub

    Challenge Yourself!

      KCC's Quizzes AQQ245 on Fossil Dating with Carbon14
    View All

    Places

    • Community Help
    • Logic Lounge
    • The Weekly Brew

    Resources

    • EZ Code of Conduct
    • Getting Started Guide
    • ADI: Words Matter
    • Community Help Videos
    View All
  • Blogs

    Highlighted Blogs

    Join the Analog Devices IEEE Radar Challenge

     

    Seeing is Believing but Smart Surveillance Cameras Let You Speak and Listen Too!

    Latest Blogs

    • We are Celebrating a Milestone on EngineerZone: Meet Our 100K Member!
    • How to Raise the Resolution of an Optical Motor Encoder without Changing the Disk
    • The Changing Nature of Logistics and Retail Automation
    • Variable Speed Drive 101
    • How to Optimize Voltage Regulators for Powering an Audio Amplifier
    Read All Blogs

    ADI Blogs

    • EZ Spotlight
    • The Engineering Mind
  • Partners

    Electronic Design Services - PartnerZone

    • Boston Engineering
    • Calian, Advanced Technologies
    • Colorado Engineering Inc. (DBA CAES AT&E)
    • Clockworks Signal Processing
    • Epiq Solutions
    • Fidus
    • PalmSens
    • Richardson RFPD
    • Tri-Star Design, Inc.
    • VadaTech
    • Vanteon
    • X-Microwave
    View All
Linux Bug Archive
  • Processors and DSP
  • Software and Development Tools
  • Linux Distribution for Blackfin
  • Linux Bug Archive
  • Cancel
Linux Bug Archive
Documents [#3821] SPI driver does not respect cs_change
  • Q&A
  • Documents
  • Members
  • Tags
  • More
  • Cancel
  • +Documents
  • +ad1836: FAQ
  • +ad1938: FAQ
  • +ad1939: FAQ
  • +AD5280: FAQ
  • +ad73311: FAQ
  • +adau1361: FAQ
  • +adau1371: FAQ
  • +adau1373: FAQ
  • +adau1761: FAQ
  • +adp5588-gpio: FAQ
  • +adv7393: FAQ
  • +ADXL34x: FAQ
  • +bf518-ezbrd: FAQ
  • +bf518: FAQ
  • +bf51x: FAQ
  • +bf526-ezbrd: FAQ
  • +bf527-ezkit: FAQ
  • +bf533-stamp/ezkit: FAQ
  • +bf533: FAQ
  • +bf538-ezkit: FAQ
  • +bf548-ezkit: FAQ
  • +BF54x: FAQ
  • +bf561-ezkit: FAQ
  • +bf5xx: FAQ
  • +bfin-mac driver: FAQ
  • +bfin-uclinux-gdb: FAQ
  • +bfin_can.c: FAQ
  • +Blackfin: FAQ
  • +bluetooth: FAQ
  • +Build kernel: FAQ
  • +Build: FAQ
  • +cfcard test: FAQ
  • FAQ: [#6170] section mismatches in cifs code(2010)
  • FAQ: [#6173] linphone testing problem(2010)
  • FAQ: [#6190] BF561-EZKIT SMP kernel can not wake up by uart(2010)
  • FAQ: [#6194] libxenomai.so.0 can't be found in xenomai kernel with fdpic mode(2010)
  • FAQ: [#6207] Build error in CTS/RTS testing on board BF548-EZKIT(2010)
  • FAQ: [#6251] pread/pwrite arent decoded correctly by strace(2010)
  • FAQ: [#6253] strace build failed in trunk with outdated toolchain (missing asm/cachectl.h)(2010)
  • FAQ: [#6255] Busybox inetd crashes/rsh noconnet/ssh(2010)
  • FAQ: [#6265] libpng build fails due to not finding zlib(2010)
  • FAQ: [#6271] "nand unlock" is an unsupported command in u-boot update in nand flash(2010)
  • FAQ: [#6272] After update u-boot in spi flash, BF548-EZKIT can not boot from spi flash(2010)
  • +gadget fs bulk: FAQ
  • +gadget zero bulk: FAQ
  • +gadget zero control: FAQ
  • +Kernel xip: FAQ
  • +ltp test: FAQ
  • +microwin test: FAQ
  • +MPU kernel: FAQ
  • +Sl811-hcd.c USB: FAQ
  • +SPORT channel: FAQ
  • +trunk head kernel: FAQ
  • +usb otg driver: FAQ
  • +zlib: FAQ
  • +Illegal i2c: FAQ
  • +isp1362-hcd: FAQ
  • +Kernel: FAQ
  • +KGDBOE: FAQ
  • [#4646] Varittronix LCD driver mixes blue and Red
  • +serial driver: FAQ
  • +sigma firmware: FAQ
  • +spi transaction: FAQ
  • +strace FAQ
  • [#4787] [ltp] LTP test case shmctl01 failed in trunk for ltp-full-20081130
  • +tiff-4.0.0beta4: FAQ
  • [#5264] ping packet size test will fail for gadget ethernet test with DMA mode
  • +USBHOST: FAQ
  • +USB_EP_NI7_RXINTERVAL: FAQ
  • [#5257] Build usb gadget driver with DMA mode will fail
  • [#4708] Blackfin irda build fails for bf533-stamp
  • [#4735] unaligned accesses in qt webkit
  • [#5168] build cpufrequtils into fdpic format has error
  • [#5321] modprobe i2c lcd on bf533 stamp wait long time
  • [#4922] unwanted sound comes up after g_audio module is installed on BF548 and BF527
  • [#5176] app cpufrequtils in Blackfin app programs fails to build in FDPIC
  • [#5237] musb driver is broken after linux-2.6.30 update
  • [#5255] ping target board sometimes get wrong data byte for gadget ethernet pio mode
  • FAQ: [#6614] Kernel panic frequently when test sdio mmc on bf518-ezbrd(2011)
  • [#5336] canbus and ppifcd drivers can not be built on BF538-EZKIT
  • -SPI driver: FAQ
    • [#3821] SPI driver does not respect cs_change
  • [#4714] the first time to build mtd-utils will fail in trunk
  • [#5524] drivers/video/bfin_adv7393fb.c build fails in 2.6.31 due to old i2c usage
  • [#5525] drivers/video/bf537-lq035.c build fails in 2.6.31 due to old i2c usage
  • [#5399] no sound when record in board and listen in PC for linphone test of ad1836 on bf533-stamp
  • [#5458] Drivers Serial:bfin_5xx:ttyBFx fails to generate resume from standby
  • [#4647] build samba fails on trunk now for redefinition in fcntl.h
  • [#5526] ip0x board has broken UART defines after resource reorganization
  • [#5527] drivers/media/video/blackfin/blackfin_cam.c build fails in 2.6.31 due to old i2c usage
  • [#5352] bfin_sport.c setup 2D DMA
  • [#5528] fs/binfmt_elf_fdpic.c build fails when CONFIG_ELF_CORE is enabled in 2.6.31
  • [#5464] isram_write() seems to be busted
  • [#5376] mmap05 sometimes can not pass when MPU
  • [#5534] run aplay/arecord will make system panic after kernel upgraded to 2.6.31
  • [#5361] Microwin (nanox) failed on trunk using AD7897 touch screen
  • [#5544] Sport uart TX stop waiting loop is too long to block RX interrupt in PIO mode when do duplex communication
  • [#5363] spi mmc is not supported in bf533-stamp
  • [#5550] fail to flash ubifs.img to nand
  • [#5470] build xenomai fails for no switchbench
  • [#5437] mathtest fails to compile
  • [#5551] SPI message lost when bus locked
  • [#5370] alsa tool fails to work after wake up from mem in bf537-stamp with ad1836 (can't resolve symbol)
  • [#5561] [ltp ]Kernel dump info when run ltp test cases access02, chown03, fchmod06, fchown03, fchown04
  • [#5377] amixer fail to run on ad1836 audio driver on BF537-STAMP
  • [#5475] build mkfs.ubifs on trunk head fails
  • [#5562] [ltp]some ltp test case is broken for getipckey and getcwd
  • [#5487] build usb.c fail in testsuites/usbdev/ test at asm/swab.h
  • [#5489] t2/t4 failed in gadget zero bulk test with dma mode
  • [#5567] build nand for bf537 fails on trunk
  • [#5494] Run tftlcd test case in bf548-ezkit, kernel crashed at the end
  • [#4879] traps test case 21 exception 0x3f: l1_instruction_access would make kernel panic on bf533 stamp
  • [#5568] Framebuffer DMA Error!!
  • [#5515] 4 more trap cases fails on bf533
  • [#5379] run scratchpad case sometimes would fail
  • [#5519] pushing Blackfin serial resources to boards broke many boards
  • [#5389] build pictureflow fails at branch head
  • [#5531] Usb SL811 failed on uclinux2009r1-rc6 on bf532 board.
  • [#5523] Blackfin MUSB build fails after update to 2.6.31
  • [#5391] For ad1836 and ad1981b, sometimes sound shakes at the end
  • [#5404] build kernel with 0x2000 as BOOT_LOAD address sometimes would fails at build-busybox-1.13.4
  • [#5469] CPU hardly idles anymore in svn trunk
  • [#5695] Build bf537-stamp fails at ad73322 for the latest trunk
  • [#5702] build xenomai into fdpic format fails for no libnative.so
  • [#5427] ircp failed on bf533-stamp
  • [#5708] Kernel can not boot up when spimmc driver is interrupt drivern in PIO mode
  • [#5711] gfortran case default_format_1.exe fails on 09r1 kernel but pass on trunk head
  • [#5712] I2C client drivers using dev_pm_ops fail to receive suspend/resume callbacks
  • [#5715] libpcap fails to compile in trunk
  • [#5589] STLport build fails
  • [#5724] SPORT driver crash on reload
  • [#5449] bfin_sdh doesn't save and restore peripheral context upon resume
  • [#5580] GPIO pin not reserved for CTS function on SPORT-UART driver
  • [#5521] trunk head build fails at ipc/shm.c
  • [#5636] generic gpio works on bf533 in the opposite way
  • [#5637] Kernel crashed when arecord and aplay on bf537-stamp with SoC I2S audio
  • [#5647] SPI driver bus_unlock() does not schedule postponed SPI messages
  • [#5683] build nand fails for format error
  • [#5689] while two or multi spi devices use gpio cs, spi setup will fail
  • [#5558] bfin mac multi-cast sending fails to work
  • [#5816] PREEMPT_RT: cyclic test stalls in some test mode
  • [#5824] some kernel modules fail to link due to losing strcpy in trunk head
  • [#5707] error in user/procps/Makefile
  • [#5841] [ltp] ltp test case shmctl01/semctl01 can not execute
  • [#5605] Build bf537-stamp fail at bf5xx-i2s.c in latest trunk
  • [#5614] With latest toolchain in trunk, fail to build some apps and libs at fork
  • [#5625] Build microwin app fails in trunk with 4.3 toolchain
  • [#5626] Build lib mad fail at option "-fforce-mem" with gcc 4.3
  • [#5722] bfin_sport_spi broken by cs_gpio changes
  • [#5627] fail to control gpio used by led and button through /sys/class/gpio/
  • [#5927] PR bit other than RAF bit in EMAC OPMODE register should be set for promisuous mode in bfin_mac driver
  • [#5727] build e2fsprogs-1.41.12 fail sometimes because of compiling order
  • [#5631] Build lib confuse failed with gcc 4.3 toolchain
  • [#5759] fix build for pwlib
  • [#5651] Build lirc failed at missing files
  • [#5931] Trying to compile CAN4LINUX for BF537-STAMP board but compilation is failing
  • [#5656] Build iproute2 fails at trunk for dlfcn.h when built as FLAT
  • [#5743] sound/soc/blackfin/bf5xx-ad1938.c build fails after 2.6.32 upgrade
  • [#5801] No interrupt occurs when reconnect gadget device in OTG mode.
  • [#5657] [ltp] ltp test case mount03/umount03 fail with error of "No such device"
  • [#5808] mmc configuration error in make config
  • [#5804] bf531: ethernet not working when switching to 2009R1
  • [#5810] initial sp is given wrong value and INIT_TASK_DATA is not linked into data
  • [#6335] Build xip failed in fdpic format when xenomai is enabled
  • [#7224] undifined variable x25_address in ./user/net-tools/lib/x25_src.c
  • [#5598] bluez-utils has parallel build issues with parser.h
  • [#5668] Fail to build app bluez-utils
  • [#7251] Blackfin SPI driver doesn't handle repeated changes in CPOL, CPHA and LSBF correctly
  • [#5767] In 09r1.1 branch, all ltp test cases show stack overflow in bf561 SMP kernel
  • [#5684] touching keypad on bf548 will make system dead and restart
  • [#7287] Can not build usb.c with libaio
  • [#5687] SPI read/write be wrong after suspend to memory and resume
  • [#7315] [ltp] ltp test case getrusage04 from ltp-full-20120903 fails in trunk
  • [#7328] Fail to compile pthread_test after toolchain update
  • [#5876] Repeating rsh/rcp causes error "poll: protocol failure in circuit setup"
  • [#7329] Fail to compile netperf after toolchain update
  • [#7333] Test dll fails to run after toolchain update
  • [#5741] adau1371 and adau1761 fail to build after 2.6.32 upgrade
  • [#7337] [ltp] ltp test case mount02 fails in ltp-full-20120903
  • [#7338] [ltp] ltp test case mount03 fails in ltp-full-20120903
  • [#5821] Fail to build pngview on regression machines with suse 10.2
  • [#5900] hardware single stepping in userspace does not handle syscalls correctly
  • [#5659] [ltp] ltp test case eventfd01 fail
  • [#7339] [ltp] can not apply patch of lchown02 in ltp-full-20101031 to ltp-full-20120903
  • [#7343] [ltp] LTP test case chdir04 fails in ltp-full-20120903
  • [#7396] build netperf fails for undefined reference to `___CPU_ZERO'
  • [#7483] bfin_sport driver does not work well in TDM DMA mode
  • [#7506] Dropbear does not build
  • [#5757] drop USER_SQUASHFS_MKSQUASHFS7Z as squashfs 4.0 does not support 7z anymore
  • [#5758] fix build for libopenh323
  • [#5833] trap test running on the second core of bf561 has serveral fails
  • [#5755] romfs target fails for lib/pwlib
  • [#5760] fix asterisk build
  • [#5756] romfs target fails for lib/libopenh323
  • [#5877] SPI transmit cs_change flag not properly handled
  • [#5939] bfin-can fails to build after linux-2.6.33 upgrade
  • [#5879] GPIO controlled slave request may fail when bfin_spi_setup() gets executed twice
  • [#5774] [ltp]ltp test case will be killed by oom-killer on bf533-ezkit in 09r1 branch occasionally
  • [#5894] BF527 uImage Flashing issue(Copy to Flash... Flash not Erased)
  • [#5941] links fails in trunk due to using fork()
  • [#5942] build usb host fail when remove anomaly 456 for BF526-EZBRD
  • [#7250] On bfin ppi test, it fails to quit from slave when send "q" from master
  • [#7379] Fail to build alsa lib in latest trunk with upgraded toolchain
  • [#5792] enc28j60 spi net fails to ping with host on trunk head kernel
  • [#4436] BF527-EZKIT unable to receive large files over UART in DMA mode
  • [#4764] Kernel prints warning when booting from jffs2 rootfs in nor flash on bf548-ezkit
  • [#5903] Impossible to work properly with two or more SPI slave devices using spi_bfin5xx driver.
  • FAQ: [#6386] build iproute2 may fail at ifstat.c sometimes in latest trunk(2010)
  • FAQ: [#6331] There is error in adau1371 audio testing on bf527-ezkit(2010)
  • [#5933] BF561-EZKIT SMP kernel can not wake up from standby mode by uart interrupt
  • FAQ: [#6564] dmacopy test on bf561-ezkit failed at sram_alloc in L1(2011)
  • [#4713] dmacopy tries to test L2 on BF537
  • [#4997] ppitest fails for bfin_ppi driver on bf537
  • [#5940] lynx fails in trunk due to using fork()
  • [#4104] Format usbdisk failed with mke2fs in trunk
  • FAQ: [#6578] iccutils build fails at scalar.c(2011)
  • [#3883] ftp server crash after connetion or chdir with MidnightCommander4.6.1
  • [#4697] kernel crash on bf533-stamp/bf533-ezkit after config IP for ethernet port
  • [#4050] xip test case failed in BF548-EZKIT
  • [#3991] mmc_spi not working out of the box.
  • [#3996] dhcpcd not stable on BF548-EZKIT
  • [#5136] Linphone: Can't hear each other and "Data access misaligned address violation"
  • [#5214] trunk applications don't build with trunk toolchain due to missing fork()
  • [#4055] top (busybox) crashs
  • [#5162] Linphone: Data access misaligned address
  • [#4992] bfin_sdh fails to build for BF514/BF516
  • [#5570] reboot on bf527-ezkit with nand and ubifs enabled fails
  • [#4955] 548 SDH: netperf, iperf triggers libertas error
  • [#5522] Lib DirectFB-1.4.0 crashes when run DirectFB demo on SVN trunk
  • [#3882] copy file function cp, after few times consume all memory
  • [#4773] BF527 usb-ide hard disk error

[#3821] SPI driver does not respect cs_change

[#3821] SPI driver does not respect cs_change

Submitted By: Larry Samuels

Open Date

2008-01-08 08:09:06     Close Date

2008-01-10 20:08:57

Priority:

High     Assignee:

Bryan Wu

Status:

Closed     Fixed In Release:

N/A

Found In Release:

N/A     Release:

2.6.x

Category:

Drivers     Board:

EZKIT Lite

Processor:

BF537     Silicon Revision:

0.3

Is this bug repeatable?:

Yes     Resolution:

Fixed

Uboot version or rev.:

    Toolchain version or rev.:

App binary format:

N/A     

Summary: SPI driver does not respect cs_change

Details:

I am reporting a bug when using SPI port on BF537 Stamp Board.

I am connecting to a SPI slave device, namely Microchip MCP23S08 SPI I/O Expander.

The chip select (CS) signal goes high after every byte of the transaction,

where I need it to stay low for all 3 bytes of the transaction.

My setup uses the generic kernel driver spidev.c for user land control of Spi,

which calls the spi_bfin5xx.c blackfin driver file.

Below is the changes I made to stamp.c (This way I select AD9960 in make menuconfig

and the spidev driver is then used)

------------------------------stamp.c-----------------------------------------------

#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)

static struct bfin5xx_spi_chip ad9960_spi_chip_info = {

        .enable_dma = 0,

        .bits_per_word = 8,

        .cs_change_per_word = 0,

};

#endif

...........

#if defined(CONFIG_AD9960) || defined(CONFIG_AD9960_MODULE)

        {

//              .modalias = "ad9960-spi",

                .modalias = "spidev",

                .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ */

                .bus_num = 0,

                .chip_select = 2,

                .controller_data = &ad9960_spi_chip_info,

        },

#endif

------------------------------------stamp.c----------------------------------

This creates /dev/spidev0.2 in the target.

My user land application is as follows:

--------------------------------------spi_bug.c-----------------------------

#include <sys/types.h>

#include <sys/stat.h>

#include <sys/poll.h>

#include <stdio.h>

#include <fcntl.h>

#include <getopt.h>

#include <unistd.h>

#include <stdlib.h>

#include <string.h>

#include <sys/ioctl.h>

#include <sys/types.h>

#include <sys/stat.h>

#include <linux/types.h>

#include <linux/spi/spidev.h>

#include <strings.h>

#include "adsp-spiadc.h"

#include "pflags.h"

#define VERSION         "0.8"

#define FUNC_SET_DIR 0

#define FUNC_SET_LED 1

#define FUNC_READ_INPUTS 2

static void do_msg(int fd)

{

      //full duplex transfer - for Microcip MP23S08

      //send 2 bytes, clock in 1 byte

    struct spi_ioc_transfer    xfer[2];

    unsigned char        buf[6], *bp;

    int            status;

    memset(xfer, 0, sizeof xfer);

    memset(buf, 0, sizeof buf);

    buf[0] = 0x41;  // read

        buf[1] = 0x09;  // GPIO register

    xfer[0].tx_buf = (__u64) buf;

    xfer[0].len = 2;

        xfer[0].cs_change = 0;

    xfer[1].rx_buf = (__u64) buf;

    xfer[1].len = 1;

        xfer[1].cs_change = 0;

       ioctl (fd,CMD_SPI_SET_CSENABLE,CFG_SPI_CHIPSEL2);

       ioctl (fd,CMD_SPI_SET_CSLOW,CFG_SPI_CS2VALUE);

    status = ioctl(fd, SPI_IOC_MESSAGE(2), xfer);

    if (status < 0) {

        printf("Error SPI_IOC_MESSAGE\n");

        return;

    }

      ioctl(fd, CMD_SPI_SET_CSDISABLE, CFG_SPI_CHIPSEL2);

      printf ("read: %02x\n", buf[0]);   // display received byte

}

int main(int argc, char ** argv)

{

    int fd;

    printf ("spi_bug v %s\n",VERSION);

    fd = open("/dev/spidev0.2",O_RDWR);  

    if(fd < 0)

    {

            printf("Can't open \/dev\/spi.\n");

            return -1;

    }

    printf ("spi dev opened\n");

    ioctl(fd, CMD_SPI_OUT_ENABLE, 1);

    ioctl(fd, CMD_SPI_MISO_ENABLE, 1);

    ioctl(fd, CMD_SPI_SET_BAUDRATE, 0x10);

    ioctl(fd, CMD_SPI_SET_MASTER, 1);

    printf ("spi dev configured\n");

    do_msg(fd);

    return 0;

}

--------------------------------------spi_bug.c----------------------------

I compile,link and copy spi_bug to /bin of the target

I run using spi_bug

The output waveforms looks like this:

SCLK  __--__--__--__--__--__--__--__--____--__--__--__--__--__--__--__--________

MOSI  --___--______________________-----_________________----________------------

CS2   --________________________________--_______________________________------

cotinued from above:

SLK  ________--__--__--__--__--__--__--__--___________________

MOSI -------------------------------------------------------- (high)

CS2  -------_________________________________------------------

CS2 is PJ11 on the BF537, and on the BF537 EZKIT it is connector SPORT0/pin 21.

Note that CS2 went high after every 8 clock bits. I need it stay low for the

entire 3 byte transaction.

With the CS going high evey byte, the slave device does not respond with any MISO message.

When I use PFlags GPIO in place of the CS signal, my slave device responds correctly.

Unfortunatley using PFLags creates a 100uSec delay  so it is not an acceptable alternative.

Please correct this bug in the driver, or let me know how to correct it.

Regards,

    Larry Samuels

Follow-ups

--- Bryan Wu                                                 2008-01-08 23:35:06

Thanks Larry,

I think I fixed the bug in the svn trunk, please update it.

Or just change one line to fix this issue which was reported as [#3427] bug

before.

---

Index: drivers/spi/spi_bfin5xx.c

===================================================================

--- drivers/spi/spi_bfin5xx.c   (revision 4081)

+++ drivers/spi/spi_bfin5xx.c   (working copy)

@@ -543,7 +543,7 @@ static void giveback(struct driver_data

                bfin_spi_disable(drv_data);

        }

-       if (!drv_data->cs_change)

+       if (drv_data->cs_change)

                cs_deactive(drv_data, chip);

        if (msg->complete)

----

-Bryan Wu

---

--- Larry Samuels                                            2008-01-09 10:35:20

Bryan

   I made the change as you suggested.  I also inserted a printk message to

confirm the change is in the kernel.

Still have the same problem.

If you copy my code from spi_bug.c and run it, you will see the CS signal going

high on an oscilloscope.

   I feel that the bug still exists.  If there is something wrong with my user

code spi_bug.c, then let me know.

Larry

--- Bryan Wu                                                 2008-01-09 13:19:03

Larry:

Firstly, there are something wrong in the spi_bug.c

<adsp-spiadc.h> is only for "Blackfin BF53x ADSP SPI ADC

support" (drivers/char/bfin_spi_adc.c). So some ioctl similar to following

code are useless.

--

ioctl (fd,CMD_SPI_SET_CSENABLE,CFG_SPI_CHIPSEL2);

ioctl (fd,CMD_SPI_SET_CSLOW,CFG_SPI_CS2VALUE);

--

The same ioctl API you can found in include/linux/spi/spidev.h

Please replace the adsp-spiadc code to spidev API.

Secondly, if software intend to control cs_change, the CPHA should be set in

SPI_CTL register. So you have 2 method to do this:

1) set spi_mode to SPI_MODE_1 (SPI_CPHA | 0) in

arch/blackfin/mach-bf537/boards/stamp.c

---

#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)

static struct bfin5xx_spi_chip spidev_chip_info = {

        .enable_dma = 0,

        .bits_per_word = 8,

        .cs_change_per_word = 0,

};

#endif

...........

#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE)

        {

                .modalias = "spidev",

                .max_speed_hz = 6250000,     /* max spi clock (SCK) speed in HZ

*/

                .bus_num = 0,

                .chip_select = 2,

                .controller_data = &spidev_chip_info,

                .mode = SPI_MODE_1,

        },

#endif

----

2) set CPHA in the spi_bug.c

---

ioctl(fd, SPI_IOC_WR_MODE, SPI_MODE_1);

---

Please revert my previous patch and do some test.

I will do the same test tomorrow morning in the office.

-Bryan Wu

--- Larry Samuels                                            2008-01-09 15:33:10

Byan,

  I made the changes to stamp.c as you suggested.

I did not do 2) ioctl(fd, SPI_IOC_WR_MODE, SPI_MODE_1)

I then added a pullup resistor to CS2 line.

Thie signal now goes low before the 3 byte transmission, and then goes high

after the 3 bytes as it should.  So that is working now.

The problem now is if I send consecutive messages, each message takes 83 usec

to transmit.

For each message:

After CS goes low, the 1st SCLK pulse appears 29 uSec later.

After the last SCLK pulse, CS goes high in 8.8 uSec

The next message CS goes low 38 uSec after that.

The portion of the message where SCLK runs is 10 uSec

So I'm losing 73 uSec of throughput every message.

Can you find a way to minimize the delay in CS to SCLK, and message to

message?

--- Bryan Wu                                                 2008-01-09 21:33:42

Thanks. Did you revert my previous patch:

--

Index: drivers/spi/spi_bfin5xx.c

===================================================================

--- drivers/spi/spi_bfin5xx.c   (revision 4081)

+++ drivers/spi/spi_bfin5xx.c   (working copy)

@@ -543,7 +543,7 @@ static void giveback(struct driver_data

                bfin_spi_disable(drv_data);

        }

-       if (!drv_data->cs_change)

+       if (drv_data->cs_change)

                cs_deactive(drv_data, chip);

        if (msg->complete)

---

For the second problem, can you open another bug tracker?

I wanna close this bug with other 2 same issues in my bug list.

Thanks

-Bryan Wu

--- Larry Samuels                                            2008-01-10 08:57:16

I found out from the BF537 Hardware Reference Manual, that only when CPHA is 1,

and therefore SPI_MODE_ and SPI_MODE_3 will CS stay enabled for the whole

transaction.

From the HRM:

When CPHA = 0, the slave select line, SPISS, must be inactive (high)

between each serial transfer. This is controlled automatically by the SPI

hardware logic. When CPHA = 1, SPISS may either remain active (low)

between successive transfers or be inactive (high). This must be controlled

by the software via manipulation of SPI_FLG.

So it is the Blackfin hardware that causes CS to go high after every byte or

word.  Only with a custom driver controlling the CS line in software could you

get SPI_MODE_0 or SPI_MODE_2 to allow CS to stay active (low) for the entire

transaction.

I will close out this bug.  Still would like to correct the timing issue.  I

will open a bug for that.

--- Larry Samuels                                            2008-01-10 09:02:02

Bryan - I need you to close out this bug.  Thanks

--- Bryan Wu                                                 2008-01-10 22:08:23

OK, Larry.

I will close this, could you tell me do you reverted my previous patch before

you did the test?

Thanks

-Bryan Wu

--- Larry Samuels                                            2008-01-11 08:50:28

Bryan,

  I did revert to the original patch in spi_bfin5xx.c.  No need to patch that.

The only issue is timing, which is covered in bug 3823.

So: if (!drv_data->cs_change)   should remain in the code.

Larry

--- Bryan Wu                                                 2008-01-11 12:31:45

OK, Larry.

I will remove it.

-Bryan

    Files

    Changes

    Commits

    Dependencies

    Duplicates

    Associations

    Tags

File Name     File Type     File Size     Posted By

No Files Were Found

  • Share
  • History
  • More
  • Cancel
Related
Recommended
Social
Quick Links
  • About ADI
  • ADI Signals+
  • Analog Dialogue
  • Careers
  • Contact us
  • Investor Relations
  • News Room
  • Quality & Reliability
  • Sales & Distribution
  • Incubators
Languages
  • English
  • 简体中文
  • 日本語
myAnalog

Interested in the latest news and articles about ADI products, design tools, training and events?

Go to myAnalog
Analog Logo
©1995 - 2023 Analog Devices, Inc. All Rights Reserved
沪ICP备09046653号-1
  • Sitemap
  • Legal
  • Privacy & Security
  • Privacy Settings
  • Cookie Settings