diff --git a/ports/samd/Makefile b/ports/samd/Makefile
index 8d49778b3b..9a03502abc 100644
--- a/ports/samd/Makefile
+++ b/ports/samd/Makefile
@@ -48,7 +48,7 @@ INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/include/pio
 INC += -I$(TOP)/lib/tinyusb/src
 
 MAKE_PIN_AF = boards/make-pin-af.py
-PIN_AF_TABLE_CSV = boards/pin-af-table-$(MCU_SERIES).csv
+PIN_AF_TABLE_CSV = mcu/$(MCU_SERIES_LOWER)/pin-af-table.csv
 GEN_PIN_AF = pin_af_table.c
 
 MAKE_PINS = boards/make-pins.py
@@ -62,7 +62,6 @@ CFLAGS = $(INC) -Wall -Werror -std=c99 -nostdlib -mthumb $(CFLAGS_MCU_$(MCU_SERI
 CFLAGS += -DMCU_$(MCU_SERIES) -D__$(CMSIS_MCU)__
 CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA)
 CFLAGS += -DMPCONFIG_MCU_H='<boards/mpconfig_$(MCU_SERIES_LOWER).h>'
-CFLAGS += -DPIN_AF_TABLE_C='<$(BUILD)/$(GEN_PIN_AF)>'
 
 LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref
 LDFLAGS += $(LDFLAGS_MOD)
diff --git a/ports/samd/boards/pin-af-table-SAMD21.csv b/ports/samd/mcu/samd21/pin-af-table.csv
similarity index 95%
rename from ports/samd/boards/pin-af-table-SAMD21.csv
rename to ports/samd/mcu/samd21/pin-af-table.csv
index d8ab903c9e..6445d148b8 100644
--- a/ports/samd/boards/pin-af-table-SAMD21.csv
+++ b/ports/samd/mcu/samd21/pin-af-table.csv
@@ -59,7 +59,7 @@ pa30,10,,,12,10,
 pa31,11,,,13,11,
 pb30,14,,,50,00,12
 pb31,15,,,51,01,13
-pb00,0,,,52,70,
-pb01,1,,,53,71,
-pb02,2,,,50,60,
-pb03,3,,,51,61,
+pb00,0,8,,52,70,
+pb01,1,9,,53,71,
+pb02,2,10,,50,60,
+pb03,3,11,,51,61,
diff --git a/ports/samd/boards/pin-af-table-SAMD51.csv b/ports/samd/mcu/samd51/pin-af-table.csv
similarity index 100%
rename from ports/samd/boards/pin-af-table-SAMD51.csv
rename to ports/samd/mcu/samd51/pin-af-table.csv
diff --git a/ports/samd/pin_af.c b/ports/samd/pin_af.c
index 8c152e0d8b..926c4ae0c2 100644
--- a/ports/samd/pin_af.c
+++ b/ports/samd/pin_af.c
@@ -38,7 +38,7 @@
 
 extern const uint8_t tcc_channel_count[];
 
-#include PIN_AF_TABLE_C
+#include "pin_af_table.c"
 
 // Just look for an table entry for a given pin and raise an error
 // in case of no match (which should not happen).