From mboxrd@z Thu Jan 1 00:00:00 1970 From: Stephen Warren Date: Thu, 17 Jan 2013 15:23:19 -0700 Subject: [U-Boot] [PATCH 1/7] Tegra114: Add arch-tegra114 include files In-Reply-To: References: <1358370848-29469-1-git-send-email-twarren@nvidia.com> <1358370848-29469-2-git-send-email-twarren@nvidia.com> <50F72A9B.80308@wwwdotorg.org> Message-ID: <50F879D7.5090003@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/17/2013 10:51 AM, Tom Warren wrote: > Stephen, > > On Wed, Jan 16, 2013 at 3:32 PM, Stephen Warren wrote: >> On 01/16/2013 02:14 PM, Tom Warren wrote: >>> Common Tegra files are in arch-tegra, shared between T20/T30/T114. >>> Tegra114-specific headers are in arch-tegra114. Note that some of >>> these will be filled in as more T114 support is added (drivers, >>> WB/LP0 support, etc.). >> >>> diff --git a/arch/arm/include/asm/arch-tegra114/gpio.h b/arch/arm/include/asm/arch-tegra114/gpio.h >> >> I think the Tegra30 and Tegra114 GPIO controllers are basically >> identical. Can this file be shared at all? >> > > gpio.h is identical for T30 and T114, but not for T20. I've already > commonized what I could in arch-tegra/gpio.h, but to do the same for > the gpio_ctlr struct and gpio_pin enums would involve #ifdefs, which > is moving in the wrong direction, IMO. If you have a way to share one > or two files between T20/T30/T114/future SoCs, I'll give it a try. This may not work well for U-Boot since it uses structs to define the register layouts rather than simply #defining the various register addresses, but: We use the exact same driver code for Tegra20/30/114. The difference in register layout between Tegra20/30 can be described algorithmically with the following data: > struct tegra_gpio_soc_config { > u32 bank_stride; > u32 upper_offset; > }; > > static struct tegra_gpio_soc_config tegra20_gpio_config = { > .bank_stride = 0x80, > .upper_offset = 0x800, > }; > > static struct tegra_gpio_soc_config tegra30_gpio_config = { > .bank_stride = 0x100, > .upper_offset = 0x80, > }; > > static struct of_device_id tegra_gpio_of_match[] = { > { .compatible = "nvidia,tegra30-gpio", .data = &tegra30_gpio_config }, > { .compatible = "nvidia,tegra20-gpio", .data = &tegra20_gpio_config }, > { }, > }; which feeds into a few register offset #defines: > #define GPIO_REG(x) (GPIO_BANK(x) * tegra_gpio_bank_stride + \ ... > #define GPIO_CNF(x) (GPIO_REG(x) + 0x00) ... > #define GPIO_MSK_CNF(x) (GPIO_REG(x) + tegra_gpio_upper_offset + 0x00) Alternatively, can the Tegra114 GPIO header simply #include the Tegra30 GPIO header and do nothing else, via some relative include or similar? I'm not sure how gross that'd turn out to be.