Re: [PATCH 6/8] marvell-cam: Right-shift i2c slave ID's in the cafe driver

2011-06-16 Thread Mauro Carvalho Chehab
Em 11-06-2011 14:46, Jonathan Corbet escreveu:
 This makes the cafe i2c implement consistent with the rest of Linux so that
 the core can use the same slave ID everywhere.
 
 Signed-off-by: Jonathan Corbet cor...@lwn.net
 ---
  drivers/media/video/marvell-ccic/cafe-driver.c |9 -
  drivers/media/video/marvell-ccic/mcam-core.c   |2 +-
  2 files changed, 9 insertions(+), 2 deletions(-)
 
 diff --git a/drivers/media/video/marvell-ccic/cafe-driver.c 
 b/drivers/media/video/marvell-ccic/cafe-driver.c
 index 1027265..3dbc7e5 100644
 --- a/drivers/media/video/marvell-ccic/cafe-driver.c
 +++ b/drivers/media/video/marvell-ccic/cafe-driver.c
 @@ -84,7 +84,14 @@ struct cafe_camera {
  #defineTWSIC0_EN   0x0001/* TWSI enable */
  #defineTWSIC0_MODE 0x0002/* 1 = 16-bit, 0 = 8-bit */
  #defineTWSIC0_SID  0x03fc/* Slave ID */
 -#defineTWSIC0_SID_SHIFT 2
 +/*
 + * Subtle trickery: the slave ID field starts with bit 2.  But the
 + * Linux i2c stack wants to treat the bottommost bit as a separate
 + * read/write bit, which is why slave ID's are usually presented
 + * 1.  For consistency with that behavior, we shift over three
 + * bits instead of two.
 + */

And this is consistent with the initial Philips I2C datasheets ;) Newer 
datasheets
use to include the read/write bit as if they're part of the I2C address, as 
well as
the registers that command I2C operations inside most chipsets. So, we end
by having 7-bit and 8-bit notations for I2C addresses.

 +#defineTWSIC0_SID_SHIFT 3
  #defineTWSIC0_CLKDIV   0x0007fc00/* Clock divider */
  #defineTWSIC0_MASKACK  0x0040/* Mask ack from sensor */
  #defineTWSIC0_OVMAGIC  0x0080/* Make it work on OV sensors */
 diff --git a/drivers/media/video/marvell-ccic/mcam-core.c 
 b/drivers/media/video/marvell-ccic/mcam-core.c
 index 0d60234..d5f18a3 100644
 --- a/drivers/media/video/marvell-ccic/mcam-core.c
 +++ b/drivers/media/video/marvell-ccic/mcam-core.c
 @@ -1549,7 +1549,7 @@ int mccic_register(struct mcam_camera *cam)
  {
   struct i2c_board_info ov7670_info = {
   .type = ov7670,
 - .addr = 0x42,
 + .addr = 0x42  1,
   .platform_data = sensor_cfg,
   };
   int ret;

Patch is OK.

Mauro.
--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/8] marvell-cam: Right-shift i2c slave ID's in the cafe driver

2011-06-11 Thread Jonathan Corbet
This makes the cafe i2c implement consistent with the rest of Linux so that
the core can use the same slave ID everywhere.

Signed-off-by: Jonathan Corbet cor...@lwn.net
---
 drivers/media/video/marvell-ccic/cafe-driver.c |9 -
 drivers/media/video/marvell-ccic/mcam-core.c   |2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/marvell-ccic/cafe-driver.c 
b/drivers/media/video/marvell-ccic/cafe-driver.c
index 1027265..3dbc7e5 100644
--- a/drivers/media/video/marvell-ccic/cafe-driver.c
+++ b/drivers/media/video/marvell-ccic/cafe-driver.c
@@ -84,7 +84,14 @@ struct cafe_camera {
 #define  TWSIC0_EN   0x0001/* TWSI enable */
 #define  TWSIC0_MODE 0x0002/* 1 = 16-bit, 0 = 8-bit */
 #define  TWSIC0_SID  0x03fc/* Slave ID */
-#define  TWSIC0_SID_SHIFT 2
+/*
+ * Subtle trickery: the slave ID field starts with bit 2.  But the
+ * Linux i2c stack wants to treat the bottommost bit as a separate
+ * read/write bit, which is why slave ID's are usually presented
+ * 1.  For consistency with that behavior, we shift over three
+ * bits instead of two.
+ */
+#define  TWSIC0_SID_SHIFT 3
 #define  TWSIC0_CLKDIV   0x0007fc00/* Clock divider */
 #define  TWSIC0_MASKACK  0x0040/* Mask ack from sensor */
 #define  TWSIC0_OVMAGIC  0x0080/* Make it work on OV sensors */
diff --git a/drivers/media/video/marvell-ccic/mcam-core.c 
b/drivers/media/video/marvell-ccic/mcam-core.c
index 0d60234..d5f18a3 100644
--- a/drivers/media/video/marvell-ccic/mcam-core.c
+++ b/drivers/media/video/marvell-ccic/mcam-core.c
@@ -1549,7 +1549,7 @@ int mccic_register(struct mcam_camera *cam)
 {
struct i2c_board_info ov7670_info = {
.type = ov7670,
-   .addr = 0x42,
+   .addr = 0x42  1,
.platform_data = sensor_cfg,
};
int ret;
-- 
1.7.5.4

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html