2 * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
4 * This source file is released under GPL v2 license (no other versions).
5 * See the COPYING file included in the main directory of this source
6 * distribution for the license terms and conditions.
11 * This file contains the implementation of hardware access methord.
18 #include "cthardware.h"
21 #include <linux/bug.h>
23 static enum CHIPTYP __devinitdata get_chip_type(struct hw *hw)
25 enum CHIPTYP type = ATCNONE;
27 switch (hw->pci->device) {
28 case 0x0005: /* 20k1 device */
31 case 0x000B: /* 20k2 device */
42 int __devinit create_hw_obj(struct pci_dev *pci, struct hw **rhw)
46 switch (pci->device) {
47 case 0x0005: /* 20k1 device */
48 err = create_20k1_hw_obj(rhw);
50 case 0x000B: /* 20k2 device */
51 err = create_20k2_hw_obj(rhw);
61 (*rhw)->get_chip_type = get_chip_type;
66 int destroy_hw_obj(struct hw *hw)
70 switch (hw->pci->device) {
71 case 0x0005: /* 20k1 device */
72 err = destroy_20k1_hw_obj(hw);
74 case 0x000B: /* 20k2 device */
75 err = destroy_20k2_hw_obj(hw);
85 unsigned int get_field(unsigned int data, unsigned int field)
90 /* @field should always be greater than 0 */
91 for (i = 0; !(field & (1 << i)); )
94 return (data & field) >> i;
97 void set_field(unsigned int *data, unsigned int field, unsigned int value)
102 /* @field should always be greater than 0 */
103 for (i = 0; !(field & (1 << i)); )
106 *data = (*data & (~field)) | ((value << i) & field);