blob: 21d54b4550508102f9e8e69a9dac8647fb51d241 [file] [log] [blame]
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -08001/*
2 * Copyright (c) 2020, The Linux Foundation. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 and
6 * only version 2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 */
14
15#include <linux/device.h>
16#include <linux/i2c.h>
17#include <linux/slab.h>
18#include <linux/platform_device.h>
19#include <linux/input.h>
20#include <linux/types.h>
21#include <linux/module.h>
22#include <linux/fs.h>
23#include <linux/of.h>
24#include <linux/of_graph.h>
25#include <linux/kernel.h>
26#include <linux/of_gpio.h>
27#include <linux/gpio.h>
28#include <linux/delay.h>
29#include <linux/regulator/consumer.h>
30#include <linux/rwlock.h>
31#include <linux/leds.h>
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -070032#include "vxr7200.h"
33
34enum power_state {
35 POWER_STATE_POWERKEY = 0,
36 POWER_STATE_ENABLE = 1,
37};
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080038
39struct vxr7200 {
40 struct device *dev;
41 struct device_node *host_node;
42
43 u8 i2c_addr;
44 int irq;
45 u32 vxr_3v3_en;
46 u32 led_5v_en;
47 u32 led_drive_en1;
48 u32 led_drive_en2;
49 u32 display_1v8_en;
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -070050 u32 mipi_switch_1v8_en;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080051 u32 display_res1;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080052
53 struct i2c_client *i2c_client;
54
55 struct regulator *vddio;
56 struct regulator *lab;
57 struct regulator *ibb;
58
59 bool power_on;
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -070060 bool enable;
61 bool usb_plugged;
62 enum power_state state;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080063};
64
Rajesh Bharathwaj9cd60e02020-03-24 18:04:14 -070065static bool dsi_way;
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -070066static struct vxr7200 *pdata;
Rajesh Bharathwaj9cd60e02020-03-24 18:04:14 -070067
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080068static int vxr7200_read(struct vxr7200 *pdata, u8 *reg, u8 *buf, u32 size)
69{
70 struct i2c_client *client = pdata->i2c_client;
71 struct i2c_msg msg[2] = {
72 {
73 .addr = client->addr,
74 .flags = 0,
75 .len = 4,
76 .buf = reg,
77 },
78 {
79 .addr = client->addr,
80 .flags = I2C_M_RD,
81 .len = size,
82 .buf = buf,
83 }
84 };
85
86 if (i2c_transfer(client->adapter, msg, 2) != 2) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -070087 pr_err("%s i2c read failed\n", __func__);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080088 return -EIO;
89 }
90
91 return 0;
92}
93
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -070094static void turn_gpio(struct vxr7200 *pdata, int gpio, bool on)
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080095{
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080096
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -070097 pr_debug("%s vxr7200_turn_gpio gpio:%d, on:%d\n", __func__, gpio, on);
98
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -080099 if (on) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700100 gpio_direction_output(gpio, 0);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800101 gpio_set_value(gpio, 1);
102 pr_debug("%s vxr7200 gpio:%d set to high\n", __func__, gpio);
103 } else {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700104 gpio_direction_output(gpio, 1);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800105 gpio_set_value(gpio, 0);
106 pr_debug("%s vxr7200 gpio:%d set to low\n", __func__, gpio);
107 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800108}
109
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700110static void vxr7200_set_gpios(struct vxr7200 *pdata, bool turn_on)
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800111{
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700112 pr_debug("%s, turn_on:%d\n", __func__, turn_on);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800113 if (pdata) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700114 if (pdata->state == POWER_STATE_POWERKEY) {
115 turn_gpio(pdata, pdata->vxr_3v3_en, turn_on);
116 turn_gpio(pdata, pdata->display_res1, turn_on);
117 turn_gpio(pdata, pdata->display_1v8_en, turn_on);
118 turn_gpio(pdata, pdata->mipi_switch_1v8_en, turn_on);
119 if (!pdata->enable && turn_on)
120 return;
121 }
122 turn_gpio(pdata, pdata->led_5v_en, turn_on);
123 turn_gpio(pdata, pdata->led_drive_en1, turn_on);
124 turn_gpio(pdata, pdata->led_drive_en2, turn_on);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800125 }
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -0700126 return;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800127}
128
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700129static ssize_t vxr7200_enable_show(struct device *dev,
130 struct device_attribute *attr,
131 char *buf)
132{
133 int ret;
134 struct i2c_client *client = to_i2c_client(dev);
135 struct vxr7200 *pdata = i2c_get_clientdata(client);
136
137
138 if (pdata->enable)
139 ret = scnprintf(buf, PAGE_SIZE, "display on\n");
140 else
141 ret = scnprintf(buf, PAGE_SIZE, "display off\n");
142
143 return ret;
144}
145
146static ssize_t vxr7200_enable_store(struct device *dev,
147 struct device_attribute *attr,
148 const char *buf, size_t count)
149{
150 struct i2c_client *client = to_i2c_client(dev);
151 struct vxr7200 *pdata = i2c_get_clientdata(client);
152 long val;
153 int ret;
154
155 ret = kstrtol(buf, 0, &val);
156 pr_debug("%s, count:%d val:%lx, buf:%s\n",
157 __func__, (int)count, val, buf);
158
159 if (val == 0x1) {
160 pr_debug("%s Turning on Display\n", __func__);
161 pdata->enable = true;
162 pdata->state = POWER_STATE_ENABLE;
163 vxr7200_set_gpios(pdata, true);
164 } else if (val == 0x0) {
165 pr_debug("%s Turning off Display\n",
166 __func__);
167 pdata->state = POWER_STATE_ENABLE;
168 pdata->enable = false;
169 vxr7200_set_gpios(pdata, false);
170 } else
171 pr_err("%s Invalid value. Valid vals(1-on,0-off)\n",
172 __func__);
173
174 return count;
175}
176
177static DEVICE_ATTR_RW(vxr7200_enable);
178
179static struct attribute *vxr7200_fs_attrs[] = {
180 &dev_attr_vxr7200_enable.attr,
181 NULL
182};
183
184static struct attribute_group vxr7200_fs_attr_group = {
185 .attrs = vxr7200_fs_attrs,
186};
187
188void vxr7200_usb_event(bool cable_plug)
189{
190 pr_debug("%s, cable_plug:%d\n", __func__, cable_plug);
191 if (pdata) {
192 pdata->state = POWER_STATE_POWERKEY;
193 if (cable_plug) {
194 pdata->usb_plugged = true;
195 vxr7200_set_gpios(pdata, true);
196 } else {
197 pdata->usb_plugged = false;
198 vxr7200_set_gpios(pdata, false);
199 }
200 }
201}
202EXPORT_SYMBOL(vxr7200_usb_event);
203
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800204static int vxr7200_parse_dt(struct device *dev,
205 struct vxr7200 *pdata)
206{
207 struct device_node *np = dev->of_node;
208 int rc = 0;
209
210 pdata->vxr_3v3_en =
211 of_get_named_gpio(np, "qcom,vxr_3v3_en", 0);
212 if (!gpio_is_valid(pdata->vxr_3v3_en)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700213 pr_err("vxr7200_3v3_en gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800214 rc = -EINVAL;
215 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700216 if (gpio_request(pdata->vxr_3v3_en, "vxr_3v3_en")) {
217 pr_err("vxr7200_3v3_en request gpio failed\n");
218 rc = -EINVAL;
219 goto gpio1Fail;
220 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800221
222 pdata->led_5v_en =
223 of_get_named_gpio(np, "qcom,led-5v-en-gpio", 0);
224 if (!gpio_is_valid(pdata->led_5v_en)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700225 pr_err("vxr7200_led_5v_en gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800226 rc = -EINVAL;
227 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700228 if (gpio_request(pdata->led_5v_en, "led_5v_en")) {
229 pr_err("vxr7200_led_5v_en request gpio failed\n");
230 rc = -EINVAL;
231 goto gpio2Fail;
232 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800233
234 pdata->led_drive_en1 =
235 of_get_named_gpio(np, "qcom,led-driver-en1-gpio", 0);
236 if (!gpio_is_valid(pdata->led_drive_en1)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700237 pr_err("vxr7200_led_drive_en1 gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800238 rc = -EINVAL;
239 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700240 if (gpio_request(pdata->led_drive_en1, "led_drive_en1")) {
241 pr_err("vxr7200_led_drive_en1 request gpio failed\n");
242 rc = -EINVAL;
243 goto gpio3Fail;
244 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800245
246 pdata->led_drive_en2 =
247 of_get_named_gpio(np, "qcom,led-driver-en2-gpio", 0);
248 if (!gpio_is_valid(pdata->led_drive_en2)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700249 pr_err("vxr7200_led_drive_en2 gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800250 rc = -EINVAL;
251 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700252 if (gpio_request(pdata->led_drive_en2, "led_drive_en2")) {
253 pr_err("vxr7200_led_drive_en2 request gpio failed\n");
254 rc = -EINVAL;
255 goto gpio4Fail;
256 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800257
258 pdata->display_1v8_en =
259 of_get_named_gpio(np, "qcom,1p8-en-gpio", 0);
260 if (!gpio_is_valid(pdata->display_1v8_en)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700261 pr_err("vxr7200_display_1v8_en gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800262 rc = -EINVAL;
263 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700264 if (gpio_request(pdata->display_1v8_en, "display_1v8_en")) {
265 pr_err("vxr7200_display_1v8_en request gpio failed\n");
266 rc = -EINVAL;
267 goto gpio5Fail;
268 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800269
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -0700270 pdata->mipi_switch_1v8_en =
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800271 of_get_named_gpio(np, "qcom,switch-power-gpio", 0);
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -0700272 if (!gpio_is_valid(pdata->mipi_switch_1v8_en)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700273 pr_err("vxr7200_mipi_switch_1v8_en gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800274 rc = -EINVAL;
275 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700276 if (gpio_request(pdata->mipi_switch_1v8_en, "mipi_switch_1v8_en")) {
277 pr_err("vxr7200_mipi_switch_1v8_en request gpio failed\n");
278 rc = -EINVAL;
279 goto gpio6Fail;
280 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800281
282 pdata->display_res1 =
283 of_get_named_gpio(np, "qcom,platform-reset-gpio", 0);
284 if (!gpio_is_valid(pdata->display_res1)) {
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700285 pr_err("vxr7200_display_res1 gpio not specified\n");
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800286 rc = -EINVAL;
287 }
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700288 if (gpio_request(pdata->display_res1, "display_res1")) {
289 pr_err("vxr7200_display_res1 request gpio failed\n");
290 rc = -EINVAL;
291 goto gpio7Fail;
292 }
293 return rc;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800294
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700295gpio7Fail:
296 gpio_free(pdata->display_res1);
297gpio6Fail:
298 gpio_free(pdata->mipi_switch_1v8_en);
299gpio5Fail:
300 gpio_free(pdata->display_1v8_en);
301gpio4Fail:
302 gpio_free(pdata->led_drive_en2);
303gpio3Fail:
304 gpio_free(pdata->led_drive_en1);
305gpio2Fail:
306 gpio_free(pdata->led_5v_en);
307gpio1Fail:
308 gpio_free(pdata->vxr_3v3_en);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800309
310 return rc;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800311}
312
313static void vxr7200_display_pwr_enable_vregs(struct vxr7200 *pdata)
314{
315 int rc = 0;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800316 pdata->vddio = devm_regulator_get(pdata->dev, "pm660_l11");
317 rc = PTR_RET(pdata->vddio);
318 if (rc) {
319 pr_err("Failed to get pm660_l11 regulator %s\n", __func__);
320 goto vddio_fail;
321 }
322 rc = regulator_set_load(pdata->vddio, 62000);
323 if (rc < 0) {
324 pr_err("Load setting failed for vddio %s\n", __func__);
325 goto vddio_fail;
326 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800327 rc = regulator_enable(pdata->vddio);
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -0700328 msleep(20);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800329 if (rc) {
330 pr_err("enable failed for vddio, rc=%d %s\n", rc, __func__);
331 goto vddio_fail;
332 }
333
334 pdata->lab = devm_regulator_get(pdata->dev, "lcdb_ldo");
335 rc = PTR_RET(pdata->lab);
336 if (rc) {
337 pr_err("Failed to get lcdb_ldo_vreg regulator %s\n", __func__);
338 goto lab_fail;
339 }
340 rc = regulator_set_load(pdata->lab, 100000);
341 if (rc < 0) {
342 pr_err("Load Setting failed for lab %s\n", __func__);
343 goto lab_fail;
344 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800345 rc = regulator_enable(pdata->lab);
346 if (rc) {
347 pr_err("enable failed for lab, rc=%d %s\n", rc, __func__);
348 goto lab_fail;
349 }
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -0700350 msleep(20);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800351
352 pdata->ibb = devm_regulator_get(pdata->dev, "lcdb_ncp");
353 rc = PTR_RET(pdata->ibb);
354 if (rc) {
355 pr_err("Failed to get lcdb_ncp_vreg regulator %s\n", __func__);
356 goto ibb_fail;
357 }
358 rc = regulator_set_load(pdata->ibb, 100000);
359 if (rc < 0) {
360 pr_err("Load Setting failed for ibb %s\n", __func__);
361 goto ibb_fail;
362 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800363 rc = regulator_enable(pdata->ibb);
364 if (rc) {
365 pr_err("enable failed for ibb, rc=%d %s\n", rc, __func__);
366 goto ibb_fail;
367 }
Rajesh Bharathwaj60ae8e42020-04-14 15:26:03 -0700368 msleep(20);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800369
370 return;
371
372ibb_fail:
373 devm_regulator_put(pdata->ibb);
374 (void)regulator_set_load(pdata->ibb, 100);
375 (void)regulator_set_voltage(pdata->ibb, 0, 6000000);
376
377lab_fail:
378 (void)regulator_set_voltage(pdata->lab, 0, 6000000);
379 (void)regulator_set_load(pdata->lab, 100);
380 devm_regulator_put(pdata->lab);
381
382vddio_fail:
383 (void)regulator_set_load(pdata->vddio, 100);
384 (void)regulator_set_voltage(pdata->vddio, 0, 1800000);
385 devm_regulator_put(pdata->vddio);
386}
387
Rajesh Bharathwaj9cd60e02020-03-24 18:04:14 -0700388static int vxr7200_probe(struct i2c_client *client,
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800389 const struct i2c_device_id *id)
390{
391 int rc;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800392 u8 reg[4] = {0x00, 0x20, 0x01, 0x60};
393 u8 buf[4] = {0x00, 0x0, 0x0, 0x0};
394
395 if (!client || !client->dev.of_node) {
396 pr_err("%s invalid input\n", __func__);
397 return -EINVAL;
398 }
399
400 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
401 pr_err("%s device doesn't support I2C\n", __func__);
402 return -ENODEV;
403 }
404
Rajesh Bharathwaj9cd60e02020-03-24 18:04:14 -0700405 if (dsi_way)
406 return -EINVAL;
407
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800408 pdata = devm_kzalloc(&client->dev,
409 sizeof(struct vxr7200), GFP_KERNEL);
410 if (!pdata)
411 return -ENOMEM;
412
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700413 pdata->state = POWER_STATE_POWERKEY;
414 pdata->enable = true;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800415
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800416 rc = vxr7200_parse_dt(&client->dev, pdata);
417 if (rc) {
418 pr_err("%s failed to parse device tree\n", __func__);
419 goto err_dt_parse;
420 }
421 pdata->dev = &client->dev;
422 pdata->i2c_client = client;
423
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700424 rc = sysfs_create_group(&pdata->dev->kobj, &vxr7200_fs_attr_group);
425 if (rc) {
426 pr_err("%s unable to register vxr7200 sysfs nodes\n",
427 __func__);
428 goto err_dt_parse;
429 }
430
431
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800432 vxr7200_display_pwr_enable_vregs(pdata);
433
434 i2c_set_clientdata(client, pdata);
435 dev_set_drvdata(&client->dev, pdata);
436
437 //vxr7200_write(pdata, 0x0A, 0x02);//Enable 4-lane DP
438 vxr7200_read(pdata, reg, buf, 4);//Enable 4-lane DP
439
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700440 return rc;
441
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800442err_dt_parse:
443 devm_kfree(&client->dev, pdata);
444
445 return rc;
446}
447
448static int vxr7200_remove(struct i2c_client *client)
449{
450 struct vxr7200 *pdata = i2c_get_clientdata(client);
451
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700452 if (pdata) {
453 sysfs_remove_group(&pdata->dev->kobj, &vxr7200_fs_attr_group);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800454 devm_kfree(&client->dev, pdata);
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700455 }
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800456 return 0;
457}
458
459
460static void vxr7200_shutdown(struct i2c_client *client)
461{
462 dev_info(&(client->dev), "shutdown");
463}
464
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800465static int vxr7200_pm_suspend(struct device *dev)
466{
467 struct i2c_client *client = to_i2c_client(dev);
468 struct vxr7200 *pdata = i2c_get_clientdata(client);
469
470 dev_info(dev, "suspend");
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700471 pdata->state = POWER_STATE_POWERKEY;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800472 vxr7200_set_gpios(pdata, false);
473 return 0;
474}
475
476static int vxr7200_pm_resume(struct device *dev)
477{
478 struct i2c_client *client = to_i2c_client(dev);
479 struct vxr7200 *pdata = i2c_get_clientdata(client);
480
481 dev_info(dev, "resume");
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700482 pdata->state = POWER_STATE_POWERKEY;
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800483 vxr7200_set_gpios(pdata, true);
484 return 0;
485}
486
487static const struct dev_pm_ops vxr7200_dev_pm_ops = {
488 .suspend = vxr7200_pm_suspend,
489 .resume = vxr7200_pm_resume,
Rajesh Bharathwaj244c9ad2020-06-15 13:11:22 -0700490 .poweroff = vxr7200_pm_suspend,
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800491};
492
493static const struct i2c_device_id vxr7200_id_table[] = {
494 {"vxr7200", 0},
495 {}
496};
497
498static struct i2c_driver vxr7200_i2c_driver = {
499 .probe = vxr7200_probe,
500 .remove = vxr7200_remove,
501 .shutdown = vxr7200_shutdown,
502 .driver = {
503 .name = "vxr7200",
504 .owner = THIS_MODULE,
505 .pm = &vxr7200_dev_pm_ops,
506 },
507 .id_table = vxr7200_id_table,
508};
Rajesh Bharathwaj9cd60e02020-03-24 18:04:14 -0700509
510static int __init vxr7200_init(void)
511{
512 char *cmdline;
513
514 cmdline = strnstr(boot_command_line,
515 "msm_drm.dsi_display0=dsi_sim_vid_display",
516 strlen(boot_command_line));
517 if (cmdline) {
518 pr_debug("%s DSI SIM mode, going to dp init cmdline:%s\n",
519 __func__, cmdline);
520 dsi_way = false;
521 } else {
522 pr_debug("%s DSI WAY, going to dsi init cmdline:%s\n",
523 __func__, cmdline);
524 dsi_way = true;
525 }
526
527 return 0;
528
529}
530
531device_initcall(vxr7200_init);
Rajesh Bharathwajdcc7af82019-12-15 22:42:55 -0800532module_i2c_driver(vxr7200_i2c_driver);
533MODULE_DEVICE_TABLE(i2c, vxr7200_id_table);
534MODULE_DESCRIPTION("VXR7200 DP2DSI Bridge");