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

mfd: twl6040: Optional clk32k clock handling

In certain boards the source for the clk32k clock can be gated. In these
boards the clk32k clock can be provided to the driver and it is going to be
enabled/disabled when it is needed.
If the clk32k clock is not provided the driver will assume that it is always
running.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>

authored by

Peter Ujfalusi and committed by
Lee Jones
68bab866 11e38e11

+14
+2
Documentation/devicetree/bindings/mfd/twl6040.txt
··· 19 19 20 20 Optional properties, nodes: 21 21 - enable-active-high: To power on the twl6040 during boot. 22 + - clocks: phandle to the clk32k clock provider 23 + - clock-names: Must be "clk32k" 22 24 23 25 Vibra functionality 24 26 Required properties:
+10
drivers/mfd/twl6040.c
··· 291 291 if (twl6040->power_count++) 292 292 goto out; 293 293 294 + clk_prepare_enable(twl6040->clk32k); 295 + 294 296 /* Allow writes to the chip */ 295 297 regcache_cache_only(twl6040->regmap, false); 296 298 ··· 348 346 349 347 twl6040->sysclk = 0; 350 348 twl6040->mclk = 0; 349 + 350 + clk_disable_unprepare(twl6040->clk32k); 351 351 } 352 352 353 353 out: ··· 647 643 return PTR_ERR(twl6040->regmap); 648 644 649 645 i2c_set_clientdata(client, twl6040); 646 + 647 + twl6040->clk32k = devm_clk_get(&client->dev, "clk32k"); 648 + if (IS_ERR(twl6040->clk32k)) { 649 + dev_info(&client->dev, "clk32k is not handled\n"); 650 + twl6040->clk32k = NULL; 651 + } 650 652 651 653 twl6040->supplies[0].supply = "vio"; 652 654 twl6040->supplies[1].supply = "v2v1";
+2
include/linux/mfd/twl6040.h
··· 28 28 #include <linux/interrupt.h> 29 29 #include <linux/mfd/core.h> 30 30 #include <linux/regulator/consumer.h> 31 + #include <linux/clk.h> 31 32 32 33 #define TWL6040_REG_ASICID 0x01 33 34 #define TWL6040_REG_ASICREV 0x02 ··· 224 223 struct regmap *regmap; 225 224 struct regmap_irq_chip_data *irq_data; 226 225 struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */ 226 + struct clk *clk32k; 227 227 struct mutex mutex; 228 228 struct mutex irq_mutex; 229 229 struct mfd_cell cells[TWL6040_CELLS];