1. 05 Oct, 2008 5 commits
    • Haavard Skinnemoen's avatar
      atmel-mci: support multiple mmc slots · 965ebf33
      Haavard Skinnemoen authored
      The Atmel MCI controller can drive multiple cards through separate sets
      of pins, but only one at a time. This patch adds support for
      multiplexing access to the controller so that multiple card slots can be
      used as if they were hooked up to separate mmc controllers.
      
      The atmel-mci driver registers each slot as a separate mmc_host. Both
      access the same common controller state, but they also have some state
      on their own for card detection/write protect handling, and separate
      shadows of the MR and SDCR registers.
      
      When one of the slots receives a request from the mmc core, the common
      controller state is checked. If it's idle, the request is submitted
      immediately. If not, the request is added to a queue. When a request is
      done, the queue is checked and if there is a queued request, it is
      submitted before the completion callback is called.
      
      This patch also includes a few cleanups and fixes, including a locking
      overhaul. I had to change the locking extensively in any case, so I
      might as well try to get it right. The driver no longer takes any
      irq-safe locks, which may or may not improve the overall system
      performance.
      
      This patch also adds a bit of documentation of the internal data
      structures.
      Signed-off-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
      965ebf33
    • Haavard Skinnemoen's avatar
      atmel-mci: Platform code for supporting multiple mmc slots · 6b918657
      Haavard Skinnemoen authored
      Add the necessary platform infrastructure to support multiple mmc/sdcard
      slots all at once through a single controller. Currently, the driver
      will use the first valid slot it finds and stick with that, but later
      patches will add support for switching between several slots on the fly.
      
      Extend the platform data structure with per-slot information: MMC/SDcard
      bus width and card detect/write protect pins. This will affect the pin
      muxing as well as the capabilities announced to the mmc core.
      
      Note that board code is now required to supply a mci_platform_data
      struct to at32_add_device_mci().
      Signed-off-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
      6b918657
    • Haavard Skinnemoen's avatar
      atmel-mci: Don't stop the clock between transfers · 945533b5
      Haavard Skinnemoen authored
      Some cards might get upset if we turn off the clock for extended periods
      of time. So keep the clock running until the mmc core tells us to turn
      it off.
      
      Also, don't reset the controller between each transfer. That was an
      attempt to work around earlier bugs, and it never really worked very
      well.
      Signed-off-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
      945533b5
    • Haavard Skinnemoen's avatar
      atmel-mci: Implement tasklet as a state machine · c06ad258
      Haavard Skinnemoen authored
      With the current system of completed/pending events, things may get
      handled in different order depending on which event triggers first. For
      example, if the data transfer is complete before the command, the stop
      command must be sent after the command is complete, not the data. This
      creates a bit of complexity around the stop command.
      
      By having the tasklet go through a sequence of clearly defined states,
      things always happen in a certain order even if the events come at
      different times, so the stop command can simply be sent when we exit the
      "sending data" state because we will never enter that state before the
      command has been sent successfully.
      Signed-off-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
      c06ad258
    • Haavard Skinnemoen's avatar
      atmel-mci: Initialize BLKR before sending data transfer command · a252e3e3
      Haavard Skinnemoen authored
      The atmel-mci driver sometimes fails data transfers like this:
      
         mmcblk0: error -5 transferring data
         end_request: I/O error, dev mmcblk0, sector 2749769
         end_request: I/O error, dev mmcblk0, sector 2749777
      
      It turns out that this might be caused by the BLKR register (which
      contains the block size and the number of blocks being transfered) being
      initialized too late. This patch moves the initialization of BLKR so
      that it contains the correct value before the block transfer command is
      sent.
      
      This error is difficult to reproduce, but if you insert a long delay
      (mdelay(10) or thereabouts) between the calls to atmci_start_command()
      and atmci_submit_data(), all transfers seem to fail without this patch,
      while I haven't seen any failures with this patch.
      Reported-by: default avatarHein_Tibosch <hein_tibosch@yahoo.es>
      Signed-off-by: default avatarHaavard Skinnemoen <haavard.skinnemoen@atmel.com>
      a252e3e3
  2. 04 Oct, 2008 16 commits
  3. 03 Oct, 2008 19 commits