This source file includes following definitions.
- pwdog_probe
- pwdog_attach
- pwdog_set_timeout
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <sys/types.h>
20 #include <sys/param.h>
21 #include <sys/device.h>
22 #include <sys/kernel.h>
23 #include <sys/proc.h>
24 #include <sys/systm.h>
25
26 #include <machine/bus.h>
27
28 #include <dev/pci/pcivar.h>
29 #include <dev/pci/pcireg.h>
30 #include <dev/pci/pcidevs.h>
31
32 struct pwdog_softc {
33 struct device pwdog_dev;
34 bus_space_tag_t iot;
35 bus_space_handle_t ioh;
36 };
37
38
39 #define PWDOG_ACTIVATE 0
40 #define PWDOG_DISABLE 1
41
42 int pwdog_probe(struct device *, void *, void *);
43 void pwdog_attach(struct device *, struct device *, void *);
44 int pwdog_set_timeout(void *, int);
45
46 struct cfattach pwdog_ca = {
47 sizeof(struct pwdog_softc), pwdog_probe, pwdog_attach
48 };
49
50 struct cfdriver pwdog_cd = {
51 NULL, "pwdog", DV_DULL
52 };
53
54 const struct pci_matchid pwdog_devices[] = {
55 { PCI_VENDOR_QUANCOM, PCI_PRODUCT_QUANCOM_PWDOG1 }
56 };
57
58 int
59 pwdog_probe(struct device *parent, void *match, void *aux)
60 {
61 return pci_matchbyid((struct pci_attach_args *)aux, pwdog_devices,
62 sizeof(pwdog_devices) / sizeof(pwdog_devices[0]));
63 }
64
65 void
66 pwdog_attach(struct device *parent, struct device *self, void *aux)
67 {
68 struct pwdog_softc *pwdog = (struct pwdog_softc *)self;
69 struct pci_attach_args *const pa = (struct pci_attach_args *)aux;
70 pcireg_t memtype;
71 bus_size_t iosize;
72
73 memtype = pci_mapreg_type(pa->pa_pc, pa->pa_tag, PCI_MAPREG_START);
74 if (pci_mapreg_map(pa, PCI_MAPREG_START, memtype, 0, &pwdog->iot,
75 &pwdog->ioh, NULL, &iosize, 0)) {
76 printf("\n%s: PCI %s region not found\n",
77 pwdog->pwdog_dev.dv_xname,
78 memtype == PCI_MAPREG_TYPE_IO ? "I/O" : "memory");
79 return;
80 }
81 printf("\n");
82 bus_space_write_1(pwdog->iot, pwdog->ioh, PWDOG_DISABLE, 0);
83 wdog_register(pwdog, pwdog_set_timeout);
84 }
85
86 int
87 pwdog_set_timeout(void *self, int seconds)
88 {
89 struct pwdog_softc *pwdog = (struct pwdog_softc *)self;
90 int s;
91
92 s = splclock();
93 if (seconds)
94 bus_space_write_1(pwdog->iot, pwdog->ioh, PWDOG_ACTIVATE, 0);
95 else
96 bus_space_write_1(pwdog->iot, pwdog->ioh, PWDOG_DISABLE, 0);
97 splx(s);
98 return seconds;
99 }