* Re: [RFC 3/4] max9260: add driver for i2c over GMSL passthrough
From: Peter Rosin @ 2017-06-15 7:09 UTC (permalink / raw)
To: Ulrich Hecht, robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c
In-Reply-To: <1497451130-7741-4-git-send-email-ulrich.hecht+renesas@gmail.com>
On 2017-06-14 16:38, Ulrich Hecht wrote:
> This driver implements tunnelling of i2c requests over GMSL via a
> MAX9260 deserializer. It provides an i2c adapter that can be used
> to reach devices on the far side of the link.
>
> Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
> ---
> drivers/media/i2c/Kconfig | 6 +
> drivers/media/i2c/Makefile | 1 +
> drivers/media/i2c/max9260.c | 294 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 301 insertions(+)
> create mode 100644 drivers/media/i2c/max9260.c
>
> diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
> index 7c23b7a..743f8ee 100644
> --- a/drivers/media/i2c/Kconfig
> +++ b/drivers/media/i2c/Kconfig
> @@ -400,6 +400,12 @@ config VIDEO_VPX3220
> To compile this driver as a module, choose M here: the
> module will be called vpx3220.
>
> +config VIDEO_MAX9260
> + tristate "Maxim MAX9260 GMSL deserializer support"
> + depends on I2C
> + ---help---
> + This driver supports the Maxim MAX9260 GMSL deserializer.
> +
> comment "Video and audio decoders"
>
> config VIDEO_SAA717X
> diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
> index 62323ec..9b2fd13 100644
> --- a/drivers/media/i2c/Makefile
> +++ b/drivers/media/i2c/Makefile
> @@ -86,3 +86,4 @@ obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
> obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o
> obj-$(CONFIG_VIDEO_OV2659) += ov2659.o
> obj-$(CONFIG_VIDEO_TC358743) += tc358743.o
> +obj-$(CONFIG_VIDEO_MAX9260) += max9260.o
> diff --git a/drivers/media/i2c/max9260.c b/drivers/media/i2c/max9260.c
> new file mode 100644
> index 0000000..2030eb0
> --- /dev/null
> +++ b/drivers/media/i2c/max9260.c
> @@ -0,0 +1,294 @@
> +/*
> + * Maxim MAX9260 GMSL Deserializer Driver
> + *
> + * Copyright (C) 2017 Ulrich Hecht
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of the GNU General Public License as published by the
> + * Free Software Foundation; either version 2 of the License, or (at your
> + * option) any later version.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/i2c.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/of_gpio.h>
> +#include <linux/serdev.h>
> +#include <linux/slab.h>
> +#include <linux/tty.h>
> +
> +#define SYNC 0x79
> +#define ACK 0xc3
> +
> +#define RX_FINISHED 0
> +#define RX_FRAME_ERROR 1
> +#define RX_EXPECT_ACK 2
> +#define RX_EXPECT_ACK_DATA 3
> +#define RX_EXPECT_DATA 4
> +
> +struct max9260_device {
> + struct serdev_device *serdev;
> + u8 *rx_buf;
> + int rx_len;
> + int rx_state;
> + wait_queue_head_t rx_wq;
> + struct i2c_adapter adap;
> +};
> +
> +static void wait_for_transaction(struct max9260_device *dev)
> +{
> + wait_event_interruptible_timeout(dev->rx_wq,
> + dev->rx_state <= RX_FRAME_ERROR,
> + HZ/2);
> +}
> +
> +static void transact(struct max9260_device *dev,
> + int expect,
> + u8 *request, int len)
> +{
> + serdev_device_mux_select(dev->serdev);
You don't check the return value here...
> +
> + serdev_device_set_baudrate(dev->serdev, 115200);
> + serdev_device_set_parity(dev->serdev, 1, 0);
> +
> + dev->rx_state = expect;
> + serdev_device_write_buf(dev->serdev, request, len);
> +
> + wait_for_transaction(dev);
> +
> + serdev_device_mux_deselect(dev->serdev);
...and unconditionally deselect the mux here. I.e. a potential
unlock of an unlocked mutex...
Cheers,
peda
> +}
> +
> +static int max9260_read_reg(struct max9260_device *dev, int reg)
> +{
> + u8 request[] = { 0x79, 0x91, reg, 1 };
> + u8 rx;
> +
> + dev->rx_len = 1;
> + dev->rx_buf = ℞
> +
> + transact(dev, RX_EXPECT_ACK_DATA, request, 4);
> +
> + if (dev->rx_state == RX_FINISHED)
> + return rx;
> +
> + return -1;
> +}
> +
> +static int max9260_setup(struct max9260_device *dev)
> +{
> + int ret;
> +
> + ret = max9260_read_reg(dev, 0x1e);
> +
> + if (ret != 0x02) {
> + dev_err(&dev->serdev->dev,
> + "device does not identify as MAX9260\n");
> + return -EINVAL;
> + }
> +
> + return 0;
> +}
> +
> +static void max9260_uart_write_wakeup(struct serdev_device *serdev)
> +{
> +}
> +
> +static int max9260_uart_receive_buf(struct serdev_device *serdev,
> + const u8 *data, size_t count)
> +{
> + struct max9260_device *dev = serdev_device_get_drvdata(serdev);
> + int accepted;
> +
> + switch (dev->rx_state) {
> + case RX_FINISHED:
> + dev_dbg(&dev->serdev->dev, "excess data ignored\n");
> + return count;
> +
> + case RX_EXPECT_ACK:
> + case RX_EXPECT_ACK_DATA:
> + if (data[0] != ACK) {
> + dev_dbg(&dev->serdev->dev, "frame error");
> + dev->rx_state = RX_FRAME_ERROR;
> + wake_up_interruptible(&dev->rx_wq);
> + return 1;
> + }
> + switch (dev->rx_state) {
> + case RX_EXPECT_ACK_DATA:
> + dev->rx_state = RX_EXPECT_DATA;
> + break;
> + case RX_EXPECT_ACK:
> + dev->rx_state = RX_FINISHED;
> + wake_up_interruptible(&dev->rx_wq);
> + break;
> + }
> + return 1;
> +
> + case RX_EXPECT_DATA:
> + accepted = dev->rx_len < count ? dev->rx_len : count;
> +
> + memcpy(dev->rx_buf, data, accepted);
> +
> + dev->rx_len -= accepted;
> + dev->rx_buf += accepted;
> +
> + if (!dev->rx_len) {
> + dev->rx_state = RX_FINISHED;
> + wake_up_interruptible(&dev->rx_wq);
> + }
> +
> + return accepted;
> +
> + case RX_FRAME_ERROR:
> + dev_dbg(&dev->serdev->dev, "%d bytes ignored\n", count);
> + return count;
> +
> + }
> + return 0;
> +}
> +
> +struct serdev_device_ops max9260_serdev_client_ops = {
> + .receive_buf = max9260_uart_receive_buf,
> + .write_wakeup = max9260_uart_write_wakeup,
> +};
> +
> +static u32 max9260_i2c_func(struct i2c_adapter *adapter)
> +{
> + return I2C_FUNC_SMBUS_EMUL;
> +}
> +
> +static s32 max9260_smbus_xfer(struct i2c_adapter *adap, u16 addr,
> + unsigned short flags, char read_write, u8 command, int size,
> + union i2c_smbus_data *data)
> +{
> + u8 request[] = { SYNC,
> + (addr << 1) + (read_write == I2C_SMBUS_READ),
> + command, 0, 0 };
> + struct max9260_device *dev = i2c_get_adapdata(adap);
> +
> + switch (size) {
> + case I2C_SMBUS_BYTE:
> + if (read_write == I2C_SMBUS_WRITE) {
> + transact(dev, RX_EXPECT_ACK, request, 4);
> + dev_dbg(&adap->dev,
> + "smbus byte - addr 0x%02x, wrote 0x%02x.\n",
> + addr, command);
> + } else {
> + /* TBD */
> + return -EOPNOTSUPP;
> + }
> + break;
> +
> + case I2C_SMBUS_BYTE_DATA:
> + request[3] = 1;
> + if (read_write == I2C_SMBUS_WRITE) {
> + request[4] = data->byte;
> + transact(dev, RX_EXPECT_ACK, request, 5);
> + dev_dbg(&adap->dev,
> + "smbus byte data - addr 0x%02x, wrote 0x%02x at 0x%02x.\n",
> + addr, data->byte, command);
> + } else {
> + dev->rx_len = 1;
> + dev->rx_buf = &data->byte;
> + transact(dev, RX_EXPECT_ACK_DATA, request, 4);
> + dev_dbg(&adap->dev,
> + "smbus byte data - addr 0x%02x, read 0x%02x at 0x%02x.\n",
> + addr, data->byte, command);
> + }
> + break;
> + default:
> + dev_dbg(&adap->dev,
> + "Unsupported I2C/SMBus command %d\n", size);
> + return -EOPNOTSUPP;
> + }
> +
> + if (dev->rx_state != RX_FINISHED) {
> + dev_dbg(&adap->dev, "xfer timed out\n");
> + return -EIO;
> + }
> +
> + return 0;
> +}
> +
> +static const struct i2c_algorithm max9260_i2c_algorithm = {
> + .functionality = max9260_i2c_func,
> + .smbus_xfer = max9260_smbus_xfer,
> +};
> +
> +static int max9260_probe(struct serdev_device *serdev)
> +{
> + struct max9260_device *dev;
> + struct i2c_adapter *adap;
> + int ret;
> +
> + dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> + if (!dev)
> + return -ENOMEM;
> +
> + init_waitqueue_head(&dev->rx_wq);
> +
> + dev->serdev = serdev;
> + serdev_device_open(serdev);
> + serdev_device_set_drvdata(serdev, dev);
> +
> + serdev_device_set_client_ops(serdev, &max9260_serdev_client_ops);
> +
> + ret = max9260_setup(dev);
> +
> + if (ret < 0)
> + goto err_free;
> +
> + adap = &dev->adap;
> + i2c_set_adapdata(adap, dev);
> +
> + adap->owner = THIS_MODULE;
> + adap->algo = &max9260_i2c_algorithm;
> + adap->dev.parent = &serdev->dev;
> + adap->retries = 5;
> + adap->nr = -1;
> + strlcpy(adap->name, dev_name(&serdev->dev), sizeof(adap->name));
> +
> + ret = i2c_add_numbered_adapter(adap);
> + if (ret < 0) {
> + dev_err(&serdev->dev, "failed to register i2c adapter\n");
> + return ret;
> + }
> +
> + return 0;
> +
> +err_free:
> + kfree(dev);
> + return ret;
> +}
> +
> +static void max9260_remove(struct serdev_device *serdev)
> +{
> + struct max9260_device *dev = serdev_device_get_drvdata(serdev);
> +
> + serdev_device_close(dev->serdev);
> +
> + kfree(dev);
> +}
> +
> +static const struct of_device_id max9260_dt_ids[] = {
> + { .compatible = "maxim,max9260" },
> + {},
> +};
> +
> +MODULE_DEVICE_TABLE(of, max9260_dt_ids);
> +
> +static struct serdev_device_driver max9260_driver = {
> + .probe = max9260_probe,
> + .remove = max9260_remove,
> + .driver = {
> + .name = "max9260",
> + .of_match_table = of_match_ptr(max9260_dt_ids),
> + },
> +};
> +
> +module_serdev_device_driver(max9260_driver);
> +
> +MODULE_DESCRIPTION("Maxim MAX9260 GMSL Deserializer Driver");
> +MODULE_AUTHOR("Ulrich Hecht");
> +MODULE_LICENSE("GPL");
>
^ permalink raw reply
* Re: [RFC 0/4] serdev GPIO-based multiplexing support
From: Peter Rosin @ 2017-06-15 7:07 UTC (permalink / raw)
To: Ulrich Hecht, robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c
In-Reply-To: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com>
On 2017-06-14 16:38, Ulrich Hecht wrote:
> Hi!
>
> This is an attempt to add multiplexer support to serdev, specifically
> GPIO-based multiplexing.
>
> Our use case is the Renesas Blanche V2H board with several MAX9260 GMSL
> deserializers attached to one serial port. A sample driver that implements
> i2c passthrough over the GMSL link is part of this series. This device
> wants to be talked to with even parity, so a patch implementing parity
> control in serdev is included as well.
>
> The board-specific part of this series depends on the "pinctrl: sh-pfc:
> r8a7792: Add SCIF1 pin groups" patch.
>
> Please tell me if this is a suitable way to implement this functionality
> in serdev, or how to improve it. Thank you.
When I look at patch 2/4, I can't help but think that you should perhaps
consider the new mux framework available in linux-next [1]. But as the
author of that, I'm maybe biased...
You then support other means of controlling the mux automatically (i.e.
you get free support for non-gpio muxes). You also get support for
sharing the mux controller should the same gpio pins control muxes
for unrelated functions (which happened for my hw).
However, I see that you request the gpios when you select the mux, and
free them when you deselect it. That is not how the gpio mux in the
mux framework operates; it instead keeps the gpios requested and either
leaves the gpios as-is on deselect or sets a specific idle value. But
that is perhaps ok for this use-case too?
Cheers,
peda
[1] https://lkml.org/lkml/2017/5/14/160
> CU
> Uli
>
>
> Ulrich Hecht (4):
> serdev: add method to set parity
> serdev: add GPIO-based multiplexer support
> max9260: add driver for i2c over GMSL passthrough
> ARM: dts: blanche: add SCIF1 and MAX9260 deserializer
>
> arch/arm/boot/dts/r8a7792-blanche.dts | 45 ++++++
> drivers/media/i2c/Kconfig | 6 +
> drivers/media/i2c/Makefile | 1 +
> drivers/media/i2c/max9260.c | 294 ++++++++++++++++++++++++++++++++++
> drivers/tty/serdev/Kconfig | 3 +
> drivers/tty/serdev/Makefile | 1 +
> drivers/tty/serdev/core.c | 55 ++++++-
> drivers/tty/serdev/mux-gpio.c | 80 +++++++++
> drivers/tty/serdev/serdev-ttyport.c | 17 ++
> include/linux/serdev.h | 30 +++-
> 10 files changed, 528 insertions(+), 4 deletions(-)
> create mode 100644 drivers/media/i2c/max9260.c
> create mode 100644 drivers/tty/serdev/mux-gpio.c
>
^ permalink raw reply
* [RFC 4/4] ARM: dts: blanche: add SCIF1 and MAX9260 deserializer
From: Ulrich Hecht @ 2017-06-14 14:38 UTC (permalink / raw)
To: robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c,
Ulrich Hecht
In-Reply-To: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com>
Adds serial port SCIF1 and the MAX9260 deserializers connected to it.
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
arch/arm/boot/dts/r8a7792-blanche.dts | 45 +++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/arch/arm/boot/dts/r8a7792-blanche.dts b/arch/arm/boot/dts/r8a7792-blanche.dts
index 9b67dca..281484d 100644
--- a/arch/arm/boot/dts/r8a7792-blanche.dts
+++ b/arch/arm/boot/dts/r8a7792-blanche.dts
@@ -21,6 +21,7 @@
aliases {
serial0 = &scif0;
serial1 = &scif3;
+ serial2 = &scif1;
};
chosen {
@@ -202,6 +203,11 @@
function = "scif0";
};
+ scif1_pins: scif1 {
+ groups = "scif1_data";
+ function = "scif1";
+ };
+
scif3_pins: scif3 {
groups = "scif3_data";
function = "scif3";
@@ -246,6 +252,45 @@
status = "okay";
};
+&scif1 {
+ pinctrl-0 = <&scif1_pins>;
+ pinctrl-names = "default";
+
+ status = "okay";
+
+ mux-select-gpios = <&gpio5 12 GPIO_ACTIVE_LOW>,
+ <&gpio5 13 GPIO_ACTIVE_LOW>,
+ <&gpio5 14 GPIO_ACTIVE_LOW>,
+ <&gpio5 15 GPIO_ACTIVE_LOW>;
+
+ #address-cells = <1>;
+ #size-cells = <0>;
+ gmsl-deserializer@0 {
+ compatible = "maxim,max9260";
+ reg = <0x8>;
+ };
+ gmsl-deserializer@1 {
+ compatible = "maxim,max9260";
+ reg = <0x9>;
+ };
+ gmsl-deserializer@2 {
+ compatible = "maxim,max9260";
+ reg = <0xa>;
+ };
+ gmsl-deserializer@3 {
+ compatible = "maxim,max9260";
+ reg = <0xb>;
+ };
+ gmsl-deserializer@4 {
+ compatible = "maxim,max9260";
+ reg = <0x4>;
+ };
+ gmsl-deserializer@5 {
+ compatible = "maxim,max9260";
+ reg = <0x5>;
+ };
+};
+
&scif3 {
pinctrl-0 = <&scif3_pins>;
pinctrl-names = "default";
--
2.7.4
^ permalink raw reply related
* [RFC 3/4] max9260: add driver for i2c over GMSL passthrough
From: Ulrich Hecht @ 2017-06-14 14:38 UTC (permalink / raw)
To: robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c,
Ulrich Hecht
In-Reply-To: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com>
This driver implements tunnelling of i2c requests over GMSL via a
MAX9260 deserializer. It provides an i2c adapter that can be used
to reach devices on the far side of the link.
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
drivers/media/i2c/Kconfig | 6 +
drivers/media/i2c/Makefile | 1 +
drivers/media/i2c/max9260.c | 294 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 301 insertions(+)
create mode 100644 drivers/media/i2c/max9260.c
diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 7c23b7a..743f8ee 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -400,6 +400,12 @@ config VIDEO_VPX3220
To compile this driver as a module, choose M here: the
module will be called vpx3220.
+config VIDEO_MAX9260
+ tristate "Maxim MAX9260 GMSL deserializer support"
+ depends on I2C
+ ---help---
+ This driver supports the Maxim MAX9260 GMSL deserializer.
+
comment "Video and audio decoders"
config VIDEO_SAA717X
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 62323ec..9b2fd13 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -86,3 +86,4 @@ obj-$(CONFIG_VIDEO_IR_I2C) += ir-kbd-i2c.o
obj-$(CONFIG_VIDEO_ML86V7667) += ml86v7667.o
obj-$(CONFIG_VIDEO_OV2659) += ov2659.o
obj-$(CONFIG_VIDEO_TC358743) += tc358743.o
+obj-$(CONFIG_VIDEO_MAX9260) += max9260.o
diff --git a/drivers/media/i2c/max9260.c b/drivers/media/i2c/max9260.c
new file mode 100644
index 0000000..2030eb0
--- /dev/null
+++ b/drivers/media/i2c/max9260.c
@@ -0,0 +1,294 @@
+/*
+ * Maxim MAX9260 GMSL Deserializer Driver
+ *
+ * Copyright (C) 2017 Ulrich Hecht
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/of.h>
+#include <linux/of_gpio.h>
+#include <linux/serdev.h>
+#include <linux/slab.h>
+#include <linux/tty.h>
+
+#define SYNC 0x79
+#define ACK 0xc3
+
+#define RX_FINISHED 0
+#define RX_FRAME_ERROR 1
+#define RX_EXPECT_ACK 2
+#define RX_EXPECT_ACK_DATA 3
+#define RX_EXPECT_DATA 4
+
+struct max9260_device {
+ struct serdev_device *serdev;
+ u8 *rx_buf;
+ int rx_len;
+ int rx_state;
+ wait_queue_head_t rx_wq;
+ struct i2c_adapter adap;
+};
+
+static void wait_for_transaction(struct max9260_device *dev)
+{
+ wait_event_interruptible_timeout(dev->rx_wq,
+ dev->rx_state <= RX_FRAME_ERROR,
+ HZ/2);
+}
+
+static void transact(struct max9260_device *dev,
+ int expect,
+ u8 *request, int len)
+{
+ serdev_device_mux_select(dev->serdev);
+
+ serdev_device_set_baudrate(dev->serdev, 115200);
+ serdev_device_set_parity(dev->serdev, 1, 0);
+
+ dev->rx_state = expect;
+ serdev_device_write_buf(dev->serdev, request, len);
+
+ wait_for_transaction(dev);
+
+ serdev_device_mux_deselect(dev->serdev);
+}
+
+static int max9260_read_reg(struct max9260_device *dev, int reg)
+{
+ u8 request[] = { 0x79, 0x91, reg, 1 };
+ u8 rx;
+
+ dev->rx_len = 1;
+ dev->rx_buf = ℞
+
+ transact(dev, RX_EXPECT_ACK_DATA, request, 4);
+
+ if (dev->rx_state == RX_FINISHED)
+ return rx;
+
+ return -1;
+}
+
+static int max9260_setup(struct max9260_device *dev)
+{
+ int ret;
+
+ ret = max9260_read_reg(dev, 0x1e);
+
+ if (ret != 0x02) {
+ dev_err(&dev->serdev->dev,
+ "device does not identify as MAX9260\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static void max9260_uart_write_wakeup(struct serdev_device *serdev)
+{
+}
+
+static int max9260_uart_receive_buf(struct serdev_device *serdev,
+ const u8 *data, size_t count)
+{
+ struct max9260_device *dev = serdev_device_get_drvdata(serdev);
+ int accepted;
+
+ switch (dev->rx_state) {
+ case RX_FINISHED:
+ dev_dbg(&dev->serdev->dev, "excess data ignored\n");
+ return count;
+
+ case RX_EXPECT_ACK:
+ case RX_EXPECT_ACK_DATA:
+ if (data[0] != ACK) {
+ dev_dbg(&dev->serdev->dev, "frame error");
+ dev->rx_state = RX_FRAME_ERROR;
+ wake_up_interruptible(&dev->rx_wq);
+ return 1;
+ }
+ switch (dev->rx_state) {
+ case RX_EXPECT_ACK_DATA:
+ dev->rx_state = RX_EXPECT_DATA;
+ break;
+ case RX_EXPECT_ACK:
+ dev->rx_state = RX_FINISHED;
+ wake_up_interruptible(&dev->rx_wq);
+ break;
+ }
+ return 1;
+
+ case RX_EXPECT_DATA:
+ accepted = dev->rx_len < count ? dev->rx_len : count;
+
+ memcpy(dev->rx_buf, data, accepted);
+
+ dev->rx_len -= accepted;
+ dev->rx_buf += accepted;
+
+ if (!dev->rx_len) {
+ dev->rx_state = RX_FINISHED;
+ wake_up_interruptible(&dev->rx_wq);
+ }
+
+ return accepted;
+
+ case RX_FRAME_ERROR:
+ dev_dbg(&dev->serdev->dev, "%d bytes ignored\n", count);
+ return count;
+
+ }
+ return 0;
+}
+
+struct serdev_device_ops max9260_serdev_client_ops = {
+ .receive_buf = max9260_uart_receive_buf,
+ .write_wakeup = max9260_uart_write_wakeup,
+};
+
+static u32 max9260_i2c_func(struct i2c_adapter *adapter)
+{
+ return I2C_FUNC_SMBUS_EMUL;
+}
+
+static s32 max9260_smbus_xfer(struct i2c_adapter *adap, u16 addr,
+ unsigned short flags, char read_write, u8 command, int size,
+ union i2c_smbus_data *data)
+{
+ u8 request[] = { SYNC,
+ (addr << 1) + (read_write == I2C_SMBUS_READ),
+ command, 0, 0 };
+ struct max9260_device *dev = i2c_get_adapdata(adap);
+
+ switch (size) {
+ case I2C_SMBUS_BYTE:
+ if (read_write == I2C_SMBUS_WRITE) {
+ transact(dev, RX_EXPECT_ACK, request, 4);
+ dev_dbg(&adap->dev,
+ "smbus byte - addr 0x%02x, wrote 0x%02x.\n",
+ addr, command);
+ } else {
+ /* TBD */
+ return -EOPNOTSUPP;
+ }
+ break;
+
+ case I2C_SMBUS_BYTE_DATA:
+ request[3] = 1;
+ if (read_write == I2C_SMBUS_WRITE) {
+ request[4] = data->byte;
+ transact(dev, RX_EXPECT_ACK, request, 5);
+ dev_dbg(&adap->dev,
+ "smbus byte data - addr 0x%02x, wrote 0x%02x at 0x%02x.\n",
+ addr, data->byte, command);
+ } else {
+ dev->rx_len = 1;
+ dev->rx_buf = &data->byte;
+ transact(dev, RX_EXPECT_ACK_DATA, request, 4);
+ dev_dbg(&adap->dev,
+ "smbus byte data - addr 0x%02x, read 0x%02x at 0x%02x.\n",
+ addr, data->byte, command);
+ }
+ break;
+ default:
+ dev_dbg(&adap->dev,
+ "Unsupported I2C/SMBus command %d\n", size);
+ return -EOPNOTSUPP;
+ }
+
+ if (dev->rx_state != RX_FINISHED) {
+ dev_dbg(&adap->dev, "xfer timed out\n");
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static const struct i2c_algorithm max9260_i2c_algorithm = {
+ .functionality = max9260_i2c_func,
+ .smbus_xfer = max9260_smbus_xfer,
+};
+
+static int max9260_probe(struct serdev_device *serdev)
+{
+ struct max9260_device *dev;
+ struct i2c_adapter *adap;
+ int ret;
+
+ dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
+
+ init_waitqueue_head(&dev->rx_wq);
+
+ dev->serdev = serdev;
+ serdev_device_open(serdev);
+ serdev_device_set_drvdata(serdev, dev);
+
+ serdev_device_set_client_ops(serdev, &max9260_serdev_client_ops);
+
+ ret = max9260_setup(dev);
+
+ if (ret < 0)
+ goto err_free;
+
+ adap = &dev->adap;
+ i2c_set_adapdata(adap, dev);
+
+ adap->owner = THIS_MODULE;
+ adap->algo = &max9260_i2c_algorithm;
+ adap->dev.parent = &serdev->dev;
+ adap->retries = 5;
+ adap->nr = -1;
+ strlcpy(adap->name, dev_name(&serdev->dev), sizeof(adap->name));
+
+ ret = i2c_add_numbered_adapter(adap);
+ if (ret < 0) {
+ dev_err(&serdev->dev, "failed to register i2c adapter\n");
+ return ret;
+ }
+
+ return 0;
+
+err_free:
+ kfree(dev);
+ return ret;
+}
+
+static void max9260_remove(struct serdev_device *serdev)
+{
+ struct max9260_device *dev = serdev_device_get_drvdata(serdev);
+
+ serdev_device_close(dev->serdev);
+
+ kfree(dev);
+}
+
+static const struct of_device_id max9260_dt_ids[] = {
+ { .compatible = "maxim,max9260" },
+ {},
+};
+
+MODULE_DEVICE_TABLE(of, max9260_dt_ids);
+
+static struct serdev_device_driver max9260_driver = {
+ .probe = max9260_probe,
+ .remove = max9260_remove,
+ .driver = {
+ .name = "max9260",
+ .of_match_table = of_match_ptr(max9260_dt_ids),
+ },
+};
+
+module_serdev_device_driver(max9260_driver);
+
+MODULE_DESCRIPTION("Maxim MAX9260 GMSL Deserializer Driver");
+MODULE_AUTHOR("Ulrich Hecht");
+MODULE_LICENSE("GPL");
--
2.7.4
^ permalink raw reply related
* [RFC 2/4] serdev: add GPIO-based multiplexer support
From: Ulrich Hecht @ 2017-06-14 14:38 UTC (permalink / raw)
To: robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c,
Ulrich Hecht
In-Reply-To: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com>
Adds an interface for slave device multiplexing, and an implementation
for GPIO-based multiplexers.
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
drivers/tty/serdev/Kconfig | 3 ++
drivers/tty/serdev/Makefile | 1 +
drivers/tty/serdev/core.c | 43 ++++++++++++++++++++++-
drivers/tty/serdev/mux-gpio.c | 80 +++++++++++++++++++++++++++++++++++++++++++
include/linux/serdev.h | 26 ++++++++++++--
5 files changed, 149 insertions(+), 4 deletions(-)
create mode 100644 drivers/tty/serdev/mux-gpio.c
diff --git a/drivers/tty/serdev/Kconfig b/drivers/tty/serdev/Kconfig
index cdc6b82..7946eeb 100644
--- a/drivers/tty/serdev/Kconfig
+++ b/drivers/tty/serdev/Kconfig
@@ -13,4 +13,7 @@ config SERIAL_DEV_CTRL_TTYPORT
depends on TTY
depends on SERIAL_DEV_BUS != m
+config SERIAL_DEV_MUX_GPIO
+ bool "Serial device GPIO multiplexer"
+
endif
diff --git a/drivers/tty/serdev/Makefile b/drivers/tty/serdev/Makefile
index 0cbdb94..08a90fa 100644
--- a/drivers/tty/serdev/Makefile
+++ b/drivers/tty/serdev/Makefile
@@ -1,5 +1,6 @@
serdev-objs := core.o
obj-$(CONFIG_SERIAL_DEV_BUS) += serdev.o
+obj-$(CONFIG_SERIAL_DEV_MUX_GPIO) += mux-gpio.o
obj-$(CONFIG_SERIAL_DEV_CTRL_TTYPORT) += serdev-ttyport.o
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 1fbaa4c..9a2c76b 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -305,7 +305,8 @@ struct serdev_device *serdev_device_alloc(struct serdev_controller *ctrl)
return NULL;
serdev->ctrl = ctrl;
- ctrl->serdev = serdev;
+ if (!ctrl->serdev)
+ ctrl->serdev = serdev;
device_initialize(&serdev->dev);
serdev->dev.parent = &ctrl->dev;
serdev->dev.bus = &serdev_bus_type;
@@ -368,6 +369,8 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
struct serdev_device *serdev = NULL;
int err;
bool found = false;
+ int nr = 0;
+ u32 reg;
for_each_available_child_of_node(ctrl->dev.of_node, node) {
if (!of_get_property(node, "compatible", NULL))
@@ -380,6 +383,10 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
continue;
serdev->dev.of_node = node;
+ serdev->nr = nr++;
+
+ if (!of_property_read_u32(node, "reg", ®))
+ serdev->mux_addr = reg;
err = serdev_device_add(serdev);
if (err) {
@@ -395,6 +402,36 @@ static int of_serdev_register_devices(struct serdev_controller *ctrl)
return 0;
}
+int serdev_device_mux_select(struct serdev_device *serdev)
+{
+ struct serdev_mux *mux = serdev->ctrl->mux;
+
+ if (!mux || !mux->ops || !mux->ops->select)
+ return -EINVAL;
+
+ rt_mutex_lock(&mux->mux_lock);
+
+ mux->ops->select(serdev);
+ serdev->ctrl->serdev = serdev;
+
+ return 0;
+}
+
+int serdev_device_mux_deselect(struct serdev_device *serdev)
+{
+ struct serdev_mux *mux = serdev->ctrl->mux;
+
+ if (!mux || serdev->ctrl->serdev != serdev)
+ return -EINVAL;
+
+ if (mux->ops->deselect)
+ mux->ops->deselect(serdev);
+
+ rt_mutex_unlock(&mux->mux_lock);
+
+ return 0;
+}
+
/**
* serdev_controller_add() - Add an serdev controller
* @ctrl: controller to be registered.
@@ -414,6 +451,10 @@ int serdev_controller_add(struct serdev_controller *ctrl)
if (ret)
return ret;
+#ifdef CONFIG_SERIAL_DEV_MUX_GPIO
+ of_serdev_register_gpio_mux(ctrl);
+#endif
+
ret = of_serdev_register_devices(ctrl);
if (ret)
goto out_dev_del;
diff --git a/drivers/tty/serdev/mux-gpio.c b/drivers/tty/serdev/mux-gpio.c
new file mode 100644
index 0000000..5bedff1
--- /dev/null
+++ b/drivers/tty/serdev/mux-gpio.c
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2017 Ulrich Hecht
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/of_gpio.h>
+#include <linux/serdev.h>
+#include <linux/slab.h>
+
+static int serdev_device_mux_select_gpio(struct serdev_device *serdev)
+{
+ int i;
+ u32 addr;
+ struct serdev_mux *mux = serdev->ctrl->mux;
+
+ addr = serdev->mux_addr;
+ for (i = 0; i < mux->ngpios; ++i, addr >>= 1) {
+ gpio_request_one(mux->gpios[i], GPIOF_DIR_OUT |
+ (addr & 1) ? GPIOF_INIT_HIGH : GPIOF_INIT_LOW,
+ "mux-enable-gpio");
+ }
+
+ return 0;
+}
+
+static int serdev_device_mux_deselect_gpio(struct serdev_device *serdev)
+{
+ int i;
+ struct serdev_mux *mux = serdev->ctrl->mux;
+
+ for (i = 0; i < mux->ngpios; ++i)
+ gpio_free(mux->gpios[i]);
+
+ return 0;
+}
+
+static const struct serdev_mux_ops gpio_mux_ops = {
+ .select = serdev_device_mux_select_gpio,
+ .deselect = serdev_device_mux_deselect_gpio,
+};
+
+int of_serdev_register_gpio_mux(struct serdev_controller *ctrl)
+{
+ int i, ngpios;
+ struct serdev_mux *mux;
+ struct device_node *np = ctrl->dev.of_node;
+
+ ngpios = of_gpio_named_count(np, "mux-select-gpios");
+ if (ngpios <= 0)
+ return -ENODEV;
+
+ mux = kzalloc(sizeof(*mux), GFP_KERNEL);
+ if (!mux)
+ return -ENOMEM;
+
+ rt_mutex_init(&mux->mux_lock);
+ mux->ops = &gpio_mux_ops;
+
+ mux->ngpios = ngpios;
+
+ mux->gpios = kcalloc(ngpios, sizeof(int), GFP_KERNEL);
+ if (!mux->gpios)
+ return -ENOMEM;
+
+ for (i = 0; i < ngpios; ++i)
+ mux->gpios[i] = of_get_named_gpio(np, "mux-select-gpios", i);
+
+ ctrl->mux = mux;
+
+ return 0;
+}
+
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index 8b67fcd..e86a0ad 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -17,6 +17,7 @@
#include <linux/device.h>
#include <linux/termios.h>
#include <linux/delay.h>
+#include <linux/rtmutex.h>
struct serdev_controller;
struct serdev_device;
@@ -51,6 +52,7 @@ struct serdev_device {
const struct serdev_device_ops *ops;
struct completion write_comp;
struct mutex write_lock;
+ int mux_addr;
};
static inline struct serdev_device *to_serdev_device(struct device *d)
@@ -76,6 +78,20 @@ static inline struct serdev_device_driver *to_serdev_device_driver(struct device
return container_of(d, struct serdev_device_driver, driver);
}
+struct serdev_mux_ops {
+ int (*select)(struct serdev_device *);
+ int (*deselect)(struct serdev_device *);
+};
+
+struct serdev_mux {
+ int ngpios;
+ int *gpios;
+ struct rt_mutex mux_lock;
+ const struct serdev_mux_ops *ops;
+};
+
+int of_serdev_register_gpio_mux(struct serdev_controller *ctrl);
+
/*
* serdev controller structures
*/
@@ -97,14 +113,16 @@ struct serdev_controller_ops {
* struct serdev_controller - interface to the serdev controller
* @dev: Driver model representation of the device.
* @nr: number identifier for this controller/bus.
- * @serdev: Pointer to slave device for this controller.
+ * @serdev: Pointer to active slave device for this controller.
* @ops: Controller operations.
+ * @mux: Slave multiplexer.
*/
struct serdev_controller {
struct device dev;
unsigned int nr;
struct serdev_device *serdev;
const struct serdev_controller_ops *ops;
+ struct serdev_mux *mux;
};
static inline struct serdev_controller *to_serdev_controller(struct device *d)
@@ -172,7 +190,7 @@ static inline void serdev_controller_write_wakeup(struct serdev_controller *ctrl
{
struct serdev_device *serdev = ctrl->serdev;
- if (!serdev || !serdev->ops->write_wakeup)
+ if (!serdev || !serdev->ops || !serdev->ops->write_wakeup)
return;
serdev->ops->write_wakeup(serdev);
@@ -184,7 +202,7 @@ static inline int serdev_controller_receive_buf(struct serdev_controller *ctrl,
{
struct serdev_device *serdev = ctrl->serdev;
- if (!serdev || !serdev->ops->receive_buf)
+ if (!serdev || !serdev->ops || !serdev->ops->receive_buf)
return -EINVAL;
return serdev->ops->receive_buf(serdev, data, count);
@@ -204,6 +222,8 @@ void serdev_device_write_wakeup(struct serdev_device *);
int serdev_device_write(struct serdev_device *, const unsigned char *, size_t, unsigned long);
void serdev_device_write_flush(struct serdev_device *);
int serdev_device_write_room(struct serdev_device *);
+int serdev_device_mux_select(struct serdev_device *);
+int serdev_device_mux_deselect(struct serdev_device *);
/*
* serdev device driver functions
--
2.7.4
^ permalink raw reply related
* [RFC 1/4] serdev: add method to set parity
From: Ulrich Hecht @ 2017-06-14 14:38 UTC (permalink / raw)
To: robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c,
Ulrich Hecht
In-Reply-To: <1497451130-7741-1-git-send-email-ulrich.hecht+renesas@gmail.com>
Adds serdev_device_set_parity() and an implementation for ttyport.
Signed-off-by: Ulrich Hecht <ulrich.hecht+renesas@gmail.com>
---
drivers/tty/serdev/core.c | 12 ++++++++++++
drivers/tty/serdev/serdev-ttyport.c | 17 +++++++++++++++++
include/linux/serdev.h | 4 ++++
3 files changed, 33 insertions(+)
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index f71b473..1fbaa4c 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -242,6 +242,18 @@ int serdev_device_set_tiocm(struct serdev_device *serdev, int set, int clear)
}
EXPORT_SYMBOL_GPL(serdev_device_set_tiocm);
+int serdev_device_set_parity(struct serdev_device *serdev,
+ bool enable, bool odd)
+{
+ struct serdev_controller *ctrl = serdev->ctrl;
+
+ if (!ctrl || !ctrl->ops->set_parity)
+ return -ENOTSUPP;
+
+ return ctrl->ops->set_parity(ctrl, enable, odd);
+}
+EXPORT_SYMBOL_GPL(serdev_device_set_parity);
+
static int serdev_drv_probe(struct device *dev)
{
const struct serdev_device_driver *sdrv = to_serdev_device_driver(dev->driver);
diff --git a/drivers/tty/serdev/serdev-ttyport.c b/drivers/tty/serdev/serdev-ttyport.c
index 302018d..9114956 100644
--- a/drivers/tty/serdev/serdev-ttyport.c
+++ b/drivers/tty/serdev/serdev-ttyport.c
@@ -195,6 +195,22 @@ static int ttyport_set_tiocm(struct serdev_controller *ctrl, unsigned int set, u
return tty->driver->ops->tiocmset(tty, set, clear);
}
+static int ttyport_set_parity(struct serdev_controller *ctrl,
+ bool enable, bool odd)
+{
+ struct serport *serport = serdev_controller_get_drvdata(ctrl);
+ struct tty_struct *tty = serport->tty;
+ struct ktermios ktermios = tty->termios;
+
+ ktermios.c_cflag &= ~(PARENB | PARODD);
+ if (enable)
+ ktermios.c_cflag |= PARENB;
+ if (odd)
+ ktermios.c_cflag |= PARODD;
+
+ return tty_set_termios(tty, &ktermios);
+}
+
static const struct serdev_controller_ops ctrl_ops = {
.write_buf = ttyport_write_buf,
.write_flush = ttyport_write_flush,
@@ -206,6 +222,7 @@ static const struct serdev_controller_ops ctrl_ops = {
.wait_until_sent = ttyport_wait_until_sent,
.get_tiocm = ttyport_get_tiocm,
.set_tiocm = ttyport_set_tiocm,
+ .set_parity = ttyport_set_parity,
};
struct device *serdev_tty_port_register(struct tty_port *port,
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index e69402d..8b67fcd 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -90,6 +90,7 @@ struct serdev_controller_ops {
void (*wait_until_sent)(struct serdev_controller *, long);
int (*get_tiocm)(struct serdev_controller *);
int (*set_tiocm)(struct serdev_controller *, unsigned int, unsigned int);
+ int (*set_parity)(struct serdev_controller *, bool, bool);
};
/**
@@ -298,6 +299,9 @@ static inline int serdev_device_set_rts(struct serdev_device *serdev, bool enabl
return serdev_device_set_tiocm(serdev, 0, TIOCM_RTS);
}
+int serdev_device_set_parity(struct serdev_device *serdev,
+ bool enable, bool odd);
+
/*
* serdev hooks into TTY core
*/
--
2.7.4
^ permalink raw reply related
* [RFC 0/4] serdev GPIO-based multiplexing support
From: Ulrich Hecht @ 2017-06-14 14:38 UTC (permalink / raw)
To: robh, linux-serial
Cc: linux-renesas-soc, magnus.damm, laurent.pinchart, wsa, linux-i2c,
Ulrich Hecht
Hi!
This is an attempt to add multiplexer support to serdev, specifically
GPIO-based multiplexing.
Our use case is the Renesas Blanche V2H board with several MAX9260 GMSL
deserializers attached to one serial port. A sample driver that implements
i2c passthrough over the GMSL link is part of this series. This device
wants to be talked to with even parity, so a patch implementing parity
control in serdev is included as well.
The board-specific part of this series depends on the "pinctrl: sh-pfc:
r8a7792: Add SCIF1 pin groups" patch.
Please tell me if this is a suitable way to implement this functionality
in serdev, or how to improve it. Thank you.
CU
Uli
Ulrich Hecht (4):
serdev: add method to set parity
serdev: add GPIO-based multiplexer support
max9260: add driver for i2c over GMSL passthrough
ARM: dts: blanche: add SCIF1 and MAX9260 deserializer
arch/arm/boot/dts/r8a7792-blanche.dts | 45 ++++++
drivers/media/i2c/Kconfig | 6 +
drivers/media/i2c/Makefile | 1 +
drivers/media/i2c/max9260.c | 294 ++++++++++++++++++++++++++++++++++
drivers/tty/serdev/Kconfig | 3 +
drivers/tty/serdev/Makefile | 1 +
drivers/tty/serdev/core.c | 55 ++++++-
drivers/tty/serdev/mux-gpio.c | 80 +++++++++
drivers/tty/serdev/serdev-ttyport.c | 17 ++
include/linux/serdev.h | 30 +++-
10 files changed, 528 insertions(+), 4 deletions(-)
create mode 100644 drivers/media/i2c/max9260.c
create mode 100644 drivers/tty/serdev/mux-gpio.c
--
2.7.4
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Alexandre Belloni @ 2017-06-14 14:26 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Richard Genoud, Greg Kroah-Hartman, Nicolas Ferre,
linux-serial@vger.kernel.org, linux-arm Mailing List,
linux-kernel@vger.kernel.org
In-Reply-To: <CAHp75Vd8osYbgxhOe3vxLFsCuDk0p+MWz+UQQWz+uX9+bvkZmw@mail.gmail.com>
On 14/06/2017 at 17:15:32 +0300, Andy Shevchenko wrote:
> On Wed, Jun 14, 2017 at 4:27 PM, Alexandre Belloni
> <alexandre.belloni@free-electrons.com> wrote:
> > On 14/06/2017 at 12:43:40 +0300, Andy Shevchenko wrote:
> >> On Tue, Jun 13, 2017 at 11:25 PM, Alexandre Belloni
> >> <alexandre.belloni@free-electrons.com> wrote:
> >> > Now that AVR32 is gone, the specific wrappers for that architecture are
> >> > unnecessary and will not be compiled anymore.
> >> >
> >>
> >> Can you rebase this on top of tty-next?
> >>
> >> I'm pretty sure this patch will gone.
> >>
> >
> > So you avoided most of the bikeshedding by not copying any of the
> > maintainers, nice...
>
> Wait, what? I used get_maintainer.pl script and I took its output + Greg.
>
Yeah, get_maintainer is not ideal but that's fine. Probably the lakml
should be added.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Andy Shevchenko @ 2017-06-14 14:15 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Richard Genoud, Greg Kroah-Hartman, Nicolas Ferre,
linux-serial@vger.kernel.org, linux-arm Mailing List,
linux-kernel@vger.kernel.org
In-Reply-To: <20170614132723.2duxhpjq4odchcw2@piout.net>
On Wed, Jun 14, 2017 at 4:27 PM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> On 14/06/2017 at 12:43:40 +0300, Andy Shevchenko wrote:
>> On Tue, Jun 13, 2017 at 11:25 PM, Alexandre Belloni
>> <alexandre.belloni@free-electrons.com> wrote:
>> > Now that AVR32 is gone, the specific wrappers for that architecture are
>> > unnecessary and will not be compiled anymore.
>> >
>>
>> Can you rebase this on top of tty-next?
>>
>> I'm pretty sure this patch will gone.
>>
>
> So you avoided most of the bikeshedding by not copying any of the
> maintainers, nice...
Wait, what? I used get_maintainer.pl script and I took its output + Greg.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Alexandre Belloni @ 2017-06-14 13:32 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Richard Genoud, Nicolas Ferre, linux-serial, linux-arm-kernel,
linux-kernel
In-Reply-To: <20170614104929.GA11313@kroah.com>
On 14/06/2017 at 12:49:29 +0200, Greg Kroah-Hartman wrote:
> On Tue, Jun 13, 2017 at 10:25:17PM +0200, Alexandre Belloni wrote:
> > Now that AVR32 is gone, the specific wrappers for that architecture are
> > unnecessary and will not be compiled anymore.
> >
> > Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> > ---
> > drivers/tty/serial/atmel_serial.c | 17 -----------------
> > 1 file changed, 17 deletions(-)
>
> Does not apply to my tty-next tree at all :(
>
That's fine, as Andy pointed out, he did the job.
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Alexandre Belloni @ 2017-06-14 13:27 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Richard Genoud, Greg Kroah-Hartman, Nicolas Ferre,
linux-serial@vger.kernel.org, linux-arm Mailing List,
linux-kernel@vger.kernel.org
In-Reply-To: <CAHp75VcMrhG0K-=dtkF1T5siAAmmLYdmCxcLdo_vvH8dLjLh=A@mail.gmail.com>
On 14/06/2017 at 12:43:40 +0300, Andy Shevchenko wrote:
> On Tue, Jun 13, 2017 at 11:25 PM, Alexandre Belloni
> <alexandre.belloni@free-electrons.com> wrote:
> > Now that AVR32 is gone, the specific wrappers for that architecture are
> > unnecessary and will not be compiled anymore.
> >
>
> Can you rebase this on top of tty-next?
>
> I'm pretty sure this patch will gone.
>
So you avoided most of the bikeshedding by not copying any of the
maintainers, nice...
--
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply
* Re: [PATCH] tty/serial: Kconfig: remove AVR32
From: Greg Kroah-Hartman @ 2017-06-14 10:49 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Richard Genoud, Nicolas Ferre, linux-serial, linux-arm-kernel,
linux-kernel
In-Reply-To: <20170613203509.32026-1-alexandre.belloni@free-electrons.com>
On Tue, Jun 13, 2017 at 10:35:09PM +0200, Alexandre Belloni wrote:
> AVR32 is now removed from the kernel, removed the config symbol that
> doesn't exist anymore. Also take the opportunity to reword the help to
> include sama5.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/tty/serial/Kconfig | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
Does not apply to tty-next at all :(
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Greg Kroah-Hartman @ 2017-06-14 10:49 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Richard Genoud, Nicolas Ferre, linux-serial, linux-arm-kernel,
linux-kernel
In-Reply-To: <20170613202517.26558-1-alexandre.belloni@free-electrons.com>
On Tue, Jun 13, 2017 at 10:25:17PM +0200, Alexandre Belloni wrote:
> Now that AVR32 is gone, the specific wrappers for that architecture are
> unnecessary and will not be compiled anymore.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/tty/serial/atmel_serial.c | 17 -----------------
> 1 file changed, 17 deletions(-)
Does not apply to my tty-next tree at all :(
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Andy Shevchenko @ 2017-06-14 9:43 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Richard Genoud, Greg Kroah-Hartman, Nicolas Ferre,
linux-serial@vger.kernel.org, linux-arm Mailing List,
linux-kernel@vger.kernel.org
In-Reply-To: <20170613202517.26558-1-alexandre.belloni@free-electrons.com>
On Tue, Jun 13, 2017 at 11:25 PM, Alexandre Belloni
<alexandre.belloni@free-electrons.com> wrote:
> Now that AVR32 is gone, the specific wrappers for that architecture are
> unnecessary and will not be compiled anymore.
>
Can you rebase this on top of tty-next?
I'm pretty sure this patch will gone.
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/tty/serial/atmel_serial.c | 17 -----------------
> 1 file changed, 17 deletions(-)
>
> diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c
> index 937d67f22fba..8bfc566df2da 100644
> --- a/drivers/tty/serial/atmel_serial.c
> +++ b/drivers/tty/serial/atmel_serial.c
> @@ -228,21 +228,6 @@ static inline void atmel_uart_writel(struct uart_port *port, u32 reg, u32 value)
> __raw_writel(value, port->membase + reg);
> }
>
> -#ifdef CONFIG_AVR32
> -
> -/* AVR32 cannot handle 8 or 16bit I/O accesses but only 32bit I/O accesses */
> -static inline u8 atmel_uart_read_char(struct uart_port *port)
> -{
> - return __raw_readl(port->membase + ATMEL_US_RHR);
> -}
> -
> -static inline void atmel_uart_write_char(struct uart_port *port, u8 value)
> -{
> - __raw_writel(value, port->membase + ATMEL_US_THR);
> -}
> -
> -#else
> -
> static inline u8 atmel_uart_read_char(struct uart_port *port)
> {
> return __raw_readb(port->membase + ATMEL_US_RHR);
> @@ -253,8 +238,6 @@ static inline void atmel_uart_write_char(struct uart_port *port, u8 value)
> __raw_writeb(value, port->membase + ATMEL_US_THR);
> }
>
> -#endif
> -
> #ifdef CONFIG_SERIAL_ATMEL_PDC
> static bool atmel_use_pdc_rx(struct uart_port *port)
> {
> --
> 2.11.0
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH] tty/serial: Kconfig: remove AVR32
From: Nicolas Ferre @ 2017-06-14 9:29 UTC (permalink / raw)
To: Alexandre Belloni, Richard Genoud, Greg Kroah-Hartman
Cc: linux-arm-kernel, linux-serial, linux-kernel
In-Reply-To: <20170613203509.32026-1-alexandre.belloni@free-electrons.com>
Le 13/06/2017 à 22:35, Alexandre Belloni a écrit :
> AVR32 is now removed from the kernel, removed the config symbol that
> doesn't exist anymore. Also take the opportunity to reword the help to
> include sama5.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/tty/serial/Kconfig | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
> index 5c8850f7a2a0..063c71e8de41 100644
> --- a/drivers/tty/serial/Kconfig
> +++ b/drivers/tty/serial/Kconfig
> @@ -114,14 +114,14 @@ config SERIAL_SB1250_DUART_CONSOLE
> If unsure, say Y.
>
> config SERIAL_ATMEL
> - bool "AT91 / AT32 on-chip serial port support"
> + bool "Atmel on-chip serial port support"
Now, I would add something like "Microchip/Atmel", it's more future-proof.
> depends on HAS_DMA
> - depends on ARCH_AT91 || AVR32 || COMPILE_TEST
> + depends on ARCH_AT91 || COMPILE_TEST
> select SERIAL_CORE
> select SERIAL_MCTRL_GPIO if GPIOLIB
> help
> This enables the driver for the on-chip UARTs of the Atmel
Here as well...
> - AT91 and AT32 processors.
> + ARM processors.
>
> config SERIAL_ATMEL_CONSOLE
> bool "Support for console on AT91 / AT32 serial port"
What about removing AT32 here as well ^ ?
>
--
Nicolas Ferre
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply
* [PATCH v5 4/4] ARM: dts: meson6: use stable UART bindings
From: Neil Armstrong @ 2017-06-14 8:29 UTC (permalink / raw)
To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
khilman-rdvid1DuHRBWk0Htik3J/w
Cc: Neil Armstrong, hgkr.klein-Re5JQEeQqe8AvxtiuMwx3w,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1497428957-19942-1-git-send-email-narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
The UART bindings needs specifying a SoC family, use the meson6 family
for the UART nodes like the other nodes.
Switch to the stable UART bindings for meson6 by adding a XTAL node and
using the proper compatible strings.
Signed-off-by: Neil Armstrong <narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
---
arch/arm/boot/dts/meson.dtsi | 8 ++++----
arch/arm/boot/dts/meson6.dtsi | 28 ++++++++++++++++++++++++++++
2 files changed, 32 insertions(+), 4 deletions(-)
diff --git a/arch/arm/boot/dts/meson.dtsi b/arch/arm/boot/dts/meson.dtsi
index 8d9c369..ecc9330 100644
--- a/arch/arm/boot/dts/meson.dtsi
+++ b/arch/arm/boot/dts/meson.dtsi
@@ -79,14 +79,14 @@
ranges = <0x0 0xc1100000 0x200000>;
uart_A: serial@84c0 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson6-uart";
reg = <0x84c0 0x18>;
interrupts = <0 26 1>;
status = "disabled";
};
uart_B: serial@84dc {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson6-uart";
reg = <0x84dc 0x18>;
interrupts = <0 75 1>;
status = "disabled";
@@ -102,7 +102,7 @@
};
uart_C: serial@8700 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson6-uart";
reg = <0x8700 0x18>;
interrupts = <0 93 1>;
status = "disabled";
@@ -153,7 +153,7 @@
};
uart_AO: serial@4c0 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson6-uart", "amlogic,meson-ao-uart";
reg = <0x4c0 0x18>;
interrupts = <0 90 1>;
status = "disabled";
diff --git a/arch/arm/boot/dts/meson6.dtsi b/arch/arm/boot/dts/meson6.dtsi
index b0fc91f..a334fbe 100644
--- a/arch/arm/boot/dts/meson6.dtsi
+++ b/arch/arm/boot/dts/meson6.dtsi
@@ -70,9 +70,37 @@
};
};
+ xtal: xtal-clk {
+ compatible = "fixed-clock";
+ clock-frequency = <24000000>;
+ clock-output-names = "xtal";
+ #clock-cells = <0>;
+ };
+
clk81: clk@0 {
#clock-cells = <0>;
compatible = "fixed-clock";
clock-frequency = <200000000>;
};
}; /* end of / */
+
+
+&uart_AO {
+ clocks = <&xtal>, <&clk81>, <&clk81>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_A {
+ clocks = <&xtal>, <&clk81>, <&clk81>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_B {
+ clocks = <&xtal>, <&clk81>, <&clk81>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_C {
+ clocks = <&xtal>, <&clk81>, <&clk81>;
+ clock-names = "xtal", "pclk", "baud";
+};
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 3/4] ARM64: dts: meson-gx: use stable UART bindings with correct gate clock
From: Neil Armstrong @ 2017-06-14 8:29 UTC (permalink / raw)
To: gregkh, khilman
Cc: Helmut Klein, linux-serial, linux-amlogic, linux-arm-kernel,
linux-kernel, devicetree, Neil Armstrong
In-Reply-To: <1497428957-19942-1-git-send-email-narmstrong@baylibre.com>
From: Helmut Klein <hgkr.klein@gmail.com>
This patch switches to the stable UART bindings but also add the correct
gate clock to the non-AO UART nodes for GXBB and GXL SoCs.
Acked-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Helmut Klein <hgkr.klein@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 12 +++++-------
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 25 +++++++++++++++++++++++++
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 25 +++++++++++++++++++++++++
3 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
index 603491d..86a4018 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gx.dtsi
@@ -225,7 +225,7 @@
};
uart_A: serial@84c0 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson-gx-uart";
reg = <0x0 0x84c0 0x0 0x14>;
interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
clocks = <&xtal>;
@@ -233,7 +233,7 @@
};
uart_B: serial@84dc {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson-gx-uart";
reg = <0x0 0x84dc 0x0 0x14>;
interrupts = <GIC_SPI 75 IRQ_TYPE_EDGE_RISING>;
clocks = <&xtal>;
@@ -279,7 +279,7 @@
};
uart_C: serial@8700 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson-gx-uart";
reg = <0x0 0x8700 0x0 0x14>;
interrupts = <GIC_SPI 93 IRQ_TYPE_EDGE_RISING>;
clocks = <&xtal>;
@@ -366,18 +366,16 @@
};
uart_AO: serial@4c0 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson-gx-uart", "amlogic,meson-ao-uart";
reg = <0x0 0x004c0 0x0 0x14>;
interrupts = <GIC_SPI 193 IRQ_TYPE_EDGE_RISING>;
- clocks = <&xtal>;
status = "disabled";
};
uart_AO_B: serial@4e0 {
- compatible = "amlogic,meson-uart";
+ compatible = "amlogic,meson-gx-uart", "amlogic,meson-ao-uart";
reg = <0x0 0x004e0 0x0 0x14>;
interrupts = <GIC_SPI 197 IRQ_TYPE_EDGE_RISING>;
- clocks = <&xtal>;
status = "disabled";
};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
index dbd300f..1ae8da7 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi
@@ -675,6 +675,31 @@
clocks = <&clkc CLKID_SPI>;
};
+&uart_A {
+ clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_AO {
+ clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_AO_B {
+ clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_B {
+ clocks = <&xtal>, <&clkc CLKID_UART1>, <&xtal>;
+ clock-names = "xtal", "core", "baud";
+};
+
+&uart_C {
+ clocks = <&xtal>, <&clkc CLKID_UART2>, <&xtal>;
+ clock-names = "xtal", "core", "baud";
+};
+
&vpu {
compatible = "amlogic,meson-gxbb-vpu", "amlogic,meson-gx-vpu";
};
diff --git a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
index 4dfc22b..0c601f8 100644
--- a/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
+++ b/arch/arm64/boot/dts/amlogic/meson-gxl.dtsi
@@ -616,6 +616,31 @@
clocks = <&clkc CLKID_SPI>;
};
+&uart_A {
+ clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
+ clock-names = "xtal", "core", "baud";
+};
+
+&uart_AO {
+ clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_AO_B {
+ clocks = <&xtal>, <&clkc CLKID_CLK81>, <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
+};
+
+&uart_B {
+ clocks = <&xtal>, <&clkc CLKID_UART1>, <&xtal>;
+ clock-names = "xtal", "core", "baud";
+};
+
+&uart_C {
+ clocks = <&xtal>, <&clkc CLKID_UART2>, <&xtal>;
+ clock-names = "xtal", "core", "baud";
+};
+
&vpu {
compatible = "amlogic,meson-gxl-vpu", "amlogic,meson-gx-vpu";
};
--
1.9.1
^ permalink raw reply related
* [PATCH v5 2/4] tty/serial: meson_uart: update to stable bindings
From: Neil Armstrong @ 2017-06-14 8:29 UTC (permalink / raw)
To: gregkh, khilman
Cc: Neil Armstrong, linux-kernel, Helmut Klein, linux-serial,
linux-amlogic, linux-arm-kernel
In-Reply-To: <1497428957-19942-1-git-send-email-narmstrong@baylibre.com>
From: Helmut Klein <hgkr.klein@gmail.com>
This patch handle the stable UART bindings but also keeps compatibility
with the legacy non-stable bindings until all boards uses them.
Reviewed-by: Jerome Brunet <jbrunet@baylibre.com>
Signed-off-by: Helmut Klein <hgkr.klein@gmail.com>
Signed-off-by: Neil Armstrong <narmstrong@baylibre.com>
---
drivers/tty/serial/meson_uart.c | 90 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 84 insertions(+), 6 deletions(-)
diff --git a/drivers/tty/serial/meson_uart.c b/drivers/tty/serial/meson_uart.c
index 60f1679..82e0709 100644
--- a/drivers/tty/serial/meson_uart.c
+++ b/drivers/tty/serial/meson_uart.c
@@ -579,8 +579,12 @@ static void meson_serial_early_console_write(struct console *co,
device->con->write = meson_serial_early_console_write;
return 0;
}
+/* Legacy bindings, should be removed when no more used */
OF_EARLYCON_DECLARE(meson, "amlogic,meson-uart",
meson_serial_early_console_setup);
+/* Stable bindings */
+OF_EARLYCON_DECLARE(meson, "amlogic,meson-ao-uart",
+ meson_serial_early_console_setup);
#define MESON_SERIAL_CONSOLE (&meson_serial_console)
#else
@@ -595,11 +599,76 @@ static void meson_serial_early_console_write(struct console *co,
.cons = MESON_SERIAL_CONSOLE,
};
+static inline struct clk *meson_uart_probe_clock(struct device *dev,
+ const char *id)
+{
+ struct clk *clk = NULL;
+ int ret;
+
+ clk = devm_clk_get(dev, id);
+ if (IS_ERR(clk))
+ return clk;
+
+ ret = clk_prepare_enable(clk);
+ if (ret) {
+ dev_err(dev, "couldn't enable clk\n");
+ return ERR_PTR(ret);
+ }
+
+ devm_add_action_or_reset(dev,
+ (void(*)(void *))clk_disable_unprepare,
+ clk);
+
+ return clk;
+}
+
+/*
+ * This function gets clocks in the legacy non-stable DT bindings.
+ * This code will be remove once all the platforms switch to the
+ * new DT bindings.
+ */
+static int meson_uart_probe_clocks_legacy(struct platform_device *pdev,
+ struct uart_port *port)
+{
+ struct clk *clk = NULL;
+
+ clk = meson_uart_probe_clock(&pdev->dev, NULL);
+ if (IS_ERR(clk))
+ return PTR_ERR(clk);
+
+ port->uartclk = clk_get_rate(clk);
+
+ return 0;
+}
+
+static int meson_uart_probe_clocks(struct platform_device *pdev,
+ struct uart_port *port)
+{
+ struct clk *clk_xtal = NULL;
+ struct clk *clk_pclk = NULL;
+ struct clk *clk_baud = NULL;
+
+ clk_pclk = meson_uart_probe_clock(&pdev->dev, "pclk");
+ if (IS_ERR(clk_pclk))
+ return PTR_ERR(clk_pclk);
+
+ clk_xtal = meson_uart_probe_clock(&pdev->dev, "xtal");
+ if (IS_ERR(clk_xtal))
+ return PTR_ERR(clk_xtal);
+
+ clk_baud = meson_uart_probe_clock(&pdev->dev, "baud");
+ if (IS_ERR(clk_baud))
+ return PTR_ERR(clk_baud);
+
+ port->uartclk = clk_get_rate(clk_baud);
+
+ return 0;
+}
+
static int meson_uart_probe(struct platform_device *pdev)
{
struct resource *res_mem, *res_irq;
struct uart_port *port;
- struct clk *clk;
int ret = 0;
if (pdev->dev.of_node)
@@ -625,11 +694,15 @@ static int meson_uart_probe(struct platform_device *pdev)
if (!port)
return -ENOMEM;
- clk = clk_get(&pdev->dev, NULL);
- if (IS_ERR(clk))
- return PTR_ERR(clk);
+ /* Use legacy way until all platforms switch to new bindings */
+ if (of_device_is_compatible(pdev->dev.of_node, "amlogic,meson-uart"))
+ ret = meson_uart_probe_clocks_legacy(pdev, port);
+ else
+ ret = meson_uart_probe_clocks(pdev, port);
+
+ if (ret)
+ return ret;
- port->uartclk = clk_get_rate(clk);
port->iotype = UPIO_MEM;
port->mapbase = res_mem->start;
port->irq = res_irq->start;
@@ -668,9 +741,14 @@ static int meson_uart_remove(struct platform_device *pdev)
return 0;
}
-
static const struct of_device_id meson_uart_dt_match[] = {
+ /* Legacy bindings, should be removed when no more used */
{ .compatible = "amlogic,meson-uart" },
+ /* Stable bindings */
+ { .compatible = "amlogic,meson6-uart" },
+ { .compatible = "amlogic,meson8-uart" },
+ { .compatible = "amlogic,meson8b-uart" },
+ { .compatible = "amlogic,meson-gx-uart" },
{ /* sentinel */ },
};
MODULE_DEVICE_TABLE(of, meson_uart_dt_match);
--
1.9.1
^ permalink raw reply related
* [PATCH v5 1/4] dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
From: Neil Armstrong @ 2017-06-14 8:29 UTC (permalink / raw)
To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
khilman-rdvid1DuHRBWk0Htik3J/w
Cc: Helmut Klein, linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA, Neil Armstrong
In-Reply-To: <1497428957-19942-1-git-send-email-narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
From: Helmut Klein <hgkr.klein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Add the documentation for the device tree binding of Amlogic Meson Serial UART.
Signed-off-by: Helmut Klein <hgkr.klein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Signed-off-by: Neil Armstrong <narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org>
---
.../bindings/serial/amlogic,meson-uart.txt | 38 ++++++++++++++++++++++
1 file changed, 38 insertions(+)
create mode 100644 Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
diff --git a/Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
new file mode 100644
index 0000000..8ff65fa
--- /dev/null
+++ b/Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
@@ -0,0 +1,38 @@
+Amlogic Meson SoC UART Serial Interface
+=======================================
+
+The Amlogic Meson SoC UART Serial Interface is present on a large range
+of SoCs, and can be present either in the "Always-On" power domain or the
+"Everything-Else" power domain.
+
+The particularity of the "Always-On" Serial Interface is that the hardware
+is active since power-on and does not need any clock gating and is usable
+as very early serial console.
+
+Required properties:
+- compatible : compatible: value should be different for each SoC family as :
+ - Meson6 : "amlogic,meson6-uart"
+ - Meson8 : "amlogic,meson8-uart"
+ - Meson8b : "amlogic,meson8b-uart"
+ - GX (GXBB, GXL, GXM) : "amlogic,meson-gx-uart"
+ eventually followed by : "amlogic,meson-ao-uart" if this UART interface
+ is in the "Always-On" power domain.
+- reg : offset and length of the register set for the device.
+- interrupts : identifier to the device interrupt
+- clocks : a list of phandle + clock-specifier pairs, one for each
+ entry in clock names.
+- clocks-names :
+ * "xtal" for external xtal clock identifier
+ * "pclk" for the bus core clock, either the clk81 clock or the gate clock
+ * "baud" for the source of the baudrate generator, can be either the xtal
+ or the pclk.
+
+e.g.
+uart_A: serial@84c0 {
+ compatible = "amlogic,meson-gx-uart";
+ reg = <0x0 0x84c0 0x0 0x14>;
+ interrupts = <GIC_SPI 26 IRQ_TYPE_EDGE_RISING>;
+ /* Use xtal as baud rate clock source */
+ clocks = <&xtal>, <&clkc CLKID_UART0>, <&xtal>;
+ clock-names = "xtal", "pclk", "baud";
+};
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related
* [PATCH v5 0/4] tty/serial: meson_uart: add support for core clock handling
From: Neil Armstrong @ 2017-06-14 8:29 UTC (permalink / raw)
To: gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
khilman-rdvid1DuHRBWk0Htik3J/w
Cc: Neil Armstrong, hgkr.klein-Re5JQEeQqe8AvxtiuMwx3w,
linux-serial-u79uwXL29TY76Z2rM5mHXA,
linux-amlogic-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
devicetree-u79uwXL29TY76Z2rM5mHXA
This patchset is a re-spin of Helmut Klein's v3 patchset at [0] and the v4 patchset at [1].
Initially, the original patchset was made to enable usage on the non-AO UARTS
not enabled by the Bootloader (uart_B and uart_C), but the patchset needed
an overall change to have clean and stable DT bindings.
The Amlogic Meson UART Driver did not have stable DT bindings and mismatched
clock handling on non-AO UARTs since these "EE" UARTs needs a clock gate to
be ungated to works correctly.
In the same way, the AO UARTs does not need gating and can be used as
Early Consoles.
In the same time, the UART Interfaces can take clock input for the baudrate
generate from either the external Xtal or the internal Bus Clock (clk81).
So new bindings was necessary to meet these requirements and the DT
maintainers requirements.
The "legacy" binding actually used in the driver is left until all the DT
files are switched to the new bindings.
The GX DT has been tested, but the last 4 Meson6/Meson8/b are only
compile-tested, and testing is welcome.
Thus only the first 3 patches can be merged until the Meson6/Meson8/b are
formally tested.
It must be noted that the meson6 cannot work today except using an early
console since the UART driver could not probe without a clocks property.
Changes since v4 at [1]:
- Droped meson8/meson8b DT patches
- Fixes copy/paste error in patch 2
- Refactored clock probing in patch 2
- merged meson6 patches together to avoid breaking bisect
[0] http://lkml.kernel.org/r/20170331165437.26227-1-hgkr.klein-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
[1] http://lkml.kernel.org/r/1497001756-942-1-git-send-email-narmstrong-rdvid1DuHRBWk0Htik3J/w@public.gmane.org
Helmut Klein (3):
dt-bindings: serial: Add bindings for the Amlogic Meson UARTs
tty/serial: meson_uart: update to stable bindings
ARM64: dts: meson-gx: use stable UART bindings with correct gate clock
Neil Armstrong (1):
ARM: dts: meson6: use stable UART bindings
.../bindings/serial/amlogic,meson-uart.txt | 38 +++++++++
arch/arm/boot/dts/meson.dtsi | 8 +-
arch/arm/boot/dts/meson6.dtsi | 28 +++++++
arch/arm64/boot/dts/amlogic/meson-gx.dtsi | 12 ++-
arch/arm64/boot/dts/amlogic/meson-gxbb.dtsi | 25 ++++++
arch/arm64/boot/dts/amlogic/meson-gxl.dtsi | 25 ++++++
drivers/tty/serial/meson_uart.c | 90 ++++++++++++++++++++--
7 files changed, 209 insertions(+), 17 deletions(-)
create mode 100644 Documentation/devicetree/bindings/serial/amlogic,meson-uart.txt
--
1.9.1
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] tty/serial: Kconfig: remove AVR32
From: Richard Genoud @ 2017-06-14 7:48 UTC (permalink / raw)
To: Alexandre Belloni, Greg Kroah-Hartman
Cc: Nicolas Ferre, linux-serial, linux-arm-kernel, linux-kernel
In-Reply-To: <20170613203509.32026-1-alexandre.belloni@free-electrons.com>
On 13/06/2017 22:35, Alexandre Belloni wrote:
> AVR32 is now removed from the kernel, removed the config symbol that
> doesn't exist anymore. Also take the opportunity to reword the help to
> include sama5.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
100 lines removed with the 4 patches, that's nice !
Thanks !
^ permalink raw reply
* Re: [PATCH] tty/serial: remove AVR32 specific access wrappers
From: Richard Genoud @ 2017-06-14 7:43 UTC (permalink / raw)
To: Alexandre Belloni, Greg Kroah-Hartman
Cc: Nicolas Ferre, linux-serial, linux-arm-kernel, linux-kernel
In-Reply-To: <20170613202517.26558-1-alexandre.belloni@free-electrons.com>
On 13/06/2017 22:25, Alexandre Belloni wrote:
> Now that AVR32 is gone, the specific wrappers for that architecture are
> unnecessary and will not be compiled anymore.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
^ permalink raw reply
* Re: [PATCH v2 2/2] tty/serial: atmel: make the driver DT only
From: Richard Genoud @ 2017-06-14 7:41 UTC (permalink / raw)
To: Alexandre Belloni, Greg Kroah-Hartman
Cc: Nicolas Ferre, linux-serial, linux-arm-kernel, linux-kernel
In-Reply-To: <20170613202439.26369-2-alexandre.belloni@free-electrons.com>
On 13/06/2017 22:24, Alexandre Belloni wrote:
> Now that AVR32 is gone, platform_data are not used to initialize the driver
> anymore, remove that path from the driver. Also remove the now unused
> struct atmel_uart_data.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
> drivers/tty/serial/atmel_serial.c | 96 +++++++++++++------------------------
> include/linux/platform_data/atmel.h | 10 ----
> 2 files changed, 33 insertions(+), 73 deletions(-)
Acked-by: Richard Genoud <richard.genoud@gmail.com>
^ permalink raw reply
* Re: [PATCH v2 1/2] tty/serial: atmel: remove atmel_default_console_device handling
From: Richard Genoud @ 2017-06-14 7:40 UTC (permalink / raw)
To: Alexandre Belloni, Greg Kroah-Hartman
Cc: Nicolas Ferre, linux-serial, linux-arm-kernel, linux-kernel
In-Reply-To: <20170613202439.26369-1-alexandre.belloni@free-electrons.com>
On 13/06/2017 22:24, Alexandre Belloni wrote:
> atmel_default_console_device was only used by AVR32, in particular
> arch/avr32/mach-at32ap/at32ap700x.c which is now gone. Remove it from the
> driver.
>
> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
> ---
>
> Changes in v2:
> - added an empty line as suggested by Andy
> - properly based the patch on v4.12-rc1
>
> drivers/tty/serial/atmel_serial.c | 43 ---------------------------------------
> 1 file changed, 43 deletions(-)
>
Acked-by: Richard Genoud <richard.genoud@gmail.com>
Thanks !
^ permalink raw reply
* [PATCH] tty/serial: Kconfig: remove AVR32
From: Alexandre Belloni @ 2017-06-13 20:35 UTC (permalink / raw)
To: Richard Genoud, Greg Kroah-Hartman
Cc: Nicolas Ferre, linux-serial, linux-arm-kernel, linux-kernel,
Alexandre Belloni
AVR32 is now removed from the kernel, removed the config symbol that
doesn't exist anymore. Also take the opportunity to reword the help to
include sama5.
Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
---
drivers/tty/serial/Kconfig | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/tty/serial/Kconfig b/drivers/tty/serial/Kconfig
index 5c8850f7a2a0..063c71e8de41 100644
--- a/drivers/tty/serial/Kconfig
+++ b/drivers/tty/serial/Kconfig
@@ -114,14 +114,14 @@ config SERIAL_SB1250_DUART_CONSOLE
If unsure, say Y.
config SERIAL_ATMEL
- bool "AT91 / AT32 on-chip serial port support"
+ bool "Atmel on-chip serial port support"
depends on HAS_DMA
- depends on ARCH_AT91 || AVR32 || COMPILE_TEST
+ depends on ARCH_AT91 || COMPILE_TEST
select SERIAL_CORE
select SERIAL_MCTRL_GPIO if GPIOLIB
help
This enables the driver for the on-chip UARTs of the Atmel
- AT91 and AT32 processors.
+ ARM processors.
config SERIAL_ATMEL_CONSOLE
bool "Support for console on AT91 / AT32 serial port"
--
2.11.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox