summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--linux-core/nv50_i2c.c48
-rw-r--r--shared-core/nouveau_reg.h82
2 files changed, 57 insertions, 73 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;
diff --git a/shared-core/nouveau_reg.h b/shared-core/nouveau_reg.h
index 8cf7f889..6ed23e26 100644
--- a/shared-core/nouveau_reg.h
+++ b/shared-core/nouveau_reg.h
@@ -632,90 +632,30 @@
# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C1 (1<<1)
# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C2 (1<<2)
# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C3 (1<<3)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C4 (1<<4)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C5 (1<<5)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C6 (1<<6)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C7 (1<<7)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C8 (1<<8)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C9 (1<<9)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C10 (1<<10)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C11 (1<<11)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C12 (1<<12)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C13 (1<<13)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C14 (1<<14)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_PLUG_I2C15 (1<<15)
# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C0 (1<<16)
# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C1 (1<<17)
# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C2 (1<<18)
# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C3 (1<<19)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C4 (1<<20)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C5 (1<<21)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C6 (1<<22)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C7 (1<<23)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C8 (1<<24)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C9 (1<<25)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C10 (1<<26)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C11 (1<<27)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C12 (1<<28)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C13 (1<<29)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C14 (1<<30)
-# define NV50_PCONNECTOR_HOTPLUG_INTR_UNPLUG_I2C15 (1<<31)
# define NV50_PCONNECTOR_HOTPLUG_CTRL 0x0000e054
# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C0 (1<<0)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C1 (1<<1)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C2 (1<<2)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C3 (1<<3)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C4 (1<<4)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C5 (1<<5)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C6 (1<<6)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C7 (1<<7)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C8 (1<<8)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C9 (1<<9)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C10 (1<<10)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C11 (1<<11)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C12 (1<<12)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C13 (1<<13)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C14 (1<<14)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_PLUG_I2C15 (1<<15)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C0 (1<<16)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C1 (1<<17)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C2 (1<<18)
# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C3 (1<<19)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C4 (1<<20)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C5 (1<<21)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C6 (1<<22)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C7 (1<<23)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C8 (1<<24)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C9 (1<<25)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C10 (1<<26)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C11 (1<<27)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C12 (1<<28)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C13 (1<<29)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C14 (1<<30)
-# define NV50_PCONNECTOR_HOTPLUG_CTRL_UNPLUG_I2C15 (1<<31)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1 0x0000e104
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C0 (1<<2)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C1 (1<<6)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C2 (1<<10)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C3 (1<<14)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C4 (1<<18)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C5 (1<<22)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C6 (1<<26)
-# define NV50_PCONNECTOR_HOTPLUG_STATE1_PIN_CONNECTED_I2C7 (1<<30)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2 0x0000e108
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C8 (1<<2)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C9 (1<<6)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C10 (1<<10)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C11 (1<<14)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C12 (1<<18)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C13 (1<<22)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C14 (1<<26)
-# define NV50_PCONNECTOR_HOTPLUG_STATE2_PIN_CONNECTED_I2C15 (1<<30)
-# define NV50_PCONNECTOR_I2C 0x0000e138
-# define NV50_PCONNECTOR_I2C__LEN 0x10
-# define NV50_PCONNECTOR_I2C__ESIZE 0x18
-# define NV50_PCONNECTOR_I2C_PORT(i) (0x0000e138+(i)*0x18)
-
+# define NV50_PCONNECTOR_HOTPLUG_STATE 0x0000e104
+# define NV50_PCONNECTOR_HOTPLUG_STATE_PIN_CONNECTED_I2C0 (1<<2)
+# define NV50_PCONNECTOR_HOTPLUG_STATE_PIN_CONNECTED_I2C1 (1<<6)
+# define NV50_PCONNECTOR_HOTPLUG_STATE_PIN_CONNECTED_I2C2 (1<<10)
+# define NV50_PCONNECTOR_HOTPLUG_STATE_PIN_CONNECTED_I2C3 (1<<14)
+# define NV50_PCONNECTOR_I2C_PORT_0 0x0000e138
+# define NV50_PCONNECTOR_I2C_PORT_1 0x0000e150
+# define NV50_PCONNECTOR_I2C_PORT_2 0x0000e168
+# define NV50_PCONNECTOR_I2C_PORT_3 0x0000e180
+# define NV50_PCONNECTOR_I2C_PORT_4 0x0000e240
+# define NV50_PCONNECTOR_I2C_PORT_5 0x0000e258
#define NV50_PBUS 0x00088000
#define NV50_PBUS__LEN 0x1