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>
32 static int set_bits(uint8_t *port, uint32_t mask, uint32_t val)
48 } while ((dword != val) && --count);
57 static int codec_detect(uint8_t *base)
62 set_bits(base + 0x08, 1, 1);
65 dword = readl(base + 0x0e);
67 writel(dword, base + 0x0e);
70 set_bits(base + 0x08, 1, 0);
73 set_bits(base + 0x08, 1, 1);
76 dword = readl(base + 0xe);
81 set_bits(base + 0x08, 1, 0);
82 printk_debug("No codec!\n");
89 static uint32_t verb_data[] = {
158 static unsigned find_verb(uint32_t viddid, uint32_t **verb)
160 if(viddid != 0x10ec0880) return 0;
161 *verb = (uint32_t *)verb_data;
162 return sizeof(verb_data)/sizeof(uint32_t);
166 static void codec_init(uint8_t *base, int addr)
175 dword = readl(base + 0x68);
178 dword = (addr<<28) | 0x000f0000;
179 writel(dword, base + 0x60);
182 dword = readl(base + 0x68);
183 } while ((dword & 3)!=2);
185 dword = readl(base + 0x64);
188 printk_debug("codec viddid: %08x\n", dword);
189 verb_size = find_verb(dword, &verb);
192 printk_debug("No verb!\n");
196 printk_debug("verb_size: %d\n", verb_size);
198 for(i=0; i<verb_size; i++) {
200 dword = readl(base + 0x68);
203 writel(verb[i], base + 0x60);
206 dword = readl(base + 0x68);
207 } while ((dword & 3) != 2);
209 printk_debug("verb loaded!\n");
212 static void codecs_init(uint8_t *base, uint32_t codec_mask)
215 for(i=2; i>=0; i--) {
216 if( codec_mask & (1<<i) )
221 static void aza_init(struct device *dev)
224 struct resource *res;
227 res = find_resource(dev, 0x10);
231 base =(uint8_t *) res->base;
232 printk_debug("base = %08x\n", base);
234 codec_mask = codec_detect(base);
237 printk_debug("codec_mask = %02x\n", codec_mask);
238 codecs_init(base, codec_mask);
242 static void lpci_set_subsystem(device_t dev, unsigned vendor, unsigned device)
244 pci_write_config32(dev, 0x40,
245 ((device & 0xffff) << 16) | (vendor & 0xffff));
248 static struct pci_operations lops_pci = {
249 .set_subsystem = lpci_set_subsystem,
252 static struct device_operations aza_audio_ops = {
253 .read_resources = pci_dev_read_resources,
254 .set_resources = pci_dev_set_resources,
255 .enable_resources = pci_dev_enable_resources,
256 // .enable = mcp55_enable,
259 .ops_pci = &lops_pci,
262 static const struct pci_driver azaaudio_driver __pci_driver = {
263 .ops = &aza_audio_ops,
264 .vendor = PCI_VENDOR_ID_NVIDIA,
265 .device = PCI_DEVICE_ID_NVIDIA_MCP55_AZA,