Lines Matching +full:u +full:- +full:blox
1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2021-2022, Intel Corporation. */
8 * ice_gnss_do_write - Write data to internal GNSS receiver
16 * * number of bytes written - success
17 * * negative - error code
23 struct ice_hw *hw = &pf->hw; in ice_gnss_do_write()
33 /* It's not possible to write a single byte to u-blox. in ice_gnss_do_write()
39 while (size - offset > ICE_GNSS_UBX_WRITE_BYTES + 1) { in ice_gnss_do_write()
51 if (size - offset == ICE_GNSS_UBX_WRITE_BYTES + 1) { in ice_gnss_do_write()
54 ICE_MAX_I2C_WRITE_BYTES - 1, in ice_gnss_do_write()
59 offset += ICE_GNSS_UBX_WRITE_BYTES - 1; in ice_gnss_do_write()
64 cpu_to_le16(buf[offset]), size - offset - 1, in ice_gnss_do_write()
72 dev_err(ice_pf_to_dev(pf), "GNSS failed to write, offset=%u, size=%u, err=%d\n", in ice_gnss_do_write()
79 * ice_gnss_read - Read data from internal GNSS module
98 pf = gnss->back; in ice_gnss_read()
99 if (!pf || !test_bit(ICE_FLAG_GNSS, pf->flags)) in ice_gnss_read()
102 hw = &pf->hw; in ice_gnss_read()
123 /* The u-blox has data_len bytes for us to read */ in ice_gnss_read()
129 err = -ENOMEM; in ice_gnss_read()
135 unsigned int bytes_left = data_len - i; in ice_gnss_read()
147 count = gnss_insert_raw(pf->gnss_dev, buf, i); in ice_gnss_read()
156 kthread_queue_delayed_work(gnss->kworker, &gnss->read_work, delay); in ice_gnss_read()
162 * ice_gnss_struct_init - Initialize GNSS receiver
168 * * pointer to initialized gnss_serial struct - success
169 * * NULL - error
181 gnss->back = pf; in ice_gnss_struct_init()
182 pf->gnss_serial = gnss; in ice_gnss_struct_init()
184 kthread_init_delayed_work(&gnss->read_work, ice_gnss_read); in ice_gnss_struct_init()
185 kworker = kthread_create_worker(0, "ice-gnss-%s", dev_name(dev)); in ice_gnss_struct_init()
191 gnss->kworker = kworker; in ice_gnss_struct_init()
197 * ice_gnss_open - Open GNSS device
203 * * 0 - success
204 * * negative - error code
212 return -EFAULT; in ice_gnss_open()
214 if (!test_bit(ICE_FLAG_GNSS, pf->flags)) in ice_gnss_open()
215 return -EFAULT; in ice_gnss_open()
217 gnss = pf->gnss_serial; in ice_gnss_open()
219 return -ENODEV; in ice_gnss_open()
221 kthread_queue_delayed_work(gnss->kworker, &gnss->read_work, 0); in ice_gnss_open()
227 * ice_gnss_close - Close GNSS device
240 gnss = pf->gnss_serial; in ice_gnss_close()
244 kthread_cancel_delayed_work_sync(&gnss->read_work); in ice_gnss_close()
248 * ice_gnss_write - Write to GNSS device
254 * * number of written bytes - success
255 * * negative - error code
266 return -EINVAL; in ice_gnss_write()
269 return -EFAULT; in ice_gnss_write()
271 if (!test_bit(ICE_FLAG_GNSS, pf->flags)) in ice_gnss_write()
272 return -EFAULT; in ice_gnss_write()
274 gnss = pf->gnss_serial; in ice_gnss_write()
276 return -ENODEV; in ice_gnss_write()
288 * ice_gnss_register - Register GNSS receiver
294 * * 0 - success
295 * * negative - error code
306 return -ENOMEM; in ice_gnss_register()
309 gdev->ops = &ice_gnss_ops; in ice_gnss_register()
310 gdev->type = GNSS_TYPE_UBX; in ice_gnss_register()
318 pf->gnss_dev = gdev; in ice_gnss_register()
325 * ice_gnss_deregister - Deregister GNSS receiver
333 if (pf->gnss_dev) { in ice_gnss_deregister()
334 gnss_deregister_device(pf->gnss_dev); in ice_gnss_deregister()
335 gnss_put_device(pf->gnss_dev); in ice_gnss_deregister()
336 pf->gnss_dev = NULL; in ice_gnss_deregister()
341 * ice_gnss_init - Initialize GNSS support
348 pf->gnss_serial = ice_gnss_struct_init(pf); in ice_gnss_init()
349 if (!pf->gnss_serial) in ice_gnss_init()
354 set_bit(ICE_FLAG_GNSS, pf->flags); in ice_gnss_init()
363 * ice_gnss_exit - Disable GNSS TTY support
369 clear_bit(ICE_FLAG_GNSS, pf->flags); in ice_gnss_exit()
371 if (pf->gnss_serial) { in ice_gnss_exit()
372 struct gnss_serial *gnss = pf->gnss_serial; in ice_gnss_exit()
374 kthread_cancel_delayed_work_sync(&gnss->read_work); in ice_gnss_exit()
375 kthread_destroy_worker(gnss->kworker); in ice_gnss_exit()
376 gnss->kworker = NULL; in ice_gnss_exit()
379 pf->gnss_serial = NULL; in ice_gnss_exit()
384 * ice_gnss_is_gps_present - Check if GPS HW is present
389 if (!hw->func_caps.ts_func_info.src_tmr_owned) in ice_gnss_is_gps_present()