Lines Matching refs:hw
37 struct hw hw; member
42 static u32 hw_read_20kx(struct hw *hw, u32 reg);
43 static void hw_write_20kx(struct hw *hw, u32 reg, u32 data);
44 static u32 hw_read_pci(struct hw *hw, u32 reg);
45 static void hw_write_pci(struct hw *hw, u32 reg, u32 data);
369 static int src_commit_write(struct hw *hw, unsigned int idx, void *blk) in src_commit_write() argument
377 hw_write_20kx(hw, SRCUPZ+idx*0x100+i*0x4, 0); in src_commit_write()
380 hw_write_20kx(hw, SRCDN0Z+idx*0x100+i*0x4, 0); in src_commit_write()
383 hw_write_20kx(hw, SRCDN1Z+idx*0x100+i*0x4, 0); in src_commit_write()
393 hw_write_20kx(hw, PRING_LO_HI+4*pm_idx, ctl->mpr); in src_commit_write()
394 hw_write_20kx(hw, PMOPLO+8*pm_idx, 0x3); in src_commit_write()
395 hw_write_20kx(hw, PMOPHI+8*pm_idx, 0x0); in src_commit_write()
399 hw_write_20kx(hw, SRCSA+idx*0x100, ctl->sa); in src_commit_write()
403 hw_write_20kx(hw, SRCLA+idx*0x100, ctl->la); in src_commit_write()
407 hw_write_20kx(hw, SRCCA+idx*0x100, ctl->ca); in src_commit_write()
412 hw_write_20kx(hw, SRCCF+idx*0x100, 0x0); in src_commit_write()
415 hw_write_20kx(hw, SRCCCR+idx*0x100, ctl->ccr); in src_commit_write()
419 hw_write_20kx(hw, SRCCTL+idx*0x100, ctl->ctl); in src_commit_write()
426 static int src_get_ca(struct hw *hw, unsigned int idx, void *blk) in src_get_ca() argument
430 ctl->ca = hw_read_20kx(hw, SRCCA+idx*0x100); in src_get_ca()
468 static int src_mgr_commit_write(struct hw *hw, void *blk) in src_mgr_commit_write() argument
476 ret = hw_read_20kx(hw, SRCENBSTAT); in src_mgr_commit_write()
478 hw_write_20kx(hw, SRCENBS, ctl->enbsa); in src_mgr_commit_write()
483 hw_write_20kx(hw, SRCENB+(i*0x100), ctl->enb[i]); in src_mgr_commit_write()
569 static int srcimp_mgr_commit_write(struct hw *hw, void *blk) in srcimp_mgr_commit_write() argument
574 hw_write_20kx(hw, SRCIMAP+ctl->srcimap.idx*0x100, in srcimp_mgr_commit_write()
673 static int amixer_commit_write(struct hw *hw, unsigned int idx, void *blk) in amixer_commit_write() argument
678 hw_write_20kx(hw, AMOPLO+idx*8, ctl->amoplo); in amixer_commit_write()
680 hw_write_20kx(hw, AMOPHI+idx*8, ctl->amophi); in amixer_commit_write()
888 static int dai_commit_write(struct hw *hw, unsigned int idx, void *blk) in dai_commit_write() argument
895 hw_write_20kx(hw, SRTSCTL+0x4*idx, ctl->srtctl); in dai_commit_write()
898 hw_write_20kx(hw, SRTICTL, ctl->srtctl); in dai_commit_write()
934 static int dao_commit_write(struct hw *hw, unsigned int idx, void *blk) in dao_commit_write() argument
941 hw_write_20kx(hw, SPOS+0x4*idx, ctl->spos); in dao_commit_write()
1108 static int daio_mgr_commit_write(struct hw *hw, void *blk) in daio_mgr_commit_write() argument
1121 hw_write_20kx(hw, I2SCTL, ctl->i2sctl); in daio_mgr_commit_write()
1129 hw_write_20kx(hw, SPOCTL, ctl->spoctl); in daio_mgr_commit_write()
1137 hw_write_20kx(hw, SPICTL, ctl->spictl); in daio_mgr_commit_write()
1141 hw_write_20kx(hw, DAOIMAP+ctl->daoimap.idx*4, in daio_mgr_commit_write()
1149 static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk) in daio_mgr_get_ctrl_blk() argument
1158 blk->i2sctl = hw_read_20kx(hw, I2SCTL); in daio_mgr_get_ctrl_blk()
1159 blk->spoctl = hw_read_20kx(hw, SPOCTL); in daio_mgr_get_ctrl_blk()
1160 blk->spictl = hw_read_20kx(hw, SPICTL); in daio_mgr_get_ctrl_blk()
1175 static int set_timer_irq(struct hw *hw, int enable) in set_timer_irq() argument
1177 hw_write_20kx(hw, GIE, enable ? IT_INT : 0); in set_timer_irq()
1181 static int set_timer_tick(struct hw *hw, unsigned int ticks) in set_timer_tick() argument
1185 hw_write_20kx(hw, TIMR, ticks); in set_timer_tick()
1189 static unsigned int get_wc(struct hw *hw) in get_wc() argument
1191 return hw_read_20kx(hw, WC); in get_wc()
1213 static int hw_daio_init(struct hw *hw, const struct daio_conf *info) in hw_daio_init() argument
1228 hw_write_20kx(hw, SPOCTL, 0x0); in hw_daio_init()
1249 hw_write_20kx(hw, I2SCTL, i2sorg); in hw_daio_init()
1250 hw_write_20kx(hw, SPOCTL, spdorg); in hw_daio_init()
1254 hw_write_20kx(hw, SPICTL, 0x0); in hw_daio_init()
1257 hw_write_20kx(hw, SPICTL, spdorg); in hw_daio_init()
1264 static int hw_trn_init(struct hw *hw, const struct trn_conf *info) in hw_trn_init() argument
1271 dev_err(hw->card->dev, in hw_trn_init()
1286 hw_write_20kx(hw, PTPALX, ptp_phys_low); in hw_trn_init()
1287 hw_write_20kx(hw, PTPAHX, ptp_phys_high); in hw_trn_init()
1288 hw_write_20kx(hw, TRNCTL, trnctl); in hw_trn_init()
1289 hw_write_20kx(hw, TRNIS, 0x200c01); /* really needed? */ in hw_trn_init()
1317 static int hw_pll_init(struct hw *hw, unsigned int rsr) in hw_pll_init() argument
1324 if (hw_read_20kx(hw, PLLCTL) == pllctl) in hw_pll_init()
1327 hw_write_20kx(hw, PLLCTL, pllctl); in hw_pll_init()
1331 dev_alert(hw->card->dev, "PLL initialization failed!!!\n"); in hw_pll_init()
1338 static int hw_auto_init(struct hw *hw) in hw_auto_init() argument
1343 gctl = hw_read_20kx(hw, GCTL); in hw_auto_init()
1345 hw_write_20kx(hw, GCTL, gctl); in hw_auto_init()
1347 hw_write_20kx(hw, GCTL, gctl); in hw_auto_init()
1350 gctl = hw_read_20kx(hw, GCTL); in hw_auto_init()
1355 dev_alert(hw->card->dev, "Card Auto-init failed!!!\n"); in hw_auto_init()
1362 static int i2c_unlock(struct hw *hw) in i2c_unlock() argument
1364 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa) in i2c_unlock()
1367 hw_write_pci(hw, 0xcc, 0x8c); in i2c_unlock()
1368 hw_write_pci(hw, 0xcc, 0x0e); in i2c_unlock()
1369 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa) in i2c_unlock()
1372 hw_write_pci(hw, 0xcc, 0xee); in i2c_unlock()
1373 hw_write_pci(hw, 0xcc, 0xaa); in i2c_unlock()
1374 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa) in i2c_unlock()
1380 static void i2c_lock(struct hw *hw) in i2c_lock() argument
1382 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa) in i2c_lock()
1383 hw_write_pci(hw, 0xcc, 0x00); in i2c_lock()
1386 static void i2c_write(struct hw *hw, u32 device, u32 addr, u32 data) in i2c_write() argument
1391 ret = hw_read_pci(hw, 0xEC); in i2c_write()
1393 hw_write_pci(hw, 0xE0, device); in i2c_write()
1394 hw_write_pci(hw, 0xE4, (data << 8) | (addr & 0xff)); in i2c_write()
1399 static int hw_reset_dac(struct hw *hw) in hw_reset_dac() argument
1405 if (i2c_unlock(hw)) in hw_reset_dac()
1409 ret = hw_read_pci(hw, 0xEC); in hw_reset_dac()
1411 hw_write_pci(hw, 0xEC, 0x05); /* write to i2c status control */ in hw_reset_dac()
1417 gpioorg = (u16)hw_read_20kx(hw, GPIO); in hw_reset_dac()
1419 hw_write_20kx(hw, GPIO, gpioorg); in hw_reset_dac()
1421 hw_write_20kx(hw, GPIO, gpioorg | 0x2); in hw_reset_dac()
1424 i2c_write(hw, 0x00180080, 0x01, 0x80); in hw_reset_dac()
1425 i2c_write(hw, 0x00180080, 0x02, 0x10); in hw_reset_dac()
1427 i2c_lock(hw); in hw_reset_dac()
1432 static int hw_dac_init(struct hw *hw, const struct dac_conf *info) in hw_dac_init() argument
1438 if (hw->model == CTSB055X) { in hw_dac_init()
1440 gpioorg = (u16)hw_read_20kx(hw, GPIO); in hw_dac_init()
1443 hw_write_20kx(hw, GPIO, gpioorg); in hw_dac_init()
1448 gpioorg = (u16)hw_read_20kx(hw, GPIO); in hw_dac_init()
1450 hw_write_20kx(hw, GPIO, gpioorg); in hw_dac_init()
1452 hw_reset_dac(hw); in hw_dac_init()
1454 if (i2c_unlock(hw)) in hw_dac_init()
1457 hw_write_pci(hw, 0xEC, 0x05); /* write to i2c status control */ in hw_dac_init()
1459 ret = hw_read_pci(hw, 0xEC); in hw_dac_init()
1477 i2c_write(hw, 0x00180080, 0x06, data); in hw_dac_init()
1478 i2c_write(hw, 0x00180080, 0x09, data); in hw_dac_init()
1479 i2c_write(hw, 0x00180080, 0x0c, data); in hw_dac_init()
1480 i2c_write(hw, 0x00180080, 0x0f, data); in hw_dac_init()
1482 i2c_lock(hw); in hw_dac_init()
1485 gpioorg = (u16)hw_read_20kx(hw, GPIO); in hw_dac_init()
1487 hw_write_20kx(hw, GPIO, gpioorg); in hw_dac_init()
1494 static int is_adc_input_selected_SB055x(struct hw *hw, enum ADCSRC type) in is_adc_input_selected_SB055x() argument
1499 static int is_adc_input_selected_SBx(struct hw *hw, enum ADCSRC type) in is_adc_input_selected_SBx() argument
1503 data = hw_read_20kx(hw, GPIO); in is_adc_input_selected_SBx()
1520 static int is_adc_input_selected_hendrix(struct hw *hw, enum ADCSRC type) in is_adc_input_selected_hendrix() argument
1524 data = hw_read_20kx(hw, GPIO); in is_adc_input_selected_hendrix()
1538 static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type) in hw_is_adc_input_selected() argument
1540 switch (hw->model) { in hw_is_adc_input_selected()
1542 return is_adc_input_selected_SB055x(hw, type); in hw_is_adc_input_selected()
1544 return is_adc_input_selected_hendrix(hw, type); in hw_is_adc_input_selected()
1546 return is_adc_input_selected_hendrix(hw, type); in hw_is_adc_input_selected()
1548 return is_adc_input_selected_SBx(hw, type); in hw_is_adc_input_selected()
1553 adc_input_select_SB055x(struct hw *hw, enum ADCSRC type, unsigned char boost) in adc_input_select_SB055x() argument
1566 data = hw_read_20kx(hw, GPIO); in adc_input_select_SB055x()
1586 hw_write_20kx(hw, GPIO, data); in adc_input_select_SB055x()
1593 adc_input_select_SBx(struct hw *hw, enum ADCSRC type, unsigned char boost) in adc_input_select_SBx() argument
1599 if (i2c_unlock(hw)) in adc_input_select_SBx()
1603 ret = hw_read_pci(hw, 0xEC); in adc_input_select_SBx()
1606 hw_write_pci(hw, 0xEC, 0x05); in adc_input_select_SBx()
1608 data = hw_read_20kx(hw, GPIO); in adc_input_select_SBx()
1624 i2c_lock(hw); in adc_input_select_SBx()
1627 hw_write_20kx(hw, GPIO, data); in adc_input_select_SBx()
1628 i2c_write(hw, 0x001a0080, 0x2a, i2c_data); in adc_input_select_SBx()
1630 i2c_write(hw, 0x001a0080, 0x1c, 0xe7); /* +12dB boost */ in adc_input_select_SBx()
1631 i2c_write(hw, 0x001a0080, 0x1e, 0xe7); /* +12dB boost */ in adc_input_select_SBx()
1633 i2c_write(hw, 0x001a0080, 0x1c, 0xcf); /* No boost */ in adc_input_select_SBx()
1634 i2c_write(hw, 0x001a0080, 0x1e, 0xcf); /* No boost */ in adc_input_select_SBx()
1637 i2c_lock(hw); in adc_input_select_SBx()
1643 adc_input_select_hendrix(struct hw *hw, enum ADCSRC type, unsigned char boost) in adc_input_select_hendrix() argument
1649 if (i2c_unlock(hw)) in adc_input_select_hendrix()
1653 ret = hw_read_pci(hw, 0xEC); in adc_input_select_hendrix()
1656 hw_write_pci(hw, 0xEC, 0x05); in adc_input_select_hendrix()
1658 data = hw_read_20kx(hw, GPIO); in adc_input_select_hendrix()
1669 i2c_lock(hw); in adc_input_select_hendrix()
1672 hw_write_20kx(hw, GPIO, data); in adc_input_select_hendrix()
1673 i2c_write(hw, 0x001a0080, 0x2a, i2c_data); in adc_input_select_hendrix()
1675 i2c_write(hw, 0x001a0080, 0x1c, 0xe7); /* +12dB boost */ in adc_input_select_hendrix()
1676 i2c_write(hw, 0x001a0080, 0x1e, 0xe7); /* +12dB boost */ in adc_input_select_hendrix()
1678 i2c_write(hw, 0x001a0080, 0x1c, 0xcf); /* No boost */ in adc_input_select_hendrix()
1679 i2c_write(hw, 0x001a0080, 0x1e, 0xcf); /* No boost */ in adc_input_select_hendrix()
1682 i2c_lock(hw); in adc_input_select_hendrix()
1687 static int hw_adc_input_select(struct hw *hw, enum ADCSRC type) in hw_adc_input_select() argument
1691 switch (hw->model) { in hw_adc_input_select()
1693 return adc_input_select_SB055x(hw, type, state); in hw_adc_input_select()
1695 return adc_input_select_hendrix(hw, type, state); in hw_adc_input_select()
1697 return adc_input_select_hendrix(hw, type, state); in hw_adc_input_select()
1699 return adc_input_select_SBx(hw, type, state); in hw_adc_input_select()
1703 static int adc_init_SB055x(struct hw *hw, int input, int mic20db) in adc_init_SB055x() argument
1705 return adc_input_select_SB055x(hw, input, mic20db); in adc_init_SB055x()
1708 static int adc_init_SBx(struct hw *hw, int input, int mic20db) in adc_init_SBx() argument
1739 if (i2c_unlock(hw)) in adc_init_SBx()
1743 ret = hw_read_pci(hw, 0xEC); in adc_init_SBx()
1745 hw_write_pci(hw, 0xEC, 0x05); /* write to i2c status control */ in adc_init_SBx()
1747 i2c_write(hw, 0x001a0080, 0x0e, 0x08); in adc_init_SBx()
1748 i2c_write(hw, 0x001a0080, 0x18, 0x0a); in adc_init_SBx()
1749 i2c_write(hw, 0x001a0080, 0x28, 0x86); in adc_init_SBx()
1750 i2c_write(hw, 0x001a0080, 0x2a, adcdata); in adc_init_SBx()
1753 i2c_write(hw, 0x001a0080, 0x1c, 0xf7); in adc_init_SBx()
1754 i2c_write(hw, 0x001a0080, 0x1e, 0xf7); in adc_init_SBx()
1756 i2c_write(hw, 0x001a0080, 0x1c, 0xcf); in adc_init_SBx()
1757 i2c_write(hw, 0x001a0080, 0x1e, 0xcf); in adc_init_SBx()
1760 if (!(hw_read_20kx(hw, ID0) & 0x100)) in adc_init_SBx()
1761 i2c_write(hw, 0x001a0080, 0x16, 0x26); in adc_init_SBx()
1763 i2c_lock(hw); in adc_init_SBx()
1765 gpioorg = (u16)hw_read_20kx(hw, GPIO); in adc_init_SBx()
1768 hw_write_20kx(hw, GPIO, gpioorg); in adc_init_SBx()
1773 static int hw_adc_init(struct hw *hw, const struct adc_conf *info) in hw_adc_init() argument
1775 if (hw->model == CTSB055X) in hw_adc_init()
1776 return adc_init_SB055x(hw, info->input, info->mic20db); in hw_adc_init()
1778 return adc_init_SBx(hw, info->input, info->mic20db); in hw_adc_init()
1781 static struct capabilities hw_capabilities(struct hw *hw) in hw_capabilities() argument
1786 cap.digit_io_switch = !(hw->model == CTSB073X || hw->model == CTUAA); in hw_capabilities()
1889 struct hw *hw = dev_id; in ct_20k1_interrupt() local
1892 status = hw_read_20kx(hw, GIP); in ct_20k1_interrupt()
1896 if (hw->irq_callback) in ct_20k1_interrupt()
1897 hw->irq_callback(hw->irq_callback_data, status); in ct_20k1_interrupt()
1899 hw_write_20kx(hw, GIP, status); in ct_20k1_interrupt()
1903 static int hw_card_start(struct hw *hw) in hw_card_start() argument
1906 struct pci_dev *pci = hw->pci; in hw_card_start()
1915 dev_err(hw->card->dev, in hw_card_start()
1922 if (!hw->io_base) { in hw_card_start()
1927 if (hw->model == CTUAA) in hw_card_start()
1928 hw->io_base = pci_resource_start(pci, 5); in hw_card_start()
1930 hw->io_base = pci_resource_start(pci, 0); in hw_card_start()
1935 if (hw->model == CTUAA) { in hw_card_start()
1942 if (hw->irq < 0) { in hw_card_start()
1944 KBUILD_MODNAME, hw); in hw_card_start()
1946 dev_err(hw->card->dev, in hw_card_start()
1950 hw->irq = pci->irq; in hw_card_start()
1959 hw->io_base = 0; in hw_card_start()
1965 static int hw_card_stop(struct hw *hw) in hw_card_stop() argument
1970 hw_write_20kx(hw, TRNCTL, 0x00); in hw_card_stop()
1973 data = hw_read_20kx(hw, PLLCTL); in hw_card_stop()
1974 hw_write_20kx(hw, PLLCTL, (data & (~(0x0F<<12)))); in hw_card_stop()
1977 if (hw->irq >= 0) in hw_card_stop()
1978 synchronize_irq(hw->irq); in hw_card_stop()
1982 static int hw_card_shutdown(struct hw *hw) in hw_card_shutdown() argument
1984 if (hw->irq >= 0) in hw_card_shutdown()
1985 free_irq(hw->irq, hw); in hw_card_shutdown()
1987 hw->irq = -1; in hw_card_shutdown()
1988 iounmap(hw->mem_base); in hw_card_shutdown()
1989 hw->mem_base = NULL; in hw_card_shutdown()
1991 if (hw->io_base) in hw_card_shutdown()
1992 pci_release_regions(hw->pci); in hw_card_shutdown()
1994 hw->io_base = 0; in hw_card_shutdown()
1996 pci_disable_device(hw->pci); in hw_card_shutdown()
2001 static int hw_card_init(struct hw *hw, struct card_conf *info) in hw_card_init() argument
2012 err = hw_card_start(hw); in hw_card_init()
2017 err = hw_pll_init(hw, info->rsr); in hw_card_init()
2022 err = hw_auto_init(hw); in hw_card_init()
2027 gctl = hw_read_20kx(hw, GCTL); in hw_card_init()
2033 hw_write_20kx(hw, GCTL, gctl); in hw_card_init()
2037 hw_write_20kx(hw, GIE, 0); in hw_card_init()
2039 hw_write_20kx(hw, SRCIP, 0); in hw_card_init()
2043 switch (hw->model) { in hw_card_init()
2045 hw_write_20kx(hw, GPIOCTL, 0x13fe); in hw_card_init()
2048 hw_write_20kx(hw, GPIOCTL, 0x00e6); in hw_card_init()
2051 hw_write_20kx(hw, GPIOCTL, 0x00c2); in hw_card_init()
2054 hw_write_20kx(hw, GPIOCTL, 0x01e6); in hw_card_init()
2059 err = hw_trn_init(hw, &trn_info); in hw_card_init()
2064 err = hw_daio_init(hw, &daio_info); in hw_card_init()
2069 err = hw_dac_init(hw, &dac_info); in hw_card_init()
2076 err = hw_adc_init(hw, &adc_info); in hw_card_init()
2080 data = hw_read_20kx(hw, SRCMCTL); in hw_card_init()
2082 hw_write_20kx(hw, SRCMCTL, data); in hw_card_init()
2088 static int hw_suspend(struct hw *hw) in hw_suspend() argument
2090 struct pci_dev *pci = hw->pci; in hw_suspend()
2092 hw_card_stop(hw); in hw_suspend()
2094 if (hw->model == CTUAA) { in hw_suspend()
2102 static int hw_resume(struct hw *hw, struct card_conf *info) in hw_resume() argument
2105 return hw_card_init(hw, info); in hw_resume()
2109 static u32 hw_read_20kx(struct hw *hw, u32 reg) in hw_read_20kx() argument
2115 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags); in hw_read_20kx()
2116 outl(reg, hw->io_base + 0x0); in hw_read_20kx()
2117 value = inl(hw->io_base + 0x4); in hw_read_20kx()
2119 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags); in hw_read_20kx()
2124 static void hw_write_20kx(struct hw *hw, u32 reg, u32 data) in hw_write_20kx() argument
2129 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags); in hw_write_20kx()
2130 outl(reg, hw->io_base + 0x0); in hw_write_20kx()
2131 outl(data, hw->io_base + 0x4); in hw_write_20kx()
2133 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags); in hw_write_20kx()
2137 static u32 hw_read_pci(struct hw *hw, u32 reg) in hw_read_pci() argument
2143 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags); in hw_read_pci()
2144 outl(reg, hw->io_base + 0x10); in hw_read_pci()
2145 value = inl(hw->io_base + 0x14); in hw_read_pci()
2147 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags); in hw_read_pci()
2152 static void hw_write_pci(struct hw *hw, u32 reg, u32 data) in hw_write_pci() argument
2157 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags); in hw_write_pci()
2158 outl(reg, hw->io_base + 0x10); in hw_write_pci()
2159 outl(data, hw->io_base + 0x14); in hw_write_pci()
2161 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags); in hw_write_pci()
2164 static struct hw ct20k1_preset = {
2268 int create_20k1_hw_obj(struct hw **rhw) in create_20k1_hw_obj()
2280 hw20k1->hw = ct20k1_preset; in create_20k1_hw_obj()
2282 *rhw = &hw20k1->hw; in create_20k1_hw_obj()
2287 int destroy_20k1_hw_obj(struct hw *hw) in destroy_20k1_hw_obj() argument
2289 if (hw->io_base) in destroy_20k1_hw_obj()
2290 hw_card_shutdown(hw); in destroy_20k1_hw_obj()
2292 kfree(container_of(hw, struct hw20k1, hw)); in destroy_20k1_hw_obj()