blob: 86cdb3a28629ab09394292e2b210eb5b689b4504 [file] [log] [blame]
Jonghwa Lee73118e62012-08-28 17:54:28 +09001/*
2 * clk-max77686.c - Clock driver for Maxim 77686
3 *
4 * Copyright (C) 2012 Samsung Electornics
5 * Jonghwa Lee <jonghwa3.lee@samsung.com>
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23#include <linux/kernel.h>
24#include <linux/slab.h>
25#include <linux/err.h>
26#include <linux/platform_device.h>
27#include <linux/mfd/max77686.h>
28#include <linux/mfd/max77686-private.h>
29#include <linux/clk-provider.h>
30#include <linux/mutex.h>
31#include <linux/clkdev.h>
32
Javier Martinez Canillasa8a76f52014-08-18 10:32:59 +020033#include <dt-bindings/clock/maxim,max77686.h>
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020034#include "clk-max-gen.h"
Jonghwa Lee73118e62012-08-28 17:54:28 +090035
36static struct clk_init_data max77686_clks_init[MAX77686_CLKS_NUM] = {
37 [MAX77686_CLK_AP] = {
38 .name = "32khz_ap",
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020039 .ops = &max_gen_clk_ops,
Jonghwa Lee73118e62012-08-28 17:54:28 +090040 .flags = CLK_IS_ROOT,
41 },
42 [MAX77686_CLK_CP] = {
43 .name = "32khz_cp",
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020044 .ops = &max_gen_clk_ops,
Jonghwa Lee73118e62012-08-28 17:54:28 +090045 .flags = CLK_IS_ROOT,
46 },
47 [MAX77686_CLK_PMIC] = {
48 .name = "32khz_pmic",
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020049 .ops = &max_gen_clk_ops,
Jonghwa Lee73118e62012-08-28 17:54:28 +090050 .flags = CLK_IS_ROOT,
51 },
52};
53
Bill Pemberton018ae932012-11-19 13:22:52 -050054static int max77686_clk_probe(struct platform_device *pdev)
Jonghwa Lee73118e62012-08-28 17:54:28 +090055{
56 struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
Jonghwa Lee73118e62012-08-28 17:54:28 +090057
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020058 return max_gen_clk_probe(pdev, iodev->regmap, MAX77686_REG_32KHZ,
59 max77686_clks_init, MAX77686_CLKS_NUM);
Jonghwa Lee73118e62012-08-28 17:54:28 +090060}
61
Bill Pemberton1fc7ad52012-11-19 13:25:43 -050062static int max77686_clk_remove(struct platform_device *pdev)
Jonghwa Lee73118e62012-08-28 17:54:28 +090063{
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020064 return max_gen_clk_remove(pdev, MAX77686_CLKS_NUM);
Jonghwa Lee73118e62012-08-28 17:54:28 +090065}
66
67static const struct platform_device_id max77686_clk_id[] = {
68 { "max77686-clk", 0},
69 { },
70};
71MODULE_DEVICE_TABLE(platform, max77686_clk_id);
72
73static struct platform_driver max77686_clk_driver = {
74 .driver = {
75 .name = "max77686-clk",
Jonghwa Lee73118e62012-08-28 17:54:28 +090076 },
77 .probe = max77686_clk_probe,
Bill Pembertonf9cfa632012-11-19 13:19:59 -050078 .remove = max77686_clk_remove,
Jonghwa Lee73118e62012-08-28 17:54:28 +090079 .id_table = max77686_clk_id,
80};
81
Javier Martinez Canillas1887d692014-08-18 10:33:01 +020082module_platform_driver(max77686_clk_driver);
Jonghwa Lee73118e62012-08-28 17:54:28 +090083
84MODULE_DESCRIPTION("MAXIM 77686 Clock Driver");
85MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");
86MODULE_LICENSE("GPL");