Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

i2c: omap: abolish variable name confusion

struct device pointers are usually called
dev. Calling our struct omap_i2c_dev pointers
also dev has caused enough confusion.

This is the result of a few simple sed rules
to convert all struct omap_i2c_dev pointers
to be called omap instead.

Signed-off-by: Felipe Balbi <balbi@ti.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>

authored by

Felipe Balbi and committed by
Wolfram Sang
63f8f856 c680e329

+299 -299
+299 -299
drivers/i2c/busses/i2c-omap.c
··· 270 270 [OMAP_I2C_IP_V2_IRQENABLE_CLR] = 0x30, 271 271 }; 272 272 273 - static inline void omap_i2c_write_reg(struct omap_i2c_dev *i2c_dev, 273 + static inline void omap_i2c_write_reg(struct omap_i2c_dev *omap, 274 274 int reg, u16 val) 275 275 { 276 - writew_relaxed(val, i2c_dev->base + 277 - (i2c_dev->regs[reg] << i2c_dev->reg_shift)); 276 + writew_relaxed(val, omap->base + 277 + (omap->regs[reg] << omap->reg_shift)); 278 278 } 279 279 280 - static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *i2c_dev, int reg) 280 + static inline u16 omap_i2c_read_reg(struct omap_i2c_dev *omap, int reg) 281 281 { 282 - return readw_relaxed(i2c_dev->base + 283 - (i2c_dev->regs[reg] << i2c_dev->reg_shift)); 282 + return readw_relaxed(omap->base + 283 + (omap->regs[reg] << omap->reg_shift)); 284 284 } 285 285 286 - static void __omap_i2c_init(struct omap_i2c_dev *dev) 286 + static void __omap_i2c_init(struct omap_i2c_dev *omap) 287 287 { 288 288 289 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 289 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); 290 290 291 291 /* Setup clock prescaler to obtain approx 12MHz I2C module clock: */ 292 - omap_i2c_write_reg(dev, OMAP_I2C_PSC_REG, dev->pscstate); 292 + omap_i2c_write_reg(omap, OMAP_I2C_PSC_REG, omap->pscstate); 293 293 294 294 /* SCL low and high time values */ 295 - omap_i2c_write_reg(dev, OMAP_I2C_SCLL_REG, dev->scllstate); 296 - omap_i2c_write_reg(dev, OMAP_I2C_SCLH_REG, dev->sclhstate); 297 - if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) 298 - omap_i2c_write_reg(dev, OMAP_I2C_WE_REG, dev->westate); 295 + omap_i2c_write_reg(omap, OMAP_I2C_SCLL_REG, omap->scllstate); 296 + omap_i2c_write_reg(omap, OMAP_I2C_SCLH_REG, omap->sclhstate); 297 + if (omap->rev >= OMAP_I2C_REV_ON_3430_3530) 298 + omap_i2c_write_reg(omap, OMAP_I2C_WE_REG, omap->westate); 299 299 300 300 /* Take the I2C module out of reset: */ 301 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 301 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 302 302 303 303 /* 304 304 * NOTE: right after setting CON_EN, STAT_BB could be 0 while the ··· 310 310 * Don't write to this register if the IE state is 0 as it can 311 311 * cause deadlock. 312 312 */ 313 - if (dev->iestate) 314 - omap_i2c_write_reg(dev, OMAP_I2C_IE_REG, dev->iestate); 313 + if (omap->iestate) 314 + omap_i2c_write_reg(omap, OMAP_I2C_IE_REG, omap->iestate); 315 315 } 316 316 317 - static int omap_i2c_reset(struct omap_i2c_dev *dev) 317 + static int omap_i2c_reset(struct omap_i2c_dev *omap) 318 318 { 319 319 unsigned long timeout; 320 320 u16 sysc; 321 321 322 - if (dev->rev >= OMAP_I2C_OMAP1_REV_2) { 323 - sysc = omap_i2c_read_reg(dev, OMAP_I2C_SYSC_REG); 322 + if (omap->rev >= OMAP_I2C_OMAP1_REV_2) { 323 + sysc = omap_i2c_read_reg(omap, OMAP_I2C_SYSC_REG); 324 324 325 325 /* Disable I2C controller before soft reset */ 326 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 327 - omap_i2c_read_reg(dev, OMAP_I2C_CON_REG) & 326 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 327 + omap_i2c_read_reg(omap, OMAP_I2C_CON_REG) & 328 328 ~(OMAP_I2C_CON_EN)); 329 329 330 - omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK); 330 + omap_i2c_write_reg(omap, OMAP_I2C_SYSC_REG, SYSC_SOFTRESET_MASK); 331 331 /* For some reason we need to set the EN bit before the 332 332 * reset done bit gets set. */ 333 333 timeout = jiffies + OMAP_I2C_TIMEOUT; 334 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 335 - while (!(omap_i2c_read_reg(dev, OMAP_I2C_SYSS_REG) & 334 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, OMAP_I2C_CON_EN); 335 + while (!(omap_i2c_read_reg(omap, OMAP_I2C_SYSS_REG) & 336 336 SYSS_RESETDONE_MASK)) { 337 337 if (time_after(jiffies, timeout)) { 338 - dev_warn(dev->dev, "timeout waiting " 338 + dev_warn(omap->dev, "timeout waiting " 339 339 "for controller reset\n"); 340 340 return -ETIMEDOUT; 341 341 } ··· 343 343 } 344 344 345 345 /* SYSC register is cleared by the reset; rewrite it */ 346 - omap_i2c_write_reg(dev, OMAP_I2C_SYSC_REG, sysc); 346 + omap_i2c_write_reg(omap, OMAP_I2C_SYSC_REG, sysc); 347 347 348 - if (dev->rev > OMAP_I2C_REV_ON_3430_3530) { 348 + if (omap->rev > OMAP_I2C_REV_ON_3430_3530) { 349 349 /* Schedule I2C-bus monitoring on the next transfer */ 350 - dev->bb_valid = 0; 350 + omap->bb_valid = 0; 351 351 } 352 352 } 353 353 354 354 return 0; 355 355 } 356 356 357 - static int omap_i2c_init(struct omap_i2c_dev *dev) 357 + static int omap_i2c_init(struct omap_i2c_dev *omap) 358 358 { 359 359 u16 psc = 0, scll = 0, sclh = 0; 360 360 u16 fsscll = 0, fssclh = 0, hsscll = 0, hssclh = 0; ··· 362 362 unsigned long internal_clk = 0; 363 363 struct clk *fclk; 364 364 365 - if (dev->rev >= OMAP_I2C_REV_ON_3430_3530) { 365 + if (omap->rev >= OMAP_I2C_REV_ON_3430_3530) { 366 366 /* 367 367 * Enabling all wakup sources to stop I2C freezing on 368 368 * WFI instruction. 369 369 * REVISIT: Some wkup sources might not be needed. 370 370 */ 371 - dev->westate = OMAP_I2C_WE_ALL; 371 + omap->westate = OMAP_I2C_WE_ALL; 372 372 } 373 373 374 - if (dev->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) { 374 + if (omap->flags & OMAP_I2C_FLAG_ALWAYS_ARMXOR_CLK) { 375 375 /* 376 376 * The I2C functional clock is the armxor_ck, so there's 377 377 * no need to get "armxor_ck" separately. Now, if OMAP2420 378 378 * always returns 12MHz for the functional clock, we can 379 379 * do this bit unconditionally. 380 380 */ 381 - fclk = clk_get(dev->dev, "fck"); 381 + fclk = clk_get(omap->dev, "fck"); 382 382 fclk_rate = clk_get_rate(fclk); 383 383 clk_put(fclk); 384 384 ··· 395 395 psc = fclk_rate / 12000000; 396 396 } 397 397 398 - if (!(dev->flags & OMAP_I2C_FLAG_SIMPLE_CLOCK)) { 398 + if (!(omap->flags & OMAP_I2C_FLAG_SIMPLE_CLOCK)) { 399 399 400 400 /* 401 401 * HSI2C controller internal clk rate should be 19.2 Mhz for ··· 403 403 * to get longer filter period for better noise suppression. 404 404 * The filter is iclk (fclk for HS) period. 405 405 */ 406 - if (dev->speed > 400 || 407 - dev->flags & OMAP_I2C_FLAG_FORCE_19200_INT_CLK) 406 + if (omap->speed > 400 || 407 + omap->flags & OMAP_I2C_FLAG_FORCE_19200_INT_CLK) 408 408 internal_clk = 19200; 409 - else if (dev->speed > 100) 409 + else if (omap->speed > 100) 410 410 internal_clk = 9600; 411 411 else 412 412 internal_clk = 4000; 413 - fclk = clk_get(dev->dev, "fck"); 413 + fclk = clk_get(omap->dev, "fck"); 414 414 fclk_rate = clk_get_rate(fclk) / 1000; 415 415 clk_put(fclk); 416 416 ··· 419 419 psc = psc - 1; 420 420 421 421 /* If configured for High Speed */ 422 - if (dev->speed > 400) { 422 + if (omap->speed > 400) { 423 423 unsigned long scl; 424 424 425 425 /* For first phase of HS mode */ ··· 428 428 fssclh = (scl / 3) - 5; 429 429 430 430 /* For second phase of HS mode */ 431 - scl = fclk_rate / dev->speed; 431 + scl = fclk_rate / omap->speed; 432 432 hsscll = scl - (scl / 3) - 7; 433 433 hssclh = (scl / 3) - 5; 434 - } else if (dev->speed > 100) { 434 + } else if (omap->speed > 100) { 435 435 unsigned long scl; 436 436 437 437 /* Fast mode */ 438 - scl = internal_clk / dev->speed; 438 + scl = internal_clk / omap->speed; 439 439 fsscll = scl - (scl / 3) - 7; 440 440 fssclh = (scl / 3) - 5; 441 441 } else { 442 442 /* Standard mode */ 443 - fsscll = internal_clk / (dev->speed * 2) - 7; 444 - fssclh = internal_clk / (dev->speed * 2) - 5; 443 + fsscll = internal_clk / (omap->speed * 2) - 7; 444 + fssclh = internal_clk / (omap->speed * 2) - 5; 445 445 } 446 446 scll = (hsscll << OMAP_I2C_SCLL_HSSCLL) | fsscll; 447 447 sclh = (hssclh << OMAP_I2C_SCLH_HSSCLH) | fssclh; ··· 450 450 fclk_rate /= (psc + 1) * 1000; 451 451 if (psc > 2) 452 452 psc = 2; 453 - scll = fclk_rate / (dev->speed * 2) - 7 + psc; 454 - sclh = fclk_rate / (dev->speed * 2) - 7 + psc; 453 + scll = fclk_rate / (omap->speed * 2) - 7 + psc; 454 + sclh = fclk_rate / (omap->speed * 2) - 7 + psc; 455 455 } 456 456 457 - dev->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | 457 + omap->iestate = (OMAP_I2C_IE_XRDY | OMAP_I2C_IE_RRDY | 458 458 OMAP_I2C_IE_ARDY | OMAP_I2C_IE_NACK | 459 - OMAP_I2C_IE_AL) | ((dev->fifo_size) ? 459 + OMAP_I2C_IE_AL) | ((omap->fifo_size) ? 460 460 (OMAP_I2C_IE_RDR | OMAP_I2C_IE_XDR) : 0); 461 461 462 - dev->pscstate = psc; 463 - dev->scllstate = scll; 464 - dev->sclhstate = sclh; 462 + omap->pscstate = psc; 463 + omap->scllstate = scll; 464 + omap->sclhstate = sclh; 465 465 466 - if (dev->rev <= OMAP_I2C_REV_ON_3430_3530) { 466 + if (omap->rev <= OMAP_I2C_REV_ON_3430_3530) { 467 467 /* Not implemented */ 468 - dev->bb_valid = 1; 468 + omap->bb_valid = 1; 469 469 } 470 470 471 - __omap_i2c_init(dev); 471 + __omap_i2c_init(omap); 472 472 473 473 return 0; 474 474 } ··· 476 476 /* 477 477 * Waiting on Bus Busy 478 478 */ 479 - static int omap_i2c_wait_for_bb(struct omap_i2c_dev *dev) 479 + static int omap_i2c_wait_for_bb(struct omap_i2c_dev *omap) 480 480 { 481 481 unsigned long timeout; 482 482 483 483 timeout = jiffies + OMAP_I2C_TIMEOUT; 484 - while (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) { 484 + while (omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG) & OMAP_I2C_STAT_BB) { 485 485 if (time_after(jiffies, timeout)) 486 - return i2c_recover_bus(&dev->adapter); 486 + return i2c_recover_bus(&omap->adapter); 487 487 msleep(1); 488 488 } 489 489 ··· 518 518 * 3. Any transfer started in the middle of another master's transfer 519 519 * results in unpredictable results and data corruption 520 520 */ 521 - static int omap_i2c_wait_for_bb_valid(struct omap_i2c_dev *dev) 521 + static int omap_i2c_wait_for_bb_valid(struct omap_i2c_dev *omap) 522 522 { 523 523 unsigned long bus_free_timeout = 0; 524 524 unsigned long timeout; 525 525 int bus_free = 0; 526 526 u16 stat, systest; 527 527 528 - if (dev->bb_valid) 528 + if (omap->bb_valid) 529 529 return 0; 530 530 531 531 timeout = jiffies + OMAP_I2C_TIMEOUT; 532 532 while (1) { 533 - stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); 533 + stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); 534 534 /* 535 535 * We will see BB or BF event in a case IP had detected any 536 536 * activity on the I2C bus. Now IP correctly tracks the bus ··· 543 543 * Otherwise, we must look signals on the bus to make 544 544 * the right decision. 545 545 */ 546 - systest = omap_i2c_read_reg(dev, OMAP_I2C_SYSTEST_REG); 546 + systest = omap_i2c_read_reg(omap, OMAP_I2C_SYSTEST_REG); 547 547 if ((systest & OMAP_I2C_SYSTEST_SCL_I_FUNC) && 548 548 (systest & OMAP_I2C_SYSTEST_SDA_I_FUNC)) { 549 549 if (!bus_free) { ··· 564 564 } 565 565 566 566 if (time_after(jiffies, timeout)) { 567 - dev_warn(dev->dev, "timeout waiting for bus ready\n"); 567 + dev_warn(omap->dev, "timeout waiting for bus ready\n"); 568 568 return -ETIMEDOUT; 569 569 } 570 570 571 571 msleep(1); 572 572 } 573 573 574 - dev->bb_valid = 1; 574 + omap->bb_valid = 1; 575 575 return 0; 576 576 } 577 577 578 - static void omap_i2c_resize_fifo(struct omap_i2c_dev *dev, u8 size, bool is_rx) 578 + static void omap_i2c_resize_fifo(struct omap_i2c_dev *omap, u8 size, bool is_rx) 579 579 { 580 580 u16 buf; 581 581 582 - if (dev->flags & OMAP_I2C_FLAG_NO_FIFO) 582 + if (omap->flags & OMAP_I2C_FLAG_NO_FIFO) 583 583 return; 584 584 585 585 /* ··· 589 589 * then we might use draining feature to transfer the remaining bytes. 590 590 */ 591 591 592 - dev->threshold = clamp(size, (u8) 1, dev->fifo_size); 592 + omap->threshold = clamp(size, (u8) 1, omap->fifo_size); 593 593 594 - buf = omap_i2c_read_reg(dev, OMAP_I2C_BUF_REG); 594 + buf = omap_i2c_read_reg(omap, OMAP_I2C_BUF_REG); 595 595 596 596 if (is_rx) { 597 597 /* Clear RX Threshold */ 598 598 buf &= ~(0x3f << 8); 599 - buf |= ((dev->threshold - 1) << 8) | OMAP_I2C_BUF_RXFIF_CLR; 599 + buf |= ((omap->threshold - 1) << 8) | OMAP_I2C_BUF_RXFIF_CLR; 600 600 } else { 601 601 /* Clear TX Threshold */ 602 602 buf &= ~0x3f; 603 - buf |= (dev->threshold - 1) | OMAP_I2C_BUF_TXFIF_CLR; 603 + buf |= (omap->threshold - 1) | OMAP_I2C_BUF_TXFIF_CLR; 604 604 } 605 605 606 - omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, buf); 606 + omap_i2c_write_reg(omap, OMAP_I2C_BUF_REG, buf); 607 607 608 - if (dev->rev < OMAP_I2C_REV_ON_3630) 609 - dev->b_hw = 1; /* Enable hardware fixes */ 608 + if (omap->rev < OMAP_I2C_REV_ON_3630) 609 + omap->b_hw = 1; /* Enable hardware fixes */ 610 610 611 611 /* calculate wakeup latency constraint for MPU */ 612 - if (dev->set_mpu_wkup_lat != NULL) 613 - dev->latency = (1000000 * dev->threshold) / 614 - (1000 * dev->speed / 8); 612 + if (omap->set_mpu_wkup_lat != NULL) 613 + omap->latency = (1000000 * omap->threshold) / 614 + (1000 * omap->speed / 8); 615 615 } 616 616 617 617 /* ··· 620 620 static int omap_i2c_xfer_msg(struct i2c_adapter *adap, 621 621 struct i2c_msg *msg, int stop) 622 622 { 623 - struct omap_i2c_dev *dev = i2c_get_adapdata(adap); 623 + struct omap_i2c_dev *omap = i2c_get_adapdata(adap); 624 624 unsigned long timeout; 625 625 u16 w; 626 626 627 - dev_dbg(dev->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", 627 + dev_dbg(omap->dev, "addr: 0x%04x, len: %d, flags: 0x%x, stop: %d\n", 628 628 msg->addr, msg->len, msg->flags, stop); 629 629 630 630 if (msg->len == 0) 631 631 return -EINVAL; 632 632 633 - dev->receiver = !!(msg->flags & I2C_M_RD); 634 - omap_i2c_resize_fifo(dev, msg->len, dev->receiver); 633 + omap->receiver = !!(msg->flags & I2C_M_RD); 634 + omap_i2c_resize_fifo(omap, msg->len, omap->receiver); 635 635 636 - omap_i2c_write_reg(dev, OMAP_I2C_SA_REG, msg->addr); 636 + omap_i2c_write_reg(omap, OMAP_I2C_SA_REG, msg->addr); 637 637 638 638 /* REVISIT: Could the STB bit of I2C_CON be used with probing? */ 639 - dev->buf = msg->buf; 640 - dev->buf_len = msg->len; 639 + omap->buf = msg->buf; 640 + omap->buf_len = msg->len; 641 641 642 - /* make sure writes to dev->buf_len are ordered */ 642 + /* make sure writes to omap->buf_len are ordered */ 643 643 barrier(); 644 644 645 - omap_i2c_write_reg(dev, OMAP_I2C_CNT_REG, dev->buf_len); 645 + omap_i2c_write_reg(omap, OMAP_I2C_CNT_REG, omap->buf_len); 646 646 647 647 /* Clear the FIFO Buffers */ 648 - w = omap_i2c_read_reg(dev, OMAP_I2C_BUF_REG); 648 + w = omap_i2c_read_reg(omap, OMAP_I2C_BUF_REG); 649 649 w |= OMAP_I2C_BUF_RXFIF_CLR | OMAP_I2C_BUF_TXFIF_CLR; 650 - omap_i2c_write_reg(dev, OMAP_I2C_BUF_REG, w); 650 + omap_i2c_write_reg(omap, OMAP_I2C_BUF_REG, w); 651 651 652 - reinit_completion(&dev->cmd_complete); 653 - dev->cmd_err = 0; 652 + reinit_completion(&omap->cmd_complete); 653 + omap->cmd_err = 0; 654 654 655 655 w = OMAP_I2C_CON_EN | OMAP_I2C_CON_MST | OMAP_I2C_CON_STT; 656 656 657 657 /* High speed configuration */ 658 - if (dev->speed > 400) 658 + if (omap->speed > 400) 659 659 w |= OMAP_I2C_CON_OPMODE_HS; 660 660 661 661 if (msg->flags & I2C_M_STOP) ··· 665 665 if (!(msg->flags & I2C_M_RD)) 666 666 w |= OMAP_I2C_CON_TRX; 667 667 668 - if (!dev->b_hw && stop) 668 + if (!omap->b_hw && stop) 669 669 w |= OMAP_I2C_CON_STP; 670 670 /* 671 671 * NOTE: STAT_BB bit could became 1 here if another master occupy 672 672 * the bus. IP successfully complete transfer when the bus will be 673 673 * free again (BB reset to 0). 674 674 */ 675 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); 675 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, w); 676 676 677 677 /* 678 678 * Don't write stt and stp together on some hardware. 679 679 */ 680 - if (dev->b_hw && stop) { 680 + if (omap->b_hw && stop) { 681 681 unsigned long delay = jiffies + OMAP_I2C_TIMEOUT; 682 - u16 con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG); 682 + u16 con = omap_i2c_read_reg(omap, OMAP_I2C_CON_REG); 683 683 while (con & OMAP_I2C_CON_STT) { 684 - con = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG); 684 + con = omap_i2c_read_reg(omap, OMAP_I2C_CON_REG); 685 685 686 686 /* Let the user know if i2c is in a bad state */ 687 687 if (time_after(jiffies, delay)) { 688 - dev_err(dev->dev, "controller timed out " 688 + dev_err(omap->dev, "controller timed out " 689 689 "waiting for start condition to finish\n"); 690 690 return -ETIMEDOUT; 691 691 } ··· 694 694 695 695 w |= OMAP_I2C_CON_STP; 696 696 w &= ~OMAP_I2C_CON_STT; 697 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); 697 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, w); 698 698 } 699 699 700 700 /* 701 701 * REVISIT: We should abort the transfer on signals, but the bus goes 702 702 * into arbitration and we're currently unable to recover from it. 703 703 */ 704 - timeout = wait_for_completion_timeout(&dev->cmd_complete, 704 + timeout = wait_for_completion_timeout(&omap->cmd_complete, 705 705 OMAP_I2C_TIMEOUT); 706 706 if (timeout == 0) { 707 - dev_err(dev->dev, "controller timed out\n"); 708 - omap_i2c_reset(dev); 709 - __omap_i2c_init(dev); 707 + dev_err(omap->dev, "controller timed out\n"); 708 + omap_i2c_reset(omap); 709 + __omap_i2c_init(omap); 710 710 return -ETIMEDOUT; 711 711 } 712 712 713 - if (likely(!dev->cmd_err)) 713 + if (likely(!omap->cmd_err)) 714 714 return 0; 715 715 716 716 /* We have an error */ 717 - if (dev->cmd_err & (OMAP_I2C_STAT_ROVR | OMAP_I2C_STAT_XUDF)) { 718 - omap_i2c_reset(dev); 719 - __omap_i2c_init(dev); 717 + if (omap->cmd_err & (OMAP_I2C_STAT_ROVR | OMAP_I2C_STAT_XUDF)) { 718 + omap_i2c_reset(omap); 719 + __omap_i2c_init(omap); 720 720 return -EIO; 721 721 } 722 722 723 - if (dev->cmd_err & OMAP_I2C_STAT_AL) 723 + if (omap->cmd_err & OMAP_I2C_STAT_AL) 724 724 return -EAGAIN; 725 725 726 - if (dev->cmd_err & OMAP_I2C_STAT_NACK) { 726 + if (omap->cmd_err & OMAP_I2C_STAT_NACK) { 727 727 if (msg->flags & I2C_M_IGNORE_NAK) 728 728 return 0; 729 729 730 - w = omap_i2c_read_reg(dev, OMAP_I2C_CON_REG); 730 + w = omap_i2c_read_reg(omap, OMAP_I2C_CON_REG); 731 731 w |= OMAP_I2C_CON_STP; 732 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, w); 732 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, w); 733 733 return -EREMOTEIO; 734 734 } 735 735 return -EIO; ··· 743 743 static int 744 744 omap_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[], int num) 745 745 { 746 - struct omap_i2c_dev *dev = i2c_get_adapdata(adap); 746 + struct omap_i2c_dev *omap = i2c_get_adapdata(adap); 747 747 int i; 748 748 int r; 749 749 750 - r = pm_runtime_get_sync(dev->dev); 750 + r = pm_runtime_get_sync(omap->dev); 751 751 if (r < 0) 752 752 goto out; 753 753 754 - r = omap_i2c_wait_for_bb_valid(dev); 754 + r = omap_i2c_wait_for_bb_valid(omap); 755 755 if (r < 0) 756 756 goto out; 757 757 758 - r = omap_i2c_wait_for_bb(dev); 758 + r = omap_i2c_wait_for_bb(omap); 759 759 if (r < 0) 760 760 goto out; 761 761 762 - if (dev->set_mpu_wkup_lat != NULL) 763 - dev->set_mpu_wkup_lat(dev->dev, dev->latency); 762 + if (omap->set_mpu_wkup_lat != NULL) 763 + omap->set_mpu_wkup_lat(omap->dev, omap->latency); 764 764 765 765 for (i = 0; i < num; i++) { 766 766 r = omap_i2c_xfer_msg(adap, &msgs[i], (i == (num - 1))); ··· 771 771 if (r == 0) 772 772 r = num; 773 773 774 - omap_i2c_wait_for_bb(dev); 774 + omap_i2c_wait_for_bb(omap); 775 775 776 - if (dev->set_mpu_wkup_lat != NULL) 777 - dev->set_mpu_wkup_lat(dev->dev, -1); 776 + if (omap->set_mpu_wkup_lat != NULL) 777 + omap->set_mpu_wkup_lat(omap->dev, -1); 778 778 779 779 out: 780 - pm_runtime_mark_last_busy(dev->dev); 781 - pm_runtime_put_autosuspend(dev->dev); 780 + pm_runtime_mark_last_busy(omap->dev); 781 + pm_runtime_put_autosuspend(omap->dev); 782 782 return r; 783 783 } 784 784 ··· 790 790 } 791 791 792 792 static inline void 793 - omap_i2c_complete_cmd(struct omap_i2c_dev *dev, u16 err) 793 + omap_i2c_complete_cmd(struct omap_i2c_dev *omap, u16 err) 794 794 { 795 - dev->cmd_err |= err; 796 - complete(&dev->cmd_complete); 795 + omap->cmd_err |= err; 796 + complete(&omap->cmd_complete); 797 797 } 798 798 799 799 static inline void 800 - omap_i2c_ack_stat(struct omap_i2c_dev *dev, u16 stat) 800 + omap_i2c_ack_stat(struct omap_i2c_dev *omap, u16 stat) 801 801 { 802 - omap_i2c_write_reg(dev, OMAP_I2C_STAT_REG, stat); 802 + omap_i2c_write_reg(omap, OMAP_I2C_STAT_REG, stat); 803 803 } 804 804 805 - static inline void i2c_omap_errata_i207(struct omap_i2c_dev *dev, u16 stat) 805 + static inline void i2c_omap_errata_i207(struct omap_i2c_dev *omap, u16 stat) 806 806 { 807 807 /* 808 808 * I2C Errata(Errata Nos. OMAP2: 1.67, OMAP3: 1.8) ··· 813 813 */ 814 814 if (stat & OMAP_I2C_STAT_RDR) { 815 815 /* Step 1: If RDR is set, clear it */ 816 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); 816 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RDR); 817 817 818 818 /* Step 2: */ 819 - if (!(omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) 819 + if (!(omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG) 820 820 & OMAP_I2C_STAT_BB)) { 821 821 822 822 /* Step 3: */ 823 - if (omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG) 823 + if (omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG) 824 824 & OMAP_I2C_STAT_RDR) { 825 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); 826 - dev_dbg(dev->dev, "RDR when bus is busy.\n"); 825 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RDR); 826 + dev_dbg(omap->dev, "RDR when bus is busy.\n"); 827 827 } 828 828 829 829 } ··· 836 836 static irqreturn_t 837 837 omap_i2c_omap1_isr(int this_irq, void *dev_id) 838 838 { 839 - struct omap_i2c_dev *dev = dev_id; 839 + struct omap_i2c_dev *omap = dev_id; 840 840 u16 iv, w; 841 841 842 - if (pm_runtime_suspended(dev->dev)) 842 + if (pm_runtime_suspended(omap->dev)) 843 843 return IRQ_NONE; 844 844 845 - iv = omap_i2c_read_reg(dev, OMAP_I2C_IV_REG); 845 + iv = omap_i2c_read_reg(omap, OMAP_I2C_IV_REG); 846 846 switch (iv) { 847 847 case 0x00: /* None */ 848 848 break; 849 849 case 0x01: /* Arbitration lost */ 850 - dev_err(dev->dev, "Arbitration lost\n"); 851 - omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_AL); 850 + dev_err(omap->dev, "Arbitration lost\n"); 851 + omap_i2c_complete_cmd(omap, OMAP_I2C_STAT_AL); 852 852 break; 853 853 case 0x02: /* No acknowledgement */ 854 - omap_i2c_complete_cmd(dev, OMAP_I2C_STAT_NACK); 855 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, OMAP_I2C_CON_STP); 854 + omap_i2c_complete_cmd(omap, OMAP_I2C_STAT_NACK); 855 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, OMAP_I2C_CON_STP); 856 856 break; 857 857 case 0x03: /* Register access ready */ 858 - omap_i2c_complete_cmd(dev, 0); 858 + omap_i2c_complete_cmd(omap, 0); 859 859 break; 860 860 case 0x04: /* Receive data ready */ 861 - if (dev->buf_len) { 862 - w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); 863 - *dev->buf++ = w; 864 - dev->buf_len--; 865 - if (dev->buf_len) { 866 - *dev->buf++ = w >> 8; 867 - dev->buf_len--; 861 + if (omap->buf_len) { 862 + w = omap_i2c_read_reg(omap, OMAP_I2C_DATA_REG); 863 + *omap->buf++ = w; 864 + omap->buf_len--; 865 + if (omap->buf_len) { 866 + *omap->buf++ = w >> 8; 867 + omap->buf_len--; 868 868 } 869 869 } else 870 - dev_err(dev->dev, "RRDY IRQ while no data requested\n"); 870 + dev_err(omap->dev, "RRDY IRQ while no data requested\n"); 871 871 break; 872 872 case 0x05: /* Transmit data ready */ 873 - if (dev->buf_len) { 874 - w = *dev->buf++; 875 - dev->buf_len--; 876 - if (dev->buf_len) { 877 - w |= *dev->buf++ << 8; 878 - dev->buf_len--; 873 + if (omap->buf_len) { 874 + w = *omap->buf++; 875 + omap->buf_len--; 876 + if (omap->buf_len) { 877 + w |= *omap->buf++ << 8; 878 + omap->buf_len--; 879 879 } 880 - omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); 880 + omap_i2c_write_reg(omap, OMAP_I2C_DATA_REG, w); 881 881 } else 882 - dev_err(dev->dev, "XRDY IRQ while no data to send\n"); 882 + dev_err(omap->dev, "XRDY IRQ while no data to send\n"); 883 883 break; 884 884 default: 885 885 return IRQ_NONE; ··· 896 896 * data to DATA_REG. Otherwise some data bytes can be lost while transferring 897 897 * them from the memory to the I2C interface. 898 898 */ 899 - static int errata_omap3_i462(struct omap_i2c_dev *dev) 899 + static int errata_omap3_i462(struct omap_i2c_dev *omap) 900 900 { 901 901 unsigned long timeout = 10000; 902 902 u16 stat; 903 903 904 904 do { 905 - stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); 905 + stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); 906 906 if (stat & OMAP_I2C_STAT_XUDF) 907 907 break; 908 908 909 909 if (stat & (OMAP_I2C_STAT_NACK | OMAP_I2C_STAT_AL)) { 910 - omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_XRDY | 910 + omap_i2c_ack_stat(omap, (OMAP_I2C_STAT_XRDY | 911 911 OMAP_I2C_STAT_XDR)); 912 912 if (stat & OMAP_I2C_STAT_NACK) { 913 - dev->cmd_err |= OMAP_I2C_STAT_NACK; 914 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK); 913 + omap->cmd_err |= OMAP_I2C_STAT_NACK; 914 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_NACK); 915 915 } 916 916 917 917 if (stat & OMAP_I2C_STAT_AL) { 918 - dev_err(dev->dev, "Arbitration lost\n"); 919 - dev->cmd_err |= OMAP_I2C_STAT_AL; 920 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_AL); 918 + dev_err(omap->dev, "Arbitration lost\n"); 919 + omap->cmd_err |= OMAP_I2C_STAT_AL; 920 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_AL); 921 921 } 922 922 923 923 return -EIO; ··· 927 927 } while (--timeout); 928 928 929 929 if (!timeout) { 930 - dev_err(dev->dev, "timeout waiting on XUDF bit\n"); 930 + dev_err(omap->dev, "timeout waiting on XUDF bit\n"); 931 931 return 0; 932 932 } 933 933 934 934 return 0; 935 935 } 936 936 937 - static void omap_i2c_receive_data(struct omap_i2c_dev *dev, u8 num_bytes, 937 + static void omap_i2c_receive_data(struct omap_i2c_dev *omap, u8 num_bytes, 938 938 bool is_rdr) 939 939 { 940 940 u16 w; 941 941 942 942 while (num_bytes--) { 943 - w = omap_i2c_read_reg(dev, OMAP_I2C_DATA_REG); 944 - *dev->buf++ = w; 945 - dev->buf_len--; 943 + w = omap_i2c_read_reg(omap, OMAP_I2C_DATA_REG); 944 + *omap->buf++ = w; 945 + omap->buf_len--; 946 946 947 947 /* 948 948 * Data reg in 2430, omap3 and 949 949 * omap4 is 8 bit wide 950 950 */ 951 - if (dev->flags & OMAP_I2C_FLAG_16BIT_DATA_REG) { 952 - *dev->buf++ = w >> 8; 953 - dev->buf_len--; 951 + if (omap->flags & OMAP_I2C_FLAG_16BIT_DATA_REG) { 952 + *omap->buf++ = w >> 8; 953 + omap->buf_len--; 954 954 } 955 955 } 956 956 } 957 957 958 - static int omap_i2c_transmit_data(struct omap_i2c_dev *dev, u8 num_bytes, 958 + static int omap_i2c_transmit_data(struct omap_i2c_dev *omap, u8 num_bytes, 959 959 bool is_xdr) 960 960 { 961 961 u16 w; 962 962 963 963 while (num_bytes--) { 964 - w = *dev->buf++; 965 - dev->buf_len--; 964 + w = *omap->buf++; 965 + omap->buf_len--; 966 966 967 967 /* 968 968 * Data reg in 2430, omap3 and 969 969 * omap4 is 8 bit wide 970 970 */ 971 - if (dev->flags & OMAP_I2C_FLAG_16BIT_DATA_REG) { 972 - w |= *dev->buf++ << 8; 973 - dev->buf_len--; 971 + if (omap->flags & OMAP_I2C_FLAG_16BIT_DATA_REG) { 972 + w |= *omap->buf++ << 8; 973 + omap->buf_len--; 974 974 } 975 975 976 - if (dev->errata & I2C_OMAP_ERRATA_I462) { 976 + if (omap->errata & I2C_OMAP_ERRATA_I462) { 977 977 int ret; 978 978 979 - ret = errata_omap3_i462(dev); 979 + ret = errata_omap3_i462(omap); 980 980 if (ret < 0) 981 981 return ret; 982 982 } 983 983 984 - omap_i2c_write_reg(dev, OMAP_I2C_DATA_REG, w); 984 + omap_i2c_write_reg(omap, OMAP_I2C_DATA_REG, w); 985 985 } 986 986 987 987 return 0; ··· 990 990 static irqreturn_t 991 991 omap_i2c_isr(int irq, void *dev_id) 992 992 { 993 - struct omap_i2c_dev *dev = dev_id; 993 + struct omap_i2c_dev *omap = dev_id; 994 994 irqreturn_t ret = IRQ_HANDLED; 995 995 u16 mask; 996 996 u16 stat; 997 997 998 - spin_lock(&dev->lock); 999 - mask = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); 1000 - stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); 998 + spin_lock(&omap->lock); 999 + mask = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG); 1000 + stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); 1001 1001 1002 1002 if (stat & mask) 1003 1003 ret = IRQ_WAKE_THREAD; 1004 1004 1005 - spin_unlock(&dev->lock); 1005 + spin_unlock(&omap->lock); 1006 1006 1007 1007 return ret; 1008 1008 } ··· 1010 1010 static irqreturn_t 1011 1011 omap_i2c_isr_thread(int this_irq, void *dev_id) 1012 1012 { 1013 - struct omap_i2c_dev *dev = dev_id; 1013 + struct omap_i2c_dev *omap = dev_id; 1014 1014 unsigned long flags; 1015 1015 u16 bits; 1016 1016 u16 stat; 1017 1017 int err = 0, count = 0; 1018 1018 1019 - spin_lock_irqsave(&dev->lock, flags); 1019 + spin_lock_irqsave(&omap->lock, flags); 1020 1020 do { 1021 - bits = omap_i2c_read_reg(dev, OMAP_I2C_IE_REG); 1022 - stat = omap_i2c_read_reg(dev, OMAP_I2C_STAT_REG); 1021 + bits = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG); 1022 + stat = omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); 1023 1023 stat &= bits; 1024 1024 1025 1025 /* If we're in receiver mode, ignore XDR/XRDY */ 1026 - if (dev->receiver) 1026 + if (omap->receiver) 1027 1027 stat &= ~(OMAP_I2C_STAT_XDR | OMAP_I2C_STAT_XRDY); 1028 1028 else 1029 1029 stat &= ~(OMAP_I2C_STAT_RDR | OMAP_I2C_STAT_RRDY); ··· 1033 1033 goto out; 1034 1034 } 1035 1035 1036 - dev_dbg(dev->dev, "IRQ (ISR = 0x%04x)\n", stat); 1036 + dev_dbg(omap->dev, "IRQ (ISR = 0x%04x)\n", stat); 1037 1037 if (count++ == 100) { 1038 - dev_warn(dev->dev, "Too much work in one IRQ\n"); 1038 + dev_warn(omap->dev, "Too much work in one IRQ\n"); 1039 1039 break; 1040 1040 } 1041 1041 1042 1042 if (stat & OMAP_I2C_STAT_NACK) { 1043 1043 err |= OMAP_I2C_STAT_NACK; 1044 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_NACK); 1044 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_NACK); 1045 1045 } 1046 1046 1047 1047 if (stat & OMAP_I2C_STAT_AL) { 1048 - dev_err(dev->dev, "Arbitration lost\n"); 1048 + dev_err(omap->dev, "Arbitration lost\n"); 1049 1049 err |= OMAP_I2C_STAT_AL; 1050 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_AL); 1050 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_AL); 1051 1051 } 1052 1052 1053 1053 /* 1054 1054 * ProDB0017052: Clear ARDY bit twice 1055 1055 */ 1056 1056 if (stat & OMAP_I2C_STAT_ARDY) 1057 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_ARDY); 1057 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_ARDY); 1058 1058 1059 1059 if (stat & (OMAP_I2C_STAT_ARDY | OMAP_I2C_STAT_NACK | 1060 1060 OMAP_I2C_STAT_AL)) { 1061 - omap_i2c_ack_stat(dev, (OMAP_I2C_STAT_RRDY | 1061 + omap_i2c_ack_stat(omap, (OMAP_I2C_STAT_RRDY | 1062 1062 OMAP_I2C_STAT_RDR | 1063 1063 OMAP_I2C_STAT_XRDY | 1064 1064 OMAP_I2C_STAT_XDR | ··· 1069 1069 if (stat & OMAP_I2C_STAT_RDR) { 1070 1070 u8 num_bytes = 1; 1071 1071 1072 - if (dev->fifo_size) 1073 - num_bytes = dev->buf_len; 1072 + if (omap->fifo_size) 1073 + num_bytes = omap->buf_len; 1074 1074 1075 - if (dev->errata & I2C_OMAP_ERRATA_I207) { 1076 - i2c_omap_errata_i207(dev, stat); 1077 - num_bytes = (omap_i2c_read_reg(dev, 1075 + if (omap->errata & I2C_OMAP_ERRATA_I207) { 1076 + i2c_omap_errata_i207(omap, stat); 1077 + num_bytes = (omap_i2c_read_reg(omap, 1078 1078 OMAP_I2C_BUFSTAT_REG) >> 8) & 0x3F; 1079 1079 } 1080 1080 1081 - omap_i2c_receive_data(dev, num_bytes, true); 1082 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RDR); 1081 + omap_i2c_receive_data(omap, num_bytes, true); 1082 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RDR); 1083 1083 continue; 1084 1084 } 1085 1085 1086 1086 if (stat & OMAP_I2C_STAT_RRDY) { 1087 1087 u8 num_bytes = 1; 1088 1088 1089 - if (dev->threshold) 1090 - num_bytes = dev->threshold; 1089 + if (omap->threshold) 1090 + num_bytes = omap->threshold; 1091 1091 1092 - omap_i2c_receive_data(dev, num_bytes, false); 1093 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_RRDY); 1092 + omap_i2c_receive_data(omap, num_bytes, false); 1093 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_RRDY); 1094 1094 continue; 1095 1095 } 1096 1096 ··· 1098 1098 u8 num_bytes = 1; 1099 1099 int ret; 1100 1100 1101 - if (dev->fifo_size) 1102 - num_bytes = dev->buf_len; 1101 + if (omap->fifo_size) 1102 + num_bytes = omap->buf_len; 1103 1103 1104 - ret = omap_i2c_transmit_data(dev, num_bytes, true); 1104 + ret = omap_i2c_transmit_data(omap, num_bytes, true); 1105 1105 if (ret < 0) 1106 1106 break; 1107 1107 1108 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XDR); 1108 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_XDR); 1109 1109 continue; 1110 1110 } 1111 1111 ··· 1113 1113 u8 num_bytes = 1; 1114 1114 int ret; 1115 1115 1116 - if (dev->threshold) 1117 - num_bytes = dev->threshold; 1116 + if (omap->threshold) 1117 + num_bytes = omap->threshold; 1118 1118 1119 - ret = omap_i2c_transmit_data(dev, num_bytes, false); 1119 + ret = omap_i2c_transmit_data(omap, num_bytes, false); 1120 1120 if (ret < 0) 1121 1121 break; 1122 1122 1123 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XRDY); 1123 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_XRDY); 1124 1124 continue; 1125 1125 } 1126 1126 1127 1127 if (stat & OMAP_I2C_STAT_ROVR) { 1128 - dev_err(dev->dev, "Receive overrun\n"); 1128 + dev_err(omap->dev, "Receive overrun\n"); 1129 1129 err |= OMAP_I2C_STAT_ROVR; 1130 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_ROVR); 1130 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_ROVR); 1131 1131 break; 1132 1132 } 1133 1133 1134 1134 if (stat & OMAP_I2C_STAT_XUDF) { 1135 - dev_err(dev->dev, "Transmit underflow\n"); 1135 + dev_err(omap->dev, "Transmit underflow\n"); 1136 1136 err |= OMAP_I2C_STAT_XUDF; 1137 - omap_i2c_ack_stat(dev, OMAP_I2C_STAT_XUDF); 1137 + omap_i2c_ack_stat(omap, OMAP_I2C_STAT_XUDF); 1138 1138 break; 1139 1139 } 1140 1140 } while (stat); 1141 1141 1142 - omap_i2c_complete_cmd(dev, err); 1142 + omap_i2c_complete_cmd(omap, err); 1143 1143 1144 1144 out: 1145 - spin_unlock_irqrestore(&dev->lock, flags); 1145 + spin_unlock_irqrestore(&omap->lock, flags); 1146 1146 1147 1147 return IRQ_HANDLED; 1148 1148 } ··· 1284 1284 static int 1285 1285 omap_i2c_probe(struct platform_device *pdev) 1286 1286 { 1287 - struct omap_i2c_dev *dev; 1287 + struct omap_i2c_dev *omap; 1288 1288 struct i2c_adapter *adap; 1289 1289 struct resource *mem; 1290 1290 const struct omap_i2c_bus_platform_data *pdata = ··· 1302 1302 return irq; 1303 1303 } 1304 1304 1305 - dev = devm_kzalloc(&pdev->dev, sizeof(struct omap_i2c_dev), GFP_KERNEL); 1306 - if (!dev) 1305 + omap = devm_kzalloc(&pdev->dev, sizeof(struct omap_i2c_dev), GFP_KERNEL); 1306 + if (!omap) 1307 1307 return -ENOMEM; 1308 1308 1309 1309 mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1310 - dev->base = devm_ioremap_resource(&pdev->dev, mem); 1311 - if (IS_ERR(dev->base)) 1312 - return PTR_ERR(dev->base); 1310 + omap->base = devm_ioremap_resource(&pdev->dev, mem); 1311 + if (IS_ERR(omap->base)) 1312 + return PTR_ERR(omap->base); 1313 1313 1314 1314 match = of_match_device(of_match_ptr(omap_i2c_of_match), &pdev->dev); 1315 1315 if (match) { 1316 1316 u32 freq = 100000; /* default to 100000 Hz */ 1317 1317 1318 1318 pdata = match->data; 1319 - dev->flags = pdata->flags; 1319 + omap->flags = pdata->flags; 1320 1320 1321 1321 of_property_read_u32(node, "clock-frequency", &freq); 1322 1322 /* convert DT freq value in Hz into kHz for speed */ 1323 - dev->speed = freq / 1000; 1323 + omap->speed = freq / 1000; 1324 1324 } else if (pdata != NULL) { 1325 - dev->speed = pdata->clkrate; 1326 - dev->flags = pdata->flags; 1327 - dev->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; 1325 + omap->speed = pdata->clkrate; 1326 + omap->flags = pdata->flags; 1327 + omap->set_mpu_wkup_lat = pdata->set_mpu_wkup_lat; 1328 1328 } 1329 1329 1330 - dev->dev = &pdev->dev; 1331 - dev->irq = irq; 1330 + omap->dev = &pdev->dev; 1331 + omap->irq = irq; 1332 1332 1333 - spin_lock_init(&dev->lock); 1333 + spin_lock_init(&omap->lock); 1334 1334 1335 - platform_set_drvdata(pdev, dev); 1336 - init_completion(&dev->cmd_complete); 1335 + platform_set_drvdata(pdev, omap); 1336 + init_completion(&omap->cmd_complete); 1337 1337 1338 - dev->reg_shift = (dev->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3; 1338 + omap->reg_shift = (omap->flags >> OMAP_I2C_FLAG_BUS_SHIFT__SHIFT) & 3; 1339 1339 1340 - pm_runtime_enable(dev->dev); 1341 - pm_runtime_set_autosuspend_delay(dev->dev, OMAP_I2C_PM_TIMEOUT); 1342 - pm_runtime_use_autosuspend(dev->dev); 1340 + pm_runtime_enable(omap->dev); 1341 + pm_runtime_set_autosuspend_delay(omap->dev, OMAP_I2C_PM_TIMEOUT); 1342 + pm_runtime_use_autosuspend(omap->dev); 1343 1343 1344 - r = pm_runtime_get_sync(dev->dev); 1345 - if (r < 0) 1344 + r = pm_runtime_get_sync(omap->dev); 1345 + if (IS_ERR_VALUE(r)) 1346 1346 goto err_free_mem; 1347 1347 1348 1348 /* ··· 1351 1351 * Also since the omap_i2c_read_reg uses reg_map_ip_* a 1352 1352 * readw_relaxed is done. 1353 1353 */ 1354 - rev = readw_relaxed(dev->base + 0x04); 1354 + rev = readw_relaxed(omap->base + 0x04); 1355 1355 1356 - dev->scheme = OMAP_I2C_SCHEME(rev); 1357 - switch (dev->scheme) { 1356 + omap->scheme = OMAP_I2C_SCHEME(rev); 1357 + switch (omap->scheme) { 1358 1358 case OMAP_I2C_SCHEME_0: 1359 - dev->regs = (u8 *)reg_map_ip_v1; 1360 - dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG); 1361 - minor = OMAP_I2C_REV_SCHEME_0_MAJOR(dev->rev); 1362 - major = OMAP_I2C_REV_SCHEME_0_MAJOR(dev->rev); 1359 + omap->regs = (u8 *)reg_map_ip_v1; 1360 + omap->rev = omap_i2c_read_reg(omap, OMAP_I2C_REV_REG); 1361 + minor = OMAP_I2C_REV_SCHEME_0_MAJOR(omap->rev); 1362 + major = OMAP_I2C_REV_SCHEME_0_MAJOR(omap->rev); 1363 1363 break; 1364 1364 case OMAP_I2C_SCHEME_1: 1365 1365 /* FALLTHROUGH */ 1366 1366 default: 1367 - dev->regs = (u8 *)reg_map_ip_v2; 1367 + omap->regs = (u8 *)reg_map_ip_v2; 1368 1368 rev = (rev << 16) | 1369 - omap_i2c_read_reg(dev, OMAP_I2C_IP_V2_REVNB_LO); 1369 + omap_i2c_read_reg(omap, OMAP_I2C_IP_V2_REVNB_LO); 1370 1370 minor = OMAP_I2C_REV_SCHEME_1_MINOR(rev); 1371 1371 major = OMAP_I2C_REV_SCHEME_1_MAJOR(rev); 1372 - dev->rev = rev; 1372 + omap->rev = rev; 1373 1373 } 1374 1374 1375 - dev->errata = 0; 1375 + omap->errata = 0; 1376 1376 1377 - if (dev->rev >= OMAP_I2C_REV_ON_2430 && 1378 - dev->rev < OMAP_I2C_REV_ON_4430_PLUS) 1379 - dev->errata |= I2C_OMAP_ERRATA_I207; 1377 + if (omap->rev >= OMAP_I2C_REV_ON_2430 && 1378 + omap->rev < OMAP_I2C_REV_ON_4430_PLUS) 1379 + omap->errata |= I2C_OMAP_ERRATA_I207; 1380 1380 1381 - if (dev->rev <= OMAP_I2C_REV_ON_3430_3530) 1382 - dev->errata |= I2C_OMAP_ERRATA_I462; 1381 + if (omap->rev <= OMAP_I2C_REV_ON_3430_3530) 1382 + omap->errata |= I2C_OMAP_ERRATA_I462; 1383 1383 1384 - if (!(dev->flags & OMAP_I2C_FLAG_NO_FIFO)) { 1384 + if (!(omap->flags & OMAP_I2C_FLAG_NO_FIFO)) { 1385 1385 u16 s; 1386 1386 1387 1387 /* Set up the fifo size - Get total size */ 1388 - s = (omap_i2c_read_reg(dev, OMAP_I2C_BUFSTAT_REG) >> 14) & 0x3; 1389 - dev->fifo_size = 0x8 << s; 1388 + s = (omap_i2c_read_reg(omap, OMAP_I2C_BUFSTAT_REG) >> 14) & 0x3; 1389 + omap->fifo_size = 0x8 << s; 1390 1390 1391 1391 /* 1392 1392 * Set up notification threshold as half the total available ··· 1394 1394 * call back latencies. 1395 1395 */ 1396 1396 1397 - dev->fifo_size = (dev->fifo_size / 2); 1397 + omap->fifo_size = (omap->fifo_size / 2); 1398 1398 1399 - if (dev->rev < OMAP_I2C_REV_ON_3630) 1400 - dev->b_hw = 1; /* Enable hardware fixes */ 1399 + if (omap->rev < OMAP_I2C_REV_ON_3630) 1400 + omap->b_hw = 1; /* Enable hardware fixes */ 1401 1401 1402 1402 /* calculate wakeup latency constraint for MPU */ 1403 - if (dev->set_mpu_wkup_lat != NULL) 1404 - dev->latency = (1000000 * dev->fifo_size) / 1405 - (1000 * dev->speed / 8); 1403 + if (omap->set_mpu_wkup_lat != NULL) 1404 + omap->latency = (1000000 * omap->fifo_size) / 1405 + (1000 * omap->speed / 8); 1406 1406 } 1407 1407 1408 1408 /* reset ASAP, clearing any IRQs */ 1409 - omap_i2c_init(dev); 1409 + omap_i2c_init(omap); 1410 1410 1411 - if (dev->rev < OMAP_I2C_OMAP1_REV_2) 1412 - r = devm_request_irq(&pdev->dev, dev->irq, omap_i2c_omap1_isr, 1413 - IRQF_NO_SUSPEND, pdev->name, dev); 1411 + if (omap->rev < OMAP_I2C_OMAP1_REV_2) 1412 + r = devm_request_irq(&pdev->dev, omap->irq, omap_i2c_omap1_isr, 1413 + IRQF_NO_SUSPEND, pdev->name, omap); 1414 1414 else 1415 - r = devm_request_threaded_irq(&pdev->dev, dev->irq, 1415 + r = devm_request_threaded_irq(&pdev->dev, omap->irq, 1416 1416 omap_i2c_isr, omap_i2c_isr_thread, 1417 1417 IRQF_NO_SUSPEND | IRQF_ONESHOT, 1418 - pdev->name, dev); 1418 + pdev->name, omap); 1419 1419 1420 1420 if (r) { 1421 - dev_err(dev->dev, "failure requesting irq %i\n", dev->irq); 1421 + dev_err(omap->dev, "failure requesting irq %i\n", omap->irq); 1422 1422 goto err_unuse_clocks; 1423 1423 } 1424 1424 1425 - adap = &dev->adapter; 1426 - i2c_set_adapdata(adap, dev); 1425 + adap = &omap->adapter; 1426 + i2c_set_adapdata(adap, omap); 1427 1427 adap->owner = THIS_MODULE; 1428 1428 adap->class = I2C_CLASS_DEPRECATED; 1429 1429 strlcpy(adap->name, "OMAP I2C adapter", sizeof(adap->name)); ··· 1436 1436 adap->nr = pdev->id; 1437 1437 r = i2c_add_numbered_adapter(adap); 1438 1438 if (r) { 1439 - dev_err(dev->dev, "failure adding adapter\n"); 1439 + dev_err(omap->dev, "failure adding adapter\n"); 1440 1440 goto err_unuse_clocks; 1441 1441 } 1442 1442 1443 - dev_info(dev->dev, "bus %d rev%d.%d at %d kHz\n", adap->nr, 1444 - major, minor, dev->speed); 1443 + dev_info(omap->dev, "bus %d rev%d.%d at %d kHz\n", adap->nr, 1444 + major, minor, omap->speed); 1445 1445 1446 - pm_runtime_mark_last_busy(dev->dev); 1447 - pm_runtime_put_autosuspend(dev->dev); 1446 + pm_runtime_mark_last_busy(omap->dev); 1447 + pm_runtime_put_autosuspend(omap->dev); 1448 1448 1449 1449 return 0; 1450 1450 1451 1451 err_unuse_clocks: 1452 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 1453 - pm_runtime_put(dev->dev); 1452 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); 1453 + pm_runtime_put(omap->dev); 1454 1454 pm_runtime_disable(&pdev->dev); 1455 1455 err_free_mem: 1456 1456 ··· 1459 1459 1460 1460 static int omap_i2c_remove(struct platform_device *pdev) 1461 1461 { 1462 - struct omap_i2c_dev *dev = platform_get_drvdata(pdev); 1462 + struct omap_i2c_dev *omap = platform_get_drvdata(pdev); 1463 1463 int ret; 1464 1464 1465 - i2c_del_adapter(&dev->adapter); 1465 + i2c_del_adapter(&omap->adapter); 1466 1466 ret = pm_runtime_get_sync(&pdev->dev); 1467 1467 if (ret < 0) 1468 1468 return ret; 1469 1469 1470 - omap_i2c_write_reg(dev, OMAP_I2C_CON_REG, 0); 1470 + omap_i2c_write_reg(omap, OMAP_I2C_CON_REG, 0); 1471 1471 pm_runtime_put(&pdev->dev); 1472 1472 pm_runtime_disable(&pdev->dev); 1473 1473 return 0; ··· 1476 1476 #ifdef CONFIG_PM 1477 1477 static int omap_i2c_runtime_suspend(struct device *dev) 1478 1478 { 1479 - struct omap_i2c_dev *_dev = dev_get_drvdata(dev); 1479 + struct omap_i2c_dev *omap = dev_get_drvdata(dev); 1480 1480 1481 - _dev->iestate = omap_i2c_read_reg(_dev, OMAP_I2C_IE_REG); 1481 + omap->iestate = omap_i2c_read_reg(omap, OMAP_I2C_IE_REG); 1482 1482 1483 - if (_dev->scheme == OMAP_I2C_SCHEME_0) 1484 - omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, 0); 1483 + if (omap->scheme == OMAP_I2C_SCHEME_0) 1484 + omap_i2c_write_reg(omap, OMAP_I2C_IE_REG, 0); 1485 1485 else 1486 - omap_i2c_write_reg(_dev, OMAP_I2C_IP_V2_IRQENABLE_CLR, 1486 + omap_i2c_write_reg(omap, OMAP_I2C_IP_V2_IRQENABLE_CLR, 1487 1487 OMAP_I2C_IP_V2_INTERRUPTS_MASK); 1488 1488 1489 - if (_dev->rev < OMAP_I2C_OMAP1_REV_2) { 1490 - omap_i2c_read_reg(_dev, OMAP_I2C_IV_REG); /* Read clears */ 1489 + if (omap->rev < OMAP_I2C_OMAP1_REV_2) { 1490 + omap_i2c_read_reg(omap, OMAP_I2C_IV_REG); /* Read clears */ 1491 1491 } else { 1492 - omap_i2c_write_reg(_dev, OMAP_I2C_STAT_REG, _dev->iestate); 1492 + omap_i2c_write_reg(omap, OMAP_I2C_STAT_REG, omap->iestate); 1493 1493 1494 1494 /* Flush posted write */ 1495 - omap_i2c_read_reg(_dev, OMAP_I2C_STAT_REG); 1495 + omap_i2c_read_reg(omap, OMAP_I2C_STAT_REG); 1496 1496 } 1497 1497 1498 1498 pinctrl_pm_select_sleep_state(dev); ··· 1502 1502 1503 1503 static int omap_i2c_runtime_resume(struct device *dev) 1504 1504 { 1505 - struct omap_i2c_dev *_dev = dev_get_drvdata(dev); 1505 + struct omap_i2c_dev *omap = dev_get_drvdata(dev); 1506 1506 1507 1507 pinctrl_pm_select_default_state(dev); 1508 1508 1509 - if (!_dev->regs) 1509 + if (!omap->regs) 1510 1510 return 0; 1511 1511 1512 - __omap_i2c_init(_dev); 1512 + __omap_i2c_init(omap); 1513 1513 1514 1514 return 0; 1515 1515 }