drivers: i2c: mentor: move platform code into header files
authorAndre Przywara <andre.przywara@arm.com>
Sun, 9 Sep 2018 00:39:57 +0000 (01:39 +0100)
committerAndre Przywara <andre.przywara@arm.com>
Wed, 19 Sep 2018 08:24:02 +0000 (09:24 +0100)
At the moment we have two I2C stub drivers (for the Allwinner and the
Marvell platform), which #include the actual .c driver file.
Change this into the more usual design, by renaming and moving the stub
drivers into platform specific header files and including these from the
actual driver file. The platform specific include directories make sure
the driver picks up the right header automatically.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
drivers/allwinner/sunxi_i2c.c [deleted file]
drivers/marvell/i2c/a8k_i2c.c [deleted file]
drivers/mentor/i2c/mi2cv.c
plat/allwinner/common/include/mentor_i2c_plat.h [new file with mode: 0644]
plat/allwinner/sun50i_h6/platform.mk
plat/marvell/a8k/common/a8k_common.mk
plat/marvell/a8k/common/include/mentor_i2c_plat.h [new file with mode: 0644]

diff --git a/drivers/allwinner/sunxi_i2c.c b/drivers/allwinner/sunxi_i2c.c
deleted file mode 100644 (file)
index cc91ca5..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io>
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- * https://spdx.org/licenses
- */
-
-/* This driver provides I2C support for Allwinner sunXi SoCs */
-
-#include <mmio.h>
-
-#define CONFIG_SYS_TCLK                        24000000
-#define CONFIG_SYS_I2C_SPEED           100000
-#define CONFIG_SYS_I2C_SLAVE           0
-
-#define I2C_INTERRUPT_CLEAR_INVERTED
-
-struct  mentor_i2c_regs {
-       uint32_t slave_address;
-       uint32_t xtnd_slave_addr;
-       uint32_t data;
-       uint32_t control;
-       uint32_t status;
-       uint32_t baudrate;
-       uint32_t soft_reset;
-};
-
-#include "../mentor/i2c/mi2cv.c"
diff --git a/drivers/marvell/i2c/a8k_i2c.c b/drivers/marvell/i2c/a8k_i2c.c
deleted file mode 100644 (file)
index 1c0f922..0000000
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2018 Marvell International Ltd.
- *
- * SPDX-License-Identifier:     BSD-3-Clause
- * https://spdx.org/licenses
- */
-
-/* This driver provides I2C support for Marvell A8K and compatible SoCs */
-
-#include <mmio.h>
-
-#define CONFIG_SYS_TCLK                        250000000
-#define CONFIG_SYS_I2C_SPEED           100000
-#define CONFIG_SYS_I2C_SLAVE           0x0
-
-#define I2C_CAN_UNSTUCK
-
-struct  mentor_i2c_regs {
-       uint32_t slave_address;
-       uint32_t data;
-       uint32_t control;
-       union {
-               uint32_t status;        /* when reading */
-               uint32_t baudrate;      /* when writing */
-       };
-       uint32_t xtnd_slave_addr;
-       uint32_t reserved[2];
-       uint32_t soft_reset;
-       uint8_t  reserved2[0xa0 - 0x20];
-       uint32_t unstuck;
-};
-
-#include "../../mentor/i2c/mi2cv.c"
index 1b73e6f1642db570ab645ce599c4391fd56f8d92..8ebd9662b14e353070c9466151ee84e878a1fac1 100644 (file)
@@ -15,6 +15,7 @@
 #include <delay_timer.h>
 #include <errno.h>
 #include <mentor/mi2cv.h>
+#include <mentor_i2c_plat.h>
 #include <mmio.h>
 
 #if LOG_LEVEL >= LOG_LEVEL_VERBOSE
diff --git a/plat/allwinner/common/include/mentor_i2c_plat.h b/plat/allwinner/common/include/mentor_i2c_plat.h
new file mode 100644 (file)
index 0000000..f547f9a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2018 Icenowy Zheng <icenowy@aosc.io>
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ * https://spdx.org/licenses
+ */
+/* This driver provides I2C support for Allwinner sunXi SoCs */
+
+#ifndef SUNXI_I2C_H
+#define SUNXI_I2C_H
+
+#define CONFIG_SYS_TCLK                        24000000
+#define CONFIG_SYS_I2C_SPEED           100000
+#define CONFIG_SYS_I2C_SLAVE           0
+
+#define I2C_INTERRUPT_CLEAR_INVERTED
+
+struct  mentor_i2c_regs {
+       uint32_t slave_address;
+       uint32_t xtnd_slave_addr;
+       uint32_t data;
+       uint32_t control;
+       uint32_t status;
+       uint32_t baudrate;
+       uint32_t soft_reset;
+};
+
+#endif
index c3901d0174836be60ef8cee078c441a2f8b24249..90987020632fd8b26060edb0c0dd10579f4a3f02 100644 (file)
@@ -15,8 +15,8 @@ PLAT_INCLUDES         :=      -Iinclude/plat/arm/common               \
                                -I${AW_PLAT}/${PLAT}/include
 
 PLAT_BL_COMMON_SOURCES :=      drivers/console/${ARCH}/console.S       \
+                               drivers/mentor/i2c/mi2cv.c              \
                                drivers/ti/uart/${ARCH}/16550_console.S \
-                               ${AW_DRIVERS}/sunxi_i2c.c               \
                                ${XLAT_TABLES_LIB_SRCS}                 \
                                ${AW_PLAT}/common/plat_helpers.S        \
                                ${AW_PLAT}/common/sunxi_common.c
index 5956737db1ba94b9f6604e0a52b28a2d8d50eb59..be2ff1e3af2e606cf8d0c34bbb8fedf9ffc6ecbd 100644 (file)
@@ -57,9 +57,9 @@ BLE_PORTING_SOURCES   :=      $(PLAT_FAMILY_BASE)/$(PLAT)/board/dram_port.c \
 
 MARVELL_MOCHI_DRV      +=      $(MARVELL_DRV_BASE)/mochi/cp110_setup.c
 
-BLE_SOURCES            :=      $(PLAT_COMMON_BASE)/plat_ble_setup.c            \
+BLE_SOURCES            :=      drivers/mentor/i2c/mi2cv.c                      \
+                               $(PLAT_COMMON_BASE)/plat_ble_setup.c            \
                                $(MARVELL_MOCHI_DRV)                           \
-                               $(MARVELL_DRV_BASE)/i2c/a8k_i2c.c               \
                                $(PLAT_COMMON_BASE)/plat_pm.c                   \
                                $(MARVELL_DRV_BASE)/thermal.c                   \
                                $(PLAT_COMMON_BASE)/plat_thermal.c              \
diff --git a/plat/marvell/a8k/common/include/mentor_i2c_plat.h b/plat/marvell/a8k/common/include/mentor_i2c_plat.h
new file mode 100644 (file)
index 0000000..8829a92
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2018 Marvell International Ltd.
+ *
+ * SPDX-License-Identifier:     BSD-3-Clause
+ * https://spdx.org/licenses
+ */
+/* This driver provides I2C support for Marvell A8K and compatible SoCs */
+
+#ifndef A8K_I2C_H
+#define A8K_I2C_H
+
+#define CONFIG_SYS_TCLK                        250000000
+#define CONFIG_SYS_I2C_SPEED           100000
+#define CONFIG_SYS_I2C_SLAVE           0x0
+
+#define I2C_CAN_UNSTUCK
+
+struct  mentor_i2c_regs {
+       uint32_t slave_address;
+       uint32_t data;
+       uint32_t control;
+       union {
+               uint32_t status;        /* when reading */
+               uint32_t baudrate;      /* when writing */
+       };
+       uint32_t xtnd_slave_addr;
+       uint32_t reserved[2];
+       uint32_t soft_reset;
+       uint8_t  reserved2[0xa0 - 0x20];
+       uint32_t unstuck;
+};
+
+#endif