[U-Boot] [PATCH 1/2] am43xx: Update EMIF DDR3 Configuration for AM43x GP

2014-06-27 Thread Franklin S Cooper Jr
From: "Franklin S. Cooper Jr" 

* Boot failures have been discovered due to a combination of routing issues and
  non optimal ddr3 timings in the EMIF
* Since ddr3 timings are different after significant board layout changes
  different timings are required for alpha, beta and production boards.

Signed-off-by: Franklin S. Cooper Jr 
---
 arch/arm/include/asm/arch-am33xx/omap.h |2 +
 board/ti/am43xx/board.c |  101 +++
 board/ti/am43xx/board.h |   11 
 3 files changed, 114 insertions(+)

diff --git a/arch/arm/include/asm/arch-am33xx/omap.h 
b/arch/arm/include/asm/arch-am33xx/omap.h
index 0855d16..e5c0b0d 100644
--- a/arch/arm/include/asm/arch-am33xx/omap.h
+++ b/arch/arm/include/asm/arch-am33xx/omap.h
@@ -29,6 +29,8 @@
 #define SRAM_SCRATCH_SPACE_ADDR0x40337C00
 #define AM4372_BOARD_NAME_STARTSRAM_SCRATCH_SPACE_ADDR
 #define AM4372_BOARD_NAME_END  SRAM_SCRATCH_SPACE_ADDR + 0xC
+#define AM4372_BOARD_VERSION_START SRAM_SCRATCH_SPACE_ADDR + 0xD
+#define AM4372_BOARD_VERSION_END   SRAM_SCRATCH_SPACE_ADDR + 0x14
 #define QSPI_BASE  0x4790
 #endif
 #endif
diff --git a/board/ti/am43xx/board.c b/board/ti/am43xx/board.c
index 054a452..5eaa4a5 100644
--- a/board/ti/am43xx/board.c
+++ b/board/ti/am43xx/board.c
@@ -68,6 +68,9 @@ static int read_eeprom(struct am43xx_board_id *header)
strncpy(am43xx_board_name, (char *)header->name, sizeof(header->name));
am43xx_board_name[sizeof(header->name)] = 0;
 
+   strncpy(am43xx_board_rev, (char *)header->version, 
sizeof(header->version));
+   am43xx_board_rev[sizeof(header->version)] = 0;
+
return 0;
 }
 
@@ -217,6 +220,44 @@ const struct emif_regs ddr3_emif_regs_400Mhz = {
.emif_rd_wr_exec_thresh = 0x0405
 };
 
+/* EMIF DDR3 Configurations are different for beta AM43X GP EVMs */
+const struct emif_regs ddr3_emif_regs_400Mhz_beta = {
+   .sdram_config   = 0x638413B2,
+   .ref_ctrl   = 0x0C30,
+   .sdram_tim1 = 0xEAAAD4DB,
+   .sdram_tim2 = 0x266B7FDA,
+   .sdram_tim3 = 0x107F8678,
+   .read_idle_ctrl = 0x0005,
+   .zq_config  = 0x50074BE4,
+   .temp_alert_config  = 0x0,
+   .emif_ddr_phy_ctlr_1= 0x0E004008,
+   .emif_ddr_ext_phy_ctrl_1= 0x08020080,
+   .emif_ddr_ext_phy_ctrl_2= 0x0065,
+   .emif_ddr_ext_phy_ctrl_3= 0x0091,
+   .emif_ddr_ext_phy_ctrl_4= 0x00B5,
+   .emif_ddr_ext_phy_ctrl_5= 0x00E5,
+   .emif_rd_wr_exec_thresh = 0x0405
+};
+
+/* EMIF DDR3 Configurations are different for production AM43X GP EVMs */
+const struct emif_regs ddr3_emif_regs_400Mhz_production = {
+   .sdram_config   = 0x638413B2,
+   .ref_ctrl   = 0x0C30,
+   .sdram_tim1 = 0xEAAAD4DB,
+   .sdram_tim2 = 0x266B7FDA,
+   .sdram_tim3 = 0x107F8678,
+   .read_idle_ctrl = 0x0005,
+   .zq_config  = 0x50074BE4,
+   .temp_alert_config  = 0x0,
+   .emif_ddr_phy_ctlr_1= 0x0E004008,
+   .emif_ddr_ext_phy_ctrl_1= 0x08020080,
+   .emif_ddr_ext_phy_ctrl_2= 0x0066,
+   .emif_ddr_ext_phy_ctrl_3= 0x0091,
+   .emif_ddr_ext_phy_ctrl_4= 0x00B9,
+   .emif_ddr_ext_phy_ctrl_5= 0x00E6,
+   .emif_rd_wr_exec_thresh = 0x0405
+};
+
 static const struct emif_regs ddr3_sk_emif_regs_400Mhz = {
.sdram_config   = 0x638413b2,
.sdram_config2  = 0x,
@@ -262,6 +303,52 @@ const u32 ext_phy_ctrl_const_base_ddr3[] = {
0x08102040
 };
 
+const u32 ext_phy_ctrl_const_base_ddr3_beta[] = {
+   0x,
+   0x0045,
+   0x0046,
+   0x0048,
+   0x0047,
+   0x,
+   0x004C,
+   0x0070,
+   0x0085,
+   0x00A3,
+   0x,
+   0x000C,
+   0x0030,
+   0x0045,
+   0x0063,
+   0x,
+   0x0,
+   0x0,
+   0x4000,
+   0x08102040
+};
+
+const u32 ext_phy_ctrl_const_base_ddr3_production[] = {
+   0x,
+   0x0044,
+   0x0044,
+   0x0046,
+   0x0046,
+   0x,
+   0x0059,
+   0x0077,
+   0x0093,
+   0x00A8,
+   0x,
+   0x0019,
+   0x0037,
+   0x0053,
+   0x0068,
+   0x,
+   0x0,
+   0x0,
+   0x4000,
+   0x08102040
+};
+
 static const u32 ext_phy_ctrl_const_base_ddr3_sk[] = {
/* first 5 are taken care by emif_regs */
0

[U-Boot] [PATCH 2/2] am43xx: Tune the system to avoid DSS underflows

2014-06-27 Thread Franklin S Cooper Jr
* This is done by limiting the ARM's bandwidth and setting DSS priority in
  the EMIF controller to ensure underflows do not occur.
---
 arch/arm/cpu/armv7/am33xx/ddr.c|   12 
 arch/arm/include/asm/arch-am33xx/cpu.h |   23 ++-
 arch/arm/include/asm/arch-am33xx/hardware_am43xx.h |3 +
 arch/arm/include/asm/emif.h|   15 -
 board/ti/am43xx/board.c|   68 ++--
 5 files changed, 111 insertions(+), 10 deletions(-)

diff --git a/arch/arm/cpu/armv7/am33xx/ddr.c b/arch/arm/cpu/armv7/am33xx/ddr.c
index bbe9d1a..fc66872 100644
--- a/arch/arm/cpu/armv7/am33xx/ddr.c
+++ b/arch/arm/cpu/armv7/am33xx/ddr.c
@@ -94,6 +94,18 @@ void config_sdram_emif4d5(const struct emif_regs *regs, int 
nr)
writel(regs->emif_rd_wr_exec_thresh,
   &emif_reg[nr]->emif_rd_wr_exec_thresh);
 
+   /*
+* for most SOCs these registers won't need to be changed so only
+* write to these registers if someone explicitly has set the
+* register's value.
+*/
+   if(regs->emif_cos_config) {
+   writel(regs->emif_prio_class_serv_map, 
&emif_reg[nr]->emif_prio_class_serv_map);
+   writel(regs->emif_connect_id_serv_1_map, 
&emif_reg[nr]->emif_connect_id_serv_1_map);
+   writel(regs->emif_connect_id_serv_2_map, 
&emif_reg[nr]->emif_connect_id_serv_2_map);
+   writel(regs->emif_cos_config, &emif_reg[nr]->emif_cos_config);
+   }
+
writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl);
writel(regs->ref_ctrl, &emif_reg[nr]->emif_sdram_ref_ctrl_shdw);
writel(regs->sdram_config, &emif_reg[nr]->emif_sdram_config);
diff --git a/arch/arm/include/asm/arch-am33xx/cpu.h 
b/arch/arm/include/asm/arch-am33xx/cpu.h
index aa10fab..8dd69b3 100644
--- a/arch/arm/include/asm/arch-am33xx/cpu.h
+++ b/arch/arm/include/asm/arch-am33xx/cpu.h
@@ -489,6 +489,12 @@ struct ctrl_stat {
 #define OMAP_GPIO_SETDATAOUT   0x0194
 
 /* Control Device Register */
+
+ /* Control Device Register */
+#define MREQPRIO_0_SAB_INIT1_MASK  0xFF8F
+#define MREQPRIO_0_SAB_INIT0_MASK  0xFFF8
+#define MREQPRIO_1_DSS_MASK0xFF8F
+
 struct ctrl_dev {
unsigned int deviceid;  /* offset 0x00 */
unsigned int resv1[7];
@@ -502,10 +508,25 @@ struct ctrl_dev {
unsigned int macid1h;   /* offset 0x3c */
unsigned int resv4[4];
unsigned int miisel;/* offset 0x50 */
-   unsigned int resv5[106];
+   unsigned int resv5[7];
+   unsigned int mreqprio_0;/* offset 0x70 */
+   unsigned int mreqprio_1;/* offset 0x74 */
+   unsigned int resv6[97];
unsigned int efuse_sma; /* offset 0x1FC */
 };
 
+/* Bandwidth Limiter Portion of the L3Fast Configuration Register */
+#define BW_LIMITER_BW_FRAC_MASK 0xFFE0
+#define BW_LIMITER_BW_INT_MASK  0xFFF0
+#define BW_LIMITER_BW_WATERMARK_MASK0xF800
+
+struct l3f_cfg_bwlimiter {
+   u32 padding0[2];
+   u32 modena_init0_bw_fractional;
+   u32 modena_init0_bw_integer;
+   u32 modena_init0_watermark_0;
+};
+
 /* gmii_sel register defines */
 #define GMII1_SEL_MII  0x0
 #define GMII1_SEL_RMII 0x1
diff --git a/arch/arm/include/asm/arch-am33xx/hardware_am43xx.h 
b/arch/arm/include/asm/arch-am33xx/hardware_am43xx.h
index 15399dc..b470319 100644
--- a/arch/arm/include/asm/arch-am33xx/hardware_am43xx.h
+++ b/arch/arm/include/asm/arch-am33xx/hardware_am43xx.h
@@ -13,6 +13,9 @@
 
 /* Module base addresses */
 
+/* L3 Fast Configuration Bandwidth Limiter Base Address */
+#define L3F_CFG_BWLIMITER  0x44005200
+
 /* UART Base Address */
 #define UART0_BASE 0x44E09000
 
diff --git a/arch/arm/include/asm/emif.h b/arch/arm/include/asm/emif.h
index 45668ca..b8d6bdc 100644
--- a/arch/arm/include/asm/emif.h
+++ b/arch/arm/include/asm/emif.h
@@ -642,11 +642,16 @@ struct emif_reg_struct {
u32 emif_ddr_phy_ctrl_1;
u32 emif_ddr_phy_ctrl_1_shdw;
u32 emif_ddr_phy_ctrl_2;
-   u32 padding7[12];
+   u32 padding7[4];
+   u32 emif_prio_class_serv_map;
+   u32 emif_connect_id_serv_1_map;
+   u32 emif_connect_id_serv_2_map;
+   u32 padding8[5];
u32 emif_rd_wr_exec_thresh;
-   u32 padding8[7];
+   u32 emif_cos_config;
+   u32 padding9[6];
u32 emif_ddr_phy_status[21];
-   u32 padding9[27];
+   u32 padding10[27];
u32 emif_ddr_ext_phy_ctrl_1;
u32 emif_ddr_ext_phy_ctrl_1_shdw;
u32 emif_ddr_ext_phy_ctrl_2;
@@ -1137,6 +1142,10 @@ struct emif_regs {
u32 emif_rd_wr_lvl_rmp_ctl;
u32 emif_rd_wr_lvl_ctl;
u32 emif_rd_wr_exec_thresh;
+   u32 emif_prio_class_serv_map;
+   u32 emif_connect_id_serv_1_map;
+   u32 emif_connect_id_serv_2_map;
+   u32 emif_cos_config;
 };
 
 struct lpddr2_mr_regs {

[U-Boot] [PATCH] am43xx_evm: Add netboot and related to environment

2015-02-16 Thread Franklin S Cooper Jr
From: Tom Rini 

Signed-off-by: Tom Rini 
---
 include/configs/am43xx_evm.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 7ccbf36..44b6f93 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -168,6 +168,10 @@
"usbroot=/dev/sda2 rw\0" \
"usbrootfstype=ext4 rootwait\0" \
"usbdev=0\0" \
+   "rootpath=/export/rootfs\0" \
+   "nfsopts=nolock\0" \
+   "static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}" \
+   "::off\0" \
"ramroot=/dev/ram0 rw\0" \
"ramrootfstype=ext2\0" \
"mmcargs=setenv bootargs console=${console} " \
@@ -178,6 +182,11 @@
"${optargs} " \
"root=${usbroot} " \
"rootfstype=${usbrootfstype}\0" \
+   "netargs=setenv bootargs console=${console} " \
+   "${optargs} " \
+   "root=/dev/nfs " \
+   "nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
+   "ip=dhcp\0" \
"bootenv=uEnv.txt\0" \
"loadbootenv=load ${devtype} ${devnum} ${loadaddr} ${bootenv}\0" \
"importbootenv=echo Importing environment from mmc ...; " \
@@ -229,6 +238,13 @@
"bootz ${loadaddr} - ${fdtaddr}; " \
"fi;" \
"fi\0" \
+   "netboot=echo Booting from network ...; " \
+   "setenv autoload no; " \
+   "dhcp; " \
+   "tftp ${loadaddr} ${bootfile}; " \
+   "tftp ${fdtaddr} ${fdtfile}; " \
+   "run netargs; " \
+   "bootz ${loadaddr} - ${fdtaddr}\0" \
"findfdt="\
"if test $board_name = AM43EPOS; then " \
"setenv fdtfile am43x-epos-evm.dtb; fi; " \
-- 
2.2.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ti: am335x/am437x/omap5 devices: Unify network environment variables

2015-04-21 Thread Franklin S Cooper Jr
Across several devices network environment variables are duplicated.
Move these variables to a common include file which insures the environment
variables are reused and insures devices across product lines share the same
values.

Signed-off-by: Franklin S Cooper Jr 
---
 include/configs/am335x_evm.h  | 17 +
 include/configs/am43xx_evm.h  |  1 +
 include/configs/ti_armv7_common.h | 25 +
 include/configs/ti_omap5_common.h | 13 +
 4 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index a87059c..8da3325 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -83,10 +83,6 @@
"mmcdev=0\0" \
"mmcroot=/dev/mmcblk0p2 ro\0" \
"mmcrootfstype=ext4 rootwait\0" \
-   "rootpath=/export/rootfs\0" \
-   "nfsopts=nolock\0" \
-   "static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}" \
-   "::off\0" \
"ramroot=/dev/ram0 rw\0" \
"ramrootfstype=ext2\0" \
"mmcargs=setenv bootargs console=${console} " \
@@ -102,11 +98,6 @@
"${optargs} " \
"root=${spiroot} " \
"rootfstype=${spirootfstype}\0" \
-   "netargs=setenv bootargs console=${console} " \
-   "${optargs} " \
-   "root=/dev/nfs " \
-   "nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
-   "ip=dhcp\0" \
"bootenv=uEnv.txt\0" \
"loadbootscript=load mmc ${mmcdev} ${loadaddr} boot.scr\0" \
"bootscript=echo Running bootscript from mmc${mmcdev} ...; " \
@@ -159,13 +150,6 @@
"sf probe ${spibusno}:0; " \
"sf read ${loadaddr} ${spisrcaddr} ${spiimgsize}; " \
"bootz ${loadaddr}\0" \
-   "netboot=echo Booting from network ...; " \
-   "setenv autoload no; " \
-   "dhcp; " \
-   "tftp ${loadaddr} ${bootfile}; " \
-   "tftp ${fdtaddr} ${fdtfile}; " \
-   "run netargs; " \
-   "bootz ${loadaddr} - ${fdtaddr}\0" \
"ramboot=echo Booting from ramdisk ...; " \
"run ramargs; " \
"bootz ${loadaddr} ${rdaddr} ${fdtaddr}\0" \
@@ -181,6 +165,7 @@
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine device tree to use; 
fi; \0" \
NANDARGS \
+   NETARGS \
DFUARGS
 #endif
 
diff --git a/include/configs/am43xx_evm.h b/include/configs/am43xx_evm.h
index 6eb31e2..331fdac 100644
--- a/include/configs/am43xx_evm.h
+++ b/include/configs/am43xx_evm.h
@@ -295,6 +295,7 @@
"setenv fdtfile am437x-idk-evm.dtb; fi; " \
"if test $fdtfile = undefined; then " \
"echo WARNING: Could not determine device tree; fi; \0" 
\
+   NETARGS \
DFUARGS \
 
 #define CONFIG_BOOTCOMMAND \
diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index 110a4f8..f882942 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -279,4 +279,29 @@
 #endif
 #endif /* !CONFIG_NOR_BOOT */
 
+/* Generic Environment Variables */
+
+#ifdef CONFIG_CMD_NET
+#define NETARGS \
+   "static_ip=${ipaddr}:${serverip}:${gatewayip}:${netmask}:${hostname}" \
+   "::off\0" \
+   "nfsopts=nolock\0" \
+   "rootpath=/export/rootfs\0" \
+   "netloadimage=tftp ${loadaddr} ${bootfile}\0" \
+   "netloadfdt=tftp ${fdtaddr} ${fdtfile}\0" \
+   "netargs=setenv bootargs console=${console} " \
+   "${optargs} " \
+   "root=/dev/nfs " \
+   "nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
+   "ip=dhcp\0" \
+   "netboot=echo Booting from network ...; " \
+   "setenv autoload no; " \
+   "dhcp; " \
+   "run netloadimage; " \
+   "run netloadfdt; " \
+   "run netargs; " \
+   "bootz ${loadaddr} - ${fdtaddr}\0"
+
+#endif
+
 #endif /* __CONFIG_TI_ARMV7_COMMON_H__ */
diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index 7957a73..791eade 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -92,11 +92,6 @@
"vram=${vram} &qu

[U-Boot] [PATCH] omap5: Add netargs and netboot option

2014-12-04 Thread Franklin S Cooper Jr
* Add netargs and netboot option.
* This enables tftp and nfs booting
* This puts omap5 devices inline with other devices such as am335x and am437x

Signed-off-by: Franklin S Cooper Jr 
---
 include/configs/ti_omap5_common.h |   15 ++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/include/configs/ti_omap5_common.h 
b/include/configs/ti_omap5_common.h
index c47651d..925cb42 100644
--- a/include/configs/ti_omap5_common.h
+++ b/include/configs/ti_omap5_common.h
@@ -85,10 +85,16 @@
"vram=${vram} " \
"root=${mmcroot} " \
"rootfstype=${mmcrootfstype}\0" \
+   "netargs=setenv bootargs console=${console} " \
+   "${optargs} " \
+   "root=/dev/nfs " \
+   "nfsroot=${serverip}:${rootpath},${nfsopts} rw " \
+   "ip=dhcp\0" \
"loadbootscript=fatload mmc ${mmcdev} ${loadaddr} boot.scr\0" \
"bootscript=echo Running bootscript from mmc${mmcdev} ...; " \
"source ${loadaddr}\0" \
-   "loadbootenv=fatload mmc ${mmcdev} ${loadaddr} uEnv.txt\0" \
+   "bootenv=uEnv.txt\0" \
+   "loadbootenv=fatload mmc ${mmcdev} ${loadaddr} ${bootenv}\0" \
"importbootenv=echo Importing environment from mmc${mmcdev} ...; " \
"env import -t ${loadaddr} ${filesize}\0" \
"loadimage=load mmc ${bootpart} ${loadaddr} ${bootdir}/${bootfile}\0" \
@@ -110,6 +116,13 @@
"bootz ${loadaddr} - ${fdtaddr}; " \
"fi;" \
"fi;\0" \
+   "netboot=echo Booting from network ...; " \
+   "set env autoload no; " \
+   "dhcp; " \
+   "tftp ${loadaddr} ${bootfile}; " \
+   "tftp ${fdtaddr} ${fdtfile}; " \
+   "run netargs; " \
+   "bootz ${loadaddr} - ${fdtaddr}\0" \
"findfdt="\
"if test $board_name = omap5_uevm; then " \
"setenv fdtfile omap5-uevm.dtb; fi; " \
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ARM: keystone2: configs: Correct burn_uboot_sp erase size

2015-11-19 Thread Franklin S Cooper Jr
The NOR flash on Keystone 2 evms has a u-boot-spl partition size of
0x8.

Currently burn_uboot_spi will erase 0x10 from the spi NOR which will
cause a partial erase of the misc partition.

Fix this by correcting the erase size.

Signed-off-by: Franklin S Cooper Jr 
---
 include/configs/ti_armv7_keystone2.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/ti_armv7_keystone2.h 
b/include/configs/ti_armv7_keystone2.h
index 2b2c060..b4f365b 100644
--- a/include/configs/ti_armv7_keystone2.h
+++ b/include/configs/ti_armv7_keystone2.h
@@ -252,7 +252,7 @@
"get_mon_net=dhcp ${addr_mon} ${tftp_root}/${name_mon}\0"   \
"get_mon_ubi=ubifsload ${addr_mon} ${name_mon}\0"   \
"get_uboot_net=dhcp ${loadaddr} ${tftp_root}/${name_uboot}\0"   \
-   "burn_uboot_spi=sf probe; sf erase 0 0x10; "\
+   "burn_uboot_spi=sf probe; sf erase 0 0x8; " \
"sf write ${loadaddr} 0 ${filesize}\0"  \
"burn_uboot_nand=nand erase 0 0x10; "   \
"nand write ${loadaddr} 0 ${filesize}\0"\
-- 
2.6.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ARM: dra7x/am57x: Remove pin input/output config from WAKEUP pins

2015-11-19 Thread Franklin S Cooper Jr
The WAKEUP_X pins are always an input no matter the pinmux mode.
However, the 18th bit that typical configures a pin as an input is
considered reserved for the WAKEUP_X pins. Therefore, for any WAKEUP
pin remove any configuration that sets that pin as an input. Since
those pins are only inputs remove any output configuration from those
pins.

Signed-off-by: Franklin S Cooper Jr 
---
 board/ti/am57xx/mux_data.h | 8 
 board/ti/dra7xx/mux_data.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/board/ti/am57xx/mux_data.h b/board/ti/am57xx/mux_data.h
index 23f22a0..3c007b7 100644
--- a/board/ti/am57xx/mux_data.h
+++ b/board/ti/am57xx/mux_data.h
@@ -255,10 +255,10 @@ const struct pad_conf_entry 
core_padconf_array_essential[] = {
{UART2_RTSN, (M1 | PIN_INPUT_SLEW)},/* uart2_rtsn.uart3_txd */
{I2C2_SDA, (M1 | PIN_INPUT)},   /* i2c2_sda.hdmi1_ddc_scl */
{I2C2_SCL, (M1 | PIN_INPUT)},   /* i2c2_scl.hdmi1_ddc_sda */
-   {WAKEUP0, (M0 | PIN_OUTPUT_PULLUP)},/* Wakeup0.Wakeup0 */
-   {WAKEUP1, (M0 | PIN_OUTPUT_PULLDOWN)},  /* Wakeup1.Wakeup1 */
-   {WAKEUP2, (M0 | PIN_OUTPUT_PULLDOWN)},  /* Wakeup2.Wakeup2 */
-   {WAKEUP3, (M0 | PIN_OUTPUT_PULLUP)},/* Wakeup3.Wakeup3 */
+   {WAKEUP0, (M0 | PULL_UP)},  /* Wakeup0.Wakeup0 */
+   {WAKEUP1, (M0)},/* Wakeup1.Wakeup1 */
+   {WAKEUP2, (M0)},/* Wakeup2.Wakeup2 */
+   {WAKEUP3, (M0 | PULL_UP)},  /* Wakeup3.Wakeup3 */
{ON_OFF, (M1 | PIN_OUTPUT_PULLUP)}, /* on_off.on_off */
{RTC_PORZ, (M0 | PIN_OUTPUT_PULLDOWN)}, /* rtc_porz.rtc_porz */
{RTCK, (M0 | PIN_INPUT_PULLDOWN)},  /* rtck.rtck */
diff --git a/board/ti/dra7xx/mux_data.h b/board/ti/dra7xx/mux_data.h
index bf40144..1bfb362 100644
--- a/board/ti/dra7xx/mux_data.h
+++ b/board/ti/dra7xx/mux_data.h
@@ -372,7 +372,7 @@ const struct pad_conf_entry dra74x_core_padconf_array[] = {
{I2C2_SDA, (M0 | PIN_INPUT_PULLUP)},/* i2c2_sda.i2c2_sda */
{I2C2_SCL, (M0 | PIN_INPUT_PULLUP)},/* i2c2_scl.i2c2_scl */
{WAKEUP0, (M15 | PULL_UP)}, /* Wakeup0.safe for dcan1_rx */
-   {WAKEUP2, (M14 | PIN_OUTPUT)},  /* Wakeup2.gpio1_2 */
+   {WAKEUP2, (M14)},   /* Wakeup2.gpio1_2 */
 };
 
 #ifdef CONFIG_IODELAY_RECALIBRATION
-- 
2.6.2

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] ti: am335x/am437x/omap5 devices: Fix breakage when CONFIG_CMD_NET is not used

2015-06-10 Thread Franklin S Cooper Jr
Currently there is no default value for NETARGS if CONFIG_CMD_NET=y isn't set.
This results in build errors which was first discovered when trying to run
make env.

By defining a blank NETARGS these errors can be avoided.

Signed-off-by: Franklin S Cooper Jr 
---
 include/configs/ti_armv7_common.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/configs/ti_armv7_common.h 
b/include/configs/ti_armv7_common.h
index f882942..d1c390f 100644
--- a/include/configs/ti_armv7_common.h
+++ b/include/configs/ti_armv7_common.h
@@ -301,7 +301,8 @@
"run netloadfdt; " \
"run netargs; " \
"bootz ${loadaddr} - ${fdtaddr}\0"
-
+#else
+#define NETARGS ""
 #endif
 
 #endif /* __CONFIG_TI_ARMV7_COMMON_H__ */
-- 
2.4.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 18/31] defconfig: keystone2: Enable U-boot runtime DTB detection

2017-03-16 Thread Franklin S Cooper Jr


On 03/09/2017 07:08 AM, Tom Rini wrote:
> On Thu, Mar 02, 2017 at 01:04:22PM -0600, Franklin S Cooper Jr wrote:
> 
>> Enable various config options to allow U-boot at runtime to select the
>> proper dtb to use from the list of dtb's within the FIT image.
>>
>> Signed-off-by: Franklin S Cooper Jr 
> 
> ... but is the goal here to eventually support more than one EVM in a
> single binary, on all of these platforms?

Yes the goal is to have a single binary that support multiple evms for a
given SoC family. Similar to what we are doing for OMAP devices except
using U-boot instead of SPL.
> 
> Reviewed-by: Tom Rini 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 28/31] ARM: dts: k2g: Disable netcp by default

2017-03-16 Thread Franklin S Cooper Jr


On 03/09/2017 07:09 AM, Tom Rini wrote:
> On Thu, Mar 02, 2017 at 01:04:32PM -0600, Franklin S Cooper Jr wrote:
> 
>> Disable netcp by default like all other peripherals in the dtsi file.
>> Enable the peripheral explicitly in the board specific dts file.
>>
>> Signed-off-by: Franklin S Cooper Jr 
> 
> Has this been pushed up to Linux yet?  Thanks!

Only an extremely bare minimal dts exist in upstream. So this patch
isn't applicable.

> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 29/31] ARM: dts: k2g: Add DT support for K2G Industrial Communication Engine evm

2017-03-16 Thread Franklin S Cooper Jr


On 03/09/2017 07:09 AM, Tom Rini wrote:
> On Thu, Mar 02, 2017 at 01:04:33PM -0600, Franklin S Cooper Jr wrote:
> 
>> Add basic DT support for K2G ICE evm. Only minimal peripherals are
>> supported to allow console output and MMC boot.
>>
>> Signed-off-by: Franklin S Cooper Jr 
>> ---
>>  arch/arm/dts/Makefile |  3 ++-
>>  arch/arm/dts/keystone-k2g-ice.dts | 25 +
> 
> Has this been pushed up to Linux yet?  Thanks!

Not yet.

> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: keystone: Pass SPI MTD partition table via kernel command line

2017-03-21 Thread Franklin S Cooper Jr


On 03/20/2017 11:57 PM, Vignesh R wrote:
> 
> 
> On Saturday 18 March 2017 08:04 PM, Tom Rini wrote:
 And can we not move towards the "normal" method of SPL loading
 the u-boot.img (or FIT) from?  I guess the current architecture here is
 confusing me.
>>> This has been same for all k2 platforms. I guess we have single image so
>>> that user don't have to bother flashing multiple images  for spi boot
>>> given the fact that all other boot modes have single image.
>>>
 Regardless, I still see the DT problem as the bigger one long term, and
 dra7xx shows that.  And I agree we need to re-size how the flash is
 partitioned.
>>> True.
>> The next question is, given that Franklin is talking about being able to
>> load the right DTB for any K2 platform basically, is the layout in
>> https://patchwork.ozlabs.org/patch/736498/ really looking like it will
>> be enough?
>>
> 
> I will leave Franklin to comment here. I dont think he has plans to do
> changes for all K2 platforms (I guess his plans are mostly limited to K2G)

I'm not sure if there is any real solution other than providing a
generous amount of storage for U-boot in the flash memory. I don't think
atleast within our TI SDK use cases we even use the misc partition. So I
don't see a reason why we couldn't give U-boot's partition 3 or 4 MB of
space.

Also has there been any thoughts of compressing dtbs? These dtbs are
relatively massive and compressed they are around 1/5 the size.

Personally I'm not a fan of U-boot performing all these fix ups before
passing things to the kernel. It forces so much coupling between
bootloader versions and kernel. And things become more painful when
changes in the kernel causes U-boot fix ups to break.

> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 12/31] board_f: Add new function to allow runtime DTB selection

2017-03-30 Thread Franklin S Cooper Jr


On 03/10/2017 09:42 AM, Tom Rini wrote:
> On Thu, Mar 09, 2017 at 09:12:56PM +0100, Lukasz Majewski wrote:
>> On Thu, 9 Mar 2017 08:08:20 -0500
>> Tom Rini  wrote:
>>
>>> On Thu, Mar 02, 2017 at 01:04:16PM -0600, Franklin S Cooper Jr wrote:
>>>
>>>> Runtime U-boot dtb selection is generally a two step process. First
>>>> step is to simply use an initial generic dtb. The second step is to
>>>> select the dtb and perhaps execute additional code ones U-boot
>>>> knows what board it is running on. Embedded_dtb_select handles the
>>>> second step by allowing board specific code to run and perform what
>>>> ever necessary configuration that is needed.
>>>
>>> So I'm not 100% sure on how to proceed here exactly.  We have a few
>>> things to consider.  First, I bet the generic dtb is good enough for
>>> loading up and booting to Linux (and loading/passing a different,
>>> complete and board specific DTB).  Second, we have the (reasonable)
>>> set of patches and discussion to make the DTB that we use available
>>> easily so that it could be passed on to Linux (or EFI apps or
>>> whatever). So, this is probably the right thing to do in the long
>>> run, but is also another data point in the "but we need to think and
>>> talk about if some platforms really shouldn't be shipping their full
>>> FT on the HW somewhere".
>>
>> It might also happen that somebody would like to have one "blessed"
>> u-boot binary stored in one place and then only change u-boot DTB stored
>> on another memory region (like eMMC, NOR).
>>
>> The above also seems like a valid use case, especially when one wants to
>> support device for a long time (many DTBs) and avoid uncontrolled grown
>> of final u-boot.img binary size (as this is now the case for TI).
> 
> I'd rather stress that the problem is that when we want to support N
> boards and we do that by including N device tree blobs, the size is
> going to grow with each board.  What's not happening yet is the DTB is
> being stored in the device and accessed that way.  I'd really like to
> see some boards moving in that direction.  And it seems like perhaps
> you're working on some that could?  Thanks!

The problem I see is storing dtbs that U-boot needs as part of booting
at a different location requires alot of guarantees across all the evms
being supported by the single image. If for NAND boot one board stores
U-boot's dtb blobs in one partition vs another then things fall apart.
The larger this minimal dtb is the harder it is to guarantee that it
will be valid in the future when/if new boards are introduced or reved.

The benefit of having a dtb bundled in the U-boot image is that no
matter the boot mode or board differences as long as something loads
U-boot it can then select the proper dtb to use from memory. I think I
remember Andrew also saying how having U-boot's dtbs built in will make
things easier in the HS world.

Now the method that U-boot is loaded and where U-boot is stored will
need to deal with U-boots larger size. But I think its rather enviable
since atleast for TI evms we kept space allowance for U-boot in NOR and
NAND rather small for no real reason.

In general if someone adds support and makes use of using a minimal
U-boot dtb and loading the "correct" one from some other location I
wouldn't have an issue with that. But atleast to me I don't think that
is the direction for TI evms.
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH] ARM: keystone: Pass SPI MTD partition table via kernel command line

2017-03-30 Thread Franklin S Cooper Jr


On 03/21/2017 07:25 PM, Tom Rini wrote:
> On Tue, Mar 21, 2017 at 01:52:07PM -0500, Franklin S Cooper Jr wrote:
>>
>>
>> On 03/20/2017 11:57 PM, Vignesh R wrote:
>>>
>>>
>>> On Saturday 18 March 2017 08:04 PM, Tom Rini wrote:
>>>>>> And can we not move towards the "normal" method of SPL loading
>>>>>> the u-boot.img (or FIT) from?  I guess the current architecture here is
>>>>>> confusing me.
>>>>> This has been same for all k2 platforms. I guess we have single image so
>>>>> that user don't have to bother flashing multiple images  for spi boot
>>>>> given the fact that all other boot modes have single image.
>>>>>
>>>>>> Regardless, I still see the DT problem as the bigger one long term, and
>>>>>> dra7xx shows that.  And I agree we need to re-size how the flash is
>>>>>> partitioned.
>>>>> True.
>>>> The next question is, given that Franklin is talking about being able to
>>>> load the right DTB for any K2 platform basically, is the layout in
>>>> https://patchwork.ozlabs.org/patch/736498/ really looking like it will
>>>> be enough?
>>>>
>>>
>>> I will leave Franklin to comment here. I dont think he has plans to do
>>> changes for all K2 platforms (I guess his plans are mostly limited to K2G)
>>
>> I'm not sure if there is any real solution other than providing a
>> generous amount of storage for U-boot in the flash memory. I don't think
>> atleast within our TI SDK use cases we even use the misc partition. So I
>> don't see a reason why we couldn't give U-boot's partition 3 or 4 MB of
>> space.
> 
> OK.  But what about a dedicated place where the right (base) board DTB
> could reside?

If the concern is space atleast for TI evms I don't see the difference
between carving out separate space just for dtbs vs having 1 large space
for both U-boot and dtbs. Without the right dtb U-boot may not properly
boot or have enough to boot a kernel. So if dtbs out grow their space we
will need to increase it anyway.

> 
>> Also has there been any thoughts of compressing dtbs? These dtbs are
>> relatively massive and compressed they are around 1/5 the size.
> 
> There has not yet been.  My first thought is about decompression time,
> but maybe that won't matter.

So my thought would be that we will compress the dtbs individually and
not the entire FIT image. This way U-boot can then read the FIT header
uncompressed and then select and uncompress only the dtb it needs.
> 
>>
>> Personally I'm not a fan of U-boot performing all these fix ups before
>> passing things to the kernel. It forces so much coupling between
>> bootloader versions and kernel. And things become more painful when
>> changes in the kernel causes U-boot fix ups to break.
> 
> To the final point, I cannot find the video from the device tree BoF at
> ELC, but as we talked about there, to some degree overlays/fixups will
> have to be done in Linux.  But by the same token, a lot of overlay
> applications will be done prior to the kernel as well.  When in doubt,
> this shouldn't be done in C, but in user replaceable/updatable scripts.
> 

I think prebuilt overlays that are loaded and applied in U-boot is the
right way to go. Atleast then its not entwined within source code and is
edited in a very human readable manner.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] mtd: nand: am335x_spl_bch: Incorporate tWB delay in nand_command function

2017-04-06 Thread Franklin S Cooper Jr
Various commands to NAND flash results in the NAND flash becoming busy.
For those commands the SoC should wait until the NAND indicates it is
no longer busy before sending further commands. However, there is a delay
between the time the SoC sends its last command and when the NAND flash
sets its Ready/Busy Pin. This delay (tWB) must be respected or the SoC may
falsely assume the flash is ready when in reality it just hasn't had enough
time to indicate that it is busy.

Properly delaying by tWB is already done for nand_command/nand_command_lp
in nand_base.c including the version of it in the Linux kernel. Therefore,
this patch brings the handling of tWB delay inline to nand_base.c

Signed-off-by: Franklin S Cooper Jr 
---
 drivers/mtd/nand/am335x_spl_bch.c | 50 +--
 1 file changed, 38 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/am335x_spl_bch.c 
b/drivers/mtd/nand/am335x_spl_bch.c
index a8a7a66..fdf6728 100644
--- a/drivers/mtd/nand/am335x_spl_bch.c
+++ b/drivers/mtd/nand/am335x_spl_bch.c
@@ -49,6 +49,12 @@ static int nand_command(int block, int page, uint32_t offs,
 
if (cmd == NAND_CMD_RESET) {
hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
+
+   /* * Apply this short delay always to ensure that we do wait
+* tWB in any case on any machine.
+*/
+   ndelay(150);
+
while (!this->dev_ready(mtd))
;
return 0;
@@ -78,23 +84,43 @@ static int nand_command(int block, int page, uint32_t offs,
 
hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
 
-   if (cmd == NAND_CMD_READ0) {
-   /* Latch in address */
-   hwctrl(mtd, NAND_CMD_READSTART,
-  NAND_CTRL_CLE | NAND_CTRL_CHANGE);
-   hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
 
-   /*
-* Wait a while for the data to be ready
-*/
-   while (!this->dev_ready(mtd))
-   ;
-   } else if (cmd == NAND_CMD_RNDOUT) {
+   /*
+* Program and erase have their own busy handlers status, sequential
+* in and status need no delay.
+*/
+   switch (cmd) {
+   case NAND_CMD_CACHEDPROG:
+   case NAND_CMD_PAGEPROG:
+   case NAND_CMD_ERASE1:
+   case NAND_CMD_ERASE2:
+   case NAND_CMD_SEQIN:
+   case NAND_CMD_RNDIN:
+   case NAND_CMD_STATUS:
+   return 0;
+
+   case NAND_CMD_RNDOUT:
+   /* No ready / busy check necessary */
hwctrl(mtd, NAND_CMD_RNDOUTSTART, NAND_CTRL_CLE |
-   NAND_CTRL_CHANGE);
+  NAND_CTRL_CHANGE);
+   hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
+   return 0;
+
+   case NAND_CMD_READ0:
+   /* Latch in address */
+   hwctrl(mtd, NAND_CMD_READSTART,
+  NAND_CTRL_CLE | NAND_CTRL_CHANGE);
hwctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
}
 
+   /* * Apply this short delay always to ensure that we do wait tWB in
+* any case on any machine.
+*/
+   ndelay(150);
+
+   while (!this->dev_ready(mtd))
+   ;
+
return 0;
 }
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 1/8] i2c: davinci: Split functions into two parts for future DM support

2017-04-11 Thread Franklin S Cooper Jr
The i2c driver will be converted to support device model. In preparation
for that change split the various functions into two parts. This will
allow device model specific driver to reuse the majority of the code from
the non device model implementation.

Also rename the probe function to probe_chip to better reflect its
purpose.

Signed-off-by: Franklin S Cooper Jr 
---
 drivers/i2c/davinci_i2c.c | 185 +++---
 1 file changed, 110 insertions(+), 75 deletions(-)

diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c
index c5bd38c..a6bce26 100644
--- a/drivers/i2c/davinci_i2c.c
+++ b/drivers/i2c/davinci_i2c.c
@@ -29,9 +29,8 @@
 
 static struct i2c_regs *davinci_get_base(struct i2c_adapter *adap);
 
-static int wait_for_bus(struct i2c_adapter *adap)
+static int _wait_for_bus(struct i2c_regs *i2c_base)
 {
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
int stat, timeout;
 
REG(&(i2c_base->i2c_stat)) = 0x;
@@ -51,10 +50,8 @@ static int wait_for_bus(struct i2c_adapter *adap)
return 1;
 }
 
-
-static int poll_i2c_irq(struct i2c_adapter *adap, int mask)
+static int _poll_i2c_irq(struct i2c_regs *i2c_base, int mask)
 {
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
int stat, timeout;
 
for (timeout = 0; timeout < 10; timeout++) {
@@ -68,10 +65,8 @@ static int poll_i2c_irq(struct i2c_adapter *adap, int mask)
return stat | I2C_TIMEOUT;
 }
 
-static void flush_rx(struct i2c_adapter *adap)
+static void _flush_rx(struct i2c_regs *i2c_base)
 {
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
-
while (1) {
if (!(REG(&(i2c_base->i2c_stat)) & I2C_STAT_RRDY))
break;
@@ -82,9 +77,9 @@ static void flush_rx(struct i2c_adapter *adap)
}
 }
 
-static uint davinci_i2c_setspeed(struct i2c_adapter *adap, uint speed)
+static uint _davinci_i2c_setspeed(struct i2c_regs *i2c_base,
+ uint speed)
 {
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
uint32_tdiv, psc;
 
psc = 2;
@@ -94,20 +89,18 @@ static uint davinci_i2c_setspeed(struct i2c_adapter *adap, 
uint speed)
REG(&(i2c_base->i2c_scll)) = (div * 50) / 100; /* 50% Duty */
REG(&(i2c_base->i2c_sclh)) = div - REG(&(i2c_base->i2c_scll));
 
-   adap->speed = speed;
return 0;
 }
 
-static void davinci_i2c_init(struct i2c_adapter *adap, int speed, int slaveadd)
+static void _davinci_i2c_init(struct i2c_regs *i2c_base,
+ uint speed, int slaveadd)
 {
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
-
if (REG(&(i2c_base->i2c_con)) & I2C_CON_EN) {
REG(&(i2c_base->i2c_con)) = 0;
udelay(5);
}
 
-   davinci_i2c_setspeed(adap, speed);
+   _davinci_i2c_setspeed(i2c_base, speed);
 
REG(&(i2c_base->i2c_oa)) = slaveadd;
REG(&(i2c_base->i2c_cnt)) = 0;
@@ -122,47 +115,9 @@ static void davinci_i2c_init(struct i2c_adapter *adap, int 
speed, int slaveadd)
udelay(1000);
 }
 
-static int davinci_i2c_probe(struct i2c_adapter *adap, uint8_t chip)
+static int _davinci_i2c_read(struct i2c_regs *i2c_base, uint8_t chip,
+uint32_t addr, int alen, uint8_t *buf, int len)
 {
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
-   int rc = 1;
-
-   if (chip == REG(&(i2c_base->i2c_oa)))
-   return rc;
-
-   REG(&(i2c_base->i2c_con)) = 0;
-   if (wait_for_bus(adap))
-   return 1;
-
-   /* try to read one byte from current (or only) address */
-   REG(&(i2c_base->i2c_cnt)) = 1;
-   REG(&(i2c_base->i2c_sa))  = chip;
-   REG(&(i2c_base->i2c_con)) = (I2C_CON_EN | I2C_CON_MST | I2C_CON_STT |
-I2C_CON_STP);
-   udelay(5);
-
-   if (!(REG(&(i2c_base->i2c_stat)) & I2C_STAT_NACK)) {
-   rc = 0;
-   flush_rx(adap);
-   REG(&(i2c_base->i2c_stat)) = 0x;
-   } else {
-   REG(&(i2c_base->i2c_stat)) = 0x;
-   REG(&(i2c_base->i2c_con)) |= I2C_CON_STP;
-   udelay(2);
-   if (wait_for_bus(adap))
-   return 1;
-   }
-
-   flush_rx(adap);
-   REG(&(i2c_base->i2c_stat)) = 0x;
-   REG(&(i2c_base->i2c_cnt)) = 0;
-   return rc;
-}
-
-static int davinci_i2c_read(struct i2c_adapter *adap, uint8_t chip,
-   uint32_t addr, int alen, uint8_t *buf, int len)
-{
-   struct i2c_regs *i2c_base = davinci_get_base(adap);
uint32_ttmp;
int i;
 
@@ -171,7 +126,7 @@ static int davinci_i2c_read(struct i2c_adapter *adap, 
uint8_t chip

[U-Boot] [PATCH 2/8] drivers: i2c: davinci_i2c: Update davinci i2c driver to driver model

2017-04-11 Thread Franklin S Cooper Jr
Convert davinci i2c driver to driver model.

Signed-off-by: Franklin S Cooper Jr 
---
 drivers/i2c/davinci_i2c.c | 92 +--
 1 file changed, 90 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c
index a6bce26..4471193 100644
--- a/drivers/i2c/davinci_i2c.c
+++ b/drivers/i2c/davinci_i2c.c
@@ -14,11 +14,21 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include "davinci_i2c.h"
 
+#ifdef CONFIG_DM_I2C
+/* Information about i2c controller */
+struct i2c_bus {
+   int id;
+   uintspeed;
+   struct i2c_regs *regs;
+};
+#endif
+
 #define CHECK_NACK() \
do {\
if (tmp & (I2C_TIMEOUT | I2C_STAT_NACK)) {\
@@ -27,8 +37,6 @@
} \
} while (0)
 
-static struct i2c_regs *davinci_get_base(struct i2c_adapter *adap);
-
 static int _wait_for_bus(struct i2c_regs *i2c_base)
 {
int stat, timeout;
@@ -331,6 +339,7 @@ static int _davinci_i2c_probe_chip(struct i2c_regs 
*i2c_base, uint8_t chip)
return rc;
 }
 
+#ifndef CONFIG_DM_I2C
 static struct i2c_regs *davinci_get_base(struct i2c_adapter *adap)
 {
switch (adap->hwadapnr) {
@@ -420,3 +429,82 @@ U_BOOT_I2C_ADAP_COMPLETE(davinci_2, davinci_i2c_init, 
davinci_i2c_probe_chip,
 CONFIG_SYS_DAVINCI_I2C_SLAVE2,
 2)
 #endif
+
+#else /* CONFIG_DM_I2C */
+
+static int davinci_i2c_xfer(struct udevice *bus, struct i2c_msg *msg,
+ int nmsgs)
+{
+   struct i2c_bus *i2c_bus = dev_get_priv(bus);
+   int ret;
+
+   debug("i2c_xfer: %d messages\n", nmsgs);
+   for (; nmsgs > 0; nmsgs--, msg++) {
+   debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len);
+   if (msg->flags & I2C_M_RD) {
+   ret = _davinci_i2c_read(i2c_bus->regs, msg->addr,
+   0, 0, msg->buf, msg->len);
+   } else {
+   ret = _davinci_i2c_write(i2c_bus->regs, msg->addr,
+   0, 0, msg->buf, msg->len);
+   }
+   if (ret) {
+   debug("i2c_write: error sending\n");
+   return -EREMOTEIO;
+   }
+   }
+
+   return ret;
+}
+
+static int davinci_i2c_set_speed(struct udevice *dev, uint speed)
+{
+   struct i2c_bus *i2c_bus = dev_get_priv(dev);
+
+   i2c_bus->speed = speed;
+   return _davinci_i2c_setspeed(i2c_bus->regs, speed);
+}
+
+static int davinci_i2c_probe(struct udevice *dev)
+{
+   struct i2c_bus *i2c_bus = dev_get_priv(dev);
+
+   i2c_bus->id = dev->seq;
+   i2c_bus->regs = (struct i2c_regs *)dev_get_addr(dev);
+
+   i2c_bus->speed = 10;
+_davinci_i2c_init(i2c_bus->regs, i2c_bus->speed, 0);
+
+   return 0;
+}
+
+static int davinci_i2c_probe_chip(struct udevice *bus, uint chip_addr,
+ uint chip_flags)
+{
+   struct i2c_bus *i2c_bus = dev_get_priv(bus);
+
+   return _davinci_i2c_probe_chip(i2c_bus->regs, chip_addr);
+}
+
+static const struct dm_i2c_ops davinci_i2c_ops = {
+   .xfer   = davinci_i2c_xfer,
+   .probe_chip = davinci_i2c_probe_chip,
+   .set_bus_speed  = davinci_i2c_set_speed,
+};
+
+static const struct udevice_id davinci_i2c_ids[] = {
+   { .compatible = "ti,davinci-i2c"},
+   { .compatible = "ti,keystone-i2c"},
+   { }
+};
+
+U_BOOT_DRIVER(i2c_davinci) = {
+   .name   = "i2c_davinci",
+   .id = UCLASS_I2C,
+   .of_match = davinci_i2c_ids,
+   .probe  = davinci_i2c_probe,
+   .priv_auto_alloc_size = sizeof(struct i2c_bus),
+   .ops= &davinci_i2c_ops,
+};
+
+#endif /* CONFIG_DM_I2C */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 3/8] ti: common: board_detect: Introduce function to set the address length.

2017-04-11 Thread Franklin S Cooper Jr
Reading from the I2C EEPROM used typically requires using an address length
of 2. However, when using DM for I2C the default address length used is 1.
To fix this introduce a new function that allows the address length to be
changed. The logic to do so was copied from cmd/i2c.c.

Signed-off-by: Franklin S Cooper Jr 
---
 board/ti/common/board_detect.c | 37 +
 1 file changed, 37 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index c55e24e..1e695f4 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -10,10 +10,47 @@
 
 #include 
 #include 
+#include 
 #include 
 
 #include "board_detect.h"
 
+#if defined(CONFIG_DM_I2C_COMPAT)
+/**
+ * ti_i2c_set_alen - Set chip's i2c address length
+ * @bus_addr - I2C bus number
+ * @dev_addr - I2C eeprom id
+ * @alen - I2C address length in bytes
+ *
+ * DM_I2C by default sets the address length to be used to 1. This
+ * function allows this address length to be changed to match the
+ * eeprom used for board detection.
+ */
+int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
+{
+   struct udevice *dev;
+   struct udevice *bus;
+   int rc;
+
+   rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus);
+   if (rc)
+   return rc;
+   rc = i2c_get_chip(bus, dev_addr, 1, &dev);
+   if (rc)
+   return rc;
+   rc = i2c_set_chip_offset_len(dev, alen);
+   if (rc)
+   return rc;
+
+   return 0;
+}
+#else
+int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
+{
+   return 0;
+}
+#endif
+
 /**
  * ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device
  * @i2c_bus: i2c bus number to initialize
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 7/8] ARM: dts: keystone-k2g-evm: Enable I2C0 and I2C1

2017-04-11 Thread Franklin S Cooper Jr
Enable I2C0 and I2C1 which is needed to enable usage of DM I2C.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2g-evm.dts | 8 
 1 file changed, 8 insertions(+)

diff --git a/arch/arm/dts/keystone-k2g-evm.dts 
b/arch/arm/dts/keystone-k2g-evm.dts
index 696a0d7..2c99df4 100644
--- a/arch/arm/dts/keystone-k2g-evm.dts
+++ b/arch/arm/dts/keystone-k2g-evm.dts
@@ -108,3 +108,11 @@
 &mmc1 {
status = "okay";
 };
+
+&i2c0 {
+   status = "okay";
+};
+
+&i2c1 {
+   status = "okay";
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 4/8] ti: common: board_detect: Set alen to expected value before i2c read

2017-04-11 Thread Franklin S Cooper Jr
In non DM I2C read operations the address length passed in during a read
operation will be used automatically. However, in DM I2C the address length
is set to a default value of one which causes problems when trying to
perform a read with a differing alen. Therefore, before the first read in a
series of read operations set the alen to the correct value.

Signed-off-by: Franklin S Cooper Jr 
---
 board/ti/common/board_detect.c | 24 ++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 1e695f4..6fdcb61 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -83,7 +83,17 @@ static int __maybe_unused ti_i2c_eeprom_init(int i2c_bus, 
int dev_addr)
 static int __maybe_unused ti_i2c_eeprom_read(int dev_addr, int offset,
 uchar *ep, int epsize)
 {
-   return i2c_read(dev_addr, offset, 2, ep, epsize);
+   int bus_num, rc, alen;
+
+   bus_num = i2c_get_bus_num();
+
+   alen = 2;
+
+   rc = ti_i2c_set_alen(bus_num, dev_addr, alen);
+   if (rc)
+   return rc;
+
+   return i2c_read(dev_addr, offset, alen, ep, epsize);
 }
 
 /**
@@ -125,6 +135,11 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, 
int dev_addr,
 * Read the header first then only read the other contents.
 */
byte = 2;
+
+   rc = ti_i2c_set_alen(bus_addr, dev_addr, byte);
+   if (rc)
+   return rc;
+
rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read, 4);
if (rc)
return rc;
@@ -137,9 +152,14 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, 
int dev_addr,
 * 1 byte address (some legacy boards need this..)
 */
byte = 1;
-   if (rc)
+   if (rc) {
+   rc = ti_i2c_set_alen(bus_addr, dev_addr, byte);
+   if (rc)
+   return rc;
+
rc = i2c_read(dev_addr, 0x0, byte, (uint8_t *)&hdr_read,
  4);
+   }
if (rc)
return rc;
}
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 5/8] ARM: dts: k2g: Add I2C nodes to 66AK2Gx

2017-04-11 Thread Franklin S Cooper Jr
Add I2C nodes to the 66AK2Gx dtsi.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2g.dtsi | 32 
 1 file changed, 32 insertions(+)

diff --git a/arch/arm/dts/keystone-k2g.dtsi b/arch/arm/dts/keystone-k2g.dtsi
index 2193f9f..191e3f1 100644
--- a/arch/arm/dts/keystone-k2g.dtsi
+++ b/arch/arm/dts/keystone-k2g.dtsi
@@ -24,6 +24,9 @@
spi2 = &spi2;
spi3 = &spi3;
spi4 = &qspi;
+   i2c0 = &i2c0;
+   i2c1 = &i2c1;
+   i2c2 = &i2c2;
};
 
memory {
@@ -149,6 +152,35 @@
#size-cells = <0>;
status = "disabled";
};
+   i2c0: i2c@253 {
+   compatible = "ti,keystone-i2c";
+   reg = <0x0253 0x400>;
+   clock-frequency = <10>;
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
+   i2c1: i2c@2530400 {
+   compatible = "ti,keystone-i2c";
+   reg = <0x02530400 0x400>;
+   clock-frequency = <10>;
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
+
+   i2c2: i2c@2530800 {
+   compatible = "ti,keystone-i2c";
+   reg = <0x02530800 0x400>;
+   clock-frequency = <10>;
+   interrupts = ;
+   #address-cells = <1>;
+   #size-cells = <0>;
+   status = "disabled";
+   };
 
mmc0: mmc@2300 {
compatible = "ti,omap4-hsmmc";
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 6/8] ARM: dts: keystone2: add I2C aliases for davinci I2C nodes

2017-04-11 Thread Franklin S Cooper Jr
Add aliases for I2C nodes required for the DM framework to probe the
davinci-i2c driver.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone.dtsi | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm/dts/keystone.dtsi b/arch/arm/dts/keystone.dtsi
index be97f3f..9a2e1f6 100644
--- a/arch/arm/dts/keystone.dtsi
+++ b/arch/arm/dts/keystone.dtsi
@@ -22,6 +22,9 @@
spi0 = &spi0;
spi1 = &spi1;
spi2 = &spi2;
+   i2c0 = &i2c0;
+   i2c1 = &i2c1;
+   i2c2 = &i2c2;
};
 
chosen {
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 0/8] drivers: i2c: davinci_i2c: Convert driver to DM

2017-04-11 Thread Franklin S Cooper Jr
This patch series converts the davinci i2c driver to use device model.
This updated driver has been verified on both Keystone K2G and Keystone
K2L evms by performing several i2c operations in U-boot prompt.

Some additional work was required to get things working on K2G due to
the code that reads the on board EEPROM. DM I2C sets the default address
length to a default value of 1 when the on EEPROM requires an address
length of 2. Therefore, an additional function and minor changes were
required to get things working properly.

Franklin S Cooper Jr (8):
  i2c: davinci: Split functions into two parts for future DM support
  drivers: i2c: davinci_i2c: Update davinci i2c driver to driver model
  ti: common: board_detect: Introduce function to set the address
length.
  ti: common: board_detect: Set alen to expected value before i2c read
  ARM: dts: k2g: Add I2C nodes to 66AK2Gx
  ARM: dts: keystone2: add I2C aliases for davinci I2C nodes
  ARM: dts: keystone-k2g-evm: Enable I2C0 and I2C1
  defconfig: keystone: Enable DM I2C

 arch/arm/dts/keystone-k2g-evm.dts |   8 ++
 arch/arm/dts/keystone-k2g.dtsi|  32 +
 arch/arm/dts/keystone.dtsi|   3 +
 board/ti/common/board_detect.c|  61 -
 configs/k2e_evm_defconfig |   1 +
 configs/k2g_evm_defconfig |   1 +
 configs/k2hk_evm_defconfig|   1 +
 configs/k2l_evm_defconfig |   1 +
 drivers/i2c/davinci_i2c.c | 277 +++---
 9 files changed, 306 insertions(+), 79 deletions(-)

-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 8/8] defconfig: keystone: Enable DM I2C

2017-04-11 Thread Franklin S Cooper Jr
Now that the davinci I2C driver is converted to driver model enable
it in 66AK2Gx defconfig

Signed-off-by: Franklin S Cooper Jr 
---
 configs/k2e_evm_defconfig  | 1 +
 configs/k2g_evm_defconfig  | 1 +
 configs/k2hk_evm_defconfig | 1 +
 configs/k2l_evm_defconfig  | 1 +
 4 files changed, 4 insertions(+)

diff --git a/configs/k2e_evm_defconfig b/configs/k2e_evm_defconfig
index d319705..52e5bd4 100644
--- a/configs/k2e_evm_defconfig
+++ b/configs/k2e_evm_defconfig
@@ -54,3 +54,4 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DM_I2C=y
diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig
index bbdcc2f..d4cdf61 100644
--- a/configs/k2g_evm_defconfig
+++ b/configs/k2g_evm_defconfig
@@ -58,3 +58,4 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DM_I2C=y
diff --git a/configs/k2hk_evm_defconfig b/configs/k2hk_evm_defconfig
index b22086d..7d22cd6 100644
--- a/configs/k2hk_evm_defconfig
+++ b/configs/k2hk_evm_defconfig
@@ -54,3 +54,4 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DM_I2C=y
diff --git a/configs/k2l_evm_defconfig b/configs/k2l_evm_defconfig
index 5a28112..ec2fcbf 100644
--- a/configs/k2l_evm_defconfig
+++ b/configs/k2l_evm_defconfig
@@ -54,3 +54,4 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DM_I2C=y
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 3/8] ti: common: board_detect: Introduce function to set the address length.

2017-04-12 Thread Franklin S Cooper Jr


On 04/12/2017 03:40 AM, Vignesh R wrote:
> 
> 
> On Wednesday 12 April 2017 12:07 AM, Franklin S Cooper Jr wrote:
>> Reading from the I2C EEPROM used typically requires using an address length
>> of 2. However, when using DM for I2C the default address length used is 1.
>> To fix this introduce a new function that allows the address length to be
>> changed. The logic to do so was copied from cmd/i2c.c.
>>
>> Signed-off-by: Franklin S Cooper Jr 
> 
> I maybe wrong, but doesn't adding DT property
> u-boot,i2c-offset-len = <2>;
> to the i2c slave node help to achieve this?

There is no i2c slave node for this. This is just a function making raw
i2c read operations. In the future especially when OMAP SPL uses DM it
would be useful to see if this can be converted to a actual driver. Then
u-boot,i2c-offset-len should work.
> 
> Regards
> Vignesh
> 
>> ---
>>  board/ti/common/board_detect.c | 37 +
>>  1 file changed, 37 insertions(+)
>>
>> diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
>> index c55e24e..1e695f4 100644
>> --- a/board/ti/common/board_detect.c
>> +++ b/board/ti/common/board_detect.c
>> @@ -10,10 +10,47 @@
>>  
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  
>>  #include "board_detect.h"
>>  
>> +#if defined(CONFIG_DM_I2C_COMPAT)
>> +/**
>> + * ti_i2c_set_alen - Set chip's i2c address length
>> + * @bus_addr - I2C bus number
>> + * @dev_addr - I2C eeprom id
>> + * @alen - I2C address length in bytes
>> + *
>> + * DM_I2C by default sets the address length to be used to 1. This
>> + * function allows this address length to be changed to match the
>> + * eeprom used for board detection.
>> + */
>> +int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
>> +{
>> +struct udevice *dev;
>> +struct udevice *bus;
>> +int rc;
>> +
>> +rc = uclass_get_device_by_seq(UCLASS_I2C, bus_addr, &bus);
>> +if (rc)
>> +return rc;
>> +rc = i2c_get_chip(bus, dev_addr, 1, &dev);
>> +if (rc)
>> +return rc;
>> +rc = i2c_set_chip_offset_len(dev, alen);
>> +if (rc)
>> +return rc;
>> +
>> +return 0;
>> +}
>> +#else
>> +int __maybe_unused ti_i2c_set_alen(int bus_addr, int dev_addr, int alen)
>> +{
>> +return 0;
>> +}
>> +#endif
>> +
>>  /**
>>   * ti_i2c_eeprom_init - Initialize an i2c bus and probe for a device
>>   * @i2c_bus: i2c bus number to initialize
>>
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 5/8] ARM: dts: k2g: Add I2C nodes to 66AK2Gx

2017-04-12 Thread Franklin S Cooper Jr


On 04/12/2017 02:11 PM, Tom Rini wrote:
> On Tue, Apr 11, 2017 at 01:37:22PM -0500, Franklin S Cooper Jr wrote:
> 
>> Add I2C nodes to the 66AK2Gx dtsi.
>>
>> Signed-off-by: Franklin S Cooper Jr 
>> ---
>>  arch/arm/dts/keystone-k2g.dtsi | 32 
>>  1 file changed, 32 insertions(+)
> 
> OK, are these upstream as well?  If so, should we perhaps sync with the
> kernel for a bunch of updates?

No this isn't upstreamed yet. There is quite a bit of clock related work
that needs to be upstreamed before we can add various peripherals to the
DT. It will be several months before this happens. Once it happens I can
sync U-boot's K2G DT with the one that has been upstreamed.
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 8/8] defconfig: keystone: Enable DM I2C

2017-04-12 Thread Franklin S Cooper Jr


On 04/12/2017 02:13 PM, Tom Rini wrote:
> On Tue, Apr 11, 2017 at 01:37:25PM -0500, Franklin S Cooper Jr wrote:
> 
>> Now that the davinci I2C driver is converted to driver model enable
>> it in 66AK2Gx defconfig
>>
>> Signed-off-by: Franklin S Cooper Jr 
>> ---
>>  configs/k2e_evm_defconfig  | 1 +
>>  configs/k2g_evm_defconfig  | 1 +
>>  configs/k2hk_evm_defconfig | 1 +
>>  configs/k2l_evm_defconfig  | 1 +
>>  4 files changed, 4 insertions(+)
> 
> Should we be imply/select'ing DM_I2C from the Kconfig file now?

Is the goal to reduce the size of the defconfig? Or is it to essentially
force all K2 boards (including possible future non TI boards) to use the
DM so we can deprecate/remove non DM code in the future?

If its for the latter then I don't have an issue doing so.
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH 8/8] defconfig: keystone: Enable DM I2C

2017-04-12 Thread Franklin S Cooper Jr


On 04/12/2017 02:33 PM, Tom Rini wrote:
> On Wed, Apr 12, 2017 at 02:26:21PM -0500, Franklin S Cooper Jr wrote:
>>
>>
>> On 04/12/2017 02:13 PM, Tom Rini wrote:
>>> On Tue, Apr 11, 2017 at 01:37:25PM -0500, Franklin S Cooper Jr wrote:
>>>
>>>> Now that the davinci I2C driver is converted to driver model enable
>>>> it in 66AK2Gx defconfig
>>>>
>>>> Signed-off-by: Franklin S Cooper Jr 
>>>> ---
>>>>  configs/k2e_evm_defconfig  | 1 +
>>>>  configs/k2g_evm_defconfig  | 1 +
>>>>  configs/k2hk_evm_defconfig | 1 +
>>>>  configs/k2l_evm_defconfig  | 1 +
>>>>  4 files changed, 4 insertions(+)
>>>
>>> Should we be imply/select'ing DM_I2C from the Kconfig file now?
>>
>> Is the goal to reduce the size of the defconfig? Or is it to essentially
>> force all K2 boards (including possible future non TI boards) to use the
>> DM so we can deprecate/remove non DM code in the future?
>>
>> If its for the latter then I don't have an issue doing so.
> 
> Well, both.  I think 'imply' is a great way to specify default values in
> such a way that making new boards/defconfigs is easy and likely to be
> correct.  But also, yes, non-DM will go away at some point.
> 

I'm ok with that. Do you want me to resend this patchset and switch this
patch from enabling DM_I2C via defconfig to KConfig? Or you can just
drop this patch from the patchset and then I can just send a separate
patch enabling DM_I2C via KConfig.

I'm ok with what ever you prefer.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 00/30] ARM: k2g: Add support for new K2G ICE EVM.

2017-05-23 Thread Franklin S Cooper Jr
This patchset adds support for the new Keystone 2 Industrial Communication
Engine board.

This patchset includes the introduction of embedded FIT images in U-boot.
This creates a FIT image of dtb files that enables board specific code to
select which DTB to use at runtime. Initially during boot a generic DTB is
required that enables board detection to occur and once it has can later be
swapped out for the correct dtb.

Version 2 changes:
Some patches were dropped since equivalent changes have already be
incorporated in upstream already.

The addition davinci i2c device model in upstream resulted in some
patches having to be added or tweaked.

The DT for K2G ICE is based on the version that has been accepted into
Linux mainline https://lkml.org/lkml/2017/5/22/28

Franklin S Cooper Jr (29):
  spl: fit: Break out some functions into a common file
  boot_fit: Create helper functions that can be used to select DTB out
of FIT
  fdt: Enable selecting correct DTB from appended FIT Image
  ti: common: board_detect: Add function to determine if EEPROM was read
  dts: Allow OF_LIST to depend on FIT_EMBED
  ARM: dts: k2g: Introduce U-boot specific dtsi file
  arm: dts: Add new "generic" 66AK2Gx device tree file.
  board_f: Add new function to allow runtime DTB selection
  Makefile: Build additional binaries for dtb FIT blobs appended to
U-boot
  ARM: keystone2: Allow to build with all image formats
  ARM: k2g: Define embedded_dtb_select for runtime DTB selection in
U-boot
  ARM: keystone2: Define board_fit_config_name_match for Keystone 2
boards
  ks2_evm: Add EEPROM based board detection
  defconfig: keystone2: Enable U-boot runtime DTB detection
  ARM: keystone2: Add additional fields used for DDR3 configuration
  ARM: k2g: Program DDR PHY MR2 register with the default value
  ARM: k2g: Program DDRPHY_DATX8 registers via mask and value variables
  ks2_evm: Add EEPROM based board detection helper functions
  ARM: k2g: Add pinmux support for K2G ICE evm
  ARM: k2g: Add DDR3 configuration for K2G ICE evm
  board: ks2: Use board detection to wrap code not specific to K2G ICE
evm
  ARM: k2g: Use board detection to wrap K2G GP specific calls
  ARM: k2g: Update board_name u-boot env variable at runtime
  ARM: dts: keystone-k2g: Remove skeleton.dtsi
  ARM: dts: keystone-k2g-evm: Add unit address to memory node
  ARM: dts: k2g: Disable netcp by default
  ARM: dts: k2g: Add DT support for K2G Industrial Communication Engine
evm
  ARM: k2g: Add K2G ICE DTB to the list of possible DTBs
  defconfig: k2g_evm_defconfig: Add K2G ICE to OF_LIST

Nishanth Menon (1):
  ti: common: board_detect: Allow settings board detection variables
manually

 .gitignore |  1 +
 Makefile   | 18 +-
 arch/arm/dts/Makefile  |  4 +-
 arch/arm/dts/keystone-k2g-evm-u-boot.dtsi  | 19 ++
 arch/arm/dts/keystone-k2g-evm.dts  |  9 +++
 arch/arm/dts/keystone-k2g-generic-u-boot.dtsi  | 19 ++
 arch/arm/dts/keystone-k2g-generic.dts  | 29 +
 arch/arm/dts/keystone-k2g-ice-u-boot.dtsi  | 19 ++
 arch/arm/dts/keystone-k2g-ice.dts  | 36 +++
 arch/arm/dts/keystone-k2g-netcp.dtsi   |  1 +
 arch/arm/dts/keystone-k2g.dtsi |  8 +--
 arch/arm/mach-keystone/config.mk   |  4 +-
 arch/arm/mach-keystone/ddr3.c  | 35 ---
 arch/arm/mach-keystone/include/mach/ddr3.h | 14 +
 arch/arm/mach-keystone/include/mach/hardware.h |  3 +
 board/ti/common/board_detect.c | 34 ++
 board/ti/common/board_detect.h | 26 
 board/ti/ks2_evm/board.c   | 21 +--
 board/ti/ks2_evm/board.h   | 21 +++
 board/ti/ks2_evm/board_k2e.c   | 10 +++
 board/ti/ks2_evm/board_k2g.c   | 86 +++---
 board/ti/ks2_evm/board_k2hk.c  | 10 +++
 board/ti/ks2_evm/board_k2l.c   | 10 +++
 board/ti/ks2_evm/ddr3_k2g.c| 78 ++-
 board/ti/ks2_evm/mux-k2g.h | 45 +-
 common/Kconfig | 18 ++
 common/Makefile|  2 +
 common/board_f.c   |  3 +
 common/boot_fit.c  | 58 +
 common/common_fit.c| 86 ++
 common/spl/spl_fit.c   | 76 +--
 configs/k2e_evm_defconfig  |  3 +
 configs/k2g_evm_defconfig  |  3 +
 configs/k2hk_evm_defconfig |  3 +
 configs/k2l_evm_defconfig  |  3 +
 dts/Kconfig| 11 ++--
 include/boot_fit.h |  9 +++
 includ

[U-Boot] [PATCH v2 02/30] spl: fit: Break out some functions into a common file

2017-05-23 Thread Franklin S Cooper Jr
Some of the functions within spl_fit will be used for non spl purposes.
Instead of duplicating functions simply break the functions to be reused
into its own file.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
Reviewed-by: Simon Glass 
---
 common/Makefile  |  1 +
 common/common_fit.c  | 86 
 common/spl/spl_fit.c | 76 +-
 3 files changed, 88 insertions(+), 75 deletions(-)
 create mode 100644 common/common_fit.c

diff --git a/common/Makefile b/common/Makefile
index 14d0184..ccd8bbc 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -95,6 +95,7 @@ obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
+obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
 obj-$(CONFIG_SPL_OF_LIBFDT) += fdt_support.o
 ifdef CONFIG_SPL_USB_HOST_SUPPORT
diff --git a/common/common_fit.c b/common/common_fit.c
new file mode 100644
index 000..a08af72
--- /dev/null
+++ b/common/common_fit.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
+{
+   const u32 *cell;
+   int len;
+
+   cell = fdt_getprop(fdt, node, prop, &len);
+   if (len != sizeof(*cell))
+   return -1U;
+   return fdt32_to_cpu(*cell);
+}
+
+int fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)
+{
+   const char *name, *fdt_name;
+   int conf, node, fdt_node;
+   int len;
+
+   *fdt_offsetp = 0;
+   conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
+   if (conf < 0) {
+   debug("%s: Cannot find /configurations node: %d\n", __func__,
+ conf);
+   return -EINVAL;
+   }
+   for (node = fdt_first_subnode(fdt, conf);
+node >= 0;
+node = fdt_next_subnode(fdt, node)) {
+   name = fdt_getprop(fdt, node, "description", &len);
+   if (!name) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("%s: Missing FDT description in DTB\n",
+  __func__);
+#endif
+   return -EINVAL;
+   }
+   if (board_fit_config_name_match(name))
+   continue;
+
+   debug("Selecting config '%s'", name);
+   fdt_name = fdt_getprop(fdt, node, FIT_FDT_PROP, &len);
+   if (!fdt_name) {
+   debug("%s: Cannot find fdt name property: %d\n",
+ __func__, len);
+   return -EINVAL;
+   }
+
+   debug(", fdt '%s'\n", fdt_name);
+   fdt_node = fdt_subnode_offset(fdt, images, fdt_name);
+   if (fdt_node < 0) {
+   debug("%s: Cannot find fdt node '%s': %d\n",
+ __func__, fdt_name, fdt_node);
+   return -EINVAL;
+   }
+
+   *fdt_offsetp = fdt_getprop_u32(fdt, fdt_node, "data-offset");
+   len = fdt_getprop_u32(fdt, fdt_node, "data-size");
+   debug("FIT: Selected '%s'\n", name);
+
+   return len;
+   }
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("No matching DT out of these options:\n");
+   for (node = fdt_first_subnode(fdt, conf);
+node >= 0;
+node = fdt_next_subnode(fdt, node)) {
+   name = fdt_getprop(fdt, node, "description", &len);
+   printf("   %s\n", name);
+   }
+#endif
+
+   return -ENOENT;
+}
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index aae556f..3a722d3 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -11,80 +11,6 @@
 #include 
 #include 
 
-static ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
-{
-   const u32 *cell;
-   int len;
-
-   cell = fdt_getprop(fdt, node, prop, &len);
-   if (len != sizeof(*cell))
-   return -1U;
-   return fdt32_to_cpu(*cell);
-}
-
-static int spl_fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)
-{
-   const char *name, *fdt_name;
-   int conf, node, fdt_node;
-   int len;
-
-   *fdt_offsetp = 0;
-   conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
-   if (conf < 0) {
-   debug("%s: Cannot find /configurations node: %d\n", __func__,
- conf);
-   return -EINVAL;
-   }
-   for (n

[U-Boot] [PATCH v2 05/30] ti: common: board_detect: Add function to determine if EEPROM was read

2017-05-23 Thread Franklin S Cooper Jr
When the EEPROM is first read its contents are stored in memory as a
cache to avoid further I2C operations. To determine if the EEPROM was
previously read the easiest way is to check the memory to see if the
EEPROM's magic header value is set. Create a new function that can
determine if the EEPROM was previously read or not without having to
perform a I2C transaction.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/common/board_detect.c | 10 ++
 board/ti/common/board_detect.h |  9 +
 2 files changed, 19 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index bf594cb..1da5ace 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -457,3 +457,13 @@ void board_ti_set_ethaddr(int index)
}
}
 }
+
+bool __maybe_unused board_ti_was_eeprom_read(void)
+{
+   struct ti_common_eeprom *ep = TI_EEPROM_DATA;
+
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   return true;
+   else
+   return false;
+}
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index e8d9484..893e1ed 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -206,6 +206,15 @@ void set_board_info_env(char *name);
 void board_ti_set_ethaddr(int index);
 
 /**
+ * board_ti_was_eeprom_read() - Check to see if the eeprom contents have been 
read
+ *
+ * This function is useful to determine if the eeprom has already been read and
+ * its contents have already been loaded into memory. It utiltzes the magic
+ * number that the header value is set to upon successful eeprom read.
+ */
+bool board_ti_was_eeprom_read(void);
+
+/**
  * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
  * @name:  Name of the board
  * @rev:   Revision of the board
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 03/30] boot_fit: Create helper functions that can be used to select DTB out of FIT

2017-05-23 Thread Franklin S Cooper Jr
Some platforms may append a FIT image to the U-boot image. This function
aids in parsing the FIT image and selecting the correct DTB at runtime.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 common/Kconfig |  8 
 common/Makefile|  1 +
 common/boot_fit.c  | 58 ++
 include/boot_fit.h |  9 +
 include/image.h|  8 
 5 files changed, 84 insertions(+)
 create mode 100644 common/boot_fit.c
 create mode 100644 include/boot_fit.h

diff --git a/common/Kconfig b/common/Kconfig
index 1879aef..2429953 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -421,6 +421,14 @@ config SYS_STDIO_DEREGISTER
 
 endmenu
 
+config FIT_EMBED
+   bool "Support a FIT image embedded in the U-boot image"
+   default n
+   help
+ This option provides hooks to allow U-boot to parse an
+ appended FIT image and enable board specific code to then select
+ the correct DTB to be used.
+
 config DEFAULT_FDT_FILE
string "Default fdt file"
help
diff --git a/common/Makefile b/common/Makefile
index ccd8bbc..0c6209b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -151,6 +151,7 @@ obj-y += image.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_)FIT) += image-fit.o
+obj-$(CONFIG_FIT_EMBED) += boot_fit.o common_fit.o
 obj-$(CONFIG_$(SPL_)FIT_SIGNATURE) += image-sig.o
 obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
diff --git a/common/boot_fit.c b/common/boot_fit.c
new file mode 100644
index 000..ff26cf7
--- /dev/null
+++ b/common/boot_fit.c
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2017
+ * Texas Instruments, 
+ *
+ * Franklin S Cooper Jr. 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int fdt_offset(void *fit)
+{
+   int fdt_offset, fdt_len;
+   int images;
+
+   images = fdt_path_offset(fit, FIT_IMAGES_PATH);
+   if (images < 0) {
+   debug("%s: Cannot find /images node: %d\n", __func__, images);
+   return -1;
+   }
+
+   /* Figure out which device tree the board wants to use */
+   fdt_len = fit_select_fdt(fit, images, &fdt_offset);
+
+   if (fdt_len < 0)
+   return fdt_len;
+
+   return fdt_offset;
+}
+
+void *locate_dtb_in_fit(void *fit)
+{
+   struct image_header *header;
+   int size;
+   int ret;
+
+   size = fdt_totalsize(fit);
+   size = (size + 3) & ~3;
+
+   header = (struct image_header *)fit;
+
+   if (image_get_magic(header) != FDT_MAGIC) {
+   debug("No FIT image appended to U-boot\n");
+   return NULL;
+   }
+
+   ret = fdt_offset(fit);
+
+   if (ret <= 0)
+   return NULL;
+   else
+   return (void *)fit+size+ret;
+}
diff --git a/include/boot_fit.h b/include/boot_fit.h
new file mode 100644
index 000..b7d2462
--- /dev/null
+++ b/include/boot_fit.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2017 Texas Instruments
+ * Written by Franklin Cooper Jr. 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+int fdt_offset(void *fit);
+void *locate_dtb_in_fit(void *fit);
diff --git a/include/image.h b/include/image.h
index 3f26f9b..1083578 100644
--- a/include/image.h
+++ b/include/image.h
@@ -18,6 +18,7 @@
 
 #include "compiler.h"
 #include 
+#include 
 
 /* Define this to avoid #ifdefs later on */
 struct lmb;
@@ -1274,6 +1275,13 @@ int board_fit_config_name_match(const char *name);
 void board_fit_image_post_process(void **p_image, size_t *p_size);
 #endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
 
+#if IS_ENABLED(CONFIG_SPL_LOAD_FIT) || IS_ENABLED(CONFIG_FIT_EMBED)
+
+ulong fdt_getprop_u32(const void *fdt, int node, const char *prop);
+int fit_select_fdt(const void *fdt, int images, int *fdt_offsetp);
+
+#endif
+
 /**
  * Mapping of image types to function handlers to be invoked on the associated
  * loaded images
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 17/30] ARM: k2g: Program DDR PHY MR2 register with the default value

2017-05-23 Thread Franklin S Cooper Jr
K2G GP doesn't require the MR2 register to be programed since the
default is good enough. However, newer K2G boards do need to change
this register value. Therefore, instead of not writing this register if
ran on a K2G board just program the value to be written to match the
default/reset value.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/ddr3.c | 3 +--
 board/ti/ks2_evm/ddr3_k2g.c   | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c
index ee8e12e..25a9637 100644
--- a/arch/arm/mach-keystone/ddr3.c
+++ b/arch/arm/mach-keystone/ddr3.c
@@ -52,8 +52,7 @@ void ddr3_init_ddrphy(u32 base, struct ddr3_phy_config 
*phy_cfg)
__raw_writel(phy_cfg->dtpr2, base + KS2_DDRPHY_DTPR2_OFFSET);
__raw_writel(phy_cfg->mr0,   base + KS2_DDRPHY_MR0_OFFSET);
__raw_writel(phy_cfg->mr1,   base + KS2_DDRPHY_MR1_OFFSET);
-   if (!cpu_is_k2g())
-   __raw_writel(phy_cfg->mr2,   base + KS2_DDRPHY_MR2_OFFSET);
+   __raw_writel(phy_cfg->mr2,   base + KS2_DDRPHY_MR2_OFFSET);
__raw_writel(phy_cfg->dtcr,  base + KS2_DDRPHY_DTCR_OFFSET);
__raw_writel(phy_cfg->pgcr2, base + KS2_DDRPHY_PGCR2_OFFSET);
 
diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c
index 344961d..aeb7da6 100644
--- a/board/ti/ks2_evm/ddr3_k2g.c
+++ b/board/ti/ks2_evm/ddr3_k2g.c
@@ -27,7 +27,7 @@ struct ddr3_phy_config ddr3phy_800_2g = {
.dtpr2  = 0x50022A00ul,
.mr0= 0x1430ul,
.mr1= 0x0006ul,
-   .mr2= 0x0018ul,
+   .mr2= 0xul,
.dtcr   = 0x710035C7ul,
.pgcr2  = 0x00F03D09ul,
.zq0cr1 = 0x0001005Dul,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 10/30] Makefile: Build additional binaries for dtb FIT blobs appended to U-boot

2017-05-23 Thread Franklin S Cooper Jr
Add additional make targets and options for building embedded FIT U-boot
images.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 .gitignore |  1 +
 Makefile   | 18 --
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7fac5b3..29757aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@
 #
 # Top-level generic files
 #
+fit-dtb.blob
 /MLO*
 /SPL*
 /System.map
diff --git a/Makefile b/Makefile
index bcab726..ec54c00 100644
--- a/Makefile
+++ b/Makefile
@@ -869,7 +869,21 @@ dts/dt.dtb: checkdtc u-boot
 quiet_cmd_copy = COPY$@
   cmd_copy = cp $< $@
 
-ifeq ($(CONFIG_OF_SEPARATE),y)
+ifeq ($(CONFIG_FIT_EMBED),y)
+
+fit-dtb.blob: dts/dt.dtb FORCE
+   $(call if_changed,mkimage)
+
+MKIMAGEFLAGS_fit-dtb.blob = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
+   -a 0 -e 0 -E \
+   $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) 
-d /dev/null
+
+u-boot-fit-dtb.bin: u-boot-nodtb.bin fit-dtb.blob
+   $(call if_changed,cat)
+
+u-boot.bin: u-boot-fit-dtb.bin FORCE
+   $(call if_changed,copy)
+else ifeq ($(CONFIG_OF_SEPARATE),y)
 u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
$(call if_changed,cat)
 
@@ -1440,7 +1454,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
$(filter-out include, $(shell ls -1 $d 2>/dev/null
 
 CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
-  boot* u-boot* MLO* SPL System.map
+  boot* u-boot* MLO* SPL System.map fit-dtb.blob
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include/generated spl tpl \
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 13/30] ARM: keystone2: Define board_fit_config_name_match for Keystone 2 boards

2017-05-23 Thread Franklin S Cooper Jr
Now with support for U-boot runtime dtb selection each board needs to
define board_fit_config_name_match so U-boot can determine what the
correct dtb is within the FIT blob.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2e.c  | 10 ++
 board/ti/ks2_evm/board_k2g.c  | 14 ++
 board/ti/ks2_evm/board_k2hk.c | 10 ++
 board/ti/ks2_evm/board_k2l.c  | 10 ++
 4 files changed, 44 insertions(+)

diff --git a/board/ti/ks2_evm/board_k2e.c b/board/ti/ks2_evm/board_k2e.c
index 64f0c9c..266a66b 100644
--- a/board/ti/ks2_evm/board_k2e.c
+++ b/board/ti/ks2_evm/board_k2e.c
@@ -166,6 +166,16 @@ int get_num_eth_ports(void)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "keystone-k2e-evm"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 int board_early_init_f(void)
 {
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 4c3819d..d354415 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -214,6 +214,20 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   bool eeprom_read = board_ti_was_eeprom_read();
+
+   if (!strcmp(name, "keystone-k2g-generic") && !eeprom_read)
+   return 0;
+   else if (!strcmp(name, "keystone-k2g-evm") && board_ti_is("66AK2GGP"))
+   return 0;
+   else
+   return -1;
+}
+#endif
+
 #if defined(CONFIG_DTB_RESELECT)
 static int k2g_alt_board_detect(void)
 {
diff --git a/board/ti/ks2_evm/board_k2hk.c b/board/ti/ks2_evm/board_k2hk.c
index b35f24d..c733099 100644
--- a/board/ti/ks2_evm/board_k2hk.c
+++ b/board/ti/ks2_evm/board_k2hk.c
@@ -150,6 +150,16 @@ int board_early_init_f(void)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "keystone-k2hk-evm"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void spl_init_keystone_plls(void)
 {
diff --git a/board/ti/ks2_evm/board_k2l.c b/board/ti/ks2_evm/board_k2l.c
index f3eea42..166367b 100644
--- a/board/ti/ks2_evm/board_k2l.c
+++ b/board/ti/ks2_evm/board_k2l.c
@@ -138,6 +138,16 @@ int board_early_init_f(void)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "keystone-k2l-evm"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void spl_init_keystone_plls(void)
 {
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 06/30] dts: Allow OF_LIST to depend on FIT_EMBED

2017-05-23 Thread Franklin S Cooper Jr
OF_LIST will be useable by SPL and U-boot. Therefore, update its
dependency to allow it to be enable by either SPL or U-boot specific
config option.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
Reviewed-by: Lokesh Vutla 
Acked-by: Andrew F. Davis 
---
 dts/Kconfig | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/dts/Kconfig b/dts/Kconfig
index 9a06221..7d688e8 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -79,14 +79,15 @@ config DEFAULT_DEVICE_TREE
 
 config OF_LIST
string "List of device tree files to include for DT control"
-   depends on SPL_LOAD_FIT
+   depends on SPL_LOAD_FIT || FIT_EMBED
default DEFAULT_DEVICE_TREE
help
  This option specifies a list of device tree files to use for DT
- control. These will be packaged into a FIT. At run-time, SPL will
- select the correct DT to use by examining the hardware (e.g.
- reading a board ID value). This is a list of device tree files
- (without the directory or .dtb suffix) separated by .
+ control. These will be packaged into a FIT. At run-time, U-boot
+ or SPL will select the correct DT to use by examining the
+ hardware (e.g. reading a board ID value). This is a list of
+ device tree files (without the directory or .dtb suffix)
+ separated by .
 
 config OF_SPL_REMOVE_PROPS
string "List of device tree properties to drop for SPL"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 12/30] ARM: k2g: Define embedded_dtb_select for runtime DTB selection in U-boot

2017-05-23 Thread Franklin S Cooper Jr
For K2G, runtime DTB selection utilizes the embedded_dtb_select function.
Therefore, define the function which will perform a EEPROM read and then
retries selecting the correct dtb now that it can detect which board its
on. For other Keystone devices use an empty function since they will still
use the embedded FIT functionality but their FIT will only contain a single
dtb.

Most production K2G boards do not have their EEPROM programmed. Therefore,
perform a test to verify a K2G GP is currently being used and if it is then
set the values normally set by a EEPROM read.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.c |  7 +++
 board/ti/ks2_evm/board_k2g.c | 38 ++
 2 files changed, 45 insertions(+)

diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index 03254e1..4792311 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -277,3 +277,10 @@ void ft_board_setup_ex(void *blob, bd_t *bd)
ddr3_check_ecc_int(KS2_DDR3A_EMIF_CTRL_BASE);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
+
+#if defined(CONFIG_DTB_RESELECT)
+int __weak embedded_dtb_select(void)
+{
+   return 0;
+}
+#endif
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 21aec8f..4c3819d 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -11,9 +11,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "mux-k2g.h"
 #include "../common/board_detect.h"
 
+#define K2G_GP_AUDIO_CODEC_ADDRESS 0x1B
+
 const unsigned int sysclk_array[MAX_SYSCLK] = {
1920,
2400,
@@ -210,6 +214,40 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_DTB_RESELECT)
+static int k2g_alt_board_detect(void)
+{
+   int rc;
+
+   rc = i2c_set_bus_num(1);
+   if (rc)
+   return rc;
+
+   rc = i2c_probe(K2G_GP_AUDIO_CODEC_ADDRESS);
+   if (rc)
+   return rc;
+
+   ti_i2c_eeprom_am_set("66AK2GGP", "1.0X");
+
+   return 0;
+}
+
+int embedded_dtb_select(void)
+{
+   int rc;
+
+   rc = k2g_alt_board_detect();
+   if (rc) {
+   printf("Unable to do board detection\n");
+   return -1;
+   }
+
+   fdtdec_setup();
+
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 
 static void k2g_reset_mux_config(void)
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 16/30] ARM: keystone2: Add additional fields used for DDR3 configuration

2017-05-23 Thread Franklin S Cooper Jr
Future boards will need to configure DDR3 registers in a slightly
different manner. Support this by defining additional variables and
defines that will be utilized later.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/include/mach/ddr3.h | 14 ++
 arch/arm/mach-keystone/include/mach/hardware.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/arch/arm/mach-keystone/include/mach/ddr3.h 
b/arch/arm/mach-keystone/include/mach/ddr3.h
index 5feffe8..93789fd 100644
--- a/arch/arm/mach-keystone/include/mach/ddr3.h
+++ b/arch/arm/mach-keystone/include/mach/ddr3.h
@@ -35,6 +35,20 @@ struct ddr3_phy_config {
unsigned int zq1cr1;
unsigned int zq2cr1;
unsigned int pir_v1;
+   unsigned int datx8_2_mask;
+   unsigned int datx8_2_val;
+   unsigned int datx8_3_mask;
+   unsigned int datx8_3_val;
+   unsigned int datx8_4_mask;
+   unsigned int datx8_4_val;
+   unsigned int datx8_5_mask;
+   unsigned int datx8_5_val;
+   unsigned int datx8_6_mask;
+   unsigned int datx8_6_val;
+   unsigned int datx8_7_mask;
+   unsigned int datx8_7_val;
+   unsigned int datx8_8_mask;
+   unsigned int datx8_8_val;
unsigned int pir_v2;
 };
 
diff --git a/arch/arm/mach-keystone/include/mach/hardware.h 
b/arch/arm/mach-keystone/include/mach/hardware.h
index 38d0190..1969a10 100644
--- a/arch/arm/mach-keystone/include/mach/hardware.h
+++ b/arch/arm/mach-keystone/include/mach/hardware.h
@@ -52,6 +52,8 @@ typedef volatile unsigned int   *dv_reg_p;
 #define KS2_DDRPHY_ZQ2CR1_OFFSET0x1A4
 #define KS2_DDRPHY_ZQ3CR1_OFFSET0x1B4
 
+#define KS2_DDRPHY_DATX8_2_OFFSET   0x240
+#define KS2_DDRPHY_DATX8_3_OFFSET   0x280
 #define KS2_DDRPHY_DATX8_4_OFFSET   0x2C0
 #define KS2_DDRPHY_DATX8_5_OFFSET   0x300
 #define KS2_DDRPHY_DATX8_6_OFFSET   0x340
@@ -70,6 +72,7 @@ typedef volatile unsigned int   *dv_reg_p;
 #define PDQ_MASK0x0070
 #define NOSRA_MASK  0x0800
 #define ECC_MASK0x0001
+#define DXEN_MASK   0x0001
 
 /* DDR3 definitions */
 #define KS2_DDR3A_EMIF_CTRL_BASE   0x2101
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 26/30] ARM: dts: keystone-k2g-evm: Add unit address to memory node

2017-05-23 Thread Franklin S Cooper Jr
Upstream Linux has the unit address being added to the various 66AK2Gx
boards dts. Therefore, update the dts to mimic this change.

Also remove memory node from the base K2G dtsi file.

Signed-off-by: Franklin S Cooper Jr 
---
Version 2 changes:
This patch attempts to get the dts closer to what is used in the Linux
kernel

 arch/arm/dts/keystone-k2g-evm.dts | 5 +
 arch/arm/dts/keystone-k2g.dtsi| 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/keystone-k2g-evm.dts 
b/arch/arm/dts/keystone-k2g-evm.dts
index 2c99df4..f6fce33 100644
--- a/arch/arm/dts/keystone-k2g-evm.dts
+++ b/arch/arm/dts/keystone-k2g-evm.dts
@@ -18,6 +18,11 @@
chosen {
stdout-path = &uart0;
};
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x8000>;
+   };
 };
 
 &mdio {
diff --git a/arch/arm/dts/keystone-k2g.dtsi b/arch/arm/dts/keystone-k2g.dtsi
index f05afb7..7b2fae6 100644
--- a/arch/arm/dts/keystone-k2g.dtsi
+++ b/arch/arm/dts/keystone-k2g.dtsi
@@ -30,11 +30,6 @@
i2c2 = &i2c2;
};
 
-   memory {
-   device_type = "memory";
-   reg = <0x8000 0x8000>;
-   };
-
cpus {
#address-cells = <1>;
#size-cells = <0>;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 08/30] arm: dts: Add new "generic" 66AK2Gx device tree file.

2017-05-23 Thread Franklin S Cooper Jr
With U-boot runtime board detect for DTB selection a "default" dtb needs
to be created. This will be used temporarily until the "proper" dtb is
selected.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---

Version 2 changes:
Added -u-boot.dtsi with U-boot specific dts changes.

 arch/arm/dts/Makefile |  3 ++-
 arch/arm/dts/keystone-k2g-generic-u-boot.dtsi | 19 ++
 arch/arm/dts/keystone-k2g-generic.dts | 29 +++
 3 files changed, 50 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/keystone-k2g-generic-u-boot.dtsi
 create mode 100644 arch/arm/dts/keystone-k2g-generic.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index e2c2584..63450f5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -354,7 +354,8 @@ dtb-$(CONFIG_ARCH_MX7ULP) += imx7ulp-evk.dtb
 dtb-$(CONFIG_SOC_KEYSTONE) += keystone-k2hk-evm.dtb \
keystone-k2l-evm.dtb \
keystone-k2e-evm.dtb \
-   keystone-k2g-evm.dtb
+   keystone-k2g-evm.dtb \
+   keystone-k2g-generic.dtb
 
 dtb-$(CONFIG_TARGET_AT91SAM9263EK) += at91sam9263ek.dtb
 
diff --git a/arch/arm/dts/keystone-k2g-generic-u-boot.dtsi 
b/arch/arm/dts/keystone-k2g-generic-u-boot.dtsi
new file mode 100644
index 000..4d073f3
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-generic-u-boot.dtsi
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/keystone-k2g-generic.dts 
b/arch/arm/dts/keystone-k2g-generic.dts
new file mode 100644
index 000..09a0bf7
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-generic.dts
@@ -0,0 +1,29 @@
+/*
+ * Device Tree Source for Generic 66AK2G0X EVM
+ *
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "keystone-k2g.dtsi"
+
+/ {
+   compatible = "ti,k2g-generic", "ti,k2g", "ti,keystone";
+   model = "Texas Instruments 66AK2G02 Generic";
+
+   chosen {
+   stdout-path = &uart0;
+   };
+};
+
+&i2c0 {
+status = "okay";
+};
+
+&i2c1 {
+status = "okay";
+};
+
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 18/30] ARM: k2g: Program DDRPHY_DATX8 registers via mask and value variables

2017-05-23 Thread Franklin S Cooper Jr
Different K2G evms may need to program the various
KS2_DDRPHY_DATX8_X_OFFSET registers in different ways. Therefore, use
the mask and val registers for each KS2_DDRPHY_DATAX_X_OFFSET to
properly program the register.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/ddr3.c | 32 +++-
 board/ti/ks2_evm/ddr3_k2g.c   | 14 ++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c
index 25a9637..4cad6a2 100644
--- a/arch/arm/mach-keystone/ddr3.c
+++ b/arch/arm/mach-keystone/ddr3.c
@@ -65,11 +65,33 @@ void ddr3_init_ddrphy(u32 base, struct ddr3_phy_config 
*phy_cfg)
;
 
if (cpu_is_k2g()) {
-   setbits_le32(base + KS2_DDRPHY_DATX8_4_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_5_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_6_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_7_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_8_OFFSET, 0x1);
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_2_OFFSET,
+   phy_cfg->datx8_2_mask,
+   phy_cfg->datx8_2_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_3_OFFSET,
+   phy_cfg->datx8_3_mask,
+   phy_cfg->datx8_3_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_4_OFFSET,
+   phy_cfg->datx8_4_mask,
+   phy_cfg->datx8_4_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_5_OFFSET,
+   phy_cfg->datx8_5_mask,
+   phy_cfg->datx8_5_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_6_OFFSET,
+   phy_cfg->datx8_6_mask,
+   phy_cfg->datx8_6_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_7_OFFSET,
+   phy_cfg->datx8_7_mask,
+   phy_cfg->datx8_7_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_8_OFFSET,
+   phy_cfg->datx8_8_mask,
+   phy_cfg->datx8_8_val);
}
 
__raw_writel(phy_cfg->pir_v2, base + KS2_DDRPHY_PIR_OFFSET);
diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c
index aeb7da6..3b12943 100644
--- a/board/ti/ks2_evm/ddr3_k2g.c
+++ b/board/ti/ks2_evm/ddr3_k2g.c
@@ -34,6 +34,20 @@ struct ddr3_phy_config ddr3phy_800_2g = {
.zq1cr1 = 0x0001005Bul,
.zq2cr1 = 0x0001005Bul,
.pir_v1 = 0x0033ul,
+   .datx8_2_mask   = 0,
+   .datx8_2_val= 0,
+   .datx8_3_mask   = 0,
+   .datx8_3_val= 0,
+   .datx8_4_mask   = 0,
+   .datx8_4_val= ((1 << 0)),
+   .datx8_5_mask   = DXEN_MASK,
+   .datx8_5_val= 0,
+   .datx8_6_mask   = DXEN_MASK,
+   .datx8_6_val= 0,
+   .datx8_7_mask   = DXEN_MASK,
+   .datx8_7_val= 0,
+   .datx8_8_mask   = DXEN_MASK,
+   .datx8_8_val= 0,
.pir_v2 = 0x0F81ul,
 };
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 25/30] ARM: dts: keystone-k2g: Remove skeleton.dtsi

2017-05-23 Thread Franklin S Cooper Jr
Adding the unit address to the memory node was causing the below error:
Warning (reg_format): "reg" property in /memory has invalid length
(8 bytes) (#address-cells == 2, #size-cells == 2)

Further debugging showed that this was due to the memory node added by
default to skeleton.dtsi which was being included in keystone-k2g.dtsi.
Adding a missing node was all that was needed to remove this deprecated
dtsi file from the SoC dtsi. With skeleton.dtsi removed the dtc compiler
no longer complained about including the unit address for the memory node.

Signed-off-by: Franklin S Cooper Jr 
---
This patch mimics similar changes being pulled into Linux kernel.

 arch/arm/dts/keystone-k2g.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/keystone-k2g.dtsi b/arch/arm/dts/keystone-k2g.dtsi
index 191e3f1..f05afb7 100644
--- a/arch/arm/dts/keystone-k2g.dtsi
+++ b/arch/arm/dts/keystone-k2g.dtsi
@@ -9,7 +9,6 @@
  */
 
 #include 
-#include "skeleton.dtsi"
 
 / {
model = "Texas Instruments K2G SoC";
@@ -17,6 +16,8 @@
#size-cells = <1>;
interrupt-parent = <&gic>;
 
+   chosen { };
+
aliases {
serial0 = &uart0;
spi0 = &spi0;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 21/30] ARM: k2g: Add DDR3 configuration for K2G ICE evm

2017-05-23 Thread Franklin S Cooper Jr
Add configuration settings used by the K2G ICE evm. Also use board
detection to determine which DDR3 configuration to use.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/ddr3_k2g.c | 62 +++--
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c
index 3b12943..44db335 100644
--- a/board/ti/ks2_evm/ddr3_k2g.c
+++ b/board/ti/ks2_evm/ddr3_k2g.c
@@ -10,7 +10,9 @@
 #include 
 #include "ddr3_cfg.h"
 #include 
+#include "board.h"
 
+/* K2G GP EVM DDR3 Configuration */
 struct ddr3_phy_config ddr3phy_800_2g = {
.pllcr  = 0x000DC000ul,
.pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
@@ -61,13 +63,69 @@ struct ddr3_emif_config ddr3_800_2g = {
.sdrfc  = 0x0C34ul,
 };
 
+/* K2G ICE evm DDR3 Configuration */
+struct ddr3_phy_config ddr3phy_800_512mb = {
+   .pllcr  = 0x000DC000ul,
+   .pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
+   .pgcr1_val  = ((1 << 2) | (2 << 7) | (1 << 23)),
+   .ptr0   = 0x42C21590ul,
+   .ptr1   = 0xD05612C0ul,
+   .ptr2   = 0,
+   .ptr3   = 0x06C30D40ul,
+   .ptr4   = 0x06413880ul,
+   .dcr_mask   = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
+   .dcr_val= ((1 << 10)),
+   .dtpr0  = 0x550E6644ul,
+   .dtpr1  = 0x32834200ul,
+   .dtpr2  = 0x50022A00ul,
+   .mr0= 0x1430ul,
+   .mr1= 0x0006ul,
+   .mr2= 0x0008ul,
+   .dtcr   = 0x710035C7ul,
+   .pgcr2  = 0x00F03D09ul,
+   .zq0cr1 = 0x0001005Dul,
+   .zq1cr1 = 0x0001005Bul,
+   .zq2cr1 = 0x0001005Bul,
+   .pir_v1 = 0x0033ul,
+   .datx8_2_mask   = DXEN_MASK,
+   .datx8_2_val= 0,
+   .datx8_3_mask   = DXEN_MASK,
+   .datx8_3_val= 0,
+   .datx8_4_mask   = DXEN_MASK,
+   .datx8_4_val= 0,
+   .datx8_5_mask   = DXEN_MASK,
+   .datx8_5_val= 0,
+   .datx8_6_mask   = DXEN_MASK,
+   .datx8_6_val= 0,
+   .datx8_7_mask   = DXEN_MASK,
+   .datx8_7_val= 0,
+   .datx8_8_mask   = DXEN_MASK,
+   .datx8_8_val= 0,
+   .pir_v2 = 0x0F81ul,
+};
+
+struct ddr3_emif_config ddr3_800_512mb = {
+   .sdcfg  = 0x62006662ul,
+   .sdtim1 = 0x0A385033ul,
+   .sdtim2 = 0x1CA5ul,
+   .sdtim3 = 0x21ADFF32ul,
+   .sdtim4 = 0x533F067Ful,
+   .zqcfg  = 0x70073200ul,
+   .sdrfc  = 0x0C34ul,
+};
+
 u32 ddr3_init(void)
 {
/* Reset DDR3 PHY after PLL enabled */
ddr3_reset_ddrphy();
 
-   ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_2g);
-   ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_2g);
+   if (board_is_k2g_gp()) {
+   ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_2g);
+   ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_2g);
+   } else if (board_is_k2g_ice()) {
+   ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_512mb);
+   ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_512mb);
+   }
 
return 0;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 15/30] defconfig: keystone2: Enable U-boot runtime DTB detection

2017-05-23 Thread Franklin S Cooper Jr
Enable various config options to allow U-boot at runtime to select the
proper dtb to use from the list of dtb's within the FIT image.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 configs/k2e_evm_defconfig  | 3 +++
 configs/k2g_evm_defconfig  | 3 +++
 configs/k2hk_evm_defconfig | 3 +++
 configs/k2l_evm_defconfig  | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/configs/k2e_evm_defconfig b/configs/k2e_evm_defconfig
index 83e2138..9ab08c6 100644
--- a/configs/k2e_evm_defconfig
+++ b/configs/k2e_evm_defconfig
@@ -44,3 +44,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2e-evm"
diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig
index 674ddcc..7b105da 100644
--- a/configs/k2g_evm_defconfig
+++ b/configs/k2g_evm_defconfig
@@ -46,3 +46,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2g-generic keystone-k2g-evm"
diff --git a/configs/k2hk_evm_defconfig b/configs/k2hk_evm_defconfig
index 7dc5cf5..a751a4f 100644
--- a/configs/k2hk_evm_defconfig
+++ b/configs/k2hk_evm_defconfig
@@ -43,3 +43,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2hk-evm"
diff --git a/configs/k2l_evm_defconfig b/configs/k2l_evm_defconfig
index 6be4941..cf24d27 100644
--- a/configs/k2l_evm_defconfig
+++ b/configs/k2l_evm_defconfig
@@ -43,3 +43,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2l-evm"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 11/30] ARM: keystone2: Allow to build with all image formats

2017-05-23 Thread Franklin S Cooper Jr
u-boot.bin is a copy of:
u-boot-fit-dtb.bin if CONFIG_FIT_EMBED is enabled,
u-boot-dtb.bin if CONFIG_OF_SEPARATE is enabled,
u-boot-nodtb.bin if DT is not enabled.
So, use u-boot.bin to to generate keystone images instead of
u-boot-dtb.bin

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/config.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-keystone/config.mk b/arch/arm/mach-keystone/config.mk
index db556ea..5806f8f 100644
--- a/arch/arm/mach-keystone/config.mk
+++ b/arch/arm/mach-keystone/config.mk
@@ -22,13 +22,13 @@ spl/u-boot-spl.gph: spl/u-boot-spl.bin FORCE
 
 OBJCOPYFLAGS_u-boot-spi.gph = -I binary -O binary 
--pad-to=$(CONFIG_SPL_PAD_TO) \
  --gap-fill=0
-u-boot-spi.gph: spl/u-boot-spl.gph u-boot-dtb.img FORCE
+u-boot-spi.gph: spl/u-boot-spl.gph u-boot.img FORCE
$(call if_changed,pad_cat)
 
 ifndef CONFIG_SPL_BUILD
 MKIMAGEFLAGS_MLO = -A $(ARCH) -T gpimage -C none \
-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -n U-Boot
-MLO: u-boot-dtb.bin FORCE
+MLO: u-boot.bin FORCE
$(call if_changed,mkimage)
@dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
 endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 19/30] ks2_evm: Add EEPROM based board detection helper functions

2017-05-23 Thread Franklin S Cooper Jr
Add a function that can be used to determine if the board being ran on is
a K2G Industrial Communication Engine EVM or K2G General Purpose EVM based
on values programmed on the EEPROM.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/board/ti/ks2_evm/board.h b/board/ti/ks2_evm/board.h
index 0698921..b3ad188 100644
--- a/board/ti/ks2_evm/board.h
+++ b/board/ti/ks2_evm/board.h
@@ -15,6 +15,26 @@
 
 extern struct eth_priv_t eth_priv_cfg[];
 
+#if defined(CONFIG_TI_I2C_BOARD_DETECT)
+static inline int board_is_k2g_gp(void)
+{
+   return board_ti_is("66AK2GGP");
+}
+static inline int board_is_k2g_ice(void)
+{
+   return board_ti_is("66AK2GIC");
+}
+#else
+static inline int board_is_k2g_gp(void)
+{
+   return false;
+}
+static inline int board_is_k2g_ice(void)
+{
+   return false;
+}
+#endif
+
 int get_num_eth_ports(void);
 void spl_init_keystone_plls(void);
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 27/30] ARM: dts: k2g: Disable netcp by default

2017-05-23 Thread Franklin S Cooper Jr
Disable netcp by default like all other peripherals in the dtsi file.
Enable the peripheral explicitly in the board specific dts file.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2g-evm.dts| 4 
 arch/arm/dts/keystone-k2g-netcp.dtsi | 1 +
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/keystone-k2g-evm.dts 
b/arch/arm/dts/keystone-k2g-evm.dts
index f6fce33..de208b3 100644
--- a/arch/arm/dts/keystone-k2g-evm.dts
+++ b/arch/arm/dts/keystone-k2g-evm.dts
@@ -37,6 +37,10 @@
phy-handle = <ðphy0>;
 };
 
+&netcp {
+   status = "okay";
+};
+
 &spi1 {
status = "okay";
 
diff --git a/arch/arm/dts/keystone-k2g-netcp.dtsi 
b/arch/arm/dts/keystone-k2g-netcp.dtsi
index a9b26c3..d76f2a1 100644
--- a/arch/arm/dts/keystone-k2g-netcp.dtsi
+++ b/arch/arm/dts/keystone-k2g-netcp.dtsi
@@ -99,6 +99,7 @@ netcp: netcp@400 {
reg = <0x2620110 0x8>;
reg-names = "efuse";
compatible = "ti,netcp-1.0";
+   status = "disabled";
#address-cells = <1>;
#size-cells = <1>;
/* power-domains = <&k2g_pds K2G_DEV_NSS0>; */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 14/30] ks2_evm: Add EEPROM based board detection

2017-05-23 Thread Franklin S Cooper Jr
Some K2G evms have their EEPROM programming while most do not. Therefore,
add EEPROM board detection to be used as the default method and fall back
to the alternative board detection when needed.

Also reorder board configuration. Perform bare minimal configuration
initially since board detection hasn't ran. Finish board configuration
once the board has been identified.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.h |  1 +
 board/ti/ks2_evm/board_k2g.c | 44 +++-
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/board/ti/ks2_evm/board.h b/board/ti/ks2_evm/board.h
index 2bbd792..0698921 100644
--- a/board/ti/ks2_evm/board.h
+++ b/board/ti/ks2_evm/board.h
@@ -11,6 +11,7 @@
 #define _KS2_BOARD
 
 #include 
+#include "../common/board_detect.h"
 
 extern struct eth_priv_t eth_priv_cfg[];
 
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index d354415..d796fd1 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -246,24 +246,6 @@ static int k2g_alt_board_detect(void)
return 0;
 }
 
-int embedded_dtb_select(void)
-{
-   int rc;
-
-   rc = k2g_alt_board_detect();
-   if (rc) {
-   printf("Unable to do board detection\n");
-   return -1;
-   }
-
-   fdtdec_setup();
-
-   return 0;
-}
-#endif
-
-#ifdef CONFIG_BOARD_EARLY_INIT_F
-
 static void k2g_reset_mux_config(void)
 {
/* Unlock the reset mux register */
@@ -277,11 +259,20 @@ static void k2g_reset_mux_config(void)
setbits_le32(KS2_RSTMUX8, RSTMUX_LOCK8_MASK);
 }
 
-int board_early_init_f(void)
+int embedded_dtb_select(void)
 {
-   init_plls();
+   int rc;
+   rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
+   CONFIG_EEPROM_CHIP_ADDRESS);
+   if (rc) {
+   rc = k2g_alt_board_detect();
+   if (rc) {
+   printf("Unable to do board detection\n");
+   return -1;
+   }
+   }
 
-   k2g_mux_config();
+   fdtdec_setup();
 
k2g_reset_mux_config();
 
@@ -313,6 +304,17 @@ int board_late_init(void)
 }
 #endif
 
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+int board_early_init_f(void)
+{
+   init_plls();
+
+   k2g_mux_config();
+
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void spl_init_keystone_plls(void)
 {
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 24/30] ARM: k2g: Update board_name u-boot env variable at runtime

2017-05-23 Thread Franklin S Cooper Jr
Enable CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG to allow "board_name" to
be set depending on the board it is being ran on.

Update findfdt to use this new dynamic board_name value to determine
which dtb should be used.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c |  6 ++
 include/configs/k2g_evm.h| 13 +++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 96b313f..5f3fc76 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -306,6 +306,12 @@ int board_late_init(void)
board_ti_set_ethaddr(1);
 #endif
 
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+   if (board_is_k2g_gp())
+   setenv("board_name", "66AK2GGP\0");
+   else if (board_is_k2g_ice())
+   setenv("board_name", "66AK2GIC\0");
+#endif
return 0;
 }
 #endif
diff --git a/include/configs/k2g_evm.h b/include/configs/k2g_evm.h
index bee1be7..c6eab0f 100644
--- a/include/configs/k2g_evm.h
+++ b/include/configs/k2g_evm.h
@@ -16,6 +16,8 @@
 /* Platform type */
 #define CONFIG_SOC_K2G
 
+#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+
 /* U-Boot general configuration */
 #define CONFIG_EXTRA_ENV_KS2_BOARD_SETTINGS\
DEFAULT_MMC_TI_ARGS \
@@ -28,7 +30,14 @@
"rd_spec=-\0"   \
"args_ubi=setenv bootargs ${bootargs} rootfstype=ubifs "\
"root=ubi0:rootfs rootflags=sync rw ubi.mtd=ubifs,2048\0"   \
-   "name_fdt=keystone-k2g-evm.dtb\0"   \
+   "findfdt="\
+   "if test $board_name = 66AK2GGP; then " \
+"setenv name_fdt keystone-k2g-evm.dtb; " \
+   "else if test $board_name = 66AK2GIC; then " \
+"setenv name_fdt keystone-k2g-ice.dtb; " \
+   "else if test $name_fdt = undefined; then " \
+   "echo WARNING: Could not determine device tree to use;"\
+   "fi;fi;fi;\0" \
"name_mon=skern-k2g.bin\0"  \
"name_ubi=k2g-evm-ubifs.ubi\0"  \
"name_uboot=u-boot-spi-k2g-evm.gph\0"   \
@@ -46,7 +55,7 @@
"run envboot; " \
"run set_name_pmmc init_${boot} init_fw_rd_${boot} "\
"get_pmmc_${boot} run_pmmc get_mon_${boot} run_mon "\
-   "get_fdt_${boot} get_kern_${boot} run_kern"
+   "findfdt get_fdt_${boot} get_kern_${boot} run_kern"
 
 #include 
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 07/30] ARM: dts: k2g: Introduce U-boot specific dtsi file

2017-05-23 Thread Franklin S Cooper Jr
Introduce K2G evm specific dtsi file for U-boot specific configurations.
This will help seperate U-boot only configurations thus making it easier to
keep device tree files synced between U-boot and Linux.

For now only add nodes to allow i2c drivers to be probed early during
the boot process.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2g-evm-u-boot.dtsi | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 arch/arm/dts/keystone-k2g-evm-u-boot.dtsi

diff --git a/arch/arm/dts/keystone-k2g-evm-u-boot.dtsi 
b/arch/arm/dts/keystone-k2g-evm-u-boot.dtsi
new file mode 100644
index 000..4d073f3
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-evm-u-boot.dtsi
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 22/30] board: ks2: Use board detection to wrap code not specific to K2G ICE evm

2017-05-23 Thread Franklin S Cooper Jr
Some code doesn't apply to K2G ICE evm. Therefore, use board detection to
wrap these calls.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index 4792311..c61baee 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -45,13 +45,17 @@ int dram_init(void)
gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
CONFIG_MAX_RAM_BANK_SIZE);
 #if defined(CONFIG_TI_AEMIF)
-   aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
+   if (!board_is_k2g_ice())
+   aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
 #endif
 
-   if (ddr3_size)
-   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, ddr3_size);
-   else
-   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, gd->ram_size >> 30);
+   if (!board_is_k2g_ice()) {
+   if (ddr3_size)
+   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, ddr3_size);
+   else
+   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE,
+ gd->ram_size >> 30);
+   }
 
return 0;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 09/30] board_f: Add new function to allow runtime DTB selection

2017-05-23 Thread Franklin S Cooper Jr
Runtime U-boot dtb selection is generally a two step process. First step
is to simply use an initial generic dtb. The second step is to select
the dtb and perhaps execute additional code ones U-boot knows what board
it is running on. Embedded_dtb_select handles the second step by allowing
board specific code to run and perform what ever necessary configuration
that is needed.

Signed-off-by: Franklin S Cooper Jr 
---
 common/Kconfig   | 10 ++
 common/board_f.c |  3 +++
 include/common.h |  4 
 3 files changed, 17 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index 2429953..b6327f0 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -421,6 +421,16 @@ config SYS_STDIO_DEREGISTER
 
 endmenu
 
+config DTB_RESELECT
+   bool "Support swapping dtbs at a later point in boot"
+   depends on FIT_EMBED
+   default n
+   help
+ It is possible during initial boot you may need to use a generic
+ dtb until you can fully determine the board your running on. This
+ config allows boards to implement a function at a later point
+ during boot to switch to the "correct" dtb.
+
 config FIT_EMBED
bool "Support a FIT image embedded in the U-boot image"
default n
diff --git a/common/board_f.c b/common/board_f.c
index a212f2b..b383239 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -759,6 +759,9 @@ static const init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo,  /* display cpu info (and speed) */
 #endif
+#if defined(CONFIG_DTB_RESELECT)
+   embedded_dtb_select,
+#endif
 #if defined(CONFIG_DISPLAY_BOARDINFO)
show_board_info,
 #endif
diff --git a/include/common.h b/include/common.h
index 45f190a..ebc716e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -478,6 +478,10 @@ void   pci_init_board(void);
 #endif
 #endif
 
+#if defined(CONFIG_DTB_RESELECT)
+intembedded_dtb_select(void);
+#endif
+
 intmisc_init_f   (void);
 intmisc_init_r   (void);
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 01/30] ti: common: board_detect: Allow settings board detection variables manually

2017-05-23 Thread Franklin S Cooper Jr
From: Nishanth Menon 

In some situations the EEPROM used for board detection may not be
programmed or simply programmed incorrectly. Therefore, it may be
necessary to "simulate" reading the contents of the EEPROM to set
appropriate variables used in the board detection code.

This may also be helpful in certain boot modes where doing i2c reads
may be costly and the config supports running only a specific board.

Signed-off-by: Nishanth Menon 
Signed-off-by: Tero Kristo 
Signed-off-by: Keerthy 
Signed-off-by: Franklin S Cooper Jr. 
---
 board/ti/common/board_detect.c | 24 
 board/ti/common/board_detect.h | 17 +
 2 files changed, 41 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 6fdcb61..bf594cb 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -173,6 +173,30 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, 
int dev_addr,
return 0;
 }
 
+int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev)
+{
+   struct ti_common_eeprom *ep;
+
+   if (!name || !rev)
+   return -1;
+
+   ep = TI_EEPROM_DATA;
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   goto already_set;
+
+   /* Set to 0 all fields */
+   memset(ep, 0, sizeof(*ep));
+   strncpy(ep->name, name, TI_EEPROM_HDR_NAME_LEN);
+   strncpy(ep->version, rev, TI_EEPROM_HDR_REV_LEN);
+   /* Some dummy serial number to identify the platform */
+   strncpy(ep->serial, "", TI_EEPROM_HDR_SERIAL_LEN);
+   /* Mark it with a valid header */
+   ep->header = TI_EEPROM_HEADER_MAGIC;
+
+already_set:
+   return 0;
+}
+
 int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr)
 {
int rc;
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index 88b0a59..e8d9484 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -205,4 +205,21 @@ void set_board_info_env(char *name);
  */
 void board_ti_set_ethaddr(int index);
 
+/**
+ * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
+ * @name:  Name of the board
+ * @rev:   Revision of the board
+ *
+ * In some cases such as in RTC-only mode, we are able to skip reading eeprom
+ * and wasting i2c based initialization time by using predefined flags for
+ * detecting what platform we are booting on. For those platforms, provide
+ * a handy function to pre-program information.
+ *
+ * NOTE: many eeprom information such as serial number, mac address etc is not
+ * available.
+ *
+ * Return: 0 if all went fine, else return error.
+ */
+int ti_i2c_eeprom_am_set(const char *name, const char *rev);
+
 #endif /* __BOARD_DETECT_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 30/30] defconfig: k2g_evm_defconfig: Add K2G ICE to OF_LIST

2017-05-23 Thread Franklin S Cooper Jr
Include K2G ICE to OF_LIST so it can be used for runtime board
detection.

Signed-off-by: Franklin S Cooper Jr 
---
 configs/k2g_evm_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig
index 7b105da..a5639ea 100644
--- a/configs/k2g_evm_defconfig
+++ b/configs/k2g_evm_defconfig
@@ -48,4 +48,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_DTB_RESELECT=y
 CONFIG_FIT_EMBED=y
-CONFIG_OF_LIST="keystone-k2g-generic keystone-k2g-evm"
+CONFIG_OF_LIST="keystone-k2g-generic keystone-k2g-evm keystone-k2g-ice"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 04/30] fdt: Enable selecting correct DTB from appended FIT Image

2017-05-23 Thread Franklin S Cooper Jr
This patch gives U-boot the runtime support to have the board specific
code decide which FDT to use. This is especially useful for devices
that need this type of runtime determination and also doesn't use SPL.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Lokesh Vutla 
Reviewed-by: Tom Rini 
---
 lib/fdtdec.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index c072e54..8bd2940 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -4,6 +4,7 @@
  */
 
 #ifndef USE_HOSTCC
+#include 
 #include 
 #include 
 #include 
@@ -1251,6 +1252,15 @@ int fdtdec_setup(void)
gd->fdt_blob = (ulong *)&_image_binary_end;
else
gd->fdt_blob = (ulong *)&__bss_end;
+
+#  elif defined CONFIG_FIT_EMBED
+   gd->fdt_blob = locate_dtb_in_fit(&_end);
+
+   if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
+   puts("Failed to find proper dtb in embedded FIT Image\n");
+   return -1;
+   }
+
 #  else
/* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 23/30] ARM: k2g: Use board detection to wrap K2G GP specific calls

2017-05-23 Thread Franklin S Cooper Jr
Certain peripherals used by K2G GP aren't used on K2G ICE evm. Or
configuration is slightly different. Therefore, use board detection to
deal with these variations.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index a93ef47..96b313f 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -208,7 +208,9 @@ int board_mmc_init(bd_t *bis)
return -1;
}
 
-   omap_mmc_init(0, 0, 0, -1, -1);
+   if (board_is_k2g_gp())
+   omap_mmc_init(0, 0, 0, -1, -1);
+
omap_mmc_init(1, 0, 0, -1, -1);
return 0;
 }
@@ -278,11 +280,13 @@ int embedded_dtb_select(void)
 
k2g_reset_mux_config();
 
-   /* deassert FLASH_HOLD */
-   clrbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_DIR_OFFSET,
-BIT(9));
-   setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET,
-BIT(9));
+   if (board_is_k2g_gp()) {
+   /* deassert FLASH_HOLD */
+   clrbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_DIR_OFFSET,
+BIT(9));
+   setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET,
+BIT(9));
+   }
 
return 0;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 20/30] ARM: k2g: Add pinmux support for K2G ICE evm

2017-05-23 Thread Franklin S Cooper Jr
Add basic pinmux data for new K2G ICE evm. Also add pinmuxing for a
generic K2G evm which includes I2C 0 and 1 used for board detection
purposes.

Since multiple K2G boards are supported that means initially generic
pinmuxing should be used when board detection hasn't ran. Once board
detection runs the proper pinmuxing can be reran to match the board
being ran on.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c |  2 ++
 board/ti/ks2_evm/mux-k2g.h   | 45 +++-
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index d796fd1..a93ef47 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -274,6 +274,8 @@ int embedded_dtb_select(void)
 
fdtdec_setup();
 
+   k2g_mux_config();
+
k2g_reset_mux_config();
 
/* deassert FLASH_HOLD */
diff --git a/board/ti/ks2_evm/mux-k2g.h b/board/ti/ks2_evm/mux-k2g.h
index 773f9b7..630103d 100644
--- a/board/ti/ks2_evm/mux-k2g.h
+++ b/board/ti/ks2_evm/mux-k2g.h
@@ -11,6 +11,22 @@
 #include 
 #include 
 #include 
+#include "board.h"
+
+struct pin_cfg k2g_generic_pin_cfg[] = {
+   /* UART0 */
+   { 115,  MODE(0) },  /* SOC_UART0_RXD */
+   { 116,  MODE(0) },  /* SOC_UART0_TXD */
+
+   /* I2C 0 */
+   { 223,  MODE(0) },  /* SOC_I2C0_SCL */
+   { 224,  MODE(0) },  /* SOC_I2C0_SDA */
+
+   /* I2C 1 */
+   { 225,  MODE(0) },  /* SOC_I2C1_SCL */
+   { 226,  MODE(0) },  /* SOC_I2C1_SDA */
+   { MAX_PIN_N, }
+};
 
 struct pin_cfg k2g_evm_pin_cfg[] = {
/* GPMC */
@@ -307,7 +323,34 @@ struct pin_cfg k2g_evm_pin_cfg[] = {
{ MAX_PIN_N, }
 };
 
+struct pin_cfg k2g_ice_evm_pin_cfg[] = {
+   /* MMC 1 */
+   { 63, MODE(0) | PIN_PTD },  /* MMC1_DAT3.MMC1_DAT3 */
+   { 64, MODE(0) | PIN_PTU },  /* MMC1_DAT2.MMC1_DAT2 */
+   { 65, MODE(0) | PIN_PTU },  /* MMC1_DAT1.MMC1_DAT1 */
+   { 66, MODE(0) | PIN_PTD },  /* MMC1_DAT0.MMC1_DAT0 */
+   { 67, MODE(0) | PIN_PTD },  /* MMC1_CLK.MMC1_CLK   */
+   { 68, MODE(0) | PIN_PTD },  /* MMC1_CMD.MMC1_CMD   */
+   { 69, MODE(3) | PIN_PTU },  /* MMC1_SDCD.GPIO0_69  */
+   { 70, MODE(0) | PIN_PTU },  /* MMC1_SDWP.MMC1_SDWP */
+   { 71, MODE(0) | PIN_PTD },  /* MMC1_POW.MMC1_POW   */
+
+   /* I2C 0 */
+   { 223,  MODE(0) },  /* SOC_I2C0_SCL */
+   { 224,  MODE(0) },  /* SOC_I2C0_SDA */
+   { MAX_PIN_N, }
+};
+
 void k2g_mux_config(void)
 {
-   configure_pin_mux(k2g_evm_pin_cfg);
+   if (!board_ti_was_eeprom_read()) {
+   configure_pin_mux(k2g_generic_pin_cfg);
+   } else if (board_is_k2g_gp()) {
+   configure_pin_mux(k2g_evm_pin_cfg);
+   } else if (board_is_k2g_ice()) {
+   configure_pin_mux(k2g_ice_evm_pin_cfg);
+   } else {
+   puts("Unknown board, cannot configure pinmux.");
+   hang();
+   }
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 28/30] ARM: dts: k2g: Add DT support for K2G Industrial Communication Engine evm

2017-05-23 Thread Franklin S Cooper Jr
Add basic DT support for K2G ICE evm. Only minimal peripherals are
supported to allow console output and MMC boot.

Signed-off-by: Franklin S Cooper Jr 
---
Version 2 changes:
Updated to the dts recently accepted into the Linux kernel.

 arch/arm/dts/Makefile |  3 ++-
 arch/arm/dts/keystone-k2g-ice-u-boot.dtsi | 19 
 arch/arm/dts/keystone-k2g-ice.dts | 36 +++
 3 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/keystone-k2g-ice-u-boot.dtsi
 create mode 100644 arch/arm/dts/keystone-k2g-ice.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 63450f5..89bac41 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -355,7 +355,8 @@ dtb-$(CONFIG_SOC_KEYSTONE) += keystone-k2hk-evm.dtb \
keystone-k2l-evm.dtb \
keystone-k2e-evm.dtb \
keystone-k2g-evm.dtb \
-   keystone-k2g-generic.dtb
+   keystone-k2g-generic.dtb \
+   keystone-k2g-ice.dtb
 
 dtb-$(CONFIG_TARGET_AT91SAM9263EK) += at91sam9263ek.dtb
 
diff --git a/arch/arm/dts/keystone-k2g-ice-u-boot.dtsi 
b/arch/arm/dts/keystone-k2g-ice-u-boot.dtsi
new file mode 100644
index 000..4d073f3
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-ice-u-boot.dtsi
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/keystone-k2g-ice.dts 
b/arch/arm/dts/keystone-k2g-ice.dts
new file mode 100644
index 000..be63782
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-ice.dts
@@ -0,0 +1,36 @@
+/*
+ * Device Tree Source for K2G Industrial Communication Engine EVM
+ *
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+/dts-v1/;
+
+#include "keystone-k2g.dtsi"
+
+/ {
+   compatible = "ti,k2g-ice", "ti,k2g", "ti,keystone";
+   model = "Texas Instruments K2G Industrial Communication EVM";
+
+   chosen {
+   stdout-path = &uart0;
+   };
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x2000>;
+   };
+};
+
+&mmc1 {
+   status = "okay";
+};
+
+&i2c0 {
+   status = "okay";
+};
+
+&i2c1 {
+   status = "okay";
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v2 29/30] ARM: k2g: Add K2G ICE DTB to the list of possible DTBs

2017-05-23 Thread Franklin S Cooper Jr
K2G ICE evm will have its own dtb. Therefore, add it to the list of dtbs
located in the appended U-boot dtb FIT image. Therefore, when swapping out
dtbs K2G ICE boards can grab the correct one.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 5f3fc76..bbd74ee 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -225,6 +225,8 @@ int board_fit_config_name_match(const char *name)
return 0;
else if (!strcmp(name, "keystone-k2g-evm") && board_ti_is("66AK2GGP"))
return 0;
+   else if (!strcmp(name, "keystone-k2g-ice") && board_ti_is("66AK2GIC"))
+   return 0;
else
return -1;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 09/30] board_f: Add new function to allow runtime DTB selection

2017-05-24 Thread Franklin S Cooper Jr


On 05/23/2017 12:42 PM, Franklin S Cooper Jr wrote:
> Runtime U-boot dtb selection is generally a two step process. First step
> is to simply use an initial generic dtb. The second step is to select
> the dtb and perhaps execute additional code ones U-boot knows what board
> it is running on. Embedded_dtb_select handles the second step by allowing
> board specific code to run and perform what ever necessary configuration
> that is needed.
> 
> Signed-off-by: Franklin S Cooper Jr 
> ---
>  common/Kconfig   | 10 ++
>  common/board_f.c |  3 +++
>  include/common.h |  4 
>  3 files changed, 17 insertions(+)
> 
> diff --git a/common/Kconfig b/common/Kconfig
> index 2429953..b6327f0 100644
> --- a/common/Kconfig
> +++ b/common/Kconfig
> @@ -421,6 +421,16 @@ config SYS_STDIO_DEREGISTER
>  
>  endmenu
>  
> +config DTB_RESELECT
> + bool "Support swapping dtbs at a later point in boot"
> + depends on FIT_EMBED
> + default n

I will be sending a new rev. I missed dropping the above statement based
on the rev 1 comment.
> + help
> +   It is possible during initial boot you may need to use a generic
> +   dtb until you can fully determine the board your running on. This
> +   config allows boards to implement a function at a later point
> +   during boot to switch to the "correct" dtb.
> +
>  config FIT_EMBED
>   bool "Support a FIT image embedded in the U-boot image"
>   default n
> diff --git a/common/board_f.c b/common/board_f.c
> index a212f2b..b383239 100644
> --- a/common/board_f.c
> +++ b/common/board_f.c
> @@ -759,6 +759,9 @@ static const init_fnc_t init_sequence_f[] = {
>  #if defined(CONFIG_DISPLAY_CPUINFO)
>   print_cpuinfo,  /* display cpu info (and speed) */
>  #endif
> +#if defined(CONFIG_DTB_RESELECT)
> + embedded_dtb_select,
> +#endif
>  #if defined(CONFIG_DISPLAY_BOARDINFO)
>   show_board_info,
>  #endif
> diff --git a/include/common.h b/include/common.h
> index 45f190a..ebc716e 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -478,6 +478,10 @@ void pci_init_board(void);
>  #endif
>  #endif
>  
> +#if defined(CONFIG_DTB_RESELECT)
> +int  embedded_dtb_select(void);
> +#endif
> +
>  int  misc_init_f   (void);
>  int  misc_init_r   (void);
>  
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 00/30] ARM: k2g: Add support for new K2G ICE EVM.

2017-05-24 Thread Franklin S Cooper Jr
This patchset adds support for the new Keystone 2 Industrial Communication
Engine board.

This patchset includes the introduction of embedded FIT images in U-boot.
This creates a FIT image of dtb files that enables board specific code to
select which DTB to use at runtime. Initially during boot a generic DTB is
required that enables board detection to occur and once it has can later be
swapped out for the correct dtb.

Version 3 changes:
Fixed minor comments that were missed in rev 2.

Version 2 changes:
Some patches were dropped since equivalent changes have already be
incorporated in upstream already.

The addition davinci i2c device model in upstream resulted in some
patches having to be added or tweaked.

The DT for K2G ICE is based on the version that has been accepted into
Linux mainline https://lkml.org/lkml/2017/5/22/28

Franklin S Cooper Jr (29):
  spl: fit: Break out some functions into a common file
  boot_fit: Create helper functions that can be used to select DTB out
of FIT
  fdt: Enable selecting correct DTB from appended FIT Image
  ti: common: board_detect: Add function to determine if EEPROM was read
  dts: Allow OF_LIST to depend on FIT_EMBED
  ARM: dts: k2g: Introduce U-boot specific dtsi file
  arm: dts: Add new "generic" 66AK2Gx device tree file.
  board_f: Add new function to allow runtime DTB selection
  Makefile: Build additional binaries for dtb FIT blobs appended to
U-boot
  ARM: keystone2: Allow to build with all image formats
  ARM: k2g: Define embedded_dtb_select for runtime DTB selection in
U-boot
  ARM: keystone2: Define board_fit_config_name_match for Keystone 2
boards
  ks2_evm: Add EEPROM based board detection
  defconfig: keystone2: Enable U-boot runtime DTB detection
  ARM: keystone2: Add additional fields used for DDR3 configuration
  ARM: k2g: Program DDR PHY MR2 register with the default value
  ARM: k2g: Program DDRPHY_DATX8 registers via mask and value variables
  ks2_evm: Add EEPROM based board detection helper functions
  ARM: k2g: Add pinmux support for K2G ICE evm
  ARM: k2g: Add DDR3 configuration for K2G ICE evm
  board: ks2: Use board detection to wrap code not specific to K2G ICE
evm
  ARM: k2g: Use board detection to wrap K2G GP specific calls
  ARM: k2g: Update board_name u-boot env variable at runtime
  ARM: dts: keystone-k2g: Remove skeleton.dtsi
  ARM: dts: keystone-k2g-evm: Add unit address to memory node
  ARM: dts: k2g: Disable netcp by default
  ARM: dts: k2g: Add DT support for K2G Industrial Communication Engine
evm
  ARM: k2g: Add K2G ICE DTB to the list of possible DTBs
  defconfig: k2g_evm_defconfig: Add K2G ICE to OF_LIST

Nishanth Menon (1):
  ti: common: board_detect: Allow settings board detection variables
manually

 .gitignore |  1 +
 Makefile   | 18 +-
 arch/arm/dts/Makefile  |  4 +-
 arch/arm/dts/keystone-k2g-evm-u-boot.dtsi  | 19 ++
 arch/arm/dts/keystone-k2g-evm.dts  |  9 +++
 arch/arm/dts/keystone-k2g-generic-u-boot.dtsi  | 19 ++
 arch/arm/dts/keystone-k2g-generic.dts  | 28 +
 arch/arm/dts/keystone-k2g-ice-u-boot.dtsi  | 19 ++
 arch/arm/dts/keystone-k2g-ice.dts  | 36 +++
 arch/arm/dts/keystone-k2g-netcp.dtsi   |  1 +
 arch/arm/dts/keystone-k2g.dtsi |  8 +--
 arch/arm/mach-keystone/config.mk   |  4 +-
 arch/arm/mach-keystone/ddr3.c  | 35 ---
 arch/arm/mach-keystone/include/mach/ddr3.h | 14 +
 arch/arm/mach-keystone/include/mach/hardware.h |  3 +
 board/ti/common/board_detect.c | 34 ++
 board/ti/common/board_detect.h | 26 
 board/ti/ks2_evm/board.c   | 21 +--
 board/ti/ks2_evm/board.h   | 21 +++
 board/ti/ks2_evm/board_k2e.c   | 10 +++
 board/ti/ks2_evm/board_k2g.c   | 86 +++---
 board/ti/ks2_evm/board_k2hk.c  | 10 +++
 board/ti/ks2_evm/board_k2l.c   | 10 +++
 board/ti/ks2_evm/ddr3_k2g.c| 78 ++-
 board/ti/ks2_evm/mux-k2g.h | 45 +-
 common/Kconfig | 16 +
 common/Makefile|  2 +
 common/board_f.c   |  3 +
 common/boot_fit.c  | 58 +
 common/common_fit.c| 86 ++
 common/spl/spl_fit.c   | 76 +--
 configs/k2e_evm_defconfig  |  3 +
 configs/k2g_evm_defconfig  |  3 +
 configs/k2hk_evm_defconfig |  3 +
 configs/k2l_evm_defconfig  |  3 +
 dts/Kconfig| 11 ++--
 include/

[U-Boot] [PATCH v3 04/30] fdt: Enable selecting correct DTB from appended FIT Image

2017-05-24 Thread Franklin S Cooper Jr
This patch gives U-boot the runtime support to have the board specific
code decide which FDT to use. This is especially useful for devices
that need this type of runtime determination and also doesn't use SPL.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Lokesh Vutla 
Reviewed-by: Tom Rini 
---
 lib/fdtdec.c | 10 ++
 1 file changed, 10 insertions(+)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index c072e54..8bd2940 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -4,6 +4,7 @@
  */
 
 #ifndef USE_HOSTCC
+#include 
 #include 
 #include 
 #include 
@@ -1251,6 +1252,15 @@ int fdtdec_setup(void)
gd->fdt_blob = (ulong *)&_image_binary_end;
else
gd->fdt_blob = (ulong *)&__bss_end;
+
+#  elif defined CONFIG_FIT_EMBED
+   gd->fdt_blob = locate_dtb_in_fit(&_end);
+
+   if (gd->fdt_blob == NULL || gd->fdt_blob <= ((void *)&_end)) {
+   puts("Failed to find proper dtb in embedded FIT Image\n");
+   return -1;
+   }
+
 #  else
/* FDT is at end of image */
gd->fdt_blob = (ulong *)&_end;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 02/30] spl: fit: Break out some functions into a common file

2017-05-24 Thread Franklin S Cooper Jr
Some of the functions within spl_fit will be used for non spl purposes.
Instead of duplicating functions simply break the functions to be reused
into its own file.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
Reviewed-by: Simon Glass 
---
 common/Makefile  |  1 +
 common/common_fit.c  | 86 
 common/spl/spl_fit.c | 76 +-
 3 files changed, 88 insertions(+), 75 deletions(-)
 create mode 100644 common/common_fit.c

diff --git a/common/Makefile b/common/Makefile
index 14d0184..ccd8bbc 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -95,6 +95,7 @@ obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
+obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
 obj-$(CONFIG_SPL_OF_LIBFDT) += fdt_support.o
 ifdef CONFIG_SPL_USB_HOST_SUPPORT
diff --git a/common/common_fit.c b/common/common_fit.c
new file mode 100644
index 000..a08af72
--- /dev/null
+++ b/common/common_fit.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
+{
+   const u32 *cell;
+   int len;
+
+   cell = fdt_getprop(fdt, node, prop, &len);
+   if (len != sizeof(*cell))
+   return -1U;
+   return fdt32_to_cpu(*cell);
+}
+
+int fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)
+{
+   const char *name, *fdt_name;
+   int conf, node, fdt_node;
+   int len;
+
+   *fdt_offsetp = 0;
+   conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
+   if (conf < 0) {
+   debug("%s: Cannot find /configurations node: %d\n", __func__,
+ conf);
+   return -EINVAL;
+   }
+   for (node = fdt_first_subnode(fdt, conf);
+node >= 0;
+node = fdt_next_subnode(fdt, node)) {
+   name = fdt_getprop(fdt, node, "description", &len);
+   if (!name) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("%s: Missing FDT description in DTB\n",
+  __func__);
+#endif
+   return -EINVAL;
+   }
+   if (board_fit_config_name_match(name))
+   continue;
+
+   debug("Selecting config '%s'", name);
+   fdt_name = fdt_getprop(fdt, node, FIT_FDT_PROP, &len);
+   if (!fdt_name) {
+   debug("%s: Cannot find fdt name property: %d\n",
+ __func__, len);
+   return -EINVAL;
+   }
+
+   debug(", fdt '%s'\n", fdt_name);
+   fdt_node = fdt_subnode_offset(fdt, images, fdt_name);
+   if (fdt_node < 0) {
+   debug("%s: Cannot find fdt node '%s': %d\n",
+ __func__, fdt_name, fdt_node);
+   return -EINVAL;
+   }
+
+   *fdt_offsetp = fdt_getprop_u32(fdt, fdt_node, "data-offset");
+   len = fdt_getprop_u32(fdt, fdt_node, "data-size");
+   debug("FIT: Selected '%s'\n", name);
+
+   return len;
+   }
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("No matching DT out of these options:\n");
+   for (node = fdt_first_subnode(fdt, conf);
+node >= 0;
+node = fdt_next_subnode(fdt, node)) {
+   name = fdt_getprop(fdt, node, "description", &len);
+   printf("   %s\n", name);
+   }
+#endif
+
+   return -ENOENT;
+}
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index aae556f..3a722d3 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -11,80 +11,6 @@
 #include 
 #include 
 
-static ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
-{
-   const u32 *cell;
-   int len;
-
-   cell = fdt_getprop(fdt, node, prop, &len);
-   if (len != sizeof(*cell))
-   return -1U;
-   return fdt32_to_cpu(*cell);
-}
-
-static int spl_fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)
-{
-   const char *name, *fdt_name;
-   int conf, node, fdt_node;
-   int len;
-
-   *fdt_offsetp = 0;
-   conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
-   if (conf < 0) {
-   debug("%s: Cannot find /configurations node: %d\n", __func__,
- conf);
-   return -EINVAL;
-   }
-   for (n

[U-Boot] [PATCH v3 01/30] ti: common: board_detect: Allow settings board detection variables manually

2017-05-24 Thread Franklin S Cooper Jr
From: Nishanth Menon 

In some situations the EEPROM used for board detection may not be
programmed or simply programmed incorrectly. Therefore, it may be
necessary to "simulate" reading the contents of the EEPROM to set
appropriate variables used in the board detection code.

This may also be helpful in certain boot modes where doing i2c reads
may be costly and the config supports running only a specific board.

Signed-off-by: Nishanth Menon 
Signed-off-by: Tero Kristo 
Signed-off-by: Keerthy 
Signed-off-by: Franklin S Cooper Jr. 
---
 board/ti/common/board_detect.c | 24 
 board/ti/common/board_detect.h | 17 +
 2 files changed, 41 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 6fdcb61..bf594cb 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -173,6 +173,30 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, 
int dev_addr,
return 0;
 }
 
+int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev)
+{
+   struct ti_common_eeprom *ep;
+
+   if (!name || !rev)
+   return -1;
+
+   ep = TI_EEPROM_DATA;
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   goto already_set;
+
+   /* Set to 0 all fields */
+   memset(ep, 0, sizeof(*ep));
+   strncpy(ep->name, name, TI_EEPROM_HDR_NAME_LEN);
+   strncpy(ep->version, rev, TI_EEPROM_HDR_REV_LEN);
+   /* Some dummy serial number to identify the platform */
+   strncpy(ep->serial, "", TI_EEPROM_HDR_SERIAL_LEN);
+   /* Mark it with a valid header */
+   ep->header = TI_EEPROM_HEADER_MAGIC;
+
+already_set:
+   return 0;
+}
+
 int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr)
 {
int rc;
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index 88b0a59..e8d9484 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -205,4 +205,21 @@ void set_board_info_env(char *name);
  */
 void board_ti_set_ethaddr(int index);
 
+/**
+ * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
+ * @name:  Name of the board
+ * @rev:   Revision of the board
+ *
+ * In some cases such as in RTC-only mode, we are able to skip reading eeprom
+ * and wasting i2c based initialization time by using predefined flags for
+ * detecting what platform we are booting on. For those platforms, provide
+ * a handy function to pre-program information.
+ *
+ * NOTE: many eeprom information such as serial number, mac address etc is not
+ * available.
+ *
+ * Return: 0 if all went fine, else return error.
+ */
+int ti_i2c_eeprom_am_set(const char *name, const char *rev);
+
 #endif /* __BOARD_DETECT_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 07/30] ARM: dts: k2g: Introduce U-boot specific dtsi file

2017-05-24 Thread Franklin S Cooper Jr
Introduce K2G evm specific dtsi file for U-boot specific configurations.
This will help seperate U-boot only configurations thus making it easier to
keep device tree files synced between U-boot and Linux.

For now only add nodes to allow i2c drivers to be probed early during
the boot process.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2g-evm-u-boot.dtsi | 19 +++
 1 file changed, 19 insertions(+)
 create mode 100644 arch/arm/dts/keystone-k2g-evm-u-boot.dtsi

diff --git a/arch/arm/dts/keystone-k2g-evm-u-boot.dtsi 
b/arch/arm/dts/keystone-k2g-evm-u-boot.dtsi
new file mode 100644
index 000..4d073f3
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-evm-u-boot.dtsi
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 16/30] ARM: keystone2: Add additional fields used for DDR3 configuration

2017-05-24 Thread Franklin S Cooper Jr
Future boards will need to configure DDR3 registers in a slightly
different manner. Support this by defining additional variables and
defines that will be utilized later.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/include/mach/ddr3.h | 14 ++
 arch/arm/mach-keystone/include/mach/hardware.h |  3 +++
 2 files changed, 17 insertions(+)

diff --git a/arch/arm/mach-keystone/include/mach/ddr3.h 
b/arch/arm/mach-keystone/include/mach/ddr3.h
index 5feffe8..93789fd 100644
--- a/arch/arm/mach-keystone/include/mach/ddr3.h
+++ b/arch/arm/mach-keystone/include/mach/ddr3.h
@@ -35,6 +35,20 @@ struct ddr3_phy_config {
unsigned int zq1cr1;
unsigned int zq2cr1;
unsigned int pir_v1;
+   unsigned int datx8_2_mask;
+   unsigned int datx8_2_val;
+   unsigned int datx8_3_mask;
+   unsigned int datx8_3_val;
+   unsigned int datx8_4_mask;
+   unsigned int datx8_4_val;
+   unsigned int datx8_5_mask;
+   unsigned int datx8_5_val;
+   unsigned int datx8_6_mask;
+   unsigned int datx8_6_val;
+   unsigned int datx8_7_mask;
+   unsigned int datx8_7_val;
+   unsigned int datx8_8_mask;
+   unsigned int datx8_8_val;
unsigned int pir_v2;
 };
 
diff --git a/arch/arm/mach-keystone/include/mach/hardware.h 
b/arch/arm/mach-keystone/include/mach/hardware.h
index 38d0190..1969a10 100644
--- a/arch/arm/mach-keystone/include/mach/hardware.h
+++ b/arch/arm/mach-keystone/include/mach/hardware.h
@@ -52,6 +52,8 @@ typedef volatile unsigned int   *dv_reg_p;
 #define KS2_DDRPHY_ZQ2CR1_OFFSET0x1A4
 #define KS2_DDRPHY_ZQ3CR1_OFFSET0x1B4
 
+#define KS2_DDRPHY_DATX8_2_OFFSET   0x240
+#define KS2_DDRPHY_DATX8_3_OFFSET   0x280
 #define KS2_DDRPHY_DATX8_4_OFFSET   0x2C0
 #define KS2_DDRPHY_DATX8_5_OFFSET   0x300
 #define KS2_DDRPHY_DATX8_6_OFFSET   0x340
@@ -70,6 +72,7 @@ typedef volatile unsigned int   *dv_reg_p;
 #define PDQ_MASK0x0070
 #define NOSRA_MASK  0x0800
 #define ECC_MASK0x0001
+#define DXEN_MASK   0x0001
 
 /* DDR3 definitions */
 #define KS2_DDR3A_EMIF_CTRL_BASE   0x2101
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 14/30] ks2_evm: Add EEPROM based board detection

2017-05-24 Thread Franklin S Cooper Jr
Some K2G evms have their EEPROM programming while most do not. Therefore,
add EEPROM board detection to be used as the default method and fall back
to the alternative board detection when needed.

Also reorder board configuration. Perform bare minimal configuration
initially since board detection hasn't ran. Finish board configuration
once the board has been identified.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.h |  1 +
 board/ti/ks2_evm/board_k2g.c | 44 +++-
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/board/ti/ks2_evm/board.h b/board/ti/ks2_evm/board.h
index 2bbd792..0698921 100644
--- a/board/ti/ks2_evm/board.h
+++ b/board/ti/ks2_evm/board.h
@@ -11,6 +11,7 @@
 #define _KS2_BOARD
 
 #include 
+#include "../common/board_detect.h"
 
 extern struct eth_priv_t eth_priv_cfg[];
 
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index d354415..d796fd1 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -246,24 +246,6 @@ static int k2g_alt_board_detect(void)
return 0;
 }
 
-int embedded_dtb_select(void)
-{
-   int rc;
-
-   rc = k2g_alt_board_detect();
-   if (rc) {
-   printf("Unable to do board detection\n");
-   return -1;
-   }
-
-   fdtdec_setup();
-
-   return 0;
-}
-#endif
-
-#ifdef CONFIG_BOARD_EARLY_INIT_F
-
 static void k2g_reset_mux_config(void)
 {
/* Unlock the reset mux register */
@@ -277,11 +259,20 @@ static void k2g_reset_mux_config(void)
setbits_le32(KS2_RSTMUX8, RSTMUX_LOCK8_MASK);
 }
 
-int board_early_init_f(void)
+int embedded_dtb_select(void)
 {
-   init_plls();
+   int rc;
+   rc = ti_i2c_eeprom_am_get(CONFIG_EEPROM_BUS_ADDRESS,
+   CONFIG_EEPROM_CHIP_ADDRESS);
+   if (rc) {
+   rc = k2g_alt_board_detect();
+   if (rc) {
+   printf("Unable to do board detection\n");
+   return -1;
+   }
+   }
 
-   k2g_mux_config();
+   fdtdec_setup();
 
k2g_reset_mux_config();
 
@@ -313,6 +304,17 @@ int board_late_init(void)
 }
 #endif
 
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+int board_early_init_f(void)
+{
+   init_plls();
+
+   k2g_mux_config();
+
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void spl_init_keystone_plls(void)
 {
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 03/30] boot_fit: Create helper functions that can be used to select DTB out of FIT

2017-05-24 Thread Franklin S Cooper Jr
Some platforms may append a FIT image to the U-boot image. This function
aids in parsing the FIT image and selecting the correct DTB at runtime.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 common/Kconfig |  7 +++
 common/Makefile|  1 +
 common/boot_fit.c  | 58 ++
 include/boot_fit.h |  9 +
 include/image.h|  8 
 5 files changed, 83 insertions(+)
 create mode 100644 common/boot_fit.c
 create mode 100644 include/boot_fit.h

diff --git a/common/Kconfig b/common/Kconfig
index 1879aef..b8d7bc6 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -421,6 +421,13 @@ config SYS_STDIO_DEREGISTER
 
 endmenu
 
+config FIT_EMBED
+   bool "Support a FIT image embedded in the U-boot image"
+   help
+ This option provides hooks to allow U-boot to parse an
+ appended FIT image and enable board specific code to then select
+ the correct DTB to be used.
+
 config DEFAULT_FDT_FILE
string "Default fdt file"
help
diff --git a/common/Makefile b/common/Makefile
index ccd8bbc..0c6209b 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -151,6 +151,7 @@ obj-y += image.o
 obj-$(CONFIG_ANDROID_BOOT_IMAGE) += image-android.o
 obj-$(CONFIG_$(SPL_)OF_LIBFDT) += image-fdt.o
 obj-$(CONFIG_$(SPL_)FIT) += image-fit.o
+obj-$(CONFIG_FIT_EMBED) += boot_fit.o common_fit.o
 obj-$(CONFIG_$(SPL_)FIT_SIGNATURE) += image-sig.o
 obj-$(CONFIG_IO_TRACE) += iotrace.o
 obj-y += memsize.o
diff --git a/common/boot_fit.c b/common/boot_fit.c
new file mode 100644
index 000..ff26cf7
--- /dev/null
+++ b/common/boot_fit.c
@@ -0,0 +1,58 @@
+/*
+ * (C) Copyright 2017
+ * Texas Instruments, 
+ *
+ * Franklin S Cooper Jr. 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+int fdt_offset(void *fit)
+{
+   int fdt_offset, fdt_len;
+   int images;
+
+   images = fdt_path_offset(fit, FIT_IMAGES_PATH);
+   if (images < 0) {
+   debug("%s: Cannot find /images node: %d\n", __func__, images);
+   return -1;
+   }
+
+   /* Figure out which device tree the board wants to use */
+   fdt_len = fit_select_fdt(fit, images, &fdt_offset);
+
+   if (fdt_len < 0)
+   return fdt_len;
+
+   return fdt_offset;
+}
+
+void *locate_dtb_in_fit(void *fit)
+{
+   struct image_header *header;
+   int size;
+   int ret;
+
+   size = fdt_totalsize(fit);
+   size = (size + 3) & ~3;
+
+   header = (struct image_header *)fit;
+
+   if (image_get_magic(header) != FDT_MAGIC) {
+   debug("No FIT image appended to U-boot\n");
+   return NULL;
+   }
+
+   ret = fdt_offset(fit);
+
+   if (ret <= 0)
+   return NULL;
+   else
+   return (void *)fit+size+ret;
+}
diff --git a/include/boot_fit.h b/include/boot_fit.h
new file mode 100644
index 000..b7d2462
--- /dev/null
+++ b/include/boot_fit.h
@@ -0,0 +1,9 @@
+/*
+ * Copyright (C) 2017 Texas Instruments
+ * Written by Franklin Cooper Jr. 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+int fdt_offset(void *fit);
+void *locate_dtb_in_fit(void *fit);
diff --git a/include/image.h b/include/image.h
index 3f26f9b..1083578 100644
--- a/include/image.h
+++ b/include/image.h
@@ -18,6 +18,7 @@
 
 #include "compiler.h"
 #include 
+#include 
 
 /* Define this to avoid #ifdefs later on */
 struct lmb;
@@ -1274,6 +1275,13 @@ int board_fit_config_name_match(const char *name);
 void board_fit_image_post_process(void **p_image, size_t *p_size);
 #endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */
 
+#if IS_ENABLED(CONFIG_SPL_LOAD_FIT) || IS_ENABLED(CONFIG_FIT_EMBED)
+
+ulong fdt_getprop_u32(const void *fdt, int node, const char *prop);
+int fit_select_fdt(const void *fdt, int images, int *fdt_offsetp);
+
+#endif
+
 /**
  * Mapping of image types to function handlers to be invoked on the associated
  * loaded images
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 10/30] Makefile: Build additional binaries for dtb FIT blobs appended to U-boot

2017-05-24 Thread Franklin S Cooper Jr
Add additional make targets and options for building embedded FIT U-boot
images.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 .gitignore |  1 +
 Makefile   | 18 --
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 7fac5b3..29757aa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,7 @@
 #
 # Top-level generic files
 #
+fit-dtb.blob
 /MLO*
 /SPL*
 /System.map
diff --git a/Makefile b/Makefile
index bcab726..ec54c00 100644
--- a/Makefile
+++ b/Makefile
@@ -869,7 +869,21 @@ dts/dt.dtb: checkdtc u-boot
 quiet_cmd_copy = COPY$@
   cmd_copy = cp $< $@
 
-ifeq ($(CONFIG_OF_SEPARATE),y)
+ifeq ($(CONFIG_FIT_EMBED),y)
+
+fit-dtb.blob: dts/dt.dtb FORCE
+   $(call if_changed,mkimage)
+
+MKIMAGEFLAGS_fit-dtb.blob = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
+   -a 0 -e 0 -E \
+   $(patsubst %,-b arch/$(ARCH)/dts/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) 
-d /dev/null
+
+u-boot-fit-dtb.bin: u-boot-nodtb.bin fit-dtb.blob
+   $(call if_changed,cat)
+
+u-boot.bin: u-boot-fit-dtb.bin FORCE
+   $(call if_changed,copy)
+else ifeq ($(CONFIG_OF_SEPARATE),y)
 u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE
$(call if_changed,cat)
 
@@ -1440,7 +1454,7 @@ CLEAN_DIRS  += $(MODVERDIR) \
$(filter-out include, $(shell ls -1 $d 2>/dev/null
 
 CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h \
-  boot* u-boot* MLO* SPL System.map
+  boot* u-boot* MLO* SPL System.map fit-dtb.blob
 
 # Directories & files removed with 'make mrproper'
 MRPROPER_DIRS  += include/config include/generated spl tpl \
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 09/30] board_f: Add new function to allow runtime DTB selection

2017-05-24 Thread Franklin S Cooper Jr
Runtime U-boot dtb selection is generally a two step process. First step
is to simply use an initial generic dtb. The second step is to select
the dtb and perhaps execute additional code ones U-boot knows what board
it is running on. Embedded_dtb_select handles the second step by allowing
board specific code to run and perform what ever necessary configuration
that is needed.

Signed-off-by: Franklin S Cooper Jr 
---
Version 3 changes:
Dropped default n

 common/Kconfig   | 9 +
 common/board_f.c | 3 +++
 include/common.h | 4 
 3 files changed, 16 insertions(+)

diff --git a/common/Kconfig b/common/Kconfig
index b8d7bc6..e41559e 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -421,6 +421,15 @@ config SYS_STDIO_DEREGISTER
 
 endmenu
 
+config DTB_RESELECT
+   bool "Support swapping dtbs at a later point in boot"
+   depends on FIT_EMBED
+   help
+ It is possible during initial boot you may need to use a generic
+ dtb until you can fully determine the board your running on. This
+ config allows boards to implement a function at a later point
+ during boot to switch to the "correct" dtb.
+
 config FIT_EMBED
bool "Support a FIT image embedded in the U-boot image"
help
diff --git a/common/board_f.c b/common/board_f.c
index a212f2b..b383239 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -759,6 +759,9 @@ static const init_fnc_t init_sequence_f[] = {
 #if defined(CONFIG_DISPLAY_CPUINFO)
print_cpuinfo,  /* display cpu info (and speed) */
 #endif
+#if defined(CONFIG_DTB_RESELECT)
+   embedded_dtb_select,
+#endif
 #if defined(CONFIG_DISPLAY_BOARDINFO)
show_board_info,
 #endif
diff --git a/include/common.h b/include/common.h
index 45f190a..ebc716e 100644
--- a/include/common.h
+++ b/include/common.h
@@ -478,6 +478,10 @@ void   pci_init_board(void);
 #endif
 #endif
 
+#if defined(CONFIG_DTB_RESELECT)
+intembedded_dtb_select(void);
+#endif
+
 intmisc_init_f   (void);
 intmisc_init_r   (void);
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 08/30] arm: dts: Add new "generic" 66AK2Gx device tree file.

2017-05-24 Thread Franklin S Cooper Jr
With U-boot runtime board detect for DTB selection a "default" dtb needs
to be created. This will be used temporarily until the "proper" dtb is
selected.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
Version 2 changes:
Added keystone-k2g-generic-u-boot.dtsi with U-boot specific dts changes.

 arch/arm/dts/Makefile |  3 ++-
 arch/arm/dts/keystone-k2g-generic-u-boot.dtsi | 19 ++
 arch/arm/dts/keystone-k2g-generic.dts | 28 +++
 3 files changed, 49 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/keystone-k2g-generic-u-boot.dtsi
 create mode 100644 arch/arm/dts/keystone-k2g-generic.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index e2c2584..63450f5 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -354,7 +354,8 @@ dtb-$(CONFIG_ARCH_MX7ULP) += imx7ulp-evk.dtb
 dtb-$(CONFIG_SOC_KEYSTONE) += keystone-k2hk-evm.dtb \
keystone-k2l-evm.dtb \
keystone-k2e-evm.dtb \
-   keystone-k2g-evm.dtb
+   keystone-k2g-evm.dtb \
+   keystone-k2g-generic.dtb
 
 dtb-$(CONFIG_TARGET_AT91SAM9263EK) += at91sam9263ek.dtb
 
diff --git a/arch/arm/dts/keystone-k2g-generic-u-boot.dtsi 
b/arch/arm/dts/keystone-k2g-generic-u-boot.dtsi
new file mode 100644
index 000..4d073f3
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-generic-u-boot.dtsi
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/keystone-k2g-generic.dts 
b/arch/arm/dts/keystone-k2g-generic.dts
new file mode 100644
index 000..c411c3d
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-generic.dts
@@ -0,0 +1,28 @@
+/*
+ * Device Tree Source for Generic 66AK2G0X EVM
+ *
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+/dts-v1/;
+
+#include "keystone-k2g.dtsi"
+
+/ {
+   compatible = "ti,k2g-generic", "ti,k2g", "ti,keystone";
+   model = "Texas Instruments 66AK2G02 Generic";
+
+   chosen {
+   stdout-path = &uart0;
+   };
+};
+
+&i2c0 {
+status = "okay";
+};
+
+&i2c1 {
+status = "okay";
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 26/30] ARM: dts: keystone-k2g-evm: Add unit address to memory node

2017-05-24 Thread Franklin S Cooper Jr
Upstream Linux has the unit address being added to the various 66AK2Gx
boards dts. Therefore, update the dts to mimic this change.

Also remove memory node from the base K2G dtsi file.

Signed-off-by: Franklin S Cooper Jr 
---
Version 2 changes:
This patch attempts to get the dts closer to what is used in the Linux
kernel

 arch/arm/dts/keystone-k2g-evm.dts | 5 +
 arch/arm/dts/keystone-k2g.dtsi| 5 -
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/arm/dts/keystone-k2g-evm.dts 
b/arch/arm/dts/keystone-k2g-evm.dts
index 2c99df4..f6fce33 100644
--- a/arch/arm/dts/keystone-k2g-evm.dts
+++ b/arch/arm/dts/keystone-k2g-evm.dts
@@ -18,6 +18,11 @@
chosen {
stdout-path = &uart0;
};
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x8000>;
+   };
 };
 
 &mdio {
diff --git a/arch/arm/dts/keystone-k2g.dtsi b/arch/arm/dts/keystone-k2g.dtsi
index f05afb7..7b2fae6 100644
--- a/arch/arm/dts/keystone-k2g.dtsi
+++ b/arch/arm/dts/keystone-k2g.dtsi
@@ -30,11 +30,6 @@
i2c2 = &i2c2;
};
 
-   memory {
-   device_type = "memory";
-   reg = <0x8000 0x8000>;
-   };
-
cpus {
#address-cells = <1>;
#size-cells = <0>;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 20/30] ARM: k2g: Add pinmux support for K2G ICE evm

2017-05-24 Thread Franklin S Cooper Jr
Add basic pinmux data for new K2G ICE evm. Also add pinmuxing for a
generic K2G evm which includes I2C 0 and 1 used for board detection
purposes.

Since multiple K2G boards are supported that means initially generic
pinmuxing should be used when board detection hasn't ran. Once board
detection runs the proper pinmuxing can be reran to match the board
being ran on.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c |  2 ++
 board/ti/ks2_evm/mux-k2g.h   | 45 +++-
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index d796fd1..a93ef47 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -274,6 +274,8 @@ int embedded_dtb_select(void)
 
fdtdec_setup();
 
+   k2g_mux_config();
+
k2g_reset_mux_config();
 
/* deassert FLASH_HOLD */
diff --git a/board/ti/ks2_evm/mux-k2g.h b/board/ti/ks2_evm/mux-k2g.h
index 773f9b7..630103d 100644
--- a/board/ti/ks2_evm/mux-k2g.h
+++ b/board/ti/ks2_evm/mux-k2g.h
@@ -11,6 +11,22 @@
 #include 
 #include 
 #include 
+#include "board.h"
+
+struct pin_cfg k2g_generic_pin_cfg[] = {
+   /* UART0 */
+   { 115,  MODE(0) },  /* SOC_UART0_RXD */
+   { 116,  MODE(0) },  /* SOC_UART0_TXD */
+
+   /* I2C 0 */
+   { 223,  MODE(0) },  /* SOC_I2C0_SCL */
+   { 224,  MODE(0) },  /* SOC_I2C0_SDA */
+
+   /* I2C 1 */
+   { 225,  MODE(0) },  /* SOC_I2C1_SCL */
+   { 226,  MODE(0) },  /* SOC_I2C1_SDA */
+   { MAX_PIN_N, }
+};
 
 struct pin_cfg k2g_evm_pin_cfg[] = {
/* GPMC */
@@ -307,7 +323,34 @@ struct pin_cfg k2g_evm_pin_cfg[] = {
{ MAX_PIN_N, }
 };
 
+struct pin_cfg k2g_ice_evm_pin_cfg[] = {
+   /* MMC 1 */
+   { 63, MODE(0) | PIN_PTD },  /* MMC1_DAT3.MMC1_DAT3 */
+   { 64, MODE(0) | PIN_PTU },  /* MMC1_DAT2.MMC1_DAT2 */
+   { 65, MODE(0) | PIN_PTU },  /* MMC1_DAT1.MMC1_DAT1 */
+   { 66, MODE(0) | PIN_PTD },  /* MMC1_DAT0.MMC1_DAT0 */
+   { 67, MODE(0) | PIN_PTD },  /* MMC1_CLK.MMC1_CLK   */
+   { 68, MODE(0) | PIN_PTD },  /* MMC1_CMD.MMC1_CMD   */
+   { 69, MODE(3) | PIN_PTU },  /* MMC1_SDCD.GPIO0_69  */
+   { 70, MODE(0) | PIN_PTU },  /* MMC1_SDWP.MMC1_SDWP */
+   { 71, MODE(0) | PIN_PTD },  /* MMC1_POW.MMC1_POW   */
+
+   /* I2C 0 */
+   { 223,  MODE(0) },  /* SOC_I2C0_SCL */
+   { 224,  MODE(0) },  /* SOC_I2C0_SDA */
+   { MAX_PIN_N, }
+};
+
 void k2g_mux_config(void)
 {
-   configure_pin_mux(k2g_evm_pin_cfg);
+   if (!board_ti_was_eeprom_read()) {
+   configure_pin_mux(k2g_generic_pin_cfg);
+   } else if (board_is_k2g_gp()) {
+   configure_pin_mux(k2g_evm_pin_cfg);
+   } else if (board_is_k2g_ice()) {
+   configure_pin_mux(k2g_ice_evm_pin_cfg);
+   } else {
+   puts("Unknown board, cannot configure pinmux.");
+   hang();
+   }
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 06/30] dts: Allow OF_LIST to depend on FIT_EMBED

2017-05-24 Thread Franklin S Cooper Jr
OF_LIST will be useable by SPL and U-boot. Therefore, update its
dependency to allow it to be enable by either SPL or U-boot specific
config option.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
Reviewed-by: Lokesh Vutla 
Acked-by: Andrew F. Davis 
---
 dts/Kconfig | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/dts/Kconfig b/dts/Kconfig
index 9a06221..7d688e8 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -79,14 +79,15 @@ config DEFAULT_DEVICE_TREE
 
 config OF_LIST
string "List of device tree files to include for DT control"
-   depends on SPL_LOAD_FIT
+   depends on SPL_LOAD_FIT || FIT_EMBED
default DEFAULT_DEVICE_TREE
help
  This option specifies a list of device tree files to use for DT
- control. These will be packaged into a FIT. At run-time, SPL will
- select the correct DT to use by examining the hardware (e.g.
- reading a board ID value). This is a list of device tree files
- (without the directory or .dtb suffix) separated by .
+ control. These will be packaged into a FIT. At run-time, U-boot
+ or SPL will select the correct DT to use by examining the
+ hardware (e.g. reading a board ID value). This is a list of
+ device tree files (without the directory or .dtb suffix)
+ separated by .
 
 config OF_SPL_REMOVE_PROPS
string "List of device tree properties to drop for SPL"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 27/30] ARM: dts: k2g: Disable netcp by default

2017-05-24 Thread Franklin S Cooper Jr
Disable netcp by default like all other peripherals in the dtsi file.
Enable the peripheral explicitly in the board specific dts file.

Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2g-evm.dts| 4 
 arch/arm/dts/keystone-k2g-netcp.dtsi | 1 +
 2 files changed, 5 insertions(+)

diff --git a/arch/arm/dts/keystone-k2g-evm.dts 
b/arch/arm/dts/keystone-k2g-evm.dts
index f6fce33..de208b3 100644
--- a/arch/arm/dts/keystone-k2g-evm.dts
+++ b/arch/arm/dts/keystone-k2g-evm.dts
@@ -37,6 +37,10 @@
phy-handle = <ðphy0>;
 };
 
+&netcp {
+   status = "okay";
+};
+
 &spi1 {
status = "okay";
 
diff --git a/arch/arm/dts/keystone-k2g-netcp.dtsi 
b/arch/arm/dts/keystone-k2g-netcp.dtsi
index a9b26c3..d76f2a1 100644
--- a/arch/arm/dts/keystone-k2g-netcp.dtsi
+++ b/arch/arm/dts/keystone-k2g-netcp.dtsi
@@ -99,6 +99,7 @@ netcp: netcp@400 {
reg = <0x2620110 0x8>;
reg-names = "efuse";
compatible = "ti,netcp-1.0";
+   status = "disabled";
#address-cells = <1>;
#size-cells = <1>;
/* power-domains = <&k2g_pds K2G_DEV_NSS0>; */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 15/30] defconfig: keystone2: Enable U-boot runtime DTB detection

2017-05-24 Thread Franklin S Cooper Jr
Enable various config options to allow U-boot at runtime to select the
proper dtb to use from the list of dtb's within the FIT image.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 configs/k2e_evm_defconfig  | 3 +++
 configs/k2g_evm_defconfig  | 3 +++
 configs/k2hk_evm_defconfig | 3 +++
 configs/k2l_evm_defconfig  | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/configs/k2e_evm_defconfig b/configs/k2e_evm_defconfig
index 83e2138..9ab08c6 100644
--- a/configs/k2e_evm_defconfig
+++ b/configs/k2e_evm_defconfig
@@ -44,3 +44,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2e-evm"
diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig
index 674ddcc..7b105da 100644
--- a/configs/k2g_evm_defconfig
+++ b/configs/k2g_evm_defconfig
@@ -46,3 +46,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2g-generic keystone-k2g-evm"
diff --git a/configs/k2hk_evm_defconfig b/configs/k2hk_evm_defconfig
index 7dc5cf5..a751a4f 100644
--- a/configs/k2hk_evm_defconfig
+++ b/configs/k2hk_evm_defconfig
@@ -43,3 +43,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2hk-evm"
diff --git a/configs/k2l_evm_defconfig b/configs/k2l_evm_defconfig
index 6be4941..cf24d27 100644
--- a/configs/k2l_evm_defconfig
+++ b/configs/k2l_evm_defconfig
@@ -43,3 +43,6 @@ CONFIG_USB=y
 CONFIG_USB_XHCI_HCD=y
 CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
+CONFIG_DTB_RESELECT=y
+CONFIG_FIT_EMBED=y
+CONFIG_OF_LIST="keystone-k2l-evm"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 24/30] ARM: k2g: Update board_name u-boot env variable at runtime

2017-05-24 Thread Franklin S Cooper Jr
Enable CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG to allow "board_name" to
be set depending on the board it is being ran on.

Update findfdt to use this new dynamic board_name value to determine
which dtb should be used.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c |  6 ++
 include/configs/k2g_evm.h| 13 +++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 96b313f..5f3fc76 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -306,6 +306,12 @@ int board_late_init(void)
board_ti_set_ethaddr(1);
 #endif
 
+#ifdef CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+   if (board_is_k2g_gp())
+   setenv("board_name", "66AK2GGP\0");
+   else if (board_is_k2g_ice())
+   setenv("board_name", "66AK2GIC\0");
+#endif
return 0;
 }
 #endif
diff --git a/include/configs/k2g_evm.h b/include/configs/k2g_evm.h
index bee1be7..c6eab0f 100644
--- a/include/configs/k2g_evm.h
+++ b/include/configs/k2g_evm.h
@@ -16,6 +16,8 @@
 /* Platform type */
 #define CONFIG_SOC_K2G
 
+#define CONFIG_ENV_VARS_UBOOT_RUNTIME_CONFIG
+
 /* U-Boot general configuration */
 #define CONFIG_EXTRA_ENV_KS2_BOARD_SETTINGS\
DEFAULT_MMC_TI_ARGS \
@@ -28,7 +30,14 @@
"rd_spec=-\0"   \
"args_ubi=setenv bootargs ${bootargs} rootfstype=ubifs "\
"root=ubi0:rootfs rootflags=sync rw ubi.mtd=ubifs,2048\0"   \
-   "name_fdt=keystone-k2g-evm.dtb\0"   \
+   "findfdt="\
+   "if test $board_name = 66AK2GGP; then " \
+"setenv name_fdt keystone-k2g-evm.dtb; " \
+   "else if test $board_name = 66AK2GIC; then " \
+"setenv name_fdt keystone-k2g-ice.dtb; " \
+   "else if test $name_fdt = undefined; then " \
+   "echo WARNING: Could not determine device tree to use;"\
+   "fi;fi;fi;\0" \
"name_mon=skern-k2g.bin\0"  \
"name_ubi=k2g-evm-ubifs.ubi\0"  \
"name_uboot=u-boot-spi-k2g-evm.gph\0"   \
@@ -46,7 +55,7 @@
"run envboot; " \
"run set_name_pmmc init_${boot} init_fw_rd_${boot} "\
"get_pmmc_${boot} run_pmmc get_mon_${boot} run_mon "\
-   "get_fdt_${boot} get_kern_${boot} run_kern"
+   "findfdt get_fdt_${boot} get_kern_${boot} run_kern"
 
 #include 
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 30/30] defconfig: k2g_evm_defconfig: Add K2G ICE to OF_LIST

2017-05-24 Thread Franklin S Cooper Jr
Include K2G ICE to OF_LIST so it can be used for runtime board
detection.

Signed-off-by: Franklin S Cooper Jr 
---
 configs/k2g_evm_defconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configs/k2g_evm_defconfig b/configs/k2g_evm_defconfig
index 7b105da..a5639ea 100644
--- a/configs/k2g_evm_defconfig
+++ b/configs/k2g_evm_defconfig
@@ -48,4 +48,4 @@ CONFIG_USB_XHCI_DWC3=y
 CONFIG_USB_STORAGE=y
 CONFIG_DTB_RESELECT=y
 CONFIG_FIT_EMBED=y
-CONFIG_OF_LIST="keystone-k2g-generic keystone-k2g-evm"
+CONFIG_OF_LIST="keystone-k2g-generic keystone-k2g-evm keystone-k2g-ice"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 05/30] ti: common: board_detect: Add function to determine if EEPROM was read

2017-05-24 Thread Franklin S Cooper Jr
When the EEPROM is first read its contents are stored in memory as a
cache to avoid further I2C operations. To determine if the EEPROM was
previously read the easiest way is to check the memory to see if the
EEPROM's magic header value is set. Create a new function that can
determine if the EEPROM was previously read or not without having to
perform a I2C transaction.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/common/board_detect.c | 10 ++
 board/ti/common/board_detect.h |  9 +
 2 files changed, 19 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index bf594cb..1da5ace 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -457,3 +457,13 @@ void board_ti_set_ethaddr(int index)
}
}
 }
+
+bool __maybe_unused board_ti_was_eeprom_read(void)
+{
+   struct ti_common_eeprom *ep = TI_EEPROM_DATA;
+
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   return true;
+   else
+   return false;
+}
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index e8d9484..893e1ed 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -206,6 +206,15 @@ void set_board_info_env(char *name);
 void board_ti_set_ethaddr(int index);
 
 /**
+ * board_ti_was_eeprom_read() - Check to see if the eeprom contents have been 
read
+ *
+ * This function is useful to determine if the eeprom has already been read and
+ * its contents have already been loaded into memory. It utiltzes the magic
+ * number that the header value is set to upon successful eeprom read.
+ */
+bool board_ti_was_eeprom_read(void);
+
+/**
  * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
  * @name:  Name of the board
  * @rev:   Revision of the board
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 23/30] ARM: k2g: Use board detection to wrap K2G GP specific calls

2017-05-24 Thread Franklin S Cooper Jr
Certain peripherals used by K2G GP aren't used on K2G ICE evm. Or
configuration is slightly different. Therefore, use board detection to
deal with these variations.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c | 16 ++--
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index a93ef47..96b313f 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -208,7 +208,9 @@ int board_mmc_init(bd_t *bis)
return -1;
}
 
-   omap_mmc_init(0, 0, 0, -1, -1);
+   if (board_is_k2g_gp())
+   omap_mmc_init(0, 0, 0, -1, -1);
+
omap_mmc_init(1, 0, 0, -1, -1);
return 0;
 }
@@ -278,11 +280,13 @@ int embedded_dtb_select(void)
 
k2g_reset_mux_config();
 
-   /* deassert FLASH_HOLD */
-   clrbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_DIR_OFFSET,
-BIT(9));
-   setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET,
-BIT(9));
+   if (board_is_k2g_gp()) {
+   /* deassert FLASH_HOLD */
+   clrbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_DIR_OFFSET,
+BIT(9));
+   setbits_le32(K2G_GPIO1_BANK2_BASE + K2G_GPIO_SETDATA_OFFSET,
+BIT(9));
+   }
 
return 0;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 29/30] ARM: k2g: Add K2G ICE DTB to the list of possible DTBs

2017-05-24 Thread Franklin S Cooper Jr
K2G ICE evm will have its own dtb. Therefore, add it to the list of dtbs
located in the appended U-boot dtb FIT image. Therefore, when swapping out
dtbs K2G ICE boards can grab the correct one.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2g.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 5f3fc76..bbd74ee 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -225,6 +225,8 @@ int board_fit_config_name_match(const char *name)
return 0;
else if (!strcmp(name, "keystone-k2g-evm") && board_ti_is("66AK2GGP"))
return 0;
+   else if (!strcmp(name, "keystone-k2g-ice") && board_ti_is("66AK2GIC"))
+   return 0;
else
return -1;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 17/30] ARM: k2g: Program DDR PHY MR2 register with the default value

2017-05-24 Thread Franklin S Cooper Jr
K2G GP doesn't require the MR2 register to be programed since the
default is good enough. However, newer K2G boards do need to change
this register value. Therefore, instead of not writing this register if
ran on a K2G board just program the value to be written to match the
default/reset value.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/ddr3.c | 3 +--
 board/ti/ks2_evm/ddr3_k2g.c   | 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c
index ee8e12e..25a9637 100644
--- a/arch/arm/mach-keystone/ddr3.c
+++ b/arch/arm/mach-keystone/ddr3.c
@@ -52,8 +52,7 @@ void ddr3_init_ddrphy(u32 base, struct ddr3_phy_config 
*phy_cfg)
__raw_writel(phy_cfg->dtpr2, base + KS2_DDRPHY_DTPR2_OFFSET);
__raw_writel(phy_cfg->mr0,   base + KS2_DDRPHY_MR0_OFFSET);
__raw_writel(phy_cfg->mr1,   base + KS2_DDRPHY_MR1_OFFSET);
-   if (!cpu_is_k2g())
-   __raw_writel(phy_cfg->mr2,   base + KS2_DDRPHY_MR2_OFFSET);
+   __raw_writel(phy_cfg->mr2,   base + KS2_DDRPHY_MR2_OFFSET);
__raw_writel(phy_cfg->dtcr,  base + KS2_DDRPHY_DTCR_OFFSET);
__raw_writel(phy_cfg->pgcr2, base + KS2_DDRPHY_PGCR2_OFFSET);
 
diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c
index 344961d..aeb7da6 100644
--- a/board/ti/ks2_evm/ddr3_k2g.c
+++ b/board/ti/ks2_evm/ddr3_k2g.c
@@ -27,7 +27,7 @@ struct ddr3_phy_config ddr3phy_800_2g = {
.dtpr2  = 0x50022A00ul,
.mr0= 0x1430ul,
.mr1= 0x0006ul,
-   .mr2= 0x0018ul,
+   .mr2= 0xul,
.dtcr   = 0x710035C7ul,
.pgcr2  = 0x00F03D09ul,
.zq0cr1 = 0x0001005Dul,
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 12/30] ARM: k2g: Define embedded_dtb_select for runtime DTB selection in U-boot

2017-05-24 Thread Franklin S Cooper Jr
For K2G, runtime DTB selection utilizes the embedded_dtb_select function.
Therefore, define the function which will perform a EEPROM read and then
retries selecting the correct dtb now that it can detect which board its
on. For other Keystone devices use an empty function since they will still
use the embedded FIT functionality but their FIT will only contain a single
dtb.

Most production K2G boards do not have their EEPROM programmed. Therefore,
perform a test to verify a K2G GP is currently being used and if it is then
set the values normally set by a EEPROM read.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.c |  7 +++
 board/ti/ks2_evm/board_k2g.c | 38 ++
 2 files changed, 45 insertions(+)

diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index 03254e1..4792311 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -277,3 +277,10 @@ void ft_board_setup_ex(void *blob, bd_t *bd)
ddr3_check_ecc_int(KS2_DDR3A_EMIF_CTRL_BASE);
 }
 #endif /* CONFIG_OF_BOARD_SETUP */
+
+#if defined(CONFIG_DTB_RESELECT)
+int __weak embedded_dtb_select(void)
+{
+   return 0;
+}
+#endif
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 21aec8f..4c3819d 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -11,9 +11,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include "mux-k2g.h"
 #include "../common/board_detect.h"
 
+#define K2G_GP_AUDIO_CODEC_ADDRESS 0x1B
+
 const unsigned int sysclk_array[MAX_SYSCLK] = {
1920,
2400,
@@ -210,6 +214,40 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_DTB_RESELECT)
+static int k2g_alt_board_detect(void)
+{
+   int rc;
+
+   rc = i2c_set_bus_num(1);
+   if (rc)
+   return rc;
+
+   rc = i2c_probe(K2G_GP_AUDIO_CODEC_ADDRESS);
+   if (rc)
+   return rc;
+
+   ti_i2c_eeprom_am_set("66AK2GGP", "1.0X");
+
+   return 0;
+}
+
+int embedded_dtb_select(void)
+{
+   int rc;
+
+   rc = k2g_alt_board_detect();
+   if (rc) {
+   printf("Unable to do board detection\n");
+   return -1;
+   }
+
+   fdtdec_setup();
+
+   return 0;
+}
+#endif
+
 #ifdef CONFIG_BOARD_EARLY_INIT_F
 
 static void k2g_reset_mux_config(void)
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 21/30] ARM: k2g: Add DDR3 configuration for K2G ICE evm

2017-05-24 Thread Franklin S Cooper Jr
Add configuration settings used by the K2G ICE evm. Also use board
detection to determine which DDR3 configuration to use.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/ddr3_k2g.c | 62 +++--
 1 file changed, 60 insertions(+), 2 deletions(-)

diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c
index 3b12943..44db335 100644
--- a/board/ti/ks2_evm/ddr3_k2g.c
+++ b/board/ti/ks2_evm/ddr3_k2g.c
@@ -10,7 +10,9 @@
 #include 
 #include "ddr3_cfg.h"
 #include 
+#include "board.h"
 
+/* K2G GP EVM DDR3 Configuration */
 struct ddr3_phy_config ddr3phy_800_2g = {
.pllcr  = 0x000DC000ul,
.pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
@@ -61,13 +63,69 @@ struct ddr3_emif_config ddr3_800_2g = {
.sdrfc  = 0x0C34ul,
 };
 
+/* K2G ICE evm DDR3 Configuration */
+struct ddr3_phy_config ddr3phy_800_512mb = {
+   .pllcr  = 0x000DC000ul,
+   .pgcr1_mask = (IODDRM_MASK | ZCKSEL_MASK),
+   .pgcr1_val  = ((1 << 2) | (2 << 7) | (1 << 23)),
+   .ptr0   = 0x42C21590ul,
+   .ptr1   = 0xD05612C0ul,
+   .ptr2   = 0,
+   .ptr3   = 0x06C30D40ul,
+   .ptr4   = 0x06413880ul,
+   .dcr_mask   = (PDQ_MASK | MPRDQ_MASK | BYTEMASK_MASK),
+   .dcr_val= ((1 << 10)),
+   .dtpr0  = 0x550E6644ul,
+   .dtpr1  = 0x32834200ul,
+   .dtpr2  = 0x50022A00ul,
+   .mr0= 0x1430ul,
+   .mr1= 0x0006ul,
+   .mr2= 0x0008ul,
+   .dtcr   = 0x710035C7ul,
+   .pgcr2  = 0x00F03D09ul,
+   .zq0cr1 = 0x0001005Dul,
+   .zq1cr1 = 0x0001005Bul,
+   .zq2cr1 = 0x0001005Bul,
+   .pir_v1 = 0x0033ul,
+   .datx8_2_mask   = DXEN_MASK,
+   .datx8_2_val= 0,
+   .datx8_3_mask   = DXEN_MASK,
+   .datx8_3_val= 0,
+   .datx8_4_mask   = DXEN_MASK,
+   .datx8_4_val= 0,
+   .datx8_5_mask   = DXEN_MASK,
+   .datx8_5_val= 0,
+   .datx8_6_mask   = DXEN_MASK,
+   .datx8_6_val= 0,
+   .datx8_7_mask   = DXEN_MASK,
+   .datx8_7_val= 0,
+   .datx8_8_mask   = DXEN_MASK,
+   .datx8_8_val= 0,
+   .pir_v2 = 0x0F81ul,
+};
+
+struct ddr3_emif_config ddr3_800_512mb = {
+   .sdcfg  = 0x62006662ul,
+   .sdtim1 = 0x0A385033ul,
+   .sdtim2 = 0x1CA5ul,
+   .sdtim3 = 0x21ADFF32ul,
+   .sdtim4 = 0x533F067Ful,
+   .zqcfg  = 0x70073200ul,
+   .sdrfc  = 0x0C34ul,
+};
+
 u32 ddr3_init(void)
 {
/* Reset DDR3 PHY after PLL enabled */
ddr3_reset_ddrphy();
 
-   ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_2g);
-   ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_2g);
+   if (board_is_k2g_gp()) {
+   ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_2g);
+   ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_2g);
+   } else if (board_is_k2g_ice()) {
+   ddr3_init_ddrphy(KS2_DDR3A_DDRPHYC, &ddr3phy_800_512mb);
+   ddr3_init_ddremif(KS2_DDR3A_EMIF_CTRL_BASE, &ddr3_800_512mb);
+   }
 
return 0;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 19/30] ks2_evm: Add EEPROM based board detection helper functions

2017-05-24 Thread Franklin S Cooper Jr
Add a function that can be used to determine if the board being ran on is
a K2G Industrial Communication Engine EVM or K2G General Purpose EVM based
on values programmed on the EEPROM.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.h | 20 
 1 file changed, 20 insertions(+)

diff --git a/board/ti/ks2_evm/board.h b/board/ti/ks2_evm/board.h
index 0698921..b3ad188 100644
--- a/board/ti/ks2_evm/board.h
+++ b/board/ti/ks2_evm/board.h
@@ -15,6 +15,26 @@
 
 extern struct eth_priv_t eth_priv_cfg[];
 
+#if defined(CONFIG_TI_I2C_BOARD_DETECT)
+static inline int board_is_k2g_gp(void)
+{
+   return board_ti_is("66AK2GGP");
+}
+static inline int board_is_k2g_ice(void)
+{
+   return board_ti_is("66AK2GIC");
+}
+#else
+static inline int board_is_k2g_gp(void)
+{
+   return false;
+}
+static inline int board_is_k2g_ice(void)
+{
+   return false;
+}
+#endif
+
 int get_num_eth_ports(void);
 void spl_init_keystone_plls(void);
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 18/30] ARM: k2g: Program DDRPHY_DATX8 registers via mask and value variables

2017-05-24 Thread Franklin S Cooper Jr
Different K2G evms may need to program the various
KS2_DDRPHY_DATX8_X_OFFSET registers in different ways. Therefore, use
the mask and val registers for each KS2_DDRPHY_DATAX_X_OFFSET to
properly program the register.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/ddr3.c | 32 +++-
 board/ti/ks2_evm/ddr3_k2g.c   | 14 ++
 2 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/arch/arm/mach-keystone/ddr3.c b/arch/arm/mach-keystone/ddr3.c
index 25a9637..4cad6a2 100644
--- a/arch/arm/mach-keystone/ddr3.c
+++ b/arch/arm/mach-keystone/ddr3.c
@@ -65,11 +65,33 @@ void ddr3_init_ddrphy(u32 base, struct ddr3_phy_config 
*phy_cfg)
;
 
if (cpu_is_k2g()) {
-   setbits_le32(base + KS2_DDRPHY_DATX8_4_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_5_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_6_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_7_OFFSET, 0x1);
-   clrbits_le32(base + KS2_DDRPHY_DATX8_8_OFFSET, 0x1);
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_2_OFFSET,
+   phy_cfg->datx8_2_mask,
+   phy_cfg->datx8_2_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_3_OFFSET,
+   phy_cfg->datx8_3_mask,
+   phy_cfg->datx8_3_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_4_OFFSET,
+   phy_cfg->datx8_4_mask,
+   phy_cfg->datx8_4_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_5_OFFSET,
+   phy_cfg->datx8_5_mask,
+   phy_cfg->datx8_5_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_6_OFFSET,
+   phy_cfg->datx8_6_mask,
+   phy_cfg->datx8_6_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_7_OFFSET,
+   phy_cfg->datx8_7_mask,
+   phy_cfg->datx8_7_val);
+
+   clrsetbits_le32(base + KS2_DDRPHY_DATX8_8_OFFSET,
+   phy_cfg->datx8_8_mask,
+   phy_cfg->datx8_8_val);
}
 
__raw_writel(phy_cfg->pir_v2, base + KS2_DDRPHY_PIR_OFFSET);
diff --git a/board/ti/ks2_evm/ddr3_k2g.c b/board/ti/ks2_evm/ddr3_k2g.c
index aeb7da6..3b12943 100644
--- a/board/ti/ks2_evm/ddr3_k2g.c
+++ b/board/ti/ks2_evm/ddr3_k2g.c
@@ -34,6 +34,20 @@ struct ddr3_phy_config ddr3phy_800_2g = {
.zq1cr1 = 0x0001005Bul,
.zq2cr1 = 0x0001005Bul,
.pir_v1 = 0x0033ul,
+   .datx8_2_mask   = 0,
+   .datx8_2_val= 0,
+   .datx8_3_mask   = 0,
+   .datx8_3_val= 0,
+   .datx8_4_mask   = 0,
+   .datx8_4_val= ((1 << 0)),
+   .datx8_5_mask   = DXEN_MASK,
+   .datx8_5_val= 0,
+   .datx8_6_mask   = DXEN_MASK,
+   .datx8_6_val= 0,
+   .datx8_7_mask   = DXEN_MASK,
+   .datx8_7_val= 0,
+   .datx8_8_mask   = DXEN_MASK,
+   .datx8_8_val= 0,
.pir_v2 = 0x0F81ul,
 };
 
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 22/30] board: ks2: Use board detection to wrap code not specific to K2G ICE evm

2017-05-24 Thread Franklin S Cooper Jr
Some code doesn't apply to K2G ICE evm. Therefore, use board detection to
wrap these calls.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board.c | 14 +-
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/board/ti/ks2_evm/board.c b/board/ti/ks2_evm/board.c
index 4792311..c61baee 100644
--- a/board/ti/ks2_evm/board.c
+++ b/board/ti/ks2_evm/board.c
@@ -45,13 +45,17 @@ int dram_init(void)
gd->ram_size = get_ram_size((long *)CONFIG_SYS_SDRAM_BASE,
CONFIG_MAX_RAM_BANK_SIZE);
 #if defined(CONFIG_TI_AEMIF)
-   aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
+   if (!board_is_k2g_ice())
+   aemif_init(ARRAY_SIZE(aemif_configs), aemif_configs);
 #endif
 
-   if (ddr3_size)
-   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, ddr3_size);
-   else
-   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, gd->ram_size >> 30);
+   if (!board_is_k2g_ice()) {
+   if (ddr3_size)
+   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE, ddr3_size);
+   else
+   ddr3_init_ecc(KS2_DDR3A_EMIF_CTRL_BASE,
+ gd->ram_size >> 30);
+   }
 
return 0;
 }
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 11/30] ARM: keystone2: Allow to build with all image formats

2017-05-24 Thread Franklin S Cooper Jr
u-boot.bin is a copy of:
u-boot-fit-dtb.bin if CONFIG_FIT_EMBED is enabled,
u-boot-dtb.bin if CONFIG_OF_SEPARATE is enabled,
u-boot-nodtb.bin if DT is not enabled.
So, use u-boot.bin to to generate keystone images instead of
u-boot-dtb.bin

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 arch/arm/mach-keystone/config.mk | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-keystone/config.mk b/arch/arm/mach-keystone/config.mk
index db556ea..5806f8f 100644
--- a/arch/arm/mach-keystone/config.mk
+++ b/arch/arm/mach-keystone/config.mk
@@ -22,13 +22,13 @@ spl/u-boot-spl.gph: spl/u-boot-spl.bin FORCE
 
 OBJCOPYFLAGS_u-boot-spi.gph = -I binary -O binary 
--pad-to=$(CONFIG_SPL_PAD_TO) \
  --gap-fill=0
-u-boot-spi.gph: spl/u-boot-spl.gph u-boot-dtb.img FORCE
+u-boot-spi.gph: spl/u-boot-spl.gph u-boot.img FORCE
$(call if_changed,pad_cat)
 
 ifndef CONFIG_SPL_BUILD
 MKIMAGEFLAGS_MLO = -A $(ARCH) -T gpimage -C none \
-a $(CONFIG_SYS_TEXT_BASE) -e $(CONFIG_SYS_TEXT_BASE) -n U-Boot
-MLO: u-boot-dtb.bin FORCE
+MLO: u-boot.bin FORCE
$(call if_changed,mkimage)
@dd if=/dev/zero bs=8 count=1 2>/dev/null >> $@
 endif
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 13/30] ARM: keystone2: Define board_fit_config_name_match for Keystone 2 boards

2017-05-24 Thread Franklin S Cooper Jr
Now with support for U-boot runtime dtb selection each board needs to
define board_fit_config_name_match so U-boot can determine what the
correct dtb is within the FIT blob.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 board/ti/ks2_evm/board_k2e.c  | 10 ++
 board/ti/ks2_evm/board_k2g.c  | 14 ++
 board/ti/ks2_evm/board_k2hk.c | 10 ++
 board/ti/ks2_evm/board_k2l.c  | 10 ++
 4 files changed, 44 insertions(+)

diff --git a/board/ti/ks2_evm/board_k2e.c b/board/ti/ks2_evm/board_k2e.c
index 64f0c9c..266a66b 100644
--- a/board/ti/ks2_evm/board_k2e.c
+++ b/board/ti/ks2_evm/board_k2e.c
@@ -166,6 +166,16 @@ int get_num_eth_ports(void)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "keystone-k2e-evm"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 #if defined(CONFIG_BOARD_EARLY_INIT_F)
 int board_early_init_f(void)
 {
diff --git a/board/ti/ks2_evm/board_k2g.c b/board/ti/ks2_evm/board_k2g.c
index 4c3819d..d354415 100644
--- a/board/ti/ks2_evm/board_k2g.c
+++ b/board/ti/ks2_evm/board_k2g.c
@@ -214,6 +214,20 @@ int board_mmc_init(bd_t *bis)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   bool eeprom_read = board_ti_was_eeprom_read();
+
+   if (!strcmp(name, "keystone-k2g-generic") && !eeprom_read)
+   return 0;
+   else if (!strcmp(name, "keystone-k2g-evm") && board_ti_is("66AK2GGP"))
+   return 0;
+   else
+   return -1;
+}
+#endif
+
 #if defined(CONFIG_DTB_RESELECT)
 static int k2g_alt_board_detect(void)
 {
diff --git a/board/ti/ks2_evm/board_k2hk.c b/board/ti/ks2_evm/board_k2hk.c
index b35f24d..c733099 100644
--- a/board/ti/ks2_evm/board_k2hk.c
+++ b/board/ti/ks2_evm/board_k2hk.c
@@ -150,6 +150,16 @@ int board_early_init_f(void)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "keystone-k2hk-evm"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void spl_init_keystone_plls(void)
 {
diff --git a/board/ti/ks2_evm/board_k2l.c b/board/ti/ks2_evm/board_k2l.c
index f3eea42..166367b 100644
--- a/board/ti/ks2_evm/board_k2l.c
+++ b/board/ti/ks2_evm/board_k2l.c
@@ -138,6 +138,16 @@ int board_early_init_f(void)
 }
 #endif
 
+#if defined(CONFIG_FIT_EMBED)
+int board_fit_config_name_match(const char *name)
+{
+   if (!strcmp(name, "keystone-k2l-evm"))
+   return 0;
+
+   return -1;
+}
+#endif
+
 #ifdef CONFIG_SPL_BUILD
 void spl_init_keystone_plls(void)
 {
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 28/30] ARM: dts: k2g: Add DT support for K2G Industrial Communication Engine evm

2017-05-24 Thread Franklin S Cooper Jr
Add basic DT support for K2G ICE evm. Only minimal peripherals are
supported to allow console output and MMC boot.

Signed-off-by: Franklin S Cooper Jr 
---
Version 2 changes:
Updated the dts to mimic version accepted into the Linux kernel.

 arch/arm/dts/Makefile |  3 ++-
 arch/arm/dts/keystone-k2g-ice-u-boot.dtsi | 19 
 arch/arm/dts/keystone-k2g-ice.dts | 36 +++
 3 files changed, 57 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/dts/keystone-k2g-ice-u-boot.dtsi
 create mode 100644 arch/arm/dts/keystone-k2g-ice.dts

diff --git a/arch/arm/dts/Makefile b/arch/arm/dts/Makefile
index 63450f5..89bac41 100644
--- a/arch/arm/dts/Makefile
+++ b/arch/arm/dts/Makefile
@@ -355,7 +355,8 @@ dtb-$(CONFIG_SOC_KEYSTONE) += keystone-k2hk-evm.dtb \
keystone-k2l-evm.dtb \
keystone-k2e-evm.dtb \
keystone-k2g-evm.dtb \
-   keystone-k2g-generic.dtb
+   keystone-k2g-generic.dtb \
+   keystone-k2g-ice.dtb
 
 dtb-$(CONFIG_TARGET_AT91SAM9263EK) += at91sam9263ek.dtb
 
diff --git a/arch/arm/dts/keystone-k2g-ice-u-boot.dtsi 
b/arch/arm/dts/keystone-k2g-ice-u-boot.dtsi
new file mode 100644
index 000..4d073f3
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-ice-u-boot.dtsi
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c0 {
+   u-boot,dm-pre-reloc;
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
diff --git a/arch/arm/dts/keystone-k2g-ice.dts 
b/arch/arm/dts/keystone-k2g-ice.dts
new file mode 100644
index 000..be63782
--- /dev/null
+++ b/arch/arm/dts/keystone-k2g-ice.dts
@@ -0,0 +1,36 @@
+/*
+ * Device Tree Source for K2G Industrial Communication Engine EVM
+ *
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+/dts-v1/;
+
+#include "keystone-k2g.dtsi"
+
+/ {
+   compatible = "ti,k2g-ice", "ti,k2g", "ti,keystone";
+   model = "Texas Instruments K2G Industrial Communication EVM";
+
+   chosen {
+   stdout-path = &uart0;
+   };
+
+   memory@8000 {
+   device_type = "memory";
+   reg = <0x8000 0x2000>;
+   };
+};
+
+&mmc1 {
+   status = "okay";
+};
+
+&i2c0 {
+   status = "okay";
+};
+
+&i2c1 {
+   status = "okay";
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 25/30] ARM: dts: keystone-k2g: Remove skeleton.dtsi

2017-05-24 Thread Franklin S Cooper Jr
Adding the unit address to the memory node was causing the below error:
Warning (reg_format): "reg" property in /memory has invalid length
(8 bytes) (#address-cells == 2, #size-cells == 2)

Further debugging showed that this was due to the memory node added by
default to skeleton.dtsi which was being included in keystone-k2g.dtsi.
Adding a missing node was all that was needed to remove this deprecated
dtsi file from the SoC dtsi. With skeleton.dtsi removed the dtc compiler
no longer complained about including the unit address for the memory node.

Signed-off-by: Franklin S Cooper Jr 
---
Note:
This patch mimics similar changes being pulled in Linux kernel

 arch/arm/dts/keystone-k2g.dtsi | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/dts/keystone-k2g.dtsi b/arch/arm/dts/keystone-k2g.dtsi
index 191e3f1..f05afb7 100644
--- a/arch/arm/dts/keystone-k2g.dtsi
+++ b/arch/arm/dts/keystone-k2g.dtsi
@@ -9,7 +9,6 @@
  */
 
 #include 
-#include "skeleton.dtsi"
 
 / {
model = "Texas Instruments K2G SoC";
@@ -17,6 +16,8 @@
#size-cells = <1>;
interrupt-parent = <&gic>;
 
+   chosen { };
+
aliases {
serial0 = &uart0;
spi0 = &spi0;
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 27/30] ARM: dts: k2g: Disable netcp by default

2017-05-26 Thread Franklin S Cooper Jr


On 05/26/2017 01:09 PM, Tom Rini wrote:
> On Wed, May 24, 2017 at 10:43:07AM -0500, Franklin S Cooper Jr wrote:
> 
>> Disable netcp by default like all other peripherals in the dtsi file.
>> Enable the peripheral explicitly in the board specific dts file.
>>
>> Signed-off-by: Franklin S Cooper Jr 
> 
> This is being mirrored in the kernel, yes?
> 

This isn't applicable in the kernel since K2G kernel dts is bare minimal
and doesn't included netcp.
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v2 09/30] board_f: Add new function to allow runtime DTB selection

2017-05-26 Thread Franklin S Cooper Jr


On 05/26/2017 03:08 AM, Lothar Waßmann wrote:
> Franklin S Cooper Jr  wrote:
> 
>> Runtime U-boot dtb selection is generally a two step process. First step
>> is to simply use an initial generic dtb. The second step is to select
>> the dtb and perhaps execute additional code ones U-boot knows what board
>>
> s/ones/once/
> 
>> it is running on. Embedded_dtb_select handles the second step by allowing
>> board specific code to run and perform what ever necessary configuration
>> that is needed.
>>
>> Signed-off-by: Franklin S Cooper Jr 
>> ---
>>  common/Kconfig   | 10 ++
>>  common/board_f.c |  3 +++
>>  include/common.h |  4 
>>  3 files changed, 17 insertions(+)
>>
>> diff --git a/common/Kconfig b/common/Kconfig
>> index 2429953..b6327f0 100644
>> --- a/common/Kconfig
>> +++ b/common/Kconfig
>> @@ -421,6 +421,16 @@ config SYS_STDIO_DEREGISTER
>>  
>>  endmenu
>>  
>> +config DTB_RESELECT
>> +bool "Support swapping dtbs at a later point in boot"
>> +depends on FIT_EMBED
>> +default n
>>
> 'default n' is redundant.
> 
> 

Tom mentioned this also in my v1 patch and I forgot to fix it in this
patchset. I've sent a v3 that already drops this.

https://patchwork.ozlabs.org/patch/766537/
> Lothar Waßmann
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 27/30] ARM: dts: k2g: Disable netcp by default

2017-05-26 Thread Franklin S Cooper Jr


On 05/26/2017 01:46 PM, Tom Rini wrote:
> On Fri, May 26, 2017 at 01:22:17PM -0500, Franklin S Cooper Jr wrote:
>>
>>
>> On 05/26/2017 01:09 PM, Tom Rini wrote:
>>> On Wed, May 24, 2017 at 10:43:07AM -0500, Franklin S Cooper Jr wrote:
>>>
>>>> Disable netcp by default like all other peripherals in the dtsi file.
>>>> Enable the peripheral explicitly in the board specific dts file.
>>>>
>>>> Signed-off-by: Franklin S Cooper Jr 
>>>
>>> This is being mirrored in the kernel, yes?
>>
>> This isn't applicable in the kernel since K2G kernel dts is bare minimal
>> and doesn't included netcp.
> 
> OK, but will it be going up at some point?

Yes. There are some dependency clock framework patches that I'm
depending on before I can enable various peripherals in the kernel.
Various folks seem to have made good progress getting things upstreamed
and I believe the remaining should get accepted soon. After that happens
we should be able to enable all the various peripherals in the kernel's
K2G dts file.
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH] ARM: dts: keystone-k2hk-evm: Add U-boot specific dtsi file

2017-06-08 Thread Franklin S Cooper Jr
With Davinci I2C switching to device model, K2HK requires U-boot specific
device tree entries. This is only required for I2C 1 which is needed
extremely early during the boot process.

Fixes: 1743d040b1df ("ARM: keystone: Enable DM_I2C by default")
Reported-by: Yan Liu 
Signed-off-by: Franklin S Cooper Jr 
---
 arch/arm/dts/keystone-k2hk-evm-u-boot.dtsi | 15 +++
 1 file changed, 15 insertions(+)
 create mode 100644 arch/arm/dts/keystone-k2hk-evm-u-boot.dtsi

diff --git a/arch/arm/dts/keystone-k2hk-evm-u-boot.dtsi 
b/arch/arm/dts/keystone-k2hk-evm-u-boot.dtsi
new file mode 100644
index 000..072a758
--- /dev/null
+++ b/arch/arm/dts/keystone-k2hk-evm-u-boot.dtsi
@@ -0,0 +1,15 @@
+/*
+ * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+/{
+   soc {
+   u-boot,dm-pre-reloc;
+   };
+};
+
+&i2c1 {
+   u-boot,dm-pre-reloc;
+};
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 01/31] ti: common: board_detect: Allow settings board detection variables manually

2017-03-02 Thread Franklin S Cooper Jr
From: Nishanth Menon 

In some situations the EEPROM used for board detection may not be
programmed or simply programmed incorrectly. Therefore, it may be
necessary to "simulate" reading the contents of the EEPROM to set
appropriate variables used in the board detection code.

This may also be helpful in certain boot modes where doing i2c reads
may be costly and the config supports running only a specific board.

Signed-off-by: Nishanth Menon 
Signed-off-by: Tero Kristo 
Signed-off-by: Keerthy 
Signed-off-by: Franklin S Cooper Jr. 
---
 board/ti/common/board_detect.c | 24 
 board/ti/common/board_detect.h | 17 +
 2 files changed, 41 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index a5dba94..5aaf884 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -116,6 +116,30 @@ static int __maybe_unused ti_i2c_eeprom_get(int bus_addr, 
int dev_addr,
return 0;
 }
 
+int __maybe_unused ti_i2c_eeprom_am_set(const char *name, const char *rev)
+{
+   struct ti_common_eeprom *ep;
+
+   if (!name || !rev)
+   return -1;
+
+   ep = TI_EEPROM_DATA;
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   goto already_set;
+
+   /* Set to 0 all fields */
+   memset(ep, 0, sizeof(*ep));
+   strncpy(ep->name, name, TI_EEPROM_HDR_NAME_LEN);
+   strncpy(ep->version, rev, TI_EEPROM_HDR_REV_LEN);
+   /* Some dummy serial number to identify the platform */
+   strncpy(ep->serial, "", TI_EEPROM_HDR_SERIAL_LEN);
+   /* Mark it with a valid header */
+   ep->header = TI_EEPROM_HEADER_MAGIC;
+
+already_set:
+   return 0;
+}
+
 int __maybe_unused ti_i2c_eeprom_am_get(int bus_addr, int dev_addr)
 {
int rc;
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index 343fcb4..eeeacd3 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -193,4 +193,21 @@ u64 board_ti_get_emif2_size(void);
  */
 void set_board_info_env(char *name);
 
+/**
+ * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
+ * @name:  Name of the board
+ * @rev:   Revision of the board
+ *
+ * In some cases such as in RTC-only mode, we are able to skip reading eeprom
+ * and wasting i2c based initialization time by using predefined flags for
+ * detecting what platform we are booting on. For those platforms, provide
+ * a handy function to pre-program information.
+ *
+ * NOTE: many eeprom information such as serial number, mac address etc is not
+ * available.
+ *
+ * Return: 0 if all went fine, else return error.
+ */
+int ti_i2c_eeprom_am_set(const char *name, const char *rev);
+
 #endif /* __BOARD_DETECT_H */
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 02/31] spl: fit: Break out some functions into a common file

2017-03-02 Thread Franklin S Cooper Jr
Some of the functions within spl_fit will be used for non spl purposes.
Instead of duplicating functions simply break the functions to be reused
into its own file.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
---
 common/Makefile  |  1 +
 common/common_fit.c  | 86 
 common/spl/spl_fit.c | 76 +-
 include/image.h  |  8 +
 4 files changed, 96 insertions(+), 75 deletions(-)
 create mode 100644 common/common_fit.c

diff --git a/common/Makefile b/common/Makefile
index 86225f1..692ebc4 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -94,6 +94,7 @@ obj-$(CONFIG_SPL_DFU_SUPPORT) += cli_hush.o
 obj-$(CONFIG_SPL_HASH_SUPPORT) += hash.o
 obj-$(CONFIG_ENV_IS_IN_FLASH) += env_flash.o
 obj-$(CONFIG_SPL_YMODEM_SUPPORT) += xyzModem.o
+obj-$(CONFIG_SPL_LOAD_FIT) += common_fit.o
 obj-$(CONFIG_SPL_NET_SUPPORT) += miiphyutil.o
 obj-$(CONFIG_SPL_OF_TRANSLATE) += fdt_support.o
 ifdef CONFIG_SPL_USB_HOST_SUPPORT
diff --git a/common/common_fit.c b/common/common_fit.c
new file mode 100644
index 000..a08af72
--- /dev/null
+++ b/common/common_fit.c
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2016 Google, Inc
+ * Written by Simon Glass 
+ *
+ * SPDX-License-Identifier: GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
+{
+   const u32 *cell;
+   int len;
+
+   cell = fdt_getprop(fdt, node, prop, &len);
+   if (len != sizeof(*cell))
+   return -1U;
+   return fdt32_to_cpu(*cell);
+}
+
+int fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)
+{
+   const char *name, *fdt_name;
+   int conf, node, fdt_node;
+   int len;
+
+   *fdt_offsetp = 0;
+   conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
+   if (conf < 0) {
+   debug("%s: Cannot find /configurations node: %d\n", __func__,
+ conf);
+   return -EINVAL;
+   }
+   for (node = fdt_first_subnode(fdt, conf);
+node >= 0;
+node = fdt_next_subnode(fdt, node)) {
+   name = fdt_getprop(fdt, node, "description", &len);
+   if (!name) {
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("%s: Missing FDT description in DTB\n",
+  __func__);
+#endif
+   return -EINVAL;
+   }
+   if (board_fit_config_name_match(name))
+   continue;
+
+   debug("Selecting config '%s'", name);
+   fdt_name = fdt_getprop(fdt, node, FIT_FDT_PROP, &len);
+   if (!fdt_name) {
+   debug("%s: Cannot find fdt name property: %d\n",
+ __func__, len);
+   return -EINVAL;
+   }
+
+   debug(", fdt '%s'\n", fdt_name);
+   fdt_node = fdt_subnode_offset(fdt, images, fdt_name);
+   if (fdt_node < 0) {
+   debug("%s: Cannot find fdt node '%s': %d\n",
+ __func__, fdt_name, fdt_node);
+   return -EINVAL;
+   }
+
+   *fdt_offsetp = fdt_getprop_u32(fdt, fdt_node, "data-offset");
+   len = fdt_getprop_u32(fdt, fdt_node, "data-size");
+   debug("FIT: Selected '%s'\n", name);
+
+   return len;
+   }
+
+#ifdef CONFIG_SPL_LIBCOMMON_SUPPORT
+   printf("No matching DT out of these options:\n");
+   for (node = fdt_first_subnode(fdt, conf);
+node >= 0;
+node = fdt_next_subnode(fdt, node)) {
+   name = fdt_getprop(fdt, node, "description", &len);
+   printf("   %s\n", name);
+   }
+#endif
+
+   return -ENOENT;
+}
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index aae556f..3a722d3 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -11,80 +11,6 @@
 #include 
 #include 
 
-static ulong fdt_getprop_u32(const void *fdt, int node, const char *prop)
-{
-   const u32 *cell;
-   int len;
-
-   cell = fdt_getprop(fdt, node, prop, &len);
-   if (len != sizeof(*cell))
-   return -1U;
-   return fdt32_to_cpu(*cell);
-}
-
-static int spl_fit_select_fdt(const void *fdt, int images, int *fdt_offsetp)
-{
-   const char *name, *fdt_name;
-   int conf, node, fdt_node;
-   int len;
-
-   *fdt_offsetp = 0;
-   conf = fdt_path_offset(fdt, FIT_CONFS_PATH);
-   if (conf < 0) {
-   debug("%s: Cannot find /configurations node: %d\n", __func__,
- conf);
-   return -EINVAL;
-   }
-   for (n

[U-Boot] [PATCH 05/31] ti: common: board_detect: Add function to determine if EEPROM was read

2017-03-02 Thread Franklin S Cooper Jr
When the EEPROM is first read its contents are stored in memory as a
cache to avoid further I2C operations. To determine if the EEPROM was
previously read the easiest way is to check the memory to see if the
EEPROM's magic header value is set. Create a new function that can
determine if the EEPROM was previously read or not without having to
perform a I2C transaction.

Signed-off-by: Franklin S Cooper Jr 
---
 board/ti/common/board_detect.c | 10 ++
 board/ti/common/board_detect.h |  9 +
 2 files changed, 19 insertions(+)

diff --git a/board/ti/common/board_detect.c b/board/ti/common/board_detect.c
index 5aaf884..b29807a 100644
--- a/board/ti/common/board_detect.c
+++ b/board/ti/common/board_detect.c
@@ -338,3 +338,13 @@ void __maybe_unused set_board_info_env(char *name)
else
setenv("board_serial", unknown);
 }
+
+bool __maybe_unused board_ti_was_eeprom_read(void)
+{
+   struct ti_common_eeprom *ep = TI_EEPROM_DATA;
+
+   if (ep->header == TI_EEPROM_HEADER_MAGIC)
+   return true;
+   else
+   return false;
+}
diff --git a/board/ti/common/board_detect.h b/board/ti/common/board_detect.h
index eeeacd3..97dc4e4 100644
--- a/board/ti/common/board_detect.h
+++ b/board/ti/common/board_detect.h
@@ -194,6 +194,15 @@ u64 board_ti_get_emif2_size(void);
 void set_board_info_env(char *name);
 
 /**
+ * board_ti_was_eeprom_read() - Check to see if the eeprom contents have been 
read
+ *
+ * This function is useful to determine if the eeprom has already been read and
+ * its contents have already been loaded into memory. It utiltzes the magic
+ * number that the header value is set to upon successful eeprom read.
+ */
+bool board_ti_was_eeprom_read(void);
+
+/**
  * ti_i2c_eeprom_am_set() - Setup the eeprom data with predefined values
  * @name:  Name of the board
  * @rev:   Revision of the board
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 06/31] dts: Allow OF_LIST to depend on FIT_EMBED

2017-03-02 Thread Franklin S Cooper Jr
OF_LIST will be useable by SPL and U-boot. Therefore, update its
dependency to allow it to be enable by either SPL or U-boot specific
config option.

Signed-off-by: Franklin S Cooper Jr 
Reviewed-by: Tom Rini 
Reviewed-by: Lokesh Vutla 
Acked-by: Andrew F. Davis 
---
 dts/Kconfig | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/dts/Kconfig b/dts/Kconfig
index 4b7d8b1..ba019a8 100644
--- a/dts/Kconfig
+++ b/dts/Kconfig
@@ -61,14 +61,15 @@ config DEFAULT_DEVICE_TREE
 
 config OF_LIST
string "List of device tree files to include for DT control"
-   depends on SPL_LOAD_FIT
+   depends on SPL_LOAD_FIT || FIT_EMBED
default DEFAULT_DEVICE_TREE
help
  This option specifies a list of device tree files to use for DT
- control. These will be packaged into a FIT. At run-time, SPL will
- select the correct DT to use by examining the hardware (e.g.
- reading a board ID value). This is a list of device tree files
- (without the directory or .dtb suffix) separated by .
+ control. These will be packaged into a FIT. At run-time, U-boot
+ or SPL will select the correct DT to use by examining the
+ hardware (e.g. reading a board ID value). This is a list of
+ device tree files (without the directory or .dtb suffix)
+ separated by .
 
 config OF_SPL_REMOVE_PROPS
string "List of device tree properties to drop for SPL"
-- 
2.10.0

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH 00/31] ARM: k2g: Add support for new K2G ICE EVM.

2017-03-02 Thread Franklin S Cooper Jr
This patchset adds support for the new Keystone 2 Industrial Communication
Engine board.

This patchset includes the introduction of embedded FIT images in U-boot.
This creates a FIT image of dtb files that enables board specific code to
select which DTB to use at runtime. Initially during boot a generic DTB is
required that enables board detection to occur and once it has can later be
swapped out for the correct dtb.

Franklin S Cooper Jr (28):
  spl: fit: Break out some functions into a common file
  boot_fit: Create helper functions that can be used to select DTB out
of FIT
  fdt: Enable selecting correct DTB from append FIT Image
  ti: common: board_detect: Add function to determine if EEPROM was read
  dts: Allow OF_LIST to depend on FIT_EMBED
  arm: dts: Add new "generic" 66AK2Gx device tree file.
  ti_armv7_keystone2: Define scratch space in SRAM
  ARM: k2g: Enable TI board detection code
  board_f: Add new function to allow runtime DTB selection
  Makefile: Build additional binaries for dtb FIT blobs appended to
U-boot
  ARM: keystone2: Allow to build with all image formats
  ARM: k2g: Define embedded_dtb_select for runtime DTB selection in
U-boot
  ARM: keystone2: Define board_fit_config_name_match for Keystone 2
boards
  ks2_evm: Add EEPROM based board detection
  defconfig: keystone2: Enable U-boot runtime DTB detection
  ARM: keystone2: Add additional fields used for DDR3 configuration
  ARM: k2g: Program DDR PHY MR2 register with the default value
  ARM: k2g: Program DDRPHY_DATX8 registers via mask and value variables
  ks2_evm: Add EEPROM based board detection helper functions
  ARM: k2g: Add pinmux support for K2G ICE evm
  ARM: k2g: Add DDR3 configuration for K2G ICE evm
  board: ks2: Use board detection to wrap code not specific to K2G ICE
evm
  ARM: k2g: Use board detection to wrap K2G GP specific calls
  ARM: k2g: Update board_name u-boot env variable at runtime
  ARM: dts: k2g: Disable netcp by default
  ARM: dts: k2g: Add DT support for K2G Industrial Communication Engine
evm
  ARM: k2g: Add K2G ICE DTB to the list of possible DTBs
  defconfig: k2g_evm_defconfig: Add K2G ICE to OF_LIST

Lokesh Vutla (1):
  ti: common: board_detect: Rename EEPROM scratch start macro

Nishanth Menon (1):
  ti: common: board_detect: Allow settings board detection variables
manually

Roger Quadros (1):
  ARM: Use Kconfig for board EEPROM's I2C bus and chip address

 .gitignore |  1 +
 Makefile   | 18 -
 arch/arm/dts/Makefile  |  4 +-
 arch/arm/dts/keystone-k2g-evm.dts  |  4 ++
 arch/arm/dts/keystone-k2g-generic.dts  | 21 ++
 arch/arm/dts/keystone-k2g-ice.dts  | 25 +++
 arch/arm/dts/keystone-k2g-netcp.dtsi   |  1 +
 arch/arm/include/asm/omap_common.h |  8 ++-
 arch/arm/mach-keystone/Kconfig |  1 +
 arch/arm/mach-keystone/config.mk   |  4 +-
 arch/arm/mach-keystone/ddr3.c  | 35 --
 arch/arm/mach-keystone/include/mach/ddr3.h | 14 
 arch/arm/mach-keystone/include/mach/hardware.h |  3 +
 board/ti/common/Kconfig| 20 +-
 board/ti/common/board_detect.c | 34 ++
 board/ti/common/board_detect.h | 28 +++-
 board/ti/ks2_evm/Kconfig   |  2 +
 board/ti/ks2_evm/board.c   | 21 --
 board/ti/ks2_evm/board.h   | 21 ++
 board/ti/ks2_evm/board_k2e.c   | 10 +++
 board/ti/ks2_evm/board_k2g.c   | 93 +++---
 board/ti/ks2_evm/board_k2hk.c  | 10 +++
 board/ti/ks2_evm/board_k2l.c   | 10 +++
 board/ti/ks2_evm/ddr3_k2g.c| 78 -
 board/ti/ks2_evm/mux-k2g.h | 45 -
 common/Kconfig | 18 +
 common/Makefile|  2 +
 common/board_f.c   |  3 +
 common/boot_fit.c  | 58 
 common/common_fit.c| 86 
 common/spl/spl_fit.c   | 76 +
 configs/k2e_evm_defconfig  |  3 +
 configs/k2g_evm_defconfig  |  3 +
 configs/k2hk_evm_defconfig |  3 +
 configs/k2l_evm_defconfig  |  3 +
 dts/Kconfig| 11 +--
 include/boot_fit.h |  9 +++
 include/common.h   |  4 ++
 include/configs/am57xx_evm.h   |  4 --
 include/configs/dra7xx_evm.h   |  4 --
 include/configs/k2g_evm.h  | 14 +++-
 include/configs/ti_armv7_keystone2.h   |  7 ++
 include/image.h 

  1   2   >