Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

clk: Add driver for Maxim 77802 PMIC clocks

The MAX77802 PMIC has two 32.768kHz Buffered Clock Outputs with
Low Jitter Mode. This patch adds support for these two clocks.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Signed-off-by: Mike Turquette <mturquette@linaro.org>

authored by

Javier Martinez Canillas and committed by
Mike Turquette
83ccf16c fcd0864c

+128
+7
drivers/clk/Kconfig
··· 42 42 ---help--- 43 43 This driver supports Maxim 77686 crystal oscillator clock. 44 44 45 + config COMMON_CLK_MAX77802 46 + tristate "Clock driver for Maxim 77802 PMIC" 47 + depends on MFD_MAX77686 48 + select COMMON_CLK_MAX_GEN 49 + ---help--- 50 + This driver supports Maxim 77802 crystal oscillator clock. 51 + 45 52 config COMMON_CLK_SI5351 46 53 tristate "Clock driver for SiLabs 5351A/B/C" 47 54 depends on I2C
+1
drivers/clk/Makefile
··· 24 24 obj-$(CONFIG_MACH_LOONGSON1) += clk-ls1x.o 25 25 obj-$(CONFIG_COMMON_CLK_MAX_GEN) += clk-max-gen.o 26 26 obj-$(CONFIG_COMMON_CLK_MAX77686) += clk-max77686.o 27 + obj-$(CONFIG_COMMON_CLK_MAX77802) += clk-max77802.o 27 28 obj-$(CONFIG_ARCH_MOXART) += clk-moxart.o 28 29 obj-$(CONFIG_ARCH_NOMADIK) += clk-nomadik.o 29 30 obj-$(CONFIG_ARCH_NSPIRE) += clk-nspire.o
+98
drivers/clk/clk-max77802.c
··· 1 + /* 2 + * clk-max77802.c - Clock driver for Maxim 77802 3 + * 4 + * Copyright (C) 2014 Google, Inc 5 + * 6 + * Copyright (C) 2012 Samsung Electornics 7 + * Jonghwa Lee <jonghwa3.lee@samsung.com> 8 + * 9 + * This program is free software; you can redistribute it and/or modify it 10 + * under the terms of the GNU General Public License as published by the 11 + * Free Software Foundation; either version 2 of the License, or (at your 12 + * option) any later version. 13 + * 14 + * This program is distributed in the hope that it will be useful, 15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 + * GNU General Public License for more details. 18 + * 19 + * This driver is based on clk-max77686.c 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-private.h> 27 + #include <linux/clk-provider.h> 28 + #include <linux/mutex.h> 29 + #include <linux/clkdev.h> 30 + 31 + #include <dt-bindings/clock/maxim,max77802.h> 32 + #include "clk-max-gen.h" 33 + 34 + #define MAX77802_CLOCK_OPMODE_MASK 0x1 35 + #define MAX77802_CLOCK_LOW_JITTER_SHIFT 0x3 36 + 37 + static struct clk_init_data max77802_clks_init[MAX77802_CLKS_NUM] = { 38 + [MAX77802_CLK_32K_AP] = { 39 + .name = "32khz_ap", 40 + .ops = &max_gen_clk_ops, 41 + .flags = CLK_IS_ROOT, 42 + }, 43 + [MAX77802_CLK_32K_CP] = { 44 + .name = "32khz_cp", 45 + .ops = &max_gen_clk_ops, 46 + .flags = CLK_IS_ROOT, 47 + }, 48 + }; 49 + 50 + static int max77802_clk_probe(struct platform_device *pdev) 51 + { 52 + struct max77686_dev *iodev = dev_get_drvdata(pdev->dev.parent); 53 + int ret; 54 + 55 + ret = max_gen_clk_probe(pdev, iodev->regmap, MAX77802_REG_32KHZ, 56 + max77802_clks_init, MAX77802_CLKS_NUM); 57 + 58 + if (ret) { 59 + dev_err(&pdev->dev, "generic probe failed %d\n", ret); 60 + return ret; 61 + } 62 + 63 + /* Enable low-jitter mode on the 32khz clocks. */ 64 + ret = regmap_update_bits(iodev->regmap, MAX77802_REG_32KHZ, 65 + 1 << MAX77802_CLOCK_LOW_JITTER_SHIFT, 66 + 1 << MAX77802_CLOCK_LOW_JITTER_SHIFT); 67 + if (ret < 0) 68 + dev_err(&pdev->dev, "failed to enable low-jitter mode\n"); 69 + 70 + return ret; 71 + } 72 + 73 + static int max77802_clk_remove(struct platform_device *pdev) 74 + { 75 + return max_gen_clk_remove(pdev, MAX77802_CLKS_NUM); 76 + } 77 + 78 + static const struct platform_device_id max77802_clk_id[] = { 79 + { "max77802-clk", 0}, 80 + { }, 81 + }; 82 + MODULE_DEVICE_TABLE(platform, max77802_clk_id); 83 + 84 + static struct platform_driver max77802_clk_driver = { 85 + .driver = { 86 + .name = "max77802-clk", 87 + .owner = THIS_MODULE, 88 + }, 89 + .probe = max77802_clk_probe, 90 + .remove = max77802_clk_remove, 91 + .id_table = max77802_clk_id, 92 + }; 93 + 94 + module_platform_driver(max77802_clk_driver); 95 + 96 + MODULE_DESCRIPTION("MAXIM 77802 Clock Driver"); 97 + MODULE_AUTHOR("Javier Martinez Canillas <javier.martinez@collabora.co.uk>"); 98 + MODULE_LICENSE("GPL");
+22
include/dt-bindings/clock/maxim,max77802.h
··· 1 + /* 2 + * Copyright (C) 2014 Google, Inc 3 + * 4 + * This program is free software; you can redistribute it and/or modify 5 + * it under the terms of the GNU General Public License version 2 as 6 + * published by the Free Software Foundation. 7 + * 8 + * Device Tree binding constants clocks for the Maxim 77802 PMIC. 9 + */ 10 + 11 + #ifndef _DT_BINDINGS_CLOCK_MAXIM_MAX77802_CLOCK_H 12 + #define _DT_BINDINGS_CLOCK_MAXIM_MAX77802_CLOCK_H 13 + 14 + /* Fixed rate clocks. */ 15 + 16 + #define MAX77802_CLK_32K_AP 0 17 + #define MAX77802_CLK_32K_CP 1 18 + 19 + /* Total number of clocks. */ 20 + #define MAX77802_CLKS_NUM (MAX77802_CLK_32K_CP + 1) 21 + 22 + #endif /* _DT_BINDINGS_CLOCK_MAXIM_MAX77802_CLOCK_H */