summaryrefslogtreecommitdiff
path: root/components/drivers/sdio/host/sdhci-dwcmshc.h
blob: 692f4199c87233a2f7ec855b81eb74f43eb476c7 (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
/*
 * Copyright (c) 2006-2024, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2024-01-30     RT-Thread    first version
 */

#ifndef __SDHCI_DWCMSHC_H__
#define __SDHCI_DWCMSHC_H__

#include "../dev_sdhci_dm.h"

#define SDHCI_DWCMSHC_ARG2_STUFF RT_GENMASK(31, 16)

/* DWCMSHC specific Mode Select value */
#define DWCMSHC_CTRL_HS400 0x7

/* DWC IP vendor area 1 pointer */
#define DWCMSHC_P_VENDOR_AREA1 0xe8
#define DWCMSHC_AREA1_MASK     RT_GENMASK(11, 0)
/* Offset inside the vendor area 1 */
#define DWCMSHC_HOST_CTRL3      0x8
#define DWCMSHC_EMMC_CONTROL    0x2c
#define DWCMSHC_CARD_IS_EMMC    RT_BIT(0)
#define DWCMSHC_ENHANCED_STROBE RT_BIT(8)
#define DWCMSHC_EMMC_ATCTRL     0x40

/* DWC IP vendor area 2 pointer */
#define DWCMSHC_P_VENDOR_AREA2 0xea

struct sdhci_dwcmshc;

struct sdhci_dwcmshc_drv_data
{
    const struct rt_sdhci_pltfm_data *pdata;

    rt_err_t (*init)(struct rt_sdhci_host *host, struct sdhci_dwcmshc *priv);
    void (*postinit)(struct rt_sdhci_host *host, struct sdhci_dwcmshc *priv);
    void (*remove)(struct rt_sdhci_host *host, struct sdhci_dwcmshc *priv);

    void *vendor_priv;
};

struct sdhci_dwcmshc
{
    struct rt_clk *bus_clk;
    /* P_VENDOR_SPECIFIC_AREA1/2 reg */
    int vendor_specific_area1;
    int vendor_specific_area2;

    void *vendor_priv;
    const struct sdhci_dwcmshc_drv_data *drv_data;
};

extern const struct sdhci_dwcmshc_drv_data sdhci_dwcmshc_generic_drv_data;

rt_err_t sdhci_dwcmshc_probe(struct rt_platform_device *pdev,
                             const struct sdhci_dwcmshc_drv_data *drv_data);
rt_err_t sdhci_dwcmshc_remove(struct rt_platform_device *pdev);

void sdhci_dwcmshc_set_uhs_signaling(struct rt_sdhci_host *host, unsigned int timing);

#endif /* __SDHCI_DWCMSHC_H__ */