From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDltr-0006Ng-CP for qemu-devel@nongnu.org; Sun, 25 Aug 2013 21:47:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VDlth-0005EP-D4 for qemu-devel@nongnu.org; Sun, 25 Aug 2013 21:47:23 -0400 Received: from [222.73.24.84] (port=47670 helo=song.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VDlth-0005CL-0u for qemu-devel@nongnu.org; Sun, 25 Aug 2013 21:47:13 -0400 Received: from fnstmail02.fnst.cn.fujitsu.com (tang.cn.fujitsu.com [127.0.0.1]) by tang.cn.fujitsu.com (8.14.3/8.13.1) with ESMTP id r7Q1l4YT029791 for ; Mon, 26 Aug 2013 09:47:05 +0800 Message-ID: <521AB39A.5000203@cn.fujitsu.com> Date: Mon, 26 Aug 2013 09:47:06 +0800 From: Yang Ning MIME-Version: 1.0 References: <201308241327167541258@cn.fujitsu.com> In-Reply-To: <201308241327167541258@cn.fujitsu.com> Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=UTF-8; format=flowed Subject: [Qemu-devel] Fw: Max7310: confused about the method of reading output port register List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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;