Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-06-07 Thread H. Nikolaus Schaller
Hi Ladislav,

> Am 07.06.2017 um 09:34 schrieb Ladislav Michl :
> 
> Dear Nikolaus,
> 
> On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
>> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
>> 
>> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
>> and turn on/off the module. It also detects if the module is turned on 
>> (sends data)
>> but should be off, e.g. if it was already turned on during boot or 
>> power-on-reset.
>> 
>> Additionally, rfkill block/unblock can be used to control an external LNA
>> (and power down the module if not needed).
>> 
>> The driver concept is based on code developed by NeilBrown 
>> but simplified and adapted to use the new serdev API introduced in 4.11.
> [snip]
>> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
>> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> new file mode 100644
>> index ..b7125c7a598c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> @@ -0,0 +1,20 @@
>> +Wi2Wi GPS module connected through UART
>> +
>> +Should be a subnode of the SoC UART it is connected to (serdev).
>> +
>> +Required properties:
>> +- compatible:   wi2wi,w2sg0004 or wi2wi,w2sg0084
>> +- on-off-gpio:  the GPIO that controls the module's on-off toggle input
>> +
>> +Optional properties:
>> +- lna-suppy:an (optional) LNA regulator that is enabled together 
>> with the GPS receiver
>> +
>> +Example:
>> +
>> + {
>> +gps: w2sg0004 {
>> +compatible = "wi2wi,w2sg0004";
>> +lna-supply = <>;   /* LNA regulator */
>> +on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
>> trigger for turning on/off w2sg0004 */
>> +};
>> +};
> 
> Here it seems is nothing specific to GPS receiver in this driver

Well, most serdev subnodes will look similar to this but still will
need different drivers (timing, pulses, other logic, special functions,
firmware download etc.).

> and
> basically UART connected GSM modules could benefit from such functionality
> too - as they need power supply, had reset and ignition pin and often
> status pin. See for example:
> http://simcom.ee/documents/SIM5300E/SIM5300E_Hardware_Design_V1.08.pdf
> page 14 or
> http://www.robotshop.com/media/files/pdf/datasheet-gsm-tc35.pdf
> page 19 for block diagrams.
> So I wonder if you would accept making this driver a bit more generic
> to cover also GSM modems use case.

We also have such a 2G/3G/4G module in the GTA04 and Pyra devices but there
we have significantly different power control needs because they are connected
through USB and not as UART / serdev.

But you could simply try to use and extend our proposed w2cbw003 bluetooth
driver [RFC 3/3] for that purpose.

It already has most of what you need: provides a user-space /dev/tty for the
serdev and controls some power-control gpio or regulator.

This w2sg0004 gps chip is very specific for this chip since it has no simple
power-enable to be controlled. This also differs too much from GSM modules
with ignition. Especially it has no status feedback.

Another aspect is that there are plans to have some gps infrastructure in the
kernel. Then, this driver wouldn't be the right solution for gsm.

Therefore it is and should remain a special purpose driver for this type of
gps chips.

The common denominator of all these things is the serdev and gpio 
infrastructure.

Feel free to take both drivers as blueprints to propose some new driver
for your chips.

BR,
Nikolaus



Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-06-07 Thread H. Nikolaus Schaller
Hi Ladislav,

> Am 07.06.2017 um 09:34 schrieb Ladislav Michl :
> 
> Dear Nikolaus,
> 
> On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
>> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
>> 
>> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
>> and turn on/off the module. It also detects if the module is turned on 
>> (sends data)
>> but should be off, e.g. if it was already turned on during boot or 
>> power-on-reset.
>> 
>> Additionally, rfkill block/unblock can be used to control an external LNA
>> (and power down the module if not needed).
>> 
>> The driver concept is based on code developed by NeilBrown 
>> but simplified and adapted to use the new serdev API introduced in 4.11.
> [snip]
>> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
>> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> new file mode 100644
>> index ..b7125c7a598c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> @@ -0,0 +1,20 @@
>> +Wi2Wi GPS module connected through UART
>> +
>> +Should be a subnode of the SoC UART it is connected to (serdev).
>> +
>> +Required properties:
>> +- compatible:   wi2wi,w2sg0004 or wi2wi,w2sg0084
>> +- on-off-gpio:  the GPIO that controls the module's on-off toggle input
>> +
>> +Optional properties:
>> +- lna-suppy:an (optional) LNA regulator that is enabled together 
>> with the GPS receiver
>> +
>> +Example:
>> +
>> + {
>> +gps: w2sg0004 {
>> +compatible = "wi2wi,w2sg0004";
>> +lna-supply = <>;   /* LNA regulator */
>> +on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
>> trigger for turning on/off w2sg0004 */
>> +};
>> +};
> 
> Here it seems is nothing specific to GPS receiver in this driver

Well, most serdev subnodes will look similar to this but still will
need different drivers (timing, pulses, other logic, special functions,
firmware download etc.).

> and
> basically UART connected GSM modules could benefit from such functionality
> too - as they need power supply, had reset and ignition pin and often
> status pin. See for example:
> http://simcom.ee/documents/SIM5300E/SIM5300E_Hardware_Design_V1.08.pdf
> page 14 or
> http://www.robotshop.com/media/files/pdf/datasheet-gsm-tc35.pdf
> page 19 for block diagrams.
> So I wonder if you would accept making this driver a bit more generic
> to cover also GSM modems use case.

We also have such a 2G/3G/4G module in the GTA04 and Pyra devices but there
we have significantly different power control needs because they are connected
through USB and not as UART / serdev.

But you could simply try to use and extend our proposed w2cbw003 bluetooth
driver [RFC 3/3] for that purpose.

It already has most of what you need: provides a user-space /dev/tty for the
serdev and controls some power-control gpio or regulator.

This w2sg0004 gps chip is very specific for this chip since it has no simple
power-enable to be controlled. This also differs too much from GSM modules
with ignition. Especially it has no status feedback.

Another aspect is that there are plans to have some gps infrastructure in the
kernel. Then, this driver wouldn't be the right solution for gsm.

Therefore it is and should remain a special purpose driver for this type of
gps chips.

The common denominator of all these things is the serdev and gpio 
infrastructure.

Feel free to take both drivers as blueprints to propose some new driver
for your chips.

BR,
Nikolaus



Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-06-07 Thread Ladislav Michl
Dear Nikolaus,

On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
> 
> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
> and turn on/off the module. It also detects if the module is turned on (sends 
> data)
> but should be off, e.g. if it was already turned on during boot or 
> power-on-reset.
> 
> Additionally, rfkill block/unblock can be used to control an external LNA
> (and power down the module if not needed).
> 
> The driver concept is based on code developed by NeilBrown 
> but simplified and adapted to use the new serdev API introduced in 4.11.
[snip]
> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> new file mode 100644
> index ..b7125c7a598c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> @@ -0,0 +1,20 @@
> +Wi2Wi GPS module connected through UART
> +
> +Should be a subnode of the SoC UART it is connected to (serdev).
> +
> +Required properties:
> +- compatible:wi2wi,w2sg0004 or wi2wi,w2sg0084
> +- on-off-gpio:   the GPIO that controls the module's on-off toggle input
> +
> +Optional properties:
> +- lna-suppy: an (optional) LNA regulator that is enabled together with the 
> GPS receiver
> +
> +Example:
> +
> + {
> + gps: w2sg0004 {
> + compatible = "wi2wi,w2sg0004";
> + lna-supply = <>;   /* LNA regulator */
> + on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
> trigger for turning on/off w2sg0004 */
> +};
> +};

Here it seems is nothing specific to GPS receiver in this driver and
basically UART connected GSM modules could benefit from such functionality
too - as they need power supply, had reset and ignition pin and often
status pin. See for example:
http://simcom.ee/documents/SIM5300E/SIM5300E_Hardware_Design_V1.08.pdf
page 14 or
http://www.robotshop.com/media/files/pdf/datasheet-gsm-tc35.pdf
page 19 for block diagrams.
So I wonder if you would accept making this driver a bit more generic
to cover also GSM modems use case.

Best regards,
ladis


Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-06-07 Thread Ladislav Michl
Dear Nikolaus,

On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
> 
> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
> and turn on/off the module. It also detects if the module is turned on (sends 
> data)
> but should be off, e.g. if it was already turned on during boot or 
> power-on-reset.
> 
> Additionally, rfkill block/unblock can be used to control an external LNA
> (and power down the module if not needed).
> 
> The driver concept is based on code developed by NeilBrown 
> but simplified and adapted to use the new serdev API introduced in 4.11.
[snip]
> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> new file mode 100644
> index ..b7125c7a598c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> @@ -0,0 +1,20 @@
> +Wi2Wi GPS module connected through UART
> +
> +Should be a subnode of the SoC UART it is connected to (serdev).
> +
> +Required properties:
> +- compatible:wi2wi,w2sg0004 or wi2wi,w2sg0084
> +- on-off-gpio:   the GPIO that controls the module's on-off toggle input
> +
> +Optional properties:
> +- lna-suppy: an (optional) LNA regulator that is enabled together with the 
> GPS receiver
> +
> +Example:
> +
> + {
> + gps: w2sg0004 {
> + compatible = "wi2wi,w2sg0004";
> + lna-supply = <>;   /* LNA regulator */
> + on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
> trigger for turning on/off w2sg0004 */
> +};
> +};

Here it seems is nothing specific to GPS receiver in this driver and
basically UART connected GSM modules could benefit from such functionality
too - as they need power supply, had reset and ignition pin and often
status pin. See for example:
http://simcom.ee/documents/SIM5300E/SIM5300E_Hardware_Design_V1.08.pdf
page 14 or
http://www.robotshop.com/media/files/pdf/datasheet-gsm-tc35.pdf
page 19 for block diagrams.
So I wonder if you would accept making this driver a bit more generic
to cover also GSM modems use case.

Best regards,
ladis


Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-06-06 Thread H. Nikolaus Schaller

> Am 31.05.2017 um 01:09 schrieb Rob Herring :
> 
> On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
>> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
>> 
>> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
>> and turn on/off the module. It also detects if the module is turned on 
>> (sends data)
>> but should be off, e.g. if it was already turned on during boot or 
>> power-on-reset.
>> 
>> Additionally, rfkill block/unblock can be used to control an external LNA
>> (and power down the module if not needed).
>> 
>> The driver concept is based on code developed by NeilBrown 
>> but simplified and adapted to use the new serdev API introduced in 4.11.
>> 
>> Signed-off-by: H. Nikolaus Schaller 
>> ---
>> .../devicetree/bindings/misc/wi2wi,w2sg0004.txt|  20 +
>> .../devicetree/bindings/vendor-prefixes.txt|   1 +
> 
> Please split binding patches.

Yes, will do.

We thought that it gives better understanding if kept together with the code in 
a single patch for this RFC.

> 
>> drivers/misc/Kconfig   |  16 +
>> drivers/misc/Makefile  |   1 +
>> drivers/misc/w2sg0004.c| 646 
>> +
>> include/linux/w2sg0004.h   |  27 +
>> 6 files changed, 711 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> create mode 100644 drivers/misc/w2sg0004.c
>> create mode 100644 include/linux/w2sg0004.h
>> 
>> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
>> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> new file mode 100644
>> index ..b7125c7a598c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> @@ -0,0 +1,20 @@
>> +Wi2Wi GPS module connected through UART
>> +
>> +Should be a subnode of the SoC UART it is connected to (serdev).
>> +
>> +Required properties:
>> +- compatible:   wi2wi,w2sg0004 or wi2wi,w2sg0084
> 
> Reformat to one per line.

Ok.

> 
>> +- on-off-gpio:  the GPIO that controls the module's on-off toggle input
> 
> Does enable-gpios or powerdown-gpios work as those are semi-standard 
> names. Also, need to state the active state.

Ok.

> 
>> +
>> +Optional properties:
>> +- lna-suppy:an (optional) LNA regulator that is enabled together 
>> with the GPS receiver
> 
> typo

tnx :)

> 
>> +
>> +Example:
>> +
>> + {
>> +gps: w2sg0004 {
> 
> w2sg0004: gps {
> 
> The node name should be generic. The label can be whatever you like.

Ok. That comes from thoughtless copying very old stuff (I think we started with 
trying to get this chip DT based around 3.14 kernels...)

> 
>> +compatible = "wi2wi,w2sg0004";
>> +lna-supply = <>;   /* LNA regulator */
>> +on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
>> trigger for turning on/off w2sg0004 */
>> +};
>> +};
>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
>> b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> index c03d20140366..c56b3181b266 100644
>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> @@ -345,6 +345,7 @@ voipac   Voipac Technologies s.r.o.
>> wd   Western Digital Corp.
>> wetekWeTek Electronics, limited.
>> wexler   Wexler
>> +wi2wi   Wi2Wi, Inc.
>> winbond Winbond Electronics corp.
>> winstar  Winstar Display Corp.
>> wlf  Wolfson Microelectronics



Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-06-06 Thread H. Nikolaus Schaller

> Am 31.05.2017 um 01:09 schrieb Rob Herring :
> 
> On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
>> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
>> 
>> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
>> and turn on/off the module. It also detects if the module is turned on 
>> (sends data)
>> but should be off, e.g. if it was already turned on during boot or 
>> power-on-reset.
>> 
>> Additionally, rfkill block/unblock can be used to control an external LNA
>> (and power down the module if not needed).
>> 
>> The driver concept is based on code developed by NeilBrown 
>> but simplified and adapted to use the new serdev API introduced in 4.11.
>> 
>> Signed-off-by: H. Nikolaus Schaller 
>> ---
>> .../devicetree/bindings/misc/wi2wi,w2sg0004.txt|  20 +
>> .../devicetree/bindings/vendor-prefixes.txt|   1 +
> 
> Please split binding patches.

Yes, will do.

We thought that it gives better understanding if kept together with the code in 
a single patch for this RFC.

> 
>> drivers/misc/Kconfig   |  16 +
>> drivers/misc/Makefile  |   1 +
>> drivers/misc/w2sg0004.c| 646 
>> +
>> include/linux/w2sg0004.h   |  27 +
>> 6 files changed, 711 insertions(+)
>> create mode 100644 Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> create mode 100644 drivers/misc/w2sg0004.c
>> create mode 100644 include/linux/w2sg0004.h
>> 
>> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
>> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> new file mode 100644
>> index ..b7125c7a598c
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>> @@ -0,0 +1,20 @@
>> +Wi2Wi GPS module connected through UART
>> +
>> +Should be a subnode of the SoC UART it is connected to (serdev).
>> +
>> +Required properties:
>> +- compatible:   wi2wi,w2sg0004 or wi2wi,w2sg0084
> 
> Reformat to one per line.

Ok.

> 
>> +- on-off-gpio:  the GPIO that controls the module's on-off toggle input
> 
> Does enable-gpios or powerdown-gpios work as those are semi-standard 
> names. Also, need to state the active state.

Ok.

> 
>> +
>> +Optional properties:
>> +- lna-suppy:an (optional) LNA regulator that is enabled together 
>> with the GPS receiver
> 
> typo

tnx :)

> 
>> +
>> +Example:
>> +
>> + {
>> +gps: w2sg0004 {
> 
> w2sg0004: gps {
> 
> The node name should be generic. The label can be whatever you like.

Ok. That comes from thoughtless copying very old stuff (I think we started with 
trying to get this chip DT based around 3.14 kernels...)

> 
>> +compatible = "wi2wi,w2sg0004";
>> +lna-supply = <>;   /* LNA regulator */
>> +on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
>> trigger for turning on/off w2sg0004 */
>> +};
>> +};
>> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
>> b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> index c03d20140366..c56b3181b266 100644
>> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
>> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
>> @@ -345,6 +345,7 @@ voipac   Voipac Technologies s.r.o.
>> wd   Western Digital Corp.
>> wetekWeTek Electronics, limited.
>> wexler   Wexler
>> +wi2wi   Wi2Wi, Inc.
>> winbond Winbond Electronics corp.
>> winstar  Winstar Display Corp.
>> wlf  Wolfson Microelectronics



Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-05-30 Thread Rob Herring
On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
> 
> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
> and turn on/off the module. It also detects if the module is turned on (sends 
> data)
> but should be off, e.g. if it was already turned on during boot or 
> power-on-reset.
> 
> Additionally, rfkill block/unblock can be used to control an external LNA
> (and power down the module if not needed).
> 
> The driver concept is based on code developed by NeilBrown 
> but simplified and adapted to use the new serdev API introduced in 4.11.
> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
>  .../devicetree/bindings/misc/wi2wi,w2sg0004.txt|  20 +
>  .../devicetree/bindings/vendor-prefixes.txt|   1 +

Please split binding patches.

>  drivers/misc/Kconfig   |  16 +
>  drivers/misc/Makefile  |   1 +
>  drivers/misc/w2sg0004.c| 646 
> +
>  include/linux/w2sg0004.h   |  27 +
>  6 files changed, 711 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>  create mode 100644 drivers/misc/w2sg0004.c
>  create mode 100644 include/linux/w2sg0004.h
> 
> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> new file mode 100644
> index ..b7125c7a598c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> @@ -0,0 +1,20 @@
> +Wi2Wi GPS module connected through UART
> +
> +Should be a subnode of the SoC UART it is connected to (serdev).
> +
> +Required properties:
> +- compatible:wi2wi,w2sg0004 or wi2wi,w2sg0084

Reformat to one per line.

> +- on-off-gpio:   the GPIO that controls the module's on-off toggle input

Does enable-gpios or powerdown-gpios work as those are semi-standard 
names. Also, need to state the active state.

> +
> +Optional properties:
> +- lna-suppy: an (optional) LNA regulator that is enabled together with the 
> GPS receiver

typo

> +
> +Example:
> +
> + {
> + gps: w2sg0004 {

w2sg0004: gps {

The node name should be generic. The label can be whatever you like.

> + compatible = "wi2wi,w2sg0004";
> + lna-supply = <>;   /* LNA regulator */
> + on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
> trigger for turning on/off w2sg0004 */
> +};
> +};
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index c03d20140366..c56b3181b266 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -345,6 +345,7 @@ voipacVoipac Technologies s.r.o.
>  wd   Western Digital Corp.
>  wetekWeTek Electronics, limited.
>  wexler   Wexler
> +wi2wiWi2Wi, Inc.
>  winbond Winbond Electronics corp.
>  winstar  Winstar Display Corp.
>  wlf  Wolfson Microelectronics


Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-05-30 Thread Rob Herring
On Sun, May 21, 2017 at 12:44:03PM +0200, H. Nikolaus Schaller wrote:
> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
> 
> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn
> and turn on/off the module. It also detects if the module is turned on (sends 
> data)
> but should be off, e.g. if it was already turned on during boot or 
> power-on-reset.
> 
> Additionally, rfkill block/unblock can be used to control an external LNA
> (and power down the module if not needed).
> 
> The driver concept is based on code developed by NeilBrown 
> but simplified and adapted to use the new serdev API introduced in 4.11.
> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
>  .../devicetree/bindings/misc/wi2wi,w2sg0004.txt|  20 +
>  .../devicetree/bindings/vendor-prefixes.txt|   1 +

Please split binding patches.

>  drivers/misc/Kconfig   |  16 +
>  drivers/misc/Makefile  |   1 +
>  drivers/misc/w2sg0004.c| 646 
> +
>  include/linux/w2sg0004.h   |  27 +
>  6 files changed, 711 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
>  create mode 100644 drivers/misc/w2sg0004.c
>  create mode 100644 include/linux/w2sg0004.h
> 
> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> new file mode 100644
> index ..b7125c7a598c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> @@ -0,0 +1,20 @@
> +Wi2Wi GPS module connected through UART
> +
> +Should be a subnode of the SoC UART it is connected to (serdev).
> +
> +Required properties:
> +- compatible:wi2wi,w2sg0004 or wi2wi,w2sg0084

Reformat to one per line.

> +- on-off-gpio:   the GPIO that controls the module's on-off toggle input

Does enable-gpios or powerdown-gpios work as those are semi-standard 
names. Also, need to state the active state.

> +
> +Optional properties:
> +- lna-suppy: an (optional) LNA regulator that is enabled together with the 
> GPS receiver

typo

> +
> +Example:
> +
> + {
> + gps: w2sg0004 {

w2sg0004: gps {

The node name should be generic. The label can be whatever you like.

> + compatible = "wi2wi,w2sg0004";
> + lna-supply = <>;   /* LNA regulator */
> + on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
> trigger for turning on/off w2sg0004 */
> +};
> +};
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index c03d20140366..c56b3181b266 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -345,6 +345,7 @@ voipacVoipac Technologies s.r.o.
>  wd   Western Digital Corp.
>  wetekWeTek Electronics, limited.
>  wexler   Wexler
> +wi2wiWi2Wi, Inc.
>  winbond Winbond Electronics corp.
>  winstar  Winstar Display Corp.
>  wlf  Wolfson Microelectronics


Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-05-21 Thread H. Nikolaus Schaller

> Am 21.05.2017 um 12:44 schrieb H. Nikolaus Schaller :
> 
> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
> 
> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn

s/BTn/GPSn/

> and turn on/off the module. It also detects if the module is turned on (sends 
> data)
> but should be off, e.g. if it was already turned on during boot or 
> power-on-reset.
> 
> Additionally, rfkill block/unblock can be used to control an external LNA
> (and power down the module if not needed).
> 
> The driver concept is based on code developed by NeilBrown 
> but simplified and adapted to use the new serdev API introduced in 4.11.
> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
> .../devicetree/bindings/misc/wi2wi,w2sg0004.txt|  20 +
> .../devicetree/bindings/vendor-prefixes.txt|   1 +
> drivers/misc/Kconfig   |  16 +
> drivers/misc/Makefile  |   1 +
> drivers/misc/w2sg0004.c| 646 +
> include/linux/w2sg0004.h   |  27 +
> 6 files changed, 711 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> create mode 100644 drivers/misc/w2sg0004.c
> create mode 100644 include/linux/w2sg0004.h
> 
> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> new file mode 100644
> index ..b7125c7a598c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> @@ -0,0 +1,20 @@
> +Wi2Wi GPS module connected through UART
> +
> +Should be a subnode of the SoC UART it is connected to (serdev).
> +
> +Required properties:
> +- compatible:wi2wi,w2sg0004 or wi2wi,w2sg0084
> +- on-off-gpio:   the GPIO that controls the module's on-off toggle input
> +
> +Optional properties:
> +- lna-suppy: an (optional) LNA regulator that is enabled together with the 
> GPS receiver
> +
> +Example:
> +
> + {
> + gps: w2sg0004 {
> + compatible = "wi2wi,w2sg0004";
> + lna-supply = <>;   /* LNA regulator */
> + on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
> trigger for turning on/off w2sg0004 */
> +};
> +};
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index c03d20140366..c56b3181b266 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -345,6 +345,7 @@ voipacVoipac Technologies s.r.o.
> wdWestern Digital Corp.
> wetek WeTek Electronics, limited.
> wexlerWexler
> +wi2wiWi2Wi, Inc.
> winbond Winbond Electronics corp.
> winstar   Winstar Display Corp.
> wlf   Wolfson Microelectronics
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 60f876b03586..7f97ef8fb6cd 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -509,4 +509,20 @@ source "drivers/misc/mic/Kconfig"
> source "drivers/misc/genwqe/Kconfig"
> source "drivers/misc/echo/Kconfig"
> source "drivers/misc/cxl/Kconfig"
> +
> +config W2SG0004
> + tristate "W2SG00x4 on/off control"
> + depends on GPIOLIB && SERIAL_DEV_BUS
> + help
> +  Enable on/off control of W2SG00x4 GPS moduled connected
> +   to some SoC UART to allow powering up/down if the /dev/ttyGPSn
> +   is opened/closed.
> +   It also provides a rfkill gps name to control the LNA power.
> +
> +config W2SG0004_DEBUG
> + bool "W2SG0004 on/off debugging"
> + depends on W2SG0004
> + help
> +   Enable driver debugging mode of W2SG0004 GPS.
> +
> endmenu
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 81ef3e67acc9..0e88e06e5ee0 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -50,6 +50,7 @@ obj-$(CONFIG_SRAM_EXEC) += sram-exec.o
> obj-y += mic/
> obj-$(CONFIG_GENWQE)  += genwqe/
> obj-$(CONFIG_ECHO)+= echo/
> +obj-$(CONFIG_W2SG0004)   += w2sg0004.o
> obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
> obj-$(CONFIG_CXL_BASE)+= cxl/
> obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o
> diff --git a/drivers/misc/w2sg0004.c b/drivers/misc/w2sg0004.c
> new file mode 100644
> index ..1b335317c8ac
> --- /dev/null
> +++ b/drivers/misc/w2sg0004.c
> @@ -0,0 +1,646 @@
> +/*
> + * w2sg0004.c
> + * Driver for power controlling the w2sg0004/w2sg0084 GPS receiver.
> + *
> + * This receiver has an ON/OFF pin which must be toggled to
> + * turn the device 'on' of 'off'.  A high->low->high toggle
> + * will switch the device on if it is off, and off if it is on.
> + *
> + * To enable receiving on/off requests we register with the
> + * UART power management notifications.
> + *
> + * It is not possible to 

Re: [RFC 2/3] misc: Add w2sg0004 (gps receiver) power control driver

2017-05-21 Thread H. Nikolaus Schaller

> Am 21.05.2017 um 12:44 schrieb H. Nikolaus Schaller :
> 
> Add driver for Wi2Wi W2SG0004/84 GPS module connected through uart.
> 
> Use serdev API hooks to monitor and forward the UART traffic to /dev/BTn

s/BTn/GPSn/

> and turn on/off the module. It also detects if the module is turned on (sends 
> data)
> but should be off, e.g. if it was already turned on during boot or 
> power-on-reset.
> 
> Additionally, rfkill block/unblock can be used to control an external LNA
> (and power down the module if not needed).
> 
> The driver concept is based on code developed by NeilBrown 
> but simplified and adapted to use the new serdev API introduced in 4.11.
> 
> Signed-off-by: H. Nikolaus Schaller 
> ---
> .../devicetree/bindings/misc/wi2wi,w2sg0004.txt|  20 +
> .../devicetree/bindings/vendor-prefixes.txt|   1 +
> drivers/misc/Kconfig   |  16 +
> drivers/misc/Makefile  |   1 +
> drivers/misc/w2sg0004.c| 646 +
> include/linux/w2sg0004.h   |  27 +
> 6 files changed, 711 insertions(+)
> create mode 100644 Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> create mode 100644 drivers/misc/w2sg0004.c
> create mode 100644 include/linux/w2sg0004.h
> 
> diff --git a/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt 
> b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> new file mode 100644
> index ..b7125c7a598c
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/misc/wi2wi,w2sg0004.txt
> @@ -0,0 +1,20 @@
> +Wi2Wi GPS module connected through UART
> +
> +Should be a subnode of the SoC UART it is connected to (serdev).
> +
> +Required properties:
> +- compatible:wi2wi,w2sg0004 or wi2wi,w2sg0084
> +- on-off-gpio:   the GPIO that controls the module's on-off toggle input
> +
> +Optional properties:
> +- lna-suppy: an (optional) LNA regulator that is enabled together with the 
> GPS receiver
> +
> +Example:
> +
> + {
> + gps: w2sg0004 {
> + compatible = "wi2wi,w2sg0004";
> + lna-supply = <>;   /* LNA regulator */
> + on-off-gpios = < 17 GPIO_ACTIVE_HIGH>;/* GPIO_145: 
> trigger for turning on/off w2sg0004 */
> +};
> +};
> diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
> b/Documentation/devicetree/bindings/vendor-prefixes.txt
> index c03d20140366..c56b3181b266 100644
> --- a/Documentation/devicetree/bindings/vendor-prefixes.txt
> +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
> @@ -345,6 +345,7 @@ voipacVoipac Technologies s.r.o.
> wdWestern Digital Corp.
> wetek WeTek Electronics, limited.
> wexlerWexler
> +wi2wiWi2Wi, Inc.
> winbond Winbond Electronics corp.
> winstar   Winstar Display Corp.
> wlf   Wolfson Microelectronics
> diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
> index 60f876b03586..7f97ef8fb6cd 100644
> --- a/drivers/misc/Kconfig
> +++ b/drivers/misc/Kconfig
> @@ -509,4 +509,20 @@ source "drivers/misc/mic/Kconfig"
> source "drivers/misc/genwqe/Kconfig"
> source "drivers/misc/echo/Kconfig"
> source "drivers/misc/cxl/Kconfig"
> +
> +config W2SG0004
> + tristate "W2SG00x4 on/off control"
> + depends on GPIOLIB && SERIAL_DEV_BUS
> + help
> +  Enable on/off control of W2SG00x4 GPS moduled connected
> +   to some SoC UART to allow powering up/down if the /dev/ttyGPSn
> +   is opened/closed.
> +   It also provides a rfkill gps name to control the LNA power.
> +
> +config W2SG0004_DEBUG
> + bool "W2SG0004 on/off debugging"
> + depends on W2SG0004
> + help
> +   Enable driver debugging mode of W2SG0004 GPS.
> +
> endmenu
> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
> index 81ef3e67acc9..0e88e06e5ee0 100644
> --- a/drivers/misc/Makefile
> +++ b/drivers/misc/Makefile
> @@ -50,6 +50,7 @@ obj-$(CONFIG_SRAM_EXEC) += sram-exec.o
> obj-y += mic/
> obj-$(CONFIG_GENWQE)  += genwqe/
> obj-$(CONFIG_ECHO)+= echo/
> +obj-$(CONFIG_W2SG0004)   += w2sg0004.o
> obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o
> obj-$(CONFIG_CXL_BASE)+= cxl/
> obj-$(CONFIG_ASPEED_LPC_CTRL) += aspeed-lpc-ctrl.o
> diff --git a/drivers/misc/w2sg0004.c b/drivers/misc/w2sg0004.c
> new file mode 100644
> index ..1b335317c8ac
> --- /dev/null
> +++ b/drivers/misc/w2sg0004.c
> @@ -0,0 +1,646 @@
> +/*
> + * w2sg0004.c
> + * Driver for power controlling the w2sg0004/w2sg0084 GPS receiver.
> + *
> + * This receiver has an ON/OFF pin which must be toggled to
> + * turn the device 'on' of 'off'.  A high->low->high toggle
> + * will switch the device on if it is off, and off if it is on.
> + *
> + * To enable receiving on/off requests we register with the
> + * UART power management notifications.
> + *
> + * It is not possible to directly detect the state of the device.
> + * However when it