diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-02-27 18:43:09 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-02-29 14:50:25 -0500 |
commit | c167a6fc6ed78a300c29181a6caf9ae1b9993289 (patch) | |
tree | 50256d2c3320ed4b4ea8481dc6fbcdaa83505a25 | |
parent | 36c785f051b21728775c9c4f2621d37d586553d0 (diff) |
drm/i915: merge gmbus and gpio i2c adpater into one
... and directly call the newly exported i2c bit-banging functions.
The code is still pretty convoluted because we only set up the gpio
i2c stuff when actually falling back, resulting in more complexity
than necessary. This will be fixed up in the next patch.
v2: Use exported i2c_bit_algo vtable instead of exported functions.
Reviewed-by: Eugeni Dodonov <eugeni.dodonov@intel.com>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/intel_i2c.c | 38 |
2 files changed, 7 insertions, 33 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 63cea5082229..47b315ca2cae 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "intel_ringbuffer.h" | 35 | #include "intel_ringbuffer.h" |
36 | #include <linux/io-mapping.h> | 36 | #include <linux/io-mapping.h> |
37 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
38 | #include <linux/i2c-algo-bit.h> | ||
38 | #include <drm/intel-gtt.h> | 39 | #include <drm/intel-gtt.h> |
39 | #include <linux/backlight.h> | 40 | #include <linux/backlight.h> |
40 | 41 | ||
@@ -303,6 +304,7 @@ struct intel_gmbus { | |||
303 | struct i2c_adapter *force_bit; | 304 | struct i2c_adapter *force_bit; |
304 | u32 reg0; | 305 | u32 reg0; |
305 | u32 gpio_reg; | 306 | u32 gpio_reg; |
307 | struct i2c_algo_bit_data bit_algo; | ||
306 | struct drm_i915_private *dev_priv; | 308 | struct drm_i915_private *dev_priv; |
307 | }; | 309 | }; |
308 | 310 | ||
diff --git a/drivers/gpu/drm/i915/intel_i2c.c b/drivers/gpu/drm/i915/intel_i2c.c index 9dfedb0e00d4..43dde957a327 100644 --- a/drivers/gpu/drm/i915/intel_i2c.c +++ b/drivers/gpu/drm/i915/intel_i2c.c | |||
@@ -154,29 +154,18 @@ intel_gpio_create(struct intel_gmbus *bus, u32 pin) | |||
154 | 0, | 154 | 0, |
155 | GPIOF, | 155 | GPIOF, |
156 | }; | 156 | }; |
157 | struct i2c_adapter *adapter; | ||
158 | struct i2c_algo_bit_data *algo; | 157 | struct i2c_algo_bit_data *algo; |
159 | 158 | ||
160 | if (pin >= ARRAY_SIZE(map_pin_to_reg) || !map_pin_to_reg[pin]) | 159 | if (pin >= ARRAY_SIZE(map_pin_to_reg) || !map_pin_to_reg[pin]) |
161 | return NULL; | 160 | return NULL; |
162 | 161 | ||
163 | adapter = kzalloc(sizeof(struct i2c_adapter), GFP_KERNEL); | 162 | algo = &bus->bit_algo; |
164 | if (adapter == NULL) | ||
165 | return NULL; | ||
166 | |||
167 | algo = kzalloc(sizeof(struct i2c_algo_bit_data), GFP_KERNEL); | ||
168 | if (algo == NULL) | ||
169 | goto out_adap; | ||
170 | 163 | ||
171 | bus->gpio_reg = map_pin_to_reg[pin]; | 164 | bus->gpio_reg = map_pin_to_reg[pin]; |
172 | if (HAS_PCH_SPLIT(dev_priv->dev)) | 165 | if (HAS_PCH_SPLIT(dev_priv->dev)) |
173 | bus->gpio_reg += PCH_GPIOA - GPIOA; | 166 | bus->gpio_reg += PCH_GPIOA - GPIOA; |
174 | 167 | ||
175 | snprintf(adapter->name, sizeof(adapter->name), | 168 | bus->adapter.algo_data = algo; |
176 | "i915 GPIO%c", "?BACDE?F"[pin]); | ||
177 | adapter->owner = THIS_MODULE; | ||
178 | adapter->algo_data = algo; | ||
179 | adapter->dev.parent = &dev_priv->dev->pdev->dev; | ||
180 | algo->setsda = set_data; | 169 | algo->setsda = set_data; |
181 | algo->setscl = set_clock; | 170 | algo->setscl = set_clock; |
182 | algo->getsda = get_data; | 171 | algo->getsda = get_data; |
@@ -185,16 +174,7 @@ intel_gpio_create(struct intel_gmbus *bus, u32 pin) | |||
185 | algo->timeout = usecs_to_jiffies(2200); | 174 | algo->timeout = usecs_to_jiffies(2200); |
186 | algo->data = bus; | 175 | algo->data = bus; |
187 | 176 | ||
188 | if (i2c_bit_add_bus(adapter)) | 177 | return &bus->adapter; |
189 | goto out_algo; | ||
190 | |||
191 | return adapter; | ||
192 | |||
193 | out_algo: | ||
194 | kfree(algo); | ||
195 | out_adap: | ||
196 | kfree(adapter); | ||
197 | return NULL; | ||
198 | } | 178 | } |
199 | 179 | ||
200 | static int | 180 | static int |
@@ -213,7 +193,7 @@ intel_i2c_quirk_xfer(struct intel_gmbus *bus, | |||
213 | set_clock(bus, 1); | 193 | set_clock(bus, 1); |
214 | udelay(I2C_RISEFALL_TIME); | 194 | udelay(I2C_RISEFALL_TIME); |
215 | 195 | ||
216 | ret = adapter->algo->master_xfer(adapter, msgs, num); | 196 | ret = i2c_bit_algo.master_xfer(adapter, msgs, num); |
217 | 197 | ||
218 | set_data(bus, 1); | 198 | set_data(bus, 1); |
219 | set_clock(bus, 1); | 199 | set_clock(bus, 1); |
@@ -353,7 +333,7 @@ static u32 gmbus_func(struct i2c_adapter *adapter) | |||
353 | adapter); | 333 | adapter); |
354 | 334 | ||
355 | if (bus->force_bit) | 335 | if (bus->force_bit) |
356 | bus->force_bit->algo->functionality(bus->force_bit); | 336 | i2c_bit_algo.functionality(bus->force_bit); |
357 | 337 | ||
358 | return (I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | | 338 | return (I2C_FUNC_I2C | I2C_FUNC_SMBUS_EMUL | |
359 | /* I2C_FUNC_10BIT_ADDR | */ | 339 | /* I2C_FUNC_10BIT_ADDR | */ |
@@ -449,9 +429,6 @@ void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit) | |||
449 | } | 429 | } |
450 | } else { | 430 | } else { |
451 | if (bus->force_bit) { | 431 | if (bus->force_bit) { |
452 | i2c_del_adapter(bus->force_bit); | ||
453 | kfree(bus->force_bit->algo); | ||
454 | kfree(bus->force_bit); | ||
455 | bus->force_bit = NULL; | 432 | bus->force_bit = NULL; |
456 | } | 433 | } |
457 | } | 434 | } |
@@ -467,11 +444,6 @@ void intel_teardown_gmbus(struct drm_device *dev) | |||
467 | 444 | ||
468 | for (i = 0; i < GMBUS_NUM_PORTS; i++) { | 445 | for (i = 0; i < GMBUS_NUM_PORTS; i++) { |
469 | struct intel_gmbus *bus = &dev_priv->gmbus[i]; | 446 | struct intel_gmbus *bus = &dev_priv->gmbus[i]; |
470 | if (bus->force_bit) { | ||
471 | i2c_del_adapter(bus->force_bit); | ||
472 | kfree(bus->force_bit->algo); | ||
473 | kfree(bus->force_bit); | ||
474 | } | ||
475 | i2c_del_adapter(&bus->adapter); | 447 | i2c_del_adapter(&bus->adapter); |
476 | } | 448 | } |
477 | 449 | ||