spi_mmc: set default spi bus
PATCH 1/1 spi_mmc: set default spi bus
This patch supports non-zero spi bus.
---
Tested spi_mmc on two nios2 boards.
Great job. Thanks.
drivers/mmc/spi_mmc.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/mmc/spi_mmc.c +5 -1
@@ -992,6 +992,9 @@ static short mmc_spi_mmc_spi_get_card_old(struct mmc_spi_dev *pdev)#endif +#ifndef CONFIG_SPI_MMC_DEFAULT_BUS +# define CONFIG_SPI_MMC_DEFAULT_BUS 0 +#endif #ifndef CONFIG_SPI_MMC_DEFAULT_CS # define CONFIG_SPI_MMC_DEFAULT_CS 1#endif
@@ -1059,7 +1062,8 @@ static int spi_mmc_init(void)spi_free_slave (slave); } - slave =spi_setup_slave (0 ,CONFIG_SPI_MMC_DEFAULT_CS , + slave =spi_setup_slave ( +CONFIG_SPI_MMC_DEFAULT_BUS ,CONFIG_SPI_MMC_DEFAULT_CS ,CONFIG_SPI_MMC_DEFAULT_SPEED ,CONFIG_SPI_MMC_DEFAULT_MODE );if (!slave)return -1 ;
Signature · 1 line
1.6.6.1
PATCH 1/1 spi_mmc: set default spi bus
drivers/mmc/spi_mmc.c static int spi_mmc_init(void) · line 1067
Quoted 4 lines · On Thursday 22 April 2010 01:16:34 Thomas Chou wrote:
drivers/mmc/spi_mmc.c +2
-1- slave =spi_setup_slave (0 ,CONFIG_SPI_MMC_DEFAULT_CS , + slave =spi_setup_slave ( +CONFIG_SPI_MMC_DEFAULT_BUS ,CONFIG_SPI_MMC_DEFAULT_CS ,CONFIG_SPI_MMC_DEFAULT_SPEED ,CONFIG_SPI_MMC_DEFAULT_MODE );
seems this is an older version of the patch. ive merged your suggestion and i'll post the latest to the list again.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100422/0d1db11c/attachment.pgp
PATCH 1/1 mmc: new legacy MMC/SPI driver
In reply to Thomas ChouFrom: Hans Eklund <[email protected]>
Needs converting to generic MMC framework.
--- drivers/mmc/Makefile | 3 + drivers/mmc/spi_mmc.c | 1119 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 1122 insertions(+), 0 deletions(-) create mode 100644 drivers/mmc/spi_mmc.c
drivers/mmc/Makefile +3 -0
@@ -23,6 +23,9 @@ include $(TOPDIR)/config.mk +# stick it up here to avoid conflicts +COBJS-$(CONFIG_SPI_MMC) += spi_mmc.o + LIB := $(obj)libmmc.a COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
drivers/mmc/spi_mmc.c new file +1119 -0
1,119 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 1/1 mmc: new legacy MMC/SPI driver
Hi Mike,
Quoted 9 lines · Mike Frysinger
drivers/mmc/spi_mmc.c new file +9
-0+static short mmc_spi_init_card (struct mmc_spi_dev *pdev) +{ +unsigned short cntr =0 ; + +/* for making init process beeing silent */ + init_mode =1 ; +/* save length of log for external usage */ + pdev->log_len =LOG_LEN ; +
drivers/mmc/spi_mmc.c line 888
Quoted 10 lines
drivers/mmc/spi_mmc.c new file +10
-0+/* 10 bytes(80 cycles) with CS de-asserted */ +mmc_spi_dummy_clocks (pdev,10 ); + pdev->doassert (); +if (send_cmd_and_wait (pdev,GO_IDLE_STATE ,0 ,R1_IDLE_STATE ,MMC_INIT_TIMEOUT )) +return 1 ; + pdev->deassert (); +/* Send One Byte Delay */ +if (pdev->write (Null_Word,1 , pdev->priv_data) <0 ) +return 1 ; + pdev->doassert ();
[...]
Is there any reason to use doassert() and deassert() except to generate the "dummy" cycles needed to initialize the card? Which driver does _need_ an explicit cs_activate() and cs_deactivate() outside the write() and read() functions?
CS control is done automatically by most drivers. According to include/spi.h, the _board_code_ is supposed to supply spi_cs_[de]activate() to be used by the driver in case the hardware can not control the chip selects automatically. The documentation is not clear about it, but from my point of view spi_cs_[de]activate() are not part of the SPI API.
I think we should not clutter client drivers with such implementation specific things.
I have to clean up my code and try to migrate to your newer code base, but I did implement a modified version using SPI_XFER_BEGIN, spi_setup_slave() (to clear the CS) and SPI_CS_HIGH to achieve the CS switching in a way compliant with e.g. the coldfire SPI driver. (Although IIRC I had to add SPI_CS_HIGH there, too)
Regards,
Wolfgang
PATCH 1/1 mmc: new legacy MMC/SPI driver
Quoted 23 lines · On Friday 23 April 2010 04:20:34 Wolfgang Wegner wrote:
Quoted 19 lines · Mike Frysinger
drivers/mmc/spi_mmc.c new file +13
-0+static short mmc_spi_init_card (struct mmc_spi_dev *pdev) +{ +unsigned short cntr =0 ; + +/* for making init process beeing silent */ + init_mode =1 ; +/* save length of log for external usage */ + pdev->log_len =LOG_LEN ; + +/* 10 bytes(80 cycles) with CS de-asserted */ +mmc_spi_dummy_clocks (pdev,10 ); + pdev->doassert (); + if (send_cmd_and_wait(pdev, GO_IDLE_STATE, 0, R1_IDLE_STATE,
MMC_INIT_TIMEOUT)) + return 1;drivers/mmc/spi_mmc.c new file +5
-0+ pdev->deassert (); +/* Send One Byte Delay */ +if (pdev->write (Null_Word,1 , pdev->priv_data) <0 ) +return 1 ; + pdev->doassert ();[...]
Quoted 4 lines
Is there any reason to use
doassert()anddeassert()except to generate the "dummy" cycles needed to initialize the card? Which driver does _need_ an explicitcs_activate()andcs_deactivate()outside thewrite()andread()functions?
i have no idea. i didnt write the driver.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20100423/117039a5/attachment.pgp