Hi! We're discussing a clarification of the content license; please look over to Current events if you're interested in editing.

Leo/FlashlightTest

From Htc-linux

< Leo(Redirected from LeoFlashlightTest)
Jump to: navigation, search

To test linux kernel boot with flashlight, you can use the following snippets.

Setting GPIO bank6 bit 22 enables the bright flashled. Note that this automatically disables (by hardware) after about 500ms, so you have to pay attention to the device.


[edit] ASM

WinCE Virtual

@ enable flashlight
        ldr     r4, =0x93700864        @ bank6_in (virtual)
        ldr     r5, =0x93700814        @ bank6_out (virtual)
        bic     r6, r4, #0x200000      @ clear bit if set
        str     r6, [r5, #0]           @ store with cleared bit (bright reset)
        orr     r6, r4, #0x200000      @ 22nd bit for flash
        str     r6, [r5, #0]           @ store in out (enables bright for 500ms, limited by hardware)

Linux Virtual (on codeaurora tree)

@ enable flashlight
        ldr     r4, =0xE0003864        @ bank6_in (virtual)
        ldr     r5, =0xE0003814        @ bank6_out (virtual)
        bic     r6, r4, #0x200000      @ clear bit if set
        str     r6, [r5, #0]           @ store with cleared bit (bright reset)
        orr     r6, r4, #0x200000      @ 22nd bit for flash
        str     r6, [r5, #0]           @ store in out (enables bright for 500ms, limited by hardware)

Physical

@ enable flashlight
        ldr     r4, =0xa9000864        @ bank6_in (phys)
        ldr     r5, =0xa9000814        @ bank6_out (phys)
        bic     r6, r4, #0x200000      @ clear bit if set
        str     r6, [r5, #0]           @ store with cleared bit (bright reset)
        orr     r6, r4, #0x200000      @ 22nd bit for flash
        str     r6, [r5, #0]           @ store in out (enables bright for 500ms, limited by hardware)

or without clearing bit first

@ enable flashlight
        ldr     r4, =0xa9000864        @ bank6_in (phys)
        ldr     r5, =0xa9000814        @ bank6_out (phys)
        orr     r6, r4, #0x200000      @ 22nd bit for flash
        str     r6, [r5, #0]           @ store in out (enables bright for 500ms, limited by hardware)

this MMU check not working on armv7 it seems? causes error

        mrc     p15, 0, r3, c1, c0     @ check if MMU is enabled
        tst     r3, #1

[edit] C++

Linux Virtual (on nexus one tree)

        volatile unsigned *bank6_in = (unsigned int*)(MSM_GPIO1_BASE + 0x0864);
        volatile unsigned *bank6_out = (unsigned int*)(MSM_GPIO1_BASE + 0x0814);
        *bank6_out = *bank6_in ^ 0x200000;
Personal tools