]>
Commit | Line | Data |
---|---|---|
ce864603 TH |
1 | /* |
2 | * SDHCI device on PCI | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License as published by the | |
6 | * Free Software Foundation; either version 2 of the License, or (at your | |
7 | * option) any later version. | |
8 | * | |
9 | * This program is distributed in the hope that it will be useful, | |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
12 | * See the GNU General Public License for more details. | |
13 | * | |
14 | * You should have received a copy of the GNU General Public License along | |
15 | * with this program; if not, see <http://www.gnu.org/licenses/>. | |
16 | */ | |
17 | ||
18 | #include "qemu/osdep.h" | |
19 | #include "qapi/error.h" | |
0b8fa32f | 20 | #include "qemu/module.h" |
a27bd6c7 | 21 | #include "hw/qdev-properties.h" |
ce864603 TH |
22 | #include "hw/sd/sdhci.h" |
23 | #include "sdhci-internal.h" | |
24 | ||
25 | static Property sdhci_pci_properties[] = { | |
26 | DEFINE_SDHCI_COMMON_PROPERTIES(SDHCIState), | |
27 | DEFINE_PROP_END_OF_LIST(), | |
28 | }; | |
29 | ||
30 | static void sdhci_pci_realize(PCIDevice *dev, Error **errp) | |
31 | { | |
32 | SDHCIState *s = PCI_SDHCI(dev); | |
33 | Error *local_err = NULL; | |
34 | ||
35 | sdhci_initfn(s); | |
36 | sdhci_common_realize(s, &local_err); | |
37 | if (local_err) { | |
38 | error_propagate(errp, local_err); | |
39 | return; | |
40 | } | |
41 | ||
42 | dev->config[PCI_CLASS_PROG] = 0x01; /* Standard Host supported DMA */ | |
43 | dev->config[PCI_INTERRUPT_PIN] = 0x01; /* interrupt pin A */ | |
44 | s->irq = pci_allocate_irq(dev); | |
45 | s->dma_as = pci_get_address_space(dev); | |
46 | pci_register_bar(dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->iomem); | |
47 | } | |
48 | ||
49 | static void sdhci_pci_exit(PCIDevice *dev) | |
50 | { | |
51 | SDHCIState *s = PCI_SDHCI(dev); | |
52 | ||
53 | sdhci_common_unrealize(s, &error_abort); | |
54 | sdhci_uninitfn(s); | |
55 | } | |
56 | ||
57 | static void sdhci_pci_class_init(ObjectClass *klass, void *data) | |
58 | { | |
59 | DeviceClass *dc = DEVICE_CLASS(klass); | |
60 | PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); | |
61 | ||
62 | k->realize = sdhci_pci_realize; | |
63 | k->exit = sdhci_pci_exit; | |
64 | k->vendor_id = PCI_VENDOR_ID_REDHAT; | |
65 | k->device_id = PCI_DEVICE_ID_REDHAT_SDHCI; | |
66 | k->class_id = PCI_CLASS_SYSTEM_SDHCI; | |
4f67d30b | 67 | device_class_set_props(dc, sdhci_pci_properties); |
ce864603 TH |
68 | |
69 | sdhci_common_class_init(klass, data); | |
70 | } | |
71 | ||
72 | static const TypeInfo sdhci_pci_info = { | |
73 | .name = TYPE_PCI_SDHCI, | |
74 | .parent = TYPE_PCI_DEVICE, | |
75 | .instance_size = sizeof(SDHCIState), | |
76 | .class_init = sdhci_pci_class_init, | |
77 | .interfaces = (InterfaceInfo[]) { | |
78 | { INTERFACE_CONVENTIONAL_PCI_DEVICE }, | |
79 | { }, | |
80 | }, | |
81 | }; | |
82 | ||
83 | static void sdhci_pci_register_type(void) | |
84 | { | |
85 | type_register_static(&sdhci_pci_info); | |
86 | } | |
87 | ||
88 | type_init(sdhci_pci_register_type) |