// SPDX-License-Identifier: GPL-2.0/* * bcm2835 sdhost driver. * * The 2835 has two SD controllers: The Arasan sdhci controller * (supported by the iproc driver) and a custom sdhost controller * (supported by this driver). * * The sdhci controller supports both sdcard and sdio. The sdhost * controller supports the sdcard only, but has better performance. * Also note that the rpi3 has sdio wifi, so driving the sdcard with * the sdhost controller allows to use the sdhci controller for wifi * support. * * The configuration is done by devicetree via pin muxing. Both * SD controller are available on the same pins (2 pin groups = pin 22 * to 27 + pin 48 to 53). So it's possible to use both SD controllers * at the same time with different pin groups. * * Author: Phil Elwell <phil@raspberrypi.org> * Copyright (C) 2015-2016 Raspberry Pi (Trading) Ltd. * * Based on * mmc-bcm2835.c by Gellert Weisz * which is, in turn, based on * sdhci-bcm2708.c by Broadcom * sdhci-bcm2835.c by Stephen Warren and Oleksandr Tymoshenko * sdhci.c and sdhci-pci.c by Pierre Ossman */#include<linux/clk.h>#include<linux/delay.h>#include<linux/device.h>#include<linux/dmaengine.h>#include<linux/dma-mapping.h>#include<linux/err.h>#include<linux/highmem.h>#include<linux/interrupt.h>#include<linux/io.h>#include<linux/iopoll.h>#include<linux/module.h>#include<linux/of_address.h>#include<linux/of_irq.h>#include<linux/platform_device.h>#include<linux/scatterlist.h>#include<linux/time.h>#include<linux/workqueue.h>#include<linux/mmc/host.h>#include<linux/mmc/mmc.h>#include<linux/mmc/sd.h>#define SDCMD 0x00 /* Command to SD card - 16 R/W */#define SDARG 0x04 /* Argument to SD card - 32 R/W */#define SDTOUT 0x08 /* Start value for timeout counter - 32 R/W */#define SDCDIV 0x0c /* Start value for clock divider - 11 R/W */#define SDRSP0 0x10 /* SD card response (31:0) - 32 R */#define SDRSP1 0x14 /* SD card response (63:32) - 32 R */#define SDRSP2 0x18 /* SD card response (95:64) - 32 R */#define SDRSP3 0x1c /* SD card response (127:96) - 32 R */#define SDHSTS 0x20 /* SD host status - 11 R/W */#define SDVDD 0x30 /* SD card power control - 1 R/W */#define SDEDM 0x34 /* Emergency Debug Mode - 13 R/W */#define SDHCFG 0x38 /* Host configuration - 2 R/W */#define SDHBCT 0x3c /* Host byte count (debug) - 32 R/W */#define SDDATA 0x40