[PATCH v4 2/2] iio: light: noa1305: Add support for NOA1305

2019-08-02 Thread Martyn Welch
This driver adds the initial support for the ON Semiconductor
NOA1305 Ambient Light Sensor.

Originally written by Sergei Miroshnichenko. Found here:
  
https://github.com/EmcraftSystems/linux-upstream/commit/196d6cf897e632d2cb82d45484bd7a1bfdd5b6d9

Signed-off-by: Sergei M 
Signed-off-by: Martyn Welch 
---

Changes:
v2:
 - Correcting authorship and SOB.
v3:
 - Improve register define naming.
 - Follow IIO convention of interleaving register bit definitions with
   register defintions.
 - Use proper endian swapping.
 - Process raw sensor count into Lux.
 - Avoid setting variables to zero when not needed.
 - Check return value of i2c writes.
 - Implement disabling of regulator as a devm action.
 - Remove excessive white spacing.
v4:
 - Clean up returns
 - Remove redundant noa1305_remove()
 - Remove redundant interrupt configuration/disabling
 - Return raw value and scaling

Note: Scaling added for all possible interation times to ensure the
  mechanism utilised would allow this, though chip currently
  statically configured to 800mS.

 drivers/iio/light/Kconfig   |  10 ++
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/noa1305.c | 312 
 3 files changed, 323 insertions(+)
 create mode 100644 drivers/iio/light/noa1305.c

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 954c958cfc43..d1db0ec0d0f5 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -309,6 +309,16 @@ config MAX44009
 To compile this driver as a module, choose M here:
 the module will be called max44009.
 
+config NOA1305
+   tristate "ON Semiconductor NOA1305 ambient light sensor"
+   depends on I2C
+   help
+Say Y here if you want to build support for the ON Semiconductor
+NOA1305 ambient light sensor.
+
+To compile this driver as a module, choose M here:
+The module will be called noa1305.
+
 config OPT3001
tristate "Texas Instruments OPT3001 Light Sensor"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index e40794fbb435..00d1f9b98f39 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_LTR501)  += ltr501.o
 obj-$(CONFIG_LV0104CS) += lv0104cs.o
 obj-$(CONFIG_MAX44000) += max44000.o
 obj-$(CONFIG_MAX44009) += max44009.o
+obj-$(CONFIG_NOA1305)  += noa1305.o
 obj-$(CONFIG_OPT3001)  += opt3001.o
 obj-$(CONFIG_PA12203001)   += pa12203001.o
 obj-$(CONFIG_RPR0521)  += rpr0521.o
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
new file mode 100644
index ..b8758aa7b32a
--- /dev/null
+++ b/drivers/iio/light/noa1305.c
@@ -0,0 +1,312 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Support for ON Semiconductor NOA1305 ambient light sensor
+ *
+ * Copyright (C) 2016 Emcraft Systems
+ * Copyright (C) 2019 Collabora Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NOA1305_REG_POWER_CONTROL  0x0
+#define   NOA1305_POWER_CONTROL_DOWN   0x00
+#define   NOA1305_POWER_CONTROL_ON 0x08
+#define NOA1305_REG_RESET  0x1
+#define   NOA1305_RESET_RESET  0x10
+#define NOA1305_REG_INTEGRATION_TIME   0x2
+#define   NOA1305_INTEGR_TIME_800MS0x00
+#define   NOA1305_INTEGR_TIME_400MS0x01
+#define   NOA1305_INTEGR_TIME_200MS0x02
+#define   NOA1305_INTEGR_TIME_100MS0x03
+#define   NOA1305_INTEGR_TIME_50MS 0x04
+#define   NOA1305_INTEGR_TIME_25MS 0x05
+#define   NOA1305_INTEGR_TIME_12_5MS   0x06
+#define   NOA1305_INTEGR_TIME_6_25MS   0x07
+#define NOA1305_REG_INT_SELECT 0x3
+#define   NOA1305_INT_SEL_ACTIVE_HIGH  0x01
+#define   NOA1305_INT_SEL_ACTIVE_LOW   0x02
+#define   NOA1305_INT_SEL_INACTIVE 0x03
+#define NOA1305_REG_INT_THRESH_LSB 0x4
+#define NOA1305_REG_INT_THRESH_MSB 0x5
+#define NOA1305_REG_ALS_DATA_LSB   0x6
+#define NOA1305_REG_ALS_DATA_MSB   0x7
+#define NOA1305_REG_DEVICE_ID_LSB  0x8
+#define NOA1305_REG_DEVICE_ID_MSB  0x9
+
+#define NOA1305_DEVICE_ID  0x0519
+#define NOA1305_DRIVER_NAME"noa1305"
+
+struct noa1305_priv {
+   struct i2c_client *client;
+   struct regmap *regmap;
+   struct regulator *vin_reg;
+};
+
+static int noa1305_measure(struct noa1305_priv *priv)
+{
+   __le16 data;
+   int ret;
+
+   ret = regmap_bulk_read(priv->regmap, NOA1305_REG_ALS_DATA_LSB, ,
+  2);
+   if (ret < 0)
+   return ret;
+
+   return le16_to_cpu(data);
+}
+
+static int noa1305_scale(struct noa1305_priv *priv, int *val, int *val2)
+{
+   int data;
+   int ret;
+
+   ret = regmap_read(priv->regmap, NOA1305_REG_INTEGRATION_TIME, );
+   if (ret < 0)
+   return ret;
+
+   /*
+* Lux = count / ( * )
+ 

[PATCH v4 1/2] dt-bindings: Add binding document for NOA1305

2019-08-02 Thread Martyn Welch
Document the ON Semiconductor NOA1305 ambient light sensor devicetree
bindings.

Signed-off-by: Martyn Welch 
Reviewed-by: Rob Herring 
---

Changes:
v2: Same as v1.
v3: Same as v2.
v4: Same as v3.

 .../bindings/iio/light/noa1305.yaml   | 44 +++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/noa1305.yaml

diff --git a/Documentation/devicetree/bindings/iio/light/noa1305.yaml 
b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
new file mode 100644
index ..17e7f140b69b
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/light/noa1305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor NOA1305 Ambient Light Sensor
+
+maintainers:
+  - Martyn Welch 
+
+description: |
+  Ambient sensing with an i2c interface.
+
+  https://www.onsemi.com/pub/Collateral/NOA1305-D.PDF
+
+properties:
+  compatible:
+enum:
+  - onnn,noa1305
+
+  reg:
+maxItems: 1
+
+  vin-supply:
+description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+i2c {
+
+#address-cells = <1>;
+#size-cells = <0>;
+
+light@39 {
+compatible = "onnn,noa1305";
+reg = <0x39>;
+};
+};
+...
-- 
2.20.1



[PATCH v3 2/2] iio: light: noa1305: Add support for NOA1305

2019-07-26 Thread Martyn Welch
This driver adds the initial support for the ON Semiconductor
NOA1305 Ambient Light Sensor.

Originally written by Sergei Miroshnichenko. Found here:
  
https://github.com/EmcraftSystems/linux-upstream/commit/196d6cf897e632d2cb82d45484bd7a1bfdd5b6d9

Signed-off-by: Sergei M 
Signed-off-by: Martyn Welch 
---

Changes:
v2:
 - Correcting authorship and SOB.
v3:
 - Improve register define naming.
 - Follow IIO convention of interleaving register bit definitions with
   register defintions.
 - Use proper endian swapping.
 - Process raw sensor count into Lux.
 - Avoid setting variables to zero when not needed.
 - Check return value of i2c writes.
 - Implement disabling of regulator as a devm action.
 - Remove excessive white spacing.

 drivers/iio/light/Kconfig   |  10 ++
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/noa1305.c | 278 
 3 files changed, 289 insertions(+)
 create mode 100644 drivers/iio/light/noa1305.c

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 954c958cfc43..d1db0ec0d0f5 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -309,6 +309,16 @@ config MAX44009
 To compile this driver as a module, choose M here:
 the module will be called max44009.
 
+config NOA1305
+   tristate "ON Semiconductor NOA1305 ambient light sensor"
+   depends on I2C
+   help
+Say Y here if you want to build support for the ON Semiconductor
+NOA1305 ambient light sensor.
+
+To compile this driver as a module, choose M here:
+The module will be called noa1305.
+
 config OPT3001
tristate "Texas Instruments OPT3001 Light Sensor"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index e40794fbb435..00d1f9b98f39 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_LTR501)  += ltr501.o
 obj-$(CONFIG_LV0104CS) += lv0104cs.o
 obj-$(CONFIG_MAX44000) += max44000.o
 obj-$(CONFIG_MAX44009) += max44009.o
+obj-$(CONFIG_NOA1305)  += noa1305.o
 obj-$(CONFIG_OPT3001)  += opt3001.o
 obj-$(CONFIG_PA12203001)   += pa12203001.o
 obj-$(CONFIG_RPR0521)  += rpr0521.o
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
new file mode 100644
index ..02b0cf48c2be
--- /dev/null
+++ b/drivers/iio/light/noa1305.c
@@ -0,0 +1,278 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Support for ON Semiconductor NOA1305 ambient light sensor
+ *
+ * Copyright (C) 2016 Emcraft Systems
+ * Copyright (C) 2019 Collabora Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NOA1305_REG_POWER_CONTROL  0x0
+#define   NOA1305_POWER_CONTROL_DOWN   0x00
+#define   NOA1305_POWER_CONTROL_ON 0x08
+#define NOA1305_REG_RESET  0x1
+#define   NOA1305_RESET_RESET  0x10
+#define NOA1305_REG_INTEGRATION_TIME   0x2
+#define   NOA1305_INTEGR_TIME_800MS0x00
+#define   NOA1305_INTEGR_TIME_400MS0x01
+#define   NOA1305_INTEGR_TIME_200MS0x02
+#define   NOA1305_INTEGR_TIME_100MS0x03
+#define   NOA1305_INTEGR_TIME_50MS 0x04
+#define   NOA1305_INTEGR_TIME_25MS 0x05
+#define   NOA1305_INTEGR_TIME_12_5MS   0x06
+#define   NOA1305_INTEGR_TIME_6_25MS   0x07
+#define NOA1305_REG_INT_SELECT 0x3
+#define   NOA1305_INT_SEL_ACTIVE_HIGH  0x01
+#define   NOA1305_INT_SEL_ACTIVE_LOW   0x02
+#define   NOA1305_INT_SEL_INACTIVE 0x03
+#define NOA1305_REG_INT_THRESH_LSB 0x4
+#define NOA1305_REG_INT_THRESH_MSB 0x5
+#define NOA1305_REG_ALS_DATA_LSB   0x6
+#define NOA1305_REG_ALS_DATA_MSB   0x7
+#define NOA1305_REG_DEVICE_ID_LSB  0x8
+#define NOA1305_REG_DEVICE_ID_MSB  0x9
+
+#define NOA1305_DEVICE_ID  0x0519
+#define NOA1305_DRIVER_NAME"noa1305"
+
+struct noa1305_priv {
+   struct i2c_client *client;
+   struct regmap *regmap;
+   struct regulator *vin_reg;
+};
+
+static int noa1305_measure(struct noa1305_priv *priv)
+{
+   __le16 data;
+   int count;
+   int ret;
+
+   ret = regmap_bulk_read(priv->regmap, NOA1305_REG_ALS_DATA_LSB, ,
+  2);
+   if (ret < 0)
+   return ret;
+
+   /*
+* Lux = count / ( * )
+*
+* Integration Constant = 7.7
+* Integration Time in Seconds (currently) = 800ms
+*/
+   return (le16_to_cpu(data) * 100) / (77 * 8);
+}
+
+static const struct iio_chan_spec noa1305_channels[] = {
+   {
+   .type = IIO_LIGHT,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED),
+   }
+};
+
+static int noa1305_read_raw(struct iio_dev *indio_dev,
+   struct iio_chan_spec const *chan,
+   int *val, int *val2, long mask)
+{
+   int ret = -EINVAL;
+   struct noa

[PATCH v3 1/2] dt-bindings: Add binding document for NOA1305

2019-07-26 Thread Martyn Welch
Document the ON Semiconductor NOA1305 ambient light sensor devicetree
bindings.

Signed-off-by: Martyn Welch 
Reviewed-by: Rob Herring 
---

Changes:
v2: Same as v1.
v3: Same as v2.

 .../bindings/iio/light/noa1305.yaml   | 44 +++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/noa1305.yaml

diff --git a/Documentation/devicetree/bindings/iio/light/noa1305.yaml 
b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
new file mode 100644
index ..17e7f140b69b
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/light/noa1305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor NOA1305 Ambient Light Sensor
+
+maintainers:
+  - Martyn Welch 
+
+description: |
+  Ambient sensing with an i2c interface.
+
+  https://www.onsemi.com/pub/Collateral/NOA1305-D.PDF
+
+properties:
+  compatible:
+enum:
+  - onnn,noa1305
+
+  reg:
+maxItems: 1
+
+  vin-supply:
+description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+i2c {
+
+#address-cells = <1>;
+#size-cells = <0>;
+
+light@39 {
+compatible = "onnn,noa1305";
+reg = <0x39>;
+};
+};
+...
-- 
2.20.1



[PATCH v2 1/2] dt-bindings: Add binding document for NOA1305

2019-06-28 Thread Martyn Welch
Document the ON Semiconductor NOA1305 ambient light sensor devicetree
bindings.

Signed-off-by: Martyn Welch 
---

Changes:
v2: Same as v1.

 .../bindings/iio/light/noa1305.yaml   | 44 +++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/noa1305.yaml

diff --git a/Documentation/devicetree/bindings/iio/light/noa1305.yaml 
b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
new file mode 100644
index ..17e7f140b69b
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/light/noa1305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor NOA1305 Ambient Light Sensor
+
+maintainers:
+  - Martyn Welch 
+
+description: |
+  Ambient sensing with an i2c interface.
+
+  https://www.onsemi.com/pub/Collateral/NOA1305-D.PDF
+
+properties:
+  compatible:
+enum:
+  - onnn,noa1305
+
+  reg:
+maxItems: 1
+
+  vin-supply:
+description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+i2c {
+
+#address-cells = <1>;
+#size-cells = <0>;
+
+light@39 {
+compatible = "onnn,noa1305";
+reg = <0x39>;
+};
+};
+...
-- 
2.20.1



[PATCH v2 2/2] iio: light: noa1305: Add support for NOA1305

2019-06-28 Thread Martyn Welch
This driver adds the initial support for the ON Semiconductor
NOA1305 Ambient Light Sensor.

Originally written by Sergei Miroshnichenko. Found here:
  
https://github.com/EmcraftSystems/linux-upstream/commit/196d6cf897e632d2cb82d45484bd7a1bfdd5b6d9

Signed-off-by: Sergei M 
Signed-off-by: Martyn Welch 
---

Changes:
v2: Correcting authorship and SOB.

 drivers/iio/light/Kconfig   |  10 ++
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/noa1305.c | 247 
 3 files changed, 258 insertions(+)
 create mode 100644 drivers/iio/light/noa1305.c

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 954c958cfc43..d1db0ec0d0f5 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -309,6 +309,16 @@ config MAX44009
 To compile this driver as a module, choose M here:
 the module will be called max44009.
 
+config NOA1305
+   tristate "ON Semiconductor NOA1305 ambient light sensor"
+   depends on I2C
+   help
+Say Y here if you want to build support for the ON Semiconductor
+NOA1305 ambient light sensor.
+
+To compile this driver as a module, choose M here:
+The module will be called noa1305.
+
 config OPT3001
tristate "Texas Instruments OPT3001 Light Sensor"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index e40794fbb435..00d1f9b98f39 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_LTR501)  += ltr501.o
 obj-$(CONFIG_LV0104CS) += lv0104cs.o
 obj-$(CONFIG_MAX44000) += max44000.o
 obj-$(CONFIG_MAX44009) += max44009.o
+obj-$(CONFIG_NOA1305)  += noa1305.o
 obj-$(CONFIG_OPT3001)  += opt3001.o
 obj-$(CONFIG_PA12203001)   += pa12203001.o
 obj-$(CONFIG_RPR0521)  += rpr0521.o
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
new file mode 100644
index ..2c65c5c2e09a
--- /dev/null
+++ b/drivers/iio/light/noa1305.c
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Support for ON Semiconductor NOA1305 ambient light sensor
+ *
+ * Copyright (C) 2016 Emcraft Systems
+ * Copyright (C) 2019 Collabora Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NOA1305_REG_POWER_CONTROL  0x0
+#define NOA1305_REG_RESET  0x1
+#define NOA1305_REG_INTEGRATION_TIME   0x2
+#define NOA1305_REG_INT_SELECT 0x3
+#define NOA1305_REG_INT_THRESH_LSB 0x4
+#define NOA1305_REG_INT_THRESH_MSB 0x5
+#define NOA1305_REG_ALS_DATA_LSB   0x6
+#define NOA1305_REG_ALS_DATA_MSB   0x7
+#define NOA1305_REG_DEVICE_ID_LSB  0x8
+#define NOA1305_REG_DEVICE_ID_MSB  0x9
+
+#define NOA1305_DEVICE_ID  0x0519
+
+#define NOA1305_POWER_ON   0x08
+#define NOA1305_POWER_DOWN 0x00
+#define NOA1305_RESET  0x10
+
+#define NOA1305_INT_ACTIVE_HIGH0x01
+#define NOA1305_INT_ACTIVE_LOW 0x02
+#define NOA1305_INT_INACTIVE   0x03
+
+#define NOA1305_INTEGR_TIME_800MS  0x00
+#define NOA1305_INTEGR_TIME_400MS  0x01
+#define NOA1305_INTEGR_TIME_200MS  0x02
+#define NOA1305_INTEGR_TIME_100MS  0x03
+#define NOA1305_INTEGR_TIME_50MS   0x04
+#define NOA1305_INTEGR_TIME_25MS   0x05
+#define NOA1305_INTEGR_TIME_12_5MS 0x06
+#define NOA1305_INTEGR_TIME_6_25MS 0x07
+
+#define NOA1305_DRIVER_NAME"noa1305"
+
+struct noa1305_priv {
+   struct i2c_client *client;
+   struct regmap *regmap;
+   struct regulator *vin_reg;
+};
+
+static int noa1305_measure(struct noa1305_priv *priv)
+{
+   u8 data[2];
+   int ret;
+
+   ret = regmap_bulk_read(priv->regmap, NOA1305_REG_ALS_DATA_LSB, data,
+  2);
+   if (ret < 0)
+   return ret;
+
+   return (data[1] << 8) | data[0];
+}
+
+static const struct iio_chan_spec noa1305_channels[] = {
+   {
+   .type = IIO_LIGHT,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+   }
+};
+
+static int noa1305_read_raw(struct iio_dev *indio_dev,
+   struct iio_chan_spec const *chan,
+   int *val, int *val2, long mask)
+{
+   int ret = -EINVAL;
+   struct noa1305_priv *priv = iio_priv(indio_dev);
+
+   switch (mask) {
+   case IIO_CHAN_INFO_RAW:
+   switch (chan->type) {
+   case IIO_LIGHT:
+   ret = noa1305_measure(priv);
+   if (ret < 0)
+   return ret;
+   *val = ret;
+   ret = IIO_VAL_INT;
+   break;
+   default:
+   break;
+   }
+   break;
+   default:
+   break;
+ 

[PATCH 2/2] iio: light: noa1305: Add support for NOA1305

2019-06-28 Thread Martyn Welch
From: Martyn Welch 

This driver adds the initial support for the ON Semiconductor
NOA1305 Ambient Light Sensor.

Originally written by Sergei Miroshnichenko. Found here:
  
https://github.com/EmcraftSystems/linux-upstream/commit/196d6cf897e632d2cb82d45484bd7a1bfdd5b6d9

Signed-off-by: Sergei M 
Signed-off-by: Martyn Welch 
---
 drivers/iio/light/Kconfig   |  10 ++
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/noa1305.c | 247 
 3 files changed, 258 insertions(+)
 create mode 100644 drivers/iio/light/noa1305.c

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 954c958cfc43..d1db0ec0d0f5 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -309,6 +309,16 @@ config MAX44009
 To compile this driver as a module, choose M here:
 the module will be called max44009.
 
+config NOA1305
+   tristate "ON Semiconductor NOA1305 ambient light sensor"
+   depends on I2C
+   help
+Say Y here if you want to build support for the ON Semiconductor
+NOA1305 ambient light sensor.
+
+To compile this driver as a module, choose M here:
+The module will be called noa1305.
+
 config OPT3001
tristate "Texas Instruments OPT3001 Light Sensor"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index e40794fbb435..00d1f9b98f39 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -29,6 +29,7 @@ obj-$(CONFIG_LTR501)  += ltr501.o
 obj-$(CONFIG_LV0104CS) += lv0104cs.o
 obj-$(CONFIG_MAX44000) += max44000.o
 obj-$(CONFIG_MAX44009) += max44009.o
+obj-$(CONFIG_NOA1305)  += noa1305.o
 obj-$(CONFIG_OPT3001)  += opt3001.o
 obj-$(CONFIG_PA12203001)   += pa12203001.o
 obj-$(CONFIG_RPR0521)  += rpr0521.o
diff --git a/drivers/iio/light/noa1305.c b/drivers/iio/light/noa1305.c
new file mode 100644
index ..2c65c5c2e09a
--- /dev/null
+++ b/drivers/iio/light/noa1305.c
@@ -0,0 +1,247 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Support for ON Semiconductor NOA1305 ambient light sensor
+ *
+ * Copyright (C) 2016 Emcraft Systems
+ * Copyright (C) 2019 Collabora Ltd.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define NOA1305_REG_POWER_CONTROL  0x0
+#define NOA1305_REG_RESET  0x1
+#define NOA1305_REG_INTEGRATION_TIME   0x2
+#define NOA1305_REG_INT_SELECT 0x3
+#define NOA1305_REG_INT_THRESH_LSB 0x4
+#define NOA1305_REG_INT_THRESH_MSB 0x5
+#define NOA1305_REG_ALS_DATA_LSB   0x6
+#define NOA1305_REG_ALS_DATA_MSB   0x7
+#define NOA1305_REG_DEVICE_ID_LSB  0x8
+#define NOA1305_REG_DEVICE_ID_MSB  0x9
+
+#define NOA1305_DEVICE_ID  0x0519
+
+#define NOA1305_POWER_ON   0x08
+#define NOA1305_POWER_DOWN 0x00
+#define NOA1305_RESET  0x10
+
+#define NOA1305_INT_ACTIVE_HIGH0x01
+#define NOA1305_INT_ACTIVE_LOW 0x02
+#define NOA1305_INT_INACTIVE   0x03
+
+#define NOA1305_INTEGR_TIME_800MS  0x00
+#define NOA1305_INTEGR_TIME_400MS  0x01
+#define NOA1305_INTEGR_TIME_200MS  0x02
+#define NOA1305_INTEGR_TIME_100MS  0x03
+#define NOA1305_INTEGR_TIME_50MS   0x04
+#define NOA1305_INTEGR_TIME_25MS   0x05
+#define NOA1305_INTEGR_TIME_12_5MS 0x06
+#define NOA1305_INTEGR_TIME_6_25MS 0x07
+
+#define NOA1305_DRIVER_NAME"noa1305"
+
+struct noa1305_priv {
+   struct i2c_client *client;
+   struct regmap *regmap;
+   struct regulator *vin_reg;
+};
+
+static int noa1305_measure(struct noa1305_priv *priv)
+{
+   u8 data[2];
+   int ret;
+
+   ret = regmap_bulk_read(priv->regmap, NOA1305_REG_ALS_DATA_LSB, data,
+  2);
+   if (ret < 0)
+   return ret;
+
+   return (data[1] << 8) | data[0];
+}
+
+static const struct iio_chan_spec noa1305_channels[] = {
+   {
+   .type = IIO_LIGHT,
+   .info_mask_separate = BIT(IIO_CHAN_INFO_RAW),
+   }
+};
+
+static int noa1305_read_raw(struct iio_dev *indio_dev,
+   struct iio_chan_spec const *chan,
+   int *val, int *val2, long mask)
+{
+   int ret = -EINVAL;
+   struct noa1305_priv *priv = iio_priv(indio_dev);
+
+   switch (mask) {
+   case IIO_CHAN_INFO_RAW:
+   switch (chan->type) {
+   case IIO_LIGHT:
+   ret = noa1305_measure(priv);
+   if (ret < 0)
+   return ret;
+   *val = ret;
+   ret = IIO_VAL_INT;
+   break;
+   default:
+   break;
+   }
+   break;
+   default:
+   break;
+   }
+
+   return ret;

[PATCH 1/2] dt-bindings: Add binding document for NOA1305

2019-06-28 Thread Martyn Welch
Document the ON Semiconductor NOA1305 ambient light sensor devicetree
bindings.

Signed-off-by: Martyn Welch 
---
 .../bindings/iio/light/noa1305.yaml   | 44 +++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/noa1305.yaml

diff --git a/Documentation/devicetree/bindings/iio/light/noa1305.yaml 
b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
new file mode 100644
index ..17e7f140b69b
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/light/noa1305.yaml
@@ -0,0 +1,44 @@
+# SPDX-License-Identifier: GPL-2.0
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/iio/light/noa1305.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ON Semiconductor NOA1305 Ambient Light Sensor
+
+maintainers:
+  - Martyn Welch 
+
+description: |
+  Ambient sensing with an i2c interface.
+
+  https://www.onsemi.com/pub/Collateral/NOA1305-D.PDF
+
+properties:
+  compatible:
+enum:
+  - onnn,noa1305
+
+  reg:
+maxItems: 1
+
+  vin-supply:
+description: Regulator that provides power to the sensor
+
+required:
+  - compatible
+  - reg
+
+examples:
+  - |
+i2c {
+
+#address-cells = <1>;
+#size-cells = <0>;
+
+light@39 {
+compatible = "onnn,noa1305";
+reg = <0x39>;
+};
+};
+...
-- 
2.20.1



Re: [PATCH] ARM: dts: am335x: Add support for Bosch Guardian

2019-02-12 Thread Martyn Welch
On Tue, 2019-02-12 at 10:49 -0800, Tony Lindgren wrote:
> Hi,
> 
> * Martyn Welch  [190211 04:27]:
> > The Bosch Guardian is a TI am335x based device.
> > 
> > It's hardware specifications are as follows:
> > 
> >  * 256 MB DDR3 memory
> >  * 512 MB NAND Flash
> >  * USB OTG
> >  * RS232
> >  * MicroSD external storage
> >  * LCD Display interface
> 
> Thanks applying into omap-for-v5.1/dt.
> 

Thanks Tony.

> Do you have some link for this device for more
> information?
> 

I'm not aware of any publicly available documentation at this time.

> > +/include/ "tps65217.dtsi"
> 
> I'll update this to use #include "tps65217.dtsi"
> while applying.
> 

OK, I found examples of both, guess I picked the wrong one :-)

Martyn

> Regards,
> 
> Tony



[PATCH] ARM: dts: am335x: Add support for Bosch Guardian

2019-02-11 Thread Martyn Welch
The Bosch Guardian is a TI am335x based device.

It's hardware specifications are as follows:

 * 256 MB DDR3 memory
 * 512 MB NAND Flash
 * USB OTG
 * RS232
 * MicroSD external storage
 * LCD Display interface

Signed-off-by: Martyn Welch 

---

 arch/arm/boot/dts/Makefile|   1 +
 arch/arm/boot/dts/am335x-guardian.dts | 511 ++
 2 files changed, 512 insertions(+)
 create mode 100644 arch/arm/boot/dts/am335x-guardian.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index bd40148a15b2..1ad9a6307b0a 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -719,6 +719,7 @@ dtb-$(CONFIG_SOC_AM33XX) += \
am335x-cm-t335.dtb \
am335x-evm.dtb \
am335x-evmsk.dtb \
+   am335x-guardian.dtb \
am335x-icev2.dtb \
am335x-lxm.dtb \
am335x-moxa-uc-2101.dtb \
diff --git a/arch/arm/boot/dts/am335x-guardian.dts 
b/arch/arm/boot/dts/am335x-guardian.dts
new file mode 100644
index ..d8652ab014b2
--- /dev/null
+++ b/arch/arm/boot/dts/am335x-guardian.dts
@@ -0,0 +1,511 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
+ * Copyright (C) 2018 Robert Bosch Power Tools GmbH
+ */
+/dts-v1/;
+
+#include "am33xx.dtsi"
+#include 
+#include 
+
+/ {
+   model = "Bosch AM335x Guardian";
+   compatible = "bosch,am335x-guardian", "ti,am33xx";
+
+   chosen {
+   stdout-path = 
+   tick-timer = 
+   };
+
+   cpus {
+   cpu@0 {
+   cpu0-supply = <_reg>;
+   };
+   };
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x1000>; /* 256 MB */
+   };
+
+   gpio_keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   pinctrl-names = "default";
+   pinctrl-0 = <_keys_pins>;
+
+   button21 {
+   label = "guardian-power-button";
+   linux,code = ;
+   gpios = < 21 0>;
+   wakeup-source;
+   };
+   };
+
+   leds {
+   compatible = "gpio-leds";
+   pinctrl-names = "default";
+   pinctrl-0 = <_pins>;
+
+   led1 {
+   label = "green:heartbeat";
+   gpios = < 27 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   default-state = "off";
+   };
+
+   led2 {
+   label = "green:mmc0";
+   gpios = < 26 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "mmc0";
+   default-state = "off";
+   };
+   };
+
+   panel {
+   compatible = "ti,tilcdc,panel";
+   pinctrl-names = "default", "sleep";
+   pinctrl-0 = <_pins_default _disen_pins>;
+   pinctrl-1 = <_pins_sleep>;
+
+   display-timings {
+   320x240 {
+   hactive = <320>;
+   vactive = <240>;
+   hback-porch = <68>;
+   hfront-porch= <20>;
+   hsync-len   = <1>;
+   vback-porch = <18>;
+   vfront-porch= <4>;
+   vsync-len   = <1>;
+   clock-frequency = <900>;
+   hsync-active= <0>;
+   vsync-active= <0>;
+   };
+   };
+   panel-info {
+   ac-bias   = <255>;
+   ac-bias-intrpt= <0>;
+   dma-burst-sz  = <16>;
+   bpp   = <24>;
+   bus-width = <16>;
+   fdd   = <0x80>;
+   sync-edge = <0>;
+   sync-ctrl = <1>;
+   raster-order  = <0>;
+   fifo-th   = <0>;
+   };
+
+   };
+
+   pwm7: dmtimer-pwm {
+   compatible = "ti,omap-dmtimer-pwm";
+   ti,timers = <>;
+   pinctrl-names = "default";
+  

[PATCH v3 2/2] ARM: dts: imx6: Add support for Phytec phyBOARD i.MX6UL Segin

2019-01-21 Thread Martyn Welch
The Phytec phyBOARD Segin is i.MX6 based SBC, available with either an
i.MX6UL or i.MX6ULL SOM and various add-on boards.

The following adds support for the "Full Featured" version of the Segin,
which is provided with the i.MX6UL SOM and the PEB-EVAL-01 evaluation
module.

Its hardware specifications are:

 * 512MB DDR3 memory
 * 512MB NAND flash
 * Dual 10/100 Ethernet
 * USB Host and USB OTG
 * RS232
 * MicroSD external storage
 * Audio, RS232, I2C, SPI, CAN headers
 * Further I/O options via A/V and Expansion headers

Signed-off-by: Martyn Welch 

---

Changes in v3:
- Add memory device_type property
- Remove unneeded pinctrl-names property
- Keep compatible string on a single line
- Make node names generic and labels specific

Changes in v2:
- Corrected spacing, ordering and naming
- Corrected ecspi3 chip selects
- Updated deprecated node
- Removed unneeded nodes

 arch/arm/boot/dts/Makefile|   1 +
 arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi   | 148 
 .../boot/dts/imx6ul-phytec-peb-eval-01.dtsi   |  55 +++
 .../dts/imx6ul-phytec-phyboard-segin-full.dts |  89 +
 .../dts/imx6ul-phytec-phyboard-segin.dtsi | 329 ++
 5 files changed, 622 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-peb-eval-01.dtsi
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-phyboard-segin-full.dts
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-phyboard-segin.dtsi

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index bd40148a15b2..d35a0bf7b8f8 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -561,6 +561,7 @@ dtb-$(CONFIG_SOC_IMX6UL) += \
imx6ul-opos6uldev.dtb \
imx6ul-pico-hobbit.dtb \
imx6ul-pico-pi.dtb \
+   imx6ul-phytec-phyboard-segin-full.dtb \
imx6ul-tx6ul-0010.dtb \
imx6ul-tx6ul-0011.dtb \
imx6ul-tx6ul-mainboard.dtb \
diff --git a/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi 
b/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
new file mode 100644
index ..fc2997449b49
--- /dev/null
+++ b/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
@@ -0,0 +1,148 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Christian Hemp 
+ */
+
+#include 
+#include 
+#include 
+#include "imx6ul.dtsi"
+
+/ {
+   model = "Phytec phyCORE i.MX6 UltraLite";
+   compatible = "phytec,imx6ul-pcl063", "fsl,imx6ul";
+
+   chosen {
+   stdout-path = 
+   };
+
+   /*
+* Set the minimum memory size here and
+* let the bootloader set the real size.
+*/
+   memory {
+   device_type = "memory";
+   reg = <0x8000 0x800>;
+   };
+
+   gpio_leds_som: leds {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpioleds_som>;
+   compatible = "gpio-leds";
+
+   led_green {
+   label = "phycore:green";
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_enet1>;
+   phy-mode = "rmii";
+   phy-handle = <>;
+   status = "okay";
+
+   mdio: mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@1 {
+   reg = <1>;
+   interrupt-parent = <>;
+   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+   micrel,led-mode = <1>;
+   clocks = < IMX6UL_CLK_ENET_REF>;
+   clock-names = "rmii-ref";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpmi_nand>;
+   nand-on-flash-bbt;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 =<_i2c1>;
+   clock-frequency = <10>;
+   status = "okay";
+
+   eeprom@52 {
+   compatible = "catalyst,24c32", "atmel,24c32";
+   reg = <0x52>;
+   };
+};
+
+_poweroff {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   status = "okay";
+};
+
+ {
+   pinctrl_enet1: enet1grp {
+   fsl,pins = <
+   MX6UL_PAD_GPIO1_IO07__ENET1_MDC 0x1b0b0
+   MX6UL_PAD_GPIO1_IO06__ENET1_MDIO0x1b0b0
+   MX6UL_PAD_ENET1_RX_EN__ENET1_RX_EN  0x1b0b0
+   

[PATCH v3 1/2] dt-bindings: Add vendor prefix for Catalyst Semiconductor

2019-01-21 Thread Martyn Welch
Add vendor prefix "catalyst" for Catalyst Semiconductor which is
already in use but undocumented.

Signed-off-by: Martyn Welch 
Reviewed-by: Rob Herring 

---

Changes in v3:
- Add full stop to denote abbreviation.

Changes in v2: None

 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 389508584f48..a81de3134724 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -65,6 +65,7 @@ bticino Bticino International
 calxedaCalxeda
 capellaCapella Microsystems, Inc
 cascodaCascoda, Ltd.
+catalyst   Catalyst Semiconductor, Inc.
 cavium Cavium, Inc.
 cdns   Cadence Design Systems Inc.
 cdtech CDTech(H.K.) Electronics Limited
-- 
2.20.1



Re: [PATCH v2 2/2] ARM: dts: imx6: Add support for Phytec phyBOARD i.MX6UL Segin

2019-01-21 Thread Martyn Welch
Hi Fabio,

On Fri, 2019-01-18 at 19:18 -0200, Fabio Estevam wrote:
> diff --git a/arch/arm/boot/dts/imx6ul-phytec-phyboard-segin-
> > full.dts b/arch/arm/boot/dts/imx6ul-phytec-phyboard-segin-full.dts
> > new file mode 100644
> > index ..83cdf4fa10c0
> > --- /dev/null
> > +++ b/arch/arm/boot/dts/imx6ul-phytec-phyboard-segin-full.dts
> > @@ -0,0 +1,96 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Copyright (C) 2016 PHYTEC Messtechnik GmbH
> > + * Author: Christian Hemp 
> > + */
> > +
> > +/dts-v1/;
> > +#include "imx6ul-phytec-pcl063.dtsi"
> > +#include "imx6ul-phytec-phyboard-segin.dtsi"
> > +#include "imx6ul-phytec-peb-eval-01.dtsi"
> > +
> > +/ {
> > +   model = "Phytec phyBOARD-Segin i.MX6 UltraLite Full
> > Featured";
> > +   compatible = "phytec,imx6ul-pbacd10", "phytec,imx6ul-
> > pcl063",
> > +"fsl,imx6ul";
> 
> Better keep it in a single line?
> 

It makes it longer than 80 chars, but I'm not adverse to that.

> > + {
> > +   pinctrl-names = "default";
> > +   pinctrl-0 = <_ecspi3>;
> > +   cs-gpios = < 20 GPIO_ACTIVE_HIGH>;
> > +   status = "okay";
> > +
> > +   spidev@0 {
> > +   compatible = "spidev";
> 
> Doesn't the kernel complain about spidev dts nodes?
> 

Oh, yes, it does when spidev is loaded...

Removing.

Martyn



[PATCH v2 1/2] dt-bindings: Add vendor prefix for Catalyst Semiconductor

2019-01-18 Thread Martyn Welch
Add vendor prefix "catalyst" for Catalyst Semiconductor which is
already in use but undocumented.

Signed-off-by: Martyn Welch 
Reviewed-by: Rob Herring 
---

Changes in v2: None

 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 389508584f48..d80b23b7771f 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -65,6 +65,7 @@ bticino Bticino International
 calxedaCalxeda
 capellaCapella Microsystems, Inc
 cascodaCascoda, Ltd.
+catalyst   Catalyst Semiconductor, Inc
 cavium Cavium, Inc.
 cdns   Cadence Design Systems Inc.
 cdtech CDTech(H.K.) Electronics Limited
-- 
2.20.1



[PATCH v2 2/2] ARM: dts: imx6: Add support for Phytec phyBOARD i.MX6UL Segin

2019-01-18 Thread Martyn Welch
The Phytec phyBOARD Segin is i.MX6 based SBC, available with either an
i.MX6UL or i.MX6ULL SOM and various add-on boards.

The following adds support for the "Full Featured" version of the Segin,
which is provided with the i.MX6UL SOM and the PEB-EVAL-01 evaluation
module.

Its hardware specifications are:

 * 512MB DDR3 memory
 * 512MB NAND flash
 * Dual 10/100 Ethernet
 * USB Host and USB OTG
 * RS232
 * MicroSD external storage
 * Audio, RS232, I2C, SPI, CAN headers
 * Further I/O options via A/V and Expansion headers

Signed-off-by: Martyn Welch 

---

Changes in v2:
- Corrected spacing, ordering and naming
- Corrected ecspi3 chip selects
- Updated deprecated node
- Removed unneeded nodes

 arch/arm/boot/dts/Makefile|   1 +
 arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi   | 149 
 .../boot/dts/imx6ul-phytec-peb-eval-01.dtsi   |  55 +++
 .../dts/imx6ul-phytec-phyboard-segin-full.dts |  96 +
 .../dts/imx6ul-phytec-phyboard-segin.dtsi | 330 ++
 5 files changed, 631 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-peb-eval-01.dtsi
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-phyboard-segin-full.dts
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-phyboard-segin.dtsi

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index bd40148a15b2..d35a0bf7b8f8 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -561,6 +561,7 @@ dtb-$(CONFIG_SOC_IMX6UL) += \
imx6ul-opos6uldev.dtb \
imx6ul-pico-hobbit.dtb \
imx6ul-pico-pi.dtb \
+   imx6ul-phytec-phyboard-segin-full.dtb \
imx6ul-tx6ul-0010.dtb \
imx6ul-tx6ul-0011.dtb \
imx6ul-tx6ul-mainboard.dtb \
diff --git a/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi 
b/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
new file mode 100644
index ..03c194c89fa7
--- /dev/null
+++ b/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
@@ -0,0 +1,149 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Christian Hemp 
+ */
+
+#include 
+#include 
+#include 
+#include "imx6ul.dtsi"
+
+/ {
+   model = "Phytec phyCORE i.MX6 UltraLite";
+   compatible = "phytec,imx6ul-pcl063", "fsl,imx6ul";
+
+   chosen {
+   stdout-path = 
+   };
+
+   /*
+* Set the minimum memory size here and
+* let the bootloader set the real size.
+*/
+   memory {
+   reg = <0x8000 0x800>;
+   };
+
+   gpio_leds_som: leds {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpioleds_som>;
+   compatible = "gpio-leds";
+
+   led_green {
+   label = "phycore:green";
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_enet1>;
+   phy-mode = "rmii";
+   phy-handle = <>;
+   status = "okay";
+
+   mdio: mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@1 {
+   reg = <1>;
+   interrupt-parent = <>;
+   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+   micrel,led-mode = <1>;
+   clocks = < IMX6UL_CLK_ENET_REF>;
+   clock-names = "rmii-ref";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpmi_nand>;
+   nand-on-flash-bbt;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 =<_i2c1>;
+   clock-frequency = <10>;
+   status = "okay";
+
+   eeprom@52 {
+   compatible = "catalyst,24c32", "atmel,24c32";
+   reg = <0x52>;
+   };
+};
+
+_poweroff {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+
+   pinctrl_enet1: enet1grp {
+   fsl,pins = <
+   MX6UL_PAD_GPIO1_IO07__ENET1_MDC 0x1b0b0
+   MX6UL_PAD_GPIO1_IO06__ENET1_MDIO0x1b0b0
+   MX6UL_PAD_ENET1_RX_EN__ENET1_RX_EN  0x1b0b0
+   MX6UL_PAD_ENET1_RX_ER__ENET1_RX_ER  0x1b0b0
+   MX6UL_PAD_ENET1_RX_DATA0__ENET1_RDATA00 0x1b0b0
+   MX6

[PATCH 1/2] dt-bindings: Add vendor prefix for Catalyst Semiconductor

2018-12-11 Thread Martyn Welch
Add vendor prefix "catalyst" for Catalyst Semiconductor which is
already in use but undocumented.

Signed-off-by: Martyn Welch 
---

 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 4b1a2a8fcc16..bbc41483e81b 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -65,6 +65,7 @@ bticino Bticino International
 calxedaCalxeda
 capellaCapella Microsystems, Inc
 cascodaCascoda, Ltd.
+catalyst   Catalyst Semiconductor, Inc
 cavium Cavium, Inc.
 cdns   Cadence Design Systems Inc.
 ceva   Ceva, Inc.
-- 
2.19.2



[PATCH 2/2] ARM: dts: imx6: Add support for Phytec phyBOARD i.MX6UL Segin

2018-12-11 Thread Martyn Welch
The Phytec phyBOARD Segin is i.MX6 based SBC, available with either an
i.MX6UL or i.MX6ULL SOM and various add-on boards.

The following adds support for the "Full Featured" version of the Segin,
which is provided with the i.MX6UL SOM and the PEB-EVAL-01 evaluation
module.

Its hardware specifications are:

 * 512MB DDR3 memory
 * 512MB NAND flash
 * Dual 10/100 Ethernet
 * USB Host and USB OTG
 * RS232
 * MicroSD external storage
 * Audio, RS232, I2C, SPI, CAN headers
 * Further I/O options via A/V and Expansion headers

Signed-off-by: Martyn Welch 

---

 arch/arm/boot/dts/Makefile|   1 +
 arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi   | 152 
 .../boot/dts/imx6ul-phytec-peb-eval-01.dtsi   |  55 +++
 .../dts/imx6ul-phytec-phyboard-segin-full.dts | 103 ++
 .../dts/imx6ul-phytec-phyboard-segin.dtsi | 341 ++
 5 files changed, 652 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-peb-eval-01.dtsi
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-phyboard-segin-full.dts
 create mode 100644 arch/arm/boot/dts/imx6ul-phytec-phyboard-segin.dtsi

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index b0e966d625b9..6ca286f6b37c 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -557,6 +557,7 @@ dtb-$(CONFIG_SOC_IMX6UL) += \
imx6ul-liteboard.dtb \
imx6ul-opos6uldev.dtb \
imx6ul-pico-hobbit.dtb \
+   imx6ul-phytec-phyboard-segin-full.dtb \
imx6ul-tx6ul-0010.dtb \
imx6ul-tx6ul-0011.dtb \
imx6ul-tx6ul-mainboard.dtb \
diff --git a/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi 
b/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
new file mode 100644
index ..ede24105044f
--- /dev/null
+++ b/arch/arm/boot/dts/imx6ul-phytec-pcl063.dtsi
@@ -0,0 +1,152 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright (C) 2016 PHYTEC Messtechnik GmbH
+ * Author: Christian Hemp 
+ */
+
+#include 
+#include 
+#include 
+#include "imx6ul.dtsi"
+
+/ {
+
+   model = "Phytec phyCORE i.MX6 UltraLite";
+   compatible = "phytec,imx6ul-pcl063", "fsl,imx6ul";
+
+   chosen {
+   stdout-path = 
+   };
+
+
+   /*
+* Set the minimum memory size here and
+* let the bootloader set the real size.
+*/
+   memory {
+   reg = <0x8000 0x800>;
+   };
+
+   gpio_leds_som: somleds {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpioleds_som>;
+   compatible = "gpio-leds";
+   status = "okay";
+
+   som_green {
+   label = "phycore:green";
+   gpios = < 4 GPIO_ACTIVE_HIGH>;
+   linux,default-trigger = "heartbeat";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_enet1>;
+   phy-mode = "rmii";
+   phy-handle = <>;
+   status = "okay";
+
+   mdio: mdio {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   ethphy0: ethernet-phy@1 {
+   reg = <1>;
+   interrupt-parent = <>;
+   interrupts = <2 IRQ_TYPE_LEVEL_LOW>;
+   micrel,led-mode = <1>;
+   clocks = < IMX6UL_CLK_ENET_REF>;
+   clock-names = "rmii-ref";
+   };
+   };
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_gpmi_nand>;
+   nand-on-flash-bbt;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 =<_i2c1>;
+   clock-frequency = <10>;
+   status = "okay";
+
+   eeprom@52 {
+   compatible = "catalyst,24c32", "atmel,24c32";
+   reg = <0x52>;
+   };
+};
+
+_poweroff {
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+   pinctrl-0 = <_uart1>;
+   status = "okay";
+};
+
+ {
+   pinctrl-names = "default";
+
+   pinctrl_enet1: enet1grp {
+   fsl,pins = <
+   MX6UL_PAD_GPIO1_IO07__ENET1_MDC 0x1b0b0
+   MX6UL_PAD_GPIO1_IO06__ENET1_MDIO0x1b0b0
+   MX6UL_PAD_ENET1_RX_EN__ENET1_RX_EN  0x1b0b0
+   MX6UL_PAD_ENET1_RX_ER__ENET1_RX_ER  0x1b0b0
+   MX6UL_PAD_ENET1_RX_DATA0__ENET1_RDATA00 0x1b0b0
+   MX6UL_PAD_ENET1_RX_DATA1__ENET1_RDATA01 0x1b0b0
+   MX6UL_PAD_ENET1_TX_EN__ENET1_TX_EN  0x1b0b0
+ 

Re: [PATCH] vme: remove unneeded kfree

2018-09-07 Thread Martyn Welch
On Thu, 2018-09-06 at 22:04 -0700, Linus Torvalds wrote:
> On Thu, Sep 6, 2018 at 1:51 AM Ding Xiang
>  wrote:
> > 
> > put_device will call vme_dev_release to free vdev, kfree is
> > unnecessary here.
> 
> That does seem to be the case.  I think "unnecessary" is overly kind,
> it does seem to be a double free.
> 
> Looks like the issue was introduced back in 2013 by commit
> def1820d25fa ("vme: add missing put_device() after device_register()
> fails").
> 
> It seems you should *either* kfree() the vdev, _or_ do put_device(),
> but doing both seems wrong.
> 
> I presume the device_register() has never failed, and this being
> vme-only I'm guessing there isn't a vibrant testing community.
> 

I think that is also overly kind :-)

I currently lack access to suitable hardware to test fully myself and I
need to find some time to (re)implement some automated testing, after I
lost access to the bits I had when I left a previous employer. That and
see if I can get access to some hardware again...

Manohar, do you still have access/interest in the VME stuff? You've
been very quiet for a long time now.

Martyn


Re: [PATCH] vme: remove unneeded kfree

2018-09-07 Thread Martyn Welch
On Thu, 2018-09-06 at 22:04 -0700, Linus Torvalds wrote:
> On Thu, Sep 6, 2018 at 1:51 AM Ding Xiang
>  wrote:
> > 
> > put_device will call vme_dev_release to free vdev, kfree is
> > unnecessary here.
> 
> That does seem to be the case.  I think "unnecessary" is overly kind,
> it does seem to be a double free.
> 
> Looks like the issue was introduced back in 2013 by commit
> def1820d25fa ("vme: add missing put_device() after device_register()
> fails").
> 
> It seems you should *either* kfree() the vdev, _or_ do put_device(),
> but doing both seems wrong.
> 
> I presume the device_register() has never failed, and this being
> vme-only I'm guessing there isn't a vibrant testing community.
> 

I think that is also overly kind :-)

I currently lack access to suitable hardware to test fully myself and I
need to find some time to (re)implement some automated testing, after I
lost access to the bits I had when I left a previous employer. That and
see if I can get access to some hardware again...

Manohar, do you still have access/interest in the VME stuff? You've
been very quiet for a long time now.

Martyn


Re: [PATCH] vme: ca91cx42: remove redundant variable i

2018-07-14 Thread Martyn Welch
On Sat, Jul 14, 2018 at 05:33:32PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Variable i is being assigned but is never used hence it is redundant
> and can be removed.
> 
> Cleans up clang warning:
> warning: variable 'i' set but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Martyn Welch 

> ---
>  drivers/vme/bridges/vme_ca91cx42.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
> b/drivers/vme/bridges/vme_ca91cx42.c
> index 5dd284008630..53bdc256805f 100644
> --- a/drivers/vme/bridges/vme_ca91cx42.c
> +++ b/drivers/vme/bridges/vme_ca91cx42.c
> @@ -970,7 +970,6 @@ static unsigned int ca91cx42_master_rmw(struct 
> vme_master_resource *image,
>  {
>   u32 result;
>   uintptr_t pci_addr;
> - int i;
>   struct ca91cx42_driver *bridge;
>   struct device *dev;
>  
> @@ -978,7 +977,6 @@ static unsigned int ca91cx42_master_rmw(struct 
> vme_master_resource *image,
>   dev = image->parent->parent;
>  
>   /* Find the PCI address that maps to the desired VME address */
> - i = image->number;
>  
>   /* Locking as we can only do one of these at a time */
>   mutex_lock(>vme_rmw);
> -- 
> 2.17.1
> 


Re: [PATCH] vme: ca91cx42: remove redundant variable i

2018-07-14 Thread Martyn Welch
On Sat, Jul 14, 2018 at 05:33:32PM +0100, Colin King wrote:
> From: Colin Ian King 
> 
> Variable i is being assigned but is never used hence it is redundant
> and can be removed.
> 
> Cleans up clang warning:
> warning: variable 'i' set but not used [-Wunused-but-set-variable]
> 
> Signed-off-by: Colin Ian King 

Reviewed-by: Martyn Welch 

> ---
>  drivers/vme/bridges/vme_ca91cx42.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/vme/bridges/vme_ca91cx42.c 
> b/drivers/vme/bridges/vme_ca91cx42.c
> index 5dd284008630..53bdc256805f 100644
> --- a/drivers/vme/bridges/vme_ca91cx42.c
> +++ b/drivers/vme/bridges/vme_ca91cx42.c
> @@ -970,7 +970,6 @@ static unsigned int ca91cx42_master_rmw(struct 
> vme_master_resource *image,
>  {
>   u32 result;
>   uintptr_t pci_addr;
> - int i;
>   struct ca91cx42_driver *bridge;
>   struct device *dev;
>  
> @@ -978,7 +977,6 @@ static unsigned int ca91cx42_master_rmw(struct 
> vme_master_resource *image,
>   dev = image->parent->parent;
>  
>   /* Find the PCI address that maps to the desired VME address */
> - i = image->number;
>  
>   /* Locking as we can only do one of these at a time */
>   mutex_lock(>vme_rmw);
> -- 
> 2.17.1
> 


Re: [PATCH] MAINTAINERS: Update E-mail address

2018-07-10 Thread Martyn Welch
On Tue, 2018-07-10 at 16:47 +0200, Peter Senna Tschudin wrote:
> Update my E-mail address on MAINTAINERS file.
> 
> Signed-off-by: Peter Senna Tschudin 

Acked-by: Martyn Welch 

> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a29d10f25e27..3204ea8c2a8f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9133,7 +9133,7 @@ S:  Maintained
>  F:   drivers/usb/mtu3/
>  
>  MEGACHIPS STDP-GE-B850V3-FW LVDS/DP++ BRIDGES
> -M:   Peter Senna Tschudin 
> +M:   Peter Senna Tschudin 
>  M:   Martin Donnelly 
>  M:   Martyn Welch 
>  S:   Maintained


Re: [PATCH] MAINTAINERS: Update E-mail address

2018-07-10 Thread Martyn Welch
On Tue, 2018-07-10 at 16:47 +0200, Peter Senna Tschudin wrote:
> Update my E-mail address on MAINTAINERS file.
> 
> Signed-off-by: Peter Senna Tschudin 

Acked-by: Martyn Welch 

> ---
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index a29d10f25e27..3204ea8c2a8f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -9133,7 +9133,7 @@ S:  Maintained
>  F:   drivers/usb/mtu3/
>  
>  MEGACHIPS STDP-GE-B850V3-FW LVDS/DP++ BRIDGES
> -M:   Peter Senna Tschudin 
> +M:   Peter Senna Tschudin 
>  M:   Martin Donnelly 
>  M:   Martyn Welch 
>  S:   Maintained


[PATCH v2] ahci: imx: Handle increased read failures for IMX53 temperature sensor in low frequency mode.

2017-11-13 Thread Martyn Welch
From: Egor Starkov <egor.star...@ge.com>

Extended testing has shown that the imx ahci driver sometimes requires
more than the 100 attempts currently alotted in the driver to perform a
successful temperature reading when running at minimum (throttled) CPU
frequency.

Debugging suggests that the read cycle can take 160 attempts (which given
that the driver averages 80 readings from the ADC equates to one failure
on each read).

Increase the attempt limit to 200 in order to greatly reduce the
likelihood of the driver failing to perform a temperature reading,
especially at low CPU frequency.

Signed-off-by: Egor Starkov <egor.star...@ge.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---

v2: - Correct spelling issues in cover letter.

 drivers/ata/ahci_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
index 787567e..a58bcc0 100644
--- a/drivers/ata/ahci_imx.c
+++ b/drivers/ata/ahci_imx.c
@@ -230,7 +230,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void 
__iomem * mmio)
 {
u16 adc_out_reg, read_sum;
u32 index, read_attempt;
-   const u32 attempt_limit = 100;
+   const u32 attempt_limit = 200;
 
imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio);
imx_phy_reg_write(rtune_ctl_reg, mmio);
-- 
1.8.3.1



[PATCH v2] ahci: imx: Handle increased read failures for IMX53 temperature sensor in low frequency mode.

2017-11-13 Thread Martyn Welch
From: Egor Starkov 

Extended testing has shown that the imx ahci driver sometimes requires
more than the 100 attempts currently alotted in the driver to perform a
successful temperature reading when running at minimum (throttled) CPU
frequency.

Debugging suggests that the read cycle can take 160 attempts (which given
that the driver averages 80 readings from the ADC equates to one failure
on each read).

Increase the attempt limit to 200 in order to greatly reduce the
likelihood of the driver failing to perform a temperature reading,
especially at low CPU frequency.

Signed-off-by: Egor Starkov 
Signed-off-by: Martyn Welch 
---

v2: - Correct spelling issues in cover letter.

 drivers/ata/ahci_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c
index 787567e..a58bcc0 100644
--- a/drivers/ata/ahci_imx.c
+++ b/drivers/ata/ahci_imx.c
@@ -230,7 +230,7 @@ static int read_adc_sum(void *dev, u16 rtune_ctl_reg, void 
__iomem * mmio)
 {
u16 adc_out_reg, read_sum;
u32 index, read_attempt;
-   const u32 attempt_limit = 100;
+   const u32 attempt_limit = 200;
 
imx_phy_reg_addressing(SATA_PHY_CR_CLOCK_RTUNE_CTL, mmio);
imx_phy_reg_write(rtune_ctl_reg, mmio);
-- 
1.8.3.1



[PATCH] staging: VME: Remove PIO2 driver

2017-10-24 Thread Martyn Welch
The PIO2 device is (as far as I know) no longer manufactured. I no longer
have access to the device and this seems unlikely to change. The only
changes to this driver in a long time have been as a result of API changes
else where. Time to remove it...

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/staging/vme/devices/Kconfig |  13 -
 drivers/staging/vme/devices/Makefile|   3 -
 drivers/staging/vme/devices/vme_pio2.h  | 244 --
 drivers/staging/vme/devices/vme_pio2_cntr.c |  71 
 drivers/staging/vme/devices/vme_pio2_core.c | 493 
 drivers/staging/vme/devices/vme_pio2_gpio.c | 220 -
 6 files changed, 1044 deletions(-)
 delete mode 100644 drivers/staging/vme/devices/vme_pio2.h
 delete mode 100644 drivers/staging/vme/devices/vme_pio2_cntr.c
 delete mode 100644 drivers/staging/vme/devices/vme_pio2_core.c
 delete mode 100644 drivers/staging/vme/devices/vme_pio2_gpio.c

diff --git a/drivers/staging/vme/devices/Kconfig 
b/drivers/staging/vme/devices/Kconfig
index 1d2ff0cc41f1..c548dd8c91e1 100644
--- a/drivers/staging/vme/devices/Kconfig
+++ b/drivers/staging/vme/devices/Kconfig
@@ -10,16 +10,3 @@ config VME_USER
 
  To compile this driver as a module, choose M here. The module will
  be called vme_user. If unsure, say N.
-
-config VME_PIO2
-   tristate "GE PIO2 VME"
-   depends on STAGING && GPIOLIB
-   help
- Say Y here to include support for the GE PIO2. The PIO2 is a 6U VME
- slave card, implementing 32 solid-state relay switched IO lines, in
- 4 groups of 8. Each bank of IO lines is built to function as input,
- output or both depending on the variant of the card.
-
- To compile this driver as a module, choose M here. The module will
- be called vme_pio2. If unsure, say N.
-
diff --git a/drivers/staging/vme/devices/Makefile 
b/drivers/staging/vme/devices/Makefile
index 172512cb5dbf..459742a75283 100644
--- a/drivers/staging/vme/devices/Makefile
+++ b/drivers/staging/vme/devices/Makefile
@@ -3,6 +3,3 @@
 #
 
 obj-$(CONFIG_VME_USER) += vme_user.o
-
-vme_pio2-objs  := vme_pio2_cntr.o vme_pio2_gpio.o vme_pio2_core.o
-obj-$(CONFIG_VME_PIO2) += vme_pio2.o
diff --git a/drivers/staging/vme/devices/vme_pio2.h 
b/drivers/staging/vme/devices/vme_pio2.h
deleted file mode 100644
index ac4a4bad4091..
--- a/drivers/staging/vme/devices/vme_pio2.h
+++ /dev/null
@@ -1,244 +0,0 @@
-#ifndef _VME_PIO2_H_
-#define _VME_PIO2_H_
-
-#define PIO2_CARDS_MAX 32
-
-#define PIO2_VARIANT_LENGTH5
-
-#define PIO2_NUM_CHANNELS  32
-#define PIO2_NUM_IRQS  11
-#define PIO2_NUM_CNTRS 6
-
-#define PIO2_REGS_SIZE 0x40
-
-#define PIO2_REGS_DATA00x0
-#define PIO2_REGS_DATA10x1
-#define PIO2_REGS_DATA20x2
-#define PIO2_REGS_DATA30x3
-
-static const int PIO2_REGS_DATA[4] = { PIO2_REGS_DATA0, PIO2_REGS_DATA1,
-   PIO2_REGS_DATA2, PIO2_REGS_DATA3 };
-
-#define PIO2_REGS_INT_STAT00x8
-#define PIO2_REGS_INT_STAT10x9
-#define PIO2_REGS_INT_STAT20xa
-#define PIO2_REGS_INT_STAT30xb
-
-static const int PIO2_REGS_INT_STAT[4] = { PIO2_REGS_INT_STAT0,
-   PIO2_REGS_INT_STAT1,
-   PIO2_REGS_INT_STAT2,
-   PIO2_REGS_INT_STAT3 };
-
-#define PIO2_REGS_INT_STAT_CNTR0xc
-#define PIO2_REGS_INT_MASK00x10
-#define PIO2_REGS_INT_MASK10x11
-#define PIO2_REGS_INT_MASK20x12
-#define PIO2_REGS_INT_MASK30x13
-#define PIO2_REGS_INT_MASK40x14
-#define PIO2_REGS_INT_MASK50x15
-#define PIO2_REGS_INT_MASK60x16
-#define PIO2_REGS_INT_MASK70x17
-
-static const int PIO2_REGS_INT_MASK[8] = { PIO2_REGS_INT_MASK0,
-   PIO2_REGS_INT_MASK1,
-   PIO2_REGS_INT_MASK2,
-   PIO2_REGS_INT_MASK3,
-   PIO2_REGS_INT_MASK4,
-   PIO2_REGS_INT_MASK5,
-   PIO2_REGS_INT_MASK6,
-   PIO2_REGS_INT_MASK7 };
-
-#define PIO2_REGS_CTRL 0x18
-#define PIO2_REGS_VME_VECTOR   0x19
-#define PIO2_REGS_CNTR00x20
-#define PIO2_REGS_CNTR10x22
-#define PIO2_REGS_CNTR20x24
-#define PIO2_REGS_CTRL_WRD00x26
-#define PIO2_REGS_CNTR30x28
-#define PIO2_REGS_CNTR40x2a
-#define PIO2_REGS_CNTR5 

[PATCH] staging: VME: Remove PIO2 driver

2017-10-24 Thread Martyn Welch
The PIO2 device is (as far as I know) no longer manufactured. I no longer
have access to the device and this seems unlikely to change. The only
changes to this driver in a long time have been as a result of API changes
else where. Time to remove it...

Signed-off-by: Martyn Welch 
---
 drivers/staging/vme/devices/Kconfig |  13 -
 drivers/staging/vme/devices/Makefile|   3 -
 drivers/staging/vme/devices/vme_pio2.h  | 244 --
 drivers/staging/vme/devices/vme_pio2_cntr.c |  71 
 drivers/staging/vme/devices/vme_pio2_core.c | 493 
 drivers/staging/vme/devices/vme_pio2_gpio.c | 220 -
 6 files changed, 1044 deletions(-)
 delete mode 100644 drivers/staging/vme/devices/vme_pio2.h
 delete mode 100644 drivers/staging/vme/devices/vme_pio2_cntr.c
 delete mode 100644 drivers/staging/vme/devices/vme_pio2_core.c
 delete mode 100644 drivers/staging/vme/devices/vme_pio2_gpio.c

diff --git a/drivers/staging/vme/devices/Kconfig 
b/drivers/staging/vme/devices/Kconfig
index 1d2ff0cc41f1..c548dd8c91e1 100644
--- a/drivers/staging/vme/devices/Kconfig
+++ b/drivers/staging/vme/devices/Kconfig
@@ -10,16 +10,3 @@ config VME_USER
 
  To compile this driver as a module, choose M here. The module will
  be called vme_user. If unsure, say N.
-
-config VME_PIO2
-   tristate "GE PIO2 VME"
-   depends on STAGING && GPIOLIB
-   help
- Say Y here to include support for the GE PIO2. The PIO2 is a 6U VME
- slave card, implementing 32 solid-state relay switched IO lines, in
- 4 groups of 8. Each bank of IO lines is built to function as input,
- output or both depending on the variant of the card.
-
- To compile this driver as a module, choose M here. The module will
- be called vme_pio2. If unsure, say N.
-
diff --git a/drivers/staging/vme/devices/Makefile 
b/drivers/staging/vme/devices/Makefile
index 172512cb5dbf..459742a75283 100644
--- a/drivers/staging/vme/devices/Makefile
+++ b/drivers/staging/vme/devices/Makefile
@@ -3,6 +3,3 @@
 #
 
 obj-$(CONFIG_VME_USER) += vme_user.o
-
-vme_pio2-objs  := vme_pio2_cntr.o vme_pio2_gpio.o vme_pio2_core.o
-obj-$(CONFIG_VME_PIO2) += vme_pio2.o
diff --git a/drivers/staging/vme/devices/vme_pio2.h 
b/drivers/staging/vme/devices/vme_pio2.h
deleted file mode 100644
index ac4a4bad4091..
--- a/drivers/staging/vme/devices/vme_pio2.h
+++ /dev/null
@@ -1,244 +0,0 @@
-#ifndef _VME_PIO2_H_
-#define _VME_PIO2_H_
-
-#define PIO2_CARDS_MAX 32
-
-#define PIO2_VARIANT_LENGTH5
-
-#define PIO2_NUM_CHANNELS  32
-#define PIO2_NUM_IRQS  11
-#define PIO2_NUM_CNTRS 6
-
-#define PIO2_REGS_SIZE 0x40
-
-#define PIO2_REGS_DATA00x0
-#define PIO2_REGS_DATA10x1
-#define PIO2_REGS_DATA20x2
-#define PIO2_REGS_DATA30x3
-
-static const int PIO2_REGS_DATA[4] = { PIO2_REGS_DATA0, PIO2_REGS_DATA1,
-   PIO2_REGS_DATA2, PIO2_REGS_DATA3 };
-
-#define PIO2_REGS_INT_STAT00x8
-#define PIO2_REGS_INT_STAT10x9
-#define PIO2_REGS_INT_STAT20xa
-#define PIO2_REGS_INT_STAT30xb
-
-static const int PIO2_REGS_INT_STAT[4] = { PIO2_REGS_INT_STAT0,
-   PIO2_REGS_INT_STAT1,
-   PIO2_REGS_INT_STAT2,
-   PIO2_REGS_INT_STAT3 };
-
-#define PIO2_REGS_INT_STAT_CNTR0xc
-#define PIO2_REGS_INT_MASK00x10
-#define PIO2_REGS_INT_MASK10x11
-#define PIO2_REGS_INT_MASK20x12
-#define PIO2_REGS_INT_MASK30x13
-#define PIO2_REGS_INT_MASK40x14
-#define PIO2_REGS_INT_MASK50x15
-#define PIO2_REGS_INT_MASK60x16
-#define PIO2_REGS_INT_MASK70x17
-
-static const int PIO2_REGS_INT_MASK[8] = { PIO2_REGS_INT_MASK0,
-   PIO2_REGS_INT_MASK1,
-   PIO2_REGS_INT_MASK2,
-   PIO2_REGS_INT_MASK3,
-   PIO2_REGS_INT_MASK4,
-   PIO2_REGS_INT_MASK5,
-   PIO2_REGS_INT_MASK6,
-   PIO2_REGS_INT_MASK7 };
-
-#define PIO2_REGS_CTRL 0x18
-#define PIO2_REGS_VME_VECTOR   0x19
-#define PIO2_REGS_CNTR00x20
-#define PIO2_REGS_CNTR10x22
-#define PIO2_REGS_CNTR20x24
-#define PIO2_REGS_CTRL_WRD00x26
-#define PIO2_REGS_CNTR30x28
-#define PIO2_REGS_CNTR40x2a
-#define PIO2_REGS_CNTR50x2c
-#define PIO2_REGS_CTRL_WRD1 

[PATCH] VME: Return -EBUSY when DMA list in use

2017-10-24 Thread Martyn Welch
From: Martyn Welch <mar...@welchs.me.uk>

The VME subsystem currently returns -EBUSY when trying to free a DMA
resource that is busy, but returns -EINVAL when trying to free a DMA list
that is in use. Switch to returning -EBUSY when trying to free a DMA list
that is in use for consistency and correctness.

Signed-off-by: Martyn Welch <mar...@welchs.me.uk>
---
 drivers/vme/vme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index d0ce50d56019..81246221a13b 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1194,7 +1194,7 @@ int vme_dma_list_free(struct vme_dma_list *list)
 
if (!mutex_trylock(>mtx)) {
printk(KERN_ERR "Link List in use\n");
-   return -EINVAL;
+   return -EBUSY;
}
 
/*
-- 
2.11.0



[PATCH] VME: Return -EBUSY when DMA list in use

2017-10-24 Thread Martyn Welch
From: Martyn Welch 

The VME subsystem currently returns -EBUSY when trying to free a DMA
resource that is busy, but returns -EINVAL when trying to free a DMA list
that is in use. Switch to returning -EBUSY when trying to free a DMA list
that is in use for consistency and correctness.

Signed-off-by: Martyn Welch 
---
 drivers/vme/vme.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/vme/vme.c b/drivers/vme/vme.c
index d0ce50d56019..81246221a13b 100644
--- a/drivers/vme/vme.c
+++ b/drivers/vme/vme.c
@@ -1194,7 +1194,7 @@ int vme_dma_list_free(struct vme_dma_list *list)
 
if (!mutex_trylock(>mtx)) {
printk(KERN_ERR "Link List in use\n");
-   return -EINVAL;
+   return -EBUSY;
}
 
/*
-- 
2.11.0



[PATCH] MAINTAINERS: Update VME subsystem tree.

2017-10-23 Thread Martyn Welch
VME Subsystem lists driver-core repository as canonical tree. Greg has
stated that char-misc should be used for submissions instead[1].

[1] https://lkml.org/lkml/2017/9/1/486

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index a74227ad082e..77c331919ad6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14380,7 +14380,7 @@ M:  Manohar Vanga <manohar.va...@gmail.com>
 M: Greg Kroah-Hartman <gre...@linuxfoundation.org>
 L: de...@driverdev.osuosl.org
 S: Maintained
-T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F: Documentation/driver-api/vme.rst
 F: drivers/staging/vme/
 F: drivers/vme/
-- 
2.11.0



[PATCH] MAINTAINERS: Update VME subsystem tree.

2017-10-23 Thread Martyn Welch
VME Subsystem lists driver-core repository as canonical tree. Greg has
stated that char-misc should be used for submissions instead[1].

[1] https://lkml.org/lkml/2017/9/1/486

Signed-off-by: Martyn Welch 
---
 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index a74227ad082e..77c331919ad6 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -14380,7 +14380,7 @@ M:  Manohar Vanga 
 M: Greg Kroah-Hartman 
 L: de...@driverdev.osuosl.org
 S: Maintained
-T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core.git
+T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
 F: Documentation/driver-api/vme.rst
 F: drivers/staging/vme/
 F: drivers/vme/
-- 
2.11.0



Re: [PATCH] hwmon: da9052 Increase sample rate when using TSI

2017-10-20 Thread Martyn Welch
On Fri, 2017-10-20 at 14:30 +, Steve Twiss wrote:
> Hi Martyn,
> 
> On 19 October 2017 16:52, Martyn Welch wrote:
> 
> > To: Support Opensource; Jean Delvare; Guenter Roeck
> > Subject: [PATCH] hwmon: da9052 Increase sample rate when using TSI
> > 
> > The TSI channel, which is usually used for touchscreen support, but can
> > be used as 4 general purpose ADCs. When used as a touchscreen interface
> > the touchscreen driver switches the device into 1ms sampling mode (rather
> > than the default 10ms economy mode) as recommended by the
> > manufacturer.
> > When using the TSI channels as a general purpose ADC we are currently not
> > doing this and testing suggests that this can result in ADC timeouts:
> > 
> > [ 5827.198289] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5827.728293] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5993.808335] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5994.328441] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5994.848291] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > 
> > Switching to the 1ms timing resolves this issue.
> > 
> > Cc: sta...@vger.kernel.org
> > Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
> > ---
> >  drivers/hwmon/da9052-hwmon.c | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
> > index 97a62f5..a973eb6 100644
> > --- a/drivers/hwmon/da9052-hwmon.c
> > +++ b/drivers/hwmon/da9052-hwmon.c
> > @@ -477,6 +477,11 @@ static int da9052_hwmon_probe(struct platform_device 
> > *pdev)
> > /* disable touchscreen features */
> > da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00);
> > 
> > +   /* Sample every 1ms */
> > +   da9052_reg_update(hwmon->da9052, DA9052_ADC_CONT_REG,
> > + DA9052_ADCCONT_ADCMODE,
> > + DA9052_ADCCONT_ADCMODE);
> > +
> 
> Acked-by: Steve Twiss <stwiss.opensou...@diasemi.com>
> 
> According to the DA9053 Datasheet, Revision 2.1, 31-Aug-2016, Section 18.3, 
> page 143.
> 
>   [The ADC] can be used either in high speed mode with measurements
>   sequences repeated every 1ms or in economy mode with sequences
>   performed every 10ms.
> 
> Also, DA9053 Datasheet, Revision 2.1, 31-Aug-2016, Section 18.17,
> Table 56: GP-ADC Control Registers, Register Address R82 ADC_CONT, page 150,
> 
>   Bit 6, ADC_MODE
>   0: Measurement sequence interval 10 ms (economy mode)
>   1: Measurement sequence interval 1 ms (recommended for TSI mode)
> 
> I can't find any reason why a global change to the sampling rate cannot be
> applied during the ADC measurements in this case. After all, as you said, this
> is gated by the previous change by Sebastian Reichel which enforces a
> protection of ADC measurements when using the TSI as a general ADC (see commit
> ebf555111bc11a5da9144e4af524260731a8b968).
> 

Hi Steve,

We were running with the above mentioned patch/commit applied, but we
were getting the above timeouts during out testing.

The only way we have managed to make this reliable is to run in 1ms
mode. We suspected that there may be something in the "recommended for
TSI mode" regarding reliability.

Martyn

> Regards,
> Steve
> 




Re: [PATCH] hwmon: da9052 Increase sample rate when using TSI

2017-10-20 Thread Martyn Welch
On Fri, 2017-10-20 at 14:30 +, Steve Twiss wrote:
> Hi Martyn,
> 
> On 19 October 2017 16:52, Martyn Welch wrote:
> 
> > To: Support Opensource; Jean Delvare; Guenter Roeck
> > Subject: [PATCH] hwmon: da9052 Increase sample rate when using TSI
> > 
> > The TSI channel, which is usually used for touchscreen support, but can
> > be used as 4 general purpose ADCs. When used as a touchscreen interface
> > the touchscreen driver switches the device into 1ms sampling mode (rather
> > than the default 10ms economy mode) as recommended by the
> > manufacturer.
> > When using the TSI channels as a general purpose ADC we are currently not
> > doing this and testing suggests that this can result in ADC timeouts:
> > 
> > [ 5827.198289] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5827.728293] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5993.808335] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5994.328441] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > [ 5994.848291] da9052 spi2.0: timeout waiting for ADC conversion interrupt
> > 
> > Switching to the 1ms timing resolves this issue.
> > 
> > Cc: sta...@vger.kernel.org
> > Signed-off-by: Martyn Welch 
> > ---
> >  drivers/hwmon/da9052-hwmon.c | 5 +
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
> > index 97a62f5..a973eb6 100644
> > --- a/drivers/hwmon/da9052-hwmon.c
> > +++ b/drivers/hwmon/da9052-hwmon.c
> > @@ -477,6 +477,11 @@ static int da9052_hwmon_probe(struct platform_device 
> > *pdev)
> > /* disable touchscreen features */
> > da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00);
> > 
> > +   /* Sample every 1ms */
> > +   da9052_reg_update(hwmon->da9052, DA9052_ADC_CONT_REG,
> > + DA9052_ADCCONT_ADCMODE,
> > + DA9052_ADCCONT_ADCMODE);
> > +
> 
> Acked-by: Steve Twiss 
> 
> According to the DA9053 Datasheet, Revision 2.1, 31-Aug-2016, Section 18.3, 
> page 143.
> 
>   [The ADC] can be used either in high speed mode with measurements
>   sequences repeated every 1ms or in economy mode with sequences
>   performed every 10ms.
> 
> Also, DA9053 Datasheet, Revision 2.1, 31-Aug-2016, Section 18.17,
> Table 56: GP-ADC Control Registers, Register Address R82 ADC_CONT, page 150,
> 
>   Bit 6, ADC_MODE
>   0: Measurement sequence interval 10 ms (economy mode)
>   1: Measurement sequence interval 1 ms (recommended for TSI mode)
> 
> I can't find any reason why a global change to the sampling rate cannot be
> applied during the ADC measurements in this case. After all, as you said, this
> is gated by the previous change by Sebastian Reichel which enforces a
> protection of ADC measurements when using the TSI as a general ADC (see commit
> ebf555111bc11a5da9144e4af524260731a8b968).
> 

Hi Steve,

We were running with the above mentioned patch/commit applied, but we
were getting the above timeouts during out testing.

The only way we have managed to make this reliable is to run in 1ms
mode. We suspected that there may be something in the "recommended for
TSI mode" regarding reliability.

Martyn

> Regards,
> Steve
> 




[PATCH] hwmon: da9052 Increase sample rate when using TSI

2017-10-19 Thread Martyn Welch
The TSI channel, which is usually used for touchscreen support, but can
be used as 4 general purpose ADCs. When used as a touchscreen interface
the touchscreen driver switches the device into 1ms sampling mode (rather
than the default 10ms economy mode) as recommended by the manufacturer.
When using the TSI channels as a general purpose ADC we are currently not
doing this and testing suggests that this can result in ADC timeouts:

[ 5827.198289] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5827.728293] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5993.808335] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5994.328441] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5994.848291] da9052 spi2.0: timeout waiting for ADC conversion interrupt

Switching to the 1ms timing resolves this issue.

Cc: sta...@vger.kernel.org
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/hwmon/da9052-hwmon.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
index 97a62f5..a973eb6 100644
--- a/drivers/hwmon/da9052-hwmon.c
+++ b/drivers/hwmon/da9052-hwmon.c
@@ -477,6 +477,11 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
/* disable touchscreen features */
da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00);
 
+   /* Sample every 1ms */
+   da9052_reg_update(hwmon->da9052, DA9052_ADC_CONT_REG,
+ DA9052_ADCCONT_ADCMODE,
+ DA9052_ADCCONT_ADCMODE);
+
err = da9052_request_irq(hwmon->da9052, DA9052_IRQ_TSIREADY,
 "tsiready-irq", da9052_tsi_datardy_irq,
 hwmon);
-- 
1.8.3.1



[PATCH] hwmon: da9052 Increase sample rate when using TSI

2017-10-19 Thread Martyn Welch
The TSI channel, which is usually used for touchscreen support, but can
be used as 4 general purpose ADCs. When used as a touchscreen interface
the touchscreen driver switches the device into 1ms sampling mode (rather
than the default 10ms economy mode) as recommended by the manufacturer.
When using the TSI channels as a general purpose ADC we are currently not
doing this and testing suggests that this can result in ADC timeouts:

[ 5827.198289] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5827.728293] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5993.808335] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5994.328441] da9052 spi2.0: timeout waiting for ADC conversion interrupt
[ 5994.848291] da9052 spi2.0: timeout waiting for ADC conversion interrupt

Switching to the 1ms timing resolves this issue.

Cc: sta...@vger.kernel.org
Signed-off-by: Martyn Welch 
---
 drivers/hwmon/da9052-hwmon.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c
index 97a62f5..a973eb6 100644
--- a/drivers/hwmon/da9052-hwmon.c
+++ b/drivers/hwmon/da9052-hwmon.c
@@ -477,6 +477,11 @@ static int da9052_hwmon_probe(struct platform_device *pdev)
/* disable touchscreen features */
da9052_reg_write(hwmon->da9052, DA9052_TSI_CONT_A_REG, 0x00);
 
+   /* Sample every 1ms */
+   da9052_reg_update(hwmon->da9052, DA9052_ADC_CONT_REG,
+ DA9052_ADCCONT_ADCMODE,
+ DA9052_ADCCONT_ADCMODE);
+
err = da9052_request_irq(hwmon->da9052, DA9052_IRQ_TSIREADY,
 "tsiready-irq", da9052_tsi_datardy_irq,
 hwmon);
-- 
1.8.3.1



Re: [GIT PULL] VME Subsystem patches for 4.14-rc4

2017-10-14 Thread Martyn Welch
On Sat, 2017-10-14 at 14:08 +0200, Greg Kroah-Hartman wrote:
> On Fri, Oct 13, 2017 at 10:09:19PM +0100, Martyn Welch wrote:
> > The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:
> > 
> >   Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)
> > 
> > are available in the git repository at:
> > 
> >   https://gitlab.collabora.com/martyn/linux.git tags/vme-next-4.14-rc4
> > 
> > for you to fetch changes up to a75dc630086a6b83d780a7b27d03c4c0abdf0807:
> > 
> >   vme: tsi148: Adjust 14 checks for null pointers (2017-10-13 21:32:04 
> > +0100)
> > 
> > 
> > VME Subsystem changes for master v4.14-rc4:
> > 
> >  - Corrections across the VME subsystem to better align with the preferred
> >kernel coding style.
> > 
> > 
> > Markus Elfring (14):
> >   vme: Delete 11 error messages for a failed memory allocation
> >   vme: Improve 11 size determinations
> >   vme: Move an assignment in vme_new_dma_list()
> >   vme: Adjust 48 checks for null pointers
> >   vme: Return directly in two functions
> >   vme: fake: Delete an error message for a failed memory allocation in 
> > fake_init()
> >   vme: fake: Improve five size determinations in fake_init()
> >   vme: fake: Adjust 11 checks for null pointers
> >   vme: ca91cx42: Delete eight error messages for a failed memory 
> > allocation
> >   vme: ca91cx42: Improve 12 size determinations
> >   vme: ca91cx42: Adjust 14 checks for null pointers
> >   vme: tsi148: Delete nine error messages for a failed memory allocation
> >   vme: tsi148: Improve 17 size determinations
> >   vme: tsi148: Adjust 14 checks for null pointers
> > 
> >  drivers/vme/bridges/vme_ca91cx42.c |  73 +-
> >  drivers/vme/bridges/vme_fake.c |  35 +++
> >  drivers/vme/bridges/vme_tsi148.c   |  83 ++--
> >  drivers/vme/vme.c  | 194 
> > -
> >  4 files changed, 157 insertions(+), 228 deletions(-)
> 
> None of these are bugfixes for 4.14-final, right?  They should all be
> delayed until 4.15-rc1?
> 

Yeah, 4.15-rc1.

Thanks

Martyn

> thanks,
> 
> greg k-h
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




Re: [GIT PULL] VME Subsystem patches for 4.14-rc4

2017-10-14 Thread Martyn Welch
On Sat, 2017-10-14 at 14:08 +0200, Greg Kroah-Hartman wrote:
> On Fri, Oct 13, 2017 at 10:09:19PM +0100, Martyn Welch wrote:
> > The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:
> > 
> >   Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)
> > 
> > are available in the git repository at:
> > 
> >   https://gitlab.collabora.com/martyn/linux.git tags/vme-next-4.14-rc4
> > 
> > for you to fetch changes up to a75dc630086a6b83d780a7b27d03c4c0abdf0807:
> > 
> >   vme: tsi148: Adjust 14 checks for null pointers (2017-10-13 21:32:04 
> > +0100)
> > 
> > 
> > VME Subsystem changes for master v4.14-rc4:
> > 
> >  - Corrections across the VME subsystem to better align with the preferred
> >kernel coding style.
> > 
> > 
> > Markus Elfring (14):
> >   vme: Delete 11 error messages for a failed memory allocation
> >   vme: Improve 11 size determinations
> >   vme: Move an assignment in vme_new_dma_list()
> >   vme: Adjust 48 checks for null pointers
> >   vme: Return directly in two functions
> >   vme: fake: Delete an error message for a failed memory allocation in 
> > fake_init()
> >   vme: fake: Improve five size determinations in fake_init()
> >   vme: fake: Adjust 11 checks for null pointers
> >   vme: ca91cx42: Delete eight error messages for a failed memory 
> > allocation
> >   vme: ca91cx42: Improve 12 size determinations
> >   vme: ca91cx42: Adjust 14 checks for null pointers
> >   vme: tsi148: Delete nine error messages for a failed memory allocation
> >   vme: tsi148: Improve 17 size determinations
> >   vme: tsi148: Adjust 14 checks for null pointers
> > 
> >  drivers/vme/bridges/vme_ca91cx42.c |  73 +-
> >  drivers/vme/bridges/vme_fake.c |  35 +++
> >  drivers/vme/bridges/vme_tsi148.c   |  83 ++--
> >  drivers/vme/vme.c  | 194 
> > -
> >  4 files changed, 157 insertions(+), 228 deletions(-)
> 
> None of these are bugfixes for 4.14-final, right?  They should all be
> delayed until 4.15-rc1?
> 

Yeah, 4.15-rc1.

Thanks

Martyn

> thanks,
> 
> greg k-h
> ___
> devel mailing list
> de...@linuxdriverproject.org
> http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[GIT PULL] VME Subsystem patches for 4.14-rc4

2017-10-13 Thread Martyn Welch
The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:

  Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)

are available in the git repository at:

  https://gitlab.collabora.com/martyn/linux.git tags/vme-next-4.14-rc4

for you to fetch changes up to a75dc630086a6b83d780a7b27d03c4c0abdf0807:

  vme: tsi148: Adjust 14 checks for null pointers (2017-10-13 21:32:04 +0100)


VME Subsystem changes for master v4.14-rc4:

 - Corrections across the VME subsystem to better align with the preferred
   kernel coding style.


Markus Elfring (14):
  vme: Delete 11 error messages for a failed memory allocation
  vme: Improve 11 size determinations
  vme: Move an assignment in vme_new_dma_list()
  vme: Adjust 48 checks for null pointers
  vme: Return directly in two functions
  vme: fake: Delete an error message for a failed memory allocation in 
fake_init()
  vme: fake: Improve five size determinations in fake_init()
  vme: fake: Adjust 11 checks for null pointers
  vme: ca91cx42: Delete eight error messages for a failed memory allocation
  vme: ca91cx42: Improve 12 size determinations
  vme: ca91cx42: Adjust 14 checks for null pointers
  vme: tsi148: Delete nine error messages for a failed memory allocation
  vme: tsi148: Improve 17 size determinations
  vme: tsi148: Adjust 14 checks for null pointers

 drivers/vme/bridges/vme_ca91cx42.c |  73 +-
 drivers/vme/bridges/vme_fake.c |  35 +++
 drivers/vme/bridges/vme_tsi148.c   |  83 ++--
 drivers/vme/vme.c  | 194 -
 4 files changed, 157 insertions(+), 228 deletions(-)


[GIT PULL] VME Subsystem patches for 4.14-rc4

2017-10-13 Thread Martyn Welch
The following changes since commit 8a5776a5f49812d29fe4b2d0a2d71675c3facf3f:

  Linux 4.14-rc4 (2017-10-08 20:53:29 -0700)

are available in the git repository at:

  https://gitlab.collabora.com/martyn/linux.git tags/vme-next-4.14-rc4

for you to fetch changes up to a75dc630086a6b83d780a7b27d03c4c0abdf0807:

  vme: tsi148: Adjust 14 checks for null pointers (2017-10-13 21:32:04 +0100)


VME Subsystem changes for master v4.14-rc4:

 - Corrections across the VME subsystem to better align with the preferred
   kernel coding style.


Markus Elfring (14):
  vme: Delete 11 error messages for a failed memory allocation
  vme: Improve 11 size determinations
  vme: Move an assignment in vme_new_dma_list()
  vme: Adjust 48 checks for null pointers
  vme: Return directly in two functions
  vme: fake: Delete an error message for a failed memory allocation in 
fake_init()
  vme: fake: Improve five size determinations in fake_init()
  vme: fake: Adjust 11 checks for null pointers
  vme: ca91cx42: Delete eight error messages for a failed memory allocation
  vme: ca91cx42: Improve 12 size determinations
  vme: ca91cx42: Adjust 14 checks for null pointers
  vme: tsi148: Delete nine error messages for a failed memory allocation
  vme: tsi148: Improve 17 size determinations
  vme: tsi148: Adjust 14 checks for null pointers

 drivers/vme/bridges/vme_ca91cx42.c |  73 +-
 drivers/vme/bridges/vme_fake.c |  35 +++
 drivers/vme/bridges/vme_tsi148.c   |  83 ++--
 drivers/vme/vme.c  | 194 -
 4 files changed, 157 insertions(+), 228 deletions(-)


[PATCH v2] serial: imx: Correct comment imx_flush_buffer()

2017-10-04 Thread Martyn Welch
The comment in imx_flush_buffer() states that the state of 4 registers
are to be saved/restored, then only saves and restores 3 registers. The
missing register (UBRC) is read only and thus can't be restored.

Update the comment to reflect reality.

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---

v2: Remove trailing whitespace.

 drivers/tty/serial/imx.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index b697c1e..76818a2 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1417,10 +1417,14 @@ static void imx_flush_buffer(struct uart_port *port)
 
/*
 * According to the Reference Manual description of the UART SRST bit:
+*
 * "Reset the transmit and receive state machines,
 * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
-* and UTS[6-3]". As we don't need to restore the old values from
-* USR1, USR2, URXD, UTXD, only save/restore the other four registers
+* and UTS[6-3]".
+*
+* We don't need to restore the old values from USR1, USR2, URXD and
+* UTXD. UBRC is read only, so only save/restore the other three
+* registers.
 */
ubir = readl(sport->port.membase + UBIR);
ubmr = readl(sport->port.membase + UBMR);
-- 
1.8.3.1



[PATCH v2] serial: imx: Correct comment imx_flush_buffer()

2017-10-04 Thread Martyn Welch
The comment in imx_flush_buffer() states that the state of 4 registers
are to be saved/restored, then only saves and restores 3 registers. The
missing register (UBRC) is read only and thus can't be restored.

Update the comment to reflect reality.

Signed-off-by: Martyn Welch 
---

v2: Remove trailing whitespace.

 drivers/tty/serial/imx.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index b697c1e..76818a2 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1417,10 +1417,14 @@ static void imx_flush_buffer(struct uart_port *port)
 
/*
 * According to the Reference Manual description of the UART SRST bit:
+*
 * "Reset the transmit and receive state machines,
 * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
-* and UTS[6-3]". As we don't need to restore the old values from
-* USR1, USR2, URXD, UTXD, only save/restore the other four registers
+* and UTS[6-3]".
+*
+* We don't need to restore the old values from USR1, USR2, URXD and
+* UTXD. UBRC is read only, so only save/restore the other three
+* registers.
 */
ubir = readl(sport->port.membase + UBIR);
ubmr = readl(sport->port.membase + UBMR);
-- 
1.8.3.1



Re: [PATCH] serial: imx: Correct comment imx_flush_buffer()

2017-10-04 Thread Martyn Welch
On Tue, 2017-10-03 at 20:27 +0200, Greg Kroah-Hartman wrote:
> On Fri, Sep 29, 2017 at 10:22:19AM +0100, Martyn Welch wrote:
> > The comment in imx_flush_buffer() states that the state of 4 registers
> > are to be saved/restored, then only saves and restores 3 registers. The
> > missing register (UBRC) is read only and thus can't be restored.
> > 
> > Update the comment to reflect reality.
> 
> Always run checkpatch.pl so you don't get grumpy maintainers telling you
> to run checkpatch.pl :(

Sorry Greg, must have got out of sync on that one :-(

Martyn



Re: [PATCH] serial: imx: Correct comment imx_flush_buffer()

2017-10-04 Thread Martyn Welch
On Tue, 2017-10-03 at 20:27 +0200, Greg Kroah-Hartman wrote:
> On Fri, Sep 29, 2017 at 10:22:19AM +0100, Martyn Welch wrote:
> > The comment in imx_flush_buffer() states that the state of 4 registers
> > are to be saved/restored, then only saves and restores 3 registers. The
> > missing register (UBRC) is read only and thus can't be restored.
> > 
> > Update the comment to reflect reality.
> 
> Always run checkpatch.pl so you don't get grumpy maintainers telling you
> to run checkpatch.pl :(

Sorry Greg, must have got out of sync on that one :-(

Martyn



[PATCH] serial: imx: Correct comment imx_flush_buffer()

2017-09-29 Thread Martyn Welch
The comment in imx_flush_buffer() states that the state of 4 registers
are to be saved/restored, then only saves and restores 3 registers. The
missing register (UBRC) is read only and thus can't be restored.

Update the comment to reflect reality.

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 474b5bc..63f544e 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1415,10 +1415,14 @@ static void imx_flush_buffer(struct uart_port *port)
 
/*
 * According to the Reference Manual description of the UART SRST bit:
+* 
 * "Reset the transmit and receive state machines,
 * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
-* and UTS[6-3]". As we don't need to restore the old values from
-* USR1, USR2, URXD, UTXD, only save/restore the other four registers
+* and UTS[6-3]".
+* 
+* We don't need to restore the old values from USR1, USR2, URXD and
+* UTXD. UBRC is read only, so only save/restore the other three 
+* registers.
 */
ubir = readl(sport->port.membase + UBIR);
ubmr = readl(sport->port.membase + UBMR);
-- 
1.8.3.1



[PATCH] serial: imx: Correct comment imx_flush_buffer()

2017-09-29 Thread Martyn Welch
The comment in imx_flush_buffer() states that the state of 4 registers
are to be saved/restored, then only saves and restores 3 registers. The
missing register (UBRC) is read only and thus can't be restored.

Update the comment to reflect reality.

Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 474b5bc..63f544e 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1415,10 +1415,14 @@ static void imx_flush_buffer(struct uart_port *port)
 
/*
 * According to the Reference Manual description of the UART SRST bit:
+* 
 * "Reset the transmit and receive state machines,
 * all FIFOs and register USR1, USR2, UBIR, UBMR, UBRC, URXD, UTXD
-* and UTS[6-3]". As we don't need to restore the old values from
-* USR1, USR2, URXD, UTXD, only save/restore the other four registers
+* and UTS[6-3]".
+* 
+* We don't need to restore the old values from USR1, USR2, URXD and
+* UTXD. UBRC is read only, so only save/restore the other three 
+* registers.
 */
ubir = readl(sport->port.membase + UBIR);
ubmr = readl(sport->port.membase + UBMR);
-- 
1.8.3.1



[PATCH] serial: imx: Switch setting dma_is_txing from "false" to "0"

2017-09-28 Thread Martyn Welch
The variable "dma_is_txing" is an unsigned int, set as either "0" or "1"
in all but one location, where it is instead set to "false". For
consistency, set dma_is_txing to "0" in this location too.

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 9da109a..474b5bc 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1410,7 +1410,7 @@ static void imx_flush_buffer(struct uart_port *port)
temp = readl(sport->port.membase + UCR1);
temp &= ~UCR1_TDMAEN;
writel(temp, sport->port.membase + UCR1);
-   sport->dma_is_txing = false;
+   sport->dma_is_txing = 0;
}
 
/*
-- 
1.8.3.1



[PATCH] serial: imx: Switch setting dma_is_txing from "false" to "0"

2017-09-28 Thread Martyn Welch
The variable "dma_is_txing" is an unsigned int, set as either "0" or "1"
in all but one location, where it is instead set to "false". For
consistency, set dma_is_txing to "0" in this location too.

Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 9da109a..474b5bc 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1410,7 +1410,7 @@ static void imx_flush_buffer(struct uart_port *port)
temp = readl(sport->port.membase + UCR1);
temp &= ~UCR1_TDMAEN;
writel(temp, sport->port.membase + UCR1);
-   sport->dma_is_txing = false;
+   sport->dma_is_txing = 0;
}
 
/*
-- 
1.8.3.1



[PATCH v2] Use RX_BUF_SIZE to set size of RX buffer

2017-09-28 Thread Martyn Welch
The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
the length of the buffer when initialising the scatter gather list.

In order to ensure that this stays consistent, use RX_BUF_SIZE in both
locations.

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
Acked-by: Uwe Kleine-König <u.kleine-kön...@pengtronix.de>
---

v2: Add missing SoB and Uwe's Acked-by.

 drivers/tty/serial/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1691ed2..9da109a 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1164,7 +1164,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
goto err;
}
 
-   sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+   sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!sport->rx_buf) {
ret = -ENOMEM;
goto err;
-- 
1.8.3.1



[PATCH v2] Use RX_BUF_SIZE to set size of RX buffer

2017-09-28 Thread Martyn Welch
The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
the length of the buffer when initialising the scatter gather list.

In order to ensure that this stays consistent, use RX_BUF_SIZE in both
locations.

Signed-off-by: Martyn Welch 
Acked-by: Uwe Kleine-König 
---

v2: Add missing SoB and Uwe's Acked-by.

 drivers/tty/serial/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 1691ed2..9da109a 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1164,7 +1164,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
goto err;
}
 
-   sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+   sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!sport->rx_buf) {
ret = -ENOMEM;
goto err;
-- 
1.8.3.1



Re: [PATCH] Use RX_BUF_SIZE to set size of RX buffer

2017-09-28 Thread Martyn Welch
On Thu, Sep 28, 2017 at 12:00:19PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 28, 2017 at 10:52:15AM +0100, Martyn Welch wrote:
> > The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
> > uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
> > the length of the buffer when initialising the scatter gather list.
> > 
> > In order to ensure that this stays consistent, use RX_BUF_SIZE in both
> > locations.
> 
> Missing SoB Line

Doh! v2 on way...

> 
> > ---
> >  drivers/tty/serial/imx.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index fe368a4..bc2f2a2f 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
> > goto err;
> > }
> >  
> > -   sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
> > +   sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
> > if (!sport->rx_buf) {
> > ret = -ENOMEM;
> > goto err;
> Acked-by: Uwe Kleine-König <u.kleine-kön...@pengtronix.de>
> 
> 
> -- 
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | http://www.pengutronix.de/  |


Re: [PATCH] Use RX_BUF_SIZE to set size of RX buffer

2017-09-28 Thread Martyn Welch
On Thu, Sep 28, 2017 at 12:00:19PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 28, 2017 at 10:52:15AM +0100, Martyn Welch wrote:
> > The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
> > uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
> > the length of the buffer when initialising the scatter gather list.
> > 
> > In order to ensure that this stays consistent, use RX_BUF_SIZE in both
> > locations.
> 
> Missing SoB Line

Doh! v2 on way...

> 
> > ---
> >  drivers/tty/serial/imx.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index fe368a4..bc2f2a2f 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
> > goto err;
> > }
> >  
> > -   sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
> > +   sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
> > if (!sport->rx_buf) {
> > ret = -ENOMEM;
> > goto err;
> Acked-by: Uwe Kleine-König 
> 
> 
> -- 
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | http://www.pengutronix.de/  |


[PATCH] serial: imx: only set dma_is_rxing when DMA starts

2017-09-28 Thread Martyn Welch
From: Romain Perier <romain.per...@collabora.com>

The variable dma_is_rxing is currently set to 1 in imx_disable_rx_int().
This is problematic as:

- whilst imx_disable_rx_int() is currently always called before
  start_rx_dma() this dependency isn't obvious.
- start_rx_dma() does error checking and might exit without
  enabling DMA. Currently this will result in dma_is_rxing suggesting
  that DMA is being used for recieving.

To avoid these issues, move the setting of dma_is_rxing to
start_rx_dma() when appropriate.

Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
Reviewed-by: Uwe Kleine-König <u.kleine-koe...@pengutronix.de>
---

This patch has been split out of series: "[PATCH v3 0/6] serial: imx:
various improvements" as this is a stand alone fix and some of the
patches in the series are problematic.

 drivers/tty/serial/imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..1691ed2 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -714,8 +714,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
 {
unsigned long temp;
 
-   sport->dma_is_rxing = 1;
-
/* disable the receiver ready and aging timer interrupts */
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RRDYEN);
@@ -1074,6 +1072,7 @@ static int start_rx_dma(struct imx_port *sport)
desc->callback_param = sport;
 
dev_dbg(dev, "RX: prepare for the DMA.\n");
+   sport->dma_is_rxing = 1;
sport->rx_cookie = dmaengine_submit(desc);
dma_async_issue_pending(chan);
return 0;
-- 
1.8.3.1



[PATCH] serial: imx: only set dma_is_rxing when DMA starts

2017-09-28 Thread Martyn Welch
From: Romain Perier 

The variable dma_is_rxing is currently set to 1 in imx_disable_rx_int().
This is problematic as:

- whilst imx_disable_rx_int() is currently always called before
  start_rx_dma() this dependency isn't obvious.
- start_rx_dma() does error checking and might exit without
  enabling DMA. Currently this will result in dma_is_rxing suggesting
  that DMA is being used for recieving.

To avoid these issues, move the setting of dma_is_rxing to
start_rx_dma() when appropriate.

Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
Reviewed-by: Uwe Kleine-König 
---

This patch has been split out of series: "[PATCH v3 0/6] serial: imx:
various improvements" as this is a stand alone fix and some of the
patches in the series are problematic.

 drivers/tty/serial/imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..1691ed2 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -714,8 +714,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
 {
unsigned long temp;
 
-   sport->dma_is_rxing = 1;
-
/* disable the receiver ready and aging timer interrupts */
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RRDYEN);
@@ -1074,6 +1072,7 @@ static int start_rx_dma(struct imx_port *sport)
desc->callback_param = sport;
 
dev_dbg(dev, "RX: prepare for the DMA.\n");
+   sport->dma_is_rxing = 1;
sport->rx_cookie = dmaengine_submit(desc);
dma_async_issue_pending(chan);
return 0;
-- 
1.8.3.1



[PATCH] Use RX_BUF_SIZE to set size of RX buffer

2017-09-28 Thread Martyn Welch
The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
the length of the buffer when initialising the scatter gather list.

In order to ensure that this stays consistent, use RX_BUF_SIZE in both
locations.
---
 drivers/tty/serial/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..bc2f2a2f 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
goto err;
}
 
-   sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+   sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!sport->rx_buf) {
ret = -ENOMEM;
goto err;
-- 
1.8.3.1



[PATCH] Use RX_BUF_SIZE to set size of RX buffer

2017-09-28 Thread Martyn Welch
The imx serial driver uses PAGE_SIZE when allocating rx_buf, but then
uses RX_BUF_SIZE (which is currently defined as PAGE_SIZE) to describe
the length of the buffer when initialising the scatter gather list.

In order to ensure that this stays consistent, use RX_BUF_SIZE in both
locations.
---
 drivers/tty/serial/imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..bc2f2a2f 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1165,7 +1165,7 @@ static int imx_uart_dma_init(struct imx_port *sport)
goto err;
}
 
-   sport->rx_buf = kzalloc(PAGE_SIZE, GFP_KERNEL);
+   sport->rx_buf = kzalloc(RX_BUF_SIZE, GFP_KERNEL);
if (!sport->rx_buf) {
ret = -ENOMEM;
goto err;
-- 
1.8.3.1



Re: [PATCH v3 1/6] serial: imx: remove CTSC and CTS handling from imx_disable_dma

2017-09-21 Thread Martyn Welch
On Thu, Sep 21, 2017 at 08:20:17PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 21, 2017 at 05:18:12PM +0100, Martyn Welch wrote:
> > From: Nandor Han <nandor@ge.com>
> > 
> > The CTSC and CTS bits affect operation of the CTS/RTS hardware flow
> > control signal (depending on whether the device is in DCE or DTE mode) and
> > are not related to DMA. When in RS-232 mode, the driver is using the
> > automatic CTSC control based on a rxFIFO fill level unless the state of
> > the CTS signal is explictly set via an ioctl call.
> > 
> > Previous improvements to the imx serial driver have resulted on
> > imx_disable_dma() only being called on shutdown, by which point the
> > serial core has already correctly deasserted CTS.
> > 
> > Testing shows that without this handling in imx_disable_dma() the CTS
> > signal state is set correctly when the device is open and TIOCM_RTS is
> > set/cleared via the TIOCMGET ioctl. The CTS signal is also correctly
> > deasserted when the device file is closed.
> 
> With that block kept CTS set once more to inactive. So the block doesn't
> hurt and is "only" superflous, right?
> 

That's my understanding, yes.

> > When in RS-485 mode, the driver uses the CTS signal very differently and
> > appears to control it via calls to imx_port_rts_active() and
> > imx_port_rts_inactive().
> > 
> > This configuration of the CTSC and CTS bits are therefore not needed.
> > 
> > Signed-off-by: Nandor Han <nandor@ge.com>
> > Signed-off-by: Romain Perier <romain.per...@collabora.com>
> > Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
> > ---
> >  drivers/tty/serial/imx.c | 5 -
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index fe368a4..d90dae3 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1225,11 +1225,6 @@ static void imx_disable_dma(struct imx_port *sport)
> > temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN);
> > writel(temp, sport->port.membase + UCR1);
> >  
> > -   /* clear UCR2 */
> > -   temp = readl(sport->port.membase + UCR2);
> > -   temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
> > -   writel(temp, sport->port.membase + UCR2);
> 
> The commit log doesn't mention ATEN, I guess that one just doesn't
> matter any more at this stage? Would be nice to point out though.
> 

Hmm, going to need to look at this again...

Patch 5 adds clearing ATEN into imx_stop_rx(), which is sensible given
that it's the aging timer on the rxFIFO, but I don't think we should be
removing that from here before it's in imx_stop_rx().

> Best regards
> Uwe
> 
> -- 
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | http://www.pengutronix.de/  |


Re: [PATCH v3 1/6] serial: imx: remove CTSC and CTS handling from imx_disable_dma

2017-09-21 Thread Martyn Welch
On Thu, Sep 21, 2017 at 08:20:17PM +0200, Uwe Kleine-König wrote:
> On Thu, Sep 21, 2017 at 05:18:12PM +0100, Martyn Welch wrote:
> > From: Nandor Han 
> > 
> > The CTSC and CTS bits affect operation of the CTS/RTS hardware flow
> > control signal (depending on whether the device is in DCE or DTE mode) and
> > are not related to DMA. When in RS-232 mode, the driver is using the
> > automatic CTSC control based on a rxFIFO fill level unless the state of
> > the CTS signal is explictly set via an ioctl call.
> > 
> > Previous improvements to the imx serial driver have resulted on
> > imx_disable_dma() only being called on shutdown, by which point the
> > serial core has already correctly deasserted CTS.
> > 
> > Testing shows that without this handling in imx_disable_dma() the CTS
> > signal state is set correctly when the device is open and TIOCM_RTS is
> > set/cleared via the TIOCMGET ioctl. The CTS signal is also correctly
> > deasserted when the device file is closed.
> 
> With that block kept CTS set once more to inactive. So the block doesn't
> hurt and is "only" superflous, right?
> 

That's my understanding, yes.

> > When in RS-485 mode, the driver uses the CTS signal very differently and
> > appears to control it via calls to imx_port_rts_active() and
> > imx_port_rts_inactive().
> > 
> > This configuration of the CTSC and CTS bits are therefore not needed.
> > 
> > Signed-off-by: Nandor Han 
> > Signed-off-by: Romain Perier 
> > Signed-off-by: Martyn Welch 
> > ---
> >  drivers/tty/serial/imx.c | 5 -
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index fe368a4..d90dae3 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1225,11 +1225,6 @@ static void imx_disable_dma(struct imx_port *sport)
> > temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN);
> > writel(temp, sport->port.membase + UCR1);
> >  
> > -   /* clear UCR2 */
> > -   temp = readl(sport->port.membase + UCR2);
> > -   temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
> > -   writel(temp, sport->port.membase + UCR2);
> 
> The commit log doesn't mention ATEN, I guess that one just doesn't
> matter any more at this stage? Would be nice to point out though.
> 

Hmm, going to need to look at this again...

Patch 5 adds clearing ATEN into imx_stop_rx(), which is sensible given
that it's the aging timer on the rxFIFO, but I don't think we should be
removing that from here before it's in imx_stop_rx().

> Best regards
> Uwe
> 
> -- 
> Pengutronix e.K.   | Uwe Kleine-König|
> Industrial Linux Solutions | http://www.pengutronix.de/  |


[PATCH v3 1/6] serial: imx: remove CTSC and CTS handling from imx_disable_dma

2017-09-21 Thread Martyn Welch
From: Nandor Han <nandor@ge.com>

The CTSC and CTS bits affect operation of the CTS/RTS hardware flow
control signal (depending on whether the device is in DCE or DTE mode) and
are not related to DMA. When in RS-232 mode, the driver is using the
automatic CTSC control based on a rxFIFO fill level unless the state of
the CTS signal is explictly set via an ioctl call.

Previous improvements to the imx serial driver have resulted on
imx_disable_dma() only being called on shutdown, by which point the
serial core has already correctly deasserted CTS.

Testing shows that without this handling in imx_disable_dma() the CTS
signal state is set correctly when the device is open and TIOCM_RTS is
set/cleared via the TIOCMGET ioctl. The CTS signal is also correctly
deasserted when the device file is closed.

When in RS-485 mode, the driver uses the CTS signal very differently and
appears to control it via calls to imx_port_rts_active() and
imx_port_rts_inactive().

This configuration of the CTSC and CTS bits are therefore not needed.

Signed-off-by: Nandor Han <nandor@ge.com>
Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..d90dae3 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1225,11 +1225,6 @@ static void imx_disable_dma(struct imx_port *sport)
temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN);
writel(temp, sport->port.membase + UCR1);
 
-   /* clear UCR2 */
-   temp = readl(sport->port.membase + UCR2);
-   temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
-   writel(temp, sport->port.membase + UCR2);
-
imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
 
sport->dma_is_enabled = 0;
-- 
1.8.3.1



[PATCH v3 1/6] serial: imx: remove CTSC and CTS handling from imx_disable_dma

2017-09-21 Thread Martyn Welch
From: Nandor Han 

The CTSC and CTS bits affect operation of the CTS/RTS hardware flow
control signal (depending on whether the device is in DCE or DTE mode) and
are not related to DMA. When in RS-232 mode, the driver is using the
automatic CTSC control based on a rxFIFO fill level unless the state of
the CTS signal is explictly set via an ioctl call.

Previous improvements to the imx serial driver have resulted on
imx_disable_dma() only being called on shutdown, by which point the
serial core has already correctly deasserted CTS.

Testing shows that without this handling in imx_disable_dma() the CTS
signal state is set correctly when the device is open and TIOCM_RTS is
set/cleared via the TIOCMGET ioctl. The CTS signal is also correctly
deasserted when the device file is closed.

When in RS-485 mode, the driver uses the CTS signal very differently and
appears to control it via calls to imx_port_rts_active() and
imx_port_rts_inactive().

This configuration of the CTSC and CTS bits are therefore not needed.

Signed-off-by: Nandor Han 
Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index fe368a4..d90dae3 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1225,11 +1225,6 @@ static void imx_disable_dma(struct imx_port *sport)
temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN);
writel(temp, sport->port.membase + UCR1);
 
-   /* clear UCR2 */
-   temp = readl(sport->port.membase + UCR2);
-   temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
-   writel(temp, sport->port.membase + UCR2);
-
imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
 
sport->dma_is_enabled = 0;
-- 
1.8.3.1



[PATCH v3 0/6] serial: imx: various improvements

2017-09-21 Thread Martyn Welch
During shutdown when a userspace service is disabled (which generates
an uart close), we got kernel crashes in the imx serial driver :

[ 1257.657423] Unhandled fault: external abort on non-linefetch (0x1008) at 
0xf0938000
[ 1257.665122] pgd = ecf2
[ 1257.667838] [f0938000] *pgd=de819811, *pte=53fc0653, *ppte=53fc0453
[ 1257.674179] Internal error: : 1008 [#1] SMP ARM
[ 1257.678722] Modules linked in:
[ 1257.681807] CPU: 0 PID: 3850 Comm: emerald_acq Not tainted 4.8.0 #10
[ 1257.688168] Hardware name: Freescale i.MX53 (Device Tree Support)
[ 1257.694269] task: e5c48000 task.stack: ed0b4000
[ 1257.698827] PC is at imx_rxint+0x5c/0x228
[ 1257.702859] LR is at lock_acquired+0x494/0x57c
[ 1257.707312] pc : [<80484884>]lr : [<80173aa0>]psr: 20070193
[ 1257.707312] sp : ed0b5c60  ip : ed0b5be8  fp : ed0b5c9c
[ 1257.718795] r10:   r9 :   r8 : 0004
[ 1257.724027] r7 : 0030  r6 : ee83e258  r5 :   r4 : ee09f410
[ 1257.730561] r3 : 0015c30c  r2 : f0938000  r1 : 0135  r0 : 40070193
[ 1257.737099] Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment 
none
[ 1257.744327] Control: 10c5387d  Table: dcf20019  DAC: 0051
[ 1257.750080] Process emerald_acq (pid: 3850, stack limit = 0xed0b4210)
[ 1257.756527] Stack: (0xed0b5c60 to 0xed0b6000)
[ 1257.760898] 5c60: ed0b5cf4 40070193 80175f64 80faf384 e5c484c0 ee09f410 
7240 5099
[ 1257.769087] 5c80: 0030 0030 80e025c4  ed0b5cf4 ed0b5ca0 
80485b18 80484834
[ 1257.777275] 5ca0: 8012fe26   60070193 ee81b210 0001 
ed0b5cdc ed0b5cc8
[ 1257.785463] 5cc0: 80171d28 80171c3c 80e2d634 ee096740 ee81b200 ee81b210 
0001 0030
[ 1257.793651] 5ce0: 80e025c4  ed0b5d34 ed0b5cf8 80182f10 804857fc 
e5c484c0 0002
[ 1257.801839] 5d00: ee81b200 ed0b5d3c 60070193 ee81b200 ee81b200 ee81b210 
0001 ee81c400
[ 1257.810027] 5d20: 0001 0008 ed0b5d54 ed0b5d38 801832d8 80182ed0 
808f4b60 
[ 1257.818216] 5d40: ee81b200 ee81b260 ed0b5d74 ed0b5d58 8018335c 801832b8 
ee81b200 ee81b260
[ 1257.826404] 5d60: ee81b210 0001 ed0b5d94 ed0b5d78 80186ba0 80183320 
80debe8c 0030
[ 1257.834592] 5d80:  0001 ed0b5da4 ed0b5d98 80182420 80186af4 
ed0b5dcc ed0b5da8
[ 1257.842780] 5da0: 801827a0 801823fc  80e8350c 0020 0001 
ed0b5df8 0001
[ 1257.850968] 5dc0: ed0b5df4 ed0b5dd0 80101530 8018274c 808f4bec 20070013 
 ed0b5e2c
[ 1257.859156] 5de0: ee09f410 ed0b4000 ed0b5e5c ed0b5df8 808f55f0 801014c8 
0001 0130
[ 1257.867345] 5e00:  e5c48000 60070013 ee09f410  60070013 
ee09f410 ed06a640
[ 1257.875533] 5e20: 0008 ed0b5e5c ed0b5df0 ed0b5e48 801756a8 808f4bec 
20070013 
[ 1257.883722] 5e40: 0051 7f00 ee09f410 0b01 ed0b5e7c ed0b5e60 
80485d74 808f4bb4
[ 1257.891912] 5e60: ee83e258 ee09f410 ee83e3a4 80e2d634 ed0b5ea4 ed0b5e80 
8047f514 80485c70
[ 1257.900100] 5e80: ee83e258 ed375000 ee09f410 ee83e310 ee83e3ac ed06a640 
ed0b5ecc ed0b5ea8
[ 1257.908288] 5ea0: 80481304 8047f400 ed375000 eeabce60  ee7973e8 
 ed06a640
[ 1257.916477] 5ec0: ed0b5f14 ed0b5ed0 80462fe0 804811ac 0008 eeabce60 
0001 0001
[ 1257.924665] 5ee0:  802713dc ed0b5f54 ed06a640 eeabce60 ee2c6910 
ee7973e8 
[ 1257.932854] 5f00: eeabce60 0008 ed0b5f54 ed0b5f18 80271404 80462ee8 
 
[ 1257.941044] 5f20: ed06c640 ed06a648 ed0b5f4c e5c48400  80e84054 
e5c48440 e5c48000
[ 1257.949232] 5f40:   ed0b5f64 ed0b5f58 802715c4 80271378 
ed0b5f8c ed0b5f68
[ 1257.957420] 5f60: 80146034 802715b8  ed0b4000 ed0b5fb0 801086c4 
801086c4 ed0b4000
[ 1257.965610] 5f80: ed0b5fac ed0b5f90 8010cc68 80145f78 0054756c  
767474b4 0006
[ 1257.973798] 5fa0:  ed0b5fb0 80108548 8010cbc4  76f2a084 
0002 
[ 1257.981986] 5fc0: 0054756c  767474b4 0006 0225e880  
76f36000 7e836d34
[ 1257.990175] 5fe0:  7e836d10 76f2a4c0 76a5db68 80070010 0062 
 
[ 1257.998357] Backtrace: 
[ 1258.000837] [<80484828>] (imx_rxint) from [<80485b18>] (imx_int+0x328/0x474)
[ 1258.007892]  r10: r9:80e025c4 r8:0030 r7:0030 r6:5099 
r5:7240
[ 1258.015815]  r4:ee09f410
[ 1258.018386] [<804857f0>] (imx_int) from [<80182f10>] 
(__handle_irq_event_percpu+0x4c/0x3e8)
[ 1258.026742]  r10: r9:80e025c4 r8:0030 r7:0001 r6:ee81b210 
r5:ee81b200
[ 1258.034664]  r4:ee096740
[ 1258.037226] [<80182ec4>] (__handle_irq_event_percpu) from [<801832d8>] 
(handle_irq_event_percpu+0x2c/0x68)
[ 1258.046885]  r10:0008 r9:0001 r8:ee81c400 r7:0001 r6:ee81b210 
r5:ee81b200
[ 1258.054806]  r4:ee81b200
[ 1258.057369] [<801832ac>] (handle_irq_event_percpu) from [<8018335c>] 
(handle_irq_event+0x48/0x6c)
[ 1258.066246]  r5:ee81b260 r4:ee81b200
[ 1258.069866] [<80183314>] (handle_irq_event) from [<80186ba0>] 
(handle_level_irq+0xb8/0x154)
[ 1258.078222]  r7:0001 r6:ee81b210 r5:ee81b260 

[PATCH v3 0/6] serial: imx: various improvements

2017-09-21 Thread Martyn Welch
During shutdown when a userspace service is disabled (which generates
an uart close), we got kernel crashes in the imx serial driver :

[ 1257.657423] Unhandled fault: external abort on non-linefetch (0x1008) at 
0xf0938000
[ 1257.665122] pgd = ecf2
[ 1257.667838] [f0938000] *pgd=de819811, *pte=53fc0653, *ppte=53fc0453
[ 1257.674179] Internal error: : 1008 [#1] SMP ARM
[ 1257.678722] Modules linked in:
[ 1257.681807] CPU: 0 PID: 3850 Comm: emerald_acq Not tainted 4.8.0 #10
[ 1257.688168] Hardware name: Freescale i.MX53 (Device Tree Support)
[ 1257.694269] task: e5c48000 task.stack: ed0b4000
[ 1257.698827] PC is at imx_rxint+0x5c/0x228
[ 1257.702859] LR is at lock_acquired+0x494/0x57c
[ 1257.707312] pc : [<80484884>]lr : [<80173aa0>]psr: 20070193
[ 1257.707312] sp : ed0b5c60  ip : ed0b5be8  fp : ed0b5c9c
[ 1257.718795] r10:   r9 :   r8 : 0004
[ 1257.724027] r7 : 0030  r6 : ee83e258  r5 :   r4 : ee09f410
[ 1257.730561] r3 : 0015c30c  r2 : f0938000  r1 : 0135  r0 : 40070193
[ 1257.737099] Flags: nzCv  IRQs off  FIQs on  Mode SVC_32  ISA ARM  Segment 
none
[ 1257.744327] Control: 10c5387d  Table: dcf20019  DAC: 0051
[ 1257.750080] Process emerald_acq (pid: 3850, stack limit = 0xed0b4210)
[ 1257.756527] Stack: (0xed0b5c60 to 0xed0b6000)
[ 1257.760898] 5c60: ed0b5cf4 40070193 80175f64 80faf384 e5c484c0 ee09f410 
7240 5099
[ 1257.769087] 5c80: 0030 0030 80e025c4  ed0b5cf4 ed0b5ca0 
80485b18 80484834
[ 1257.777275] 5ca0: 8012fe26   60070193 ee81b210 0001 
ed0b5cdc ed0b5cc8
[ 1257.785463] 5cc0: 80171d28 80171c3c 80e2d634 ee096740 ee81b200 ee81b210 
0001 0030
[ 1257.793651] 5ce0: 80e025c4  ed0b5d34 ed0b5cf8 80182f10 804857fc 
e5c484c0 0002
[ 1257.801839] 5d00: ee81b200 ed0b5d3c 60070193 ee81b200 ee81b200 ee81b210 
0001 ee81c400
[ 1257.810027] 5d20: 0001 0008 ed0b5d54 ed0b5d38 801832d8 80182ed0 
808f4b60 
[ 1257.818216] 5d40: ee81b200 ee81b260 ed0b5d74 ed0b5d58 8018335c 801832b8 
ee81b200 ee81b260
[ 1257.826404] 5d60: ee81b210 0001 ed0b5d94 ed0b5d78 80186ba0 80183320 
80debe8c 0030
[ 1257.834592] 5d80:  0001 ed0b5da4 ed0b5d98 80182420 80186af4 
ed0b5dcc ed0b5da8
[ 1257.842780] 5da0: 801827a0 801823fc  80e8350c 0020 0001 
ed0b5df8 0001
[ 1257.850968] 5dc0: ed0b5df4 ed0b5dd0 80101530 8018274c 808f4bec 20070013 
 ed0b5e2c
[ 1257.859156] 5de0: ee09f410 ed0b4000 ed0b5e5c ed0b5df8 808f55f0 801014c8 
0001 0130
[ 1257.867345] 5e00:  e5c48000 60070013 ee09f410  60070013 
ee09f410 ed06a640
[ 1257.875533] 5e20: 0008 ed0b5e5c ed0b5df0 ed0b5e48 801756a8 808f4bec 
20070013 
[ 1257.883722] 5e40: 0051 7f00 ee09f410 0b01 ed0b5e7c ed0b5e60 
80485d74 808f4bb4
[ 1257.891912] 5e60: ee83e258 ee09f410 ee83e3a4 80e2d634 ed0b5ea4 ed0b5e80 
8047f514 80485c70
[ 1257.900100] 5e80: ee83e258 ed375000 ee09f410 ee83e310 ee83e3ac ed06a640 
ed0b5ecc ed0b5ea8
[ 1257.908288] 5ea0: 80481304 8047f400 ed375000 eeabce60  ee7973e8 
 ed06a640
[ 1257.916477] 5ec0: ed0b5f14 ed0b5ed0 80462fe0 804811ac 0008 eeabce60 
0001 0001
[ 1257.924665] 5ee0:  802713dc ed0b5f54 ed06a640 eeabce60 ee2c6910 
ee7973e8 
[ 1257.932854] 5f00: eeabce60 0008 ed0b5f54 ed0b5f18 80271404 80462ee8 
 
[ 1257.941044] 5f20: ed06c640 ed06a648 ed0b5f4c e5c48400  80e84054 
e5c48440 e5c48000
[ 1257.949232] 5f40:   ed0b5f64 ed0b5f58 802715c4 80271378 
ed0b5f8c ed0b5f68
[ 1257.957420] 5f60: 80146034 802715b8  ed0b4000 ed0b5fb0 801086c4 
801086c4 ed0b4000
[ 1257.965610] 5f80: ed0b5fac ed0b5f90 8010cc68 80145f78 0054756c  
767474b4 0006
[ 1257.973798] 5fa0:  ed0b5fb0 80108548 8010cbc4  76f2a084 
0002 
[ 1257.981986] 5fc0: 0054756c  767474b4 0006 0225e880  
76f36000 7e836d34
[ 1257.990175] 5fe0:  7e836d10 76f2a4c0 76a5db68 80070010 0062 
 
[ 1257.998357] Backtrace: 
[ 1258.000837] [<80484828>] (imx_rxint) from [<80485b18>] (imx_int+0x328/0x474)
[ 1258.007892]  r10: r9:80e025c4 r8:0030 r7:0030 r6:5099 
r5:7240
[ 1258.015815]  r4:ee09f410
[ 1258.018386] [<804857f0>] (imx_int) from [<80182f10>] 
(__handle_irq_event_percpu+0x4c/0x3e8)
[ 1258.026742]  r10: r9:80e025c4 r8:0030 r7:0001 r6:ee81b210 
r5:ee81b200
[ 1258.034664]  r4:ee096740
[ 1258.037226] [<80182ec4>] (__handle_irq_event_percpu) from [<801832d8>] 
(handle_irq_event_percpu+0x2c/0x68)
[ 1258.046885]  r10:0008 r9:0001 r8:ee81c400 r7:0001 r6:ee81b210 
r5:ee81b200
[ 1258.054806]  r4:ee81b200
[ 1258.057369] [<801832ac>] (handle_irq_event_percpu) from [<8018335c>] 
(handle_irq_event+0x48/0x6c)
[ 1258.066246]  r5:ee81b260 r4:ee81b200
[ 1258.069866] [<80183314>] (handle_irq_event) from [<80186ba0>] 
(handle_level_irq+0xb8/0x154)
[ 1258.078222]  r7:0001 r6:ee81b210 r5:ee81b260 

[PATCH v3 4/6] serial: imx: unmap sg buffers when DMA channel is released

2017-09-21 Thread Martyn Welch
From: Nandor Han <nandor@ge.com>

This commits unmaps sg buffers when the DMA channel is released. It also
sets to zero `dma_is_rxing` and `dma_is_txing` to state that the
corresponding channels cannot transmit/receive data, as these are
disabled.

Signed-off-by: Nandor Han <nandor@ge.com>
Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 2fb3210..ed02783 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -357,6 +357,12 @@ static void imx_stop_tx_dma(struct imx_port *sport)
temp = readl(sport->port.membase + UCR1);
temp &= ~UCR1_TDMAEN;
writel(temp, sport->port.membase + UCR1);
+
+   if (sport->dma_is_txing) {
+   dma_unmap_sg(sport->port.dev, >tx_sgl[0],
+   sport->dma_tx_nents, DMA_TO_DEVICE);
+   sport->dma_is_txing = 0;
+   }
 }
 
 static void imx_stop_rx_dma(struct imx_port *sport)
@@ -366,6 +372,12 @@ static void imx_stop_rx_dma(struct imx_port *sport)
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RDMAEN | UCR1_ATDMAEN);
writel(temp, sport->port.membase + UCR1);
+
+   if (sport->dma_is_rxing) {
+   dma_unmap_sg(sport->port.dev, >rx_sgl, 1,
+   DMA_FROM_DEVICE);
+   sport->dma_is_rxing = 0;
+   }
 }
 
 /*
-- 
1.8.3.1



[PATCH v3 3/6] serial: imx: Simplify DMA disablement

2017-09-21 Thread Martyn Welch
From: Nandor Han <nandor@ge.com>

This commits simplify the function imx_disable_dma() by moving
the code for disabling RX and TX DMAs to dedicated functions.
This is a preparation for the next commit.

Signed-off-by: Nandor Han <nandor@ge.com>
Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 7835279..2fb3210 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -350,6 +350,24 @@ static void imx_port_rts_auto(struct imx_port *sport, 
unsigned long *ucr2)
*ucr2 |= UCR2_CTSC;
 }
 
+static void imx_stop_tx_dma(struct imx_port *sport)
+{
+   unsigned long temp;
+
+   temp = readl(sport->port.membase + UCR1);
+   temp &= ~UCR1_TDMAEN;
+   writel(temp, sport->port.membase + UCR1);
+}
+
+static void imx_stop_rx_dma(struct imx_port *sport)
+{
+   unsigned long temp;
+
+   temp = readl(sport->port.membase + UCR1);
+   temp &= ~(UCR1_RDMAEN | UCR1_ATDMAEN);
+   writel(temp, sport->port.membase + UCR1);
+}
+
 /*
  * interrupts disabled on entry
  */
@@ -1217,13 +1235,8 @@ static void imx_enable_dma(struct imx_port *sport)
 
 static void imx_disable_dma(struct imx_port *sport)
 {
-   unsigned long temp;
-
-   /* clear UCR1 */
-   temp = readl(sport->port.membase + UCR1);
-   temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN);
-   writel(temp, sport->port.membase + UCR1);
-
+   imx_stop_rx_dma(sport);
+   imx_stop_tx_dma(sport);
imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
 
sport->dma_is_enabled = 0;
-- 
1.8.3.1



[PATCH v3 4/6] serial: imx: unmap sg buffers when DMA channel is released

2017-09-21 Thread Martyn Welch
From: Nandor Han 

This commits unmaps sg buffers when the DMA channel is released. It also
sets to zero `dma_is_rxing` and `dma_is_txing` to state that the
corresponding channels cannot transmit/receive data, as these are
disabled.

Signed-off-by: Nandor Han 
Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 2fb3210..ed02783 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -357,6 +357,12 @@ static void imx_stop_tx_dma(struct imx_port *sport)
temp = readl(sport->port.membase + UCR1);
temp &= ~UCR1_TDMAEN;
writel(temp, sport->port.membase + UCR1);
+
+   if (sport->dma_is_txing) {
+   dma_unmap_sg(sport->port.dev, >tx_sgl[0],
+   sport->dma_tx_nents, DMA_TO_DEVICE);
+   sport->dma_is_txing = 0;
+   }
 }
 
 static void imx_stop_rx_dma(struct imx_port *sport)
@@ -366,6 +372,12 @@ static void imx_stop_rx_dma(struct imx_port *sport)
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RDMAEN | UCR1_ATDMAEN);
writel(temp, sport->port.membase + UCR1);
+
+   if (sport->dma_is_rxing) {
+   dma_unmap_sg(sport->port.dev, >rx_sgl, 1,
+   DMA_FROM_DEVICE);
+   sport->dma_is_rxing = 0;
+   }
 }
 
 /*
-- 
1.8.3.1



[PATCH v3 3/6] serial: imx: Simplify DMA disablement

2017-09-21 Thread Martyn Welch
From: Nandor Han 

This commits simplify the function imx_disable_dma() by moving
the code for disabling RX and TX DMAs to dedicated functions.
This is a preparation for the next commit.

Signed-off-by: Nandor Han 
Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 27 ---
 1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 7835279..2fb3210 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -350,6 +350,24 @@ static void imx_port_rts_auto(struct imx_port *sport, 
unsigned long *ucr2)
*ucr2 |= UCR2_CTSC;
 }
 
+static void imx_stop_tx_dma(struct imx_port *sport)
+{
+   unsigned long temp;
+
+   temp = readl(sport->port.membase + UCR1);
+   temp &= ~UCR1_TDMAEN;
+   writel(temp, sport->port.membase + UCR1);
+}
+
+static void imx_stop_rx_dma(struct imx_port *sport)
+{
+   unsigned long temp;
+
+   temp = readl(sport->port.membase + UCR1);
+   temp &= ~(UCR1_RDMAEN | UCR1_ATDMAEN);
+   writel(temp, sport->port.membase + UCR1);
+}
+
 /*
  * interrupts disabled on entry
  */
@@ -1217,13 +1235,8 @@ static void imx_enable_dma(struct imx_port *sport)
 
 static void imx_disable_dma(struct imx_port *sport)
 {
-   unsigned long temp;
-
-   /* clear UCR1 */
-   temp = readl(sport->port.membase + UCR1);
-   temp &= ~(UCR1_RDMAEN | UCR1_TDMAEN | UCR1_ATDMAEN);
-   writel(temp, sport->port.membase + UCR1);
-
+   imx_stop_rx_dma(sport);
+   imx_stop_tx_dma(sport);
imx_setup_ufcr(sport, TXTL_DEFAULT, RXTL_DEFAULT);
 
sport->dma_is_enabled = 0;
-- 
1.8.3.1



[PATCH v3 2/6] serial: imx: only set dma_is_rxing when DMA starts

2017-09-21 Thread Martyn Welch
From: Romain Perier <romain.per...@collabora.com>

The variable dma_is_rxing is currently set to 1 in imx_disable_rx_int().
This is problematic as:

- whilst imx_disable_rx_int() is currently always called before
  start_rx_dma() this dependency isn't obvious.
- start_rx_dma() does error checking and might exit without
  enabling DMA. Currently this will result in dma_is_rxing suggesting
  that DMA is being used for recieving.

To avoid these issues, move the setting of dma_is_rxing to
start_rx_dma() when appropriate.

Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index d90dae3..7835279 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -714,8 +714,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
 {
unsigned long temp;
 
-   sport->dma_is_rxing = 1;
-
/* disable the receiver ready and aging timer interrupts */
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RRDYEN);
@@ -1074,6 +1072,7 @@ static int start_rx_dma(struct imx_port *sport)
desc->callback_param = sport;
 
dev_dbg(dev, "RX: prepare for the DMA.\n");
+   sport->dma_is_rxing = 1;
sport->rx_cookie = dmaengine_submit(desc);
dma_async_issue_pending(chan);
return 0;
-- 
1.8.3.1



[PATCH v3 2/6] serial: imx: only set dma_is_rxing when DMA starts

2017-09-21 Thread Martyn Welch
From: Romain Perier 

The variable dma_is_rxing is currently set to 1 in imx_disable_rx_int().
This is problematic as:

- whilst imx_disable_rx_int() is currently always called before
  start_rx_dma() this dependency isn't obvious.
- start_rx_dma() does error checking and might exit without
  enabling DMA. Currently this will result in dma_is_rxing suggesting
  that DMA is being used for recieving.

To avoid these issues, move the setting of dma_is_rxing to
start_rx_dma() when appropriate.

Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index d90dae3..7835279 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -714,8 +714,6 @@ static void imx_disable_rx_int(struct imx_port *sport)
 {
unsigned long temp;
 
-   sport->dma_is_rxing = 1;
-
/* disable the receiver ready and aging timer interrupts */
temp = readl(sport->port.membase + UCR1);
temp &= ~(UCR1_RRDYEN);
@@ -1074,6 +1072,7 @@ static int start_rx_dma(struct imx_port *sport)
desc->callback_param = sport;
 
dev_dbg(dev, "RX: prepare for the DMA.\n");
+   sport->dma_is_rxing = 1;
sport->rx_cookie = dmaengine_submit(desc);
dma_async_issue_pending(chan);
return 0;
-- 
1.8.3.1



[PATCH v3 5/6] serial: imx: update the stop rx,tx procedures

2017-09-21 Thread Martyn Welch
From: Nandor Han <nandor@ge.com>

According to "Documentation/serial/driver" both procedures should stop
receiving or sending data. Based on this the procedures should stop the
activity regardless if DMA is enabled or not.

This commit updates both imx_stop_{rx|tx} procedures to stop the
activity and disable the interrupts related to that.

Signed-off-by: Nandor Han <nandor@ge.com>
Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index ed02783..256b128 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -388,15 +388,14 @@ static void imx_stop_tx(struct uart_port *port)
struct imx_port *sport = (struct imx_port *)port;
unsigned long temp;
 
-   /*
-* We are maybe in the SMP context, so if the DMA TX thread is running
-* on other cpu, we have to wait for it to finish.
-*/
-   if (sport->dma_is_enabled && sport->dma_is_txing)
-   return;
+   sport->tx_bytes = 0;
+
+   if (sport->dma_is_enabled)
+   imx_stop_tx_dma(sport);
 
temp = readl(port->membase + UCR1);
-   writel(temp & ~UCR1_TXMPTYEN, port->membase + UCR1);
+   temp &= ~(UCR1_TXMPTYEN | UCR1_TRDYEN | UCR1_RTSDEN);
+   writel(temp, port->membase + UCR1);
 
/* in rs485 mode disable transmitter if shifter is empty */
if (port->rs485.flags & SER_RS485_ENABLED &&
@@ -423,21 +422,20 @@ static void imx_stop_rx(struct uart_port *port)
struct imx_port *sport = (struct imx_port *)port;
unsigned long temp;
 
-   if (sport->dma_is_enabled && sport->dma_is_rxing) {
-   if (sport->port.suspended) {
-   dmaengine_terminate_all(sport->dma_chan_rx);
-   sport->dma_is_rxing = 0;
-   } else {
-   return;
-   }
-   }
+   if (sport->dma_is_enabled)
+   imx_stop_rx_dma(sport);
+
+   temp = readl(sport->port.membase + UCR1);
+   temp &= ~UCR1_RRDYEN;
+   writel(temp, sport->port.membase + UCR1);
 
temp = readl(sport->port.membase + UCR2);
-   writel(temp & ~UCR2_RXEN, sport->port.membase + UCR2);
+   temp &= ~UCR2_ATEN;
+   writel(temp, sport->port.membase + UCR2);
 
-   /* disable the `Receiver Ready Interrrupt` */
-   temp = readl(sport->port.membase + UCR1);
-   writel(temp & ~UCR1_RRDYEN, sport->port.membase + UCR1);
+   temp = readl(sport->port.membase + UCR3);
+   temp &= ~UCR3_AWAKEN;
+   writel(temp, sport->port.membase + UCR3);
 }
 
 /*
-- 
1.8.3.1



[PATCH v3 6/6] serial: imx: Fix imx_shutdown procedure

2017-09-21 Thread Martyn Welch
From: Nandor Han <nandor@ge.com>

In some cases, it looks that interrupts can happen after the dma was
disabled and port was not yet shutdown. This will result in interrupts
handled by imx_rxint.

This commits updates the shutdown function to ensure that underlying
components are disabled in the right order. This disables RX and TX
blocks, then it disabled interrupts. In case DMA is enabled, it disables
DMA and free corresponding resources. It disables UART port and stop
clocks.

Signed-off-by: Nandor Han <nandor@ge.com>
Signed-off-by: Romain Perier <romain.per...@collabora.com>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/tty/serial/imx.c | 34 +++---
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 256b128..393c1c0 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1368,44 +1368,40 @@ static void imx_shutdown(struct uart_port *port)
unsigned long temp;
unsigned long flags;
 
-   if (sport->dma_is_enabled) {
-   sport->dma_is_rxing = 0;
-   sport->dma_is_txing = 0;
-   dmaengine_terminate_sync(sport->dma_chan_tx);
-   dmaengine_terminate_sync(sport->dma_chan_rx);
-
+   if (!sport->port.suspended) {
spin_lock_irqsave(>port.lock, flags);
imx_stop_tx(port);
imx_stop_rx(port);
-   imx_disable_dma(sport);
+
+   if (sport->dma_is_inited && sport->dma_is_enabled)
+   imx_disable_dma(sport);
+
spin_unlock_irqrestore(>port.lock, flags);
imx_uart_dma_exit(sport);
}
 
-   mctrl_gpio_disable_ms(sport->gpios);
-
spin_lock_irqsave(>port.lock, flags);
temp = readl(sport->port.membase + UCR2);
-   temp &= ~(UCR2_TXEN);
+   temp &= ~(UCR2_TXEN | UCR2_RXEN);
writel(temp, sport->port.membase + UCR2);
+   temp = readl(sport->port.membase + UCR4);
+   temp &= ~UCR4_OREN;
+   writel(temp, sport->port.membase + UCR4);
spin_unlock_irqrestore(>port.lock, flags);
 
-   /*
-* Stop our timer.
-*/
-   del_timer_sync(>timer);
+   mctrl_gpio_disable_ms(sport->gpios);
 
-   /*
-* Disable all interrupts, port and break condition.
-*/
+   /* Stop our timer. */
+   del_timer_sync(>timer);
 
+   /* Disable port. */
spin_lock_irqsave(>port.lock, flags);
temp = readl(sport->port.membase + UCR1);
-   temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
-
+   temp &= ~UCR1_UARTEN;
writel(temp, sport->port.membase + UCR1);
spin_unlock_irqrestore(>port.lock, flags);
 
+   /* Disable clocks. */
clk_disable_unprepare(sport->clk_per);
clk_disable_unprepare(sport->clk_ipg);
 }
-- 
1.8.3.1



[PATCH v3 5/6] serial: imx: update the stop rx,tx procedures

2017-09-21 Thread Martyn Welch
From: Nandor Han 

According to "Documentation/serial/driver" both procedures should stop
receiving or sending data. Based on this the procedures should stop the
activity regardless if DMA is enabled or not.

This commit updates both imx_stop_{rx|tx} procedures to stop the
activity and disable the interrupts related to that.

Signed-off-by: Nandor Han 
Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 36 +---
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index ed02783..256b128 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -388,15 +388,14 @@ static void imx_stop_tx(struct uart_port *port)
struct imx_port *sport = (struct imx_port *)port;
unsigned long temp;
 
-   /*
-* We are maybe in the SMP context, so if the DMA TX thread is running
-* on other cpu, we have to wait for it to finish.
-*/
-   if (sport->dma_is_enabled && sport->dma_is_txing)
-   return;
+   sport->tx_bytes = 0;
+
+   if (sport->dma_is_enabled)
+   imx_stop_tx_dma(sport);
 
temp = readl(port->membase + UCR1);
-   writel(temp & ~UCR1_TXMPTYEN, port->membase + UCR1);
+   temp &= ~(UCR1_TXMPTYEN | UCR1_TRDYEN | UCR1_RTSDEN);
+   writel(temp, port->membase + UCR1);
 
/* in rs485 mode disable transmitter if shifter is empty */
if (port->rs485.flags & SER_RS485_ENABLED &&
@@ -423,21 +422,20 @@ static void imx_stop_rx(struct uart_port *port)
struct imx_port *sport = (struct imx_port *)port;
unsigned long temp;
 
-   if (sport->dma_is_enabled && sport->dma_is_rxing) {
-   if (sport->port.suspended) {
-   dmaengine_terminate_all(sport->dma_chan_rx);
-   sport->dma_is_rxing = 0;
-   } else {
-   return;
-   }
-   }
+   if (sport->dma_is_enabled)
+   imx_stop_rx_dma(sport);
+
+   temp = readl(sport->port.membase + UCR1);
+   temp &= ~UCR1_RRDYEN;
+   writel(temp, sport->port.membase + UCR1);
 
temp = readl(sport->port.membase + UCR2);
-   writel(temp & ~UCR2_RXEN, sport->port.membase + UCR2);
+   temp &= ~UCR2_ATEN;
+   writel(temp, sport->port.membase + UCR2);
 
-   /* disable the `Receiver Ready Interrrupt` */
-   temp = readl(sport->port.membase + UCR1);
-   writel(temp & ~UCR1_RRDYEN, sport->port.membase + UCR1);
+   temp = readl(sport->port.membase + UCR3);
+   temp &= ~UCR3_AWAKEN;
+   writel(temp, sport->port.membase + UCR3);
 }
 
 /*
-- 
1.8.3.1



[PATCH v3 6/6] serial: imx: Fix imx_shutdown procedure

2017-09-21 Thread Martyn Welch
From: Nandor Han 

In some cases, it looks that interrupts can happen after the dma was
disabled and port was not yet shutdown. This will result in interrupts
handled by imx_rxint.

This commits updates the shutdown function to ensure that underlying
components are disabled in the right order. This disables RX and TX
blocks, then it disabled interrupts. In case DMA is enabled, it disables
DMA and free corresponding resources. It disables UART port and stop
clocks.

Signed-off-by: Nandor Han 
Signed-off-by: Romain Perier 
Signed-off-by: Martyn Welch 
---
 drivers/tty/serial/imx.c | 34 +++---
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 256b128..393c1c0 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -1368,44 +1368,40 @@ static void imx_shutdown(struct uart_port *port)
unsigned long temp;
unsigned long flags;
 
-   if (sport->dma_is_enabled) {
-   sport->dma_is_rxing = 0;
-   sport->dma_is_txing = 0;
-   dmaengine_terminate_sync(sport->dma_chan_tx);
-   dmaengine_terminate_sync(sport->dma_chan_rx);
-
+   if (!sport->port.suspended) {
spin_lock_irqsave(>port.lock, flags);
imx_stop_tx(port);
imx_stop_rx(port);
-   imx_disable_dma(sport);
+
+   if (sport->dma_is_inited && sport->dma_is_enabled)
+   imx_disable_dma(sport);
+
spin_unlock_irqrestore(>port.lock, flags);
imx_uart_dma_exit(sport);
}
 
-   mctrl_gpio_disable_ms(sport->gpios);
-
spin_lock_irqsave(>port.lock, flags);
temp = readl(sport->port.membase + UCR2);
-   temp &= ~(UCR2_TXEN);
+   temp &= ~(UCR2_TXEN | UCR2_RXEN);
writel(temp, sport->port.membase + UCR2);
+   temp = readl(sport->port.membase + UCR4);
+   temp &= ~UCR4_OREN;
+   writel(temp, sport->port.membase + UCR4);
spin_unlock_irqrestore(>port.lock, flags);
 
-   /*
-* Stop our timer.
-*/
-   del_timer_sync(>timer);
+   mctrl_gpio_disable_ms(sport->gpios);
 
-   /*
-* Disable all interrupts, port and break condition.
-*/
+   /* Stop our timer. */
+   del_timer_sync(>timer);
 
+   /* Disable port. */
spin_lock_irqsave(>port.lock, flags);
temp = readl(sport->port.membase + UCR1);
-   temp &= ~(UCR1_TXMPTYEN | UCR1_RRDYEN | UCR1_RTSDEN | UCR1_UARTEN);
-
+   temp &= ~UCR1_UARTEN;
writel(temp, sport->port.membase + UCR1);
spin_unlock_irqrestore(>port.lock, flags);
 
+   /* Disable clocks. */
clk_disable_unprepare(sport->clk_per);
clk_disable_unprepare(sport->clk_ipg);
 }
-- 
1.8.3.1



Re: [PATCH] staging:vme Fix use BIT macro

2017-09-21 Thread Martyn Welch
On 21 September 2017 at 06:52, Janani Sankara Babu  wrote:
> This patch is created to solve the following warning shown by the checkpatch
> script Warning: Replace all occurences of (1<
> Signed-off-by: Janani Sankara Babu 
> ---
>  drivers/staging/vme/devices/vme_pio2.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/vme/devices/vme_pio2.h 
> b/drivers/staging/vme/devices/vme_pio2.h
> index ac4a4ba..e9c3cf6 100644
> --- a/drivers/staging/vme/devices/vme_pio2.h
> +++ b/drivers/staging/vme/devices/vme_pio2.h
> @@ -179,7 +179,7 @@
> PIO2_REGS_CTRL_WRD1 };
>
>  #define PIO2_CNTR_SC_DEV0  0
> -#define PIO2_CNTR_SC_DEV1  (1 << 6)
> +#define PIO2_CNTR_SC_DEV1  BIT(6)

Sorry, these changes just don't make sense given the defines below.

>  #define PIO2_CNTR_SC_DEV2  (2 << 6)
>  #define PIO2_CNTR_SC_RDBACK(3 << 6)
>
> @@ -188,12 +188,12 @@
> PIO2_CNTR_SC_DEV1, PIO2_CNTR_SC_DEV2 
> };
>
>  #define PIO2_CNTR_RW_LATCH 0
> -#define PIO2_CNTR_RW_LSB   (1 << 4)
> +#define PIO2_CNTR_RW_LSB   BIT(4)
>  #define PIO2_CNTR_RW_MSB   (2 << 4)
>  #define PIO2_CNTR_RW_BOTH  (3 << 4)
>
>  #define PIO2_CNTR_MODE00
> -#define PIO2_CNTR_MODE1(1 << 1)
> +#define PIO2_CNTR_MODE1BIT(1)
>  #define PIO2_CNTR_MODE2(2 << 1)
>  #define PIO2_CNTR_MODE3(3 << 1)
>  #define PIO2_CNTR_MODE4(4 << 1)
> --
> 1.9.1
>


Re: [PATCH] staging:vme Fix use BIT macro

2017-09-21 Thread Martyn Welch
On 21 September 2017 at 06:52, Janani Sankara Babu  wrote:
> This patch is created to solve the following warning shown by the checkpatch
> script Warning: Replace all occurences of (1<
> Signed-off-by: Janani Sankara Babu 
> ---
>  drivers/staging/vme/devices/vme_pio2.h | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/staging/vme/devices/vme_pio2.h 
> b/drivers/staging/vme/devices/vme_pio2.h
> index ac4a4ba..e9c3cf6 100644
> --- a/drivers/staging/vme/devices/vme_pio2.h
> +++ b/drivers/staging/vme/devices/vme_pio2.h
> @@ -179,7 +179,7 @@
> PIO2_REGS_CTRL_WRD1 };
>
>  #define PIO2_CNTR_SC_DEV0  0
> -#define PIO2_CNTR_SC_DEV1  (1 << 6)
> +#define PIO2_CNTR_SC_DEV1  BIT(6)

Sorry, these changes just don't make sense given the defines below.

>  #define PIO2_CNTR_SC_DEV2  (2 << 6)
>  #define PIO2_CNTR_SC_RDBACK(3 << 6)
>
> @@ -188,12 +188,12 @@
> PIO2_CNTR_SC_DEV1, PIO2_CNTR_SC_DEV2 
> };
>
>  #define PIO2_CNTR_RW_LATCH 0
> -#define PIO2_CNTR_RW_LSB   (1 << 4)
> +#define PIO2_CNTR_RW_LSB   BIT(4)
>  #define PIO2_CNTR_RW_MSB   (2 << 4)
>  #define PIO2_CNTR_RW_BOTH  (3 << 4)
>
>  #define PIO2_CNTR_MODE00
> -#define PIO2_CNTR_MODE1(1 << 1)
> +#define PIO2_CNTR_MODE1BIT(1)
>  #define PIO2_CNTR_MODE2(2 << 1)
>  #define PIO2_CNTR_MODE3(3 << 1)
>  #define PIO2_CNTR_MODE4(4 << 1)
> --
> 1.9.1
>


Re: [PATCH v2 3/6] serial: imx: remove CTSC and CTS handling

2017-09-15 Thread Martyn Welch
Hi

On Wed, Jul 05, 2017 at 03:38:45PM +0200, Uwe Kleine-König wrote:
> Cc += Clemens Gruber + Fabio Estevam
> 
> On Wed, Jul 05, 2017 at 03:07:03PM +0200, Romain Perier wrote:
> > From: Nandor Han 
> > 
> > CTSC and CTS are not related to DMA and might add
> > disruption in some cases.
> > 
> > Signed-off-by: Romain Perier 
> 
> If it was Nandor Han who created this patch, it would be great to get
> his sob. If it was you, drop the From: line above.
> 

This patch was broken out from a larger one written by Nandor, who is
happy for me to add his sob.

> > ---
> >  drivers/tty/serial/imx.c | 5 -
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index 5291b86..dd3ebb4 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1249,11 +1249,6 @@ static void imx_disable_dma(struct imx_port *sport)
> > imx_stop_rx_dma(sport);
> > imx_stop_tx_dma(sport);
> >  
> > -   /* clear UCR2 */
> > -   temp = readl(sport->port.membase + UCR2);
> > -   temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
> > -   writel(temp, sport->port.membase + UCR2);
> > -
> 
> Before this patch imx_disable_dma resulted in the #CTS pin being high
> (inactive).
> 
> Does this qualify as a fix? If so, you should sort this patch to the
> beginning of the series. Did you do test this patch and its effects
> separately?
> 

I've been giving the RTS/CTS lines a bit of a kick with (and without) this
patch and I'm seeing what I'd expect to see on the CTS pin (the Wandboard
I'm using runs this in DCE mode even though it really should be in DTE
mode, hey ho). Using a little test app I've found/modified (listed below),
the CTS line can be (de)asserted whilst the device is open and the line
gets deasserted when the device closes. I have tested this port both when
acting as a console (and thus with DMA turned off) and when not used as a
console, with DMA enabled (confirmed with existing debug in driver).

This matches the behaviour of a FTDI based debug board that I've also
tried (in this case I looked at the RTS line as the device is running as a
DTE).

On my PC the same test app sets the RTS line (the serial port running as a
DTE, 8250_pnp driver) results in the CTS line being set appropriately as
well. It also stays in that state even after the serial device is closed,
this does seem right either but there you go.

With regards to the operation of the CTS/RTS line when twiddling it via
the ioctl, I think the behaviour of the IMX/FTDI is the expected one. Is
that the case?

Which I guess brings us to the lines above.

When running as an RS232 port (i.e. not rs485) the driver is using the
automatic CTSC control based on a rxFIFO watermark unless the state of the
CTS line is explictly set via an ioctl call. As such, unless I'm missing
something, the rxFIFO (and thus the automatic CTS control) is independent
of whether the DMA is running or not and thus this section looks wrong or
is at the very least in the wrong place.

Have I misunderstood something?

IIRC, the timing of DMA being enabled and disabled was changed reasonably
recently did that fix the #CTS issue possibly?

Martyn



Test app:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

static struct termios oldterminfo;


void closeserial(int fd)
{
tcsetattr(fd, TCSANOW, );
if (close(fd) < 0)
perror("closeserial()");
}


int openserial(char *devicename)
{
int fd;
struct termios attr;

if ((fd = open(devicename, O_RDWR)) == -1) {
perror("openserial(): open()");
return 0;
}
if (tcgetattr(fd, ) == -1) {
perror("openserial(): tcgetattr()");
return 0;
}
attr = oldterminfo;
attr.c_cflag |= CRTSCTS | CLOCAL;
attr.c_oflag = 0;
if (tcflush(fd, TCIOFLUSH) == -1) {
perror("openserial(): tcflush()");
return 0;
}
if (tcsetattr(fd, TCSANOW, ) == -1) {
perror("initserial(): tcsetattr()");
return 0;
}
return fd;
}


int setRTS(int fd, int level)
{
int status;

if (ioctl(fd, TIOCMGET, ) == -1) {
perror("setRTS(): TIOCMGET");
return 0;
}
if (level)
status |= TIOCM_RTS;
else
status &= ~TIOCM_RTS;
if (ioctl(fd, TIOCMSET, ) == -1) {
perror("setRTS(): TIOCMSET");
return 0;
}
return 1;
}


int main(int argc, char *argv[])
{
int fd;
bool loop = true;
int state = 1;
int got;


fd = openserial(argv[1]);
if (!fd) {
fprintf(stderr, "Error while initializing %s.\n", argv[1]);
return 1;
}


while(loop) {
printf("Switching RTS %s\n", state ? "on" : "off");
setRTS(fd, state);

state = (++state) % 2;

got = getchar();
if (got == 'q')
break;
}
closeserial(fd);
return 0;
}



Re: [PATCH v2 3/6] serial: imx: remove CTSC and CTS handling

2017-09-15 Thread Martyn Welch
Hi

On Wed, Jul 05, 2017 at 03:38:45PM +0200, Uwe Kleine-König wrote:
> Cc += Clemens Gruber + Fabio Estevam
> 
> On Wed, Jul 05, 2017 at 03:07:03PM +0200, Romain Perier wrote:
> > From: Nandor Han 
> > 
> > CTSC and CTS are not related to DMA and might add
> > disruption in some cases.
> > 
> > Signed-off-by: Romain Perier 
> 
> If it was Nandor Han who created this patch, it would be great to get
> his sob. If it was you, drop the From: line above.
> 

This patch was broken out from a larger one written by Nandor, who is
happy for me to add his sob.

> > ---
> >  drivers/tty/serial/imx.c | 5 -
> >  1 file changed, 5 deletions(-)
> > 
> > diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
> > index 5291b86..dd3ebb4 100644
> > --- a/drivers/tty/serial/imx.c
> > +++ b/drivers/tty/serial/imx.c
> > @@ -1249,11 +1249,6 @@ static void imx_disable_dma(struct imx_port *sport)
> > imx_stop_rx_dma(sport);
> > imx_stop_tx_dma(sport);
> >  
> > -   /* clear UCR2 */
> > -   temp = readl(sport->port.membase + UCR2);
> > -   temp &= ~(UCR2_CTSC | UCR2_CTS | UCR2_ATEN);
> > -   writel(temp, sport->port.membase + UCR2);
> > -
> 
> Before this patch imx_disable_dma resulted in the #CTS pin being high
> (inactive).
> 
> Does this qualify as a fix? If so, you should sort this patch to the
> beginning of the series. Did you do test this patch and its effects
> separately?
> 

I've been giving the RTS/CTS lines a bit of a kick with (and without) this
patch and I'm seeing what I'd expect to see on the CTS pin (the Wandboard
I'm using runs this in DCE mode even though it really should be in DTE
mode, hey ho). Using a little test app I've found/modified (listed below),
the CTS line can be (de)asserted whilst the device is open and the line
gets deasserted when the device closes. I have tested this port both when
acting as a console (and thus with DMA turned off) and when not used as a
console, with DMA enabled (confirmed with existing debug in driver).

This matches the behaviour of a FTDI based debug board that I've also
tried (in this case I looked at the RTS line as the device is running as a
DTE).

On my PC the same test app sets the RTS line (the serial port running as a
DTE, 8250_pnp driver) results in the CTS line being set appropriately as
well. It also stays in that state even after the serial device is closed,
this does seem right either but there you go.

With regards to the operation of the CTS/RTS line when twiddling it via
the ioctl, I think the behaviour of the IMX/FTDI is the expected one. Is
that the case?

Which I guess brings us to the lines above.

When running as an RS232 port (i.e. not rs485) the driver is using the
automatic CTSC control based on a rxFIFO watermark unless the state of the
CTS line is explictly set via an ioctl call. As such, unless I'm missing
something, the rxFIFO (and thus the automatic CTS control) is independent
of whether the DMA is running or not and thus this section looks wrong or
is at the very least in the wrong place.

Have I misunderstood something?

IIRC, the timing of DMA being enabled and disabled was changed reasonably
recently did that fix the #CTS issue possibly?

Martyn



Test app:

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

static struct termios oldterminfo;


void closeserial(int fd)
{
tcsetattr(fd, TCSANOW, );
if (close(fd) < 0)
perror("closeserial()");
}


int openserial(char *devicename)
{
int fd;
struct termios attr;

if ((fd = open(devicename, O_RDWR)) == -1) {
perror("openserial(): open()");
return 0;
}
if (tcgetattr(fd, ) == -1) {
perror("openserial(): tcgetattr()");
return 0;
}
attr = oldterminfo;
attr.c_cflag |= CRTSCTS | CLOCAL;
attr.c_oflag = 0;
if (tcflush(fd, TCIOFLUSH) == -1) {
perror("openserial(): tcflush()");
return 0;
}
if (tcsetattr(fd, TCSANOW, ) == -1) {
perror("initserial(): tcsetattr()");
return 0;
}
return fd;
}


int setRTS(int fd, int level)
{
int status;

if (ioctl(fd, TIOCMGET, ) == -1) {
perror("setRTS(): TIOCMGET");
return 0;
}
if (level)
status |= TIOCM_RTS;
else
status &= ~TIOCM_RTS;
if (ioctl(fd, TIOCMSET, ) == -1) {
perror("setRTS(): TIOCMSET");
return 0;
}
return 1;
}


int main(int argc, char *argv[])
{
int fd;
bool loop = true;
int state = 1;
int got;


fd = openserial(argv[1]);
if (!fd) {
fprintf(stderr, "Error while initializing %s.\n", argv[1]);
return 1;
}


while(loop) {
printf("Switching RTS %s\n", state ? "on" : "off");
setRTS(fd, state);

state = (++state) % 2;

got = getchar();
if (got == 'q')
break;
}
closeserial(fd);
return 0;
}



Re: [PATCH v6 2/2] ARM: dts: imx53: Add GE Healthcare PPD

2017-09-13 Thread Martyn Welch
On Fri, 2017-08-18 at 16:53 +0100, Martyn Welch wrote:
> From: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>
> 
> PPD is a product from GE Healthcare to monitor vital biometric signals.
> 
> Signed-off-by: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>
> Signed-off-by: Sebastian Reichel <sebastian.reic...@collabora.co.uk>
> Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
> Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>
> 

Ping.

Any more changes needed?

Martyn

> ---
> 
> Changes since PATCHv5: https://patchwork.kernel.org/patch/9852327/
>  - Model corrected
>  - Using hyphens in node names rather than underscores
>  - Removing redundant "okay" statuses
>  - Improving label and node names
>  - Removing backslashes from brightness-levels
>  - Using defines for input codes
>  - Improve formatting
>  - Added comment for cpu frequency override
>  - Removing / updating obsolete properties nodes and containers
>  - Removing leading zeros from unit-address
>  - ge,achc documented
>  - Remove No_PAD_CTL pinmuxing
> Changes since PATCHv4: https://patchwork.kernel.org/patch/9834733/
>  - actually remove fsl,mode node
>  - more IOMUX configuration corrections
>  - limit CPU frequency to chip max frequency
> Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
>  - licensing modified
>  - manufacturer changed to GE
>  - regulator nodes corrected
>  - backlight node corrected
>  - flags rather than magic numbers used
>  - registers for usbphys added
>  - set up IOMUX configuration correctly
>  - various whitespace corrections
>  - removed unused fsl,mode node
>  - missing unit addresses added
>  - reordered nodes and properties as requested
> Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
>  - drop dma-info property from serial nodes. That property is not
>available in mainline.
> Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
>  - fixed issues raised by Mark
>  - added some missing vendor prefixes
>  - dropped anx9804 nodes (no upstream support/binding)
>  - use proper chip-select for ecspi1.cs0
> 
>  arch/arm/boot/dts/Makefile  |1 +
>  arch/arm/boot/dts/imx53-ppd.dts | 1042 
> +++
>  2 files changed, 1043 insertions(+)
>  create mode 100644 arch/arm/boot/dts/imx53-ppd.dts
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index 4b17f35..7f3dcab 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -342,6 +342,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
>   imx53-ard.dtb \
>   imx53-m53evk.dtb \
>   imx53-mba53.dtb \
> + imx53-ppd.dtb \
>   imx53-qsb.dtb \
>   imx53-qsrb.dtb \
>   imx53-smd.dtb \
> diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
> new file mode 100644
> index 000..cce9594
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx53-ppd.dts
> @@ -0,0 +1,1042 @@
> +/*
> + * Copyright 2014 General Electric Company
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * This file 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.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + * obtaining a copy of this software and associated documentation
> + * files (the "Software"), to deal in the Software without
> + * restriction, including without limitation the rights to use,
> + * copy, modify, merge, publish, distribute, sublicense, and/or
> + * sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following
> + * conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> + * included in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + * OF MERCHANTABILITY, FIT

Re: [PATCH v6 2/2] ARM: dts: imx53: Add GE Healthcare PPD

2017-09-13 Thread Martyn Welch
On Fri, 2017-08-18 at 16:53 +0100, Martyn Welch wrote:
> From: Fabien Lahoudere 
> 
> PPD is a product from GE Healthcare to monitor vital biometric signals.
> 
> Signed-off-by: Fabien Lahoudere 
> Signed-off-by: Sebastian Reichel 
> Signed-off-by: Martyn Welch 
> Reviewed-by: Fabio Estevam 
> 

Ping.

Any more changes needed?

Martyn

> ---
> 
> Changes since PATCHv5: https://patchwork.kernel.org/patch/9852327/
>  - Model corrected
>  - Using hyphens in node names rather than underscores
>  - Removing redundant "okay" statuses
>  - Improving label and node names
>  - Removing backslashes from brightness-levels
>  - Using defines for input codes
>  - Improve formatting
>  - Added comment for cpu frequency override
>  - Removing / updating obsolete properties nodes and containers
>  - Removing leading zeros from unit-address
>  - ge,achc documented
>  - Remove No_PAD_CTL pinmuxing
> Changes since PATCHv4: https://patchwork.kernel.org/patch/9834733/
>  - actually remove fsl,mode node
>  - more IOMUX configuration corrections
>  - limit CPU frequency to chip max frequency
> Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
>  - licensing modified
>  - manufacturer changed to GE
>  - regulator nodes corrected
>  - backlight node corrected
>  - flags rather than magic numbers used
>  - registers for usbphys added
>  - set up IOMUX configuration correctly
>  - various whitespace corrections
>  - removed unused fsl,mode node
>  - missing unit addresses added
>  - reordered nodes and properties as requested
> Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
>  - drop dma-info property from serial nodes. That property is not
>available in mainline.
> Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
>  - fixed issues raised by Mark
>  - added some missing vendor prefixes
>  - dropped anx9804 nodes (no upstream support/binding)
>  - use proper chip-select for ecspi1.cs0
> 
>  arch/arm/boot/dts/Makefile  |1 +
>  arch/arm/boot/dts/imx53-ppd.dts | 1042 
> +++
>  2 files changed, 1043 insertions(+)
>  create mode 100644 arch/arm/boot/dts/imx53-ppd.dts
> 
> diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
> index 4b17f35..7f3dcab 100644
> --- a/arch/arm/boot/dts/Makefile
> +++ b/arch/arm/boot/dts/Makefile
> @@ -342,6 +342,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
>   imx53-ard.dtb \
>   imx53-m53evk.dtb \
>   imx53-mba53.dtb \
> + imx53-ppd.dtb \
>   imx53-qsb.dtb \
>   imx53-qsrb.dtb \
>   imx53-smd.dtb \
> diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
> new file mode 100644
> index 000..cce9594
> --- /dev/null
> +++ b/arch/arm/boot/dts/imx53-ppd.dts
> @@ -0,0 +1,1042 @@
> +/*
> + * Copyright 2014 General Electric Company
> + *
> + * This file is dual-licensed: you can use it either under the terms
> + * of the GPL or the X11 license, at your option. Note that this dual
> + * licensing only applies to this file, and not this project as a
> + * whole.
> + *
> + *  a) This file is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2 as published by the Free Software Foundation.
> + *
> + * This file 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.
> + *
> + * Or, alternatively,
> + *
> + *  b) Permission is hereby granted, free of charge, to any person
> + * obtaining a copy of this software and associated documentation
> + * files (the "Software"), to deal in the Software without
> + * restriction, including without limitation the rights to use,
> + * copy, modify, merge, publish, distribute, sublicense, and/or
> + * sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following
> + * conditions:
> + *
> + * The above copyright notice and this permission notice shall be
> + * included in all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
> + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
> + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
> + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
> + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> + * WHETHE

[GIT PULL] VME Subsystem patches for 4.13-rc7

2017-09-01 Thread Martyn Welch
The following changes since commit 0f9b011d3321ca1079c7a46c18cb1956fbdb7bcb:

  driver core: bus: Fix a potential double free (2017-08-31 18:57:30 +0200)

are available in the git repository at:

  https://gitlab.collabora.com/martyn/linux.git tags/vme-next-4.13-rc7

for you to fetch changes up to 92203389d32f83f71cb1944840af31ffb3a42e6f:

  vme: tsi148: Adjust 14 checks for null pointers (2017-09-01 14:08:46 +0100)


VME Subsystem changes for driver-core-next v4.13-rc7


Markus Elfring (14):
  vme: Delete 11 error messages for a failed memory allocation
  vme: Improve 11 size determinations
  vme: Move an assignment in vme_new_dma_list()
  vme: Adjust 48 checks for null pointers
  vme: Return directly in two functions
  vme: fake: Delete an error message for a failed memory allocation in 
fake_init()
  vme: fake: Improve five size determinations in fake_init()
  vme: fake: Adjust 11 checks for null pointers
  vme: ca91cx42: Delete eight error messages for a failed memory allocation
  vme: ca91cx42: Improve 12 size determinations
  vme: ca91cx42: Adjust 14 checks for null pointers
  vme: tsi148: Delete nine error messages for a failed memory allocation
  vme: tsi148: Improve 17 size determinations
  vme: tsi148: Adjust 14 checks for null pointers

 drivers/vme/bridges/vme_ca91cx42.c |  73 +-
 drivers/vme/bridges/vme_fake.c |  35 +++
 drivers/vme/bridges/vme_tsi148.c   |  83 ++--
 drivers/vme/vme.c  | 194 -
 4 files changed, 157 insertions(+), 228 deletions(-)


[GIT PULL] VME Subsystem patches for 4.13-rc7

2017-09-01 Thread Martyn Welch
The following changes since commit 0f9b011d3321ca1079c7a46c18cb1956fbdb7bcb:

  driver core: bus: Fix a potential double free (2017-08-31 18:57:30 +0200)

are available in the git repository at:

  https://gitlab.collabora.com/martyn/linux.git tags/vme-next-4.13-rc7

for you to fetch changes up to 92203389d32f83f71cb1944840af31ffb3a42e6f:

  vme: tsi148: Adjust 14 checks for null pointers (2017-09-01 14:08:46 +0100)


VME Subsystem changes for driver-core-next v4.13-rc7


Markus Elfring (14):
  vme: Delete 11 error messages for a failed memory allocation
  vme: Improve 11 size determinations
  vme: Move an assignment in vme_new_dma_list()
  vme: Adjust 48 checks for null pointers
  vme: Return directly in two functions
  vme: fake: Delete an error message for a failed memory allocation in 
fake_init()
  vme: fake: Improve five size determinations in fake_init()
  vme: fake: Adjust 11 checks for null pointers
  vme: ca91cx42: Delete eight error messages for a failed memory allocation
  vme: ca91cx42: Improve 12 size determinations
  vme: ca91cx42: Adjust 14 checks for null pointers
  vme: tsi148: Delete nine error messages for a failed memory allocation
  vme: tsi148: Improve 17 size determinations
  vme: tsi148: Adjust 14 checks for null pointers

 drivers/vme/bridges/vme_ca91cx42.c |  73 +-
 drivers/vme/bridges/vme_fake.c |  35 +++
 drivers/vme/bridges/vme_tsi148.c   |  83 ++--
 drivers/vme/vme.c  | 194 -
 4 files changed, 157 insertions(+), 228 deletions(-)


Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-30 Thread Martyn Welch
On 26 August 2017 at 08:00, SF Markus Elfring
 wrote:
>>> @@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
>>> struct pci_device_id *id)
>>>  master_num--;
>>>
>>>  tsi148_device->flush_image =
>>> -kmalloc(sizeof(struct vme_master_resource), 
>>> GFP_KERNEL);
>>> +kmalloc(sizeof(*tsi148_device->flush_image), 
>>> GFP_KERNEL);
>>
>> This line is now a tiny bit too long
>
> Can you eventually tolerate a line length of 81 characters at such a source 
> code place?
>

I think there's some irony here. On the one hand you are submitting
patches that correct coding style issues, on the other you are asking
whether we can ignore the coding style...

>
>> and needs to be broken over two lines.
>
> How would like to achieve this?
>
> * It seems that you would not like to perform such a tweak yourself.
>

To be honest, it is quicker and easier in this instance to do just
that. So that's now done.

Patches now in my testing branch:

https://gitlab.collabora.com/martyn/linux/commits/vme-testing

For future reference:

> * Do you expect a resend for the complete patch series?
>

Unless the maintainer has commented that they have accepted patches x,
y and z, then sending the entire series again is generally the right
thing to do.

> * Will it be sufficient to send another patch only for the requested 
> reformatting
>   of a single line?
>

No, unless the patches have been accepted as-is.

Martyn


Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-30 Thread Martyn Welch
On 26 August 2017 at 08:00, SF Markus Elfring
 wrote:
>>> @@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
>>> struct pci_device_id *id)
>>>  master_num--;
>>>
>>>  tsi148_device->flush_image =
>>> -kmalloc(sizeof(struct vme_master_resource), 
>>> GFP_KERNEL);
>>> +kmalloc(sizeof(*tsi148_device->flush_image), 
>>> GFP_KERNEL);
>>
>> This line is now a tiny bit too long
>
> Can you eventually tolerate a line length of 81 characters at such a source 
> code place?
>

I think there's some irony here. On the one hand you are submitting
patches that correct coding style issues, on the other you are asking
whether we can ignore the coding style...

>
>> and needs to be broken over two lines.
>
> How would like to achieve this?
>
> * It seems that you would not like to perform such a tweak yourself.
>

To be honest, it is quicker and easier in this instance to do just
that. So that's now done.

Patches now in my testing branch:

https://gitlab.collabora.com/martyn/linux/commits/vme-testing

For future reference:

> * Do you expect a resend for the complete patch series?
>

Unless the maintainer has commented that they have accepted patches x,
y and z, then sending the entire series again is generally the right
thing to do.

> * Will it be sufficient to send another patch only for the requested 
> reformatting
>   of a single line?
>

No, unless the patches have been accepted as-is.

Martyn


Re: [PATCH 00/14] VME: Adjustments for several function implementations

2017-08-25 Thread Martyn Welch
On Fri, Aug 25, 2017 at 05:41:13PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 25 Aug 2017 13:15:43 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (14):
>   Delete 11 error messages for a failed memory allocation
>   Improve 11 size determinations
>   Move an assignment in vme_new_dma_list()
>   Adjust 48 checks for null pointers
>   Return directly in two functions
>   fake: Delete an error message for a failed memory allocation in fake_init()
>   fake: Improve five size determinations in fake_init()
>   fake: Adjust 11 checks for null pointers
>   ca91cx42: Delete eight error messages for a failed memory allocation
>   ca91cx42: Improve 12 size determinations
>   ca91cx42: Adjust 14 checks for null pointers
>   tsi148: Delete nine error messages for a failed memory allocation
>   tsi148: Improve 17 size determinations
>   tsi148: Adjust 14 checks for null pointers
> 

Hi Markus,

Thanks for the patches. Other than the minor tweak needed to patch 13,
these are looking good to me.

Martyn

>  drivers/vme/bridges/vme_ca91cx42.c |  73 +-
>  drivers/vme/bridges/vme_fake.c |  35 +++
>  drivers/vme/bridges/vme_tsi148.c   |  82 ++--
>  drivers/vme/vme.c  | 194 
> -
>  4 files changed, 156 insertions(+), 228 deletions(-)
> 
> -- 
> 2.14.0
> 


Re: [PATCH 00/14] VME: Adjustments for several function implementations

2017-08-25 Thread Martyn Welch
On Fri, Aug 25, 2017 at 05:41:13PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring 
> Date: Fri, 25 Aug 2017 13:15:43 +0200
> 
> Several update suggestions were taken into account
> from static source code analysis.
> 
> Markus Elfring (14):
>   Delete 11 error messages for a failed memory allocation
>   Improve 11 size determinations
>   Move an assignment in vme_new_dma_list()
>   Adjust 48 checks for null pointers
>   Return directly in two functions
>   fake: Delete an error message for a failed memory allocation in fake_init()
>   fake: Improve five size determinations in fake_init()
>   fake: Adjust 11 checks for null pointers
>   ca91cx42: Delete eight error messages for a failed memory allocation
>   ca91cx42: Improve 12 size determinations
>   ca91cx42: Adjust 14 checks for null pointers
>   tsi148: Delete nine error messages for a failed memory allocation
>   tsi148: Improve 17 size determinations
>   tsi148: Adjust 14 checks for null pointers
> 

Hi Markus,

Thanks for the patches. Other than the minor tweak needed to patch 13,
these are looking good to me.

Martyn

>  drivers/vme/bridges/vme_ca91cx42.c |  73 +-
>  drivers/vme/bridges/vme_fake.c |  35 +++
>  drivers/vme/bridges/vme_tsi148.c   |  82 ++--
>  drivers/vme/vme.c  | 194 
> -
>  4 files changed, 156 insertions(+), 228 deletions(-)
> 
> -- 
> 2.14.0
> 


Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-25 Thread Martyn Welch
On Fri, Aug 25, 2017 at 06:15:08PM +0200, SF Markus Elfring wrote:



> @@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
> struct pci_device_id *id)
>   master_num--;
>  
>   tsi148_device->flush_image =
> - kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL);
> + kmalloc(sizeof(*tsi148_device->flush_image), 
> GFP_KERNEL);

This line is now a tiny bit too long and needs to be broken over two lines.

Martyn


Re: [PATCH 13/14] vme: tsi148: Improve 17 size determinations

2017-08-25 Thread Martyn Welch
On Fri, Aug 25, 2017 at 06:15:08PM +0200, SF Markus Elfring wrote:



> @@ -2363,5 +2364,5 @@ static int tsi148_probe(struct pci_dev *pdev, const 
> struct pci_device_id *id)
>   master_num--;
>  
>   tsi148_device->flush_image =
> - kmalloc(sizeof(struct vme_master_resource), GFP_KERNEL);
> + kmalloc(sizeof(*tsi148_device->flush_image), 
> GFP_KERNEL);

This line is now a tiny bit too long and needs to be broken over two lines.

Martyn


[PATCH v6 2/2] ARM: dts: imx53: Add GE Healthcare PPD

2017-08-18 Thread Martyn Welch
From: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>

PPD is a product from GE Healthcare to monitor vital biometric signals.

Signed-off-by: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>
Signed-off-by: Sebastian Reichel <sebastian.reic...@collabora.co.uk>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
Reviewed-by: Fabio Estevam <fabio.este...@nxp.com>

---

Changes since PATCHv5: https://patchwork.kernel.org/patch/9852327/
 - Model corrected
 - Using hyphens in node names rather than underscores
 - Removing redundant "okay" statuses
 - Improving label and node names
 - Removing backslashes from brightness-levels
 - Using defines for input codes
 - Improve formatting
 - Added comment for cpu frequency override
 - Removing / updating obsolete properties nodes and containers
 - Removing leading zeros from unit-address
 - ge,achc documented
 - Remove No_PAD_CTL pinmuxing
Changes since PATCHv4: https://patchwork.kernel.org/patch/9834733/
 - actually remove fsl,mode node
 - more IOMUX configuration corrections
 - limit CPU frequency to chip max frequency
Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
 - licensing modified
 - manufacturer changed to GE
 - regulator nodes corrected
 - backlight node corrected
 - flags rather than magic numbers used
 - registers for usbphys added
 - set up IOMUX configuration correctly
 - various whitespace corrections
 - removed unused fsl,mode node
 - missing unit addresses added
 - reordered nodes and properties as requested
Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
 - drop dma-info property from serial nodes. That property is not
   available in mainline.
Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
 - fixed issues raised by Mark
 - added some missing vendor prefixes
 - dropped anx9804 nodes (no upstream support/binding)
 - use proper chip-select for ecspi1.cs0

 arch/arm/boot/dts/Makefile  |1 +
 arch/arm/boot/dts/imx53-ppd.dts | 1042 +++
 2 files changed, 1043 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35..7f3dcab 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -342,6 +342,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
new file mode 100644
index 000..cce9594
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -0,0 +1,1042 @@
+/*
+ * Copyright 2014 General Electric Company
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx53.dtsi"
+#include 
+
+/ {
+   model = "General Electric CS ONE";
+   compatible = "ge,imx53-cpuvo", "fsl,imx53";
+
+   aliases {
+   spi0 = 
+   sp

[PATCH v6 0/2] Add device tree and associated documentation for GE Healthcare PPD

2017-08-18 Thread Martyn Welch
This series adds the device tree for the GE Healthcare PPD and binding
documentation for the ge-achc, as used by the PPD device tree.

Fabien Lahoudere (1):
  ARM: dts: imx53: Add GE Healthcare PPD

Martyn Welch (1):
  dt-bindings: misc: achc: Add device tree binding for GE ACHC

 Documentation/devicetree/bindings/misc/ge-achc.txt |   26 +
 arch/arm/boot/dts/Makefile |1 +
 arch/arm/boot/dts/imx53-ppd.dts| 1042 
 3 files changed, 1069 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/ge-achc.txt
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

-- 
1.8.3.1



[PATCH v6 0/2] Add device tree and associated documentation for GE Healthcare PPD

2017-08-18 Thread Martyn Welch
This series adds the device tree for the GE Healthcare PPD and binding
documentation for the ge-achc, as used by the PPD device tree.

Fabien Lahoudere (1):
  ARM: dts: imx53: Add GE Healthcare PPD

Martyn Welch (1):
  dt-bindings: misc: achc: Add device tree binding for GE ACHC

 Documentation/devicetree/bindings/misc/ge-achc.txt |   26 +
 arch/arm/boot/dts/Makefile |1 +
 arch/arm/boot/dts/imx53-ppd.dts| 1042 
 3 files changed, 1069 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/ge-achc.txt
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

-- 
1.8.3.1



[PATCH v6 2/2] ARM: dts: imx53: Add GE Healthcare PPD

2017-08-18 Thread Martyn Welch
From: Fabien Lahoudere 

PPD is a product from GE Healthcare to monitor vital biometric signals.

Signed-off-by: Fabien Lahoudere 
Signed-off-by: Sebastian Reichel 
Signed-off-by: Martyn Welch 
Reviewed-by: Fabio Estevam 

---

Changes since PATCHv5: https://patchwork.kernel.org/patch/9852327/
 - Model corrected
 - Using hyphens in node names rather than underscores
 - Removing redundant "okay" statuses
 - Improving label and node names
 - Removing backslashes from brightness-levels
 - Using defines for input codes
 - Improve formatting
 - Added comment for cpu frequency override
 - Removing / updating obsolete properties nodes and containers
 - Removing leading zeros from unit-address
 - ge,achc documented
 - Remove No_PAD_CTL pinmuxing
Changes since PATCHv4: https://patchwork.kernel.org/patch/9834733/
 - actually remove fsl,mode node
 - more IOMUX configuration corrections
 - limit CPU frequency to chip max frequency
Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
 - licensing modified
 - manufacturer changed to GE
 - regulator nodes corrected
 - backlight node corrected
 - flags rather than magic numbers used
 - registers for usbphys added
 - set up IOMUX configuration correctly
 - various whitespace corrections
 - removed unused fsl,mode node
 - missing unit addresses added
 - reordered nodes and properties as requested
Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
 - drop dma-info property from serial nodes. That property is not
   available in mainline.
Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
 - fixed issues raised by Mark
 - added some missing vendor prefixes
 - dropped anx9804 nodes (no upstream support/binding)
 - use proper chip-select for ecspi1.cs0

 arch/arm/boot/dts/Makefile  |1 +
 arch/arm/boot/dts/imx53-ppd.dts | 1042 +++
 2 files changed, 1043 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35..7f3dcab 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -342,6 +342,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
new file mode 100644
index 000..cce9594
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -0,0 +1,1042 @@
+/*
+ * Copyright 2014 General Electric Company
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx53.dtsi"
+#include 
+
+/ {
+   model = "General Electric CS ONE";
+   compatible = "ge,imx53-cpuvo", "fsl,imx53";
+
+   aliases {
+   spi0 = 
+   spi1 = 
+   spi2 = 
+   };
+
+   chosen {
+   stdout-path = ":115200n8";
+   };
+
+   memory@7000 {
+   device_type = "memory";
+

[PATCH v6 1/2] dt-bindings: misc: achc: Add device tree binding for GE ACHC

2017-08-18 Thread Martyn Welch
Add Device Tree binding document for GE Healthcare USB Management
Controller (ACHC).

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 Documentation/devicetree/bindings/misc/ge-achc.txt | 26 ++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/ge-achc.txt

diff --git a/Documentation/devicetree/bindings/misc/ge-achc.txt 
b/Documentation/devicetree/bindings/misc/ge-achc.txt
new file mode 100644
index 000..77df94d
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/ge-achc.txt
@@ -0,0 +1,26 @@
+* GE Healthcare USB Management Controller
+
+A device which handles data aquisition from compatible USB based peripherals.
+SPI is used for device management.
+
+Note: This device does not expose the peripherals as USB devices.
+
+Required properties:
+
+- compatible : Should be "ge,achc"
+
+Required SPI properties:
+
+- reg : Should be address of the device chip select within
+  the controller.
+
+- spi-max-frequency : Maximum SPI clocking speed of device in Hz, should be
+  1MHz for the GE ACHC.
+
+Example:
+
+spidev0: spi@0 {
+   compatible = "ge,achc";
+   reg = <0>;
+   spi-max-frequency = <100>;
+};
-- 
1.8.3.1



[PATCH v6 1/2] dt-bindings: misc: achc: Add device tree binding for GE ACHC

2017-08-18 Thread Martyn Welch
Add Device Tree binding document for GE Healthcare USB Management
Controller (ACHC).

Signed-off-by: Martyn Welch 
---
 Documentation/devicetree/bindings/misc/ge-achc.txt | 26 ++
 1 file changed, 26 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/ge-achc.txt

diff --git a/Documentation/devicetree/bindings/misc/ge-achc.txt 
b/Documentation/devicetree/bindings/misc/ge-achc.txt
new file mode 100644
index 000..77df94d
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/ge-achc.txt
@@ -0,0 +1,26 @@
+* GE Healthcare USB Management Controller
+
+A device which handles data aquisition from compatible USB based peripherals.
+SPI is used for device management.
+
+Note: This device does not expose the peripherals as USB devices.
+
+Required properties:
+
+- compatible : Should be "ge,achc"
+
+Required SPI properties:
+
+- reg : Should be address of the device chip select within
+  the controller.
+
+- spi-max-frequency : Maximum SPI clocking speed of device in Hz, should be
+  1MHz for the GE ACHC.
+
+Example:
+
+spidev0: spi@0 {
+   compatible = "ge,achc";
+   reg = <0>;
+   spi-max-frequency = <100>;
+};
-- 
1.8.3.1



[PATCH v5] ARM: dts: imx53: Add GE Healthcare PPD

2017-07-19 Thread Martyn Welch
From: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>

PPD is a product from GE Healthcare to monitor vital biometric signals.

Signed-off-by: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>
Signed-off-by: Sebastian Reichel <sebastian.reic...@collabora.co.uk>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---

Changes since PATCHv4: https://patchwork.kernel.org/patch/9834733/
 - actually remove fsl,mode node
 - more IOMUX configuration corrections
 - limit CPU frequency to chip max frequency
Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
 - licensing modified
 - manufacturer changed to GE
 - regulator nodes corrected
 - backlight node corrected
 - flags rather than magic numbers used
 - registers for usbphys added
 - set up IOMUX configuration correctly
 - various whitespace corrections
 - removed unused fsl,mode node
 - missing unit addresses added
 - reordered nodes and properties as requested
Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
 - drop dma-info property from serial nodes. That property is not
   available in mainline.
Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
 - fixed issues raised by Mark
 - added some missing vendor prefixes
 - dropped anx9804 nodes (no upstream support/binding)
 - use proper chip-select for ecspi1.cs0

 arch/arm/boot/dts/Makefile  |1 +
 arch/arm/boot/dts/imx53-ppd.dts | 1067 +++
 2 files changed, 1068 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35..7f3dcab 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -342,6 +342,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
new file mode 100644
index 000..320026a
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -0,0 +1,1067 @@
+/*
+ * Copyright 2014 General Electric Company
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx53.dtsi"
+
+/ {
+   model = "Freescale i.MX53 CPUV0 PPD rev6";
+   compatible = "ge,imx53-cpuvo", "fsl,imx53";
+
+   aliases {
+   spi0 = 
+   spi1 = 
+   spi2 = 
+   };
+
+   chosen {
+   stdout-path = ":115200n8";
+   };
+
+   memory@7000 {
+   device_type = "memory";
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   cko2_11M: sgtl_clock_cko2 {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <11289600>;
+   };
+
+   sgtlsound: sound {
+   compatible = "fsl,imx53-cpuvo-s

[PATCH v5] ARM: dts: imx53: Add GE Healthcare PPD

2017-07-19 Thread Martyn Welch
From: Fabien Lahoudere 

PPD is a product from GE Healthcare to monitor vital biometric signals.

Signed-off-by: Fabien Lahoudere 
Signed-off-by: Sebastian Reichel 
Signed-off-by: Martyn Welch 
---

Changes since PATCHv4: https://patchwork.kernel.org/patch/9834733/
 - actually remove fsl,mode node
 - more IOMUX configuration corrections
 - limit CPU frequency to chip max frequency
Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
 - licensing modified
 - manufacturer changed to GE
 - regulator nodes corrected
 - backlight node corrected
 - flags rather than magic numbers used
 - registers for usbphys added
 - set up IOMUX configuration correctly
 - various whitespace corrections
 - removed unused fsl,mode node
 - missing unit addresses added
 - reordered nodes and properties as requested
Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
 - drop dma-info property from serial nodes. That property is not
   available in mainline.
Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
 - fixed issues raised by Mark
 - added some missing vendor prefixes
 - dropped anx9804 nodes (no upstream support/binding)
 - use proper chip-select for ecspi1.cs0

 arch/arm/boot/dts/Makefile  |1 +
 arch/arm/boot/dts/imx53-ppd.dts | 1067 +++
 2 files changed, 1068 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 4b17f35..7f3dcab 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -342,6 +342,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
new file mode 100644
index 000..320026a
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -0,0 +1,1067 @@
+/*
+ * Copyright 2014 General Electric Company
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx53.dtsi"
+
+/ {
+   model = "Freescale i.MX53 CPUV0 PPD rev6";
+   compatible = "ge,imx53-cpuvo", "fsl,imx53";
+
+   aliases {
+   spi0 = 
+   spi1 = 
+   spi2 = 
+   };
+
+   chosen {
+   stdout-path = ":115200n8";
+   };
+
+   memory@7000 {
+   device_type = "memory";
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   cko2_11M: sgtl_clock_cko2 {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <11289600>;
+   };
+
+   sgtlsound: sound {
+   compatible = "fsl,imx53-cpuvo-sgtl5000",
+"fsl,imx-audio-sgtl5000";
+   model = "imx53-cpuvo-sgtl5000";
+   ssi-controller = <&

[PATCH v4 1/1] ARM: dts: imx53: Add GE Healthcare PPD

2017-07-11 Thread Martyn Welch
From: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>

PPD is a product from GE Healthcare to monitor vital biometric signals.

Signed-off-by: Fabien Lahoudere <fabien.lahoud...@collabora.co.uk>
Signed-off-by: Sebastian Reichel <sebastian.reic...@collabora.co.uk>
Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---

Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
 - licensing modified
 - manufacturer changed to GE
 - regulator nodes corrected
 - backlight node corrected
 - flags rather than magic numbers used
 - registers for usbphys added
 - set up IOMUX configuration correctly
 - various whitespace corrections
 - removed unused fsl,mode node
 - missing unit addresses added
 - reordered nodes and properties as requested
Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
 - drop dma-info property from serial nodes. That property is not
   available in mainline.
Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
 - fixed issues raised by Mark
 - added some missing vendor prefixes
 - dropped anx9804 nodes (no upstream support/binding)
 - use proper chip-select for ecspi1.cs0

 arch/arm/boot/dts/Makefile  |1 +
 arch/arm/boot/dts/imx53-ppd.dts | 1059 +++
 2 files changed, 1060 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c5e1d9..135ae56 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -340,6 +340,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
new file mode 100644
index 000..0480fa9
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -0,0 +1,1059 @@
+/*
+ * Copyright 2014 General Electric Company
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx53.dtsi"
+
+/ {
+   model = "Freescale i.MX53 CPUV0 PPD rev6";
+   compatible = "ge,imx53-cpuvo", "fsl,imx53";
+
+   aliases {
+   spi0 = 
+   spi1 = 
+   spi2 = 
+   };
+
+   chosen {
+   stdout-path = ":115200n8";
+   };
+
+   memory@7000 {
+   device_type = "memory";
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   cko2_11M: sgtl_clock_cko2 {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <11289600>;
+   };
+
+   sgtlsound: sound {
+   compatible = "fsl,imx53-cpuvo-sgtl5000",
+"fsl,imx-audio-sgtl5000";
+   model = "imx53-cpuvo-sgtl5000";
+   ssi-controller = <>;
+   audio-cod

[PATCH v4 1/1] ARM: dts: imx53: Add GE Healthcare PPD

2017-07-11 Thread Martyn Welch
From: Fabien Lahoudere 

PPD is a product from GE Healthcare to monitor vital biometric signals.

Signed-off-by: Fabien Lahoudere 
Signed-off-by: Sebastian Reichel 
Signed-off-by: Martyn Welch 
---

Changes since PATCHv3: https://patchwork.kernel.org/patch/9819017/
 - licensing modified
 - manufacturer changed to GE
 - regulator nodes corrected
 - backlight node corrected
 - flags rather than magic numbers used
 - registers for usbphys added
 - set up IOMUX configuration correctly
 - various whitespace corrections
 - removed unused fsl,mode node
 - missing unit addresses added
 - reordered nodes and properties as requested
Changes since PATCHv2: https://patchwork.kernel.org/patch/9809681/
 - drop dma-info property from serial nodes. That property is not
   available in mainline.
Changes since PATCHv1: https://patchwork.kernel.org/patch/9265391/
 - fixed issues raised by Mark
 - added some missing vendor prefixes
 - dropped anx9804 nodes (no upstream support/binding)
 - use proper chip-select for ecspi1.cs0

 arch/arm/boot/dts/Makefile  |1 +
 arch/arm/boot/dts/imx53-ppd.dts | 1059 +++
 2 files changed, 1060 insertions(+)
 create mode 100644 arch/arm/boot/dts/imx53-ppd.dts

diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile
index 9c5e1d9..135ae56 100644
--- a/arch/arm/boot/dts/Makefile
+++ b/arch/arm/boot/dts/Makefile
@@ -340,6 +340,7 @@ dtb-$(CONFIG_SOC_IMX53) += \
imx53-ard.dtb \
imx53-m53evk.dtb \
imx53-mba53.dtb \
+   imx53-ppd.dtb \
imx53-qsb.dtb \
imx53-qsrb.dtb \
imx53-smd.dtb \
diff --git a/arch/arm/boot/dts/imx53-ppd.dts b/arch/arm/boot/dts/imx53-ppd.dts
new file mode 100644
index 000..0480fa9
--- /dev/null
+++ b/arch/arm/boot/dts/imx53-ppd.dts
@@ -0,0 +1,1059 @@
+/*
+ * Copyright 2014 General Electric Company
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * This file 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.
+ *
+ * Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "imx53.dtsi"
+
+/ {
+   model = "Freescale i.MX53 CPUV0 PPD rev6";
+   compatible = "ge,imx53-cpuvo", "fsl,imx53";
+
+   aliases {
+   spi0 = 
+   spi1 = 
+   spi2 = 
+   };
+
+   chosen {
+   stdout-path = ":115200n8";
+   };
+
+   memory@7000 {
+   device_type = "memory";
+   reg = <0x7000 0x2000>,
+ <0xb000 0x2000>;
+   };
+
+   cko2_11M: sgtl_clock_cko2 {
+   compatible = "fixed-clock";
+   #clock-cells = <0>;
+   clock-frequency = <11289600>;
+   };
+
+   sgtlsound: sound {
+   compatible = "fsl,imx53-cpuvo-sgtl5000",
+"fsl,imx-audio-sgtl5000";
+   model = "imx53-cpuvo-sgtl5000";
+   ssi-controller = <>;
+   audio-codec = <>;
+   audio-routing =
+   "MIC_IN", "Mic Jack",
+   &q

Re: [PATCH] HID: Accutouch: Add driver for ELO Accutouch 2216 USB Touchscreens

2017-03-02 Thread Martyn Welch
On Wed, Mar 01, 2017 at 02:30:31PM +0100, Benjamin Tissoires wrote:
> Hi,
> 
> On Feb 28 2017 or thereabouts, Martyn Welch wrote:
> > This patch has been sitting on the list for about 2 weeks. Is there
> > anything wrong with this patch?
> 
> The only wrong thing with the patch (I haven't started reviewing it yet)
> is the timing. It was sent shortly before or at the time of the merge
> window, where Jiri doesn't want to take new patches in, especially if
> they add new drivers. For my side, I wasn't able to do much upstream
> work for 3 weeks for personal reasons, urgent stuffs at work and time
> off. I'll try to review it today or tomorrow, but don't expect Jiri to
> take it until the merge window is closed (this Sunday normally, but you
> should probably give him some time to process all the backlog from those
> past 3 weeks).
> 

Thanks for the info Benjamin, much appreciated.

Martyn

> Cheers,
> Benjamin
> 
> > 
> > Thanks,
> > 
> > Martyn
> > 
> > On Tue, Feb 14, 2017 at 02:17:56PM +, Martyn Welch wrote:
> > > The Accutouch 2216 is reporting BTN_LEFT/BTN_MOUSE rather than BTM_TOUCH
> > > in it's capabilities, which is what user space expects a touchscreen
> > > device to report. This is causing udev to consider the device to be a
> > > "VMware's USB mouse" rather than as a touchscreen, which results in a
> > > mouse cursor being displayed in Weston.
> > > 
> > > This patch adds a special driver for the device to correct the
> > > capabilities reported.
> > > 
> > > Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
> > > ---
> > >  drivers/hid/Kconfig | 12 +++
> > >  drivers/hid/Makefile|  1 +
> > >  drivers/hid/hid-accutouch.c | 52 
> > > +
> > >  drivers/hid/hid-core.c  |  1 +
> > >  drivers/hid/hid-ids.h   |  1 +
> > >  5 files changed, 67 insertions(+)
> > >  create mode 100644 drivers/hid/hid-accutouch.c
> > > 
> > > diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> > > index 4070b73..ba0d17a 100644
> > > --- a/drivers/hid/Kconfig
> > > +++ b/drivers/hid/Kconfig
> > > @@ -98,6 +98,18 @@ config HID_A4TECH
> > >   ---help---
> > >   Support for A4 tech X5 and WOP-35 / Trust 450L mice.
> > >  
> > > +config HID_ACCUTOUCH
> > > + tristate "Accutouch touch device"
> > > + depends on USB_HID
> > > + ---help---
> > > +   This selects a driver for the Accutouch 2216 touch controller.
> > > +
> > > +   The driver works around a problem in the reported device capabilities
> > > +   which causes userspace to detect the device as a mouse rather than
> > > +  a touchscreen.
> > > +
> > > +   Say Y here if you have a Accutouch 2216 touch controller.
> > > +
> > >  config HID_ACRUX
> > >   tristate "ACRUX game controller support"
> > >   depends on HID
> > > diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> > > index 4d111f2..48be3ed 100644
> > > --- a/drivers/hid/Makefile
> > > +++ b/drivers/hid/Makefile
> > > @@ -21,6 +21,7 @@ hid-wiimote-y   := hid-wiimote-core.o 
> > > hid-wiimote-modules.o
> > >  hid-wiimote-$(CONFIG_DEBUG_FS)   += hid-wiimote-debug.o
> > >  
> > >  obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
> > > +obj-$(CONFIG_HID_ACCUTOUCH)  += hid-accutouch.o
> > >  obj-$(CONFIG_HID_ALPS)   += hid-alps.o
> > >  obj-$(CONFIG_HID_ACRUX)  += hid-axff.o
> > >  obj-$(CONFIG_HID_APPLE)  += hid-apple.o
> > > diff --git a/drivers/hid/hid-accutouch.c b/drivers/hid/hid-accutouch.c
> > > new file mode 100644
> > > index 000..4e28716
> > > --- /dev/null
> > > +++ b/drivers/hid/hid-accutouch.c
> > > @@ -0,0 +1,52 @@
> > > +/*
> > > + * HID driver for Elo Accutouch touchscreens
> > > + *
> > > + * Copyright (c) 2016, Collabora Ltd.
> > > + * Copyright (c) 2016, General Electric Company
> > > + *
> > > + * based on hid-penmount.c
> > > + *  Copyright (c) 2014 Christian Gmeiner  
> > > gmail.com>
> > > + */
> > > +
> > > +/*
> > > + * 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; e

Re: [PATCH] HID: Accutouch: Add driver for ELO Accutouch 2216 USB Touchscreens

2017-03-02 Thread Martyn Welch
On Wed, Mar 01, 2017 at 02:30:31PM +0100, Benjamin Tissoires wrote:
> Hi,
> 
> On Feb 28 2017 or thereabouts, Martyn Welch wrote:
> > This patch has been sitting on the list for about 2 weeks. Is there
> > anything wrong with this patch?
> 
> The only wrong thing with the patch (I haven't started reviewing it yet)
> is the timing. It was sent shortly before or at the time of the merge
> window, where Jiri doesn't want to take new patches in, especially if
> they add new drivers. For my side, I wasn't able to do much upstream
> work for 3 weeks for personal reasons, urgent stuffs at work and time
> off. I'll try to review it today or tomorrow, but don't expect Jiri to
> take it until the merge window is closed (this Sunday normally, but you
> should probably give him some time to process all the backlog from those
> past 3 weeks).
> 

Thanks for the info Benjamin, much appreciated.

Martyn

> Cheers,
> Benjamin
> 
> > 
> > Thanks,
> > 
> > Martyn
> > 
> > On Tue, Feb 14, 2017 at 02:17:56PM +, Martyn Welch wrote:
> > > The Accutouch 2216 is reporting BTN_LEFT/BTN_MOUSE rather than BTM_TOUCH
> > > in it's capabilities, which is what user space expects a touchscreen
> > > device to report. This is causing udev to consider the device to be a
> > > "VMware's USB mouse" rather than as a touchscreen, which results in a
> > > mouse cursor being displayed in Weston.
> > > 
> > > This patch adds a special driver for the device to correct the
> > > capabilities reported.
> > > 
> > > Signed-off-by: Martyn Welch 
> > > ---
> > >  drivers/hid/Kconfig | 12 +++
> > >  drivers/hid/Makefile|  1 +
> > >  drivers/hid/hid-accutouch.c | 52 
> > > +
> > >  drivers/hid/hid-core.c  |  1 +
> > >  drivers/hid/hid-ids.h   |  1 +
> > >  5 files changed, 67 insertions(+)
> > >  create mode 100644 drivers/hid/hid-accutouch.c
> > > 
> > > diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> > > index 4070b73..ba0d17a 100644
> > > --- a/drivers/hid/Kconfig
> > > +++ b/drivers/hid/Kconfig
> > > @@ -98,6 +98,18 @@ config HID_A4TECH
> > >   ---help---
> > >   Support for A4 tech X5 and WOP-35 / Trust 450L mice.
> > >  
> > > +config HID_ACCUTOUCH
> > > + tristate "Accutouch touch device"
> > > + depends on USB_HID
> > > + ---help---
> > > +   This selects a driver for the Accutouch 2216 touch controller.
> > > +
> > > +   The driver works around a problem in the reported device capabilities
> > > +   which causes userspace to detect the device as a mouse rather than
> > > +  a touchscreen.
> > > +
> > > +   Say Y here if you have a Accutouch 2216 touch controller.
> > > +
> > >  config HID_ACRUX
> > >   tristate "ACRUX game controller support"
> > >   depends on HID
> > > diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> > > index 4d111f2..48be3ed 100644
> > > --- a/drivers/hid/Makefile
> > > +++ b/drivers/hid/Makefile
> > > @@ -21,6 +21,7 @@ hid-wiimote-y   := hid-wiimote-core.o 
> > > hid-wiimote-modules.o
> > >  hid-wiimote-$(CONFIG_DEBUG_FS)   += hid-wiimote-debug.o
> > >  
> > >  obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
> > > +obj-$(CONFIG_HID_ACCUTOUCH)  += hid-accutouch.o
> > >  obj-$(CONFIG_HID_ALPS)   += hid-alps.o
> > >  obj-$(CONFIG_HID_ACRUX)  += hid-axff.o
> > >  obj-$(CONFIG_HID_APPLE)  += hid-apple.o
> > > diff --git a/drivers/hid/hid-accutouch.c b/drivers/hid/hid-accutouch.c
> > > new file mode 100644
> > > index 000..4e28716
> > > --- /dev/null
> > > +++ b/drivers/hid/hid-accutouch.c
> > > @@ -0,0 +1,52 @@
> > > +/*
> > > + * HID driver for Elo Accutouch touchscreens
> > > + *
> > > + * Copyright (c) 2016, Collabora Ltd.
> > > + * Copyright (c) 2016, General Electric Company
> > > + *
> > > + * based on hid-penmount.c
> > > + *  Copyright (c) 2014 Christian Gmeiner  
> > > gmail.com>
> > > + */
> > > +
> > > +/*
> > > + * 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 

Re: [PATCH] HID: Accutouch: Add driver for ELO Accutouch 2216 USB Touchscreens

2017-02-28 Thread Martyn Welch
This patch has been sitting on the list for about 2 weeks. Is there
anything wrong with this patch?

Thanks,

Martyn

On Tue, Feb 14, 2017 at 02:17:56PM +, Martyn Welch wrote:
> The Accutouch 2216 is reporting BTN_LEFT/BTN_MOUSE rather than BTM_TOUCH
> in it's capabilities, which is what user space expects a touchscreen
> device to report. This is causing udev to consider the device to be a
> "VMware's USB mouse" rather than as a touchscreen, which results in a
> mouse cursor being displayed in Weston.
> 
> This patch adds a special driver for the device to correct the
> capabilities reported.
> 
> Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
> ---
>  drivers/hid/Kconfig | 12 +++
>  drivers/hid/Makefile|  1 +
>  drivers/hid/hid-accutouch.c | 52 
> +
>  drivers/hid/hid-core.c  |  1 +
>  drivers/hid/hid-ids.h   |  1 +
>  5 files changed, 67 insertions(+)
>  create mode 100644 drivers/hid/hid-accutouch.c
> 
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index 4070b73..ba0d17a 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -98,6 +98,18 @@ config HID_A4TECH
>   ---help---
>   Support for A4 tech X5 and WOP-35 / Trust 450L mice.
>  
> +config HID_ACCUTOUCH
> + tristate "Accutouch touch device"
> + depends on USB_HID
> + ---help---
> +   This selects a driver for the Accutouch 2216 touch controller.
> +
> +   The driver works around a problem in the reported device capabilities
> +   which causes userspace to detect the device as a mouse rather than
> +  a touchscreen.
> +
> +   Say Y here if you have a Accutouch 2216 touch controller.
> +
>  config HID_ACRUX
>   tristate "ACRUX game controller support"
>   depends on HID
> diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> index 4d111f2..48be3ed 100644
> --- a/drivers/hid/Makefile
> +++ b/drivers/hid/Makefile
> @@ -21,6 +21,7 @@ hid-wiimote-y   := hid-wiimote-core.o 
> hid-wiimote-modules.o
>  hid-wiimote-$(CONFIG_DEBUG_FS)   += hid-wiimote-debug.o
>  
>  obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
> +obj-$(CONFIG_HID_ACCUTOUCH)  += hid-accutouch.o
>  obj-$(CONFIG_HID_ALPS)   += hid-alps.o
>  obj-$(CONFIG_HID_ACRUX)  += hid-axff.o
>  obj-$(CONFIG_HID_APPLE)  += hid-apple.o
> diff --git a/drivers/hid/hid-accutouch.c b/drivers/hid/hid-accutouch.c
> new file mode 100644
> index 000..4e28716
> --- /dev/null
> +++ b/drivers/hid/hid-accutouch.c
> @@ -0,0 +1,52 @@
> +/*
> + * HID driver for Elo Accutouch touchscreens
> + *
> + * Copyright (c) 2016, Collabora Ltd.
> + * Copyright (c) 2016, General Electric Company
> + *
> + * based on hid-penmount.c
> + *  Copyright (c) 2014 Christian Gmeiner  gmail.com>
> + */
> +
> +/*
> + * 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 
> +#include 
> +#include "hid-ids.h"
> +
> +static int accutouch_input_mapping(struct hid_device *hdev,
> +struct hid_input *hi,
> +struct hid_field *field,
> +struct hid_usage *usage,
> +unsigned long **bit, int *max)
> +{
> + if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) {
> + hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> +static const struct hid_device_id accutouch_devices[] = {
> + { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
> + { }
> +};
> +MODULE_DEVICE_TABLE(hid, accutouch_devices);
> +
> +static struct hid_driver accutouch_driver = {
> + .name = "hid-accutouch",
> + .id_table = accutouch_devices,
> + .input_mapping = accutouch_input_mapping,
> +};
> +
> +module_hid_driver(accutouch_driver);
> +
> +MODULE_AUTHOR("Martyn Welch <martyn.we...@collabora.co.uk");
> +MODULE_DESCRIPTION("Elo Accutouch HID TouchScreen driver");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index ea36b55..b697491 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1893,6 +1893,7 @@ void hid_disconnect(struct hid_device *hdev)
>   { HID_BLUETOOTH_DEV

Re: [PATCH] HID: Accutouch: Add driver for ELO Accutouch 2216 USB Touchscreens

2017-02-28 Thread Martyn Welch
This patch has been sitting on the list for about 2 weeks. Is there
anything wrong with this patch?

Thanks,

Martyn

On Tue, Feb 14, 2017 at 02:17:56PM +, Martyn Welch wrote:
> The Accutouch 2216 is reporting BTN_LEFT/BTN_MOUSE rather than BTM_TOUCH
> in it's capabilities, which is what user space expects a touchscreen
> device to report. This is causing udev to consider the device to be a
> "VMware's USB mouse" rather than as a touchscreen, which results in a
> mouse cursor being displayed in Weston.
> 
> This patch adds a special driver for the device to correct the
> capabilities reported.
> 
> Signed-off-by: Martyn Welch 
> ---
>  drivers/hid/Kconfig | 12 +++
>  drivers/hid/Makefile|  1 +
>  drivers/hid/hid-accutouch.c | 52 
> +
>  drivers/hid/hid-core.c  |  1 +
>  drivers/hid/hid-ids.h   |  1 +
>  5 files changed, 67 insertions(+)
>  create mode 100644 drivers/hid/hid-accutouch.c
> 
> diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
> index 4070b73..ba0d17a 100644
> --- a/drivers/hid/Kconfig
> +++ b/drivers/hid/Kconfig
> @@ -98,6 +98,18 @@ config HID_A4TECH
>   ---help---
>   Support for A4 tech X5 and WOP-35 / Trust 450L mice.
>  
> +config HID_ACCUTOUCH
> + tristate "Accutouch touch device"
> + depends on USB_HID
> + ---help---
> +   This selects a driver for the Accutouch 2216 touch controller.
> +
> +   The driver works around a problem in the reported device capabilities
> +   which causes userspace to detect the device as a mouse rather than
> +  a touchscreen.
> +
> +   Say Y here if you have a Accutouch 2216 touch controller.
> +
>  config HID_ACRUX
>   tristate "ACRUX game controller support"
>   depends on HID
> diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
> index 4d111f2..48be3ed 100644
> --- a/drivers/hid/Makefile
> +++ b/drivers/hid/Makefile
> @@ -21,6 +21,7 @@ hid-wiimote-y   := hid-wiimote-core.o 
> hid-wiimote-modules.o
>  hid-wiimote-$(CONFIG_DEBUG_FS)   += hid-wiimote-debug.o
>  
>  obj-$(CONFIG_HID_A4TECH) += hid-a4tech.o
> +obj-$(CONFIG_HID_ACCUTOUCH)  += hid-accutouch.o
>  obj-$(CONFIG_HID_ALPS)   += hid-alps.o
>  obj-$(CONFIG_HID_ACRUX)  += hid-axff.o
>  obj-$(CONFIG_HID_APPLE)  += hid-apple.o
> diff --git a/drivers/hid/hid-accutouch.c b/drivers/hid/hid-accutouch.c
> new file mode 100644
> index 000..4e28716
> --- /dev/null
> +++ b/drivers/hid/hid-accutouch.c
> @@ -0,0 +1,52 @@
> +/*
> + * HID driver for Elo Accutouch touchscreens
> + *
> + * Copyright (c) 2016, Collabora Ltd.
> + * Copyright (c) 2016, General Electric Company
> + *
> + * based on hid-penmount.c
> + *  Copyright (c) 2014 Christian Gmeiner  gmail.com>
> + */
> +
> +/*
> + * 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 
> +#include 
> +#include "hid-ids.h"
> +
> +static int accutouch_input_mapping(struct hid_device *hdev,
> +struct hid_input *hi,
> +struct hid_field *field,
> +struct hid_usage *usage,
> +unsigned long **bit, int *max)
> +{
> + if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) {
> + hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
> + return 1;
> + }
> +
> + return 0;
> +}
> +
> +static const struct hid_device_id accutouch_devices[] = {
> + { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
> + { }
> +};
> +MODULE_DEVICE_TABLE(hid, accutouch_devices);
> +
> +static struct hid_driver accutouch_driver = {
> + .name = "hid-accutouch",
> + .id_table = accutouch_devices,
> + .input_mapping = accutouch_input_mapping,
> +};
> +
> +module_hid_driver(accutouch_driver);
> +
> +MODULE_AUTHOR("Martyn Welch  +MODULE_DESCRIPTION("Elo Accutouch HID TouchScreen driver");
> +MODULE_LICENSE("GPL");
> diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
> index ea36b55..b697491 100644
> --- a/drivers/hid/hid-core.c
> +++ b/drivers/hid/hid-core.c
> @@ -1893,6 +1893,7 @@ void hid_disconnect(struct hid_device *hdev)
>   { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, 
> USB_DEVICE_ID_ELECOM_BM084) },
>   { HID_USB_DEV

[PATCH] HID: Accutouch: Add driver for ELO Accutouch 2216 USB Touchscreens

2017-02-14 Thread Martyn Welch
The Accutouch 2216 is reporting BTN_LEFT/BTN_MOUSE rather than BTM_TOUCH
in it's capabilities, which is what user space expects a touchscreen
device to report. This is causing udev to consider the device to be a
"VMware's USB mouse" rather than as a touchscreen, which results in a
mouse cursor being displayed in Weston.

This patch adds a special driver for the device to correct the
capabilities reported.

Signed-off-by: Martyn Welch <martyn.we...@collabora.co.uk>
---
 drivers/hid/Kconfig | 12 +++
 drivers/hid/Makefile|  1 +
 drivers/hid/hid-accutouch.c | 52 +
 drivers/hid/hid-core.c  |  1 +
 drivers/hid/hid-ids.h   |  1 +
 5 files changed, 67 insertions(+)
 create mode 100644 drivers/hid/hid-accutouch.c

diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 4070b73..ba0d17a 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -98,6 +98,18 @@ config HID_A4TECH
---help---
Support for A4 tech X5 and WOP-35 / Trust 450L mice.
 
+config HID_ACCUTOUCH
+   tristate "Accutouch touch device"
+   depends on USB_HID
+   ---help---
+ This selects a driver for the Accutouch 2216 touch controller.
+
+ The driver works around a problem in the reported device capabilities
+ which causes userspace to detect the device as a mouse rather than
+  a touchscreen.
+
+ Say Y here if you have a Accutouch 2216 touch controller.
+
 config HID_ACRUX
tristate "ACRUX game controller support"
depends on HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 4d111f2..48be3ed 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -21,6 +21,7 @@ hid-wiimote-y := hid-wiimote-core.o 
hid-wiimote-modules.o
 hid-wiimote-$(CONFIG_DEBUG_FS) += hid-wiimote-debug.o
 
 obj-$(CONFIG_HID_A4TECH)   += hid-a4tech.o
+obj-$(CONFIG_HID_ACCUTOUCH)+= hid-accutouch.o
 obj-$(CONFIG_HID_ALPS) += hid-alps.o
 obj-$(CONFIG_HID_ACRUX)+= hid-axff.o
 obj-$(CONFIG_HID_APPLE)+= hid-apple.o
diff --git a/drivers/hid/hid-accutouch.c b/drivers/hid/hid-accutouch.c
new file mode 100644
index 000..4e28716
--- /dev/null
+++ b/drivers/hid/hid-accutouch.c
@@ -0,0 +1,52 @@
+/*
+ * HID driver for Elo Accutouch touchscreens
+ *
+ * Copyright (c) 2016, Collabora Ltd.
+ * Copyright (c) 2016, General Electric Company
+ *
+ * based on hid-penmount.c
+ *  Copyright (c) 2014 Christian Gmeiner  gmail.com>
+ */
+
+/*
+ * 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 
+#include 
+#include "hid-ids.h"
+
+static int accutouch_input_mapping(struct hid_device *hdev,
+  struct hid_input *hi,
+  struct hid_field *field,
+  struct hid_usage *usage,
+  unsigned long **bit, int *max)
+{
+   if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) {
+   hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
+   return 1;
+   }
+
+   return 0;
+}
+
+static const struct hid_device_id accutouch_devices[] = {
+   { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
+   { }
+};
+MODULE_DEVICE_TABLE(hid, accutouch_devices);
+
+static struct hid_driver accutouch_driver = {
+   .name = "hid-accutouch",
+   .id_table = accutouch_devices,
+   .input_mapping = accutouch_input_mapping,
+};
+
+module_hid_driver(accutouch_driver);
+
+MODULE_AUTHOR("Martyn Welch <martyn.we...@collabora.co.uk");
+MODULE_DESCRIPTION("Elo Accutouch HID TouchScreen driver");
+MODULE_LICENSE("GPL");
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index ea36b55..b697491 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1893,6 +1893,7 @@ void hid_disconnect(struct hid_device *hdev)
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, 
USB_DEVICE_ID_ELECOM_BM084) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
{ HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) },
+   { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
{ HID_USB_DEVICE(USB_VENDOR_ID_EMS, 
USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
{ HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
{ HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, 
USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 350accf..9472ef2 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -362,6 +362,7 @@
 #define USB_VENDOR_ID_ELO  0x04E7
 #d

  1   2   3   >