cregit-Linux how code gets into the kernel

Release 4.11 drivers/clk/mediatek/reset.c

/*
 * Copyright (c) 2014 MediaTek Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 *
 * 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.
 */

#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/reset-controller.h>
#include <linux/slab.h>

#include "clk-mtk.h"


struct mtk_reset {
	
struct regmap *regmap;
	
int regofs;
	
struct reset_controller_dev rcdev;
};


static int mtk_reset_assert(struct reset_controller_dev *rcdev, unsigned long id) { struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev); return regmap_update_bits(data->regmap, data->regofs + ((id / 32) << 2), BIT(id % 32), ~0); }

Contributors

PersonTokensPropCommitsCommitProp
Sascha Hauer62100.00%1100.00%
Total62100.00%1100.00%


static int mtk_reset_deassert(struct reset_controller_dev *rcdev, unsigned long id) { struct mtk_reset *data = container_of(rcdev, struct mtk_reset, rcdev); return regmap_update_bits(data->regmap, data->regofs + ((id / 32) << 2), BIT(id % 32), 0); }

Contributors

PersonTokensPropCommitsCommitProp
Sascha Hauer61100.00%1100.00%
Total61100.00%1100.00%


static int mtk_reset(struct reset_controller_dev *rcdev, unsigned long id) { int ret; ret = mtk_reset_assert(rcdev, id); if (ret) return ret; return mtk_reset_deassert(rcdev, id); }

Contributors

PersonTokensPropCommitsCommitProp
Sascha Hauer42100.00%1100.00%
Total42100.00%1100.00%

static const struct reset_control_ops mtk_reset_ops = { .assert = mtk_reset_assert, .deassert = mtk_reset_deassert, .reset = mtk_reset, };
void mtk_register_reset_controller(struct device_node *np, unsigned int num_regs, int regofs) { struct mtk_reset *data; int ret; struct regmap *regmap; regmap = syscon_node_to_regmap(np); if (IS_ERR(regmap)) { pr_err("Cannot find regmap for %s: %ld\n", np->full_name, PTR_ERR(regmap)); return; } data = kzalloc(sizeof(*data), GFP_KERNEL); if (!data) return; data->regmap = regmap; data->regofs = regofs; data->rcdev.owner = THIS_MODULE; data->rcdev.nr_resets = num_regs * 32; data->rcdev.ops = &mtk_reset_ops; data->rcdev.of_node = np; ret = reset_controller_register(&data->rcdev); if (ret) { pr_err("could not register reset controller: %d\n", ret); kfree(data); return; } }

Contributors

PersonTokensPropCommitsCommitProp
Sascha Hauer156100.00%1100.00%
Total156100.00%1100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Sascha Hauer38599.74%150.00%
Philipp Zabel10.26%150.00%
Total386100.00%2100.00%
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.