| .. | .. |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * SuperH Mobile I2C Controller |
|---|
| 4 | 4 | * |
|---|
| 5 | | - * Copyright (C) 2014 Wolfram Sang <wsa@sang-engineering.com> |
|---|
| 6 | | - * |
|---|
| 5 | + * Copyright (C) 2014-19 Wolfram Sang <wsa@sang-engineering.com> |
|---|
| 7 | 6 | * Copyright (C) 2008 Magnus Damm |
|---|
| 8 | 7 | * |
|---|
| 9 | 8 | * Portions of the code based on out-of-tree driver i2c-sh7343.c |
|---|
| .. | .. |
|---|
| 130 | 129 | int sr; |
|---|
| 131 | 130 | bool send_stop; |
|---|
| 132 | 131 | bool stop_after_dma; |
|---|
| 132 | + bool atomic_xfer; |
|---|
| 133 | 133 | |
|---|
| 134 | 134 | struct resource *res; |
|---|
| 135 | 135 | struct dma_chan *dma_tx; |
|---|
| .. | .. |
|---|
| 145 | 145 | }; |
|---|
| 146 | 146 | |
|---|
| 147 | 147 | #define IIC_FLAG_HAS_ICIC67 (1 << 0) |
|---|
| 148 | | - |
|---|
| 149 | | -#define STANDARD_MODE 100000 |
|---|
| 150 | | -#define FAST_MODE 400000 |
|---|
| 151 | 148 | |
|---|
| 152 | 149 | /* Register offsets */ |
|---|
| 153 | 150 | #define ICDR 0x00 |
|---|
| .. | .. |
|---|
| 271 | 268 | |
|---|
| 272 | 269 | i2c_clk_khz = clk_get_rate(pd->clk) / 1000 / pd->clks_per_count; |
|---|
| 273 | 270 | |
|---|
| 274 | | - if (pd->bus_speed == STANDARD_MODE) { |
|---|
| 271 | + if (pd->bus_speed == I2C_MAX_STANDARD_MODE_FREQ) { |
|---|
| 275 | 272 | tLOW = 47; /* tLOW = 4.7 us */ |
|---|
| 276 | 273 | tHIGH = 40; /* tHD;STA = tHIGH = 4.0 us */ |
|---|
| 277 | 274 | tf = 3; /* tf = 0.3 us */ |
|---|
| 278 | | - } else if (pd->bus_speed == FAST_MODE) { |
|---|
| 275 | + } else if (pd->bus_speed == I2C_MAX_FAST_MODE_FREQ) { |
|---|
| 279 | 276 | tLOW = 13; /* tLOW = 1.3 us */ |
|---|
| 280 | 277 | tHIGH = 6; /* tHD;STA = tHIGH = 0.6 us */ |
|---|
| 281 | 278 | tf = 3; /* tf = 0.3 us */ |
|---|
| .. | .. |
|---|
| 303 | 300 | return sh_mobile_i2c_check_timing(pd); |
|---|
| 304 | 301 | } |
|---|
| 305 | 302 | |
|---|
| 306 | | -static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, |
|---|
| 307 | | - enum sh_mobile_i2c_op op, unsigned char data) |
|---|
| 303 | +static unsigned char i2c_op(struct sh_mobile_i2c_data *pd, enum sh_mobile_i2c_op op) |
|---|
| 308 | 304 | { |
|---|
| 309 | 305 | unsigned char ret = 0; |
|---|
| 310 | 306 | unsigned long flags; |
|---|
| 311 | 307 | |
|---|
| 312 | | - dev_dbg(pd->dev, "op %d, data in 0x%02x\n", op, data); |
|---|
| 308 | + dev_dbg(pd->dev, "op %d\n", op); |
|---|
| 313 | 309 | |
|---|
| 314 | 310 | spin_lock_irqsave(&pd->lock, flags); |
|---|
| 315 | 311 | |
|---|
| .. | .. |
|---|
| 317 | 313 | case OP_START: /* issue start and trigger DTE interrupt */ |
|---|
| 318 | 314 | iic_wr(pd, ICCR, ICCR_ICE | ICCR_TRS | ICCR_BBSY); |
|---|
| 319 | 315 | break; |
|---|
| 320 | | - case OP_TX_FIRST: /* disable DTE interrupt and write data */ |
|---|
| 316 | + case OP_TX_FIRST: /* disable DTE interrupt and write client address */ |
|---|
| 321 | 317 | iic_wr(pd, ICIC, ICIC_WAITE | ICIC_ALE | ICIC_TACKE); |
|---|
| 322 | | - iic_wr(pd, ICDR, data); |
|---|
| 318 | + iic_wr(pd, ICDR, i2c_8bit_addr_from_msg(pd->msg)); |
|---|
| 323 | 319 | break; |
|---|
| 324 | 320 | case OP_TX: /* write data */ |
|---|
| 325 | | - iic_wr(pd, ICDR, data); |
|---|
| 321 | + iic_wr(pd, ICDR, pd->msg->buf[pd->pos]); |
|---|
| 326 | 322 | break; |
|---|
| 327 | 323 | case OP_TX_STOP: /* issue a stop (or rep_start) */ |
|---|
| 328 | 324 | iic_wr(pd, ICCR, pd->send_stop ? ICCR_ICE | ICCR_TRS |
|---|
| .. | .. |
|---|
| 335 | 331 | ret = iic_rd(pd, ICDR); |
|---|
| 336 | 332 | break; |
|---|
| 337 | 333 | case OP_RX_STOP: /* enable DTE interrupt, issue stop */ |
|---|
| 338 | | - iic_wr(pd, ICIC, |
|---|
| 339 | | - ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE); |
|---|
| 334 | + if (!pd->atomic_xfer) |
|---|
| 335 | + iic_wr(pd, ICIC, |
|---|
| 336 | + ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE); |
|---|
| 340 | 337 | iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK); |
|---|
| 341 | 338 | break; |
|---|
| 342 | 339 | case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */ |
|---|
| 343 | | - iic_wr(pd, ICIC, |
|---|
| 344 | | - ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE); |
|---|
| 340 | + if (!pd->atomic_xfer) |
|---|
| 341 | + iic_wr(pd, ICIC, |
|---|
| 342 | + ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE); |
|---|
| 345 | 343 | ret = iic_rd(pd, ICDR); |
|---|
| 346 | 344 | iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK); |
|---|
| 347 | 345 | break; |
|---|
| .. | .. |
|---|
| 353 | 351 | return ret; |
|---|
| 354 | 352 | } |
|---|
| 355 | 353 | |
|---|
| 356 | | -static bool sh_mobile_i2c_is_first_byte(struct sh_mobile_i2c_data *pd) |
|---|
| 357 | | -{ |
|---|
| 358 | | - return pd->pos == -1; |
|---|
| 359 | | -} |
|---|
| 360 | | - |
|---|
| 361 | | -static void sh_mobile_i2c_get_data(struct sh_mobile_i2c_data *pd, |
|---|
| 362 | | - unsigned char *buf) |
|---|
| 363 | | -{ |
|---|
| 364 | | - switch (pd->pos) { |
|---|
| 365 | | - case -1: |
|---|
| 366 | | - *buf = i2c_8bit_addr_from_msg(pd->msg); |
|---|
| 367 | | - break; |
|---|
| 368 | | - default: |
|---|
| 369 | | - *buf = pd->msg->buf[pd->pos]; |
|---|
| 370 | | - } |
|---|
| 371 | | -} |
|---|
| 372 | | - |
|---|
| 373 | 354 | static int sh_mobile_i2c_isr_tx(struct sh_mobile_i2c_data *pd) |
|---|
| 374 | 355 | { |
|---|
| 375 | | - unsigned char data; |
|---|
| 376 | | - |
|---|
| 377 | 356 | if (pd->pos == pd->msg->len) { |
|---|
| 378 | | - i2c_op(pd, OP_TX_STOP, 0); |
|---|
| 357 | + i2c_op(pd, OP_TX_STOP); |
|---|
| 379 | 358 | return 1; |
|---|
| 380 | 359 | } |
|---|
| 381 | 360 | |
|---|
| 382 | | - sh_mobile_i2c_get_data(pd, &data); |
|---|
| 383 | | - i2c_op(pd, sh_mobile_i2c_is_first_byte(pd) ? OP_TX_FIRST : OP_TX, data); |
|---|
| 361 | + if (pd->pos == -1) |
|---|
| 362 | + i2c_op(pd, OP_TX_FIRST); |
|---|
| 363 | + else |
|---|
| 364 | + i2c_op(pd, OP_TX); |
|---|
| 384 | 365 | |
|---|
| 385 | 366 | pd->pos++; |
|---|
| 386 | 367 | return 0; |
|---|
| .. | .. |
|---|
| 388 | 369 | |
|---|
| 389 | 370 | static int sh_mobile_i2c_isr_rx(struct sh_mobile_i2c_data *pd) |
|---|
| 390 | 371 | { |
|---|
| 391 | | - unsigned char data; |
|---|
| 392 | 372 | int real_pos; |
|---|
| 393 | 373 | |
|---|
| 394 | | - do { |
|---|
| 395 | | - if (pd->pos <= -1) { |
|---|
| 396 | | - sh_mobile_i2c_get_data(pd, &data); |
|---|
| 374 | + /* switch from TX (address) to RX (data) adds two interrupts */ |
|---|
| 375 | + real_pos = pd->pos - 2; |
|---|
| 397 | 376 | |
|---|
| 398 | | - if (sh_mobile_i2c_is_first_byte(pd)) |
|---|
| 399 | | - i2c_op(pd, OP_TX_FIRST, data); |
|---|
| 400 | | - else |
|---|
| 401 | | - i2c_op(pd, OP_TX, data); |
|---|
| 402 | | - break; |
|---|
| 377 | + if (pd->pos == -1) { |
|---|
| 378 | + i2c_op(pd, OP_TX_FIRST); |
|---|
| 379 | + } else if (pd->pos == 0) { |
|---|
| 380 | + i2c_op(pd, OP_TX_TO_RX); |
|---|
| 381 | + } else if (pd->pos == pd->msg->len) { |
|---|
| 382 | + if (pd->stop_after_dma) { |
|---|
| 383 | + /* Simulate PIO end condition after DMA transfer */ |
|---|
| 384 | + i2c_op(pd, OP_RX_STOP); |
|---|
| 385 | + pd->pos++; |
|---|
| 386 | + goto done; |
|---|
| 403 | 387 | } |
|---|
| 404 | 388 | |
|---|
| 405 | | - if (pd->pos == 0) { |
|---|
| 406 | | - i2c_op(pd, OP_TX_TO_RX, 0); |
|---|
| 407 | | - break; |
|---|
| 408 | | - } |
|---|
| 389 | + if (real_pos < 0) |
|---|
| 390 | + i2c_op(pd, OP_RX_STOP); |
|---|
| 391 | + else |
|---|
| 392 | + pd->msg->buf[real_pos] = i2c_op(pd, OP_RX_STOP_DATA); |
|---|
| 393 | + } else if (real_pos >= 0) { |
|---|
| 394 | + pd->msg->buf[real_pos] = i2c_op(pd, OP_RX); |
|---|
| 395 | + } |
|---|
| 409 | 396 | |
|---|
| 410 | | - real_pos = pd->pos - 2; |
|---|
| 411 | | - |
|---|
| 412 | | - if (pd->pos == pd->msg->len) { |
|---|
| 413 | | - if (pd->stop_after_dma) { |
|---|
| 414 | | - /* Simulate PIO end condition after DMA transfer */ |
|---|
| 415 | | - i2c_op(pd, OP_RX_STOP, 0); |
|---|
| 416 | | - pd->pos++; |
|---|
| 417 | | - break; |
|---|
| 418 | | - } |
|---|
| 419 | | - |
|---|
| 420 | | - if (real_pos < 0) { |
|---|
| 421 | | - i2c_op(pd, OP_RX_STOP, 0); |
|---|
| 422 | | - break; |
|---|
| 423 | | - } |
|---|
| 424 | | - data = i2c_op(pd, OP_RX_STOP_DATA, 0); |
|---|
| 425 | | - } else if (real_pos >= 0) { |
|---|
| 426 | | - data = i2c_op(pd, OP_RX, 0); |
|---|
| 427 | | - } |
|---|
| 428 | | - |
|---|
| 429 | | - if (real_pos >= 0) |
|---|
| 430 | | - pd->msg->buf[real_pos] = data; |
|---|
| 431 | | - } while (0); |
|---|
| 432 | | - |
|---|
| 397 | + done: |
|---|
| 433 | 398 | pd->pos++; |
|---|
| 434 | 399 | return pd->pos == (pd->msg->len + 2); |
|---|
| 435 | 400 | } |
|---|
| .. | .. |
|---|
| 467 | 432 | |
|---|
| 468 | 433 | if (wakeup) { |
|---|
| 469 | 434 | pd->sr |= SW_DONE; |
|---|
| 470 | | - wake_up(&pd->wait); |
|---|
| 435 | + if (!pd->atomic_xfer) |
|---|
| 436 | + wake_up(&pd->wait); |
|---|
| 471 | 437 | } |
|---|
| 472 | 438 | |
|---|
| 473 | 439 | /* defeat write posting to avoid spurious WAIT interrupts */ |
|---|
| .. | .. |
|---|
| 518 | 484 | char *chan_name = dir == DMA_MEM_TO_DEV ? "tx" : "rx"; |
|---|
| 519 | 485 | int ret; |
|---|
| 520 | 486 | |
|---|
| 521 | | - chan = dma_request_slave_channel_reason(dev, chan_name); |
|---|
| 487 | + chan = dma_request_chan(dev, chan_name); |
|---|
| 522 | 488 | if (IS_ERR(chan)) { |
|---|
| 523 | 489 | dev_dbg(dev, "request_channel failed for %s (%ld)\n", chan_name, |
|---|
| 524 | 490 | PTR_ERR(chan)); |
|---|
| .. | .. |
|---|
| 619 | 585 | pd->pos = -1; |
|---|
| 620 | 586 | pd->sr = 0; |
|---|
| 621 | 587 | |
|---|
| 588 | + if (pd->atomic_xfer) |
|---|
| 589 | + return; |
|---|
| 590 | + |
|---|
| 622 | 591 | pd->dma_buf = i2c_get_dma_safe_msg_buf(pd->msg, 8); |
|---|
| 623 | 592 | if (pd->dma_buf) |
|---|
| 624 | 593 | sh_mobile_i2c_xfer_dma(pd); |
|---|
| .. | .. |
|---|
| 675 | 644 | return i ? 0 : -ETIMEDOUT; |
|---|
| 676 | 645 | } |
|---|
| 677 | 646 | |
|---|
| 678 | | -static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, |
|---|
| 679 | | - struct i2c_msg *msgs, |
|---|
| 680 | | - int num) |
|---|
| 647 | +static int sh_mobile_xfer(struct sh_mobile_i2c_data *pd, |
|---|
| 648 | + struct i2c_msg *msgs, int num) |
|---|
| 681 | 649 | { |
|---|
| 682 | | - struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter); |
|---|
| 683 | 650 | struct i2c_msg *msg; |
|---|
| 684 | 651 | int err = 0; |
|---|
| 685 | 652 | int i; |
|---|
| 686 | | - long timeout; |
|---|
| 653 | + long time_left; |
|---|
| 687 | 654 | |
|---|
| 688 | 655 | /* Wake up device and enable clock */ |
|---|
| 689 | 656 | pm_runtime_get_sync(pd->dev); |
|---|
| .. | .. |
|---|
| 698 | 665 | start_ch(pd, msg, do_start); |
|---|
| 699 | 666 | |
|---|
| 700 | 667 | if (do_start) |
|---|
| 701 | | - i2c_op(pd, OP_START, 0); |
|---|
| 668 | + i2c_op(pd, OP_START); |
|---|
| 702 | 669 | |
|---|
| 703 | | - /* The interrupt handler takes care of the rest... */ |
|---|
| 704 | | - timeout = wait_event_timeout(pd->wait, |
|---|
| 705 | | - pd->sr & (ICSR_TACK | SW_DONE), |
|---|
| 706 | | - adapter->timeout); |
|---|
| 670 | + if (pd->atomic_xfer) { |
|---|
| 671 | + unsigned long j = jiffies + pd->adap.timeout; |
|---|
| 707 | 672 | |
|---|
| 708 | | - /* 'stop_after_dma' tells if DMA transfer was complete */ |
|---|
| 709 | | - i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, pd->stop_after_dma); |
|---|
| 673 | + time_left = time_before_eq(jiffies, j); |
|---|
| 674 | + while (time_left && |
|---|
| 675 | + !(pd->sr & (ICSR_TACK | SW_DONE))) { |
|---|
| 676 | + unsigned char sr = iic_rd(pd, ICSR); |
|---|
| 710 | 677 | |
|---|
| 711 | | - if (!timeout) { |
|---|
| 678 | + if (sr & (ICSR_AL | ICSR_TACK | |
|---|
| 679 | + ICSR_WAIT | ICSR_DTE)) { |
|---|
| 680 | + sh_mobile_i2c_isr(0, pd); |
|---|
| 681 | + udelay(150); |
|---|
| 682 | + } else { |
|---|
| 683 | + cpu_relax(); |
|---|
| 684 | + } |
|---|
| 685 | + time_left = time_before_eq(jiffies, j); |
|---|
| 686 | + } |
|---|
| 687 | + } else { |
|---|
| 688 | + /* The interrupt handler takes care of the rest... */ |
|---|
| 689 | + time_left = wait_event_timeout(pd->wait, |
|---|
| 690 | + pd->sr & (ICSR_TACK | SW_DONE), |
|---|
| 691 | + pd->adap.timeout); |
|---|
| 692 | + |
|---|
| 693 | + /* 'stop_after_dma' tells if DMA xfer was complete */ |
|---|
| 694 | + i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, |
|---|
| 695 | + pd->stop_after_dma); |
|---|
| 696 | + } |
|---|
| 697 | + |
|---|
| 698 | + if (!time_left) { |
|---|
| 712 | 699 | dev_err(pd->dev, "Transfer request timed out\n"); |
|---|
| 713 | 700 | if (pd->dma_direction != DMA_NONE) |
|---|
| 714 | 701 | sh_mobile_i2c_cleanup_dma(pd); |
|---|
| .. | .. |
|---|
| 734 | 721 | return err ?: num; |
|---|
| 735 | 722 | } |
|---|
| 736 | 723 | |
|---|
| 724 | +static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter, |
|---|
| 725 | + struct i2c_msg *msgs, |
|---|
| 726 | + int num) |
|---|
| 727 | +{ |
|---|
| 728 | + struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter); |
|---|
| 729 | + |
|---|
| 730 | + pd->atomic_xfer = false; |
|---|
| 731 | + return sh_mobile_xfer(pd, msgs, num); |
|---|
| 732 | +} |
|---|
| 733 | + |
|---|
| 734 | +static int sh_mobile_i2c_xfer_atomic(struct i2c_adapter *adapter, |
|---|
| 735 | + struct i2c_msg *msgs, |
|---|
| 736 | + int num) |
|---|
| 737 | +{ |
|---|
| 738 | + struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter); |
|---|
| 739 | + |
|---|
| 740 | + pd->atomic_xfer = true; |
|---|
| 741 | + return sh_mobile_xfer(pd, msgs, num); |
|---|
| 742 | +} |
|---|
| 743 | + |
|---|
| 737 | 744 | static u32 sh_mobile_i2c_func(struct i2c_adapter *adapter) |
|---|
| 738 | 745 | { |
|---|
| 739 | 746 | return I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | I2C_FUNC_PROTOCOL_MANGLING; |
|---|
| 740 | 747 | } |
|---|
| 741 | 748 | |
|---|
| 742 | 749 | static const struct i2c_algorithm sh_mobile_i2c_algorithm = { |
|---|
| 743 | | - .functionality = sh_mobile_i2c_func, |
|---|
| 744 | | - .master_xfer = sh_mobile_i2c_xfer, |
|---|
| 750 | + .functionality = sh_mobile_i2c_func, |
|---|
| 751 | + .master_xfer = sh_mobile_i2c_xfer, |
|---|
| 752 | + .master_xfer_atomic = sh_mobile_i2c_xfer_atomic, |
|---|
| 745 | 753 | }; |
|---|
| 746 | 754 | |
|---|
| 747 | 755 | static const struct i2c_adapter_quirks sh_mobile_i2c_quirks = { |
|---|
| .. | .. |
|---|
| 749 | 757 | }; |
|---|
| 750 | 758 | |
|---|
| 751 | 759 | /* |
|---|
| 752 | | - * r8a7740 chip has lasting errata on I2C I/O pad reset. |
|---|
| 753 | | - * this is work-around for it. |
|---|
| 760 | + * r8a7740 has an errata regarding I2C I/O pad reset needing this workaround. |
|---|
| 754 | 761 | */ |
|---|
| 755 | 762 | static int sh_mobile_i2c_r8a7740_workaround(struct sh_mobile_i2c_data *pd) |
|---|
| 756 | 763 | { |
|---|
| .. | .. |
|---|
| 800 | 807 | static const struct of_device_id sh_mobile_i2c_dt_ids[] = { |
|---|
| 801 | 808 | { .compatible = "renesas,iic-r8a73a4", .data = &fast_clock_dt_config }, |
|---|
| 802 | 809 | { .compatible = "renesas,iic-r8a7740", .data = &r8a7740_dt_config }, |
|---|
| 803 | | - { .compatible = "renesas,iic-r8a774c0", .data = &fast_clock_dt_config }, |
|---|
| 810 | + { .compatible = "renesas,iic-r8a774c0", .data = &v2_freq_calc_dt_config }, |
|---|
| 804 | 811 | { .compatible = "renesas,iic-r8a7790", .data = &v2_freq_calc_dt_config }, |
|---|
| 805 | | - { .compatible = "renesas,iic-r8a7791", .data = &fast_clock_dt_config }, |
|---|
| 806 | | - { .compatible = "renesas,iic-r8a7792", .data = &fast_clock_dt_config }, |
|---|
| 807 | | - { .compatible = "renesas,iic-r8a7793", .data = &fast_clock_dt_config }, |
|---|
| 808 | | - { .compatible = "renesas,iic-r8a7794", .data = &fast_clock_dt_config }, |
|---|
| 809 | | - { .compatible = "renesas,rcar-gen2-iic", .data = &fast_clock_dt_config }, |
|---|
| 810 | | - { .compatible = "renesas,iic-r8a7795", .data = &fast_clock_dt_config }, |
|---|
| 811 | | - { .compatible = "renesas,rcar-gen3-iic", .data = &fast_clock_dt_config }, |
|---|
| 812 | | - { .compatible = "renesas,iic-r8a77990", .data = &fast_clock_dt_config }, |
|---|
| 812 | + { .compatible = "renesas,iic-r8a7791", .data = &v2_freq_calc_dt_config }, |
|---|
| 813 | + { .compatible = "renesas,iic-r8a7792", .data = &v2_freq_calc_dt_config }, |
|---|
| 814 | + { .compatible = "renesas,iic-r8a7793", .data = &v2_freq_calc_dt_config }, |
|---|
| 815 | + { .compatible = "renesas,iic-r8a7794", .data = &v2_freq_calc_dt_config }, |
|---|
| 816 | + { .compatible = "renesas,iic-r8a7795", .data = &v2_freq_calc_dt_config }, |
|---|
| 817 | + { .compatible = "renesas,iic-r8a77990", .data = &v2_freq_calc_dt_config }, |
|---|
| 813 | 818 | { .compatible = "renesas,iic-sh73a0", .data = &fast_clock_dt_config }, |
|---|
| 819 | + { .compatible = "renesas,rcar-gen2-iic", .data = &v2_freq_calc_dt_config }, |
|---|
| 820 | + { .compatible = "renesas,rcar-gen3-iic", .data = &v2_freq_calc_dt_config }, |
|---|
| 814 | 821 | { .compatible = "renesas,rmobile-iic", .data = &default_dt_config }, |
|---|
| 815 | 822 | {}, |
|---|
| 816 | 823 | }; |
|---|
| .. | .. |
|---|
| 884 | 891 | return PTR_ERR(pd->reg); |
|---|
| 885 | 892 | |
|---|
| 886 | 893 | ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed); |
|---|
| 887 | | - pd->bus_speed = (ret || !bus_speed) ? STANDARD_MODE : bus_speed; |
|---|
| 894 | + pd->bus_speed = (ret || !bus_speed) ? I2C_MAX_STANDARD_MODE_FREQ : bus_speed; |
|---|
| 888 | 895 | pd->clks_per_count = 1; |
|---|
| 889 | 896 | |
|---|
| 890 | 897 | /* Newer variants come with two new bits in ICIC */ |
|---|
| .. | .. |
|---|
| 949 | 956 | return 0; |
|---|
| 950 | 957 | } |
|---|
| 951 | 958 | |
|---|
| 952 | | -static int sh_mobile_i2c_runtime_nop(struct device *dev) |
|---|
| 953 | | -{ |
|---|
| 954 | | - /* Runtime PM callback shared between ->runtime_suspend() |
|---|
| 955 | | - * and ->runtime_resume(). Simply returns success. |
|---|
| 956 | | - * |
|---|
| 957 | | - * This driver re-initializes all registers after |
|---|
| 958 | | - * pm_runtime_get_sync() anyway so there is no need |
|---|
| 959 | | - * to save and restore registers here. |
|---|
| 960 | | - */ |
|---|
| 961 | | - return 0; |
|---|
| 962 | | -} |
|---|
| 963 | | - |
|---|
| 964 | | -static const struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = { |
|---|
| 965 | | - .runtime_suspend = sh_mobile_i2c_runtime_nop, |
|---|
| 966 | | - .runtime_resume = sh_mobile_i2c_runtime_nop, |
|---|
| 967 | | -}; |
|---|
| 968 | | - |
|---|
| 969 | 959 | static struct platform_driver sh_mobile_i2c_driver = { |
|---|
| 970 | 960 | .driver = { |
|---|
| 971 | 961 | .name = "i2c-sh_mobile", |
|---|
| 972 | | - .pm = &sh_mobile_i2c_dev_pm_ops, |
|---|
| 973 | 962 | .of_match_table = sh_mobile_i2c_dt_ids, |
|---|
| 974 | 963 | }, |
|---|
| 975 | 964 | .probe = sh_mobile_i2c_probe, |
|---|
| .. | .. |
|---|
| 989 | 978 | module_exit(sh_mobile_i2c_adap_exit); |
|---|
| 990 | 979 | |
|---|
| 991 | 980 | MODULE_DESCRIPTION("SuperH Mobile I2C Bus Controller driver"); |
|---|
| 992 | | -MODULE_AUTHOR("Magnus Damm and Wolfram Sang"); |
|---|
| 981 | +MODULE_AUTHOR("Magnus Damm"); |
|---|
| 982 | +MODULE_AUTHOR("Wolfram Sang"); |
|---|
| 993 | 983 | MODULE_LICENSE("GPL v2"); |
|---|
| 994 | 984 | MODULE_ALIAS("platform:i2c-sh_mobile"); |
|---|