From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Wed, 20 Apr 2016 06:48:51 +0200 Subject: [U-Boot] [PATCH 06/60] i2c: tegra: move header file to driver directory In-Reply-To: <1461099580-3866-7-git-send-email-swarren@wwwdotorg.org> References: <1461099580-3866-1-git-send-email-swarren@wwwdotorg.org> <1461099580-3866-7-git-send-email-swarren@wwwdotorg.org> Message-ID: <57170A33.2000503@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Stephen, Am 19.04.2016 um 22:58 schrieb Stephen Warren: > From: Stephen Warren > > 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 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 > --- > 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%) Thanks! Acked-by: Heiko Schocher bye, Heiko > > 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 > + * > + * SPDX-License-Identifier: GPL-2.0+ > + */ > + > +#include > +#include > +#include > +#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, ®->cmd_addr0); > + writel(config, ®->cnfg); > +} > + > +void tegra_i2c_ll_write_data(uint data, uint config) > +{ > + struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE; > + > + writel(data, ®->cmd_data1); > + writel(config, ®->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 > #include > #include > -#include > #include > +#include > #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 > #include > #include > -#include > +#include > #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, ®->cmd_addr0); > - writel(config, ®->cnfg); > -} > - > -void tegra_i2c_ll_write_data(uint data, uint config) > -{ > - struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE; > - > - writel(data, ®->cmd_data1); > - writel(config, ®->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 > * > * SPDX-License-Identifier: GPL-2.0+ > @@ -7,27 +7,11 @@ > > #include > #include > -#include > +#include > #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, ®->cmd_addr0); > - writel(config, ®->cnfg); > -} > - > -void tegra_i2c_ll_write_data(uint data, uint config) > -{ > - struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE; > - > - writel(data, ®->cmd_data1); > - writel(config, ®->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 > #include > #include > -#include > +#include > +#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 > > @@ -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 > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany