From: Valentin Longchamp <valentin.longchamp@keymile.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v2 1/4] kirkwood: add kirkwood_mpp_read function
Date: Thu, 31 May 2012 16:04:16 +0200 [thread overview]
Message-ID: <4FC77A60.1080805@keymile.com> (raw)
In-Reply-To: <F766E4F80769BD478052FB6533FA745D1A2FBA018D@SC-VEXCH4.marvell.com>
On 05/31/2012 10:49 AM, Prafulla Wadaskar wrote:
>
>
>> -----Original Message-----
>> From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
>> Sent: 31 May 2012 14:14
>> To: Prafulla Wadaskar
>> Cc: holger.brunck at keymile.com; u-boot at lists.denx.de
>> Subject: Re: [PATCH v2 1/4] kirkwood: add kirkwood_mpp_read function
>>
>> Hi Prafulla,
>>
>> On 05/31/2012 10:30 AM, Prafulla Wadaskar wrote:
>>>> -----Original Message-----
>>>> From: Valentin Longchamp [mailto:valentin.longchamp at keymile.com]
>>>> Sent: 30 May 2012 21:12
>>>> To: Prafulla Wadaskar
>>>> Cc: Valentin Longchamp; holger.brunck at keymile.com; u-
>>>> boot at lists.denx.de; Prafulla Wadaskar
>>>> Subject: [PATCH v2 1/4] kirkwood: add kirkwood_mpp_read function
>>>>
>>>> This function can be used to save current mpp state of all mpp pins
>>>> given in the mpp_list argument by reading the mpp registers, in the
>>>> second mpp_saved argument.
>>>>
>>>> A later call to kirkwood_mpp_conf function with this saved list
>> will
>>>> reset the mpp configuration as it was when kirkwood_mpp_read was
>>>> called.
>>>>
>>>> Signed-off-by: Valentin Longchamp <valentin.longchamp@keymile.com>
>>>> cc: Holger Brunck <holger.brunck@keymile.com>
>>>> cc: Prafulla Wadaskar <prafulla@marvell.com>
>>>> ---
>>>> arch/arm/cpu/arm926ejs/kirkwood/mpp.c | 41
>>>> ++++++++++++++++++++++++++++++
>>>> arch/arm/include/asm/arch-kirkwood/mpp.h | 1 +
>>>> 2 files changed, 42 insertions(+), 0 deletions(-)
>>>>
>>>> diff --git a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
>>>> b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
>>>> index 3da6c98..9fb9aea 100644
>>>> --- a/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
>>>> +++ b/arch/arm/cpu/arm926ejs/kirkwood/mpp.c
>>>> @@ -80,3 +80,44 @@ void kirkwood_mpp_conf(u32 *mpp_list)
>>>> debug("\n");
>>>>
>>>> }
>>>> +
>>>> +void kirkwood_mpp_read(u32 *mpp_list, u32 *mpp_saved)
>>>> +{
>>>> + u32 mpp_ctrl[MPP_NR_REGS];
>>>> + unsigned int variant_mask;
>>>> + int i;
>>>> +
>>>> + variant_mask = kirkwood_variant();
>>>> + if (!variant_mask)
>>>> + return;
>>>> +
>>>> + for (i = 0; i < MPP_NR_REGS; i++) {
>>>> + mpp_ctrl[i] = readl(MPP_CTRL(i));
>>>> + debug(" %08x", mpp_ctrl[i]);
>>>> + }
>>>> +
>>>> + while (*mpp_list) {
>>>> + unsigned int num = MPP_NUM(*mpp_list);
>>>> + unsigned int sel;
>>>> + int shift;
>>>> +
>>>> + if (num > MPP_MAX) {
>>>> + debug("kirkwood_mpp_conf: invalid MPP "
>>>> + "number (%u)\n", num);
>>> + continue;
>>>> + }
>>>> + if (!(*mpp_list & variant_mask)) {
>>>> + debug("kirkwood_mpp_conf: requested MPP%u config "
>>>> + "unavailable on this hardware\n", num);
>>>> + continue;
>>>> + }
>>>> +
>>>> + shift = (num & 7) << 2;
>>>> + sel = (mpp_ctrl[num / 8] >> shift) & 0xf;
>>>> + *mpp_saved = num | (sel << 8) | variant_mask;
>>>> +
>>>> + mpp_list++;
>>>> + mpp_saved++;
>>>> + }
>>>> +}
>>>> +
>>>
>>> Hi Valentin
>>> There is code duplication, similar code it already there in function
>> kirkwood_mpp_conf(), to make it short you should use kirkwood_mpp_read
>> function within kirkwood_mpp_conf
>>>
>>
>> Not sure I understand what you mean. You want me to implement the
>> kirkwood_mpp_read functionnality directly into kirkwood_mpp_conf ?
>
> Yes,
>
>>
>> If this is so, it would mean that I would have to change
>> kirkwood_mpp_conf "API"
>> to add the second argument (mpp_saved) and then I would have to fix
>> all the
>> calls to this function. Is that what you mean ?
>
> Yes, my objective here is - how good we can optimise the code.
>
> I will not stretch it further, it's up to you.
>
OK, I have done it. Sending v3 of the series in a few minutes.
next prev parent reply other threads:[~2012-05-31 14:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-30 15:42 [U-Boot] [PATCH v2 0/4] kirkwood spi_claim/release_bus support Valentin Longchamp
2012-05-30 15:42 ` [U-Boot] [PATCH v2 1/4] kirkwood: add kirkwood_mpp_read function Valentin Longchamp
2012-05-31 8:30 ` Prafulla Wadaskar
2012-05-31 8:43 ` Valentin Longchamp
2012-05-31 8:49 ` Prafulla Wadaskar
2012-05-31 14:04 ` Valentin Longchamp [this message]
2012-05-30 15:42 ` [U-Boot] [PATCH v2 2/4] kw_spi: backup and reset the MPP of the chosen CS pin Valentin Longchamp
2012-05-31 8:36 ` Prafulla Wadaskar
2012-05-31 8:45 ` Valentin Longchamp
2012-05-30 15:42 ` [U-Boot] [PATCH v2 3/4] kw_spi: support spi_claim/release_bus functions Valentin Longchamp
2012-05-31 8:44 ` Prafulla Wadaskar
2012-05-30 15:42 ` [U-Boot] [PATCH v2 4/4] kw_spi: add weak functions board_spi_claim/release_bus Valentin Longchamp
2012-05-31 8:45 ` Prafulla Wadaskar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4FC77A60.1080805@keymile.com \
--to=valentin.longchamp@keymile.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox