diff options
author | Haojian Zhuang <haojian.zhuang@gmail.com> | 2012-09-21 06:06:52 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-10-02 05:43:13 -0400 |
commit | 2e57d56747e601b3e0ff6697e524025d0504d161 (patch) | |
tree | 29a7c677878d39f64e90dfbdf7063a11c08d4c15 /drivers/input/touchscreen | |
parent | 837c8293ba24d08cd7438d82ad9bb8d2fb0f8a5b (diff) |
mfd: 88pm860x: Device tree support
Signed-off-by: Haojian Zhuang <haojian.zhuang@gmail.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/88pm860x-ts.c | 46 |
1 files changed, 31 insertions, 15 deletions
diff --git a/drivers/input/touchscreen/88pm860x-ts.c b/drivers/input/touchscreen/88pm860x-ts.c index 05f30b73c3c3..4f81e6eb74b6 100644 --- a/drivers/input/touchscreen/88pm860x-ts.c +++ b/drivers/input/touchscreen/88pm860x-ts.c | |||
@@ -10,6 +10,7 @@ | |||
10 | */ | 10 | */ |
11 | #include <linux/kernel.h> | 11 | #include <linux/kernel.h> |
12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
13 | #include <linux/of.h> | ||
13 | #include <linux/platform_device.h> | 14 | #include <linux/platform_device.h> |
14 | #include <linux/i2c.h> | 15 | #include <linux/i2c.h> |
15 | #include <linux/input.h> | 16 | #include <linux/input.h> |
@@ -113,14 +114,31 @@ static void pm860x_touch_close(struct input_dev *dev) | |||
113 | pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0); | 114 | pm860x_set_bits(touch->i2c, MEAS_EN3, data, 0); |
114 | } | 115 | } |
115 | 116 | ||
117 | #ifdef CONFIG_OF | ||
118 | static int __devinit pm860x_touch_dt_init(struct platform_device *pdev, | ||
119 | int *res_x) | ||
120 | { | ||
121 | struct device_node *np = pdev->dev.parent->of_node; | ||
122 | if (!np) | ||
123 | return -ENODEV; | ||
124 | np = of_find_node_by_name(np, "touch"); | ||
125 | if (!np) { | ||
126 | dev_err(&pdev->dev, "Can't find touch node\n"); | ||
127 | return -EINVAL; | ||
128 | } | ||
129 | of_property_read_u32(np, "marvell,88pm860x-resistor-X", res_x); | ||
130 | return 0; | ||
131 | } | ||
132 | #else | ||
133 | #define pm860x_touch_dt_init(x, y) (-1) | ||
134 | #endif | ||
135 | |||
116 | static int __devinit pm860x_touch_probe(struct platform_device *pdev) | 136 | static int __devinit pm860x_touch_probe(struct platform_device *pdev) |
117 | { | 137 | { |
118 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); | 138 | struct pm860x_chip *chip = dev_get_drvdata(pdev->dev.parent); |
119 | struct pm860x_platform_data *pm860x_pdata = \ | 139 | struct pm860x_touch_pdata *pdata = pdev->dev.platform_data; |
120 | pdev->dev.parent->platform_data; | ||
121 | struct pm860x_touch_pdata *pdata = NULL; | ||
122 | struct pm860x_touch *touch; | 140 | struct pm860x_touch *touch; |
123 | int irq, ret; | 141 | int irq, ret, res_x = 0; |
124 | 142 | ||
125 | irq = platform_get_irq(pdev, 0); | 143 | irq = platform_get_irq(pdev, 0); |
126 | if (irq < 0) { | 144 | if (irq < 0) { |
@@ -128,15 +146,13 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev) | |||
128 | return -EINVAL; | 146 | return -EINVAL; |
129 | } | 147 | } |
130 | 148 | ||
131 | if (!pm860x_pdata) { | 149 | if (pm860x_touch_dt_init(pdev, &res_x)) { |
132 | dev_err(&pdev->dev, "platform data is missing\n"); | 150 | if (pdata) |
133 | return -EINVAL; | 151 | res_x = pdata->res_x; |
134 | } | 152 | else { |
135 | 153 | dev_err(&pdev->dev, "failed to get platform data\n"); | |
136 | pdata = pm860x_pdata->touch; | 154 | return -EINVAL; |
137 | if (!pdata) { | 155 | } |
138 | dev_err(&pdev->dev, "touchscreen data is missing\n"); | ||
139 | return -EINVAL; | ||
140 | } | 156 | } |
141 | 157 | ||
142 | touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL); | 158 | touch = kzalloc(sizeof(struct pm860x_touch), GFP_KERNEL); |
@@ -159,8 +175,8 @@ static int __devinit pm860x_touch_probe(struct platform_device *pdev) | |||
159 | touch->idev->close = pm860x_touch_close; | 175 | touch->idev->close = pm860x_touch_close; |
160 | touch->chip = chip; | 176 | touch->chip = chip; |
161 | touch->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; | 177 | touch->i2c = (chip->id == CHIP_PM8607) ? chip->client : chip->companion; |
162 | touch->irq = irq + chip->irq_base; | 178 | touch->irq = irq; |
163 | touch->res_x = pdata->res_x; | 179 | touch->res_x = res_x; |
164 | input_set_drvdata(touch->idev, touch); | 180 | input_set_drvdata(touch->idev, touch); |
165 | 181 | ||
166 | ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler, | 182 | ret = request_threaded_irq(touch->irq, NULL, pm860x_touch_handler, |