[PATCH 02/17] ARM: i.MX: Add function to extract BMOD value

Andrey Smirnov andrew.smirnov at gmail.com
Mon Apr 16 06:36:50 PDT 2018


On Mon, Apr 16, 2018 at 12:37 AM, Sascha Hauer <s.hauer at pengutronix.de> wrote:
> On Sat, Apr 14, 2018 at 10:50:48AM -0700, Andrey Smirnov wrote:
>> The location of BMDO field in SBMR/SBMR2 registers is consistent
>> across all i.MX SoCs starting from i.MX53. Add simple helper function
>> imx53_get_bmod and use it to avoid code duplication.
>>
>> Signed-off-by: Andrey Smirnov <andrew.smirnov at gmail.com>
>> ---
>>  arch/arm/mach-imx/boot.c | 25 ++++++++++++++-----------
>>  1 file changed, 14 insertions(+), 11 deletions(-)
>>
>> diff --git a/arch/arm/mach-imx/boot.c b/arch/arm/mach-imx/boot.c
>> index 4657fa017..56f9fb5d4 100644
>> --- a/arch/arm/mach-imx/boot.c
>> +++ b/arch/arm/mach-imx/boot.c
>> @@ -169,12 +169,23 @@ void imx51_get_boot_source(enum bootsource *src, int *instance)
>>  }
>>
>>  #define IMX53_SRC_SBMR       0x4
>> +
>> +static unsigned int sbmr(uint32_t r, unsigned int msb, unsigned int lsb)
>> +{
>> +     return (r & GENMASK(msb, lsb)) >> lsb;
>> +}
>
> If you like GENMASK then maybe the FIELD_GET and FIELD_PREP macros from
> the Linux kernel are for you aswell.
>
> #define SRC_SBMR_BMOD   GENMASK(25, 24)
>

Definetly! I like it a lot! I was hoping that something like that
existed but didn't find anything in barebox's tree. Should've checked
the kernel one instead. Will add and use in v2 of the patch.

Thanks,
Andrey Smirnov



More information about the barebox mailing list