22 #include <linux/module.h>
23 #include <linux/input.h>
27 #include <linux/slab.h>
29 #include <linux/i2c.h>
52 {
"picodlp_i2c_driver", 0 },
97 msg[0].buf = read_cmd;
109 static int picodlp_i2c_write_block(
struct i2c_client *client,
113 int i,
r, msg_count = 1;
115 struct picodlp_i2c_data *picodlp_i2c_data = i2c_get_clientdata(client);
117 if (len < 1 || len > 32) {
119 "too long syn_write_block len %d\n", len);
140 for (i = 0; i < len; i++)
142 "addr %x bw 0x%02x[%d]: 0x%02x\n",
143 client->
addr, data[0] + i, i, data[i]);
147 dev_err(&client->
dev,
"picodlp_i2c_write error\n");
157 for (i = 1; i < 5; i++)
158 data[i] = (value >> (32 - (i) * 8)) & 0xFF;
160 return picodlp_i2c_write_block(client, data, 5);
163 static int picodlp_i2c_write_array(
struct i2c_client *client,
168 for (i = 0; i <
count; i++) {
169 r = picodlp_i2c_write(client, commands[i].reg,
177 static int picodlp_wait_for_dma_done(
struct i2c_client *client)
198 static int picodlp_i2c_init(
struct i2c_client *client)
282 r = picodlp_i2c_write_array(client, init_cmd_set1,
287 r = picodlp_wait_for_dma_done(client);
291 r = picodlp_i2c_write_array(client, init_cmd_set2,
296 r = picodlp_wait_for_dma_done(client);
300 r = picodlp_i2c_write_array(client, init_cmd_set3,
305 r = picodlp_wait_for_dma_done(client);
309 r = picodlp_i2c_write_array(client, init_cmd_set4,
317 static int picodlp_i2c_probe(
struct i2c_client *client,
320 struct picodlp_i2c_data *picodlp_i2c_data;
322 picodlp_i2c_data = kzalloc(
sizeof(
struct picodlp_i2c_data),
GFP_KERNEL);
324 if (!picodlp_i2c_data)
328 i2c_set_clientdata(client, picodlp_i2c_data);
333 static int picodlp_i2c_remove(
struct i2c_client *client)
335 struct picodlp_i2c_data *picodlp_i2c_data =
336 i2c_get_clientdata(client);
337 kfree(picodlp_i2c_data);
341 static struct i2c_driver picodlp_i2c_driver = {
343 .name =
"picodlp_i2c_driver",
345 .probe = picodlp_i2c_probe,
346 .remove = picodlp_i2c_remove,
347 .id_table = picodlp_i2c_id,
386 dev_err(&dssdev->
dev,
"failed to enable DPI\n");
425 int r = 0, picodlp_adapter_id;
427 dssdev->
panel.timings = pico_ls_timings;
439 dev_err(&dssdev->
dev,
"can't get i2c adapter\n");
444 picodlp_i2c_client =
i2c_new_device(adapter, &picodlp_i2c_board_info);
445 if (!picodlp_i2c_client) {
446 dev_err(&dssdev->
dev,
"can't add i2c device::"
447 " picodlp_i2c_client is NULL\n");
467 dev_dbg(&dssdev->
dev,
"removing picodlp panel\n");
477 dev_dbg(&dssdev->
dev,
"enabling picodlp panel\n");
485 r = picodlp_panel_power_on(dssdev);
498 picodlp_panel_power_off(dssdev);
503 dev_dbg(&dssdev->
dev,
"disabling picodlp panel\n");
514 dev_err(&dssdev->
dev,
"unable to suspend picodlp panel,"
515 " panel is not ACTIVE\n");
519 picodlp_panel_power_off(dssdev);
524 dev_dbg(&dssdev->
dev,
"suspending picodlp panel\n");
536 dev_err(&dssdev->
dev,
"unable to resume picodlp panel,"
537 " panel is not ACTIVE\n");
541 r = picodlp_panel_power_on(dssdev);
543 dev_dbg(&dssdev->
dev,
"resuming picodlp panel\n");
550 *xres = dssdev->
panel.timings.x_res;
551 *yres = dssdev->
panel.timings.y_res;
555 .probe = picodlp_panel_probe,
556 .remove = picodlp_panel_remove,
558 .enable = picodlp_panel_enable,
559 .disable = picodlp_panel_disable,
561 .get_resolution = picodlp_get_resolution,
563 .suspend = picodlp_panel_suspend,
564 .resume = picodlp_panel_resume,
567 .name =
"picodlp_panel",
572 static int __init picodlp_init(
void)
576 r = i2c_add_driver(&picodlp_i2c_driver);
579 " registration failed\n");
590 static void __exit picodlp_exit(
void)