summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mci-core.c
Commit message (Collapse)AuthorAgeFilesLines
* mci: core: Do not fail if vmmc regulator failAlexander Shiyan2016-06-201-9/+10
| | | | | | | | The vmmc regulator can be an usupported device for barebox, the specific MFD regulator type, for example. Just lets think is all ok. Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Fix version numbers againTrent Piepho2016-06-071-5/+9
| | | | | | | | | | | The SD and eMMC version numbers are a pain to print and sort, since they are inconsistent in if a two digit minor version shdoulde be treated as a single number or as minor and micro version numbers. This allows version 1.10 and 4.5 and 4.41, where 41 is less than 5. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* string: Fix (v)asprintf prototypesSascha Hauer2016-04-151-3/+3
| | | | | | | | | | Our asprintf and vasprintf have different prototypes than the glibc functions. This causes trouble when we want to share barebox code with userspace code. Change the prototypes for (v)asprintf to match the glibc prototypes. Since the current (v)asprintf are convenient to use change the existing functions to b(v)asprintf. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* MCI: init device_node for MCI mainarea cdevLucas Stach2015-12-101-0/+3
| | | | | | | | | | | | | This fixes a regression, where boards specifying the environment path using the form device-path = &phandle, "partname:part" would be unable to find their env. This is due to of_find_path() switching to cdev_by_device_node() internally, which expects the device_node member of the main area cdev to be initialized. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: core: bus-width property should override driver defaultTrent Piepho2015-11-191-16/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | The OF code for parsing bus-width would only add the specified width to those the driver might have already set capability flags for. Because of this, if the driver had set 8 or 4 bit width, it wasn't possible for the DT to specify that fewer pins were used on the board and a smaller width was necessary. Change this so the width in the DT overrides whatever widths the driver says it supports. There is no reason to have an incorrect device tree and it makes far more sense for the DT to override the driver default than for the driver default to override the DT. The widths the driver puts in host_caps before calling mci_of_parse() are considered the default if the DT doesn't specify bus-width. This should cause the least amount of change to existing boards, as despite a comment that no bus-width meant to use 1 bit, using the driver default is what was really happening. Unfortunately, half of existing drivers default to the largest width they support while the other half default to the smallest. Boards should just stick the width in the device tree. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Print versions with micro levels correctlyTrent Piepho2015-11-051-5/+4
| | | | | | | | | | The version is stored as BCD, e.g. 0x40 -> ".4" and 0x41 -> ".41". The latter was getting printed as ".65". Simplify the logic a bit to not split the minor into nybbles just to re-assemble it into a byte again. Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: core: Increase clock for SD highspeed modeSascha Hauer2015-10-021-0/+3
| | | | | | | | Putting a SD card into highspeed mode doesn't help much when we still clock the card with 25MHz. Increase the clock speed to 50MHz for high speed cards. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: mci: Add mci_get_device_by_name functionDaniel Schultz2015-09-041-0/+18
| | | | | | | Get a 'struct mci' by search after the device name. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: mci: Make two functions publicDaniel Schultz2015-09-041-2/+2
| | | | | | | | | There is no possibility to read/write to the extended CSD register of MMC devices from a command. To avoid duplicated driver code, two driver functions have to be public. Signed-off-by: Daniel Schultz <d.schultz@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: core: Check return value of dev_add_param_boolWadim Egorov2015-03-191-1/+2
| | | | | | | | | | | | Commit 03b59bdb64e83ebcdb9111681775117ebce0e03b changed the return values of dev_add_param_* to ERR_PTR(-ENOSYS) and broke a few boards. We have now to care about the return value of dev_add_param_bool() in mci_register(). Also set the ret variable when dev_add_param_bool() fails. Signed-off-by: Wadim Egorov <w.egorov@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: core: the sd1.0 card can work in 4 bits modeBo Shen2014-07-291-3/+3
| | | | | | | The sd 1.0 card can work in 4 bits mode also. Signed-off-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: implement non-removable propertyLucas Stach2014-06-041-1/+4
| | | | | | | | There is no need to check the card-detect status for non-removable devices. Signed-off-by: Lucas Stach <dev@lynxeye.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add regulator supportSascha Hauer2014-04-291-2/+16
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: core: Typo fix in printk specifierAlexander Shiyan2014-03-171-1/+1
| | | | | Signed-off-by: Alexander Shiyan <shc_work@mail.ru> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Fix version handlingSascha Hauer2014-02-141-9/+19
| | | | | | | | | | | | Currently the version defines reflect the digits in the version number. MMC_VERSION_4_41 is defined as 0x441 and MMC_VERSION_4_5 is defined as 0x405. This results in MMC_VERSION_4_5 < MMC_VERSION_4_41 becoming true which was surely not intended. Fix this by redefining the versions as 0x<major><minor><micro>. This makes the string generation more complicated but makes versions comparable again. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: add device tree support for DSRMarkus Niebel2014-01-151-0/+8
| | | | | | | add optional DSR support. This should go into the kernel, too Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: add DSR supportMarkus Niebel2014-01-151-0/+27
| | | | | | | | | | | | | | | | The eMMC and the SD-Card specifications describe the optional SET_DSR command. During measurements at our lab we found that some cards implementing this feature having really strong driver strengts per default. This can lead to voltage peaks above the specification of the host on signal edges for data sent from a card to the host. Since availability of a given card type may be shorter than the time a certain hardware will be produced it is useful to have support for this command (Alternative would be changing termination resistors and adapting the driver strength of the host to the used card.) Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: production year for eMMC 4.41 and laterMarkus Niebel2014-01-101-4/+11
| | | | | | | | | | | | Year is coded in 4 bits of CID. eMMC 4.41 adds a new interpretation rule: production year for 4.41 cards and newer is between 2010 and 2025 with 0 corresponding to 2013. This fix was inspired by currect kernel code. Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Support the correct version for eMMCMarkus Niebel2014-01-101-8/+30
| | | | | | | | | | | | | | | | eMMC is available up to version 4.5 but the correct version is not decoded. Change version definitions to support more minor verions, add missing versions and parse the minor versions from ext_csd. After this, card detection code and devinfo reports correct versions. Handling is inspired by u-boot code. Signed-off-by: Markus Niebel <Markus.Niebel@tqs.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* barebox: remove double semicolonsAlexander Aring2013-11-181-1/+1
| | | | | Signed-off-by: Alexander Aring <alex.aring@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Add missing includesSascha Hauer2013-11-081-0/+1
| | | | | | | | A lot of files rely on include/driver.h including include/of.h (and this including include/errno.h. include the files explicitly so we can eventually get rid of including of.h from driver.h Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: add max_req_size supportJean-Christophe PLAGNIOL-VILLARD2013-10-221-8/+30
| | | | | | | | Some controller such as the ARM AMBA pl181 can not handle more than 16bits data length request. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add devicetree partition parsingSascha Hauer2013-07-181-0/+1
| | | | | | | | | MMC/SD cards normally have a DOS/GPT partition table, but sometimes barebox uses the unpartitioned area to store its environment. Add devicetree partition parsing also for SD/MMC cards so that we have a way to describe the partition in the devicetree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: set partnames of eMMC boot partitionsSascha Hauer2013-07-151-5/+7
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Use tran_speed field to fix highspeed MMC card clockSascha Hauer2013-06-201-13/+6
| | | | | | | | | | | | | | | The tran_speed field as decoded from csd is valid in most cases, so use it to determine the maximum clock we can support. It is not valid though for MMC highspeed cards, in this case the csd contains invalid values and we have to set tran_speed explicitly to the maximum speed. As the values passed into mci_set_clock are now based on tran_speed we no longer have to limit the rate to tran_speed in mci_set_clock. The (intended) effect of this patch is that highspeed MMC cards are no longer limited to non highspeed rates. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: add mci_caps functionSascha Hauer2013-06-201-9/+9
| | | | | | | To let the card caps be card caps and not the intersection between card caps and host caps. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: provide static inline function for mmc_host_is_spiSascha Hauer2013-06-201-2/+0
| | | | | | | | | | To prevent compiler warnings like: warning: unused variable 'host' When CONFIG_MCI_SPI is disabled. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Print more infoSascha Hauer2013-06-031-1/+27
| | | | | | | | | | In devinfo for the card also print: - capabilities for host and card - current bus width - current clock Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: rename capabilities flagsSascha Hauer2013-06-031-12/+12
| | | | | | | | | | Use MMC_CAP_ names instead of MMC_MODE_. This makes it more clear that these are capabilities of host/card and do not refer to the current mode. These are in line with the Linux Kernel except for MMC_CAP_MMC_HIGHSPEED_52MHZ which could be fixed later. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Add devicetree helper functionSascha Hauer2013-05-311-0/+38
| | | | | | | This adds helper code to parse the bus-width and max-frequency property from devicetree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: implement detect driver callbackSascha Hauer2013-05-311-0/+21
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: set name of mci device to same name as the filenameSascha Hauer2013-05-301-2/+8
| | | | | | | | | | We already have the possibility to register a mci with a certain filename to get persistent names. However, the device needed to find the probe parameter still has the name 'mcix'. This patch changes this by registering the mci device with the same name as the filename. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: embed mci device into struct mciSascha Hauer2013-05-301-122/+95
| | | | | | To safe a separate allocation and to make the code simpler. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: make mci device a pure deviceSascha Hauer2013-05-301-8/+20
| | | | | | | No need to match and probe the device if all that we want is a logical deivice for the mci. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Attach info callback to device, not to driverSascha Hauer2013-05-301-5/+3
| | | | | | | | Since the info is device specific and not driver specific, attach the callback to the device. This makes it possible to have a info callback for a device which does not have a driver attached. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>