Skip to content

Commit a394693

Browse files
galakMaureenHelm
authored andcommitted
drivers: flash: NXP k6x/kw2xd: Convert to use device tree
Convert NXP k6x and kw2xd flash driver to use device tree to get the flash controller name from device tree. We introduce yaml bindings for the "nxp,kinetis-ftfe" and "nxp,kinetis-ftfl" devices. Fixes: #5788 Signed-off-by: Kumar Gala <[email protected]>
1 parent 68d826c commit a394693

File tree

10 files changed

+65
-16
lines changed

10 files changed

+65
-16
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/* SoC level DTS fixup file */
2+
3+
#define FLASH_DEV_BASE_ADDRESS NXP_KINETIS_FTFE_40020000_BASE_ADDRESS_0
4+
#define FLASH_DEV_NAME NXP_KINETIS_FTFE_40020000_LABEL
5+
6+
/* End of SoC Level DTS fixup file */

arch/arm/soc/nxp_kinetis/k6x/soc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern "C" {
5454

5555
/* For IMG_MANAGER */
5656
#if defined(CONFIG_SOC_FLASH_MCUX)
57-
#define FLASH_DRIVER_NAME CONFIG_SOC_FLASH_MCUX_DEV_NAME
57+
#define FLASH_DRIVER_NAME FLASH_DEV_NAME
5858
#endif
5959

6060
#endif /* !_ASMLANGUAGE */
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* SoC level DTS fixup file */
2+
3+
#if defined(CONFIG_SOC_MKW22D5) || defined(CONFIG_SOC_MKW24D5)
4+
#define FLASH_DEV_BASE_ADDRESS NXP_KINETIS_FTFL_40020000_BASE_ADDRESS_0
5+
#define FLASH_DEV_NAME NXP_KINETIS_FTFL_40020000_LABEL
6+
#endif /* CONFIG_SOC_MKW22D5 || CONFIG_SOC_MKW24D5 */
7+
8+
/* End of SoC Level DTS fixup file */

drivers/flash/Kconfig

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ config SOC_FLASH_MCUX
149149
have an impact on the overall system performance - whether
150150
this is acceptable or not will depend on the use case.
151151

152-
config SOC_FLASH_MCUX_DEV_NAME
153-
string "MCUX flash device name"
154-
depends on SOC_FLASH_MCUX
155-
default "MCUX_FLASH"
156-
help
157-
Specify the device name for the flash driver.
158-
159152
source "drivers/flash/Kconfig.stm32"
160153

161154
source "drivers/flash/Kconfig.sam0"

drivers/flash/soc_flash_mcux.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ static int flash_mcux_init(struct device *dev)
110110
return (rc == kStatus_Success) ? 0 : -EIO;
111111
}
112112

113-
DEVICE_AND_API_INIT(flash_mcux, CONFIG_SOC_FLASH_MCUX_DEV_NAME,
113+
DEVICE_AND_API_INIT(flash_mcux, FLASH_DEV_NAME,
114114
flash_mcux_init, &flash_data, NULL, POST_KERNEL,
115115
CONFIG_KERNEL_INIT_PRIORITY_DEVICE, &flash_mcux_api);
116116

dts/arm/nxp/nxp_k6x.dtsi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,12 @@
6464
#clocks-cells = <3>;
6565
};
6666

67-
flash-controller@4001f000 {
68-
compatible = "nxp,k64f-flash-controller";
69-
reg = <0x4001f000 0x27c>;
67+
flash-controller@40020000 {
68+
compatible = "nxp,kinetis-ftfe";
69+
label = "FLASH_CTRL";
70+
reg = <0x40020000 0x18>;
7071
interrupts = <18 0>, <19 0>;
72+
interrupt-names = "command-complete", "read-collision";
7173

7274
#address-cells = <1>;
7375
#size-cells = <1>;

dts/arm/nxp/nxp_kw2xd.dtsi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@
5656
#clocks-cells = <3>;
5757
};
5858

59-
flash-controller@4001f000 {
60-
compatible = "nxp,k64f-flash-controller";
61-
reg = <0x4001f000 0x27c>;
59+
flash-controller@40020000 {
60+
compatible = "nxp,kinetis-ftfl";
61+
label = "FLASH_CTRL";
62+
reg = <0x40020000 0x18>;
6263
interrupts = <18 0>, <19 0>;
64+
interrupt-names = "command-complete", "read-collision";
6365

6466
#address-cells = <1>;
6567
#size-cells = <1>;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: NXP Kinetis Flash Memory Module (FTFE)
3+
id: nxp,kinetis-ftfe
4+
version: 0.1
5+
6+
description: >
7+
This binding gives for the NXP Kinetis Flash Memory Module E (FTFE)
8+
9+
inherits:
10+
!include flash-controller.yaml
11+
12+
properties:
13+
compatible:
14+
type: string
15+
category: required
16+
description: compatible strings
17+
constraint: "nxp,kinetis-ftfe"
18+
19+
...
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: NXP Kinetis Flash Memory Module (FTFL)
3+
id: nxp,kinetis-ftfl
4+
version: 0.1
5+
6+
description: >
7+
This binding gives for the NXP Kinetis Flash Memory Module L (FTFL)
8+
9+
inherits:
10+
!include flash-controller.yaml
11+
12+
properties:
13+
compatible:
14+
type: string
15+
category: required
16+
description: compatible strings
17+
constraint: "nxp,kinetis-ftfl"
18+
19+
...

samples/mpu/mpu_test/src/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ static int shell_cmd_write_mcux(int argc, char *argv[])
4141
ARG_UNUSED(argv);
4242

4343
struct device *flash_dev;
44-
flash_dev = device_get_binding(CONFIG_SOC_FLASH_MCUX_DEV_NAME);
44+
flash_dev = device_get_binding(FLASH_DEV_NAME);
4545

4646
u32_t value[2];
4747

0 commit comments

Comments
 (0)