Skip to content

Commit 64b9e4d

Browse files
Peter UjfalusiSamuel Ortiz
authored andcommitted
input: twl4030-vibra: Support for DT booted kernel
Add support when the kernel has been booted with DT blob. In this case the pdata is NULL, we need to reach up to the core node and check if the codec part has been enabled to determine if we need to coexist with the codec or not. Signed-off-by: Peter Ujfalusi <[email protected]> Acked-by: Dmitry Torokhov <[email protected]> Signed-off-by: Samuel Ortiz <[email protected]>
1 parent 019a7e6 commit 64b9e4d

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

drivers/input/misc/twl4030-vibra.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <linux/module.h>
2727
#include <linux/jiffies.h>
2828
#include <linux/platform_device.h>
29+
#include <linux/of.h>
2930
#include <linux/workqueue.h>
3031
#include <linux/i2c/twl.h>
3132
#include <linux/mfd/twl4030-audio.h>
@@ -194,13 +195,26 @@ static int twl4030_vibra_resume(struct device *dev)
194195
static SIMPLE_DEV_PM_OPS(twl4030_vibra_pm_ops,
195196
twl4030_vibra_suspend, twl4030_vibra_resume);
196197

198+
static bool twl4030_vibra_check_coexist(struct twl4030_vibra_data *pdata,
199+
struct device_node *node)
200+
{
201+
if (pdata && pdata->coexist)
202+
return true;
203+
204+
if (of_find_node_by_name(node, "codec"))
205+
return true;
206+
207+
return false;
208+
}
209+
197210
static int __devinit twl4030_vibra_probe(struct platform_device *pdev)
198211
{
199212
struct twl4030_vibra_data *pdata = pdev->dev.platform_data;
213+
struct device_node *twl4030_core_node = pdev->dev.parent->of_node;
200214
struct vibra_info *info;
201215
int ret;
202216

203-
if (!pdata) {
217+
if (!pdata && !twl4030_core_node) {
204218
dev_dbg(&pdev->dev, "platform_data not available\n");
205219
return -EINVAL;
206220
}
@@ -210,7 +224,7 @@ static int __devinit twl4030_vibra_probe(struct platform_device *pdev)
210224
return -ENOMEM;
211225

212226
info->dev = &pdev->dev;
213-
info->coexist = pdata->coexist;
227+
info->coexist = twl4030_vibra_check_coexist(pdata, twl4030_core_node);
214228
INIT_WORK(&info->play_work, vibra_play_work);
215229

216230
info->input_dev = input_allocate_device();

0 commit comments

Comments
 (0)