@@ -973,19 +973,43 @@ static int get_clock(void *i2c_priv)
973
973
{
974
974
struct ast_i2c_chan * i2c = i2c_priv ;
975
975
struct ast_private * ast = i2c -> dev -> dev_private ;
976
- uint32_t val ;
976
+ uint32_t val , val2 , count , pass ;
977
+
978
+ count = 0 ;
979
+ pass = 0 ;
980
+ val = (ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x10 ) >> 4 ) & 0x01 ;
981
+ do {
982
+ val2 = (ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x10 ) >> 4 ) & 0x01 ;
983
+ if (val == val2 ) {
984
+ pass ++ ;
985
+ } else {
986
+ pass = 0 ;
987
+ val = (ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x10 ) >> 4 ) & 0x01 ;
988
+ }
989
+ } while ((pass < 5 ) && (count ++ < 0x10000 ));
977
990
978
- val = ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x10 ) >> 4 ;
979
991
return val & 1 ? 1 : 0 ;
980
992
}
981
993
982
994
static int get_data (void * i2c_priv )
983
995
{
984
996
struct ast_i2c_chan * i2c = i2c_priv ;
985
997
struct ast_private * ast = i2c -> dev -> dev_private ;
986
- uint32_t val ;
998
+ uint32_t val , val2 , count , pass ;
999
+
1000
+ count = 0 ;
1001
+ pass = 0 ;
1002
+ val = (ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x20 ) >> 5 ) & 0x01 ;
1003
+ do {
1004
+ val2 = (ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x20 ) >> 5 ) & 0x01 ;
1005
+ if (val == val2 ) {
1006
+ pass ++ ;
1007
+ } else {
1008
+ pass = 0 ;
1009
+ val = (ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x20 ) >> 5 ) & 0x01 ;
1010
+ }
1011
+ } while ((pass < 5 ) && (count ++ < 0x10000 ));
987
1012
988
- val = ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x20 ) >> 5 ;
989
1013
return val & 1 ? 1 : 0 ;
990
1014
}
991
1015
@@ -998,7 +1022,7 @@ static void set_clock(void *i2c_priv, int clock)
998
1022
999
1023
for (i = 0 ; i < 0x10000 ; i ++ ) {
1000
1024
ujcrb7 = ((clock & 0x01 ) ? 0 : 1 );
1001
- ast_set_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0xfe , ujcrb7 );
1025
+ ast_set_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0xf4 , ujcrb7 );
1002
1026
jtemp = ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x01 );
1003
1027
if (ujcrb7 == jtemp )
1004
1028
break ;
@@ -1014,7 +1038,7 @@ static void set_data(void *i2c_priv, int data)
1014
1038
1015
1039
for (i = 0 ; i < 0x10000 ; i ++ ) {
1016
1040
ujcrb7 = ((data & 0x01 ) ? 0 : 1 ) << 2 ;
1017
- ast_set_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0xfb , ujcrb7 );
1041
+ ast_set_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0xf1 , ujcrb7 );
1018
1042
jtemp = ast_get_index_reg_mask (ast , AST_IO_CRTC_PORT , 0xb7 , 0x04 );
1019
1043
if (ujcrb7 == jtemp )
1020
1044
break ;
0 commit comments