27 #include <linux/module.h>
42 #define to_sil164_priv(x) \
43 ((struct sil164_priv *)to_encoder_slave(x)->slave_priv)
45 #define sil164_dbg(client, format, ...) do { \
46 if (drm_debug & DRM_UT_KMS) \
47 dev_printk(KERN_DEBUG, &client->dev, \
48 "%s: " format, __func__, ## __VA_ARGS__); \
50 #define sil164_info(client, format, ...) \
51 dev_info(&client->dev, format, __VA_ARGS__)
52 #define sil164_err(client, format, ...) \
53 dev_err(&client->dev, format, __VA_ARGS__)
55 #define SIL164_I2C_ADDR_MASTER 0x38
56 #define SIL164_I2C_ADDR_SLAVE 0x39
60 #define SIL164_VENDOR_LO 0x0
61 #define SIL164_VENDOR_HI 0x1
62 #define SIL164_DEVICE_LO 0x2
63 #define SIL164_DEVICE_HI 0x3
64 #define SIL164_REVISION 0x4
65 #define SIL164_FREQ_MIN 0x6
66 #define SIL164_FREQ_MAX 0x7
67 #define SIL164_CONTROL0 0x8
68 # define SIL164_CONTROL0_POWER_ON 0x01
69 # define SIL164_CONTROL0_EDGE_RISING 0x02
70 # define SIL164_CONTROL0_INPUT_24BIT 0x04
71 # define SIL164_CONTROL0_DUAL_EDGE 0x08
72 # define SIL164_CONTROL0_HSYNC_ON 0x10
73 # define SIL164_CONTROL0_VSYNC_ON 0x20
74 #define SIL164_DETECT 0x9
75 # define SIL164_DETECT_INTR_STAT 0x01
76 # define SIL164_DETECT_HOTPLUG_STAT 0x02
77 # define SIL164_DETECT_RECEIVER_STAT 0x04
78 # define SIL164_DETECT_INTR_MODE_RECEIVER 0x00
79 # define SIL164_DETECT_INTR_MODE_HOTPLUG 0x08
80 # define SIL164_DETECT_OUT_MODE_HIGH 0x00
81 # define SIL164_DETECT_OUT_MODE_INTR 0x10
82 # define SIL164_DETECT_OUT_MODE_RECEIVER 0x20
83 # define SIL164_DETECT_OUT_MODE_HOTPLUG 0x30
84 # define SIL164_DETECT_VSWING_STAT 0x80
85 #define SIL164_CONTROL1 0xa
86 # define SIL164_CONTROL1_DESKEW_ENABLE 0x10
87 # define SIL164_CONTROL1_DESKEW_INCR_SHIFT 5
88 #define SIL164_GPIO 0xb
89 #define SIL164_CONTROL2 0xc
90 # define SIL164_CONTROL2_FILTER_ENABLE 0x01
91 # define SIL164_CONTROL2_FILTER_SETTING_SHIFT 1
92 # define SIL164_CONTROL2_DUALLINK_MASTER 0x40
93 # define SIL164_CONTROL2_SYNC_CONT 0x80
94 #define SIL164_DUALLINK 0xd
95 # define SIL164_DUALLINK_ENABLE 0x10
96 # define SIL164_DUALLINK_SKEW_SHIFT 5
97 #define SIL164_PLLZONE 0xe
98 # define SIL164_PLLZONE_STAT 0x08
99 # define SIL164_PLLZONE_FORCE_ON 0x10
100 # define SIL164_PLLZONE_FORCE_HIGH 0x20
112 sil164_err(client,
"Error %d writing to subaddress 0x%x\n",
133 sil164_err(client,
"Error %d reading from subaddress 0x%x\n",
143 for (i = 0x8; i <= 0xe; i++)
144 state[i] = sil164_read(client, i);
152 for (i = 0x8; i <= 0xe; i++)
153 sil164_write(client, i, state[i]);
157 sil164_set_power_state(
struct i2c_client *client,
bool on)
221 bool duallink = (on && encoder->
crtc->mode.clock > 165000);
223 sil164_set_power_state(drm_i2c_encoder_get_client(encoder), on);
234 sil164_save_state(drm_i2c_encoder_get_client(encoder),
243 sil164_encoder_restore(
struct drm_encoder *encoder)
247 sil164_restore_state(drm_i2c_encoder_get_client(encoder),
256 sil164_encoder_mode_fixup(
struct drm_encoder *encoder,
264 sil164_encoder_mode_valid(
struct drm_encoder *encoder,
269 if (mode->
clock < 32000)
272 if (mode->
clock > 330000 ||
280 sil164_encoder_mode_set(
struct drm_encoder *encoder,
285 bool duallink = adjusted_mode->
clock > 165000;
287 sil164_init_state(drm_i2c_encoder_get_client(encoder),
301 struct i2c_client *client = drm_i2c_encoder_get_client(encoder);
310 sil164_encoder_get_modes(
struct drm_encoder *encoder,
317 sil164_encoder_create_resources(
struct drm_encoder *encoder,
324 sil164_encoder_set_property(
struct drm_encoder *encoder,
333 sil164_encoder_destroy(
struct drm_encoder *encoder)
345 .set_config = sil164_encoder_set_config,
346 .destroy = sil164_encoder_destroy,
347 .dpms = sil164_encoder_dpms,
348 .save = sil164_encoder_save,
349 .restore = sil164_encoder_restore,
350 .mode_fixup = sil164_encoder_mode_fixup,
351 .mode_valid = sil164_encoder_mode_valid,
352 .mode_set = sil164_encoder_mode_set,
353 .detect = sil164_encoder_detect,
354 .get_modes = sil164_encoder_get_modes,
355 .create_resources = sil164_encoder_create_resources,
356 .set_property = sil164_encoder_set_property,
370 if (vendor != 0x1 || device != 0x6) {
371 sil164_dbg(client,
"Unknown device %x:%x.%x\n",
372 vendor, device, rev);
377 vendor, device, rev);
389 sil164_detect_slave(
struct i2c_client *client)
401 sil164_dbg(adap,
"No dual-link slave found.");
409 sil164_encoder_init(
struct i2c_client *client,
435 .probe = sil164_probe,
436 .remove = sil164_remove,
440 .id_table = sil164_ids,
442 .encoder_init = sil164_encoder_init,
450 return drm_i2c_encoder_register(
THIS_MODULE, &sil164_driver);
456 drm_i2c_encoder_unregister(&sil164_driver);