774 } |
774 } |
775 } |
775 } |
776 |
776 |
777 EC_CONFIG_ERR(sc, "PDO entry 0x%04X:%02X is not mapped.\n", |
777 EC_CONFIG_ERR(sc, "PDO entry 0x%04X:%02X is not mapped.\n", |
778 index, subindex); |
778 index, subindex); |
|
779 return -ENOENT; |
|
780 } |
|
781 |
|
782 /*****************************************************************************/ |
|
783 |
|
784 int ecrt_slave_config_reg_pdo_entry_pos( |
|
785 ec_slave_config_t *sc, |
|
786 uint8_t sync_index, |
|
787 unsigned int pdo_pos, |
|
788 unsigned int entry_pos, |
|
789 ec_domain_t *domain, |
|
790 unsigned int *bit_position |
|
791 ) |
|
792 { |
|
793 const ec_sync_config_t *sync_config; |
|
794 unsigned int bit_offset, pp, ep; |
|
795 ec_pdo_t *pdo; |
|
796 ec_pdo_entry_t *entry; |
|
797 |
|
798 EC_CONFIG_DBG(sc, 1, "%s(sc = 0x%p, sync_index = %u, pdo_pos = %u," |
|
799 " entry_pos = %u, domain = 0x%p, bit_position = 0x%p)\n", |
|
800 __func__, sc, sync_index, pdo_pos, entry_pos, |
|
801 domain, bit_position); |
|
802 |
|
803 if (sync_index >= EC_MAX_SYNC_MANAGERS) { |
|
804 EC_CONFIG_ERR(sc, "Invalid syncmanager position %u.\n", sync_index); |
|
805 return -EINVAL; |
|
806 } |
|
807 |
|
808 sync_config = &sc->sync_configs[sync_index]; |
|
809 bit_offset = 0; |
|
810 pp = 0; |
|
811 |
|
812 list_for_each_entry(pdo, &sync_config->pdos.list, list) { |
|
813 ep = 0; |
|
814 list_for_each_entry(entry, &pdo->entries, list) { |
|
815 if (pp != pdo_pos || ep != entry_pos) { |
|
816 bit_offset += entry->bit_length; |
|
817 } else { |
|
818 unsigned int bit_pos = bit_offset % 8; |
|
819 int sync_offset; |
|
820 |
|
821 if (bit_position) { |
|
822 *bit_position = bit_pos; |
|
823 } else if (bit_pos) { |
|
824 EC_CONFIG_ERR(sc, "PDO entry 0x%04X:%02X does" |
|
825 " not byte-align.\n", |
|
826 pdo->index, entry->subindex); |
|
827 return -EFAULT; |
|
828 } |
|
829 |
|
830 sync_offset = ec_slave_config_prepare_fmmu( |
|
831 sc, domain, sync_index, sync_config->dir); |
|
832 if (sync_offset < 0) |
|
833 return sync_offset; |
|
834 |
|
835 return sync_offset + bit_offset / 8; |
|
836 } |
|
837 ep++; |
|
838 } |
|
839 pp++; |
|
840 } |
|
841 |
|
842 EC_CONFIG_ERR(sc, "PDO entry specification %u/%u/%u out of range.\n", |
|
843 sync_index, pdo_pos, entry_pos); |
779 return -ENOENT; |
844 return -ENOENT; |
780 } |
845 } |
781 |
846 |
782 /*****************************************************************************/ |
847 /*****************************************************************************/ |
783 |
848 |