2008-09-17 15:05:45 spi_mmc: No /dev/ or /proc entries
Nathan Martin (UNITED STATES)
Message: 62330
I am using 2.6.22.19-ADI-2008R1.5-svn (custom build) kernel for the Blackfin 561 EZ-KIT board. The only changes I have made in my custom built kernel is the menuconfig differences in order for spi_mmc driver to be built along with using PF2 instead of PF4 to use for chip select to the SD card.
I have been following both of these articles to try to get the driver working:
https://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:spi_mmc
http://www.vpx.nu/dokuwiki/doku.php?id=mmc_sd_configuration
I can compile and load the driver just fine. But what confuses me is that I don't get a /proc/spi_mmc nor a /dev/spi_mmc (based on the first wiki article, but it appears to have been changed to /dev/mmc since the wiki was updated of which doesn't exist either). So I went and changed the build setting to enable debug messages for the driver and this is what I get:
root:/> modprobe spi_mmc
40549, spi_mmc_init(): 1304 Registering spi_mmc_dummy...
40557, spi_mmc_init(): 1308 Registering spi_mmc...
40565, spi_mmc_init(): 1312 init ok!
root:/>
I have also checked /var/log/messages and it just shows the same spi_mmc related messages to what I just pasted above. After looking through both wiki articles I cannot figure out what is wrong. I have rechecked the wiring on my board and the SD socket board seems to be wired correctly to the MOSI, MISO, VCC, etc...
The thing that really throws me off is that the device driver never reports that it did or did not find an SD card across the SPI. Normally device drivers will report something especially if it cannot find or do something, and definitely would get some kind of a clue even with a debug build of which I am still clueless as to why it isn't creating the entry points in /dev/ and /proc like it is documented to do.
I have even attempted to look through the code of the driver and because I am very new to linux kernel driver development I am not sure what to look into to see what might be wrong, but I would think the driver is fine since others have reported the driver working fine for them except an unloading problem reported a while back (of which I can load and unload the driver via rmmod and modprobe just fine without any crashes or errors, just the same debug output).
Any suggestions are welcome. Thanks.
QuoteReplyEditDelete
2008-09-17 20:42:14 Re: spi_mmc: No /dev/ or /proc entries
Mike Frysinger (UNITED STATES)
Message: 62348
looking in /var/log wont give you anything that wasnt already available via `dmesg`
the document says that it isnt possible to detect cards automatically if you dont hook up the notification irq pin ... thus you need to poke it yourself
if you dont have a /dev/spi_mmc dev node, create one by hand, and then run `fdisk -l` on it
you should also try using the SPI bus directly rather than using the SPI framework
QuoteReplyEditDelete
2008-09-18 12:41:31 Re: spi_mmc: No /dev/ or /proc entries
Nathan Martin (UNITED STATES)
Message: 62393
> The document says that it isnt possible to detect cards automatically if you dont hook up the notification irq pin ... thus you need to poke it yourself.
How do I go about 'poking' it?
> if you dont have a /dev/spi_mmc dev node, create one by hand, and then run `fdisk -l` on it
How do I create the that dev node?
> you should also try using the SPI bus directly rather than using the SPI framework
I cannot do that since I will need to use the SPI for other devices as well than just the SD socket in the very near future and the BF561 only has one SPI controller.
QuoteReplyEditDelete
2008-09-18 16:11:25 Re: spi_mmc: No /dev/ or /proc entries
Mike Frysinger (UNITED STATES)
Message: 62403
you use `mknod` like any other Linux system. look up the major number in /proc/devices.
using the spi mmc/sd driver with the common spi framework may lead to failures ... search the forums and you'll see this clearly
QuoteReplyEditDelete
2008-09-18 19:01:28 Re: spi_mmc: No /dev/ or /proc entries
Nathan Martin (UNITED STATES)
Message: 62408
> you use `mknod` like any other Linux system.
I haven't use mknod in the past decade of time I have used Linux on x86 hardware, so I didn't know about it.
Alright I have looked at /proc/devices and the results are:
root:/> cat /proc/devices
Character devices:
1 mem
5 /dev/tty
5 /dev/console
5 /dev/ptmx
10 misc
29 fb
128 ptm
136 pts
204 ttyBF
Block devices:
1 ramdisk
7 loop
31 mtdblock
179 mmc
Which I am to assume I should create a /dev/mmc with mknod? Let's give it a try:
root:/> mknod /dev/mmc b 179 0
root:/> fdisk -l /dev/mmc
root:/> fdisk /dev/mmc
Unable to open /dev/mmc
root:/> cat /dev/mmc
cat: /dev/mmc: No such device or address
OK that didn't work out, so let's rm /dev/mmc and try with /dev/spi_mmc:
root:/> mknod /dev/spi_mmc b 179 0
root:/> fdisk -l /dev/spi_mmc
root:/> fdisk /dev/spi_mmc
Unable to open /dev/spi_mmc
root:/> cat /dev/spi_mmc
cat: /dev/spi_mmc: No such device or address
****, same results. Now I figured the minor would be zero since it is declared to be in the uClinux-dist-2008R1.5-RC3/vendors/AnalogDevices/BF561-EZKIT/device_table.txt. But the funny thing is is that the major is suppose to be 36 and not 179 as reported by /proc/devices or are they not going to match at runtime?
Now I did notice that in the device_table.txt that there isn't a /dev/spi_mmc defined, but /dev/mmc is which means the driver was changed for it to be /dev/mmc instead of as documented on https://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:spi_mmc
I can only figure that the spi_mmc driver is simply broken due to the fact that not even /proc/spi_mmc exists of which cannot be created via utilities and should have been available once the driver was finished initializing.
QuoteReplyEditDelete
2008-09-18 19:20:29 Re: spi_mmc: No /dev/ or /proc entries
Mike Frysinger (UNITED STATES)
Message: 62409
more likely it means you didnt update the SPI platfrom resources to declare settings for the spi_mmc driver. there are no SPI resources in the BF561-EZKIT by default because the SPI port on the board is useless with standard daughter cards.
look at the boards that we have tested for example resources.
QuoteReplyEditDelete
2008-09-19 15:21:41 Re: spi_mmc: No /dev/ or /proc entries
Nathan Martin (UNITED STATES)
Message: 62449
Please clarify as to what you mean by platform resources and what is necessary to get SPI worked in BF561-EZKIT builds. I have looked at the vendors/AnalogDevices/BF561-EZKIT/ directory and even ran a diff compare against the BF537-STAMP/ directory and only changes seen are in devices_list.txt, config.device, and config.vendor-2.6.x files. The last two files are just .config defaults.
I have also looked at linux-2.6.x/drivers/spi/spi_bfin5xx.c and it already uses the correct register addresses for the SPI since all blackfins use the same SPI register locations so far that I have seen.
Now if you are talking about the .config for linux-2.6.x/ it does have entries in the 'make menuconfig' menu to build the spi_mmc driver else it wouldn't have been available for me to modprobe:
CONFIG_MMC=y
# CONFIG_MMC_DEBUG is not set
# CONFIG_MMC_UNSAFE_RESUME is not set
#
# MMC/SD Card Drivers
#
CONFIG_MMC_BLOCK=y
#
# MMC/SD Host Controller Drivers
#
CONFIG_SPI_MMC=m
CONFIG_SPI_MMC_FRAMEWORK_DRIVER=y
# CONFIG_SPI_MMC_BFIN_PIO_SPI is not set
CONFIG_SPI_MMC_CS_CHAN=2
CONFIG_SPI_MMC_MAX_HZ=20000000
# CONFIG_SPI_MMC_CARD_DETECT is not set
CONFIG_SPI_MMC_DEBUG_MODE=y
Also SPI related:
#
# SPI support
#
CONFIG_SPI=y
CONFIG_SPI_MASTER=y
#
# SPI Master Controller Drivers
#
CONFIG_SPI_BFIN=y
# CONFIG_SPI_BITBANG is not set
If none of this is what you mean then I do not know what you are talking about and you need to be more specific.
QuoteReplyEditDelete
2008-09-19 15:28:10 Re: spi_mmc: No /dev/ or /proc entries
Mike Frysinger (UNITED STATES)
Message: 62450
review the documentation:
http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:customizing_for_your_board
QuoteReplyEditDelete
2008-09-19 17:07:54 Re: spi_mmc: No /dev/ or /proc entries
Nathan Martin (UNITED STATES)
Message: 62456
Thank you. That's exactly what I needed. Now I get these results:
root:/> modprobe spi_mmc
4294955153, spi_mmc_init(): 1304 Registering spi_mmc_dummy...
4294955161, spi_mmc_init(): 1308 Registering spi_mmc...
4294955170, spi_mmc_probe(): 1243
4294955172, spi_mmc_dev_setup(): 1106 Major number 36 was ok
4294955174, spi_mmc_block_setup(): 1205 on version > 2.6.19
4294955182, spi_mmc_init(): 1312 init ok!
root:/> cat /proc/spi_mmc
Driver build date: Sep 19 2008
SCLK: 20000 KHz
SPISEL2 as chip select
Driver: SPI Framework master
No MMC/SD card found.
root:/> fdisk /dev/spi_mmc
3540, mmc_spi_init_card(): 767 1
3541, mmc_spi_init_card(): 777 2
3542, spi_mmc_open(): 930
3543, mmc_spi_init_card(): 767 1
3545, mmc_spi_init_card(): 777 2
3547, spi_mmc_open(): 930
Unable to open /dev/spi_mmc
root:/> cat /dev/spi_mmc
7330, mmc_spi_init_card(): 767 1
7331, mmc_spi_init_card(): 777 2
7332, spi_mmc_open(): 930
cat: /dev/spi_mmc: No such device
root:/>
Looks like I still have some wiring to check and I'll hookup an analyzer to see if the SPI pins get any activity. In the mean time I've attached my changes to the linux-2.6.x/arch/blackfin/mach-bf561/boards/ezkit.c that I made based off of the SPI setup in linux-2.6.x/arch/blackfin/mach-bf537/boards/stamp.c for anybody who else needs to get the driver working on their BF561 EZKIT.
bf561-ezkit_spimmc_fix.diff
ezkit.c