Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * drivers/mmc/host/sdhci-of-hlwd.c
0004  *
0005  * Nintendo Wii Secure Digital Host Controller Interface.
0006  * Copyright (C) 2009 The GameCube Linux Team
0007  * Copyright (C) 2009 Albert Herranz
0008  *
0009  * Based on sdhci-of-esdhc.c
0010  *
0011  * Copyright (c) 2007 Freescale Semiconductor, Inc.
0012  * Copyright (c) 2009 MontaVista Software, Inc.
0013  *
0014  * Authors: Xiaobo Xie <X.Xie@freescale.com>
0015  *      Anton Vorontsov <avorontsov@ru.mvista.com>
0016  */
0017 
0018 #include <linux/delay.h>
0019 #include <linux/module.h>
0020 #include <linux/mmc/host.h>
0021 #include "sdhci-pltfm.h"
0022 
0023 /*
0024  * Ops and quirks for the Nintendo Wii SDHCI controllers.
0025  */
0026 
0027 /*
0028  * We need a small delay after each write, or things go horribly wrong.
0029  */
0030 #define SDHCI_HLWD_WRITE_DELAY  5 /* usecs */
0031 
0032 static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg)
0033 {
0034     sdhci_be32bs_writel(host, val, reg);
0035     udelay(SDHCI_HLWD_WRITE_DELAY);
0036 }
0037 
0038 static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg)
0039 {
0040     sdhci_be32bs_writew(host, val, reg);
0041     udelay(SDHCI_HLWD_WRITE_DELAY);
0042 }
0043 
0044 static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg)
0045 {
0046     sdhci_be32bs_writeb(host, val, reg);
0047     udelay(SDHCI_HLWD_WRITE_DELAY);
0048 }
0049 
0050 static const struct sdhci_ops sdhci_hlwd_ops = {
0051     .read_l = sdhci_be32bs_readl,
0052     .read_w = sdhci_be32bs_readw,
0053     .read_b = sdhci_be32bs_readb,
0054     .write_l = sdhci_hlwd_writel,
0055     .write_w = sdhci_hlwd_writew,
0056     .write_b = sdhci_hlwd_writeb,
0057     .set_clock = sdhci_set_clock,
0058     .set_bus_width = sdhci_set_bus_width,
0059     .reset = sdhci_reset,
0060     .set_uhs_signaling = sdhci_set_uhs_signaling,
0061 };
0062 
0063 static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
0064     .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
0065           SDHCI_QUIRK_32BIT_DMA_SIZE,
0066     .ops = &sdhci_hlwd_ops,
0067 };
0068 
0069 static int sdhci_hlwd_probe(struct platform_device *pdev)
0070 {
0071     return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0);
0072 }
0073 
0074 static const struct of_device_id sdhci_hlwd_of_match[] = {
0075     { .compatible = "nintendo,hollywood-sdhci" },
0076     { }
0077 };
0078 MODULE_DEVICE_TABLE(of, sdhci_hlwd_of_match);
0079 
0080 static struct platform_driver sdhci_hlwd_driver = {
0081     .driver = {
0082         .name = "sdhci-hlwd",
0083         .probe_type = PROBE_PREFER_ASYNCHRONOUS,
0084         .of_match_table = sdhci_hlwd_of_match,
0085         .pm = &sdhci_pltfm_pmops,
0086     },
0087     .probe = sdhci_hlwd_probe,
0088     .remove = sdhci_pltfm_unregister,
0089 };
0090 
0091 module_platform_driver(sdhci_hlwd_driver);
0092 
0093 MODULE_DESCRIPTION("Nintendo Wii SDHCI OF driver");
0094 MODULE_AUTHOR("The GameCube Linux Team, Albert Herranz");
0095 MODULE_LICENSE("GPL v2");