Commit 68bab866 authored by Peter Ujfalusi's avatar Peter Ujfalusi Committed by Lee Jones

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: default avatarPeter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: default avatarLee Jones <lee.jones@linaro.org>
parent 11e38e11
...@@ -19,6 +19,8 @@ Required properties: ...@@ -19,6 +19,8 @@ Required properties:
Optional properties, nodes: Optional properties, nodes:
- enable-active-high: To power on the twl6040 during boot. - enable-active-high: To power on the twl6040 during boot.
- clocks: phandle to the clk32k clock provider
- clock-names: Must be "clk32k"
Vibra functionality Vibra functionality
Required properties: Required properties:
......
...@@ -291,6 +291,8 @@ int twl6040_power(struct twl6040 *twl6040, int on) ...@@ -291,6 +291,8 @@ int twl6040_power(struct twl6040 *twl6040, int on)
if (twl6040->power_count++) if (twl6040->power_count++)
goto out; goto out;
clk_prepare_enable(twl6040->clk32k);
/* Allow writes to the chip */ /* Allow writes to the chip */
regcache_cache_only(twl6040->regmap, false); regcache_cache_only(twl6040->regmap, false);
...@@ -346,6 +348,8 @@ int twl6040_power(struct twl6040 *twl6040, int on) ...@@ -346,6 +348,8 @@ int twl6040_power(struct twl6040 *twl6040, int on)
twl6040->sysclk = 0; twl6040->sysclk = 0;
twl6040->mclk = 0; twl6040->mclk = 0;
clk_disable_unprepare(twl6040->clk32k);
} }
out: out:
...@@ -644,6 +648,12 @@ static int twl6040_probe(struct i2c_client *client, ...@@ -644,6 +648,12 @@ static int twl6040_probe(struct i2c_client *client,
i2c_set_clientdata(client, twl6040); i2c_set_clientdata(client, twl6040);
twl6040->clk32k = devm_clk_get(&client->dev, "clk32k");
if (IS_ERR(twl6040->clk32k)) {
dev_info(&client->dev, "clk32k is not handled\n");
twl6040->clk32k = NULL;
}
twl6040->supplies[0].supply = "vio"; twl6040->supplies[0].supply = "vio";
twl6040->supplies[1].supply = "v2v1"; twl6040->supplies[1].supply = "v2v1";
ret = devm_regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES, ret = devm_regulator_bulk_get(&client->dev, TWL6040_NUM_SUPPLIES,
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/mfd/core.h> #include <linux/mfd/core.h>
#include <linux/regulator/consumer.h> #include <linux/regulator/consumer.h>
#include <linux/clk.h>
#define TWL6040_REG_ASICID 0x01 #define TWL6040_REG_ASICID 0x01
#define TWL6040_REG_ASICREV 0x02 #define TWL6040_REG_ASICREV 0x02
...@@ -223,6 +224,7 @@ struct twl6040 { ...@@ -223,6 +224,7 @@ struct twl6040 {
struct regmap *regmap; struct regmap *regmap;
struct regmap_irq_chip_data *irq_data; struct regmap_irq_chip_data *irq_data;
struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */ struct regulator_bulk_data supplies[2]; /* supplies for vio, v2v1 */
struct clk *clk32k;
struct mutex mutex; struct mutex mutex;
struct mutex irq_mutex; struct mutex irq_mutex;
struct mfd_cell cells[TWL6040_CELLS]; struct mfd_cell cells[TWL6040_CELLS];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment