From bf6f13a2b0a185e935b8554e41317ab471a4c0ec Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Mon, 23 Oct 2023 00:37:27 +0100 Subject: [PATCH] Consolidate some EEPROM Driver configuration (#22321) --- docs/eeprom_driver.md | 8 ++++++++ drivers/eeprom/eeprom_spi.h | 12 ++++++++++++ keyboards/custommk/evo70_r2/config.h | 1 + keyboards/rgbkb/mun/keymaps/default/config.h | 2 -- keyboards/rgbkb/mun/keymaps/via/config.h | 2 -- keyboards/rgbkb/sol3/keymaps/default/config.h | 3 --- keyboards/rgbkb/sol3/keymaps/via/config.h | 3 --- keyboards/tau4/config.h | 9 --------- keyboards/tzarc/djinn/rev1/config.h | 3 +-- keyboards/tzarc/djinn/rev2/config.h | 3 +-- keyboards/tzarc/ghoul/config.h | 3 +-- keyboards/vinhcatba/uncertainty/config.h | 6 +----- keyboards/xelus/kangaroo/rev1/config.h | 3 --- keyboards/xelus/pachi/rgb/rev1/config.h | 3 --- keyboards/xelus/rs108/config.h | 9 +-------- keyboards/xelus/rs60/rev2_0/config.h | 9 +-------- keyboards/xelus/valor/rev2/config.h | 3 --- keyboards/xelus/valor_frl_tkl/rev1/config.h | 6 ------ keyboards/xelus/xs108/config.h | 3 --- keyboards/xelus/xs60/hotswap/config.h | 3 --- platforms/chibios/boards/BONSAI_C4/configs/config.h | 4 +--- 21 files changed, 28 insertions(+), 70 deletions(-) diff --git a/docs/eeprom_driver.md b/docs/eeprom_driver.md index 34b6f51cbe8..c77d18c68df 100644 --- a/docs/eeprom_driver.md +++ b/docs/eeprom_driver.md @@ -66,6 +66,14 @@ Currently QMK supports 25xx-series chips over SPI. As such, requires a working s `#define EXTERNAL_EEPROM_PAGE_SIZE` | `32` | Page size of the EEPROM in bytes, as specified in the datasheet `#define EXTERNAL_EEPROM_ADDRESS_SIZE` | `2` | The number of bytes to transmit for the memory location within the EEPROM +Default values and extended descriptions can be found in `drivers/eeprom/eeprom_spi.h`. + +Alternatively, there are pre-defined hardware configurations for available chips/modules: + +Module | Equivalent `#define` | Source +-----------------|---------------------------------|------------------------------------------ +MB85RS64V FRAM | `define EEPROM_SPI_MB85RS64V` | + !> There's no way to determine if there is an SPI EEPROM actually responding. Generally, this will result in reads of nothing but zero. ## Transient Driver configuration :id=transient-eeprom-driver-configuration diff --git a/drivers/eeprom/eeprom_spi.h b/drivers/eeprom/eeprom_spi.h index 282c603565f..6a21d5516bb 100644 --- a/drivers/eeprom/eeprom_spi.h +++ b/drivers/eeprom/eeprom_spi.h @@ -16,6 +16,18 @@ #pragma once +/* + Default device configurations: + + For the Adafruit SPI Non-Volatile FRAM Breakout: https://www.adafruit.com/product/1897 + #define EEPROM_SPI_MB85RS64V +*/ +#if defined(EEPROM_SPI_MB85RS64V) +# define EXTERNAL_EEPROM_BYTE_COUNT 8192 +# define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer +# define EXTERNAL_EEPROM_ADDRESS_SIZE 2 +#endif + /* The slave select pin of the EEPROM. This needs to be a normal GPIO pin_t value, such as A7. diff --git a/keyboards/custommk/evo70_r2/config.h b/keyboards/custommk/evo70_r2/config.h index 25ab789d75f..62606cf1ee6 100644 --- a/keyboards/custommk/evo70_r2/config.h +++ b/keyboards/custommk/evo70_r2/config.h @@ -26,6 +26,7 @@ #define MATRIX_ROW_PINS { A8, A1, A2, B1, A7 } // FRAM configuration +#define EEPROM_SPI_MB85RS64V #define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A0 #define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 4 // 48MHz / 4 = 12MHz; max supported by MB85R64 is 20MHz diff --git a/keyboards/rgbkb/mun/keymaps/default/config.h b/keyboards/rgbkb/mun/keymaps/default/config.h index 9fbbfc59015..88bdc06dee1 100644 --- a/keyboards/rgbkb/mun/keymaps/default/config.h +++ b/keyboards/rgbkb/mun/keymaps/default/config.h @@ -19,5 +19,3 @@ // 20m timeout (20m * 60s * 1000mil) // #define RGB_MATRIX_TIMEOUT 1200000 #define RGB_DISABLE_WHEN_USB_SUSPENDED - -#define STM32_ONBOARD_EEPROM_SIZE 2048 diff --git a/keyboards/rgbkb/mun/keymaps/via/config.h b/keyboards/rgbkb/mun/keymaps/via/config.h index 002081a1c8f..a0f581b50a6 100644 --- a/keyboards/rgbkb/mun/keymaps/via/config.h +++ b/keyboards/rgbkb/mun/keymaps/via/config.h @@ -24,5 +24,3 @@ // 224B per layer right now #define DYNAMIC_KEYMAP_LAYER_COUNT 8 #define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 - -#define STM32_ONBOARD_EEPROM_SIZE 2048 diff --git a/keyboards/rgbkb/sol3/keymaps/default/config.h b/keyboards/rgbkb/sol3/keymaps/default/config.h index 7e467261156..88bdc06dee1 100644 --- a/keyboards/rgbkb/sol3/keymaps/default/config.h +++ b/keyboards/rgbkb/sol3/keymaps/default/config.h @@ -19,6 +19,3 @@ // 20m timeout (20m * 60s * 1000mil) // #define RGB_MATRIX_TIMEOUT 1200000 #define RGB_DISABLE_WHEN_USB_SUSPENDED - -#define STM32_ONBOARD_EEPROM_SIZE 2048 - diff --git a/keyboards/rgbkb/sol3/keymaps/via/config.h b/keyboards/rgbkb/sol3/keymaps/via/config.h index ff1ff77472b..7b7f8062619 100644 --- a/keyboards/rgbkb/sol3/keymaps/via/config.h +++ b/keyboards/rgbkb/sol3/keymaps/via/config.h @@ -25,6 +25,3 @@ // 224B per layer right now #define DYNAMIC_KEYMAP_LAYER_COUNT 8 #define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 2047 - -#define STM32_ONBOARD_EEPROM_SIZE 2048 - diff --git a/keyboards/tau4/config.h b/keyboards/tau4/config.h index 053f210c07a..e36b3b8f2e2 100644 --- a/keyboards/tau4/config.h +++ b/keyboards/tau4/config.h @@ -17,15 +17,6 @@ along with this program. If not, see . #pragma once - -// Buggy, currently disabled -/* #define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10100000 -#define EXTERNAL_EEPROM_I2C_ADDRESS(loc) (EXTERNAL_EEPROM_I2C_BASE_ADDRESS | ((((loc) >> 8) & 0x07) << 1)) -#define EXTERNAL_EEPROM_BYTE_COUNT 2048 -#define EXTERNAL_EEPROM_PAGE_SIZE 16 -#define EXTERNAL_EEPROM_ADDRESS_SIZE 1 -#define EXTERNAL_EEPROM_WRITE_TIME 5 */ - #define RGBLIGHT_LAYERS_RETAIN_VAL #define OLED_DISPLAY_WIDTH 128 diff --git a/keyboards/tzarc/djinn/rev1/config.h b/keyboards/tzarc/djinn/rev1/config.h index 5dffc00141f..cdcabed05c0 100644 --- a/keyboards/tzarc/djinn/rev1/config.h +++ b/keyboards/tzarc/djinn/rev1/config.h @@ -22,7 +22,6 @@ #define RGB_CURR_3000mA_OK_PIN C5 // EEPROM configuration +#define EEPROM_SPI_MB85RS64V #define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN B5 #define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // (160MHz/8) => 20MHz -#define EXTERNAL_EEPROM_BYTE_COUNT 8192 -#define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer size diff --git a/keyboards/tzarc/djinn/rev2/config.h b/keyboards/tzarc/djinn/rev2/config.h index 12a63724057..00a893ff650 100644 --- a/keyboards/tzarc/djinn/rev2/config.h +++ b/keyboards/tzarc/djinn/rev2/config.h @@ -25,10 +25,9 @@ #define RGB_CURR_3000mA_OK_PIN C4 // EEPROM configuration +#define EEPROM_SPI_MB85RS64V #define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN B5 #define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // (160MHz/8) => 20MHz -#define EXTERNAL_EEPROM_BYTE_COUNT 8192 -#define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer size // External flash config #define EXTERNAL_FLASH_SPI_MODE 3 diff --git a/keyboards/tzarc/ghoul/config.h b/keyboards/tzarc/ghoul/config.h index 932ea8eb50d..402f14cd924 100644 --- a/keyboards/tzarc/ghoul/config.h +++ b/keyboards/tzarc/ghoul/config.h @@ -8,8 +8,7 @@ // #define MATRIX_COLS 8 // actually defined in info.json: 8 bits per register // EEPROM configuration -#define EXTERNAL_EEPROM_BYTE_COUNT 8192 -#define EXTERNAL_EEPROM_PAGE_SIZE 64 // it's FRAM, so it doesn't actually matter, this just sets the RAM buffer +#define EEPROM_SPI_MB85RS64V // RGB configuration #define RGB_MATRIX_LED_COUNT 40 diff --git a/keyboards/vinhcatba/uncertainty/config.h b/keyboards/vinhcatba/uncertainty/config.h index 288f1d81a94..5c02b78efe6 100644 --- a/keyboards/vinhcatba/uncertainty/config.h +++ b/keyboards/vinhcatba/uncertainty/config.h @@ -19,11 +19,7 @@ #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_16_9 /* eeprom i2c driver config */ -#define EXTERNAL_EEPROM_I2C_BASE_ADDRESS 0b10100000 -#define EXTERNAL_EEPROM_BYTE_COUNT 4096 -#define EXTERNAL_EEPROM_PAGE_SIZE 32 -#define EXTERNAL_EEPROM_WRITE_TIME 10 -//#define EEPROM_I2C_24LC32 +#define EEPROM_I2C_24LC32A /* OLED config */ #define OLED_UPDATE_INTERVAL 100 diff --git a/keyboards/xelus/kangaroo/rev1/config.h b/keyboards/xelus/kangaroo/rev1/config.h index 7f246458f50..c174b67e573 100644 --- a/keyboards/xelus/kangaroo/rev1/config.h +++ b/keyboards/xelus/kangaroo/rev1/config.h @@ -35,6 +35,3 @@ // I2C EEPROM #define EEPROM_I2C_CAT24C512 - -// Dynamic EEPROM -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 65535 diff --git a/keyboards/xelus/pachi/rgb/rev1/config.h b/keyboards/xelus/pachi/rgb/rev1/config.h index baa15eaa491..e51a176c847 100644 --- a/keyboards/xelus/pachi/rgb/rev1/config.h +++ b/keyboards/xelus/pachi/rgb/rev1/config.h @@ -36,9 +36,6 @@ // I2C EEPROM #define EEPROM_I2C_24LC64 -// More EEPROM for layers -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191 - // RGB Matrix defines #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND diff --git a/keyboards/xelus/rs108/config.h b/keyboards/xelus/rs108/config.h index 9ff25facc87..45f2a545309 100644 --- a/keyboards/xelus/rs108/config.h +++ b/keyboards/xelus/rs108/config.h @@ -30,14 +30,7 @@ #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2 // EEPROM config -// 24LC32 -#define EXTERNAL_EEPROM_BYTE_COUNT 4096 -#define EXTERNAL_EEPROM_PAGE_SIZE 32 -#define EXTERNAL_EEPROM_ADDRESS_SIZE 2 -#define EXTERNAL_EEPROM_WRITE_TIME 5 - -// More EEPROM for layers -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095 +#define EEPROM_I2C_24LC32A // Hardware Defines #define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE diff --git a/keyboards/xelus/rs60/rev2_0/config.h b/keyboards/xelus/rs60/rev2_0/config.h index 9ff25facc87..45f2a545309 100644 --- a/keyboards/xelus/rs60/rev2_0/config.h +++ b/keyboards/xelus/rs60/rev2_0/config.h @@ -30,14 +30,7 @@ #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2 // EEPROM config -// 24LC32 -#define EXTERNAL_EEPROM_BYTE_COUNT 4096 -#define EXTERNAL_EEPROM_PAGE_SIZE 32 -#define EXTERNAL_EEPROM_ADDRESS_SIZE 2 -#define EXTERNAL_EEPROM_WRITE_TIME 5 - -// More EEPROM for layers -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095 +#define EEPROM_I2C_24LC32A // Hardware Defines #define EARLY_INIT_PERFORM_BOOTLOADER_JUMP TRUE diff --git a/keyboards/xelus/valor/rev2/config.h b/keyboards/xelus/valor/rev2/config.h index e5acad6f9c8..9a0146172dd 100644 --- a/keyboards/xelus/valor/rev2/config.h +++ b/keyboards/xelus/valor/rev2/config.h @@ -36,9 +36,6 @@ // I2C EEPROM #define EEPROM_I2C_24LC64 -// More EEPROM for layers -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191 - /* RGB Matrix */ #define RGB_MATRIX_LED_COUNT 28 #define NOP_FUDGE 0.4 diff --git a/keyboards/xelus/valor_frl_tkl/rev1/config.h b/keyboards/xelus/valor_frl_tkl/rev1/config.h index a03694deaa3..af702fcafda 100644 --- a/keyboards/xelus/valor_frl_tkl/rev1/config.h +++ b/keyboards/xelus/valor_frl_tkl/rev1/config.h @@ -35,10 +35,4 @@ #define I2C1_TIMINGR_SCLL 9U // I2C EEPROM -// 24LC64 #define EEPROM_I2C_24LC64 - -// Dynamic EEPROM -// Something sensible or else VIA may crash -// Users may enable more if they wish -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 4095 diff --git a/keyboards/xelus/xs108/config.h b/keyboards/xelus/xs108/config.h index 8a6ab123c43..4b3b447c957 100644 --- a/keyboards/xelus/xs108/config.h +++ b/keyboards/xelus/xs108/config.h @@ -34,6 +34,3 @@ // I2C EEPROM #define EEPROM_I2C_24LC64 - -// More EEPROM for layers -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191 diff --git a/keyboards/xelus/xs60/hotswap/config.h b/keyboards/xelus/xs60/hotswap/config.h index d1138c735de..56ecd57ec9d 100644 --- a/keyboards/xelus/xs60/hotswap/config.h +++ b/keyboards/xelus/xs60/hotswap/config.h @@ -34,9 +34,6 @@ // I2C EEPROM #define EEPROM_I2C_24LC64 -// More EEPROM for layers -#define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191 - // RGBLIGHT #define RGBLIGHT_LAYERS #define WS2812_EXTERNAL_PULLUP diff --git a/platforms/chibios/boards/BONSAI_C4/configs/config.h b/platforms/chibios/boards/BONSAI_C4/configs/config.h index 7539ebed415..193b028bdec 100644 --- a/platforms/chibios/boards/BONSAI_C4/configs/config.h +++ b/platforms/chibios/boards/BONSAI_C4/configs/config.h @@ -24,11 +24,9 @@ // FRAM configuration #ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN +# define EEPROM_SPI_MB85RS64V # define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN PAL_LINE(GPIOA, 0) # define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 // 96MHz / 8 = 12MHz; max supported by MB85R64 is 20MHz -# define EXTERNAL_EEPROM_BYTE_COUNT 8192 -# define EXTERNAL_EEPROM_PAGE_SIZE 64 // does not matter for FRAM, just sets the RAM buffer size in STM32F chip -# define DYNAMIC_KEYMAP_EEPROM_MAX_ADDR 8191 #endif // External flash configuration