Re: [U-Boot] [PATCH 2/4] i2c: rcar_i2c: Add DM and DT capable I2C driver

2018-05-10 Thread Heiko Schocher

Hello Marek,

Am 01.05.2018 um 09:03 schrieb Marek Vasut:

Add derivative of the rcar_i2c driver which is capable of
probing itself from DM and uses DT.

Signed-off-by: Marek Vasut 
Cc: Heiko Schocher 
Cc: Nobuhiro Iwamatsu 
---
  drivers/i2c/Kconfig|   6 +
  drivers/i2c/Makefile   |   1 +
  drivers/i2c/rcar_i2c.c | 355 +
  3 files changed, 362 insertions(+)
  create mode 100644 drivers/i2c/rcar_i2c.c


I fixed patch 1/4 and tried to apply this patch, but checkpatch says:

--2018-05-10 09:16:48--  http://patchwork.ozlabs.org/patch/906952/mbox
Auflösen des Hostnamens patchwork.ozlabs.org (patchwork.ozlabs.org)… 
203.11.71.1, 2401:3900:2:1::2
Verbindungsaufbau zu patchwork.ozlabs.org 
(patchwork.ozlabs.org)|203.11.71.1|:80 … verbunden.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 301 Moved Permanently
Platz: /patch/906952/mbox/ [folgend]
--2018-05-10 09:16:49--  http://patchwork.ozlabs.org/patch/906952/mbox/
Wiederverwendung der bestehenden Verbindung zu patchwork.ozlabs.org:80.
HTTP-Anforderung gesendet, auf Antwort wird gewartet … 200 OK
Länge: nicht spezifiziert [text/plain]
Wird in »mbox« gespeichert.

mbox  [ <=> 
]  11,38K  --.-KB/sin 0,01s


2018-05-10 09:16:50 (933 KB/s) - »mbox« gespeichert [11653]

WARNING: please write a paragraph that describes the config symbol fully
#37: FILE: drivers/i2c/Kconfig:342:
+config SYS_I2C_RCAR_I2C

WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#59:
new file mode 100644

WARNING: Missing or malformed SPDX-License-Identifier tag in line 1
#64: FILE: drivers/i2c/rcar_i2c.c:1:
+/*

CHECK: Blank lines aren't necessary after an open brace '{'
#214: FILE: drivers/i2c/rcar_i2c.c:151:
+   for (i = 0; i < msg->len; i++) {
+

total: 0 errors, 3 warnings, 1 checks, 374 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
  mechanically convert to the typical style using --fix or --fix-inplace.

mbox has style problems, please review.

NOTE: Ignored message types: COMPLEX_MACRO CONSIDER_KSTRTO MINMAX MULTISTATEMENT_MACRO_USE_DO_WHILE 
NETWORKING_BLOCK_COMMENT_STYLE PREFER_ETHER_ADDR_COPY USLEEP_RANGE


NOTE: If any of the errors are false positives, please report
  them to the maintainer, see CHECKPATCH in MAINTAINERS.
Wende an: i2c: rcar_i2c: Add DM and DT capable I2C driver

Coukd you please send a rebased version of the patchset?

Thanks!

Beside of this, you can add my to patch 1 and 2:

Reviewed-by: Heiko Schocher 

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 2/4] i2c: rcar_i2c: Add DM and DT capable I2C driver

2018-05-01 Thread Marek Vasut
Add derivative of the rcar_i2c driver which is capable of
probing itself from DM and uses DT.

Signed-off-by: Marek Vasut 
Cc: Heiko Schocher 
Cc: Nobuhiro Iwamatsu 
---
 drivers/i2c/Kconfig|   6 +
 drivers/i2c/Makefile   |   1 +
 drivers/i2c/rcar_i2c.c | 355 +
 3 files changed, 362 insertions(+)
 create mode 100644 drivers/i2c/rcar_i2c.c

diff --git a/drivers/i2c/Kconfig b/drivers/i2c/Kconfig
index 7fb201d8e6..5eceab9ea8 100644
--- a/drivers/i2c/Kconfig
+++ b/drivers/i2c/Kconfig
@@ -339,6 +339,12 @@ config SYS_OMAP24_I2C_SPEED
  OMAP24xx Slave speed channel 0
 endif
 
+config SYS_I2C_RCAR_I2C
+   bool "Renesas RCar I2C driver"
+   depends on (RCAR_GEN3 || RCAR_GEN2) && DM_I2C
+   help
+ Support for Renesas RCar I2C controller.
+
 config SYS_I2C_RCAR_IIC
bool "Renesas RCar Gen3 IIC driver"
depends on (RCAR_GEN3 || RCAR_GEN2) && DM_I2C
diff --git a/drivers/i2c/Makefile b/drivers/i2c/Makefile
index 4a6e06fbc5..4e9f233cda 100644
--- a/drivers/i2c/Makefile
+++ b/drivers/i2c/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_SYS_I2C_MVTWSI) += mvtwsi.o
 obj-$(CONFIG_SYS_I2C_MXC) += mxc_i2c.o
 obj-$(CONFIG_SYS_I2C_MXS) += mxs_i2c.o
 obj-$(CONFIG_SYS_I2C_OMAP24XX) += omap24xx_i2c.o
+obj-$(CONFIG_SYS_I2C_RCAR_I2C) += rcar_i2c.o
 obj-$(CONFIG_SYS_I2C_RCAR_IIC) += rcar_iic.o
 obj-$(CONFIG_SYS_I2C_ROCKCHIP) += rk_i2c.o
 obj-$(CONFIG_SYS_I2C_S3C24X0) += s3c24x0_i2c.o exynos_hs_i2c.o
diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
new file mode 100644
index 00..6010ccde61
--- /dev/null
+++ b/drivers/i2c/rcar_i2c.c
@@ -0,0 +1,355 @@
+/*
+ * drivers/i2c/rcar_i2c.c
+ *
+ * Copyright (C) 2018 Marek Vasut 
+ *
+ * Clock configuration based on Linux i2c-rcar.c:
+ * Copyright (C) 2014-15 Wolfram Sang 
+ * Copyright (C) 2011-2015 Renesas Electronics Corporation
+ * Copyright (C) 2012-14 Renesas Solutions Corp.
+ *   Kuninori Morimoto 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define RCAR_I2C_ICSCR 0x00
+#define RCAR_I2C_ICMCR 0x04
+#define RCAR_I2C_ICMCR_MDBSBIT(7)
+#define RCAR_I2C_ICMCR_FSCLBIT(6)
+#define RCAR_I2C_ICMCR_FSDABIT(5)
+#define RCAR_I2C_ICMCR_OBPCBIT(4)
+#define RCAR_I2C_ICMCR_MIE BIT(3)
+#define RCAR_I2C_ICMCR_TSBEBIT(2)
+#define RCAR_I2C_ICMCR_FSB BIT(1)
+#define RCAR_I2C_ICMCR_ESG BIT(0)
+#define RCAR_I2C_ICSSR 0x08
+#define RCAR_I2C_ICMSR 0x0c
+#define RCAR_I2C_ICMSR_MASK0x7f
+#define RCAR_I2C_ICMSR_MNR BIT(6)
+#define RCAR_I2C_ICMSR_MAL BIT(5)
+#define RCAR_I2C_ICMSR_MST BIT(4)
+#define RCAR_I2C_ICMSR_MDE BIT(3)
+#define RCAR_I2C_ICMSR_MDT BIT(2)
+#define RCAR_I2C_ICMSR_MDR BIT(1)
+#define RCAR_I2C_ICMSR_MAT BIT(0)
+#define RCAR_I2C_ICSIER0x10
+#define RCAR_I2C_ICMIER0x14
+#define RCAR_I2C_ICCCR 0x18
+#define RCAR_I2C_ICCCR_SCGD_OFF3
+#define RCAR_I2C_ICSAR 0x1c
+#define RCAR_I2C_ICMAR 0x20
+#define RCAR_I2C_ICRXD_ICTXD   0x24
+
+struct rcar_i2c_priv {
+   void __iomem*base;
+   struct clk  clk;
+   u32 intdelay;
+   u32 icccr;
+};
+
+static int rcar_i2c_finish(struct udevice *dev)
+{
+   struct rcar_i2c_priv *priv = dev_get_priv(dev);
+   int ret;
+
+   ret = wait_for_bit_le32(priv->base + RCAR_I2C_ICMSR, RCAR_I2C_ICMSR_MST,
+   true, 10, true);
+
+   writel(0, priv->base + RCAR_I2C_ICSSR);
+   writel(0, priv->base + RCAR_I2C_ICMSR);
+   writel(0, priv->base + RCAR_I2C_ICMCR);
+
+   return ret;
+}
+
+static void rcar_i2c_recover(struct udevice *dev)
+{
+   struct rcar_i2c_priv *priv = dev_get_priv(dev);
+   u32 mcr = RCAR_I2C_ICMCR_MDBS | RCAR_I2C_ICMCR_OBPC;
+   u32 mcra = mcr | RCAR_I2C_ICMCR_FSDA;
+   int i;
+
+   /* Send 9 SCL pulses */
+   for (i = 0; i < 9; i++) {
+   writel(mcra | RCAR_I2C_ICMCR_FSCL, priv->base + RCAR_I2C_ICMCR);
+   udelay(5);
+   writel(mcra, priv->base + RCAR_I2C_ICMCR);
+   udelay(5);
+   }
+
+   /* Send stop condition */
+   udelay(5);
+   writel(mcra, priv->base + RCAR_I2C_ICMCR);
+   udelay(5);
+   writel(mcr, priv->base + RCAR_I2C_ICMCR);
+   udelay(5);
+   writel(mcr | RCAR_I2C_ICMCR_FSCL, priv->base + RCAR_I2C_ICMCR);
+   udelay(5);
+   writel(mcra | RCAR_I2C_ICMCR_FSCL, priv->base + RCAR_I2C_ICMCR);
+   udelay(5);
+}
+
+static int rcar_i2c_set_addr(struct udevice *dev, u8 chip, u8 read)
+{
+   struct rcar_i2c_priv *priv = dev_get_priv(dev);
+   u32 mask = RCAR_I2C_