-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[dm][nvmem] support nvmem #11032
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
[dm][nvmem] support nvmem #11032
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * Copyright (c) 2006-2023, RT-Thread Development Team | ||
| * | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| * | ||
| * Change Logs: | ||
| * Date Author Notes | ||
| * 2023-02-25 GuEe-GUI the first version | ||
| */ | ||
|
|
||
| #ifndef __NVMEM_H__ | ||
| #define __NVMEM_H__ | ||
|
|
||
| #include <ref.h> | ||
|
|
||
| #include <drivers/ofw.h> | ||
| #include <drivers/core/dm.h> | ||
| #include <drivers/core/driver.h> | ||
|
|
||
| struct rt_nvmem_device | ||
| { | ||
| struct rt_device parent; | ||
|
|
||
| int cells_nr; | ||
| rt_list_t cell_nodes; | ||
|
|
||
| rt_ssize_t (*reg_read)(struct rt_nvmem_device *, int offset, void *val, rt_size_t bytes); | ||
| rt_ssize_t (*reg_write)(struct rt_nvmem_device *, int offset, void *val, rt_size_t bytes); | ||
|
|
||
| rt_ssize_t size; | ||
| int word_size; | ||
| int stride; | ||
|
|
||
| rt_bool_t read_only; | ||
| rt_bool_t ignore_wp; | ||
| rt_base_t wp_pin; | ||
| rt_uint8_t wp_pin_active; | ||
|
|
||
| struct rt_ref ref; | ||
| struct rt_spinlock spinlock; | ||
|
|
||
| void *priv; | ||
| }; | ||
|
|
||
| struct rt_nvmem_cell | ||
| { | ||
| rt_list_t list; | ||
|
|
||
| int index; | ||
| const char *id; | ||
| const rt_bool_t free_able; | ||
|
|
||
| rt_uint32_t offset; | ||
| rt_uint32_t bytes; | ||
| rt_uint32_t bit_offset; | ||
| rt_uint32_t nbits; | ||
|
|
||
| struct rt_ref ref; | ||
|
|
||
| struct rt_ofw_node *np; | ||
| struct rt_nvmem_device *nvmem; | ||
| }; | ||
|
|
||
| rt_err_t rt_nvmem_device_register(struct rt_nvmem_device *ndev); | ||
| rt_err_t rt_nvmem_device_unregister(struct rt_nvmem_device *ndev); | ||
|
|
||
| rt_err_t rt_nvmem_device_append_cell(struct rt_nvmem_device *ndev, struct rt_nvmem_cell *cell); | ||
|
|
||
| rt_ssize_t rt_nvmem_cell_read(struct rt_nvmem_cell *cell, void *buffer, rt_size_t len); | ||
| rt_ssize_t rt_nvmem_cell_write(struct rt_nvmem_cell *cell, void *buffer, rt_size_t len); | ||
|
|
||
| rt_ssize_t rt_nvmem_cell_read_u8(struct rt_nvmem_cell *cell, rt_uint8_t *out_val); | ||
| rt_ssize_t rt_nvmem_cell_read_u16(struct rt_nvmem_cell *cell, rt_uint16_t *out_val); | ||
| rt_ssize_t rt_nvmem_cell_read_u32(struct rt_nvmem_cell *cell, rt_uint32_t *out_val); | ||
| rt_ssize_t rt_nvmem_cell_read_u64(struct rt_nvmem_cell *cell, rt_uint64_t *out_val); | ||
|
|
||
| struct rt_nvmem_cell *rt_nvmem_get_cell_by_index(struct rt_device *dev, int index); | ||
| struct rt_nvmem_cell *rt_nvmem_get_cell_by_name(struct rt_device *dev, const char *id); | ||
| void rt_nvmem_put_cell(struct rt_nvmem_cell *cell); | ||
|
|
||
| #endif /* __NVMEM_H__ */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| menuconfig RT_USING_NVMEM | ||
| bool "Using Non Volatile Memory (NVMEM) device drivers" | ||
| depends on RT_USING_DM | ||
| depends on RT_USING_OFW | ||
| depends on RT_USING_PIN | ||
| select RT_USING_ADT | ||
| select RT_USING_ADT_REF | ||
| default n | ||
|
|
||
| if RT_USING_NVMEM | ||
| osource "$(SOC_DM_NVMEM_DIR)/Kconfig" | ||
| endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| from building import * | ||
|
|
||
| group = [] | ||
|
|
||
| if not GetDepend(['RT_USING_NVMEM']): | ||
| Return('group') | ||
|
|
||
| cwd = GetCurrentDir() | ||
| CPPPATH = [cwd + '/../include'] | ||
|
|
||
| src = ['nvmem.c'] | ||
|
|
||
| group = DefineGroup('DeviceDrivers', src, depend = [''], CPPPATH = CPPPATH) | ||
|
|
||
| Return('group') |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.