Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * linux/arch/arm/mach-omap1/board-h2-mmc.c
0004  *
0005  * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
0006  * Author: Felipe Balbi <felipe.lima@indt.org.br>
0007  *
0008  * This code is based on linux/arch/arm/mach-omap2/board-n800-mmc.c, which is:
0009  * Copyright (C) 2006 Nokia Corporation
0010  */
0011 #include <linux/gpio.h>
0012 #include <linux/platform_device.h>
0013 #include <linux/platform_data/gpio-omap.h>
0014 #include <linux/mfd/tps65010.h>
0015 
0016 #include "board-h2.h"
0017 #include "mmc.h"
0018 
0019 #if IS_ENABLED(CONFIG_MMC_OMAP)
0020 
0021 static int mmc_set_power(struct device *dev, int slot, int power_on,
0022                 int vdd)
0023 {
0024     gpio_set_value(H2_TPS_GPIO_MMC_PWR_EN, power_on);
0025     return 0;
0026 }
0027 
0028 static int mmc_late_init(struct device *dev)
0029 {
0030     int ret = gpio_request(H2_TPS_GPIO_MMC_PWR_EN, "MMC power");
0031     if (ret < 0)
0032         return ret;
0033 
0034     gpio_direction_output(H2_TPS_GPIO_MMC_PWR_EN, 0);
0035 
0036     return ret;
0037 }
0038 
0039 static void mmc_cleanup(struct device *dev)
0040 {
0041     gpio_free(H2_TPS_GPIO_MMC_PWR_EN);
0042 }
0043 
0044 /*
0045  * H2 could use the following functions tested:
0046  * - mmc_get_cover_state that uses OMAP_MPUIO(1)
0047  * - mmc_get_wp that uses OMAP_MPUIO(3)
0048  */
0049 static struct omap_mmc_platform_data mmc1_data = {
0050     .nr_slots                       = 1,
0051     .init               = mmc_late_init,
0052     .cleanup            = mmc_cleanup,
0053     .slots[0]       = {
0054         .set_power              = mmc_set_power,
0055         .ocr_mask               = MMC_VDD_32_33 | MMC_VDD_33_34,
0056         .name                   = "mmcblk",
0057     },
0058 };
0059 
0060 static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
0061 
0062 void __init h2_mmc_init(void)
0063 {
0064     mmc_data[0] = &mmc1_data;
0065     omap1_init_mmc(mmc_data, OMAP16XX_NR_MMC);
0066 }
0067 
0068 #else
0069 
0070 void __init h2_mmc_init(void)
0071 {
0072 }
0073 
0074 #endif