summaryrefslogtreecommitdiffstats
path: root/drivers/mci/mci-core.c
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'for-next/mmc'Sascha Hauer2019-01-151-0/+5
|\
| * mci: core: Use alias as a devname by defaultAndrey Smirnov2018-12-101-0/+5
| | | | | | | | | | | | | | | | This idiom is repeatead by almost every mci driver, so move it to mci_of_parse() in order to reduce amount of duplicated code. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mci: skip of_partitions_register_fixup for boot partitionsAhmad Fatoum2019-01-031-1/+6
| | | | | | | | | | | | | | | | | | The bootN-partitions binding is barebox-specific, so it shouldn't be fixed up into the kernel device tree. Suggested-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mci: Rely on NULL being a dummy regulatorAndrey Smirnov2018-12-171-10/+9
|/ | | | | | | | | Since NULL, is a dummy regulator, we can drop a bit of error checking logic and simplify the code if we assing host->supply to NULL in case we can't find an appropriate regulator during probing. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* drivers: Introduce dev_set_name()Andrey Smirnov2018-10-181-2/+2
| | | | | | | | Introduce dev_set_name() in order to hide implementation details of setting device's name so it'd be easier to change it. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: drop unused parameter from mci_switch()Uwe Kleine-König2018-01-221-10/+6
| | | | | | | | | | | | | | | | | | | The SWITCH command has two purposes: a) switch the command set b) Write to the EXT_CSD register If the access field (bits [25:24]) in the argument are b00, we're in case a), otherwise in b). As mci_switch() always passes MMC_SWITCH_MODE_WRITE_BYTE (0b3) in the access field, only case b) is relevant here. According to the eMMC specification[1] the command set field is ignored in case b) and so the respective parameter (that is unused already now) can be dropped. [1] Embedded Multi-Media Card (e•MMC) Electrical Standard (5.1), February 2015; paragraph 6.6.1 Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mmc: allow skipping SD card initializationPhilipp Zabel2017-09-261-4/+8
| | | | | | | | | This patch allows to skip SD card initialization for eMMCs by setting the "no-sd" property in the host controller device tree node. Avoiding two SD command timeouts speeds up detection time by well over 200 ms. Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mmc: add eMMC v5 and V5.1 detection supportPeter Seiderer2017-07-061-0/+6
| | | | | | | Just add the defines. Signed-off-by: Peter Seiderer <ps.report@gmx.net> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* mmc: Consistently use EXT_CSD_* names from eMMC 5.1 specSascha Hauer2017-07-061-24/+24
| | | | | | | | | | We have kept the EXT_CSD registers which were added in the 5.1 spec separately for no good reason. Order the EXT_CSD defines by register number instead. Also we had some duplicates, for these consistently use the names from the 5.1 spec. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
* mci: be more verbose about wrong bus-widthChristoph Fritz2017-05-031-4/+7
| | | | | | | | | | | | | | If configured or default bus-width is wrong for the current hardware, registration of card/emmc is likely to fail. This patch adds more verbosity in the case of a failed detection: | omap-hsmmc 48060000.mmc: registered as 48060000.mmc | mmc0: detected MMC card version 4.41 | mmc0: Changing MMC bus width failed: -110 | mmc0: Card's startup fails with -110 Signed-off-by: Christoph Fritz <chf.fritz@googlemail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/ofpart'Sascha Hauer2017-04-071-1/+3
|\
| * of: partition: Register the of partition fixup for of partition usersSascha Hauer2017-03-311-1/+3
| | | | | | | | | | | | | | at24, at25 and mci core are using of_parse_partitions(). Register the fixup for them aswell. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | mci: Allow parsing for explicit DT nodeAndrey Smirnov2017-03-301-5/+8
|/ | | | | | | | | | | | | | Convert mci_of_parse into mci_of_parse_node, a function that takes explicit deivce tree node pointer to be used for SD/MMC related properties extraction. Implement original mci_of_parse as a wrapper around the call to new function. This is useful for controllers who specify parameter like bus witdth and GPIOs as a part of main controller's child nodes (e.g. AT91 SoCs). Acked-by: Sam Ravnborg <sam@ravnborg.org> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* mci: Allow to partition eMMC boot partitionsSascha Hauer2017-01-191-23/+55
| | | | | | | | | So far the eMMC boot partitions cannot be partitioned from the device tree. Since they are often 4MiB in size they are big enough to hold a barebox image and the environment. Add partition parsing to the boot partitions to allow this usecase. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* 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>