summaryrefslogtreecommitdiff
path: root/linux-core
diff options
context:
space:
mode:
authorMaarten Maathuis <madman2003@gmail.com>2008-07-01 15:14:30 +0200
committerMaarten Maathuis <madman2003@gmail.com>2008-07-01 15:14:30 +0200
commitbc32d1798a213d7701b20feb95781eb51a42e945 (patch)
tree939c0b2aabcd31978d3a7e1262981b1c3e63ee01 /linux-core
parent91c742663a618e81da69ad4f098321d9af56d636 (diff)
NV50: some i2c cleanup
Diffstat (limited to 'linux-core')
-rw-r--r--linux-core/nv50_i2c.c48
1 files changed, 46 insertions, 2 deletions
diff --git a/linux-core/nv50_i2c.c b/linux-core/nv50_i2c.c
index cf55645b..e90a4cee 100644
--- a/linux-core/nv50_i2c.c
+++ b/linux-core/nv50_i2c.c
@@ -28,18 +28,62 @@
#include "nv50_i2c.h"
+static uint32_t nv50_i2c_port(int index)
+{
+ uint32_t port = 0;
+
+ switch (index) {
+ case 0:
+ port = NV50_PCONNECTOR_I2C_PORT_0;
+ break;
+ case 1:
+ port = NV50_PCONNECTOR_I2C_PORT_1;
+ break;
+ case 2:
+ port = NV50_PCONNECTOR_I2C_PORT_2;
+ break;
+ case 3:
+ port = NV50_PCONNECTOR_I2C_PORT_3;
+ break;
+ case 4:
+ port = NV50_PCONNECTOR_I2C_PORT_4;
+ break;
+ case 5:
+ port = NV50_PCONNECTOR_I2C_PORT_5;
+ break;
+ default:
+ break;
+ }
+
+ if (!port) {
+ DRM_ERROR("Invalid i2c port, returning 0.\n");
+ BUG();
+ }
+
+ return port;
+}
+
static void nv50_i2c_set_bits(struct nv50_i2c_channel *chan, int clock_high, int data_high)
{
struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
+ uint32_t port = nv50_i2c_port(chan->index);
- NV_WRITE(NV50_PCONNECTOR_I2C_PORT(chan->index), 4 | (data_high << 1) | clock_high);
+ if (!port)
+ return;
+
+ NV_WRITE(port, 4 | (data_high << 1) | clock_high);
}
static void nv50_i2c_get_bits(struct nv50_i2c_channel *chan, int *clock_high, int *data_high)
{
struct drm_nouveau_private *dev_priv = chan->dev->dev_private;
+ uint32_t port = nv50_i2c_port(chan->index);
+ uint32_t val;
+
+ if (!port)
+ return;
- uint32_t val = NV_READ(NV50_PCONNECTOR_I2C_PORT(chan->index));
+ val = NV_READ(port);
if (val & 1)
*clock_high = 1;