443 EC_CONFIG_ERR(sc, "Invalid sync manager index %u!\n", sync_index); |
443 EC_CONFIG_ERR(sc, "Invalid sync manager index %u!\n", sync_index); |
444 return -ENOENT; |
444 return -ENOENT; |
445 } |
445 } |
446 |
446 |
447 if (dir != EC_DIR_OUTPUT && dir != EC_DIR_INPUT) { |
447 if (dir != EC_DIR_OUTPUT && dir != EC_DIR_INPUT) { |
448 EC_CONFIG_ERR(sc, "Invalid direction %u!\n", (u32) dir); |
448 EC_CONFIG_ERR(sc, "Invalid direction %u!\n", (unsigned int) dir); |
449 return -EINVAL; |
449 return -EINVAL; |
450 } |
450 } |
451 |
451 |
452 sync_config = &sc->sync_configs[sync_index]; |
452 sync_config = &sc->sync_configs[sync_index]; |
453 sync_config->dir = dir; |
453 sync_config->dir = dir; |
714 |
714 |
715 void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate, |
715 void ecrt_slave_config_dc(ec_slave_config_t *sc, uint16_t assign_activate, |
716 uint32_t sync0_cycle_time, uint32_t sync0_shift_time, |
716 uint32_t sync0_cycle_time, uint32_t sync0_shift_time, |
717 uint32_t sync1_cycle_time, uint32_t sync1_shift_time) |
717 uint32_t sync1_cycle_time, uint32_t sync1_shift_time) |
718 { |
718 { |
|
719 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, assign_activate = 0x%04X," |
|
720 " sync0_cycle = %u, sync0_shift = %u," |
|
721 " sync1_cycle = %u, sync1_shift = %u\n", |
|
722 __func__, sc, assign_activate, sync0_cycle_time, sync0_shift_time, |
|
723 sync1_cycle_time, sync1_shift_time); |
|
724 |
719 sc->dc_assign_activate = assign_activate; |
725 sc->dc_assign_activate = assign_activate; |
720 sc->dc_sync[0].cycle_time = sync0_cycle_time; |
726 sc->dc_sync[0].cycle_time = sync0_cycle_time; |
721 sc->dc_sync[0].shift_time = sync0_shift_time; |
727 sc->dc_sync[0].shift_time = sync0_shift_time; |
722 sc->dc_sync[1].cycle_time = sync1_cycle_time; |
728 sc->dc_sync[1].cycle_time = sync1_cycle_time; |
723 sc->dc_sync[1].shift_time = sync1_shift_time; |
729 sc->dc_sync[1].shift_time = sync1_shift_time; |
770 { |
776 { |
771 uint8_t data[1]; |
777 uint8_t data[1]; |
772 |
778 |
773 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, " |
779 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, index = 0x%04X, " |
774 "subindex = 0x%02X, value = %u)\n", |
780 "subindex = 0x%02X, value = %u)\n", |
775 __func__, sc, index, subindex, (u32) value); |
781 __func__, sc, index, subindex, (unsigned int) value); |
776 |
782 |
777 EC_WRITE_U8(data, value); |
783 EC_WRITE_U8(data, value); |
778 return ecrt_slave_config_sdo(sc, index, subindex, data, 1); |
784 return ecrt_slave_config_sdo(sc, index, subindex, data, 1); |
779 } |
785 } |
780 |
786 |
959 } |
965 } |
960 } |
966 } |
961 |
967 |
962 /*****************************************************************************/ |
968 /*****************************************************************************/ |
963 |
969 |
964 int ecrt_slave_config_idn(ec_slave_config_t *sc, uint16_t idn, |
970 int ecrt_slave_config_idn(ec_slave_config_t *sc, uint8_t drive_no, |
965 const uint8_t *data, size_t size) |
971 uint16_t idn, ec_al_state_t state, const uint8_t *data, |
|
972 size_t size) |
966 { |
973 { |
967 ec_slave_t *slave = sc->slave; |
974 ec_slave_t *slave = sc->slave; |
968 ec_soe_request_t *req; |
975 ec_soe_request_t *req; |
969 int ret; |
976 int ret; |
970 |
977 |
971 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, idn = 0x%04X, " |
978 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, drive_no = %u, idn = 0x%04X, " |
972 "data = 0x%p, size = %zu)\n", __func__, sc, idn, data, size); |
979 "state = %u, data = 0x%p, size = %zu)\n", |
|
980 __func__, sc, drive_no, idn, state, data, size); |
|
981 |
|
982 if (drive_no > 7) { |
|
983 EC_CONFIG_ERR(sc, "Invalid drive number!\n"); |
|
984 return -EINVAL; |
|
985 } |
|
986 |
|
987 if (state != EC_AL_STATE_PREOP && state != EC_AL_STATE_SAFEOP) { |
|
988 EC_CONFIG_ERR(sc, "AL state for IDN config" |
|
989 " must be PREOP or SAFEOP!\n"); |
|
990 return -EINVAL; |
|
991 } |
973 |
992 |
974 if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_SOE)) { |
993 if (slave && !(slave->sii.mailbox_protocols & EC_MBOX_SOE)) { |
975 EC_CONFIG_WARN(sc, "Attached slave does not support SoE!\n"); |
994 EC_CONFIG_WARN(sc, "Attached slave does not support SoE!\n"); |
976 } |
995 } |
977 |
996 |
981 " IDN configuration!\n"); |
1000 " IDN configuration!\n"); |
982 return -ENOMEM; |
1001 return -ENOMEM; |
983 } |
1002 } |
984 |
1003 |
985 ec_soe_request_init(req); |
1004 ec_soe_request_init(req); |
|
1005 ec_soe_request_set_drive_no(req, drive_no); |
986 ec_soe_request_set_idn(req, idn); |
1006 ec_soe_request_set_idn(req, idn); |
|
1007 req->al_state = state; |
987 |
1008 |
988 ret = ec_soe_request_copy_data(req, data, size); |
1009 ret = ec_soe_request_copy_data(req, data, size); |
989 if (ret < 0) { |
1010 if (ret < 0) { |
990 ec_soe_request_clear(req); |
1011 ec_soe_request_clear(req); |
991 kfree(req); |
1012 kfree(req); |