2008-11-20 22:59:12 +08:00
|
|
|
#ifndef __LINUX_ATMEL_MCI_H
|
|
|
|
#define __LINUX_ATMEL_MCI_H
|
atmel-mci: Driver for Atmel on-chip MMC controllers
This is a driver for the MMC controller on the AP7000 chips from
Atmel. It should in theory work on AT91 systems too with some
tweaking, but since the DMA interface is quite different, it's not
entirely clear if it's worth merging this with the at91_mci driver.
This driver has been around for a while in BSPs and kernel sources
provided by Atmel, but this particular version uses the generic DMA
Engine framework (with the slave extensions) instead of an
avr32-only DMA controller framework.
This driver can also use PIO transfers when no DMA channels are
available, and for transfers where using DMA may be difficult or
impractical for some reason (e.g. the DMA setup overhead is usually
not worth it for very short transfers, and badly aligned buffers or
lengths are difficult to handle.)
Currently, the driver only support PIO transfers. DMA support has been
split out to a separate patch to hopefully make it easier to review.
The driver has been tested using mmc-block and ext3fs on several SD,
SDHC and MMC+ cards. Reads and writes work fine, with read transfer
rates up to 3.5 MiB/s on fast cards with debugging disabled.
The driver has also been tested using the mmc_test module on the same
cards. All tests except 7, 9, 15 and 17 succeed. The first two are
unsupported by all the cards I have, so I don't know if the driver
handles this correctly. The last two fail because the hardware flags a
Data CRC Error instead of a Data Timeout error. I'm not sure how to deal
with that.
Documentation for this controller can be found in many data sheets from
Atmel, including the AT32AP7000 data sheet which can be found here:
http://www.atmel.com/dyn/products/datasheets.asp?family_id=682
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
2008-07-01 00:35:03 +08:00
|
|
|
|
2014-08-07 21:14:06 +08:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2011-08-11 23:25:41 +08:00
|
|
|
#define ATMCI_MAX_NR_SLOTS 2
|
atmel-mci: support multiple mmc slots
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: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2008-09-18 02:53:55 +08:00
|
|
|
|
2008-08-07 20:08:49 +08:00
|
|
|
/**
|
|
|
|
* struct mci_slot_pdata - board-specific per-slot configuration
|
|
|
|
* @bus_width: Number of data lines wired up the slot
|
|
|
|
* @detect_pin: GPIO pin wired to the card detect switch
|
|
|
|
* @wp_pin: GPIO pin wired to the write protect sensor
|
2009-03-31 17:16:48 +08:00
|
|
|
* @detect_is_active_high: The state of the detect pin when it is active
|
2014-11-03 19:12:59 +08:00
|
|
|
* @non_removable: The slot is not removable, only detect once
|
2008-08-07 20:08:49 +08:00
|
|
|
*
|
|
|
|
* If a given slot is not present on the board, @bus_width should be
|
|
|
|
* set to 0. The other fields are ignored in this case.
|
|
|
|
*
|
|
|
|
* Any pins that aren't available should be set to a negative value.
|
atmel-mci: support multiple mmc slots
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: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2008-09-18 02:53:55 +08:00
|
|
|
*
|
|
|
|
* Note that support for multiple slots is experimental -- some cards
|
|
|
|
* might get upset if we don't get the clock management exactly right.
|
|
|
|
* But in most cases, it should work just fine.
|
2008-08-07 20:08:49 +08:00
|
|
|
*/
|
|
|
|
struct mci_slot_pdata {
|
|
|
|
unsigned int bus_width;
|
atmel-mci: Driver for Atmel on-chip MMC controllers
This is a driver for the MMC controller on the AP7000 chips from
Atmel. It should in theory work on AT91 systems too with some
tweaking, but since the DMA interface is quite different, it's not
entirely clear if it's worth merging this with the at91_mci driver.
This driver has been around for a while in BSPs and kernel sources
provided by Atmel, but this particular version uses the generic DMA
Engine framework (with the slave extensions) instead of an
avr32-only DMA controller framework.
This driver can also use PIO transfers when no DMA channels are
available, and for transfers where using DMA may be difficult or
impractical for some reason (e.g. the DMA setup overhead is usually
not worth it for very short transfers, and badly aligned buffers or
lengths are difficult to handle.)
Currently, the driver only support PIO transfers. DMA support has been
split out to a separate patch to hopefully make it easier to review.
The driver has been tested using mmc-block and ext3fs on several SD,
SDHC and MMC+ cards. Reads and writes work fine, with read transfer
rates up to 3.5 MiB/s on fast cards with debugging disabled.
The driver has also been tested using the mmc_test module on the same
cards. All tests except 7, 9, 15 and 17 succeed. The first two are
unsupported by all the cards I have, so I don't know if the driver
handles this correctly. The last two fail because the hardware flags a
Data CRC Error instead of a Data Timeout error. I'm not sure how to deal
with that.
Documentation for this controller can be found in many data sheets from
Atmel, including the AT32AP7000 data sheet which can be found here:
http://www.atmel.com/dyn/products/datasheets.asp?family_id=682
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
2008-07-01 00:35:03 +08:00
|
|
|
int detect_pin;
|
|
|
|
int wp_pin;
|
2009-03-31 17:16:48 +08:00
|
|
|
bool detect_is_active_high;
|
2014-11-03 19:12:59 +08:00
|
|
|
bool non_removable;
|
atmel-mci: Driver for Atmel on-chip MMC controllers
This is a driver for the MMC controller on the AP7000 chips from
Atmel. It should in theory work on AT91 systems too with some
tweaking, but since the DMA interface is quite different, it's not
entirely clear if it's worth merging this with the at91_mci driver.
This driver has been around for a while in BSPs and kernel sources
provided by Atmel, but this particular version uses the generic DMA
Engine framework (with the slave extensions) instead of an
avr32-only DMA controller framework.
This driver can also use PIO transfers when no DMA channels are
available, and for transfers where using DMA may be difficult or
impractical for some reason (e.g. the DMA setup overhead is usually
not worth it for very short transfers, and badly aligned buffers or
lengths are difficult to handle.)
Currently, the driver only support PIO transfers. DMA support has been
split out to a separate patch to hopefully make it easier to review.
The driver has been tested using mmc-block and ext3fs on several SD,
SDHC and MMC+ cards. Reads and writes work fine, with read transfer
rates up to 3.5 MiB/s on fast cards with debugging disabled.
The driver has also been tested using the mmc_test module on the same
cards. All tests except 7, 9, 15 and 17 succeed. The first two are
unsupported by all the cards I have, so I don't know if the driver
handles this correctly. The last two fail because the hardware flags a
Data CRC Error instead of a Data Timeout error. I'm not sure how to deal
with that.
Documentation for this controller can be found in many data sheets from
Atmel, including the AT32AP7000 data sheet which can be found here:
http://www.atmel.com/dyn/products/datasheets.asp?family_id=682
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
2008-07-01 00:35:03 +08:00
|
|
|
};
|
|
|
|
|
2008-08-07 20:08:49 +08:00
|
|
|
/**
|
|
|
|
* struct mci_platform_data - board-specific MMC/SDcard configuration
|
2009-01-07 02:38:16 +08:00
|
|
|
* @dma_slave: DMA slave interface to use in data transfers.
|
2008-08-07 20:08:49 +08:00
|
|
|
* @slot: Per-slot configuration data.
|
|
|
|
*/
|
|
|
|
struct mci_platform_data {
|
2009-12-15 10:01:30 +08:00
|
|
|
struct mci_dma_data *dma_slave;
|
2011-08-11 23:25:41 +08:00
|
|
|
struct mci_slot_pdata slot[ATMCI_MAX_NR_SLOTS];
|
2008-08-07 20:08:49 +08:00
|
|
|
};
|
|
|
|
|
2008-11-20 22:59:12 +08:00
|
|
|
#endif /* __LINUX_ATMEL_MCI_H */
|