From c33d72912856c0c8fc7586170d10a906d7f854be Mon Sep 17 00:00:00 2001
From: Alex Deucher <alexdeucher@gmail.com>
Date: Mon, 8 Feb 2010 14:40:24 -0500
Subject: [PATCH] drm/radeon/kms: more hw i2c fixes

- rs300 doesn't have a pin select bit
- r200 has a different pin select setup

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
---
 drivers/gpu/drm/radeon/radeon_combios.c |   12 +++++++++++-
 drivers/gpu/drm/radeon/radeon_i2c.c     |   16 +++++++++++++++-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 1d398af..31e4a61 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -513,6 +513,7 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
 	case CHIP_RS100:
 	case CHIP_RV200:
 	case CHIP_RS200:
+	case CHIP_RS300:
 		switch (ddc_line) {
 		case RADEON_GPIO_DVI_DDC:
 			/* in theory this should be hw capable,
@@ -526,8 +527,17 @@ static struct radeon_i2c_bus_rec combios_setup_i2c_bus(struct radeon_device *rde
 		}
 		break;
 	case CHIP_R200:
+		switch (ddc_line) {
+		case RADEON_GPIO_DVI_DDC:
+		case RADEON_GPIO_MONID:
+			i2c.hw_capable = true;
+			break;
+		default:
+			i2c.hw_capable = false;
+			break;
+		}
+		break;
 	case CHIP_RV250:
-	case CHIP_RS300:
 	case CHIP_RV280:
 		switch (ddc_line) {
 		case RADEON_GPIO_VGA_DDC:
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index b715632..272c45d 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -228,6 +228,7 @@ static int r100_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
 		case CHIP_RS100:
 		case CHIP_RV200:
 		case CHIP_RS200:
+		case CHIP_RS300:
 			switch (rec->mask_clk_reg) {
 			case RADEON_GPIO_DVI_DDC:
 				/* no gpio select bit */
@@ -239,8 +240,21 @@ static int r100_hw_i2c_xfer(struct i2c_adapter *i2c_adap,
 			}
 			break;
 		case CHIP_R200:
+			/* only bit 4 on r200 */
+			switch (rec->mask_clk_reg) {
+			case RADEON_GPIO_DVI_DDC:
+				reg |= R200_DVI_I2C_PIN_SEL(R200_SEL_DDC1);
+				break;
+			case RADEON_GPIO_MONID:
+				reg |= R200_DVI_I2C_PIN_SEL(R200_SEL_DDC3);
+				break;
+			default:
+				DRM_ERROR("gpio not supported with hw i2c\n");
+				ret = -EINVAL;
+				goto done;
+			}
+			break;
 		case CHIP_RV250:
-		case CHIP_RS300:
 		case CHIP_RV280:
 			/* bits 3 and 4 */
 			switch (rec->mask_clk_reg) {
-- 
1.5.6.3

