Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r1662 - trunk/oe/packages/tasks ([EMAIL PROTECTED])
   2. r1663 - in trunk/src/target/OM-2007/applications:
      openmoko-appmanager/data openmoko-calculator/data
      openmoko-dialer/data openmoko-mainmenu/data
      openmoko-messages/data openmoko-rssreader/data
      openmoko-taskmanager/data ([EMAIL PROTECTED])
   3. r1664 - trunk/src/host/qemu-neo1973/openmoko
      ([EMAIL PROTECTED])
   4. r1665 - trunk/src/target/kernel/patches
      ([EMAIL PROTECTED])
   5. r1666 - trunk/src/host/qemu-neo1973/hw ([EMAIL PROTECTED])
   6. r1667 - in trunk/src/host/qemu-neo1973: . hw
      ([EMAIL PROTECTED])
--- Begin Message ---
Author: mickey
Date: 2007-04-05 12:31:19 +0200 (Thu, 05 Apr 2007)
New Revision: 1662

Modified:
   trunk/oe/packages/tasks/task-openmoko.bb
Log:
oe: ship libgtkstylus in task-openmoko-ui


Modified: trunk/oe/packages/tasks/task-openmoko.bb
===================================================================
--- trunk/oe/packages/tasks/task-openmoko.bb    2007-04-05 08:43:57 UTC (rev 
1661)
+++ trunk/oe/packages/tasks/task-openmoko.bb    2007-04-05 10:31:19 UTC (rev 
1662)
@@ -62,6 +62,8 @@
   pango-module-basic-x \
   pango-module-basic-fc \
   gtk+ \
+  libgtkstylus \
+#  libgtkinput \
   matchbox-common \
   matchbox-wm \
   xserver-kdrive-fbdev \




--- End Message ---
--- Begin Message ---
Author: mickey
Date: 2007-04-05 13:36:50 +0200 (Thu, 05 Apr 2007)
New Revision: 1663

Modified:
   
trunk/src/target/OM-2007/applications/openmoko-appmanager/data/openmoko-appmanager.desktop
   
trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop
   
trunk/src/target/OM-2007/applications/openmoko-dialer/data/openmoko-dialer.desktop
   
trunk/src/target/OM-2007/applications/openmoko-mainmenu/data/openmoko-mainmenu.desktop
   
trunk/src/target/OM-2007/applications/openmoko-messages/data/openmoko-messages.desktop
   
trunk/src/target/OM-2007/applications/openmoko-rssreader/data/openmoko-rssreader.desktop
   
trunk/src/target/OM-2007/applications/openmoko-taskmanager/data/openmoko-taskmanager.desktop
Log:
applications: unify names in the desktop files


Modified: 
trunk/src/target/OM-2007/applications/openmoko-appmanager/data/openmoko-appmanager.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-appmanager/data/openmoko-appmanager.desktop
  2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-appmanager/data/openmoko-appmanager.desktop
  2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,6 +1,6 @@
 [Desktop Entry]
-Name=OpenMoko Appmanager
-Comment=OpenMoko Application Manager
+Name=Applications
+Comment=Install or Remove additional applications
 Encoding=UTF-8
 Version=1.0
 Type=Application

Modified: 
trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop
  2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-calculator/data/openmoko-calculator.desktop
  2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,11 +1,12 @@
 [Desktop Entry]
-Name=OpenMoko Calculator
-Comment=Simple finger calculator
+Name=Calculator
+Comment=Perform simple calculations
 Encoding=UTF-8
 Version=1.0
 Type=Application
 Exec=openmoko-calculator
 Icon=openmoko-calculator.png
 Terminal=false
+Categories=GTK;Application;PIM;Office
 SingleInstance=true
 StartupNotify=true

Modified: 
trunk/src/target/OM-2007/applications/openmoko-dialer/data/openmoko-dialer.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-dialer/data/openmoko-dialer.desktop
  2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-dialer/data/openmoko-dialer.desktop
  2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Encoding=UTF-8
-Name=Openmoko-dialer
-Comment=dialer
+Name=Dialer
+Comment=Telephone Calls
 Exec=openmoko-dialer
 Icon=Dialer
 Terminal=false

Modified: 
trunk/src/target/OM-2007/applications/openmoko-mainmenu/data/openmoko-mainmenu.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-mainmenu/data/openmoko-mainmenu.desktop
      2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-mainmenu/data/openmoko-mainmenu.desktop
      2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,11 +1,12 @@
 [Desktop Entry]
-Name=OpenMoko Mainmenu
-Comment=OpenMoko Finger Application
+Name=MainMenu
+Comment=Run Applications
 Encoding=UTF-8
 Version=1.0
 Type=Application
 Exec=openmoko-mainmenu
 Icon=openmoko-mainmenu
 Terminal=false
+Categories=GTK;Application;PIM;Office
 SingleInstance=true
 StartupNotify=true

Modified: 
trunk/src/target/OM-2007/applications/openmoko-messages/data/openmoko-messages.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-messages/data/openmoko-messages.desktop
      2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-messages/data/openmoko-messages.desktop
      2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Encoding=UTF-8
-Name=Openmoko-messages
-Comment=messages
+Name=Messages
+Comment=Send and Receive SMS and E-Mail messages
 Exec=openmoko-messages
 Icon=Message
 Terminal=false

Modified: 
trunk/src/target/OM-2007/applications/openmoko-rssreader/data/openmoko-rssreader.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-rssreader/data/openmoko-rssreader.desktop
    2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-rssreader/data/openmoko-rssreader.desktop
    2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Encoding=UTF-8
-Name=Openmoko-rssreader
-Comment=rssreader
+Name=Feed Reader
+Comment=Read your favourite RSS feeds
 Exec=openmoko-rssreader
 Icon=RSS
 Terminal=false

Modified: 
trunk/src/target/OM-2007/applications/openmoko-taskmanager/data/openmoko-taskmanager.desktop
===================================================================
--- 
trunk/src/target/OM-2007/applications/openmoko-taskmanager/data/openmoko-taskmanager.desktop
        2007-04-05 10:31:19 UTC (rev 1662)
+++ 
trunk/src/target/OM-2007/applications/openmoko-taskmanager/data/openmoko-taskmanager.desktop
        2007-04-05 11:36:50 UTC (rev 1663)
@@ -1,11 +1,12 @@
 [Desktop Entry]
-Name=OpenMoko Task Manager
-Comment=OpenMoko Finger Application
+Name=Tasks
+Comment=Switch between running applications
 Encoding=UTF-8
 Version=1.0
 Type=Application
 Exec=openmoko-taskmanager
 Icon=openmoko-taskmanager
 Terminal=false
+Categories=GTK;Application;PIM;Office
 SingleInstance=true
 StartupNotify=true




--- End Message ---
--- Begin Message ---
Author: andrew
Date: 2007-04-05 23:07:47 +0200 (Thu, 05 Apr 2007)
New Revision: 1664

Modified:
   trunk/src/host/qemu-neo1973/openmoko/Makefile
   trunk/src/host/qemu-neo1973/openmoko/download.sh
   trunk/src/host/qemu-neo1973/openmoko/env
   trunk/src/host/qemu-neo1973/openmoko/flash.sh
Log:
Take script compatibility-related suggestions from various people on IRC 
and wiki into account.
Correct button assignment message.
Add optional parameter to openmoko/flash.sh with search path for images.


Modified: trunk/src/host/qemu-neo1973/openmoko/Makefile
===================================================================
--- trunk/src/host/qemu-neo1973/openmoko/Makefile       2007-04-05 11:36:50 UTC 
(rev 1663)
+++ trunk/src/host/qemu-neo1973/openmoko/Makefile       2007-04-05 21:07:47 UTC 
(rev 1664)
@@ -21,6 +21,7 @@
 SPLASH=splashimg.pl
 SPLASHIMG=System_boot.png
 FLASHIMG=openmoko-flash.image
+SHELL=bash
 
 splash.gz: splash
        gzip -c < $^ > $@
@@ -40,7 +41,7 @@
 
 $(FLASHIMG):
        # Making an empty/erased flash image.  Need a correct echo behavior.
-       echo -en \\0377\\0377\\0377\\0377\\0377\\0377\\0377\\0377 > .8b
+       $(echo) -en \\0377\\0377\\0377\\0377\\0377\\0377\\0377\\0377 > .8b
        cat .8b .8b > .16b # OOB is 16 bytes
        cat .16b .16b .16b .16b .16b .16b .16b .16b > .512b
        cat .16b .16b .16b .16b .16b .16b .16b .16b >> .512b

Modified: trunk/src/host/qemu-neo1973/openmoko/download.sh
===================================================================
--- trunk/src/host/qemu-neo1973/openmoko/download.sh    2007-04-05 11:36:50 UTC 
(rev 1663)
+++ trunk/src/host/qemu-neo1973/openmoko/download.sh    2007-04-05 21:07:47 UTC 
(rev 1664)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /usr/bin/env bash
 # Chooses and downloads some OpenMoko image snapshots for flash.sh to use.
 #
 # Copyright (C) 2007 OpenMoko, Inc.
@@ -25,26 +25,26 @@
 cd $script_dir
 
 echo "    "Retrieving available builds list...
-files=`lynx -dump -listonly $download_dir | grep http | sed "s,[0-9 
\t\.]*$download_dir\([a-zA-Z0-9_\.-]\)[ \t]*,\1,"`
+files=`lynx -dump $download_dir | grep http | sed "s,[0-9 
\t\.]*$download_dir\([a-zA-Z0-9_\.-]\)[ \t]*,\1,"`
 
 most_recent () {
-       echo > .list
+       ${echo} > .list
        for name in $files; do
                if [[ "$name" == $1 ]]; then
-                       echo "$name" > .list
+                       ${echo} "$name" > .list
                fi
        done
        export $2=`sort .list | tail -n 1`
        rm -rf .list
-       [ -z "${!2}" ] && ( echo not found; exit -1 )
-       echo ${!2}
+       [ -z "${!2}" ] && ( ${echo} not found; exit -1 )
+       ${echo} ${!2}
 }
 
-echo -n "    "Kernel is...\ 
+${echo} -n "    "Kernel is...\ 
 most_recent "$kernel_wildcard" kernel_image || exit -1
-echo -n "    "Root filesystem is...\ 
+${echo} -n "    "Root filesystem is...\ 
 most_recent "$rootfs_wildcard" rootfs_image || exit -1
-echo -n "    "U-boot is...\ 
+${echo} -n "    "U-boot is...\ 
 most_recent "$uboot_wildcard" uboot_image || exit -1
 
 sleep 2

Modified: trunk/src/host/qemu-neo1973/openmoko/env
===================================================================
--- trunk/src/host/qemu-neo1973/openmoko/env    2007-04-05 11:36:50 UTC (rev 
1663)
+++ trunk/src/host/qemu-neo1973/openmoko/env    2007-04-05 21:07:47 UTC (rev 
1664)
@@ -7,7 +7,11 @@
 qemu_relative="arm-softmmu/qemu-system-arm -M neo -m 130"
 qemu="$src_dir/$qemu_relative"
 flash_image=openmoko-flash.image
-make=gmake
+make=make
+which gmake && make=gmake
+echo=echo
+which gecho && echo=gecho
+export make echo
 
 kernel_addr=0x32000000
 splash_addr=0x36000000

Modified: trunk/src/host/qemu-neo1973/openmoko/flash.sh
===================================================================
--- trunk/src/host/qemu-neo1973/openmoko/flash.sh       2007-04-05 11:36:50 UTC 
(rev 1663)
+++ trunk/src/host/qemu-neo1973/openmoko/flash.sh       2007-04-05 21:07:47 UTC 
(rev 1664)
@@ -1,4 +1,4 @@
-#! /bin/bash
+#! /usr/bin/env bash
 # Generates a ready to use OpenMoko NAND flash image.  Vaguely based
 # on devirginator and http://wiki.openmoko.org/wiki/NAND_bad_blocks.
 #
@@ -23,6 +23,12 @@
 
 . openmoko/env
 
+if [[ "$1" != "" ]]; then
+       img_dir="$1"
+else
+       img_dir="$script_dir"
+fi
+
 cd $script_dir
 
 if ! which pngtopnm || ! which ppmtorgb3; then
@@ -36,7 +42,9 @@
 # Find the most recent OpenMoko images in the current directory.
 # We assume they have numeric date or some build number in their names.
 most_recent () {
-       export $2="`ls -1 $1 | sort | tail -n 1`"
+       cd $src_dir
+       export $2="`basename \`ls -d -1 $img_dir/$1 | sort | tail -n 1\``"
+       cd $script_dir
        export $3="`python -c \"print hex(\`stat -c %s ${!2}\`)\"`"
        [ -n "${!3}" ]
 }
@@ -78,8 +86,7 @@
 }
 
 # Set up BBT, u-boot environment, boot menu and program u-boot binary.
-uboot $uboot_image 20 "
-
+uboot $uboot_image 40 "               
 setenv dontask y
 nand createbbt
 setenv bootcmd 'setenv bootargs \${bootargs_base} \${mtdparts}; bootm 
$kernel_addr'
@@ -93,18 +100,15 @@
 saveenv"
 
 # Program bootsplash.
-uboot splash.gz 10 "
-
+uboot splash.gz 10 "               
 nand write.e $kernel_addr splash $splash_size"
 
 # Program the kernel binary.
-uboot $kernel_image 10 "
-
+uboot $kernel_image 10 "               
 nand write.e $kernel_addr kernel $kernel_size"
 
 # Program the root filesystem.
-uboot $rootfs_image 15 "
-
+uboot $rootfs_image 20 "               
 nand write.jffs2 $kernel_addr rootfs $rootfs_size"
 
 echo
@@ -115,5 +119,5 @@
 echo
 echo "    "Append \'-snapshot\' to make the flash image read-only so that every
 echo "    "time emulation starts in the original unmodified state.
-echo "    "[Space] for AUX button, [Enter] for POWER.
+echo "    "[Enter] for AUX button, [Space] for POWER.
 echo




--- End Message ---
--- Begin Message ---
Author: laforge
Date: 2007-04-05 23:36:44 +0200 (Thu, 05 Apr 2007)
New Revision: 1665

Added:
   trunk/src/target/kernel/patches/s3c2410-usb-switch.patch
Log:
add (inactive) patch for usb host/device switching


Added: trunk/src/target/kernel/patches/s3c2410-usb-switch.patch
===================================================================
--- trunk/src/target/kernel/patches/s3c2410-usb-switch.patch    2007-04-05 
21:07:47 UTC (rev 1664)
+++ trunk/src/target/kernel/patches/s3c2410-usb-switch.patch    2007-04-05 
21:36:44 UTC (rev 1665)
@@ -0,0 +1,113 @@
+Support switching of USB mode between host and device port
+
+Index: linux-2.6.20.4/arch/arm/mach-s3c2410/usb-modeswitch.c
+===================================================================
+--- /dev/null  1970-01-01 00:00:00.000000000 +0000
++++ linux-2.6.20.4/arch/arm/mach-s3c2410/usb-modeswitch.c      2007-04-01 
12:36:49.000000000 +0200
+@@ -0,0 +1,33 @@
++/*
++ * linux/arch/arm/mach-s3c2410/usb-modeswitch.c
++ *
++ * S3C2410 USB Host/Device switch
++ *
++ * Copyright (C) 2007 by OpenMoko, Inc.
++ * Author: Harald Welte <[EMAIL PROTECTED]>
++ * All rights reserved.
++ *
++ * This program is free software; you can redistribute it and/or
++ * modify it under the terms of the GNU General Public License as
++ * published by the Free Software Foundation; either version 2 of
++ * the License, or (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
++ * MA 02111-1307 USA
++ *
++ */
++
++void s3c2410_usb_enable_host(int on)
++{
++      s3c2410_modify_misccr(S3C2410_MISCCR_HSBHOST,
++                            on ? S3C2410_MISCCR_USBHOST : 0);
++}
++
++
+Index: linux-2.6.20.4/drivers/usb/host/ohci-s3c2410.c
+===================================================================
+--- linux-2.6.20.4.orig/drivers/usb/host/ohci-s3c2410.c        2007-04-01 
12:33:01.000000000 +0200
++++ linux-2.6.20.4/drivers/usb/host/ohci-s3c2410.c     2007-04-01 
12:36:49.000000000 +0200
+@@ -24,6 +24,7 @@
+ 
+ #include <asm/hardware.h>
+ #include <asm/arch/usb-control.h>
++#include <asm/arch/regs-gpio.h>
+ 
+ #define valid_port(idx) ((idx) == 1 || (idx) == 2)
+ 
+@@ -308,6 +309,36 @@
+       local_irq_restore(flags);
+ }
+ 
++/* switching of USB pads */
++static ssize_t show_usb_mode(struct device *dev, struct device_attribute 
*attr,
++                           char *buf)
++{
++      if (__raw_readl(S3C24XX_MISCCR) & S3C2410_MISCCR_USBHOST)
++              return sprintf(buf, "host");
++
++      return sprintf(buf, "device");
++}
++
++static ssize_t set_usb_mode(struct device *dev, struct device_attribute *attr,
++                          const char *buf, size_t count)
++{
++      if (!strcmp(buf, "host")) {
++              s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST,
++                                    S3C2410_MISCCR_USBHOST);
++              /* FIXME: 
++               * - call machine-specific disable-pullup function i
++               * - enable +Vbus (if hardware supports it)
++               */
++      } else if (!strcmp(buf, "device")) {
++              s3c2410_modify_misccr(S3C2410_MISCCR_USBHOST, 0);
++      } else
++              return -EINVAL;
++
++      return count;
++}
++
++static DEVICE_ATTR(usb_mode, S_IRUGO | S_IWUSR, show_usb_mode, set_usb_mode);
++
+ /* may be called without controller electrically present */
+ /* may be called with controller, bus, and devices active */
+ 
+@@ -325,6 +356,7 @@
+ static void
+ usb_hcd_s3c2410_remove (struct usb_hcd *hcd, struct platform_device *dev)
+ {
++      device_remove_file(&dev->dev, &dev_attr_usb_mode);
+       usb_remove_hcd(hcd);
+       s3c2410_stop_hc(dev);
+       iounmap(hcd->regs);
+@@ -392,8 +424,15 @@
+       if (retval != 0)
+               goto err_ioremap;
+ 
++      retval = device_create_file(&dev->dev, &dev_attr_usb_mode);
++      if (retval != 0)
++              goto err_hcd;
++
+       return 0;
+ 
++ err_hcd:
++      usb_remove_hcd(hcd);
++
+  err_ioremap:
+       s3c2410_stop_hc(dev);
+       iounmap(hcd->regs);




--- End Message ---
--- Begin Message ---
Author: andrew
Date: 2007-04-05 23:41:34 +0200 (Thu, 05 Apr 2007)
New Revision: 1666

Modified:
   trunk/src/host/qemu-neo1973/hw/nand.c
Log:
Fix a NAND erase block size off-by-one error.


Modified: trunk/src/host/qemu-neo1973/hw/nand.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/nand.c       2007-04-05 21:36:44 UTC (rev 
1665)
+++ trunk/src/host/qemu-neo1973/hw/nand.c       2007-04-05 21:41:34 UTC (rev 
1666)
@@ -557,7 +557,7 @@
         page = i >> 9;
         if (bdrv_read(s->bdrv, page, iobuf, 1) == -1)
             printf("%s: read error in sector %i\n", __FUNCTION__, page);
-        memset(iobuf, 0xff, addr & 0x1ff);
+        memset(iobuf, 0xff, ((addr - 1) & 0x1ff) + 1);
         if (bdrv_write(s->bdrv, page, iobuf, 1) == -1)
             printf("%s: write error in sector %i\n", __FUNCTION__, page);
     }




--- End Message ---
--- Begin Message ---
Author: andrew
Date: 2007-04-06 01:50:59 +0200 (Fri, 06 Apr 2007)
New Revision: 1667

Added:
   trunk/src/host/qemu-neo1973/hw/modem.c
Modified:
   trunk/src/host/qemu-neo1973/Makefile.target
   trunk/src/host/qemu-neo1973/hw/neo1973.c
   trunk/src/host/qemu-neo1973/vl.h
Log:
Add a dummy modem attached to UART0 (most functions unimplemented).
Clean-up the Neo board file.


Modified: trunk/src/host/qemu-neo1973/Makefile.target
===================================================================
--- trunk/src/host/qemu-neo1973/Makefile.target 2007-04-05 21:41:34 UTC (rev 
1666)
+++ trunk/src/host/qemu-neo1973/Makefile.target 2007-04-05 23:50:59 UTC (rev 
1667)
@@ -381,7 +381,7 @@
 VL_OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o max111x.o max7310.o
 VL_OBJS+= ads7846.o sd.o ide.o serial.o nand.o $(AUDIODRV) wm8750.o wm8753.o
 VL_OBJS+= s3c2410.o s3c24xx_gpio.o s3c24xx_lcd.o s3c24xx_mmci.o s3c24xx_rtc.o
-VL_OBJS+= neo1973.o pcf5060x.o jbt6k74.o
+VL_OBJS+= neo1973.o pcf5060x.o jbt6k74.o modem.o
 CPPFLAGS += -DHAS_AUDIO -DHIGH_LATENCY
 endif
 ifeq ($(TARGET_BASE_ARCH), sh4)

Added: trunk/src/host/qemu-neo1973/hw/modem.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/modem.c      2007-04-05 21:41:34 UTC (rev 
1666)
+++ trunk/src/host/qemu-neo1973/hw/modem.c      2007-04-05 23:50:59 UTC (rev 
1667)
@@ -0,0 +1,447 @@
+/*
+ * AT commands interpreter. (Fake GSM modem)
+ *
+ * Copyright (c) 2007 OpenMoko, Inc.
+ * Author: Andrzej Zaborowski <[EMAIL PROTECTED]>
+ *
+ * This code is licenced under the GNU GPL v2.
+ */
+#include "vl.h"
+
+struct modem_s {
+    int enable;
+    CharDriverState chr;
+    IOCanRWHandler *can_read;
+    IOReadHandler *read;
+    void *opaque;
+    int cmd_len;
+    char cmd[1024];
+#define FIFO_LEN       4096
+    int out_start;
+    int out_len;
+    char outfifo[FIFO_LEN];
+    QEMUTimer *out_tm;
+    int64_t baud_delay;
+};
+
+static void modem_reset(struct modem_s *s)
+{
+    s->cmd_len = 0;
+    s->out_len = 0;
+    s->baud_delay = ticks_per_sec;
+}
+
+static void modem_add_read_handler(CharDriverState *chr,
+                IOCanRWHandler *modem_can_read, IOReadHandler *modem_read,
+                void *opaque)
+{
+    struct modem_s *s = (struct modem_s *) chr->opaque;
+
+    s->can_read = modem_can_read;
+    s->read = modem_read;
+    s->opaque = opaque;
+}
+
+static inline void modem_fifo_wake(struct modem_s *s)
+{
+    if (!s->enable || !s->out_len)
+        return;
+
+    if (s->can_read && s->can_read(s->opaque) && s->read) {
+        s->read(s->opaque, s->outfifo + s->out_start ++, 1);
+        s->out_len --;
+        s->out_start &= FIFO_LEN - 1;
+    }
+
+    if (s->out_len)
+        qemu_mod_timer(s->out_tm, qemu_get_clock(vm_clock) + s->baud_delay);
+}
+
+static void modem_resp(struct modem_s *s, const char *fmt, ...)
+        __attribute__ ((__format__ (__printf__, 2, 3)));
+static void modem_resp(struct modem_s *s, const char *fmt, ...)
+{
+    static char buf[FIFO_LEN];
+    int len, off;
+    va_list ap;
+    va_start(ap, fmt);
+    len = vsnprintf(buf, sizeof(buf), fmt, ap);
+    va_end(ap);
+    if (len + s->out_len > FIFO_LEN) {
+        s->out_len = 0;
+        return;
+    }
+    off = (s->out_start + s->out_len) & (FIFO_LEN - 1);
+    if (off + len > FIFO_LEN) {
+        memcpy(s->outfifo + off, buf, FIFO_LEN - off);
+        memcpy(s->outfifo, buf + (FIFO_LEN - off), off + len - FIFO_LEN);
+    } else
+        memcpy(s->outfifo + off, buf, len);
+    s->out_len += len;
+    modem_fifo_wake(s);
+}
+
+static struct modem_cmd_s {
+    const char *cmd;
+    enum { modem_ok, modem_error, modem_call, modem_str } action;
+    int (*call)(struct modem_s *s, const char *param);
+    const char *resp;
+} modem_cmds[] = {
+    { "AT+CACM", modem_error },
+    { "AT+CAMM", modem_error },
+    { "AT+CAOC", modem_error },
+    { "AT+CBC", modem_error },
+    { "AT+CBST", modem_error },
+    { "AT+CCFC", modem_error },
+    { "AT+CCUG", modem_error },
+    { "AT+CCWA", modem_error },
+    { "AT+CCWE", modem_error },
+    { "AT+CEER", modem_error },
+    { "AT+CFUN", modem_error },
+    { "AT+CGACT", modem_error },
+    { "AT+CGANS", modem_error },
+    { "AT+CGATT", modem_error },
+    { "AT+CGAUTO", modem_error },
+    { "AT+CGCLASS", modem_error },
+    { "AT+CGDATA", modem_error },
+    { "AT+CGDCONT", modem_error },
+    { "AT+CGEREP", modem_error },
+    { "AT+CGMI", modem_str, 0, "<manufacturer>\n\n" },
+    { "AT+CGMM", modem_str, 0, "<model>\n\n" },
+    { "AT+CGMR", modem_str, 0, "<revision>\n\n" },
+    { "AT+CGPADDR", modem_error },
+    { "AT+CGQMIN", modem_error },
+    { "AT+CGQREQ", modem_error },
+    { "AT+CGREG", modem_error },
+    { "AT+CGSMS", modem_error },
+    { "AT+CGSN", modem_str, 0, "<serial number>\n\n" },
+    { "AT+CHLD", modem_error },
+    { "AT+CHUP", modem_error },
+    { "AT+CIMI", modem_error },
+    { "AT+CLAC", modem_error },
+    { "AT+CLAE", modem_error },
+    { "AT+CLAN", modem_error },
+    { "AT+CLCC", modem_error },
+    { "AT+CLCK", modem_error },
+    { "AT+CLIP", modem_error },
+    { "AT+CDIP", modem_error },
+    { "AT+CLIR", modem_error },
+    { "AT+CLVL", modem_error },
+    { "AT+CMEE", modem_error },
+    { "AT+CMGC", modem_error },
+    { "AT+CMGD", modem_error },
+    { "AT+CMGF", modem_error },
+    { "AT+CMGL", modem_error },
+    { "AT+CMGR", modem_error },
+    { "AT+CMGS", modem_error },
+    { "AT+CMGW", modem_error },
+    { "AT+CMOD", modem_error },
+    { "AT+CMSS", modem_error },
+    { "AT+CMMS", modem_error },
+    { "AT+CMUT", modem_error },
+    { "AT+CMUX", modem_error },
+    { "AT+CNMA", modem_error },
+    { "AT+CNMI", modem_error },
+    { "AT+CNUM", modem_error },
+    { "AT+COLP", modem_error },
+    { "AT+COPN", modem_error },
+    { "AT+COPS", modem_ok },
+    { "AT+CPAS", modem_error },
+    { "AT+CPBF", modem_error },
+    { "AT+CPBR", modem_error },
+    { "AT+CPBS", modem_error },
+    { "AT+CPBW", modem_error },
+    { "AT+CPIN", modem_ok },
+    { "AT+CPMS", modem_error },
+    { "AT+CPOL", modem_error },
+    { "AT+CPUC", modem_error },
+    { "AT+CPWD", modem_error },
+    { "AT+CR", modem_error },
+    { "AT+CRC", modem_error },
+    { "AT+CREG", modem_error },
+    { "AT+CRES", modem_error },
+    { "AT+CRLP", modem_error },
+    { "AT+CRSL", modem_error },
+    { "AT+CRSM", modem_error },
+    { "AT+CSAS", modem_error },
+    { "AT+CSCA", modem_error },
+    { "AT+CSCB", modem_error },
+    { "AT+CSCS", modem_error },
+    { "AT+CSDH", modem_error },
+    { "AT+CSIM", modem_error },
+    { "AT+CSMP", modem_error },
+    { "AT+CSMS", modem_error },
+    { "AT+CSNS", modem_error },
+    { "AT+CSQ", modem_error },
+    { "AT%CSQ", modem_error },
+    { "AT+CSSN", modem_error },
+    { "AT+CSTA", modem_error },
+    { "AT+CSVM", modem_error },
+    { "AT+CTFR", modem_error },
+    { "AT+CUSD", modem_error },
+    { "AT+DR", modem_error },
+    { "AT+FAP", modem_error },
+    { "AT+FBO", modem_error },
+    { "AT+FBS", modem_error },
+    { "AT+FBU", modem_error },
+    { "AT+FCC", modem_error },
+    { "AT+FCLASS", modem_error },
+    { "AT+FCQ", modem_error },
+    { "AT+FCR", modem_error },
+    { "AT+FCS", modem_error },
+    { "AT+FCT", modem_error },
+    { "AT+FDR", modem_error },
+    { "AT+FDT", modem_error },
+    { "AT+FEA", modem_error },
+    { "AT+FFC", modem_error },
+    { "AT+FHS", modem_error },
+    { "AT+FIE", modem_error },
+    { "AT+FIP", modem_error },
+    { "AT+FIS", modem_error },
+    { "AT+FIT", modem_error },
+    { "AT+FKS", modem_error },
+    { "AT+FLI", modem_error },
+    { "AT+FLO", modem_error },
+    { "AT+FLP", modem_error },
+    { "AT+FMI", modem_error },
+    { "AT+FMM", modem_error },
+    { "AT+FMR", modem_error },
+    { "AT+FMS", modem_error },
+    { "AT+FND", modem_error },
+    { "AT+FNR", modem_error },
+    { "AT+FNS", modem_error },
+    { "AT+FPA", modem_error },
+    { "AT+FPI", modem_error },
+    { "AT+FPS", modem_error },
+    { "AT+FPW", modem_error },
+    { "AT+FRQ", modem_error },
+    { "AT+FSA", modem_error },
+    { "AT+FSP", modem_error },
+    { "AT+GCAP", modem_error },
+    { "AT+GCI", modem_error },
+    { "AT+GMI", modem_error },
+    { "AT+GMM", modem_error },
+    { "AT+GMR", modem_error },
+    { "AT+GSN", modem_error },
+    { "AT+ICF", modem_error },
+    { "AT+IFC", modem_error },
+    { "AT+ILRR", modem_error },
+    { "AT+IPR", modem_error },
+    { "AT+VTS", modem_error },
+    { "AT+WS46", modem_error },
+    { "AT%ALS", modem_error },
+    { "AT%ATR", modem_error },
+    { "AT%BAND", modem_error },
+    { "AT%CACM", modem_error },
+    { "AT%CAOC", modem_error },
+    { "AT%CCBS", modem_error },
+    { "AT%STDR", modem_error },
+    { "AT%CGAATT", modem_error },
+    { "AT%CGMM", modem_error },
+    { "AT%CGREG", modem_error },
+    { "AT%CNAP", modem_error },
+    { "AT%CPI", modem_error },
+    { "AT%COLR", modem_error },
+    { "AT%CPRIM", modem_error },
+    { "AT%CTV", modem_error },
+    { "AT%CUNS", modem_error },
+    { "AT%NRG", modem_error },
+    { "AT%SATC", modem_error },
+    { "AT%SATE", modem_error },
+    { "AT%SATR", modem_error },
+    { "AT%SATT", modem_error },
+    { "AT%SNCNT", modem_error },
+    { "AT%VER", modem_error },
+    { "AT%CGCLASS", modem_error },
+    { "AT%CGPCO", modem_error },
+    { "AT%CGPPP", modem_error },
+    { "AT%EM", modem_error },
+    { "AT%EMET", modem_error },
+    { "AT%EMETS", modem_error },
+    { "AT%CBHZ", modem_error },
+    { "AT%CPHS", modem_error },
+    { "AT%CPNUMS", modem_error },
+    { "AT%CPALS", modem_error },
+    { "AT%CPVWI", modem_error },
+    { "AT%CPOPN", modem_error },
+    { "AT%CPCFU", modem_error },
+    { "AT%CPINF", modem_error },
+    { "AT%CPMB", modem_error },
+    { "AT%CPRI", modem_error },
+    { "AT%DATA", modem_error },
+    { "AT%DINF", modem_error },
+    { "AT%CLCC", modem_error },
+    { "AT%DBGINFO", modem_error },
+    { "AT%VTS", modem_error },
+    { "AT%CHPL", modem_error },
+    { "AT%CREG", modem_error },
+    { "AT+CTZR", modem_error },
+    { "AT+CTZU", modem_error },
+    { "AT%CTZV", modem_error },
+    { "AT%CNIV", modem_error },
+    { "AT%PVRF", modem_error },
+    { "AT%CWUP", modem_error },
+    { "AT%DAR", modem_error },
+    { "AT+CIND", modem_error },
+    { "AT+CMER", modem_error },
+    { "AT%CSCN", modem_error },
+    { "AT%RDL", modem_error },
+    { "AT%RDLB", modem_error },
+    { "AT%CSTAT", modem_error },
+    { "AT%CPRSM", modem_error },
+    { "AT%CHLD", modem_error },
+    { "AT%SIMIND", modem_error },
+    { "AT%SECP", modem_error },
+    { "AT%SECS", modem_error },
+    { "AT%CSSN", modem_error },
+    { "AT+CCLK", modem_error },
+    { "AT%CSSD", modem_error },
+    { "AT%COPS", modem_error },
+    { "AT%CPMBW", modem_error },
+    { "AT%CUST", modem_error },
+    { "AT%SATCC", modem_error },
+    { "AT%COPN", modem_error },
+    { "AT%CGEREP", modem_error },
+    { "AT%CUSCFG", modem_error },
+    { "AT%CUSDR", modem_error },
+    { "AT%CPBS", modem_error },
+    { "AT%PBCF", modem_error },
+    { "AT%SIMEF", modem_error },
+    { "AT%EFRSLT", modem_error },
+    { "AT%CMGMDU", modem_error },
+    { "AT%CMGL", modem_error },
+    { "AT%CMGR", modem_error },
+    { "ATA", modem_ok },
+    { "ATB", modem_error },
+    { "AT&C", modem_error },
+    { "ATD", modem_ok },
+    { "AT&D", modem_error },
+    { "ATE", modem_ok },
+    { "ATF", modem_error },
+    { "AT&F", modem_error },
+    { "ATH", modem_ok },
+    { "ATI", modem_error },
+    { "AT&K", modem_error },
+    { "ATL", modem_error },
+    { "ATM", modem_error },
+    { "ATO", modem_error },
+    { "ATP", modem_error },
+    { "ATQ", modem_error },
+    { "ATS", modem_error },
+    { "ATT", modem_error },
+    { "ATV", modem_error },
+    { "ATW", modem_error },
+    { "AT&W", modem_error },
+    { "ATX", modem_error },
+    { "ATZ", modem_error },
+    { 0 }
+};
+
+static void modem_cmd(struct modem_s *s, const char *cmd)
+{
+    struct modem_cmd_s *entry;
+    const char *eq, *param;
+    int ok;
+    eq = strchr(cmd, '=');
+    if (eq)
+        param = eq + 1;
+    else
+        param = 0;
+    ok = 0;
+    for (entry = modem_cmds; entry->cmd; entry ++)
+        if (!strncmp(cmd, entry->cmd, strlen(entry->cmd))) {
+            switch (entry->action) {
+            case modem_ok:
+                ok = 1;
+                break;
+            case modem_error:
+                ok = 0;
+                break;
+            case modem_call:
+                ok = entry->call(s, param);
+                break;
+            case modem_str:
+                modem_resp(s, entry->resp);
+                ok = 1;
+                break;
+            }
+            return;
+        }
+    if (ok)
+        modem_resp(s, "OK\n");
+    else
+        modem_resp(s, "ERROR\n");
+}
+
+static int modem_write(struct CharDriverState *chr,
+                const uint8_t *buf, int len)
+{
+    struct modem_s *s = (struct modem_s *) chr->opaque;
+    char *eol;
+    if (!s->enable)
+        return 0;
+
+    len = MIN(len, 1023 - s->cmd_len);
+    memcpy(s->cmd + s->cmd_len, buf, len);
+    s->cmd_len += len;
+    s->cmd[s->cmd_len] = 0;
+
+    eol = strchr(s->cmd, '\n');
+    if (eol) {
+        s->cmd_len -= eol - s->cmd;
+        *eol = 0;
+        modem_cmd(s, s->cmd);
+        memcpy(s->cmd, eol + 1, s->cmd_len --);
+    } else if (s->cmd_len >= 1023)
+        s->cmd_len = 0;
+    return len;
+}
+
+static int modem_ioctl(struct CharDriverState *chr, int cmd, void *arg)
+{
+    QEMUSerialSetParams *ssp;
+    struct modem_s *s = (struct modem_s *) chr->opaque;
+    switch (cmd) {
+    case CHR_IOCTL_SERIAL_SET_PARAMS:
+        ssp = (QEMUSerialSetParams *) arg;
+        s->baud_delay = ticks_per_sec / ssp->speed;
+        break;
+
+    case CHR_IOCTL_MODEM_HANDSHAKE:
+        if (!s->enable)
+            return -ENOTSUP;
+        if (*(int *) arg)
+            modem_resp(s, "AT-Command Interpreter Ready\nOK\n");
+        break;
+
+    default:
+        return -ENOTSUP;
+    }
+    return 0;
+}
+
+void modem_enable(CharDriverState *chr, int enable)
+{
+    struct modem_s *s = (struct modem_s *) chr->opaque;
+    if (enable)
+        modem_reset(s);
+    s->enable = enable;
+}
+
+static void modem_out_tick(void *opaque)
+{
+    modem_fifo_wake((struct modem_s *) opaque);
+}
+
+CharDriverState *modem_init()
+{
+    struct modem_s *s = (struct modem_s *)
+            qemu_mallocz(sizeof(struct modem_s));
+    s->chr.opaque = s;
+    s->chr.chr_write = modem_write;
+    s->chr.chr_ioctl = modem_ioctl;
+    s->chr.chr_add_read_handler = modem_add_read_handler;
+    s->out_tm = qemu_new_timer(vm_clock, modem_out_tick, s);
+
+    return &s->chr;
+}

Modified: trunk/src/host/qemu-neo1973/hw/neo1973.c
===================================================================
--- trunk/src/host/qemu-neo1973/hw/neo1973.c    2007-04-05 21:41:34 UTC (rev 
1666)
+++ trunk/src/host/qemu-neo1973/hw/neo1973.c    2007-04-05 23:50:59 UTC (rev 
1667)
@@ -54,6 +54,15 @@
 #define GTA01_GPIO_GPS_EN_3V   S3C_GPG(10)
 #define GTA01_GPIO_GPS_RESET   S3C_GPC(0)
 
+struct neo_board_s {
+    struct s3c_state_s *cpu;
+    struct i2c_slave_s *pmu;
+    struct i2c_slave_s *wm;
+    struct i2c_slave_s *lcm;
+    CharDriverState *modem;
+    void *kbd_pic;
+};
+
 /* Handlers for output ports */
 static void neo_bl_switch(int line, int level, void *opaque)
 {
@@ -84,6 +93,8 @@
 
 static void neo_modem_switch(int line, int level, void *opaque)
 {
+    struct neo_board_s *s = (struct neo_board_s *) opaque;
+    modem_enable(s->modem, level);
     neo_printf("Modem powered %s.\n", level ? "up" : "down");
 }
 
@@ -135,70 +146,62 @@
 {
 }
 
-struct neo_kbd_s {
-    void *pic;
-    struct i2c_slave_s *pmu;
-};
-
 /* Hardware keys */
 static void neo_kbd_handler(void *opaque, int keycode)
 {
-    struct neo_kbd_s *kbd = (struct neo_kbd_s *) opaque;
+    struct neo_board_s *s = (struct neo_board_s *) opaque;
     switch (keycode & 0x7f) {
     case 0x1c: /* Return */
-        pic_set_irq_new(kbd->pic, GTA01_IRQ_911_KEY, !(keycode & 0x80));
+        pic_set_irq_new(s->kbd_pic, GTA01_IRQ_911_KEY, !(keycode & 0x80));
         break;
     case 0x39: /* Space */
-        pic_set_irq_new(kbd->pic, GTA01_IRQ_HOLD_KEY, !(keycode & 0x80));
-        pcf_onkey_set(kbd->pmu, !(keycode & 80));      /* Active LOW */
+        pic_set_irq_new(s->kbd_pic, GTA01_IRQ_HOLD_KEY, !(keycode & 0x80));
+        pcf_onkey_set(s->pmu, !(keycode & 80));        /* Active LOW */
         break;
     }
 }
 
-static void neo_kbd_init(struct s3c_state_s *cpu, struct i2c_slave_s *pmu)
+static void neo_kbd_init(struct neo_board_s *s)
 {
-    struct neo_kbd_s *kbd = (struct neo_kbd_s *)
-            qemu_mallocz(sizeof(struct neo_kbd_s));
-    kbd->pic = cpu->io;
-    kbd->pmu = pmu;
-    qemu_add_kbd_event_handler(neo_kbd_handler, kbd);
+    s->kbd_pic = s->cpu->io;
+    qemu_add_kbd_event_handler(neo_kbd_handler, s);
 }
 
-static void neo_gpio_setup(struct s3c_state_s *cpu)
+static void neo_gpio_setup(struct neo_board_s *s)
 {
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_BACKLIGHT,
-                    neo_bl_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_GPS_PWRON,
-                    neo_gpspwr_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_MODEM_RST,
-                    neo_modem_rst_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_MODEM_ON,
-                    neo_modem_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_LCD_RESET,
-                    neo_lcd_rst_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_VIBRATOR_ON,
-                    neo_vib_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_VIBRATOR_ON2,
-                    neo_vib_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01v3_GPIO_nGSM_EN,
-                    neo_gsm_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01Bv2_GPIO_nGSM_EN,
-                    neo_gsm_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_BT_EN,
-                    neo_bt_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_GPS_EN_2V8,
-                    neo_gps_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_GPS_EN_3V,
-                    neo_gps_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_GPS_EN_3V3,
-                    neo_gps_switch, cpu);
-    s3c_gpio_handler_set(cpu->io, GTA01_GPIO_GPS_RESET,
-                    neo_gps_rst_switch, cpu);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_BACKLIGHT,
+                    neo_bl_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_GPS_PWRON,
+                    neo_gpspwr_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_MODEM_RST,
+                    neo_modem_rst_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_MODEM_ON,
+                    neo_modem_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_LCD_RESET,
+                    neo_lcd_rst_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_VIBRATOR_ON,
+                    neo_vib_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_VIBRATOR_ON2,
+                    neo_vib_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01v3_GPIO_nGSM_EN,
+                    neo_gsm_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01Bv2_GPIO_nGSM_EN,
+                    neo_gsm_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_BT_EN,
+                    neo_bt_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_GPS_EN_2V8,
+                    neo_gps_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_GPS_EN_3V,
+                    neo_gps_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_GPS_EN_3V3,
+                    neo_gps_switch, s);
+    s3c_gpio_handler_set(s->cpu->io, GTA01_GPIO_GPS_RESET,
+                    neo_gps_rst_switch, s);
 
-    s3c_timers_cmp_handler_set(cpu->timers, 0, neo_bl_intensity, cpu);
+    s3c_timers_cmp_handler_set(s->cpu->timers, 0, neo_bl_intensity, s);
 
     /* MMC/SD host */
-    s3c_mmci_handlers(cpu->mmci, cpu->io, neo_mmc_writeprotect_switch,
+    s3c_mmci_handlers(s->cpu->mmci, s->cpu->io, neo_mmc_writeprotect_switch,
                     neo_mmc_cover_switch);
 }
 
@@ -264,58 +267,62 @@
 #define NEO_WM_ADDR    0x1a
 #define NEO_AMP_ADDR   0x7c    /* ADR wired to low */
 
-static struct i2c_slave_s *neo_i2c_setup(struct s3c_state_s *cpu)
+static void neo_i2c_setup(struct neo_board_s *s)
 {
     struct i2c_bus_s *bus = (struct i2c_bus_s *)
             qemu_mallocz(sizeof(struct i2c_bus_s));
-    struct i2c_slave_s *pmu;
 #ifdef HAS_AUDIO
-    struct i2c_slave_s *wm;
     AudioState *audio;
 #endif
 
-    pmu = pcf5060x_init(cpu->pic, GTA01_IRQ_PCF50606, 0);
+    s->pmu = pcf5060x_init(s->cpu->pic, GTA01_IRQ_PCF50606, 0);
+    s->lcm = lm4857_init();
 
     /* Attach the CPU on one end of our I2C bus.  */
-    i2c_master_attach(bus, s3c_i2c_master(cpu->i2c));
+    i2c_master_attach(bus, s3c_i2c_master(s->cpu->i2c));
 
     /* Attach a PCF50606 to the bus */
-    i2c_slave_attach(bus, NEO_PMU_ADDR, pmu);
+    i2c_slave_attach(bus, NEO_PMU_ADDR, s->pmu);
 
     /* Attach a LM4857 to the bus */
-    i2c_slave_attach(bus, NEO_AMP_ADDR, lm4857_init());
+    i2c_slave_attach(bus, NEO_AMP_ADDR, s->lcm);
 
 #ifdef HAS_AUDIO
     audio = AUD_init();
     if (!audio)
-        goto done;
-    wm = wm8753_init(audio);
+        return;
+    s->wm = wm8753_init(audio);
 
     /* Attach a WM8750 to the bus */
-    i2c_slave_attach(bus, NEO_WM_ADDR, wm);
+    i2c_slave_attach(bus, NEO_WM_ADDR, s->wm);
     /* .. and to the sound interface.  */
-    cpu->i2s->opaque = wm->opaque;
-    cpu->i2s->codec_out = wm8753_dac_dat;
-    cpu->i2s->codec_in = wm8753_adc_dat;
-    wm8753_data_req_set(wm, cpu->i2s->data_req, cpu->i2s);
-done:
+    s->cpu->i2s->opaque = s->wm->opaque;
+    s->cpu->i2s->codec_out = wm8753_dac_dat;
+    s->cpu->i2s->codec_in = wm8753_adc_dat;
+    wm8753_data_req_set(s->wm, s->cpu->i2s->data_req, s->cpu->i2s);
 #endif
-    return pmu;
 }
 
-static void neo_spi_setup(struct s3c_state_s *cpu)
+static void neo_spi_setup(struct neo_board_s *s)
 {
     void *jbt6k74 = jbt6k74_init();
 
-    s3c_spi_attach(cpu->spi, 0, 0, 0, 0);
-    s3c_spi_attach(cpu->spi, 1, jbt6k74_txrx, jbt6k74_btxrx, jbt6k74);
+    s3c_spi_attach(s->cpu->spi, 0, 0, 0, 0);
+    s3c_spi_attach(s->cpu->spi, 1, jbt6k74_txrx, jbt6k74_btxrx, jbt6k74);
 }
 
+static void neo_gsm_setup(struct neo_board_s *s)
+{
+    s->modem = modem_init();
+
+    s3c_uart_attach(s->cpu->uart[0], s->modem);
+}
+
 static void neo_reset(void *opaque)
 {
-    struct s3c_state_s *cpu = (struct s3c_state_s *) opaque;
-    s3c2410_reset(cpu);
-    cpu->env->regs[15] = S3C_RAM_BASE;
+    struct neo_board_s *s = (struct neo_board_s *) opaque;
+    s3c2410_reset(s->cpu);
+    s->cpu->env->regs[15] = S3C_RAM_BASE;
 }
 
 /* Board init.  */
@@ -325,34 +332,36 @@
                 const char *initrd_filename)
 {
     uint32_t neo_ram = 0x08000000;
-    struct s3c_state_s *cpu;
-    struct i2c_slave_s *pmu;
+    struct neo_board_s *s = (struct neo_board_s *)
+            qemu_mallocz(sizeof(struct neo_board_s));
 
-    cpu = s3c2410_init(ds);
+    s->cpu = s3c2410_init(ds);
 
     /* Setup memory */
-    if (ram_size < neo_ram + cpu->free_ram_start) {
+    if (ram_size < neo_ram + s->cpu->free_ram_start) {
         fprintf(stderr, "This platform requires %i bytes of memory\n",
-                        neo_ram + cpu->free_ram_start);
+                        neo_ram + s->cpu->free_ram_start);
         exit(1);
     }
     cpu_register_physical_memory(S3C_RAM_BASE, neo_ram,
-                    cpu->free_ram_start | IO_MEM_RAM);
-    cpu->free_ram_start += neo_ram;
+                    s->cpu->free_ram_start | IO_MEM_RAM);
+    s->cpu->free_ram_start += neo_ram;
 
-    s3c_nand_register(cpu, nand_init(NAND_MFR_SAMSUNG, 0x76));
+    s3c_nand_register(s->cpu, nand_init(NAND_MFR_SAMSUNG, 0x76));
 
     /* Setup peripherals */
-    neo_gpio_setup(cpu);
+    neo_gpio_setup(s);
 
-    pmu = neo_i2c_setup(cpu);
+    neo_i2c_setup(s);
 
-    neo_kbd_init(cpu, pmu);
+    neo_kbd_init(s);
 
-    neo_spi_setup(cpu);
+    neo_spi_setup(s);
 
-    qemu_register_reset(neo_reset, cpu);
+    neo_gsm_setup(s);
 
+    qemu_register_reset(neo_reset, s);
+
     /* Setup initial (reset) machine state */
 #if 0
     cpu->env->regs[15] = S3C_SRAM_BASE;
@@ -364,14 +373,14 @@
                     phys_ram_base + S3C_SRAM_SIZE + 0x03f80000);
     load_image(kernel_filename,
                     phys_ram_base + S3C_SRAM_SIZE + 0x02000000);
-    cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000;
+    s->cpu->env->regs[15] = S3C_RAM_BASE | 0x03f80000;
 #endif
 
     /* Imitate ONKEY wakeup */
-    pcf_onkey_set(pmu, 0);
-    pcf_onkey_set(pmu, 1);
+    pcf_onkey_set(s->pmu, 0);
+    pcf_onkey_set(s->pmu, 1);
     /* Connect the charger */
-    pcf_exton_set(pmu, 1);
+    pcf_exton_set(s->pmu, 1);
 }
 
 QEMUMachine neo1973_machine = {

Modified: trunk/src/host/qemu-neo1973/vl.h
===================================================================
--- trunk/src/host/qemu-neo1973/vl.h    2007-04-05 21:41:34 UTC (rev 1666)
+++ trunk/src/host/qemu-neo1973/vl.h    2007-04-05 23:50:59 UTC (rev 1667)
@@ -292,7 +292,7 @@
 #define CHR_IOCTL_PP_WRITE_CONTROL    6
 #define CHR_IOCTL_PP_READ_STATUS      7
 
-#define CHR_IOCTL_MODEM_SET_AFC       8
+#define CHR_IOCTL_MODEM_HANDSHAKE     8
 
 typedef void IOEventHandler(void *opaque, int event);
 
@@ -1462,6 +1462,10 @@
 #include "hw/s3c.h"
 #endif
 
+/* modem.c */
+CharDriverState *modem_init();
+void modem_enable(CharDriverState *chr, int enable);
+
 #endif /* defined(QEMU_TOOL) */
 
 /* monitor.c */




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to