Lines Matching +full:aux +full:- +full:reg

1 /* ST Microelectronics LSM6DSV16X 6-axis IMU sensor driver
5 * SPDX-License-Identifier: Apache-2.0
59 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_lis2mdl_init()
62 data->magn_gain = LIS2MDL_SENSITIVITY; in lsm6dsv16x_lis2mdl_init()
69 k_sleep(K_MSEC(10)); /* turn-on time in ms */ in lsm6dsv16x_lis2mdl_init()
95 return -ENOTSUP; in lsm6dsv16x_lis2mdl_odr_set()
113 return lsm6dsv16x_lis2mdl_odr_set(dev, i2c_addr, val->val1); in lsm6dsv16x_lis2mdl_conf()
116 return -ENOTSUP; in lsm6dsv16x_lis2mdl_conf()
140 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_hts221_read_conv_data()
142 struct hts221_data *ht = &data->hts221; in lsm6dsv16x_hts221_read_conv_data()
145 unsigned char len = MIN(7, sizeof(buf) - i); in lsm6dsv16x_hts221_read_conv_data()
152 return -EIO; in lsm6dsv16x_hts221_read_conv_data()
156 ht->y0 = buf[0] / 2; in lsm6dsv16x_hts221_read_conv_data()
157 ht->y1 = buf[1] / 2; in lsm6dsv16x_hts221_read_conv_data()
158 ht->x0 = buf[6] | (buf[7] << 8); in lsm6dsv16x_hts221_read_conv_data()
159 ht->x1 = buf[10] | (buf[11] << 8); in lsm6dsv16x_hts221_read_conv_data()
191 return -ENOTSUP; in lsm6dsv16x_hts221_odr_set()
209 return lsm6dsv16x_hts221_odr_set(dev, i2c_addr, val->val1); in lsm6dsv16x_hts221_conf()
212 return -ENOTSUP; in lsm6dsv16x_hts221_conf()
241 k_sleep(K_MSEC(1)); /* turn-on time in ms */ in lsm6dsv16x_lps22hb_init()
275 k_sleep(K_MSEC(100)); /* turn-on time in ms */ in lsm6dsv16x_lps22hh_init()
304 return -ENOTSUP; in lsm6dsv16x_lps22hh_odr_set()
322 return lsm6dsv16x_lps22hh_odr_set(dev, i2c_addr, val->val1); in lsm6dsv16x_lps22hh_conf()
325 return -ENOTSUP; in lsm6dsv16x_lps22hh_conf()
355 k_busy_wait(50); /* turn-on time in us */ in lsm6dsv16x_lps22df_init()
384 return -ENOTSUP; in lsm6dsv16x_lps22df_odr_set()
402 return lsm6dsv16x_lps22df_odr_set(dev, i2c_addr, val->val1); in lsm6dsv16x_lps22df_conf()
405 return -ENOTSUP; in lsm6dsv16x_lps22df_conf()
503 if (!--tries) { in lsm6dsv16x_shub_wait_completed()
505 return -ETIMEDOUT; in lsm6dsv16x_shub_wait_completed()
516 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_shub_enable()
517 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_shub_enable()
518 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_shub_enable()
521 if (!data->accel_freq) { in lsm6dsv16x_shub_enable()
555 LOG_DBG("shub: error reading embedded reg"); in lsm6dsv16x_shub_check_slv0_nack()
556 return -EIO; in lsm6dsv16x_shub_check_slv0_nack()
561 return -EIO; in lsm6dsv16x_shub_check_slv0_nack()
574 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_shub_read_target_reg()
575 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_shub_read_target_reg()
591 return -EIO; in lsm6dsv16x_shub_read_target_reg()
596 return -EIO; in lsm6dsv16x_shub_read_target_reg()
610 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_shub_write_target_reg()
611 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_shub_write_target_reg()
630 return -EIO; in lsm6dsv16x_shub_write_target_reg()
650 * - TARGET 0: used for configuring all target devices
651 * - TARGET 1: used as data read channel for external target device #1
652 * - TARGET 2: used as data read channel for external target device #2
653 * - TARGET 3: used for generic reads while data channel is enabled
657 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_shub_set_data_channel()
658 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_shub_set_data_channel()
659 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_shub_set_data_channel()
665 for (n = 0; n < data->num_ext_dev; n++) { in lsm6dsv16x_shub_set_data_channel()
666 sp = &lsm6dsv16x_shub_slist[data->shub_ext[n]]; in lsm6dsv16x_shub_set_data_channel()
668 trgt_cfg.slv_add = sp->ext_i2c_addr; in lsm6dsv16x_shub_set_data_channel()
669 trgt_cfg.slv_subadd = sp->out_data_addr; in lsm6dsv16x_shub_set_data_channel()
670 trgt_cfg.slv_len = sp->out_data_len; in lsm6dsv16x_shub_set_data_channel()
674 return -EIO; in lsm6dsv16x_shub_set_data_channel()
679 lsm6dsv16x_sh_slave_connected_t aux = LSM6DSV16X_SLV_0_1_2; in lsm6dsv16x_shub_set_data_channel() local
681 if (lsm6dsv16x_sh_slave_connected_set(ctx, aux) < 0) { in lsm6dsv16x_shub_set_data_channel()
682 LOG_DBG("shub: error setting aux sensors"); in lsm6dsv16x_shub_set_data_channel()
683 return -EIO; in lsm6dsv16x_shub_set_data_channel()
696 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_shub_get_idx()
699 for (n = 0; n < data->num_ext_dev; n++) { in lsm6dsv16x_shub_get_idx()
700 sp = &lsm6dsv16x_shub_slist[data->shub_ext[n]]; in lsm6dsv16x_shub_get_idx()
702 if (sp->type == type) { in lsm6dsv16x_shub_get_idx()
707 LOG_ERR("shub: dev %s type %d not supported", dev->name, type); in lsm6dsv16x_shub_get_idx()
708 return -ENOTSUP; in lsm6dsv16x_shub_get_idx()
714 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_shub_fetch_external_devs()
715 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_shub_fetch_external_devs()
716 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_shub_fetch_external_devs()
722 return -EIO; in lsm6dsv16x_shub_fetch_external_devs()
725 for (n = 0; n < data->num_ext_dev; n++) { in lsm6dsv16x_shub_fetch_external_devs()
726 sp = &lsm6dsv16x_shub_slist[data->shub_ext[n]]; in lsm6dsv16x_shub_fetch_external_devs()
728 if (lsm6dsv16x_read_reg(ctx, sp->sh_out_reg, in lsm6dsv16x_shub_fetch_external_devs()
729 data->ext_data[n], sp->out_data_len) < 0) { in lsm6dsv16x_shub_fetch_external_devs()
732 return -EIO; in lsm6dsv16x_shub_fetch_external_devs()
743 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_shub_config()
747 for (n = 0; n < data->num_ext_dev; n++) { in lsm6dsv16x_shub_config()
748 sp = &lsm6dsv16x_shub_slist[data->shub_ext[n]]; in lsm6dsv16x_shub_config()
750 if (sp->type == chan) { in lsm6dsv16x_shub_config()
755 if (n == data->num_ext_dev) { in lsm6dsv16x_shub_config()
756 LOG_DBG("shub: %s chan %d not supported", dev->name, chan); in lsm6dsv16x_shub_config()
757 return -ENOTSUP; in lsm6dsv16x_shub_config()
760 if (sp == NULL || sp->dev_conf == NULL) { in lsm6dsv16x_shub_config()
762 return -ENOTSUP; in lsm6dsv16x_shub_config()
765 return sp->dev_conf(dev, sp->ext_i2c_addr, chan, attr, val); in lsm6dsv16x_shub_config()
770 struct lsm6dsv16x_data *data = dev->data; in lsm6dsv16x_shub_init()
771 const struct lsm6dsv16x_config *cfg = dev->config; in lsm6dsv16x_shub_init()
772 stmdev_ctx_t *ctx = (stmdev_ctx_t *)&cfg->ctx; in lsm6dsv16x_shub_init()
777 LOG_INF("shub: start sensorhub for %s", dev->name); in lsm6dsv16x_shub_init()
785 return -EIO; in lsm6dsv16x_shub_init()
789 if (data->num_ext_dev >= LSM6DSV16X_SHUB_MAX_NUM_TARGETS) { in lsm6dsv16x_shub_init()
801 for (i = 0U; i < ARRAY_SIZE(sp->i2c_addr); i++) { in lsm6dsv16x_shub_init()
803 sp->i2c_addr[i], in lsm6dsv16x_shub_init()
804 sp->wai_addr, in lsm6dsv16x_shub_init()
809 if (chip_id == sp->wai_val) { in lsm6dsv16x_shub_init()
814 if (i >= ARRAY_SIZE(sp->i2c_addr)) { in lsm6dsv16x_shub_init()
819 sp->ext_i2c_addr = sp->i2c_addr[i]; in lsm6dsv16x_shub_init()
821 data->shub_ext[data->num_ext_dev++] = n; in lsm6dsv16x_shub_init()
824 LOG_DBG("shub: dev %s - num_ext_dev %d", dev->name, data->num_ext_dev); in lsm6dsv16x_shub_init()
825 if (data->num_ext_dev == 0) { in lsm6dsv16x_shub_init()
827 return -EINVAL; in lsm6dsv16x_shub_init()
831 for (n = 0, regn = 0; n < data->num_ext_dev; n++) { in lsm6dsv16x_shub_init()
832 sp = &lsm6dsv16x_shub_slist[data->shub_ext[n]]; in lsm6dsv16x_shub_init()
833 sp->sh_out_reg = LSM6DSV16X_SENSOR_HUB_1 + regn; in lsm6dsv16x_shub_init()
834 regn += sp->out_data_len; in lsm6dsv16x_shub_init()
835 sp->dev_init(dev, sp->ext_i2c_addr); in lsm6dsv16x_shub_init()