staging: sm750fb: coding style fixes
Subsystems (2)
v3 cover staging: sm750fb: coding style fixes
Hi,
These patches are fixing coding style issues in ddk750_*i2c* files of the sm750fb driver
v3 changes:
* fix wrong variable rename in patch 12 (staging: sm750fb: ddk750_swi2c: staticize swI2C{SCL,SDA})
* fix changelong text in patch 9 (staging: sm750fb: ddk750_swi2c: staticize swI2C{SCL,SDA})
v2 changes:
* add changelog text
* change patch 5 (staging: sm750fb: ddk750_hwi2c: rename CamelCase static functions) so that ut won't add sm750_ prefix to static functions
Mike Rapoport (17):
staging: sm750fb: rename hwI2CInit to sm750_hw_i2c_init
staging: sm750fb: rename hwI2CClose to sm750_hw_i2c_close
staging: sm750fb: rename hwI2CReadReg to sm750_hw_i2c_read_reg
staging: sm750fb: rename hwI2CWriteReg to sm750_hw_i2c_write_reg
staging: sm750fb: ddk750_hwi2c: rename CamelCase static functions
staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
staging: sm750fb: rename swI2CReadReg to sm750_sw_i2c_read_reg
staging: sm750fb: rename swI2CWriteReg to sm750_sw_i2c_write_reg
staging: sm750fb: ddk750_swi2c: staticize swI2C{SCL,SDA}
staging: sm750fb: ddk750_swi2c: rename CamelCase static functions
staging: sm750fb: ddk750_hw_i2c: rename busSpeedMode
staging: sm750fb: hw_i2c_{read,write}: rename CamelCase variables
staging: sm750fb: ddk750_hwi2c: reduce amount of CamelCase
staging: sm750fb: ddk750_swi2c: rename CamelCase static variables
staging: sm750fb: ddk750_swi2c: further reduce CamelCase
staging: sm750fb: ddk750_*i2c: remove multiple blank lines
staging: sm750fb: ddk750_*i2c: shorten lines to under 80 characters
drivers/staging/sm750fb/ddk750_hwi2c.c | 109 ++++++------ drivers/staging/sm750fb/ddk750_hwi2c.h | 9 +- drivers/staging/sm750fb/ddk750_sii164.c | 8 +- drivers/staging/sm750fb/ddk750_swi2c.c | 291 ++++++++++++++++---------------- drivers/staging/sm750fb/ddk750_swi2c.h | 47 ++---- drivers/staging/sm750fb/sm750_hw.c | 10 +- 6 files changed, 228 insertions(+), 246 deletions(-)
Signature · 1 line
2.1.0
PATCH v3 1/17 staging: sm750fb: rename hwI2CInit to sm750_hw_i2c_init
Fix the checkpatch warning about CamelCase
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +1 -1
@@ -9,7 +9,7 @@#define HWI2C_WAIT_TIMEOUT 0xF0000 -int hwI2CInit ( +int sm750_hw_i2c_init (unsigned char busSpeedMode ) {
drivers/staging/sm750fb/ddk750_hwi2c.h +1 -1
@@ -2,7 +2,7 @@#define DDK750_HWI2C_H__ /* hwi2c functions */ -int hwI2CInit (unsigned char busSpeedMode); +int sm750_hw_i2c_init (unsigned char busSpeedMode);void hwI2CClose (void );unsigned char hwI2CReadReg (unsigned char deviceAddress,unsigned char registerIndex);
drivers/staging/sm750fb/ddk750_sii164.c +1 -1
@@ -130,7 +130,7 @@ long sii164InitChip(/* Initialize the i2c bus */ #ifdef USE_HW_I2C /* Use fast mode. */ -hwI2CInit (1 ); +sm750_hw_i2c_init (1 );#else swI2CInit (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA );#endif
Signature · 1 line
2.1.0
Re: [PATCH v3 01/17] staging: sm750fb: rename hwI2CInit to sm750_hw_i2c_init
Quoted 14 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/staging/sm750fb/ddk750_hwi2c.c +0
-0
drivers/staging/sm750fb/ddk750_hwi2c.c line 12
Quoted 5 lines
drivers/staging/sm750fb/ddk750_hwi2c.c +1
-1@@ -9,7 +9,7 @@#define HWI2C_WAIT_TIMEOUT 0xF0000 -int hwI2CInit( +int sm750_hw_i2c_init(
sm750_i2c_init()? Of course it's "hw", that's redundant :)
PATCH v3 2/17 staging: sm750fb: rename hwI2CClose to sm750_hw_i2c_close
In reply to Mike RapoportFix the checkpatch warning about CamelCase
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +1 -1
@@ -40,7 +40,7 @@ unsigned char busSpeedMode } -void hwI2CClose (void ) +void sm750_hw_i2c_close (void ) {unsigned int value;
drivers/staging/sm750fb/ddk750_hwi2c.h +1 -1
@@ -3,7 +3,7 @@/* hwi2c functions */ int sm750_hw_i2c_init (unsigned char busSpeedMode); -void hwI2CClose (void ); +void sm750_hw_i2c_close (void );unsigned char hwI2CReadReg (unsigned char deviceAddress,unsigned char registerIndex);int hwI2CWriteReg (unsigned char deviceAddress,unsigned char registerIndex,unsigned char data);
Signature · 1 line
2.1.0
Re: [PATCH v3 02/17] staging: sm750fb: rename hwI2CClose to sm750_hw_i2c_close
Quoted 13 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)drivers/staging/sm750fb/ddk750_hwi2c.c +0
-0
drivers/staging/sm750fb/ddk750_hwi2c.c unsigned char busSpeedMode · line 43
Quoted 5 lines
drivers/staging/sm750fb/ddk750_hwi2c.c +1
-1@@ -40,7 +40,7 @@ unsigned char busSpeedMode } -void hwI2CClose (void ) +void sm750_hw_i2c_close (void )
Same here, no need for the extra "hw_".
PATCH v3 3/17 staging: sm750fb: rename hwI2CReadReg to sm750_hw_i2c_read_reg
In reply to Mike RapoportFix the checkpatch warning about CamelCase
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +1 -1
@@ -219,7 +219,7 @@ static unsigned int hwI2CReadData(* Return Value: * Register value */ -unsigned char hwI2CReadReg ( +unsigned char sm750_hw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex )
drivers/staging/sm750fb/ddk750_hwi2c.h +1 -1
@@ -5,6 +5,6 @@int sm750_hw_i2c_init (unsigned char busSpeedMode);void sm750_hw_i2c_close (void ); -unsigned char hwI2CReadReg (unsigned char deviceAddress,unsigned char registerIndex); +unsigned char sm750_hw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex);int hwI2CWriteReg (unsigned char deviceAddress,unsigned char registerIndex,unsigned char data);#endif
drivers/staging/sm750fb/ddk750_sii164.c +1 -1
@@ -12,7 +12,7 @@#ifdef USE_HW_I2C #define i2cWriteReg hwI2CWriteReg -#define i2cReadReg hwI2CReadReg +#define i2cReadReg sm750_hw_i2c_read_reg#else #define i2cWriteReg swI2CWriteReg#define i2cReadReg swI2CReadReg
Signature · 1 line
2.1.0
Re: [PATCH v3 03/17] staging: sm750fb: rename hwI2CReadReg to sm750_hw_i2c_read_reg
Quoted 14 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)drivers/staging/sm750fb/ddk750_hwi2c.c +0
-0
drivers/staging/sm750fb/ddk750_hwi2c.c static unsigned int hwI2CReadData( · line 222
Quoted 5 lines
drivers/staging/sm750fb/ddk750_hwi2c.c +1
-1@@ -219,7 +219,7 @@ static unsigned int hwI2CReadData(* Return Value: * Register value */ -unsigned char hwI2CReadReg( +unsigned char sm750_hw_i2c_read_reg(
Same for all of these, just drop the hw_ for the whole series and resend.
thanks,
greg k-h
PATCH v3 4/17 staging: sm750fb: rename hwI2CWriteReg to sm750_hw_i2c_write_reg
In reply to Mike RapoportFix the checkpatch warning about CamelCase
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 2 +- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +1 -1
@@ -249,7 +249,7 @@ unsigned char sm750_hw_i2c_read_reg(* 0 - Success * -1 - Fail */ -int hwI2CWriteReg ( +int sm750_hw_i2c_write_reg (unsigned char deviceAddress,unsigned char registerIndex, unsigned char data
drivers/staging/sm750fb/ddk750_hwi2c.h +1 -1
@@ -6,5 +6,5 @@ int sm750_hw_i2c_init(unsigned char busSpeedMode);void sm750_hw_i2c_close (void );unsigned char sm750_hw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex); -int hwI2CWriteReg (unsigned char deviceAddress,unsigned char registerIndex,unsigned char data); +int sm750_hw_i2c_write_reg (unsigned char deviceAddress,unsigned char registerIndex,unsigned char data);#endif
drivers/staging/sm750fb/ddk750_sii164.c +1 -1
@@ -11,7 +11,7 @@#define USE_HW_I2C #ifdef USE_HW_I2C -#define i2cWriteReg hwI2CWriteReg +#define i2cWriteReg sm750_hw_i2c_write_reg#define i2cReadReg sm750_hw_i2c_read_reg#else #define i2cWriteReg swI2CWriteReg
Signature · 1 line
2.1.0
PATCH v3 5/17 staging: sm750fb: ddk750_hwi2c: rename CamelCase static functions
In reply to Mike RapoportFix the checkpatch warning about CamelCase.
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +8 -8
@@ -60,7 +60,7 @@ void sm750_hw_i2c_close(void) } -static long hwI2CWaitTXDone (void ) +static long hw_i2c_wait_tx_done (void ) {unsigned int timeout;
@@ -90,7 +90,7 @@ static long hwI2CWaitTXDone(void)* Return Value: * Total number of bytes those are actually written. */ -static unsigned int hwI2CWriteData ( +static unsigned int hw_i2c_write_data (unsigned char deviceAddress,unsigned int length, unsigned char *pBuffer
@@ -125,7 +125,7 @@ static unsigned int hwI2CWriteData(POKE32 (I2C_CTRL ,FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START ));/* Wait until the transfer is completed. */ -if (hwI2CWaitTXDone () !=0 ) +if (hw_i2c_wait_tx_done () !=0 )break ;/* Substract length */
@@ -156,7 +156,7 @@ static unsigned int hwI2CWriteData(* Return Value: * Total number of actual bytes read from the slave device */ -static unsigned int hwI2CReadData ( +static unsigned int hw_i2c_read_data (unsigned char deviceAddress,unsigned int length, unsigned char *pBuffer
@@ -187,7 +187,7 @@ static unsigned int hwI2CReadData(POKE32 (I2C_CTRL ,FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START ));/* Wait until transaction done. */ -if (hwI2CWaitTXDone () !=0 ) +if (hw_i2c_wait_tx_done () !=0 )break ;/* Save the data to the given buffer */
@@ -226,8 +226,8 @@ unsigned char sm750_hw_i2c_read_reg( {unsigned char value = (0xFF ); -if (hwI2CWriteData (deviceAddress,1 , ®isterIndex) ==1 ) -hwI2CReadData (deviceAddress,1 , &value); +if (hw_i2c_write_data (deviceAddress,1 , ®isterIndex) ==1 ) +hw_i2c_read_data (deviceAddress,1 , &value);return value; }
@@ -259,7 +259,7 @@ int sm750_hw_i2c_write_reg( value[0 ] = registerIndex; value[1 ] = data; -if (hwI2CWriteData (deviceAddress,2 , value) ==2 ) +if (hw_i2c_write_data (deviceAddress,2 , value) ==2 )return 0 ;return (-1 );
Signature · 1 line
2.1.0
PATCH v3 6/17 staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
In reply to Mike RapoportFix the checkpatch warning about CamelCase.
--- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
drivers/staging/sm750fb/ddk750_sii164.c +1 -1
@@ -132,7 +132,7 @@ long sii164InitChip(/* Use fast mode. */ sm750_hw_i2c_init (1 );#else -swI2CInit (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA ); +sm750_sw_i2c_init (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA );#endif /* Check if SII164 Chip exists */
drivers/staging/sm750fb/ddk750_swi2c.c +1 -1
@@ -386,7 +386,7 @@ static long swI2CInit_SM750LE(unsigned char i2cClkGPIO,* -1 - Fail to initialize the i2c * 0 - Success */ -long swI2CInit ( +long sm750_sw_i2c_init (unsigned char i2cClkGPIO,unsigned char i2cDataGPIO )
drivers/staging/sm750fb/ddk750_swi2c.h +1 -1
@@ -28,7 +28,7 @@* -1 - Fail to initialize the i2c * 0 - Success */ -long swI2CInit ( +long sm750_sw_i2c_init (unsigned char i2cClkGPIO,unsigned char i2cDataGPIO );
drivers/staging/sm750fb/sm750_hw.c +1 -1
@@ -169,7 +169,7 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)/* Set up GPIO for software I2C to program DVI chip in the Xilinx SP605 board, in order to have video signal. */ -swI2CInit (0 ,1 ); +sm750_sw_i2c_init (0 ,1 );/* Customer may NOT use CH7301 DVI chip, which has to be
Signature · 1 line
2.1.0
Re: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Quoted 15 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase.
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)drivers/staging/sm750fb/ddk750_sii164.c +0
-0
drivers/staging/sm750fb/ddk750_sii164.c long sii164InitChip( · line 135
Quoted 5 lines
drivers/staging/sm750fb/ddk750_sii164.c +1
-1@@ -132,7 +132,7 @@ long sii164InitChip(/* Use fast mode. */ sm750_hw_i2c_init (1 );#else -swI2CInit (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA ); +sm750_sw_i2c_init (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA );
Hm, wait, "sw_"? what is the difference between the hw and sw versions?
Re: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase.
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
Quoted 12 lines
drivers/staging/sm750fb/ddk750_sii164.c long sii164InitChip( · line 135
Quoted 10 lines
drivers/staging/sm750fb/ddk750_sii164.c +1
-1@@ -132,7 +132,7 @@ long sii164InitChip(/* Use fast mode. */ sm750_hw_i2c_init (1 );#else -swI2CInit (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA ); +sm750_sw_i2c_init (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA );Hm, wait, "
sw_"? what is the difference between the hw and sw versions?
As far as I understood, the intention for HW is for using i2c controller, and SW is for using gpio bit-bang
--
Sincerely yours,
Mike.
Re: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Quoted 25 lines · Mike Rapoport
Quoted 11 lines · Greg Kroah-Hartman
Quoted 10 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase.
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)Quoted 12 lines
drivers/staging/sm750fb/ddk750_sii164.c long sii164InitChip( · line 135
Quoted 10 lines
drivers/staging/sm750fb/ddk750_sii164.c +1
-1@@ -132,7 +132,7 @@ long sii164InitChip(/* Use fast mode. */ sm750_hw_i2c_init (1 );#else -swI2CInit (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA ); +sm750_sw_i2c_init (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA );Hm, wait, "
sw_"? what is the difference between the hw and sw versions?
Quoted 2 lines
As far as I understood, the intention for HW is for using i2c controller, and SW is for using gpio bit-bang
big-bang i2c? ick.
Ok, maybe your original choices made more sense. Can you review them again and resend if you feel they are ok? They are now gone from my queue, sorry.
thanks,
greg k-h
Sudip Mukherjee
maintainerRe: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Quoted 26 lines · Greg Kroah-Hartman
Quoted 25 lines · Mike Rapoport
Quoted 23 lines · Greg Kroah-Hartman
Quoted 15 lines · Mike Rapoport
Fix the checkpatch warning about CamelCase.
Signed-off-by Mike Rapoport <[email protected]>--- drivers/staging/sm750fb/ddk750_sii164.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)drivers/staging/sm750fb/ddk750_sii164.c +0
-0drivers/staging/sm750fb/ddk750_sii164.c long sii164InitChip( · line 135
Quoted 5 lines
drivers/staging/sm750fb/ddk750_sii164.c +1
-1@@ -132,7 +132,7 @@ long sii164InitChip(/* Use fast mode. */ sm750_hw_i2c_init (1 );#else -swI2CInit (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA ); +sm750_sw_i2c_init (DEFAULT_I2C_SCL ,DEFAULT_I2C_SDA );Hm, wait, "
sw_"? what is the difference between the hw and sw versions?
Quoted 4 lines
Quoted 2 lines
As far as I understood, the intention for HW is for using i2c controller, and SW is for using gpio bit-bang
big-bang i2c? ick.
:(
Yes, there is a special version of SM750 which uses sw i2c. SM750LE is a special version which only Huawei uses.
regards
sudip
Re: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Hi Sudip,
Quoted 9 lines · Sudip Mukherjee
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines
As far as I understood, the intention for HW is for using i2c controller, and SW is for using gpio bit-bang
big-bang i2c? ick.
:(
Yes, there is a special version of SM750 which uses sw i2c. SM750LE is a special version which only Huawei uses.
If I'm not mistaken, device variant can be identified in run-time and i2c implementation may be selected accordingly. Am I right?
Quoted 2 lines
regards
sudip
--
Sincerely yours,
Mike.
Sudip Mukherjee
maintainerRe: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Quoted 8 lines · Mike Rapoport
Hi Sudip,
Quoted 5 lines · Sudip Mukherjee
Quoted 4 lines · Greg Kroah-Hartman
Quoted 3 lines
As far as I understood, the intention for HW is for using i2c controller, and SW is for using gpio bit-bang
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
big-bang i2c? ick.
:(
Yes, there is a special version of SM750 which uses sw i2c. SM750LE is a special version which only Huawei uses.If I'm not mistaken, device variant can be identified in run-time and i2c implementation may be selected accordingly. Am I right?
Yes, that is a possibility but I do not have this SM750LE hardware, so if anything breaks in the sw i2c while trying to unify these two i2c codes, I will not be able to test.
Maybe Greg can give some idea here about how to proceed.
regards
sudip
Re: [PATCH v3 06/17] staging: sm750fb: rename swI2CInit to sm750_sw_i2c_init
Quoted 14 lines · Sudip Mukherjee
Quoted 13 lines · Mike Rapoport
Hi Sudip,
Quoted 9 lines · Sudip Mukherjee
Quoted 5 lines · Greg Kroah-Hartman
Quoted 3 lines
As far as I understood, the intention for HW is for using i2c controller, and SW is for using gpio bit-bang
big-bang i2c? ick.
:(
Yes, there is a special version of SM750 which uses sw i2c. SM750LE is a special version which only Huawei uses.
Quoted 6 lines
Quoted 2 lines
If I'm not mistaken, device variant can be identified in run-time and i2c implementation may be selected accordingly. Am I right?
Yes, that is a possibility but I do not have this SM750LE hardware, so if anything breaks in the sw i2c while trying to unify these two i2c codes, I will not be able to test.
Maybe Greg can give some idea here about how to proceed.
No idea, sorry.
PATCH v3 7/17 staging: sm750fb: rename swI2CReadReg to sm750_sw_i2c_read_reg
In reply to Mike RapoportFix the checkpatch warning about CamelCase.
--- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +1 -1
@@ -443,7 +443,7 @@ long sm750_sw_i2c_init(* Return Value: * Register value */ -unsigned char swI2CReadReg ( +unsigned char sm750_sw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex )
drivers/staging/sm750fb/ddk750_swi2c.h +1 -1
@@ -44,7 +44,7 @@ long sm750_sw_i2c_init(* Return Value: * Register value */ -unsigned char swI2CReadReg ( +unsigned char sm750_sw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex );
drivers/staging/sm750fb/sm750_hw.c +1 -1
@@ -175,7 +175,7 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)/* Customer may NOT use CH7301 DVI chip, which has to be initialized differently. */ -if (swI2CReadReg (0xec ,0x4a ) ==0x95 ) { +if (sm750_sw_i2c_read_reg (0xec ,0x4a ) ==0x95 ) {/* The following register values for CH7301 are from Chrontel app note and our experiment. */
Signature · 1 line
2.1.0
PATCH v3 8/17 staging: sm750fb: rename swI2CWriteReg to sm750_sw_i2c_write_reg
In reply to Mike RapoportFix the checkpatch warning about CamelCase.
--- drivers/staging/sm750fb/ddk750_swi2c.c | 2 +- drivers/staging/sm750fb/ddk750_swi2c.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +1 -1
@@ -483,7 +483,7 @@ unsigned char sm750_sw_i2c_read_reg(* 0 - Success * -1 - Fail */ -long swI2CWriteReg ( +long sm750_sw_i2c_write_reg (unsigned char deviceAddress,unsigned char registerIndex, unsigned char data
drivers/staging/sm750fb/ddk750_swi2c.h +1 -1
@@ -62,7 +62,7 @@ unsigned char sm750_sw_i2c_read_reg(* 0 - Success * -1 - Fail */ -long swI2CWriteReg ( +long sm750_sw_i2c_write_reg (unsigned char deviceAddress,unsigned char registerIndex, unsigned char data
drivers/staging/sm750fb/sm750_hw.c +3 -3
@@ -180,9 +180,9 @@ int hw_sm750_inithw(struct lynx_share *share, struct pci_dev *pdev)Chrontel app note and our experiment. */ pr_info ("yes,CH7301 DVI chip found\n" ); -swI2CWriteReg (0xec ,0x1d ,0x16 ); -swI2CWriteReg (0xec ,0x21 ,0x9 ); -swI2CWriteReg (0xec ,0x49 ,0xC0 ); +sm750_sw_i2c_write_reg (0xec ,0x1d ,0x16 ); +sm750_sw_i2c_write_reg (0xec ,0x21 ,0x9 ); +sm750_sw_i2c_write_reg (0xec ,0x49 ,0xC0 );pr_info ("okay,CH7301 DVI chip setup done\n" ); } }
Signature · 1 line
2.1.0
PATCH v3 9/17 staging: sm750fb: ddk750_swi2c: staticize swI2C{SCL,SDA}
In reply to Mike RapoportswI2C{SCL,SDA} are not used outside ddk750_swi2c, make them static
--- drivers/staging/sm750fb/ddk750_swi2c.c | 4 ++-- drivers/staging/sm750fb/ddk750_swi2c.h | 21 --------------------- 2 files changed, 2 insertions(+), 23 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +2 -2
@@ -119,7 +119,7 @@ static void swI2CWait(void)* signal because the i2c will fail when other device try to drive the * signal due to SM50x will drive the signal to always high. */ -void swI2CSCL (unsigned char value) +static void swI2CSCL (unsigned char value) {unsigned long ulGPIOData;unsigned long ulGPIODirection;
@@ -153,7 +153,7 @@ void swI2CSCL(unsigned char value)* signal because the i2c will fail when other device try to drive the * signal due to SM50x will drive the signal to always high. */ -void swI2CSDA (unsigned char value) +static void swI2CSDA (unsigned char value) {unsigned long ulGPIOData;unsigned long ulGPIODirection;
drivers/staging/sm750fb/ddk750_swi2c.h +0 -21
@@ -68,25 +68,4 @@ long sm750_sw_i2c_write_reg(unsigned char data ); -/* -* These two functions toggle the data on the SCL and SDA I2C lines. -* The use of these two functions is not recommended unless it is necessary. -*/ - -/* -* This function set/reset the SCL GPIO pin -* -* Parameters: -* value - Bit value to set to the SCL or SDA (0 = low, 1 = high) -*/ -void swI2CSCL (unsigned char value); - -/* -* This function set/reset the SDA GPIO pin -* -* Parameters: -* value - Bit value to set to the SCL or SDA (0 = low, 1 = high) -*/ -void swI2CSDA (unsigned char value); -#endif /* _SWI2C_H_ */
Signature · 1 line
2.1.0
PATCH v3 10/17 staging: sm750fb: ddk750_swi2c: rename CamelCase static functions
In reply to Mike RapoportFix the checkpatch warning about CamelCase.
--- drivers/staging/sm750fb/ddk750_swi2c.c | 116 ++++++++++++++++----------------- 1 file changed, 58 insertions(+), 58 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +58 -58
@@ -82,7 +82,7 @@ static unsigned long g_i2cDataGPIODataDirReg = GPIO_DATA_DIRECTION;/* * This function puts a delay between command */ -static void swI2CWait (void ) +static void sw_i2c_wait (void ) {/* find a bug: * peekIO method works well before suspend/resume
@@ -119,7 +119,7 @@ static void swI2CWait(void)* signal because the i2c will fail when other device try to drive the * signal due to SM50x will drive the signal to always high. */ -static void swI2CSCL (unsigned char value) +static void sw_i2c_scl (unsigned char value) {unsigned long ulGPIOData;unsigned long ulGPIODirection;
@@ -153,7 +153,7 @@ static void swI2CSCL(unsigned char value)* signal because the i2c will fail when other device try to drive the * signal due to SM50x will drive the signal to always high. */ -static void swI2CSDA (unsigned char value) +static void sw_i2c_sda (unsigned char value) {unsigned long ulGPIOData;unsigned long ulGPIODirection;
@@ -181,7 +181,7 @@ static void swI2CSDA(unsigned char value)* Return Value: * The SDA data bit sent by the Slave */ -static unsigned char swI2CReadSDA (void ) +static unsigned char sw_i2c_read_sda (void ) {unsigned long ulGPIODirection;unsigned long ulGPIOData;
@@ -204,7 +204,7 @@ static unsigned char swI2CReadSDA(void)/* * This function sends ACK signal */ -static void swI2CAck (void ) +static void sw_i2c_ack (void ) {return ;/* Single byte read is ok without it. */ }
@@ -212,23 +212,23 @@ static void swI2CAck(void)/* * This function sends the start command to the slave device */ -static void swI2CStart (void ) +static void sw_i2c_start (void ) {/* Start I2C */ -swI2CSDA (1 ); -swI2CSCL (1 ); -swI2CSDA (0 ); +sw_i2c_sda (1 ); +sw_i2c_scl (1 ); +sw_i2c_sda (0 ); }/* * This function sends the stop command to the slave device */ -static void swI2CStop (void ) +static void sw_i2c_stop (void ) {/* Stop the I2C */ -swI2CSCL (1 ); -swI2CSDA (0 ); -swI2CSDA (1 ); +sw_i2c_scl (1 ); +sw_i2c_sda (0 ); +sw_i2c_sda (1 ); }/*
@@ -241,7 +241,7 @@ static void swI2CStop(void)* 0 - Success * -1 - Fail to write byte */ -static long swI2CWriteByte (unsigned char data) +static long sw_i2c_write_byte (unsigned char data) {unsigned char value = data;int i;
@@ -249,47 +249,47 @@ static long swI2CWriteByte(unsigned char data)/* Sending the data bit by bit */ for (i =0 ; i <8 ; i++) {/* Set SCL to low */ -swI2CSCL (0 ); +sw_i2c_scl (0 );/* Send data bit */ if ((value &0x80 ) !=0 ) -swI2CSDA (1 ); +sw_i2c_sda (1 );else -swI2CSDA (0 ); +sw_i2c_sda (0 ); -swI2CWait (); +sw_i2c_wait ();/* Toggle clk line to one */ -swI2CSCL (1 ); -swI2CWait (); +sw_i2c_scl (1 ); +sw_i2c_wait ();/* Shift byte to be sent */ value = value <<1 ; }/* Set the SCL Low and SDA High (prepare to get input) */ -swI2CSCL (0 ); -swI2CSDA (1 ); +sw_i2c_scl (0 ); +sw_i2c_sda (1 );/* Set the SCL High for ack */ -swI2CWait (); -swI2CSCL (1 ); -swI2CWait (); +sw_i2c_wait (); +sw_i2c_scl (1 ); +sw_i2c_wait ();/* Read SDA, until SDA==0 */ for (i =0 ; i <0xff ; i++) { -if (!swI2CReadSDA ()) +if (!sw_i2c_read_sda ())break ; -swI2CSCL (0 ); -swI2CWait (); -swI2CSCL (1 ); -swI2CWait (); +sw_i2c_scl (0 ); +sw_i2c_wait (); +sw_i2c_scl (1 ); +sw_i2c_wait (); }/* Set the SCL Low and SDA High */ -swI2CSCL (0 ); -swI2CSDA (1 ); +sw_i2c_scl (0 ); +sw_i2c_sda (1 );if (i <0xff )return 0 ;
@@ -307,31 +307,31 @@ static long swI2CWriteByte(unsigned char data)* Return Value: * One byte data read from the Slave device */ -static unsigned char swI2CReadByte (unsigned char ack) +static unsigned char sw_i2c_read_byte (unsigned char ack) {int i;unsigned char data =0 ;for (i =7 ; i >=0 ; i--) {/* Set the SCL to Low and SDA to High (Input) */ -swI2CSCL (0 ); -swI2CSDA (1 ); -swI2CWait (); +sw_i2c_scl (0 ); +sw_i2c_sda (1 ); +sw_i2c_wait ();/* Set the SCL High */ -swI2CSCL (1 ); -swI2CWait (); +sw_i2c_scl (1 ); +sw_i2c_wait ();/* Read data bits from SDA */ - data |= (swI2CReadSDA () << i); + data |= (sw_i2c_read_sda () << i); }if (ack) -swI2CAck (); +sw_i2c_ack ();/* Set the SCL Low and SDA High */ -swI2CSCL (0 ); -swI2CSDA (1 ); +sw_i2c_scl (0 ); +sw_i2c_sda (1 );return data; }
@@ -347,7 +347,7 @@ static unsigned char swI2CReadByte(unsigned char ack)* -1 - Fail to initialize the i2c * 0 - Success */ -static long swI2CInit_SM750LE (unsigned char i2cClkGPIO, +static long sm750le_i2c_init (unsigned char i2cClkGPIO,unsigned char i2cDataGPIO) {int i;
@@ -370,7 +370,7 @@ static long swI2CInit_SM750LE(unsigned char i2cClkGPIO,/* Clear the i2c lines. */ for (i =0 ; i <9 ; i++) -swI2CStop (); +sw_i2c_stop ();return 0 ; }
@@ -398,7 +398,7 @@ long sm750_sw_i2c_init(return -1 ;if (getChipType () ==SM750LE ) -return swI2CInit_SM750LE (i2cClkGPIO, i2cDataGPIO); +return sm750le_i2c_init (i2cClkGPIO, i2cDataGPIO);/* Initialize the GPIO pin for the i2c Clock Register */ g_i2cClkGPIOMuxReg =GPIO_MUX ;
@@ -427,7 +427,7 @@ long sm750_sw_i2c_init(/* Clear the i2c lines. */ for (i =0 ; i <9 ; i++) -swI2CStop (); +sw_i2c_stop ();return 0 ; }
@@ -451,21 +451,21 @@ unsigned char sm750_sw_i2c_read_reg(unsigned char data;/* Send the Start signal */ -swI2CStart (); +sw_i2c_start ();/* Send the device address */ -swI2CWriteByte (deviceAddress); +sw_i2c_write_byte (deviceAddress);/* Send the register index */ -swI2CWriteByte (registerIndex); +sw_i2c_write_byte (registerIndex);/* Get the bus again and get the data from the device read address */ -swI2CStart (); -swI2CWriteByte (deviceAddress +1 ); - data =swI2CReadByte (1 ); +sw_i2c_start (); +sw_i2c_write_byte (deviceAddress +1 ); + data =sw_i2c_read_byte (1 );/* Stop swI2C and release the bus */ -swI2CStop (); +sw_i2c_stop ();return data; }
@@ -492,19 +492,19 @@ long sm750_sw_i2c_write_reg(long returnValue =0 ;/* Send the Start signal */ -swI2CStart (); +sw_i2c_start ();/* Send the device address and read the data. All should return success in order for the writing processed to be successful */ -if ((swI2CWriteByte (deviceAddress) !=0 ) || - (swI2CWriteByte (registerIndex) !=0 ) || - (swI2CWriteByte (data) !=0 )) { +if ((sw_i2c_write_byte (deviceAddress) !=0 ) || + (sw_i2c_write_byte (registerIndex) !=0 ) || + (sw_i2c_write_byte (data) !=0 )) { returnValue =-1 ; }/* Stop i2c and release the bus */ -swI2CStop (); +sw_i2c_stop ();return returnValue; }
Signature · 1 line
2.1.0
PATCH v3 11/17 staging: sm750fb: ddk750_hw_i2c: rename busSpeedMode
In reply to Mike Rapoportrename CamelCase parameter in sm750_hw_i2c_init()
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 4 ++-- drivers/staging/sm750fb/ddk750_hwi2c.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +2 -2
@@ -10,7 +10,7 @@int sm750_hw_i2c_init ( -unsigned char busSpeedMode +unsigned char bus_speed_mode ) {unsigned int value;
@@ -29,7 +29,7 @@ unsigned char busSpeedMode/* Enable the I2C Controller and set the bus speed mode */ value =PEEK32 (I2C_CTRL ); -if (busSpeedMode ==0 ) +if (bus_speed_mode ==0 ) value =FIELD_SET (value,I2C_CTRL ,MODE ,STANDARD );else value =FIELD_SET (value,I2C_CTRL ,MODE ,FAST );
drivers/staging/sm750fb/ddk750_hwi2c.h +1 -1
@@ -2,7 +2,7 @@#define DDK750_HWI2C_H__ /* hwi2c functions */ -int sm750_hw_i2c_init (unsigned char busSpeedMode); +int sm750_hw_i2c_init (unsigned char bus_speed_mode);void sm750_hw_i2c_close (void );unsigned char sm750_hw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex);
Signature · 1 line
2.1.0
PATCH v3 12/17 staging: sm750fb: hw_i2c_{read,write}: rename CamelCase variables
In reply to Mike RapoportRename longCamelCase variables deviceAddress and registerIndex to shorter addr and reg
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 16 ++++++++-------- drivers/staging/sm750fb/ddk750_hwi2c.h | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +8 -8
@@ -220,14 +220,14 @@ static unsigned int hw_i2c_read_data(* Register value */ unsigned char sm750_hw_i2c_read_reg ( -unsigned char deviceAddress, -unsigned char registerIndex +unsigned char addr, +unsigned char reg ) {unsigned char value = (0xFF ); -if (hw_i2c_write_data (deviceAddress,1 , ®isterIndex) ==1 ) -hw_i2c_read_data (deviceAddress,1 , &value); +if (hw_i2c_write_data (addr,1 , ®) ==1 ) +hw_i2c_read_data (addr,1 , &value);return value; }
@@ -250,16 +250,16 @@ unsigned char sm750_hw_i2c_read_reg(* -1 - Fail */ int sm750_hw_i2c_write_reg ( -unsigned char deviceAddress, -unsigned char registerIndex, +unsigned char addr, +unsigned char reg,unsigned char data ) {unsigned char value[2 ]; - value[0 ] = registerIndex; + value[0 ] = reg; value[1 ] = data; -if (hw_i2c_write_data (deviceAddress,2 , value) ==2 ) +if (hw_i2c_write_data (addr,2 , value) ==2 )return 0 ;return (-1 );
drivers/staging/sm750fb/ddk750_hwi2c.h +2 -2
@@ -5,6 +5,6 @@int sm750_hw_i2c_init (unsigned char bus_speed_mode);void sm750_hw_i2c_close (void ); -unsigned char sm750_hw_i2c_read_reg (unsigned char deviceAddress,unsigned char registerIndex); -int sm750_hw_i2c_write_reg (unsigned char deviceAddress,unsigned char registerIndex,unsigned char data); +unsigned char sm750_hw_i2c_read_reg (unsigned char addr,unsigned char reg); +int sm750_hw_i2c_write_reg (unsigned char addr,unsigned char reg,unsigned char data);#endif
Signature · 1 line
2.1.0
PATCH v3 13/17 staging: sm750fb: ddk750_hwi2c: reduce amount of CamelCase
In reply to Mike RapoportRename camel case variables deviceAddress, pBuffer and totalBytes to addr, buf and total_bytes respectively in sm750_hw_i2c_{read,write}_data functions.
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +18 -18
@@ -82,25 +82,25 @@ static long hw_i2c_wait_tx_done(void)* This function writes data to the i2c slave device registers. * * Parameters: -* deviceAddress - i2c Slave device address +* addr - i2c Slave device address * length - Total number of bytes to be written to the device -* pBuffer - The buffer that contains the data to be written to the +* buf - The buffer that contains the data to be written to the * i2c device. * * Return Value: * Total number of bytes those are actually written. */ static unsigned int hw_i2c_write_data ( -unsigned char deviceAddress, +unsigned char addr,unsigned int length, -unsigned char *pBuffer +unsigned char *buf ) {unsigned char count, i; -unsigned int totalBytes =0 ; +unsigned int total_bytes =0 ;/* Set the Device Address */ -POKE32 (I2C_SLAVE_ADDRESS , deviceAddress & ~0x01 ); +POKE32 (I2C_SLAVE_ADDRESS , addr & ~0x01 );/* Write data. * Note:
@@ -119,7 +119,7 @@ static unsigned int hw_i2c_write_data(/* Move the data to the I2C data register */ for (i =0 ; i <= count; i++) -POKE32 (I2C_DATA0 + i, *pBuffer++); +POKE32 (I2C_DATA0 + i, *buf++);/* Start the I2C */ POKE32 (I2C_CTRL ,FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START ));
@@ -132,11 +132,11 @@ static unsigned int hw_i2c_write_data( length -= (count +1 );/* Total byte written */ - totalBytes += (count +1 ); + total_bytes += (count +1 ); }while (length >0 ); -return totalBytes; +return total_bytes; }
@@ -147,9 +147,9 @@ static unsigned int hw_i2c_write_data(* in the given buffer * * Parameters: -* deviceAddress - i2c Slave device address +* addr - i2c Slave device address * length - Total number of bytes to be read -* pBuffer - Pointer to a buffer to be filled with the data read +* buf - Pointer to a buffer to be filled with the data read * from the slave device. It has to be the same size as the * length to make sure that it can keep all the data read. *
@@ -157,16 +157,16 @@ static unsigned int hw_i2c_write_data(* Total number of actual bytes read from the slave device */ static unsigned int hw_i2c_read_data ( -unsigned char deviceAddress, +unsigned char addr,unsigned int length, -unsigned char *pBuffer +unsigned char *buf ) {unsigned char count, i; -unsigned int totalBytes =0 ; +unsigned int total_bytes =0 ;/* Set the Device Address */ -POKE32 (I2C_SLAVE_ADDRESS , deviceAddress |0x01 ); +POKE32 (I2C_SLAVE_ADDRESS , addr |0x01 );/* Read data and save them to the buffer. * Note:
@@ -192,17 +192,17 @@ static unsigned int hw_i2c_read_data(/* Save the data to the given buffer */ for (i =0 ; i <= count; i++) - *pBuffer++ =PEEK32 (I2C_DATA0 + i); + *buf++ =PEEK32 (I2C_DATA0 + i);/* Substract length by 16 */ length -= (count +1 );/* Number of bytes read. */ - totalBytes += (count +1 ); + total_bytes += (count +1 ); }while (length >0 ); -return totalBytes; +return total_bytes; }
Signature · 1 line
2.1.0
PATCH v3 14/17 staging: sm750fb: ddk750_swi2c: rename CamelCase static variables
In reply to Mike RapoportRename static variables defining I2C GPIO pins and their control registers from CamelCase.
--- drivers/staging/sm750fb/ddk750_swi2c.c | 96 +++++++++++++++++----------------- 1 file changed, 48 insertions(+), 48 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +48 -48
@@ -55,8 +55,8 @@******************************************************************/ /* GPIO pins used for this I2C. It ranges from 0 to 63. */ -static unsigned char g_i2cClockGPIO =DEFAULT_I2C_SCL ; -static unsigned char g_i2cDataGPIO =DEFAULT_I2C_SDA ; +static unsigned char sw_i2c_clk_gpio =DEFAULT_I2C_SCL ; +static unsigned char sw_i2c_data_gpio =DEFAULT_I2C_SDA ;/* * Below is the variable declaration for the GPIO pin register usage
@@ -70,14 +70,14 @@ static unsigned char g_i2cDataGPIO = DEFAULT_I2C_SDA;*/ /* i2c Clock GPIO Register usage */ -static unsigned long g_i2cClkGPIOMuxReg =GPIO_MUX ; -static unsigned long g_i2cClkGPIODataReg =GPIO_DATA ; -static unsigned long g_i2cClkGPIODataDirReg =GPIO_DATA_DIRECTION ; +static unsigned long sw_i2c_clk_gpio_mux_reg =GPIO_MUX ; +static unsigned long sw_i2c_clk_gpio_data_reg =GPIO_DATA ; +static unsigned long sw_i2c_clk_gpio_data_dir_reg =GPIO_DATA_DIRECTION ;/* i2c Data GPIO Register usage */ -static unsigned long g_i2cDataGPIOMuxReg =GPIO_MUX ; -static unsigned long g_i2cDataGPIODataReg =GPIO_DATA ; -static unsigned long g_i2cDataGPIODataDirReg =GPIO_DATA_DIRECTION ; +static unsigned long sw_i2c_data_gpio_mux_reg =GPIO_MUX ; +static unsigned long sw_i2c_data_gpio_data_reg =GPIO_DATA ; +static unsigned long sw_i2c_data_gpio_data_dir_reg =GPIO_DATA_DIRECTION ;/* * This function puts a delay between command
@@ -124,20 +124,20 @@ static void sw_i2c_scl(unsigned char value)unsigned long ulGPIOData;unsigned long ulGPIODirection; - ulGPIODirection =PEEK32 (g_i2cClkGPIODataDirReg); + ulGPIODirection =PEEK32 (sw_i2c_clk_gpio_data_dir_reg);if (value) {/* High */ /* Set direction as input. This will automatically pull the signal up. */ - ulGPIODirection &= ~(1 << g_i2cClockGPIO); -POKE32 (g_i2cClkGPIODataDirReg, ulGPIODirection); + ulGPIODirection &= ~(1 << sw_i2c_clk_gpio); +POKE32 (sw_i2c_clk_gpio_data_dir_reg, ulGPIODirection); }else {/* Low */ /* Set the signal down */ - ulGPIOData =PEEK32 (g_i2cClkGPIODataReg); - ulGPIOData &= ~(1 << g_i2cClockGPIO); -POKE32 (g_i2cClkGPIODataReg, ulGPIOData); + ulGPIOData =PEEK32 (sw_i2c_clk_gpio_data_reg); + ulGPIOData &= ~(1 << sw_i2c_clk_gpio); +POKE32 (sw_i2c_clk_gpio_data_reg, ulGPIOData);/* Set direction as output */ - ulGPIODirection |= (1 << g_i2cClockGPIO); -POKE32 (g_i2cClkGPIODataDirReg, ulGPIODirection); + ulGPIODirection |= (1 << sw_i2c_clk_gpio); +POKE32 (sw_i2c_clk_gpio_data_dir_reg, ulGPIODirection); } }
@@ -158,20 +158,20 @@ static void sw_i2c_sda(unsigned char value)unsigned long ulGPIOData;unsigned long ulGPIODirection; - ulGPIODirection =PEEK32 (g_i2cDataGPIODataDirReg); + ulGPIODirection =PEEK32 (sw_i2c_data_gpio_data_dir_reg);if (value) {/* High */ /* Set direction as input. This will automatically pull the signal up. */ - ulGPIODirection &= ~(1 << g_i2cDataGPIO); -POKE32 (g_i2cDataGPIODataDirReg, ulGPIODirection); + ulGPIODirection &= ~(1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_dir_reg, ulGPIODirection); }else {/* Low */ /* Set the signal down */ - ulGPIOData =PEEK32 (g_i2cDataGPIODataReg); - ulGPIOData &= ~(1 << g_i2cDataGPIO); -POKE32 (g_i2cDataGPIODataReg, ulGPIOData); + ulGPIOData =PEEK32 (sw_i2c_data_gpio_data_reg); + ulGPIOData &= ~(1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_reg, ulGPIOData);/* Set direction as output */ - ulGPIODirection |= (1 << g_i2cDataGPIO); -POKE32 (g_i2cDataGPIODataDirReg, ulGPIODirection); + ulGPIODirection |= (1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_dir_reg, ulGPIODirection); } }
@@ -187,15 +187,15 @@ static unsigned char sw_i2c_read_sda(void)unsigned long ulGPIOData;/* Make sure that the direction is input (High) */ - ulGPIODirection =PEEK32 (g_i2cDataGPIODataDirReg); -if ((ulGPIODirection & (1 << g_i2cDataGPIO)) != (~(1 << g_i2cDataGPIO))) { - ulGPIODirection &= ~(1 << g_i2cDataGPIO); -POKE32 (g_i2cDataGPIODataDirReg, ulGPIODirection); + ulGPIODirection =PEEK32 (sw_i2c_data_gpio_data_dir_reg); +if ((ulGPIODirection & (1 << sw_i2c_data_gpio)) != (~(1 << sw_i2c_data_gpio))) { + ulGPIODirection &= ~(1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_dir_reg, ulGPIODirection); }/* Now read the SDA line */ - ulGPIOData =PEEK32 (g_i2cDataGPIODataReg); -if (ulGPIOData & (1 << g_i2cDataGPIO)) + ulGPIOData =PEEK32 (sw_i2c_data_gpio_data_reg); +if (ulGPIOData & (1 << sw_i2c_data_gpio))return 1 ;else return 0 ;
@@ -353,18 +353,18 @@ static long sm750le_i2c_init(unsigned char i2cClkGPIO,int i;/* Initialize the GPIO pin for the i2c Clock Register */ - g_i2cClkGPIODataReg =GPIO_DATA_SM750LE ; - g_i2cClkGPIODataDirReg =GPIO_DATA_DIRECTION_SM750LE ; + sw_i2c_clk_gpio_data_reg =GPIO_DATA_SM750LE ; + sw_i2c_clk_gpio_data_dir_reg =GPIO_DATA_DIRECTION_SM750LE ;/* Initialize the Clock GPIO Offset */ - g_i2cClockGPIO = i2cClkGPIO; + sw_i2c_clk_gpio = i2cClkGPIO;/* Initialize the GPIO pin for the i2c Data Register */ - g_i2cDataGPIODataReg =GPIO_DATA_SM750LE ; - g_i2cDataGPIODataDirReg =GPIO_DATA_DIRECTION_SM750LE ; + sw_i2c_data_gpio_data_reg =GPIO_DATA_SM750LE ; + sw_i2c_data_gpio_data_dir_reg =GPIO_DATA_DIRECTION_SM750LE ;/* Initialize the Data GPIO Offset */ - g_i2cDataGPIO = i2cDataGPIO; + sw_i2c_data_gpio = i2cDataGPIO;/* Note that SM750LE don't have GPIO MUX and power is always on */
@@ -401,26 +401,26 @@ long sm750_sw_i2c_init(return sm750le_i2c_init (i2cClkGPIO, i2cDataGPIO);/* Initialize the GPIO pin for the i2c Clock Register */ - g_i2cClkGPIOMuxReg =GPIO_MUX ; - g_i2cClkGPIODataReg =GPIO_DATA ; - g_i2cClkGPIODataDirReg =GPIO_DATA_DIRECTION ; + sw_i2c_clk_gpio_mux_reg =GPIO_MUX ; + sw_i2c_clk_gpio_data_reg =GPIO_DATA ; + sw_i2c_clk_gpio_data_dir_reg =GPIO_DATA_DIRECTION ;/* Initialize the Clock GPIO Offset */ - g_i2cClockGPIO = i2cClkGPIO; + sw_i2c_clk_gpio = i2cClkGPIO;/* Initialize the GPIO pin for the i2c Data Register */ - g_i2cDataGPIOMuxReg =GPIO_MUX ; - g_i2cDataGPIODataReg =GPIO_DATA ; - g_i2cDataGPIODataDirReg =GPIO_DATA_DIRECTION ; + sw_i2c_data_gpio_mux_reg =GPIO_MUX ; + sw_i2c_data_gpio_data_reg =GPIO_DATA ; + sw_i2c_data_gpio_data_dir_reg =GPIO_DATA_DIRECTION ;/* Initialize the Data GPIO Offset */ - g_i2cDataGPIO = i2cDataGPIO; + sw_i2c_data_gpio = i2cDataGPIO;/* Enable the GPIO pins for the i2c Clock and Data (GPIO MUX) */ -POKE32 (g_i2cClkGPIOMuxReg, -PEEK32 (g_i2cClkGPIOMuxReg) & ~(1 << g_i2cClockGPIO)); -POKE32 (g_i2cDataGPIOMuxReg, -PEEK32 (g_i2cDataGPIOMuxReg) & ~(1 << g_i2cDataGPIO)); +POKE32 (sw_i2c_clk_gpio_mux_reg, +PEEK32 (sw_i2c_clk_gpio_mux_reg) & ~(1 << sw_i2c_clk_gpio)); +POKE32 (sw_i2c_data_gpio_mux_reg, +PEEK32 (sw_i2c_data_gpio_mux_reg) & ~(1 << sw_i2c_data_gpio));/* Enable GPIO power */ enableGPIO (1 );
Signature · 1 line
2.1.0
PATCH v3 15/17 staging: sm750fb: ddk750_swi2c: further reduce CamelCase
In reply to Mike RapoportRename remaining CamelCase variables
--- drivers/staging/sm750fb/ddk750_swi2c.c | 122 ++++++++++++++++----------------- drivers/staging/sm750fb/ddk750_swi2c.h | 20 +++--- 2 files changed, 71 insertions(+), 71 deletions(-)
drivers/staging/sm750fb/ddk750_swi2c.c +61 -61
@@ -98,11 +98,11 @@ static void sw_i2c_wait(void)*/ while (peekIO (0x3ce ,0x61 ) &0x10 );#else -int i, Temp; +int i, tmp;for (i =0 ; i <600 ; i++) { - Temp = i; - Temp += i; + tmp = i; + tmp += i; }#endif }
@@ -121,23 +121,23 @@ static void sw_i2c_wait(void)*/ static void sw_i2c_scl (unsigned char value) { -unsigned long ulGPIOData; -unsigned long ulGPIODirection; +unsigned long gpio_data; +unsigned long gpio_dir; - ulGPIODirection =PEEK32 (sw_i2c_clk_gpio_data_dir_reg); + gpio_dir =PEEK32 (sw_i2c_clk_gpio_data_dir_reg);if (value) {/* High */ /* Set direction as input. This will automatically pull the signal up. */ - ulGPIODirection &= ~(1 << sw_i2c_clk_gpio); -POKE32 (sw_i2c_clk_gpio_data_dir_reg, ulGPIODirection); + gpio_dir &= ~(1 << sw_i2c_clk_gpio); +POKE32 (sw_i2c_clk_gpio_data_dir_reg, gpio_dir); }else {/* Low */ /* Set the signal down */ - ulGPIOData =PEEK32 (sw_i2c_clk_gpio_data_reg); - ulGPIOData &= ~(1 << sw_i2c_clk_gpio); -POKE32 (sw_i2c_clk_gpio_data_reg, ulGPIOData); + gpio_data =PEEK32 (sw_i2c_clk_gpio_data_reg); + gpio_data &= ~(1 << sw_i2c_clk_gpio); +POKE32 (sw_i2c_clk_gpio_data_reg, gpio_data);/* Set direction as output */ - ulGPIODirection |= (1 << sw_i2c_clk_gpio); -POKE32 (sw_i2c_clk_gpio_data_dir_reg, ulGPIODirection); + gpio_dir |= (1 << sw_i2c_clk_gpio); +POKE32 (sw_i2c_clk_gpio_data_dir_reg, gpio_dir); } }
@@ -155,23 +155,23 @@ static void sw_i2c_scl(unsigned char value)*/ static void sw_i2c_sda (unsigned char value) { -unsigned long ulGPIOData; -unsigned long ulGPIODirection; +unsigned long gpio_data; +unsigned long gpio_dir; - ulGPIODirection =PEEK32 (sw_i2c_data_gpio_data_dir_reg); + gpio_dir =PEEK32 (sw_i2c_data_gpio_data_dir_reg);if (value) {/* High */ /* Set direction as input. This will automatically pull the signal up. */ - ulGPIODirection &= ~(1 << sw_i2c_data_gpio); -POKE32 (sw_i2c_data_gpio_data_dir_reg, ulGPIODirection); + gpio_dir &= ~(1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_dir_reg, gpio_dir); }else {/* Low */ /* Set the signal down */ - ulGPIOData =PEEK32 (sw_i2c_data_gpio_data_reg); - ulGPIOData &= ~(1 << sw_i2c_data_gpio); -POKE32 (sw_i2c_data_gpio_data_reg, ulGPIOData); + gpio_data =PEEK32 (sw_i2c_data_gpio_data_reg); + gpio_data &= ~(1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_reg, gpio_data);/* Set direction as output */ - ulGPIODirection |= (1 << sw_i2c_data_gpio); -POKE32 (sw_i2c_data_gpio_data_dir_reg, ulGPIODirection); + gpio_dir |= (1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_dir_reg, gpio_dir); } }
@@ -183,19 +183,19 @@ static void sw_i2c_sda(unsigned char value)*/ static unsigned char sw_i2c_read_sda (void ) { -unsigned long ulGPIODirection; -unsigned long ulGPIOData; +unsigned long gpio_dir; +unsigned long gpio_data;/* Make sure that the direction is input (High) */ - ulGPIODirection =PEEK32 (sw_i2c_data_gpio_data_dir_reg); -if ((ulGPIODirection & (1 << sw_i2c_data_gpio)) != (~(1 << sw_i2c_data_gpio))) { - ulGPIODirection &= ~(1 << sw_i2c_data_gpio); -POKE32 (sw_i2c_data_gpio_data_dir_reg, ulGPIODirection); + gpio_dir =PEEK32 (sw_i2c_data_gpio_data_dir_reg); +if ((gpio_dir & (1 << sw_i2c_data_gpio)) != (~(1 << sw_i2c_data_gpio))) { + gpio_dir &= ~(1 << sw_i2c_data_gpio); +POKE32 (sw_i2c_data_gpio_data_dir_reg, gpio_dir); }/* Now read the SDA line */ - ulGPIOData =PEEK32 (sw_i2c_data_gpio_data_reg); -if (ulGPIOData & (1 << sw_i2c_data_gpio)) + gpio_data =PEEK32 (sw_i2c_data_gpio_data_reg); +if (gpio_data & (1 << sw_i2c_data_gpio))return 1 ;else return 0 ;
@@ -340,15 +340,15 @@ static unsigned char sw_i2c_read_byte(unsigned char ack)* This function initializes GPIO port for SW I2C communication. * * Parameters: -* i2cClkGPIO - The GPIO pin to be used as i2c SCL -* i2cDataGPIO - The GPIO pin to be used as i2c SDA +* clk_gpio - The GPIO pin to be used as i2c SCL +* data_gpio - The GPIO pin to be used as i2c SDA * * Return Value: * -1 - Fail to initialize the i2c * 0 - Success */ -static long sm750le_i2c_init (unsigned char i2cClkGPIO, -unsigned char i2cDataGPIO) +static long sm750le_i2c_init (unsigned char clk_gpio, +unsigned char data_gpio) {int i;
@@ -357,14 +357,14 @@ static long sm750le_i2c_init(unsigned char i2cClkGPIO, sw_i2c_clk_gpio_data_dir_reg =GPIO_DATA_DIRECTION_SM750LE ;/* Initialize the Clock GPIO Offset */ - sw_i2c_clk_gpio = i2cClkGPIO; + sw_i2c_clk_gpio = clk_gpio;/* Initialize the GPIO pin for the i2c Data Register */ sw_i2c_data_gpio_data_reg =GPIO_DATA_SM750LE ; sw_i2c_data_gpio_data_dir_reg =GPIO_DATA_DIRECTION_SM750LE ;/* Initialize the Data GPIO Offset */ - sw_i2c_data_gpio = i2cDataGPIO; + sw_i2c_data_gpio = data_gpio;/* Note that SM750LE don't have GPIO MUX and power is always on */
@@ -379,26 +379,26 @@ static long sm750le_i2c_init(unsigned char i2cClkGPIO,* This function initializes the i2c attributes and bus * * Parameters: -* i2cClkGPIO - The GPIO pin to be used as i2c SCL -* i2cDataGPIO - The GPIO pin to be used as i2c SDA +* clk_gpio - The GPIO pin to be used as i2c SCL +* data_gpio - The GPIO pin to be used as i2c SDA * * Return Value: * -1 - Fail to initialize the i2c * 0 - Success */ long sm750_sw_i2c_init ( -unsigned char i2cClkGPIO, -unsigned char i2cDataGPIO +unsigned char clk_gpio, +unsigned char data_gpio ) {int i;/* Return 0 if the GPIO pins to be used is out of range. The range is only from [0..63] */ -if ((i2cClkGPIO >31 ) || (i2cDataGPIO >31 )) +if ((clk_gpio >31 ) || (data_gpio >31 ))return -1 ;if (getChipType () ==SM750LE ) -return sm750le_i2c_init (i2cClkGPIO, i2cDataGPIO); +return sm750le_i2c_init (clk_gpio, data_gpio);/* Initialize the GPIO pin for the i2c Clock Register */ sw_i2c_clk_gpio_mux_reg =GPIO_MUX ;
@@ -406,7 +406,7 @@ long sm750_sw_i2c_init( sw_i2c_clk_gpio_data_dir_reg =GPIO_DATA_DIRECTION ;/* Initialize the Clock GPIO Offset */ - sw_i2c_clk_gpio = i2cClkGPIO; + sw_i2c_clk_gpio = clk_gpio;/* Initialize the GPIO pin for the i2c Data Register */ sw_i2c_data_gpio_mux_reg =GPIO_MUX ;
@@ -414,7 +414,7 @@ long sm750_sw_i2c_init( sw_i2c_data_gpio_data_dir_reg =GPIO_DATA_DIRECTION ;/* Initialize the Data GPIO Offset */ - sw_i2c_data_gpio = i2cDataGPIO; + sw_i2c_data_gpio = data_gpio;/* Enable the GPIO pins for the i2c Clock and Data (GPIO MUX) */ POKE32(sw_i2c_clk_gpio_mux_reg,
@@ -436,16 +436,16 @@ long sm750_sw_i2c_init(* This function reads the slave device's register * * Parameters: -* deviceAddress - i2c Slave device address which register +* addr - i2c Slave device address which register * to be read from -* registerIndex - Slave device's register to be read +* reg - Slave device's register to be read * * Return Value: * Register value */ unsigned char sm750_sw_i2c_read_reg ( -unsigned char deviceAddress, -unsigned char registerIndex +unsigned char addr, +unsigned char reg ) {unsigned char data;
@@ -454,14 +454,14 @@ unsigned char sm750_sw_i2c_read_reg(sw_i2c_start ();/* Send the device address */ -sw_i2c_write_byte (deviceAddress); +sw_i2c_write_byte (addr);/* Send the register index */ -sw_i2c_write_byte (registerIndex); +sw_i2c_write_byte (reg);/* Get the bus again and get the data from the device read address */ sw_i2c_start (); -sw_i2c_write_byte (deviceAddress +1 ); +sw_i2c_write_byte (addr +1 ); data =sw_i2c_read_byte (1 );/* Stop swI2C and release the bus */
@@ -474,9 +474,9 @@ unsigned char sm750_sw_i2c_read_reg(* This function writes a value to the slave device's register * * Parameters: -* deviceAddress - i2c Slave device address which register +* addr - i2c Slave device address which register * to be written -* registerIndex - Slave device's register to be written +* reg - Slave device's register to be written * data - Data to be written to the register * * Result:
@@ -484,12 +484,12 @@ unsigned char sm750_sw_i2c_read_reg(* -1 - Fail */ long sm750_sw_i2c_write_reg ( -unsigned char deviceAddress, -unsigned char registerIndex, +unsigned char addr, +unsigned char reg,unsigned char data ) { -long returnValue =0 ; +long ret =0 ;/* Send the Start signal */ sw_i2c_start ();
@@ -497,14 +497,14 @@ long sm750_sw_i2c_write_reg(/* Send the device address and read the data. All should return success in order for the writing processed to be successful */ -if ((sw_i2c_write_byte (deviceAddress) !=0 ) || - (sw_i2c_write_byte (registerIndex) !=0 ) || +if ((sw_i2c_write_byte (addr) !=0 ) || + (sw_i2c_write_byte (reg) !=0 ) || (sw_i2c_write_byte (data) !=0 )) { - returnValue =-1 ; + ret =-1 ; }/* Stop i2c and release the bus */ sw_i2c_stop (); -return returnValue; +return ret; }
drivers/staging/sm750fb/ddk750_swi2c.h +10 -10
@@ -29,33 +29,33 @@* 0 - Success */ long sm750_sw_i2c_init ( -unsigned char i2cClkGPIO, -unsigned char i2cDataGPIO +unsigned char clk_gpio, +unsigned char data_gpio );/* * This function reads the slave device's register * * Parameters: -* deviceAddress - i2c Slave device address which register +* addr - i2c Slave device address which register * to be read from -* registerIndex - Slave device's register to be read +* reg - Slave device's register to be read * * Return Value: * Register value */ unsigned char sm750_sw_i2c_read_reg ( -unsigned char deviceAddress, -unsigned char registerIndex +unsigned char addr, +unsigned char reg );/* * This function writes a value to the slave device's register * * Parameters: -* deviceAddress - i2c Slave device address which register +* addr - i2c Slave device address which register * to be written -* registerIndex - Slave device's register to be written +* reg - Slave device's register to be written * data - Data to be written to the register * * Result:
@@ -63,8 +63,8 @@ unsigned char sm750_sw_i2c_read_reg(* -1 - Fail */ long sm750_sw_i2c_write_reg ( -unsigned char deviceAddress, -unsigned char registerIndex, +unsigned char addr, +unsigned char reg,unsigned char data );
Signature · 1 line
2.1.0
PATCH v3 16/17 staging: sm750fb: ddk750_*i2c: remove multiple blank lines
In reply to Mike RapoportFix the checkpatch warning about multiple blank lines
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 16 ---------------- drivers/staging/sm750fb/ddk750_swi2c.c | 1 - 2 files changed, 17 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +0 -16
@@ -8,7 +8,6 @@#define MAX_HWI2C_FIFO 16#define HWI2C_WAIT_TIMEOUT 0xF0000 -int sm750_hw_i2c_init (unsigned char bus_speed_mode )
@@ -39,7 +38,6 @@ unsigned char bus_speed_modereturn 0 ; } -void sm750_hw_i2c_close (void ) {unsigned int value;
@@ -59,7 +57,6 @@ void sm750_hw_i2c_close(void)POKE32 (GPIO_MUX , value); } -static long hw_i2c_wait_tx_done (void ) {unsigned int timeout;
@@ -76,8 +73,6 @@ static long hw_i2c_wait_tx_done(void)return 0 ; } - -/* * This function writes data to the i2c slave device registers. *
@@ -139,9 +134,6 @@ static unsigned int hw_i2c_write_data(return total_bytes; } - - -/* * This function reads data from the slave device and stores them * in the given buffer
@@ -205,9 +197,6 @@ static unsigned int hw_i2c_read_data(return total_bytes; } - - -/* * This function reads the slave device's register *
@@ -232,10 +221,6 @@ unsigned char sm750_hw_i2c_read_reg(return value; } - - - -/* * This function writes a value to the slave device's register *
@@ -265,5 +250,4 @@ int sm750_hw_i2c_write_reg( return (-1); } -#endif
drivers/staging/sm750fb/ddk750_swi2c.c +0 -1
@@ -15,7 +15,6 @@#include "ddk750_swi2c.h" #include "ddk750_power.h" -/******************************************************************* * I2C Software Master Driver: * ===========================
Signature · 1 line
2.1.0
PATCH v3 17/17 staging: sm750fb: ddk750_*i2c: shorten lines to under 80 characters
In reply to Mike RapoportFix some checkpatch warnings about long lines
--- drivers/staging/sm750fb/ddk750_hwi2c.c | 19 ++++++++++++++----- drivers/staging/sm750fb/ddk750_hwi2c.h | 3 ++- drivers/staging/sm750fb/ddk750_swi2c.c | 22 ++++++++++++++++------ 3 files changed, 32 insertions(+), 12 deletions(-)
drivers/staging/sm750fb/ddk750_hwi2c.c +14 -5
@@ -63,7 +63,8 @@ static long hw_i2c_wait_tx_done(void)/* Wait until the transfer is completed. */ timeout =HWI2C_WAIT_TIMEOUT ; -while ((FIELD_GET (PEEK32 (I2C_STATUS ),I2C_STATUS ,TX ) !=I2C_STATUS_TX_COMPLETED ) && +while ((FIELD_GET (PEEK32 (I2C_STATUS ), +I2C_STATUS ,TX ) !=I2C_STATUS_TX_COMPLETED ) && (timeout !=0 )) timeout--;
@@ -102,7 +103,10 @@ static unsigned int hw_i2c_write_data(* Only 16 byte can be accessed per i2c start instruction. */ do { - /* Reset I2C by writing 0 to I2C_RESET register to clear the previous status. */ + /* + * Reset I2C by writing 0 to I2C_RESET register to + * clear the previous status. + */ POKE32(I2C_RESET, 0); /* Set the number of bytes to be written */
@@ -117,7 +121,8 @@ static unsigned int hw_i2c_write_data(POKE32 (I2C_DATA0 + i, *buf++);/* Start the I2C */ -POKE32 (I2C_CTRL ,FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START )); +POKE32 (I2C_CTRL , +FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START ));/* Wait until the transfer is completed. */ if (hw_i2c_wait_tx_done () !=0 )
@@ -165,7 +170,10 @@ static unsigned int hw_i2c_read_data(* Only 16 byte can be accessed per i2c start instruction. */ do { - /* Reset I2C by writing 0 to I2C_RESET register to clear all the status. */ + /* + * Reset I2C by writing 0 to I2C_RESET register to + * clear all the status. + */ POKE32(I2C_RESET, 0); /* Set the number of bytes to be read */
@@ -176,7 +184,8 @@ static unsigned int hw_i2c_read_data(POKE32 (I2C_BYTE_COUNT , count);/* Start the I2C */ -POKE32 (I2C_CTRL ,FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START )); +POKE32 (I2C_CTRL , +FIELD_SET (PEEK32 (I2C_CTRL ),I2C_CTRL ,CTRL ,START ));/* Wait until transaction done. */ if (hw_i2c_wait_tx_done () !=0 )
drivers/staging/sm750fb/ddk750_hwi2c.h +2 -1
@@ -6,5 +6,6 @@ int sm750_hw_i2c_init(unsigned char bus_speed_mode);void sm750_hw_i2c_close (void );unsigned char sm750_hw_i2c_read_reg (unsigned char addr,unsigned char reg); -int sm750_hw_i2c_write_reg (unsigned char addr,unsigned char reg,unsigned char data); +int sm750_hw_i2c_write_reg (unsigned char addr,unsigned char reg, +unsigned char data);#endif
drivers/staging/sm750fb/ddk750_swi2c.c +16 -6
@@ -125,7 +125,10 @@ static void sw_i2c_scl(unsigned char value) gpio_dir =PEEK32 (sw_i2c_clk_gpio_data_dir_reg);if (value) {/* High */ -/* Set direction as input. This will automatically pull the signal up. */ +/* +* Set direction as input. This will automatically +* pull the signal up. +*/ gpio_dir &= ~(1 << sw_i2c_clk_gpio);POKE32 (sw_i2c_clk_gpio_data_dir_reg, gpio_dir); }else {/* Low */
@@ -159,7 +162,10 @@ static void sw_i2c_sda(unsigned char value) gpio_dir =PEEK32 (sw_i2c_data_gpio_data_dir_reg);if (value) {/* High */ -/* Set direction as input. This will automatically pull the signal up. */ +/* +* Set direction as input. This will automatically +* pull the signal up. +*/ gpio_dir &= ~(1 << sw_i2c_data_gpio);POKE32 (sw_i2c_data_gpio_data_dir_reg, gpio_dir); }else {/* Low */
@@ -184,10 +190,11 @@ static unsigned char sw_i2c_read_sda(void) {unsigned long gpio_dir;unsigned long gpio_data; +unsigned long dir_mask =1 << sw_i2c_data_gpio;/* Make sure that the direction is input (High) */ gpio_dir =PEEK32 (sw_i2c_data_gpio_data_dir_reg); -if ((gpio_dir & (1 << sw_i2c_data_gpio)) != (~(1 << sw_i2c_data_gpio))) { +if ((gpio_dir & dir_mask) != ~dir_mask) { gpio_dir &= ~(1 << sw_i2c_data_gpio);POKE32 (sw_i2c_data_gpio_data_dir_reg, gpio_dir); }
@@ -392,7 +399,10 @@ long sm750_sw_i2c_init( {int i; -/* Return 0 if the GPIO pins to be used is out of range. The range is only from [0..63] */ +/* +* Return 0 if the GPIO pins to be used is out of range. The +* range is only from [0..63] +*/ if ((clk_gpio >31 ) || (data_gpio >31 ))return -1 ;
@@ -417,9 +427,9 @@ long sm750_sw_i2c_init(/* Enable the GPIO pins for the i2c Clock and Data (GPIO MUX) */ POKE32 (sw_i2c_clk_gpio_mux_reg, -PEEK32 (sw_i2c_clk_gpio_mux_reg) & ~(1 << sw_i2c_clk_gpio)); +PEEK32 (sw_i2c_clk_gpio_mux_reg) & ~(1 << sw_i2c_clk_gpio));POKE32 (sw_i2c_data_gpio_mux_reg, -PEEK32 (sw_i2c_data_gpio_mux_reg) & ~(1 << sw_i2c_data_gpio)); +PEEK32 (sw_i2c_data_gpio_mux_reg) & ~(1 << sw_i2c_data_gpio));/* Enable GPIO power */ enableGPIO (1 );
Signature · 1 line
2.1.0