summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-omap/omap4_twl6030_mmc.c
blob: c5fa0e77aa2a418c53c0a314ef01b899a3738a8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 * Copyright (C) 2011 Alexander Aring <a.aring@phytec.de
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <common.h>
#include <io.h>

#include <mfd/twl6030.h>
#include <mach/omap/omap4_twl6030_mmc.h>

/* MMC voltage */
#define OMAP4_CONTROL_PBIASLITE			0x4A100600
#define OMAP4_MMC1_PBIASLITE_VMODE		(1<<21)
#define OMAP4_MMC1_PBIASLITE_PWRDNZ		(1<<22)
#define OMAP4_MMC1_PWRDNZ				(1<<26)

static void twl6030_mci_write(u8 address, u8 data)
{
	int ret;
	struct twl6030 *twl6030 = twl6030_get();

	ret = twl6030_reg_write(twl6030, address, data);
	if (ret != 0)
		printf("TWL6030 Write[0x%x] Error %d\n", address, ret);
}

void set_up_mmc_voltage_omap4(void)
{
	u32 value;

	value = readl(OMAP4_CONTROL_PBIASLITE);
	value &= ~(OMAP4_MMC1_PBIASLITE_PWRDNZ | OMAP4_MMC1_PWRDNZ);
	writel(value, OMAP4_CONTROL_PBIASLITE);

	twl6030_mci_write(TWL6030_PMCS_VMMC_CFG_VOLTAGE,
			  TWL6030_VMMC_WR_S |
			  TWL6030_VMMC_VSEL_0 | TWL6030_VMMC_VSEL_2 |
			  TWL6030_VMMC_VSEL_4);
	twl6030_mci_write(TWL6030_PMCS_VMMC_CFG_STATE,
			  TWL6030_VMMC_STATE0 | TWL6030_VMMC_GRP_APP);

	value = readl(OMAP4_CONTROL_PBIASLITE);
	value |= (OMAP4_MMC1_PBIASLITE_VMODE | OMAP4_MMC1_PBIASLITE_PWRDNZ |
			OMAP4_MMC1_PWRDNZ);
	writel(value, OMAP4_CONTROL_PBIASLITE);
}
EXPORT_SYMBOL(set_up_mmc_voltage_omap4);