diff --git a/debugger/debug_rdata.c b/debugger/debug_rdata.c
index f7dc4245b962..fc7682b02581 100644
--- a/debugger/debug_rdata.c
+++ b/debugger/debug_rdata.c
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 struct eu_rdata {
 	union {
diff --git a/lib/drmtest.c b/lib/drmtest.c
index c2751e75d86a..112f04977445 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -55,6 +55,7 @@
 #include "igt_debugfs.h"
 #include "../version.h"
 #include "config.h"
+#include "intel_reg.h"
 
 /* This file contains a bunch of wrapper functions to directly use gem ioctls.
  * Mostly useful to write kernel tests. */
diff --git a/lib/gen6_render.h b/lib/gen6_render.h
index 902051484588..60dc93e6434e 100644
--- a/lib/gen6_render.h
+++ b/lib/gen6_render.h
@@ -261,10 +261,6 @@
 #define GEN6_TS_STRG_VAL		       0x7e04
 #define GEN6_TS_RDATA		       0x7e08
 
-/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
-#ifndef GEN6_TD_CTL
-#define GEN6_TD_CTL		       0x8000
-#endif
 #define GEN6_TD_CTL_MUX_SHIFT	       8
 #define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
 #define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
@@ -570,10 +566,6 @@
 #define GEN6_TS_STRG_VAL		       0x7e04
 #define GEN6_TS_RDATA		       0x7e08
 
-/* TD_CTL on gen6 is 0x7000, to not break stuff which depends on this... */
-#ifndef GEN6_TD_CTL
-#define GEN6_TD_CTL                   0x8000
-#endif
 #define GEN6_TD_CTL_MUX_SHIFT	       8
 #define GEN6_TD_CTL_EXTERNAL_HALT_R0_DEBUG_MATCH	   (1 << 7)
 #define GEN6_TD_CTL_FORCE_EXTERNAL_HALT		   (1 << 6)
diff --git a/lib/gen7_media.h b/lib/gen7_media.h
index d75ee1be8864..d5f9921adbc0 100644
--- a/lib/gen7_media.h
+++ b/lib/gen7_media.h
@@ -1,6 +1,8 @@
 #ifndef GEN7_MEDIA_H
 #define GEN7_MEDIA_H
 
+#include <stdint.h>
+
 #define GEN7_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
 #define GEN7_SURFACEFORMAT_R32G32B32A32_SINT              0x001
 #define GEN7_SURFACEFORMAT_R32G32B32A32_UINT              0x002
diff --git a/lib/gen8_media.h b/lib/gen8_media.h
index b890df4e0c8d..1214cd15a066 100644
--- a/lib/gen8_media.h
+++ b/lib/gen8_media.h
@@ -1,6 +1,8 @@
 #ifndef GEN8_MEDIA_H
 #define GEN8_MEDIA_H
 
+#include <stdint.h>
+
 #define GEN8_SURFACEFORMAT_R32G32B32A32_FLOAT             0x000
 #define GEN8_SURFACEFORMAT_R32G32B32A32_SINT              0x001
 #define GEN8_SURFACEFORMAT_R32G32B32A32_UINT              0x002
diff --git a/lib/igt_core.h b/lib/igt_core.h
index a8bb28e18e33..c21448e70add 100644
--- a/lib/igt_core.h
+++ b/lib/igt_core.h
@@ -30,6 +30,8 @@
 #ifndef IGT_CORE_H
 #define IGT_CORE_H
 
+#include <stdbool.h>
+
 bool __igt_fixture(void);
 void __igt_fixture_complete(void);
 void __igt_fixture_end(void) __attribute__((noreturn));
diff --git a/lib/igt_debugfs.h b/lib/igt_debugfs.h
index d3d23896b50c..3312a8bdb49c 100644
--- a/lib/igt_debugfs.h
+++ b/lib/igt_debugfs.h
@@ -27,9 +27,8 @@
 
 #include <stdbool.h>
 #include <stdint.h>
-#include <stdio.h>
 
-#include "igt_display.h"
+enum pipe;
 
 int igt_debugfs_open(const char *filename, int mode);
 FILE *igt_debugfs_fopen(const char *filename,
diff --git a/lib/igt_kms.h b/lib/igt_kms.h
index df658b0b4678..6590fd58dd15 100644
--- a/lib/igt_kms.h
+++ b/lib/igt_kms.h
@@ -26,11 +26,11 @@
 #define __IGT_KMS_H__
 
 #include <stdbool.h>
-
+#include <stdint.h>
 #include <drm_fourcc.h>
 #include <cairo.h>
 
-#include <igt_display.h>
+#include "igt_display.h"
 
 struct kmstest_connector_config {
 	drmModeCrtc *crtc;
diff --git a/lib/intel_batchbuffer.h b/lib/intel_batchbuffer.h
index 7764064286b9..244bdbda195d 100644
--- a/lib/intel_batchbuffer.h
+++ b/lib/intel_batchbuffer.h
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include "intel_bufmgr.h"
 #include "igt_core.h"
+#include "intel_reg.h"
 
 #define BATCH_SZ 4096
 #define BATCH_RESERVED 16
diff --git a/lib/intel_chipset.h b/lib/intel_chipset.h
index 2f3077881dd4..f6757d4aace2 100644
--- a/lib/intel_chipset.h
+++ b/lib/intel_chipset.h
@@ -28,7 +28,6 @@
 #ifndef _INTEL_CHIPSET_H
 #define _INTEL_CHIPSET_H
 
-#include <sys/types.h>
 #include <pciaccess.h>
 
 struct pci_device *intel_get_pci_device(void);
@@ -36,6 +35,7 @@ uint32_t intel_get_drm_devid(int fd);
 int intel_gen(uint32_t devid);
 
 extern enum pch_type intel_pch;
+
 enum pch_type {
 	PCH_NONE,
 	PCH_IBX,
diff --git a/lib/intel_gpu_tools.h b/lib/intel_gpu_tools.h
index aab07290f77b..591fd3f446c3 100644
--- a/lib/intel_gpu_tools.h
+++ b/lib/intel_gpu_tools.h
@@ -29,13 +29,8 @@
 #define INTEL_GPU_TOOLS_H
 
 #include <stdint.h>
-#include <sys/types.h>
 #include <pciaccess.h>
 
-#include "intel_chipset.h"
-#include "intel_reg.h"
-#include "drmtest.h"
-
 /* register access helpers from intel_mmio.c */
 extern void *mmio;
 void intel_get_mmio(struct pci_device *pci_dev);
diff --git a/lib/intel_iosf.c b/lib/intel_iosf.c
index f57212f6cc27..b7b4ce23626c 100644
--- a/lib/intel_iosf.c
+++ b/lib/intel_iosf.c
@@ -4,6 +4,7 @@
 #include <err.h>
 #include <errno.h>
 #include "intel_gpu_tools.h"
+#include "intel_reg.h"
 
 #define TIMEOUT_US 500000
 
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index 224800989189..3e1aac740a50 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -43,6 +43,7 @@
 
 #include "intel_gpu_tools.h"
 #include "igt_debugfs.h"
+#include "intel_chipset.h"
 
 #define FAKEKEY 0x2468ace0
 
diff --git a/lib/intel_os.c b/lib/intel_os.c
index ce4dcbcad5b2..4b72f5175a30 100644
--- a/lib/intel_os.c
+++ b/lib/intel_os.c
@@ -49,6 +49,7 @@
 
 #include "intel_gpu_tools.h"
 #include "i915_drm.h"
+#include "drmtest.h"
 
 uint64_t
 intel_get_total_ram_mb(void)
diff --git a/lib/intel_reg_map.c b/lib/intel_reg_map.c
index 26ddd0651438..ec63d79edfb9 100644
--- a/lib/intel_reg_map.c
+++ b/lib/intel_reg_map.c
@@ -30,6 +30,7 @@
 #include <stdlib.h>
 #include <sys/types.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static struct intel_register_range gen_bwcl_register_map[] = {
 	{0x00000000, 0x00000fff, INTEL_RANGE_RW},
diff --git a/lib/media_fill_gen7.c b/lib/media_fill_gen7.c
index 520c4a22ca75..7494d44d1536 100644
--- a/lib/media_fill_gen7.c
+++ b/lib/media_fill_gen7.c
@@ -1,5 +1,6 @@
 #include "media_fill.h"
 #include "gen7_media.h"
+#include "intel_reg.h"
 
 #include <assert.h>
 
diff --git a/lib/media_fill_gen8.c b/lib/media_fill_gen8.c
index 7e0a5677762b..d65d26085b20 100644
--- a/lib/media_fill_gen8.c
+++ b/lib/media_fill_gen8.c
@@ -1,5 +1,6 @@
 #include "media_fill.h"
 #include "gen8_media.h"
+#include "intel_reg.h"
 
 #include <assert.h>
 
diff --git a/lib/rendercopy_gen6.c b/lib/rendercopy_gen6.c
index 4f5b57904d4a..a908ae6bbe38 100644
--- a/lib/rendercopy_gen6.c
+++ b/lib/rendercopy_gen6.c
@@ -18,6 +18,7 @@
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen6_render.h"
+#include "intel_reg.h"
 
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 #define VERTEX_SIZE (3*4)
diff --git a/lib/rendercopy_gen7.c b/lib/rendercopy_gen7.c
index ddd6b97c7619..05e6829319a4 100644
--- a/lib/rendercopy_gen7.c
+++ b/lib/rendercopy_gen7.c
@@ -18,6 +18,7 @@
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen7_render.h"
+#include "intel_reg.h"
 
 #define ALIGN(x, y) (((x) + (y)-1) & ~((y)-1))
 
diff --git a/lib/rendercopy_gen8.c b/lib/rendercopy_gen8.c
index f6dd2b5b0445..ef19ebf43a60 100644
--- a/lib/rendercopy_gen8.c
+++ b/lib/rendercopy_gen8.c
@@ -18,6 +18,7 @@
 #include "intel_gpu_tools.h"
 #include "rendercopy.h"
 #include "gen8_render.h"
+#include "intel_reg.h"
 
 #include <intel_aub.h>
 
diff --git a/tests/ddi_compute_wrpll.c b/tests/ddi_compute_wrpll.c
index 9d31ebc2301e..c1db6c08de5b 100644
--- a/tests/ddi_compute_wrpll.c
+++ b/tests/ddi_compute_wrpll.c
@@ -4,6 +4,7 @@
 #include <stdlib.h>
 
 #include "intel_gpu_tools.h"
+#include "drmtest.h"
 
 #define LC_FREQ 2700
 #define LC_FREQ_2K (LC_FREQ * 2000)
diff --git a/tools/intel_audio_dump.c b/tools/intel_audio_dump.c
index 3ed291800e40..9762b4f7a195 100644
--- a/tools/intel_audio_dump.c
+++ b/tools/intel_audio_dump.c
@@ -34,6 +34,9 @@
 #include <err.h>
 #include <arpa/inet.h>
 #include "intel_gpu_tools.h"
+#include "intel_reg.h"
+#include "intel_chipset.h"
+#include "drmtest.h"
 
 static uint32_t devid;
 
diff --git a/tools/intel_backlight.c b/tools/intel_backlight.c
index bd7c813b2383..e2591847f548 100644
--- a/tools/intel_backlight.c
+++ b/tools/intel_backlight.c
@@ -31,6 +31,8 @@
 #include <string.h>
 
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
 
 /* XXX PCH only today */
 
diff --git a/tools/intel_bios_reader.c b/tools/intel_bios_reader.c
index 19b0fd92a748..8eb46f3dead6 100644
--- a/tools/intel_bios_reader.c
+++ b/tools/intel_bios_reader.c
@@ -37,6 +37,8 @@
 
 #include "intel_bios.h"
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "drmtest.h"
 
 static uint32_t devid = -1;
 
diff --git a/tools/intel_dpio_read.c b/tools/intel_dpio_read.c
index 85f8a18dc59f..2196041a6ac3 100644
--- a/tools/intel_dpio_read.c
+++ b/tools/intel_dpio_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_dpio_write.c b/tools/intel_dpio_write.c
index e09f9947bb60..c3c682a654c8 100644
--- a/tools/intel_dpio_write.c
+++ b/tools/intel_dpio_write.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_error_decode.c b/tools/intel_error_decode.c
index fff2aed57830..b1d51b74a6fc 100644
--- a/tools/intel_error_decode.c
+++ b/tools/intel_error_decode.c
@@ -55,6 +55,7 @@
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
 #include "instdone.h"
+#include "intel_reg.h"
 
 static uint32_t
 print_head(unsigned int reg)
diff --git a/tools/intel_forcewaked.c b/tools/intel_forcewaked.c
index a90e73e0f1b8..b4e7b5cc6319 100644
--- a/tools/intel_forcewaked.c
+++ b/tools/intel_forcewaked.c
@@ -35,6 +35,7 @@
 #include <syslog.h>
 #include <unistd.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 bool daemonized;
 
diff --git a/tools/intel_gpu_time.c b/tools/intel_gpu_time.c
index c30b84d200c4..0b8ca9e4c578 100644
--- a/tools/intel_gpu_time.c
+++ b/tools/intel_gpu_time.c
@@ -35,6 +35,8 @@
 #include <sys/wait.h>
 
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
 
 #define SAMPLES_PER_SEC             10000
 
diff --git a/tools/intel_gpu_top.c b/tools/intel_gpu_top.c
index 31e080a7bf4d..ccbe9736db23 100644
--- a/tools/intel_gpu_top.c
+++ b/tools/intel_gpu_top.c
@@ -44,6 +44,8 @@
 #endif
 #include "intel_gpu_tools.h"
 #include "instdone.h"
+#include "intel_reg.h"
+#include "intel_chipset.h"
 
 #define  FORCEWAKE	    0xA18C
 #define  FORCEWAKE_ACK	    0x130090
diff --git a/tools/intel_gtt.c b/tools/intel_gtt.c
index a21c26a76328..f3d1c3082052 100644
--- a/tools/intel_gtt.c
+++ b/tools/intel_gtt.c
@@ -35,6 +35,7 @@
 #include <unistd.h>
 
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 #define KB(x) ((x) * 1024)
 #define MB(x) ((x) * 1024 * 1024)
diff --git a/tools/intel_infoframes.c b/tools/intel_infoframes.c
index 81e034337277..76dd6271e1fd 100644
--- a/tools/intel_infoframes.c
+++ b/tools/intel_infoframes.c
@@ -31,6 +31,8 @@
 #include <string.h>
 #include <getopt.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "drmtest.h"
 
 typedef enum {
 	TRANSC_A = 0,
diff --git a/tools/intel_lid.c b/tools/intel_lid.c
index 51a95fee6c06..34960461382c 100644
--- a/tools/intel_lid.c
+++ b/tools/intel_lid.c
@@ -40,6 +40,7 @@
 #include "intel_gpu_tools.h"
 #include "intel_reg.h"
 #include "intel_bios.h"
+#include "intel_chipset.h"
 
 enum lid_status {
 	LID_UNKNOWN = -1,
diff --git a/tools/intel_nc_read.c b/tools/intel_nc_read.c
index a2c2e9f71e57..0ec3e75764b9 100644
--- a/tools/intel_nc_read.c
+++ b/tools/intel_nc_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_nc_write.c b/tools/intel_nc_write.c
index 58be79a6c8b7..5700f67f3f2f 100644
--- a/tools/intel_nc_write.c
+++ b/tools/intel_nc_write.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_opregion_decode.c b/tools/intel_opregion_decode.c
index 8a9ef209d4da..0beece699a1d 100644
--- a/tools/intel_opregion_decode.c
+++ b/tools/intel_opregion_decode.c
@@ -38,6 +38,7 @@
 #include <sys/types.h>
 
 #include "intel_gpu_tools.h"
+#include "drmtest.h"
 
 #define OPREGION_HEADER_OFFSET		0
 #define OPREGION_ACPI_OFFSET		0x100
diff --git a/tools/intel_panel_fitter.c b/tools/intel_panel_fitter.c
index f6723d1799f8..2e3f6883d9c5 100644
--- a/tools/intel_panel_fitter.c
+++ b/tools/intel_panel_fitter.c
@@ -31,6 +31,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
 
 int gen;
 
diff --git a/tools/intel_punit_read.c b/tools/intel_punit_read.c
index 3fa2ca8cd764..187bd77c7b0c 100644
--- a/tools/intel_punit_read.c
+++ b/tools/intel_punit_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_punit_write.c b/tools/intel_punit_write.c
index eb036ba96a50..c0aa08530353 100644
--- a/tools/intel_punit_write.c
+++ b/tools/intel_punit_write.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void usage(char *cmdname)
 {
diff --git a/tools/intel_reg_checker.c b/tools/intel_reg_checker.c
index daa8d0fbe6f3..a2c76419fbcd 100644
--- a/tools/intel_reg_checker.c
+++ b/tools/intel_reg_checker.c
@@ -27,6 +27,7 @@
 #include <string.h>
 #include <stdbool.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static uint32_t devid;
 static int gen;
diff --git a/tools/intel_reg_dumper.c b/tools/intel_reg_dumper.c
index 65fe41ebf610..432892aec3ac 100644
--- a/tools/intel_reg_dumper.c
+++ b/tools/intel_reg_dumper.c
@@ -34,6 +34,9 @@
 #include <err.h>
 #include <unistd.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
+#include "intel_reg.h"
+#include "drmtest.h"
 
 static uint32_t devid = 0;
 
diff --git a/tools/intel_reg_read.c b/tools/intel_reg_read.c
index ae631be02eb2..961248a02db4 100644
--- a/tools/intel_reg_read.c
+++ b/tools/intel_reg_read.c
@@ -31,6 +31,7 @@
 #include <err.h>
 #include <string.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void bit_decode(uint32_t reg)
 {
diff --git a/tools/intel_reg_snapshot.c b/tools/intel_reg_snapshot.c
index 9c5fa839dc61..09a95b3932c4 100644
--- a/tools/intel_reg_snapshot.c
+++ b/tools/intel_reg_snapshot.c
@@ -27,6 +27,7 @@
 #include <unistd.h>
 #include <assert.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 int main(int argc, char** argv)
 {
diff --git a/tools/intel_reg_write.c b/tools/intel_reg_write.c
index dd636f65dcc3..0f73a7706ece 100644
--- a/tools/intel_reg_write.c
+++ b/tools/intel_reg_write.c
@@ -30,6 +30,7 @@
 #include <stdio.h>
 #include <err.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 int main(int argc, char** argv)
 {
diff --git a/tools/intel_stepping.c b/tools/intel_stepping.c
index f6f15d1ac082..626c5bbb0010 100644
--- a/tools/intel_stepping.c
+++ b/tools/intel_stepping.c
@@ -33,6 +33,7 @@
 #include <err.h>
 #include "intel_chipset.h"
 #include "intel_gpu_tools.h"
+#include "intel_reg.h"
 
 static void
 print_clock(const char *name, int clock) {
diff --git a/tools/intel_vga_read.c b/tools/intel_vga_read.c
index 7d868195b244..40a9cdc869ca 100644
--- a/tools/intel_vga_read.c
+++ b/tools/intel_vga_read.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <sys/io.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static uint8_t read_reg(uint32_t reg, bool use_mmio)
 {
diff --git a/tools/intel_vga_write.c b/tools/intel_vga_write.c
index effca462bfd6..91af0fe5017a 100644
--- a/tools/intel_vga_write.c
+++ b/tools/intel_vga_write.c
@@ -32,6 +32,7 @@
 #include <unistd.h>
 #include <sys/io.h>
 #include "intel_gpu_tools.h"
+#include "intel_chipset.h"
 
 static void write_reg(uint32_t reg, uint8_t val, bool use_mmio)
 {
