Lines Matching +full:gnss +full:- +full:receiver
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
13 * Write UBX command data to the 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
80 * @work: GNSS read work structure
82 * Read the data from internal GNSS receiver, write it to gnss_dev.
86 struct gnss_serial *gnss = container_of(work, struct gnss_serial, in ice_gnss_read() local
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()
158 dev_dbg(ice_pf_to_dev(pf), "GNSS failed to read err=%d\n", err); in ice_gnss_read()
162 * ice_gnss_struct_init - Initialize GNSS receiver
165 * Initialize GNSS structures and workers.
168 * * pointer to initialized gnss_serial struct - success
169 * * NULL - error
175 struct gnss_serial *gnss; in ice_gnss_struct_init() local
177 gnss = kzalloc(sizeof(*gnss), GFP_KERNEL); in ice_gnss_struct_init()
178 if (!gnss) in ice_gnss_struct_init()
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_run_worker(0, "ice-gnss-%s", dev_name(dev)); in ice_gnss_struct_init()
187 kfree(gnss); in ice_gnss_struct_init()
191 gnss->kworker = kworker; in ice_gnss_struct_init()
193 return gnss; in ice_gnss_struct_init()
197 * ice_gnss_open - Open GNSS device
198 * @gdev: pointer to the gnss device struct
200 * Open GNSS device and start filling the read buffer for consumer.
203 * * 0 - success
204 * * negative - error code
209 struct gnss_serial *gnss; in ice_gnss_open() local
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()
218 if (!gnss) 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
228 * @gdev: pointer to the gnss device struct
230 * Close GNSS device, cancel worker, stop filling the read buffer.
235 struct gnss_serial *gnss; in ice_gnss_close() local
240 gnss = pf->gnss_serial; in ice_gnss_close()
241 if (!gnss) 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
249 * @gdev: pointer to the gnss device struct
251 * @count: size of the buffer to be sent to the GNSS device
254 * * number of written bytes - success
255 * * negative - error code
262 struct gnss_serial *gnss; in ice_gnss_write() local
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()
275 if (!gnss) in ice_gnss_write()
276 return -ENODEV; in ice_gnss_write()
288 * ice_gnss_register - Register GNSS receiver
291 * Allocate and register GNSS receiver in the Linux GNSS subsystem.
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
328 * Deregister GNSS receiver from the Linux GNSS subsystem,
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()
355 dev_info(ice_pf_to_dev(pf), "GNSS init successful\n"); in ice_gnss_init()
358 dev_err(ice_pf_to_dev(pf), "GNSS init failure\n"); 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() local
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()
378 kfree(gnss); 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()