blob: 677ccef5cd32eddbe1e309d0f169e70af547e041 [file] [log] [blame]
Linus Walleijbb3cee22009-04-23 10:22:13 +01001/*
2 *
3 * arch/arm/mach-u300/mmc.c
4 *
5 *
Linus Walleijec8f1252010-08-13 11:31:59 +02006 * Copyright (C) 2009 ST-Ericsson SA
Linus Walleijbb3cee22009-04-23 10:22:13 +01007 * License terms: GNU General Public License (GPL) version 2
8 *
9 * Author: Linus Walleij <linus.walleij@stericsson.com>
Linus Walleijec8f1252010-08-13 11:31:59 +020010 * Author: Johan Lundin
Linus Walleijbb3cee22009-04-23 10:22:13 +010011 * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
12 */
13#include <linux/device.h>
14#include <linux/amba/bus.h>
15#include <linux/mmc/host.h>
Linus Walleijbb3cee22009-04-23 10:22:13 +010016#include <linux/gpio.h>
Linus Walleijec8f1252010-08-13 11:31:59 +020017#include <linux/dmaengine.h>
Linus Walleij6ef297f2009-09-22 14:29:36 +010018#include <linux/amba/mmci.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090019#include <linux/slab.h>
Linus Walleijec8f1252010-08-13 11:31:59 +020020#include <mach/coh901318.h>
21#include <mach/dma_channels.h>
Linus Walleijbb3cee22009-04-23 10:22:13 +010022
Linus Walleijbb3cee22009-04-23 10:22:13 +010023#include "mmc.h"
Linus Walleijdf1e0522009-08-10 12:52:40 +010024#include "padmux.h"
Linus Walleijbb3cee22009-04-23 10:22:13 +010025
Linus Walleij1a721852011-02-02 14:41:19 +010026static struct mmci_platform_data mmc0_plat_data = {
Linus Walleijf9e8eef2009-09-24 21:42:44 +010027 /*
28 * Do not set ocr_mask or voltage translation function,
29 * we have a regulator we can control instead.
30 */
Linus Walleijbb3cee22009-04-23 10:22:13 +010031 /* Nominally 2.85V on our platform */
Linus Walleij1a721852011-02-02 14:41:19 +010032 .f_max = 24000000,
33 .gpio_wp = -1,
34 .gpio_cd = U300_GPIO_PIN_MMC_CD,
35 .cd_invert = true,
36 .capabilities = MMC_CAP_MMC_HIGHSPEED |
37 MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
Linus Walleijec8f1252010-08-13 11:31:59 +020038#ifdef CONFIG_COH901318
39 .dma_filter = coh901318_filter_id,
40 .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
41 /* Don't specify a TX channel, this RX channel is bidirectional */
42#endif
Linus Walleij1a721852011-02-02 14:41:19 +010043};
Linus Walleijbb3cee22009-04-23 10:22:13 +010044
Linus Walleij1a721852011-02-02 14:41:19 +010045int __devinit mmc_init(struct amba_device *adev)
46{
47 struct device *mmcsd_device = &adev->dev;
48 struct pmx *pmx;
49 int ret = 0;
Linus Walleijbb3cee22009-04-23 10:22:13 +010050
Linus Walleij1a721852011-02-02 14:41:19 +010051 mmcsd_device->platform_data = &mmc0_plat_data;
Linus Walleijbb3cee22009-04-23 10:22:13 +010052
Linus Walleijdf1e0522009-08-10 12:52:40 +010053 /*
54 * Setup padmuxing for MMC. Since this must always be
55 * compiled into the kernel, pmx is never released.
56 */
57 pmx = pmx_get(mmcsd_device, U300_APP_PMX_MMC_SETTING);
58
59 if (IS_ERR(pmx))
60 pr_warning("Could not get padmux handle\n");
61 else {
62 ret = pmx_activate(mmcsd_device, pmx);
63 if (IS_ERR_VALUE(ret))
64 pr_warning("Could not activate padmuxing\n");
65 }
66
Linus Walleijbb3cee22009-04-23 10:22:13 +010067 return ret;
68}