From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lgm20-0006iv-83 for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:25:00 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lgm1y-0006gr-Hq for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:24:59 -0400 Received: from [199.232.76.173] (port=50194 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lgm1y-0006gD-8j for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:24:58 -0400 Received: from mx20.gnu.org ([199.232.41.8]:3117) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lgm1w-0000ym-Os for qemu-devel@nongnu.org; Mon, 09 Mar 2009 16:24:57 -0400 Received: from fmmailgate01.web.de ([217.72.192.221]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1LgPCc-0000hS-Qq for qemu-devel@nongnu.org; Sun, 08 Mar 2009 16:02:27 -0400 Received: from smtp06.web.de (fmsmtp06.dlan.cinetic.de [172.20.5.172]) by fmmailgate01.web.de (Postfix) with ESMTP id 98968FE59CEC for ; Sun, 8 Mar 2009 21:01:47 +0100 (CET) Received: from [92.75.142.96] (helo=[192.168.1.4]) by smtp06.web.de with asmtp (TLSv1:AES256-SHA:256) (WEB.DE 4.110 #277) id 1LgPBy-0006av-00 for qemu-devel@nongnu.org; Sun, 08 Mar 2009 21:01:46 +0100 Message-ID: <49B42425.6070107@web.de> Date: Sun, 08 Mar 2009 21:01:41 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <4999D9CB.5020702@web.de> In-Reply-To: <4999D9CB.5020702@web.de> Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig9EA12DB7C9407075CC2B674A" Sender: jan.kiszka@web.de Subject: [Qemu-devel] Re: [PATCH] musicpal: Reorganize IO memory handling Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig9EA12DB7C9407075CC2B674A Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: quoted-printable Jan Kiszka wrote: > The new MMIO interface requires non-overlapping slots. Reorganize the > musicpal accordingly, fixing a regression for the Ethernet emulation. >=20 > Signed-off-by: Jan Kiszka > --- >=20 > hw/musicpal.c | 189 ++++++++++++++++++++++++++++++++++++++++++-------= -------- > 1 files changed, 139 insertions(+), 50 deletions(-) >=20 > diff --git a/hw/musicpal.c b/hw/musicpal.c > index 75c8887..03f40d3 100644 > --- a/hw/musicpal.c > +++ b/hw/musicpal.c > @@ -20,12 +20,21 @@ > #include "audio/audio.h" > #include "i2c.h" > =20 > +#define MP_MISC_BASE 0x80002000 > +#define MP_MISC_SIZE 0x00001000 > + > #define MP_ETH_BASE 0x80008000 > #define MP_ETH_SIZE 0x00001000 > =20 > +#define MP_WLAN_BASE 0x8000C000 > +#define MP_WLAN_SIZE 0x00000800 > + > #define MP_UART1_BASE 0x8000C840 > #define MP_UART2_BASE 0x8000C940 > =20 > +#define MP_GPIO_BASE 0x8000D000 > +#define MP_GPIO_SIZE 0x00001000 > + > #define MP_FLASHCFG_BASE 0x90006000 > #define MP_FLASHCFG_SIZE 0x00001000 > =20 > @@ -429,7 +438,7 @@ static CPUWriteMemoryFunc *musicpal_audio_writefn[]= =3D { > musicpal_audio_write > }; > =20 > -static i2c_interface *musicpal_audio_init(uint32_t base, qemu_irq irq)= > +static i2c_interface *musicpal_audio_init(qemu_irq irq) > { > AudioState *audio; > musicpal_audio_state *s; > @@ -457,14 +466,14 @@ static i2c_interface *musicpal_audio_init(uint32_= t base, qemu_irq irq) > =20 > iomemtype =3D cpu_register_io_memory(0, musicpal_audio_readfn, > musicpal_audio_writefn, s); > - cpu_register_physical_memory(base, MP_AUDIO_SIZE, iomemtype); > + cpu_register_physical_memory(MP_AUDIO_BASE, MP_AUDIO_SIZE, iomemty= pe); > =20 > qemu_register_reset(musicpal_audio_reset, s); > =20 > return i2c; > } > #else /* !HAS_AUDIO */ > -static i2c_interface *musicpal_audio_init(uint32_t base, qemu_irq irq)= > +static i2c_interface *musicpal_audio_init(qemu_irq irq) > { > return NULL; > } > @@ -899,7 +908,7 @@ static CPUWriteMemoryFunc *musicpal_lcd_writefn[] =3D= { > musicpal_lcd_write > }; > =20 > -static void musicpal_lcd_init(uint32_t base) > +static void musicpal_lcd_init(void) > { > musicpal_lcd_state *s; > int iomemtype; > @@ -907,7 +916,7 @@ static void musicpal_lcd_init(uint32_t base) > s =3D qemu_mallocz(sizeof(musicpal_lcd_state)); > iomemtype =3D cpu_register_io_memory(0, musicpal_lcd_readfn, > musicpal_lcd_writefn, s); > - cpu_register_physical_memory(base, MP_LCD_SIZE, iomemtype); > + cpu_register_physical_memory(MP_LCD_BASE, MP_LCD_SIZE, iomemtype);= > =20 > s->ds =3D graphic_console_init(lcd_refresh, lcd_invalidate, > NULL, NULL, s); > @@ -1195,20 +1204,102 @@ static void mv88w8618_flashcfg_init(uint32_t b= ase) > cpu_register_physical_memory(base, MP_FLASHCFG_SIZE, iomemtype); > } > =20 > -/* Various registers in the 0x80000000 domain */ > -#define MP_BOARD_REVISION 0x2018 > +/* Misc register offsets */ > +#define MP_MISC_BOARD_REVISION 0x18 > + > +#define MP_BOARD_REVISION 0x31 > + > +static uint32_t musicpal_misc_read(void *opaque, target_phys_addr_t of= fset) > +{ > + switch (offset) { > + case MP_MISC_BOARD_REVISION: > + return MP_BOARD_REVISION; > + > + default: > + return 0; > + } > +} > + > +static void musicpal_misc_write(void *opaque, target_phys_addr_t offse= t, > + uint32_t value) > +{ > +} > + > +static CPUReadMemoryFunc *musicpal_misc_readfn[] =3D { > + musicpal_misc_read, > + musicpal_misc_read, > + musicpal_misc_read, > +}; > + > +static CPUWriteMemoryFunc *musicpal_misc_writefn[] =3D { > + musicpal_misc_write, > + musicpal_misc_write, > + musicpal_misc_write, > +}; > + > +static void musicpal_misc_init(void) > +{ > + int iomemtype; > + > + iomemtype =3D cpu_register_io_memory(0, musicpal_misc_readfn, > + musicpal_misc_writefn, NULL); > + cpu_register_physical_memory(MP_MISC_BASE, MP_MISC_SIZE, iomemtype= ); > +} > + > +/* WLAN register offsets */ > +#define MP_WLAN_MAGIC1 0x11c > +#define MP_WLAN_MAGIC2 0x124 > + > +static uint32_t mv88w8618_wlan_read(void *opaque, target_phys_addr_t o= ffset) > +{ > + switch (offset) { > + /* Workaround to allow loading the binary-only wlandrv.ko crap > + * from the original Freecom firmware. */ > + case MP_WLAN_MAGIC1: > + return ~3; > + case MP_WLAN_MAGIC2: > + return -1; > + > + default: > + return 0; > + } > +} > + > +static void mv88w8618_wlan_write(void *opaque, target_phys_addr_t offs= et, > + uint32_t value) > +{ > +} > + > +static CPUReadMemoryFunc *mv88w8618_wlan_readfn[] =3D { > + mv88w8618_wlan_read, > + mv88w8618_wlan_read, > + mv88w8618_wlan_read, > +}; > + > +static CPUWriteMemoryFunc *mv88w8618_wlan_writefn[] =3D { > + mv88w8618_wlan_write, > + mv88w8618_wlan_write, > + mv88w8618_wlan_write, > +}; > + > +static void mv88w8618_wlan_init(uint32_t base) > +{ > + int iomemtype; > =20 > -#define MP_WLAN_MAGIC1 0xc11c > -#define MP_WLAN_MAGIC2 0xc124 > + iomemtype =3D cpu_register_io_memory(0, mv88w8618_wlan_readfn, > + mv88w8618_wlan_writefn, NULL); > + cpu_register_physical_memory(base, MP_WLAN_SIZE, iomemtype); > +} > =20 > -#define MP_GPIO_OE_LO 0xd008 > -#define MP_GPIO_OUT_LO 0xd00c > -#define MP_GPIO_IN_LO 0xd010 > -#define MP_GPIO_ISR_LO 0xd020 > -#define MP_GPIO_OE_HI 0xd508 > -#define MP_GPIO_OUT_HI 0xd50c > -#define MP_GPIO_IN_HI 0xd510 > -#define MP_GPIO_ISR_HI 0xd520 > +/* GPIO register offsets */ > +#define MP_GPIO_OE_LO 0x008 > +#define MP_GPIO_OUT_LO 0x00c > +#define MP_GPIO_IN_LO 0x010 > +#define MP_GPIO_ISR_LO 0x020 > +#define MP_GPIO_OE_HI 0x508 > +#define MP_GPIO_OUT_HI 0x50c > +#define MP_GPIO_IN_HI 0x510 > +#define MP_GPIO_ISR_HI 0x520 > =20 > /* GPIO bits & masks */ > #define MP_GPIO_WHEEL_VOL (1 << 8) > @@ -1227,12 +1318,9 @@ static void mv88w8618_flashcfg_init(uint32_t bas= e) > /* LCD brightness bits in GPIO_OE_HI */ > #define MP_OE_LCD_BRIGHTNESS 0x0007 > =20 > -static uint32_t musicpal_read(void *opaque, target_phys_addr_t offset)= > +static uint32_t musicpal_gpio_read(void *opaque, target_phys_addr_t of= fset) > { > switch (offset) { > - case MP_BOARD_REVISION: > - return 0x0031; > - > case MP_GPIO_OE_HI: /* used for LCD brightness control */ > return lcd_brightness & MP_OE_LCD_BRIGHTNESS; > =20 > @@ -1254,20 +1342,13 @@ static uint32_t musicpal_read(void *opaque, tar= get_phys_addr_t offset) > case MP_GPIO_ISR_HI: > return gpio_isr >> 16; > =20 > - /* Workaround to allow loading the binary-only wlandrv.ko crap > - * from the original Freecom firmware. */ > - case MP_WLAN_MAGIC1: > - return ~3; > - case MP_WLAN_MAGIC2: > - return -1; > - > default: > return 0; > } > } > =20 > -static void musicpal_write(void *opaque, target_phys_addr_t offset, > - uint32_t value) > +static void musicpal_gpio_write(void *opaque, target_phys_addr_t offse= t, > + uint32_t value) > { > switch (offset) { > case MP_GPIO_OE_HI: /* used for LCD brightness control */ > @@ -1290,6 +1371,27 @@ static void musicpal_write(void *opaque, target_= phys_addr_t offset, > } > } > =20 > +static CPUReadMemoryFunc *musicpal_gpio_readfn[] =3D { > + musicpal_gpio_read, > + musicpal_gpio_read, > + musicpal_gpio_read, > +}; > + > +static CPUWriteMemoryFunc *musicpal_gpio_writefn[] =3D { > + musicpal_gpio_write, > + musicpal_gpio_write, > + musicpal_gpio_write, > +}; > + > +static void musicpal_gpio_init(void) > +{ > + int iomemtype; > + > + iomemtype =3D cpu_register_io_memory(0, musicpal_gpio_readfn, > + musicpal_gpio_writefn, NULL); > + cpu_register_physical_memory(MP_GPIO_BASE, MP_GPIO_SIZE, iomemtype= ); > +} > + > /* Keyboard codes & masks */ > #define KEY_RELEASED 0x80 > #define KEY_CODE 0x7f > @@ -1370,18 +1472,6 @@ static void musicpal_key_event(void *opaque, int= keycode) > kbd_extended =3D 0; > } > =20 > -static CPUReadMemoryFunc *musicpal_readfn[] =3D { > - musicpal_read, > - musicpal_read, > - musicpal_read, > -}; > - > -static CPUWriteMemoryFunc *musicpal_writefn[] =3D { > - musicpal_write, > - musicpal_write, > - musicpal_write, > -}; > - > static struct arm_boot_info musicpal_binfo =3D { > .loader_start =3D 0x0, > .board_id =3D 0x20e, > @@ -1395,7 +1485,6 @@ static void musicpal_init(ram_addr_t ram_size, in= t vga_ram_size, > CPUState *env; > qemu_irq *pic; > int index; > - int iomemtype; > unsigned long flash_size; > =20 > if (!cpu_model) > @@ -1415,11 +1504,6 @@ static void musicpal_init(ram_addr_t ram_size, i= nt vga_ram_size, > sram_off =3D qemu_ram_alloc(MP_SRAM_SIZE); > cpu_register_physical_memory(MP_SRAM_BASE, MP_SRAM_SIZE, sram_off)= ; > =20 > - /* Catch various stuff not handled by separate subsystems */ > - iomemtype =3D cpu_register_io_memory(0, musicpal_readfn, > - musicpal_writefn, env); > - cpu_register_physical_memory(0x80000000, 0x10000, iomemtype); > - > pic =3D mv88w8618_pic_init(MP_PIC_BASE, pic[ARM_PIC_CPU_IRQ]); > mv88w8618_pit_init(MP_PIT_BASE, pic, MP_TIMER1_IRQ); > =20 > @@ -1454,13 +1538,18 @@ static void musicpal_init(ram_addr_t ram_size, = int vga_ram_size, > } > mv88w8618_flashcfg_init(MP_FLASHCFG_BASE); > =20 > - musicpal_lcd_init(MP_LCD_BASE); > + musicpal_lcd_init(); > =20 > qemu_add_kbd_event_handler(musicpal_key_event, pic[MP_GPIO_IRQ]); > =20 > mv88w8618_eth_init(&nd_table[0], MP_ETH_BASE, pic[MP_ETH_IRQ]); > =20 > - mixer_i2c =3D musicpal_audio_init(MP_AUDIO_BASE, pic[MP_AUDIO_IRQ]= ); > + mixer_i2c =3D musicpal_audio_init(pic[MP_AUDIO_IRQ]); > + > + mv88w8618_wlan_init(MP_WLAN_BASE); > + > + musicpal_misc_init(); > + musicpal_gpio_init(); > =20 > musicpal_binfo.ram_size =3D MP_RAM_DEFAULT_SIZE; > musicpal_binfo.kernel_filename =3D kernel_filename; >=20 >=20 >=20 Could anyone out there apply this patch? Then please push it to both trunk and stable as it is primarily a bug fix. Thanks, Jan --------------enig9EA12DB7C9407075CC2B674A Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.9 (GNU/Linux) Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org iEYEARECAAYFAkm0JCkACgkQniDOoMHTA+nAZACeK6s2JrKPf9JfKL9bWfok5l/X 4QwAn10TCH1DFHsQ7MnBR9Jzo83ASmPI =FwXz -----END PGP SIGNATURE----- --------------enig9EA12DB7C9407075CC2B674A--