2 * TWL6040 clock module driver for OMAP4 McPDM functional clock
4 * Copyright (C) 2012 Texas Instruments Inc.
5 * Peter Ujfalusi <peter.ujfalusi@ti.com>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
23 #include <linux/module.h>
24 #include <linux/slab.h>
25 #include <linux/platform_device.h>
26 #include <linux/mfd/twl6040.h>
27 #include <linux/clk-provider.h>
30 struct twl6040
*twl6040
;
32 struct clk_hw mcpdm_fclk
;
37 static int twl6040_bitclk_is_enabled(struct clk_hw
*hw
)
39 struct twl6040_clk
*twl6040_clk
= container_of(hw
, struct twl6040_clk
,
41 return twl6040_clk
->enabled
;
44 static int twl6040_bitclk_prepare(struct clk_hw
*hw
)
46 struct twl6040_clk
*twl6040_clk
= container_of(hw
, struct twl6040_clk
,
50 ret
= twl6040_power(twl6040_clk
->twl6040
, 1);
52 twl6040_clk
->enabled
= 1;
57 static void twl6040_bitclk_unprepare(struct clk_hw
*hw
)
59 struct twl6040_clk
*twl6040_clk
= container_of(hw
, struct twl6040_clk
,
63 ret
= twl6040_power(twl6040_clk
->twl6040
, 0);
65 twl6040_clk
->enabled
= 0;
68 static const struct clk_ops twl6040_mcpdm_ops
= {
69 .is_enabled
= twl6040_bitclk_is_enabled
,
70 .prepare
= twl6040_bitclk_prepare
,
71 .unprepare
= twl6040_bitclk_unprepare
,
74 static struct clk_init_data wm831x_clkout_init
= {
76 .ops
= &twl6040_mcpdm_ops
,
80 static int twl6040_clk_probe(struct platform_device
*pdev
)
82 struct twl6040
*twl6040
= dev_get_drvdata(pdev
->dev
.parent
);
83 struct twl6040_clk
*clkdata
;
85 clkdata
= devm_kzalloc(&pdev
->dev
, sizeof(*clkdata
), GFP_KERNEL
);
89 clkdata
->dev
= &pdev
->dev
;
90 clkdata
->twl6040
= twl6040
;
92 clkdata
->mcpdm_fclk
.init
= &wm831x_clkout_init
;
93 clkdata
->clk
= devm_clk_register(&pdev
->dev
, &clkdata
->mcpdm_fclk
);
94 if (IS_ERR(clkdata
->clk
))
95 return PTR_ERR(clkdata
->clk
);
97 platform_set_drvdata(pdev
, clkdata
);
102 static struct platform_driver twl6040_clk_driver
= {
104 .name
= "twl6040-clk",
106 .probe
= twl6040_clk_probe
,
109 module_platform_driver(twl6040_clk_driver
);
111 MODULE_DESCRIPTION("TWL6040 clock driver for McPDM functional clock");
112 MODULE_AUTHOR("Peter Ujfalusi <peter.ujfalusi@ti.com>");
113 MODULE_ALIAS("platform:twl6040-clk");
114 MODULE_LICENSE("GPL");