27 #include <linux/export.h>
29 #include <linux/pci.h>
30 #include <linux/i2c.h>
35 #define HDMI_READ(reg) readl(hdmi_dev->regs + (reg))
36 #define HDMI_WRITE(reg, val) writel(val, hdmi_dev->regs + (reg))
38 #define HDMI_HCR 0x1000
39 #define HCR_DETECT_HDP (1 << 6)
40 #define HCR_ENABLE_HDCP (1 << 5)
41 #define HCR_ENABLE_AUDIO (1 << 2)
42 #define HCR_ENABLE_PIXEL (1 << 1)
43 #define HCR_ENABLE_TMDS (1 << 0)
44 #define HDMI_HICR 0x1004
45 #define HDMI_INTR_I2C_ERROR (1 << 4)
46 #define HDMI_INTR_I2C_FULL (1 << 3)
47 #define HDMI_INTR_I2C_DONE (1 << 2)
48 #define HDMI_INTR_HPD (1 << 0)
49 #define HDMI_HSR 0x1008
50 #define HDMI_HISR 0x100C
51 #define HDMI_HI2CRDB0 0x1200
52 #define HDMI_HI2CHCR 0x1240
53 #define HI2C_HDCP_WRITE (0 << 2)
54 #define HI2C_HDCP_RI_READ (1 << 2)
55 #define HI2C_HDCP_READ (2 << 2)
56 #define HI2C_EDID_READ (3 << 2)
57 #define HI2C_READ_CONTINUE (1 << 1)
58 #define HI2C_ENABLE_TRANSACTION (1 << 0)
60 #define HDMI_ICRH 0x1100
61 #define HDMI_HI2CTDR0 0x1244
62 #define HDMI_HI2CTDR1 0x1248
64 #define I2C_STAT_INIT 0
65 #define I2C_READ_DONE 1
66 #define I2C_TRANSACTION_DONE 2
124 static int oaktrail_hdmi_i2c_access(
struct i2c_adapter *adap,
138 hdmi_i2c_irq_enable(hdmi_dev);
139 for (i = 0; i < num; i++) {
140 if (pmsg->
len && pmsg->
buf) {
142 xfer_read(adap, pmsg);
144 xfer_write(adap, pmsg);
150 hdmi_i2c_irq_disable(hdmi_dev);
162 static const struct i2c_algorithm oaktrail_hdmi_i2c_algorithm = {
163 .master_xfer = oaktrail_hdmi_i2c_access,
164 .functionality = oaktrail_hdmi_i2c_func,
167 static struct i2c_adapter oaktrail_hdmi_i2c_adapter = {
168 .name =
"oaktrail_hdmi_i2c",
172 .algo = &oaktrail_hdmi_i2c_algorithm,
184 for (i = 0; i < 0x10; i++) {
186 memcpy(buf + (offset + i * 4), &temp, 4);
223 static irqreturn_t oaktrail_hdmi_i2c_handler(
int this_irq,
void *
dev)
237 hdmi_i2c_read(hdmi_dev);
240 hdmi_i2c_transaction_done(hdmi_dev);
251 static void oaktrail_hdmi_i2c_gpio_fix(
void)
255 int gpio_len = 0x1000;
260 DRM_ERROR(
"gpio ioremap fail\n");
264 temp =
readl(base + 0x44);
265 DRM_DEBUG_DRIVER(
"old gpio val %x\n", temp);
266 writel((temp | 0x00000a00), (base + 0x44));
267 temp =
readl(base + 0x44);
268 DRM_DEBUG_DRIVER(
"new gpio val %x\n", temp);
279 hdmi_dev = pci_get_drvdata(dev);
282 if (i2c_dev ==
NULL) {
283 DRM_ERROR(
"Can't allocate interface\n");
288 i2c_dev->
adap = &oaktrail_hdmi_i2c_adapter;
290 init_completion(&i2c_dev->
complete);
292 i2c_set_adapdata(&oaktrail_hdmi_i2c_adapter, hdmi_dev);
296 oaktrail_hdmi_i2c_gpio_fix();
300 oaktrail_hdmi_i2c_adapter.
name, hdmi_dev);
302 DRM_ERROR(
"Failed to request IRQ for I2C controller\n");
321 hdmi_dev = pci_get_drvdata(dev);
323 DRM_DEBUG_DRIVER(
"Failed to delete hdmi-i2c adapter\n");