lib: Change IOSF SB devfn to 0.0
PATCH 1/9 lib: Change IOSF SB devfn to 0.0
From: Ville Syrjälä <[email protected]>
The devfn field in the IOSF SB messages is only relevant when there's a real PCI bus or some other multifunction device behind a single port. Otherwise the port number itself is enough to uniquely identify the target. In fact some IOSF SB targets reject the access when devfn is not 0.0 (eg. GPIO_NC on BYT).
--- lib/intel_iosf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/intel_iosf.c +1 -1
@@ -28,7 +28,7 @@ static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr, bar =0 ; be =0xf ; - devfn =16 ; + devfn =0 ; cmd = (devfn <<IOSF_DEVFN_SHIFT ) | (opcode <<IOSF_OPCODE_SHIFT ) | (port << IOSF_PORT_SHIFT) | (be << IOSF_BYTE_ENABLES_SHIFT) |
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/9 lib: Allow 32bit addresses for IOSF-SB registers
From: Ville Syrjälä <[email protected]>
--- lib/intel_io.h | 8 ++++---- lib/intel_iosf.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-)
lib/intel_io.h +4 -4
@@ -53,10 +53,10 @@ void intel_flisdsi_reg_write(uint32_t reg, uint32_t val);uint32_t intel_iosf_sb_read (uint32_t port,uint32_t reg);void intel_iosf_sb_write (uint32_t port,uint32_t reg,uint32_t val); -int intel_punit_read (uint8_t addr,uint32_t *val); -int intel_punit_write (uint8_t addr,uint32_t val); -int intel_nc_read (uint8_t addr,uint32_t *val); -int intel_nc_write (uint8_t addr,uint32_t val); +int intel_punit_read (uint32_t addr,uint32_t *val); +int intel_punit_write (uint32_t addr,uint32_t val); +int intel_nc_read (uint32_t addr,uint32_t *val); +int intel_nc_write (uint32_t addr,uint32_t val);/* register maps from intel_reg_map.c */ #ifndef __GTK_DOC_IGNORE__
lib/intel_iosf.c +4 -4
@@ -73,7 +73,7 @@ static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr,* Returns: * 0 when the register access succeeded, negative errno code on failure. */ -int intel_punit_read (uint8_t addr,uint32_t *val) +int intel_punit_read (uint32_t addr,uint32_t *val) {return vlv_sideband_rw (IOSF_PORT_PUNIT ,SB_CRRDDA_NP , addr, val); }
@@ -88,7 +88,7 @@ int intel_punit_read(uint8_t addr, uint32_t *val)* Returns: * 0 when the register access succeeded, negative errno code on failure. */ -int intel_punit_write (uint8_t addr,uint32_t val) +int intel_punit_write (uint32_t addr,uint32_t val) {return vlv_sideband_rw (IOSF_PORT_PUNIT ,SB_CRWRDA_NP , addr, &val); }
@@ -103,7 +103,7 @@ int intel_punit_write(uint8_t addr, uint32_t val)* Returns: * 0 when the register access succeeded, negative errno code on failure. */ -int intel_nc_read (uint8_t addr,uint32_t *val) +int intel_nc_read (uint32_t addr,uint32_t *val) {return vlv_sideband_rw (IOSF_PORT_NC ,SB_CRRDDA_NP , addr, val); }
@@ -118,7 +118,7 @@ int intel_nc_read(uint8_t addr, uint32_t *val)* Returns: * 0 when the register access succeeded, negative errno code on failure. */ -int intel_nc_write (uint8_t addr,uint32_t val) +int intel_nc_write (uint32_t addr,uint32_t val) {return vlv_sideband_rw (IOSF_PORT_NC ,SB_CRWRDA_NP , addr, &val); }
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/9 toos/intel_iosf_sb_*: Fix DPIO IOSF SB port number
In reply to [email protected]From: Ville Syrjälä <[email protected]>
The correct port is 0x12, not 0x13 which is actually GPIO_NC.
--- tools/intel_iosf_sb_read.c | 2 +- tools/intel_iosf_sb_write.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
tools/intel_iosf_sb_read.c +1 -1
@@ -55,7 +55,7 @@ int main(int argc, char *argv[])else if (!strcasecmp (argv[1 ],"nc" )) port =0x11 ;else if (!strcasecmp (argv[1 ],"dpio" )) - port =0x13 ; + port =0x12 ;else if (!strcasecmp (argv[1 ],"gpio_nc" )) port =0x13 ;else if (!strcasecmp (argv[1 ],"cck" ))
tools/intel_iosf_sb_write.c +1 -1
@@ -54,7 +54,7 @@ int main(int argc, char** argv)else if (!strcasecmp (argv[1 ],"nc" )) port =0x11 ;else if (!strcasecmp (argv[1 ],"dpio" )) - port =0x13 ; + port =0x12 ;else if (!strcasecmp (argv[1 ],"gpio_nc" )) port =0x13 ;else if (!strcasecmp (argv[1 ],"cck" ))
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/9 tools: Remove intel_dpio_{read, write} tools
In reply to [email protected]From: Ville Syrjälä <[email protected]>
intel_dpio_{read,write} as redundant as intel_iosf_sb_{read,write} handle the same task.
The difference between the tools was the opcode used to read/write the registers, but with DPIO both opcodes work just fine, so there's no need for both sets of tools.
--- tools/Makefile.sources | 2 -- tools/intel_dpio_read.c | 69 ----------------------------------------------- tools/intel_dpio_write.c | 70 ------------------------------------------------ 3 files changed, 141 deletions(-) delete mode 100644 tools/intel_dpio_read.c delete mode 100644 tools/intel_dpio_write.c
tools/Makefile.sources +0 -2
@@ -9,8 +9,6 @@ bin_PROGRAMS = \ intel_bios_dumper \ intel_bios_reader \ intel_display_poller \ - intel_dpio_read \ - intel_dpio_write \ intel_dump_decode \ intel_error_decode \ intel_forcewaked \
tools/intel_dpio_read.c deleted +0 -69
69 lines not on this page · raw message
tools/intel_dpio_write.c deleted +0 -70
70 lines not on this page · raw message
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/9 tools/intel_iosf_sb_*: Replace if ladder with an array and bsearch()
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Replace the silly strcasecmp() if ladder with and array that maps the unit names to port numbers. And keep the thing sorted so we can do the lookup with bsearch() for extra speed :)
--- tools/intel_iosf_sb_read.c | 59 ++++++++++++++++++++++++++++++--------------- tools/intel_iosf_sb_write.c | 59 ++++++++++++++++++++++++++++++--------------- 2 files changed, 78 insertions(+), 40 deletions(-)
tools/intel_iosf_sb_read.c +39 -20
@@ -29,6 +29,44 @@#include <string.h> #include "intel_io.h" #include "intel_chipset.h" +#include "drmtest.h" + +/* keep sorted by name for bsearch() */ +static const struct iosf_sb_port { +const char *name; +uint8_t port; +} iosf_sb_ports[] = { + {"bunit" ,0x03 , }, + {"cck" ,0x14 , }, + {"ccu" ,0xa9 , }, + {"dpio" ,0x12 , }, + {"dpio2" ,0x1a , }, + {"flisdsi" ,0x1b , }, + {"gpio_nc" ,0x13 , }, + {"nc" ,0x11 , }, + {"punit" ,0x04 , }, +}; + +static int iosf_sb_port_compare (const void *a,const void *b) +{ +const char *name = a; +const struct iosf_sb_port *p = b; + +return strcasecmp (name, p->name); +} + +static int iosf_sb_port_parse (const char *name) +{ +const struct iosf_sb_port *p; + + p =bsearch (name, iosf_sb_ports,ARRAY_SIZE (iosf_sb_ports), +sizeof (iosf_sb_ports[0 ]), + iosf_sb_port_compare); +if (p) +return p->port; + +return strtoul (name,NULL ,16 ); +}static void usage (const char *name) {
@@ -48,26 +86,7 @@ int main(int argc, char *argv[])return 1 ; } -if (!strcasecmp (argv[1 ],"bunit" )) - port =0x03 ; -else if (!strcasecmp (argv[1 ],"punit" )) - port =0x04 ; -else if (!strcasecmp (argv[1 ],"nc" )) - port =0x11 ; -else if (!strcasecmp (argv[1 ],"dpio" )) - port =0x12 ; -else if (!strcasecmp (argv[1 ],"gpio_nc" )) - port =0x13 ; -else if (!strcasecmp (argv[1 ],"cck" )) - port =0x14 ; -else if (!strcasecmp (argv[1 ],"ccu" )) - port =0xa9 ; -else if (!strcasecmp (argv[1 ],"dpio2" )) - port =0x1a ; -else if (!strcasecmp (argv[1 ],"flisdsi" )) - port =0x1b ; -else - port =strtoul (argv[1 ],NULL ,16 ); + port =iosf_sb_port_parse (argv[1 ]); reg =strtoul (argv[2 ],NULL ,16 );
tools/intel_iosf_sb_write.c +39 -20
71 lines not on this page · raw message
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 6/9 tools/intel_iosf_sb_*: Use getopt() to parse the options
In reply to [email protected]From: Ville Syrjälä <[email protected]>
I want to add some command line options so switch to getopt() to make that easier.
--- tools/intel_iosf_sb_read.c | 45 ++++++++++++++++++++++++++++++++------- tools/intel_iosf_sb_write.c | 51 ++++++++++++++++++++++++++++++++++++--------- 2 files changed, 78 insertions(+), 18 deletions(-)
tools/intel_iosf_sb_read.c +37 -8
@@ -70,30 +70,59 @@ static int iosf_sb_port_parse(const char *name)static void usage (const char *name) { -printf ("Warning : This program will work only on Valleyview\n" -"Usage: %s <port> <reg>\n" -"\t port/reg : in 0xXXXX format\n" , - name); +int i; + +printf ("Warning : This program will work only on Valleyview/Cherryview\n" +"Usage: %s [-h] [--] <port> <reg>\n" +"\t -h : Show this help text\n" +"\t <port> : " , name); +for (i =0 ; i <ARRAY_SIZE (iosf_sb_ports); i++) +printf ("%s," , iosf_sb_ports[i].name); +printf (" or in hex\n" +"\t <reg> : in hex\n" ); }int main (int argc,char *argv[]) {uint32_t port, reg, val;struct pci_device *dev =intel_get_pci_device (); +int i, nregs; +const char *name; -if (argc !=3 || !(IS_VALLEYVIEW (dev->device_id) ||IS_CHERRYVIEW (dev->device_id))) { +if (!IS_VALLEYVIEW (dev->device_id) && + !IS_CHERRYVIEW (dev->device_id)) {usage (argv[0 ]);return 1 ; } - port =iosf_sb_port_parse (argv[1 ]); +for (;;) { +int c =getopt (argc, argv,"h" ); + +if (c ==-1 ) +break ; + +switch (c) { +case 'h' : +usage (argv[0 ]); +return 0 ; + } + } + + nregs = argc - optind; +if (nregs <1 ) { +usage (argv[0 ]); +return 2 ; + } - reg =strtoul (argv[2 ],NULL ,16 ); + i = optind; + name = argv[i++]; + port =iosf_sb_port_parse (name);intel_register_access_init (dev,0 ); + reg =strtoul (argv[i],NULL ,16 ); val =intel_iosf_sb_read (port, reg); -printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, argv[1 ], reg, val); +printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, name, reg, val);intel_register_access_fini ();
tools/intel_iosf_sb_write.c +41 -10
77 lines not on this page · raw message
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 7/9 tools/intel_iosf_sb_*: Support reading/writing multiple registers at once
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Allow the user to specify a list of registers to read, and register/value pairs to write.
--- tools/intel_iosf_sb_read.c | 13 ++++++++----- tools/intel_iosf_sb_write.c | 20 ++++++++++---------- 2 files changed, 18 insertions(+), 15 deletions(-)
tools/intel_iosf_sb_read.c +8 -5
@@ -73,7 +73,7 @@ static void usage(const char *name)int i;printf ("Warning : This program will work only on Valleyview/Cherryview\n" -"Usage: %s [-h] [--] <port> <reg>\n" +"Usage: %s [-h] [--] <port> <reg> [<reg> ...]\n" "\t -h : Show this help text\n" "\t <port> : " , name);for (i =0 ; i <ARRAY_SIZE (iosf_sb_ports); i++)
@@ -96,7 +96,7 @@ int main(int argc, char *argv[]) }for (;;) { -int c =getopt (argc, argv,"h" ); +int c =getopt (argc, argv,"hc:" );if (c ==-1 )break ;
@@ -120,9 +120,12 @@ int main(int argc, char *argv[])intel_register_access_init (dev,0 ); - reg =strtoul (argv[i],NULL ,16 ); - val =intel_iosf_sb_read (port, reg); -printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, name, reg, val); +for (; i < argc; i++) { + reg =strtoul (argv[i],NULL ,16 ); + + val =intel_iosf_sb_read (port, reg); +printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, name, reg, val); + }intel_register_access_fini ();
tools/intel_iosf_sb_write.c +10 -10
@@ -72,7 +72,7 @@ static void usage(const char *name)int i;printf ("Warning : This program will work only on Valleyview/Cherryview\n" -"Usage: %s [-h] [--] <port> <reg> <val>\n" +"Usage: %s [-h] [--] <port> <reg> <val> [<reg> <val> ...]\n" "\t -h : Show this help text\n" "\t <port> : " , name);for (i =0 ; i <ARRAY_SIZE (iosf_sb_ports); i++)
@@ -118,18 +118,18 @@ int main(int argc, char** argv) name = argv[i++]; port =iosf_sb_port_parse (name); - reg =strtoul (argv[i],NULL ,16 ); - val =strtoul (argv[i+1 ],NULL ,16 ); -intel_register_access_init (dev,0 ); - tmp =intel_iosf_sb_read (port, reg); -printf ("0x%02x(%s)/0x%04x before : 0x%08x\n" , port, name, reg, tmp); - -intel_iosf_sb_write (port, reg, val); +for (; i < argc; i +=2 ) { + reg =strtoul (argv[i],NULL ,16 ); + val =strtoul (argv[i+1 ],NULL ,16 ); - tmp =intel_iosf_sb_read (port, reg); -printf ("0x%02x(%s)/0x%04x after : 0x%08x\n" , port, name, reg, tmp); + tmp =intel_iosf_sb_read (port, reg); +printf ("0x%02x(%s)/0x%04x before : 0x%08x\n" , port, name, reg, tmp); +intel_iosf_sb_write (port, reg, val); + tmp =intel_iosf_sb_read (port, reg); +printf ("0x%02x(%s)/0x%04x after : 0x%08x\n" , port, name, reg, tmp); + }intel_register_access_fini ();
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 8/9 tools/intel_iosf_sb_read: Add -c command line option like intel_reg_read
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Add a command line option '-c <count>' that can be used to read set of consecutive registers without having to specify the offset for each of them.
--- tools/intel_iosf_sb_read.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-)
tools/intel_iosf_sb_read.c +17 -4
@@ -73,8 +73,9 @@ static void usage(const char *name)int i;printf ("Warning : This program will work only on Valleyview/Cherryview\n" -"Usage: %s [-h] [--] <port> <reg> [<reg> ...]\n" +"Usage: %s [-h] [-c <count>] [--] <port> <reg> [<reg> ...]\n" "\t -h : Show this help text\n" +"\t -c <count> : how many consecutive registers to read\n" "\t <port> : " , name);for (i =0 ; i <ARRAY_SIZE (iosf_sb_ports); i++)printf ("%s," , iosf_sb_ports[i].name);
@@ -86,7 +87,7 @@ int main(int argc, char *argv[]) {uint32_t port, reg, val;struct pci_device *dev =intel_get_pci_device (); -int i, nregs; +int i, nregs, count =1 ;const char *name; if (!IS_VALLEYVIEW(dev->device_id) &&
@@ -105,6 +106,13 @@ int main(int argc, char *argv[])case 'h' :usage (argv[0 ]);return 0 ; +case 'c' : + count =strtol (optarg,NULL ,0 ); +if (count <1 ) { +usage (argv[0 ]); +return 3 ; + } +break ; } }
@@ -121,10 +129,15 @@ int main(int argc, char *argv[])intel_register_access_init (dev,0 );for (; i < argc; i++) { +int j; + reg =strtoul (argv[i],NULL ,16 ); - val =intel_iosf_sb_read (port, reg); -printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, name, reg, val); +for (j =0 ; j < count; j++) { + val =intel_iosf_sb_read (port, reg); +printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, name, reg, val); + reg +=4 ; + } }intel_register_access_fini ();
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 9/9 tools/intel_iosf_sb_read: Support different register strides
In reply to [email protected]From: Ville Syrjälä <[email protected]>
Some IOSF SB units ogranize their registers in a pecualiar way. Even though the registers are 32 bits wide, the register offsets only increment by one when going from one register to the next. Correctly deal with this when dumping several consecutive registers.
--- tools/intel_iosf_sb_read.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-)
tools/intel_iosf_sb_read.c +18 -14
@@ -35,16 +35,17 @@static const struct iosf_sb_port {const char *name;uint8_t port; +uint8_t reg_stride; } iosf_sb_ports[] = { - {"bunit" ,0x03 , }, - {"cck" ,0x14 , }, - {"ccu" ,0xa9 , }, - {"dpio" ,0x12 , }, - {"dpio2" ,0x1a , }, - {"flisdsi" ,0x1b , }, - {"gpio_nc" ,0x13 , }, - {"nc" ,0x11 , }, - {"punit" ,0x04 , }, + {"bunit" ,0x03 ,1 , }, + {"cck" ,0x14 ,1 , }, + {"ccu" ,0xa9 ,4 , }, + {"dpio" ,0x12 ,4 , }, + {"dpio2" ,0x1a ,4 , }, + {"flisdsi" ,0x1b ,1 , }, + {"gpio_nc" ,0x13 ,4 , }, + {"nc" ,0x11 ,4 , }, + {"punit" ,0x04 ,1 , }, };static int iosf_sb_port_compare (const void *a,const void *b)
@@ -55,16 +56,19 @@ static int iosf_sb_port_compare(const void *a, const void *b)return strcasecmp (name, p->name); } -static int iosf_sb_port_parse (const char *name) +static int iosf_sb_port_parse (const char *name,int *reg_stride) {const struct iosf_sb_port *p; p =bsearch (name, iosf_sb_ports,ARRAY_SIZE (iosf_sb_ports),sizeof (iosf_sb_ports[0 ]), iosf_sb_port_compare); -if (p) +if (p) { + *reg_stride = p->reg_stride;return p->port; + } + *reg_stride =4 ;return strtoul (name,NULL ,16 ); }
@@ -87,7 +91,7 @@ int main(int argc, char *argv[]) {uint32_t port, reg, val;struct pci_device *dev =intel_get_pci_device (); -int i, nregs, count =1 ; +int i, nregs, count =1 , reg_stride;const char *name; if (!IS_VALLEYVIEW(dev->device_id) &&
@@ -124,7 +128,7 @@ int main(int argc, char *argv[]) i = optind; name = argv[i++]; - port =iosf_sb_port_parse (name); + port =iosf_sb_port_parse (name, ®_stride);intel_register_access_init (dev,0 );
@@ -136,7 +140,7 @@ int main(int argc, char *argv[])for (j =0 ; j < count; j++) { val =intel_iosf_sb_read (port, reg);printf ("0x%02x(%s)/0x%04x : 0x%08x\n" , port, name, reg, val); - reg +=4 ; + reg += reg_stride; } }
Signature · 6 lines
2.0.5 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx