Lines Matching +full:orientation +full:- +full:switch
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2019 TDK-InvenSense, Inc.
49 switch (st->chip_type) { in inv_magn_supported()
73 return -ENODEV; in inv_magn_init()
76 switch (st->chip_type) { in inv_magn_init()
101 /* switch back to power-down */ in inv_magn_init()
113 switch (st->chip_type) { in inv_magn_init()
124 return -EINVAL; in inv_magn_init()
130 * Hadj = H * (((ASA - 128) * 0.5 / 128) + 1) in inv_magn_init()
136 st->magn_raw_to_gauss[0] = (((int32_t)asa[0] + 128) * sensitivity) / 256; in inv_magn_init()
137 st->magn_raw_to_gauss[1] = (((int32_t)asa[1] + 128) * sensitivity) / 256; in inv_magn_init()
138 st->magn_raw_to_gauss[2] = (((int32_t)asa[2] + 128) * sensitivity) / 256; in inv_magn_init()
144 * inv_mpu_magn_probe() - probe and setup magnetometer chip
173 * i2c SLV0: read sensor data, 7 bytes data(6)-ST2 in inv_mpu_magn_probe()
174 * Byte swap data to store them in big-endian in impair address groups in inv_mpu_magn_probe()
176 ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_ADDR(0), in inv_mpu_magn_probe()
181 ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_REG(0), in inv_mpu_magn_probe()
186 ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(0), in inv_mpu_magn_probe()
195 ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_ADDR(1), in inv_mpu_magn_probe()
200 ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_REG(1), in inv_mpu_magn_probe()
207 switch (st->chip_type) { in inv_mpu_magn_probe()
215 ret = regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_DO(1), val); in inv_mpu_magn_probe()
219 return regmap_write(st->map, INV_MPU6050_REG_I2C_SLV_CTRL(1), in inv_mpu_magn_probe()
224 * inv_mpu_magn_set_rate() - set magnetometer sampling rate
247 d = fifo_rate / INV_MPU_MAGN_FREQ_HZ_MAX - 1; in inv_mpu_magn_set_rate()
251 return regmap_write(st->map, INV_MPU6050_REG_I2C_SLV4_CTRL, d); in inv_mpu_magn_set_rate()
255 * inv_mpu_magn_set_orient() - fill magnetometer mounting matrix
264 struct device *dev = regmap_get_device(st->map); in inv_mpu_magn_set_orient()
269 /* fill magnetometer orientation */ in inv_mpu_magn_set_orient()
270 switch (st->chip_type) { in inv_mpu_magn_set_orient()
274 /* x <- y */ in inv_mpu_magn_set_orient()
275 st->magn_orient.rotation[0] = st->orientation.rotation[3]; in inv_mpu_magn_set_orient()
276 st->magn_orient.rotation[1] = st->orientation.rotation[4]; in inv_mpu_magn_set_orient()
277 st->magn_orient.rotation[2] = st->orientation.rotation[5]; in inv_mpu_magn_set_orient()
278 /* y <- x */ in inv_mpu_magn_set_orient()
279 st->magn_orient.rotation[3] = st->orientation.rotation[0]; in inv_mpu_magn_set_orient()
280 st->magn_orient.rotation[4] = st->orientation.rotation[1]; in inv_mpu_magn_set_orient()
281 st->magn_orient.rotation[5] = st->orientation.rotation[2]; in inv_mpu_magn_set_orient()
282 /* z <- -z */ in inv_mpu_magn_set_orient()
284 orient = st->orientation.rotation[i]; in inv_mpu_magn_set_orient()
294 if (orient[0] == '-') in inv_mpu_magn_set_orient()
299 str = devm_kasprintf(dev, GFP_KERNEL, "-%s", orient); in inv_mpu_magn_set_orient()
301 return -ENOMEM; in inv_mpu_magn_set_orient()
303 st->magn_orient.rotation[i] = str; in inv_mpu_magn_set_orient()
307 st->magn_orient = st->orientation; in inv_mpu_magn_set_orient()
315 * inv_mpu_magn_read() - read magnetometer data
331 return -ENODEV; in inv_mpu_magn_read()
334 switch (axis) { in inv_mpu_magn_read()
345 return -EINVAL; in inv_mpu_magn_read()
350 ret = regmap_read(st->map, INV_MPU6050_REG_I2C_MST_STATUS, &status); in inv_mpu_magn_read()
356 return -EIO; in inv_mpu_magn_read()
358 ret = regmap_bulk_read(st->map, addr, &data, sizeof(data)); in inv_mpu_magn_read()