2009-05-31 03:37:09 Help: SPORT emulate SPI for SD Card?
Tony Liu (CHINA)
Message: 74832
I'm using "Device Driver->SPI Support->emulate SPI bus with Blackfin SPORT" to connect a SD Card.
Circuit Connect as below:
SPORT1 function PINS:
TSCLK1 + RSCLK1 -> SD SDCLK
TFS1 + RFS1 -> SD DAT3 (#CS)
DR1PRI -> SD DAT0(As SPI MISO function)
DT1PRI -> SD CMD (As SPI MOSI function)
& build the driver in kernel.
At start I'm not find the related message of emulate SPI bus with Blackfin SPORT.
cat /proc/interrupts & no find the registed sport interrupt resource.
How to configure & modify ?
Thanks!
QuoteReplyEditDelete
2009-05-31 04:13:33 Re: Help: SPORT emulate SPI for SD Card?
Sonic Zhang (CHINA)
Message: 74833
Did you build the mmc_spi driver into your kernel as well?
QuoteReplyEditDelete
2009-05-31 04:21:15 Re: Help: SPORT emulate SPI for SD Card?
Yi Li (CHINA)
Message: 74872
Can you find anything in /sys/bus/spi/ ?
-Yi
QuoteReplyEditDelete
2009-05-31 09:30:29 Re: Help: SPORT emulate SPI for SD Card?
Tony Liu (CHINA)
Message: 74877
Thanks!
My platform: CPU BF531
uCLinux Dist: 2009R (svn update 20090427)
I added the related __initdata (mach-bf533\boards]\ezkit.c)for SPORT emulate SPI as below:
#if defined(CONFIG_SPI_BFIN_SPORT) //|| defined(CONFIG_SPI_BFIN_SPORT_MODULE)
/* SPORT SPI controller data */
static struct bfin5xx_spi_master bfin_sport_spi0_info = {
.num_chipselect = 1, /* master only supports one device */
.enable_dma = 0, /* master don't support DMA */
.pin_req = {P_SPORT0_DTPRI, P_SPORT0_TSCLK, P_SPORT0_DRPRI,
P_SPORT0_RSCLK, P_SPORT0_TFS, P_SPORT0_RFS, 0},
};
static struct resource bfin_sport_spi0_resource[] = {
[0] = {
.start = SPORT0_TCR1,
.end = SPORT0_TCR1 + 0xFF,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_SPORT0_ERROR,
.end = IRQ_SPORT0_ERROR,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device bfin_sport_spi0_device = {
.name = "bfin-sport-spi",
.id = 1, /* Bus number */
.num_resources = ARRAY_SIZE(bfin_sport_spi0_resource),
.resource = bfin_sport_spi0_resource,
.dev = {
.platform_data = &bfin_sport_spi0_info, /* Passed to driver */
},
};
static struct bfin5xx_spi_master bfin_sport_spi1_info = {
.num_chipselect = 1, /* master only supports one device */
.enable_dma = 0, /* master don't support DMA */
.pin_req = {P_SPORT1_DTPRI, P_SPORT1_TSCLK, P_SPORT1_DRPRI,
P_SPORT1_RSCLK, P_SPORT1_TFS, P_SPORT1_RFS, 0},
};
static struct resource bfin_sport_spi1_resource[] = {
[0] = {
.start = SPORT1_TCR1,
.end = SPORT1_TCR1 + 0xFF,
.flags = IORESOURCE_MEM,
},
[1] = {
.start = IRQ_SPORT1_ERROR,
.end = IRQ_SPORT1_ERROR,
.flags = IORESOURCE_IRQ,
},
};
static struct platform_device bfin_sport_spi1_device = {
.name = "bfin-sport-spi",
.id = 2, /* Bus number */
.num_resources = ARRAY_SIZE(bfin_sport_spi1_resource),
.resource = bfin_sport_spi1_resource,
.dev = {
.platform_data = &bfin_sport_spi1_info, /* Passed to driver */
},
};
#endif /* sport spi master and devices */
static struct platform_device *ezkit_devices[] __initdata = {
//Tony add
#if defined(CONFIG_SPI_BFIN_SPORT) //|| defined(CONFIG_SPI_BFIN_SPORT_MODULE)
&bfin_sport_spi0_device,
&bfin_sport_spi1_device,
#endif ........................
}
then start message can get:
bfin-sport-spi bfin-sport-spi.1: Blackfin SPORT emulated SPI Driver, Version 1.0, regs_base@ffc00800
bfin-sport-spi bfin-sport-spi.2: Blackfin SPORT emulated SPI Driver, Version 1.0, regs_base@ffc00900
Add the MMC/SD init data at this file:
//tony add
#if 1//defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) || defined(CONFIG_SPI_BFIN_SPORT)
#define MMC_SPI_CARD_DETECT_INT IRQ_PF5
static int bfin_mmc_spi_init(struct device *dev,irqreturn_t (*detect_int)(int, void *), void *data)
{
return request_irq(MMC_SPI_CARD_DETECT_INT, detect_int,IRQF_TRIGGER_FALLING, "mmc-spi-detect", data);
}
static void bfin_mmc_spi_exit(struct device *dev, void *data)
{
free_irq(MMC_SPI_CARD_DETECT_INT, data);
}
static struct mmc_spi_platform_data bfin_mmc_spi_pdata = {
.init = bfin_mmc_spi_init,
.exit = bfin_mmc_spi_exit,
.detect_delay = 100, /* msecs */
};
static struct bfin5xx_spi_chip mmc_spi_chip_info = {
.enable_dma = 0,
.bits_per_word = 8,
};
#endif
static struct spi_board_info bfin_spi_board_info[] __initdata = {
//tony
#if 1//defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) || defined(CONFIG_SPI_BFIN_SPORT)
{
.modalias = "mmc_spi",
.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 0,
.chip_select = 3,
.platform_data = &bfin_mmc_spi_pdata,
.controller_data = &mmc_spi_chip_info,
.mode = SPI_MODE_3,
},
#endif
...................
}
Not find the /dev/mmcxxxx device node. & no SD Card start up message.
At /sys/bus dir have :
/sys/bus/spi/device
/sys/bus/spi/drivers/mmc_spi/uevent
/sys/bus/spi/uevent
cat /proc/interrupt
10: 0 INTN sport_err
11: 0 INTN sport_err
How to modify?
Thanks!
QuoteReplyEditDelete
2009-05-31 21:54:50 Re: Help: SPORT emulate SPI for SD Card?
Yi Li (CHINA)
Message: 74879
You can refer to arch/blackfin/mach-bf537/boards/stamp.c and understant it.
".bus_num = 0," need to be ".bus_num=1" I think.
-Yi
QuoteReplyEditDelete
2009-05-31 23:36:11 Re: Help: SPORT emulate SPI for SD Card?
Sonic Zhang (CHINA)
Message: 74881
You'd better disable CONFIG_SPI_BFIN, otherwize there are 2 SPI buses in your system. You may set the wrong bus_num in your mmc spi configuration.
QuoteReplyEditDelete
2009-06-01 04:59:03 Re: Help: SPORT emulate SPI for SD Card?
Tony Liu (CHINA)
Message: 74912
Thanks!
Modify as below:
#if 1//defined(CONFIG_MMC_SPI) || defined(CONFIG_MMC_SPI_MODULE) || defined(CONFIG_SPI_BFIN_SPORT)
{
.modalias = "mmc_spi",
.max_speed_hz = 20000000, /* max spi clock (SCK) speed in HZ */
.bus_num = 1,
.chip_select = 0,
.platform_data = &bfin_mmc_spi_pdata,
.controller_data = &mmc_spi_chip_info,
.mode = SPI_MODE_3,
},
#endif
start message:
bfin-sport-spi bfin-sport-spi.1: Blackfin SPORT emulated SPI Driver, Version 1.0, regs_base@ffc00800
bfin-sport-spi bfin-sport-spi.2: Blackfin SPORT emulated SPI Driver, Version 1.0, regs_base@ffc00900
mmc_spi spi1.0: ASSUMING 3.2-3.4 V slot power
bfin_mmc_spi_init
mmc_spi spi1.0: SD/MMC host mmc0, no DMA, no WP, no poweroff
TCP cubic registered
NET: Registered protocol family 17
rtc-bfin rtc-bfin: setting system clock to 1970-01-01 03:22:08 UTC (12128)
Freeing unused kernel memory: 5092k freed
status error: TOVF ROVF
BUG: soft lockup - CPU#0 stuck for 61s! [ksoftirqd/0:3]
Modules linked in:
SEQUENCER STATUS: Not tainted
SEQSTAT: 00000026 IPEND: 8050 SYSCFG: 0006
EXCAUSE : 0x26
interrupts disabled
physical IVG6 asserted : <0xffa00c64> { _evt_timer + 0x0 }
physical IVG15 asserted : <0xffa00cd0> { _evt_system_call + 0x0 }
logical irq 6 mapped : <0xffa0037c> { _timer_interrupt + 0x0 }
logical irq 10 mapped : <0x000ae9b0> { _sport_err_handler + 0x0 }
logical irq 11 mapped : <0x000ae9b0> { _sport_err_handler + 0x0 }
logical irq 14 mapped : <0x000b14a4> { _bfin_rtc_interrupt + 0x0 }
logical irq 38 mapped : <0x000b91ec> { _mmc_spi_detect_irq + 0x0 }
RETE: <0x00000000> { _do_one_initcall + 0xfffff000 }
RETN: <0x00000000> { _do_one_initcall + 0xfffff000 }
RETX: <0x00000000> { _do_one_initcall + 0xfffff000 }
RETS: <0x000af310> { _bfin_sport_spi_u8_duplex + 0xc }
PC : <0x000af33c> { _bfin_sport_spi_u8_duplex + 0x38 }
DCPLB_FAULT_ADDR: <0x00000000> { _do_one_initcall + 0xfffff000 }
ICPLB_FAULT_ADDR: <0x00000000> { _do_one_initcall + 0xfffff000 }
PROCESSOR STATE:
R0 : 00000040 R1 : 01166b51 R2 : 01166b40 R3 : 01167000
R4 : 0000000a R5 : 00000100 R6 : 00000014 R7 : 00000001
P0 : ffa00890 P1 : ffc00830 P2 : ffc00810 P3 : 01164da0
P4 : 006ec290 P5 : 01167d44 FP : 006ec2b4 SP : 006d1e38
LB0: 000b201a LT0: 000b201a LC0: 00000000
LB1: 00096096 LT1: 0009608a LC1: 00000000
B0 : 01be9dc4 L0 : 00000000 M0 : 00000010 I0 : 00000004
B1 : 0000ffff L1 : 00000000 M1 : 00000000 I1 : 01be9e44
B2 : 01be9d80 L2 : 00000000 M2 : 00000000 I2 : 00000010
B3 : 00000000 L3 : 00000000 M3 : 00000000 I3 : 00000001
A0.w: 00000000 A0.x: 00000000 A1.w: 00000000 A1.x: 00000000
USP : 00000000 ASTAT: 02003024
system halt.
Let's go on! HaHaHaHa
QuoteReplyEditDelete
2009-06-01 23:01:46 Re: Help: SPORT emulate SPI for SD Card?
Cliff Cai (CHINA)
Message: 74939
Tony,
The sport got overflow,I think you need to have a look at the hardware design of sport-spi.
Please refer to: blackfin.uclinux.org/gf/project/uclinux-dist/tracker/?action=TrackerItemEdit&tracker_item_id=4277
and you need hardware support for SPI_MODE3.
we haven't done full test of this driver,till to now,we've only tested it with SPI-ADC and SPI-flash.
Cliff