[U-Boot] [PATCH 4/7] ARM: sun6i: Add clock support

Olliver Schinagl oliver at schinagl.nl
Mon Sep 29 08:31:52 CEST 2014


On 28-09-14 17:42, Hans de Goede wrote:
> Hi,
>
> On 09/28/2014 05:37 PM, Ian Campbell wrote:
>> On Sun, 2014-09-28 at 17:23 +0200, Hans de Goede wrote:
>>> If you take a closer look at the code you will see not all 3 writes are the
>>> same:
>>>
>>>          /* Set PLL ldo voltage without this PLL6 does not work properly */
>>>          writel(PRCM_PLL_CTRL_LDO_DIGITAL_EN | PRCM_PLL_CTRL_LDO_ANALOG_EN |
>>>                  PRCM_PLL_CTRL_EXT_OSC_EN | PRCM_PLL_CTRL_LDO_OUT_L(1140) |
>>>                  PRCM_PLL_CTRL_LDO_KEY, &prcm->pll_ctrl1);
>>>          writel(PRCM_PLL_CTRL_LDO_DIGITAL_EN | PRCM_PLL_CTRL_LDO_ANALOG_EN |
>>>                  PRCM_PLL_CTRL_EXT_OSC_EN | PRCM_PLL_CTRL_LDO_OUT_L(1140) |
>>>                  PRCM_PLL_CTRL_LDO_KEY, &prcm->pll_ctrl1);
>>>          writel(PRCM_PLL_CTRL_LDO_DIGITAL_EN | PRCM_PLL_CTRL_LDO_ANALOG_EN |
>>>                  PRCM_PLL_CTRL_EXT_OSC_EN | PRCM_PLL_CTRL_LDO_OUT_L(1140),
>>>                  &prcm->pll_ctrl1);
>>>
>>> This register is locked with a so called "key", the first write is to set
>>> the key (and has everything else the same in case the key is already
>>> written). The second write actually makes the changes, and the third write
>>> clears the key bits.
>> Even after staring really hard I still don't see what differs in the
>> first and second ones ;-)
> Right, that is because there is no change between the first 2, I guess
> using setclr_bits to first only set the key, then only the bits, then
> only clear the key would be a good idea here :)
I think I wrote those lines ages ago, and I think i used writel instead 
of setclr_bits and friends initially, was to first 'copy' over the 
original implementation and swap magic values for defines. Once that 
could be verified to working, change over to prettier code :)

Granted, Since we have little docs and no comments, merging the first 
two lines requires some testing, which without hardware is near 
impossible. It would have probably worked having only set the key on the 
first line, key + values on the second and leave 3rd as is.

Olliver
>
> Regards,
>
> Hans



More information about the U-Boot mailing list