@@ -467,6 +467,54 @@ static void rk808_device_shutdown(void)
467467 }
468468}
469469
470+ static ssize_t rk8xx_dbg_store (struct device * dev ,
471+ struct device_attribute * attr ,
472+ const char * buf , size_t count )
473+ {
474+ int ret ;
475+ char cmd ;
476+ u32 input [2 ], addr , data ;
477+ struct rk808 * rk808 = i2c_get_clientdata (rk808_i2c_client );
478+
479+ ret = sscanf (buf , "%c " , & cmd );
480+ switch (cmd ) {
481+ case 'w' :
482+ ret = sscanf (buf , "%c %x %x " , & cmd , & input [0 ], & input [1 ]);
483+ if (ret != 3 ) {
484+ pr_err ("erro! cmd format: echo w [addr] [value]\n" );
485+ goto out ;
486+ };
487+ addr = input [0 ] & 0xff ;
488+ data = input [1 ] & 0xff ;
489+ pr_info ("cmd : %c %x %x\n\n" , cmd , input [0 ], input [1 ]);
490+ regmap_write (rk808 -> regmap , addr , data );
491+ regmap_read (rk808 -> regmap , addr , & data );
492+ pr_info ("new: %x %x\n" , addr , data );
493+ break ;
494+ case 'r' :
495+ ret = sscanf (buf , "%c %x " , & cmd , & input [0 ]);
496+ if (ret != 2 ) {
497+ pr_err ("erro! cmd format: echo r [addr]\n" );
498+ goto out ;
499+ };
500+ pr_info ("cmd : %c %x\n\n" , cmd , input [0 ]);
501+ addr = input [0 ] & 0xff ;
502+ regmap_read (rk808 -> regmap , addr , & data );
503+ pr_info ("%x %x\n" , input [0 ], data );
504+ break ;
505+ default :
506+ pr_err ("Unknown command\n" );
507+ break ;
508+ }
509+
510+ out :
511+ return count ;
512+ }
513+
514+ static struct kobject * rk8xx_kobj ;
515+ static struct device_attribute rk8xx_attrs =
516+ __ATTR (rk8xx_dbg , 0200 , NULL , rk8xx_dbg_store );
517+
470518static const struct of_device_id rk808_of_match [] = {
471519 { .compatible = "rockchip,rk805" },
472520 { .compatible = "rockchip,rk808" },
@@ -628,6 +676,13 @@ static int rk808_probe(struct i2c_client *client,
628676 }
629677 }
630678
679+ rk8xx_kobj = kobject_create_and_add ("rk8xx" , NULL );
680+ if (rk8xx_kobj ) {
681+ ret = sysfs_create_file (rk8xx_kobj , & rk8xx_attrs .attr );
682+ if (ret )
683+ dev_err (& client -> dev , "create rk8xx sysfs error\n" );
684+ }
685+
631686 return 0 ;
632687
633688err_irq :
0 commit comments