xref: /linux/drivers/mmc/host/sdhci-of-hlwd.c (revision 96d7b78cfc2fd6b1539704e2d33239dbaa097cc4)
11144ab5dSAlbert Herranz /*
21144ab5dSAlbert Herranz  * drivers/mmc/host/sdhci-of-hlwd.c
31144ab5dSAlbert Herranz  *
41144ab5dSAlbert Herranz  * Nintendo Wii Secure Digital Host Controller Interface.
51144ab5dSAlbert Herranz  * Copyright (C) 2009 The GameCube Linux Team
61144ab5dSAlbert Herranz  * Copyright (C) 2009 Albert Herranz
71144ab5dSAlbert Herranz  *
81144ab5dSAlbert Herranz  * Based on sdhci-of-esdhc.c
91144ab5dSAlbert Herranz  *
101144ab5dSAlbert Herranz  * Copyright (c) 2007 Freescale Semiconductor, Inc.
111144ab5dSAlbert Herranz  * Copyright (c) 2009 MontaVista Software, Inc.
121144ab5dSAlbert Herranz  *
131144ab5dSAlbert Herranz  * Authors: Xiaobo Xie <X.Xie@freescale.com>
141144ab5dSAlbert Herranz  *	    Anton Vorontsov <avorontsov@ru.mvista.com>
151144ab5dSAlbert Herranz  *
161144ab5dSAlbert Herranz  * This program is free software; you can redistribute it and/or modify
171144ab5dSAlbert Herranz  * it under the terms of the GNU General Public License as published by
181144ab5dSAlbert Herranz  * the Free Software Foundation; either version 2 of the License, or (at
191144ab5dSAlbert Herranz  * your option) any later version.
201144ab5dSAlbert Herranz  */
211144ab5dSAlbert Herranz 
221144ab5dSAlbert Herranz #include <linux/delay.h>
2388b47679SPaul Gortmaker #include <linux/module.h>
241144ab5dSAlbert Herranz #include <linux/mmc/host.h>
2538576af1SShawn Guo #include "sdhci-pltfm.h"
261144ab5dSAlbert Herranz 
271144ab5dSAlbert Herranz /*
281144ab5dSAlbert Herranz  * Ops and quirks for the Nintendo Wii SDHCI controllers.
291144ab5dSAlbert Herranz  */
301144ab5dSAlbert Herranz 
311144ab5dSAlbert Herranz /*
321144ab5dSAlbert Herranz  * We need a small delay after each write, or things go horribly wrong.
331144ab5dSAlbert Herranz  */
341144ab5dSAlbert Herranz #define SDHCI_HLWD_WRITE_DELAY	5 /* usecs */
351144ab5dSAlbert Herranz 
361144ab5dSAlbert Herranz static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg)
371144ab5dSAlbert Herranz {
381144ab5dSAlbert Herranz 	sdhci_be32bs_writel(host, val, reg);
391144ab5dSAlbert Herranz 	udelay(SDHCI_HLWD_WRITE_DELAY);
401144ab5dSAlbert Herranz }
411144ab5dSAlbert Herranz 
421144ab5dSAlbert Herranz static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg)
431144ab5dSAlbert Herranz {
441144ab5dSAlbert Herranz 	sdhci_be32bs_writew(host, val, reg);
451144ab5dSAlbert Herranz 	udelay(SDHCI_HLWD_WRITE_DELAY);
461144ab5dSAlbert Herranz }
471144ab5dSAlbert Herranz 
481144ab5dSAlbert Herranz static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg)
491144ab5dSAlbert Herranz {
501144ab5dSAlbert Herranz 	sdhci_be32bs_writeb(host, val, reg);
511144ab5dSAlbert Herranz 	udelay(SDHCI_HLWD_WRITE_DELAY);
521144ab5dSAlbert Herranz }
531144ab5dSAlbert Herranz 
54c915568dSLars-Peter Clausen static const struct sdhci_ops sdhci_hlwd_ops = {
55dc297c92SMatt Fleming 	.read_l = sdhci_be32bs_readl,
56dc297c92SMatt Fleming 	.read_w = sdhci_be32bs_readw,
57dc297c92SMatt Fleming 	.read_b = sdhci_be32bs_readb,
58dc297c92SMatt Fleming 	.write_l = sdhci_hlwd_writel,
59dc297c92SMatt Fleming 	.write_w = sdhci_hlwd_writew,
60dc297c92SMatt Fleming 	.write_b = sdhci_hlwd_writeb,
611771059cSRussell King 	.set_clock = sdhci_set_clock,
622317f56cSRussell King 	.set_bus_width = sdhci_set_bus_width,
6303231f9bSRussell King 	.reset = sdhci_reset,
64*96d7b78cSRussell King 	.set_uhs_signaling = sdhci_set_uhs_signaling,
65e307148fSShawn Guo };
66e307148fSShawn Guo 
671db5eebfSLars-Peter Clausen static const struct sdhci_pltfm_data sdhci_hlwd_pdata = {
68e307148fSShawn Guo 	.quirks = SDHCI_QUIRK_32BIT_DMA_ADDR |
69e307148fSShawn Guo 		  SDHCI_QUIRK_32BIT_DMA_SIZE,
70e307148fSShawn Guo 	.ops = &sdhci_hlwd_ops,
711144ab5dSAlbert Herranz };
7238576af1SShawn Guo 
73c3be1efdSBill Pemberton static int sdhci_hlwd_probe(struct platform_device *pdev)
7438576af1SShawn Guo {
750e748234SChristian Daudt 	return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0);
7638576af1SShawn Guo }
7738576af1SShawn Guo 
786e0ee714SBill Pemberton static int sdhci_hlwd_remove(struct platform_device *pdev)
7938576af1SShawn Guo {
8038576af1SShawn Guo 	return sdhci_pltfm_unregister(pdev);
8138576af1SShawn Guo }
8238576af1SShawn Guo 
8338576af1SShawn Guo static const struct of_device_id sdhci_hlwd_of_match[] = {
8438576af1SShawn Guo 	{ .compatible = "nintendo,hollywood-sdhci" },
8538576af1SShawn Guo 	{ }
8638576af1SShawn Guo };
8738576af1SShawn Guo MODULE_DEVICE_TABLE(of, sdhci_hlwd_of_match);
8838576af1SShawn Guo 
8938576af1SShawn Guo static struct platform_driver sdhci_hlwd_driver = {
9038576af1SShawn Guo 	.driver = {
9138576af1SShawn Guo 		.name = "sdhci-hlwd",
9238576af1SShawn Guo 		.owner = THIS_MODULE,
9338576af1SShawn Guo 		.of_match_table = sdhci_hlwd_of_match,
9429495aa0SManuel Lauss 		.pm = SDHCI_PLTFM_PMOPS,
9538576af1SShawn Guo 	},
9638576af1SShawn Guo 	.probe = sdhci_hlwd_probe,
970433c143SBill Pemberton 	.remove = sdhci_hlwd_remove,
9838576af1SShawn Guo };
9938576af1SShawn Guo 
100d1f81a64SAxel Lin module_platform_driver(sdhci_hlwd_driver);
10138576af1SShawn Guo 
10238576af1SShawn Guo MODULE_DESCRIPTION("Nintendo Wii SDHCI OF driver");
10338576af1SShawn Guo MODULE_AUTHOR("The GameCube Linux Team, Albert Herranz");
10438576af1SShawn Guo MODULE_LICENSE("GPL v2");
105