mmc: msm_sdcc: Add gpio handling function to driver
PATCH 1/2 mmc: msm_sdcc: Add gpio handling function to driver
Configure SDCC GPIOs when the host is powered up or powered off.
Signed-off-by Sahitya Tummala <[email protected]>
--- arch/arm/mach-msm/include/mach/mmc.h | 11 +++++++++ drivers/mmc/host/msm_sdcc.c | 40 +++++++++++++++++++++++++++++++++- drivers/mmc/host/msm_sdcc.h | 1 + 3 files changed, 51 insertions(+), 1 deletions(-)
arch/arm/mach-msm/include/mach/mmc.h +11 -0
@@ -15,12 +15,23 @@ struct embedded_sdio_data { int num_funcs; }; +struct msm_mmc_gpio { +unsigned no; +const char *name; +}; + +struct msm_mmc_gpio_data { +struct msm_mmc_gpio *gpio; +u8 size; +}; +struct msm_mmc_platform_data {unsigned int ocr_mask;/* available voltages */ u32 (*translate_vdd)(struct device *,unsigned int );unsigned int (*status)(struct device *);struct embedded_sdio_data *embedded_sdio;int (*register_status_notify)(void (*callback)(int card_present,void *dev_id),void *dev_id); +struct msm_mmc_gpio_data *gpio_data; };#endif
drivers/mmc/host/msm_sdcc.c +39 -1
@@ -36,6 +36,7 @@#include <linux/io.h> #include <linux/memory.h> #include <linux/gfp.h> +#include <linux/gpio.h> #include <asm/cacheflush.h> #include <asm/div64.h>
@@ -946,6 +947,38 @@ msmsdcc_request(struct mmc_host *mmc, struct mmc_request *mrq)spin_unlock_irqrestore (&host->lock, flags); } +static void msmsdcc_setup_gpio (struct msmsdcc_host *host,bool enable) +{ +struct msm_mmc_gpio_data *curr; +int i, rc =0 ; + +if (!host->plat->gpio_data && host->gpio_config_status == enable) +return ; + + curr = host->plat->gpio_data; +for (i =0 ; i < curr->size; i++) { +if (enable) { + rc =gpio_request (curr->gpio[i].no, + curr->gpio[i].name); +if (rc) { +pr_err ("%s: gpio_request(%d, %s) failed %d\n" , +mmc_hostname (host->mmc), + curr->gpio[i].no, + curr->gpio[i].name, rc); + goto free_gpios; + } + }else { +gpio_free (curr->gpio[i].no); + } + } + host->gpio_config_status = enable; +return ; + +free_gpios: +for (; i >=0 ; i--) +gpio_free (curr->gpio[i].no); +} +static void msmsdcc_set_ios (struct mmc_host *mmc,struct mmc_ios *ios) {
@@ -958,6 +991,8 @@ msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)msmsdcc_enable_clocks (host); +spin_unlock_irqrestore (&host->lock, flags); +if (ios->clock) {if (ios->clock != host->clk_rate) { rc =clk_set_rate (host->clk, ios->clock);
@@ -984,9 +1019,11 @@ msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)switch (ios->power_mode) {case MMC_POWER_OFF : +msmsdcc_setup_gpio (host, false);break ;case MMC_POWER_UP : pwr |=MCI_PWR_UP ; +msmsdcc_setup_gpio (host, true);break ;case MMC_POWER_ON : pwr |=MCI_PWR_ON ;
@@ -1003,9 +1040,10 @@ msmsdcc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)msmsdcc_writel (host, pwr,MMCIPOWER ); }#if BUSCLK_PWRSAVE +spin_lock_irqsave (&host->lock, flags);msmsdcc_disable_clocks (host,1 ); -#endif spin_unlock_irqrestore (&host->lock, flags); +#endif }static void msmsdcc_enable_sdio_irq (struct mmc_host *mmc,int enable)
drivers/mmc/host/msm_sdcc.h +1 -0
@@ -243,6 +243,7 @@ struct msmsdcc_host {unsigned int cmd_datactrl;struct mmc_command *cmd_cmd;u32 cmd_c; +bool gpio_config_status;bool prog_scan;bool prog_enable;
Signature · 5 lines
1.7.1 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
PATCH 2/2 msm: 8x50: Add initial support for SDCC
Signed-off-by Sahitya Tummala <[email protected]>
--- arch/arm/mach-msm/board-qsd8x50.c | 81 +++++++++- arch/arm/mach-msm/devices-qsd8x50.c | 196 +++++++++++++++++++++++ arch/arm/mach-msm/gpiomux-8x50.c | 23 +++ arch/arm/mach-msm/include/mach/msm_iomap-8x50.h | 8 +- 4 files changed, 303 insertions(+), 5 deletions(-)
arch/arm/mach-msm/board-qsd8x50.c +80 -1
@@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and
@@ -21,6 +21,7 @@#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/usb/msm_hsusb.h> +#include <linux/err.h> #include <asm/mach-types.h> #include <asm/mach/arch.h>
@@ -31,6 +32,8 @@#include <mach/irqs.h> #include <mach/sirc.h> #include <mach/gpio.h> +#include <mach/vreg.h> +#include <mach/mmc.h> #include "devices.h"
@@ -95,6 +98,81 @@ static struct platform_device *devices[] __initdata = { &msm_device_hsusb_host, }; +static struct msm_mmc_gpio sdc1_gpio_cfg[] = { + {51 ,"sdc1_dat_3" }, + {52 ,"sdc1_dat_2" }, + {53 ,"sdc1_dat_1" }, + {54 ,"sdc1_dat_0" }, + {55 ,"sdc1_cmd" }, + {56 ,"sdc1_clk" } +}; + +static struct vreg *vreg_mmc; +static unsigned long vreg_sts; + +static uint32_t msm_sdcc_setup_power (struct device *dv,unsigned int vdd) +{ +int rc =0 ; +struct platform_device *pdev; + + pdev = container_of(dv, struct platform_device, dev); + +if (vdd ==0 ) { +if (!vreg_sts) +return 0 ; + +clear_bit (pdev->id, &vreg_sts); + +if (!vreg_sts) { + rc =vreg_disable (vreg_mmc); +if (rc) +pr_err ("vreg_mmc disable failed for slot " +"%d: %d\n" , pdev->id, rc); + } +return 0 ; + } + +if (!vreg_sts) { + rc =vreg_set_level (vreg_mmc,2900 ); +if (rc) +pr_err ("vreg_mmc set level failed for slot %d: %d\n" , + pdev->id, rc); + rc =vreg_enable (vreg_mmc); +if (rc) +pr_err ("vreg_mmc enable failed for slot %d: %d\n" , + pdev->id, rc); + } +set_bit (pdev->id, &vreg_sts); +return 0 ; +} + +static struct msm_mmc_gpio_data sdc1_gpio = { + .gpio = sdc1_gpio_cfg, + .size =ARRAY_SIZE (sdc1_gpio_cfg), +}; + +static struct msm_mmc_platform_data qsd8x50_sdc1_data = { + .ocr_mask =MMC_VDD_27_28 |MMC_VDD_28_29 , + .translate_vdd = msm_sdcc_setup_power, + .gpio_data = &sdc1_gpio, +}; + +static void __init qsd8x50_init_mmc (void ) +{ +if (machine_is_qsd8x50_ffa () ||machine_is_qsd8x50a_ffa ()) + vreg_mmc =vreg_get (NULL ,"gp6" ); +else + vreg_mmc =vreg_get (NULL ,"gp5" ); + +if (IS_ERR (vreg_mmc)) { +pr_err ("vreg get for vreg_mmc failed (%ld)\n" , +PTR_ERR (vreg_mmc)); +return ; + } + +msm_add_sdcc (1 , &qsd8x50_sdc1_data,0 ,0 ); +} +static void __init qsd8x50_map_io (void ) {msm_map_qsd8x50_io ();
@@ -113,6 +191,7 @@ static void __init qsd8x50_init(void) msm_device_hsusb.dev.parent = &msm_device_otg.dev; msm_device_hsusb_host.dev.parent = &msm_device_otg.dev;platform_add_devices (devices,ARRAY_SIZE (devices)); +qsd8x50_init_mmc (); }MACHINE_START (QSD8X50_SURF ,"QCT QSD8X50 SURF" )
arch/arm/mach-msm/devices-qsd8x50.c +196 -0
208 lines not on this page · raw message
arch/arm/mach-msm/gpiomux-8x50.c +23 -0
@@ -16,6 +16,19 @@*/ #include "gpiomux.h" +#if defined(CONFIG_MMC_MSM ) || defined(CONFIG_MMC_MSM_MODULE ) +#define SDCC_DAT_0_3_CMD_ACTV_CFG (GPIOMUX_VALID | GPIOMUX_PULL_UP\ + | GPIOMUX_FUNC_1 | GPIOMUX_DRV_8MA) +#define SDCC_CLK_ACTV_CFG (GPIOMUX_VALID | GPIOMUX_PULL_NONE\ + | GPIOMUX_FUNC_1 | GPIOMUX_DRV_8MA) +#else +#define SDCC_DAT_0_3_CMD_ACTV_CFG 0 +#define SDCC_CLK_ACTV_CFG 0 +#endif + +#define SDC1_SUSPEND_CONFIG (GPIOMUX_VALID | GPIOMUX_PULL_DOWN\ + | GPIOMUX_FUNC_GPIO | GPIOMUX_DRV_2MA) +struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS ] = { [86 ] = {/* UART3 RX */ .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN |
@@ -25,4 +38,14 @@ struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = { .suspended = GPIOMUX_DRV_2MA | GPIOMUX_PULL_DOWN | GPIOMUX_FUNC_1 | GPIOMUX_VALID, }, +/* SDC1 data[3:0] & CMD */ + [51 ... 55] = { + .active = SDCC_DAT_0_3_CMD_ACTV_CFG, + .suspended =SDC1_SUSPEND_CONFIG + }, +/* SDC1 CLK */ + [56] = { + .active = SDCC_CLK_ACTV_CFG, + .suspended =SDC1_SUSPEND_CONFIG + }, };
arch/arm/mach-msm/include/mach/msm_iomap-8x50.h +4 -4
@@ -132,16 +132,16 @@#define MSM_UART2DM_PHYS 0xA0900000 -#define MSM_SDC1_PHYS 0xA0400000 +#define MSM_SDC1_PHYS 0xA0300000#define MSM_SDC1_SIZE SZ_4K -#define MSM_SDC2_PHYS 0xA0500000 +#define MSM_SDC2_PHYS 0xA0400000#define MSM_SDC2_SIZE SZ_4K -#define MSM_SDC3_PHYS 0xA0600000 +#define MSM_SDC3_PHYS 0xA0500000#define MSM_SDC3_SIZE SZ_4K -#define MSM_SDC4_PHYS 0xA0700000 +#define MSM_SDC4_PHYS 0xA0600000#define MSM_SDC4_SIZE SZ_4K#endif
Signature · 5 lines
1.7.1 -- Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/2] msm: 8x50: Add initial support for SDCC
Hi Sahitya,
Quoted 13 lines · Sahitya Tummala
Signed-off-by Sahitya Tummala<[email protected]>--- arch/arm/mach-msm/board-qsd8x50.c | 81 +++++++++- arch/arm/mach-msm/devices-qsd8x50.c | 196 +++++++++++++++++++++++ arch/arm/mach-msm/gpiomux-8x50.c | 23 +++ arch/arm/mach-msm/include/mach/msm_iomap-8x50.h | 8 +- 4 files changed, 303 insertions(+), 5 deletions(-)arch/arm/mach-msm/board-qsd8x50.c +0
-0
arch/arm/mach-msm/board-qsd8x50.c line 1
Quoted 2 lines
arch/arm/mach-msm/board-qsd8x50.c +1
-1@@ -1,4 +1,4 @@ -/* Copyright (c) 2008-2009, Code Aurora Forum. All rights reserved. +/* Copyright (c) 2009-2011, Code Aurora Forum. All rights reserved.
Why not 2008-2011?
Quoted 59 lines
arch/arm/mach-msm/board-qsd8x50.c +38
-0* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and @@ -21,6 +21,7 @@#include <linux/platform_device.h> #include <linux/delay.h> #include <linux/usb/msm_hsusb.h> +#include <linux/err.h> #include <asm/mach-types.h> #include <asm/mach/arch.h> @@ -31,6 +32,8 @@#include <mach/irqs.h> #include <mach/sirc.h> #include <mach/gpio.h> +#include <mach/vreg.h> +#include <mach/mmc.h> #include "devices.h" @@ -95,6 +98,81 @@ static struct platform_device *devices[] __initdata = { &msm_device_hsusb_host, }; +static struct msm_mmc_gpio sdc1_gpio_cfg[] = { + {51 ,"sdc1_dat_3" }, + {52 ,"sdc1_dat_2" }, + {53 ,"sdc1_dat_1" }, + {54 ,"sdc1_dat_0" }, + {55 ,"sdc1_cmd" }, + {56 ,"sdc1_clk" } +}; + +static struct vreg *vreg_mmc; +static unsigned long vreg_sts; + +static uint32_t msm_sdcc_setup_power (struct device *dv,unsigned int vdd) +{ +int rc =0 ; +struct platform_device *pdev; + + pdev = container_of(dv, struct platform_device, dev); + +if (vdd ==0 ) { +if (!vreg_sts) +return 0 ; + +clear_bit (pdev->id,&vreg_sts); + +if (!vreg_sts) { + rc =vreg_disable (vreg_mmc); +if (rc) +pr_err ("vreg_mmc disable failed for slot " +"%d: %d\n" , pdev->id, rc); + } +return 0 ; + } + +if (!vreg_sts) {
arch/arm/mach-msm/board-qsd8x50.c static struct platform_device *devices[] __initdata = { · line 145
Quoted 10 lines
arch/arm/mach-msm/board-qsd8x50.c +10
-0+ rc =vreg_set_level (vreg_mmc,2900 ); +if (rc) +pr_err ("vreg_mmc set level failed for slot %d: %d\n" , + pdev->id, rc); + rc =vreg_enable (vreg_mmc); +if (rc) +pr_err ("vreg_mmc enable failed for slot %d: %d\n" , + pdev->id, rc); + } +set_bit (pdev->id,&vreg_sts);
non-atomic version? __set_bit?
---Trilok Soni
Signature · 2 lines
Sent by a consultant of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.
Re: [PATCH 2/2] msm: 8x50: Add initial support for SDCC
In reply to Sahitya TummalaQuoted 7 lines · Sahitya Tummala
Signed-off-by Sahitya Tummala <[email protected]>--- arch/arm/mach-msm/board-qsd8x50.c | 81 +++++++++- arch/arm/mach-msm/devices-qsd8x50.c | 196 +++++++++++++++++++++++ arch/arm/mach-msm/gpiomux-8x50.c | 23 +++ arch/arm/mach-msm/include/mach/msm_iomap-8x50.h | 8 +- 4 files changed, 303 insertions(+), 5 deletions(-)
This will have to wait until the msm_sdcc driver itself is cleaned up to not use the internal dma api calls (and compiles again with the current kernel).
Signature · 2 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.