Changeset 3236


Ignore:
Timestamp:
Aug 29, 2012, 2:48:20 AM (3 years ago)
Author:
wmb
Message:

OLPC ARM - implemented a generic mechanism for enabling and disabling device clocks based on the "clocks" property. Important new words are "my-clock-on" and "my-clock-off", which can be called from a device instance in a node that has a "clocks" property.

Location:
cpu/arm/mmp2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpu/arm/mmp2/apbc.fth

    r3214 r3236  
    9090" clock-enable-registers" property
    9191
     92: on/off  ( on? clock# -- )
     93   get-reg&masks  if  drop exit  then  ( on? set-mask clr-mask reg )
     94   >r  r@ apbc@  and                   ( on? set-mask regval   r: reg )
     95   rot  if  or  else  nip  then        ( regval'  r: reg )
     96   r> apbc!
     97;
     98
    9299end-package
  • cpu/arm/mmp2/pmua.fth

    r3160 r3236  
    22: clocks 2 ;
    33previous definitions
     4
     5\ Given a clock index, retrieve the register offset and set/clear masks
     6\ from the clock-enable-registers property in the device node from which
     7\ this is called.  The format and usage of clock-enable-registers is
     8\ specific to PXA/MMP SoCs, but might be useful for any hardware whose
     9\ clock enabling can be expressed by clearing some register bits and
     10\ setting others.
     11
     12: get-reg&masks  ( clock# -- set-mask ~clr-mask reg false | true )
     13   " clock-enable-registers" get-property  if  ( clock# )
     14      drop true exit      ( true -- )
     15   then                   ( clock# propval$ )
     16
     17   \ Offset into clock-enable-registers array
     18   rot  h# 10 *           ( propval$ offset )
     19   2dup  <=  if           ( propval$ offset )
     20      3drop true exit     ( true -- )
     21   then                   ( propval-adr$ offset )
     22   /string                ( propval-adr$' )
     23
     24   decode-int >r          ( propval-adr$'  r: reg )
     25   decode-int invert >r   ( propval-adr$'  r: reg ~clr-mask )
     26   get-encoded-int r> r>  ( set-mask ~clr-mask reg )
     27   false                  ( set-mask ~clr-mask reg false )
     28;
    429
    5300 0  " "  " /" begin-package
     
    97122" clock-enable-registers" property
    98123
     124[ifdef] notdef
     125   " clock-enable-registers" get-property  if  ( on? clock# )
     126      2drop exit          ( -- )
     127   then                   ( on? clock# propval$ )
     128
     129   \ Offset into clock-enable-registers array
     130   rot  h# 10 *           ( on? propval$ offset )
     131   2dup  <=  if           ( on? propval$ offset )
     132      4drop exit          ( -- )
     133   then                   ( on? propval-adr$ offset )
     134   /string                ( on? propval-adr$' )
     135   
     136   \ Get register offset
     137   decode-int >r          ( on? propval-adr$'           r: reg-offset )
     138
     139   \ Apply the clear mask to the register value
     140   decode-int invert      ( on? propval-adr$' clr-mask  r: reg-offset )
     141   r@ pmua@ and           ( on? propval-adr$' regval    r: reg-offset )
     142   -rot                   ( on? regval propval-adr$     r: reg-offset )
     143
     144   \ Apply the set mask if the clock is being turned on
     145   3 roll  if             ( regval propval-adr$         r: reg-offset )
     146      get-encoded-int or  ( regval'                     r: reg-offset )
     147   else                   ( regval propval-adr$         r: reg-offset )
     148      2drop               ( regval                      r: reg-offset )
     149   then                   ( regval                      r: reg-offset )
     150
     151   \ Write back the modified register value
     152   r> pmua!               ( )
     153[then]
     154
     155: generic-on/off  ( on? clock# -- )
     156   get-reg&masks  if  drop exit  then  ( on? set-mask clr-mask reg )
     157   >r  r@ pmua@  and                   ( on? set-mask regval   r: reg )
     158   rot  if  or  else  nip  then        ( regval'  r: reg )
     159   r> pmua!
     160;
     161
     162[ifdef] mmp3
     163: ccic-isp-island-off  ( -- )
     164   h# 600 h# 1fc pmua!  \ Isolation enabled
     165   \ Fiddle with ISP_CLK_RES_CTRL here to turn off ISP engine
     166   h# 000 h# 1fc pmua!  \ Power off
     167;
     168
     169: ccic-isp-island-on   ( -- )
     170   \ set ISP regs to the default value
     171   0 h#  50 pmua!
     172   0 h# 1fc pmua!
     173
     174   \ Turn on the CCIC/ISP power switch
     175   h# 200 h# 1fc pmua!  \ Partially powered
     176   d# 10 ms
     177   h# 600 h# 1fc pmua!  \ Fully powered
     178   d# 10 ms
     179   h# 700 h# 1fc pmua!  \ Isolation disabled
     180
     181[ifdef] notdef
     182   \ Empirically, the memory redundancy and SRAMs are unnecessary
     183   \ for camera-only (no ISP) operation.
     184
     185   \ Start memory redundacy repair
     186   4 h# 224 pmua-set   \ PMUA_ISP_CLK_RES_CTRL
     187   begin  d# 10 ms h# 224 pmua@  4 and  0=  until
     188       
     189   \ Enable dummy clocks to the SRAMS
     190   h# 10 h# 1e0 pmua-set   \ PMUA_ISLD_CI_PDWN_CTRL
     191   d# 200 ms
     192   h# 10 h# 1e0 pmua-clr
     193[then]
     194
     195   \ Enable ISP clocks here if you want to use the ISP
     196   \ 8 h# 224 pmua-set  \ Enable AXI clock in PMUA_ISP_CLK_RES_CTRL
     197   \ h# f00 h# 200 h# 224 pmua-fld \ Clock divider
     198   \ h#  c0 h#  40 h# 224 pmua-fld \ CLock source
     199   \ h# 10 h# 224 pmua-set
     200
     201   \ enable CCIC clocks
     202   h# 8238 h# 50 pmua-set
     203
     204   \ Deassert ISP clocks here if you want to use the ISP
     205   \ XXX should these be pmua-clr ?
     206   \ 1 h# 224 pmua-set  \ AXI reset
     207   \ 2 h# 224 pmua-set  \ ISP SW reset
     208   \ h# 10000 h# 50 pmua-set  \ CCIC1 AXI Arbiter reset
     209
     210   \ De-assert CCIC Resets
     211   h# 10107 h# 50 pmua-set \ XXX change to 107
     212;
     213[then]
     214
     215: ccic-on/off  ( on? -- )
     216   if
     217      [ifdef] mmp3  ccic-isp-island-on  [then]
     218
     219      \ Enable clocks
     220      h#        3f h# 28 pmua!  \ Clock gating - AHB, Internal PIXCLK, AXI clock always on
     221      h# 0003.805b h# 50 pmua!  \ PMUA clock config for CCIC - /1, PLL1/16, AXI arb, AXI, perip on
     222   else
     223      h# 3f h# 50 pmua-clr
     224      [ifdef] mmp3  ccic-isp-island-off  [then]
     225   then
     226;
     227
     228: on/off  ( on? clock# -- )
     229   \ Special-case devices that need more elaborate on/off procedures
     230   dup 2  =  if     \ CCIC         ( on? clock# )
     231      drop  ccic-on/off  exit      ( -- )
     232   then                            ( on? clock# )
     233
     234   generic-on/off
     235;
     236
    99237end-package
     238
     239\ This is a general-purpose mechanism for enabling/disabling a clock
     240\ that is described by a "clocks" property in the device node.  The
     241\ property value is a phandle and an index, as used in Linux.
     242
     243: my-clock-on/off  ( on? -- )
     244   " clocks" get-my-property  abort" No clocks property"  ( on? propval$ )
     245   decode-int  >r                  ( on? propval$  r: phandle )
     246   get-encoded-int                 ( on? clock#  r: phandle )
     247   r> push-package                 ( on? clock#  )
     248   " on/off" package-execute       ( )
     249   pop-package                     ( )
     250;
     251: my-clock-off  ( -- )  false  my-clock-on/off  ;
     252: my-clock-on  ( -- )  true  my-clock-on/off  ;
Note: See TracChangeset for help on using the changeset viewer.