Skip to contentSkip to conversation

viafb: update driver to use both I2C Channels

PATCH In review Deepak Saxena 2 participants 3 messages Jul 15, 2009 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 viafb: update driver to use both I2C Channels

The Chrome chip has two serial I2C channels and the driver currently only exposes one of them. This patch exposes both of them and also cleans up some structure naming to be be less confusing.

This is specifically needed on the XO-1.5 platform as the DCON chip is connected via Chrome I2C channel 0 and the current driver only exploses channel 1.

---

This patch is not the cleanest way to export the second port, but in my opinion the whole via_i2c code and its users need a rewrite to use the driver model instead of what we're doing right now, which is to have the chip drivers directly call the I2C read/write functions after poking at the adapter's I/O address. This patch is meant as a stop gap until that happens since I don't currently have time to do a full cleanup and I need the both ports working ASAP. :)

Patch is against top of Linus' tree (e9e961)

 drivers/video/via/chip.h     |    4 +-
 drivers/video/via/dvi.c      |   20 ++++----
 drivers/video/via/lcd.c      |   10 ++--
 drivers/video/via/via_i2c.c  |  120 ++++++++++++++++++++++++++---------------
 drivers/video/via/via_i2c.h  |    7 ++-
 drivers/video/via/viafbdev.h |    3 +-
 drivers/video/via/vt1636.c   |    4 +-
 7 files changed, 101 insertions(+), 67 deletions(-)
drivers/video/via/chip.h +2 -2
index dde95ed..442cd8a 100644
@@ -107,7 +107,7 @@ struct tmds_chip_information {
 	int dvi_panel_id;
 	int data_mode;
 	int output_interface;
-	int i2c_port;
+	int i2c_ioport;
 	int device_type;
 };
 
@@ -116,7 +116,7 @@ struct lvds_chip_information {
 	int lvds_chip_slave_addr;
 	int data_mode;
 	int output_interface;
-	int i2c_port;
+	int i2c_ioport;
 };
 
 struct chip_information {
drivers/video/via/dvi.c +10 -10
index d696544..f826aaf 100644
@@ -96,7 +96,7 @@ int viafb_tmds_trasmitter_identify(void)
 	viaparinfo->chip_info->tmds_chip_info.tmds_chip_name = VT1632_TMDS;
 	viaparinfo->chip_info->
 		tmds_chip_info.tmds_chip_slave_addr = VT1632_TMDS_I2C_ADDR;
-	viaparinfo->chip_info->tmds_chip_info.i2c_port = I2CPORTINDEX;
+	viaparinfo->chip_info->tmds_chip_info.i2c_ioport = I2CPORT1INDEX;
 	if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID) != FAIL) {
 		/*
 		 * Currently only support 12bits,dual edge,add 24bits mode later
@@ -107,10 +107,10 @@ int viafb_tmds_trasmitter_identify(void)
 		DEBUG_MSG(KERN_INFO "\n %2d",
 			  viaparinfo->chip_info->tmds_chip_info.tmds_chip_name);
 		DEBUG_MSG(KERN_INFO "\n %2d",
-			  viaparinfo->chip_info->tmds_chip_info.i2c_port);
+			  viaparinfo->chip_info->tmds_chip_info.i2c_ioport);
 		return OK;
 	} else {
-		viaparinfo->chip_info->tmds_chip_info.i2c_port = GPIOPORTINDEX;
+		viaparinfo->chip_info->tmds_chip_info.i2c_ioport = GPIOPORTINDEX;
 		if (check_tmds_chip(VT1632_DEVICE_ID_REG, VT1632_DEVICE_ID)
 		    != FAIL) {
 			tmds_register_write(0x08, 0x3b);
@@ -120,7 +120,7 @@ int viafb_tmds_trasmitter_identify(void)
 				  tmds_chip_info.tmds_chip_name);
 			DEBUG_MSG(KERN_INFO "\n %2d",
 				  viaparinfo->chip_info->
-				  tmds_chip_info.i2c_port);
+				  tmds_chip_info.i2c_ioport);
 			return OK;
 		}
 	}
@@ -160,8 +160,8 @@ int viafb_tmds_trasmitter_identify(void)
 
 static void tmds_register_write(int index, u8 data)
 {
-	viaparinfo->i2c_stuff.i2c_port =
-		viaparinfo->chip_info->tmds_chip_info.i2c_port;
+	viaparinfo->i2c_port1.i2c_ioport =
+		viaparinfo->chip_info->tmds_chip_info.i2c_ioport;
 
 	viafb_i2c_writebyte(viaparinfo->chip_info->tmds_chip_info.
 		tmds_chip_slave_addr, index,
@@ -172,8 +172,8 @@ static int tmds_register_read(int index)
 {
 	u8 data;
 
-	viaparinfo->i2c_stuff.i2c_port =
-		viaparinfo->chip_info->tmds_chip_info.i2c_port;
+	viaparinfo->i2c_port1.i2c_ioport =
+		viaparinfo->chip_info->tmds_chip_info.i2c_ioport;
 	viafb_i2c_readbyte((u8) viaparinfo->chip_info->
 	    tmds_chip_info.tmds_chip_slave_addr,
 			(u8) index, &data);
@@ -182,8 +182,8 @@ static int tmds_register_read(int index)
 
 static int tmds_register_read_bytes(int index, u8 *buff, int buff_len)
 {
-	viaparinfo->i2c_stuff.i2c_port =
-		viaparinfo->chip_info->tmds_chip_info.i2c_port;
+	viaparinfo->i2c_port1.i2c_ioport =
+		viaparinfo->chip_info->tmds_chip_info.i2c_ioport;
 	viafb_i2c_readbytes((u8) viaparinfo->chip_info->tmds_chip_info.
 			 tmds_chip_slave_addr, (u8) index, buff, buff_len);
 	return 0;
drivers/video/via/lcd.c +5 -5
index 6c7290a..15620bd 100644
@@ -207,15 +207,15 @@ static bool lvds_identify_integratedlvds(void)
 
 int viafb_lvds_trasmitter_identify(void)
 {
-	viaparinfo->i2c_stuff.i2c_port = I2CPORTINDEX;
+ 	viaparinfo->i2c_port1.i2c_ioport = I2CPORT1INDEX;
 	if (viafb_lvds_identify_vt1636()) {
-		viaparinfo->chip_info->lvds_chip_info.i2c_port = I2CPORTINDEX;
+ 		viaparinfo->chip_info->lvds_chip_info.i2c_ioport = I2CPORT1INDEX;
 		DEBUG_MSG(KERN_INFO
 			  "Found VIA VT1636 LVDS on port i2c 0x31 \n");
 	} else {
-		viaparinfo->i2c_stuff.i2c_port = GPIOPORTINDEX;
+ 		viaparinfo->i2c_port1.i2c_ioport = GPIOPORTINDEX;
 		if (viafb_lvds_identify_vt1636()) {
-			viaparinfo->chip_info->lvds_chip_info.i2c_port =
+ 			viaparinfo->chip_info->lvds_chip_info.i2c_ioport =
 				GPIOPORTINDEX;
 			DEBUG_MSG(KERN_INFO
 				  "Found VIA VT1636 LVDS on port gpio 0x2c \n");
@@ -470,7 +470,7 @@ static int lvds_register_read(int index)
 {
 	u8 data;
 
-	viaparinfo->i2c_stuff.i2c_port = GPIOPORTINDEX;
+	viaparinfo->i2c_port1.i2c_ioport = GPIOPORTINDEX;
 	viafb_i2c_readbyte((u8) viaparinfo->chip_info->
 	    lvds_chip_info.lvds_chip_slave_addr,
 			(u8) index, &data);
drivers/video/via/via_i2c.c +76 -44

201 lines not on this page · raw message

drivers/video/via/via_i2c.h +4 -3
index 3a13242..5792ff6 100644
@@ -24,14 +24,15 @@
 #include <linux/i2c.h>
 #include <linux/i2c-algo-bit.h>
 
-struct via_i2c_stuff {
-	u16 i2c_port;			/* GPIO or I2C port */
+struct via_i2c_port {
+	u16 i2c_ioport;			/* GPIO or I2C port */
 	struct i2c_adapter adapter;
 	struct i2c_algo_bit_data algo;
 };
 
 #define I2CPORT           0x3c4
-#define I2CPORTINDEX      0x31
+#define I2CPORT0INDEX      0x26
+#define I2CPORT1INDEX      0x31
 #define GPIOPORT          0x3C4
 #define GPIOPORTINDEX     0x2C
 #define I2C_BUS             1
drivers/video/via/viafbdev.h +2 -1
index a4158e8..3583451 100644
@@ -62,7 +62,8 @@ struct viafb_par {
 	u8 duoview;		/*Is working in duoview mode? */
 
 	/* I2C stuff */
-	struct via_i2c_stuff i2c_stuff;
+	struct via_i2c_port i2c_port0; 
+	struct via_i2c_port i2c_port1;
 
 	/* All the information will be needed to set engine */
 	struct tmds_setting_information *tmds_setting_info;
drivers/video/via/vt1636.c +2 -2
index 322a9f9..e757aa8 100644
@@ -27,7 +27,7 @@ u8 viafb_gpio_i2c_read_lvds(struct lvds_setting_information
 {
 	u8 data;
 
-	viaparinfo->i2c_stuff.i2c_port = plvds_chip_info->i2c_port;
+	viaparinfo->i2c_port1.i2c_ioport = plvds_chip_info->i2c_ioport;
 	viafb_i2c_readbyte(plvds_chip_info->lvds_chip_slave_addr, index, &data);
 
 	return data;
@@ -39,7 +39,7 @@ void viafb_gpio_i2c_write_mask_lvds(struct lvds_setting_information
 {
 	int index, data;
 
-	viaparinfo->i2c_stuff.i2c_port = plvds_chip_info->i2c_port;
+	viaparinfo->i2c_port1.i2c_ioport = plvds_chip_info->i2c_ioport;
 
 	index = io_data.Index;
 	data = viafb_gpio_i2c_read_lvds(plvds_setting_info, plvds_chip_info,
Signature · 1 line
1.5.5.1.29.gcbf75.dirty
#1 lore raw

Hi Deepak,

as I have pointed out a couple of times to some OLPC folks (not sure if you
were included), there is a via-viafb-i2c tree in my git tree (http://git.gnumonks.org/cgi-bin/gitweb.cgi?p=linux-2.6-via.git;a=shortlog;h=refs/heads/via-viafb-i2c)
that tries to clean up the i2c mess (after cleaning up a lot of other mess).

I've submitted a long series of those viafb patches some time ago, but somehow none of them was merged mainline yet :(

Were you aware of this? If yes, then it means that you're reluctant to merge the tons of not-yet-mainline cleanup code from my tree, which I could understand, too.

Signature · 3 lines
- Harald Welte <[email protected]>	    http://linux.via.com.tw/
============================================================================
VIA Free and Open Source Software Liaison
#2 lore raw

On Jul 15 2009, at 22:17, Harald Welte was caught saying:

Quoted 6 lines

Hi Deepak,

as I have pointed out a couple of times to some OLPC folks (not sure if you
were included), there is a via-viafb-i2c tree in my git tree (http://git.gnumonks.org/cgi-bin/gitweb.cgi?p=linux-2.6-via.git;a=shortlog;h=refs/heads/via-viafb-i2c)
that tries to clean up the i2c mess (after cleaning up a lot of other mess).

Quoted 6 lines

I've submitted a long series of those viafb patches some time ago, but somehow none of them was merged mainline yet :(

Were you aware of this? If yes, then it means that you're reluctant to merge the tons of not-yet-mainline cleanup code from my tree, which I could understand, too.

Nope, was not aware of this. Will grab that tree and take a look at it.

Thanks,
~Deepak