Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 1 | /* |
| 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> |
Paul Gortmaker | a0c4dfe | 2015-05-01 20:02:30 -0400 | [diff] [blame] | 26 | #include <linux/module.h> |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 27 | #include <linux/platform_device.h> |
| 28 | #include <linux/mfd/max77686.h> |
| 29 | #include <linux/mfd/max77686-private.h> |
| 30 | #include <linux/clk-provider.h> |
| 31 | #include <linux/mutex.h> |
| 32 | #include <linux/clkdev.h> |
| 33 | |
Javier Martinez Canillas | a8a76f5 | 2014-08-18 10:32:59 +0200 | [diff] [blame] | 34 | #include <dt-bindings/clock/maxim,max77686.h> |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 35 | #include "clk-max-gen.h" |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 36 | |
| 37 | static struct clk_init_data max77686_clks_init[MAX77686_CLKS_NUM] = { |
| 38 | [MAX77686_CLK_AP] = { |
| 39 | .name = "32khz_ap", |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 40 | .ops = &max_gen_clk_ops, |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 41 | .flags = CLK_IS_ROOT, |
| 42 | }, |
| 43 | [MAX77686_CLK_CP] = { |
| 44 | .name = "32khz_cp", |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 45 | .ops = &max_gen_clk_ops, |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 46 | .flags = CLK_IS_ROOT, |
| 47 | }, |
| 48 | [MAX77686_CLK_PMIC] = { |
| 49 | .name = "32khz_pmic", |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 50 | .ops = &max_gen_clk_ops, |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 51 | .flags = CLK_IS_ROOT, |
| 52 | }, |
| 53 | }; |
| 54 | |
Bill Pemberton | 018ae93 | 2012-11-19 13:22:52 -0500 | [diff] [blame] | 55 | static int max77686_clk_probe(struct platform_device *pdev) |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 56 | { |
| 57 | struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 58 | |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 59 | return max_gen_clk_probe(pdev, iodev->regmap, MAX77686_REG_32KHZ, |
| 60 | max77686_clks_init, MAX77686_CLKS_NUM); |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 61 | } |
| 62 | |
Bill Pemberton | 1fc7ad5 | 2012-11-19 13:25:43 -0500 | [diff] [blame] | 63 | static int max77686_clk_remove(struct platform_device *pdev) |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 64 | { |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 65 | return max_gen_clk_remove(pdev, MAX77686_CLKS_NUM); |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | static const struct platform_device_id max77686_clk_id[] = { |
| 69 | { "max77686-clk", 0}, |
| 70 | { }, |
| 71 | }; |
| 72 | MODULE_DEVICE_TABLE(platform, max77686_clk_id); |
| 73 | |
| 74 | static struct platform_driver max77686_clk_driver = { |
| 75 | .driver = { |
| 76 | .name = "max77686-clk", |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 77 | }, |
| 78 | .probe = max77686_clk_probe, |
Bill Pemberton | f9cfa63 | 2012-11-19 13:19:59 -0500 | [diff] [blame] | 79 | .remove = max77686_clk_remove, |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 80 | .id_table = max77686_clk_id, |
| 81 | }; |
| 82 | |
Javier Martinez Canillas | 1887d69 | 2014-08-18 10:33:01 +0200 | [diff] [blame] | 83 | module_platform_driver(max77686_clk_driver); |
Jonghwa Lee | 73118e6 | 2012-08-28 17:54:28 +0900 | [diff] [blame] | 84 | |
| 85 | MODULE_DESCRIPTION("MAXIM 77686 Clock Driver"); |
| 86 | MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>"); |
| 87 | MODULE_LICENSE("GPL"); |