Albert Herranz | 1144ab5 | 2009-12-17 15:27:20 -0800 | [diff] [blame] | 1 | /* |
| 2 | * drivers/mmc/host/sdhci-of-hlwd.c |
| 3 | * |
| 4 | * Nintendo Wii Secure Digital Host Controller Interface. |
| 5 | * Copyright (C) 2009 The GameCube Linux Team |
| 6 | * Copyright (C) 2009 Albert Herranz |
| 7 | * |
| 8 | * Based on sdhci-of-esdhc.c |
| 9 | * |
| 10 | * Copyright (c) 2007 Freescale Semiconductor, Inc. |
| 11 | * Copyright (c) 2009 MontaVista Software, Inc. |
| 12 | * |
| 13 | * Authors: Xiaobo Xie <X.Xie@freescale.com> |
| 14 | * Anton Vorontsov <avorontsov@ru.mvista.com> |
| 15 | * |
| 16 | * This program is free software; you can redistribute it and/or modify |
| 17 | * it under the terms of the GNU General Public License as published by |
| 18 | * the Free Software Foundation; either version 2 of the License, or (at |
| 19 | * your option) any later version. |
| 20 | */ |
| 21 | |
| 22 | #include <linux/delay.h> |
Paul Gortmaker | 88b4767 | 2011-07-03 15:15:51 -0400 | [diff] [blame] | 23 | #include <linux/module.h> |
Albert Herranz | 1144ab5 | 2009-12-17 15:27:20 -0800 | [diff] [blame] | 24 | #include <linux/mmc/host.h> |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 25 | #include "sdhci-pltfm.h" |
Albert Herranz | 1144ab5 | 2009-12-17 15:27:20 -0800 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * Ops and quirks for the Nintendo Wii SDHCI controllers. |
| 29 | */ |
| 30 | |
| 31 | /* |
| 32 | * We need a small delay after each write, or things go horribly wrong. |
| 33 | */ |
| 34 | #define SDHCI_HLWD_WRITE_DELAY 5 /* usecs */ |
| 35 | |
| 36 | static void sdhci_hlwd_writel(struct sdhci_host *host, u32 val, int reg) |
| 37 | { |
| 38 | sdhci_be32bs_writel(host, val, reg); |
| 39 | udelay(SDHCI_HLWD_WRITE_DELAY); |
| 40 | } |
| 41 | |
| 42 | static void sdhci_hlwd_writew(struct sdhci_host *host, u16 val, int reg) |
| 43 | { |
| 44 | sdhci_be32bs_writew(host, val, reg); |
| 45 | udelay(SDHCI_HLWD_WRITE_DELAY); |
| 46 | } |
| 47 | |
| 48 | static void sdhci_hlwd_writeb(struct sdhci_host *host, u8 val, int reg) |
| 49 | { |
| 50 | sdhci_be32bs_writeb(host, val, reg); |
| 51 | udelay(SDHCI_HLWD_WRITE_DELAY); |
| 52 | } |
| 53 | |
Lars-Peter Clausen | c915568 | 2013-03-13 19:26:05 +0100 | [diff] [blame] | 54 | static const struct sdhci_ops sdhci_hlwd_ops = { |
Shawn Guo | e307148 | 2011-07-20 17:13:36 -0400 | [diff] [blame] | 55 | .read_l = sdhci_be32bs_readl, |
| 56 | .read_w = sdhci_be32bs_readw, |
| 57 | .read_b = sdhci_be32bs_readb, |
| 58 | .write_l = sdhci_hlwd_writel, |
| 59 | .write_w = sdhci_hlwd_writew, |
| 60 | .write_b = sdhci_hlwd_writeb, |
Russell King | 1771059 | 2014-04-25 12:58:55 +0100 | [diff] [blame] | 61 | .set_clock = sdhci_set_clock, |
Russell King | 2317f56 | 2014-04-25 12:57:07 +0100 | [diff] [blame] | 62 | .set_bus_width = sdhci_set_bus_width, |
Russell King | 03231f9 | 2014-04-25 12:57:12 +0100 | [diff] [blame] | 63 | .reset = sdhci_reset, |
Russell King | 96d7b78 | 2014-04-25 12:59:26 +0100 | [diff] [blame] | 64 | .set_uhs_signaling = sdhci_set_uhs_signaling, |
Shawn Guo | e307148 | 2011-07-20 17:13:36 -0400 | [diff] [blame] | 65 | }; |
| 66 | |
Lars-Peter Clausen | 1db5eeb | 2013-03-13 19:26:03 +0100 | [diff] [blame] | 67 | static const struct sdhci_pltfm_data sdhci_hlwd_pdata = { |
Albert Herranz | 1144ab5 | 2009-12-17 15:27:20 -0800 | [diff] [blame] | 68 | .quirks = SDHCI_QUIRK_32BIT_DMA_ADDR | |
| 69 | SDHCI_QUIRK_32BIT_DMA_SIZE, |
Shawn Guo | e307148 | 2011-07-20 17:13:36 -0400 | [diff] [blame] | 70 | .ops = &sdhci_hlwd_ops, |
Albert Herranz | 1144ab5 | 2009-12-17 15:27:20 -0800 | [diff] [blame] | 71 | }; |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 72 | |
Bill Pemberton | c3be1ef | 2012-11-19 13:23:06 -0500 | [diff] [blame] | 73 | static int sdhci_hlwd_probe(struct platform_device *pdev) |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 74 | { |
Christian Daudt | 0e74823 | 2013-05-29 13:50:05 -0700 | [diff] [blame] | 75 | return sdhci_pltfm_register(pdev, &sdhci_hlwd_pdata, 0); |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 76 | } |
| 77 | |
Bill Pemberton | 6e0ee71 | 2012-11-19 13:26:03 -0500 | [diff] [blame] | 78 | static int sdhci_hlwd_remove(struct platform_device *pdev) |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 79 | { |
| 80 | return sdhci_pltfm_unregister(pdev); |
| 81 | } |
| 82 | |
| 83 | static const struct of_device_id sdhci_hlwd_of_match[] = { |
| 84 | { .compatible = "nintendo,hollywood-sdhci" }, |
| 85 | { } |
| 86 | }; |
| 87 | MODULE_DEVICE_TABLE(of, sdhci_hlwd_of_match); |
| 88 | |
| 89 | static struct platform_driver sdhci_hlwd_driver = { |
| 90 | .driver = { |
| 91 | .name = "sdhci-hlwd", |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 92 | .of_match_table = sdhci_hlwd_of_match, |
Manuel Lauss | 29495aa | 2011-11-03 11:09:45 +0100 | [diff] [blame] | 93 | .pm = SDHCI_PLTFM_PMOPS, |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 94 | }, |
| 95 | .probe = sdhci_hlwd_probe, |
Bill Pemberton | 0433c14 | 2012-11-19 13:20:26 -0500 | [diff] [blame] | 96 | .remove = sdhci_hlwd_remove, |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 97 | }; |
| 98 | |
Axel Lin | d1f81a6 | 2011-11-26 12:55:43 +0800 | [diff] [blame] | 99 | module_platform_driver(sdhci_hlwd_driver); |
Shawn Guo | 38576af | 2011-05-27 23:48:14 +0800 | [diff] [blame] | 100 | |
| 101 | MODULE_DESCRIPTION("Nintendo Wii SDHCI OF driver"); |
| 102 | MODULE_AUTHOR("The GameCube Linux Team, Albert Herranz"); |
| 103 | MODULE_LICENSE("GPL v2"); |