[U-Boot] [PATCH 06/60] i2c: tegra: move header file to driver directory

Stephen Warren swarren at wwwdotorg.org
Tue Apr 19 22:58:46 CEST 2016


From: Stephen Warren <swarren at nvidia.com>

tegra_i2c.h contains primarily private definitions for use inside the I2C
driver. Move those out of the global include directory since nothing
should need to access them.

The Tegra I2C driver exports a Tegra-specific API. Move its prototype into
a <mach/*> header. Hopefully one day this will go away.

Tegra's SPL doesn't (yet?) support the full I2C driver stack. However, SPL
must make some I2C accesses to program the PMIC to boot the main CPU
complex (note that Tegra's SPL runs on a different CPU). Share the
implementation of those functions in a new file. This isolates the hacky
use of private register definitions to a single file.

Signed-off-by: Stephen Warren <swarren at nvidia.com>
---
 arch/arm/mach-tegra/Makefile                       |  3 ++-
 arch/arm/mach-tegra/i2c_early.c                    | 28 ++++++++++++++++++++++
 arch/arm/mach-tegra/include/mach/tegra_i2c.h       | 25 +++++++++++++++++++
 arch/arm/mach-tegra/tegra20/pmu.c                  |  2 +-
 arch/arm/mach-tegra/tegra30/cpu.c                  | 19 ++-------------
 board/nvidia/venice2/as3722_init.c                 | 20 ++--------------
 drivers/i2c/tegra_i2c.c                            |  3 ++-
 .../tegra_i2c.h => drivers/i2c/tegra_i2c_priv.h    | 13 +++-------
 8 files changed, 65 insertions(+), 48 deletions(-)
 create mode 100644 arch/arm/mach-tegra/i2c_early.c
 create mode 100644 arch/arm/mach-tegra/include/mach/tegra_i2c.h
 rename arch/arm/include/asm/arch-tegra/tegra_i2c.h => drivers/i2c/tegra_i2c_priv.h (95%)

diff --git a/arch/arm/mach-tegra/Makefile b/arch/arm/mach-tegra/Makefile
index b2dbc6999c71..197bdfeadd57 100644
--- a/arch/arm/mach-tegra/Makefile
+++ b/arch/arm/mach-tegra/Makefile
@@ -1,5 +1,5 @@
 #
-# (C) Copyright 2010-2015 Nvidia Corporation.
+# (C) Copyright 2010-2016 Nvidia Corporation.
 #
 # (C) Copyright 2000-2008
 # Wolfgang Denk, DENX Software Engineering, wd at denx.de.
@@ -26,6 +26,7 @@ obj-y += xusb-padctl-dummy.o
 obj-$(CONFIG_DISPLAY_CPUINFO) += sys_info.o
 obj-$(CONFIG_TEGRA_GPU) += gpu.o
 obj-$(CONFIG_TEGRA_CLOCK_SCALING) += emc.o
+obj-$(CONFIG_SPL_BUILD) += i2c_early.o
 
 ifndef CONFIG_SPL_BUILD
 obj-$(CONFIG_ARMV7_PSCI) += psci.o
diff --git a/arch/arm/mach-tegra/i2c_early.c b/arch/arm/mach-tegra/i2c_early.c
new file mode 100644
index 000000000000..dcdd86cef71e
--- /dev/null
+++ b/arch/arm/mach-tegra/i2c_early.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+ * Copyright (c) 2010-2016 NVIDIA Corporation
+ * NVIDIA Corporation <www.nvidia.com>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <mach/tegra_i2c.h>
+#include "../../../drivers/i2c/tegra_i2c_priv.h"
+
+void tegra_i2c_ll_write_addr(uint addr, uint config)
+{
+	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+
+	writel(addr, &reg->cmd_addr0);
+	writel(config, &reg->cnfg);
+}
+
+void tegra_i2c_ll_write_data(uint data, uint config)
+{
+	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
+
+	writel(data, &reg->cmd_data1);
+	writel(config, &reg->cnfg);
+}
diff --git a/arch/arm/mach-tegra/include/mach/tegra_i2c.h b/arch/arm/mach-tegra/include/mach/tegra_i2c.h
new file mode 100644
index 000000000000..57837885176a
--- /dev/null
+++ b/arch/arm/mach-tegra/include/mach/tegra_i2c.h
@@ -0,0 +1,25 @@
+/*
+ * NVIDIA Tegra I2C controller custom API
+ *
+ * Copyright 2010-2016 NVIDIA Corporation
+ *
+ * SPDX-License-Identifier:	GPL-2.0
+ */
+
+#ifndef _MACH_TEGRA_I2C_H_
+#define _MACH_TEGRA_I2C_H_
+
+struct udevice;
+
+/* Custom APIs for very early I2C access */
+void tegra_i2c_ll_write_addr(uint addr, uint config);
+void tegra_i2c_ll_write_data(uint data, uint config);
+
+/**
+ * Returns the bus number of the DVC controller
+ *
+ * @return number of bus, or -1 if there is no DVC active
+ */
+int tegra_i2c_get_dvc_bus(struct udevice **busp);
+
+#endif
diff --git a/arch/arm/mach-tegra/tegra20/pmu.c b/arch/arm/mach-tegra/tegra20/pmu.c
index 0da704cd4f3c..8488d97d5cde 100644
--- a/arch/arm/mach-tegra/tegra20/pmu.c
+++ b/arch/arm/mach-tegra/tegra20/pmu.c
@@ -10,8 +10,8 @@
 #include <tps6586x.h>
 #include <asm/io.h>
 #include <asm/arch/tegra.h>
-#include <asm/arch-tegra/tegra_i2c.h>
 #include <asm/arch-tegra/sys_proto.h>
+#include <mach/tegra_i2c.h>
 #include "../cpu.h"
 
 #define VDD_CORE_NOMINAL_T25	0x17	/* 1.3v */
diff --git a/arch/arm/mach-tegra/tegra30/cpu.c b/arch/arm/mach-tegra/tegra30/cpu.c
index 66b021b82459..774207354064 100644
--- a/arch/arm/mach-tegra/tegra30/cpu.c
+++ b/arch/arm/mach-tegra/tegra30/cpu.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010-2014, NVIDIA CORPORATION.  All rights reserved.
+ * Copyright (c) 2010-2016, NVIDIA CORPORATION.  All rights reserved.
  *
  * SPDX-License-Identifier:	GPL-2.0
  */
@@ -11,25 +11,10 @@
 #include <asm/arch/tegra.h>
 #include <asm/arch-tegra/clk_rst.h>
 #include <asm/arch-tegra/pmc.h>
-#include <asm/arch-tegra/tegra_i2c.h>
+#include <mach/tegra_i2c.h>
 #include "../cpu.h"
 
 /* Tegra30-specific CPU init code */
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
-
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
 
 #define TPS62366A_I2C_ADDR		0xC0
 #define TPS62366A_SET1_REG		0x01
diff --git a/board/nvidia/venice2/as3722_init.c b/board/nvidia/venice2/as3722_init.c
index 960fea7ee7e3..86b164db3be1 100644
--- a/board/nvidia/venice2/as3722_init.c
+++ b/board/nvidia/venice2/as3722_init.c
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2013
+ * (C) Copyright 2013-2016
  * NVIDIA Corporation <www.nvidia.com>
  *
  * SPDX-License-Identifier:     GPL-2.0+
@@ -7,27 +7,11 @@
 
 #include <common.h>
 #include <asm/io.h>
-#include <asm/arch-tegra/tegra_i2c.h>
+#include <mach/tegra_i2c.h>
 #include "as3722_init.h"
 
 /* AS3722-PMIC-specific early init code - get CPU rails up, etc */
 
-void tegra_i2c_ll_write_addr(uint addr, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(addr, &reg->cmd_addr0);
-	writel(config, &reg->cnfg);
-}
-
-void tegra_i2c_ll_write_data(uint data, uint config)
-{
-	struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
-
-	writel(data, &reg->cmd_data1);
-	writel(config, &reg->cnfg);
-}
-
 void pmic_enable_cpu_vdd(void)
 {
 	debug("%s entry\n", __func__);
diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c
index 0735ea0b2b12..2a8ab2d5e0b9 100644
--- a/drivers/i2c/tegra_i2c.c
+++ b/drivers/i2c/tegra_i2c.c
@@ -17,7 +17,8 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/pinmux.h>
 #include <asm/arch-tegra/clk_rst.h>
-#include <asm/arch-tegra/tegra_i2c.h>
+#include <mach/tegra_i2c.h>
+#include "tegra_i2c_priv.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
diff --git a/arch/arm/include/asm/arch-tegra/tegra_i2c.h b/drivers/i2c/tegra_i2c_priv.h
similarity index 95%
rename from arch/arm/include/asm/arch-tegra/tegra_i2c.h
rename to drivers/i2c/tegra_i2c_priv.h
index eb83af89f7f5..95c73293d341 100644
--- a/arch/arm/include/asm/arch-tegra/tegra_i2c.h
+++ b/drivers/i2c/tegra_i2c_priv.h
@@ -6,8 +6,8 @@
  * SPDX-License-Identifier:	GPL-2.0
  */
 
-#ifndef _TEGRA_I2C_H_
-#define _TEGRA_I2C_H_
+#ifndef _TEGRA_I2C_PRIV_H
+#define _TEGRA_I2C_PRIV_H
 
 #include <asm/types.h>
 
@@ -139,11 +139,4 @@ struct i2c_ctlr {
 /* I2C_CLK_DIVISOR_REGISTER */
 #define CLK_MULT_STD_FAST_MODE		8
 
-/**
- * Returns the bus number of the DVC controller
- *
- * @return number of bus, or -1 if there is no DVC active
- */
-int tegra_i2c_get_dvc_bus(struct udevice **busp);
-
-#endif	/* _TEGRA_I2C_H_ */
+#endif
-- 
2.8.1



More information about the U-Boot mailing list