Commit 3ce2ea65 authored by Jani Nikula's avatar Jani Nikula

drm/i915: extract intel_gmbus.h from i915_drv.h and rename intel_i2c.c

It used to be handy that we only had a couple of headers, but over time
i915_drv.h has become unwieldy. Extract declarations to a separate
header file corresponding to the implementation module, clarifying the
modularity of the driver.

Ensure the new header is self-contained, and do so with minimal further
includes, using forward declarations as needed. Include the new header
only where needed, and sort the modified include directives while at it
and as needed.

While at it, rename intel_i2c.c to intel_gmbus.c and the functions to
intel_gmbus_*.

No functional changes.
Reviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/5834b8fbbfd4ac2e3d0159e69c87f6926066f537.1556809195.git.jani.nikula@intel.com
parent b30ed4cc
...@@ -176,8 +176,8 @@ i915-y += dvo_ch7017.o \ ...@@ -176,8 +176,8 @@ i915-y += dvo_ch7017.o \
intel_dsi_dcs_backlight.o \ intel_dsi_dcs_backlight.o \
intel_dsi_vbt.o \ intel_dsi_vbt.o \
intel_dvo.o \ intel_dvo.o \
intel_gmbus.o \
intel_hdmi.o \ intel_hdmi.o \
intel_i2c.o \
intel_lspcon.o \ intel_lspcon.o \
intel_lvds.o \ intel_lvds.o \
intel_panel.o \ intel_panel.o \
......
...@@ -42,6 +42,7 @@ header_test := \ ...@@ -42,6 +42,7 @@ header_test := \
intel_fbdev.h \ intel_fbdev.h \
intel_fifo_underrun.h \ intel_fifo_underrun.h \
intel_frontbuffer.h \ intel_frontbuffer.h \
intel_gmbus.h \
intel_hdcp.h \ intel_hdcp.h \
intel_hdmi.h \ intel_hdmi.h \
intel_hotplug.h \ intel_hotplug.h \
......
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include "intel_dp.h" #include "intel_dp.h"
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_fbdev.h" #include "intel_fbdev.h"
#include "intel_gmbus.h"
#include "intel_hotplug.h" #include "intel_hotplug.h"
#include "intel_overlay.h" #include "intel_overlay.h"
#include "intel_pipe_crc.h" #include "intel_pipe_crc.h"
...@@ -705,7 +706,7 @@ static int i915_load_modeset_init(struct drm_device *dev) ...@@ -705,7 +706,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
if (ret) if (ret)
goto cleanup_csr; goto cleanup_csr;
intel_setup_gmbus(dev_priv); intel_gmbus_setup(dev_priv);
/* Important: The output setup functions called by modeset_init need /* Important: The output setup functions called by modeset_init need
* working irqs for e.g. gmbus and dp aux transfers. */ * working irqs for e.g. gmbus and dp aux transfers. */
...@@ -740,7 +741,7 @@ static int i915_load_modeset_init(struct drm_device *dev) ...@@ -740,7 +741,7 @@ static int i915_load_modeset_init(struct drm_device *dev)
intel_modeset_cleanup(dev); intel_modeset_cleanup(dev);
cleanup_irq: cleanup_irq:
drm_irq_uninstall(dev); drm_irq_uninstall(dev);
intel_teardown_gmbus(dev_priv); intel_gmbus_teardown(dev_priv);
cleanup_csr: cleanup_csr:
intel_csr_ucode_fini(dev_priv); intel_csr_ucode_fini(dev_priv);
intel_power_domains_fini_hw(dev_priv); intel_power_domains_fini_hw(dev_priv);
......
...@@ -3235,23 +3235,6 @@ extern int i915_restore_state(struct drm_i915_private *dev_priv); ...@@ -3235,23 +3235,6 @@ extern int i915_restore_state(struct drm_i915_private *dev_priv);
void i915_setup_sysfs(struct drm_i915_private *dev_priv); void i915_setup_sysfs(struct drm_i915_private *dev_priv);
void i915_teardown_sysfs(struct drm_i915_private *dev_priv); void i915_teardown_sysfs(struct drm_i915_private *dev_priv);
/* intel_i2c.c */
extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
extern void intel_teardown_gmbus(struct drm_i915_private *dev_priv);
extern bool intel_gmbus_is_valid_pin(struct drm_i915_private *dev_priv,
unsigned int pin);
extern int intel_gmbus_output_aksv(struct i2c_adapter *adapter);
extern struct i2c_adapter *
intel_gmbus_get_adapter(struct drm_i915_private *dev_priv, unsigned int pin);
extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
{
return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
}
extern void intel_i2c_reset(struct drm_i915_private *dev_priv);
/* intel_device_info.c */ /* intel_device_info.c */
static inline struct intel_device_info * static inline struct intel_device_info *
mkwrite_device_info(struct drm_i915_private *dev_priv) mkwrite_device_info(struct drm_i915_private *dev_priv)
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include "i915_reg.h" #include "i915_reg.h"
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_fbc.h" #include "intel_fbc.h"
#include "intel_gmbus.h"
static void i915_save_display(struct drm_i915_private *dev_priv) static void i915_save_display(struct drm_i915_private *dev_priv)
{ {
...@@ -144,7 +145,7 @@ int i915_restore_state(struct drm_i915_private *dev_priv) ...@@ -144,7 +145,7 @@ int i915_restore_state(struct drm_i915_private *dev_priv)
mutex_unlock(&dev_priv->drm.struct_mutex); mutex_unlock(&dev_priv->drm.struct_mutex);
intel_i2c_reset(dev_priv); intel_gmbus_reset(dev_priv);
return 0; return 0;
} }
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
#include <drm/drm_dp_helper.h> #include <drm/drm_dp_helper.h>
#include <drm/i915_drm.h> #include <drm/i915_drm.h>
#include "i915_drv.h" #include "i915_drv.h"
#include "intel_gmbus.h"
#define _INTEL_BIOS_PRIVATE #define _INTEL_BIOS_PRIVATE
#include "intel_vbt_defs.h" #include "intel_vbt_defs.h"
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include "intel_ddi.h" #include "intel_ddi.h"
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_fifo_underrun.h" #include "intel_fifo_underrun.h"
#include "intel_gmbus.h"
#include "intel_hotplug.h" #include "intel_hotplug.h"
/* Here's the desired hotplug mode */ /* Here's the desired hotplug mode */
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_dsi.h" #include "intel_dsi.h"
#include "intel_fifo_underrun.h" #include "intel_fifo_underrun.h"
#include "intel_gmbus.h"
#include "intel_hdcp.h" #include "intel_hdcp.h"
#include "intel_hdmi.h" #include "intel_hdmi.h"
#include "intel_hotplug.h" #include "intel_hotplug.h"
......
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include "intel_fbdev.h" #include "intel_fbdev.h"
#include "intel_fifo_underrun.h" #include "intel_fifo_underrun.h"
#include "intel_frontbuffer.h" #include "intel_frontbuffer.h"
#include "intel_gmbus.h"
#include "intel_hdcp.h" #include "intel_hdcp.h"
#include "intel_hdmi.h" #include "intel_hdmi.h"
#include "intel_hotplug.h" #include "intel_hotplug.h"
...@@ -16641,7 +16642,7 @@ void intel_modeset_cleanup(struct drm_device *dev) ...@@ -16641,7 +16642,7 @@ void intel_modeset_cleanup(struct drm_device *dev)
intel_overlay_cleanup(dev_priv); intel_overlay_cleanup(dev_priv);
intel_teardown_gmbus(dev_priv); intel_gmbus_teardown(dev_priv);
destroy_workqueue(dev_priv->modeset_wq); destroy_workqueue(dev_priv->modeset_wq);
......
...@@ -37,6 +37,7 @@ ...@@ -37,6 +37,7 @@
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_dvo.h" #include "intel_dvo.h"
#include "intel_dvo_dev.h" #include "intel_dvo_dev.h"
#include "intel_gmbus.h"
#include "intel_panel.h" #include "intel_panel.h"
#define INTEL_DVO_CHIP_NONE 0 #define INTEL_DVO_CHIP_NONE 0
......
...@@ -26,13 +26,17 @@ ...@@ -26,13 +26,17 @@
* Eric Anholt <eric@anholt.net> * Eric Anholt <eric@anholt.net>
* Chris Wilson <chris@chris-wilson.co.uk> * Chris Wilson <chris@chris-wilson.co.uk>
*/ */
#include <linux/i2c.h>
#include <linux/i2c-algo-bit.h>
#include <linux/export.h> #include <linux/export.h>
#include <linux/i2c-algo-bit.h>
#include <linux/i2c.h>
#include <drm/drm_hdcp.h> #include <drm/drm_hdcp.h>
#include "intel_drv.h"
#include <drm/i915_drm.h> #include <drm/i915_drm.h>
#include "i915_drv.h" #include "i915_drv.h"
#include "intel_drv.h"
#include "intel_gmbus.h"
struct gmbus_pin { struct gmbus_pin {
const char *name; const char *name;
...@@ -134,7 +138,7 @@ to_intel_gmbus(struct i2c_adapter *i2c) ...@@ -134,7 +138,7 @@ to_intel_gmbus(struct i2c_adapter *i2c)
} }
void void
intel_i2c_reset(struct drm_i915_private *dev_priv) intel_gmbus_reset(struct drm_i915_private *dev_priv)
{ {
I915_WRITE(GMBUS0, 0); I915_WRITE(GMBUS0, 0);
I915_WRITE(GMBUS4, 0); I915_WRITE(GMBUS4, 0);
...@@ -256,7 +260,7 @@ intel_gpio_pre_xfer(struct i2c_adapter *adapter) ...@@ -256,7 +260,7 @@ intel_gpio_pre_xfer(struct i2c_adapter *adapter)
adapter); adapter);
struct drm_i915_private *dev_priv = bus->dev_priv; struct drm_i915_private *dev_priv = bus->dev_priv;
intel_i2c_reset(dev_priv); intel_gmbus_reset(dev_priv);
if (IS_PINEVIEW(dev_priv)) if (IS_PINEVIEW(dev_priv))
pnv_gmbus_clock_gating(dev_priv, false); pnv_gmbus_clock_gating(dev_priv, false);
...@@ -811,7 +815,7 @@ static const struct i2c_lock_operations gmbus_lock_ops = { ...@@ -811,7 +815,7 @@ static const struct i2c_lock_operations gmbus_lock_ops = {
* intel_gmbus_setup - instantiate all Intel i2c GMBuses * intel_gmbus_setup - instantiate all Intel i2c GMBuses
* @dev_priv: i915 device private * @dev_priv: i915 device private
*/ */
int intel_setup_gmbus(struct drm_i915_private *dev_priv) int intel_gmbus_setup(struct drm_i915_private *dev_priv)
{ {
struct pci_dev *pdev = dev_priv->drm.pdev; struct pci_dev *pdev = dev_priv->drm.pdev;
struct intel_gmbus *bus; struct intel_gmbus *bus;
...@@ -872,7 +876,7 @@ int intel_setup_gmbus(struct drm_i915_private *dev_priv) ...@@ -872,7 +876,7 @@ int intel_setup_gmbus(struct drm_i915_private *dev_priv)
goto err; goto err;
} }
intel_i2c_reset(dev_priv); intel_gmbus_reset(dev_priv);
return 0; return 0;
...@@ -918,7 +922,14 @@ void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit) ...@@ -918,7 +922,14 @@ void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit)
mutex_unlock(&dev_priv->gmbus_mutex); mutex_unlock(&dev_priv->gmbus_mutex);
} }
void intel_teardown_gmbus(struct drm_i915_private *dev_priv) bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
{
struct intel_gmbus *bus = to_intel_gmbus(adapter);
return bus->force_bit;
}
void intel_gmbus_teardown(struct drm_i915_private *dev_priv)
{ {
struct intel_gmbus *bus; struct intel_gmbus *bus;
unsigned int pin; unsigned int pin;
......
/* SPDX-License-Identifier: MIT */
/*
* Copyright © 2019 Intel Corporation
*/
#ifndef __INTEL_GMBUS_H__
#define __INTEL_GMBUS_H__
#include <linux/types.h>
struct drm_i915_private;
struct i2c_adapter;
int intel_gmbus_setup(struct drm_i915_private *dev_priv);
void intel_gmbus_teardown(struct drm_i915_private *dev_priv);
bool intel_gmbus_is_valid_pin(struct drm_i915_private *dev_priv,
unsigned int pin);
int intel_gmbus_output_aksv(struct i2c_adapter *adapter);
struct i2c_adapter *
intel_gmbus_get_adapter(struct drm_i915_private *dev_priv, unsigned int pin);
void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter);
void intel_gmbus_reset(struct drm_i915_private *dev_priv);
#endif /* __INTEL_GMBUS_H__ */
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#include "intel_dpio_phy.h" #include "intel_dpio_phy.h"
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_fifo_underrun.h" #include "intel_fifo_underrun.h"
#include "intel_gmbus.h"
#include "intel_hdcp.h" #include "intel_hdcp.h"
#include "intel_hdmi.h" #include "intel_hdmi.h"
#include "intel_hotplug.h" #include "intel_hotplug.h"
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "intel_atomic.h" #include "intel_atomic.h"
#include "intel_connector.h" #include "intel_connector.h"
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_gmbus.h"
#include "intel_lvds.h" #include "intel_lvds.h"
#include "intel_panel.h" #include "intel_panel.h"
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "intel_connector.h" #include "intel_connector.h"
#include "intel_drv.h" #include "intel_drv.h"
#include "intel_fifo_underrun.h" #include "intel_fifo_underrun.h"
#include "intel_gmbus.h"
#include "intel_hdmi.h" #include "intel_hdmi.h"
#include "intel_hotplug.h" #include "intel_hotplug.h"
#include "intel_panel.h" #include "intel_panel.h"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment