cregit-Linux how code gets into the kernel

Release 4.7 drivers/mmc/core/pwrseq_simple.c

Directory: drivers/mmc/core
/*
 *  Copyright (C) 2014 Linaro Ltd
 *
 * Author: Ulf Hansson <ulf.hansson@linaro.org>
 *
 * License terms: GNU General Public License (GPL) version 2
 *
 *  Simple MMC power sequence management
 */
#include <linux/clk.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/gpio/consumer.h>

#include <linux/mmc/host.h>

#include "pwrseq.h"


struct mmc_pwrseq_simple {
	
struct mmc_pwrseq pwrseq;
	
bool clk_enabled;
	
struct clk *ext_clk;
	
struct gpio_descs *reset_gpios;
};


#define to_pwrseq_simple(p) container_of(p, struct mmc_pwrseq_simple, pwrseq)


static void mmc_pwrseq_simple_set_gpios_value(struct mmc_pwrseq_simple *pwrseq, int value) { struct gpio_descs *reset_gpios = pwrseq->reset_gpios; if (!IS_ERR(reset_gpios)) { int i; int values[reset_gpios->ndescs]; for (i = 0; i < reset_gpios->ndescs; i++) values[i] = value; gpiod_set_array_value_cansleep( reset_gpios->ndescs, reset_gpios->desc, values); } }

Contributors

PersonTokensPropCommitsCommitProp
javier martinez canillasjavier martinez canillas6683.54%266.67%
martin fuzzeymartin fuzzey1316.46%133.33%
Total79100.00%3100.00%


static void mmc_pwrseq_simple_pre_power_on(struct mmc_host *host) { struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq); if (!IS_ERR(pwrseq->ext_clk) && !pwrseq->clk_enabled) { clk_prepare_enable(pwrseq->ext_clk); pwrseq->clk_enabled = true; } mmc_pwrseq_simple_set_gpios_value(pwrseq, 1); }

Contributors

PersonTokensPropCommitsCommitProp
javier martinez canillasjavier martinez canillas3151.67%250.00%
ulf hanssonulf hansson2846.67%125.00%
srinivas kandagatlasrinivas kandagatla11.67%125.00%
Total60100.00%4100.00%


static void mmc_pwrseq_simple_post_power_on(struct mmc_host *host) { struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq); mmc_pwrseq_simple_set_gpios_value(pwrseq, 0); }

Contributors

PersonTokensPropCommitsCommitProp
ulf hanssonulf hansson2893.33%133.33%
javier martinez canillasjavier martinez canillas13.33%133.33%
srinivas kandagatlasrinivas kandagatla13.33%133.33%
Total30100.00%3100.00%


static void mmc_pwrseq_simple_power_off(struct mmc_host *host) { struct mmc_pwrseq_simple *pwrseq = to_pwrseq_simple(host->pwrseq); mmc_pwrseq_simple_set_gpios_value(pwrseq, 1); if (!IS_ERR(pwrseq->ext_clk) && pwrseq->clk_enabled) { clk_disable_unprepare(pwrseq->ext_clk); pwrseq->clk_enabled = false; } }

Contributors

PersonTokensPropCommitsCommitProp
javier martinez canillasjavier martinez canillas5898.31%150.00%
srinivas kandagatlasrinivas kandagatla11.69%150.00%
Total59100.00%2100.00%

static const struct mmc_pwrseq_ops mmc_pwrseq_simple_ops = { .pre_power_on = mmc_pwrseq_simple_pre_power_on, .post_power_on = mmc_pwrseq_simple_post_power_on, .power_off = mmc_pwrseq_simple_power_off, }; static const struct of_device_id mmc_pwrseq_simple_of_match[] = { { .compatible = "mmc-pwrseq-simple",}, {/* sentinel */}, }; MODULE_DEVICE_TABLE(of, mmc_pwrseq_simple_of_match);
static int mmc_pwrseq_simple_probe(struct platform_device *pdev) { struct mmc_pwrseq_simple *pwrseq; struct device *dev = &pdev->dev; pwrseq = devm_kzalloc(dev, sizeof(*pwrseq), GFP_KERNEL); if (!pwrseq) return -ENOMEM; pwrseq->ext_clk = devm_clk_get(dev, "ext_clock"); if (IS_ERR(pwrseq->ext_clk) && PTR_ERR(pwrseq->ext_clk) != -ENOENT) return PTR_ERR(pwrseq->ext_clk); pwrseq->reset_gpios = devm_gpiod_get_array(dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(pwrseq->reset_gpios) && PTR_ERR(pwrseq->reset_gpios) != -ENOENT && PTR_ERR(pwrseq->reset_gpios) != -ENOSYS) { return PTR_ERR(pwrseq->reset_gpios); } pwrseq->pwrseq.dev = dev; pwrseq->pwrseq.ops = &mmc_pwrseq_simple_ops; pwrseq->pwrseq.owner = THIS_MODULE; platform_set_drvdata(pdev, pwrseq); return mmc_pwrseq_register(&pwrseq->pwrseq); }

Contributors

PersonTokensPropCommitsCommitProp
ulf hanssonulf hansson6837.57%228.57%
javier martinez canillasjavier martinez canillas4826.52%342.86%
srinivas kandagatlasrinivas kandagatla4524.86%114.29%
martin fuzzeymartin fuzzey2011.05%114.29%
Total181100.00%7100.00%


static int mmc_pwrseq_simple_remove(struct platform_device *pdev) { struct mmc_pwrseq_simple *pwrseq = platform_get_drvdata(pdev); mmc_pwrseq_unregister(&pwrseq->pwrseq); return 0; }

Contributors

PersonTokensPropCommitsCommitProp
srinivas kandagatlasrinivas kandagatla2578.12%133.33%
ulf hanssonulf hansson721.88%266.67%
Total32100.00%3100.00%

static struct platform_driver mmc_pwrseq_simple_driver = { .probe = mmc_pwrseq_simple_probe, .remove = mmc_pwrseq_simple_remove, .driver = { .name = "pwrseq_simple", .of_match_table = mmc_pwrseq_simple_of_match, }, }; module_platform_driver(mmc_pwrseq_simple_driver); MODULE_LICENSE("GPL v2");

Overall Contributors

PersonTokensPropCommitsCommitProp
javier martinez canillasjavier martinez canillas21836.58%333.33%
ulf hanssonulf hansson18831.54%222.22%
srinivas kandagatlasrinivas kandagatla15626.17%222.22%
martin fuzzeymartin fuzzey335.54%111.11%
julia lawalljulia lawall10.17%111.11%
Total596100.00%9100.00%
Directory: drivers/mmc/core
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
{% endraw %}