Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

Untitled

By: a guest on Feb 17th, 2010  |  syntax: None  |  size: 5.32 KB  |  hits: 47  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1.  
  2. /*(R8->uint32_6) = 0xA8081000;
  3. (R8->uint32_5) = 0xB3200000;
  4. (R8->uint32_4) = 0xB3B10000;
  5. (R8->uint32_3) = 0xAA0FC000;
  6. (R8->uint32_2) = 0xB5400000;
  7. (R8->uint32_1) = 0xaa0fc0b4;
  8. (R8->uint32_0) = 0xaa0fc0b8;*/
  9.  
  10. struct vdc_rail_cache
  11. {
  12.         unsigned int uint32_0;  // = 0xaa0fc0b8
  13.         unsigned int uint32_1;  // = 0xaa0fc0b4
  14.         unsigned int uint32_2;  // = 0xB5400000
  15.         unsigned int uint32_3;  // = 0xAA0FC000
  16.         unsigned int uint32_4;  // = 0xB3B10000
  17.         unsigned int uint32_5;  // = 0xB3200000
  18.         unsigned int uint32_6;  // = 0xA8081000
  19. }
  20.  
  21. static vdc_rail_cache global_vdc_rail_cache;
  22.  
  23. // special function... some sort of lock
  24. int SetClkLocked( int mem_addr, int value )
  25. {
  26.    int R2 = 1;
  27.    do {
  28.    SWPB r3, r2, [ mem_addr ]
  29.    } while( r3 == 1 )
  30.    
  31.    * (mem_addr + 3) = value;
  32.    
  33.    return mem_addr; // doesn't have to return...
  34. }
  35.  
  36. int reset_global_grp_clk_guess( int mem_addr )
  37. {
  38. // not implemented yet
  39. }
  40.  
  41. /* function has 1 argument... fact */
  42. int mask_clock_reg_guess( int r0 )
  43. {
  44. // not implemented yet
  45. }
  46.  
  47.  
  48. int set_grp_clk( int arg )
  49. {
  50.         if ( arg != 0 )
  51.         {
  52.                 //axi_reset
  53.                 writel(readl(MSM_CLK_CTL_BASE+0x208) |0x20,          MSM_CLK_CTL_BASE+0x208);
  54.                 //row_reset
  55.                 writel(readl(MSM_CLK_CTL_BASE+0x214) |0x20000,       MSM_CLK_CTL_BASE+0x214);
  56.                 //vdd_grp gfs_ctl
  57.                 writel(                              0x11f,          MSM_CLK_CTL_BASE+0x284);
  58.                
  59.                 // put delay here...
  60.                 // 0x11f - 0x26 cycles... pbus cycles..        
  61.                
  62.                 //grp NS
  63.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  |0x800,         MSM_CLK_CTL_BASE+0x84);
  64.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  |0x80,          MSM_CLK_CTL_BASE+0x84);
  65.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  |0x200,         MSM_CLK_CTL_BASE+0x84);
  66.                 //grp idx
  67.                 writel(readl(MSM_CLK_CTL_BASE)       |0x8,           MSM_CLK_CTL_BASE);
  68.                 //grp clk ramp
  69.                 writel(readl(MSM_CLK_CTL_BASE+0x290) &(~(0x4)),      MSM_CLK_CTL_BASE+0x290);
  70.                 //writel(readl(MSM_CLK_CTL_BASE+0x290) |0x4,           MSM_CLK_CTL_BASE+0x290);
  71.                 //Suppress bit 0 of grp MD (?!?)
  72.                 writel(readl(MSM_CLK_CTL_BASE+0x80)  &(~(0x1)),      MSM_CLK_CTL_BASE+0x80);
  73.                 //axi_reset
  74.                 writel(readl(MSM_CLK_CTL_BASE+0x208) &(~(0x20)),     MSM_CLK_CTL_BASE+0x208);
  75.                 //row_reset
  76.                 writel(readl(MSM_CLK_CTL_BASE+0x214) &(~(0x20000)),  MSM_CLK_CTL_BASE+0x214);
  77.         }
  78.         else
  79.         {
  80.                 //grp NS
  81.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  |0x800,         MSM_CLK_CTL_BASE+0x84);
  82.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  |0x80,          MSM_CLK_CTL_BASE+0x84);
  83.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  |0x200,         MSM_CLK_CTL_BASE+0x84);
  84.                
  85.                 //grp idx
  86.                 writel(readl(MSM_CLK_CTL_BASE)       |0x8,           MSM_CLK_CTL_BASE);
  87.                
  88.                 //grp MD
  89.                 writel(readl(MSM_CLK_CTL_BASE+0x80)  |0x1,              MSM_CLK_CTL_BASE+0x80);
  90.  
  91.                 int i = 0;
  92.                 int status = 0;
  93.                 while ( status == 0 && i < 100)
  94.                 {
  95.                         i++;
  96.                         status = readl(MSM_CLK_CTL_BASE+0x84) & 0x1;                   
  97.                 }
  98.                
  99.                 writel(readl(MSM_CLK_CTL_BASE+0x208) |0x20,             MSM_CLK_CTL_BASE+0x208);
  100.                 writel(readl(MSM_CLK_CTL_BASE+0x214) |0x20000,          MSM_CLK_CTL_BASE+0x214);
  101.                
  102.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  &(~(0x800)),   MSM_CLK_CTL_BASE+0x84);
  103.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  &(~(0x80)),    MSM_CLK_CTL_BASE+0x84);
  104.                 writel(readl(MSM_CLK_CTL_BASE+0x84)  &(~(0x200)),   MSM_CLK_CTL_BASE+0x84);
  105.  
  106.                 writel(readl(MSM_CLK_CTL_BASE+0x290) |0x4,              MSM_CLK_CTL_BASE+0x290);
  107.                 writel(                              0x11f,         MSM_CLK_CTL_BASE+0x284);
  108.                
  109.                 R2 = * (R0 + 0x10);
  110.                 R3 = * (R2 + 0x288);
  111.                
  112.                 int control = readl(MSM_CLK_CTL_BASE+0x288); //VDD_VDC_GFS_CTL
  113.                 if ( control & 0x100 )
  114.                         writel(readl(MSM_CLK_CTL_BASE) &(~(0x8)),       MSM_CLK_CTL_BASE);
  115.         }
  116. }
  117.  
  118. int clk_regime_vdc_rail_off_ex( int clk_id, int arg )
  119. {
  120.         if ( vdc_rail_cache->uint32_1 == 0 )
  121.         {
  122.                 global_vdc_rail_cache->uint32_6 = 0xa8000000 | 0x81000;
  123.                 global_vdc_rail_cache->uint32_5 = 0xb3000000 | 0x200000;
  124.                 global_vdc_rail_cache->uint32_4 = 0xb3000000 | 0xb10000;
  125.                 global_vdc_rail_cache->uint32_3 = 0xaa000000 | 0xfc000;
  126.                 global_vdc_rail_cache->uint32_2 = 0xb5000000 | 0x400000;
  127.                 global_vdc_rail_cache->uint32_1 = 0xaa0fc0b4;
  128.                 global_vdc_rail_cache->uint32_0 = 0xaa0fc0b8;
  129.         }
  130.        
  131.         if ( clk_id >= 0x11 )
  132.                 return 0;
  133.  
  134.         //int lock_vector = DoExceptionVectorHandling( 0 ); // I guess this is a try{
  135.        
  136.         SetClkLocked( vdc_rail_cache->uint32_1, 0x91 );
  137.         int r0 = reset_global_grp_clk_guess( vdc_rail_cache->uint32_1 ); // argument is a guess, return is also guess
  138.        
  139.         unsigned int clk_bit_mask = 1 << clk_id;
  140.        
  141.         int bit_checked;
  142.        
  143.         // check if the clock is already enabled
  144.         if ( r0 & clk_bit_mask )
  145.                 bit_checked = 0;
  146.         else
  147.                 bit_checked = 1;
  148.        
  149.         // if we are enabling this shit... set the correct bit..
  150.         if ( arg != 0 )
  151.                 r0 |= clk_bit_mask;
  152.                
  153.         mask_clock_reg_guess( r0 ); // argument guessed, dono if we should use its return
  154.        
  155.         switch( clk_id )
  156.         {
  157.                 case 0:
  158.                 case 1:
  159.                 case 2:
  160.                 case 3:
  161.                 case 4:
  162.                 case 5:
  163.                 case 6:
  164.                 case 7:
  165.                 case 8:
  166.                 case 9:
  167.                 case 10:
  168.                 case 11:
  169.                 case 13: // max
  170.                 // not handled for now
  171.                 break;
  172.                
  173.                 case 12:
  174.                         set_grp_clk( arg );            
  175.                 break;
  176.         }
  177.        
  178.         // if we have disabled something set the correct shit..
  179.         if ( arg == 0 )
  180.                 r0 &= ~clk_bit_mask;
  181.                
  182.         mask_clock_reg_guess( r0 )
  183.        
  184.         ResetClkLocked( vdc_rail_cache->uint32_1, 0x91 );
  185.        
  186.         writel( r0, 0xA80814F4 ); // set clock shit.. ... need to convert
  187.        
  188.         DoExceptionVectorHandling( lock_vector );
  189.        
  190.         return bit_checked;    
  191. }