blob: 0601164f5f2effce7f6c1a0f281626a60e450c43 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
* Copyright (c) 2006-2022, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-12-06 GuEe-GUI first version
*/
#include "dev_sdio_dw.h"
#include <mmu.h>
#define SYNOPSYS_DW_MCI_VENDOR_ID 0x0700
#define SYNOPSYS_DW_MCI_DEVICE_ID 0x1107
#define MCI_REG_NO 2
static const struct sdio_dw_drv_data sdio_dw_pci_drv_data =
{
};
static rt_err_t sdio_dw_pci_probe(struct rt_pci_device *pdev)
{
rt_err_t err;
struct sdio_dw *sd = rt_calloc(1, sizeof(*sd));
if (!sd)
{
return -RT_ENOMEM;
}
sd->bus_dev = &pdev->parent;
sd->base = rt_pci_iomap(pdev, MCI_REG_NO);
if (!sd->base)
{
goto _fail;
}
sd->irq = pdev->irq;
rt_pci_irq_unmask(pdev);
sd->base_phy = (rt_ubase_t)rt_kmem_v2p(sd->base);
sd->drv_data = &sdio_dw_pci_drv_data;
/* board data */
sd->bus_hz = 33 * 1000 * 1000;
sd->detect_delay_ms = 200;
sd->fifo_depth = 32;
pdev->parent.user_data = sd;
if ((err = sdio_dw_probe(sd)))
{
goto _fail;
}
return RT_EOK;
_fail:
if (sd->base)
{
rt_iounmap(sd->base);
}
rt_free(sd);
return err;
}
static rt_err_t sdio_dw_pci_remove(struct rt_pci_device *pdev)
{
struct sdio_dw *sd = pdev->parent.user_data;
sdio_dw_remove(sd);
rt_iounmap(sd->base);
rt_free(sd);
return RT_EOK;
}
static const struct rt_pci_device_id sdio_dw_pci_pci_ids[] =
{
{ RT_PCI_DEVICE_ID(SYNOPSYS_DW_MCI_VENDOR_ID, SYNOPSYS_DW_MCI_DEVICE_ID) },
{ /* sentinel */ }
};
static struct rt_pci_driver sdio_dw_pci_driver =
{
.name = "dw-mmc-pci",
.ids = sdio_dw_pci_pci_ids,
.probe = sdio_dw_pci_probe,
.remove = sdio_dw_pci_remove,
};
RT_PCI_DRIVER_EXPORT(sdio_dw_pci_driver);
|