Skip to contentSkip to conversation

Tegra-next

PATCH Superseded Lucas Stach 2 participants 28 messages May 12, 2014

Subsystems (11)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover Tegra-next

Ok, here we go: this is a truckload of fixes and new features for the Tegra arch. One big patch series this time as it took me some time to validate everything.

Patches 1-6 introduce a proper reset controller and remove the old hacks used to reset the devices. This is needed for the follow on patches as the Tegra i2c driver needs closer control over device reset.

Patches 7-10 add the Tegra i2c driver and the necessary clocks.

Patch 11 uses the new i2c support to active the SDMMC1 voltage rail on Beaver.

Patches 12-15 are fixes to the Tegra MCI and pinctrl to make SD cards work on Tegra 3, not only eMMC as before.

Patches 17-25 import the Tegra cbootimage tool, add infrastructure to build persistable images and convert existing boards over to use it.

All in all this now allows to build flashable images. I verified that things are working by loading an image from SD card on Beaver and writing it to the boot partition on eMMC.

After reset of the board I'm now greeted by barebox instead of U-Boot. :)

Lucas Stach (25):
reset: add reset controller framework
tegra: lowlevel: add function to fetch chipid
reset: add tegra reset controller
clk: tegra: reset UARTS from clock controller
mci: tegra: add reset control
clk: tegra: remove device reset hack
clk: tegra: allow to register clocks with 16 bit divider
clk: tegra30: register i2c clocks
clk: tegra20: register i2c clocks
i2c: add Tegra driver
ARM: tegra: beaver: activate sdmmc1 voltage rail
ARM: tegra: beaver: adjust pinmux to make sdmmc1 work
mci: tegra: apply pad autocalibration on T30
mci: tegra: don't set 8bit mode unconditionally
pinctrl: tegra30: parse drive groups
scripts: tegra: import cbootimage
tegra: cbootimage: remove noisy output Makefile.lib: add rule to built Tegra BCTs
images: add Tegra20 image build rules
images: add Tegra30 image build rules
ARM: boards: colibri t20: import BCT cfgs
images: tegra: build all Toradex Colibri images
ARM: boards: beaver: import BCT cfg
images: tegra: build NVidia Beaver image
images: tegra: rename ac100 image

 .gitignore                                         |    1 +
 arch/arm/Kconfig                                   |    1 +
 arch/arm/boards/nvidia-beaver/Makefile             |    3 +
 .../boards/nvidia-beaver/beaver-2gb-emmc.bct.cfg   |  819 +++++++++++++++
 arch/arm/boards/nvidia-beaver/board.c              |   38 +
 arch/arm/boards/toradex-colibri-t20/Makefile       |    4 +
 .../colibri-t20_256_hsmmc.bct.cfg                  |  451 ++++++++
 .../colibri-t20_256_v11_nand.bct.cfg               |  459 ++++++++
 .../colibri-t20_256_v12_nand.bct.cfg               |  459 ++++++++
 .../colibri-t20_512_hsmmc.bct.cfg                  |  451 ++++++++
 .../colibri-t20_512_v11_nand.bct.cfg               |  459 ++++++++
 .../colibri-t20_512_v12_nand.bct.cfg               |  459 ++++++++
 arch/arm/boards/toradex-colibri-t20/entry.c        |   42 +-
 arch/arm/dts/tegra30-beaver.dts                    |   10 +
 arch/arm/mach-tegra/include/mach/lowlevel.h        |    6 +
 arch/arm/mach-tegra/include/mach/tegra30-car.h     |    2 +
 drivers/Kconfig                                    |    1 +
 drivers/Makefile                                   |    1 +
 drivers/clk/tegra/clk-periph.c                     |   46 +-
 drivers/clk/tegra/clk-tegra20.c                    |   16 +
 drivers/clk/tegra/clk-tegra30.c                    |   19 +
 drivers/clk/tegra/clk.c                            |  145 ++-
 drivers/clk/tegra/clk.h                            |   18 +
 drivers/i2c/busses/Kconfig                         |    4 +
 drivers/i2c/busses/Makefile                        |    1 +
 drivers/i2c/busses/i2c-tegra.c                     |  708 +++++++++++++
 drivers/mci/tegra-sdmmc.c                          |   37 +-
 drivers/pinctrl/pinctrl-tegra30.c                  |  159 ++-
 drivers/reset/Kconfig                              |   13 +
 drivers/reset/Makefile                             |    1 +
 drivers/reset/core.c                               |  236 +++++
 images/.gitignore                                  |    4 +
 images/Makefile                                    |    3 +-
 images/Makefile.tegra                              |   70 +-
 include/linux/reset-controller.h                   |   50 +
 include/linux/reset.h                              |   67 ++
 scripts/Makefile                                   |    1 +
 scripts/Makefile.lib                               |    6 +
 scripts/tegra/Makefile                             |   22 +
 scripts/tegra/aes_ref.c                            |  326 ++++++
 scripts/tegra/bct_dump.c                           |  296 ++++++
 scripts/tegra/cbootimage.c                         |  242 +++++
 scripts/tegra/cbootimage.h                         |  108 ++
 scripts/tegra/context.c                            |   42 +
 scripts/tegra/context.h                            |   28 +
 scripts/tegra/crypto.c                             |  299 ++++++
 scripts/tegra/crypto.h                             |   47 +
 scripts/tegra/data_layout.c                        |  898 ++++++++++++++++
 scripts/tegra/data_layout.h                        |   55 +
 scripts/tegra/nvaes_ref.h                          |   35 +
 scripts/tegra/parse.c                              |  803 ++++++++++++++
 scripts/tegra/parse.h                              |  923 ++++++++++++++++
 scripts/tegra/set.c                                |  206 ++++
 scripts/tegra/set.h                                |   49 +
 scripts/tegra/t114/nvbctlib_t114.c                 | 1103 +++++++++++++++++++
 scripts/tegra/t114/nvboot_bct_t114.h               |  363 +++++++
 scripts/tegra/t114/nvboot_sdram_param_t114.h       |  806 ++++++++++++++
 scripts/tegra/t114/parse_t114.c                    |  430 ++++++++
 scripts/tegra/t124/nvbctlib_t124.c                 | 1104 ++++++++++++++++++++
 scripts/tegra/t124/nvboot_bct_t124.h               |  359 +++++++
 scripts/tegra/t124/nvboot_sdram_param_t124.h       |  803 ++++++++++++++
 scripts/tegra/t124/parse_t124.c                    |  429 ++++++++
 scripts/tegra/t20/nvbctlib_t20.c                   |  684 ++++++++++++
 scripts/tegra/t20/nvboot_bct_t20.h                 |  316 ++++++
 scripts/tegra/t20/nvboot_sdram_param_t20.h         |  363 +++++++
 scripts/tegra/t20/parse_t20.c                      |  251 +++++
 scripts/tegra/t30/nvbctlib_t30.c                   |  891 ++++++++++++++++
 scripts/tegra/t30/nvboot_bct_t30.h                 |  379 +++++++
 scripts/tegra/t30/nvboot_sdram_param_t30.h         |  568 ++++++++++
 scripts/tegra/t30/parse_t30.c                      |  360 +++++++
 70 files changed, 18820 insertions(+), 38 deletions(-)
 create mode 100644 arch/arm/boards/nvidia-beaver/beaver-2gb-emmc.bct.cfg
 create mode 100644 arch/arm/boards/nvidia-beaver/board.c
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_256_hsmmc.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_256_v11_nand.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_256_v12_nand.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_512_hsmmc.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_512_v11_nand.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_512_v12_nand.bct.cfg
 create mode 100644 drivers/i2c/busses/i2c-tegra.c
 create mode 100644 drivers/reset/Kconfig
 create mode 100644 drivers/reset/Makefile
 create mode 100644 drivers/reset/core.c
 create mode 100644 include/linux/reset-controller.h
 create mode 100644 include/linux/reset.h
 create mode 100644 scripts/tegra/Makefile
 create mode 100644 scripts/tegra/aes_ref.c
 create mode 100644 scripts/tegra/bct_dump.c
 create mode 100644 scripts/tegra/cbootimage.c
 create mode 100644 scripts/tegra/cbootimage.h
 create mode 100644 scripts/tegra/context.c
 create mode 100644 scripts/tegra/context.h
 create mode 100644 scripts/tegra/crypto.c
 create mode 100644 scripts/tegra/crypto.h
 create mode 100644 scripts/tegra/data_layout.c
 create mode 100644 scripts/tegra/data_layout.h
 create mode 100644 scripts/tegra/nvaes_ref.h
 create mode 100644 scripts/tegra/parse.c
 create mode 100644 scripts/tegra/parse.h
 create mode 100644 scripts/tegra/set.c
 create mode 100644 scripts/tegra/set.h
 create mode 100644 scripts/tegra/t114/nvbctlib_t114.c
 create mode 100644 scripts/tegra/t114/nvboot_bct_t114.h
 create mode 100644 scripts/tegra/t114/nvboot_sdram_param_t114.h
 create mode 100644 scripts/tegra/t114/parse_t114.c
 create mode 100644 scripts/tegra/t124/nvbctlib_t124.c
 create mode 100644 scripts/tegra/t124/nvboot_bct_t124.h
 create mode 100644 scripts/tegra/t124/nvboot_sdram_param_t124.h
 create mode 100644 scripts/tegra/t124/parse_t124.c
 create mode 100644 scripts/tegra/t20/nvbctlib_t20.c
 create mode 100644 scripts/tegra/t20/nvboot_bct_t20.h
 create mode 100644 scripts/tegra/t20/nvboot_sdram_param_t20.h
 create mode 100644 scripts/tegra/t20/parse_t20.c
 create mode 100644 scripts/tegra/t30/nvbctlib_t30.c
 create mode 100644 scripts/tegra/t30/nvboot_bct_t30.h
 create mode 100644 scripts/tegra/t30/nvboot_sdram_param_t30.h
 create mode 100644 scripts/tegra/t30/parse_t30.c
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 1/25 reset: add reset controller framework

Add stripped sown version of the reset controller
framework from the Linux kernel.

---
 drivers/Kconfig                  |   1 +
 drivers/Makefile                 |   1 +
 drivers/reset/Kconfig            |  13 +++
 drivers/reset/Makefile           |   1 +
 drivers/reset/core.c             | 236 +++++++++++++++++++++++++++++++++++++++
 include/linux/reset-controller.h |  50 +++++++++
 include/linux/reset.h            |  67 +++++++++++
 7 files changed, 369 insertions(+)
 create mode 100644 drivers/reset/Kconfig
 create mode 100644 drivers/reset/Makefile
 create mode 100644 drivers/reset/core.c
 create mode 100644 include/linux/reset-controller.h
 create mode 100644 include/linux/reset.h
drivers/Kconfig +1 -0
index 7a2aa28..53e1e97 100644
@@ -26,5 +26,6 @@ source "drivers/w1/Kconfig"
 source "drivers/pinctrl/Kconfig"
 source "drivers/bus/Kconfig"
 source "drivers/regulator/Kconfig"
+source "drivers/reset/Kconfig"
 
 endmenu
drivers/Makefile +1 -0
index f79da89..ef3604f 100644
@@ -25,3 +25,4 @@ obj-$(CONFIG_W1) += w1/
 obj-y += pinctrl/
 obj-y += bus/
 obj-$(CONFIG_REGULATOR) += regulator/
+obj-$(CONFIG_RESET_CONTROLLER) += reset/
drivers/reset/Kconfig new file +13 -0
new file mode 100644
index 0000000..c9d04f7
@@ -0,0 +1,13 @@
+config ARCH_HAS_RESET_CONTROLLER
+	bool
+
+menuconfig RESET_CONTROLLER
+	bool "Reset Controller Support"
+	default y if ARCH_HAS_RESET_CONTROLLER
+	help
+	  Generic Reset Controller support.
+
+	  This framework is designed to abstract reset handling of devices
+	  via GPIOs or SoC-internal reset controller modules.
+
+	  If unsure, say no.
drivers/reset/Makefile new file +1 -0
new file mode 100644
index 0000000..1e2d83f
@@ -0,0 +1 @@
+obj-$(CONFIG_RESET_CONTROLLER) += core.o
drivers/reset/core.c new file +236 -0

236 lines not on this page · raw message

include/linux/reset-controller.h new file +50 -0

50 lines not on this page · raw message

include/linux/reset.h new file +67 -0

67 lines not on this page · raw message

Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 2/25 tegra: lowlevel: add function to fetch chipid

In reply to Lucas Stach

This is needed as a safe way to flush the ABP bus.

---
 arch/arm/mach-tegra/include/mach/lowlevel.h | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm/mach-tegra/include/mach/lowlevel.h +6 -0
index 52b405d..1026518 100644
@@ -70,6 +70,12 @@ enum tegra_chiptype {
 };
 
 static __always_inline
+u32 tegra_read_chipid(void)
+{
+	return readl(TEGRA_APB_MISC_BASE + APB_MISC_HIDREV);
+}
+
+static __always_inline
 enum tegra_chiptype tegra_get_chiptype(void)
 {
 	u32 hidrev;
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 3/25 reset: add tegra reset controller

In reply to Lucas Stach

Allows us to drop the hack in the clock controller and implement proper reset at device level.

---
 arch/arm/Kconfig                |   1 +
 drivers/clk/tegra/clk-tegra20.c |   2 +
 drivers/clk/tegra/clk-tegra30.c |   2 +
 drivers/clk/tegra/clk.c         | 134 +++++++++++++++++++++++++++++++++++++++-
 drivers/clk/tegra/clk.h         |  12 ++++
 5 files changed, 150 insertions(+), 1 deletion(-)
arch/arm/Kconfig +1 -0
index 4a2ec41..f93ef4c 100644
@@ -192,6 +192,7 @@ config ARCH_TEGRA
 	select OFDEVICE
 	select OFTREE
 	select RELOCATABLE
+	select RESET_CONTROLLER
 
 config ARCH_ZYNQ
 	bool "Xilinx Zynq-based boards"
drivers/clk/tegra/clk-tegra20.c +2 -0
index ea39f46..7c7a915 100644
@@ -347,6 +347,8 @@ static int tegra20_car_probe(struct device_d *dev)
 	of_clk_add_provider(dev->device_node, of_clk_src_onecell_get,
 			    &clk_data);
 
+	tegra_clk_init_rst_controller(car_base, dev->device_node, 3 * 32);
+
 	return 0;
 }
 
drivers/clk/tegra/clk-tegra30.c +2 -0
index 94bbeac..adb5824 100644
@@ -341,6 +341,8 @@ static int tegra30_car_probe(struct device_d *dev)
 	of_clk_add_provider(dev->device_node, of_clk_src_onecell_get,
 			    &clk_data);
 
+	tegra_clk_init_rst_controller(car_base, dev->device_node, 6 * 32);
+
 	return 0;
 }
 
drivers/clk/tegra/clk.c +133 -1

150 lines not on this page · raw message

drivers/clk/tegra/clk.h +12 -0
index 9bb8f1c..29d5249 100644
@@ -148,3 +148,15 @@ struct tegra_clk_init_table {
 
 void tegra_init_from_table(struct tegra_clk_init_table *tbl,
 		struct clk *clks[], int clk_max);
+
+struct tegra_clk_periph_regs {
+	u32 enb_reg;
+	u32 enb_set_reg;
+	u32 enb_clr_reg;
+	u32 rst_reg;
+	u32 rst_set_reg;
+	u32 rst_clr_reg;
+};
+
+void tegra_clk_init_rst_controller(void __iomem *base, struct device_node *np,
+		unsigned int num);
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 4/25 clk: tegra: reset UARTS from clock controller

In reply to Lucas Stach

The console devices are the only ones that can't use the reset controller properly, as they get registered from platform code. Reset those devices from the clock controller.

---
 drivers/clk/tegra/clk-tegra20.c |  1 +
 drivers/clk/tegra/clk-tegra30.c |  1 +
 drivers/clk/tegra/clk.c         | 11 +++++++++++
 drivers/clk/tegra/clk.h         |  2 ++
 4 files changed, 15 insertions(+)
drivers/clk/tegra/clk-tegra20.c +1 -0
index 7c7a915..cb0a571 100644
@@ -348,6 +348,7 @@ static int tegra20_car_probe(struct device_d *dev)
 			    &clk_data);
 
 	tegra_clk_init_rst_controller(car_base, dev->device_node, 3 * 32);
+	tegra_clk_reset_uarts();
 
 	return 0;
 }
drivers/clk/tegra/clk-tegra30.c +1 -0
index adb5824..9536288 100644
@@ -342,6 +342,7 @@ static int tegra30_car_probe(struct device_d *dev)
 			    &clk_data);
 
 	tegra_clk_init_rst_controller(car_base, dev->device_node, 6 * 32);
+	tegra_clk_reset_uarts();
 
 	return 0;
 }
drivers/clk/tegra/clk.c +11 -0
index a6b81d0..cb4d920 100644
@@ -187,3 +187,14 @@ void tegra_clk_init_rst_controller(void __iomem *base, struct device_node *np,
 	rst_ctlr.nr_resets = num;
 	reset_controller_register(&rst_ctlr);
 }
+
+void tegra_clk_reset_uarts(void) {
+	int i;
+	int console_device_ids[] = {6, 7, 55, 65, 66};
+
+	for (i = 0; i < ARRAY_SIZE(console_device_ids); i++) {
+		rst_ops.assert(&rst_ctlr, console_device_ids[i]);
+		udelay(2);
+		rst_ops.deassert(&rst_ctlr, console_device_ids[i]);
+	}
+};
drivers/clk/tegra/clk.h +2 -0
index 29d5249..6ce9f7e 100644
@@ -160,3 +160,5 @@ struct tegra_clk_periph_regs {
 
 void tegra_clk_init_rst_controller(void __iomem *base, struct device_node *np,
 		unsigned int num);
+
+void tegra_clk_reset_uarts(void);
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 5/25 mci: tegra: add reset control

In reply to Lucas Stach

Enable the driver to reset the device itself.

---
 drivers/mci/tegra-sdmmc.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/mci/tegra-sdmmc.c +9 -0
index e4d8219..0ea0b5c 100644
@@ -28,6 +28,7 @@
 #include <mci.h>
 #include <of_gpio.h>
 #include <linux/clk.h>
+#include <linux/reset.h>
 
 #include "sdhci.h"
 
@@ -62,6 +63,7 @@ struct tegra_sdmmc_host {
 	struct mci_host		mci;
 	void __iomem		*regs;
 	struct clk		*clk;
+	struct reset_control	*reset;
 	int			gpio_cd, gpio_pwr;
 };
 #define to_tegra_sdmmc_host(mci) container_of(mci, struct tegra_sdmmc_host, mci)
@@ -400,6 +402,10 @@ static int tegra_sdmmc_probe(struct device_d *dev)
 	if (IS_ERR(host->clk))
 		return PTR_ERR(host->clk);
 
+	host->reset = reset_control_get(dev, NULL);
+	if (IS_ERR(host->reset))
+		return PTR_ERR(host->reset);
+
 	host->regs = dev_request_mem_region(dev, 0);
 	if (!host->regs) {
 		dev_err(dev, "could not get iomem region\n");
@@ -430,6 +436,9 @@ static int tegra_sdmmc_probe(struct device_d *dev)
 	}
 
 	clk_enable(host->clk);
+	reset_control_assert(host->reset);
+	udelay(2);
+	reset_control_deassert(host->reset);
 
 	mci->init = tegra_sdmmc_init;
 	mci->card_present = tegra_sdmmc_card_present;
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

PATCH 6/25 clk: tegra: remove device reset hack

In reply to Lucas Stach

Now that we have a proper reset controller, it
isn't necessary anymore to keep the device reset
hack coupled to the clock.

---
 drivers/clk/tegra/clk-periph.c | 18 ------------------
 1 file changed, 18 deletions(-)
drivers/clk/tegra/clk-periph.c +0 -18
index be83955..c05e563 100644
@@ -74,33 +74,15 @@ static int clk_periph_is_enabled(struct clk *hw)
 static int clk_periph_enable(struct clk *hw)
 {
 	struct tegra_clk_periph *periph = to_clk_periph(hw);
-	u32 reg;
-
-	reg = readl(periph->rst_reg);
-	reg |= (1 << periph->rst_shift);
-	writel(reg, periph->rst_reg);
 
 	periph->gate->ops->enable(periph->gate);
 
-	udelay(2);
-
-	reg = readl(periph->rst_reg);
-	reg &= ~(1 << periph->rst_shift);
-	writel(reg, periph->rst_reg);
-
 	return 0;
 }
 
 static void clk_periph_disable(struct clk *hw)
 {
 	struct tegra_clk_periph *periph = to_clk_periph(hw);
-	u32 reg;
-
-	reg = readl(periph->rst_reg);
-	reg |= (1 << periph->rst_shift);
-	writel(reg, periph->rst_reg);
-
-	udelay(2);
 
 	periph->gate->ops->disable(periph->gate);
 }
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

PATCH 7/25 clk: tegra: allow to register clocks with 16 bit divider

In reply to Lucas Stach

Some peripherals have a double wide divider in front of them.

---
 drivers/clk/tegra/clk-periph.c | 28 +++++++++++++++++++++-------
 drivers/clk/tegra/clk.h        |  4 ++++
 2 files changed, 25 insertions(+), 7 deletions(-)
drivers/clk/tegra/clk-periph.c +21 -7
index c05e563..e4e5412 100644
@@ -106,10 +106,10 @@ const struct clk_ops tegra_clk_periph_nodiv_ops = {
 	.disable = clk_periph_disable,
 };
 
-struct clk *_tegra_clk_register_periph(const char *name,
+static struct clk *_tegra_clk_register_periph(const char *name,
 		const char **parent_names, int num_parents,
 		void __iomem *clk_base, u32 reg_offset, u8 id, u8 flags,
-		bool has_div)
+		int div)
 {
 	struct tegra_clk_periph *periph;
 	int ret, gate_offs, rst_offs;
@@ -136,15 +136,20 @@ struct clk *_tegra_clk_register_periph(const char *name,
 	if (!periph->gate)
 		goto out_gate;
 
-	if (has_div) {
+	if (div == 8) {
 		periph->div = tegra_clk_divider_alloc(NULL, NULL, clk_base +
-				reg_offset, 0, TEGRA_DIVIDER_ROUND_UP, 0, 8, 1);
+		              reg_offset, 0, TEGRA_DIVIDER_ROUND_UP, 0, 8, 1);
+		if (!periph->div)
+			goto out_div;
+	} else if (div == 16) {
+		periph->div = tegra_clk_divider_alloc(NULL, NULL, clk_base +
+		              reg_offset, 0, TEGRA_DIVIDER_ROUND_UP, 0, 16, 0);
 		if (!periph->div)
 			goto out_div;
 	}
 
 	periph->hw.name = name;
-	periph->hw.ops = has_div ? &tegra_clk_periph_ops :
+	periph->hw.ops = div ? &tegra_clk_periph_ops :
 				   &tegra_clk_periph_nodiv_ops;
 	periph->hw.parent_names = parent_names;
 	periph->hw.num_parents = num_parents;
@@ -181,7 +186,7 @@ struct clk *tegra_clk_register_periph_nodiv(const char *name,
 {
 	return _tegra_clk_register_periph(name, parent_names, num_parents,
 					  clk_base, reg_offset, id, flags,
-					  false);
+					  0);
 }
 
 struct clk *tegra_clk_register_periph(const char *name,
@@ -190,5 +195,14 @@ struct clk *tegra_clk_register_periph(const char *name,
 {
 	return _tegra_clk_register_periph(name, parent_names, num_parents,
 					  clk_base, reg_offset, id, flags,
-					  true);
+					  8);
+}
+
+struct clk *tegra_clk_register_periph_div16(const char *name,
+		const char **parent_names, int num_parents,
+		void __iomem *clk_base, u32 reg_offset, u8 id, u8 flags)
+{
+	return _tegra_clk_register_periph(name, parent_names, num_parents,
+					  clk_base, reg_offset, id, flags,
+					  16);
 }
drivers/clk/tegra/clk.h +4 -0
index 6ce9f7e..d5d0730 100644
@@ -138,6 +138,10 @@ struct clk *tegra_clk_register_periph(const char *name,
 		const char **parent_names, int num_parents,
 		void __iomem *clk_base, u32 reg_offset, u8 id, u8 flags);
 
+struct clk *tegra_clk_register_periph_div16(const char *name,
+		const char **parent_names, int num_parents,
+		void __iomem *clk_base, u32 reg_offset, u8 id, u8 flags);
+
 /* struct clk_init_table - clock initialization table */
 struct tegra_clk_init_table {
 	unsigned int	clk_id;
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH 8/25 clk: tegra30: register i2c clocks

In reply to Lucas Stach
---
 arch/arm/mach-tegra/include/mach/tegra30-car.h |  2 ++
 drivers/clk/tegra/clk-tegra30.c                | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)
arch/arm/mach-tegra/include/mach/tegra30-car.h +2 -0
index ce11060..286a2a6 100644
@@ -25,6 +25,8 @@
 #define CRC_CLK_SOURCE_MSEL_SRC_PLLM	2
 #define CRC_CLK_SOURCE_MSEL_SRC_CLKM	3
 
+#define CRC_CLK_SOURCE_I2C4		0x3c4
+
 #define CRC_RST_DEV_V_SET		0x430
 #define CRC_RST_DEV_V_MSELECT		(1 << 3)
 
drivers/clk/tegra/clk-tegra30.c +16 -0
index 9536288..3b50830 100644
@@ -296,6 +296,22 @@ static void tegra30_periph_init(void)
 	clks[TEGRA30_CLK_SDMMC4] = tegra_clk_register_periph("sdmmc4",
 			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
 			CRC_CLK_SOURCE_SDMMC4, TEGRA30_CLK_SDMMC4, 1);
+
+	clks[TEGRA30_CLK_I2C1] = tegra_clk_register_periph_div16("i2c1",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C1, TEGRA30_CLK_I2C1, 1);
+	clks[TEGRA30_CLK_I2C2] = tegra_clk_register_periph_div16("i2c2",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C2, TEGRA30_CLK_I2C2, 1);
+	clks[TEGRA30_CLK_I2C3] = tegra_clk_register_periph_div16("i2c3",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C3, TEGRA30_CLK_I2C3, 1);
+	clks[TEGRA30_CLK_I2C4] = tegra_clk_register_periph_div16("i2c4",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C4, TEGRA30_CLK_I2C4, 1);
+	clks[TEGRA30_CLK_I2C5] = tegra_clk_register_periph_div16("i2c5",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_DVC, TEGRA30_CLK_I2C5, 1);
 }
 
 static struct tegra_clk_init_table init_table[] = {
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#9 lore raw

PATCH 9/25 clk: tegra20: register i2c clocks

In reply to Lucas Stach
---
 drivers/clk/tegra/clk-tegra20.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
drivers/clk/tegra/clk-tegra20.c +13 -0
index cb0a571..5803414 100644
@@ -301,6 +301,19 @@ static void tegra20_periph_init(void)
 	clks[TEGRA20_CLK_SDMMC4] = tegra_clk_register_periph("sdmmc4",
 			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
 			CRC_CLK_SOURCE_SDMMC4, TEGRA20_CLK_SDMMC4, 1);
+
+	clks[TEGRA20_CLK_I2C1] = tegra_clk_register_periph_div16("i2c1",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C1, TEGRA20_CLK_I2C1, 1);
+	clks[TEGRA20_CLK_I2C2] = tegra_clk_register_periph_div16("i2c2",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C2, TEGRA20_CLK_I2C2, 1);
+	clks[TEGRA20_CLK_I2C3] = tegra_clk_register_periph_div16("i2c3",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_I2C3, TEGRA20_CLK_I2C3, 1);
+	clks[TEGRA20_CLK_DVC] = tegra_clk_register_periph_div16("dvc",
+			mux_pllpcm_clkm, ARRAY_SIZE(mux_pllpcm_clkm), car_base,
+			CRC_CLK_SOURCE_DVC, TEGRA20_CLK_DVC, 1);
 }
 
 static struct tegra_clk_init_table init_table[] = {
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#10 lore raw

PATCH 10/25 i2c: add Tegra driver

In reply to Lucas Stach
---
 drivers/i2c/busses/Kconfig     |   4 +
 drivers/i2c/busses/Makefile    |   1 +
 drivers/i2c/busses/i2c-tegra.c | 708 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 713 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-tegra.c
drivers/i2c/busses/Kconfig +4 -0
index 68d9b46..370abb0 100644
@@ -20,6 +20,10 @@ config I2C_OMAP
 	bool "OMAP I2C Master driver"
 	depends on ARCH_OMAP
 
+config I2C_TEGRA
+	bool "Tegra I2C master driver"
+	depends on ARCH_TEGRA
+
 config I2C_VERSATILE
 	tristate "ARM Versatile/Realview I2C bus support"
 	depends on ARCH_VERSATILE
drivers/i2c/busses/Makefile +1 -0
index a30f9b8..9823d1b 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
+obj-$(CONFIG_I2C_TEGRA)		+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)	+= i2c-versatile.o
drivers/i2c/busses/i2c-tegra.c new file +708 -0

708 lines not on this page · raw message

Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#11 lore raw

Re: [PATCH 10/25] i2c: add Tegra driver

Quoted 608 lines · Lucas Stach
---
 drivers/i2c/busses/Kconfig     |   4 +
 drivers/i2c/busses/Makefile    |   1 +
 drivers/i2c/busses/i2c-tegra.c | 708 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 713 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-tegra.c
drivers/i2c/busses/Kconfig +4 -0
index 68d9b46..370abb0 100644
@@ -20,6 +20,10 @@ config I2C_OMAP
 	bool "OMAP I2C Master driver"
 	depends on ARCH_OMAP
 
+config I2C_TEGRA
+	bool "Tegra I2C master driver"
+	depends on ARCH_TEGRA
+
 config I2C_VERSATILE
 	tristate "ARM Versatile/Realview I2C bus support"
 	depends on ARCH_VERSATILE
drivers/i2c/busses/Makefile +1 -0
index a30f9b8..9823d1b 100644
@@ -1,4 +1,5 @@
 obj-$(CONFIG_I2C_GPIO)		+= i2c-gpio.o
 obj-$(CONFIG_I2C_IMX) += i2c-imx.o
 obj-$(CONFIG_I2C_OMAP) += i2c-omap.o
+obj-$(CONFIG_I2C_TEGRA)		+= i2c-tegra.o
 obj-$(CONFIG_I2C_VERSATILE)	+= i2c-versatile.o
drivers/i2c/busses/i2c-tegra.c new file +569 -0
new file mode 100644
index 0000000..1f27a97
@@ -0,0 +1,708 @@
+/*
+ * Copyright (C) 2014 Lucas Stach <[email protected]>
+ *
+ * Partly based on code Copyright (C) 2010 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ */
+#include <common.h>
+#include <clock.h>
+#include <init.h>
+#include <io.h>
+#include <malloc.h>
+#include <i2c/i2c.h>
+#include <linux/kernel.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/reset.h>
+
+#include <asm/unaligned.h>
+
+#define TEGRA_I2C_TIMEOUT (msecs_to_jiffies(1000))
+#define BYTES_PER_FIFO_WORD 4
+
+#define I2C_CNFG				0x000
+#define I2C_CNFG_DEBOUNCE_CNT_SHIFT		12
+#define I2C_CNFG_PACKET_MODE_EN			(1<<10)
+#define I2C_CNFG_NEW_MASTER_FSM			(1<<11)
+#define I2C_STATUS				0x01C
+#define I2C_SL_CNFG				0x020
+#define I2C_SL_CNFG_NACK			(1<<1)
+#define I2C_SL_CNFG_NEWSL			(1<<2)
+#define I2C_SL_ADDR1				0x02c
+#define I2C_SL_ADDR2				0x030
+#define I2C_TX_FIFO				0x050
+#define I2C_RX_FIFO				0x054
+#define I2C_PACKET_TRANSFER_STATUS		0x058
+#define I2C_FIFO_CONTROL			0x05c
+#define I2C_FIFO_CONTROL_TX_FLUSH		(1<<1)
+#define I2C_FIFO_CONTROL_RX_FLUSH		(1<<0)
+#define I2C_FIFO_CONTROL_TX_TRIG_SHIFT		5
+#define I2C_FIFO_CONTROL_RX_TRIG_SHIFT		2
+#define I2C_FIFO_STATUS				0x060
+#define I2C_FIFO_STATUS_TX_MASK			0xF0
+#define I2C_FIFO_STATUS_TX_SHIFT		4
+#define I2C_FIFO_STATUS_RX_MASK			0x0F
+#define I2C_FIFO_STATUS_RX_SHIFT		0
+#define I2C_INT_MASK				0x064
+#define I2C_INT_STATUS				0x068
+#define I2C_INT_PACKET_XFER_COMPLETE		(1<<7)
+#define I2C_INT_ALL_PACKETS_XFER_COMPLETE	(1<<6)
+#define I2C_INT_TX_FIFO_OVERFLOW		(1<<5)
+#define I2C_INT_RX_FIFO_UNDERFLOW		(1<<4)
+#define I2C_INT_NO_ACK				(1<<3)
+#define I2C_INT_ARBITRATION_LOST		(1<<2)
+#define I2C_INT_TX_FIFO_DATA_REQ		(1<<1)
+#define I2C_INT_RX_FIFO_DATA_REQ		(1<<0)
+#define I2C_CLK_DIVISOR				0x06c
+#define I2C_CLK_DIVISOR_STD_FAST_MODE_SHIFT	16
+#define I2C_CLK_MULTIPLIER_STD_FAST_MODE	8
+
+#define DVC_CTRL_REG1				0x000
+#define DVC_CTRL_REG1_INTR_EN			(1<<10)
+#define DVC_CTRL_REG2				0x004
+#define DVC_CTRL_REG3				0x008
+#define DVC_CTRL_REG3_SW_PROG			(1<<26)
+#define DVC_CTRL_REG3_I2C_DONE_INTR_EN		(1<<30)
+#define DVC_STATUS				0x00c
+#define DVC_STATUS_I2C_DONE_INTR		(1<<30)
+
+#define I2C_ERR_NONE				0x00
+#define I2C_ERR_NO_ACK				0x01
+#define I2C_ERR_ARBITRATION_LOST		0x02
+#define I2C_ERR_UNKNOWN_INTERRUPT		0x04
+
+#define PACKET_HEADER0_HEADER_SIZE_SHIFT	28
+#define PACKET_HEADER0_PACKET_ID_SHIFT		16
+#define PACKET_HEADER0_CONT_ID_SHIFT		12
+#define PACKET_HEADER0_PROTOCOL_I2C		(1<<4)
+
+#define I2C_HEADER_HIGHSPEED_MODE		(1<<22)
+#define I2C_HEADER_CONT_ON_NAK			(1<<21)
+#define I2C_HEADER_SEND_START_BYTE		(1<<20)
+#define I2C_HEADER_READ				(1<<19)
+#define I2C_HEADER_10BIT_ADDR			(1<<18)
+#define I2C_HEADER_IE_ENABLE			(1<<17)
+#define I2C_HEADER_REPEAT_START			(1<<16)
+#define I2C_HEADER_CONTINUE_XFER		(1<<15)
+#define I2C_HEADER_MASTER_ADDR_SHIFT		12
+#define I2C_HEADER_SLAVE_ADDR_SHIFT		1
+/*
+ * msg_end_type: The bus control which need to be send at end of transfer.
+ * @MSG_END_STOP: Send stop pulse at end of transfer.
+ * @MSG_END_REPEAT_START: Send repeat start at end of transfer.
+ * @MSG_END_CONTINUE: The following on message is coming and so do not send
+ *		stop or repeat start.
+ */
+enum msg_end_type {
+	MSG_END_STOP,
+	MSG_END_REPEAT_START,
+	MSG_END_CONTINUE,
+};
+
+/**
+ * struct tegra_i2c_hw_feature : Different HW support on Tegra
+ * @has_continue_xfer_support: Continue transfer supports.
+ * @has_per_pkt_xfer_complete_irq: Has enable/disable capability for transfer
+ *		complete interrupt per packet basis.
+ * @has_single_clk_source: The i2c controller has single clock source. Tegra30
+ *		and earlier Socs has two clock sources i.e. div-clk and
+ *		fast-clk.
+ * @clk_divisor_hs_mode: Clock divisor in HS mode.
+ * @clk_divisor_std_fast_mode: Clock divisor in standard/fast mode. It is
+ *		applicable if there is no fast clock source i.e. single clock
+ *		source.
+ */
+
+struct tegra_i2c_hw_feature {
+	bool has_continue_xfer_support;
+	bool has_per_pkt_xfer_complete_irq;
+	bool has_single_clk_source;
+	int clk_divisor_hs_mode;
+	int clk_divisor_std_fast_mode;
+};
+
+/**
+ * struct tegra_i2c_dev	- per device i2c context
+ * @dev: device reference for power management
+ * @hw: Tegra i2c hw feature.
+ * @adapter: core i2c layer adapter information
+ * @div_clk: clock reference for div clock of i2c controller.
+ * @fast_clk: clock reference for fast clock of i2c controller.
+ * @base: ioremapped registers cookie
+ * @is_dvc: identifies the DVC i2c controller, has a different register layout
+ * @msg_err: error code for completed message
+ * @msg_buf: pointer to current message data
+ * @msg_buf_remaining: size of unsent data in the message buffer
+ * @msg_read: identifies read transfers
+ * @bus_clk_rate: current i2c bus clock rate
+ */
+struct tegra_i2c_dev {
+	struct device_d *dev;
+	const struct tegra_i2c_hw_feature *hw;
+	struct i2c_adapter adapter;
+	struct clk *div_clk;
+	struct clk *fast_clk;
+	struct reset_control *rst;
+	void __iomem *base;
+	int is_dvc;
+	int msg_err;
+	u8 *msg_buf;
+	size_t msg_buf_remaining;
+	int msg_read;
+	u32 bus_clk_rate;
+};
+#define to_tegra_i2c_dev(a)	container_of(a, struct tegra_i2c_dev, adapter)
+
+static void dvc_writel(struct tegra_i2c_dev *i2c_dev, u32 val, unsigned long reg)
+{
+	writel(val, i2c_dev->base + reg);
+}
+
+static u32 dvc_readl(struct tegra_i2c_dev *i2c_dev, unsigned long reg)
+{
+	return readl(i2c_dev->base + reg);
+}
+
+/*
+ * i2c_writel and i2c_readl will offset the register if necessary to talk
+ * to the I2C block inside the DVC block
+ */
+static unsigned long tegra_i2c_reg_addr(struct tegra_i2c_dev *i2c_dev,
+	unsigned long reg)
+{
+	if (i2c_dev->is_dvc)
+		reg += (reg >= I2C_TX_FIFO) ? 0x10 : 0x40;
+	return reg;
+}
+
+static void i2c_writel(struct tegra_i2c_dev *i2c_dev, u32 val,
+	unsigned long reg)
+{
+	writel(val, i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
+
+	/* Read back register to make sure that register writes completed */
+	if (reg != I2C_TX_FIFO)
+		readl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
+}
+
+static u32 i2c_readl(struct tegra_i2c_dev *i2c_dev, unsigned long reg)
+{
+	return readl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg));
+}
+
+static void i2c_writesl(struct tegra_i2c_dev *i2c_dev, void *data,
+	unsigned long reg, int len)
+{
+	writesl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len);
+}
+
+static void i2c_readsl(struct tegra_i2c_dev *i2c_dev, void *data,
+	unsigned long reg, int len)
+{
+	readsl(i2c_dev->base + tegra_i2c_reg_addr(i2c_dev, reg), data, len);
+}
+
+static int tegra_i2c_flush_fifos(struct tegra_i2c_dev *i2c_dev)
+{
+	uint64_t start = get_time_ns();
+	u32 val = i2c_readl(i2c_dev, I2C_FIFO_CONTROL);
+	val |= I2C_FIFO_CONTROL_TX_FLUSH | I2C_FIFO_CONTROL_RX_FLUSH;
+	i2c_writel(i2c_dev, val, I2C_FIFO_CONTROL);
+
+	while (i2c_readl(i2c_dev, I2C_FIFO_CONTROL) &
+		(I2C_FIFO_CONTROL_TX_FLUSH | I2C_FIFO_CONTROL_RX_FLUSH)) {
+		if (is_timeout(start, SECOND)) {
+			dev_warn(i2c_dev->dev, "timeout waiting for fifo flush\n");
+			return -ETIMEDOUT;
+		}
+		mdelay(1);
+	}
+	return 0;
+}
+
+static int tegra_i2c_empty_rx_fifo(struct tegra_i2c_dev *i2c_dev)
+{
+	u32 val;
+	int rx_fifo_avail;
+	u8 *buf = i2c_dev->msg_buf;
+	size_t buf_remaining = i2c_dev->msg_buf_remaining;
+	int words_to_transfer;
+
+	val = i2c_readl(i2c_dev, I2C_FIFO_STATUS);
+	rx_fifo_avail = (val & I2C_FIFO_STATUS_RX_MASK) >>
+		I2C_FIFO_STATUS_RX_SHIFT;
+
+	/* Rounds down to not include partial word at the end of buf */
+	words_to_transfer = buf_remaining / BYTES_PER_FIFO_WORD;
+	if (words_to_transfer > rx_fifo_avail)
+		words_to_transfer = rx_fifo_avail;
+
+	i2c_readsl(i2c_dev, buf, I2C_RX_FIFO, words_to_transfer);
+
+	buf += words_to_transfer * BYTES_PER_FIFO_WORD;
+	buf_remaining -= words_to_transfer * BYTES_PER_FIFO_WORD;
+	rx_fifo_avail -= words_to_transfer;
+
+	/*
+	 * If there is a partial word at the end of buf, handle it manually to
+	 * prevent overwriting past the end of buf
+	 */
+	if (rx_fifo_avail > 0 && buf_remaining > 0) {
+		BUG_ON(buf_remaining > 3);
+		val = i2c_readl(i2c_dev, I2C_RX_FIFO);
+		memcpy(buf, &val, buf_remaining);
+		buf_remaining = 0;
+		rx_fifo_avail--;
+	}
+
+	BUG_ON(rx_fifo_avail > 0 && buf_remaining > 0);
+	i2c_dev->msg_buf_remaining = buf_remaining;
+	i2c_dev->msg_buf = buf;
+	return 0;
+}
+
+static int tegra_i2c_fill_tx_fifo(struct tegra_i2c_dev *i2c_dev)
+{
+	u32 val;
+	int tx_fifo_avail;
+	u8 *buf = i2c_dev->msg_buf;
+	size_t buf_remaining = i2c_dev->msg_buf_remaining;
+	int words_to_transfer;
+
+	val = i2c_readl(i2c_dev, I2C_FIFO_STATUS);
+	tx_fifo_avail = (val & I2C_FIFO_STATUS_TX_MASK) >>
+		I2C_FIFO_STATUS_TX_SHIFT;
+
+	/* Rounds down to not include partial word at the end of buf */
+	words_to_transfer = buf_remaining / BYTES_PER_FIFO_WORD;
+
+	/* It's very common to have < 4 bytes, so optimize that case. */
+	if (words_to_transfer) {
+		if (words_to_transfer > tx_fifo_avail)
+			words_to_transfer = tx_fifo_avail;
+
+		/*
+		 * Update state before writing to FIFO.  If this casues us
+		 * to finish writing all bytes (AKA buf_remaining goes to 0) we
+		 * have a potential for an interrupt (PACKET_XFER_COMPLETE is
+		 * not maskable).  We need to make sure that the isr sees
+		 * buf_remaining as 0 and doesn't call us back re-entrantly.
+		 */
+		buf_remaining -= words_to_transfer * BYTES_PER_FIFO_WORD;
+		tx_fifo_avail -= words_to_transfer;
+		i2c_dev->msg_buf_remaining = buf_remaining;
+		i2c_dev->msg_buf = buf +
+			words_to_transfer * BYTES_PER_FIFO_WORD;
+		barrier();
+
+		i2c_writesl(i2c_dev, buf, I2C_TX_FIFO, words_to_transfer);
+
+		buf += words_to_transfer * BYTES_PER_FIFO_WORD;
+	}
+
+	/*
+	 * If there is a partial word at the end of buf, handle it manually to
+	 * prevent reading past the end of buf, which could cross a page
+	 * boundary and fault.
+	 */
+	if (tx_fifo_avail > 0 && buf_remaining > 0) {
+		BUG_ON(buf_remaining > 3);
+		memcpy(&val, buf, buf_remaining);
+
+		/* Again update before writing to FIFO to make sure isr sees. */
+		i2c_dev->msg_buf_remaining = 0;
+		i2c_dev->msg_buf = NULL;
+		barrier();
+
+		i2c_writel(i2c_dev, val, I2C_TX_FIFO);
+	}
+
+	return 0;
+}
+
+/*
+ * One of the Tegra I2C blocks is inside the DVC (Digital Voltage Controller)
+ * block.  This block is identical to the rest of the I2C blocks, except that
+ * it only supports master mode, it has registers moved around, and it needs
+ * some extra init to get it into I2C mode.  The register moves are handled
+ * by i2c_readl and i2c_writel
+ */
+static void tegra_dvc_init(struct tegra_i2c_dev *i2c_dev)
+{
+	u32 val = 0;
+	val = dvc_readl(i2c_dev, DVC_CTRL_REG3);
+	val |= DVC_CTRL_REG3_SW_PROG;
+	val |= DVC_CTRL_REG3_I2C_DONE_INTR_EN;
+	dvc_writel(i2c_dev, val, DVC_CTRL_REG3);
+
+	val = dvc_readl(i2c_dev, DVC_CTRL_REG1);
+	val |= DVC_CTRL_REG1_INTR_EN;
+	dvc_writel(i2c_dev, val, DVC_CTRL_REG1);
+}
+
+static inline int tegra_i2c_clock_enable(struct tegra_i2c_dev *i2c_dev)
+{
+	int ret;
+	if (!i2c_dev->hw->has_single_clk_source) {
+		ret = clk_enable(i2c_dev->fast_clk);
+		if (ret < 0) {
+			dev_err(i2c_dev->dev,
+				"Enabling fast clk failed, err %d\n", ret);
+			return ret;
+		}
+	}
+	ret = clk_enable(i2c_dev->div_clk);
+	if (ret < 0) {
+		dev_err(i2c_dev->dev,
+			"Enabling div clk failed, err %d\n", ret);
+		clk_disable(i2c_dev->fast_clk);
+	}
+	return ret;
+}
+
+static inline void tegra_i2c_clock_disable(struct tegra_i2c_dev *i2c_dev)
+{
+	clk_disable(i2c_dev->div_clk);
+	if (!i2c_dev->hw->has_single_clk_source)
+		clk_disable(i2c_dev->fast_clk);
+}
+
+static int tegra_i2c_init(struct tegra_i2c_dev *i2c_dev)
+{
+	u32 val;
+	int err = 0;
+	int clk_multiplier = I2C_CLK_MULTIPLIER_STD_FAST_MODE;
+	u32 clk_divisor;
+
+	err = tegra_i2c_clock_enable(i2c_dev);
+	if (err < 0) {
+		dev_err(i2c_dev->dev, "Clock enable failed %d\n", err);
+		return err;
+	}
+
+	reset_control_assert(i2c_dev->rst);
+	udelay(2);
+	reset_control_deassert(i2c_dev->rst);
+
+	if (i2c_dev->is_dvc)
+		tegra_dvc_init(i2c_dev);
+
+	val = I2C_CNFG_NEW_MASTER_FSM | I2C_CNFG_PACKET_MODE_EN |
+		(0x2 << I2C_CNFG_DEBOUNCE_CNT_SHIFT);
+	i2c_writel(i2c_dev, val, I2C_CNFG);
+	i2c_writel(i2c_dev, 0, I2C_INT_MASK);
+
+	clk_multiplier *= (i2c_dev->hw->clk_divisor_std_fast_mode + 1);
+	clk_set_rate(i2c_dev->div_clk, i2c_dev->bus_clk_rate * clk_multiplier);
+
+	/* Make sure clock divisor programmed correctly */
+	clk_divisor = i2c_dev->hw->clk_divisor_hs_mode;
+	clk_divisor |= i2c_dev->hw->clk_divisor_std_fast_mode <<
+					I2C_CLK_DIVISOR_STD_FAST_MODE_SHIFT;
+	i2c_writel(i2c_dev, clk_divisor, I2C_CLK_DIVISOR);
+
+	if (!i2c_dev->is_dvc) {
+		u32 sl_cfg = i2c_readl(i2c_dev, I2C_SL_CNFG);
+		sl_cfg |= I2C_SL_CNFG_NACK | I2C_SL_CNFG_NEWSL;
+		i2c_writel(i2c_dev, sl_cfg, I2C_SL_CNFG);
+		i2c_writel(i2c_dev, 0xfc, I2C_SL_ADDR1);
+		i2c_writel(i2c_dev, 0x00, I2C_SL_ADDR2);
+	}
+
+	val = 7 << I2C_FIFO_CONTROL_TX_TRIG_SHIFT |
+		0 << I2C_FIFO_CONTROL_RX_TRIG_SHIFT;
+	i2c_writel(i2c_dev, val, I2C_FIFO_CONTROL);
+
+	if (tegra_i2c_flush_fifos(i2c_dev))
+		err = -ETIMEDOUT;
+
+	tegra_i2c_clock_disable(i2c_dev);
+
+	return err;
+}
+
+static int tegra_i2c_wait_completion(struct tegra_i2c_dev *i2c_dev)
+{
+	u32 status;
+	const u32 status_err = I2C_INT_NO_ACK | I2C_INT_ARBITRATION_LOST;
+	uint64_t start = get_time_ns();
+
+	while (!is_timeout(start, SECOND)) {
+
+		status = i2c_readl(i2c_dev, I2C_INT_STATUS);
+
+		if (unlikely(status & status_err)) {
+			if (status & I2C_INT_NO_ACK)
+				i2c_dev->msg_err |= I2C_ERR_NO_ACK;
+			if (status & I2C_INT_ARBITRATION_LOST)
+				i2c_dev->msg_err |= I2C_ERR_ARBITRATION_LOST;
+			goto err;
+		}
+
+		if (i2c_dev->msg_read && (status & I2C_INT_RX_FIFO_DATA_REQ)) {
+			if (i2c_dev->msg_buf_remaining)
+				tegra_i2c_empty_rx_fifo(i2c_dev);
+			else
+				BUG();
+		}
+
+		if (!i2c_dev->msg_read && (status & I2C_INT_TX_FIFO_DATA_REQ)) {
+			if (i2c_dev->msg_buf_remaining)
+				tegra_i2c_fill_tx_fifo(i2c_dev);
+		}
+
+		i2c_writel(i2c_dev, status, I2C_INT_STATUS);
+		if (i2c_dev->is_dvc)
+			dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR,
+			           DVC_STATUS);
+
+		if (status & I2C_INT_PACKET_XFER_COMPLETE) {
+			BUG_ON(i2c_dev->msg_buf_remaining);
+			return 0;
+		}
+	}
+	return -ETIMEDOUT;
+
+err:
+	i2c_writel(i2c_dev, status, I2C_INT_STATUS);
+	if (i2c_dev->is_dvc)
+		dvc_writel(i2c_dev, DVC_STATUS_I2C_DONE_INTR, DVC_STATUS);
+
+	return 0;
+}
+
+static int tegra_i2c_xfer_msg(struct tegra_i2c_dev *i2c_dev,
+	struct i2c_msg *msg, enum msg_end_type end_state)
+{
+	u32 packet_header;
+	int ret;
+
+	tegra_i2c_flush_fifos(i2c_dev);
+
+	if (msg->len == 0)
+		return -EINVAL;
+
+	i2c_dev->msg_buf = msg->buf;
+	i2c_dev->msg_buf_remaining = msg->len;
+	i2c_dev->msg_err = I2C_ERR_NONE;
+	i2c_dev->msg_read = (msg->flags & I2C_M_RD);
+
+	packet_header = (0 << PACKET_HEADER0_HEADER_SIZE_SHIFT) |
+			PACKET_HEADER0_PROTOCOL_I2C |
+			(i2c_dev->adapter.nr << PACKET_HEADER0_CONT_ID_SHIFT) |
+			(1 << PACKET_HEADER0_PACKET_ID_SHIFT);
+	i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO);
+
+	packet_header = msg->len - 1;
+	i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO);
+
+	packet_header = I2C_HEADER_IE_ENABLE;
+	if (end_state == MSG_END_CONTINUE)
+		packet_header |= I2C_HEADER_CONTINUE_XFER;
+	else if (end_state == MSG_END_REPEAT_START)
+		packet_header |= I2C_HEADER_REPEAT_START;
+	if (msg->flags & I2C_M_TEN) {
+		packet_header |= msg->addr;
+		packet_header |= I2C_HEADER_10BIT_ADDR;
+	} else {
+		packet_header |= msg->addr << I2C_HEADER_SLAVE_ADDR_SHIFT;
+	}
+	if (msg->flags & I2C_M_IGNORE_NAK)
+		packet_header |= I2C_HEADER_CONT_ON_NAK;
+	if (msg->flags & I2C_M_RD)
+		packet_header |= I2C_HEADER_READ;
+	i2c_writel(i2c_dev, packet_header, I2C_TX_FIFO);
+
+	if (!(msg->flags & I2C_M_RD))
+		tegra_i2c_fill_tx_fifo(i2c_dev);
+
+	ret = tegra_i2c_wait_completion(i2c_dev);
+	if (ret) {
+		dev_err(i2c_dev->dev, "i2c transfer timed out\n");
+
+		tegra_i2c_init(i2c_dev);
+		return -ETIMEDOUT;
+	}
+
+	if (likely(i2c_dev->msg_err == I2C_ERR_NONE))
+		return 0;
+
+	/*
+	 * NACK interrupt is generated before the I2C controller generates the
+	 * STOP condition on the bus. So wait for 2 clock periods before resetting
+	 * the controller so that STOP condition has been delivered properly.
+	 */
+	if (i2c_dev->msg_err == I2C_ERR_NO_ACK)
+		udelay(DIV_ROUND_UP(2 * 1000000, i2c_dev->bus_clk_rate));
+
+	tegra_i2c_init(i2c_dev);
+	if (i2c_dev->msg_err == I2C_ERR_NO_ACK) {
+		if (msg->flags & I2C_M_IGNORE_NAK)
+			return 0;
+		return -EREMOTEIO;
+	}
+
+	return -EIO;
+}
+
+static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
+	int num)
+{
+	struct tegra_i2c_dev *i2c_dev = to_tegra_i2c_dev(adap);
+	int i;
+	int ret = 0;
+
+	ret = tegra_i2c_clock_enable(i2c_dev);
+	if (ret < 0) {
+		dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
+		return ret;
+	}
+

drivers/i2c/busses/i2c-tegra.c line 579

Quoted 10 lines
drivers/i2c/busses/i2c-tegra.c new file +10 -0
+	for (i = 0; i < num; i++) {
+		enum msg_end_type end_type = MSG_END_STOP;
+		if (i < (num - 1))
+			end_type = MSG_END_REPEAT_START;
+		ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);
+		if (ret)
+			break;
+	}
+	tegra_i2c_clock_disable(i2c_dev);
+	return ret ?: i;

What does this return when ret is true? ret? I've never seen this.

drivers/i2c/busses/i2c-tegra.c line 629

Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c new file +5 -0
+	i2c_dev = xzalloc(sizeof(*i2c_dev));
+	if (!i2c_dev) {
+		dev_err(dev, "Could not allocate struct tegra_i2c_dev");
+		return -ENOMEM;
+	}

No need to check the result of xzalloc.

drivers/i2c/busses/i2c-tegra.c line 568

Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c new file +5 -0
+	ret = tegra_i2c_clock_enable(i2c_dev);
+		if (ret < 0) {
+			dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
+			return ret;
+		}

Indentation broken here. tegra_i2c_init below also calls tegra_i2c_clock_enable, so this should be unnecessary here, right?

drivers/i2c/busses/i2c-tegra.c line 670

Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c new file +6 -0
+	ret = tegra_i2c_init(i2c_dev);
+	if (ret) {
+		dev_err(dev, "Failed to initialize i2c controller");
+		return ret;
+	}
+

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#12 lore raw

Re: [PATCH 10/25] i2c: add Tegra driver

Am Montag, den 12.05.2014, 13:49 +0200 schrieb Sascha Hauer:

Quoted 9 lines · Lucas Stach
Quoted 8 lines
---
 drivers/i2c/busses/Kconfig     |   4 +
 drivers/i2c/busses/Makefile    |   1 +
 drivers/i2c/busses/i2c-tegra.c | 708 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 713 insertions(+)
 create mode 100644 drivers/i2c/busses/i2c-tegra.c

[...]

Quoted 18 lines
Quoted 18 lines
drivers/i2c/busses/i2c-tegra.c new file +18 -0
+
+static int tegra_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msgs[],
+	int num)
+{
+	struct tegra_i2c_dev *i2c_dev = to_tegra_i2c_dev(adap);
+	int i;
+	int ret = 0;
+
+	ret = tegra_i2c_clock_enable(i2c_dev);
+	if (ret < 0) {
+		dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
+		return ret;
+	}
+
+	for (i = 0; i < num; i++) {
+		enum msg_end_type end_type = MSG_END_STOP;
+		if (i < (num - 1))
+			end_type = MSG_END_REPEAT_START;
Quoted 8 lines

drivers/i2c/busses/i2c-tegra.c line 579

Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c new file +6 -0
+		ret = tegra_i2c_xfer_msg(i2c_dev, &msgs[i], end_type);
+		if (ret)
+			break;
+	}
+	tegra_i2c_clock_disable(i2c_dev);
+	return ret ?: i;

What does this return when ret is true? ret? I've never seen this.

This is present in the Linux source this is based on. I've just had to look it up and apparently it's a GNU extension which uses the first operand implicitly as the second. So yep, this is returning ret if true. Will change this as it's really confusing.

Quoted 9 lines

drivers/i2c/busses/i2c-tegra.c line 629

Quoted 6 lines
drivers/i2c/busses/i2c-tegra.c new file +5 -0
+	i2c_dev = xzalloc(sizeof(*i2c_dev));
+	if (!i2c_dev) {
+		dev_err(dev, "Could not allocate struct tegra_i2c_dev");
+		return -ENOMEM;
+	}

No need to check the result of xzalloc.

Ok, will remove.

Quoted 8 lines

drivers/i2c/busses/i2c-tegra.c line 568

Quoted 5 lines
drivers/i2c/busses/i2c-tegra.c new file +5 -0
+	ret = tegra_i2c_clock_enable(i2c_dev);
+		if (ret < 0) {
+			dev_err(i2c_dev->dev, "Clock enable failed %d\n", ret);
+			return ret;
+		}

Indentation broken here. tegra_i2c_init below also calls tegra_i2c_clock_enable, so this should be unnecessary here, right?

Right, this is a leftover from debugging. Thanks for spotting.

Quoted 10 lines

drivers/i2c/busses/i2c-tegra.c line 670

Quoted 7 lines
drivers/i2c/busses/i2c-tegra.c new file +6 -0
+	ret = tegra_i2c_init(i2c_dev);
+	if (ret) {
+		dev_err(dev, "Failed to initialize i2c controller");
+		return ret;
+	}
+

Sascha

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#13 lore raw

PATCH 11/25 ARM: tegra: beaver: activate sdmmc1 voltage rail

In reply to Lucas Stach

In order to get the SD card solt working.

---
One day we might move this to a regulator, but now isn't the time.

---
 arch/arm/boards/nvidia-beaver/Makefile |  1 +
 arch/arm/boards/nvidia-beaver/board.c  | 38 ++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)
 create mode 100644 arch/arm/boards/nvidia-beaver/board.c
arch/arm/boards/nvidia-beaver/Makefile +1 -0
index d2d2173..2b6c09e 100644
@@ -2,3 +2,4 @@ CFLAGS_pbl-entry.o := \
 	-mcpu=arm7tdmi -march=armv4t \
 	-fno-tree-switch-conversion -fno-jump-tables
 lwl-y += entry.o
+obj-y += board.o
arch/arm/boards/nvidia-beaver/board.c new file +38 -0
new file mode 100644
index 0000000..e87594d
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2014 Lucas Stach <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <common.h>
+#include <init.h>
+#include <i2c/i2c.h>
+
+static int nvidia_beaver_devices_init(void)
+{
+	struct i2c_client client;
+	u8 data;
+
+	if (!of_machine_is_compatible("nvidia,beaver"))
+		return 0;
+
+	client.adapter = i2c_get_adapter(4);
+	client.addr = 0x2d;
+
+	/* TPS659110: LDO5_REG = 3.3v, ACTIVE to SDMMC1 */
+	data = 0x65;
+	i2c_write_reg(&client, 0x32, &data, 1);
+
+	return 0;
+}
+device_initcall(nvidia_beaver_devices_init);
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#14 lore raw

PATCH 12/25 ARM: tegra: beaver: adjust pinmux to make sdmmc1 work

In reply to Lucas Stach
---
 arch/arm/dts/tegra30-beaver.dts | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/dts/tegra30-beaver.dts +10 -0
index 1110b89..35b4d7e 100644
@@ -191,6 +191,15 @@
 						"pex_l1_clkreq_n_pdd6";
 				nvidia,pull = <TEGRA_PIN_PULL_UP>;
 			};
+			sdio1 {
+				nvidia,pins = "drive_sdio1";
+				nvidia,high-speed-mode = <TEGRA_PIN_DISABLE>;
+				nvidia,schmitt = <TEGRA_PIN_DISABLE>;
+				nvidia,pull-down-strength = <46>;
+				nvidia,pull-up-strength = <42>;
+				nvidia,slew-rate-rising = <1>;
+				nvidia,slew-rate-falling = <1>;
+			};
 			sdio3 {
 				nvidia,pins = "drive_sdio3";
 				nvidia,high-speed-mode = <TEGRA_PIN_DISABLE>;
@@ -325,6 +334,7 @@
 						"vi_hsync_pd7";
 				nvidia,function = "ddr";
 				nvidia,tristate = <TEGRA_PIN_DISABLE>;
+				nvidia,io-reset = <TEGRA_PIN_DISABLE>;
 			};
 			ddr_up {
 				nvidia,pins =	"vi_d11_pt3";
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#15 lore raw

PATCH 13/25 mci: tegra: apply pad autocalibration on T30

In reply to Lucas Stach

Needed for SD cards connected to sdmmc1 or sdmmc3
to work properly.

---
 drivers/mci/tegra-sdmmc.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
drivers/mci/tegra-sdmmc.c +25 -0
index 0ea0b5c..6345157 100644
@@ -59,6 +59,14 @@
 #define TEGRA_SDMMC_INT_SIG_EN				0x038
 #define  TEGRA_SDMMC_INT_SIG_EN_XFER_COMPLETE		(1 << 1)
 
+#define TEGRA_SDMMC_SDMEMCOMPPADCTRL			0x1e0
+#define  TEGRA_SDMMC_SDMEMCOMPPADCTRL_VREF_SEL_SHIFT	0
+
+#define TEGRA_SDMMC_AUTO_CAL_CONFIG			0x1e4
+#define  TEGRA_SDMMC_AUTO_CAL_CONFIG_PU_OFFSET_SHIFT	0
+#define  TEGRA_SDMMC_AUTO_CAL_CONFIG_PD_OFFSET_SHIFT	8
+#define  TEGRA_SDMMC_AUTO_CAL_CONFIG_ENABLE		(1 << 29)
+
 struct tegra_sdmmc_host {
 	struct mci_host		mci;
 	void __iomem		*regs;
@@ -333,6 +341,23 @@ static int tegra_sdmmc_init(struct mci_host *mci, struct device_d *dev)
 	val |= TEGRA_SDMMC_PWR_CNTL_33_V | TEGRA_SDMMC_PWR_CNTL_SD_BUS;
 	writel(val, regs + TEGRA_SDMMC_PWR_CNTL);
 
+	/* sdmmc1 and sdmmc3 on T30 need a bit of padctrl init */
+	if (of_device_is_compatible(mci->hw_dev->device_node,
+			"nvidia,tegra30-sdhci") &&
+			((u32)regs == 0x78000000 || (u32)regs == 78000400)) {
+		val = readl(regs + TEGRA_SDMMC_SDMEMCOMPPADCTRL);
+		val &= 0xfffffff0;
+		val |= 0x7 << TEGRA_SDMMC_SDMEMCOMPPADCTRL_VREF_SEL_SHIFT;
+		writel(val, regs + TEGRA_SDMMC_SDMEMCOMPPADCTRL);
+
+		val = readl(regs + TEGRA_SDMMC_AUTO_CAL_CONFIG);
+		val &= 0xffff0000;
+		val |= (0x62 << TEGRA_SDMMC_AUTO_CAL_CONFIG_PU_OFFSET_SHIFT) |
+		       (0x70 << TEGRA_SDMMC_AUTO_CAL_CONFIG_PD_OFFSET_SHIFT) |
+		       TEGRA_SDMMC_AUTO_CAL_CONFIG_ENABLE;
+		writel(val, regs + TEGRA_SDMMC_AUTO_CAL_CONFIG);
+	}
+
 	/* setup signaling */
 	writel(0xffffffff, regs + TEGRA_SDMMC_INT_STAT_EN);
 	writel(0xffffffff, regs + TEGRA_SDMMC_INT_SIG_EN);
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#16 lore raw

PATCH 14/25 mci: tegra: don't set 8bit mode unconditionally

In reply to Lucas Stach

Those flags should be set from the DT parsing code.

---
 drivers/mci/tegra-sdmmc.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mci/tegra-sdmmc.c +1 -2
index 6345157..62cf730 100644
@@ -470,8 +470,7 @@ static int tegra_sdmmc_probe(struct device_d *dev)
 	mci->set_ios = tegra_sdmmc_set_ios;
 	mci->send_cmd = tegra_sdmmc_send_cmd;
 	mci->voltages = MMC_VDD_32_33 | MMC_VDD_33_34 | MMC_VDD_165_195;
-	mci->host_caps |= MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA |
-	                  MMC_CAP_MMC_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED_52MHZ |
+	mci->host_caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED_52MHZ |
 	                  MMC_CAP_SD_HIGHSPEED;
 
 	dev->priv = host;
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#17 lore raw

PATCH 15/25 pinctrl: tegra30: parse drive groups

In reply to Lucas Stach

These are special groups to configure pad properties such as drive strength and slew rate for a group of pads.

---
 drivers/pinctrl/pinctrl-tegra30.c | 159 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 158 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-tegra30.c +158 -1
index 032377f..888bf04 100644
@@ -37,6 +37,23 @@ struct tegra30_pingroup {
 	u16 reg;
 };
 
+struct tegra30_drive_pingroup {
+	const char *name;
+	u16 reg;
+	u32 hsm_bit:5;
+	u32 schmitt_bit:5;
+	u32 lpmd_bit:5;
+	u32 drvdn_bit:5;
+	u32 drvup_bit:5;
+	u32 slwr_bit:5;
+	u32 slwf_bit:5;
+	u32 drvtype_bit:5;
+	u32 drvdn_width:6;
+	u32 drvup_width:6;
+	u32 slwr_width:6;
+	u32 slwf_width:6;
+};
+
 #define PG(pg_name, f0, f1, f2, f3, offset)		\
 	{						\
 		.name = #pg_name,			\
@@ -44,6 +61,25 @@ struct tegra30_pingroup {
 		.reg = offset				\
 	}
 
+#define DRV_PG(pg_name, r, hsm_b, schmitt_b, lpmd_b,	\
+               drvdn_b, drvdn_w, drvup_b, drvup_w,	\
+               slwr_b, slwr_w, slwf_b, slwf_w)		\
+	{						\
+		.name = "drive_" #pg_name,		\
+		.reg = r - 0x868,			\
+		.hsm_bit = hsm_b,			\
+		.schmitt_bit = schmitt_b,		\
+		.lpmd_bit = lpmd_b,			\
+		.drvdn_bit = drvdn_b,			\
+		.drvdn_width = drvdn_w,			\
+		.drvup_bit = drvup_b,			\
+		.drvup_width = drvup_w,			\
+		.slwr_bit = slwr_b,			\
+		.slwr_width = slwr_w,			\
+		.slwf_bit = slwf_b,			\
+		.slwf_width = slwf_w,			\
+	}
+
 static const struct tegra30_pingroup tegra30_groups[] = {
 	/* name,                 f0,        f1,        f2,        f3,           reg  */
 	PG(clk_32k_out_pa0,      blink,     rsvd2,     rsvd3,     rsvd4,        0x31c),
@@ -297,6 +333,122 @@ static const struct tegra30_pingroup tegra30_groups[] = {
 	PG(pwr_int_n,            pwr_int_n, rsvd2,     rsvd3,     rsvd4,        0x32c),
 };
 
+static const struct tegra30_drive_pingroup tegra30_drive_groups[] = {
+	DRV_PG(ao1,   0x868,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(ao2,   0x86c,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(at1,   0x870,  2,  3,  4,  14,  5,  19,  5,  24,  2,  28,  2),
+	DRV_PG(at2,   0x874,  2,  3,  4,  14,  5,  19,  5,  24,  2,  28,  2),
+	DRV_PG(at3,   0x878,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(at4,   0x87c,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(at5,   0x880,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(cdev1, 0x884,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(cdev2, 0x888,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(cec,   0x938,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(crt,   0x8f8,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(csus,  0x88c, -1, -1, -1,  12,  5,  19,  5,  24,  4,  28,  4),
+	DRV_PG(dap1,  0x890,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(dap2,  0x894,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(dap3,  0x898,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(dap4,  0x89c,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(dbg,   0x8a0,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(ddc,   0x8fc,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(dev3,  0x92c,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(gma,   0x900, -1, -1, -1,  14,  5,  19,  5,  24,  4,  28,  4),
+	DRV_PG(gmb,   0x904, -1, -1, -1,  14,  5,  19,  5,  24,  4,  28,  4),
+	DRV_PG(gmc,   0x908, -1, -1, -1,  14,  5,  19,  5,  24,  4,  28,  4),
+	DRV_PG(gmd,   0x90c, -1, -1, -1,  14,  5,  19,  5,  24,  4,  28,  4),
+	DRV_PG(gme,   0x910,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(gmf,   0x914,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(gmg,   0x918,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(gmh,   0x91c,  2,  3,  4,  14,  5,  19,  5,  28,  2,  30,  2),
+	DRV_PG(gpv,   0x928,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(lcd1,  0x8a4,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(lcd2,  0x8a8,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(owr,   0x920,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(sdio1, 0x8ec,  2,  3, -1,  12,  7,  20,  7,  28,  2,  30,  2),
+	DRV_PG(sdio2, 0x8ac,  2,  3, -1,  12,  7,  20,  7,  28,  2,  30,  2),
+	DRV_PG(sdio3, 0x8b0,  2,  3, -1,  12,  7,  20,  7,  28,  2,  30,  2),
+	DRV_PG(spi,   0x8b4,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(uaa,   0x8b8,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(uab,   0x8bc,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(uart2, 0x8c0,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(uart3, 0x8c4,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(uda,   0x924,  2,  3,  4,  12,  5,  20,  5,  28,  2,  30,  2),
+	DRV_PG(vi1,   0x8c8, -1, -1, -1,  14,  5,  19,  5,  24,  4,  28,  4),
+};
+
+static int pinctrl_tegra30_set_drvstate(struct pinctrl_tegra30 *ctrl,
+                                        struct device_node *np)
+{
+	const char *pins = NULL;
+	const struct tegra30_drive_pingroup *group = NULL;
+	int hsm = -1, schmitt = -1, pds = -1, pus = -1, srr = -1, srf = -1;
+	int i;
+	u32 __iomem *regaddr;
+	u32 val;
+
+	if (of_property_read_string(np, "nvidia,pins", &pins))
+		return 0;
+
+	for (i = 0; i < ARRAY_SIZE(tegra30_drive_groups); i++) {
+		if (!strcmp(pins, tegra30_drive_groups[i].name)) {
+			group = &tegra30_drive_groups[i];
+			break;
+		}
+	}
+	/* if no matching drivegroup is found */
+	if (i == ARRAY_SIZE(tegra30_groups))
+		return 0;
+
+	regaddr = ctrl->regs.ctrl + (group->reg >> 2);
+
+	of_property_read_u32_array(np, "nvidia,high-speed-mode", &hsm, 1);
+	of_property_read_u32_array(np, "nvidia,schmitt", &schmitt, 1);
+	of_property_read_u32_array(np, "nvidia,pull-down-strength", &pds, 1);
+	of_property_read_u32_array(np, "nvidia,pull-up-strength", &pus, 1);
+	of_property_read_u32_array(np, "nvidia,slew-rate-rising", &srr, 1);
+	of_property_read_u32_array(np, "nvidia,slew-rate-falling", &srf, 1);
+
+	if (hsm >= 0) {
+		val = readl(regaddr);
+		val &= ~(0x1 << group->hsm_bit);
+		val |= hsm << group->hsm_bit;
+		writel(val, regaddr);
+	}
+	if (schmitt >= 0) {
+		val = readl(regaddr);
+		val &= ~(0x1 << group->schmitt_bit);
+		val |= hsm << group->schmitt_bit;
+		writel(val, regaddr);
+	}
+	if (pds >= 0) {
+		val = readl(regaddr);
+		val &= ~(((1 << group->drvdn_width) - 1) << group->drvdn_bit);
+		val |= hsm << group->drvdn_bit;
+		writel(val, regaddr);
+	}
+	if (pus >= 0) {
+		val = readl(regaddr);
+		val &= ~(((1 << group->drvup_width) - 1) << group->drvup_bit);
+		val |= hsm << group->drvup_bit;
+		writel(val, regaddr);
+	}
+	if (srr >= 0) {
+		val = readl(regaddr);
+		val &= ~(((1 << group->slwr_width) - 1) << group->slwr_bit);
+		val |= hsm << group->slwr_bit;
+		writel(val, regaddr);
+	}
+	if (srf >= 0) {
+		val = readl(regaddr);
+		val &= ~(((1 << group->slwf_width) - 1) << group->slwf_bit);
+		val |= hsm << group->slwf_bit;
+		writel(val, regaddr);
+	}
+
+	return 1;
+}
+
 static void pinctrl_tegra30_set_func(struct pinctrl_tegra30 *ctrl,
 				     u32 reg, int func)
 {
@@ -405,8 +557,13 @@ static int pinctrl_tegra30_set_state(struct pinctrl_device *pdev,
 				break;
 			}
 		}
-		/* if no matching pingroup is found bail out */
+		/* if no matching pingroup is found */
 		if (j == ARRAY_SIZE(tegra30_groups)) {
+			/* see if we can find a drivegroup */
+			if (pinctrl_tegra30_set_drvstate(ctrl, np))
+				continue;
+
+			/* nothing matching found, warn and bail out */
 			dev_warn(ctrl->pinctrl.dev,
 				 "invalid pingroup %s referenced in node %s\n",
 				 pins, np->name);
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#18 lore raw

PATCH 16/25 scripts: tegra: import cbootimage

In reply to Lucas Stach

Needed to built the BCTs and bootable images.

Version 1.2 from https://github.com/NVIDIA/cbootimage.git

---
 scripts/Makefile                             |    1 +
 scripts/tegra/Makefile                       |   22 +
 scripts/tegra/aes_ref.c                      |  326 ++++++++
 scripts/tegra/bct_dump.c                     |  296 +++++++
 scripts/tegra/cbootimage.c                   |  247 ++++++
 scripts/tegra/cbootimage.h                   |  108 +++
 scripts/tegra/context.c                      |   42 +
 scripts/tegra/context.h                      |   28 +
 scripts/tegra/crypto.c                       |  299 +++++++
 scripts/tegra/crypto.h                       |   47 ++
 scripts/tegra/data_layout.c                  |  898 +++++++++++++++++++++
 scripts/tegra/data_layout.h                  |   55 ++
 scripts/tegra/nvaes_ref.h                    |   35 +
 scripts/tegra/parse.c                        |  803 +++++++++++++++++++
 scripts/tegra/parse.h                        |  923 +++++++++++++++++++++
 scripts/tegra/set.c                          |  206 +++++
 scripts/tegra/set.h                          |   49 ++
 scripts/tegra/t114/nvbctlib_t114.c           | 1103 +++++++++++++++++++++++++
 scripts/tegra/t114/nvboot_bct_t114.h         |  363 +++++++++
 scripts/tegra/t114/nvboot_sdram_param_t114.h |  806 +++++++++++++++++++
 scripts/tegra/t114/parse_t114.c              |  430 ++++++++++
 scripts/tegra/t124/nvbctlib_t124.c           | 1104 ++++++++++++++++++++++++++
 scripts/tegra/t124/nvboot_bct_t124.h         |  359 +++++++++
 scripts/tegra/t124/nvboot_sdram_param_t124.h |  803 +++++++++++++++++++
 scripts/tegra/t124/parse_t124.c              |  429 ++++++++++
 scripts/tegra/t20/nvbctlib_t20.c             |  684 ++++++++++++++++
 scripts/tegra/t20/nvboot_bct_t20.h           |  316 ++++++++
 scripts/tegra/t20/nvboot_sdram_param_t20.h   |  363 +++++++++
 scripts/tegra/t20/parse_t20.c                |  251 ++++++
 scripts/tegra/t30/nvbctlib_t30.c             |  891 +++++++++++++++++++++
 scripts/tegra/t30/nvboot_bct_t30.h           |  379 +++++++++
 scripts/tegra/t30/nvboot_sdram_param_t30.h   |  568 +++++++++++++
 scripts/tegra/t30/parse_t30.c                |  360 +++++++++
 33 files changed, 13594 insertions(+)
 create mode 100644 scripts/tegra/Makefile
 create mode 100644 scripts/tegra/aes_ref.c
 create mode 100644 scripts/tegra/bct_dump.c
 create mode 100644 scripts/tegra/cbootimage.c
 create mode 100644 scripts/tegra/cbootimage.h
 create mode 100644 scripts/tegra/context.c
 create mode 100644 scripts/tegra/context.h
 create mode 100644 scripts/tegra/crypto.c
 create mode 100644 scripts/tegra/crypto.h
 create mode 100644 scripts/tegra/data_layout.c
 create mode 100644 scripts/tegra/data_layout.h
 create mode 100644 scripts/tegra/nvaes_ref.h
 create mode 100644 scripts/tegra/parse.c
 create mode 100644 scripts/tegra/parse.h
 create mode 100644 scripts/tegra/set.c
 create mode 100644 scripts/tegra/set.h
 create mode 100644 scripts/tegra/t114/nvbctlib_t114.c
 create mode 100644 scripts/tegra/t114/nvboot_bct_t114.h
 create mode 100644 scripts/tegra/t114/nvboot_sdram_param_t114.h
 create mode 100644 scripts/tegra/t114/parse_t114.c
 create mode 100644 scripts/tegra/t124/nvbctlib_t124.c
 create mode 100644 scripts/tegra/t124/nvboot_bct_t124.h
 create mode 100644 scripts/tegra/t124/nvboot_sdram_param_t124.h
 create mode 100644 scripts/tegra/t124/parse_t124.c
 create mode 100644 scripts/tegra/t20/nvbctlib_t20.c
 create mode 100644 scripts/tegra/t20/nvboot_bct_t20.h
 create mode 100644 scripts/tegra/t20/nvboot_sdram_param_t20.h
 create mode 100644 scripts/tegra/t20/parse_t20.c
 create mode 100644 scripts/tegra/t30/nvbctlib_t30.c
 create mode 100644 scripts/tegra/t30/nvboot_bct_t30.h
 create mode 100644 scripts/tegra/t30/nvboot_sdram_param_t30.h
 create mode 100644 scripts/tegra/t30/parse_t30.c
scripts/Makefile +1 -0
index 3908c1d..c02c7f3 100644
@@ -24,6 +24,7 @@ subdir-$(CONFIG_OMAP4_USBBOOT)	+= omap4_usbboot
 subdir-$(CONFIG_ARCH_IMX)	+= imx
 subdir-$(CONFIG_X86)		+= setupmbr
 subdir-$(CONFIG_DTC)		+= dtc
+subdir-$(CONFIG_ARCH_TEGRA)	+= tegra
 
 targetprogs-$(CONFIG_BAREBOXENV_TARGET) += bareboxenv-target
 targetprogs-$(CONFIG_KERNEL_INSTALL_TARGET) += kernel-install-target
scripts/tegra/Makefile new file +22 -0
new file mode 100644
index 0000000..99aef3f
@@ -0,0 +1,22 @@
+hostprogs-$(CONFIG_ARCH_TEGRA) += cbootimage
+
+always          := $(hostprogs-y)
+
+HOSTLOADLIBES_cbootimage  = '-lm'
+
+cbootimage-objs := \
+	cbootimage.o \
+	data_layout.o \
+	set.o \
+	crypto.o \
+	aes_ref.o \
+	context.o \
+	parse.o \
+	t124/parse_t124.o \
+	t114/parse_t114.o \
+	t30/parse_t30.o \
+	t20/parse_t20.o \
+	t124/nvbctlib_t124.o \
+	t114/nvbctlib_t114.o \
+	t30/nvbctlib_t30.o \
+	t20/nvbctlib_t20.o
scripts/tegra/aes_ref.c new file +326 -0

326 lines not on this page · raw message

scripts/tegra/bct_dump.c new file +296 -0

296 lines not on this page · raw message

scripts/tegra/cbootimage.c new file +247 -0

247 lines not on this page · raw message

scripts/tegra/cbootimage.h new file +108 -0

108 lines not on this page · raw message

scripts/tegra/context.c new file +42 -0

42 lines not on this page · raw message

scripts/tegra/context.h new file +28 -0
new file mode 100644
index 0000000..6e72471
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ */
+
+#ifndef INCLUDED_CONTEXT_H
+#define INCLUDED_CONTEXT_H
+
+#include "cbootimage.h"
+
+int init_context(build_image_context *context);
+void cleanup_context(build_image_context *context);
+
+#endif /* #ifndef INCLUDED_CONTEXT_H */
scripts/tegra/crypto.c new file +299 -0

299 lines not on this page · raw message

scripts/tegra/crypto.h new file +47 -0

47 lines not on this page · raw message

scripts/tegra/data_layout.c new file +898 -0

898 lines not on this page · raw message

scripts/tegra/data_layout.h new file +55 -0

55 lines not on this page · raw message

scripts/tegra/nvaes_ref.h new file +35 -0
new file mode 100644
index 0000000..76bd6c3
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ */
+
+#include "cbootimage.h"
+#include "string.h"
+
+#ifndef INCLUDED_NVAES_REF_H
+#define INCLUDED_NVAES_REF_H
+
+#define NVAES_STATECOLS	4
+#define NVAES_KEYCOLS	4
+#define NVAES_ROUNDS	10
+
+void nv_aes_expand_key(u_int8_t *key, u_int8_t *expkey);
+void nv_aes_encrypt(u_int8_t *in,
+		u_int8_t *expkey,
+		u_int8_t *out);
+
+#endif // INCLUDED_NVAES_REF_H
scripts/tegra/parse.c new file +803 -0

590 lines not on this page · raw message

scripts/tegra/parse.h new file +923 -0

923 lines not on this page · raw message

scripts/tegra/set.c new file +206 -0

206 lines not on this page · raw message

scripts/tegra/set.h new file +49 -0

49 lines not on this page · raw message

scripts/tegra/t114/nvbctlib_t114.c new file +1103 -0

1,103 lines not on this page · raw message

scripts/tegra/t114/nvboot_bct_t114.h new file +363 -0

363 lines not on this page · raw message

scripts/tegra/t114/nvboot_sdram_param_t114.h new file +806 -0

806 lines not on this page · raw message

scripts/tegra/t114/parse_t114.c new file +430 -0

430 lines not on this page · raw message

scripts/tegra/t124/nvbctlib_t124.c new file +1104 -0

1,104 lines not on this page · raw message

scripts/tegra/t124/nvboot_bct_t124.h new file +359 -0

359 lines not on this page · raw message

scripts/tegra/t124/nvboot_sdram_param_t124.h new file +803 -0

803 lines not on this page · raw message

scripts/tegra/t124/parse_t124.c new file +429 -0

429 lines not on this page · raw message

scripts/tegra/t20/nvbctlib_t20.c new file +684 -0

684 lines not on this page · raw message

scripts/tegra/t20/nvboot_bct_t20.h new file +316 -0

316 lines not on this page · raw message

scripts/tegra/t20/nvboot_sdram_param_t20.h new file +363 -0

363 lines not on this page · raw message

scripts/tegra/t20/parse_t20.c new file +251 -0

251 lines not on this page · raw message

scripts/tegra/t30/nvbctlib_t30.c new file +891 -0

891 lines not on this page · raw message

scripts/tegra/t30/nvboot_bct_t30.h new file +379 -0

379 lines not on this page · raw message

scripts/tegra/t30/nvboot_sdram_param_t30.h new file +568 -0

568 lines not on this page · raw message

scripts/tegra/t30/parse_t30.c new file +360 -0

360 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Part of the diff is not shown here. View the raw message.

#19 lore raw

PATCH 17/25 tegra: cbootimage: remove noisy output

In reply to Lucas Stach

Our build is quiet by default, so don't allow cbootimage to spam our logs.

---
 scripts/tegra/cbootimage.c | 5 -----
 1 file changed, 5 deletions(-)
scripts/tegra/cbootimage.c +0 -5
index 1332c5f..51422d1 100644
@@ -217,8 +217,6 @@ main(int argc, char *argv[])
 
 		fwrite(context.bct, 1, context.bct_size,
 			context.raw_file);
-		printf("New BCT file %s has been successfully generated!\n",
-			context.image_filename);
 		goto fail;
 	}
 
@@ -232,9 +230,6 @@ main(int argc, char *argv[])
 	/* The image hasn't been written yet. */
 	if (write_image_file(&context) != 0)
 		printf("Error writing image file.\n");
-	else
-		printf("Image file %s has been successfully generated!\n",
-				context.image_filename);
 
  fail:
 	/* Close the file(s). */
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#20 lore raw

PATCH 18/25 Makefile.lib: add rule to built Tegra BCTs

In reply to Lucas Stach
---
 .gitignore           | 1 +
 scripts/Makefile.lib | 6 ++++++
 2 files changed, 7 insertions(+)
.gitignore +1 -0
index d490491..5555e15 100644
@@ -20,6 +20,7 @@
 *.elf
 *.mcp
 *.orig
+*.bct
 *.dcd
 *.dcd.S
 *.bbenv
scripts/Makefile.lib +6 -0
index d4306cb..0851870 100644
@@ -400,3 +400,9 @@ quiet_cmd_imx_image = IMX-IMG $@
 
 quiet_cmd_kwb_image = KWB     $@
       cmd_kwb_image = scripts/kwbimage -p $< $(OPTS_$(@F)) -o $@
+
+quiet_cmd_cboot_bct = BCT     $@
+      cmd_cboot_bct = $(objtree)/scripts/tegra/cbootimage -gbct -s $(soc) $< $@
+
+$(obj)/%.bct: $(obj)/%.bct.cfg
+	$(call cmd,cboot_bct)
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#21 lore raw

PATCH 19/25 images: add Tegra20 image build rules

In reply to Lucas Stach

Allows to build persistent images for the Tegra20
line of SoCs.

---
 images/.gitignore     | 2 ++
 images/Makefile       | 2 +-
 images/Makefile.tegra | 8 ++++++++
 3 files changed, 11 insertions(+), 1 deletion(-)
images/.gitignore +2 -0
index 1f601e7..5f6f0b2 100644
@@ -8,6 +8,8 @@
 *.kwbimg
 *.kwbuartimg
 *.socfpgaimg
+*.t20img
+*.t20img.cfg
 pbl.lds
 barebox.x
 barebox.z
images/Makefile +1 -1
index 5509a4c..1ad7dac 100644
@@ -117,5 +117,5 @@ images: $(addprefix $(obj)/, $(image-y)) FORCE
 	@for i in $(image-y); do echo $$i; done
 
 clean-files := *.pbl *.pblb *.pblx *.map start_*.imximg *.img barebox.z start_*.kwbimg \
-	start_*.kwbuartimg *.socfpgaimg *.mlo
+	start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg
 clean-files += pbl.lds
images/Makefile.tegra +8 -0
index c957599..6c9a705 100644
@@ -1,6 +1,14 @@
 #
 # barebox image generation Makefile for Tegra images
 #
+quiet_cmd_tegra20_image = T20IMG  $@
+      cmd_tegra20_image = echo "Version = 0x00020001;Bctcopy = 1; \
+                                Bctfile = $(BCT_$(@F)); \
+                                BootLoader = $(subst .t20img,,$@),0x00108000,0x00108000,Complete;" \
+                                > [email protected]; \
+                          $(objtree)/scripts/tegra/cbootimage -s tegra20 [email protected] $@
+$(obj)/%.t20img: $(obj)/% FORCE
+	$(call if_changed,tegra20_image)
 
 board = $(srctree)/arch/$(ARCH)/boards
 
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#22 lore raw

PATCH 20/25 images: add Tegra30 image build rules

In reply to Lucas Stach

Allows to build persistent images for the Tegra30
line of SoCs.

---
 images/.gitignore     | 2 ++
 images/Makefile       | 3 ++-
 images/Makefile.tegra | 9 +++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
images/.gitignore +2 -0
index 5f6f0b2..42991af 100644
@@ -10,6 +10,8 @@
 *.socfpgaimg
 *.t20img
 *.t20img.cfg
+*.t30img
+*.t30img.cfg
 pbl.lds
 barebox.x
 barebox.z
images/Makefile +2 -1
index 1ad7dac..b050dbf 100644
@@ -117,5 +117,6 @@ images: $(addprefix $(obj)/, $(image-y)) FORCE
 	@for i in $(image-y); do echo $$i; done
 
 clean-files := *.pbl *.pblb *.pblx *.map start_*.imximg *.img barebox.z start_*.kwbimg \
-	start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg
+	start_*.kwbuartimg *.socfpgaimg *.mlo *.t20img *.t20img.cfg *.t30img \
+	*.t30img.cfg
 clean-files += pbl.lds
images/Makefile.tegra +9 -0
index 6c9a705..7dc44a2 100644
@@ -10,6 +10,15 @@ quiet_cmd_tegra20_image = T20IMG  $@
 $(obj)/%.t20img: $(obj)/% FORCE
 	$(call if_changed,tegra20_image)
 
+quiet_cmd_tegra30_image = T30IMG  $@
+      cmd_tegra30_image = echo "Version = 0x00030001;Bctcopy = 1; \
+                                Bctfile = $(BCT_$(@F)); \
+                                BootLoader = $(subst .t30img,,$@),0x80108000,0x80108000,Complete;" \
+                                > [email protected]; \
+                          $(objtree)/scripts/tegra/cbootimage -s tegra30 [email protected] $@
+$(obj)/%.t30img: $(obj)/% FORCE
+	$(call if_changed,tegra30_image)
+
 board = $(srctree)/arch/$(ARCH)/boards
 
 # ----------------------- Tegra20 based boards ---------------------------
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#23 lore raw

PATCH 21/25 ARM: boards: colibri t20: import BCT cfgs

In reply to Lucas Stach

From https://github.com/NVIDIA/cbootimage-configs.git

There are a bunch of different versions and boot options for this board. Import BCTs for all of them.

---
 arch/arm/boards/toradex-colibri-t20/Makefile       |   4 +
 .../colibri-t20_256_hsmmc.bct.cfg                  | 451 ++++++++++++++++++++
 .../colibri-t20_256_v11_nand.bct.cfg               | 459 +++++++++++++++++++++
 .../colibri-t20_256_v12_nand.bct.cfg               | 459 +++++++++++++++++++++
 .../colibri-t20_512_hsmmc.bct.cfg                  | 451 ++++++++++++++++++++
 .../colibri-t20_512_v11_nand.bct.cfg               | 459 +++++++++++++++++++++
 .../colibri-t20_512_v12_nand.bct.cfg               | 459 +++++++++++++++++++++
 7 files changed, 2742 insertions(+)
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_256_hsmmc.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_256_v11_nand.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_256_v12_nand.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_512_hsmmc.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_512_v11_nand.bct.cfg
 create mode 100644 arch/arm/boards/toradex-colibri-t20/colibri-t20_512_v12_nand.bct.cfg
arch/arm/boards/toradex-colibri-t20/Makefile +4 -0
index d2d2173..1f76732 100644
@@ -1,4 +1,8 @@
 CFLAGS_pbl-entry.o := \
 	-mcpu=arm7tdmi -march=armv4t \
 	-fno-tree-switch-conversion -fno-jump-tables
+soc := tegra20
 lwl-y += entry.o
+extra-y += colibri-t20_256_hsmmc.bct colibri-t20_256_v11_nand.bct \
+           colibri-t20_256_v12_nand.bct colibri-t20_512_hsmmc.bct \
+           colibri-t20_512_v11_nand.bct colibri-t20_512_v12_nand.bct
\ No newline at end of file
arch/arm/boards/toradex-colibri-t20/colibri-t20_256_hsmmc.bct.cfg new file +451 -0

451 lines not on this page · raw message

arch/arm/boards/toradex-colibri-t20/colibri-t20_256_v11_nand.bct.cfg new file +459 -0

459 lines not on this page · raw message

arch/arm/boards/toradex-colibri-t20/colibri-t20_256_v12_nand.bct.cfg new file +459 -0

459 lines not on this page · raw message

arch/arm/boards/toradex-colibri-t20/colibri-t20_512_hsmmc.bct.cfg new file +451 -0

451 lines not on this page · raw message

arch/arm/boards/toradex-colibri-t20/colibri-t20_512_v11_nand.bct.cfg new file +459 -0

459 lines not on this page · raw message

arch/arm/boards/toradex-colibri-t20/colibri-t20_512_v12_nand.bct.cfg new file +459 -0

459 lines not on this page · raw message

Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#24 lore raw

PATCH 22/25 images: tegra: build all Toradex Colibri images

In reply to Lucas Stach

Six images for the the 256MB and 512MB version with different boot sources (MMC, NAND [different chips on pre-/production modules]).

---
 arch/arm/boards/toradex-colibri-t20/entry.c | 42 ++++++++++++++++++++++++++++-
 images/Makefile.tegra                       | 40 ++++++++++++++++++++++++---
 2 files changed, 78 insertions(+), 4 deletions(-)
arch/arm/boards/toradex-colibri-t20/entry.c +41 -1
index 886613f..695862c 100644
@@ -22,7 +22,7 @@
 
 extern char __dtb_tegra20_colibri_iris_start[];
 
-ENTRY_FUNCTION(start_toradex_colibri_t20_iris, r0, r1, r2)
+static void common_toradex_colibri_t20_iris_start(void)
 {
 	uint32_t fdt;
 
@@ -32,3 +32,43 @@ ENTRY_FUNCTION(start_toradex_colibri_t20_iris, r0, r1, r2)
 
 	tegra_avp_reset_vector(fdt);
 }
+
+ENTRY_FUNCTION(start_colibri_t20_256_usbload, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_256_hsmmc, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_256_v11_nand, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_256_v12_nand, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_512_usbload, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_512_hsmmc, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_512_v11_nand, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
+
+ENTRY_FUNCTION(start_colibri_t20_512_v12_nand, r0, r1, r2)
+{
+	common_toradex_colibri_t20_iris_start();
+}
images/Makefile.tegra +37 -3
index 7dc44a2..75efc68 100644
@@ -26,9 +26,43 @@ pblx-$(CONFIG_MACH_TOSHIBA_AC100) += start_toshiba_ac100
 FILE_barebox-tegra20-toshiba-ac100.img = start_toshiba_ac100.pblx
 image-$(CONFIG_MACH_TOSHIBA_AC100) += barebox-tegra20-toshiba-ac100.img
 
-pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_toradex_colibri_t20_iris
-FILE_barebox-tegra20-toradex-colibri-t20-iris.img = start_toradex_colibri_t20_iris.pblx
-image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-iris.img
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_256_usbload
+FILE_barebox-tegra20-toradex-colibri-t20-256-usbloader-iris.img = start_colibri_t20_256_usbload.pblx
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-256-usbloader-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_256_hsmmc
+BCT_start_colibri_t20_256_hsmmc.pblx.t20img = $(board)/toradex-colibri-t20/colibri-t20_256_hsmmc.bct
+FILE_barebox-tegra20-toradex-colibri-t20-256-hsmmc-iris.img = start_colibri_t20_256_hsmmc.pblx.t20img
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-256-hsmmc-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_256_v11_nand
+BCT_start_colibri_t20_256_v11_nand.pblx.t20img = $(board)/toradex-colibri-t20/colibri-t20_256_v11_nand.bct
+FILE_barebox-tegra20-toradex-colibri-t20-256-v11-nand-iris.img = start_colibri_t20_256_v11_nand.pblx.t20img
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-256-v11-nand-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_256_v12_nand
+BCT_start_colibri_t20_256_v12_nand.pblx.t20img = $(board)/toradex-colibri-t20/colibri-t20_256_v12_nand.bct
+FILE_barebox-tegra20-toradex-colibri-t20-256-v12-nand-iris.img = start_colibri_t20_256_v12_nand.pblx.t20img
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-256-v12-nand-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_512_usbload
+FILE_barebox-tegra20-toradex-colibri-t20-512-usbloader-iris.img = start_colibri_t20_512_usbload.pblx
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-512-usbloader-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_512_hsmmc
+BCT_start_colibri_t20_512_hsmmc.pblx.t20img = $(board)/toradex-colibri-t20/colibri-t20_512_hsmmc.bct
+FILE_barebox-tegra20-toradex-colibri-t20-512-hsmmc-iris.img = start_colibri_t20_512_hsmmc.pblx.t20img
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-512-hsmmc-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_512_v11_nand
+BCT_start_colibri_t20_512_v11_nand.pblx.t20img = $(board)/toradex-colibri-t20/colibri-t20_512_v11_nand.bct
+FILE_barebox-tegra20-toradex-colibri-t20-512-v11-nand-iris.img = start_colibri_t20_512_v11_nand.pblx.t20img
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-512-v11-nand-iris.img
+
+pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_512_v12_nand
+BCT_start_colibri_t20_512_v12_nand.pblx.t20img = $(board)/toradex-colibri-t20/colibri-t20_512_v12_nand.bct
+FILE_barebox-tegra20-toradex-colibri-t20-512-v12-nand-iris.img = start_colibri_t20_512_v12_nand.pblx.t20img
+image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-512-v12-nand-iris.img
 
 # ----------------------- Tegra30 based boards ---------------------------
 pblx-$(CONFIG_MACH_NVIDIA_BEAVER) += start_nvidia_beaver
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#25 lore raw

PATCH 23/25 ARM: boards: beaver: import BCT cfg

In reply to Lucas Stach

From https://github.com/NVIDIA/cbootimage-configs.git

---
 arch/arm/boards/nvidia-beaver/Makefile             |   2 +
 .../boards/nvidia-beaver/beaver-2gb-emmc.bct.cfg   | 819 +++++++++++++++++++++
 2 files changed, 821 insertions(+)
 create mode 100644 arch/arm/boards/nvidia-beaver/beaver-2gb-emmc.bct.cfg
arch/arm/boards/nvidia-beaver/Makefile +2 -0
index 2b6c09e..7ade54e 100644
@@ -1,5 +1,7 @@
 CFLAGS_pbl-entry.o := \
 	-mcpu=arm7tdmi -march=armv4t \
 	-fno-tree-switch-conversion -fno-jump-tables
+soc := tegra30
 lwl-y += entry.o
 obj-y += board.o
+extra-y += beaver-2gb-emmc.bct
arch/arm/boards/nvidia-beaver/beaver-2gb-emmc.bct.cfg new file +819 -0

819 lines not on this page · raw message

Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#26 lore raw

PATCH 24/25 images: tegra: build NVidia Beaver image

In reply to Lucas Stach
---
 images/Makefile.tegra | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
images/Makefile.tegra +7 -2
index 75efc68..2828353 100644
@@ -66,5 +66,10 @@ image-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += barebox-tegra20-toradex-colibri-t20-
 
 # ----------------------- Tegra30 based boards ---------------------------
 pblx-$(CONFIG_MACH_NVIDIA_BEAVER) += start_nvidia_beaver
-FILE_barebox-tegra30-nvidia-beaver.img = start_nvidia_beaver.pblx
-image-$(CONFIG_MACH_NVIDIA_BEAVER) += barebox-tegra30-nvidia-beaver.img
+FILE_barebox-tegra30-nvidia-beaver-usbloader.img = start_nvidia_beaver.pblx
+image-$(CONFIG_MACH_NVIDIA_BEAVER) += barebox-tegra30-nvidia-beaver-usbloader.img
+
+pblx-$(CONFIG_MACH_NVIDIA_BEAVER) += start_nvidia_beaver
+BCT_start_nvidia_beaver.pblx.t30img = $(board)/nvidia-beaver/beaver-2gb-emmc.bct
+FILE_barebox-tegra30-nvidia-beaver-emmc.img = start_nvidia_beaver.pblx.t30img
+image-$(CONFIG_MACH_NVIDIA_BEAVER) += barebox-tegra30-nvidia-beaver-emmc.img
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#27 lore raw

PATCH 25/25 images: tegra: rename ac100 image

In reply to Lucas Stach

To make it clear that this image is only suitable
for loading via usbloader. We can't do anything
about this, as there is no upstream BCT available
for AC100.

---
 images/Makefile.tegra | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
images/Makefile.tegra +2 -2
index 2828353..f22c2d3 100644
@@ -23,8 +23,8 @@ board = $(srctree)/arch/$(ARCH)/boards
 
 # ----------------------- Tegra20 based boards ---------------------------
 pblx-$(CONFIG_MACH_TOSHIBA_AC100) += start_toshiba_ac100
-FILE_barebox-tegra20-toshiba-ac100.img = start_toshiba_ac100.pblx
-image-$(CONFIG_MACH_TOSHIBA_AC100) += barebox-tegra20-toshiba-ac100.img
+FILE_barebox-tegra20-toshiba-ac100-usbloader.img = start_toshiba_ac100.pblx
+image-$(CONFIG_MACH_TOSHIBA_AC100) += barebox-tegra20-toshiba-ac100-usbloader.img
 
 pblx-$(CONFIG_MACH_TORADEX_COLIBRI_T20) += start_colibri_t20_256_usbload
 FILE_barebox-tegra20-toradex-colibri-t20-256-usbloader-iris.img = start_colibri_t20_256_usbload.pblx
Signature · 7 lines
1.9.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox