0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <linux/types.h>
0015 #include <linux/slab.h>
0016 #include <linux/pci.h>
0017 #include <linux/io.h>
0018 #include <linux/string.h>
0019 #include <linux/spinlock.h>
0020 #include <linux/kernel.h>
0021 #include <linux/interrupt.h>
0022 #include <linux/delay.h>
0023 #include "cthw20k1.h"
0024 #include "ct20k1reg.h"
0025
0026 struct hw20k1 {
0027 struct hw hw;
0028 spinlock_t reg_20k1_lock;
0029 spinlock_t reg_pci_lock;
0030 };
0031
0032 static u32 hw_read_20kx(struct hw *hw, u32 reg);
0033 static void hw_write_20kx(struct hw *hw, u32 reg, u32 data);
0034 static u32 hw_read_pci(struct hw *hw, u32 reg);
0035 static void hw_write_pci(struct hw *hw, u32 reg, u32 data);
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047 #define SRCCTL_STATE 0x00000007
0048 #define SRCCTL_BM 0x00000008
0049 #define SRCCTL_RSR 0x00000030
0050 #define SRCCTL_SF 0x000001C0
0051 #define SRCCTL_WR 0x00000200
0052 #define SRCCTL_PM 0x00000400
0053 #define SRCCTL_ROM 0x00001800
0054 #define SRCCTL_VO 0x00002000
0055 #define SRCCTL_ST 0x00004000
0056 #define SRCCTL_IE 0x00008000
0057 #define SRCCTL_ILSZ 0x000F0000
0058 #define SRCCTL_BP 0x00100000
0059
0060 #define SRCCCR_CISZ 0x000007FF
0061 #define SRCCCR_CWA 0x001FF800
0062 #define SRCCCR_D 0x00200000
0063 #define SRCCCR_RS 0x01C00000
0064 #define SRCCCR_NAL 0x3E000000
0065 #define SRCCCR_RA 0xC0000000
0066
0067 #define SRCCA_CA 0x03FFFFFF
0068 #define SRCCA_RS 0x1C000000
0069 #define SRCCA_NAL 0xE0000000
0070
0071 #define SRCSA_SA 0x03FFFFFF
0072
0073 #define SRCLA_LA 0x03FFFFFF
0074
0075
0076
0077 #define MPRLH_PITCH 0xFFFFFFFF
0078
0079
0080 union src_dirty {
0081 struct {
0082 u16 ctl:1;
0083 u16 ccr:1;
0084 u16 sa:1;
0085 u16 la:1;
0086 u16 ca:1;
0087 u16 mpr:1;
0088 u16 czbfs:1;
0089 u16 rsv:9;
0090 } bf;
0091 u16 data;
0092 };
0093
0094 struct src_rsc_ctrl_blk {
0095 unsigned int ctl;
0096 unsigned int ccr;
0097 unsigned int ca;
0098 unsigned int sa;
0099 unsigned int la;
0100 unsigned int mpr;
0101 union src_dirty dirty;
0102 };
0103
0104
0105 union src_mgr_dirty {
0106 struct {
0107 u16 enb0:1;
0108 u16 enb1:1;
0109 u16 enb2:1;
0110 u16 enb3:1;
0111 u16 enb4:1;
0112 u16 enb5:1;
0113 u16 enb6:1;
0114 u16 enb7:1;
0115 u16 enbsa:1;
0116 u16 rsv:7;
0117 } bf;
0118 u16 data;
0119 };
0120
0121 struct src_mgr_ctrl_blk {
0122 unsigned int enbsa;
0123 unsigned int enb[8];
0124 union src_mgr_dirty dirty;
0125 };
0126
0127
0128 #define SRCAIM_ARC 0x00000FFF
0129 #define SRCAIM_NXT 0x00FF0000
0130 #define SRCAIM_SRC 0xFF000000
0131
0132 struct srcimap {
0133 unsigned int srcaim;
0134 unsigned int idx;
0135 };
0136
0137
0138 union srcimp_mgr_dirty {
0139 struct {
0140 u16 srcimap:1;
0141 u16 rsv:15;
0142 } bf;
0143 u16 data;
0144 };
0145
0146 struct srcimp_mgr_ctrl_blk {
0147 struct srcimap srcimap;
0148 union srcimp_mgr_dirty dirty;
0149 };
0150
0151
0152
0153
0154
0155 static int src_get_rsc_ctrl_blk(void **rblk)
0156 {
0157 struct src_rsc_ctrl_blk *blk;
0158
0159 *rblk = NULL;
0160 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
0161 if (!blk)
0162 return -ENOMEM;
0163
0164 *rblk = blk;
0165
0166 return 0;
0167 }
0168
0169 static int src_put_rsc_ctrl_blk(void *blk)
0170 {
0171 kfree(blk);
0172
0173 return 0;
0174 }
0175
0176 static int src_set_state(void *blk, unsigned int state)
0177 {
0178 struct src_rsc_ctrl_blk *ctl = blk;
0179
0180 set_field(&ctl->ctl, SRCCTL_STATE, state);
0181 ctl->dirty.bf.ctl = 1;
0182 return 0;
0183 }
0184
0185 static int src_set_bm(void *blk, unsigned int bm)
0186 {
0187 struct src_rsc_ctrl_blk *ctl = blk;
0188
0189 set_field(&ctl->ctl, SRCCTL_BM, bm);
0190 ctl->dirty.bf.ctl = 1;
0191 return 0;
0192 }
0193
0194 static int src_set_rsr(void *blk, unsigned int rsr)
0195 {
0196 struct src_rsc_ctrl_blk *ctl = blk;
0197
0198 set_field(&ctl->ctl, SRCCTL_RSR, rsr);
0199 ctl->dirty.bf.ctl = 1;
0200 return 0;
0201 }
0202
0203 static int src_set_sf(void *blk, unsigned int sf)
0204 {
0205 struct src_rsc_ctrl_blk *ctl = blk;
0206
0207 set_field(&ctl->ctl, SRCCTL_SF, sf);
0208 ctl->dirty.bf.ctl = 1;
0209 return 0;
0210 }
0211
0212 static int src_set_wr(void *blk, unsigned int wr)
0213 {
0214 struct src_rsc_ctrl_blk *ctl = blk;
0215
0216 set_field(&ctl->ctl, SRCCTL_WR, wr);
0217 ctl->dirty.bf.ctl = 1;
0218 return 0;
0219 }
0220
0221 static int src_set_pm(void *blk, unsigned int pm)
0222 {
0223 struct src_rsc_ctrl_blk *ctl = blk;
0224
0225 set_field(&ctl->ctl, SRCCTL_PM, pm);
0226 ctl->dirty.bf.ctl = 1;
0227 return 0;
0228 }
0229
0230 static int src_set_rom(void *blk, unsigned int rom)
0231 {
0232 struct src_rsc_ctrl_blk *ctl = blk;
0233
0234 set_field(&ctl->ctl, SRCCTL_ROM, rom);
0235 ctl->dirty.bf.ctl = 1;
0236 return 0;
0237 }
0238
0239 static int src_set_vo(void *blk, unsigned int vo)
0240 {
0241 struct src_rsc_ctrl_blk *ctl = blk;
0242
0243 set_field(&ctl->ctl, SRCCTL_VO, vo);
0244 ctl->dirty.bf.ctl = 1;
0245 return 0;
0246 }
0247
0248 static int src_set_st(void *blk, unsigned int st)
0249 {
0250 struct src_rsc_ctrl_blk *ctl = blk;
0251
0252 set_field(&ctl->ctl, SRCCTL_ST, st);
0253 ctl->dirty.bf.ctl = 1;
0254 return 0;
0255 }
0256
0257 static int src_set_ie(void *blk, unsigned int ie)
0258 {
0259 struct src_rsc_ctrl_blk *ctl = blk;
0260
0261 set_field(&ctl->ctl, SRCCTL_IE, ie);
0262 ctl->dirty.bf.ctl = 1;
0263 return 0;
0264 }
0265
0266 static int src_set_ilsz(void *blk, unsigned int ilsz)
0267 {
0268 struct src_rsc_ctrl_blk *ctl = blk;
0269
0270 set_field(&ctl->ctl, SRCCTL_ILSZ, ilsz);
0271 ctl->dirty.bf.ctl = 1;
0272 return 0;
0273 }
0274
0275 static int src_set_bp(void *blk, unsigned int bp)
0276 {
0277 struct src_rsc_ctrl_blk *ctl = blk;
0278
0279 set_field(&ctl->ctl, SRCCTL_BP, bp);
0280 ctl->dirty.bf.ctl = 1;
0281 return 0;
0282 }
0283
0284 static int src_set_cisz(void *blk, unsigned int cisz)
0285 {
0286 struct src_rsc_ctrl_blk *ctl = blk;
0287
0288 set_field(&ctl->ccr, SRCCCR_CISZ, cisz);
0289 ctl->dirty.bf.ccr = 1;
0290 return 0;
0291 }
0292
0293 static int src_set_ca(void *blk, unsigned int ca)
0294 {
0295 struct src_rsc_ctrl_blk *ctl = blk;
0296
0297 set_field(&ctl->ca, SRCCA_CA, ca);
0298 ctl->dirty.bf.ca = 1;
0299 return 0;
0300 }
0301
0302 static int src_set_sa(void *blk, unsigned int sa)
0303 {
0304 struct src_rsc_ctrl_blk *ctl = blk;
0305
0306 set_field(&ctl->sa, SRCSA_SA, sa);
0307 ctl->dirty.bf.sa = 1;
0308 return 0;
0309 }
0310
0311 static int src_set_la(void *blk, unsigned int la)
0312 {
0313 struct src_rsc_ctrl_blk *ctl = blk;
0314
0315 set_field(&ctl->la, SRCLA_LA, la);
0316 ctl->dirty.bf.la = 1;
0317 return 0;
0318 }
0319
0320 static int src_set_pitch(void *blk, unsigned int pitch)
0321 {
0322 struct src_rsc_ctrl_blk *ctl = blk;
0323
0324 set_field(&ctl->mpr, MPRLH_PITCH, pitch);
0325 ctl->dirty.bf.mpr = 1;
0326 return 0;
0327 }
0328
0329 static int src_set_clear_zbufs(void *blk, unsigned int clear)
0330 {
0331 ((struct src_rsc_ctrl_blk *)blk)->dirty.bf.czbfs = (clear ? 1 : 0);
0332 return 0;
0333 }
0334
0335 static int src_set_dirty(void *blk, unsigned int flags)
0336 {
0337 ((struct src_rsc_ctrl_blk *)blk)->dirty.data = (flags & 0xffff);
0338 return 0;
0339 }
0340
0341 static int src_set_dirty_all(void *blk)
0342 {
0343 ((struct src_rsc_ctrl_blk *)blk)->dirty.data = ~(0x0);
0344 return 0;
0345 }
0346
0347 #define AR_SLOT_SIZE 4096
0348 #define AR_SLOT_BLOCK_SIZE 16
0349 #define AR_PTS_PITCH 6
0350 #define AR_PARAM_SRC_OFFSET 0x60
0351
0352 static unsigned int src_param_pitch_mixer(unsigned int src_idx)
0353 {
0354 return ((src_idx << 4) + AR_PTS_PITCH + AR_SLOT_SIZE
0355 - AR_PARAM_SRC_OFFSET) % AR_SLOT_SIZE;
0356
0357 }
0358
0359 static int src_commit_write(struct hw *hw, unsigned int idx, void *blk)
0360 {
0361 struct src_rsc_ctrl_blk *ctl = blk;
0362 int i;
0363
0364 if (ctl->dirty.bf.czbfs) {
0365
0366 for (i = 0; i < 8; i++)
0367 hw_write_20kx(hw, SRCUPZ+idx*0x100+i*0x4, 0);
0368
0369 for (i = 0; i < 4; i++)
0370 hw_write_20kx(hw, SRCDN0Z+idx*0x100+i*0x4, 0);
0371
0372 for (i = 0; i < 8; i++)
0373 hw_write_20kx(hw, SRCDN1Z+idx*0x100+i*0x4, 0);
0374
0375 ctl->dirty.bf.czbfs = 0;
0376 }
0377 if (ctl->dirty.bf.mpr) {
0378
0379
0380
0381
0382 unsigned int pm_idx = src_param_pitch_mixer(idx);
0383 hw_write_20kx(hw, PRING_LO_HI+4*pm_idx, ctl->mpr);
0384 hw_write_20kx(hw, PMOPLO+8*pm_idx, 0x3);
0385 hw_write_20kx(hw, PMOPHI+8*pm_idx, 0x0);
0386 ctl->dirty.bf.mpr = 0;
0387 }
0388 if (ctl->dirty.bf.sa) {
0389 hw_write_20kx(hw, SRCSA+idx*0x100, ctl->sa);
0390 ctl->dirty.bf.sa = 0;
0391 }
0392 if (ctl->dirty.bf.la) {
0393 hw_write_20kx(hw, SRCLA+idx*0x100, ctl->la);
0394 ctl->dirty.bf.la = 0;
0395 }
0396 if (ctl->dirty.bf.ca) {
0397 hw_write_20kx(hw, SRCCA+idx*0x100, ctl->ca);
0398 ctl->dirty.bf.ca = 0;
0399 }
0400
0401
0402 hw_write_20kx(hw, SRCCF+idx*0x100, 0x0);
0403
0404 if (ctl->dirty.bf.ccr) {
0405 hw_write_20kx(hw, SRCCCR+idx*0x100, ctl->ccr);
0406 ctl->dirty.bf.ccr = 0;
0407 }
0408 if (ctl->dirty.bf.ctl) {
0409 hw_write_20kx(hw, SRCCTL+idx*0x100, ctl->ctl);
0410 ctl->dirty.bf.ctl = 0;
0411 }
0412
0413 return 0;
0414 }
0415
0416 static int src_get_ca(struct hw *hw, unsigned int idx, void *blk)
0417 {
0418 struct src_rsc_ctrl_blk *ctl = blk;
0419
0420 ctl->ca = hw_read_20kx(hw, SRCCA+idx*0x100);
0421 ctl->dirty.bf.ca = 0;
0422
0423 return get_field(ctl->ca, SRCCA_CA);
0424 }
0425
0426 static unsigned int src_get_dirty(void *blk)
0427 {
0428 return ((struct src_rsc_ctrl_blk *)blk)->dirty.data;
0429 }
0430
0431 static unsigned int src_dirty_conj_mask(void)
0432 {
0433 return 0x20;
0434 }
0435
0436 static int src_mgr_enbs_src(void *blk, unsigned int idx)
0437 {
0438 ((struct src_mgr_ctrl_blk *)blk)->enbsa = ~(0x0);
0439 ((struct src_mgr_ctrl_blk *)blk)->dirty.bf.enbsa = 1;
0440 ((struct src_mgr_ctrl_blk *)blk)->enb[idx/32] |= (0x1 << (idx%32));
0441 return 0;
0442 }
0443
0444 static int src_mgr_enb_src(void *blk, unsigned int idx)
0445 {
0446 ((struct src_mgr_ctrl_blk *)blk)->enb[idx/32] |= (0x1 << (idx%32));
0447 ((struct src_mgr_ctrl_blk *)blk)->dirty.data |= (0x1 << (idx/32));
0448 return 0;
0449 }
0450
0451 static int src_mgr_dsb_src(void *blk, unsigned int idx)
0452 {
0453 ((struct src_mgr_ctrl_blk *)blk)->enb[idx/32] &= ~(0x1 << (idx%32));
0454 ((struct src_mgr_ctrl_blk *)blk)->dirty.data |= (0x1 << (idx/32));
0455 return 0;
0456 }
0457
0458 static int src_mgr_commit_write(struct hw *hw, void *blk)
0459 {
0460 struct src_mgr_ctrl_blk *ctl = blk;
0461 int i;
0462 unsigned int ret;
0463
0464 if (ctl->dirty.bf.enbsa) {
0465 do {
0466 ret = hw_read_20kx(hw, SRCENBSTAT);
0467 } while (ret & 0x1);
0468 hw_write_20kx(hw, SRCENBS, ctl->enbsa);
0469 ctl->dirty.bf.enbsa = 0;
0470 }
0471 for (i = 0; i < 8; i++) {
0472 if ((ctl->dirty.data & (0x1 << i))) {
0473 hw_write_20kx(hw, SRCENB+(i*0x100), ctl->enb[i]);
0474 ctl->dirty.data &= ~(0x1 << i);
0475 }
0476 }
0477
0478 return 0;
0479 }
0480
0481 static int src_mgr_get_ctrl_blk(void **rblk)
0482 {
0483 struct src_mgr_ctrl_blk *blk;
0484
0485 *rblk = NULL;
0486 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
0487 if (!blk)
0488 return -ENOMEM;
0489
0490 *rblk = blk;
0491
0492 return 0;
0493 }
0494
0495 static int src_mgr_put_ctrl_blk(void *blk)
0496 {
0497 kfree(blk);
0498
0499 return 0;
0500 }
0501
0502 static int srcimp_mgr_get_ctrl_blk(void **rblk)
0503 {
0504 struct srcimp_mgr_ctrl_blk *blk;
0505
0506 *rblk = NULL;
0507 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
0508 if (!blk)
0509 return -ENOMEM;
0510
0511 *rblk = blk;
0512
0513 return 0;
0514 }
0515
0516 static int srcimp_mgr_put_ctrl_blk(void *blk)
0517 {
0518 kfree(blk);
0519
0520 return 0;
0521 }
0522
0523 static int srcimp_mgr_set_imaparc(void *blk, unsigned int slot)
0524 {
0525 struct srcimp_mgr_ctrl_blk *ctl = blk;
0526
0527 set_field(&ctl->srcimap.srcaim, SRCAIM_ARC, slot);
0528 ctl->dirty.bf.srcimap = 1;
0529 return 0;
0530 }
0531
0532 static int srcimp_mgr_set_imapuser(void *blk, unsigned int user)
0533 {
0534 struct srcimp_mgr_ctrl_blk *ctl = blk;
0535
0536 set_field(&ctl->srcimap.srcaim, SRCAIM_SRC, user);
0537 ctl->dirty.bf.srcimap = 1;
0538 return 0;
0539 }
0540
0541 static int srcimp_mgr_set_imapnxt(void *blk, unsigned int next)
0542 {
0543 struct srcimp_mgr_ctrl_blk *ctl = blk;
0544
0545 set_field(&ctl->srcimap.srcaim, SRCAIM_NXT, next);
0546 ctl->dirty.bf.srcimap = 1;
0547 return 0;
0548 }
0549
0550 static int srcimp_mgr_set_imapaddr(void *blk, unsigned int addr)
0551 {
0552 struct srcimp_mgr_ctrl_blk *ctl = blk;
0553
0554 ctl->srcimap.idx = addr;
0555 ctl->dirty.bf.srcimap = 1;
0556 return 0;
0557 }
0558
0559 static int srcimp_mgr_commit_write(struct hw *hw, void *blk)
0560 {
0561 struct srcimp_mgr_ctrl_blk *ctl = blk;
0562
0563 if (ctl->dirty.bf.srcimap) {
0564 hw_write_20kx(hw, SRCIMAP+ctl->srcimap.idx*0x100,
0565 ctl->srcimap.srcaim);
0566 ctl->dirty.bf.srcimap = 0;
0567 }
0568
0569 return 0;
0570 }
0571
0572
0573
0574
0575
0576 #define AMOPLO_M 0x00000003
0577 #define AMOPLO_X 0x0003FFF0
0578 #define AMOPLO_Y 0xFFFC0000
0579
0580 #define AMOPHI_SADR 0x000000FF
0581 #define AMOPHI_SE 0x80000000
0582
0583
0584 union amixer_dirty {
0585 struct {
0586 u16 amoplo:1;
0587 u16 amophi:1;
0588 u16 rsv:14;
0589 } bf;
0590 u16 data;
0591 };
0592
0593
0594 struct amixer_rsc_ctrl_blk {
0595 unsigned int amoplo;
0596 unsigned int amophi;
0597 union amixer_dirty dirty;
0598 };
0599
0600 static int amixer_set_mode(void *blk, unsigned int mode)
0601 {
0602 struct amixer_rsc_ctrl_blk *ctl = blk;
0603
0604 set_field(&ctl->amoplo, AMOPLO_M, mode);
0605 ctl->dirty.bf.amoplo = 1;
0606 return 0;
0607 }
0608
0609 static int amixer_set_iv(void *blk, unsigned int iv)
0610 {
0611
0612 return 0;
0613 }
0614
0615 static int amixer_set_x(void *blk, unsigned int x)
0616 {
0617 struct amixer_rsc_ctrl_blk *ctl = blk;
0618
0619 set_field(&ctl->amoplo, AMOPLO_X, x);
0620 ctl->dirty.bf.amoplo = 1;
0621 return 0;
0622 }
0623
0624 static int amixer_set_y(void *blk, unsigned int y)
0625 {
0626 struct amixer_rsc_ctrl_blk *ctl = blk;
0627
0628 set_field(&ctl->amoplo, AMOPLO_Y, y);
0629 ctl->dirty.bf.amoplo = 1;
0630 return 0;
0631 }
0632
0633 static int amixer_set_sadr(void *blk, unsigned int sadr)
0634 {
0635 struct amixer_rsc_ctrl_blk *ctl = blk;
0636
0637 set_field(&ctl->amophi, AMOPHI_SADR, sadr);
0638 ctl->dirty.bf.amophi = 1;
0639 return 0;
0640 }
0641
0642 static int amixer_set_se(void *blk, unsigned int se)
0643 {
0644 struct amixer_rsc_ctrl_blk *ctl = blk;
0645
0646 set_field(&ctl->amophi, AMOPHI_SE, se);
0647 ctl->dirty.bf.amophi = 1;
0648 return 0;
0649 }
0650
0651 static int amixer_set_dirty(void *blk, unsigned int flags)
0652 {
0653 ((struct amixer_rsc_ctrl_blk *)blk)->dirty.data = (flags & 0xffff);
0654 return 0;
0655 }
0656
0657 static int amixer_set_dirty_all(void *blk)
0658 {
0659 ((struct amixer_rsc_ctrl_blk *)blk)->dirty.data = ~(0x0);
0660 return 0;
0661 }
0662
0663 static int amixer_commit_write(struct hw *hw, unsigned int idx, void *blk)
0664 {
0665 struct amixer_rsc_ctrl_blk *ctl = blk;
0666
0667 if (ctl->dirty.bf.amoplo || ctl->dirty.bf.amophi) {
0668 hw_write_20kx(hw, AMOPLO+idx*8, ctl->amoplo);
0669 ctl->dirty.bf.amoplo = 0;
0670 hw_write_20kx(hw, AMOPHI+idx*8, ctl->amophi);
0671 ctl->dirty.bf.amophi = 0;
0672 }
0673
0674 return 0;
0675 }
0676
0677 static int amixer_get_y(void *blk)
0678 {
0679 struct amixer_rsc_ctrl_blk *ctl = blk;
0680
0681 return get_field(ctl->amoplo, AMOPLO_Y);
0682 }
0683
0684 static unsigned int amixer_get_dirty(void *blk)
0685 {
0686 return ((struct amixer_rsc_ctrl_blk *)blk)->dirty.data;
0687 }
0688
0689 static int amixer_rsc_get_ctrl_blk(void **rblk)
0690 {
0691 struct amixer_rsc_ctrl_blk *blk;
0692
0693 *rblk = NULL;
0694 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
0695 if (!blk)
0696 return -ENOMEM;
0697
0698 *rblk = blk;
0699
0700 return 0;
0701 }
0702
0703 static int amixer_rsc_put_ctrl_blk(void *blk)
0704 {
0705 kfree(blk);
0706
0707 return 0;
0708 }
0709
0710 static int amixer_mgr_get_ctrl_blk(void **rblk)
0711 {
0712
0713
0714 *rblk = NULL;
0715
0716
0717
0718
0719
0720
0721 return 0;
0722 }
0723
0724 static int amixer_mgr_put_ctrl_blk(void *blk)
0725 {
0726
0727
0728 return 0;
0729 }
0730
0731
0732
0733
0734
0735
0736 #define SRTCTL_SRCR 0x000000FF
0737 #define SRTCTL_SRCL 0x0000FF00
0738 #define SRTCTL_RSR 0x00030000
0739 #define SRTCTL_DRAT 0x000C0000
0740 #define SRTCTL_RLE 0x10000000
0741 #define SRTCTL_RLP 0x20000000
0742 #define SRTCTL_EC 0x40000000
0743 #define SRTCTL_ET 0x80000000
0744
0745
0746 union dai_dirty {
0747 struct {
0748 u16 srtctl:1;
0749 u16 rsv:15;
0750 } bf;
0751 u16 data;
0752 };
0753
0754
0755 struct dai_ctrl_blk {
0756 unsigned int srtctl;
0757 union dai_dirty dirty;
0758 };
0759
0760
0761 union dao_dirty {
0762 struct {
0763 u16 spos:1;
0764 u16 rsv:15;
0765 } bf;
0766 u16 data;
0767 };
0768
0769
0770 struct dao_ctrl_blk {
0771 unsigned int spos;
0772 union dao_dirty dirty;
0773 };
0774
0775
0776 #define AIM_ARC 0x00000FFF
0777 #define AIM_NXT 0x007F0000
0778
0779 struct daoimap {
0780 unsigned int aim;
0781 unsigned int idx;
0782 };
0783
0784
0785 #define I2SCTL_EA 0x00000004
0786 #define I2SCTL_EI 0x00000010
0787
0788
0789 #define SPOCTL_OE 0x00000001
0790 #define SPOCTL_OS 0x0000000E
0791 #define SPOCTL_RIV 0x00000010
0792 #define SPOCTL_LIV 0x00000020
0793 #define SPOCTL_SR 0x000000C0
0794
0795
0796 #define SPICTL_EN 0x00000001
0797 #define SPICTL_I24 0x00000002
0798 #define SPICTL_IB 0x00000004
0799 #define SPICTL_SM 0x00000008
0800 #define SPICTL_VM 0x00000010
0801
0802
0803 union daio_mgr_dirty {
0804 struct {
0805 u32 i2soctl:4;
0806 u32 i2sictl:4;
0807 u32 spoctl:4;
0808 u32 spictl:4;
0809 u32 daoimap:1;
0810 u32 rsv:15;
0811 } bf;
0812 u32 data;
0813 };
0814
0815
0816 struct daio_mgr_ctrl_blk {
0817 unsigned int i2sctl;
0818 unsigned int spoctl;
0819 unsigned int spictl;
0820 struct daoimap daoimap;
0821 union daio_mgr_dirty dirty;
0822 };
0823
0824 static int dai_srt_set_srcr(void *blk, unsigned int src)
0825 {
0826 struct dai_ctrl_blk *ctl = blk;
0827
0828 set_field(&ctl->srtctl, SRTCTL_SRCR, src);
0829 ctl->dirty.bf.srtctl = 1;
0830 return 0;
0831 }
0832
0833 static int dai_srt_set_srcl(void *blk, unsigned int src)
0834 {
0835 struct dai_ctrl_blk *ctl = blk;
0836
0837 set_field(&ctl->srtctl, SRTCTL_SRCL, src);
0838 ctl->dirty.bf.srtctl = 1;
0839 return 0;
0840 }
0841
0842 static int dai_srt_set_rsr(void *blk, unsigned int rsr)
0843 {
0844 struct dai_ctrl_blk *ctl = blk;
0845
0846 set_field(&ctl->srtctl, SRTCTL_RSR, rsr);
0847 ctl->dirty.bf.srtctl = 1;
0848 return 0;
0849 }
0850
0851 static int dai_srt_set_drat(void *blk, unsigned int drat)
0852 {
0853 struct dai_ctrl_blk *ctl = blk;
0854
0855 set_field(&ctl->srtctl, SRTCTL_DRAT, drat);
0856 ctl->dirty.bf.srtctl = 1;
0857 return 0;
0858 }
0859
0860 static int dai_srt_set_ec(void *blk, unsigned int ec)
0861 {
0862 struct dai_ctrl_blk *ctl = blk;
0863
0864 set_field(&ctl->srtctl, SRTCTL_EC, ec ? 1 : 0);
0865 ctl->dirty.bf.srtctl = 1;
0866 return 0;
0867 }
0868
0869 static int dai_srt_set_et(void *blk, unsigned int et)
0870 {
0871 struct dai_ctrl_blk *ctl = blk;
0872
0873 set_field(&ctl->srtctl, SRTCTL_ET, et ? 1 : 0);
0874 ctl->dirty.bf.srtctl = 1;
0875 return 0;
0876 }
0877
0878 static int dai_commit_write(struct hw *hw, unsigned int idx, void *blk)
0879 {
0880 struct dai_ctrl_blk *ctl = blk;
0881
0882 if (ctl->dirty.bf.srtctl) {
0883 if (idx < 4) {
0884
0885 hw_write_20kx(hw, SRTSCTL+0x4*idx, ctl->srtctl);
0886 } else {
0887
0888 hw_write_20kx(hw, SRTICTL, ctl->srtctl);
0889 }
0890 ctl->dirty.bf.srtctl = 0;
0891 }
0892
0893 return 0;
0894 }
0895
0896 static int dai_get_ctrl_blk(void **rblk)
0897 {
0898 struct dai_ctrl_blk *blk;
0899
0900 *rblk = NULL;
0901 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
0902 if (!blk)
0903 return -ENOMEM;
0904
0905 *rblk = blk;
0906
0907 return 0;
0908 }
0909
0910 static int dai_put_ctrl_blk(void *blk)
0911 {
0912 kfree(blk);
0913
0914 return 0;
0915 }
0916
0917 static int dao_set_spos(void *blk, unsigned int spos)
0918 {
0919 ((struct dao_ctrl_blk *)blk)->spos = spos;
0920 ((struct dao_ctrl_blk *)blk)->dirty.bf.spos = 1;
0921 return 0;
0922 }
0923
0924 static int dao_commit_write(struct hw *hw, unsigned int idx, void *blk)
0925 {
0926 struct dao_ctrl_blk *ctl = blk;
0927
0928 if (ctl->dirty.bf.spos) {
0929 if (idx < 4) {
0930
0931 hw_write_20kx(hw, SPOS+0x4*idx, ctl->spos);
0932 }
0933 ctl->dirty.bf.spos = 0;
0934 }
0935
0936 return 0;
0937 }
0938
0939 static int dao_get_spos(void *blk, unsigned int *spos)
0940 {
0941 *spos = ((struct dao_ctrl_blk *)blk)->spos;
0942 return 0;
0943 }
0944
0945 static int dao_get_ctrl_blk(void **rblk)
0946 {
0947 struct dao_ctrl_blk *blk;
0948
0949 *rblk = NULL;
0950 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
0951 if (!blk)
0952 return -ENOMEM;
0953
0954 *rblk = blk;
0955
0956 return 0;
0957 }
0958
0959 static int dao_put_ctrl_blk(void *blk)
0960 {
0961 kfree(blk);
0962
0963 return 0;
0964 }
0965
0966 static int daio_mgr_enb_dai(void *blk, unsigned int idx)
0967 {
0968 struct daio_mgr_ctrl_blk *ctl = blk;
0969
0970 if (idx < 4) {
0971
0972 set_field(&ctl->spictl, SPICTL_EN << (idx*8), 1);
0973 ctl->dirty.bf.spictl |= (0x1 << idx);
0974 } else {
0975
0976 idx %= 4;
0977 set_field(&ctl->i2sctl, I2SCTL_EI << (idx*8), 1);
0978 ctl->dirty.bf.i2sictl |= (0x1 << idx);
0979 }
0980 return 0;
0981 }
0982
0983 static int daio_mgr_dsb_dai(void *blk, unsigned int idx)
0984 {
0985 struct daio_mgr_ctrl_blk *ctl = blk;
0986
0987 if (idx < 4) {
0988
0989 set_field(&ctl->spictl, SPICTL_EN << (idx*8), 0);
0990 ctl->dirty.bf.spictl |= (0x1 << idx);
0991 } else {
0992
0993 idx %= 4;
0994 set_field(&ctl->i2sctl, I2SCTL_EI << (idx*8), 0);
0995 ctl->dirty.bf.i2sictl |= (0x1 << idx);
0996 }
0997 return 0;
0998 }
0999
1000 static int daio_mgr_enb_dao(void *blk, unsigned int idx)
1001 {
1002 struct daio_mgr_ctrl_blk *ctl = blk;
1003
1004 if (idx < 4) {
1005
1006 set_field(&ctl->spoctl, SPOCTL_OE << (idx*8), 1);
1007 ctl->dirty.bf.spoctl |= (0x1 << idx);
1008 } else {
1009
1010 idx %= 4;
1011 set_field(&ctl->i2sctl, I2SCTL_EA << (idx*8), 1);
1012 ctl->dirty.bf.i2soctl |= (0x1 << idx);
1013 }
1014 return 0;
1015 }
1016
1017 static int daio_mgr_dsb_dao(void *blk, unsigned int idx)
1018 {
1019 struct daio_mgr_ctrl_blk *ctl = blk;
1020
1021 if (idx < 4) {
1022
1023 set_field(&ctl->spoctl, SPOCTL_OE << (idx*8), 0);
1024 ctl->dirty.bf.spoctl |= (0x1 << idx);
1025 } else {
1026
1027 idx %= 4;
1028 set_field(&ctl->i2sctl, I2SCTL_EA << (idx*8), 0);
1029 ctl->dirty.bf.i2soctl |= (0x1 << idx);
1030 }
1031 return 0;
1032 }
1033
1034 static int daio_mgr_dao_init(void *blk, unsigned int idx, unsigned int conf)
1035 {
1036 struct daio_mgr_ctrl_blk *ctl = blk;
1037
1038 if (idx < 4) {
1039
1040 switch ((conf & 0x7)) {
1041 case 0:
1042 set_field(&ctl->spoctl, SPOCTL_SR << (idx*8), 3);
1043 break;
1044 case 1:
1045 set_field(&ctl->spoctl, SPOCTL_SR << (idx*8), 0);
1046 break;
1047 case 2:
1048 set_field(&ctl->spoctl, SPOCTL_SR << (idx*8), 1);
1049 break;
1050 case 4:
1051 set_field(&ctl->spoctl, SPOCTL_SR << (idx*8), 2);
1052 break;
1053 default:
1054 break;
1055 }
1056 set_field(&ctl->spoctl, SPOCTL_LIV << (idx*8),
1057 (conf >> 4) & 0x1);
1058 set_field(&ctl->spoctl, SPOCTL_RIV << (idx*8),
1059 (conf >> 4) & 0x1);
1060 set_field(&ctl->spoctl, SPOCTL_OS << (idx*8),
1061 ((conf >> 3) & 0x1) ? 2 : 2);
1062
1063 ctl->dirty.bf.spoctl |= (0x1 << idx);
1064 } else {
1065
1066
1067 }
1068 return 0;
1069 }
1070
1071 static int daio_mgr_set_imaparc(void *blk, unsigned int slot)
1072 {
1073 struct daio_mgr_ctrl_blk *ctl = blk;
1074
1075 set_field(&ctl->daoimap.aim, AIM_ARC, slot);
1076 ctl->dirty.bf.daoimap = 1;
1077 return 0;
1078 }
1079
1080 static int daio_mgr_set_imapnxt(void *blk, unsigned int next)
1081 {
1082 struct daio_mgr_ctrl_blk *ctl = blk;
1083
1084 set_field(&ctl->daoimap.aim, AIM_NXT, next);
1085 ctl->dirty.bf.daoimap = 1;
1086 return 0;
1087 }
1088
1089 static int daio_mgr_set_imapaddr(void *blk, unsigned int addr)
1090 {
1091 struct daio_mgr_ctrl_blk *ctl = blk;
1092
1093 ctl->daoimap.idx = addr;
1094 ctl->dirty.bf.daoimap = 1;
1095 return 0;
1096 }
1097
1098 static int daio_mgr_commit_write(struct hw *hw, void *blk)
1099 {
1100 struct daio_mgr_ctrl_blk *ctl = blk;
1101 int i;
1102
1103 if (ctl->dirty.bf.i2sictl || ctl->dirty.bf.i2soctl) {
1104 for (i = 0; i < 4; i++) {
1105 if ((ctl->dirty.bf.i2sictl & (0x1 << i)))
1106 ctl->dirty.bf.i2sictl &= ~(0x1 << i);
1107
1108 if ((ctl->dirty.bf.i2soctl & (0x1 << i)))
1109 ctl->dirty.bf.i2soctl &= ~(0x1 << i);
1110 }
1111 hw_write_20kx(hw, I2SCTL, ctl->i2sctl);
1112 mdelay(1);
1113 }
1114 if (ctl->dirty.bf.spoctl) {
1115 for (i = 0; i < 4; i++) {
1116 if ((ctl->dirty.bf.spoctl & (0x1 << i)))
1117 ctl->dirty.bf.spoctl &= ~(0x1 << i);
1118 }
1119 hw_write_20kx(hw, SPOCTL, ctl->spoctl);
1120 mdelay(1);
1121 }
1122 if (ctl->dirty.bf.spictl) {
1123 for (i = 0; i < 4; i++) {
1124 if ((ctl->dirty.bf.spictl & (0x1 << i)))
1125 ctl->dirty.bf.spictl &= ~(0x1 << i);
1126 }
1127 hw_write_20kx(hw, SPICTL, ctl->spictl);
1128 mdelay(1);
1129 }
1130 if (ctl->dirty.bf.daoimap) {
1131 hw_write_20kx(hw, DAOIMAP+ctl->daoimap.idx*4,
1132 ctl->daoimap.aim);
1133 ctl->dirty.bf.daoimap = 0;
1134 }
1135
1136 return 0;
1137 }
1138
1139 static int daio_mgr_get_ctrl_blk(struct hw *hw, void **rblk)
1140 {
1141 struct daio_mgr_ctrl_blk *blk;
1142
1143 *rblk = NULL;
1144 blk = kzalloc(sizeof(*blk), GFP_KERNEL);
1145 if (!blk)
1146 return -ENOMEM;
1147
1148 blk->i2sctl = hw_read_20kx(hw, I2SCTL);
1149 blk->spoctl = hw_read_20kx(hw, SPOCTL);
1150 blk->spictl = hw_read_20kx(hw, SPICTL);
1151
1152 *rblk = blk;
1153
1154 return 0;
1155 }
1156
1157 static int daio_mgr_put_ctrl_blk(void *blk)
1158 {
1159 kfree(blk);
1160
1161 return 0;
1162 }
1163
1164
1165 static int set_timer_irq(struct hw *hw, int enable)
1166 {
1167 hw_write_20kx(hw, GIE, enable ? IT_INT : 0);
1168 return 0;
1169 }
1170
1171 static int set_timer_tick(struct hw *hw, unsigned int ticks)
1172 {
1173 if (ticks)
1174 ticks |= TIMR_IE | TIMR_IP;
1175 hw_write_20kx(hw, TIMR, ticks);
1176 return 0;
1177 }
1178
1179 static unsigned int get_wc(struct hw *hw)
1180 {
1181 return hw_read_20kx(hw, WC);
1182 }
1183
1184
1185 struct dac_conf {
1186 unsigned int msr;
1187 };
1188
1189 struct adc_conf {
1190 unsigned int msr;
1191 unsigned char input;
1192 unsigned char mic20db;
1193 };
1194
1195 struct daio_conf {
1196 unsigned int msr;
1197 };
1198
1199 struct trn_conf {
1200 unsigned long vm_pgt_phys;
1201 };
1202
1203 static int hw_daio_init(struct hw *hw, const struct daio_conf *info)
1204 {
1205 u32 i2sorg;
1206 u32 spdorg;
1207
1208
1209
1210 i2sorg = 0x94040404;
1211
1212
1213 i2sorg &= 0xfffffffc;
1214
1215
1216
1217
1218 hw_write_20kx(hw, SPOCTL, 0x0);
1219 spdorg = 0x05;
1220
1221 switch (info->msr) {
1222 case 1:
1223 i2sorg |= 1;
1224 spdorg |= (0x0 << 6);
1225 break;
1226 case 2:
1227 i2sorg |= 2;
1228 spdorg |= (0x1 << 6);
1229 break;
1230 case 4:
1231 i2sorg |= 3;
1232 spdorg |= (0x2 << 6);
1233 break;
1234 default:
1235 i2sorg |= 1;
1236 break;
1237 }
1238
1239 hw_write_20kx(hw, I2SCTL, i2sorg);
1240 hw_write_20kx(hw, SPOCTL, spdorg);
1241
1242
1243
1244 hw_write_20kx(hw, SPICTL, 0x0);
1245 mdelay(1);
1246 spdorg = 0x0a0a0a0a;
1247 hw_write_20kx(hw, SPICTL, spdorg);
1248 mdelay(1);
1249
1250 return 0;
1251 }
1252
1253
1254 static int hw_trn_init(struct hw *hw, const struct trn_conf *info)
1255 {
1256 u32 trnctl;
1257 u32 ptp_phys_low, ptp_phys_high;
1258
1259
1260 if ((~0UL) == info->vm_pgt_phys) {
1261 dev_err(hw->card->dev,
1262 "Wrong device page table page address!\n");
1263 return -1;
1264 }
1265
1266 trnctl = 0x13;
1267 ptp_phys_low = (u32)info->vm_pgt_phys;
1268 ptp_phys_high = upper_32_bits(info->vm_pgt_phys);
1269 if (sizeof(void *) == 8)
1270 trnctl |= (1 << 2);
1271 #if 0
1272 #if PAGE_SIZE == 8192
1273 trnctl |= (1<<5);
1274 #endif
1275 #endif
1276 hw_write_20kx(hw, PTPALX, ptp_phys_low);
1277 hw_write_20kx(hw, PTPAHX, ptp_phys_high);
1278 hw_write_20kx(hw, TRNCTL, trnctl);
1279 hw_write_20kx(hw, TRNIS, 0x200c01);
1280
1281 return 0;
1282 }
1283
1284
1285 #define GCTL_EAC 0x00000001
1286 #define GCTL_EAI 0x00000002
1287 #define GCTL_BEP 0x00000004
1288 #define GCTL_BES 0x00000008
1289 #define GCTL_DSP 0x00000010
1290 #define GCTL_DBP 0x00000020
1291 #define GCTL_ABP 0x00000040
1292 #define GCTL_TBP 0x00000080
1293 #define GCTL_SBP 0x00000100
1294 #define GCTL_FBP 0x00000200
1295 #define GCTL_XA 0x00000400
1296 #define GCTL_ET 0x00000800
1297 #define GCTL_PR 0x00001000
1298 #define GCTL_MRL 0x00002000
1299 #define GCTL_SDE 0x00004000
1300 #define GCTL_SDI 0x00008000
1301 #define GCTL_SM 0x00010000
1302 #define GCTL_SR 0x00020000
1303 #define GCTL_SD 0x00040000
1304 #define GCTL_SE 0x00080000
1305 #define GCTL_AID 0x00100000
1306
1307 static int hw_pll_init(struct hw *hw, unsigned int rsr)
1308 {
1309 unsigned int pllctl;
1310 int i;
1311
1312 pllctl = (48000 == rsr) ? 0x1480a001 : 0x1480a731;
1313 for (i = 0; i < 3; i++) {
1314 if (hw_read_20kx(hw, PLLCTL) == pllctl)
1315 break;
1316
1317 hw_write_20kx(hw, PLLCTL, pllctl);
1318 msleep(40);
1319 }
1320 if (i >= 3) {
1321 dev_alert(hw->card->dev, "PLL initialization failed!!!\n");
1322 return -EBUSY;
1323 }
1324
1325 return 0;
1326 }
1327
1328 static int hw_auto_init(struct hw *hw)
1329 {
1330 unsigned int gctl;
1331 int i;
1332
1333 gctl = hw_read_20kx(hw, GCTL);
1334 set_field(&gctl, GCTL_EAI, 0);
1335 hw_write_20kx(hw, GCTL, gctl);
1336 set_field(&gctl, GCTL_EAI, 1);
1337 hw_write_20kx(hw, GCTL, gctl);
1338 mdelay(10);
1339 for (i = 0; i < 400000; i++) {
1340 gctl = hw_read_20kx(hw, GCTL);
1341 if (get_field(gctl, GCTL_AID))
1342 break;
1343 }
1344 if (!get_field(gctl, GCTL_AID)) {
1345 dev_alert(hw->card->dev, "Card Auto-init failed!!!\n");
1346 return -EBUSY;
1347 }
1348
1349 return 0;
1350 }
1351
1352 static int i2c_unlock(struct hw *hw)
1353 {
1354 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa)
1355 return 0;
1356
1357 hw_write_pci(hw, 0xcc, 0x8c);
1358 hw_write_pci(hw, 0xcc, 0x0e);
1359 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa)
1360 return 0;
1361
1362 hw_write_pci(hw, 0xcc, 0xee);
1363 hw_write_pci(hw, 0xcc, 0xaa);
1364 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa)
1365 return 0;
1366
1367 return -1;
1368 }
1369
1370 static void i2c_lock(struct hw *hw)
1371 {
1372 if ((hw_read_pci(hw, 0xcc) & 0xff) == 0xaa)
1373 hw_write_pci(hw, 0xcc, 0x00);
1374 }
1375
1376 static void i2c_write(struct hw *hw, u32 device, u32 addr, u32 data)
1377 {
1378 unsigned int ret;
1379
1380 do {
1381 ret = hw_read_pci(hw, 0xEC);
1382 } while (!(ret & 0x800000));
1383 hw_write_pci(hw, 0xE0, device);
1384 hw_write_pci(hw, 0xE4, (data << 8) | (addr & 0xff));
1385 }
1386
1387
1388
1389 static int hw_reset_dac(struct hw *hw)
1390 {
1391 u32 i;
1392 u16 gpioorg;
1393 unsigned int ret;
1394
1395 if (i2c_unlock(hw))
1396 return -1;
1397
1398 do {
1399 ret = hw_read_pci(hw, 0xEC);
1400 } while (!(ret & 0x800000));
1401 hw_write_pci(hw, 0xEC, 0x05);
1402
1403
1404 for (i = 0; i < 2; i++) {
1405
1406 msleep(100);
1407 gpioorg = (u16)hw_read_20kx(hw, GPIO);
1408 gpioorg &= 0xfffd;
1409 hw_write_20kx(hw, GPIO, gpioorg);
1410 mdelay(1);
1411 hw_write_20kx(hw, GPIO, gpioorg | 0x2);
1412 }
1413
1414 i2c_write(hw, 0x00180080, 0x01, 0x80);
1415 i2c_write(hw, 0x00180080, 0x02, 0x10);
1416
1417 i2c_lock(hw);
1418
1419 return 0;
1420 }
1421
1422 static int hw_dac_init(struct hw *hw, const struct dac_conf *info)
1423 {
1424 u32 data;
1425 u16 gpioorg;
1426 unsigned int ret;
1427
1428 if (hw->model == CTSB055X) {
1429
1430 gpioorg = (u16)hw_read_20kx(hw, GPIO);
1431 gpioorg &= 0xffbf;
1432 gpioorg |= 2;
1433 hw_write_20kx(hw, GPIO, gpioorg);
1434 return 0;
1435 }
1436
1437
1438 gpioorg = (u16)hw_read_20kx(hw, GPIO);
1439 gpioorg &= 0xffbf;
1440 hw_write_20kx(hw, GPIO, gpioorg);
1441
1442 hw_reset_dac(hw);
1443
1444 if (i2c_unlock(hw))
1445 return -1;
1446
1447 hw_write_pci(hw, 0xEC, 0x05);
1448 do {
1449 ret = hw_read_pci(hw, 0xEC);
1450 } while (!(ret & 0x800000));
1451
1452 switch (info->msr) {
1453 case 1:
1454 data = 0x24;
1455 break;
1456 case 2:
1457 data = 0x25;
1458 break;
1459 case 4:
1460 data = 0x26;
1461 break;
1462 default:
1463 data = 0x24;
1464 break;
1465 }
1466
1467 i2c_write(hw, 0x00180080, 0x06, data);
1468 i2c_write(hw, 0x00180080, 0x09, data);
1469 i2c_write(hw, 0x00180080, 0x0c, data);
1470 i2c_write(hw, 0x00180080, 0x0f, data);
1471
1472 i2c_lock(hw);
1473
1474
1475 gpioorg = (u16)hw_read_20kx(hw, GPIO);
1476 gpioorg = gpioorg | 0x40;
1477 hw_write_20kx(hw, GPIO, gpioorg);
1478
1479 return 0;
1480 }
1481
1482
1483
1484 static int is_adc_input_selected_SB055x(struct hw *hw, enum ADCSRC type)
1485 {
1486 return 0;
1487 }
1488
1489 static int is_adc_input_selected_SBx(struct hw *hw, enum ADCSRC type)
1490 {
1491 u32 data;
1492
1493 data = hw_read_20kx(hw, GPIO);
1494 switch (type) {
1495 case ADC_MICIN:
1496 data = ((data & (0x1<<7)) && (data & (0x1<<8)));
1497 break;
1498 case ADC_LINEIN:
1499 data = (!(data & (0x1<<7)) && (data & (0x1<<8)));
1500 break;
1501 case ADC_NONE:
1502 data = (!(data & (0x1<<8)));
1503 break;
1504 default:
1505 data = 0;
1506 }
1507 return data;
1508 }
1509
1510 static int is_adc_input_selected_hendrix(struct hw *hw, enum ADCSRC type)
1511 {
1512 u32 data;
1513
1514 data = hw_read_20kx(hw, GPIO);
1515 switch (type) {
1516 case ADC_MICIN:
1517 data = (data & (0x1 << 7)) ? 1 : 0;
1518 break;
1519 case ADC_LINEIN:
1520 data = (data & (0x1 << 7)) ? 0 : 1;
1521 break;
1522 default:
1523 data = 0;
1524 }
1525 return data;
1526 }
1527
1528 static int hw_is_adc_input_selected(struct hw *hw, enum ADCSRC type)
1529 {
1530 switch (hw->model) {
1531 case CTSB055X:
1532 return is_adc_input_selected_SB055x(hw, type);
1533 case CTSB073X:
1534 return is_adc_input_selected_hendrix(hw, type);
1535 case CTUAA:
1536 return is_adc_input_selected_hendrix(hw, type);
1537 default:
1538 return is_adc_input_selected_SBx(hw, type);
1539 }
1540 }
1541
1542 static int
1543 adc_input_select_SB055x(struct hw *hw, enum ADCSRC type, unsigned char boost)
1544 {
1545 u32 data;
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556 data = hw_read_20kx(hw, GPIO);
1557 data &= 0xec73;
1558 switch (type) {
1559 case ADC_MICIN:
1560 data |= (0x1<<7) | (0x1<<8) | (0x1<<9) ;
1561 data |= boost ? (0x1<<2) : 0;
1562 break;
1563 case ADC_LINEIN:
1564 data |= (0x1<<8);
1565 break;
1566 case ADC_AUX:
1567 data |= (0x1<<8) | (0x1<<12);
1568 break;
1569 case ADC_NONE:
1570 data |= (0x1<<12);
1571 break;
1572 default:
1573 return -1;
1574 }
1575
1576 hw_write_20kx(hw, GPIO, data);
1577
1578 return 0;
1579 }
1580
1581
1582 static int
1583 adc_input_select_SBx(struct hw *hw, enum ADCSRC type, unsigned char boost)
1584 {
1585 u32 data;
1586 u32 i2c_data;
1587 unsigned int ret;
1588
1589 if (i2c_unlock(hw))
1590 return -1;
1591
1592 do {
1593 ret = hw_read_pci(hw, 0xEC);
1594 } while (!(ret & 0x800000));
1595
1596 hw_write_pci(hw, 0xEC, 0x05);
1597
1598 data = hw_read_20kx(hw, GPIO);
1599 switch (type) {
1600 case ADC_MICIN:
1601 data |= ((0x1 << 7) | (0x1 << 8));
1602 i2c_data = 0x1;
1603 break;
1604 case ADC_LINEIN:
1605 data &= ~(0x1 << 7);
1606 data |= (0x1 << 8);
1607 i2c_data = 0x2;
1608 break;
1609 case ADC_NONE:
1610 data &= ~(0x1 << 8);
1611 i2c_data = 0x0;
1612 break;
1613 default:
1614 i2c_lock(hw);
1615 return -1;
1616 }
1617 hw_write_20kx(hw, GPIO, data);
1618 i2c_write(hw, 0x001a0080, 0x2a, i2c_data);
1619 if (boost) {
1620 i2c_write(hw, 0x001a0080, 0x1c, 0xe7);
1621 i2c_write(hw, 0x001a0080, 0x1e, 0xe7);
1622 } else {
1623 i2c_write(hw, 0x001a0080, 0x1c, 0xcf);
1624 i2c_write(hw, 0x001a0080, 0x1e, 0xcf);
1625 }
1626
1627 i2c_lock(hw);
1628
1629 return 0;
1630 }
1631
1632 static int
1633 adc_input_select_hendrix(struct hw *hw, enum ADCSRC type, unsigned char boost)
1634 {
1635 u32 data;
1636 u32 i2c_data;
1637 unsigned int ret;
1638
1639 if (i2c_unlock(hw))
1640 return -1;
1641
1642 do {
1643 ret = hw_read_pci(hw, 0xEC);
1644 } while (!(ret & 0x800000));
1645
1646 hw_write_pci(hw, 0xEC, 0x05);
1647
1648 data = hw_read_20kx(hw, GPIO);
1649 switch (type) {
1650 case ADC_MICIN:
1651 data |= (0x1 << 7);
1652 i2c_data = 0x1;
1653 break;
1654 case ADC_LINEIN:
1655 data &= ~(0x1 << 7);
1656 i2c_data = 0x2;
1657 break;
1658 default:
1659 i2c_lock(hw);
1660 return -1;
1661 }
1662 hw_write_20kx(hw, GPIO, data);
1663 i2c_write(hw, 0x001a0080, 0x2a, i2c_data);
1664 if (boost) {
1665 i2c_write(hw, 0x001a0080, 0x1c, 0xe7);
1666 i2c_write(hw, 0x001a0080, 0x1e, 0xe7);
1667 } else {
1668 i2c_write(hw, 0x001a0080, 0x1c, 0xcf);
1669 i2c_write(hw, 0x001a0080, 0x1e, 0xcf);
1670 }
1671
1672 i2c_lock(hw);
1673
1674 return 0;
1675 }
1676
1677 static int hw_adc_input_select(struct hw *hw, enum ADCSRC type)
1678 {
1679 int state = type == ADC_MICIN;
1680
1681 switch (hw->model) {
1682 case CTSB055X:
1683 return adc_input_select_SB055x(hw, type, state);
1684 case CTSB073X:
1685 return adc_input_select_hendrix(hw, type, state);
1686 case CTUAA:
1687 return adc_input_select_hendrix(hw, type, state);
1688 default:
1689 return adc_input_select_SBx(hw, type, state);
1690 }
1691 }
1692
1693 static int adc_init_SB055x(struct hw *hw, int input, int mic20db)
1694 {
1695 return adc_input_select_SB055x(hw, input, mic20db);
1696 }
1697
1698 static int adc_init_SBx(struct hw *hw, int input, int mic20db)
1699 {
1700 u16 gpioorg;
1701 u16 input_source;
1702 u32 adcdata;
1703 unsigned int ret;
1704
1705 input_source = 0x100;
1706 switch (input) {
1707 case ADC_MICIN:
1708 adcdata = 0x1;
1709 input_source = 0x180;
1710 break;
1711 case ADC_LINEIN:
1712 adcdata = 0x2;
1713 break;
1714 case ADC_VIDEO:
1715 adcdata = 0x4;
1716 break;
1717 case ADC_AUX:
1718 adcdata = 0x8;
1719 break;
1720 case ADC_NONE:
1721 adcdata = 0x0;
1722 input_source = 0x0;
1723 break;
1724 default:
1725 adcdata = 0x0;
1726 break;
1727 }
1728
1729 if (i2c_unlock(hw))
1730 return -1;
1731
1732 do {
1733 ret = hw_read_pci(hw, 0xEC);
1734 } while (!(ret & 0x800000));
1735 hw_write_pci(hw, 0xEC, 0x05);
1736
1737 i2c_write(hw, 0x001a0080, 0x0e, 0x08);
1738 i2c_write(hw, 0x001a0080, 0x18, 0x0a);
1739 i2c_write(hw, 0x001a0080, 0x28, 0x86);
1740 i2c_write(hw, 0x001a0080, 0x2a, adcdata);
1741
1742 if (mic20db) {
1743 i2c_write(hw, 0x001a0080, 0x1c, 0xf7);
1744 i2c_write(hw, 0x001a0080, 0x1e, 0xf7);
1745 } else {
1746 i2c_write(hw, 0x001a0080, 0x1c, 0xcf);
1747 i2c_write(hw, 0x001a0080, 0x1e, 0xcf);
1748 }
1749
1750 if (!(hw_read_20kx(hw, ID0) & 0x100))
1751 i2c_write(hw, 0x001a0080, 0x16, 0x26);
1752
1753 i2c_lock(hw);
1754
1755 gpioorg = (u16)hw_read_20kx(hw, GPIO);
1756 gpioorg &= 0xfe7f;
1757 gpioorg |= input_source;
1758 hw_write_20kx(hw, GPIO, gpioorg);
1759
1760 return 0;
1761 }
1762
1763 static int hw_adc_init(struct hw *hw, const struct adc_conf *info)
1764 {
1765 if (hw->model == CTSB055X)
1766 return adc_init_SB055x(hw, info->input, info->mic20db);
1767 else
1768 return adc_init_SBx(hw, info->input, info->mic20db);
1769 }
1770
1771 static struct capabilities hw_capabilities(struct hw *hw)
1772 {
1773 struct capabilities cap;
1774
1775
1776 cap.digit_io_switch = !(hw->model == CTSB073X || hw->model == CTUAA);
1777 cap.dedicated_mic = 0;
1778 cap.output_switch = 0;
1779 cap.mic_source_switch = 0;
1780
1781 return cap;
1782 }
1783
1784 #define CTLBITS(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
1785
1786 #define UAA_CFG_PWRSTATUS 0x44
1787 #define UAA_CFG_SPACE_FLAG 0xA0
1788 #define UAA_CORE_CHANGE 0x3FFC
1789 static int uaa_to_xfi(struct pci_dev *pci)
1790 {
1791 unsigned int bar0, bar1, bar2, bar3, bar4, bar5;
1792 unsigned int cmd, irq, cl_size, l_timer, pwr;
1793 unsigned int is_uaa;
1794 unsigned int data[4] = {0};
1795 unsigned int io_base;
1796 void __iomem *mem_base;
1797 int i;
1798 const u32 CTLX = CTLBITS('C', 'T', 'L', 'X');
1799 const u32 CTL_ = CTLBITS('C', 'T', 'L', '-');
1800 const u32 CTLF = CTLBITS('C', 'T', 'L', 'F');
1801 const u32 CTLi = CTLBITS('C', 'T', 'L', 'i');
1802 const u32 CTLA = CTLBITS('C', 'T', 'L', 'A');
1803 const u32 CTLZ = CTLBITS('C', 'T', 'L', 'Z');
1804 const u32 CTLL = CTLBITS('C', 'T', 'L', 'L');
1805
1806
1807 io_base = pci_resource_start(pci, 0);
1808 mem_base = ioremap(io_base, pci_resource_len(pci, 0));
1809 if (!mem_base)
1810 return -ENOENT;
1811
1812
1813 for (i = 0; i < 4; i++)
1814 data[i] = readl(mem_base + UAA_CORE_CHANGE);
1815
1816
1817 if (data[0] == CTLA) {
1818 is_uaa = ((data[1] == CTLZ && data[2] == CTLL
1819 && data[3] == CTLA) || (data[1] == CTLA
1820 && data[2] == CTLZ && data[3] == CTLL));
1821 } else if (data[0] == CTLZ) {
1822 is_uaa = (data[1] == CTLL
1823 && data[2] == CTLA && data[3] == CTLA);
1824 } else if (data[0] == CTLL) {
1825 is_uaa = (data[1] == CTLA
1826 && data[2] == CTLA && data[3] == CTLZ);
1827 } else {
1828 is_uaa = 0;
1829 }
1830
1831 if (!is_uaa) {
1832
1833 iounmap(mem_base);
1834 return 0;
1835 }
1836
1837 pci_read_config_dword(pci, PCI_BASE_ADDRESS_0, &bar0);
1838 pci_read_config_dword(pci, PCI_BASE_ADDRESS_1, &bar1);
1839 pci_read_config_dword(pci, PCI_BASE_ADDRESS_2, &bar2);
1840 pci_read_config_dword(pci, PCI_BASE_ADDRESS_3, &bar3);
1841 pci_read_config_dword(pci, PCI_BASE_ADDRESS_4, &bar4);
1842 pci_read_config_dword(pci, PCI_BASE_ADDRESS_5, &bar5);
1843 pci_read_config_dword(pci, PCI_INTERRUPT_LINE, &irq);
1844 pci_read_config_dword(pci, PCI_CACHE_LINE_SIZE, &cl_size);
1845 pci_read_config_dword(pci, PCI_LATENCY_TIMER, &l_timer);
1846 pci_read_config_dword(pci, UAA_CFG_PWRSTATUS, &pwr);
1847 pci_read_config_dword(pci, PCI_COMMAND, &cmd);
1848
1849
1850
1851 pci_write_config_dword(pci, UAA_CFG_SPACE_FLAG, 0x87654321);
1852
1853 pci_write_config_dword(pci, PCI_BASE_ADDRESS_0, bar5);
1854
1855 pci_write_config_dword(pci, UAA_CFG_SPACE_FLAG, 0x12345678);
1856 pci_write_config_dword(pci, PCI_BASE_ADDRESS_1, bar1);
1857 pci_write_config_dword(pci, PCI_BASE_ADDRESS_2, bar2);
1858 pci_write_config_dword(pci, PCI_BASE_ADDRESS_3, bar3);
1859 pci_write_config_dword(pci, PCI_BASE_ADDRESS_4, bar4);
1860 pci_write_config_dword(pci, PCI_INTERRUPT_LINE, irq);
1861 pci_write_config_dword(pci, PCI_CACHE_LINE_SIZE, cl_size);
1862 pci_write_config_dword(pci, PCI_LATENCY_TIMER, l_timer);
1863 pci_write_config_dword(pci, UAA_CFG_PWRSTATUS, pwr);
1864 pci_write_config_dword(pci, PCI_COMMAND, cmd);
1865
1866
1867 writel(CTLX, (mem_base + UAA_CORE_CHANGE));
1868 writel(CTL_, (mem_base + UAA_CORE_CHANGE));
1869 writel(CTLF, (mem_base + UAA_CORE_CHANGE));
1870 writel(CTLi, (mem_base + UAA_CORE_CHANGE));
1871
1872 iounmap(mem_base);
1873
1874 return 0;
1875 }
1876
1877 static irqreturn_t ct_20k1_interrupt(int irq, void *dev_id)
1878 {
1879 struct hw *hw = dev_id;
1880 unsigned int status;
1881
1882 status = hw_read_20kx(hw, GIP);
1883 if (!status)
1884 return IRQ_NONE;
1885
1886 if (hw->irq_callback)
1887 hw->irq_callback(hw->irq_callback_data, status);
1888
1889 hw_write_20kx(hw, GIP, status);
1890 return IRQ_HANDLED;
1891 }
1892
1893 static int hw_card_start(struct hw *hw)
1894 {
1895 int err;
1896 struct pci_dev *pci = hw->pci;
1897 const unsigned int dma_bits = BITS_PER_LONG;
1898
1899 err = pci_enable_device(pci);
1900 if (err < 0)
1901 return err;
1902
1903
1904 if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(dma_bits)))
1905 dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32));
1906
1907 if (!hw->io_base) {
1908 err = pci_request_regions(pci, "XFi");
1909 if (err < 0)
1910 goto error1;
1911
1912 if (hw->model == CTUAA)
1913 hw->io_base = pci_resource_start(pci, 5);
1914 else
1915 hw->io_base = pci_resource_start(pci, 0);
1916
1917 }
1918
1919
1920 if (hw->model == CTUAA) {
1921 err = uaa_to_xfi(pci);
1922 if (err)
1923 goto error2;
1924
1925 }
1926
1927 if (hw->irq < 0) {
1928 err = request_irq(pci->irq, ct_20k1_interrupt, IRQF_SHARED,
1929 KBUILD_MODNAME, hw);
1930 if (err < 0) {
1931 dev_err(hw->card->dev,
1932 "XFi: Cannot get irq %d\n", pci->irq);
1933 goto error2;
1934 }
1935 hw->irq = pci->irq;
1936 hw->card->sync_irq = hw->irq;
1937 }
1938
1939 pci_set_master(pci);
1940
1941 return 0;
1942
1943 error2:
1944 pci_release_regions(pci);
1945 hw->io_base = 0;
1946 error1:
1947 pci_disable_device(pci);
1948 return err;
1949 }
1950
1951 static int hw_card_stop(struct hw *hw)
1952 {
1953 unsigned int data;
1954
1955
1956 hw_write_20kx(hw, TRNCTL, 0x00);
1957
1958
1959 data = hw_read_20kx(hw, PLLCTL);
1960 hw_write_20kx(hw, PLLCTL, (data & (~(0x0F<<12))));
1961
1962 return 0;
1963 }
1964
1965 static int hw_card_shutdown(struct hw *hw)
1966 {
1967 if (hw->irq >= 0)
1968 free_irq(hw->irq, hw);
1969
1970 hw->irq = -1;
1971 iounmap(hw->mem_base);
1972 hw->mem_base = NULL;
1973
1974 if (hw->io_base)
1975 pci_release_regions(hw->pci);
1976
1977 hw->io_base = 0;
1978
1979 pci_disable_device(hw->pci);
1980
1981 return 0;
1982 }
1983
1984 static int hw_card_init(struct hw *hw, struct card_conf *info)
1985 {
1986 int err;
1987 unsigned int gctl;
1988 u32 data;
1989 struct dac_conf dac_info = {0};
1990 struct adc_conf adc_info = {0};
1991 struct daio_conf daio_info = {0};
1992 struct trn_conf trn_info = {0};
1993
1994
1995 err = hw_card_start(hw);
1996 if (err)
1997 return err;
1998
1999
2000 err = hw_pll_init(hw, info->rsr);
2001 if (err < 0)
2002 return err;
2003
2004
2005 err = hw_auto_init(hw);
2006 if (err < 0)
2007 return err;
2008
2009
2010 gctl = hw_read_20kx(hw, GCTL);
2011 set_field(&gctl, GCTL_EAC, 1);
2012 set_field(&gctl, GCTL_DBP, 1);
2013 set_field(&gctl, GCTL_TBP, 1);
2014 set_field(&gctl, GCTL_FBP, 1);
2015 set_field(&gctl, GCTL_ET, 1);
2016 hw_write_20kx(hw, GCTL, gctl);
2017 mdelay(10);
2018
2019
2020 hw_write_20kx(hw, GIE, 0);
2021
2022 hw_write_20kx(hw, SRCIP, 0);
2023 msleep(30);
2024
2025
2026 switch (hw->model) {
2027 case CTSB055X:
2028 hw_write_20kx(hw, GPIOCTL, 0x13fe);
2029 break;
2030 case CTSB073X:
2031 hw_write_20kx(hw, GPIOCTL, 0x00e6);
2032 break;
2033 case CTUAA:
2034 hw_write_20kx(hw, GPIOCTL, 0x00c2);
2035 break;
2036 default:
2037 hw_write_20kx(hw, GPIOCTL, 0x01e6);
2038 break;
2039 }
2040
2041 trn_info.vm_pgt_phys = info->vm_pgt_phys;
2042 err = hw_trn_init(hw, &trn_info);
2043 if (err < 0)
2044 return err;
2045
2046 daio_info.msr = info->msr;
2047 err = hw_daio_init(hw, &daio_info);
2048 if (err < 0)
2049 return err;
2050
2051 dac_info.msr = info->msr;
2052 err = hw_dac_init(hw, &dac_info);
2053 if (err < 0)
2054 return err;
2055
2056 adc_info.msr = info->msr;
2057 adc_info.input = ADC_LINEIN;
2058 adc_info.mic20db = 0;
2059 err = hw_adc_init(hw, &adc_info);
2060 if (err < 0)
2061 return err;
2062
2063 data = hw_read_20kx(hw, SRCMCTL);
2064 data |= 0x1;
2065 hw_write_20kx(hw, SRCMCTL, data);
2066
2067 return 0;
2068 }
2069
2070 #ifdef CONFIG_PM_SLEEP
2071 static int hw_suspend(struct hw *hw)
2072 {
2073 struct pci_dev *pci = hw->pci;
2074
2075 hw_card_stop(hw);
2076
2077 if (hw->model == CTUAA) {
2078
2079 pci_write_config_dword(pci, UAA_CFG_SPACE_FLAG, 0x0);
2080 }
2081
2082 return 0;
2083 }
2084
2085 static int hw_resume(struct hw *hw, struct card_conf *info)
2086 {
2087
2088 return hw_card_init(hw, info);
2089 }
2090 #endif
2091
2092 static u32 hw_read_20kx(struct hw *hw, u32 reg)
2093 {
2094 u32 value;
2095 unsigned long flags;
2096
2097 spin_lock_irqsave(
2098 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags);
2099 outl(reg, hw->io_base + 0x0);
2100 value = inl(hw->io_base + 0x4);
2101 spin_unlock_irqrestore(
2102 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags);
2103
2104 return value;
2105 }
2106
2107 static void hw_write_20kx(struct hw *hw, u32 reg, u32 data)
2108 {
2109 unsigned long flags;
2110
2111 spin_lock_irqsave(
2112 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags);
2113 outl(reg, hw->io_base + 0x0);
2114 outl(data, hw->io_base + 0x4);
2115 spin_unlock_irqrestore(
2116 &container_of(hw, struct hw20k1, hw)->reg_20k1_lock, flags);
2117
2118 }
2119
2120 static u32 hw_read_pci(struct hw *hw, u32 reg)
2121 {
2122 u32 value;
2123 unsigned long flags;
2124
2125 spin_lock_irqsave(
2126 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags);
2127 outl(reg, hw->io_base + 0x10);
2128 value = inl(hw->io_base + 0x14);
2129 spin_unlock_irqrestore(
2130 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags);
2131
2132 return value;
2133 }
2134
2135 static void hw_write_pci(struct hw *hw, u32 reg, u32 data)
2136 {
2137 unsigned long flags;
2138
2139 spin_lock_irqsave(
2140 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags);
2141 outl(reg, hw->io_base + 0x10);
2142 outl(data, hw->io_base + 0x14);
2143 spin_unlock_irqrestore(
2144 &container_of(hw, struct hw20k1, hw)->reg_pci_lock, flags);
2145 }
2146
2147 static const struct hw ct20k1_preset = {
2148 .irq = -1,
2149
2150 .card_init = hw_card_init,
2151 .card_stop = hw_card_stop,
2152 .pll_init = hw_pll_init,
2153 .is_adc_source_selected = hw_is_adc_input_selected,
2154 .select_adc_source = hw_adc_input_select,
2155 .capabilities = hw_capabilities,
2156 #ifdef CONFIG_PM_SLEEP
2157 .suspend = hw_suspend,
2158 .resume = hw_resume,
2159 #endif
2160
2161 .src_rsc_get_ctrl_blk = src_get_rsc_ctrl_blk,
2162 .src_rsc_put_ctrl_blk = src_put_rsc_ctrl_blk,
2163 .src_mgr_get_ctrl_blk = src_mgr_get_ctrl_blk,
2164 .src_mgr_put_ctrl_blk = src_mgr_put_ctrl_blk,
2165 .src_set_state = src_set_state,
2166 .src_set_bm = src_set_bm,
2167 .src_set_rsr = src_set_rsr,
2168 .src_set_sf = src_set_sf,
2169 .src_set_wr = src_set_wr,
2170 .src_set_pm = src_set_pm,
2171 .src_set_rom = src_set_rom,
2172 .src_set_vo = src_set_vo,
2173 .src_set_st = src_set_st,
2174 .src_set_ie = src_set_ie,
2175 .src_set_ilsz = src_set_ilsz,
2176 .src_set_bp = src_set_bp,
2177 .src_set_cisz = src_set_cisz,
2178 .src_set_ca = src_set_ca,
2179 .src_set_sa = src_set_sa,
2180 .src_set_la = src_set_la,
2181 .src_set_pitch = src_set_pitch,
2182 .src_set_dirty = src_set_dirty,
2183 .src_set_clear_zbufs = src_set_clear_zbufs,
2184 .src_set_dirty_all = src_set_dirty_all,
2185 .src_commit_write = src_commit_write,
2186 .src_get_ca = src_get_ca,
2187 .src_get_dirty = src_get_dirty,
2188 .src_dirty_conj_mask = src_dirty_conj_mask,
2189 .src_mgr_enbs_src = src_mgr_enbs_src,
2190 .src_mgr_enb_src = src_mgr_enb_src,
2191 .src_mgr_dsb_src = src_mgr_dsb_src,
2192 .src_mgr_commit_write = src_mgr_commit_write,
2193
2194 .srcimp_mgr_get_ctrl_blk = srcimp_mgr_get_ctrl_blk,
2195 .srcimp_mgr_put_ctrl_blk = srcimp_mgr_put_ctrl_blk,
2196 .srcimp_mgr_set_imaparc = srcimp_mgr_set_imaparc,
2197 .srcimp_mgr_set_imapuser = srcimp_mgr_set_imapuser,
2198 .srcimp_mgr_set_imapnxt = srcimp_mgr_set_imapnxt,
2199 .srcimp_mgr_set_imapaddr = srcimp_mgr_set_imapaddr,
2200 .srcimp_mgr_commit_write = srcimp_mgr_commit_write,
2201
2202 .amixer_rsc_get_ctrl_blk = amixer_rsc_get_ctrl_blk,
2203 .amixer_rsc_put_ctrl_blk = amixer_rsc_put_ctrl_blk,
2204 .amixer_mgr_get_ctrl_blk = amixer_mgr_get_ctrl_blk,
2205 .amixer_mgr_put_ctrl_blk = amixer_mgr_put_ctrl_blk,
2206 .amixer_set_mode = amixer_set_mode,
2207 .amixer_set_iv = amixer_set_iv,
2208 .amixer_set_x = amixer_set_x,
2209 .amixer_set_y = amixer_set_y,
2210 .amixer_set_sadr = amixer_set_sadr,
2211 .amixer_set_se = amixer_set_se,
2212 .amixer_set_dirty = amixer_set_dirty,
2213 .amixer_set_dirty_all = amixer_set_dirty_all,
2214 .amixer_commit_write = amixer_commit_write,
2215 .amixer_get_y = amixer_get_y,
2216 .amixer_get_dirty = amixer_get_dirty,
2217
2218 .dai_get_ctrl_blk = dai_get_ctrl_blk,
2219 .dai_put_ctrl_blk = dai_put_ctrl_blk,
2220 .dai_srt_set_srco = dai_srt_set_srcr,
2221 .dai_srt_set_srcm = dai_srt_set_srcl,
2222 .dai_srt_set_rsr = dai_srt_set_rsr,
2223 .dai_srt_set_drat = dai_srt_set_drat,
2224 .dai_srt_set_ec = dai_srt_set_ec,
2225 .dai_srt_set_et = dai_srt_set_et,
2226 .dai_commit_write = dai_commit_write,
2227
2228 .dao_get_ctrl_blk = dao_get_ctrl_blk,
2229 .dao_put_ctrl_blk = dao_put_ctrl_blk,
2230 .dao_set_spos = dao_set_spos,
2231 .dao_commit_write = dao_commit_write,
2232 .dao_get_spos = dao_get_spos,
2233
2234 .daio_mgr_get_ctrl_blk = daio_mgr_get_ctrl_blk,
2235 .daio_mgr_put_ctrl_blk = daio_mgr_put_ctrl_blk,
2236 .daio_mgr_enb_dai = daio_mgr_enb_dai,
2237 .daio_mgr_dsb_dai = daio_mgr_dsb_dai,
2238 .daio_mgr_enb_dao = daio_mgr_enb_dao,
2239 .daio_mgr_dsb_dao = daio_mgr_dsb_dao,
2240 .daio_mgr_dao_init = daio_mgr_dao_init,
2241 .daio_mgr_set_imaparc = daio_mgr_set_imaparc,
2242 .daio_mgr_set_imapnxt = daio_mgr_set_imapnxt,
2243 .daio_mgr_set_imapaddr = daio_mgr_set_imapaddr,
2244 .daio_mgr_commit_write = daio_mgr_commit_write,
2245
2246 .set_timer_irq = set_timer_irq,
2247 .set_timer_tick = set_timer_tick,
2248 .get_wc = get_wc,
2249 };
2250
2251 int create_20k1_hw_obj(struct hw **rhw)
2252 {
2253 struct hw20k1 *hw20k1;
2254
2255 *rhw = NULL;
2256 hw20k1 = kzalloc(sizeof(*hw20k1), GFP_KERNEL);
2257 if (!hw20k1)
2258 return -ENOMEM;
2259
2260 spin_lock_init(&hw20k1->reg_20k1_lock);
2261 spin_lock_init(&hw20k1->reg_pci_lock);
2262
2263 hw20k1->hw = ct20k1_preset;
2264
2265 *rhw = &hw20k1->hw;
2266
2267 return 0;
2268 }
2269
2270 int destroy_20k1_hw_obj(struct hw *hw)
2271 {
2272 if (hw->io_base)
2273 hw_card_shutdown(hw);
2274
2275 kfree(container_of(hw, struct hw20k1, hw));
2276 return 0;
2277 }