All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Fw: Max7310: confused about the method of reading output port register
       [not found] <201308241327167541258@cn.fujitsu.com>
@ 2013-08-26  1:47 ` Yang Ning
  2013-09-01 22:38   ` andrzej zaborowski
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Ning @ 2013-08-26  1:47 UTC (permalink / raw)
  To: qemu-devel


Dear  All:

Firstly,I'm writing to express my thanks to Zaborowski for the source 
code of Max7310 which have helped me so much.
  But I'm still confused about the method of reading output port register.
code:
>    case 0x01:	/* Output port */
>        return s->level & ~s->direction;
>        break;

I found some instruction of output port register in the datasheet.
>" Reads from the output port register reflect the value that is in the flip-flop
>controlling the output selection, not the actual I/O value, which may differ if
>the out-put is overloaded."

So,in my opinion,in the defination of MAX7310State,whether the property 
of outputport_reg should be added?
And does the method of reading/writing output port should be modified as 
follows.

[reading]
     case 0x01:	/* Output port */
         return s->outputport_reg;
         break;
[writing]
     case 0x01:	/* Output port */
>        for (diff = (data ^ s->level) & ~s->direction; diff;
>                        diff &= ~(1 << line)) {
>           line = ffs(diff) - 1;
>            if (s->handler[line])
>                qemu_set_irq(s->handler[line], (data >> line) & 1);
>        }
>        s->level = (s->level & s->direction) | (data & ~s->direction);
         s->outputport_reg =  data;
         break;	

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] Fw: Max7310: confused about the method of reading output port register
  2013-08-26  1:47 ` [Qemu-devel] Fw: Max7310: confused about the method of reading output port register Yang Ning
@ 2013-09-01 22:38   ` andrzej zaborowski
  0 siblings, 0 replies; 2+ messages in thread
From: andrzej zaborowski @ 2013-09-01 22:38 UTC (permalink / raw)
  To: Yang Ning; +Cc: qemu-devel@nongnu.org

Hi Yang,

On 26 August 2013 03:47, Yang Ning <yangn.fnst@cn.fujitsu.com> wrote:
>
> Dear  All:
>
> Firstly,I'm writing to express my thanks to Zaborowski for the source code
> of Max7310 which have helped me so much.
>  But I'm still confused about the method of reading output port register.
> code:
>>
>>    case 0x01:   /* Output port */
>>        return s->level & ~s->direction;
>>        break;
>
>
> I found some instruction of output port register in the datasheet.
>>
>> " Reads from the output port register reflect the value that is in the
>> flip-flop
>> controlling the output selection, not the actual I/O value, which may
>> differ if
>> the out-put is overloaded."
>
>
> So,in my opinion,in the defination of MAX7310State,whether the property of
> outputport_reg should be added?
> And does the method of reading/writing output port should be modified as
> follows.
>
> [reading]
>     case 0x01:  /* Output port */
>         return s->outputport_reg;
>         break;
> [writing]
>     case 0x01:  /* Output port */
>>
>>        for (diff = (data ^ s->level) & ~s->direction; diff;
>>                        diff &= ~(1 << line)) {
>>           line = ffs(diff) - 1;
>>            if (s->handler[line])
>>                qemu_set_irq(s->handler[line], (data >> line) & 1);
>>        }
>>        s->level = (s->level & s->direction) | (data & ~s->direction);
>
>         s->outputport_reg =  data;
>         break;

Yes, if by "overload" they mean change direction to "input", then yes,
I think you are correct.

Personally I'd call it s->output.  I'm wondering if we may need to
update the output levels when the Configuration (0x03) is written and
on reset.  This would be best done by adding a short function
max7310_update() that does the "for (diff = ...)" loop and calls
qemu_set_irq.

Best regards

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-09-01 22:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <201308241327167541258@cn.fujitsu.com>
2013-08-26  1:47 ` [Qemu-devel] Fw: Max7310: confused about the method of reading output port register Yang Ning
2013-09-01 22:38   ` andrzej zaborowski

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.