Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Dirk Eibach | a3f9d6c | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 |
| 4 | * Dirk Eibach, Guntermann & Drunck GmbH, dirk.eibach@gdsys.cc |
Dirk Eibach | a3f9d6c | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | /* Chrontel CH7301C DVI Transmitter */ |
| 8 | |
Mario Six | fe4a967 | 2019-03-29 10:18:10 +0100 | [diff] [blame] | 9 | #ifdef CONFIG_GDSYS_LEGACY_DRIVERS |
| 10 | |
Dirk Eibach | a3f9d6c | 2015-10-28 11:46:32 +0100 | [diff] [blame] | 11 | #include <common.h> |
| 12 | #include <asm/io.h> |
| 13 | #include <errno.h> |
| 14 | #include <i2c.h> |
| 15 | |
| 16 | #define CH7301_I2C_ADDR 0x75 |
| 17 | |
| 18 | enum { |
| 19 | CH7301_CM = 0x1c, /* Clock Mode Register */ |
| 20 | CH7301_IC = 0x1d, /* Input Clock Register */ |
| 21 | CH7301_GPIO = 0x1e, /* GPIO Control Register */ |
| 22 | CH7301_IDF = 0x1f, /* Input Data Format Register */ |
| 23 | CH7301_CD = 0x20, /* Connection Detect Register */ |
| 24 | CH7301_DC = 0x21, /* DAC Control Register */ |
| 25 | CH7301_HPD = 0x23, /* Hot Plug Detection Register */ |
| 26 | CH7301_TCTL = 0x31, /* DVI Control Input Register */ |
| 27 | CH7301_TPCP = 0x33, /* DVI PLL Charge Pump Ctrl Register */ |
| 28 | CH7301_TPD = 0x34, /* DVI PLL Divide Register */ |
| 29 | CH7301_TPVT = 0x35, /* DVI PLL Supply Control Register */ |
| 30 | CH7301_TPF = 0x36, /* DVI PLL Filter Register */ |
| 31 | CH7301_TCT = 0x37, /* DVI Clock Test Register */ |
| 32 | CH7301_TSTP = 0x48, /* Test Pattern Register */ |
| 33 | CH7301_PM = 0x49, /* Power Management register */ |
| 34 | CH7301_VID = 0x4a, /* Version ID Register */ |
| 35 | CH7301_DID = 0x4b, /* Device ID Register */ |
| 36 | CH7301_DSP = 0x56, /* DVI Sync polarity Register */ |
| 37 | }; |
| 38 | |
| 39 | int ch7301_i2c[] = CONFIG_SYS_CH7301_I2C; |
| 40 | |
| 41 | int ch7301_probe(unsigned screen, bool power) |
| 42 | { |
| 43 | u8 value; |
| 44 | |
| 45 | i2c_set_bus_num(ch7301_i2c[screen]); |
| 46 | if (i2c_probe(CH7301_I2C_ADDR)) |
| 47 | return -1; |
| 48 | |
| 49 | value = i2c_reg_read(CH7301_I2C_ADDR, CH7301_DID); |
| 50 | if (value != 0x17) |
| 51 | return -1; |
| 52 | |
| 53 | if (power) { |
| 54 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_TPCP, 0x08); |
| 55 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_TPD, 0x16); |
| 56 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_TPF, 0x60); |
| 57 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_DC, 0x09); |
| 58 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_PM, 0xc0); |
| 59 | } else { |
| 60 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_DC, 0x00); |
| 61 | i2c_reg_write(CH7301_I2C_ADDR, CH7301_PM, 0x01); |
| 62 | } |
| 63 | |
| 64 | return 0; |
| 65 | } |
Mario Six | fe4a967 | 2019-03-29 10:18:10 +0100 | [diff] [blame] | 66 | |
| 67 | #endif /* CONFIG_GDSYS_LEGACY_DRIVERS */ |