Граф коммитов

20 Коммитов

Автор SHA1 Сообщение Дата
Loys Ollivier d4584bbfcf gnss: add driver for mediatek receivers
Add driver for serial-connected Mediatek-based GNSS receivers.

These devices typically boot transmitting vendor specific NMEA output
sequences. The serial port bit rate is read from the device tree
"current-speed".

Note that the driver uses the generic GNSS serial implementation and
therefore essentially only manages power abstracted into three power
states: ACTIVE, STANDBY, and OFF.

For mediatek receivers with a main supply and no enable-gpios, this simply
means that the main supply is disabled in STANDBY and OFF (the optional
backup supply is kept enabled while the driver is bound).

Note that the timepulse-support is left unimplemented.

Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
[ johan: rename backup supply ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-02-15 16:54:38 +01:00
Loys Ollivier 625239d4ad gnss: add mtk receiver type support
Add an MTK (Mediatek) type to the "GNSS_TYPE" attribute.

Note that MTK receivers support a subset of NMEA 0183 with vendor
extensions.

Signed-off-by: Loys Ollivier <lollivier@baylibre.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-02-15 16:54:38 +01:00
Andreas Kemnade 8fafef42c7 gnss: sirf: add a separate supply for a lna
Devices might have a separate lna between antenna input of the gps
chip and the antenna which might have a separate supply.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 12:07:42 +01:00
Andreas Kemnade ccd0e4963f gnss: sirf: add support for configurations without wakeup signal
Some Wi2Wi devices do not have a wakeup output, so device state can
only be indirectly detected by looking whether there is communication
over the serial lines.
This approach requires a report cycle set to a value less than 2 seconds
to be reliable.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
[ johan: simplify sirf_set_active(), style changes ]
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 12:07:42 +01:00
Andreas Kemnade 196d918460 gnss: sirf: write data to gnss only when the gnss device is open
The api forbids writing data there otherwise. Prepare for the
serdev_open()/close() being a part of sirf_set_active.

Signed-off-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 11:35:06 +01:00
Johan Hovold 9f1623fdb3 gnss: sirf: drop redundant double negation
The active flag is of type bool so drop the redundant double negation
when storing the gpio state.

Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 10:58:56 +01:00
Johan Hovold 4ceda5f654 gnss: sirf: force hibernate mode on probe
Make sure to put the receiver in hibernate mode in case it is already
active during probe in order to avoid wasting power until first open or
suspend.

This can happen, for example, after a reset or non-clean shutdown, and
possibly also due to glitches during power-on.

Reported-by: Andreas Kemnade <andreas@kemnade.info>
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 10:58:54 +01:00
Johan Hovold 82f844c225 gnss: sirf: fix premature wakeup interrupt enable
Make sure the receiver is powered (and booted) before enabling the
wakeup interrupt to avoid spurious interrupts due to a floating input.

Similarly, disable the interrupt before powering off on probe errors and
on unbind.

Fixes: d2efbbd18b ("gnss: add driver for sirfstar-based receivers")
Cc: stable <stable@vger.kernel.org>	# 4.19
Signed-off-by: Johan Hovold <johan@kernel.org>
2019-01-25 10:58:52 +01:00
Greg Kroah-Hartman 9c96f401e9 Merge 4.20-rc6 into tty-next
We want the TTY changes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-12-10 10:17:45 +01:00
Johan Hovold 06fd9ab12b gnss: sirf: fix activation retry handling
Fix activation helper which would return -ETIMEDOUT even if the last
retry attempt was successful.

Also change the semantics of the retries variable so that it actually
holds the number of retries (rather than tries).

Fixes: d2efbbd18b ("gnss: add driver for sirfstar-based receivers")
Cc: stable <stable@vger.kernel.org>	# 4.19
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-12-06 17:22:23 +01:00
Johan Hovold 0bbf0a88fa serdev: make synchronous write return bytes written
Make the synchronous serdev_device_write() helper behave analogous to
the asynchronous serdev_device_write_buf() by returning the number of
bytes written (or rather buffered) also on timeout.

This will allow drivers to distinguish the case where data was partially
written from the case where no data was written.

Also update the only two users that checked the return value.

Signed-off-by: Johan Hovold <johan@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-11-27 19:44:21 +01:00
Johan Hovold 1decef3704 gnss: sirf: fix synchronous write timeout
Passing a timeout of zero to the synchronous serdev_device_write()
helper does currently not imply to wait forever (unlike passing zero to
serdev_device_wait_until_sent()). Instead, if there's insufficient
room in the write buffer, we'd end up with an incomplete write.

Fixes: d2efbbd18b ("gnss: add driver for sirfstar-based receivers")
Cc: stable <stable@vger.kernel.org>     # 4.19
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-11-14 20:37:41 +01:00
Johan Hovold 56a6c72683 gnss: serial: fix synchronous write timeout
Passing a timeout of zero to the synchronous serdev_device_write()
helper does currently not imply to wait forever (unlike passing zero to
serdev_device_wait_until_sent()). Instead, if there's insufficient
room in the write buffer, we'd end up with an incomplete write.

Fixes: 37768b054f ("gnss: add generic serial driver")
Cc: stable <stable@vger.kernel.org>     # 4.19
Signed-off-by: Johan Hovold <johan@kernel.org>
2018-11-14 20:37:28 +01:00
Dan Carpenter d9995a0fab gnss: fix potential error pointer dereference
The gnss_allocate_device() function returns a mix of NULL and error
pointers on error.  It should only return one or the other.  Since the
callers both check for NULL, I've modified it to return NULL on error.

Fixes: 2b6a440351 ("gnss: add GNSS receiver subsystem")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-16 12:48:07 +02:00
Colin Ian King 55570f1a44 gnss: ubx: make struct ubx_gserial_ops static
The structure ubx_gserial_ops is local to the source and does not need
to be in global scope, so make it static.

Cleans up sparse warning:
symbol 'ubx_gserial_ops' was not declared. Should it be static?

Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-07-16 12:48:07 +02:00
Johan Hovold 10f146639f gnss: add receiver type support
Add a "type" device attribute and a "GNSS_TYPE" uevent variable which
can be used to determine the type of a GNSS receiver. The currently
identified types reflect the protocol(s) supported by a receiver:

	"NMEA"	NMEA 0183
	"SiRF"	SiRF Binary
	"UBX"	UBX

Note that both SiRF and UBX type receivers typically support a subset of
NMEA 0183 with vendor extensions (e.g. to allow switching to the vendor
protocol).

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 20:32:51 +09:00
Johan Hovold d2efbbd18b gnss: add driver for sirfstar-based receivers
Add driver for serial-connected SiRFstar-based GNSS receivers.

These devices typically boot into hibernate mode from which they can be
woken using a pulse on the ON_OFF input pin. Once active, a pulse on the
same ON_OFF pin is used to put the device back into hibernate mode. The
current state can be determined by sampling the WAKEUP output.

Hardware configurations where WAKEUP has been connected to ON_OFF (and
where an initial WAKEUP pulse during boot is sufficient to have the
device boot into active mode) are also supported. In this case, device
power is managed using the main-supply regulator only.

Note that configurations where WAKEUP is left not connected, so that the
device power state can only indirectly be determined using the I/O
interface, is currently not supported. It should be fairly
straight-forward to extend the current implementation with such support
however (and this this is the main reason for not using the generic
serial implementation for this driver).

Note that timepulse-support is left unimplemented.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 20:32:51 +09:00
Johan Hovold 1ad69f10e3 gnss: add driver for u-blox receivers
Add driver for serial-connected u-blox GNSS receivers.

Note that the driver uses the generic GNSS serial implementation and
therefore essentially only manages power abstracted into three power
states: ACTIVE, STANDBY, and OFF.

For u-blox receivers with a main supply and no enable-gpios, this simply
means that the main supply is disabled in STANDBY and OFF (the optional
backup supply is kept enabled while the driver is bound).

Note that timepulse-support is not yet implemented.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 20:31:32 +09:00
Johan Hovold 37768b054f gnss: add generic serial driver
Add a generic serial GNSS driver (library) which provides a common
implementation for the gnss interface and power management (runtime and
system suspend). This allows GNSS drivers for specific chip to be
implemented by simply providing a set_power() callback to handle three
states: ACTIVE, STANDBY and OFF.

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 20:31:32 +09:00
Johan Hovold 2b6a440351 gnss: add GNSS receiver subsystem
Add a new subsystem for GNSS (e.g. GPS) receivers.

While GNSS receivers are typically accessed using a UART interface they
often also support other I/O interfaces such as I2C, SPI and USB, while
yet other devices use iomem or even some form of remote-processor
messaging (rpmsg).

The new GNSS subsystem abstracts the underlying interface and provides a
new "gnss" class type, which exposes a character-device interface (e.g.
/dev/gnss0) to user space. This allows GNSS receivers to have a
representation in the Linux device model, something which is important
not least for power management purposes.

Note that the character-device interface provides raw access to whatever
protocol the receiver is (currently) using, such as NMEA 0183, UBX or
SiRF Binary. These protocols are expected to be continued to be handled
by user space for the time being, even if some hybrid solutions are also
conceivable (e.g. to have kernel drivers issue management commands).

This will still allow for better platform integration by allowing GNSS
devices and their resources (e.g. regulators and enable-gpios) to be
described by firmware and managed by kernel drivers rather than
platform-specific scripts and services.

While the current interface is kept minimal, it could be extended using
IOCTLs, sysfs or uevents as needs and proper abstraction levels are
identified and determined (e.g. for device and feature identification).

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2018-06-28 20:29:47 +09:00