Re: problems writing to mem

From: Philip Blundell <pb_at_nexus.co.uk>
Date: Thu, 11 Mar 2004 19:45:33 +0000

Can you write to any HAMCOP registers successfully? If not, check your
MSC settings are correct, particularly the VLIO bit.

If you can write to other registers but not the LEDs, this probably
means that the clock to the LED block is stopped. Refer to the power
and clock chapter of the HAMCOP book to find out how to turn it on, or
take a look at the equivalent code for SAMCOP.

p.

On Thu, 2004-03-11 at 18:50, Danny Norging wrote:
> Hi,
>
> currenly i am playing with the leds. Using HaRET and the script below,
> all is working well, but when it comes to writing to mem from inside
> linux i am stuck :(
>
> First I tried from userspace with devmem2 tool found at:
> http://www.lart.tudelft.nl/lartware/port/devmem2.c
>
> If you are also missing a /dev/mem, a "mknod /dev/mem c 1 1" will help.
> Reading the mem at 0x7200 works well, see the following logs:
>
> /home # # amber is blinking (charging)
> /home # ./devmem2 0x7200
> /dev/mem opened.
> Memory mapped at address 0x4013f000.
> Value at address 0x7200 (0x4013f200): 0x41
>
> <restart linux>
>
> /home # # amber is on (full)
> /home # ./devmem2 0x7200
> /dev/mem opened.
> Memory mapped at address 0x4013f000.
> Value at address 0x7200 (0x4013f200): 0x13
>
> Decoded with the info from
> http://www.handhelds.org/platforms/hp/ipaq-h22xx/12-led_driver.pdf
> 0x41 means LED0_ENB is set (blinking) and 0x13 means LED0_INITV is set
> (switched-on), so the address is correct :), *but*
>
> /home # ./devmem2 0x7200 h 0
> /dev/mem opened.
> Memory mapped at address 0x4013f000.
> Value at address 0x7200 (0x4013f200): 0x13
> Written 0x0; readback 0x13
>
> It doesnt matter if i use b(yte), h(alfword) or w(ord) as write access
> type, the value simply isnt written to mem :(
>
> So, my first guess was, that this is some sort of limitation on
> userspace, so I wrote a small kernel module to check this out. I used
> the sample "Hello world" module found at
> http://lwn.net/Articles/driver-porting/ (which is btw a great source of
> info) and tried the following inside init:
>
> void *target;
> target=ioremap(0x7200UL,4);
> writeb(0,target);
> outb(0,target);
>
> Same result here, address seems ok, but writing to mem (also with w,l
> variants) simply doesnt work...
>
> Thats it for the moment, every comment is *higly* appreciated.
>
> Thanks to all of you for doing such a *fantastic* job!
>
> Greetings
> Danny
>
>
> # copy and paste me into a telnet session with HaRET running
>
> # goal of this session will be to: get <count> blinks of led x
> set count 5
>
> # set LEDCON:LED Control register offsets
> # note: when x=0 and x=1 are *both* active, color is yellow
> # x=3 and x=4 seem not to be connected
> set LEDxCON0 0x7200 # x=0 -> amber led right side
> set LEDxCON1 0x7204
> # or
> set LEDxCON0 0x7208 # x=1 -> green led right side
> set LEDxCON1 0x720c
> # or
> set LEDxCON0 0x7210 # x=2 -> blue led left side
> set LEDxCON1 0x7214
> # as only the LEDrCLK bit from LED0CON0 register is used we need
> set LED0CON0 0x7200
> set LEDPS0 0x7228
> set LEDPS1 0x722c
>
> # set LEDxCON0 bits and masks
> set LEDxrENB 0x1 # [0]
> set LEDxrINITV 0x2 # [1]
> set mLEDxrCMP 0x1f0 # [8:4]
> set LEDxrCNTEN 0x200 # [9]
> set LEDrCLK 0x400 # [10]
>
> # set LEDxCON1 bits and masks
> set mLEDxrCNT 0x7ff # [10:0]
> set mLEDxrDIV 0xf800 # [15:11]
>
> # set LEDPSy masks
> set mLEDPS0 0xffff # [15:0]
> set mLEDPS1 0x7ff # [10:0]
>
> # set some vars
> # pocketpc uses 0x40 as LEDxrCMP so we keep it; just remember that
> # 0x0 <= LEDxrCMP <= 0x1f0 AND LEDxrCMP <= LEDxrDIV
> set LEDxrCMP 0x40
> # pocketpc uses 0x4800 as LEDxrDIV so we keep it; just remember that
> # 0x0800 <= LEDxrDIV <= 0xf800
> set LEDxrDIV 0x4800
>
> # print some (hopefully) useful debug info
> print "LEDx_ENB is : %x" pmh(LEDxCON0) & LEDxrENB
> print "LEDx_INITV is: %x" pmh(LEDxCON0) & LEDxrINITV
> print "LEDx_CMP is : %x" pmh(LEDxCON0) & mLEDxrCMP
> print "LEDx_CNTEN is: %x" pmh(LEDxCON0) & LEDxrCNTEN
> print "LEDx_CLK is : %x" pmh(LED0CON0) & LEDrCLK
> print "LEDx_CNT is : %x" pmh(LEDxCON1) & mLEDxrCNT
> print "LEDx_DIV is : %x" pmh(LEDxCON1) & mLEDxrDIV
> print "LEDPS0 is : %x" pmh(LEDPS0) & mLEDPS0
> print "LEDPS1 is : %x" pmh(LEDPS1) & mLEDPS1
>
> # to switch LEDx on
> set pmh(LEDxCON0) (pmh(LEDxCON0) | LEDxrINITV)
>
> # to switch LEDx off
> set pmh(LEDxCON0) (pmh(LEDxCON0) & ~LEDxrINITV)
>
> # to clear current count value and put our <count> in place
> # (with x=0 and charging it defaults to 1799 blinks!)
> set pmh(LEDxCON1) ((pmh(LEDxCON1) & ~mLEDxrCNT) | (count+1))
>
> # to set the duration of the complete blink phase
> set pmh(LEDxCON1) ((pmh(LEDxCON1) & ~mLEDxrDIV) | LEDxrDIV)
>
> # to set the duration of the dark phase
> set pmh(LEDxCON0) ((pmh(LEDxCON0) & ~mLEDxrCMP) | LEDxrCMP)
>
> # to activate LEDx_CNT controlled blinking
> set pmh(LEDxCON0) (pmh(LEDxCON0) | LEDxrCNTEN)
>
> # to deactivate LEDx_CNT controlled blinking
> set pmh(LEDxCON0) (pmh(LEDxCON0) & ~LEDxrCNTEN)
>
> # to activate led with blinking
> set pmh(LEDxCON0) (pmh(LEDxCON0) | LEDxrENB)
>
> # to deactivate led with blinking
> set pmh(LEDxCON0) (pmh(LEDxCON0) & ~LEDxrENB)
>
>
> _______________________________________________
> H2200-port mailing list
> H2200-port_at_handhelds.org
> https://handhelds.org/mailman/listinfo/h2200-port
Received on Thu Mar 11 2004 - 19:46:01 EST

This archive was generated by hypermail 2.2.0 : Mon Jul 25 2005 - 17:19:26 EDT