diff options
author | Alexander Aring <a.aring@phytec.de> | 2011-12-21 08:50:30 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-12-21 12:48:08 +0100 |
commit | 659f150e90d8bfcf8aa4c51bd3ab552f42e288f0 (patch) | |
tree | 20f239795617794eaca566b321825d0b7da36283 | |
parent | 8658e6a9528c7e65bf7a3732d815f662c9c8ed11 (diff) | |
download | barebox-659f150e90d8bfcf8aa4c51bd3ab552f42e288f0.tar.gz barebox-659f150e90d8bfcf8aa4c51bd3ab552f42e288f0.tar.xz |
omap_hsmmc: setup mmc voltage on twl6030
Support the setup of the mmc voltage, when booting OMAP4 with twl6030
from nand.
Signed-off-by: Alexander Aring <a.aring@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r-- | arch/arm/mach-omap/Makefile | 1 | ||||
-rw-r--r-- | arch/arm/mach-omap/include/mach/omap4_twl6030_mmc.h | 14 | ||||
-rw-r--r-- | arch/arm/mach-omap/omap4_twl6030_mmc.c | 46 | ||||
-rw-r--r-- | drivers/mci/Makefile | 1 | ||||
-rw-r--r-- | drivers/mci/omap_hsmmc.c | 17 | ||||
-rw-r--r-- | drivers/mci/twl6030.c | 29 |
6 files changed, 108 insertions, 0 deletions
diff --git a/arch/arm/mach-omap/Makefile b/arch/arm/mach-omap/Makefile index 07bf30afab..9bd2b629a5 100644 --- a/arch/arm/mach-omap/Makefile +++ b/arch/arm/mach-omap/Makefile @@ -26,4 +26,5 @@ obj-$(CONFIG_ARCH_OMAP4) += omap4_generic.o omap4_clock.o obj-$(CONFIG_OMAP3_CLOCK_CONFIG) += omap3_clock_core.o omap3_clock.o obj-$(CONFIG_OMAP_GPMC) += gpmc.o devices-gpmc-nand.o obj-$(CONFIG_SHELL_NONE) += xload.o +obj-$(CONFIG_I2C_TWL6030) += omap4_twl6030_mmc.o obj-y += gpio.o diff --git a/arch/arm/mach-omap/include/mach/omap4_twl6030_mmc.h b/arch/arm/mach-omap/include/mach/omap4_twl6030_mmc.h new file mode 100644 index 0000000000..e5e2d9c229 --- /dev/null +++ b/arch/arm/mach-omap/include/mach/omap4_twl6030_mmc.h @@ -0,0 +1,14 @@ +/* + * Copyright (C) 2011 Alexander Aring <a.aring@phytec.de> + */ + +#ifndef __OMAP4_TWL6030_MMC_H__ +#define __OMAP4_TWL6030_MMC_H__ + +/* + * Sets up voltage for mmc slot. + */ +void set_up_mmc_voltage_omap4(void); + +/* __OMAP4_TWL6030_MMC_H__ */ +#endif diff --git a/arch/arm/mach-omap/omap4_twl6030_mmc.c b/arch/arm/mach-omap/omap4_twl6030_mmc.c new file mode 100644 index 0000000000..5d87935404 --- /dev/null +++ b/arch/arm/mach-omap/omap4_twl6030_mmc.c @@ -0,0 +1,46 @@ +/* + * 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. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include <common.h> +#include <io.h> + +#include <mci/twl6030.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) + +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_power_init(); + + 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); diff --git a/drivers/mci/Makefile b/drivers/mci/Makefile index 0fc31af744..b7bb846291 100644 --- a/drivers/mci/Makefile +++ b/drivers/mci/Makefile @@ -4,6 +4,7 @@ obj-$(CONFIG_MCI_S3C) += s3c.o obj-$(CONFIG_MCI_IMX) += imx.o obj-$(CONFIG_MCI_IMX_ESDHC) += imx-esdhc.o obj-$(CONFIG_MCI_OMAP_HSMMC) += omap_hsmmc.o +obj-$(CONFIG_I2C_TWL6030) += twl6030.o obj-$(CONFIG_MCI_PXA) += pxamci.o obj-$(CONFIG_MCI_ATMEL) += atmel_mci.o obj-$(CONFIG_MCI_SPI) += mci_spi.o diff --git a/drivers/mci/omap_hsmmc.c b/drivers/mci/omap_hsmmc.c index d171c1dcf7..e671bbea73 100644 --- a/drivers/mci/omap_hsmmc.c +++ b/drivers/mci/omap_hsmmc.c @@ -33,6 +33,12 @@ #include <mach/omap_hsmmc.h> +#if defined(CONFIG_I2C_TWL6030) && \ + defined(CONFIG_MCI_OMAP_HSMMC) && \ + defined(CONFIG_ARCH_OMAP4) +#include <mach/omap4_twl6030_mmc.h> +#endif + struct hsmmc { unsigned char res1[0x10]; unsigned int sysconfig; /* 0x10 */ @@ -215,6 +221,17 @@ static int mmc_init_setup(struct mci_host *mci, struct device_d *dev) unsigned int dsor; uint64_t start; +/* + * Fix voltage for mmc, if booting from nand. + * It's necessary to do this here, because + * you need to set up this at probetime. + */ +#if defined(CONFIG_I2C_TWL6030) && \ + defined(CONFIG_MCI_OMAP_HSMMC) && \ + defined(CONFIG_ARCH_OMAP4) + set_up_mmc_voltage_omap4(); +#endif + writel(readl(&mmc_base->sysconfig) | MMC_SOFTRESET, &mmc_base->sysconfig); diff --git a/drivers/mci/twl6030.c b/drivers/mci/twl6030.c new file mode 100644 index 0000000000..4a875bd62b --- /dev/null +++ b/drivers/mci/twl6030.c @@ -0,0 +1,29 @@ +/* + * MCI pmic power. + */ + +#include <mfd/twl6030.h> +#include <mci/twl6030.h> +#include <asm/io.h> + +static int 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:MCI:Write[0x%x] Error %d\n", address, ret); + + return ret; +} + +void twl6030_mci_power_init(void) +{ + twl6030_mci_write(TWL6030_PMCS_VMMC_CFG_VOLTAGE, + 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); +} + |