Skip to content

driver: flash: Add Set/ Get write protect function #90150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 28, 2025

Conversation

benson0715
Copy link
Contributor

Add Set_WP function to set SPI flash WP line to low
Add Get_WP function to obtain status of the SPI flash WP line

@@ -427,20 +427,44 @@ static int flash_read_sr2(const struct device *dev, uint8_t *val)
}
#endif

#ifdef CONFIG_FLASH_EX_OP_ENABLED
#define SPIC_BASE 0x40010200ul
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This base address is already captured by the driver config structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

#define SPIC_BASE 0x40010200ul
static int flash_set_wp(const struct device *dev, uint8_t *val, uint8_t cnt)
{
volatile uint32_t *reg = (volatile uint32_t *)(SPIC_BASE + 0x110u);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to define register 0x110 in the struct reg_spic_reg structure.

Suggested change
volatile uint32_t *reg = (volatile uint32_t *)(SPIC_BASE + 0x110u);
const struct flash_rts5912_dev_config *config = dev->config;
volatile struct reg_spic_reg *spic_reg = config->regs;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


static int flash_get_wp(const struct device *dev, uint8_t *val)
{
volatile uint32_t *reg = (volatile uint32_t *)(SPIC_BASE + 0x110u);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here - use struct reg_spic_reg to access the register at offset 0x110.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@benson0715 benson0715 force-pushed the main branch 3 times, most recently from 7209bcd to f1affb5 Compare May 22, 2025 11:08
@@ -427,20 +427,44 @@ static int flash_read_sr2(const struct device *dev, uint8_t *val)
}
#endif

#ifdef CONFIG_FLASH_EX_OP_ENABLED
static int flash_set_wp(const struct device *dev, uint8_t *val, uint8_t cnt)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cnt parameter is not used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Add Set_WP function to set SPI flash WP line to low
Add Get_WP function to obtain status of the SPI flash WP line

Signed-off-by: Benson Huang <[email protected]>
Copy link

@kartben kartben merged commit 3e8ec3a into zephyrproject-rtos:main May 28, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants