One thing you can do to keep prevent the runaway dependencies on
specific chips is to parameterized the features. For example, if
STM32abc, STM32def, and STM32ghi and have FEATURE_X, then instead of
conditioning the implementation of FEATURE_X on all of those MCUs, you
could minimize the chaos by defining a single CONFIG_STM32_FEATURE_X
Then conditioning the implementation of FEATURE_X on only that one
parameter.
Also, use separater files when the logic is vastly different. Look,
for example, at how many stm32*_rcc.c files there are in stm32/. The
correct one is selected in the Make.defs.
Mateusz and DavidS have also been championing the use of versioned
driver files. Look at how stm32_dma_v1.c and stm32_dma_v2.c are managed
under stm32/ as an example. I have not looked at ChibiOS, but my
understanding is that they share all of the drivers for all of the
STM32's in some fashion using some versioning. But then the author
works for STM32 a surely has a better understanding of the IP versioning
than we do.
There are a few things that you can do to order support several large
families of STM32 parts under a single directory. I am glad you are
considering this seriously. Most people have not.