internal: Don't try linux_mtd on x86

We assume that the first MTD device found represents the "internal"
firmware flash. This is true on many architectures, and assumed to
be working. On x86, however, there is traditionally no MTD device.
One exception is the `spi-intel` driver, but this one is tagged
"DANGEROUS" and often makes trouble if a Linux distribution enabled
it nevertheless.

So, let's disable the internal/MTD automatism on x86. Flashrom has
better drivers, and if somebody runs into a situation where the MTD
driver would work but the internal one doesn't, they can still use
`linux_mtd` explicitly.

Change-Id: I813980786a09fe64f541906e1963b0abd8b93cb5
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/73987
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
diff --git a/Makefile b/Makefile
index 7bd4de9..388f3c8 100644
--- a/Makefile
+++ b/Makefile
@@ -348,6 +348,13 @@
 $(call mark_unsupported,CONFIG_INTERNAL)
 endif
 
+# Try linux_mtd as internal programmer on all but x86
+ifeq ($(ARCH), x86)
+FEATURE_FLAGS += -D'LINUX_MTD_AS_INTERNAL=0'
+else
+FEATURE_FLAGS += -D'LINUX_MTD_AS_INTERNAL=1'
+endif
+
 ifeq ($(HAS_SERIAL), no)
 $(call mark_unsupported, $(DEPENDS_ON_SERIAL))
 endif
diff --git a/include/programmer.h b/include/programmer.h
index 6798851..a4e2be6 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -373,7 +373,7 @@
 void probe_superio_ite(void);
 int init_superio_ite(void);
 
-#if CONFIG_LINUX_MTD == 1
+#if CONFIG_LINUX_MTD == 1 && LINUX_MTD_AS_INTERNAL == 1
 /* trivial wrapper to avoid cluttering internal_init() with #if */
 static inline int try_mtd(void) { return programmer_linux_mtd.init(); };
 #else
diff --git a/meson.build b/meson.build
index 81b3b8b..a77c5a1 100644
--- a/meson.build
+++ b/meson.build
@@ -278,6 +278,7 @@
     'flags' : [
       '-DCONFIG_INTERNAL=1',
       '-DCONFIG_INTERNAL_DMI=' + (get_option('use_internal_dmi') ? '1' : '0'),
+      '-DLINUX_MTD_AS_INTERNAL=' + (host_machine.cpu_family() in ['x86', 'x86_64'] ? '0' : '1'),
     ]
   },
   'it8212' : {