diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-02-19 15:14:20 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-02-19 15:14:20 +0000 |
commit | 20e239ac249b5a59f6c3dea0a42c2951d01a45f8 (patch) | |
tree | 8d9cc95e5da3c0d0035a5a73695744a6271f41e6 | |
parent | de8a15f48a1ae8a80705c902e1f22e377a4cd16a (diff) |
Add built-in audio support on Lemote systems.
-rw-r--r-- | distrib/notes/loongson/contents | 5 | ||||
-rw-r--r-- | distrib/notes/loongson/hardware | 13 | ||||
-rw-r--r-- | distrib/notes/loongson/install | 27 | ||||
-rw-r--r-- | sys/arch/loongson/conf/GENERIC | 5 | ||||
-rw-r--r-- | sys/arch/loongson/dev/glx.c | 107 |
5 files changed, 137 insertions, 20 deletions
diff --git a/distrib/notes/loongson/contents b/distrib/notes/loongson/contents index d27bf23639d..5f0caab8f01 100644 --- a/distrib/notes/loongson/contents +++ b/distrib/notes/loongson/contents @@ -1,4 +1,4 @@ -dnl $OpenBSD: contents,v 1.3 2010/02/17 18:09:47 miod Exp $ +dnl $OpenBSD: contents,v 1.4 2010/02/19 15:14:16 miod Exp $ TopPart OpenBSDdistsets @@ -9,8 +9,7 @@ OpenBSDrd dnl not yet... dnl OpenBSDcd - boot The OpenBSD/MACHINE boot block for Lemote - systems. + boot The OpenBSD/MACHINE bootloader. DistributionDescription(eleven) diff --git a/distrib/notes/loongson/hardware b/distrib/notes/loongson/hardware index ffe4acaf38d..3d7e228146a 100644 --- a/distrib/notes/loongson/hardware +++ b/distrib/notes/loongson/hardware @@ -1,16 +1,15 @@ -dnl $OpenBSD: hardware,v 1.5 2010/02/19 09:08:04 otto Exp $ +dnl $OpenBSD: hardware,v 1.6 2010/02/19 15:14:16 miod Exp $ The following machines are supported by OpenBSD/MACHINE: Lemote Fuloong 2F - onboard serial port, USB and Ethernet are supported; - onboard display and audio are not supported yet. + onboard serial port, audio, USB and Ethernet are supported; + onboard display is not supported yet. Lemote Yeeloong (8.9" and 10.1" models) all onboard devices (keyboard, trackpad, display, SD card reader, - USB ports, Ethernet adapter, wireless network adapter, - webcam on the 8.9" model) are supported except for the audio - controller; suspend/resume and battery information are not - supported yet. + USB ports, Ethernet adapter, wireless network adapter, audio, + webcam on the 8.9" model) are supported; suspend/resume and battery + information are not supported yet. Gdium Liberty 1000 all onboard devices (keyboard, trackpad, display, SD card reader, diff --git a/distrib/notes/loongson/install b/distrib/notes/loongson/install index 4a4ad814fad..a0e656821fd 100644 --- a/distrib/notes/loongson/install +++ b/distrib/notes/loongson/install @@ -1,4 +1,4 @@ -dnl $OpenBSD: install,v 1.7 2010/02/19 10:48:14 otto Exp $ +dnl $OpenBSD: install,v 1.8 2010/02/19 15:14:16 miod Exp $ OpenBSDInstallPrelude Booting the installation media: @@ -29,7 +29,6 @@ on Lemote systems, and PMON> g on Gdium systems. - dnl dnl Alternatively, if your particular PMON flavour supports `fat' filesystems, dnl you can boot the kernel from an usb key with: @@ -169,14 +168,28 @@ OpenBSDInstallWrapup Gdium systems do not have a boot menu, and directly boot the system (Linux, by default). Unfortunately, the OpenBSD - bootloader does not work on this machine. + bootloader operation is very limited on this machine, as + it can not access USB devices (which means no keyboard + input as well). + + To overcome this and be able to boot OpenBSD nevertheless, + the bootloader relies upon PMON's ability to load a Linux + so-called ``initrd'' image. By making PMON load the kernel + as the ``initrd'' image, and then run the bootloader, + the bootloader will be able to ``load'' the OpenBSD kernel + correctly. The path to the file booted by default is set in the `al' - environment variable. To boot the bsd kernel on the G-Key - by default, assuming it has been copied to /boot on the first - ext3 partition, you can change it to: + environment variable, and the path to the initrd image is + set in the `rd' environment variable. + + To boot the bsd kernel on the G-Key by default, assuming it + has been copied to /boot/bsd on the first ext3 partition, and + the bootloader has been copied to /boot/boot on the same + filesystem, the settings are: - PMON> set al /dev/fs/ext2@usbg0/boot/bsd + PMON> set al /dev/fs/ext2@usbg0/boot/boot + PMON> set rd /dev/fs/ext2@usbg0/boot/bsd Alternatively, you can disable autoboot by removing this variable: diff --git a/sys/arch/loongson/conf/GENERIC b/sys/arch/loongson/conf/GENERIC index 0bf4b3f303a..00e522f1ecc 100644 --- a/sys/arch/loongson/conf/GENERIC +++ b/sys/arch/loongson/conf/GENERIC @@ -1,4 +1,4 @@ -# $OpenBSD: GENERIC,v 1.11 2010/02/19 08:30:04 otto Exp $ +# $OpenBSD: GENERIC,v 1.12 2010/02/19 15:14:19 miod Exp $ # # For further information on compiling OpenBSD kernels, see the config(8) # man page. @@ -48,6 +48,8 @@ com0 at isa? port 0x2f8 irq 3 # Fuloong 2F only pciide* at pci? wd* at pciide? flags 0x0000 smfb* at pci? # Yeeloong only +auglx* at pci? +audio* at auglx? # Gdium Liberty specific devices voyager* at pci? @@ -57,7 +59,6 @@ gdiumiic0 at gpio0 offset 46 mask 0x03 # pins 46 and 47 iic0 at gdiumiic0 lmtemp0 at iic0 # National Semiconductor LM75 mfokclock0 at iic0 # M41T8x todclock -#gdiumiic1 at gpio0 offset 41 mask 0x03 # pins 41 and 42 #iic* at voyager? #ohci* at voyager? smfb* at voyager? diff --git a/sys/arch/loongson/dev/glx.c b/sys/arch/loongson/dev/glx.c index 70d8dfb888a..e66330e7c27 100644 --- a/sys/arch/loongson/dev/glx.c +++ b/sys/arch/loongson/dev/glx.c @@ -1,4 +1,4 @@ -/* $OpenBSD: glx.c,v 1.4 2010/02/12 08:11:27 miod Exp $ */ +/* $OpenBSD: glx.c,v 1.5 2010/02/19 15:14:19 miod Exp $ */ /* * Copyright (c) 2009 Miodrag Vallat. @@ -185,6 +185,7 @@ glx_pci_read_hook(void *v, pci_chipset_tag_t pc, pcitag_t tag, *data = glx_fn2_read(offset); break; case 3: /* AC97 codec */ + *data = glx_fn3_read(offset); break; case 4: /* OHCI controller */ *data = glx_fn4_read(offset); @@ -227,6 +228,7 @@ glx_pci_write_hook(void *v, pci_chipset_tag_t pc, pcitag_t tag, glx_fn2_write(offset, data); break; case 3: /* AC97 codec */ + glx_fn3_write(offset, data); break; case 4: /* OHCI controller */ glx_fn4_write(offset, data); @@ -536,6 +538,109 @@ glx_fn2_write(int reg, pcireg_t data) } /* + * Function 3: AC97 Codec + */ + +static pcireg_t ac97_bar_size = 0x80; +static pcireg_t ac97_bar_value; + +pcireg_t +glx_fn3_read(int reg) +{ + uint64_t msr; + pcireg_t data; + + switch (reg) { + case PCI_ID_REG: + case PCI_SUBSYS_ID_REG: + data = PCI_ID_CODE(PCI_VENDOR_AMD, + PCI_PRODUCT_AMD_CS5536_AUDIO); + break; + case PCI_COMMAND_STATUS_REG: + data = glx_get_status(); + data |= PCI_COMMAND_IO_ENABLE; + msr = rdmsr(GLIU_PAE); + if ((msr & (0x3 << 8)) == 0x03) + data |= PCI_COMMAND_MASTER_ENABLE; + break; + case PCI_CLASS_REG: + msr = rdmsr(ACC_GLD_MSR_CAP); + data = (PCI_CLASS_MULTIMEDIA << PCI_CLASS_SHIFT) | + (PCI_SUBCLASS_MULTIMEDIA_AUDIO << PCI_SUBCLASS_SHIFT) | + (msr & PCI_REVISION_MASK); + break; + case PCI_BHLC_REG: + msr = rdmsr(GLPCI_CTRL); + data = (0x00 << PCI_HDRTYPE_SHIFT) | + (((msr & 0xff00000000UL) >> 32) << PCI_LATTIMER_SHIFT) | + (0x08 << PCI_CACHELINE_SHIFT); + break; + case PCI_MAPREG_START: + data = ac97_bar_value; + if (data == 0xffffffff) + data = PCI_MAPREG_IO_ADDR_MASK & ~(ac97_bar_size - 1); + else { + msr = rdmsr(GLIU_IOD_BM1); + data = (msr >> 20) & 0x000fffff; + data &= (msr & 0x000fffff); + } + if (data != 0) + data |= PCI_MAPREG_TYPE_IO; + break; + case PCI_INTERRUPT_REG: + data = (0x40 << PCI_MAX_LAT_SHIFT) | + (PCI_INTERRUPT_PIN_A << PCI_INTERRUPT_PIN_SHIFT); + break; + default: + data = 0; + break; + } + + return data; +} + +void +glx_fn3_write(int reg, pcireg_t data) +{ + uint64_t msr; + + switch (reg) { + case PCI_COMMAND_STATUS_REG: + msr = rdmsr(GLIU_PAE); + if (data & PCI_COMMAND_MASTER_ENABLE) + msr |= 0x03 << 8; + else + msr &= ~(0x03 << 8); + wrmsr(GLIU_PAE, msr); + break; + case PCI_BHLC_REG: + msr = rdmsr(GLPCI_CTRL); + msr &= 0xff00000000UL; + msr |= ((uint64_t)PCI_LATTIMER(data)) << 32; + break; + case PCI_MAPREG_START: + if (data == 0xffffffff) { + ac97_bar_value = data; + } else { + if ((data & PCI_MAPREG_TYPE_MASK) == + PCI_MAPREG_TYPE_IO) { + data &= PCI_MAPREG_IO_ADDR_MASK; + msr = rdmsr(GLIU_IOD_BM1); + msr &= 0x0fffff0000000000UL; + msr |= 5UL << 61; /* AC97 */ + msr |= ((uint64_t)data & 0xfffff) << 20; + msr |= 0x000fffff & ~(ac97_bar_size - 1); + wrmsr(GLIU_IOD_BM1, msr); + } else { + wrmsr(GLIU_IOD_BM1, 0); + } + ac97_bar_value = 0; + } + break; + } +} + +/* * Function 4: OHCI Controller */ |