Release 4.11 drivers/mmc/core/pwrseq_simple.c
/*
* 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/delay.h>
#include <linux/property.h>
#include <linux/mmc/host.h>
#include "pwrseq.h"
struct mmc_pwrseq_simple {
struct mmc_pwrseq pwrseq;
bool clk_enabled;
u32 post_power_on_delay_ms;
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
Person | Tokens | Prop | Commits | CommitProp |
Javier Martinez Canillas | 66 | 83.54% | 2 | 66.67% |
Martin Fuzzey | 13 | 16.46% | 1 | 33.33% |
Total | 79 | 100.00% | 3 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Javier Martinez Canillas | 31 | 51.67% | 2 | 50.00% |
Ulf Hansson | 28 | 46.67% | 1 | 25.00% |
Srinivas Kandagatla | 1 | 1.67% | 1 | 25.00% |
Total | 60 | 100.00% | 4 | 100.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);
if (pwrseq->post_power_on_delay_ms)
msleep(pwrseq->post_power_on_delay_ms);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Ulf Hansson | 28 | 65.12% | 1 | 25.00% |
Hans de Goede | 13 | 30.23% | 1 | 25.00% |
Javier Martinez Canillas | 1 | 2.33% | 1 | 25.00% |
Srinivas Kandagatla | 1 | 2.33% | 1 | 25.00% |
Total | 43 | 100.00% | 4 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Javier Martinez Canillas | 58 | 98.31% | 1 | 50.00% |
Srinivas Kandagatla | 1 | 1.69% | 1 | 50.00% |
Total | 59 | 100.00% | 2 | 100.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);
}
device_property_read_u32(dev, "post-power-on-delay-ms",
&pwrseq->post_power_on_delay_ms);
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
Person | Tokens | Prop | Commits | CommitProp |
Ulf Hansson | 68 | 35.23% | 2 | 25.00% |
Javier Martinez Canillas | 48 | 24.87% | 3 | 37.50% |
Srinivas Kandagatla | 45 | 23.32% | 1 | 12.50% |
Martin Fuzzey | 20 | 10.36% | 1 | 12.50% |
Hans de Goede | 12 | 6.22% | 1 | 12.50% |
Total | 193 | 100.00% | 8 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Srinivas Kandagatla | 25 | 78.12% | 1 | 33.33% |
Ulf Hansson | 7 | 21.88% | 2 | 66.67% |
Total | 32 | 100.00% | 3 | 100.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
Person | Tokens | Prop | Commits | CommitProp |
Javier Martinez Canillas | 218 | 34.60% | 3 | 30.00% |
Ulf Hansson | 188 | 29.84% | 2 | 20.00% |
Srinivas Kandagatla | 156 | 24.76% | 2 | 20.00% |
Hans de Goede | 34 | 5.40% | 1 | 10.00% |
Martin Fuzzey | 33 | 5.24% | 1 | 10.00% |
Julia Lawall | 1 | 0.16% | 1 | 10.00% |
Total | 630 | 100.00% | 10 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.