-
Notifications
You must be signed in to change notification settings - Fork 3k
Add QSPI #7783
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
Add QSPI #7783
Conversation
@@ -0,0 +1,192 @@ | |||
/* mbed Microcontroller Library |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it common practice to use specific commercial manufacturers setups in mbed Tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's common, actually it's first time. But how to figure out what frequency or what dummy cycle count is supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@OPpuolitaival Please review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know how the configuration works but this sounds wrong place to put board specific configuration. We should have some mechanism existing for these configs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually it's memory chip specific configuration.The configuration covers: max supported frequency, dummy_cycles_count for different write/read modes, mechanisms for enabling/disabling dual/quad/fast modes (which flag in which register to be set).
Here is example of adding QSPI support to new target by vendor, also contain new memory chip description file (link)
Alternatives:
- put config elsewhere (but where?)
- use SFDP as is in
QSPI SFDP Flash - Block Device
link, but it's high level mechanism, not sure if it's adequate here - reduce test to subset of common features supported by all memory chips (not a good idea, HAL tests should cover max of features available in specific API)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maciejbocianski - I have no advise on this subject, sorry.
Other than that looks great to me - thanks.
return QSPI_STATUS_OK | ||
|
||
|
||
#define QUAD_ENABLE() \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see currently those are TODOs, is there a plan to test QUAD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure dual/quad will be tested, currently we have problems to enable dual/quad mode on targets with N25Q128A memory chip
sUnknown | ||
}; | ||
|
||
struct QspiCommand { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know struct and class are both legit, but I would prefer to see here a Class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, now QspiCommand
is a class with privat _cmd
|
||
qspi_command_t * get(); | ||
|
||
qspi_command_t cmd; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another reason to make it a class - If a class would have been used, then mbed-os coding style would have required this member to be '_cmd' - later on in the cpp code its hard to tell whether cmd is a member/global/member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, now QspiCommand
is a class with privat _cmd
drivers/QSPI.h
Outdated
@@ -0,0 +1,222 @@ | |||
/* mbed Microcontroller Library | |||
* Copyright (c) 2006-2015 ARM Limited |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo I think license date should be updated
drivers/QSPI.h
Outdated
* | ||
* @param inst_width Bus width used by instruction phase(Valid values are 1,2,4) | ||
* @param address_width Bus width used by address phase(Valid values are 1,2,4) | ||
* @param address_size Size in bits used by address phase(Valid values are 8,16,24,32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here, better specifies valid ENUM values and not the integer representation which are different
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@maciejbocianski Can you remove those integers. It's obvious what type these parameters are
drivers/QSPI.h
Outdated
|
||
/** Acquire exclusive access to this SPI bus | ||
*/ | ||
virtual void lock(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we want driver lock/unlock to be public? It could potentially be misused to block other SPI users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what was the design @0xc0170 @SenRamakri , but public lock/unlock
could be utilized to synchronize between two QSPI driver instances controlling two parallel flash chips connected to the same data lines
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. I would have assumed this is made protected
at least.
@SenRamakri use case for having locks public
?
drivers/QSPI.cpp
Outdated
bool QSPI::_initialize() | ||
{ | ||
if (_mode != 0 && _mode != 1) | ||
return QSPI_STATUS_INVALID_PARAMETER; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QSPI_STATUS_INVALID_PARAMETER value (-2) is returned as boolean.
Possibly a problem can occur if "acquire" is called and you return without changing _initialized to false.
also single line 'if' should also be within {..}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AStyle to be run on this feature branch additions
drivers/QSPI.h
Outdated
|
||
/** Configure the data transmission format | ||
* | ||
* @param inst_width Bus width used by instruction phase(Valid values are 1,2,4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better use the ENUM for Valid values.
The integer representation for the valid values is 0,1,2 :
typedef enum qspi_bus_width {
QSPI_CFG_BUS_SINGLE,
QSPI_CFG_BUS_DUAL,
QSPI_CFG_BUS_QUAD,
} qspi_bus_width_t;
drivers/QSPI.cpp
Outdated
_initialized = false; | ||
|
||
//Go ahead init the device here with the default config | ||
_initialize(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ctor can not return potential failure in 'initialize' - maybe we should at least add an error log print?
@maciejbocianski - Some of my remarks appear twice due to a problem I had in my network during the review - I apologize |
for (uint32_t j = 0; j < reg_size; j++) { | ||
utest_printf("register byte %u data: ", j); | ||
for(int i = 0; i < 8; i++) { | ||
utest_printf("%s ", ((reg[j] & (1 << i)) & 0xFF) == 0 ? "0" : "1"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't it make more sense to print the register contents MSB first? I.e. do a (1 << (7-i))
instead.
Guys we need to accelerate merging this, we have some dependencies. @donatieng @dannybenor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting for the update (@offirko comments addressed)
Does this docs PR for the driver need updating, or is it still accurate? |
Update done all comments were addressed. @offirko please review @donatieng @bulislaw @0xc0170 API has changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good, let's get this one in!
Hi @AnotherButler, The porting guide is Here, we will update that, and we'll submit a new PR on the handbook. |
@jamesbeyond Thanks @kegilbert Could you please review the linked PR in place of @SenRamakri as he's out? |
@bulislaw @AnotherButler @jamesbeyond @donatieng |
/morph build |
CI related. |
/morph build |
Build : FAILUREBuild number : 2867 |
Build : FAILUREBuild number : 2870 |
1 similar comment
Build : FAILUREBuild number : 2870 |
Covering for Senthil for the docs portion, left a few comments on the Handbook PRs but overall looks pretty good. |
/morph build |
Failed while compiling
|
Build : SUCCESSBuild number : 2879 Triggering tests/morph test |
/morph export-build |
Exporter Build : FAILUREBuild number : 2498 |
Restarting . Error initialize storage for one target, eclipse. /morph export-build |
Exporter Build : FAILUREBuild number : 2499 |
Pausing Test CI until 5.9.6 PR is merged. |
Network licensing issues. Testing gap while release PR is worked on. |
Exporter Build : SUCCESSBuild number : 2509 |
/morph test |
Test : SUCCESSBuild number : 2635 |
This PR is ready now for integration. @AnotherButler Can you review API docs please (there are comments above but not touching the API docs review, so assuming it has not yet been done) ? If there are any edits needed, can you send them as subsequent PR please (this PR is required by few other dependencies so would like to have this in today to continue other work related). |
Exporter Build : FAILUREBuild number : 2514 |
Description
Bring new QSPI HAL API to master.
Pull request type
@bulislaw @donatieng @jamesbeyond @0xc0170 @offirko