12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
21144ab5dSAlbert Herranz /*
31144ab5dSAlbert Herranz * drivers/mmc/host/sdhci-of-hlwd.c
41144ab5dSAlbert Herranz *
51144ab5dSAlbert Herranz * Nintendo Wii Secure Digital Host Controller Interface.
61144ab5dSAlbert Herranz * Copyright (C) 2009 The GameCube Linux Team
71144ab5dSAlbert Herranz * Copyright (C) 2009 Albert Herranz
81144ab5dSAlbert Herranz *
91144ab5dSAlbert Herranz * Based on sdhci-of-esdhc.c
101144ab5dSAlbert Herranz *
111144ab5dSAlbert Herranz * Copyright (c) 2007 Freescale Semiconductor, Inc.
121144ab5dSAlbert Herranz * Copyright (c) 2009 MontaVista Software, Inc.
131144ab5dSAlbert Herranz *
141144ab5dSAlbert Herranz * Authors: Xiaobo Xie <X.Xie@freescale.com>
151144ab5dSAlbert Herranz * Anton Vorontsov <avorontsov@ru.mvista.com>
161144ab5dSAlbert Herranz */
171144ab5dSAlbert Herranz
181144ab5dSAlbert Herranz #include <linux/delay.h>
1988b47679SPaul Gortmaker #include <linux/module.h>
201144ab5dSAlbert Herranz #include <linux/mmc/host.h>
2138576af1SShawn Guo #include "sdhci-pltfm.h"
221144ab5dSAlbert Herranz
231144ab5dSAlbert Herranz /*
241144ab5dSAlbert Herranz * Ops and quirks for the Nintendo Wii SDHCI controllers.
251144ab5dSAlbert Herranz */
261144ab5dSAlbert Herranz
271144ab5dSAlbert Herranz /*
281144ab5dSAlbert Herranz * We need a small delay after each write, or things go horribly wrong.
291144ab5dSAlbert Herranz */
301144ab5dSAlbert Herranz #define SDHCI_HLWD_WRITE_DELAY 5 /* usecs */
311144ab5dSAlbert Herranz
sdhci_hlwd_writel(struct sdhci_host * host,u32 val,int reg)321144ab5dSAlbert Herranz static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg)
331144ab5dSAlbert Herranz {
341144ab5dSAlbert Herranz sdhci_be32bs_writel(host, val, reg);
351144ab5dSAlbert Herranz udelay(SDHCI_HLWD_WRITE_DELAY);
361144ab5dSAlbert Herranz }
371144ab5dSAlbert Herranz
sdhci_hlwd_writew(struct sdhci_host * host,u16 val,int reg)381144ab5dSAlbert Herranz static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg)
391144ab5dSAlbert Herranz {
401144ab5dSAlbert Herranz sdhci_be32bs_writew(host, val, reg);
411144ab5dSAlbert Herranz udelay(SDHCI_HLWD_WRITE_DELAY);
421144ab5dSAlbert Herranz }
431144ab5dSAlbert Herranz
sdhci_hlwd_writeb(struct sdhci_host * host,u8 val,int reg)441144ab5dSAlbert Herranz static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg)
451144ab5dSAlbert Herranz {
461144ab5dSAlbert Herranz sdhci_be32bs_writeb(host, val, reg);
471144ab5dSAlbert Herranz udelay(SDHCI_HLWD_WRITE_DELAY);
481144ab5dSAlbert Herranz }
491144ab5dSAlbert Herranz
50c915568dSLars-Peter Clausen static const struct sdhci_ops sdhci_hlwd_ops = {
51dc297c92SMatt Fleming .read_l = sdhci_be32bs_readl,
52dc297c92SMatt Fleming .read_w = sdhci_be32bs_readw,
53dc297c92SMatt Fleming .read_b = sdhci_be32bs_readb,
54dc297c92SMatt Fleming .write_l = sdhci_hlwd_writel,
55dc297c92SMatt Fleming .write_w = sdhci_hlwd_writew,
56dc297c92SMatt Fleming .write_b = sdhci_hlwd_writeb,
571771059cSRussell King .set_clock = sdhci_set_clock,
582317f56cSRussell King .set_bus_width = sdhci_set_bus_width,
5903231f9bSRussell King .reset = sdhci_reset,
6096d7b78cSRussell King .set_uhs_signaling = sdhci_set_uhs_signaling,
61e307148fSShawn Guo };
62e307148fSShawn Guo
631db5eebfSLars-Peter Clausen static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
64e307148fSShawn Guo .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
65e307148fSShawn Guo SDHCI_QUIRK_32BIT_DMA_SIZE,
66e307148fSShawn Guo .ops = &sdhci_hlwd_ops,
671144ab5dSAlbert Herranz };
6838576af1SShawn Guo
sdhci_hlwd_probe(struct platform_device * pdev)69c3be1efdSBill Pemberton static int sdhci_hlwd_probe(struct platform_device *pdev)
7038576af1SShawn Guo {
71*899171dcSAdrian Hunter return sdhci_pltfm_init_and_add_host(pdev, &sdhci_hlwd_pdata, 0);
7238576af1SShawn Guo }
7338576af1SShawn Guo
7438576af1SShawn Guo static const struct of_device_id sdhci_hlwd_of_match[] = {
7538576af1SShawn Guo { .compatible = "nintendo,hollywood-sdhci" },
7638576af1SShawn Guo { }
7738576af1SShawn Guo };
7838576af1SShawn Guo MODULE_DEVICE_TABLE(of, sdhci_hlwd_of_match);
7938576af1SShawn Guo
8038576af1SShawn Guo static struct platform_driver sdhci_hlwd_driver = {
8138576af1SShawn Guo .driver = {
8238576af1SShawn Guo .name = "sdhci-hlwd",
8321b2cec6SDouglas Anderson .probe_type = PROBE_PREFER_ASYNCHRONOUS,
8438576af1SShawn Guo .of_match_table = sdhci_hlwd_of_match,
85fa243f64SUlf Hansson .pm = &sdhci_pltfm_pmops,
8638576af1SShawn Guo },
8738576af1SShawn Guo .probe = sdhci_hlwd_probe,
88ed581f29SAdrian Hunter .remove_new = sdhci_pltfm_remove,
8938576af1SShawn Guo };
9038576af1SShawn Guo
91d1f81a64SAxel Lin module_platform_driver(sdhci_hlwd_driver);
9238576af1SShawn Guo
9338576af1SShawn Guo MODULE_DESCRIPTION("Nintendo Wii SDHCI OF driver");
9438576af1SShawn Guo MODULE_AUTHOR("The GameCube Linux Team, Albert Herranz");
9538576af1SShawn Guo MODULE_LICENSE("GPL v2");
96