clk-max77686.c 2.35 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * clk-max77686.c - Clock driver for Maxim 77686
 *
 * Copyright (C) 2012 Samsung Electornics
 * Jonghwa Lee <jonghwa3.lee@samsung.com>
 *
 * This program is free software; you can redistribute  it and/or modify it
 * under  the terms of  the GNU General  Public License as published by the
 * Free Software Foundation;  either version 2 of the  License, or (at your
 * option) any later version.
 *
 * 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/err.h>
26
#include <linux/module.h>
27 28 29 30 31 32 33
#include <linux/platform_device.h>
#include <linux/mfd/max77686.h>
#include <linux/mfd/max77686-private.h>
#include <linux/clk-provider.h>
#include <linux/mutex.h>
#include <linux/clkdev.h>

34
#include <dt-bindings/clock/maxim,max77686.h>
35
#include "clk-max-gen.h"
36 37 38 39

static struct clk_init_data max77686_clks_init[MAX77686_CLKS_NUM] = {
	[MAX77686_CLK_AP] = {
		.name = "32khz_ap",
40
		.ops = &max_gen_clk_ops,
41 42 43
	},
	[MAX77686_CLK_CP] = {
		.name = "32khz_cp",
44
		.ops = &max_gen_clk_ops,
45 46 47
	},
	[MAX77686_CLK_PMIC] = {
		.name = "32khz_pmic",
48
		.ops = &max_gen_clk_ops,
49 50 51
	},
};

52
static int max77686_clk_probe(struct platform_device *pdev)
53 54
{
	struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
55

56 57
	return max_gen_clk_probe(pdev, iodev->regmap, MAX77686_REG_32KHZ,
				 max77686_clks_init, MAX77686_CLKS_NUM);
58 59
}

60
static int max77686_clk_remove(struct platform_device *pdev)
61
{
62
	return max_gen_clk_remove(pdev, MAX77686_CLKS_NUM);
63 64 65 66 67 68 69 70 71 72 73 74 75
}

static const struct platform_device_id max77686_clk_id[] = {
	{ "max77686-clk", 0},
	{ },
};
MODULE_DEVICE_TABLE(platform, max77686_clk_id);

static struct platform_driver max77686_clk_driver = {
	.driver = {
		.name  = "max77686-clk",
	},
	.probe = max77686_clk_probe,
76
	.remove = max77686_clk_remove,
77 78 79
	.id_table = max77686_clk_id,
};

80
module_platform_driver(max77686_clk_driver);
81 82 83 84

MODULE_DESCRIPTION("MAXIM 77686 Clock Driver");
MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");
MODULE_LICENSE("GPL");