• Home
  • Raw
  • Download

Lines Matching refs:bus

13 static void azx_clear_corbrp(struct hdac_bus *bus)  in azx_clear_corbrp()  argument
18 if (snd_hdac_chip_readw(bus, CORBRP) & AZX_CORBRP_RST) in azx_clear_corbrp()
23 dev_err(bus->dev, "CORB reset timeout#1, CORBRP = %d\n", in azx_clear_corbrp()
24 snd_hdac_chip_readw(bus, CORBRP)); in azx_clear_corbrp()
26 snd_hdac_chip_writew(bus, CORBRP, 0); in azx_clear_corbrp()
28 if (snd_hdac_chip_readw(bus, CORBRP) == 0) in azx_clear_corbrp()
33 dev_err(bus->dev, "CORB reset timeout#2, CORBRP = %d\n", in azx_clear_corbrp()
34 snd_hdac_chip_readw(bus, CORBRP)); in azx_clear_corbrp()
41 void snd_hdac_bus_init_cmd_io(struct hdac_bus *bus) in snd_hdac_bus_init_cmd_io() argument
43 WARN_ON_ONCE(!bus->rb.area); in snd_hdac_bus_init_cmd_io()
45 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_init_cmd_io()
47 bus->corb.addr = bus->rb.addr; in snd_hdac_bus_init_cmd_io()
48 bus->corb.buf = (__le32 *)bus->rb.area; in snd_hdac_bus_init_cmd_io()
49 snd_hdac_chip_writel(bus, CORBLBASE, (u32)bus->corb.addr); in snd_hdac_bus_init_cmd_io()
50 snd_hdac_chip_writel(bus, CORBUBASE, upper_32_bits(bus->corb.addr)); in snd_hdac_bus_init_cmd_io()
53 snd_hdac_chip_writeb(bus, CORBSIZE, 0x02); in snd_hdac_bus_init_cmd_io()
55 snd_hdac_chip_writew(bus, CORBWP, 0); in snd_hdac_bus_init_cmd_io()
58 snd_hdac_chip_writew(bus, CORBRP, AZX_CORBRP_RST); in snd_hdac_bus_init_cmd_io()
59 if (!bus->corbrp_self_clear) in snd_hdac_bus_init_cmd_io()
60 azx_clear_corbrp(bus); in snd_hdac_bus_init_cmd_io()
63 snd_hdac_chip_writeb(bus, CORBCTL, AZX_CORBCTL_RUN); in snd_hdac_bus_init_cmd_io()
66 bus->rirb.addr = bus->rb.addr + 2048; in snd_hdac_bus_init_cmd_io()
67 bus->rirb.buf = (__le32 *)(bus->rb.area + 2048); in snd_hdac_bus_init_cmd_io()
68 bus->rirb.wp = bus->rirb.rp = 0; in snd_hdac_bus_init_cmd_io()
69 memset(bus->rirb.cmds, 0, sizeof(bus->rirb.cmds)); in snd_hdac_bus_init_cmd_io()
70 snd_hdac_chip_writel(bus, RIRBLBASE, (u32)bus->rirb.addr); in snd_hdac_bus_init_cmd_io()
71 snd_hdac_chip_writel(bus, RIRBUBASE, upper_32_bits(bus->rirb.addr)); in snd_hdac_bus_init_cmd_io()
74 snd_hdac_chip_writeb(bus, RIRBSIZE, 0x02); in snd_hdac_bus_init_cmd_io()
76 snd_hdac_chip_writew(bus, RIRBWP, AZX_RIRBWP_RST); in snd_hdac_bus_init_cmd_io()
78 snd_hdac_chip_writew(bus, RINTCNT, 1); in snd_hdac_bus_init_cmd_io()
80 snd_hdac_chip_writeb(bus, RIRBCTL, AZX_RBCTL_DMA_EN | AZX_RBCTL_IRQ_EN); in snd_hdac_bus_init_cmd_io()
81 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_init_cmd_io()
86 static void hdac_wait_for_cmd_dmas(struct hdac_bus *bus) in hdac_wait_for_cmd_dmas() argument
91 while ((snd_hdac_chip_readb(bus, RIRBCTL) & AZX_RBCTL_DMA_EN) in hdac_wait_for_cmd_dmas()
96 while ((snd_hdac_chip_readb(bus, CORBCTL) & AZX_CORBCTL_RUN) in hdac_wait_for_cmd_dmas()
105 void snd_hdac_bus_stop_cmd_io(struct hdac_bus *bus) in snd_hdac_bus_stop_cmd_io() argument
107 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_stop_cmd_io()
109 snd_hdac_chip_writeb(bus, RIRBCTL, 0); in snd_hdac_bus_stop_cmd_io()
110 snd_hdac_chip_writeb(bus, CORBCTL, 0); in snd_hdac_bus_stop_cmd_io()
111 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_stop_cmd_io()
113 hdac_wait_for_cmd_dmas(bus); in snd_hdac_bus_stop_cmd_io()
115 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_stop_cmd_io()
117 snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_UNSOL, 0); in snd_hdac_bus_stop_cmd_io()
118 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_stop_cmd_io()
138 int snd_hdac_bus_send_cmd(struct hdac_bus *bus, unsigned int val) in snd_hdac_bus_send_cmd() argument
143 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_send_cmd()
145 bus->last_cmd[azx_command_addr(val)] = val; in snd_hdac_bus_send_cmd()
148 wp = snd_hdac_chip_readw(bus, CORBWP); in snd_hdac_bus_send_cmd()
151 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_send_cmd()
157 rp = snd_hdac_chip_readw(bus, CORBRP); in snd_hdac_bus_send_cmd()
160 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_send_cmd()
164 bus->rirb.cmds[addr]++; in snd_hdac_bus_send_cmd()
165 bus->corb.buf[wp] = cpu_to_le32(val); in snd_hdac_bus_send_cmd()
166 snd_hdac_chip_writew(bus, CORBWP, wp); in snd_hdac_bus_send_cmd()
168 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_send_cmd()
182 void snd_hdac_bus_update_rirb(struct hdac_bus *bus) in snd_hdac_bus_update_rirb() argument
188 wp = snd_hdac_chip_readw(bus, RIRBWP); in snd_hdac_bus_update_rirb()
194 if (wp == bus->rirb.wp) in snd_hdac_bus_update_rirb()
196 bus->rirb.wp = wp; in snd_hdac_bus_update_rirb()
198 while (bus->rirb.rp != wp) { in snd_hdac_bus_update_rirb()
199 bus->rirb.rp++; in snd_hdac_bus_update_rirb()
200 bus->rirb.rp %= AZX_MAX_RIRB_ENTRIES; in snd_hdac_bus_update_rirb()
202 rp = bus->rirb.rp << 1; /* an RIRB entry is 8-bytes */ in snd_hdac_bus_update_rirb()
203 res_ex = le32_to_cpu(bus->rirb.buf[rp + 1]); in snd_hdac_bus_update_rirb()
204 res = le32_to_cpu(bus->rirb.buf[rp]); in snd_hdac_bus_update_rirb()
207 dev_err(bus->dev, in snd_hdac_bus_update_rirb()
209 res, res_ex, bus->rirb.rp, wp); in snd_hdac_bus_update_rirb()
212 snd_hdac_bus_queue_event(bus, res, res_ex); in snd_hdac_bus_update_rirb()
213 else if (bus->rirb.cmds[addr]) { in snd_hdac_bus_update_rirb()
214 bus->rirb.res[addr] = res; in snd_hdac_bus_update_rirb()
215 bus->rirb.cmds[addr]--; in snd_hdac_bus_update_rirb()
217 dev_err_ratelimited(bus->dev, in snd_hdac_bus_update_rirb()
219 res, res_ex, bus->last_cmd[addr]); in snd_hdac_bus_update_rirb()
233 int snd_hdac_bus_get_response(struct hdac_bus *bus, unsigned int addr, in snd_hdac_bus_get_response() argument
242 spin_lock_irq(&bus->reg_lock); in snd_hdac_bus_get_response()
243 if (!bus->rirb.cmds[addr]) { in snd_hdac_bus_get_response()
245 *res = bus->rirb.res[addr]; /* the last value */ in snd_hdac_bus_get_response()
246 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_get_response()
249 spin_unlock_irq(&bus->reg_lock); in snd_hdac_bus_get_response()
271 int snd_hdac_bus_parse_capabilities(struct hdac_bus *bus) in snd_hdac_bus_parse_capabilities() argument
277 offset = snd_hdac_chip_readw(bus, LLCH); in snd_hdac_bus_parse_capabilities()
281 cur_cap = _snd_hdac_chip_readl(bus, offset); in snd_hdac_bus_parse_capabilities()
283 dev_dbg(bus->dev, "Capability version: 0x%x\n", in snd_hdac_bus_parse_capabilities()
286 dev_dbg(bus->dev, "HDA capability ID: 0x%x\n", in snd_hdac_bus_parse_capabilities()
290 dev_dbg(bus->dev, "Invalid capability reg read\n"); in snd_hdac_bus_parse_capabilities()
296 dev_dbg(bus->dev, "Found ML capability\n"); in snd_hdac_bus_parse_capabilities()
297 bus->mlcap = bus->remap_addr + offset; in snd_hdac_bus_parse_capabilities()
301 dev_dbg(bus->dev, "Found GTS capability offset=%x\n", offset); in snd_hdac_bus_parse_capabilities()
302 bus->gtscap = bus->remap_addr + offset; in snd_hdac_bus_parse_capabilities()
307 dev_dbg(bus->dev, "Found PP capability offset=%x\n", offset); in snd_hdac_bus_parse_capabilities()
308 bus->ppcap = bus->remap_addr + offset; in snd_hdac_bus_parse_capabilities()
313 dev_dbg(bus->dev, "Found SPB capability\n"); in snd_hdac_bus_parse_capabilities()
314 bus->spbcap = bus->remap_addr + offset; in snd_hdac_bus_parse_capabilities()
319 dev_dbg(bus->dev, "Found DRSM capability\n"); in snd_hdac_bus_parse_capabilities()
320 bus->drsmcap = bus->remap_addr + offset; in snd_hdac_bus_parse_capabilities()
324 dev_err(bus->dev, "Unknown capability %d\n", cur_cap); in snd_hdac_bus_parse_capabilities()
332 dev_err(bus->dev, "We exceeded HDAC capabilities!!!\n"); in snd_hdac_bus_parse_capabilities()
355 void snd_hdac_bus_enter_link_reset(struct hdac_bus *bus) in snd_hdac_bus_enter_link_reset() argument
360 snd_hdac_chip_updatel(bus, GCTL, AZX_GCTL_RESET, 0); in snd_hdac_bus_enter_link_reset()
363 while ((snd_hdac_chip_readb(bus, GCTL) & AZX_GCTL_RESET) && in snd_hdac_bus_enter_link_reset()
375 void snd_hdac_bus_exit_link_reset(struct hdac_bus *bus) in snd_hdac_bus_exit_link_reset() argument
379 snd_hdac_chip_updateb(bus, GCTL, 0, AZX_GCTL_RESET); in snd_hdac_bus_exit_link_reset()
382 while (!snd_hdac_chip_readb(bus, GCTL) && time_before(jiffies, timeout)) in snd_hdac_bus_exit_link_reset()
388 int snd_hdac_bus_reset_link(struct hdac_bus *bus, bool full_reset) in snd_hdac_bus_reset_link() argument
394 snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK); in snd_hdac_bus_reset_link()
397 snd_hdac_bus_enter_link_reset(bus); in snd_hdac_bus_reset_link()
405 snd_hdac_bus_exit_link_reset(bus); in snd_hdac_bus_reset_link()
412 if (!snd_hdac_chip_readb(bus, GCTL)) { in snd_hdac_bus_reset_link()
413 dev_dbg(bus->dev, "controller not ready!\n"); in snd_hdac_bus_reset_link()
418 snd_hdac_chip_updatel(bus, GCTL, 0, AZX_GCTL_UNSOL); in snd_hdac_bus_reset_link()
421 if (!bus->codec_mask) { in snd_hdac_bus_reset_link()
422 bus->codec_mask = snd_hdac_chip_readw(bus, STATESTS); in snd_hdac_bus_reset_link()
423 dev_dbg(bus->dev, "codec_mask = 0x%lx\n", bus->codec_mask); in snd_hdac_bus_reset_link()
431 static void azx_int_enable(struct hdac_bus *bus) in azx_int_enable() argument
434 snd_hdac_chip_updatel(bus, INTCTL, 0, AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN); in azx_int_enable()
438 static void azx_int_disable(struct hdac_bus *bus) in azx_int_disable() argument
443 list_for_each_entry(azx_dev, &bus->stream_list, list) in azx_int_disable()
447 snd_hdac_chip_writeb(bus, INTCTL, 0); in azx_int_disable()
450 snd_hdac_chip_updatel(bus, INTCTL, AZX_INT_CTRL_EN | AZX_INT_GLOBAL_EN, 0); in azx_int_disable()
454 static void azx_int_clear(struct hdac_bus *bus) in azx_int_clear() argument
459 list_for_each_entry(azx_dev, &bus->stream_list, list) in azx_int_clear()
463 snd_hdac_chip_writew(bus, STATESTS, STATESTS_INT_MASK); in azx_int_clear()
466 snd_hdac_chip_writeb(bus, RIRBSTS, RIRB_INT_MASK); in azx_int_clear()
469 snd_hdac_chip_writel(bus, INTSTS, AZX_INT_CTRL_EN | AZX_INT_ALL_STREAM); in azx_int_clear()
477 bool snd_hdac_bus_init_chip(struct hdac_bus *bus, bool full_reset) in snd_hdac_bus_init_chip() argument
479 if (bus->chip_init) in snd_hdac_bus_init_chip()
483 snd_hdac_bus_reset_link(bus, full_reset); in snd_hdac_bus_init_chip()
486 azx_int_clear(bus); in snd_hdac_bus_init_chip()
489 snd_hdac_bus_init_cmd_io(bus); in snd_hdac_bus_init_chip()
492 azx_int_enable(bus); in snd_hdac_bus_init_chip()
495 if (bus->use_posbuf && bus->posbuf.addr) { in snd_hdac_bus_init_chip()
496 snd_hdac_chip_writel(bus, DPLBASE, (u32)bus->posbuf.addr); in snd_hdac_bus_init_chip()
497 snd_hdac_chip_writel(bus, DPUBASE, upper_32_bits(bus->posbuf.addr)); in snd_hdac_bus_init_chip()
500 bus->chip_init = true; in snd_hdac_bus_init_chip()
509 void snd_hdac_bus_stop_chip(struct hdac_bus *bus) in snd_hdac_bus_stop_chip() argument
511 if (!bus->chip_init) in snd_hdac_bus_stop_chip()
515 azx_int_disable(bus); in snd_hdac_bus_stop_chip()
516 azx_int_clear(bus); in snd_hdac_bus_stop_chip()
519 snd_hdac_bus_stop_cmd_io(bus); in snd_hdac_bus_stop_chip()
522 if (bus->posbuf.addr) { in snd_hdac_bus_stop_chip()
523 snd_hdac_chip_writel(bus, DPLBASE, 0); in snd_hdac_bus_stop_chip()
524 snd_hdac_chip_writel(bus, DPUBASE, 0); in snd_hdac_bus_stop_chip()
527 bus->chip_init = false; in snd_hdac_bus_stop_chip()
539 int snd_hdac_bus_handle_stream_irq(struct hdac_bus *bus, unsigned int status, in snd_hdac_bus_handle_stream_irq() argument
547 list_for_each_entry(azx_dev, &bus->stream_list, list) { in snd_hdac_bus_handle_stream_irq()
556 ack(bus, azx_dev); in snd_hdac_bus_handle_stream_irq()
570 int snd_hdac_bus_alloc_stream_pages(struct hdac_bus *bus) in snd_hdac_bus_alloc_stream_pages() argument
576 list_for_each_entry(s, &bus->stream_list, list) { in snd_hdac_bus_alloc_stream_pages()
578 err = bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV, in snd_hdac_bus_alloc_stream_pages()
588 err = bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV, in snd_hdac_bus_alloc_stream_pages()
589 num_streams * 8, &bus->posbuf); in snd_hdac_bus_alloc_stream_pages()
592 list_for_each_entry(s, &bus->stream_list, list) in snd_hdac_bus_alloc_stream_pages()
593 s->posbuf = (__le32 *)(bus->posbuf.area + s->index * 8); in snd_hdac_bus_alloc_stream_pages()
596 return bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV, in snd_hdac_bus_alloc_stream_pages()
597 PAGE_SIZE, &bus->rb); in snd_hdac_bus_alloc_stream_pages()
605 void snd_hdac_bus_free_stream_pages(struct hdac_bus *bus) in snd_hdac_bus_free_stream_pages() argument
609 list_for_each_entry(s, &bus->stream_list, list) { in snd_hdac_bus_free_stream_pages()
611 bus->io_ops->dma_free_pages(bus, &s->bdl); in snd_hdac_bus_free_stream_pages()
614 if (bus->rb.area) in snd_hdac_bus_free_stream_pages()
615 bus->io_ops->dma_free_pages(bus, &bus->rb); in snd_hdac_bus_free_stream_pages()
616 if (bus->posbuf.area) in snd_hdac_bus_free_stream_pages()
617 bus->io_ops->dma_free_pages(bus, &bus->posbuf); in snd_hdac_bus_free_stream_pages()