From: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [6202] ETRAX: Add a dummy tempsensor and correct the NAND flash model.
Date: Wed, 07 Jan 2009 13:05:59 +0000 [thread overview]
Message-ID: <E1LKY6h-0007zT-4O@cvs.savannah.gnu.org> (raw)
Revision: 6202
http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6202
Author: edgar_igl
Date: 2009-01-07 13:05:58 +0000 (Wed, 07 Jan 2009)
Log Message:
-----------
ETRAX: Add a dummy tempsensor and correct the NAND flash model.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Modified Paths:
--------------
trunk/hw/axis_dev88.c
Modified: trunk/hw/axis_dev88.c
===================================================================
--- trunk/hw/axis_dev88.c 2009-01-07 12:36:06 UTC (rev 6201)
+++ trunk/hw/axis_dev88.c 2009-01-07 13:05:58 UTC (rev 6202)
@@ -84,12 +84,88 @@
&nand_writel,
};
-#define RW_PA_DOUT 0
-#define R_PA_DIN 1
-#define RW_PA_OE 2
-struct gpio_state_t
+
+struct tempsensor_t
{
+ unsigned int shiftreg;
+ unsigned int count;
+ enum {
+ ST_OUT, ST_IN, ST_Z
+ } state;
+
+ uint16_t regs[3];
+};
+
+static void tempsensor_clkedge(struct tempsensor_t *s,
+ unsigned int clk, unsigned int data_in)
+{
+ D(printf("%s clk=%d state=%d sr=%x\n", __func__,
+ clk, s->state, s->shiftreg));
+ if (s->count == 0) {
+ s->count = 16;
+ s->state = ST_OUT;
+ }
+ switch (s->state) {
+ case ST_OUT:
+ /* Output reg is clocked at negedge. */
+ if (!clk) {
+ s->count--;
+ s->shiftreg <<= 1;
+ if (s->count == 0) {
+ s->shiftreg = 0;
+ s->state = ST_IN;
+ s->count = 16;
+ }
+ }
+ break;
+ case ST_Z:
+ if (clk) {
+ s->count--;
+ if (s->count == 0) {
+ s->shiftreg = 0;
+ s->state = ST_OUT;
+ s->count = 16;
+ }
+ }
+ break;
+ case ST_IN:
+ /* Indata is sampled at posedge. */
+ if (clk) {
+ s->count--;
+ s->shiftreg <<= 1;
+ s->shiftreg |= data_in & 1;
+ if (s->count == 0) {
+ D(printf("%s cfgreg=%x\n", __func__, s->shiftreg));
+ s->regs[0] = s->shiftreg;
+ s->state = ST_OUT;
+ s->count = 16;
+
+ if ((s->regs[0] & 0xff) == 0) {
+ /* 25 degrees celcius. */
+ s->shiftreg = 0x0b9f;
+ } else if ((s->regs[0] & 0xff) == 0xff) {
+ /* Sensor ID, 0x8100 LM70. */
+ s->shiftreg = 0x8100;
+ } else
+ printf("Invalid tempsens state %x\n", s->regs[0]);
+ }
+ }
+ break;
+ }
+}
+
+
+#define RW_PA_DOUT 0x00
+#define R_PA_DIN 0x01
+#define RW_PA_OE 0x02
+#define RW_PD_DOUT 0x10
+#define R_PD_DIN 0x11
+#define RW_PD_OE 0x12
+
+static struct gpio_state_t
+{
struct nand_state_t *nand;
+ struct tempsensor_t tempsensor;
uint32_t regs[0x5c / 4];
} gpio_state;
@@ -107,6 +183,13 @@
/* Encode pins from the nand. */
r |= s->nand->rdy << 7;
break;
+ case R_PD_DIN:
+ r = s->regs[RW_PD_DOUT] & s->regs[RW_PD_OE];
+
+ /* Encode temp sensor pins. */
+ r |= (!!(s->tempsensor.shiftreg & 0x10000)) << 4;
+ break;
+
default:
r = s->regs[addr];
break;
@@ -131,6 +214,15 @@
s->regs[addr] = value;
break;
+
+ case RW_PD_DOUT:
+ /* Temp sensor clk. */
+ if ((s->regs[addr] ^ value) & 2)
+ tempsensor_clkedge(&s->tempsensor, !!(value & 2),
+ !!(value & 16));
+ s->regs[addr] = value;
+ break;
+
default:
s->regs[addr] = value;
break;
@@ -194,13 +286,13 @@
/* Attach a NAND flash to CS1. */
- nand_state.nand = nand_init(NAND_MFR_STMICRO, 0xf1);
+ nand_state.nand = nand_init(NAND_MFR_STMICRO, 0x39);
nand_regs = cpu_register_io_memory(0, nand_read, nand_write, &nand_state);
cpu_register_physical_memory(0x10000000, 0x05000000, nand_regs);
gpio_state.nand = &nand_state;
gpio_regs = cpu_register_io_memory(0, gpio_read, gpio_write, &gpio_state);
- cpu_register_physical_memory(0x3001a000, 0x1c, gpio_regs);
+ cpu_register_physical_memory(0x3001a000, 0x5c, gpio_regs);
pic = etraxfs_pic_init(env, 0x3001c000);
reply other threads:[~2009-01-07 13:06 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=E1LKY6h-0007zT-4O@cvs.savannah.gnu.org \
--to=edgar.iglesias@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).