Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 1 | /* |
| 2 | * picodlp panel driver |
| 3 | * picodlp_i2c_driver: i2c_client driver |
| 4 | * |
| 5 | * Copyright (C) 2009-2011 Texas Instruments |
| 6 | * Author: Mythri P K <mythripk@ti.com> |
| 7 | * Mayuresh Janorkar <mayur@ti.com> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify it |
| 10 | * under the terms of the GNU General Public License version 2 as published by |
| 11 | * the Free Software Foundation. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 14 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 16 | * more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License along with |
| 19 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 20 | */ |
| 21 | |
Tomi Valkeinen | 3e28189 | 2011-10-04 11:39:38 +0300 | [diff] [blame] | 22 | #include <linux/module.h> |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 23 | #include <linux/input.h> |
| 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/interrupt.h> |
| 26 | #include <linux/firmware.h> |
| 27 | #include <linux/slab.h> |
| 28 | #include <linux/mutex.h> |
| 29 | #include <linux/i2c.h> |
| 30 | #include <linux/delay.h> |
| 31 | #include <linux/gpio.h> |
| 32 | |
| 33 | #include <video/omapdss.h> |
Archit Taneja | a0d8dde | 2013-02-12 16:46:46 +0530 | [diff] [blame] | 34 | #include <video/omap-panel-data.h> |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 35 | |
| 36 | #include "panel-picodlp.h" |
| 37 | |
| 38 | struct picodlp_data { |
| 39 | struct mutex lock; |
| 40 | struct i2c_client *picodlp_i2c_client; |
| 41 | }; |
| 42 | |
| 43 | static struct i2c_board_info picodlp_i2c_board_info = { |
| 44 | I2C_BOARD_INFO("picodlp_i2c_driver", 0x1b), |
| 45 | }; |
| 46 | |
| 47 | struct picodlp_i2c_data { |
| 48 | struct mutex xfer_lock; |
| 49 | }; |
| 50 | |
| 51 | static struct i2c_device_id picodlp_i2c_id[] = { |
| 52 | { "picodlp_i2c_driver", 0 }, |
Axel Lin | c252ea0 | 2012-11-30 12:30:45 +0800 | [diff] [blame] | 53 | { } |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | struct picodlp_i2c_command { |
| 57 | u8 reg; |
| 58 | u32 value; |
| 59 | }; |
| 60 | |
| 61 | static struct omap_video_timings pico_ls_timings = { |
| 62 | .x_res = 864, |
| 63 | .y_res = 480, |
| 64 | .hsw = 7, |
| 65 | .hfp = 11, |
| 66 | .hbp = 7, |
| 67 | |
| 68 | .pixel_clock = 19200, |
| 69 | |
| 70 | .vsw = 2, |
| 71 | .vfp = 3, |
| 72 | .vbp = 14, |
Archit Taneja | a8d5e41 | 2012-06-25 12:26:38 +0530 | [diff] [blame] | 73 | |
| 74 | .vsync_level = OMAPDSS_SIG_ACTIVE_LOW, |
| 75 | .hsync_level = OMAPDSS_SIG_ACTIVE_LOW, |
| 76 | .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE, |
| 77 | .de_level = OMAPDSS_SIG_ACTIVE_HIGH, |
| 78 | .sync_pclk_edge = OMAPDSS_DRIVE_SIG_FALLING_EDGE, |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 79 | }; |
| 80 | |
| 81 | static inline struct picodlp_panel_data |
| 82 | *get_panel_data(const struct omap_dss_device *dssdev) |
| 83 | { |
| 84 | return (struct picodlp_panel_data *) dssdev->data; |
| 85 | } |
| 86 | |
| 87 | static u32 picodlp_i2c_read(struct i2c_client *client, u8 reg) |
| 88 | { |
| 89 | u8 read_cmd[] = {READ_REG_SELECT, reg}, data[4]; |
| 90 | struct picodlp_i2c_data *picodlp_i2c_data = i2c_get_clientdata(client); |
| 91 | struct i2c_msg msg[2]; |
| 92 | |
| 93 | mutex_lock(&picodlp_i2c_data->xfer_lock); |
| 94 | |
| 95 | msg[0].addr = client->addr; |
| 96 | msg[0].flags = 0; |
| 97 | msg[0].len = 2; |
| 98 | msg[0].buf = read_cmd; |
| 99 | |
| 100 | msg[1].addr = client->addr; |
| 101 | msg[1].flags = I2C_M_RD; |
| 102 | msg[1].len = 4; |
| 103 | msg[1].buf = data; |
| 104 | |
| 105 | i2c_transfer(client->adapter, msg, 2); |
| 106 | mutex_unlock(&picodlp_i2c_data->xfer_lock); |
| 107 | return (data[3] | (data[2] << 8) | (data[1] << 16) | (data[0] << 24)); |
| 108 | } |
| 109 | |
| 110 | static int picodlp_i2c_write_block(struct i2c_client *client, |
| 111 | u8 *data, int len) |
| 112 | { |
| 113 | struct i2c_msg msg; |
| 114 | int i, r, msg_count = 1; |
| 115 | |
| 116 | struct picodlp_i2c_data *picodlp_i2c_data = i2c_get_clientdata(client); |
| 117 | |
| 118 | if (len < 1 || len > 32) { |
| 119 | dev_err(&client->dev, |
| 120 | "too long syn_write_block len %d\n", len); |
| 121 | return -EIO; |
| 122 | } |
| 123 | mutex_lock(&picodlp_i2c_data->xfer_lock); |
| 124 | |
| 125 | msg.addr = client->addr; |
| 126 | msg.flags = 0; |
| 127 | msg.len = len; |
| 128 | msg.buf = data; |
| 129 | r = i2c_transfer(client->adapter, &msg, msg_count); |
| 130 | mutex_unlock(&picodlp_i2c_data->xfer_lock); |
| 131 | |
| 132 | /* |
| 133 | * i2c_transfer returns: |
| 134 | * number of messages sent in case of success |
| 135 | * a negative error number in case of failure |
| 136 | */ |
| 137 | if (r != msg_count) |
| 138 | goto err; |
| 139 | |
| 140 | /* In case of success */ |
| 141 | for (i = 0; i < len; i++) |
| 142 | dev_dbg(&client->dev, |
| 143 | "addr %x bw 0x%02x[%d]: 0x%02x\n", |
| 144 | client->addr, data[0] + i, i, data[i]); |
| 145 | |
| 146 | return 0; |
| 147 | err: |
| 148 | dev_err(&client->dev, "picodlp_i2c_write error\n"); |
| 149 | return r; |
| 150 | } |
| 151 | |
| 152 | static int picodlp_i2c_write(struct i2c_client *client, u8 reg, u32 value) |
| 153 | { |
| 154 | u8 data[5]; |
| 155 | int i; |
| 156 | |
| 157 | data[0] = reg; |
| 158 | for (i = 1; i < 5; i++) |
| 159 | data[i] = (value >> (32 - (i) * 8)) & 0xFF; |
| 160 | |
| 161 | return picodlp_i2c_write_block(client, data, 5); |
| 162 | } |
| 163 | |
| 164 | static int picodlp_i2c_write_array(struct i2c_client *client, |
| 165 | const struct picodlp_i2c_command commands[], |
| 166 | int count) |
| 167 | { |
| 168 | int i, r = 0; |
| 169 | for (i = 0; i < count; i++) { |
| 170 | r = picodlp_i2c_write(client, commands[i].reg, |
| 171 | commands[i].value); |
| 172 | if (r) |
| 173 | return r; |
| 174 | } |
| 175 | return r; |
| 176 | } |
| 177 | |
| 178 | static int picodlp_wait_for_dma_done(struct i2c_client *client) |
| 179 | { |
| 180 | u8 trial = 100; |
| 181 | |
| 182 | do { |
| 183 | msleep(1); |
| 184 | if (!trial--) |
| 185 | return -ETIMEDOUT; |
| 186 | } while (picodlp_i2c_read(client, MAIN_STATUS) & DMA_STATUS); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * picodlp_i2c_init: i2c_initialization routine |
| 193 | * client: i2c_client for communication |
| 194 | * |
| 195 | * return |
| 196 | * 0 : Success, no error |
| 197 | * error code : Failure |
| 198 | */ |
| 199 | static int picodlp_i2c_init(struct i2c_client *client) |
| 200 | { |
| 201 | int r; |
| 202 | static const struct picodlp_i2c_command init_cmd_set1[] = { |
| 203 | {SOFT_RESET, 1}, |
| 204 | {DMD_PARK_TRIGGER, 1}, |
| 205 | {MISC_REG, 5}, |
| 206 | {SEQ_CONTROL, 0}, |
| 207 | {SEQ_VECTOR, 0x100}, |
| 208 | {DMD_BLOCK_COUNT, 7}, |
| 209 | {DMD_VCC_CONTROL, 0x109}, |
| 210 | {DMD_PARK_PULSE_COUNT, 0xA}, |
| 211 | {DMD_PARK_PULSE_WIDTH, 0xB}, |
| 212 | {DMD_PARK_DELAY, 0x2ED}, |
| 213 | {DMD_SHADOW_ENABLE, 0}, |
| 214 | {FLASH_OPCODE, 0xB}, |
| 215 | {FLASH_DUMMY_BYTES, 1}, |
| 216 | {FLASH_ADDR_BYTES, 3}, |
| 217 | {PBC_CONTROL, 0}, |
| 218 | {FLASH_START_ADDR, CMT_LUT_0_START_ADDR}, |
| 219 | {FLASH_READ_BYTES, CMT_LUT_0_SIZE}, |
| 220 | {CMT_SPLASH_LUT_START_ADDR, 0}, |
| 221 | {CMT_SPLASH_LUT_DEST_SELECT, CMT_LUT_ALL}, |
| 222 | {PBC_CONTROL, 1}, |
| 223 | }; |
| 224 | |
| 225 | static const struct picodlp_i2c_command init_cmd_set2[] = { |
| 226 | {PBC_CONTROL, 0}, |
| 227 | {CMT_SPLASH_LUT_DEST_SELECT, 0}, |
| 228 | {PBC_CONTROL, 0}, |
| 229 | {FLASH_START_ADDR, SEQUENCE_0_START_ADDR}, |
| 230 | {FLASH_READ_BYTES, SEQUENCE_0_SIZE}, |
| 231 | {SEQ_RESET_LUT_START_ADDR, 0}, |
| 232 | {SEQ_RESET_LUT_DEST_SELECT, SEQ_SEQ_LUT}, |
| 233 | {PBC_CONTROL, 1}, |
| 234 | }; |
| 235 | |
| 236 | static const struct picodlp_i2c_command init_cmd_set3[] = { |
| 237 | {PBC_CONTROL, 0}, |
| 238 | {SEQ_RESET_LUT_DEST_SELECT, 0}, |
| 239 | {PBC_CONTROL, 0}, |
| 240 | {FLASH_START_ADDR, DRC_TABLE_0_START_ADDR}, |
| 241 | {FLASH_READ_BYTES, DRC_TABLE_0_SIZE}, |
| 242 | {SEQ_RESET_LUT_START_ADDR, 0}, |
| 243 | {SEQ_RESET_LUT_DEST_SELECT, SEQ_DRC_LUT_ALL}, |
| 244 | {PBC_CONTROL, 1}, |
| 245 | }; |
| 246 | |
| 247 | static const struct picodlp_i2c_command init_cmd_set4[] = { |
| 248 | {PBC_CONTROL, 0}, |
| 249 | {SEQ_RESET_LUT_DEST_SELECT, 0}, |
| 250 | {SDC_ENABLE, 1}, |
| 251 | {AGC_CTRL, 7}, |
| 252 | {CCA_C1A, 0x100}, |
| 253 | {CCA_C1B, 0x0}, |
| 254 | {CCA_C1C, 0x0}, |
| 255 | {CCA_C2A, 0x0}, |
| 256 | {CCA_C2B, 0x100}, |
| 257 | {CCA_C2C, 0x0}, |
| 258 | {CCA_C3A, 0x0}, |
| 259 | {CCA_C3B, 0x0}, |
| 260 | {CCA_C3C, 0x100}, |
| 261 | {CCA_C7A, 0x100}, |
| 262 | {CCA_C7B, 0x100}, |
| 263 | {CCA_C7C, 0x100}, |
| 264 | {CCA_ENABLE, 1}, |
| 265 | {CPU_IF_MODE, 1}, |
| 266 | {SHORT_FLIP, 1}, |
| 267 | {CURTAIN_CONTROL, 0}, |
| 268 | {DMD_PARK_TRIGGER, 0}, |
| 269 | {R_DRIVE_CURRENT, 0x298}, |
| 270 | {G_DRIVE_CURRENT, 0x298}, |
| 271 | {B_DRIVE_CURRENT, 0x298}, |
| 272 | {RGB_DRIVER_ENABLE, 7}, |
| 273 | {SEQ_CONTROL, 0}, |
| 274 | {ACTGEN_CONTROL, 0x10}, |
| 275 | {SEQUENCE_MODE, SEQ_LOCK}, |
| 276 | {DATA_FORMAT, RGB888}, |
| 277 | {INPUT_RESOLUTION, WVGA_864_LANDSCAPE}, |
| 278 | {INPUT_SOURCE, PARALLEL_RGB}, |
| 279 | {CPU_IF_SYNC_METHOD, 1}, |
| 280 | {SEQ_CONTROL, 1} |
| 281 | }; |
| 282 | |
| 283 | r = picodlp_i2c_write_array(client, init_cmd_set1, |
| 284 | ARRAY_SIZE(init_cmd_set1)); |
| 285 | if (r) |
| 286 | return r; |
| 287 | |
| 288 | r = picodlp_wait_for_dma_done(client); |
| 289 | if (r) |
| 290 | return r; |
| 291 | |
| 292 | r = picodlp_i2c_write_array(client, init_cmd_set2, |
| 293 | ARRAY_SIZE(init_cmd_set2)); |
| 294 | if (r) |
| 295 | return r; |
| 296 | |
| 297 | r = picodlp_wait_for_dma_done(client); |
| 298 | if (r) |
| 299 | return r; |
| 300 | |
| 301 | r = picodlp_i2c_write_array(client, init_cmd_set3, |
| 302 | ARRAY_SIZE(init_cmd_set3)); |
| 303 | if (r) |
| 304 | return r; |
| 305 | |
| 306 | r = picodlp_wait_for_dma_done(client); |
| 307 | if (r) |
| 308 | return r; |
| 309 | |
| 310 | r = picodlp_i2c_write_array(client, init_cmd_set4, |
| 311 | ARRAY_SIZE(init_cmd_set4)); |
| 312 | if (r) |
| 313 | return r; |
| 314 | |
| 315 | return 0; |
| 316 | } |
| 317 | |
| 318 | static int picodlp_i2c_probe(struct i2c_client *client, |
| 319 | const struct i2c_device_id *id) |
| 320 | { |
| 321 | struct picodlp_i2c_data *picodlp_i2c_data; |
| 322 | |
| 323 | picodlp_i2c_data = kzalloc(sizeof(struct picodlp_i2c_data), GFP_KERNEL); |
| 324 | |
| 325 | if (!picodlp_i2c_data) |
| 326 | return -ENOMEM; |
| 327 | |
| 328 | mutex_init(&picodlp_i2c_data->xfer_lock); |
| 329 | i2c_set_clientdata(client, picodlp_i2c_data); |
| 330 | |
| 331 | return 0; |
| 332 | } |
| 333 | |
| 334 | static int picodlp_i2c_remove(struct i2c_client *client) |
| 335 | { |
| 336 | struct picodlp_i2c_data *picodlp_i2c_data = |
| 337 | i2c_get_clientdata(client); |
| 338 | kfree(picodlp_i2c_data); |
| 339 | return 0; |
| 340 | } |
| 341 | |
| 342 | static struct i2c_driver picodlp_i2c_driver = { |
| 343 | .driver = { |
| 344 | .name = "picodlp_i2c_driver", |
| 345 | }, |
| 346 | .probe = picodlp_i2c_probe, |
| 347 | .remove = picodlp_i2c_remove, |
| 348 | .id_table = picodlp_i2c_id, |
| 349 | }; |
| 350 | |
| 351 | static int picodlp_panel_power_on(struct omap_dss_device *dssdev) |
| 352 | { |
| 353 | int r, trial = 100; |
| 354 | struct picodlp_data *picod = dev_get_drvdata(&dssdev->dev); |
| 355 | struct picodlp_panel_data *picodlp_pdata = get_panel_data(dssdev); |
| 356 | |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 357 | gpio_set_value(picodlp_pdata->pwrgood_gpio, 0); |
| 358 | msleep(1); |
| 359 | gpio_set_value(picodlp_pdata->pwrgood_gpio, 1); |
| 360 | |
| 361 | while (!gpio_get_value(picodlp_pdata->emu_done_gpio)) { |
| 362 | if (!trial--) { |
| 363 | dev_err(&dssdev->dev, "emu_done signal not" |
| 364 | " going high\n"); |
| 365 | return -ETIMEDOUT; |
| 366 | } |
| 367 | msleep(5); |
| 368 | } |
| 369 | /* |
| 370 | * As per dpp2600 programming guide, |
| 371 | * it is required to sleep for 1000ms after emu_done signal goes high |
| 372 | * then only i2c commands can be successfully sent to dpp2600 |
| 373 | */ |
| 374 | msleep(1000); |
Archit Taneja | c499144 | 2012-08-08 14:28:54 +0530 | [diff] [blame] | 375 | |
| 376 | omapdss_dpi_set_timings(dssdev, &dssdev->panel.timings); |
Archit Taneja | c6b393d | 2012-07-06 15:30:52 +0530 | [diff] [blame] | 377 | omapdss_dpi_set_data_lines(dssdev, dssdev->phy.dpi.data_lines); |
Archit Taneja | c499144 | 2012-08-08 14:28:54 +0530 | [diff] [blame] | 378 | |
Tomi Valkeinen | 79e4424 | 2011-06-23 16:36:36 +0300 | [diff] [blame] | 379 | r = omapdss_dpi_display_enable(dssdev); |
| 380 | if (r) { |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 381 | dev_err(&dssdev->dev, "failed to enable DPI\n"); |
| 382 | goto err1; |
| 383 | } |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 384 | |
| 385 | r = picodlp_i2c_init(picod->picodlp_i2c_client); |
| 386 | if (r) |
| 387 | goto err; |
| 388 | |
Tomi Valkeinen | 79e4424 | 2011-06-23 16:36:36 +0300 | [diff] [blame] | 389 | dssdev->state = OMAP_DSS_DISPLAY_ACTIVE; |
| 390 | |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 391 | return r; |
| 392 | err: |
| 393 | omapdss_dpi_display_disable(dssdev); |
| 394 | err1: |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 395 | return r; |
| 396 | } |
| 397 | |
| 398 | static void picodlp_panel_power_off(struct omap_dss_device *dssdev) |
| 399 | { |
| 400 | struct picodlp_panel_data *picodlp_pdata = get_panel_data(dssdev); |
| 401 | |
| 402 | omapdss_dpi_display_disable(dssdev); |
| 403 | |
| 404 | gpio_set_value(picodlp_pdata->emu_done_gpio, 0); |
| 405 | gpio_set_value(picodlp_pdata->pwrgood_gpio, 0); |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 406 | } |
| 407 | |
| 408 | static int picodlp_panel_probe(struct omap_dss_device *dssdev) |
| 409 | { |
| 410 | struct picodlp_data *picod; |
| 411 | struct picodlp_panel_data *picodlp_pdata = get_panel_data(dssdev); |
| 412 | struct i2c_adapter *adapter; |
| 413 | struct i2c_client *picodlp_i2c_client; |
Archit Taneja | d52e2e7 | 2012-12-04 15:36:34 +0530 | [diff] [blame] | 414 | int r, picodlp_adapter_id; |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 415 | |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 416 | dssdev->panel.timings = pico_ls_timings; |
| 417 | |
Archit Taneja | d52e2e7 | 2012-12-04 15:36:34 +0530 | [diff] [blame] | 418 | if (!picodlp_pdata) |
| 419 | return -EINVAL; |
| 420 | |
Archit Taneja | e1b94f1 | 2012-11-20 14:23:27 +0530 | [diff] [blame] | 421 | picod = devm_kzalloc(&dssdev->dev, sizeof(*picod), GFP_KERNEL); |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 422 | if (!picod) |
| 423 | return -ENOMEM; |
| 424 | |
| 425 | mutex_init(&picod->lock); |
| 426 | |
| 427 | picodlp_adapter_id = picodlp_pdata->picodlp_adapter_id; |
| 428 | |
| 429 | adapter = i2c_get_adapter(picodlp_adapter_id); |
| 430 | if (!adapter) { |
| 431 | dev_err(&dssdev->dev, "can't get i2c adapter\n"); |
Archit Taneja | e1b94f1 | 2012-11-20 14:23:27 +0530 | [diff] [blame] | 432 | return -ENODEV; |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 433 | } |
| 434 | |
| 435 | picodlp_i2c_client = i2c_new_device(adapter, &picodlp_i2c_board_info); |
| 436 | if (!picodlp_i2c_client) { |
| 437 | dev_err(&dssdev->dev, "can't add i2c device::" |
| 438 | " picodlp_i2c_client is NULL\n"); |
Archit Taneja | e1b94f1 | 2012-11-20 14:23:27 +0530 | [diff] [blame] | 439 | return -ENODEV; |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 440 | } |
| 441 | |
| 442 | picod->picodlp_i2c_client = picodlp_i2c_client; |
| 443 | |
| 444 | dev_set_drvdata(&dssdev->dev, picod); |
Archit Taneja | e1b94f1 | 2012-11-20 14:23:27 +0530 | [diff] [blame] | 445 | |
Archit Taneja | d52e2e7 | 2012-12-04 15:36:34 +0530 | [diff] [blame] | 446 | if (gpio_is_valid(picodlp_pdata->emu_done_gpio)) { |
| 447 | r = devm_gpio_request_one(&dssdev->dev, |
| 448 | picodlp_pdata->emu_done_gpio, |
| 449 | GPIOF_IN, "DLP EMU DONE"); |
| 450 | if (r) |
| 451 | return r; |
| 452 | } |
| 453 | |
| 454 | if (gpio_is_valid(picodlp_pdata->pwrgood_gpio)) { |
| 455 | r = devm_gpio_request_one(&dssdev->dev, |
| 456 | picodlp_pdata->pwrgood_gpio, |
| 457 | GPIOF_OUT_INIT_LOW, "DLP PWRGOOD"); |
| 458 | if (r) |
| 459 | return r; |
| 460 | } |
| 461 | |
Archit Taneja | e1b94f1 | 2012-11-20 14:23:27 +0530 | [diff] [blame] | 462 | return 0; |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | static void picodlp_panel_remove(struct omap_dss_device *dssdev) |
| 466 | { |
| 467 | struct picodlp_data *picod = dev_get_drvdata(&dssdev->dev); |
| 468 | |
| 469 | i2c_unregister_device(picod->picodlp_i2c_client); |
| 470 | dev_set_drvdata(&dssdev->dev, NULL); |
| 471 | dev_dbg(&dssdev->dev, "removing picodlp panel\n"); |
| 472 | |
| 473 | kfree(picod); |
| 474 | } |
| 475 | |
| 476 | static int picodlp_panel_enable(struct omap_dss_device *dssdev) |
| 477 | { |
| 478 | struct picodlp_data *picod = dev_get_drvdata(&dssdev->dev); |
| 479 | int r; |
| 480 | |
| 481 | dev_dbg(&dssdev->dev, "enabling picodlp panel\n"); |
| 482 | |
| 483 | mutex_lock(&picod->lock); |
| 484 | if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED) { |
| 485 | mutex_unlock(&picod->lock); |
| 486 | return -EINVAL; |
| 487 | } |
| 488 | |
| 489 | r = picodlp_panel_power_on(dssdev); |
| 490 | mutex_unlock(&picod->lock); |
| 491 | |
| 492 | return r; |
| 493 | } |
| 494 | |
| 495 | static void picodlp_panel_disable(struct omap_dss_device *dssdev) |
| 496 | { |
| 497 | struct picodlp_data *picod = dev_get_drvdata(&dssdev->dev); |
| 498 | |
| 499 | mutex_lock(&picod->lock); |
| 500 | /* Turn off DLP Power */ |
| 501 | if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) |
| 502 | picodlp_panel_power_off(dssdev); |
| 503 | |
| 504 | dssdev->state = OMAP_DSS_DISPLAY_DISABLED; |
| 505 | mutex_unlock(&picod->lock); |
| 506 | |
| 507 | dev_dbg(&dssdev->dev, "disabling picodlp panel\n"); |
| 508 | } |
| 509 | |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 510 | static void picodlp_get_resolution(struct omap_dss_device *dssdev, |
| 511 | u16 *xres, u16 *yres) |
| 512 | { |
| 513 | *xres = dssdev->panel.timings.x_res; |
| 514 | *yres = dssdev->panel.timings.y_res; |
| 515 | } |
| 516 | |
| 517 | static struct omap_dss_driver picodlp_driver = { |
| 518 | .probe = picodlp_panel_probe, |
| 519 | .remove = picodlp_panel_remove, |
| 520 | |
| 521 | .enable = picodlp_panel_enable, |
| 522 | .disable = picodlp_panel_disable, |
| 523 | |
| 524 | .get_resolution = picodlp_get_resolution, |
| 525 | |
Mayuresh Janorkar | 24305db | 2011-05-17 17:49:40 +0530 | [diff] [blame] | 526 | .driver = { |
| 527 | .name = "picodlp_panel", |
| 528 | .owner = THIS_MODULE, |
| 529 | }, |
| 530 | }; |
| 531 | |
| 532 | static int __init picodlp_init(void) |
| 533 | { |
| 534 | int r = 0; |
| 535 | |
| 536 | r = i2c_add_driver(&picodlp_i2c_driver); |
| 537 | if (r) { |
| 538 | printk(KERN_WARNING "picodlp_i2c_driver" \ |
| 539 | " registration failed\n"); |
| 540 | return r; |
| 541 | } |
| 542 | |
| 543 | r = omap_dss_register_driver(&picodlp_driver); |
| 544 | if (r) |
| 545 | i2c_del_driver(&picodlp_i2c_driver); |
| 546 | |
| 547 | return r; |
| 548 | } |
| 549 | |
| 550 | static void __exit picodlp_exit(void) |
| 551 | { |
| 552 | i2c_del_driver(&picodlp_i2c_driver); |
| 553 | omap_dss_unregister_driver(&picodlp_driver); |
| 554 | } |
| 555 | |
| 556 | module_init(picodlp_init); |
| 557 | module_exit(picodlp_exit); |
| 558 | |
| 559 | MODULE_AUTHOR("Mythri P K <mythripk@ti.com>"); |
| 560 | MODULE_DESCRIPTION("picodlp driver"); |
| 561 | MODULE_LICENSE("GPL"); |