boot: zephyr: obtain FLASH_DRIVER_NAME, FLASH_ALIGN from OS

Zephyr now provides defines for FLASH_DRIVER_NAME and
FLASH_WRITE_BLOCK_SIZE (which is what we call FLASH_ALIGN) in
the SoC headers for most targets supported by mcuboot. Use that
information when it's available, falling back on MCUBOOT_TARGET_CONFIG
otherwise.

The soc_family_foo.h files remain for FLASH_AREA_IMAGE_SECTOR_SIZE.  A
subsequent patch can remove these files when the relevant SoC flash
driver provides a page layout.

Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
diff --git a/boot/zephyr/include/target.h b/boot/zephyr/include/target.h
index 6e4fe31..8a3b14d 100644
--- a/boot/zephyr/include/target.h
+++ b/boot/zephyr/include/target.h
@@ -6,12 +6,24 @@
 #ifndef H_TARGETS_TARGET_
 #define H_TARGETS_TARGET_
 
-/* Board-specific definitions go first, to allow maximum override. */
 #if defined(MCUBOOT_TARGET_CONFIG)
+/*
+ * Target-specific definitions are permitted in legacy cases that
+ * don't provide the information via DTS, etc.
+ */
 #include MCUBOOT_TARGET_CONFIG
-#endif
+#else
+/*
+ * Otherwise, the Zephyr SoC header and the DTS provide most
+ * everything we need.
+ *
+ * TODO: remove soc_family_foo.h once image sector sizes come from the
+ * flash driver.
+ */
+#include <soc.h>
 
-/* SoC family configuration. */
+#define FLASH_ALIGN FLASH_WRITE_BLOCK_SIZE
+
 #if defined(CONFIG_SOC_FAMILY_NRF5)
 #include "soc_family_nrf5.h"
 #elif defined(CONFIG_SOC_FAMILY_STM32)
@@ -19,11 +31,10 @@
 #elif defined(CONFIG_SOC_FAMILY_KINETIS)
 #include "soc_family_kinetis.h"
 #endif
+#endif /* !defined(MCUBOOT_TARGET_CONFIG) */
 
 /*
- * This information can come from DTS, a target-specific header file,
- * or an SoC-specific header file. If any of it is missing, target
- * support is incomplete.
+ * Sanity check the target support.
  */
 #if !defined(FLASH_DRIVER_NAME) || \
     !defined(FLASH_ALIGN) ||                  \
diff --git a/boot/zephyr/targets/soc_family_kinetis.h b/boot/zephyr/targets/soc_family_kinetis.h
index 71929e1..ab60e09 100644
--- a/boot/zephyr/targets/soc_family_kinetis.h
+++ b/boot/zephyr/targets/soc_family_kinetis.h
@@ -4,7 +4,5 @@
  */
 
 #ifdef CONFIG_SOC_SERIES_KINETIS_K6X
-#define FLASH_DRIVER_NAME		CONFIG_SOC_FLASH_MCUX_DEV_NAME
-#define FLASH_ALIGN			8
 #define FLASH_AREA_IMAGE_SECTOR_SIZE	0x01000
 #endif
diff --git a/boot/zephyr/targets/soc_family_nrf5.h b/boot/zephyr/targets/soc_family_nrf5.h
index c0baeaf..7fbdb71 100644
--- a/boot/zephyr/targets/soc_family_nrf5.h
+++ b/boot/zephyr/targets/soc_family_nrf5.h
@@ -3,8 +3,4 @@
  *  SPDX-License-Identifier: Apache-2.0
  */
 
-#include <soc.h>
-
 #define FLASH_AREA_IMAGE_SECTOR_SIZE (NRF_FICR->CODEPAGESIZE)
-#define FLASH_DRIVER_NAME CONFIG_SOC_FLASH_NRF5_DEV_NAME
-#define FLASH_ALIGN 4
diff --git a/boot/zephyr/targets/soc_family_stm32.h b/boot/zephyr/targets/soc_family_stm32.h
index cf21bb0..4e7b9e3 100644
--- a/boot/zephyr/targets/soc_family_stm32.h
+++ b/boot/zephyr/targets/soc_family_stm32.h
@@ -3,11 +3,6 @@
  *  SPDX-License-Identifier: Apache-2.0
  */
 
-#include <zephyr.h>
-#include <soc.h>
-
-#define FLASH_DRIVER_NAME               CONFIG_SOC_FLASH_STM32_DEV_NAME
-
 #if defined(CONFIG_SOC_SERIES_STM32F4X)
 /*
  * The Zephyr flash driver will let us remove the need for
@@ -22,8 +17,6 @@
      FLASH_AREA_IMAGE_0_OFFSET >= KB(128))
 #define FLASH_AREA_IMAGE_SECTOR_SIZE    0x20000
 #endif
-#define FLASH_ALIGN                     1
 #elif defined(CONFIG_SOC_SERIES_STM32L4X) /* !CONFIG_SOC_SERIES_STM32F4X */
-#define FLASH_ALIGN                     8
 #define FLASH_AREA_IMAGE_SECTOR_SIZE    FLASH_PAGE_SIZE /* from the HAL */
 #endif /* CONFIG_SOC_SERIES_STM32F4X */