
I feel like a fool :S. If i didn't miss anything spi_xfer is defined in include/spi.h and that function is implemented in cpu related code. I see also that atmel has put their code in drivers/spi and drivers/mmc. Finally i took as example cpu/pxa/mmc.c where i found functions (defined in include/mmc.h) to provide access to the mmc card with the commands cp and mmc (if CONFIG_CMD_MMC is defined). Then, i chose to put my code in cpu/nios2/mmc_spi.c to implement the following functions,
Functions used in common/cmd_mmc.c, mmc_read: return -1 (cp error) mmc_write: return -1 (cp error) mmc2info: return -1 (cp error) mmc_init: it initializes the card in spi mode and it fills the block_dev_desc_t structure (mmc command).
Functions used to access the block device, mmc_block_read: it reads a block in spi mode and its passed as a pointer in the field block_read in block_dev_desc_t (used in fs/fat/fat.c to access the partition table) mmc_get_dev: to give a pointer to the block_dev_desc_t variable (needed by disk/part.c because CONFIG_MMC is defined).
Because i had to write functions to manage the spi core, i thought that spi_xfer() should be used to access the core in mmc_block_read. I'm a little lost because there are some implementations that places the code in cpu/ and others in drivers/. Is the code well placed in cpu/?. I would like to write the code as it should be written and i wouldn't like to mess up the code tree.
Regards, Ivan Llopard.
2009/2/5 Wolfgang Denk wd@denx.de
Dear ivanchuklist ivanchu,
In message 51a313240902051201k1977196cu314e60a1cfcd0e11@mail.gmail.com you wrote:
I see also in cpu/nios an implementation of the spi core, it uses
volatiles
variables to access hardware, so it will not work. Nevertheless the implementation is correct.
I'm not a NIOS expert - but if it doesn't work, this should be fixed. Patches welcome.
I'm adding sd access by spi protocol to u-boot, so i created a new file called mmc_spi.c in cpu/nios2. I faced many problems. I just want to have access to the fat partition, then i wrote mmc_get_dev and mmc_read_block
but
i need to initialize the card so i implemented mmc_init (which add mmc command) and i don't want to write mmc_read/write/2info. Should i
implement
those functions?. In the other hand, should i use spi_xfer() to do spi transactions?.
Sorry, I don't know any of this code,
Best regards,
Wolfgang Denk
-- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de "What terrible way to die." "There are no good ways." -- Sulu and Kirk, "That Which Survives", stardate unknown