- /*(R8->uint32_6) = 0xA8081000;
- (R8->uint32_5) = 0xB3200000;
- (R8->uint32_4) = 0xB3B10000;
- (R8->uint32_3) = 0xAA0FC000;
- (R8->uint32_2) = 0xB5400000;
- (R8->uint32_1) = 0xaa0fc0b4;
- (R8->uint32_0) = 0xaa0fc0b8;*/
- struct vdc_rail_cache
- {
- unsigned int uint32_0; // = 0xaa0fc0b8
- unsigned int uint32_1; // = 0xaa0fc0b4
- unsigned int uint32_2; // = 0xB5400000
- unsigned int uint32_3; // = 0xAA0FC000
- unsigned int uint32_4; // = 0xB3B10000
- unsigned int uint32_5; // = 0xB3200000
- unsigned int uint32_6; // = 0xA8081000
- }
- static vdc_rail_cache global_vdc_rail_cache;
- // special function... some sort of lock
- int SetClkLocked( int mem_addr, int value )
- {
- int R2 = 1;
- do {
- SWPB r3, r2, [ mem_addr ]
- } while( r3 == 1 )
- * (mem_addr + 3) = value;
- return mem_addr; // doesn't have to return...
- }
- int reset_global_grp_clk_guess( int mem_addr )
- {
- // not implemented yet
- }
- /* function has 1 argument... fact */
- int mask_clock_reg_guess( int r0 )
- {
- // not implemented yet
- }
- int set_grp_clk( int arg )
- {
- if ( arg != 0 )
- {
- //axi_reset
- writel(readl(MSM_CLK_CTL_BASE+0x208) |0x20, MSM_CLK_CTL_BASE+0x208);
- //row_reset
- writel(readl(MSM_CLK_CTL_BASE+0x214) |0x20000, MSM_CLK_CTL_BASE+0x214);
- //vdd_grp gfs_ctl
- writel( 0x11f, MSM_CLK_CTL_BASE+0x284);
- // put delay here...
- // 0x11f - 0x26 cycles... pbus cycles..
- //grp NS
- writel(readl(MSM_CLK_CTL_BASE+0x84) |0x800, MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x84) |0x80, MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x84) |0x200, MSM_CLK_CTL_BASE+0x84);
- //grp idx
- writel(readl(MSM_CLK_CTL_BASE) |0x8, MSM_CLK_CTL_BASE);
- //grp clk ramp
- writel(readl(MSM_CLK_CTL_BASE+0x290) &(~(0x4)), MSM_CLK_CTL_BASE+0x290);
- //writel(readl(MSM_CLK_CTL_BASE+0x290) |0x4, MSM_CLK_CTL_BASE+0x290);
- //Suppress bit 0 of grp MD (?!?)
- writel(readl(MSM_CLK_CTL_BASE+0x80) &(~(0x1)), MSM_CLK_CTL_BASE+0x80);
- //axi_reset
- writel(readl(MSM_CLK_CTL_BASE+0x208) &(~(0x20)), MSM_CLK_CTL_BASE+0x208);
- //row_reset
- writel(readl(MSM_CLK_CTL_BASE+0x214) &(~(0x20000)), MSM_CLK_CTL_BASE+0x214);
- }
- else
- {
- //grp NS
- writel(readl(MSM_CLK_CTL_BASE+0x84) |0x800, MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x84) |0x80, MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x84) |0x200, MSM_CLK_CTL_BASE+0x84);
- //grp idx
- writel(readl(MSM_CLK_CTL_BASE) |0x8, MSM_CLK_CTL_BASE);
- //grp MD
- writel(readl(MSM_CLK_CTL_BASE+0x80) |0x1, MSM_CLK_CTL_BASE+0x80);
- int i = 0;
- int status = 0;
- while ( status == 0 && i < 100)
- {
- i++;
- status = readl(MSM_CLK_CTL_BASE+0x84) & 0x1;
- }
- writel(readl(MSM_CLK_CTL_BASE+0x208) |0x20, MSM_CLK_CTL_BASE+0x208);
- writel(readl(MSM_CLK_CTL_BASE+0x214) |0x20000, MSM_CLK_CTL_BASE+0x214);
- writel(readl(MSM_CLK_CTL_BASE+0x84) &(~(0x800)), MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x84) &(~(0x80)), MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x84) &(~(0x200)), MSM_CLK_CTL_BASE+0x84);
- writel(readl(MSM_CLK_CTL_BASE+0x290) |0x4, MSM_CLK_CTL_BASE+0x290);
- writel( 0x11f, MSM_CLK_CTL_BASE+0x284);
- R2 = * (R0 + 0x10);
- R3 = * (R2 + 0x288);
- int control = readl(MSM_CLK_CTL_BASE+0x288); //VDD_VDC_GFS_CTL
- if ( control & 0x100 )
- writel(readl(MSM_CLK_CTL_BASE) &(~(0x8)), MSM_CLK_CTL_BASE);
- }
- }
- int clk_regime_vdc_rail_off_ex( int clk_id, int arg )
- {
- if ( vdc_rail_cache->uint32_1 == 0 )
- {
- global_vdc_rail_cache->uint32_6 = 0xa8000000 | 0x81000;
- global_vdc_rail_cache->uint32_5 = 0xb3000000 | 0x200000;
- global_vdc_rail_cache->uint32_4 = 0xb3000000 | 0xb10000;
- global_vdc_rail_cache->uint32_3 = 0xaa000000 | 0xfc000;
- global_vdc_rail_cache->uint32_2 = 0xb5000000 | 0x400000;
- global_vdc_rail_cache->uint32_1 = 0xaa0fc0b4;
- global_vdc_rail_cache->uint32_0 = 0xaa0fc0b8;
- }
- if ( clk_id >= 0x11 )
- return 0;
- //int lock_vector = DoExceptionVectorHandling( 0 ); // I guess this is a try{
- SetClkLocked( vdc_rail_cache->uint32_1, 0x91 );
- int r0 = reset_global_grp_clk_guess( vdc_rail_cache->uint32_1 ); // argument is a guess, return is also guess
- unsigned int clk_bit_mask = 1 << clk_id;
- int bit_checked;
- // check if the clock is already enabled
- if ( r0 & clk_bit_mask )
- bit_checked = 0;
- else
- bit_checked = 1;
- // if we are enabling this shit... set the correct bit..
- if ( arg != 0 )
- r0 |= clk_bit_mask;
- mask_clock_reg_guess( r0 ); // argument guessed, dono if we should use its return
- switch( clk_id )
- {
- case 0:
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- case 6:
- case 7:
- case 8:
- case 9:
- case 10:
- case 11:
- case 13: // max
- // not handled for now
- break;
- case 12:
- set_grp_clk( arg );
- break;
- }
- // if we have disabled something set the correct shit..
- if ( arg == 0 )
- r0 &= ~clk_bit_mask;
- mask_clock_reg_guess( r0 )
- ResetClkLocked( vdc_rail_cache->uint32_1, 0x91 );
- writel( r0, 0xA80814F4 ); // set clock shit.. ... need to convert
- DoExceptionVectorHandling( lock_vector );
- return bit_checked;
- }