Commit 044591a6 authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'w1-drv-6.9' of...

Merge tag 'w1-drv-6.9' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1 into tty-next

Krzysztof writes:

1-Wire bus drivers for v6.9

1. Few cleanups: constifying, convert platform remove callback returning
   void.

2. Add UART 1-Wire bus driver which uses UART interface to create the
   1-Wire timing patterns.

* tag 'w1-drv-6.9' of https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-w1:
  w1: w1-gpio: Convert to platform remove callback returning void
  w1: sgi_w1: Convert to platform remove callback returning void
  w1: omap_hdq: Convert to platform remove callback returning void
  w1: mxc_w1: Convert to platform remove callback returning void
  w1: add UART w1 bus driver
  dt-bindings: w1: UART 1-Wire bus
  dt-bindings: serial: allow onewire as child node
  w1: make w1_bus_type const
parents 13a44ba0 d97d2631
......@@ -88,7 +88,7 @@ properties:
TX FIFO threshold configuration (in bytes).
patternProperties:
"^(bluetooth|bluetooth-gnss|gnss|gps|mcu)$":
"^(bluetooth|bluetooth-gnss|gnss|gps|mcu|onewire)$":
if:
type: object
then:
......
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/w1/w1-uart.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#
title: UART 1-Wire Bus
maintainers:
- Christoph Winklhofer <cj.winklhofer@gmail.com>
description: |
UART 1-wire bus. Utilizes the UART interface via the Serial Device Bus
to create the 1-Wire timing patterns.
The UART peripheral must support full-duplex and operate in open-drain
mode. The timing patterns are generated by a specific combination of
baud-rate and transmitted byte, which corresponds to a 1-Wire read bit,
write bit or reset pulse.
The default baud-rate for reset and presence detection is 9600 and for
a 1-Wire read or write operation 115200. In case the actual baud-rate
is different from the requested one, the transmitted byte is adapted
to generate the 1-Wire timing patterns.
https://www.analog.com/en/technical-articles/using-a-uart-to-implement-a-1wire-bus-master.html
properties:
compatible:
const: w1-uart
reset-bps:
default: 9600
description:
The baud rate for the 1-Wire reset and presence detect.
write-0-bps:
default: 115200
description:
The baud rate for the 1-Wire write-0 cycle.
write-1-bps:
default: 115200
description:
The baud rate for the 1-Wire write-1 and read cycle.
required:
- compatible
additionalProperties:
type: object
examples:
- |
serial {
onewire {
compatible = "w1-uart";
};
};
......@@ -12,3 +12,4 @@
mxc-w1
omap-hdq
w1-gpio
w1-uart
.. SPDX-License-Identifier: GPL-2.0-or-later
=====================
Kernel driver w1-uart
=====================
Author: Christoph Winklhofer <cj.winklhofer@gmail.com>
Description
-----------
UART 1-Wire bus driver. The driver utilizes the UART interface via the
Serial Device Bus to create the 1-Wire timing patterns as described in
the document `"Using a UART to Implement a 1-Wire Bus Master"`_.
.. _"Using a UART to Implement a 1-Wire Bus Master": https://www.analog.com/en/technical-articles/using-a-uart-to-implement-a-1wire-bus-master.html
In short, the UART peripheral must support full-duplex and operate in
open-drain mode. The timing patterns are generated by a specific
combination of baud-rate and transmitted byte, which corresponds to a
1-Wire read bit, write bit or reset pulse.
For instance the timing pattern for a 1-Wire reset and presence detect uses
the baud-rate 9600, i.e. 104.2 us per bit. The transmitted byte 0xf0 over
UART (least significant bit first, start-bit low) sets the reset low time
for 1-Wire to 521 us. A present 1-Wire device changes the received byte by
pulling the line low, which is used by the driver to evaluate the result of
the 1-Wire operation.
Similar for a 1-Wire read bit or write bit, which uses the baud-rate
115200, i.e. 8.7 us per bit. The transmitted byte 0x80 is used for a
Write-0 operation (low time 69.6us) and the byte 0xff for Read-0, Read-1
and Write-1 (low time 8.7us).
The default baud-rate for reset and presence detection is 9600 and for
a 1-Wire read or write operation 115200. In case the actual baud-rate
is different from the requested one, the transmitted byte is adapted
to generate the 1-Wire timing patterns.
Usage
-----
Specify the UART 1-wire bus in the device tree by adding the single child
onewire to the serial node (e.g. uart0). For example:
::
@uart0 {
...
onewire {
compatible = "w1-uart";
};
};
......@@ -78,5 +78,15 @@ config W1_MASTER_SGI
This support is also available as a module. If so, the module
will be called sgi_w1.
config W1_MASTER_UART
tristate "UART 1-wire driver"
depends on SERIAL_DEV_BUS
help
Say Y here if you want to communicate with your 1-wire devices using
UART interface.
This support is also available as a module. If so, the module
will be called w1-uart.
endmenu
......@@ -12,3 +12,4 @@ obj-$(CONFIG_W1_MASTER_MXC) += mxc_w1.o
obj-$(CONFIG_W1_MASTER_GPIO) += w1-gpio.o
obj-$(CONFIG_HDQ_MASTER_OMAP) += omap_hdq.o
obj-$(CONFIG_W1_MASTER_SGI) += sgi_w1.o
obj-$(CONFIG_W1_MASTER_UART) += w1-uart.o
......@@ -151,15 +151,13 @@ static int mxc_w1_probe(struct platform_device *pdev)
/*
* disassociate the w1 device from the driver
*/
static int mxc_w1_remove(struct platform_device *pdev)
static void mxc_w1_remove(struct platform_device *pdev)
{
struct mxc_w1_device *mdev = platform_get_drvdata(pdev);
w1_remove_master_device(&mdev->bus_master);
clk_disable_unprepare(mdev->clk);
return 0;
}
static const struct of_device_id mxc_w1_dt_ids[] = {
......@@ -174,7 +172,7 @@ static struct platform_driver mxc_w1_driver = {
.of_match_table = mxc_w1_dt_ids,
},
.probe = mxc_w1_probe,
.remove = mxc_w1_remove,
.remove_new = mxc_w1_remove,
};
module_platform_driver(mxc_w1_driver);
......
......@@ -647,7 +647,7 @@ static int omap_hdq_probe(struct platform_device *pdev)
return ret;
}
static int omap_hdq_remove(struct platform_device *pdev)
static void omap_hdq_remove(struct platform_device *pdev)
{
int active;
......@@ -661,8 +661,6 @@ static int omap_hdq_remove(struct platform_device *pdev)
if (active >= 0)
pm_runtime_put_sync(&pdev->dev);
pm_runtime_disable(&pdev->dev);
return 0;
}
static const struct of_device_id omap_hdq_dt_ids[] = {
......@@ -674,7 +672,7 @@ MODULE_DEVICE_TABLE(of, omap_hdq_dt_ids);
static struct platform_driver omap_hdq_driver = {
.probe = omap_hdq_probe,
.remove = omap_hdq_remove,
.remove_new = omap_hdq_remove,
.driver = {
.name = "omap_hdq",
.of_match_table = omap_hdq_dt_ids,
......
......@@ -105,13 +105,11 @@ static int sgi_w1_probe(struct platform_device *pdev)
/*
* disassociate the w1 device from the driver
*/
static int sgi_w1_remove(struct platform_device *pdev)
static void sgi_w1_remove(struct platform_device *pdev)
{
struct sgi_w1_device *sdev = platform_get_drvdata(pdev);
w1_remove_master_device(&sdev->bus_master);
return 0;
}
static struct platform_driver sgi_w1_driver = {
......@@ -119,7 +117,7 @@ static struct platform_driver sgi_w1_driver = {
.name = "sgi_w1",
},
.probe = sgi_w1_probe,
.remove = sgi_w1_remove,
.remove_new = sgi_w1_remove,
};
module_platform_driver(sgi_w1_driver);
......
......@@ -141,7 +141,7 @@ static int w1_gpio_probe(struct platform_device *pdev)
return 0;
}
static int w1_gpio_remove(struct platform_device *pdev)
static void w1_gpio_remove(struct platform_device *pdev)
{
struct w1_bus_master *master = platform_get_drvdata(pdev);
struct w1_gpio_ddata *ddata = master->data;
......@@ -150,8 +150,6 @@ static int w1_gpio_remove(struct platform_device *pdev)
gpiod_set_value(ddata->pullup_gpiod, 0);
w1_remove_master_device(master);
return 0;
}
static struct platform_driver w1_gpio_driver = {
......@@ -160,7 +158,7 @@ static struct platform_driver w1_gpio_driver = {
.of_match_table = of_match_ptr(w1_gpio_dt_ids),
},
.probe = w1_gpio_probe,
.remove = w1_gpio_remove,
.remove_new = w1_gpio_remove,
};
module_platform_driver(w1_gpio_driver);
......
This diff is collapsed.
......@@ -167,7 +167,7 @@ static struct w1_family w1_default_family = {
static int w1_uevent(const struct device *dev, struct kobj_uevent_env *env);
static struct bus_type w1_bus_type = {
static const struct bus_type w1_bus_type = {
.name = "w1",
.uevent = w1_uevent,
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment