board/BuR/common: simplify access to devicetree
PATCH 1/3 board/BuR/common: simplify access to devicetree
instead of polling everytime the environment, we take usage of the global gd->fdt_blob variable and check it only against NULL.
Variable "dtbaddr" from environment is needed only one time on loading the devicetree within "load_devicetree()"
---
board/BuR/common/common.c | 114 ++++++++++++++++++++++----------------------- 1 file changed, 55 insertions(+), 59 deletions(-)
board/BuR/common/common.c +55 -59
@@ -39,7 +39,7 @@ static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE;DECLARE_GLOBAL_DATA_PTR ;#ifdef CONFIG_USE_FDT -#define FDTPROP (a, b, c) fdt_getprop_u32_default((void *)a, b, c, ~0UL) +#define FDTPROP (b, c) fdt_getprop_u32_default(gd->fdt_blob, b, c, ~0UL)#define PATHTIM "/panel/display-timings/default"#define PATHINF "/panel/panel-info"#endif
@@ -50,51 +50,50 @@ int load_lcdtiming(struct am335x_lcdpanel *panel) {struct am335x_lcdpanel pnltmp;#ifdef CONFIG_USE_FDT -u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 , ~0UL );u32 dtbprop; -if (dtbaddr == ~0UL ) { -puts ("load_lcdtiming: failed to get 'dtbaddr' from env!\n" ); +if (gd->fdt_blob ==NULL ) { +printf ("%s: don't have a valid gd->fdt_blob!\n" , __func__);return -1 ; }memcpy (&pnltmp, (void *)panel,sizeof (struct am335x_lcdpanel )); - pnltmp.hactive =FDTPROP (dtbaddr,PATHTIM ,"hactive" ); - pnltmp.vactive =FDTPROP (dtbaddr,PATHTIM ,"vactive" ); - pnltmp.bpp =FDTPROP (dtbaddr,PATHINF ,"bpp" ); - pnltmp.hfp =FDTPROP (dtbaddr,PATHTIM ,"hfront-porch" ); - pnltmp.hbp =FDTPROP (dtbaddr,PATHTIM ,"hback-porch" ); - pnltmp.hsw =FDTPROP (dtbaddr,PATHTIM ,"hsync-len" ); - pnltmp.vfp =FDTPROP (dtbaddr,PATHTIM ,"vfront-porch" ); - pnltmp.vbp =FDTPROP (dtbaddr,PATHTIM ,"vback-porch" ); - pnltmp.vsw =FDTPROP (dtbaddr,PATHTIM ,"vsync-len" ); - pnltmp.pup_delay =FDTPROP (dtbaddr,PATHTIM ,"pupdelay" ); - pnltmp.pon_delay =FDTPROP (dtbaddr,PATHTIM ,"pondelay" ); + pnltmp.hactive =FDTPROP (PATHTIM ,"hactive" ); + pnltmp.vactive =FDTPROP (PATHTIM ,"vactive" ); + pnltmp.bpp =FDTPROP (PATHINF ,"bpp" ); + pnltmp.hfp =FDTPROP (PATHTIM ,"hfront-porch" ); + pnltmp.hbp =FDTPROP (PATHTIM ,"hback-porch" ); + pnltmp.hsw =FDTPROP (PATHTIM ,"hsync-len" ); + pnltmp.vfp =FDTPROP (PATHTIM ,"vfront-porch" ); + pnltmp.vbp =FDTPROP (PATHTIM ,"vback-porch" ); + pnltmp.vsw =FDTPROP (PATHTIM ,"vsync-len" ); + pnltmp.pup_delay =FDTPROP (PATHTIM ,"pupdelay" ); + pnltmp.pon_delay =FDTPROP (PATHTIM ,"pondelay" );/* calc. proper clk-divisor */ - dtbprop =FDTPROP (dtbaddr,PATHTIM ,"clock-frequency" ); + dtbprop =FDTPROP (PATHTIM ,"clock-frequency" );if (dtbprop != ~0UL ) pnltmp.pxl_clk_div =192000000 / dtbprop;else pnltmp.pxl_clk_div = ~0UL ;/* check polarity of control-signals */ - dtbprop =FDTPROP (dtbaddr,PATHTIM ,"hsync-active" ); + dtbprop =FDTPROP (PATHTIM ,"hsync-active" );if (dtbprop ==0 ) pnltmp.pol |=HSYNC_INVERT ; - dtbprop =FDTPROP (dtbaddr,PATHTIM ,"vsync-active" ); + dtbprop =FDTPROP (PATHTIM ,"vsync-active" );if (dtbprop ==0 ) pnltmp.pol |=VSYNC_INVERT ; - dtbprop =FDTPROP (dtbaddr,PATHINF ,"sync-ctrl" ); + dtbprop =FDTPROP (PATHINF ,"sync-ctrl" );if (dtbprop ==1 ) pnltmp.pol |=HSVS_CONTROL ; - dtbprop =FDTPROP (dtbaddr,PATHINF ,"sync-edge" ); + dtbprop =FDTPROP (PATHINF ,"sync-edge" );if (dtbprop ==1 ) pnltmp.pol |=HSVS_RISEFALL ; - dtbprop =FDTPROP (dtbaddr,PATHTIM ,"pixelclk-active" ); + dtbprop =FDTPROP (PATHTIM ,"pixelclk-active" );if (dtbprop ==0 ) pnltmp.pol |=PXCLK_INVERT ; - dtbprop =FDTPROP (dtbaddr,PATHTIM ,"de-active" ); + dtbprop =FDTPROP (PATHTIM ,"de-active" );if (dtbprop ==0 ) pnltmp.pol |=DE_INVERT ;#else
@@ -163,11 +162,16 @@ static int load_devicetree(void)char *dtbname =getenv ("dtb" );char *dtbdev =getenv ("dtbdev" );char *dtppart =getenv ("dtbpart" ); -u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 , ~0UL ); +u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 ,0UL ); +int rc;loff_t dtbsize; -if (!dtbdev || !dtbdev) { -puts ("load_devicetree: <dtbdev>/<dtbpart> missing.\n" ); +if (dtbaddr ==0 ) { +printf ("%s: don't have a valid <dtbaddr> in env!\n" , __func__); +return -1 ; + } +if (!dtbdev || !dtbdev || !dtbname) { +printf ("%s: <dtbdev>/<dtbpart>/<dtb> missing.\n" , __func__);return -1 ; }
@@ -175,18 +179,16 @@ static int load_devicetree(void)puts ("load_devicetree: set_blk_dev failed.\n" );return -1 ; } -if (dtbname && dtbaddr != ~0UL ) { -if (fs_read (dtbname, dtbaddr,0 ,0 , &dtbsize) ==0 ) { - gd->fdt_blob = (void *)dtbaddr; - gd->fdt_size = dtbsize; -debug ("loaded %d bytes of dtb onto 0x%08x\n" , - (u32 )dtbsize, dtbaddr); -return dtbsize; - } -puts ("load_devicetree: load dtb failed,file does not exist!\n" ); + rc =fs_read (dtbname, (u32 )dtbaddr,0 ,0 , &dtbsize); +if (rc ==0 ) { + gd->fdt_blob = (void *)dtbaddr; + gd->fdt_size = dtbsize; +debug ("loaded %d bytes of dtb onto 0x%08x\n" , + (u32 )dtbsize, (u32 )gd->fdt_blob); +return dtbsize; } -puts ("load_devicetree: <dtb>/<dtbaddr> missing!\n" ); +printf ("%s: load dtb failed!\n" , __func__);return -1 ; }
@@ -196,26 +198,25 @@ static const char *dtbmacaddr(u32 ifno)char enet[16 ];const char *mac;const char *path; -u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 , ~0UL ); -if (dtbaddr == ~0UL ) { -puts ("dtbmacaddr: failed to get 'dtbaddr' from env!\n" ); +if (gd->fdt_blob ==NULL ) { +printf ("%s: don't have a valid gd->fdt_blob!\n" , __func__);return NULL ; } - node =fdt_path_offset ((void *)dtbaddr,"/aliases" ); + node =fdt_path_offset (gd->fdt_blob,"/aliases" );if (node <0 )return NULL ;sprintf (enet,"ethernet%d" , ifno); - path =fdt_getprop ((void *)dtbaddr, node, enet,NULL ); + path =fdt_getprop (gd->fdt_blob, node, enet,NULL );if (!path) {printf ("no alias for %s\n" , enet);return NULL ; } - node =fdt_path_offset ((void *)dtbaddr, path); - mac =fdt_getprop ((void *)dtbaddr, node,"mac-address" , &len); + node =fdt_path_offset (gd->fdt_blob, path); + mac =fdt_getprop (gd->fdt_blob, node,"mac-address" , &len);if (mac &&is_valid_ether_addr ((u8 *)mac))return mac;
@@ -226,15 +227,14 @@ static void br_summaryscreen_printdtb(char *prefix,char *name, char *suffix) { - u32 dtbaddr = getenv_ulong("dtbaddr", 16, ~0UL); char buf[32] = { 0 };const char *nodep = buf;char *mac =0 ;int nodeoffset;int len; -if (dtbaddr == ~0UL ) { -puts ("br_summaryscreen: failed to get 'dtbaddr' from env!\n" ); +if (gd->fdt_blob ==NULL ) { +printf ("%s: don't have a valid gd->fdt_blob!\n" , __func__);return ; }
@@ -247,13 +247,13 @@ static void br_summaryscreen_printdtb(char *prefix,if (mac)sprintf (buf,"%pM" , mac); }else { - nodeoffset =fdt_path_offset ((void *)dtbaddr, + nodeoffset =fdt_path_offset (gd->fdt_blob,"/factory-settings" );if (nodeoffset <0 ) {puts ("no 'factory-settings' in dtb!\n" );return ; } - nodep =fdt_getprop ((void *)dtbaddr, nodeoffset, name, &len); + nodep =fdt_getprop (gd->fdt_blob, nodeoffset, name, &len); }if (nodep &&strlen (nodep) >1 )lcd_printf ("%s %s %s" , prefix, nodep, suffix);
@@ -318,13 +318,11 @@ void lcdpower(int on) {u32 pin, swval, i;#ifdef CONFIG_USE_FDT -u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 , ~0UL ); - -if (dtbaddr == ~0UL ) { -puts ("lcdpower: failed to get 'dtbaddr' from env!\n" ); +if (gd->fdt_blob ==NULL ) { +printf ("%s: don't have a valid gd->fdt_blob!\n" , __func__);return ; } - pin =FDTPROP (dtbaddr,PATHINF ,"pwrpin" ); + pin =FDTPROP (PATHINF ,"pwrpin" );#else pin =getenv_ulong ("ds1_pwr" ,16 , ~0UL );#endif
@@ -385,15 +383,13 @@ void lcd_ctrl_init(void *lcdbase)void lcd_enable (void ) {#ifdef CONFIG_USE_FDT -u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 , ~0UL ); - -if (dtbaddr == ~0UL ) { -puts ("lcdpower: failed to get 'dtbaddr' from env!\n" ); +if (gd->fdt_blob ==NULL ) { +printf ("%s: don't have a valid gd->fdt_blob!\n" , __func__);return ; } -unsigned int driver =FDTPROP (dtbaddr,PATHINF ,"brightdrv" ); -unsigned int bright =FDTPROP (dtbaddr,PATHINF ,"brightdef" ); -unsigned int pwmfrq =FDTPROP (dtbaddr,PATHINF ,"brightfdim" ); +unsigned int driver =FDTPROP (PATHINF ,"brightdrv" ); +unsigned int bright =FDTPROP (PATHINF ,"brightdef" ); +unsigned int pwmfrq =FDTPROP (PATHINF ,"brightfdim" );#else unsigned int driver =getenv_ulong ("ds1_bright_drv" ,16 ,0UL );unsigned int bright =getenv_ulong ("ds1_bright_def" ,10 ,50 );
Signature · 1 line
1.7.9.5
PATCH 2/3 board/BuR/tseries: reactivate NAND-board
The NAND-version has been become a bit orphan. Now we need to reactivate it, so bring necessary things:
- loading devicetree
- switch control signal to correct pins
- setup pinmux
- default-environment
up to date.
---
board/BuR/common/common.c | 15 +++++++++++---- board/BuR/tseries/board.c | 3 +++ board/BuR/tseries/mux.c | 2 +- include/configs/tseries.h | 37 ++++++++++++++++++++----------------- 4 files changed, 35 insertions(+), 22 deletions(-)
board/BuR/common/common.c +11 -4
@@ -33,6 +33,7 @@#endif #include "bur_common.h" #include "../../../drivers/video/am335x-fb.h" +#include <nand.h> static struct ctrl_dev *cdev = (struct ctrl_dev *)CTRL_DEVICE_BASE ;
@@ -159,17 +160,22 @@ int load_lcdtiming(struct am335x_lcdpanel *panel)#ifdef CONFIG_USE_FDT static int load_devicetree (void ) { -char *dtbname =getenv ("dtb" ); -char *dtbdev =getenv ("dtbdev" ); -char *dtppart =getenv ("dtbpart" ); -u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 ,0UL );int rc;loff_t dtbsize; +u32 dtbaddr =getenv_ulong ("dtbaddr" ,16 ,0UL );if (dtbaddr ==0 ) {printf ("%s: don't have a valid <dtbaddr> in env!\n" , __func__);return -1 ; } +#ifdef CONFIG_NAND + dtbsize =0x20000 ; + rc =nand_read_skip_bad (&nand_info[0 ],0x40000 , (size_t *)&dtbsize, +NULL ,0x20000 , (u_char *)dtbaddr); +#else +char *dtbname =getenv ("dtb" ); +char *dtbdev =getenv ("dtbdev" ); +char *dtppart =getenv ("dtbpart" );if (!dtbdev || !dtbdev || !dtbname) {printf ("%s: <dtbdev>/<dtbpart>/<dtb> missing.\n" , __func__);return -1 ;
@@ -180,6 +186,7 @@ static int load_devicetree(void) return -1; } rc =fs_read (dtbname, (u32 )dtbaddr,0 ,0 , &dtbsize); +#endif if (rc ==0 ) { gd->fdt_blob = (void *)dtbaddr; gd->fdt_size = dtbsize;
board/BuR/tseries/board.c +3 -0
@@ -128,6 +128,9 @@ void am33xx_spl_board_init(void)i2c_set_bus_num (0 );i2c_init (CONFIG_SYS_OMAP24_I2C_SPEED ,CONFIG_SYS_OMAP24_I2C_SLAVE );pmicsetup (0 ); + +gpio_direction_output (64 +29 ,1 );/* switch NAND_RnB to GPMC_WAIT1 */ +gpio_direction_output (64 +28 ,1 );/* switch MII2_CRS to GPMC_WAIT0 */ }const struct dpll_params *get_dpll_ddr_params (void )
board/BuR/tseries/mux.c +1 -1
@@ -123,7 +123,7 @@ static struct module_pin_mux nand_pin_mux[] = { {OFFSET(gpmc_ad5), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD5 */ {OFFSET(gpmc_ad6), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD6 */ {OFFSET(gpmc_ad7), (MODE(0) | PULLUP_EN | RXACTIVE)}, /* NAND AD7 */ - {OFFSET(gpmc_wait0), (MODE(0) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ + {OFFSET(gpmc_clk), (MODE(2) | RXACTIVE | PULLUP_EN)}, /* NAND WAIT */ {OFFSET(gpmc_wpn), (MODE(7) | PULLUP_EN | RXACTIVE)}, /* NAND_WPN */ {OFFSET(gpmc_csn0), (MODE(0) | PULLUDEN)}, /* NAND_CS0 */ {OFFSET(gpmc_advn_ale), (MODE(0) | PULLUDEN)}, /* NAND_ADV_ALE */
include/configs/tseries.h +20 -17
@@ -23,6 +23,8 @@#define CONFIG_HW_WATCHDOG #define CONFIG_OMAP_WATCHDOG #define CONFIG_SPL_WATCHDOG_SUPPORT + +#define CONFIG_SPL_GPIO_SUPPORT /* Bootcount using the RTC block */ #define CONFIG_SYS_BOOTCOUNT_ADDR 0x44E3E000#define CONFIG_BOOTCOUNT_LIMIT
@@ -103,15 +105,16 @@"mtdparts=" MTDPARTS_DEFAULT "\0" \"nandargs=setenv bootargs console=${console} " \"${optargs} " \ -"root=${nandroot} " \ -"rootfstype=${nandrootfstype}\0" \ -"nandroot=ubi0:rootfs rw ubi.mtd=8,2048\0" \ -"nandrootfstype=ubifs rootwait=1\0" \ -"nandimgsize=0x500000\0" \ -"nandboot=echo Booting from nand ...; " \ +"root=mtd6 " \ +"rootfstype=jffs2\0" \ +"kernelsize=0x400000\0" \ +"nandboot=echo booting from nand ...; " \"run nandargs; " \ -"nand read ${loadaddr} kernel ${nandimgsize}; " \ - "bootz ${loadaddr}\0" +"nand read ${loadaddr} kernel ${kernelsize}; " \ +"bootz ${loadaddr} - ${dtbaddr}\0" \ +"defboot=run nandboot\0" \ +"bootlimit=1\0" \ + "altbootcmd=run usbscript\0"#else #define NANDARGS ""#endif /* CONFIG_NAND */
@@ -231,15 +234,15 @@ MMCARGS#define MTDIDS_DEFAULT "nand0=omap2-nand.0"#define MTDPARTS_DEFAULT "mtdparts=omap2-nand.0:" \ - "128k(SPL)," \ - "128k(SPL.backup1)," \ - "128k(SPL.backup2)," \ - "128k(SPL.backup3)," \ - "512k(u-boot)," \ - "128k(u-boot-spl-os)," \ + "128k(MLO)," \ + "128k(MLO.backup)," \ + "128k(dtb)," \ "128k(u-boot-env)," \ - "5m(kernel),"\ - "-(rootfs)" + "512k(u-boot)," \ + "4m(kernel),"\ + "128m(rootfs),"\ + "-(user)" +#define CONFIG_NAND_OMAP_GPMC_WSCFG 1#endif /* CONFIG_NAND */ /* USB configuration */
@@ -298,7 +301,7 @@ MMCARGS#else #define CONFIG_ENV_IS_IN_NAND #endif -#define CONFIG_ENV_OFFSET 0x120000/* TODO: Adresse definieren */ +#define CONFIG_ENV_OFFSET 0x60000#define CONFIG_SYS_ENV_SECT_SIZE CONFIG_ENV_SIZE#else #error "no storage for Environment defined!"
Signature · 1 line
1.7.9.5
PATCH 2/3 board/BuR/tseries: reactivate NAND-board
Quoted 11 lines · Hannes Petermaier
The NAND-version has been become a bit orphan. Now we need to reactivate it, so bring necessary things:
- loading devicetree
- switch control signal to correct pins
- setup pinmux
- default-environmentup to date.
Signed-off-by Hannes Petermaier <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150423/b424e334/attachment.sig>
PATCH 3/3 board/BuR/tseries: change pinmux
In reply to Hannes Petermaiersome pins on the board have been rerouted to other peripherals, so we change the pinmux to apply with hardware-design.
---
board/BuR/tseries/mux.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
board/BuR/tseries/mux.c +9 -3
@@ -17,8 +17,10 @@#include <i2c.h> static struct module_pin_mux uart0_pin_mux[] = { +/* UART0_RTS */ + {OFFSET (uart0_rtsn), (MODE (0 ) |PULLUDEN )},/* UART0_CTS */ - {OFFSET (uart0_ctsn), (MODE (7 ) |PULLUDEN |PULLUP_EN |RXACTIVE )}, + {OFFSET (uart0_ctsn), (MODE (0 ) |PULLUDEN |PULLUP_EN |RXACTIVE )},/* UART0_RXD */ {OFFSET (uart0_rxd), (MODE (0 ) |PULLUDEN |PULLUP_EN |RXACTIVE )},/* UART0_TXD */
@@ -26,9 +28,13 @@ static struct module_pin_mux uart0_pin_mux[] = { {-1}, };static struct module_pin_mux uart1_pin_mux[] = { -/* UART0_RXD */ +/* UART1_RTS as I2C2-SCL */ + {OFFSET (uart1_rtsn), (MODE (3 ) |PULLUDEN |PULLUP_EN |RXACTIVE )}, +/* UART1_CTS as I2C2-SDA */ + {OFFSET (uart1_ctsn), (MODE (3 ) |PULLUDEN |PULLUP_EN |RXACTIVE )}, +/* UART1_RXD */ {OFFSET (uart1_rxd), (MODE (0 ) |PULLUDEN |PULLUP_EN |RXACTIVE )}, -/* UART0_TXD */ +/* UART1_TXD */ {OFFSET (uart1_txd), (MODE (0 ) |PULLUDEN )}, {-1 }, };
Signature · 1 line
1.7.9.5
PATCH 3/3 board/BuR/tseries: change pinmux
Quoted 4 lines · Hannes Petermaier
some pins on the board have been rerouted to other peripherals, so we change the pinmux to apply with hardware-design.
Signed-off-by Hannes Petermaier <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150423/aed940df/attachment.sig>
PATCH 1/3 board/BuR/common: simplify access to devicetree
In reply to Hannes PetermaierQuoted 7 lines · Hannes Petermaier
instead of polling everytime the environment, we take usage of the global
gd->fdt_blobvariable and check it only against NULL.Variable "dtbaddr" from environment is needed only one time on loading the devicetree within "
load_devicetree()"Signed-off-by Hannes Petermaier <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150423/495f6798/attachment.sig>