summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mci-core.c
Commit message (Collapse)AuthorAgeFilesLines
...
* mci: Add support for MMC boot partitionsSascha Hauer2013-05-301-42/+151
| | | | | | | | | | | | | | | | | Some MMC cards support boot partitions. These are special regions on the MMC card intended to put a bootloader on. This patch adds support for these partitions, they are accessible as /dev/diskx.boot[0|1]. Additionally the partitions can be configured bootable using a device parameter. This can be used to mark the user area or one of the boot partitions as bootable. Since this feature is mostly seen on eMMC cards it is made optional to lower the size impact for boards which do not have eMMC. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/param'Sascha Hauer2013-05-061-33/+13
|\ | | | | | | | | Conflicts: drivers/mci/mci-core.c
| * console: Use dev_add_param_int for baudrate parameterSascha Hauer2013-04-111-7/+8
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * mci: Use dev_add_param_int for probe parameterSascha Hauer2013-04-111-28/+10
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | MCI/Core: honor transmission limits at the card's sideJuergen Beisert2013-04-271-1/+5
| | | | | | | | | | | | | | | | The host limits are only one limit we must honor when changing the transmission frequency. The SD cards have their own limits, so take them also into account. Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | MCI/Core: increase the transmission frequency while card detectionJuergen Beisert2013-04-271-1/+2
| | | | | | | | | | | | | | According to the SD card spec the detection can happen at 400 kHz Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mci: Fix bug if probe parameter is omittedAlexander Shiyan2013-04-091-0/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | barebox@Phytec phyCORE-i.MX27:/ mci0.probe= unable to handle NULL pointer dereference at address 0x00000000 pc : [<a7f24700>] lr : [<a7f193f4>] sp : a7fff8e0 ip : 00000000 fp : 00000001 r10: 00000000 r9 : a6ffba8c r8 : 00000000 r7 : a7fffad0 r6 : a6ffbb04 r5 : a6fdd5cc r4 : a6fdd658 r3 : a7f18760 r2 : 00000000 r1 : 00000000 r0 : 00000000 Flags: nZCv IRQs off FIQs off Mode SVC_32 [<a7f24700>] (simple_strtoul+0xc/0xc0) from [<a7f193f4>] (mci_set_probe+0xc94/0xd64) [<a7f193f4>] (mci_set_probe+0xc94/0xd64) from [<a7f252cc>] (dev_set_param+0x74/0x8c) [<a7f252cc>] (dev_set_param+0x74/0x8c) from [<a7f0606c>] (setenv+0x60/0xd8) [<a7f0606c>] (setenv+0x60/0xd8) from [<a7f00820>] (set_local_var.isra.3+0x5c/0x7c) [<a7f00820>] (set_local_var.isra.3+0x5c/0x7c) from [<a7f01a6c>] (run_list_real+0x494/0x934) [<a7f01a6c>] (run_list_real+0x494/0x934) from [<a7f01400>] (parse_stream_outer+0x198/0x270) [<a7f01400>] (parse_stream_outer+0x198/0x270) from [<a7f0209c>] (run_shell+0x3c/0x7c) [<a7f0209c>] (run_shell+0x3c/0x7c) from [<a7f05494>] (execute_command+0x38/0x78) [<a7f05494>] (execute_command+0x38/0x78) from [<a7f01db8>] (run_list_real+0x7e0/0x934) [<a7f01db8>] (run_list_real+0x7e0/0x934) from [<a7f019ec>] (run_list_real+0x414/0x934) [<a7f39578>] (unwind_backtrace+0x0/0xa8) from [<a7f24ed4>] (panic+0x28/0x3c) [<a7f24ed4>] (panic+0x28/0x3c) from [<a7f39a3c>] (do_exception+0x10/0x14) [<a7f39a3c>] (do_exception+0x10/0x14) from [<a7f39ac8>] (do_data_abort+0x2c/0x38) [<a7f39ac8>] (do_data_abort+0x2c/0x38) from [<a7f39788>] (data_abort+0x48/0x60) Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci-core: fix coding styleHubert Feurstein2013-04-031-1/+2
| | | | | Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci-core: use dev_* for messagesHubert Feurstein2013-04-031-5/+8
| | | | | Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: add card_write_protectedJean-Christophe PLAGNIOL-VILLARD2013-01-271-0/+6
| | | | | | | | | Currently there is no common way for the mci host driver to tell that thee car is write protected. This adds a card_write_protected callback which is used by the framework to tell whether it's protected or not. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add card_present callbackSascha Hauer2013-01-201-0/+5
| | | | | | | | Currently there is no common way for the mci host driver to tell that there is no card present. This adds a card_present callback which is used by the framework to tell whether it's present or not. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Always add probe parameter for cardsSascha Hauer2013-01-201-21/+5
| | | | | | | Always add the 'probe' parameter to cards so that scripts can rely on the parameter to be present. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: return 0 for probe parameter even when already initializedSascha Hauer2013-01-201-1/+1
| | | | | | | | This makes the behaviour more friendly to scripts which can now set the probe parameter without checking if it has been done before. Having a succesful result now means that there is a card. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Allow to specify device nameSascha Hauer2012-12-171-3/+7
| | | | | | | | When multiple MMC/SD cards are present in the system we often have to have persistent names to identify them during runtime. This patch allows to overwrite the devicename which is used. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/base: fix corrupt device treeSascha Hauer2012-12-121-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_add_child is a very unsafe function. If called multiple times it allows setting the same device to different parents thus corrupting the siblings list. This happens regularly since: | commit c2e568d19c5c34a05a1002d25280bf113b72b752 | Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> | Date: Sat Nov 3 16:11:05 2012 +0100 | | bus: add bus device | | automatically add it as parent of any bus device if none already specified | | we have now a nice output per bus If for example a FATfs is mounted this nice output per bus often ends with: > `---- fat0 > `---- 0 > `---- 0x86f0000087020031-0x86f000410df27124: /dev/<NULL> > `---- sram00 > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > `---- 0x00000000-0xffffffffffffffff: /dev/<NULL> > unable to handle NULL pointer dereference at address 0x0000000c > pc : [<87f08a20>] lr : [<87f08a04>] > sp : 86eff8c0 ip : 87f3fbde fp : ffffffff > r10: ffffffff r9 : 00000000 r8 : 00000003 > r7 : 86f075b8 r6 : 00000002 r5 : ffffffec r4 : 86f07544 > r3 : 00000000 r2 : 43f900b4 r1 : 00000020 r0 : 00000005 > Flags: Nzcv IRQs off FIQs off Mode SVC_32 > [<87f08a20>] (do_devinfo_subtree+0x90/0x130) from [<87f08a90>] (do_devinfo_subtree+0x100/0x130) > > [<87f3e070>] (unwind_backtrace+0x0/0x90) from [<87f28514>] (panic+0x28/0x3c) > [<87f28514>] (panic+0x28/0x3c) from [<87f3e4b8>] (do_exception+0x10/0x14) > [<87f3e4b8>] (do_exception+0x10/0x14) from [<87f3e544>] (do_data_abort+0x2c/0x38) > [<87f3e544>] (do_data_abort+0x2c/0x38) from [<87f3e268>] (data_abort+0x48/0x60) This patch fixes this by adding a device to its parents children list in register_device so that dev_add_child is no longer needed. This function is removed from the tree. Now callers of register_device have to clearly set the parent *before* registering a device. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reported-by: Jan Lübbe <jlu@pengutronix.de>
* mci: Fix capacity calculation for high capacity MMC cardsSascha Hauer2012-12-031-7/+15
| | | | | | | For these cards we have to calculate the size using the ext csd sector count fields. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add STUFF_BITS and use itSascha Hauer2012-11-291-5/+36
| | | | | | | | This adds the STUFF_BITS macro from the kernel to extract numbers from the csd. This also fixes several places where the csd fields in SD cards differ from MMC cards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mci'Sascha Hauer2012-11-161-3/+7
|\
| * mci-core: spi fix op cond supportJean-Christophe PLAGNIOL-VILLARD2012-11-141-3/+7
| | | | | | | | | | | | | | | | | | so we can detect sd card version 2.0 on spi as we need to the OCR_HCS on version 2.0 regardless if it's a SPI or not Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mci-core: fix debug Capacity castJean-Christophe PLAGNIOL-VILLARD2012-11-151-1/+1
|/ | | | | | | so we print the correct size Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* switch all platform_bus device/driver registering to ↵Jean-Christophe PLAGNIOL-VILLARD2012-10-041-2/+2
| | | | | | | | platform_driver/device_register now register_driver and register_device are for bus only usage. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-4/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Use DEVICE_ID_DYNAMIC where applicableSascha Hauer2012-04-161-1/+1
| | | | | | | We now have DEVICE_ID_DYNAMIC for dynamic allocation of device ids, Use it where applicable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers/mci: fix read/write stallingRobert Jarzmik2012-02-291-21/+10
| | | | | | | | | | | | | | If a read or write operation encounters an error, the card might stay in "recv" or "data" state, and never get back to "tran" state. In these cases, the host is required to send a CMD12 (end transmission) to switch the FSM of the card back to "tran" state, as described in MMC Specification, chapter "Data Transfer Mode". Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Fix 8 bit mmc cardsSascha Hauer2012-02-091-26/+107
| | | | | | | | | | Currently we test the cards capabilities for being 8bit capable. This does not work since noone ever sets this bit. Unfortunately there is no bit to test 8bit capability, so we introduce a patch from the kernel which puts the mmc card into 8bit mode and tests whether it can succesfully read the ext_csd in this mode. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add a complete list of EXT_CSD_* fields from the kernelSascha Hauer2012-02-091-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Be more verbose on what device is associated to which diskSascha Hauer2012-02-091-3/+7
| | | | | | | This is quite useful when multiple SD cards are present so spare some bytes to print this information. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: cdev_find_free_index won't fail, no need to checkSascha Hauer2012-02-091-2/+0
| | | | | | | There will always be the next integer number unless we register INT_MAX disk devices which is rarely the case. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: factor out mci/sd specific startup functionsSascha Hauer2012-02-091-56/+77
| | | | | | This saves an indention level and makes the code more readable. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: replace pr_debug with dev_dbgSascha Hauer2012-02-091-59/+59
| | | | | | | The mci layer uses pr_debug throughout. Use dev_dbg instead which is very useful when multiple cards are involved. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Use struct mci for internal argument passingSascha Hauer2012-02-091-143/+128
| | | | | | | | | The mci layer currently passes around a struct device_d for its internal use. Apart from being confusing this drops typesafety for no good reason. Instead, pass around a struct mci. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci core: fix mixup of max write/read block lenSascha Hauer2012-02-091-1/+1
| | | | | | | The argmument order in this pr_debug does not match the string printed. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: remove unused device argument from set_iosSascha Hauer2012-02-091-1/+1
| | | | | | This argmuent is unused in all drivers, so remove it. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci core: replace discrete ios values with struct iosSascha Hauer2012-02-091-5/+9
| | | | | | | As we'll need more arguments to set_ios over time put them in a struct mci_ios like the kernel does. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: fix high capacity detectionSascha Hauer2012-02-091-3/+0
| | | | | | | | | Whether a card is high capacity is checked in sd_send_op_cond/mmc_send_op_cond. Remove the wrong check in mmc_change_freq which wrongly recognizes some eMMC flash as high capacity. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: use card type definitionsSascha Hauer2012-02-091-2/+2
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: add the probe parameter if any error happened during the probeJean-Christophe PLAGNIOL-VILLARD2011-12-051-1/+1
| | | | | | | as example today if the timeout happened we can not probe the SD card again Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Use generic block layer to access the drives and do partition parsingJuergen Beisert2011-11-281-55/+80
| | | | | | | Change all relevant blockdevice users to the simplified interface. Signed-off-by: Juergen Beisert <jbe@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add MCI over SPI supportFranck Jullien2011-11-251-16/+53
| | | | | | | | | | | This patch adds MMC over SPI support to mci-core.c and mci_spi.c driver. This driver is useful when SOC doesn't have built-in MCI component. Tested with nios, 2Go SD-CARD and FAT file system. Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: remove unnecessary loopsSascha Hauer2011-11-111-30/+21
| | | | | | | | We used to loop around the sectors in mci_sd_write/mci_sd_read. Now that we have multi block read and write this is not necessary anymore. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: implement multi block writeSascha Hauer2011-11-111-4/+25
| | | | | | This speeds up writes to MMC/SD cards significantly. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci-core: fix typo for pr_warnRobert Schwebel2011-10-121-1/+1
| | | | | | | It is pr_warning(), not pr_warn(). Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: parent fixupsSascha Hauer2011-08-171-1/+4
| | | | | | | Make the mci host a child of the hardware device and the disk a child of the mci host. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: embed mci_dev into mci_host instead of allocating it seperatelySascha Hauer2011-08-151-3/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci-core: switch to resourceJean-Christophe PLAGNIOL-VILLARD2011-07-301-8/+2
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* mci: do not use unitialized resourceSascha Hauer2011-07-291-2/+1
| | | | | | | | | | | | | | | disk_dev->resource is unitialized. Do not use it. This got broken in: commit 4c542622cb07354c410680e0a6782508179f9e5f Author: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Date: Mon Jul 18 20:17:04 2011 +0800 mci: switch to "struct resource" Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: switch to "struct resource"Jean-Christophe PLAGNIOL-VILLARD2011-07-231-2/+2
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* mci-core: add missing newline in debug messageHubert Feurstein2011-06-011-1/+1
| | | | | | Signed-off-by: Hubert Feurstein <h.feurstein@gmail.com> Acked-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: turn several pr_* statements into debugSascha Hauer2011-05-061-12/+12
| | | | | | These are mostly useful for developers, so turn them off by default. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: shrink string footprintSascha Hauer2011-05-061-6/+8
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>