Skip to content
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 Atmel SAMA5 platform support #1714

Merged
merged 2 commits into from
Aug 31, 2017
Merged

Add Atmel SAMA5 platform support #1714

merged 2 commits into from
Aug 31, 2017

Conversation

nodeax
Copy link
Contributor

@nodeax nodeax commented Jul 24, 2017

Adding support for Atmel/Microchip SAMA5D2-XULT board

The processor supports:
ARM TrustZone, configuring memory and/or peripherals as secure, secure RTC, Secure boot, On-the-fly encryption/decryption of the DDR bus, Tamper protection etc. Datasheet.

Instructions to build optee_os along with bootlog, test results can be found here.

@nodeax
Copy link
Contributor Author

nodeax commented Jul 25, 2017 via email

Copy link
Contributor

@jforissier jforissier left a comment

Choose a reason for hiding this comment

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

  • For the first commit ("plat-sam: Add support..."), please see my review comments. I suggest you add the platform description above to the commit text, and also add a Link: tag to link to the datasheet.

  • For the second commit ("arm: pl310: Support processors without SCU"):
    Acked-by: Jerome Forissier <[email protected]>

return AT91C_BASE_MATRIX64;
}

static int matrix_configure_slave(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

The function always returns 0, so you should return void instead


CFG_WITH_STACK_CANARIES ?= y

CFG_PL310=y
Copy link
Contributor

Choose a reason for hiding this comment

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

When setting CFG_ values, please use either ?= or $(call force, ...). This commit: dffb004951df explains when to use one or the other.
Same for CFG_AT91_MATRIX below.

unsigned int array_size;
int ret;

array_size = sizeof(security_ps_peri_id) / sizeof(unsigned int);
Copy link
Contributor

Choose a reason for hiding this comment

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

Use ARRAY_SIZE from <util.h>

#define MATRIX_MEIER 0x0150 /* Master Error Interrupt Enable Register */
#define MATRIX_MEIDR 0x0154 /* Master Error Interrupt Disable Register */
#define MATRIX_MEIMR 0x0158 /* Master Error Interrupt Mask Register */
#define MATRIX_MESR 0x015c /* Master Error Statue Register */
Copy link
Contributor

Choose a reason for hiding this comment

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

s/Statue/Status/

.matrix = MATRIX_H64MX,
.security_type = SECURITY_TYPE_PS,
},
/* ARM */
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment (and all the others below) are kind of useless since they simply repeat what's written into .peri_id, they don't really improve readability either IMO. But you can keep them if you prefer.

* Treats shared accesses (bit22=0, bit13=0)
* Parity disabled (bit21=0)
* Event monitor disabled (bit20=0)
* Platform fmavor specific way config:
Copy link
Contributor

Choose a reason for hiding this comment

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

s/fmavor/flavor/

*
* I/Dcache prefetch enabled (bit29:28=2b11)
* NS can access interrupts (bit27=1)
* NS can lockown cache lines (bit26=1)
Copy link
Contributor

Choose a reason for hiding this comment

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

s/lockown/lockdown/

#ifndef __TZ_MATRIX_H__
#define __TZ_MATRIX_H__

#define MATRIX_MCFG(n) (0x0000 + (n) * 4)/* Master Configuration Register */
Copy link
Contributor

Choose a reason for hiding this comment

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

Space after ) and before /*

};

void atmel_uart_init(struct atmel_uart_data *pd, paddr_t base);
void set_mmu_flag(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

Unused? (remove)

@nodeax
Copy link
Contributor Author

nodeax commented Jul 25, 2017

@jforissier : Thanks for all the review comments/suggestions. All of them have been addressed in the updated pull request.
@MrVan: The memory map comment has been updated to reflect the correct layout.

* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __TZ_MATRIX_H__
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: different styles of header guards are used through all header files (sometimes wrapped with __ __, sometimes without them)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed in latest update.

Copy link
Contributor

@jforissier jforissier left a comment

Choose a reason for hiding this comment

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

Some more comments.

In the commit description, please move the Link: tag next to the Signed-off-by: without any blank line in between, like so:

Commit subject

Commit description
(several lines)

Link: ...
Signed-off-by: ...


for (i = 0; i < ARRAY_SIZE(peri_security_array); i++) {
if (peri_id == peri_security_array[i].peri_id)
break;
Copy link
Contributor

Choose a reason for hiding this comment

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

return &peri_security_array[i]; here and return NULL; after the loop.

matrix_write(matrix_base, MATRIX_SASSR(slave), srsplit_setting);
}

static struct peri_security *get_peri_security(unsigned int peri_id)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should probably return const struct peri_security *

unsigned int size);

extern vaddr_t matrix32_base(void);
extern vaddr_t matrix64_base(void);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are those extern needed? I don't think so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

matrix32/64_base() is being used in both matrix.c and main.c, hence it is included in the header.

I have fixed all other review comments in the updated pull request. Thanks for reviewing.

Copy link
Contributor

Choose a reason for hiding this comment

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

Huh, sorry for not being clear, I meant the extern keyword is not needed, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sorry, misread the original comment. no they are not needed, fixed in latest update.

struct peri_security *periperal_sec;
int ret;

if ((peri_id_array == NULL) || (size == 0))
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!peri_id_array || !size)

peri_id_p = peri_id_array;
for (i = 0; i < size; i++) {
periperal_sec = get_peri_security(*peri_id_p);
if (periperal_sec == NULL)
Copy link
Contributor

Choose a reason for hiding this comment

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

if (!peripheral_sec)

},
};

static inline void matrix_write(unsigned int base,
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop inline

write32(value, offset + base);
}

static inline unsigned int matrix_read(int base, unsigned int offset)
Copy link
Contributor

Choose a reason for hiding this comment

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

Drop inline

AT91C_ID_CHIPID,
};

static int matrix_config_periheral(void)
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo, and perhaps plural is better? (matrix_config_peripherals)

if (ret)
return -1;

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify:

static int matrix_config_peripherals(void)
{
        return matrix_configure_peri_security(security_ps_peri_id,
                                              ARRAY_SIZE(security_ps_peri_id));
}

if (ret)
return -1;

return 0;
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify: return matrix_config_peripherals();

@jenswi-linaro
Copy link
Contributor

Is this review still active?

@jforissier
Copy link
Contributor

LGTM, @nodeax you may add my Ack to the 2nd commit, too.
Acked-by: Jerome Forissier <[email protected]>

Not all processors might have a SCU unit. So conditionally include code
that configures SCU.

Signed-off-by: Akshay Bhat <[email protected]>
Acked-by: Jerome Forissier <[email protected]>
Add basic support to get op-tee to run on SAMA5D2-XULT board.

The SoC is based on single core ARM Cortex-A5 and supports:
 ARM TrustZone with support for configuring memory/peripherals as secure
 Secure RTC
 Secure boot
 On-the-fly encryption/decryption of DDR bus
 Tamper protection

Link: http://www.atmel.com/Images/Atmel-11267-32-bit-Cortex-A5-Microcontroller-SAMA5D2_Datasheet.pdf
Signed-off-by: Akshay Bhat <[email protected]>
Acked-by: Jerome Forissier <[email protected]>
@nodeax
Copy link
Contributor Author

nodeax commented Aug 28, 2017

@jforissier : Thanks for the review, added you Ack to the 2nd commit.
@jenswi-linaro : Was on vacation. Rebased/Verified everything still works after pulling in changes from master and also added Ack from jforissier.

@jforissier jforissier merged commit e20d1bc into OP-TEE:master Aug 31, 2017
@jforissier
Copy link
Contributor

@nodeax thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants