44 * Author: Naveen Kumar G <naveen.gaddipati@stericsson.com> for ST-Ericsson
55 */
66
7- #include <linux/kernel .h>
7+ #include <linux/bitops .h>
88#include <linux/delay.h>
9- #include <linux/interrupt .h>
9+ #include <linux/gpio/consumer .h>
1010#include <linux/i2c.h>
11- #include <linux/workqueue.h>
1211#include <linux/input.h>
13- #include <linux/input/bu21013.h>
14- #include <linux/slab.h>
15- #include <linux/regulator/consumer.h>
12+ #include <linux/interrupt.h>
13+ #include <linux/kernel.h>
1614#include <linux/module.h>
17- #include <linux/gpio/consumer.h>
18- #include <linux/of.h>
15+ #include <linux/property.h>
16+ #include <linux/regulator/consumer.h>
17+ #include <linux/slab.h>
18+ #include <linux/types.h>
1919
2020#define MAX_FINGERS 2
2121#define RESET_DELAY 30
137137/**
138138 * struct bu21013_ts - touch panel data structure
139139 * @client: pointer to the i2c client
140- * @touch_stopped: touch stop flag
141- * @chip: pointer to the touch panel controller
142140 * @in_dev: pointer to the input device structure
143141 * @regulator: pointer to the Regulator used for touch screen
144142 * @cs_gpiod: chip select GPIO line
145143 * @int_gpiod: touch interrupt GPIO line
144+ * @irq: interrupt number the device is using
145+ * @touch_x_max: maximum X coordinate reported by the device
146+ * @touch_y_max: maximum Y coordinate reported by the device
147+ * @x_flip: indicates that the driver should invert X coordinate before
148+ * reporting
149+ * @y_flip: indicates that the driver should invert Y coordinate before
150+ * reporting
151+ * @touch_stopped: touch stop flag
146152 *
147153 * Touch panel device data structure
148154 */
149155struct bu21013_ts {
150156 struct i2c_client * client ;
151- const struct bu21013_platform_device * chip ;
152157 struct input_dev * in_dev ;
153158 struct regulator * regulator ;
154159 struct gpio_desc * cs_gpiod ;
155160 struct gpio_desc * int_gpiod ;
156161 unsigned int irq ;
162+ u32 touch_x_max ;
163+ u32 touch_y_max ;
164+ bool x_flip ;
165+ bool y_flip ;
157166 bool touch_stopped ;
158167};
159168
@@ -208,10 +217,10 @@ static int bu21013_do_touch_report(struct bu21013_ts *ts)
208217 }
209218
210219 for (i = 0 ; i < finger_down_count ; i ++ ) {
211- if (ts -> chip -> x_flip )
212- pos_x [i ] = ts -> chip -> touch_x_max - pos_x [i ];
213- if (ts -> chip -> y_flip )
214- pos_y [i ] = ts -> chip -> touch_y_max - pos_y [i ];
220+ if (ts -> x_flip )
221+ pos_x [i ] = ts -> touch_x_max - pos_x [i ];
222+ if (ts -> y_flip )
223+ pos_y [i ] = ts -> touch_y_max - pos_y [i ];
215224
216225 input_report_abs (ts -> in_dev ,
217226 ABS_MT_POSITION_X , pos_x [i ]);
@@ -304,14 +313,9 @@ static int bu21013_init_chip(struct bu21013_ts *ts)
304313 return error ;
305314 }
306315
307- if (ts -> chip -> ext_clk )
308- error = i2c_smbus_write_byte_data (client , BU21013_CLK_MODE_REG ,
309- BU21013_CLK_MODE_EXT |
310- BU21013_CLK_MODE_CALIB );
311- else
312- error = i2c_smbus_write_byte_data (client , BU21013_CLK_MODE_REG ,
313- BU21013_CLK_MODE_DIV |
314- BU21013_CLK_MODE_CALIB );
316+ error = i2c_smbus_write_byte_data (client , BU21013_CLK_MODE_REG ,
317+ BU21013_CLK_MODE_DIV |
318+ BU21013_CLK_MODE_CALIB );
315319 if (error ) {
316320 dev_err (& client -> dev , "BU21013_CLK_MODE reg write failed\n" );
317321 return error ;
@@ -388,43 +392,6 @@ static int bu21013_init_chip(struct bu21013_ts *ts)
388392 return 0 ;
389393}
390394
391- #ifdef CONFIG_OF
392- static const struct bu21013_platform_device *
393- bu21013_parse_dt (struct device * dev )
394- {
395- struct device_node * np = dev -> of_node ;
396- struct bu21013_platform_device * pdata ;
397-
398- if (!np ) {
399- dev_err (dev , "no device tree or platform data\n" );
400- return ERR_PTR (- EINVAL );
401- }
402-
403- pdata = devm_kzalloc (dev , sizeof (* pdata ), GFP_KERNEL );
404- if (!pdata )
405- return ERR_PTR (- ENOMEM );
406-
407- pdata -> y_flip = pdata -> x_flip = false;
408-
409- pdata -> x_flip = of_property_read_bool (np , "rohm,flip-x" );
410- pdata -> y_flip = of_property_read_bool (np , "rohm,flip-y" );
411-
412- of_property_read_u32 (np , "rohm,touch-max-x" , & pdata -> touch_x_max );
413- of_property_read_u32 (np , "rohm,touch-max-y" , & pdata -> touch_y_max );
414-
415- pdata -> ext_clk = false;
416-
417- return pdata ;
418- }
419- #else
420- static inline const struct bu21013_platform_device *
421- bu21013_parse_dt (struct device * dev )
422- {
423- dev_err (dev , "no platform data available\n" );
424- return ERR_PTR (- EINVAL );
425- }
426- #endif
427-
428395static void bu21013_power_off (void * _ts )
429396{
430397 struct bu21013_ts * ts = _ts ;
@@ -442,8 +409,6 @@ static void bu21013_disable_chip(void *_ts)
442409static int bu21013_probe (struct i2c_client * client ,
443410 const struct i2c_device_id * id )
444411{
445- const struct bu21013_platform_device * pdata =
446- dev_get_platdata (& client -> dev );
447412 struct bu21013_ts * ts ;
448413 struct input_dev * in_dev ;
449414 int error ;
@@ -454,19 +419,20 @@ static int bu21013_probe(struct i2c_client *client,
454419 return - EIO ;
455420 }
456421
457- if (!pdata ) {
458- pdata = bu21013_parse_dt (& client -> dev );
459- if (IS_ERR (pdata ))
460- return PTR_ERR (pdata );
461- }
462-
463422 ts = devm_kzalloc (& client -> dev , sizeof (* ts ), GFP_KERNEL );
464423 if (!ts )
465424 return - ENOMEM ;
466425
467- ts -> chip = pdata ;
468426 ts -> client = client ;
469427
428+ ts -> x_flip = device_property_read_bool (& client -> dev , "rohm,flip-x" );
429+ ts -> y_flip = device_property_read_bool (& client -> dev , "rohm,flip-y" );
430+
431+ device_property_read_u32 (& client -> dev , "rohm,touch-max-x" ,
432+ & ts -> touch_x_max );
433+ device_property_read_u32 (& client -> dev , "rohm,touch-max-y" ,
434+ & ts -> touch_y_max );
435+
470436 in_dev = devm_input_allocate_device (& client -> dev );
471437 if (!in_dev ) {
472438 dev_err (& client -> dev , "device memory alloc failed\n" );
@@ -483,9 +449,9 @@ static int bu21013_probe(struct i2c_client *client,
483449 __set_bit (EV_ABS , in_dev -> evbit );
484450
485451 input_set_abs_params (in_dev , ABS_MT_POSITION_X ,
486- 0 , pdata -> touch_x_max , 0 , 0 );
452+ 0 , ts -> touch_x_max , 0 , 0 );
487453 input_set_abs_params (in_dev , ABS_MT_POSITION_Y ,
488- 0 , pdata -> touch_y_max , 0 , 0 );
454+ 0 , ts -> touch_y_max , 0 , 0 );
489455 input_set_drvdata (in_dev , ts );
490456
491457 ts -> regulator = devm_regulator_get (& client -> dev , "avdd" );
@@ -560,7 +526,6 @@ static int bu21013_probe(struct i2c_client *client,
560526 return error ;
561527 }
562528
563- device_init_wakeup (& client -> dev , pdata -> wakeup );
564529 i2c_set_clientdata (client , ts );
565530
566531 return 0 ;
0 commit comments