ichlpcib.c revision 1.6 1 1.6 jmcneill /* $NetBSD: ichlpcib.c,v 1.6 2007/12/09 20:27:49 jmcneill Exp $ */
2 1.1 xtraeme
3 1.1 xtraeme /*-
4 1.1 xtraeme * Copyright (c) 2004 The NetBSD Foundation, Inc.
5 1.1 xtraeme * All rights reserved.
6 1.1 xtraeme *
7 1.1 xtraeme * This code is derived from software contributed to The NetBSD Foundation
8 1.1 xtraeme * by Minoura Makoto and Matthew R. Green.
9 1.1 xtraeme *
10 1.1 xtraeme * Redistribution and use in source and binary forms, with or without
11 1.1 xtraeme * modification, are permitted provided that the following conditions
12 1.1 xtraeme * are met:
13 1.1 xtraeme * 1. Redistributions of source code must retain the above copyright
14 1.1 xtraeme * notice, this list of conditions and the following disclaimer.
15 1.1 xtraeme * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 xtraeme * notice, this list of conditions and the following disclaimer in the
17 1.1 xtraeme * documentation and/or other materials provided with the distribution.
18 1.1 xtraeme * 3. All advertising materials mentioning features or use of this software
19 1.1 xtraeme * must display the following acknowledgement:
20 1.1 xtraeme * This product includes software developed by the NetBSD
21 1.1 xtraeme * Foundation, Inc. and its contributors.
22 1.1 xtraeme * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 xtraeme * contributors may be used to endorse or promote products derived
24 1.1 xtraeme * from this software without specific prior written permission.
25 1.1 xtraeme *
26 1.1 xtraeme * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 xtraeme * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 xtraeme * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 xtraeme * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 xtraeme * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 xtraeme * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 xtraeme * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 xtraeme * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 xtraeme * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 xtraeme * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 xtraeme * POSSIBILITY OF SUCH DAMAGE.
37 1.1 xtraeme */
38 1.1 xtraeme
39 1.1 xtraeme /*
40 1.1 xtraeme * Intel I/O Controller Hub (ICHn) LPC Interface Bridge driver
41 1.1 xtraeme *
42 1.1 xtraeme * LPC Interface Bridge is basically a pcib (PCI-ISA Bridge), but has
43 1.1 xtraeme * some power management and monitoring functions.
44 1.1 xtraeme * Currently we support the watchdog timer, SpeedStep (on some systems)
45 1.1 xtraeme * and the power management timer.
46 1.1 xtraeme */
47 1.1 xtraeme
48 1.1 xtraeme #include <sys/cdefs.h>
49 1.6 jmcneill __KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.6 2007/12/09 20:27:49 jmcneill Exp $");
50 1.1 xtraeme
51 1.1 xtraeme #include <sys/types.h>
52 1.1 xtraeme #include <sys/param.h>
53 1.1 xtraeme #include <sys/systm.h>
54 1.1 xtraeme #include <sys/device.h>
55 1.1 xtraeme #include <sys/sysctl.h>
56 1.6 jmcneill #include <sys/timetc.h>
57 1.1 xtraeme #include <machine/bus.h>
58 1.1 xtraeme
59 1.1 xtraeme #include <dev/pci/pcivar.h>
60 1.1 xtraeme #include <dev/pci/pcireg.h>
61 1.1 xtraeme #include <dev/pci/pcidevs.h>
62 1.1 xtraeme
63 1.1 xtraeme #include <dev/sysmon/sysmonvar.h>
64 1.1 xtraeme
65 1.6 jmcneill #include <dev/ic/acpipmtimer.h>
66 1.1 xtraeme #include <dev/ic/i82801lpcreg.h>
67 1.6 jmcneill #include <dev/ic/hpetreg.h>
68 1.6 jmcneill #include <dev/ic/hpetvar.h>
69 1.6 jmcneill
70 1.6 jmcneill #include "hpet.h"
71 1.1 xtraeme
72 1.1 xtraeme struct lpcib_softc {
73 1.1 xtraeme /* Device object. */
74 1.1 xtraeme struct device sc_dev;
75 1.1 xtraeme
76 1.1 xtraeme pci_chipset_tag_t sc_pc;
77 1.1 xtraeme pcitag_t sc_pcitag;
78 1.1 xtraeme
79 1.6 jmcneill struct pci_attach_args sc_pa;
80 1.6 jmcneill int sc_has_rcba;
81 1.6 jmcneill int sc_has_ich5_hpet;
82 1.6 jmcneill
83 1.6 jmcneill /* RCBA */
84 1.6 jmcneill bus_space_tag_t sc_rcbat;
85 1.6 jmcneill bus_space_handle_t sc_rcbah;
86 1.6 jmcneill pcireg_t sc_rcba_reg;
87 1.6 jmcneill
88 1.1 xtraeme /* Watchdog variables. */
89 1.1 xtraeme struct sysmon_wdog sc_smw;
90 1.1 xtraeme bus_space_tag_t sc_iot;
91 1.1 xtraeme bus_space_handle_t sc_ioh;
92 1.6 jmcneill
93 1.6 jmcneill #if NHPET > 0
94 1.6 jmcneill /* HPET variables. */
95 1.6 jmcneill uint32_t sc_hpet_reg;
96 1.6 jmcneill #endif
97 1.6 jmcneill
98 1.1 xtraeme /* Power management */
99 1.1 xtraeme pcireg_t sc_pirq[8];
100 1.6 jmcneill pcireg_t sc_pmcon;
101 1.6 jmcneill pcireg_t sc_fwhsel2;
102 1.1 xtraeme };
103 1.1 xtraeme
104 1.1 xtraeme static int lpcibmatch(struct device *, struct cfdata *, void *);
105 1.1 xtraeme static void lpcibattach(struct device *, struct device *, void *);
106 1.6 jmcneill static bool lpcib_suspend(device_t);
107 1.6 jmcneill static bool lpcib_resume(device_t);
108 1.1 xtraeme
109 1.6 jmcneill static void pmtimer_configure(struct lpcib_softc *);
110 1.1 xtraeme
111 1.6 jmcneill static void tcotimer_configure(struct lpcib_softc *);
112 1.1 xtraeme static int tcotimer_setmode(struct sysmon_wdog *);
113 1.1 xtraeme static int tcotimer_tickle(struct sysmon_wdog *);
114 1.1 xtraeme static void tcotimer_stop(struct lpcib_softc *);
115 1.1 xtraeme static void tcotimer_start(struct lpcib_softc *);
116 1.1 xtraeme static void tcotimer_status_reset(struct lpcib_softc *);
117 1.6 jmcneill static int tcotimer_disable_noreboot(struct lpcib_softc *);
118 1.1 xtraeme
119 1.6 jmcneill static void speedstep_configure(struct lpcib_softc *);
120 1.1 xtraeme static int speedstep_sysctl_helper(SYSCTLFN_ARGS);
121 1.1 xtraeme
122 1.6 jmcneill #if NHPET > 0
123 1.6 jmcneill static void lpcib_hpet_configure(struct lpcib_softc *);
124 1.6 jmcneill #endif
125 1.6 jmcneill
126 1.1 xtraeme struct lpcib_softc *speedstep_cookie; /* XXX */
127 1.1 xtraeme
128 1.1 xtraeme /* Defined in arch/.../pci/pcib.c. */
129 1.1 xtraeme extern void pcibattach(struct device *, struct device *, void *);
130 1.1 xtraeme
131 1.1 xtraeme CFATTACH_DECL(ichlpcib, sizeof(struct lpcib_softc),
132 1.1 xtraeme lpcibmatch, lpcibattach, NULL, NULL);
133 1.1 xtraeme
134 1.6 jmcneill static struct lpcib_device {
135 1.6 jmcneill pcireg_t vendor, product;
136 1.6 jmcneill int has_rcba;
137 1.6 jmcneill int has_ich5_hpet;
138 1.6 jmcneill } lpcib_devices[] = {
139 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801AA_LPC, 0, 0 },
140 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BA_LPC, 0, 0 },
141 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801BAM_LPC, 0, 0 },
142 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CA_LPC, 0, 0 },
143 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801CAM_LPC, 0, 0 },
144 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_LPC, 0, 0 },
145 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801DB_ISA, 0, 0 },
146 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801EB_LPC, 0, 1 },
147 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FB_LPC, 1, 0 },
148 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801FBM_LPC, 1, 0 },
149 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801G_LPC, 1, 0 },
150 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GBM_LPC, 1, 0 },
151 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801GHM_LPC, 1, 0 },
152 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801H_LPC, 1, 0 },
153 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HEM_LPC, 1, 0 },
154 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HH_LPC, 1, 0 },
155 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HO_LPC, 1, 0 },
156 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801HBM_LPC, 1, 0 },
157 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IH_LPC, 1, 0 },
158 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IO_LPC, 1, 0 },
159 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IR_LPC, 1, 0 },
160 1.6 jmcneill { PCI_VENDOR_INTEL, PCI_PRODUCT_INTEL_82801IB_LPC, 1, 0 },
161 1.6 jmcneill { 0, 0, 0, 0 },
162 1.6 jmcneill };
163 1.6 jmcneill
164 1.1 xtraeme /*
165 1.1 xtraeme * Autoconf callbacks.
166 1.1 xtraeme */
167 1.1 xtraeme static int
168 1.1 xtraeme lpcibmatch(struct device *parent, struct cfdata *match, void *aux)
169 1.1 xtraeme {
170 1.1 xtraeme struct pci_attach_args *pa = aux;
171 1.6 jmcneill struct lpcib_device *lpcib_dev;
172 1.1 xtraeme
173 1.1 xtraeme /* We are ISA bridge, of course */
174 1.1 xtraeme if (PCI_CLASS(pa->pa_class) != PCI_CLASS_BRIDGE ||
175 1.1 xtraeme PCI_SUBCLASS(pa->pa_class) != PCI_SUBCLASS_BRIDGE_ISA)
176 1.1 xtraeme return 0;
177 1.1 xtraeme
178 1.6 jmcneill for (lpcib_dev = lpcib_devices; lpcib_dev->vendor; ++lpcib_dev) {
179 1.6 jmcneill if (PCI_VENDOR(pa->pa_id) == lpcib_dev->vendor &&
180 1.6 jmcneill PCI_PRODUCT(pa->pa_id) == lpcib_dev->product)
181 1.1 xtraeme return 10;
182 1.1 xtraeme }
183 1.1 xtraeme
184 1.1 xtraeme return 0;
185 1.1 xtraeme }
186 1.1 xtraeme
187 1.1 xtraeme static void
188 1.1 xtraeme lpcibattach(struct device *parent, struct device *self, void *aux)
189 1.1 xtraeme {
190 1.1 xtraeme struct pci_attach_args *pa = aux;
191 1.6 jmcneill struct lpcib_softc *sc = device_private(self);
192 1.6 jmcneill struct lpcib_device *lpcib_dev;
193 1.1 xtraeme
194 1.1 xtraeme sc->sc_pc = pa->pa_pc;
195 1.1 xtraeme sc->sc_pcitag = pa->pa_tag;
196 1.6 jmcneill sc->sc_pa = *pa;
197 1.6 jmcneill
198 1.6 jmcneill for (lpcib_dev = lpcib_devices; lpcib_dev->vendor; ++lpcib_dev) {
199 1.6 jmcneill if (PCI_VENDOR(pa->pa_id) != lpcib_dev->vendor ||
200 1.6 jmcneill PCI_PRODUCT(pa->pa_id) != lpcib_dev->product)
201 1.6 jmcneill continue;
202 1.6 jmcneill sc->sc_has_rcba = lpcib_dev->has_rcba;
203 1.6 jmcneill sc->sc_has_ich5_hpet = lpcib_dev->has_ich5_hpet;
204 1.6 jmcneill break;
205 1.6 jmcneill }
206 1.1 xtraeme
207 1.1 xtraeme pcibattach(parent, self, aux);
208 1.1 xtraeme
209 1.1 xtraeme /*
210 1.1 xtraeme * Part of our I/O registers are used as ACPI PM regs.
211 1.1 xtraeme * Since our ACPI subsystem accesses the I/O space directly so far,
212 1.1 xtraeme * we do not have to bother bus_space I/O map confliction.
213 1.1 xtraeme */
214 1.1 xtraeme if (pci_mapreg_map(pa, LPCIB_PCI_PMBASE, PCI_MAPREG_TYPE_IO, 0,
215 1.1 xtraeme &sc->sc_iot, &sc->sc_ioh, NULL, NULL)) {
216 1.1 xtraeme aprint_error("%s: can't map power management i/o space",
217 1.1 xtraeme sc->sc_dev.dv_xname);
218 1.1 xtraeme return;
219 1.1 xtraeme }
220 1.1 xtraeme
221 1.6 jmcneill /* For ICH6 and later, always enable RCBA */
222 1.6 jmcneill if (sc->sc_has_rcba) {
223 1.6 jmcneill pcireg_t rcba;
224 1.6 jmcneill
225 1.6 jmcneill sc->sc_rcbat = sc->sc_pa.pa_memt;
226 1.6 jmcneill
227 1.6 jmcneill rcba = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_RCBA);
228 1.6 jmcneill if ((rcba & LPCIB_RCBA_EN) == 0) {
229 1.6 jmcneill aprint_error("%s: RCBA is not enabled",
230 1.6 jmcneill sc->sc_dev.dv_xname);
231 1.6 jmcneill return;
232 1.6 jmcneill }
233 1.6 jmcneill rcba &= ~LPCIB_RCBA_EN;
234 1.6 jmcneill
235 1.6 jmcneill if (bus_space_map(sc->sc_rcbat, rcba, LPCIB_RCBA_SIZE, 0,
236 1.6 jmcneill &sc->sc_rcbah)) {
237 1.6 jmcneill aprint_error("%s: RCBA could not be mapped",
238 1.6 jmcneill sc->sc_dev.dv_xname);
239 1.6 jmcneill return;
240 1.6 jmcneill }
241 1.6 jmcneill }
242 1.6 jmcneill
243 1.1 xtraeme /* Set up the power management timer. */
244 1.6 jmcneill pmtimer_configure(sc);
245 1.1 xtraeme
246 1.1 xtraeme /* Set up the TCO (watchdog). */
247 1.6 jmcneill tcotimer_configure(sc);
248 1.1 xtraeme
249 1.1 xtraeme /* Set up SpeedStep. */
250 1.6 jmcneill speedstep_configure(sc);
251 1.1 xtraeme
252 1.6 jmcneill #if NHPET > 0
253 1.6 jmcneill /* Set up HPET. */
254 1.6 jmcneill lpcib_hpet_configure(sc);
255 1.6 jmcneill #endif
256 1.6 jmcneill
257 1.6 jmcneill /* Install power handler */
258 1.6 jmcneill if (!pmf_device_register(self, lpcib_suspend, lpcib_resume))
259 1.6 jmcneill aprint_error_dev(self, "couldn't establish power handler\n");
260 1.6 jmcneill }
261 1.6 jmcneill
262 1.6 jmcneill static bool
263 1.6 jmcneill lpcib_suspend(device_t dv)
264 1.6 jmcneill {
265 1.6 jmcneill struct lpcib_softc *sc = device_private(dv);
266 1.6 jmcneill pci_chipset_tag_t pc = sc->sc_pc;
267 1.6 jmcneill pcitag_t tag = sc->sc_pcitag;
268 1.6 jmcneill
269 1.6 jmcneill /* capture PIRQ routing control registers */
270 1.6 jmcneill sc->sc_pirq[0] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQA_ROUT);
271 1.6 jmcneill sc->sc_pirq[1] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQB_ROUT);
272 1.6 jmcneill sc->sc_pirq[2] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQC_ROUT);
273 1.6 jmcneill sc->sc_pirq[3] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQD_ROUT);
274 1.6 jmcneill sc->sc_pirq[4] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQE_ROUT);
275 1.6 jmcneill sc->sc_pirq[5] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQF_ROUT);
276 1.6 jmcneill sc->sc_pirq[6] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQG_ROUT);
277 1.6 jmcneill sc->sc_pirq[7] = pci_conf_read(pc, tag, LPCIB_PCI_PIRQH_ROUT);
278 1.6 jmcneill
279 1.6 jmcneill sc->sc_pmcon = pci_conf_read(pc, tag, LPCIB_PCI_GEN_PMCON_1);
280 1.6 jmcneill sc->sc_fwhsel2 = pci_conf_read(pc, tag, LPCIB_PCI_GEN_STA);
281 1.6 jmcneill
282 1.6 jmcneill if (sc->sc_has_rcba) {
283 1.6 jmcneill sc->sc_rcba_reg = pci_conf_read(pc, tag, LPCIB_RCBA);
284 1.6 jmcneill #if NHPET > 0
285 1.6 jmcneill sc->sc_hpet_reg = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah,
286 1.6 jmcneill LPCIB_RCBA_HPTC);
287 1.6 jmcneill #endif
288 1.6 jmcneill } else if (sc->sc_has_ich5_hpet) {
289 1.6 jmcneill #if NHPET > 0
290 1.6 jmcneill sc->sc_hpet_reg = pci_conf_read(pc, tag, LPCIB_PCI_GEN_CNTL);
291 1.6 jmcneill #endif
292 1.6 jmcneill }
293 1.6 jmcneill
294 1.6 jmcneill return true;
295 1.6 jmcneill }
296 1.6 jmcneill
297 1.6 jmcneill static bool
298 1.6 jmcneill lpcib_resume(device_t dv)
299 1.6 jmcneill {
300 1.6 jmcneill struct lpcib_softc *sc = device_private(dv);
301 1.6 jmcneill pci_chipset_tag_t pc = sc->sc_pc;
302 1.6 jmcneill pcitag_t tag = sc->sc_pcitag;
303 1.6 jmcneill
304 1.6 jmcneill /* restore PIRQ routing control registers */
305 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQA_ROUT, sc->sc_pirq[0]);
306 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQB_ROUT, sc->sc_pirq[1]);
307 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQC_ROUT, sc->sc_pirq[2]);
308 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQD_ROUT, sc->sc_pirq[3]);
309 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQE_ROUT, sc->sc_pirq[4]);
310 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQF_ROUT, sc->sc_pirq[5]);
311 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQG_ROUT, sc->sc_pirq[6]);
312 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_PIRQH_ROUT, sc->sc_pirq[7]);
313 1.6 jmcneill
314 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_GEN_PMCON_1, sc->sc_pmcon);
315 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_GEN_STA, sc->sc_fwhsel2);
316 1.6 jmcneill
317 1.6 jmcneill if (sc->sc_has_rcba) {
318 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_RCBA, sc->sc_rcba_reg);
319 1.6 jmcneill #if NHPET > 0
320 1.6 jmcneill bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_RCBA_HPTC,
321 1.6 jmcneill sc->sc_hpet_reg);
322 1.6 jmcneill #endif
323 1.6 jmcneill } else if (sc->sc_has_ich5_hpet) {
324 1.6 jmcneill #if NHPET > 0
325 1.6 jmcneill pci_conf_write(pc, tag, LPCIB_PCI_GEN_CNTL, sc->sc_hpet_reg);
326 1.6 jmcneill #endif
327 1.6 jmcneill }
328 1.1 xtraeme
329 1.6 jmcneill return true;
330 1.1 xtraeme }
331 1.1 xtraeme
332 1.1 xtraeme /*
333 1.1 xtraeme * Initialize the power management timer.
334 1.1 xtraeme */
335 1.1 xtraeme static void
336 1.6 jmcneill pmtimer_configure(struct lpcib_softc *sc)
337 1.1 xtraeme {
338 1.1 xtraeme pcireg_t control;
339 1.1 xtraeme
340 1.1 xtraeme /*
341 1.1 xtraeme * Check if power management I/O space is enabled and enable the ACPI_EN
342 1.1 xtraeme * bit if it's disabled.
343 1.1 xtraeme */
344 1.6 jmcneill control = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_ACPI_CNTL);
345 1.1 xtraeme if ((control & LPCIB_PCI_ACPI_CNTL_EN) == 0) {
346 1.1 xtraeme control |= LPCIB_PCI_ACPI_CNTL_EN;
347 1.6 jmcneill pci_conf_write(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_ACPI_CNTL,
348 1.1 xtraeme control);
349 1.1 xtraeme }
350 1.1 xtraeme
351 1.1 xtraeme /* Attach our PM timer with the generic acpipmtimer function */
352 1.1 xtraeme acpipmtimer_attach(&sc->sc_dev, sc->sc_iot, sc->sc_ioh,
353 1.1 xtraeme LPCIB_PM1_TMR, 0);
354 1.1 xtraeme }
355 1.1 xtraeme
356 1.1 xtraeme /*
357 1.1 xtraeme * Initialize the watchdog timer.
358 1.1 xtraeme */
359 1.1 xtraeme static void
360 1.6 jmcneill tcotimer_configure(struct lpcib_softc *sc)
361 1.1 xtraeme {
362 1.1 xtraeme uint32_t ioreg;
363 1.1 xtraeme unsigned int period;
364 1.1 xtraeme
365 1.1 xtraeme /*
366 1.4 xtraeme * Clear the No Reboot (NR) bit. If this fails, enabling the TCO_EN bit
367 1.1 xtraeme * in the SMI_EN register is the last chance.
368 1.1 xtraeme */
369 1.6 jmcneill if (tcotimer_disable_noreboot(sc)) {
370 1.1 xtraeme ioreg = bus_space_read_4(sc->sc_iot, sc->sc_ioh, LPCIB_SMI_EN);
371 1.1 xtraeme ioreg |= LPCIB_SMI_EN_TCO_EN;
372 1.1 xtraeme bus_space_write_4(sc->sc_iot, sc->sc_ioh, LPCIB_SMI_EN, ioreg);
373 1.1 xtraeme }
374 1.1 xtraeme
375 1.1 xtraeme /* Reset the watchdog status registers. */
376 1.1 xtraeme tcotimer_status_reset(sc);
377 1.1 xtraeme
378 1.1 xtraeme /* Explicitly stop the TCO timer. */
379 1.1 xtraeme tcotimer_stop(sc);
380 1.1 xtraeme
381 1.1 xtraeme /*
382 1.1 xtraeme * Register the driver with the sysmon watchdog framework.
383 1.1 xtraeme */
384 1.1 xtraeme sc->sc_smw.smw_name = sc->sc_dev.dv_xname;
385 1.1 xtraeme sc->sc_smw.smw_cookie = sc;
386 1.1 xtraeme sc->sc_smw.smw_setmode = tcotimer_setmode;
387 1.1 xtraeme sc->sc_smw.smw_tickle = tcotimer_tickle;
388 1.6 jmcneill if (sc->sc_has_rcba)
389 1.1 xtraeme period = LPCIB_TCOTIMER2_MAX_TICK;
390 1.1 xtraeme else
391 1.1 xtraeme period = LPCIB_TCOTIMER_MAX_TICK;
392 1.1 xtraeme sc->sc_smw.smw_period = lpcib_tcotimer_tick_to_second(period);
393 1.1 xtraeme
394 1.1 xtraeme if (sysmon_wdog_register(&sc->sc_smw)) {
395 1.1 xtraeme aprint_error("%s: unable to register TCO timer"
396 1.1 xtraeme "as a sysmon watchdog device.\n",
397 1.1 xtraeme sc->sc_dev.dv_xname);
398 1.1 xtraeme return;
399 1.1 xtraeme }
400 1.1 xtraeme
401 1.1 xtraeme aprint_verbose("%s: TCO (watchdog) timer configured.\n",
402 1.1 xtraeme sc->sc_dev.dv_xname);
403 1.1 xtraeme }
404 1.1 xtraeme
405 1.1 xtraeme /*
406 1.1 xtraeme * Sysmon watchdog callbacks.
407 1.1 xtraeme */
408 1.1 xtraeme static int
409 1.1 xtraeme tcotimer_setmode(struct sysmon_wdog *smw)
410 1.1 xtraeme {
411 1.1 xtraeme struct lpcib_softc *sc = smw->smw_cookie;
412 1.1 xtraeme unsigned int period;
413 1.1 xtraeme uint16_t ich6period = 0;
414 1.1 xtraeme
415 1.1 xtraeme if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
416 1.1 xtraeme /* Stop the TCO timer. */
417 1.1 xtraeme tcotimer_stop(sc);
418 1.1 xtraeme } else {
419 1.1 xtraeme /*
420 1.6 jmcneill * ICH6 or newer are limited to 2s min and 613s max.
421 1.1 xtraeme * ICH5 or older are limited to 4s min and 39s max.
422 1.1 xtraeme */
423 1.6 jmcneill if (sc->sc_has_rcba) {
424 1.6 jmcneill if (smw->smw_period < LPCIB_TCOTIMER2_MIN_TICK ||
425 1.6 jmcneill smw->smw_period > LPCIB_TCOTIMER2_MAX_TICK)
426 1.6 jmcneill return EINVAL;
427 1.6 jmcneill } else {
428 1.5 xtraeme if (smw->smw_period < LPCIB_TCOTIMER_MIN_TICK ||
429 1.5 xtraeme smw->smw_period > LPCIB_TCOTIMER_MAX_TICK)
430 1.1 xtraeme return EINVAL;
431 1.1 xtraeme }
432 1.5 xtraeme period = lpcib_tcotimer_second_to_tick(smw->smw_period);
433 1.5 xtraeme
434 1.1 xtraeme /* Stop the TCO timer, */
435 1.1 xtraeme tcotimer_stop(sc);
436 1.1 xtraeme
437 1.1 xtraeme /* set the timeout, */
438 1.6 jmcneill if (sc->sc_has_rcba) {
439 1.1 xtraeme /* ICH6 or newer */
440 1.1 xtraeme ich6period = bus_space_read_2(sc->sc_iot, sc->sc_ioh,
441 1.1 xtraeme LPCIB_TCO_TMR2);
442 1.1 xtraeme ich6period &= 0xfc00;
443 1.1 xtraeme bus_space_write_2(sc->sc_iot, sc->sc_ioh,
444 1.1 xtraeme LPCIB_TCO_TMR2, ich6period | period);
445 1.1 xtraeme } else {
446 1.1 xtraeme /* ICH5 or older */
447 1.1 xtraeme period |= bus_space_read_1(sc->sc_iot, sc->sc_ioh,
448 1.1 xtraeme LPCIB_TCO_TMR);
449 1.1 xtraeme period &= 0xc0;
450 1.1 xtraeme bus_space_write_1(sc->sc_iot, sc->sc_ioh,
451 1.1 xtraeme LPCIB_TCO_TMR, period);
452 1.1 xtraeme }
453 1.1 xtraeme
454 1.1 xtraeme /* and start/reload the timer. */
455 1.1 xtraeme tcotimer_start(sc);
456 1.1 xtraeme tcotimer_tickle(smw);
457 1.1 xtraeme }
458 1.1 xtraeme
459 1.1 xtraeme return 0;
460 1.1 xtraeme }
461 1.1 xtraeme
462 1.1 xtraeme static int
463 1.1 xtraeme tcotimer_tickle(struct sysmon_wdog *smw)
464 1.1 xtraeme {
465 1.1 xtraeme struct lpcib_softc *sc = smw->smw_cookie;
466 1.1 xtraeme
467 1.1 xtraeme /* any value is allowed */
468 1.6 jmcneill if (sc->sc_has_rcba)
469 1.6 jmcneill bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_RLD, 1);
470 1.6 jmcneill else
471 1.1 xtraeme bus_space_write_1(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_RLD, 1);
472 1.1 xtraeme
473 1.1 xtraeme return 0;
474 1.1 xtraeme }
475 1.1 xtraeme
476 1.1 xtraeme static void
477 1.1 xtraeme tcotimer_stop(struct lpcib_softc *sc)
478 1.1 xtraeme {
479 1.1 xtraeme uint16_t ioreg;
480 1.1 xtraeme
481 1.1 xtraeme ioreg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO1_CNT);
482 1.1 xtraeme ioreg |= LPCIB_TCO1_CNT_TCO_TMR_HLT;
483 1.1 xtraeme bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO1_CNT, ioreg);
484 1.1 xtraeme }
485 1.1 xtraeme
486 1.1 xtraeme static void
487 1.1 xtraeme tcotimer_start(struct lpcib_softc *sc)
488 1.1 xtraeme {
489 1.1 xtraeme uint16_t ioreg;
490 1.1 xtraeme
491 1.1 xtraeme ioreg = bus_space_read_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO1_CNT);
492 1.1 xtraeme ioreg &= ~LPCIB_TCO1_CNT_TCO_TMR_HLT;
493 1.1 xtraeme bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO1_CNT, ioreg);
494 1.1 xtraeme }
495 1.1 xtraeme
496 1.1 xtraeme static void
497 1.1 xtraeme tcotimer_status_reset(struct lpcib_softc *sc)
498 1.1 xtraeme {
499 1.1 xtraeme bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO1_STS,
500 1.1 xtraeme LPCIB_TCO1_STS_TIMEOUT);
501 1.1 xtraeme bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO2_STS,
502 1.1 xtraeme LPCIB_TCO2_STS_BOOT_STS);
503 1.1 xtraeme bus_space_write_2(sc->sc_iot, sc->sc_ioh, LPCIB_TCO2_STS,
504 1.1 xtraeme LPCIB_TCO2_STS_SECONDS_TO_STS);
505 1.1 xtraeme }
506 1.1 xtraeme
507 1.1 xtraeme /*
508 1.4 xtraeme * Clear the No Reboot (NR) bit, this enables reboots when the timer
509 1.4 xtraeme * reaches the timeout for the second time.
510 1.1 xtraeme */
511 1.1 xtraeme static int
512 1.6 jmcneill tcotimer_disable_noreboot(struct lpcib_softc *sc)
513 1.1 xtraeme {
514 1.1 xtraeme
515 1.6 jmcneill if (sc->sc_has_rcba) {
516 1.6 jmcneill uint32_t status;
517 1.6 jmcneill
518 1.6 jmcneill status = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_GCS_OFFSET);
519 1.6 jmcneill status &= ~LPCIB_GCS_NO_REBOOT;
520 1.6 jmcneill bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_GCS_OFFSET, status);
521 1.6 jmcneill status = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_GCS_OFFSET);
522 1.6 jmcneill if (status & LPCIB_GCS_NO_REBOOT)
523 1.6 jmcneill goto error;
524 1.6 jmcneill } else {
525 1.6 jmcneill pcireg_t pcireg;
526 1.6 jmcneill
527 1.1 xtraeme pcireg = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
528 1.1 xtraeme LPCIB_PCI_GEN_STA);
529 1.1 xtraeme if (pcireg & LPCIB_PCI_GEN_STA_NO_REBOOT) {
530 1.1 xtraeme /* TCO timeout reset is disabled; try to enable it */
531 1.1 xtraeme pcireg &= ~LPCIB_PCI_GEN_STA_NO_REBOOT;
532 1.1 xtraeme pci_conf_write(sc->sc_pc, sc->sc_pcitag,
533 1.1 xtraeme LPCIB_PCI_GEN_STA, pcireg);
534 1.1 xtraeme if (pcireg & LPCIB_PCI_GEN_STA_NO_REBOOT)
535 1.1 xtraeme goto error;
536 1.1 xtraeme }
537 1.1 xtraeme }
538 1.1 xtraeme
539 1.1 xtraeme return 0;
540 1.1 xtraeme error:
541 1.1 xtraeme aprint_error("%s: TCO timer reboot disabled by hardware; "
542 1.1 xtraeme "hope SMBIOS properly handles it.\n", sc->sc_dev.dv_xname);
543 1.1 xtraeme return EINVAL;
544 1.1 xtraeme }
545 1.1 xtraeme
546 1.1 xtraeme
547 1.1 xtraeme /*
548 1.1 xtraeme * Intel ICH SpeedStep support.
549 1.1 xtraeme */
550 1.1 xtraeme #define SS_READ(sc, reg) \
551 1.1 xtraeme bus_space_read_1((sc)->sc_iot, (sc)->sc_ioh, (reg))
552 1.1 xtraeme #define SS_WRITE(sc, reg, val) \
553 1.1 xtraeme bus_space_write_1((sc)->sc_iot, (sc)->sc_ioh, (reg), (val))
554 1.1 xtraeme
555 1.1 xtraeme /*
556 1.1 xtraeme * Linux driver says that SpeedStep on older chipsets cause
557 1.1 xtraeme * lockups on Dell Inspiron 8000 and 8100.
558 1.1 xtraeme */
559 1.1 xtraeme static int
560 1.1 xtraeme speedstep_bad_hb_check(struct pci_attach_args *pa)
561 1.1 xtraeme {
562 1.1 xtraeme
563 1.1 xtraeme if (PCI_PRODUCT(pa->pa_id) == PCI_PRODUCT_INTEL_82815_FULL_HUB &&
564 1.1 xtraeme PCI_REVISION(pa->pa_class) < 5)
565 1.1 xtraeme return 1;
566 1.1 xtraeme
567 1.1 xtraeme return 0;
568 1.1 xtraeme }
569 1.1 xtraeme
570 1.1 xtraeme static void
571 1.6 jmcneill speedstep_configure(struct lpcib_softc *sc)
572 1.1 xtraeme {
573 1.1 xtraeme const struct sysctlnode *node, *ssnode;
574 1.1 xtraeme int rv;
575 1.1 xtraeme
576 1.1 xtraeme /* Supported on ICH2-M, ICH3-M and ICH4-M. */
577 1.6 jmcneill if (PCI_PRODUCT(sc->sc_pa.pa_id) == PCI_PRODUCT_INTEL_82801DB_ISA ||
578 1.6 jmcneill PCI_PRODUCT(sc->sc_pa.pa_id) == PCI_PRODUCT_INTEL_82801CAM_LPC ||
579 1.6 jmcneill (PCI_PRODUCT(sc->sc_pa.pa_id) == PCI_PRODUCT_INTEL_82801BAM_LPC &&
580 1.6 jmcneill pci_find_device(&sc->sc_pa, speedstep_bad_hb_check) == 0)) {
581 1.1 xtraeme uint8_t pmcon;
582 1.1 xtraeme
583 1.1 xtraeme /* Enable SpeedStep if it isn't already enabled. */
584 1.6 jmcneill pmcon = pci_conf_read(sc->sc_pc, sc->sc_pcitag,
585 1.1 xtraeme LPCIB_PCI_GEN_PMCON_1);
586 1.1 xtraeme if ((pmcon & LPCIB_PCI_GEN_PMCON_1_SS_EN) == 0)
587 1.6 jmcneill pci_conf_write(sc->sc_pc, sc->sc_pcitag,
588 1.1 xtraeme LPCIB_PCI_GEN_PMCON_1,
589 1.1 xtraeme pmcon | LPCIB_PCI_GEN_PMCON_1_SS_EN);
590 1.1 xtraeme
591 1.1 xtraeme /* Put in machdep.speedstep_state (0 for low, 1 for high). */
592 1.1 xtraeme if ((rv = sysctl_createv(NULL, 0, NULL, &node,
593 1.1 xtraeme CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
594 1.1 xtraeme NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL)) != 0)
595 1.1 xtraeme goto err;
596 1.1 xtraeme
597 1.1 xtraeme /* CTLFLAG_ANYWRITE? kernel option like EST? */
598 1.1 xtraeme if ((rv = sysctl_createv(NULL, 0, &node, &ssnode,
599 1.1 xtraeme CTLFLAG_READWRITE, CTLTYPE_INT, "speedstep_state", NULL,
600 1.1 xtraeme speedstep_sysctl_helper, 0, NULL, 0, CTL_CREATE,
601 1.1 xtraeme CTL_EOL)) != 0)
602 1.1 xtraeme goto err;
603 1.1 xtraeme
604 1.1 xtraeme /* XXX save the sc for IO tag/handle */
605 1.1 xtraeme speedstep_cookie = sc;
606 1.1 xtraeme aprint_verbose("%s: SpeedStep enabled\n", sc->sc_dev.dv_xname);
607 1.1 xtraeme }
608 1.1 xtraeme
609 1.1 xtraeme return;
610 1.1 xtraeme
611 1.1 xtraeme err:
612 1.1 xtraeme aprint_normal("%s: sysctl_createv failed (rv = %d)\n", __func__, rv);
613 1.1 xtraeme }
614 1.1 xtraeme
615 1.1 xtraeme /*
616 1.1 xtraeme * get/set the SpeedStep state: 0 == low power, 1 == high power.
617 1.1 xtraeme */
618 1.1 xtraeme static int
619 1.1 xtraeme speedstep_sysctl_helper(SYSCTLFN_ARGS)
620 1.1 xtraeme {
621 1.1 xtraeme struct sysctlnode node;
622 1.1 xtraeme struct lpcib_softc *sc = speedstep_cookie;
623 1.1 xtraeme uint8_t state, state2;
624 1.1 xtraeme int ostate, nstate, s, error = 0;
625 1.1 xtraeme
626 1.1 xtraeme /*
627 1.1 xtraeme * We do the dance with spl's to avoid being at high ipl during
628 1.1 xtraeme * sysctl_lookup() which can both copyin and copyout.
629 1.1 xtraeme */
630 1.1 xtraeme s = splserial();
631 1.1 xtraeme state = SS_READ(sc, LPCIB_PM_SS_CNTL);
632 1.1 xtraeme splx(s);
633 1.1 xtraeme if ((state & LPCIB_PM_SS_STATE_LOW) == 0)
634 1.1 xtraeme ostate = 1;
635 1.1 xtraeme else
636 1.1 xtraeme ostate = 0;
637 1.1 xtraeme nstate = ostate;
638 1.1 xtraeme
639 1.1 xtraeme node = *rnode;
640 1.1 xtraeme node.sysctl_data = &nstate;
641 1.1 xtraeme
642 1.1 xtraeme error = sysctl_lookup(SYSCTLFN_CALL(&node));
643 1.1 xtraeme if (error || newp == NULL)
644 1.1 xtraeme goto out;
645 1.1 xtraeme
646 1.1 xtraeme /* Only two states are available */
647 1.1 xtraeme if (nstate != 0 && nstate != 1) {
648 1.1 xtraeme error = EINVAL;
649 1.1 xtraeme goto out;
650 1.1 xtraeme }
651 1.1 xtraeme
652 1.1 xtraeme s = splserial();
653 1.1 xtraeme state2 = SS_READ(sc, LPCIB_PM_SS_CNTL);
654 1.1 xtraeme if ((state2 & LPCIB_PM_SS_STATE_LOW) == 0)
655 1.1 xtraeme ostate = 1;
656 1.1 xtraeme else
657 1.1 xtraeme ostate = 0;
658 1.1 xtraeme
659 1.1 xtraeme if (ostate != nstate) {
660 1.1 xtraeme uint8_t cntl;
661 1.1 xtraeme
662 1.1 xtraeme if (nstate == 0)
663 1.1 xtraeme state2 |= LPCIB_PM_SS_STATE_LOW;
664 1.1 xtraeme else
665 1.1 xtraeme state2 &= ~LPCIB_PM_SS_STATE_LOW;
666 1.1 xtraeme
667 1.1 xtraeme /*
668 1.1 xtraeme * Must disable bus master arbitration during the change.
669 1.1 xtraeme */
670 1.1 xtraeme cntl = SS_READ(sc, LPCIB_PM_CTRL);
671 1.1 xtraeme SS_WRITE(sc, LPCIB_PM_CTRL, cntl | LPCIB_PM_SS_CNTL_ARB_DIS);
672 1.1 xtraeme SS_WRITE(sc, LPCIB_PM_SS_CNTL, state2);
673 1.1 xtraeme SS_WRITE(sc, LPCIB_PM_CTRL, cntl);
674 1.1 xtraeme }
675 1.1 xtraeme splx(s);
676 1.1 xtraeme out:
677 1.1 xtraeme return error;
678 1.1 xtraeme }
679 1.6 jmcneill
680 1.6 jmcneill #if NHPET > 0
681 1.6 jmcneill struct lpcib_hpet_attach_arg {
682 1.6 jmcneill bus_space_tag_t hpet_mem_t;
683 1.6 jmcneill uint32_t hpet_reg;
684 1.6 jmcneill };
685 1.6 jmcneill
686 1.6 jmcneill static int
687 1.6 jmcneill lpcib_hpet_match(device_t parent, struct cfdata *match, void *aux)
688 1.6 jmcneill {
689 1.6 jmcneill struct lpcib_hpet_attach_arg *arg = aux;
690 1.6 jmcneill bus_space_tag_t tag;
691 1.6 jmcneill bus_space_handle_t handle;
692 1.6 jmcneill
693 1.6 jmcneill tag = arg->hpet_mem_t;
694 1.6 jmcneill
695 1.6 jmcneill if (bus_space_map(tag, arg->hpet_reg, HPET_WINDOW_SIZE, 0, &handle)) {
696 1.6 jmcneill aprint_verbose("%s: HPET window not mapped, skipping\n",
697 1.6 jmcneill parent->dv_xname);
698 1.6 jmcneill return 0;
699 1.6 jmcneill }
700 1.6 jmcneill bus_space_unmap(tag, handle, HPET_WINDOW_SIZE);
701 1.6 jmcneill
702 1.6 jmcneill return 1;
703 1.6 jmcneill }
704 1.6 jmcneill
705 1.6 jmcneill static void
706 1.6 jmcneill lpcib_hpet_attach(device_t parent, device_t self, void *aux)
707 1.6 jmcneill {
708 1.6 jmcneill struct hpet_softc *sc = device_private(self);
709 1.6 jmcneill struct lpcib_hpet_attach_arg *arg = aux;
710 1.6 jmcneill
711 1.6 jmcneill aprint_naive("\n");
712 1.6 jmcneill aprint_normal("\n");
713 1.6 jmcneill
714 1.6 jmcneill sc->sc_memt = arg->hpet_mem_t;
715 1.6 jmcneill
716 1.6 jmcneill if (bus_space_map(sc->sc_memt, arg->hpet_reg, HPET_WINDOW_SIZE, 0,
717 1.6 jmcneill &sc->sc_memh)) {
718 1.6 jmcneill aprint_error("%s: HPET memory window could not be mapped",
719 1.6 jmcneill sc->sc_dev.dv_xname);
720 1.6 jmcneill return;
721 1.6 jmcneill }
722 1.6 jmcneill
723 1.6 jmcneill hpet_attach_subr(sc);
724 1.6 jmcneill }
725 1.6 jmcneill
726 1.6 jmcneill CFATTACH_DECL(ichlpcib_hpet, sizeof(struct hpet_softc), lpcib_hpet_match,
727 1.6 jmcneill lpcib_hpet_attach, NULL, NULL);
728 1.6 jmcneill
729 1.6 jmcneill static void
730 1.6 jmcneill lpcib_hpet_configure(struct lpcib_softc *sc)
731 1.6 jmcneill {
732 1.6 jmcneill struct lpcib_hpet_attach_arg arg;
733 1.6 jmcneill uint32_t hpet_reg, val;
734 1.6 jmcneill
735 1.6 jmcneill if (sc->sc_has_ich5_hpet) {
736 1.6 jmcneill val = pci_conf_read(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_CNTL);
737 1.6 jmcneill switch (val & LPCIB_ICH5_HPTC_WIN_MASK) {
738 1.6 jmcneill case LPCIB_ICH5_HPTC_0000:
739 1.6 jmcneill hpet_reg = LPCIB_ICH5_HPTC_0000_BASE;
740 1.6 jmcneill break;
741 1.6 jmcneill case LPCIB_ICH5_HPTC_1000:
742 1.6 jmcneill hpet_reg = LPCIB_ICH5_HPTC_1000_BASE;
743 1.6 jmcneill break;
744 1.6 jmcneill case LPCIB_ICH5_HPTC_2000:
745 1.6 jmcneill hpet_reg = LPCIB_ICH5_HPTC_2000_BASE;
746 1.6 jmcneill break;
747 1.6 jmcneill case LPCIB_ICH5_HPTC_3000:
748 1.6 jmcneill hpet_reg = LPCIB_ICH5_HPTC_3000_BASE;
749 1.6 jmcneill break;
750 1.6 jmcneill default:
751 1.6 jmcneill return;
752 1.6 jmcneill }
753 1.6 jmcneill val |= sc->sc_hpet_reg | LPCIB_ICH5_HPTC_EN;
754 1.6 jmcneill pci_conf_write(sc->sc_pc, sc->sc_pcitag, LPCIB_PCI_GEN_CNTL, val);
755 1.6 jmcneill } else if (sc->sc_has_rcba) {
756 1.6 jmcneill val = bus_space_read_4(sc->sc_rcbat, sc->sc_rcbah,
757 1.6 jmcneill LPCIB_RCBA_HPTC);
758 1.6 jmcneill switch (val & LPCIB_RCBA_HPTC_WIN_MASK) {
759 1.6 jmcneill case LPCIB_RCBA_HPTC_0000:
760 1.6 jmcneill hpet_reg = LPCIB_RCBA_HPTC_0000_BASE;
761 1.6 jmcneill break;
762 1.6 jmcneill case LPCIB_RCBA_HPTC_1000:
763 1.6 jmcneill hpet_reg = LPCIB_RCBA_HPTC_1000_BASE;
764 1.6 jmcneill break;
765 1.6 jmcneill case LPCIB_RCBA_HPTC_2000:
766 1.6 jmcneill hpet_reg = LPCIB_RCBA_HPTC_2000_BASE;
767 1.6 jmcneill break;
768 1.6 jmcneill case LPCIB_RCBA_HPTC_3000:
769 1.6 jmcneill hpet_reg = LPCIB_RCBA_HPTC_3000_BASE;
770 1.6 jmcneill break;
771 1.6 jmcneill default:
772 1.6 jmcneill return;
773 1.6 jmcneill }
774 1.6 jmcneill val |= LPCIB_RCBA_HPTC_EN;
775 1.6 jmcneill bus_space_write_4(sc->sc_rcbat, sc->sc_rcbah, LPCIB_RCBA_HPTC,
776 1.6 jmcneill val);
777 1.6 jmcneill } else {
778 1.6 jmcneill /* No HPET here */
779 1.6 jmcneill return;
780 1.6 jmcneill }
781 1.6 jmcneill
782 1.6 jmcneill arg.hpet_mem_t = sc->sc_pa.pa_memt;
783 1.6 jmcneill arg.hpet_reg = hpet_reg;
784 1.6 jmcneill
785 1.6 jmcneill config_found_ia((struct device *)sc, "hpetichbus", &arg, NULL);
786 1.6 jmcneill }
787 1.6 jmcneill #endif
788