 Okay, so normally we should start in five minutes, but I think everyone is here so we can start now So hello, I'm Greg Clement and I will talk about the SD and a MMC card and especially about their new spin mode So we have some rocket free electron Made several development on armada base board and recently I work on adding support from a new controller which support all this new mode And that's why I work on this talk First quick presentation of what are SD card and EMMC They are common point. They both came from MNC and their multimedia card and They increase their bandwraiths as new version of the radar come and Now they can reach more than 400 megabytes by second in theory, of course it depends on the officer hardware, but For the point of view of the protocol you can reach this this speed and Both of this Of the chip are supported in Linux in the MMC subsystem and So what we are going to see is first is presentation of the SD card and EMMC and Where they come from and their common points are different Then we are going to see the initial support in Linux. So how it come in Linux and After this we are going to to see the speed is a new speaking mode in in both version of the card MMC card and SD card and EMMC and SD card and Then finally we are going to see the state of the support for this new speed mode In in the Linux kind So the SD card Stand for Secure digital but secure in the sense of the Compire copyright content. It's not secure as a sexual boot for example. It's more of the idea. I think was too blowing to provide SD card with movies on it or Music something like that and but protected by DRM like you find in DVD From my point of view I've never seen this kind of SD card. That was the the first idea to create this this new system it was introduced in 1899 and it's based on the MMC protocol it cannot have the extension of it and It's standardized by the SD association Which was creating actually after the first version of the of the protocol in 2000 At the very beginning the Evans of the protocol are completely closed them if You are not a member of the HDA but Pretty quickly even the member of the HDA provide part of the of the protocol and Now you can officially Have the specification the assembly specification, but which is enough to Support most of the mode. There is the only the secure part which is You can't access and also some Application not the top but for if you want to create a driver you have enough documentation So what is the SD card itself, but it's a flash it With a small controller embedded in a in a card At the very beginning in this flash shape. It was not Non-flash it was more nor flash and now I'm pretty sure that is only a non-flash embedded on it And it had you find nine pins. So the clock the command line the for data line and then Line for power and ground You have a SPI compatibility mode so in this mode the Usage of the pin are modified. So the date three become the chip select the command line becomes the data in and that zero becomes data out and In the initialize are released. It was The clock was limited to 25 megahertz exactly like the first release of the MNC aspect The SD bus protocol itself Is a command and data bit stream. So you have a start bit and and and bit You have the command and the response of the command on the command line and The data associated to this command on the data lines So even if you can have multiple data lines, the command are always on a single line You the principle is a basic transaction with a command and response and you can have some operation which have a data token, but not not out of them and All the communication are initiated by the host so which is really the host who take care of which always at initiate any any exchange and Also, the data transfer are in block with some CRC The last thing that you can have multiple data blocks in this case. It's also the host which explicitly stop The number of data blocks. So you have you initiate Data transfer and then at the point you have on the command line a specific command to say to the car to stop to send data or receive data So there is few difference between SD card and MNC Even at the beginning. So in the initial version of the MNC you can use only one line Whereas since the beginning on SD card you can use a four lines for the data But nowadays the MNC there is some car like MNC plus MNC Something like that can go to eight data lines There is no DRM. So no secure part in the MNC and Also now the common set a different maybe something I did not mention is on top of the small command and something like that there is a all the command set sent by the host I specified in the documentation and all this command have a special meaning we are going to see for example the command six which we will use when you want to switch from one to another mode you have some some common to Change the voltage common to Ask from ID to the car and so on. So at the beginning of course They have the same set of command, but then when SD card extends they add their own set of the command for example at the very beginning there are specific commands for the secure part and EMMC when it evolves will have also another set of commands so you can have a different command number which at the end do more as the same thing but they diverge from from this point and especially we are going to see it with I think it was for the for the tuning they do the more as the same thing but with a command a different command number and And also a common patch with MMC and SD card as they both have SPI compatibility mode because actually This compatibility mode came also from MMC Yes another thing about SPI SPI compatibility mode is that it pretty different. It's not only The way are which are different is as I said the SWC is a bit stream mode Whereas SPI is byte oriented. So it sends something on the way you pass the data Of course at the upper level so the command are the same Meaning of the command are the same, but the way you pass the command it is different Now we are going to the EMMC. So EMMC is MMC extension Standardized by the MMC association But also by the GDEC. The GDEC is more about solid state storage And as EMMC is a made it MMC, so it's soldered on the board then They joined their effort to standardize this This protocol and Now all the new specification are published by the GDEC So as I say MMC stands for Embedded Multimedia Card and the first mention of the EMMC in the MMC spec was in the spec 4.1 in 2007 but it was not to adjust we have a few words about it, but not really a specific feature With it. It's later that we are going to see this So how it is it is also a Flash chip with also a small controller on it, but this time it in the BGA chip and The pinout of the BGA is also standardized And among them you have 14 important pins so the clock The command line and then you have eight data lines and you have also two kind of Voltage line For one for The chip and the flash itself and another which will be used by the signal We are going to see that to achieve Heighter rate we we're going to use a smaller voltage and so it is Provided by this one then with version 4.4 One more point pine pin we was I did it was a reset one So a number of reset at directly on the MMC and then with version 5.0 the data strobe line and this one will be used for High-speed and we are going to see it later Something to to say that's For emmc science 4.3 the SP SPI compatibility mode was removed. So we are no more The emmc are no more expected to answer to the SPI Command Whereas for the for the SD card you will still have the SPI mode compatibility ever now, but With a restriction is that the in SPI mode you can only handle the command until the version 2 of the SD card All the newer command are not supported so you can send this command, but they are going just to be ignore, but not not use And in the initial real realize the clock of the bus was 52 megahertz So the protocol actually is as both came from MMC the protocol was is the same so we it's also Common in response on a single line then we have dedicated Data lines so but here you can go up to eight Data lines, but everything else is the same And of course as I said the difference will be in upper layer in the common supported and Which are different between SD card and emmc and so the as MMC is more emmc is more less just a MMC soldered in the board They're pretty the same, but there are few difference The first one is the fact that it's not removable But then there are some additional feature in the emmc so like partitioning Device information you can have directly From the MMC like you can have information about the geometry of the flash inside the emmc so something more advanced that for the MMC Another thing is that now it's very hard or maybe not possible to find emmc card. I think the normal It's no more used so it's really really the emmc that Now the MMC protocol are really drive the visor emmc itself Even if if you read the last Specification, they're still mentioned the MMC card and MMC plus, but I didn't to see any controller support stem so we we had seen the MMC and SD card and where they come from and now we are going to see how they were supported in Linux so The framework was added in 2004 so before git in 2.69 by by ressort king we in the initial commit he said is that he takes some inspiration by as a Andal dot andal dot org project which wanted to put Linux on pda, but it just inspire audit, but re-write it from scratch Then later the SD card to brought was I did in 2005 in 2.6 14 by prayer osman. Oh, I made a tip with 2s for osman Who became maintainer in 2006? Which is interesting with his first commit that he said that Sdr is SD specification is supposed to be closed, but Evan Sandisk Provide the specification. So I think the NDA about it is a No, no value no value and So it's start to implement on base based on the on the specification and then later It will be can really officially accessible from the asia from the asia session In 2006 with 2.6 that 17 kernel there was the support for the secure digital host controlling controller interface so it's standardization of a controller and It's if you want to support SD card you don't have to use them, but most of the controller are based on this on this one this interface And if you have a look on the code Half of the driver are based on on this one The high speed mode support for mmc for MMC was I did in 2.620 and in the same release the high speed mode support for the SD card was the ID 2 and Sdio extinction Was I did in 2007 so the Sdio I didn't mention it. It was to use now the What you find the most is using as a Wi-Fi Wi-Fi card, but it was as you have also Serial card and GPS. It was most common Card you use in Sdio So the code is located in driver's MMC and the header in include Linux MMC It's currently maintained now by the by a health Hanson And the code in separate in two parts. So as we have the core part Where you have the quote protocol and common function between emmc and a SD card and You have the host directory where you have the support for all the controller And Among them you have the easy hc controller which are maintained by Adrienne Hunter Yeah, there is also the SP SPI mod which is a supported in MMC SPI dot c but currently There is no no maintainer for it, but even if there is still a new code will come in here So Now we are going to focus on the spin mod improvement so the first one was a Pretty hold now it was the high speed mode. It's mainly passing from 26 megahertz to 52 for MMC and pass for 25 megahertz to 50 for SD card but what is bring is the usage of the Command six so to switch the mode this command was there from the beginning of the of the Of the specification, but now it is really used to do something and so What she introduced is the way to switch for a motto in other mode So typically and what we always find is of course you start by default on the lower mode Then you read the capability of the card you compare this capability to the capability of the host and then Depending of the both the best capability you can have you use the command six to request the card to To or inform for this one the card that you are going to to switch to a new mode And so it was introduced in the virtue of the SD specification and the V4 on the MMC specification Then in 2010 with the SD 3.0 1 Ultra speed It was ultra high speed mode which were which were introduced with several new new modes. So SDR 12, SDR 25, SDR 15 and so on so all the name of this mode are based on the Maximum bounce rife you can achieve with this mode So it's another thing is that this if you compare the SDR 12 and the SDR 25 is actually exactly the same Boundaries like you can achieve in default speed. So at 25 megahertz with four four bytes you have 12 megabytes per second and so the main difference for these two mode is the fact that your Your signal are Under 1.8 volt instead of 3 volts. So the main difference is just here But it's allow you to either both consume less but also your signal are more stable because if you have a big range of Voltage, then you have some time to go to Highter voltage lower voltage so you can Are more stable things but at the opposite it's also you need also to have a controller who can Must be more sensible because you have to make the big difference between zero and one dot eight instead of zero in three three But there So for this new mode for the UHS as This one dot eight volt is mandatory and so this Introduce a new step in the common switch sequence. So now you still Look for the capability of the card of the host and then you try to switch to The first switch command you send is to change the voltage And if it works, then you can try a new speed if you can't switch to a new New voltage, then you won't be able to use a UHS mode. So it's mandatory to to use a 1.8 volt Yes more Statter about it. So As it's not not for clear So as they are 12 is at 25 megahertz and it's because you have four lines with the same for all of them The most the interest is one are the last one. So in Sdr 104 then Actualy though I was wrong. I think I think that that is 104 megahertz or so And for this one as you are greater than 100 megahertz you also need to do Speed tuning It is done with command 18 so what it is is this as the main problem is the clock always came from the host But when you read that up you send your clock, but there is a way back through to the card and then it returns to you and so you you can have a little difference between the clock seen by The card and the clock generate by your host and to be sure that you're exactly on the same clock Then you have in this command you just send a known pattern. So you ask to Actually, you asked to the card to send you a known pattern and then knowing this pattern you can tune finally tune your host to exactly know when you have to sample the data so this tuning mode is also available for Sdr 50 and DDR 50 but for this one is not military whereas for Sdr 104 is mandatory to have this tuning a state in DDR 50 your zero clock run at 50 megahertz, but In this mode the data sample are the some The data are sampled on each front of the clock. So in the rising a front and the Lower front and Then it's not just before in MMC with MMC 4.4 Version 2009 there was a DDR support for the emmc and the emmc. So We are still at 52 megahertz like the high speed mode, but the main difference is We Have double rate Double data rate is for the year. So we sample at Front and and the opposite The difference between The SD card is we still use the switch command, but with not with the same the same arguments For SD card is really a different speed mode. So you have the DDR 50 mode whereas from MMC is not a different mode is as a the whites of the Of the booth, which is different. So we said that we are in 4 byte or 8 byte but on double rate. So at the end it's the same information, but Send in a different way Another change is that unlike the SD card you can still use The double rate at the 3 volt You it's not mandatory to switch to 1.8 volt to use this mode in with MMC 4.5 in true in 211 You with Ashes high speed 200 was Introduced so it's just a matter to are going faster. So to instead of 52 megahertz then we can go up to 200 megahertz. It would still a single data rate But here We have also the tuning command the same is a The same kind of commands that are used for SDR 104, but this this time for MMC is Command 21 whereas it was command 19, but it's exactly the same the same idea. So you request The EMMC to send you a known pattern and then you adjust your your host with this pattern This one now must be used at 1.8 volt or 1.2 volt To to be able to use and With emcee 5.0 was in 2013 The Hase 40 400 was introduced. So it's just keep the same Clock speed that's the Hase 200, but now we use the Double data rates or the two front of the clock For this We a new signal was introduced the data through with so the The data through is here to help to the host to be sure that you the data your sample is valid So Morris is just the same at the same rate of the clock, but with 19 degrees phase so it's just Between each one and it's helped to be sure that when you sample the rate, it's a valid and so as for Hase 200 you have also the tuning command and Also, it must be used at low voltage and with a M Oh, and also the data shrub is used during the data and So on all the data lines and also when you have the CRC response for a small part of the exchange And in the MMC 5.1 so in 2014 The nnth strobe was I did so it's hello to use this data strobe line also during the command response, so it's all also Thanks to this you have more reliable data also during this sequence the last speed mode We find ears as a UHS to which was Introducing SD 4.1 in 2013 so it's a completely new mode You have also with this one a new set of signal so you you have a Difference differential signal to to pair of different differential signal do D0 and D1 you also have Here may not clear, but you also have two voltage as we have for the MMC you have a voltage for the The flash is safe and the controller in itself and then voltage for the signal The Event the clock is also differential, but the clock is remain pretty low So only 26 or 52 megahertz and the idea here is use the same kind of Protocol you have on a USB 3 PCI express sata so very fast line with So this differential signal And then so you have this reference clock and then both the card and the Host then use PLL to internally have signal running 15 or 30 Time the speed of the clock. So think to this you can achieve 312 megabytes per second depending of the much protein So it's at the very low level. It's the first change Also, but something to know. It's a completely different protocol. So if we have a look on the on the first slide we have Yes, this is you can hear this one support us too and What's happening when you switch from? UHS one or any other mod from UHS to then you don't use any more This set of pin and you just use the new set of pin. So it's really a completely new protocol a completely new set of signal and so The compatibility is just because we you keep the old line but when you switch from a mod to another mod internally, it's different and and Because So Here you don't have any more the different line with a common line and for a different data line and so on here. We are just very speed data line dedicated and when we use the zero on the one it's You can either use D zero on a on the way and D1 on the other way So you do full duplex or you can also aggregate the two lines who have a duplex and either speed rate, but What you exchange here is Message package On both way we also saw that when with SD SD bus or MMC bus it's always There are some kind of package we always come from The host and the other package from come from the from this is the cat here You can exchange the same kind of package, but it's just Inside of it you have different either and different pillow data, but it's completely It's from my point of view is it's closer that you can find on the TCP IP or this kind of protocol and then It's still possible, but I'll very upper layer to have About compatibility with SD card, but it's just a way to send the SD command which are Uncapsulated with in this Packet so it's allow you to steal Exchange data With the SD card and you don't have to modify your upper part of your application But you still need to have a completely new driver because you still need to for the lower level when you want to negotiate from some speeds when you want to And manage the error then for this one you you have to know the packet message and how it works And recently this year's with We have a UHS 3 but from what I saw it's just a way to be able to go faster But this is the same protocol is just The difference is really at the low level to to to gain faster Faster clock Yes Now we are going to see the support of all this mod in Linux So as we saw the GR 50, so it was the DDR mod for emmc It was I did in 2010 with 2.6 or 37 The UHS one support so with all the sub mode was I did in 3.0 kernel in 2011 Then the HS 200 was I did in 3.10 and the HS 400 was I did in 3.16 and Two years ago the Retuning retuning was also I did so the retuning is I didn't speak about it. It's just Aware when if you have some Suspend or some aborted Common or something like that you can request to do a retune during the life of the protocol to be sure that you're really aligned with a with a good frequency and Last year the end strobe we saw was I did in with 4.8 so 40 nukes It's not too much actually The because the the signal voltage switch which is needed for all the the really new mode is supported in the framework In core doti really in the core of the framework and it's make use of the regulator framework So most of the time what you have to even if you add a new driver You don't have to do too much. It's under the core of the core framework and In in your device tree you just have to enter a new A new regulator which always called VQ MMC and then that's all it once we have this as the way to switch Signal is Common then the the framework will take care of it. So you don't have to do too much For a controller for this particular part Then the tuning which is used by a mmc and is decal so there is Global function present in the core, but here in each Controller have some Hardware fertility that were acceleration acceleration. So The implementation is done really at driver level. So you can use some common function, but you you also Can put your own function how many step of the of this sequence to Do what you want and or or at the opposite Tell to the framework to don't do anything and then you are where we take care of all the all the exchange of the the tune one The global switch with switching sequence is undel by the core, but here again If your hardware provides some acceleration or some help here you can provide your own Your own function or you can just skip some part done by by the core. So for the channel that Was not too much to to had of course the the devol is in the in the detail because When you have some hardware which can do something automatically Maybe it's not really fit in the in the kernel. So you have to really see how you you can Enter in it and and even recently We make some evolution directly in the core to to be able to Use a specific hardware facilities So for the future What are the missing part and the challenge for the MMC Speed mode point of view. I think there is Most of the development are done. Of course really for the Point of view of the support of the protocol From what I saw I think everything is here but of course till some Creaks to support a new driver, but it's more at the driver level that that the framework level For SDK R there is no support at all for USH 2 and USH 3 But as you see there's a completely new protocol and a lot of things to do I think another reason is I made some quick research and most of the hardware controller I saw have support for MMC specification 5.1 so no problem, but most of that many of them Stop their Support for SD at the version 3 and the version 3 of the SD Specification is the USS 1 protocol. So I think another reason to not having USS 2 is Because there is a few hardware at least for embedded system which support it, but there is I also find there is many IP which support this one from I saw some from Cadence, Arizona and There was a one for all the IP are present, but I didn't See them yet in the AdSock level So if you have any question, I feel free to ask So you want to know if the SD card MMC card we create some poor management They provide some poor management feature But I don't know if they are rich rare power management For example, you can I don't know I am not some part I thought I don't know is there are some thermal Not sure no the question One two, okay So a few years ago we had to bring up SDHC controller in one arm chip and people who designed this chip was already fired So we had bad documentation and we had to enable it and what we try to do is to connect logic analyzer to SD lines and Try it to debug and we found few hardware issues and we spent few months Trying to bring up it and maybe there is some easy way to find such issues what I can say is it's There is a lot of patches come on the Linux for managing quirks on many hardware controller and in card, so I'm not due to I'm not at all Surprise that you have a shoe and because there is the protocol which is pretty okay And then the implementation is pretty different from the protocol So as we have a lot of correct to say, okay, don't don't trust what the Host controller said I know that it can work only on this way on this way. So there is a lot of crux around it and That's also a problem of the Framework is at the beginning. We have had a lot of Chris there and there but from now There are some effort to to try to lead more global way. So we just keep the common part Common and each quick is you would try to put them on each driver if possible, but Yes, so that's right when I wrote this this talk Finally, I find it pretty no no much things to say because actually from what I saw is the most a part is not really Applies The protocol or follow the specification is more to deal with the real hardware When they don't follow the protocol and find why and and then we and as the hardware is as here You just have to to do with it and to modify the code for this problem to you with with a crappy hardware and I sold it very quickly and with a trick and I simply Slowed down the speed of the communication with the SD card Well, I know it's not the best option, but the crappy hardware deserves it So for debugging some of these higher speed modes, what kind of hardware tools do you use? I mean, do you have any recommendations for any analyzers or any other sort? Sorry, I am no recommendation because I am For myself, I didn't work on this part. I'm more cropped on the part to the For the controller I work on the code was already there also the hardware part was always debug and then it was most of my work to see how to Modify the code to fit the kernel Standard but this was not really on the on this part So I don't know what the hardware team and use for debugging It's okay Thank you