This source file includes following definitions.
- gscpm_match
- gscpm_attach
- gscpm_get_timecount
- gscpm_setperf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 #include <sys/param.h>
23 #include <sys/systm.h>
24 #include <sys/device.h>
25 #include <sys/kernel.h>
26 #include <sys/sysctl.h>
27 #ifdef __HAVE_TIMECOUNTER
28 #include <sys/timetc.h>
29 #endif
30
31 #include <machine/bus.h>
32
33 #include <dev/pci/pcireg.h>
34 #include <dev/pci/pcivar.h>
35 #include <dev/pci/pcidevs.h>
36
37 #include <i386/pci/gscpmreg.h>
38
39 struct gscpm_softc {
40 struct device sc_dev;
41
42 pci_chipset_tag_t sc_pc;
43 pcitag_t sc_tag;
44 bus_space_tag_t sc_iot;
45 bus_space_handle_t sc_acpi_ioh;
46 };
47
48 int gscpm_match(struct device *, void *, void *);
49 void gscpm_attach(struct device *, struct device *, void *);
50
51 void gscpm_setperf(int);
52
53 #ifdef __HAVE_TIMECOUNTER
54 u_int gscpm_get_timecount(struct timecounter *tc);
55
56 struct timecounter gscpm_timecounter = {
57 gscpm_get_timecount,
58 0,
59 0xffffff,
60 3579545,
61 "GSCPM",
62 1000
63 };
64 #endif
65
66 struct cfattach gscpm_ca = {
67 sizeof (struct gscpm_softc),
68 gscpm_match,
69 gscpm_attach
70 };
71
72 struct cfdriver gscpm_cd = {
73 NULL, "gscpm", DV_DULL
74 };
75
76 #if 0
77 static void *gscpm_cookie;
78 #endif
79
80 int
81 gscpm_match(struct device *parent, void *match, void *aux)
82 {
83 struct pci_attach_args *pa = aux;
84
85 if (PCI_VENDOR(pa->pa_id) == PCI_VENDOR_NS &&
86 PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_NS_SC1100_SMI)
87 return (1);
88
89 return (0);
90 }
91
92 void
93 gscpm_attach(struct device *parent, struct device *self, void *aux)
94 {
95 struct gscpm_softc *sc = (struct gscpm_softc *)self;
96 struct pci_attach_args *pa = aux;
97 pcireg_t csr, acpibase;
98
99 sc->sc_pc = pa->pa_pc;
100 sc->sc_tag = pa->pa_tag;
101 sc->sc_iot = pa->pa_iot;
102
103
104 csr = pci_conf_read(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG);
105 pci_conf_write(sc->sc_pc, sc->sc_tag, PCI_COMMAND_STATUS_REG,
106 csr | PCI_COMMAND_IO_ENABLE);
107
108
109 acpibase = pci_conf_read(sc->sc_pc, sc->sc_tag, GSCPM_ACPIBASE);
110 if (PCI_MAPREG_IO_ADDR(acpibase) == 0 ||
111 bus_space_map(sc->sc_iot, PCI_MAPREG_IO_ADDR(acpibase),
112 GSCPM_ACPISIZE, 0, &sc->sc_acpi_ioh)) {
113 printf(": failed to map ACPI registers\n");
114 return;
115 }
116
117 printf("\n");
118
119 #ifdef __HAVE_TIMECOUNTER
120
121 gscpm_timecounter.tc_priv = sc;
122 tc_init(&gscpm_timecounter);
123 #endif
124
125
126 #if 0
127
128 gscpm_cookie = sc;
129 cpu_setperf = gscpm_setperf;
130 #endif
131
132 }
133
134 #ifdef __HAVE_TIMECOUNTER
135 u_int
136 gscpm_get_timecount(struct timecounter *tc)
137 {
138 struct gscpm_softc *sc = tc->tc_priv;
139
140 return (bus_space_read_4(sc->sc_iot, sc->sc_acpi_ioh, GSCPM_PM_TMR));
141 }
142 #endif
143
144 #if 0
145 void
146 gscpm_setperf(int level)
147 {
148 struct gscpm_softc *sc = gscpm_cookie;
149 int i;
150 u_int32_t pctl;
151
152 pctl = bus_space_read_4(sc->sc_iot, sc->sc_acpi_ioh, GSCPM_P_CNT);
153
154 if (level == 100) {
155
156 pctl &= ~GSCPM_P_CNT_THTEN;
157 } else {
158 for (i = 0; i < GSCPM_THT_LEVELS; i++)
159 if (level >= gscpm_tht[i].level)
160 break;
161 pctl = (0xf0 | GSCPM_P_CNT_THTEN |
162 GSCPM_P_CNT_CLK(gscpm_tht[i].value));
163 }
164
165
166 bus_space_write_4(sc->sc_iot, sc->sc_acpi_ioh, GSCPM_P_CNT, pctl);
167 }
168 #endif