Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
0ba0e9e
Documentation
arch
block
crypto
drivers
accessibility
acpi
amba
ata
atm
auxdisplay
base
block
bluetooth
cdrom
char
clocksource
connector
cpufreq
cpuidle
crypto
dca
dio
dma
edac
eisa
firewire
firmware
gpio
gpu
drm
i810
i830
i915
Makefile
dvo.h
dvo_ch7017.c
dvo_ch7xxx.c
dvo_ivch.c
dvo_sil164.c
dvo_tfp410.c
i915_dma.c
i915_drv.c
i915_drv.h
i915_gem.c
i915_gem_debug.c
i915_gem_debugfs.c
i915_gem_tiling.c
i915_ioc32.c
i915_irq.c
i915_mem.c
i915_opregion.c
i915_reg.h
i915_suspend.c
intel_bios.c
intel_bios.h
intel_crt.c
intel_display.c
intel_drv.h
intel_dvo.c
intel_fb.c
intel_hdmi.c
intel_i2c.c
intel_lvds.c
intel_modes.c
intel_sdvo.c
intel_sdvo_regs.h
intel_tv.c
mga
r128
radeon
savage
sis
tdfx
via
Kconfig
Makefile
README.drm
ati_pcigart.c
drm_agpsupport.c
drm_auth.c
drm_bufs.c
drm_cache.c
drm_context.c
drm_crtc.c
drm_crtc_helper.c
drm_debugfs.c
drm_dma.c
drm_drawable.c
drm_drv.c
drm_edid.c
drm_fops.c
drm_gem.c
drm_hashtab.c
drm_info.c
drm_ioc32.c
drm_ioctl.c
drm_irq.c
drm_lock.c
drm_memory.c
drm_mm.c
drm_modes.c
drm_pci.c
drm_proc.c
drm_scatter.c
drm_sman.c
drm_stub.c
drm_sysfs.c
drm_vm.c
Makefile
hid
hwmon
i2c
ide
idle
ieee1394
infiniband
input
isdn
leds
lguest
macintosh
mca
md
media
memstick
message
mfd
misc
mmc
mtd
net
nubus
of
oprofile
parisc
parport
pci
pcmcia
platform
pnp
power
ps3
rapidio
regulator
rtc
s390
sbus
scsi
serial
sh
sn
spi
ssb
staging
tc
telephony
thermal
uio
usb
uwb
video
virtio
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
drivers
/
gpu
/
drm
/
i915
/
intel_i2c.c
Copy path
Blame
Blame
Latest commit
History
History
197 lines (172 loc) · 5.51 KB
Breadcrumbs
linux
/
drivers
/
gpu
/
drm
/
i915
/
intel_i2c.c
Top
File metadata and controls
Code
Blame
197 lines (172 loc) · 5.51 KB
Raw
/* * Copyright (c) 2006 Dave Airlie <airlied@linux.ie> * Copyright © 2006-2008 Intel Corporation * Jesse Barnes <jesse.barnes@intel.com> * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. * * Authors: * Eric Anholt <eric@anholt.net> */ #include <linux/i2c.h> #include <linux/i2c-id.h> #include <linux/i2c-algo-bit.h> #include "drmP.h" #include "drm.h" #include "intel_drv.h" #include "i915_drm.h" #include "i915_drv.h" void intel_i2c_quirk_set(struct drm_device *dev, bool enable) { struct drm_i915_private *dev_priv = dev->dev_private; /* When using bit bashing for I2C, this bit needs to be set to 1 */ if (!IS_IGD(dev)) return; if (enable) I915_WRITE(CG_2D_DIS, I915_READ(CG_2D_DIS) | DPCUNIT_CLOCK_GATE_DISABLE); else I915_WRITE(CG_2D_DIS, I915_READ(CG_2D_DIS) & (~DPCUNIT_CLOCK_GATE_DISABLE)); } /* * Intel GPIO access functions */ #define I2C_RISEFALL_TIME 20 static int get_clock(void *data) { struct intel_i2c_chan *chan = data; struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; u32 val; val = I915_READ(chan->reg); return ((val & GPIO_CLOCK_VAL_IN) != 0); } static int get_data(void *data) { struct intel_i2c_chan *chan = data; struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; u32 val; val = I915_READ(chan->reg); return ((val & GPIO_DATA_VAL_IN) != 0); } static void set_clock(void *data, int state_high) { struct intel_i2c_chan *chan = data; struct drm_device *dev = chan->drm_dev; struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; u32 reserved = 0, clock_bits; /* On most chips, these bits must be preserved in software. */ if (!IS_I830(dev) && !IS_845G(dev)) reserved = I915_READ(chan->reg) & (GPIO_DATA_PULLUP_DISABLE | GPIO_CLOCK_PULLUP_DISABLE); if (state_high) clock_bits = GPIO_CLOCK_DIR_IN | GPIO_CLOCK_DIR_MASK; else clock_bits = GPIO_CLOCK_DIR_OUT | GPIO_CLOCK_DIR_MASK | GPIO_CLOCK_VAL_MASK; I915_WRITE(chan->reg, reserved | clock_bits); udelay(I2C_RISEFALL_TIME); /* wait for the line to change state */ } static void set_data(void *data, int state_high) { struct intel_i2c_chan *chan = data; struct drm_device *dev = chan->drm_dev; struct drm_i915_private *dev_priv = chan->drm_dev->dev_private; u32 reserved = 0, data_bits; /* On most chips, these bits must be preserved in software. */ if (!IS_I830(dev) && !IS_845G(dev)) reserved = I915_READ(chan->reg) & (GPIO_DATA_PULLUP_DISABLE | GPIO_CLOCK_PULLUP_DISABLE); if (state_high) data_bits = GPIO_DATA_DIR_IN | GPIO_DATA_DIR_MASK; else data_bits = GPIO_DATA_DIR_OUT | GPIO_DATA_DIR_MASK | GPIO_DATA_VAL_MASK; I915_WRITE(chan->reg, reserved | data_bits); udelay(I2C_RISEFALL_TIME); /* wait for the line to change state */ } /** * intel_i2c_create - instantiate an Intel i2c bus using the specified GPIO reg * @dev: DRM device * @output: driver specific output device * @reg: GPIO reg to use * @name: name for this bus * * Creates and registers a new i2c bus with the Linux i2c layer, for use * in output probing and control (e.g. DDC or SDVO control functions). * * Possible values for @reg include: * %GPIOA * %GPIOB * %GPIOC * %GPIOD * %GPIOE * %GPIOF * %GPIOG * %GPIOH * see PRM for details on how these different busses are used. */ struct intel_i2c_chan *intel_i2c_create(struct drm_device *dev, const u32 reg, const char *name) { struct intel_i2c_chan *chan; chan = kzalloc(sizeof(struct intel_i2c_chan), GFP_KERNEL); if (!chan) goto out_free; chan->drm_dev = dev; chan->reg = reg; snprintf(chan->adapter.name, I2C_NAME_SIZE, "intel drm %s", name); chan->adapter.owner = THIS_MODULE; chan->adapter.algo_data = &chan->algo; chan->adapter.dev.parent = &dev->pdev->dev; chan->algo.setsda = set_data; chan->algo.setscl = set_clock; chan->algo.getsda = get_data; chan->algo.getscl = get_clock; chan->algo.udelay = 20; chan->algo.timeout = usecs_to_jiffies(2200); chan->algo.data = chan; i2c_set_adapdata(&chan->adapter, chan); if(i2c_bit_add_bus(&chan->adapter)) goto out_free; /* JJJ: raise SCL and SDA? */ intel_i2c_quirk_set(dev, true); set_data(chan, 1); set_clock(chan, 1); intel_i2c_quirk_set(dev, false); udelay(20); return chan; out_free: kfree(chan); return NULL; } /** * intel_i2c_destroy - unregister and free i2c bus resources * @output: channel to free * * Unregister the adapter from the i2c layer, then free the structure. */ void intel_i2c_destroy(struct intel_i2c_chan *chan) { if (!chan) return; i2c_del_adapter(&chan->adapter); kfree(chan); }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
You can’t perform that action at this time.