clk-max77686.c 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include <linux/kernel.h>
  23. #include <linux/slab.h>
  24. #include <linux/err.h>
  25. #include <linux/platform_device.h>
  26. #include <linux/mfd/max77686.h>
  27. #include <linux/mfd/max77686-private.h>
  28. #include <linux/clk-provider.h>
  29. #include <linux/mutex.h>
  30. #include <linux/clkdev.h>
  31. #include <dt-bindings/clock/maxim,max77686.h>
  32. #include "clk-max-gen.h"
  33. static struct clk_init_data max77686_clks_init[MAX77686_CLKS_NUM] = {
  34. [MAX77686_CLK_AP] = {
  35. .name = "32khz_ap",
  36. .ops = &max_gen_clk_ops,
  37. .flags = CLK_IS_ROOT,
  38. },
  39. [MAX77686_CLK_CP] = {
  40. .name = "32khz_cp",
  41. .ops = &max_gen_clk_ops,
  42. .flags = CLK_IS_ROOT,
  43. },
  44. [MAX77686_CLK_PMIC] = {
  45. .name = "32khz_pmic",
  46. .ops = &max_gen_clk_ops,
  47. .flags = CLK_IS_ROOT,
  48. },
  49. };
  50. static int max77686_clk_probe(struct platform_device *pdev)
  51. {
  52. struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent);
  53. return max_gen_clk_probe(pdev, iodev->regmap, MAX77686_REG_32KHZ,
  54. max77686_clks_init, MAX77686_CLKS_NUM);
  55. }
  56. static int max77686_clk_remove(struct platform_device *pdev)
  57. {
  58. return max_gen_clk_remove(pdev, MAX77686_CLKS_NUM);
  59. }
  60. static const struct platform_device_id max77686_clk_id[] = {
  61. { "max77686-clk", 0},
  62. { },
  63. };
  64. MODULE_DEVICE_TABLE(platform, max77686_clk_id);
  65. static struct platform_driver max77686_clk_driver = {
  66. .driver = {
  67. .name = "max77686-clk",
  68. },
  69. .probe = max77686_clk_probe,
  70. .remove = max77686_clk_remove,
  71. .id_table = max77686_clk_id,
  72. };
  73. module_platform_driver(max77686_clk_driver);
  74. MODULE_DESCRIPTION("MAXIM 77686 Clock Driver");
  75. MODULE_AUTHOR("Jonghwa Lee <jonghwa3.lee@samsung.com>");
  76. MODULE_LICENSE("GPL");