Indirect register access through PPC440 DCR.
PATCH 1/1 Indirect register access through PPC440 DCR.
DESCRIPTION:
Existing getdcr and setdcr monitor functions don't allow indirect access to PPC440 registers in one step. It's still possible theoretically use setdcr to write offset into correct address DCRN and then read/write from data DCRN, but that doesn't work if address got updated in the middle. For instance, I never could read value of SDR0_PINSTP (address/data DCRNs 0xE/0xF, offset 0x40) - immediately after me somebody changed address DCRN to 0x20.
The solution is to implement new special functions getidcr/setidcr for indirect access with following format:
getidcr adr_dcrn[.dat_dcrn] offset
setidcr adr_dcrn[.dat_dcrn] offset value
dat_dcrn will be set adr_dcrn+1 if omitted.
Examples (Yosemite PPC440EP board has been used):
1. Read SDR0_PINSTP:
=> getidcr e 40
000e.000f-0040 Read e0000000
2. Read SDR0_CUST0, update it and read back:
=> getidcr e 4000
000e.000f-4000 Read 40082350
=> setidcr e.f 4000 50082350
000e.000f-4000 Write 50082350
=> getidcr e 4000
000e.000f-4000 Read 50082350
CHANGELOG entry:
* Add monitor functions for indirect access to PPC440 registers via Data Control Register (DCR).
PATCH: (diff file ppc440dcr.txt attached).
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ppc440dcr.txt
Url: http://lists.denx.de/pipermail/u-boot/attachments/20061005/8696d0a0/attachment.txt
PATCH 1/1 Indirect register access through PPC440 DCR.
Hi Leonid,
Quoted 4 lines · Leonid
* Add monitor functions for indirect access to PPC440 registers via Data Control Register (DCR).
PATCH: (diff file ppc440dcr.txt attached).
Please find some comments below...
Review
Quoted 2 lines
==== //depot/Alchemy/ppc/uboot/u-boot-1.1.4/common/cmd_dcr.c#1 -
/home/leonid/pd/ppc/uboot/u-boot-1.1.4/common/cmd_dcr.c====(quoted diff) +0
-0@@ -104,10 +104,126 @@
Please generate the patch as described in the README:
diff -purN OLD NEW
Or create a git patch.
Quoted 9 lines
(quoted diff) +4
-0} while (nbytes); return 0; } +/* ======================================================================= + * Interpreter command to retrieve an register value through AMCC PPC 4xx + * Device Control Register inderect addressing. + * =======================================================================
Review line 122
Quoted 10 lines
(quoted diff) +10
-0+ */ +int do_getidcr ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[] ) +{ + unsigned long get_dcr (unsigned short); + unsigned long set_dcr (unsigned short, unsigned long); + unsigned short adr_dcrn; /* Device Control Register Num for Address */ + unsigned short dat_dcrn; /* Device Control Register Num for Data */ + unsigned short offset; /* Register's offset */ + unsigned long value; /* register's value */ + unsigned char * ptr=NULL, buf[80];
Only tabs for indentation.
Review line 131
Quoted 9 lines
(quoted diff) +9
-0+ + /* Validate arguments */ + if (argc < 3) { + printf ("Usage:\n%s\n", cmdtp->usage); + return 1; + } + + /* Find out whether ther is '.' (dot) symbol in the first parameter. */ + strncpy(buf, argv[1], sizeof(buf)-1);
Indentation.
Review line 136
Quoted 5 lines
(quoted diff) +5
-0+ buf[sizeof(buf)-1]=0; /* will guarantee zero-end string */ + ptr = strchr(buf, '.'); + + if(ptr != NULL) + {/* first parameter has fromat adr_dcrn.dat_dcrn */
Opening brace in the line of the if statement please.
Review line 144
Quoted 8 lines
(quoted diff) +8
-0+ * ptr = 0; /* erase '.', create zero-end string */ + ptr++; /* will point to dat_dcr */ + adr_dcrn = (unsigned short) simple_strtoul (buf, NULL, 16); + dat_dcrn = (unsigned short) simple_strtoul (ptr, NULL, 16); + } + else + { /* first parameter has fromat adr_dcrn; dat_dcrn will be + calculated as adr_dcrn+1. */
Please use:
} else {I'm stopping here. Please recheck you patch regarding the coding style. You could of course use something like "Lindent" to help you here.
<snip>
Please fix the above mentioned issues and resubmit a new patch. Thanks.
Best regards,
Stefan
PATCH 1/1 Indirect register access through PPC440 DCR.
Quoted 2 lines · Stefan Roese
Please generate the patch as described in the README:
diff -purN OLD NEW
Done, attached (ppc440dcr_diff.txt).
Quoted 1 line
Only tabs for indentation.
Done.
Quoted 1 line
Opening brace in the line of the if statement please.
Done.
Quoted 2 lines
Please use:
} else {
Done.
Quoted 1 line
Please fix the above mentioned issues and resubmit a new patch.
Thanks.
Done; see below, after asterisks.
Best regards,
Leonid.
************************************************************************
***
DESCRIPTION:
Existing getdcr and setdcr monitor functions don't allow indirect access to PPC440 registers in one step. It's still possible theoretically use setdcr to write offset into correct address DCRN and then read/write from data DCRN, but that doesn't work if address got updated in the middle. For instance, I never could read value of SDR0_PINSTP (address/data DCRNs 0xE/0xF, offset 0x40) - immediately after me somebody changed address DCRN to 0x20.
The solution is to implement new special functions getidcr/setidcr for indirect access with following format:
getidcr adr_dcrn[.dat_dcrn] offset
setidcr adr_dcrn[.dat_dcrn] offset value
dat_dcrn will be set adr_dcrn+1 if omitted.
Examples (Yosemite PPC440EP board has been used):
1. Read SDR0_PINSTP:
=> getidcr e 40
000e.000f-0040 Read e0000000
2. Read SDR0_CUST0, update it and read back:
=> getidcr e 4000
000e.000f-4000 Read 40082350
=> setidcr e.f 4000 50082350
000e.000f-4000 Write 50082350
=> getidcr e 4000
000e.000f-4000 Read 50082350
CHANGELOG entry:
* Add monitor functions for indirect access to PPC440 registers via Data Control Register (DCR).
PATCH: (diff file ppc440dcr_diff.txt attached).
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ppc440dcr_diff.txt
Url: http://lists.denx.de/pipermail/u-boot/attachments/20061012/76efea57/attachment.txt
PATCH 1/1 Indirect register access through PPC440 DCR.
Hi Leonid,
sorry for being so insistent but there are still some issues that need to be cleaned up in your patch. Please see below...
Quoted 4 lines
common/cmd_dcr.c +0
-0@@ -106,6 +106,122 @@ int do_setdcr (cmd_tbl_t * cmdtp, int flreturn 0 ;
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 116
Quoted 10 lines
common/cmd_dcr.c +8
-0} +/* ======================================================================= +* Interpreter command to retrieve an register value through AMCC PPC 4xx +* Device Control Register inderect addressing. +* ======================================================================= +*/ +int do_getidcr (cmd_tbl_t *cmdtp,int flag,int argc,char *argv[] ) +{ +unsigned long get_dcr (unsigned short );
Please use tabs for indentation. Indentation size is 8 by the way. This is a problem in the complete patch.
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 122
Quoted 6 lines
common/cmd_dcr.c +6
-0+unsigned long set_dcr (unsigned short ,unsigned long ); +unsigned short adr_dcrn;/* Device Control Register Num for Address */ +unsigned short dat_dcrn;/* Device Control Register Num for Data */ +unsigned short offset;/* Register's offset */ +unsigned long value;/* register's value */ +unsigned char *ptr=NULL ;
Space before and after the "=".
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 134
Quoted 12 lines
common/cmd_dcr.c +12
-0+unsigned char buf[80 ]; + +/* Validate arguments */ +if (argc <3 ) { +printf ("Usage:\n%s\n" , cmdtp->usage); +return 1 ; + } + +/* Find out whether ther is '.' (dot) symbol in the first parameter. */ +strncpy (buf, argv[1 ],sizeof (buf)-1 ); + buf[sizeof (buf)-1 ]=0 ;/* will guarantee zero-end string */ + ptr =strchr (buf,'.' );
Why are here 2 spaces before the "="? It's not aligned to another line of code. Please use just one space.
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 136
Quoted 2 lines
common/cmd_dcr.c +2
-0+ +if (ptr !=NULL ) {
A space after the "if" please.
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 138
Quoted 2 lines
common/cmd_dcr.c +2
-0+/* first parameter has format adr_dcrn.dat_dcrn */ + * ptr =0 ;/* erase '.', create zero-end string */
*ptr = 0;
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 139
Quoted 1 line
common/cmd_dcr.c +1
-0+ ptr++;/* will point to dat_dcr */
And why not:
*ptr++ = 0;
Quoted 44 lines
common/cmd_dcr.c +44
-0+ adr_dcrn = (unsigned short )simple_strtoul (buf,NULL ,16 ); + dat_dcrn = (unsigned short )simple_strtoul (ptr,NULL ,16 ); + }else { +/* first parameter has format adr_dcrn; dat_dcrn will be +calculated as adr_dcrn+1. */ + adr_dcrn = (unsigned short )simple_strtoul (buf,NULL ,16 ); + dat_dcrn = adr_dcrn+1 ; + } + +/* Register's offset */ + offset = (unsigned short )simple_strtoul (argv[2 ],NULL ,16 ); + +/* Disable interrupts */ +disable_interrupts (); +/* Set offset */ +set_dcr (adr_dcrn, offset); +/* get data */ + value =get_dcr (dat_dcrn); +/* Enable interrupts */ +enable_interrupts (); + +printf ("%04x.%04x-%04x Read %08lx\n" , adr_dcrn, dat_dcrn, offset, value); + +return 0 ; +} + +/* ======================================================================= +* Interpreter command to update an register value through AMCC PPC 4xx +* Device Control Register inderect addressing. +* ======================================================================= +*/ +int do_setidcr (cmd_tbl_t * cmdtp,int flag,int argc,char *argv[]) +{ +unsigned long get_dcr (unsigned short ); +unsigned long set_dcr (unsigned short ,unsigned long ); +unsigned short adr_dcrn;/* Device Control Register Num for Address */ +unsigned short dat_dcrn;/* Device Control Register Num for Data */ +unsigned short offset;/* Register's offset */ +unsigned long value;/* register's value */ +unsigned char *ptr=NULL ; +unsigned char buf[80 ]; + +/* Validate arguments */ +if (argc <4 ) {
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 193
Quoted 10 lines
common/cmd_dcr.c +10
-0+printf ("Usage:\n%s\n" , cmdtp->usage); +return 1 ; + } + +/* Find out whether ther is '.' (dot) symbol in the first parameter. */ +strncpy (buf, argv[1 ],sizeof (buf)-1 ); + buf[sizeof (buf)-1 ]=0 ;/* will guarantee zero-end string */ + ptr =strchr (buf,'.' ); + +if (ptr !=NULL ) {
Space after if again.
common/cmd_dcr.c int do_setdcr (cmd_tbl_t * cmdtp, int fl · line 196
Quoted 3 lines
common/cmd_dcr.c +3
-0+/* first parameter has format adr_dcrn.dat_dcrn */ + * ptr =0 ;/* erase '.', create zero-end string */ + ptr++;/* will point to dat_dcr */
*ptr++ = 0;
Quoted 45 lines
common/cmd_dcr.c +37
-0+ adr_dcrn = (unsigned short )simple_strtoul (buf,NULL ,16 ); + dat_dcrn = (unsigned short )simple_strtoul (ptr,NULL ,16 ); + }else { +/* first parameter has format adr_dcrn; dat_dcrn will be +calculated as adr_dcrn+1. */ + adr_dcrn = (unsigned short )simple_strtoul (buf,NULL ,16 ); + dat_dcrn = adr_dcrn+1 ; + } + +/* Register's offset */ + offset = (unsigned short )simple_strtoul (argv[2 ],NULL ,16 ); +/* New value */ + value = (unsigned long )simple_strtoul (argv[3 ],NULL ,16 ); + +/* Disable interrupts */ +disable_interrupts (); +/* Set offset */ +set_dcr (adr_dcrn, offset); +/* set data */ +set_dcr (dat_dcrn, value); +/* Enable interrupts */ +enable_interrupts (); + +printf ("%04x.%04x-%04x Write %08lx\n" , adr_dcrn, dat_dcrn, offset, value); + +return 0 ; +} +/***************************************************/ U_BOOT_CMD(@@ -119,4 +235,16 @@ U_BOOT_CMD("dcrn - set a DCR's value.\n" ); +U_BOOT_CMD ( + getidcr,3 ,1 , do_getidcr, +"getidcr - Get a register value via indirect DCR addressing\n" , + "adr_dcrn[.dat_dcrn] offset - write offset to adr_dcrn, read value from dat_dcrn.\n" +); + +U_BOOT_CMD( + setidcr, 4, 1, do_setidcr, + "setidcr - Set a register value via indirect DCR addressing\n", + "adr_dcrn[.dat_dcrn] offset value - write offset to adr_dcrn, write value
Quoted 3 lines
to dat_dcrn.\n" +);
+
#endif /*CONFIG_4xx&CFG_CMD_SETGETDCR*/
Please fix the issues mentioned above and resubmit your patch. Thanks.
Best regards,
Stefan
PATCH 1/1 Indirect register access through PPC440 DCR.
Quoted 2 lines · Stefan Roese
sorry for being so insistent but there are still some issues that need to be cleaned up in your patch. Please see below...
No worries, quite opposite, I appreciate your comments.
Quoted 2 lines
Please use tabs for indentation. Indentation size is 8 by the way. This is a problem in the complete patch.
Well, I kind of did, but looks like xemacs, I'm using has different tab configuration. I've inserted tabs using vi, now they are 8 spaces each.
Quoted 1 line
Space before and after the "=".
Done.
Quoted 2 lines
Why are here 2 spaces before the "="? It's not aligned to another line of code. Please use just one space.
Done.
Quoted 5 lines
*ptr = 0;Quoted 1 line
+ ptr++; /* will point to
dat_dcr*/And why not:
*ptr++ = 0;
Done.
Quoted 1 line
Space after if again.
Done.
************************************************************************
***
DESCRIPTION:
Existing getdcr and setdcr monitor functions don't allow indirect access to PPC440 registers in one step. It's still possible theoretically use setdcr to write offset into correct address DCRN and then read/write from data DCRN, but that doesn't work if address got updated in the middle. For instance, I never could read value of SDR0_PINSTP (address/data DCRNs 0xE/0xF, offset 0x40) - immediately after me somebody changed address DCRN to 0x20.
The solution is to implement new special functions getidcr/setidcr for indirect access with following format:
getidcr adr_dcrn[.dat_dcrn] offset
setidcr adr_dcrn[.dat_dcrn] offset value
dat_dcrn will be set adr_dcrn+1 if omitted.
Examples (Yosemite PPC440EP board has been used):
1. Read SDR0_PINSTP:
=> getidcr e 40
000e.000f-0040 Read e0000000
2. Read SDR0_CUST0, update it and read back:
=> getidcr e 4000
000e.000f-4000 Read 40082350
=> setidcr e.f 4000 50082350
000e.000f-4000 Write 50082350
=> getidcr e 4000
000e.000f-4000 Read 50082350
CHANGELOG entry:
* Add monitor functions for indirect access to PPC440 registers via Data Control Register (DCR).
PATCH: (diff file ppc440dcr_diff.txt attached).
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ppc440dcr_diff.txt
Url: http://lists.denx.de/pipermail/u-boot/attachments/20061012/7da2b3a6/attachment.txt
Stefan Roese
AppliedPATCH 1/1 Indirect register access through PPC440 DCR.
Quoted 2 lines · Leonid
* Add monitor functions for indirect access to PPC440 registers via Data Control Register (DCR).
Applied. Thanks.
Viele Gr??e,
Stefan