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-06-30 23:35:03 +07:00
|
|
|
/*
|
|
|
|
* Atmel MultiMedia Card Interface driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2004-2006 Atmel Corporation
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
2009-06-12 22:58:29 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Superset of MCI IP registers integrated in Atmel AVR32 and AT91 Processors
|
2009-06-12 22:58:30 +07:00
|
|
|
* Registers and bitfields marked with [2] are only available in MCI2
|
2009-06-12 22:58:29 +07:00
|
|
|
*/
|
|
|
|
|
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-06-30 23:35:03 +07:00
|
|
|
#ifndef __DRIVERS_MMC_ATMEL_MCI_H__
|
|
|
|
#define __DRIVERS_MMC_ATMEL_MCI_H__
|
|
|
|
|
|
|
|
/* MCI Register Definitions */
|
2011-08-11 22:25:41 +07:00
|
|
|
#define ATMCI_CR 0x0000 /* Control */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CR_MCIEN ( 1 << 0) /* MCI Enable */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CR_MCIDIS ( 1 << 1) /* MCI Disable */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CR_PWSEN ( 1 << 2) /* Power Save Enable */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CR_PWSDIS ( 1 << 3) /* Power Save Disable */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CR_SWRST ( 1 << 7) /* Software Reset */
|
2011-08-11 22:25:41 +07:00
|
|
|
#define ATMCI_MR 0x0004 /* Mode */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_MR_CLKDIV(x) ((x) << 0) /* Clock Divider */
|
|
|
|
# define ATMCI_MR_PWSDIV(x) ((x) << 8) /* Power Saving Divider */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_MR_RDPROOF ( 1 << 11) /* Read Proof */
|
|
|
|
# define ATMCI_MR_WRPROOF ( 1 << 12) /* Write Proof */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_MR_PDCFBYTE ( 1 << 13) /* Force Byte Transfer */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_MR_PDCPADV ( 1 << 14) /* Padding Value */
|
|
|
|
# define ATMCI_MR_PDCMODE ( 1 << 15) /* PDC-oriented Mode */
|
2012-03-21 22:41:23 +07:00
|
|
|
# define ATMCI_MR_CLKODD(x) ((x) << 16) /* LSB of Clock Divider */
|
2011-08-11 22:25:43 +07:00
|
|
|
#define ATMCI_DTOR 0x0008 /* Data Timeout */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_DTOCYC(x) ((x) << 0) /* Data Timeout Cycles */
|
|
|
|
# define ATMCI_DTOMUL(x) ((x) << 4) /* Data Timeout Multiplier */
|
2011-08-11 22:25:43 +07:00
|
|
|
#define ATMCI_SDCR 0x000c /* SD Card / SDIO */
|
|
|
|
# define ATMCI_SDCSEL_SLOT_A ( 0 << 0) /* Select SD slot A */
|
|
|
|
# define ATMCI_SDCSEL_SLOT_B ( 1 << 0) /* Select SD slot A */
|
|
|
|
# define ATMCI_SDCSEL_MASK ( 3 << 0)
|
|
|
|
# define ATMCI_SDCBUS_1BIT ( 0 << 6) /* 1-bit data bus */
|
|
|
|
# define ATMCI_SDCBUS_4BIT ( 2 << 6) /* 4-bit data bus */
|
|
|
|
# define ATMCI_SDCBUS_8BIT ( 3 << 6) /* 8-bit data bus[2] */
|
|
|
|
# define ATMCI_SDCBUS_MASK ( 3 << 6)
|
|
|
|
#define ATMCI_ARGR 0x0010 /* Command Argument */
|
|
|
|
#define ATMCI_CMDR 0x0014 /* Command */
|
|
|
|
# define ATMCI_CMDR_CMDNB(x) ((x) << 0) /* Command Opcode */
|
|
|
|
# define ATMCI_CMDR_RSPTYP_NONE ( 0 << 6) /* No response */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CMDR_RSPTYP_48BIT ( 1 << 6) /* 48-bit response */
|
|
|
|
# define ATMCI_CMDR_RSPTYP_136BIT ( 2 << 6) /* 136-bit response */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CMDR_SPCMD_INIT ( 1 << 8) /* Initialization command */
|
|
|
|
# define ATMCI_CMDR_SPCMD_SYNC ( 2 << 8) /* Synchronized command */
|
|
|
|
# define ATMCI_CMDR_SPCMD_INT ( 4 << 8) /* Interrupt command */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CMDR_SPCMD_INTRESP ( 5 << 8) /* Interrupt response */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CMDR_OPDCMD ( 1 << 11) /* Open Drain */
|
|
|
|
# define ATMCI_CMDR_MAXLAT_5CYC ( 0 << 12) /* Max latency 5 cycles */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CMDR_MAXLAT_64CYC ( 1 << 12) /* Max latency 64 cycles */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CMDR_START_XFER ( 1 << 16) /* Start data transfer */
|
|
|
|
# define ATMCI_CMDR_STOP_XFER ( 2 << 16) /* Stop data transfer */
|
|
|
|
# define ATMCI_CMDR_TRDIR_WRITE ( 0 << 18) /* Write data */
|
|
|
|
# define ATMCI_CMDR_TRDIR_READ ( 1 << 18) /* Read data */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CMDR_BLOCK ( 0 << 19) /* Single-block transfer */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CMDR_MULTI_BLOCK ( 1 << 19) /* Multi-block transfer */
|
|
|
|
# define ATMCI_CMDR_STREAM ( 2 << 19) /* MMC Stream transfer */
|
|
|
|
# define ATMCI_CMDR_SDIO_BYTE ( 4 << 19) /* SDIO Byte transfer */
|
|
|
|
# define ATMCI_CMDR_SDIO_BLOCK ( 5 << 19) /* SDIO Block transfer */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CMDR_SDIO_SUSPEND ( 1 << 24) /* SDIO Suspend Command */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CMDR_SDIO_RESUME ( 2 << 24) /* SDIO Resume Command */
|
|
|
|
#define ATMCI_BLKR 0x0018 /* Block */
|
|
|
|
# define ATMCI_BCNT(x) ((x) << 0) /* Data Block Count */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_BLKLEN(x) ((x) << 16) /* Data Block Length */
|
2011-08-11 22:25:43 +07:00
|
|
|
#define ATMCI_CSTOR 0x001c /* Completion Signal Timeout[2] */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CSTOCYC(x) ((x) << 0) /* CST cycles */
|
|
|
|
# define ATMCI_CSTOMUL(x) ((x) << 4) /* CST multiplier */
|
2011-08-11 22:25:43 +07:00
|
|
|
#define ATMCI_RSPR 0x0020 /* Response 0 */
|
|
|
|
#define ATMCI_RSPR1 0x0024 /* Response 1 */
|
|
|
|
#define ATMCI_RSPR2 0x0028 /* Response 2 */
|
|
|
|
#define ATMCI_RSPR3 0x002c /* Response 3 */
|
2011-08-11 22:25:41 +07:00
|
|
|
#define ATMCI_RDR 0x0030 /* Receive Data */
|
|
|
|
#define ATMCI_TDR 0x0034 /* Transmit Data */
|
|
|
|
#define ATMCI_SR 0x0040 /* Status */
|
|
|
|
#define ATMCI_IER 0x0044 /* Interrupt Enable */
|
|
|
|
#define ATMCI_IDR 0x0048 /* Interrupt Disable */
|
|
|
|
#define ATMCI_IMR 0x004c /* Interrupt Mask */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CMDRDY ( 1 << 0) /* Command Ready */
|
|
|
|
# define ATMCI_RXRDY ( 1 << 1) /* Receiver Ready */
|
|
|
|
# define ATMCI_TXRDY ( 1 << 2) /* Transmitter Ready */
|
|
|
|
# define ATMCI_BLKE ( 1 << 3) /* Data Block Ended */
|
|
|
|
# define ATMCI_DTIP ( 1 << 4) /* Data Transfer In Progress */
|
|
|
|
# define ATMCI_NOTBUSY ( 1 << 5) /* Data Not Busy */
|
2011-08-11 22:25:44 +07:00
|
|
|
# define ATMCI_ENDRX ( 1 << 6) /* End of RX Buffer */
|
|
|
|
# define ATMCI_ENDTX ( 1 << 7) /* End of TX Buffer */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_SDIOIRQA ( 1 << 8) /* SDIO IRQ in slot A */
|
|
|
|
# define ATMCI_SDIOIRQB ( 1 << 9) /* SDIO IRQ in slot B */
|
2011-08-11 22:25:44 +07:00
|
|
|
# define ATMCI_SDIOWAIT ( 1 << 12) /* SDIO Read Wait Operation Status */
|
|
|
|
# define ATMCI_CSRCV ( 1 << 13) /* CE-ATA Completion Signal Received */
|
|
|
|
# define ATMCI_RXBUFF ( 1 << 14) /* RX Buffer Full */
|
|
|
|
# define ATMCI_TXBUFE ( 1 << 15) /* TX Buffer Empty */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_RINDE ( 1 << 16) /* Response Index Error */
|
|
|
|
# define ATMCI_RDIRE ( 1 << 17) /* Response Direction Error */
|
|
|
|
# define ATMCI_RCRCE ( 1 << 18) /* Response CRC Error */
|
|
|
|
# define ATMCI_RENDE ( 1 << 19) /* Response End Bit Error */
|
|
|
|
# define ATMCI_RTOE ( 1 << 20) /* Response Time-Out Error */
|
|
|
|
# define ATMCI_DCRCE ( 1 << 21) /* Data CRC Error */
|
|
|
|
# define ATMCI_DTOE ( 1 << 22) /* Data Time-Out Error */
|
2011-08-11 22:25:44 +07:00
|
|
|
# define ATMCI_CSTOE ( 1 << 23) /* Completion Signal Time-out Error */
|
|
|
|
# define ATMCI_BLKOVRE ( 1 << 24) /* DMA Block Overrun Error */
|
|
|
|
# define ATMCI_DMADONE ( 1 << 25) /* DMA Transfer Done */
|
|
|
|
# define ATMCI_FIFOEMPTY ( 1 << 26) /* FIFO Empty Flag */
|
|
|
|
# define ATMCI_XFRDONE ( 1 << 27) /* Transfer Done Flag */
|
|
|
|
# define ATMCI_ACKRCV ( 1 << 28) /* Boot Operation Acknowledge Received */
|
|
|
|
# define ATMCI_ACKRCVE ( 1 << 29) /* Boot Operation Acknowledge Error */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_OVRE ( 1 << 30) /* RX Overrun Error */
|
|
|
|
# define ATMCI_UNRE ( 1 << 31) /* TX Underrun Error */
|
2011-08-11 22:25:41 +07:00
|
|
|
#define ATMCI_DMA 0x0050 /* DMA Configuration[2] */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_DMA_OFFSET(x) ((x) << 0) /* DMA Write Buffer Offset */
|
|
|
|
# define ATMCI_DMA_CHKSIZE(x) ((x) << 4) /* DMA Channel Read and Write Chunk Size */
|
|
|
|
# define ATMCI_DMAEN ( 1 << 8) /* DMA Hardware Handshaking Enable */
|
2011-08-11 22:25:41 +07:00
|
|
|
#define ATMCI_CFG 0x0054 /* Configuration[2] */
|
|
|
|
# define ATMCI_CFG_FIFOMODE_1DATA ( 1 << 0) /* MCI Internal FIFO control mode */
|
2011-08-11 22:25:43 +07:00
|
|
|
# define ATMCI_CFG_FERRCTRL_COR ( 1 << 4) /* Flow Error flag reset control mode */
|
2011-08-11 22:25:41 +07:00
|
|
|
# define ATMCI_CFG_HSMODE ( 1 << 8) /* High Speed Mode */
|
|
|
|
# define ATMCI_CFG_LSYNC ( 1 << 12) /* Synchronize on the last block */
|
2011-08-11 22:25:43 +07:00
|
|
|
#define ATMCI_WPMR 0x00e4 /* Write Protection Mode[2] */
|
|
|
|
# define ATMCI_WP_EN ( 1 << 0) /* WP Enable */
|
|
|
|
# define ATMCI_WP_KEY (0x4d4349 << 8) /* WP Key */
|
|
|
|
#define ATMCI_WPSR 0x00e8 /* Write Protection Status[2] */
|
|
|
|
# define ATMCI_GET_WP_VS(x) ((x) & 0x0f)
|
|
|
|
# define ATMCI_GET_WP_VSRC(x) (((x) >> 8) & 0xffff)
|
2011-08-11 22:25:44 +07:00
|
|
|
#define ATMCI_VERSION 0x00FC /* Version */
|
2011-08-11 22:25:43 +07:00
|
|
|
#define ATMCI_FIFO_APERTURE 0x0200 /* FIFO Aperture[2] */
|
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-06-30 23:35:03 +07:00
|
|
|
|
2009-06-12 22:58:30 +07:00
|
|
|
/* This is not including the FIFO Aperture on MCI2 */
|
2011-08-11 22:25:41 +07:00
|
|
|
#define ATMCI_REGS_SIZE 0x100
|
2008-07-24 19:18:59 +07:00
|
|
|
|
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-06-30 23:35:03 +07:00
|
|
|
/* Register access macros */
|
2015-03-18 22:53:11 +07:00
|
|
|
#ifdef CONFIG_AVR32
|
|
|
|
#define atmci_readl(port, reg) \
|
2011-08-11 22:25:42 +07:00
|
|
|
__raw_readl((port)->regs + reg)
|
2015-03-18 22:53:11 +07:00
|
|
|
#define atmci_writel(port, reg, value) \
|
2011-08-11 22:25:42 +07:00
|
|
|
__raw_writel((value), (port)->regs + reg)
|
2015-03-18 22:53:11 +07:00
|
|
|
#else
|
|
|
|
#define atmci_readl(port, reg) \
|
|
|
|
readl_relaxed((port)->regs + reg)
|
|
|
|
#define atmci_writel(port, reg, value) \
|
|
|
|
writel_relaxed((value), (port)->regs + reg)
|
|
|
|
#endif
|
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-06-30 23:35:03 +07:00
|
|
|
|
2012-08-30 23:34:27 +07:00
|
|
|
/* On AVR chips the Peripheral DMA Controller is not connected to MCI. */
|
|
|
|
#ifdef CONFIG_AVR32
|
|
|
|
# define ATMCI_PDC_CONNECTED 0
|
|
|
|
#else
|
|
|
|
# define ATMCI_PDC_CONNECTED 1
|
|
|
|
#endif
|
|
|
|
|
2012-06-06 17:19:44 +07:00
|
|
|
/*
|
|
|
|
* Fix sconfig's burst size according to atmel MCI. We need to convert them as:
|
|
|
|
* 1 -> 0, 4 -> 1, 8 -> 2, 16 -> 3.
|
|
|
|
*
|
|
|
|
* This can be done by finding most significant bit set.
|
|
|
|
*/
|
|
|
|
static inline unsigned int atmci_convert_chksize(unsigned int maxburst)
|
|
|
|
{
|
|
|
|
if (maxburst > 1)
|
|
|
|
return fls(maxburst) - 2;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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-06-30 23:35:03 +07:00
|
|
|
#endif /* __DRIVERS_MMC_ATMEL_MCI_H__ */
|