2 * This file is part of the coreboot project.
4 * Copyright (C) 2004 Tyan Computer
5 * Written by Yinghai Lu <yhlu@tyan.com> for Tyan Computer.
6 * Copyright (C) 2006,2007 AMD
7 * Written by Yinghai Lu <yinghai.lu@amd.com> for AMD.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #include <console/console.h>
25 #include <device/device.h>
26 #include <device/pci.h>
27 #include <device/pci_ids.h>
28 #include <device/pci_ops.h>
33 static int set_bits(uint8_t *port, uint32_t mask, uint32_t val)
49 } while ((dword != val) && --count);
58 static int codec_detect(uint8_t *base)
63 set_bits(base + 0x08, 1, 1);
66 dword = read32(base + 0x0e);
68 write32(base + 0x0e, dword);
71 set_bits(base + 0x08, 1, 0);
74 set_bits(base + 0x08, 1, 1);
77 dword = read32(base + 0xe);
82 set_bits(base + 0x08, 1, 0);
83 printk(BIOS_DEBUG, "No codec!\n");
90 static uint32_t verb_data[] = {
159 static unsigned find_verb(uint32_t viddid, uint32_t **verb)
161 if(viddid != 0x10ec0880) return 0;
162 *verb = (uint32_t *)verb_data;
163 return sizeof(verb_data)/sizeof(uint32_t);
167 static void codec_init(uint8_t *base, int addr)
176 dword = read32(base + 0x68);
179 dword = (addr<<28) | 0x000f0000;
180 write32(base + 0x60, dword);
183 dword = read32(base + 0x68);
184 } while ((dword & 3)!=2);
186 dword = read32(base + 0x64);
189 printk(BIOS_DEBUG, "codec viddid: %08x\n", dword);
190 verb_size = find_verb(dword, &verb);
193 printk(BIOS_DEBUG, "No verb!\n");
197 printk(BIOS_DEBUG, "verb_size: %d\n", verb_size);
199 for(i=0; i<verb_size; i++) {
201 dword = read32(base + 0x68);
204 write32(base + 0x60, verb[i]);
207 dword = read32(base + 0x68);
208 } while ((dword & 3) != 2);
210 printk(BIOS_DEBUG, "verb loaded!\n");
213 static void codecs_init(uint8_t *base, uint32_t codec_mask)
216 for(i=2; i>=0; i--) {
217 if( codec_mask & (1<<i) )
222 static void aza_init(struct device *dev)
225 struct resource *res;
228 res = find_resource(dev, 0x10);
232 base =(uint8_t *) res->base;
233 printk(BIOS_DEBUG, "base = %08x\n", base);
235 codec_mask = codec_detect(base);
238 printk(BIOS_DEBUG, "codec_mask = %02x\n", codec_mask);
239 codecs_init(base, codec_mask);
243 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
245 pci_write_config32(dev, 0x40,
246 ((device & 0xffff) << 16) | (vendor & 0xffff));
249 static struct pci_operations lops_pci = {
250 .set_subsystem = lpci_set_subsystem,
253 static struct device_operations aza_audio_ops = {
254 .read_resources = pci_dev_read_resources,
255 .set_resources = pci_dev_set_resources,
256 .enable_resources = pci_dev_enable_resources,
257 // .enable = mcp55_enable,
260 .ops_pci = &lops_pci,
263 static const struct pci_driver azaaudio_driver __pci_driver = {
264 .ops = &aza_audio_ops,
265 .vendor = PCI_VENDOR_ID_NVIDIA,
266 .device = PCI_DEVICE_ID_NVIDIA_MCP55_AZA,