.. | .. |
---|
121 | 121 | |
---|
122 | 122 | #define FUNCTION_DESC_GPIO_OUTPUT_A(id) \ |
---|
123 | 123 | { \ |
---|
124 | | - .name = "DES_GPIO"#id"_OUTPUT_A", \ |
---|
| 124 | + .name = "SER_TXID"#id"_TO_DES_LINKA", \ |
---|
125 | 125 | .group_names = serdes_gpio_groups, \ |
---|
126 | 126 | .num_group_names = ARRAY_SIZE(serdes_gpio_groups), \ |
---|
127 | 127 | .data = (void *)(const struct serdes_function_data []) { \ |
---|
.. | .. |
---|
132 | 132 | |
---|
133 | 133 | #define FUNCTION_DESC_GPIO_OUTPUT_B(id) \ |
---|
134 | 134 | { \ |
---|
135 | | - .name = "DES_GPIO"#id"_OUTPUT_B", \ |
---|
| 135 | + .name = "SER_TXID"#id"_TO_DES_LINKB", \ |
---|
136 | 136 | .group_names = serdes_gpio_groups, \ |
---|
137 | 137 | .num_group_names = ARRAY_SIZE(serdes_gpio_groups), \ |
---|
138 | 138 | .data = (void *)(const struct serdes_function_data []) { \ |
---|
.. | .. |
---|
143 | 143 | |
---|
144 | 144 | #define FUNCTION_DESC_GPIO_INPUT_A(id) \ |
---|
145 | 145 | { \ |
---|
146 | | - .name = "DES_GPIO"#id"_INPUT_A", \ |
---|
| 146 | + .name = "DES_RXID"#id"_TO_SER_LINKA", \ |
---|
147 | 147 | .group_names = serdes_gpio_groups, \ |
---|
148 | 148 | .num_group_names = ARRAY_SIZE(serdes_gpio_groups), \ |
---|
149 | 149 | .data = (void *)(const struct serdes_function_data []) { \ |
---|
.. | .. |
---|
153 | 153 | |
---|
154 | 154 | #define FUNCTION_DESC_GPIO_INPUT_B(id) \ |
---|
155 | 155 | { \ |
---|
156 | | - .name = "DES_GPIO"#id"_INPUT_B", \ |
---|
| 156 | + .name = "DES_RXID"#id"_TO_SER_LINKB", \ |
---|
157 | 157 | .group_names = serdes_gpio_groups, \ |
---|
158 | 158 | .num_group_names = ARRAY_SIZE(serdes_gpio_groups), \ |
---|
159 | 159 | .data = (void *)(const struct serdes_function_data []) { \ |
---|
.. | .. |
---|
377 | 377 | static bool max96745_vid_tx_active(struct serdes *serdes) |
---|
378 | 378 | { |
---|
379 | 379 | u32 val; |
---|
| 380 | + int i = 0, ret = 0; |
---|
380 | 381 | |
---|
381 | | - if (serdes_reg_read(serdes, 0x0107, &val)) |
---|
382 | | - return false; |
---|
| 382 | + for (i = 0; i < 5; i++) { |
---|
| 383 | + ret = serdes_reg_read(serdes, 0x0107, &val); |
---|
| 384 | + if (!ret) |
---|
| 385 | + break; |
---|
383 | 386 | |
---|
384 | | - if (!FIELD_GET(VID_TX_ACTIVE_A | VID_TX_ACTIVE_B, val)) |
---|
| 387 | + SERDES_DBG_CHIP("serdes %s: false val=%d i=%d ret=%d\n", __func__, val, i, ret); |
---|
| 388 | + msleep(20); |
---|
| 389 | + } |
---|
| 390 | + |
---|
| 391 | + if (ret) { |
---|
| 392 | + SERDES_DBG_CHIP("serdes %s: false val=%d ret=%d\n", __func__, val, ret); |
---|
385 | 393 | return false; |
---|
| 394 | + } |
---|
| 395 | + |
---|
| 396 | + if (!FIELD_GET(VID_TX_ACTIVE_A | VID_TX_ACTIVE_B, val)) { |
---|
| 397 | + SERDES_DBG_CHIP("serdes %s: false val=%d\n", __func__, val); |
---|
| 398 | + return false; |
---|
| 399 | + } |
---|
386 | 400 | |
---|
387 | 401 | return true; |
---|
388 | 402 | } |
---|
.. | .. |
---|
391 | 405 | { |
---|
392 | 406 | if (max96745_vid_tx_active(serdes)) { |
---|
393 | 407 | extcon_set_state(serdes->extcon, EXTCON_JACK_VIDEO_OUT, true); |
---|
394 | | - pr_info("%s, extcon is true\n", __func__); |
---|
| 408 | + pr_info("serdes %s, extcon is true state=%d\n", __func__, serdes->extcon->state); |
---|
395 | 409 | } else { |
---|
396 | | - pr_info("%s, extcon is false\n", __func__); |
---|
| 410 | + pr_info("serdes %s, extcon is false\n", __func__); |
---|
397 | 411 | } |
---|
398 | 412 | |
---|
399 | 413 | return 0; |
---|
.. | .. |
---|
403 | 417 | { |
---|
404 | 418 | u32 val; |
---|
405 | 419 | |
---|
406 | | - if (serdes->lock_gpio) |
---|
407 | | - return gpiod_get_value_cansleep(serdes->lock_gpio); |
---|
| 420 | + if (serdes->lock_gpio) { |
---|
| 421 | + val = gpiod_get_value_cansleep(serdes->lock_gpio); |
---|
| 422 | + SERDES_DBG_CHIP("serdes %s:val=%d\n", __func__, val); |
---|
| 423 | + return val; |
---|
| 424 | + } |
---|
408 | 425 | |
---|
409 | | - if (serdes_reg_read(serdes, 0x002a, &val)) |
---|
| 426 | + if (serdes_reg_read(serdes, 0x002a, &val)) { |
---|
| 427 | + SERDES_DBG_CHIP("serdes %s: false val=%d\n", __func__, val); |
---|
410 | 428 | return false; |
---|
| 429 | + } |
---|
411 | 430 | |
---|
412 | | - if (!FIELD_GET(LINK_LOCKED, val)) |
---|
| 431 | + if (!FIELD_GET(LOCKED, val)) { |
---|
| 432 | + SERDES_DBG_CHIP("serdes %s: false val=%d\n", __func__, val); |
---|
413 | 433 | return false; |
---|
| 434 | + } |
---|
414 | 435 | |
---|
415 | 436 | return true; |
---|
416 | 437 | } |
---|
.. | .. |
---|
444 | 465 | |
---|
445 | 466 | if (atomic_cmpxchg(&serdes_bridge->triggered, 1, 0)) { |
---|
446 | 467 | status = connector_status_disconnected; |
---|
| 468 | + SERDES_DBG_CHIP("1 status=%d state=%d\n", status, serdes->extcon->state); |
---|
447 | 469 | goto out; |
---|
448 | 470 | } |
---|
449 | 471 | |
---|
450 | 472 | if (serdes_reg_read(serdes, 0x641a, &dprx_trn_status2)) { |
---|
451 | 473 | status = connector_status_disconnected; |
---|
| 474 | + SERDES_DBG_CHIP("2 status=%d state=%d\n", status, serdes->extcon->state); |
---|
452 | 475 | goto out; |
---|
453 | 476 | } |
---|
454 | 477 | |
---|
.. | .. |
---|
456 | 479 | dev_err(serdes->dev, "Training State: 0x%lx\n", |
---|
457 | 480 | FIELD_GET(DPRX_TRAIN_STATE, dprx_trn_status2)); |
---|
458 | 481 | status = connector_status_disconnected; |
---|
| 482 | + SERDES_DBG_CHIP("3 status=%d state=%d\n", status, serdes->extcon->state); |
---|
459 | 483 | goto out; |
---|
460 | 484 | } |
---|
461 | 485 | } else { |
---|
462 | 486 | atomic_set(&serdes_bridge->triggered, 0); |
---|
| 487 | + SERDES_DBG_CHIP("4 status=%d state=%d\n", status, serdes->extcon->state); |
---|
463 | 488 | } |
---|
| 489 | + |
---|
| 490 | + if (serdes_bridge->next_bridge && (serdes_bridge->next_bridge->ops & DRM_BRIDGE_OP_DETECT)) |
---|
| 491 | + return drm_bridge_detect(serdes_bridge->next_bridge); |
---|
464 | 492 | |
---|
465 | 493 | out: |
---|
466 | 494 | serdes_bridge->status = status; |
---|
467 | | - SERDES_DBG_MFD("%s: status=%d\n", __func__, status); |
---|
| 495 | + SERDES_DBG_CHIP("5 status=%d state=%d\n", status, serdes->extcon->state); |
---|
468 | 496 | return status; |
---|
469 | 497 | } |
---|
470 | 498 | |
---|
.. | .. |
---|
472 | 500 | { |
---|
473 | 501 | int ret = 0; |
---|
474 | 502 | |
---|
475 | | - SERDES_DBG_CHIP("%s: serdes chip %s ret=%d\n", __func__, serdes->chip_data->name, ret); |
---|
| 503 | + SERDES_DBG_CHIP("%s: serdes chip %s ret=%d state=%d\n", |
---|
| 504 | + __func__, serdes->chip_data->name, ret, serdes->extcon->state); |
---|
476 | 505 | return ret; |
---|
477 | 506 | } |
---|
478 | 507 | |
---|
.. | .. |
---|
490 | 519 | .enable = max96745_bridge_enable, |
---|
491 | 520 | .disable = max96745_bridge_disable, |
---|
492 | 521 | }; |
---|
| 522 | + |
---|
| 523 | +static int max96745_pinctrl_set_mux(struct serdes *serdes, |
---|
| 524 | + unsigned int function, unsigned int group) |
---|
| 525 | +{ |
---|
| 526 | + struct serdes_pinctrl *pinctrl = serdes->pinctrl; |
---|
| 527 | + struct function_desc *func; |
---|
| 528 | + struct group_desc *grp; |
---|
| 529 | + int i; |
---|
| 530 | + |
---|
| 531 | + func = pinmux_generic_get_function(pinctrl->pctl, function); |
---|
| 532 | + if (!func) |
---|
| 533 | + return -EINVAL; |
---|
| 534 | + |
---|
| 535 | + grp = pinctrl_generic_get_group(pinctrl->pctl, group); |
---|
| 536 | + if (!grp) |
---|
| 537 | + return -EINVAL; |
---|
| 538 | + |
---|
| 539 | + SERDES_DBG_CHIP("%s: serdes chip %s func=%s data=%p group=%s data=%p, num_pin=%d\n", |
---|
| 540 | + __func__, serdes->chip_data->name, |
---|
| 541 | + func->name, func->data, grp->name, grp->data, grp->num_pins); |
---|
| 542 | + |
---|
| 543 | + if (func->data) { |
---|
| 544 | + struct serdes_function_data *data = func->data; |
---|
| 545 | + |
---|
| 546 | + for (i = 0; i < grp->num_pins; i++) { |
---|
| 547 | + serdes_set_bits(serdes, |
---|
| 548 | + GPIO_A_REG(grp->pins[i] - pinctrl->pin_base), |
---|
| 549 | + GPIO_OUT_DIS, |
---|
| 550 | + FIELD_PREP(GPIO_OUT_DIS, data->gpio_out_dis)); |
---|
| 551 | + if (data->gpio_tx_en_a || data->gpio_tx_en_b) |
---|
| 552 | + serdes_set_bits(serdes, |
---|
| 553 | + GPIO_B_REG(grp->pins[i] - pinctrl->pin_base), |
---|
| 554 | + GPIO_TX_ID, |
---|
| 555 | + FIELD_PREP(GPIO_TX_ID, data->gpio_tx_id)); |
---|
| 556 | + if (data->gpio_rx_en_a || data->gpio_rx_en_b) |
---|
| 557 | + serdes_set_bits(serdes, |
---|
| 558 | + GPIO_C_REG(grp->pins[i] - pinctrl->pin_base), |
---|
| 559 | + GPIO_RX_ID, |
---|
| 560 | + FIELD_PREP(GPIO_RX_ID, data->gpio_rx_id)); |
---|
| 561 | + serdes_set_bits(serdes, |
---|
| 562 | + GPIO_D_REG(grp->pins[i] - pinctrl->pin_base), |
---|
| 563 | + GPIO_TX_EN_A | GPIO_TX_EN_B | GPIO_IO_RX_EN | |
---|
| 564 | + GPIO_RX_EN_A | GPIO_RX_EN_B, |
---|
| 565 | + FIELD_PREP(GPIO_TX_EN_A, data->gpio_tx_en_a) | |
---|
| 566 | + FIELD_PREP(GPIO_TX_EN_B, data->gpio_tx_en_b) | |
---|
| 567 | + FIELD_PREP(GPIO_RX_EN_A, data->gpio_rx_en_a) | |
---|
| 568 | + FIELD_PREP(GPIO_RX_EN_B, data->gpio_rx_en_b) | |
---|
| 569 | + FIELD_PREP(GPIO_IO_RX_EN, data->gpio_io_rx_en)); |
---|
| 570 | + } |
---|
| 571 | + } |
---|
| 572 | + |
---|
| 573 | + return 0; |
---|
| 574 | +} |
---|
493 | 575 | |
---|
494 | 576 | static int max96745_pinctrl_config_get(struct serdes *serdes, |
---|
495 | 577 | unsigned int pin, unsigned long *config) |
---|
.. | .. |
---|
635 | 717 | return 0; |
---|
636 | 718 | } |
---|
637 | 719 | |
---|
638 | | -static int max96745_pinctrl_set_mux(struct serdes *serdes, |
---|
639 | | - unsigned int function, unsigned int group) |
---|
640 | | -{ |
---|
641 | | - struct serdes_pinctrl *pinctrl = serdes->pinctrl; |
---|
642 | | - struct function_desc *func; |
---|
643 | | - struct group_desc *grp; |
---|
644 | | - int i; |
---|
645 | | - |
---|
646 | | - func = pinmux_generic_get_function(pinctrl->pctl, function); |
---|
647 | | - if (!func) |
---|
648 | | - return -EINVAL; |
---|
649 | | - |
---|
650 | | - grp = pinctrl_generic_get_group(pinctrl->pctl, group); |
---|
651 | | - if (!grp) |
---|
652 | | - return -EINVAL; |
---|
653 | | - |
---|
654 | | - SERDES_DBG_CHIP("%s: serdes chip %s func=%s data=%p group=%s data=%p, num_pin=%d\n", |
---|
655 | | - __func__, serdes->chip_data->name, |
---|
656 | | - func->name, func->data, grp->name, grp->data, grp->num_pins); |
---|
657 | | - |
---|
658 | | - if (func->data) { |
---|
659 | | - struct serdes_function_data *data = func->data; |
---|
660 | | - |
---|
661 | | - for (i = 0; i < grp->num_pins; i++) { |
---|
662 | | - serdes_set_bits(serdes, |
---|
663 | | - GPIO_A_REG(grp->pins[i] - pinctrl->pin_base), |
---|
664 | | - GPIO_OUT_DIS, |
---|
665 | | - FIELD_PREP(GPIO_OUT_DIS, data->gpio_out_dis)); |
---|
666 | | - if (data->gpio_tx_en_a || data->gpio_tx_en_b) |
---|
667 | | - serdes_set_bits(serdes, |
---|
668 | | - GPIO_B_REG(grp->pins[i] - pinctrl->pin_base), |
---|
669 | | - GPIO_TX_ID, |
---|
670 | | - FIELD_PREP(GPIO_TX_ID, data->gpio_tx_id)); |
---|
671 | | - if (data->gpio_rx_en_a || data->gpio_rx_en_b) |
---|
672 | | - serdes_set_bits(serdes, |
---|
673 | | - GPIO_C_REG(grp->pins[i] - pinctrl->pin_base), |
---|
674 | | - GPIO_RX_ID, |
---|
675 | | - FIELD_PREP(GPIO_RX_ID, data->gpio_rx_id)); |
---|
676 | | - serdes_set_bits(serdes, |
---|
677 | | - GPIO_D_REG(grp->pins[i] - pinctrl->pin_base), |
---|
678 | | - GPIO_TX_EN_A | GPIO_TX_EN_B | GPIO_IO_RX_EN | |
---|
679 | | - GPIO_RX_EN_A | GPIO_RX_EN_B, |
---|
680 | | - FIELD_PREP(GPIO_TX_EN_A, data->gpio_tx_en_a) | |
---|
681 | | - FIELD_PREP(GPIO_TX_EN_B, data->gpio_tx_en_b) | |
---|
682 | | - FIELD_PREP(GPIO_RX_EN_A, data->gpio_rx_en_a) | |
---|
683 | | - FIELD_PREP(GPIO_RX_EN_B, data->gpio_rx_en_b) | |
---|
684 | | - FIELD_PREP(GPIO_IO_RX_EN, data->gpio_io_rx_en)); |
---|
685 | | - } |
---|
686 | | - } |
---|
687 | | - |
---|
688 | | - return 0; |
---|
689 | | -} |
---|
690 | | - |
---|
691 | 720 | static struct serdes_chip_pinctrl_ops max96745_pinctrl_ops = { |
---|
692 | 721 | .pin_config_get = max96745_pinctrl_config_get, |
---|
693 | 722 | .pin_config_set = max96745_pinctrl_config_set, |
---|
.. | .. |
---|
733 | 762 | .to_irq = max96745_gpio_to_irq, |
---|
734 | 763 | }; |
---|
735 | 764 | |
---|
| 765 | +static int max96745_select(struct serdes *serdes, int chan) |
---|
| 766 | +{ |
---|
| 767 | + /*0076 for linkA and 0086 for linkB*/ |
---|
| 768 | + if (chan == DUAL_LINK) { |
---|
| 769 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 770 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 771 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 772 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 773 | + SERDES_DBG_CHIP("%s: enable %s remote i2c of linkA and linkB\n", __func__, |
---|
| 774 | + serdes->chip_data->name); |
---|
| 775 | + } else if (chan == LINKA) { |
---|
| 776 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 777 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 778 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 779 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 780 | + SERDES_DBG_CHIP("%s: only enable %s remote i2c of linkA\n", __func__, |
---|
| 781 | + serdes->chip_data->name); |
---|
| 782 | + } else if (chan == LINKB) { |
---|
| 783 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 784 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 785 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 786 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 787 | + SERDES_DBG_CHIP("%s: only enable %s remote i2c of linkB\n", __func__, |
---|
| 788 | + serdes->chip_data->name); |
---|
| 789 | + } else if (chan == SPLITTER_MODE) { |
---|
| 790 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 791 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 792 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 793 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 794 | + SERDES_DBG_CHIP("%s: enable %s remote i2c of linkA and linkB\n", __func__, |
---|
| 795 | + serdes->chip_data->name); |
---|
| 796 | + } |
---|
| 797 | + |
---|
| 798 | + return 0; |
---|
| 799 | +} |
---|
| 800 | + |
---|
| 801 | +static int max96745_deselect(struct serdes *serdes, int chan) |
---|
| 802 | +{ |
---|
| 803 | + |
---|
| 804 | + if (chan == DUAL_LINK) { |
---|
| 805 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 806 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 807 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 808 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 809 | + SERDES_DBG_CHIP("%s: disable %s remote i2c of linkA and linkB\n", __func__, |
---|
| 810 | + serdes->chip_data->name); |
---|
| 811 | + } else if (chan == LINKA) { |
---|
| 812 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 813 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 814 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 815 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 816 | + SERDES_DBG_CHIP("%s: only disable %s remote i2c of linkA\n", __func__, |
---|
| 817 | + serdes->chip_data->name); |
---|
| 818 | + } else if (chan == LINKB) { |
---|
| 819 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 820 | + FIELD_PREP(DIS_REM_CC, 0)); |
---|
| 821 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 822 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 823 | + SERDES_DBG_CHIP("%s: only disable %s remote i2c of linkB\n", __func__, |
---|
| 824 | + serdes->chip_data->name); |
---|
| 825 | + } else if (chan == SPLITTER_MODE) { |
---|
| 826 | + serdes_set_bits(serdes, 0x0076, DIS_REM_CC, |
---|
| 827 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 828 | + serdes_set_bits(serdes, 0x0086, DIS_REM_CC, |
---|
| 829 | + FIELD_PREP(DIS_REM_CC, 1)); |
---|
| 830 | + SERDES_DBG_CHIP("%s: disable %s remote i2c of linkA and linkB\n", __func__, |
---|
| 831 | + serdes->chip_data->name); |
---|
| 832 | + } |
---|
| 833 | + |
---|
| 834 | + return 0; |
---|
| 835 | +} |
---|
| 836 | + |
---|
| 837 | + |
---|
| 838 | +static struct serdes_chip_split_ops max96745_split_ops = { |
---|
| 839 | + .select = max96745_select, |
---|
| 840 | + .deselect = max96745_deselect, |
---|
| 841 | +}; |
---|
| 842 | + |
---|
736 | 843 | static int max96745_pm_suspend(struct serdes *serdes) |
---|
737 | 844 | { |
---|
738 | 845 | return 0; |
---|
.. | .. |
---|
773 | 880 | .bridge_ops = &max96745_bridge_ops, |
---|
774 | 881 | .pinctrl_ops = &max96745_pinctrl_ops, |
---|
775 | 882 | .gpio_ops = &max96745_gpio_ops, |
---|
| 883 | + .split_ops = &max96745_split_ops, |
---|
776 | 884 | .pm_ops = &max96745_pm_ops, |
---|
777 | 885 | .irq_ops = &max96745_irq_ops, |
---|
778 | 886 | }; |
---|