Commit 0d19eac12031680dc5f5402921fb0c388e42f619

Authored by Linus Torvalds

Merge branch 'amba' of git://git.linaro.org/people/rmk/linux-arm

Pull #2 ARM updates from Russell King:
 "Further ARM AMBA primecell updates which aren't included directly in
  the previous commit.  I wanted to keep these separate as they're
  touching stuff outside arch/arm/."

* 'amba' of git://git.linaro.org/people/rmk/linux-arm:
  ARM: 7362/1: AMBA: Add module_amba_driver() helper macro for amba_driver
  ARM: 7335/1: mach-u300: do away with MMC config files
  ARM: 7280/1: mmc: mmci: Cache MMCICLOCK and MMCIPOWER register
  ARM: 7309/1: realview: fix unconnected interrupts on EB11MP
  ARM: 7230/1: mmc: mmci: Fix PIO read for small SDIO packets
  ARM: 7227/1: mmc: mmci: Prepare for SDIO before setting up DMA job
  ARM: 7223/1: mmc: mmci: Fixup use of runtime PM and use autosuspend
  ARM: 7221/1: mmc: mmci: Change from using legacy suspend
  ARM: 7219/1: mmc: mmci: Change vdd_handler to a generic ios_handler
  ARM: 7218/1: mmc: mmci: Provide option to configure bus signal direction
  ARM: 7217/1: mmc: mmci: Put power register deviations in variant data
  ARM: 7216/1: mmc: mmci: Do not release spinlock in request_end
  ARM: 7215/1: mmc: mmci: Increase max_segs from 16 to 128

Showing 17 changed files Side-by-side Diff

arch/arm/mach-realview/include/mach/irqs-eb.h
... ... @@ -96,16 +96,19 @@
96 96 #define IRQ_EB11MP_L220_SLAVE (IRQ_EB_GIC_START + 30)
97 97 #define IRQ_EB11MP_L220_DECODE (IRQ_EB_GIC_START + 31)
98 98  
99   -#define IRQ_EB11MP_UART2 -1
100   -#define IRQ_EB11MP_UART3 -1
101   -#define IRQ_EB11MP_CLCD -1
102   -#define IRQ_EB11MP_DMA -1
103   -#define IRQ_EB11MP_WDOG -1
104   -#define IRQ_EB11MP_GPIO0 -1
105   -#define IRQ_EB11MP_GPIO1 -1
106   -#define IRQ_EB11MP_GPIO2 -1
107   -#define IRQ_EB11MP_SCI -1
108   -#define IRQ_EB11MP_SSP -1
  99 +/*
  100 + * The 11MPcore tile leaves the following unconnected.
  101 + */
  102 +#define IRQ_EB11MP_UART2 0
  103 +#define IRQ_EB11MP_UART3 0
  104 +#define IRQ_EB11MP_CLCD 0
  105 +#define IRQ_EB11MP_DMA 0
  106 +#define IRQ_EB11MP_WDOG 0
  107 +#define IRQ_EB11MP_GPIO0 0
  108 +#define IRQ_EB11MP_GPIO1 0
  109 +#define IRQ_EB11MP_GPIO2 0
  110 +#define IRQ_EB11MP_SCI 0
  111 +#define IRQ_EB11MP_SSP 0
109 112  
110 113 #define NR_GIC_EB11MP 2
111 114  
arch/arm/mach-u300/Makefile
... ... @@ -8,7 +8,6 @@
8 8 obj- :=
9 9  
10 10 obj-$(CONFIG_ARCH_U300) += u300.o
11   -obj-$(CONFIG_MMC) += mmc.o
12 11 obj-$(CONFIG_SPI_PL022) += spi.o
13 12 obj-$(CONFIG_MACH_U300_SPIDUMMY) += dummyspichip.o
14 13 obj-$(CONFIG_I2C_STU300) += i2c.o
arch/arm/mach-u300/core.c
... ... @@ -18,6 +18,7 @@
18 18 #include <linux/termios.h>
19 19 #include <linux/dmaengine.h>
20 20 #include <linux/amba/bus.h>
  21 +#include <linux/amba/mmci.h>
21 22 #include <linux/amba/serial.h>
22 23 #include <linux/platform_device.h>
23 24 #include <linux/gpio.h>
24 25  
... ... @@ -44,9 +45,9 @@
44 45 #include <mach/gpio-u300.h>
45 46  
46 47 #include "clock.h"
47   -#include "mmc.h"
48 48 #include "spi.h"
49 49 #include "i2c.h"
  50 +#include "u300-gpio.h"
50 51  
51 52 /*
52 53 * Static I/O mappings that are needed for booting the U300 platforms. The
... ... @@ -117,11 +118,6 @@
117 118 /* AHB device at 0x4000 offset */
118 119 static AMBA_APB_DEVICE(pl172, "pl172", 0, U300_EMIF_CFG_BASE, { }, NULL);
119 120  
120   -
121   -/*
122   - * Everything within this next ifdef deals with external devices connected to
123   - * the APP SPI bus.
124   - */
125 121 /* Fast device at 0x6000 offset */
126 122 static AMBA_APB_DEVICE(pl022, "pl022", 0, U300_SPI_BASE,
127 123 { IRQ_U300_SPI }, NULL);
128 124  
... ... @@ -129,8 +125,26 @@
129 125 /* Fast device at 0x1000 offset */
130 126 #define U300_MMCSD_IRQS { IRQ_U300_MMCSD_MCIINTR0, IRQ_U300_MMCSD_MCIINTR1 }
131 127  
  128 +static struct mmci_platform_data mmcsd_platform_data = {
  129 + /*
  130 + * Do not set ocr_mask or voltage translation function,
  131 + * we have a regulator we can control instead.
  132 + */
  133 + .f_max = 24000000,
  134 + .gpio_wp = -1,
  135 + .gpio_cd = U300_GPIO_PIN_MMC_CD,
  136 + .cd_invert = true,
  137 + .capabilities = MMC_CAP_MMC_HIGHSPEED |
  138 + MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
  139 +#ifdef CONFIG_COH901318
  140 + .dma_filter = coh901318_filter_id,
  141 + .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
  142 + /* Don't specify a TX channel, this RX channel is bidirectional */
  143 +#endif
  144 +};
  145 +
132 146 static AMBA_APB_DEVICE(mmcsd, "mmci", 0, U300_MMCSD_BASE,
133   - U300_MMCSD_IRQS, NULL);
  147 + U300_MMCSD_IRQS, &mmcsd_platform_data);
134 148  
135 149 /*
136 150 * The order of device declaration may be important, since some devices
... ... @@ -1829,16 +1843,6 @@
1829 1843 U300_SYSCON_SMCR_SEMI_SREFREQ_ENABLE;
1830 1844 writew(val, U300_SYSCON_VBASE + U300_SYSCON_SMCR);
1831 1845 }
1832   -
1833   -static int core_module_init(void)
1834   -{
1835   - /*
1836   - * This needs to be initialized later: it needs the input framework
1837   - * to be initialized first.
1838   - */
1839   - return mmc_init(&mmcsd_device);
1840   -}
1841   -module_init(core_module_init);
1842 1846  
1843 1847 /* Forward declare this function from the watchdog */
1844 1848 void coh901327_watchdog_reset(void);
arch/arm/mach-u300/mmc.c
1   -/*
2   - *
3   - * arch/arm/mach-u300/mmc.c
4   - *
5   - *
6   - * Copyright (C) 2009 ST-Ericsson SA
7   - * License terms: GNU General Public License (GPL) version 2
8   - *
9   - * Author: Linus Walleij <linus.walleij@stericsson.com>
10   - * Author: Johan Lundin
11   - * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
12   - */
13   -#include <linux/device.h>
14   -#include <linux/amba/bus.h>
15   -#include <linux/mmc/host.h>
16   -#include <linux/dmaengine.h>
17   -#include <linux/amba/mmci.h>
18   -#include <linux/slab.h>
19   -#include <mach/coh901318.h>
20   -#include <mach/dma_channels.h>
21   -
22   -#include "u300-gpio.h"
23   -#include "mmc.h"
24   -
25   -static struct mmci_platform_data mmc0_plat_data = {
26   - /*
27   - * Do not set ocr_mask or voltage translation function,
28   - * we have a regulator we can control instead.
29   - */
30   - /* Nominally 2.85V on our platform */
31   - .f_max = 24000000,
32   - .gpio_wp = -1,
33   - .gpio_cd = U300_GPIO_PIN_MMC_CD,
34   - .cd_invert = true,
35   - .capabilities = MMC_CAP_MMC_HIGHSPEED |
36   - MMC_CAP_SD_HIGHSPEED | MMC_CAP_4_BIT_DATA | MMC_CAP_8_BIT_DATA,
37   -#ifdef CONFIG_COH901318
38   - .dma_filter = coh901318_filter_id,
39   - .dma_rx_param = (void *) U300_DMA_MMCSD_RX_TX,
40   - /* Don't specify a TX channel, this RX channel is bidirectional */
41   -#endif
42   -};
43   -
44   -int __devinit mmc_init(struct amba_device *adev)
45   -{
46   - struct device *mmcsd_device = &adev->dev;
47   - int ret = 0;
48   -
49   - mmcsd_device->platform_data = &mmc0_plat_data;
50   -
51   - return ret;
52   -}
arch/arm/mach-u300/mmc.h
1   -/*
2   - *
3   - * arch/arm/mach-u300/mmc.h
4   - *
5   - *
6   - * Copyright (C) 2009 ST-Ericsson AB
7   - * License terms: GNU General Public License (GPL) version 2
8   - *
9   - * Author: Jonas Aaberg <jonas.aberg@stericsson.com>
10   - */
11   -#ifndef MMC_H
12   -#define MMC_H
13   -
14   -#include <linux/amba/bus.h>
15   -
16   -int __devinit mmc_init(struct amba_device *adev);
17   -
18   -#endif
arch/arm/mach-ux500/board-mop500-sdi.c
... ... @@ -31,21 +31,13 @@
31 31 * SDI 0 (MicroSD slot)
32 32 */
33 33  
34   -/* MMCIPOWER bits */
35   -#define MCI_DATA2DIREN (1 << 2)
36   -#define MCI_CMDDIREN (1 << 3)
37   -#define MCI_DATA0DIREN (1 << 4)
38   -#define MCI_DATA31DIREN (1 << 5)
39   -#define MCI_FBCLKEN (1 << 7)
40   -
41 34 /* GPIO pins used by the sdi0 level shifter */
42 35 static int sdi0_en = -1;
43 36 static int sdi0_vsel = -1;
44 37  
45   -static u32 mop500_sdi0_vdd_handler(struct device *dev, unsigned int vdd,
46   - unsigned char power_mode)
  38 +static int mop500_sdi0_ios_handler(struct device *dev, struct mmc_ios *ios)
47 39 {
48   - switch (power_mode) {
  40 + switch (ios->power_mode) {
49 41 case MMC_POWER_UP:
50 42 case MMC_POWER_ON:
51 43 /*
... ... @@ -65,8 +57,7 @@
65 57 break;
66 58 }
67 59  
68   - return MCI_FBCLKEN | MCI_CMDDIREN | MCI_DATA0DIREN |
69   - MCI_DATA2DIREN | MCI_DATA31DIREN;
  60 + return 0;
70 61 }
71 62  
72 63 #ifdef CONFIG_STE_DMA40
73 64  
... ... @@ -90,13 +81,17 @@
90 81 #endif
91 82  
92 83 static struct mmci_platform_data mop500_sdi0_data = {
93   - .vdd_handler = mop500_sdi0_vdd_handler,
  84 + .ios_handler = mop500_sdi0_ios_handler,
94 85 .ocr_mask = MMC_VDD_29_30,
95 86 .f_max = 50000000,
96 87 .capabilities = MMC_CAP_4_BIT_DATA |
97 88 MMC_CAP_SD_HIGHSPEED |
98 89 MMC_CAP_MMC_HIGHSPEED,
99 90 .gpio_wp = -1,
  91 + .sigdir = MCI_ST_FBCLKEN |
  92 + MCI_ST_CMDDIREN |
  93 + MCI_ST_DATA0DIREN |
  94 + MCI_ST_DATA2DIREN,
100 95 #ifdef CONFIG_STE_DMA40
101 96 .dma_filter = stedma40_filter,
102 97 .dma_rx_param = &mop500_sdi0_dma_cfg_rx,
drivers/char/hw_random/nomadik-rng.c
... ... @@ -107,18 +107,7 @@
107 107 .id_table = nmk_rng_ids,
108 108 };
109 109  
110   -static int __init nmk_rng_init(void)
111   -{
112   - return amba_driver_register(&nmk_rng_driver);
113   -}
114   -
115   -static void __devexit nmk_rng_exit(void)
116   -{
117   - amba_driver_unregister(&nmk_rng_driver);
118   -}
119   -
120   -module_init(nmk_rng_init);
121   -module_exit(nmk_rng_exit);
  110 +module_amba_driver(nmk_rng_driver);
122 111  
123 112 MODULE_LICENSE("GPL");
... ... @@ -1035,18 +1035,7 @@
1035 1035 .remove = pl330_remove,
1036 1036 };
1037 1037  
1038   -static int __init pl330_init(void)
1039   -{
1040   - return amba_driver_register(&pl330_driver);
1041   -}
1042   -module_init(pl330_init);
1043   -
1044   -static void __exit pl330_exit(void)
1045   -{
1046   - amba_driver_unregister(&pl330_driver);
1047   - return;
1048   -}
1049   -module_exit(pl330_exit);
  1038 +module_amba_driver(pl330_driver);
1050 1039  
1051 1040 MODULE_AUTHOR("Jaswinder Singh <jassi.brar@samsung.com>");
1052 1041 MODULE_DESCRIPTION("API Driver for PL330 DMAC");
drivers/input/serio/ambakmi.c
... ... @@ -208,18 +208,7 @@
208 208 .resume = amba_kmi_resume,
209 209 };
210 210  
211   -static int __init amba_kmi_init(void)
212   -{
213   - return amba_driver_register(&ambakmi_driver);
214   -}
215   -
216   -static void __exit amba_kmi_exit(void)
217   -{
218   - amba_driver_unregister(&ambakmi_driver);
219   -}
220   -
221   -module_init(amba_kmi_init);
222   -module_exit(amba_kmi_exit);
  211 +module_amba_driver(ambakmi_driver);
223 212  
224 213 MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
225 214 MODULE_DESCRIPTION("AMBA KMI controller driver");
drivers/mmc/host/mmci.c
... ... @@ -53,6 +53,8 @@
53 53 * @sdio: variant supports SDIO
54 54 * @st_clkdiv: true if using a ST-specific clock divider algorithm
55 55 * @blksz_datactrl16: true if Block size is at b16..b30 position in datactrl register
  56 + * @pwrreg_powerup: power up value for MMCIPOWER register
  57 + * @signal_direction: input/out direction of bus signals can be indicated
56 58 */
57 59 struct variant_data {
58 60 unsigned int clkreg;
59 61  
60 62  
... ... @@ -63,18 +65,22 @@
63 65 bool sdio;
64 66 bool st_clkdiv;
65 67 bool blksz_datactrl16;
  68 + u32 pwrreg_powerup;
  69 + bool signal_direction;
66 70 };
67 71  
68 72 static struct variant_data variant_arm = {
69 73 .fifosize = 16 * 4,
70 74 .fifohalfsize = 8 * 4,
71 75 .datalength_bits = 16,
  76 + .pwrreg_powerup = MCI_PWR_UP,
72 77 };
73 78  
74 79 static struct variant_data variant_arm_extended_fifo = {
75 80 .fifosize = 128 * 4,
76 81 .fifohalfsize = 64 * 4,
77 82 .datalength_bits = 16,
  83 + .pwrreg_powerup = MCI_PWR_UP,
78 84 };
79 85  
80 86 static struct variant_data variant_u300 = {
... ... @@ -83,6 +89,8 @@
83 89 .clkreg_enable = MCI_ST_U300_HWFCEN,
84 90 .datalength_bits = 16,
85 91 .sdio = true,
  92 + .pwrreg_powerup = MCI_PWR_ON,
  93 + .signal_direction = true,
86 94 };
87 95  
88 96 static struct variant_data variant_ux500 = {
... ... @@ -93,6 +101,8 @@
93 101 .datalength_bits = 24,
94 102 .sdio = true,
95 103 .st_clkdiv = true,
  104 + .pwrreg_powerup = MCI_PWR_ON,
  105 + .signal_direction = true,
96 106 };
97 107  
98 108 static struct variant_data variant_ux500v2 = {
99 109  
... ... @@ -104,11 +114,35 @@
104 114 .sdio = true,
105 115 .st_clkdiv = true,
106 116 .blksz_datactrl16 = true,
  117 + .pwrreg_powerup = MCI_PWR_ON,
  118 + .signal_direction = true,
107 119 };
108 120  
109 121 /*
110 122 * This must be called with host->lock held
111 123 */
  124 +static void mmci_write_clkreg(struct mmci_host *host, u32 clk)
  125 +{
  126 + if (host->clk_reg != clk) {
  127 + host->clk_reg = clk;
  128 + writel(clk, host->base + MMCICLOCK);
  129 + }
  130 +}
  131 +
  132 +/*
  133 + * This must be called with host->lock held
  134 + */
  135 +static void mmci_write_pwrreg(struct mmci_host *host, u32 pwr)
  136 +{
  137 + if (host->pwr_reg != pwr) {
  138 + host->pwr_reg = pwr;
  139 + writel(pwr, host->base + MMCIPOWER);
  140 + }
  141 +}
  142 +
  143 +/*
  144 + * This must be called with host->lock held
  145 + */
112 146 static void mmci_set_clkreg(struct mmci_host *host, unsigned int desired)
113 147 {
114 148 struct variant_data *variant = host->variant;
... ... @@ -153,7 +187,7 @@
153 187 if (host->mmc->ios.bus_width == MMC_BUS_WIDTH_8)
154 188 clk |= MCI_ST_8BIT_BUS;
155 189  
156   - writel(clk, host->base + MMCICLOCK);
  190 + mmci_write_clkreg(host, clk);
157 191 }
158 192  
159 193 static void
160 194  
... ... @@ -166,14 +200,10 @@
166 200 host->mrq = NULL;
167 201 host->cmd = NULL;
168 202  
169   - /*
170   - * Need to drop the host lock here; mmc_request_done may call
171   - * back into the driver...
172   - */
173   - spin_unlock(&host->lock);
174   - pm_runtime_put(mmc_dev(host->mmc));
175 203 mmc_request_done(host->mmc, mrq);
176   - spin_lock(&host->lock);
  204 +
  205 + pm_runtime_mark_last_busy(mmc_dev(host->mmc));
  206 + pm_runtime_put_autosuspend(mmc_dev(host->mmc));
177 207 }
178 208  
179 209 static void mmci_set_mask1(struct mmci_host *host, unsigned int mask)
... ... @@ -607,6 +637,11 @@
607 637 if (data->flags & MMC_DATA_READ)
608 638 datactrl |= MCI_DPSM_DIRECTION;
609 639  
  640 + /* The ST Micro variants has a special bit to enable SDIO */
  641 + if (variant->sdio && host->mmc->card)
  642 + if (mmc_card_sdio(host->mmc->card))
  643 + datactrl |= MCI_ST_DPSM_SDIOEN;
  644 +
610 645 /*
611 646 * Attempt to use DMA operation mode, if this
612 647 * should fail, fall back to PIO mode
... ... @@ -635,11 +670,6 @@
635 670 irqmask = MCI_TXFIFOHALFEMPTYMASK;
636 671 }
637 672  
638   - /* The ST Micro variants has a special bit to enable SDIO */
639   - if (variant->sdio && host->mmc->card)
640   - if (mmc_card_sdio(host->mmc->card))
641   - datactrl |= MCI_ST_DPSM_SDIOEN;
642   -
643 673 writel(datactrl, base + MMCIDATACTRL);
644 674 writel(readl(base + MMCIMASK0) & ~MCI_DATAENDMASK, base + MMCIMASK0);
645 675 mmci_set_mask1(host, irqmask);
... ... @@ -786,7 +816,24 @@
786 816 if (count <= 0)
787 817 break;
788 818  
789   - readsl(base + MMCIFIFO, ptr, count >> 2);
  819 + /*
  820 + * SDIO especially may want to send something that is
  821 + * not divisible by 4 (as opposed to card sectors
  822 + * etc). Therefore make sure to always read the last bytes
  823 + * while only doing full 32-bit reads towards the FIFO.
  824 + */
  825 + if (unlikely(count & 0x3)) {
  826 + if (count < 4) {
  827 + unsigned char buf[4];
  828 + readsl(base + MMCIFIFO, buf, 1);
  829 + memcpy(ptr, buf, count);
  830 + } else {
  831 + readsl(base + MMCIFIFO, ptr, count >> 2);
  832 + count &= ~0x3;
  833 + }
  834 + } else {
  835 + readsl(base + MMCIFIFO, ptr, count >> 2);
  836 + }
790 837  
791 838 ptr += count;
792 839 remain -= count;
793 840  
794 841  
... ... @@ -821,14 +868,13 @@
821 868 */
822 869 if (variant->sdio &&
823 870 mmc_card_sdio(host->mmc->card)) {
  871 + u32 clk;
824 872 if (count < 8)
825   - writel(readl(host->base + MMCICLOCK) &
826   - ~variant->clkreg_enable,
827   - host->base + MMCICLOCK);
  873 + clk = host->clk_reg & ~variant->clkreg_enable;
828 874 else
829   - writel(readl(host->base + MMCICLOCK) |
830   - variant->clkreg_enable,
831   - host->base + MMCICLOCK);
  875 + clk = host->clk_reg | variant->clkreg_enable;
  876 +
  877 + mmci_write_clkreg(host, clk);
832 878 }
833 879  
834 880 /*
835 881  
... ... @@ -1015,10 +1061,17 @@
1015 1061 static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
1016 1062 {
1017 1063 struct mmci_host *host = mmc_priv(mmc);
  1064 + struct variant_data *variant = host->variant;
1018 1065 u32 pwr = 0;
1019 1066 unsigned long flags;
1020 1067 int ret;
1021 1068  
  1069 + pm_runtime_get_sync(mmc_dev(mmc));
  1070 +
  1071 + if (host->plat->ios_handler &&
  1072 + host->plat->ios_handler(mmc_dev(mmc), ios))
  1073 + dev_err(mmc_dev(mmc), "platform ios_handler failed\n");
  1074 +
1022 1075 switch (ios->power_mode) {
1023 1076 case MMC_POWER_OFF:
1024 1077 if (host->vcc)
1025 1078  
1026 1079  
... ... @@ -1035,22 +1088,38 @@
1035 1088 * power should be rare so we print an error
1036 1089 * and return here.
1037 1090 */
1038   - return;
  1091 + goto out;
1039 1092 }
1040 1093 }
1041   - if (host->plat->vdd_handler)
1042   - pwr |= host->plat->vdd_handler(mmc_dev(mmc), ios->vdd,
1043   - ios->power_mode);
1044   - /* The ST version does not have this, fall through to POWER_ON */
1045   - if (host->hw_designer != AMBA_VENDOR_ST) {
1046   - pwr |= MCI_PWR_UP;
1047   - break;
1048   - }
  1094 + /*
  1095 + * The ST Micro variant doesn't have the PL180s MCI_PWR_UP
  1096 + * and instead uses MCI_PWR_ON so apply whatever value is
  1097 + * configured in the variant data.
  1098 + */
  1099 + pwr |= variant->pwrreg_powerup;
  1100 +
  1101 + break;
1049 1102 case MMC_POWER_ON:
1050 1103 pwr |= MCI_PWR_ON;
1051 1104 break;
1052 1105 }
1053 1106  
  1107 + if (variant->signal_direction && ios->power_mode != MMC_POWER_OFF) {
  1108 + /*
  1109 + * The ST Micro variant has some additional bits
  1110 + * indicating signal direction for the signals in
  1111 + * the SD/MMC bus and feedback-clock usage.
  1112 + */
  1113 + pwr |= host->plat->sigdir;
  1114 +
  1115 + if (ios->bus_width == MMC_BUS_WIDTH_4)
  1116 + pwr &= ~MCI_ST_DATA74DIREN;
  1117 + else if (ios->bus_width == MMC_BUS_WIDTH_1)
  1118 + pwr &= (~MCI_ST_DATA74DIREN &
  1119 + ~MCI_ST_DATA31DIREN &
  1120 + ~MCI_ST_DATA2DIREN);
  1121 + }
  1122 +
1054 1123 if (ios->bus_mode == MMC_BUSMODE_OPENDRAIN) {
1055 1124 if (host->hw_designer != AMBA_VENDOR_ST)
1056 1125 pwr |= MCI_ROD;
1057 1126  
1058 1127  
... ... @@ -1066,13 +1135,13 @@
1066 1135 spin_lock_irqsave(&host->lock, flags);
1067 1136  
1068 1137 mmci_set_clkreg(host, ios->clock);
  1138 + mmci_write_pwrreg(host, pwr);
1069 1139  
1070   - if (host->pwr != pwr) {
1071   - host->pwr = pwr;
1072   - writel(pwr, host->base + MMCIPOWER);
1073   - }
1074   -
1075 1140 spin_unlock_irqrestore(&host->lock, flags);
  1141 +
  1142 + out:
  1143 + pm_runtime_mark_last_busy(mmc_dev(mmc));
  1144 + pm_runtime_put_autosuspend(mmc_dev(mmc));
1076 1145 }
1077 1146  
1078 1147 static int mmci_get_ro(struct mmc_host *mmc)
... ... @@ -1346,6 +1415,8 @@
1346 1415  
1347 1416 mmci_dma_setup(host);
1348 1417  
  1418 + pm_runtime_set_autosuspend_delay(&dev->dev, 50);
  1419 + pm_runtime_use_autosuspend(&dev->dev);
1349 1420 pm_runtime_put(&dev->dev);
1350 1421  
1351 1422 mmc_add_host(mmc);
1352 1423  
1353 1424  
1354 1425  
1355 1426  
1356 1427  
1357 1428  
1358 1429  
1359 1430  
... ... @@ -1430,43 +1501,49 @@
1430 1501 return 0;
1431 1502 }
1432 1503  
1433   -#ifdef CONFIG_PM
1434   -static int mmci_suspend(struct amba_device *dev, pm_message_t state)
  1504 +#ifdef CONFIG_SUSPEND
  1505 +static int mmci_suspend(struct device *dev)
1435 1506 {
1436   - struct mmc_host *mmc = amba_get_drvdata(dev);
  1507 + struct amba_device *adev = to_amba_device(dev);
  1508 + struct mmc_host *mmc = amba_get_drvdata(adev);
1437 1509 int ret = 0;
1438 1510  
1439 1511 if (mmc) {
1440 1512 struct mmci_host *host = mmc_priv(mmc);
1441 1513  
1442 1514 ret = mmc_suspend_host(mmc);
1443   - if (ret == 0)
  1515 + if (ret == 0) {
  1516 + pm_runtime_get_sync(dev);
1444 1517 writel(0, host->base + MMCIMASK0);
  1518 + }
1445 1519 }
1446 1520  
1447 1521 return ret;
1448 1522 }
1449 1523  
1450   -static int mmci_resume(struct amba_device *dev)
  1524 +static int mmci_resume(struct device *dev)
1451 1525 {
1452   - struct mmc_host *mmc = amba_get_drvdata(dev);
  1526 + struct amba_device *adev = to_amba_device(dev);
  1527 + struct mmc_host *mmc = amba_get_drvdata(adev);
1453 1528 int ret = 0;
1454 1529  
1455 1530 if (mmc) {
1456 1531 struct mmci_host *host = mmc_priv(mmc);
1457 1532  
1458 1533 writel(MCI_IRQENABLE, host->base + MMCIMASK0);
  1534 + pm_runtime_put(dev);
1459 1535  
1460 1536 ret = mmc_resume_host(mmc);
1461 1537 }
1462 1538  
1463 1539 return ret;
1464 1540 }
1465   -#else
1466   -#define mmci_suspend NULL
1467   -#define mmci_resume NULL
1468 1541 #endif
1469 1542  
  1543 +static const struct dev_pm_ops mmci_dev_pm_ops = {
  1544 + SET_SYSTEM_SLEEP_PM_OPS(mmci_suspend, mmci_resume)
  1545 +};
  1546 +
1470 1547 static struct amba_id mmci_ids[] = {
1471 1548 {
1472 1549 .id = 0x00041180,
1473 1550  
1474 1551  
1475 1552  
... ... @@ -1512,26 +1589,15 @@
1512 1589 static struct amba_driver mmci_driver = {
1513 1590 .drv = {
1514 1591 .name = DRIVER_NAME,
  1592 + .pm = &mmci_dev_pm_ops,
1515 1593 },
1516 1594 .probe = mmci_probe,
1517 1595 .remove = __devexit_p(mmci_remove),
1518   - .suspend = mmci_suspend,
1519   - .resume = mmci_resume,
1520 1596 .id_table = mmci_ids,
1521 1597 };
1522 1598  
1523   -static int __init mmci_init(void)
1524   -{
1525   - return amba_driver_register(&mmci_driver);
1526   -}
  1599 +module_amba_driver(mmci_driver);
1527 1600  
1528   -static void __exit mmci_exit(void)
1529   -{
1530   - amba_driver_unregister(&mmci_driver);
1531   -}
1532   -
1533   -module_init(mmci_init);
1534   -module_exit(mmci_exit);
1535 1601 module_param(fmax, uint, 0444);
1536 1602  
1537 1603 MODULE_DESCRIPTION("ARM PrimeCell PL180/181 Multimedia Card Interface driver");
drivers/mmc/host/mmci.h
... ... @@ -13,16 +13,6 @@
13 13 #define MCI_PWR_ON 0x03
14 14 #define MCI_OD (1 << 6)
15 15 #define MCI_ROD (1 << 7)
16   -/*
17   - * The ST Micro version does not have ROD and reuse the voltage registers
18   - * for direction settings
19   - */
20   -#define MCI_ST_DATA2DIREN (1 << 2)
21   -#define MCI_ST_CMDDIREN (1 << 3)
22   -#define MCI_ST_DATA0DIREN (1 << 4)
23   -#define MCI_ST_DATA31DIREN (1 << 5)
24   -#define MCI_ST_FBCLKEN (1 << 7)
25   -#define MCI_ST_DATA74DIREN (1 << 8)
26 16  
27 17 #define MMCICLOCK 0x004
28 18 #define MCI_CLK_ENABLE (1 << 8)
... ... @@ -160,7 +150,7 @@
160 150 (MCI_RXFIFOHALFFULLMASK | MCI_RXDATAAVLBLMASK | \
161 151 MCI_TXFIFOHALFEMPTYMASK)
162 152  
163   -#define NR_SG 16
  153 +#define NR_SG 128
164 154  
165 155 struct clk;
166 156 struct variant_data;
... ... @@ -189,7 +179,8 @@
189 179  
190 180 unsigned int mclk;
191 181 unsigned int cclk;
192   - u32 pwr;
  182 + u32 pwr_reg;
  183 + u32 clk_reg;
193 184 struct mmci_platform_data *plat;
194 185 struct variant_data *variant;
195 186  
drivers/rtc/rtc-pl030.c
... ... @@ -185,18 +185,7 @@
185 185 .id_table = pl030_ids,
186 186 };
187 187  
188   -static int __init pl030_init(void)
189   -{
190   - return amba_driver_register(&pl030_driver);
191   -}
192   -
193   -static void __exit pl030_exit(void)
194   -{
195   - amba_driver_unregister(&pl030_driver);
196   -}
197   -
198   -module_init(pl030_init);
199   -module_exit(pl030_exit);
  188 +module_amba_driver(pl030_driver);
200 189  
201 190 MODULE_AUTHOR("Russell King <rmk@arm.linux.org.uk>");
202 191 MODULE_DESCRIPTION("ARM AMBA PL030 RTC Driver");
drivers/rtc/rtc-pl031.c
... ... @@ -431,18 +431,7 @@
431 431 .remove = pl031_remove,
432 432 };
433 433  
434   -static int __init pl031_init(void)
435   -{
436   - return amba_driver_register(&pl031_driver);
437   -}
438   -
439   -static void __exit pl031_exit(void)
440   -{
441   - amba_driver_unregister(&pl031_driver);
442   -}
443   -
444   -module_init(pl031_init);
445   -module_exit(pl031_exit);
  434 +module_amba_driver(pl031_driver);
446 435  
447 436 MODULE_AUTHOR("Deepak Saxena <dsaxena@plexity.net");
448 437 MODULE_DESCRIPTION("ARM AMBA PL031 RTC Driver");
drivers/watchdog/sp805_wdt.c
... ... @@ -370,17 +370,7 @@
370 370 .remove = __devexit_p(sp805_wdt_remove),
371 371 };
372 372  
373   -static int __init sp805_wdt_init(void)
374   -{
375   - return amba_driver_register(&sp805_wdt_driver);
376   -}
377   -module_init(sp805_wdt_init);
378   -
379   -static void __exit sp805_wdt_exit(void)
380   -{
381   - amba_driver_unregister(&sp805_wdt_driver);
382   -}
383   -module_exit(sp805_wdt_exit);
  373 +module_amba_driver(sp805_wdt_driver);
384 374  
385 375 module_param(nowayout, int, 0);
386 376 MODULE_PARM_DESC(nowayout,
include/linux/amba/bus.h
... ... @@ -125,5 +125,14 @@
125 125 .periphid = id, \
126 126 }
127 127  
  128 +/*
  129 + * module_amba_driver() - Helper macro for drivers that don't do anything
  130 + * special in module init/exit. This eliminates a lot of boilerplate. Each
  131 + * module may only use this macro once, and calling it replaces module_init()
  132 + * and module_exit()
  133 + */
  134 +#define module_amba_driver(__amba_drv) \
  135 + module_driver(__amba_drv, amba_driver_register, amba_driver_unregister)
  136 +
128 137 #endif
include/linux/amba/mmci.h
... ... @@ -6,6 +6,19 @@
6 6  
7 7 #include <linux/mmc/host.h>
8 8  
  9 +
  10 +/*
  11 + * These defines is places here due to access is needed from machine
  12 + * configuration files. The ST Micro version does not have ROD and
  13 + * reuse the voltage registers for direction settings.
  14 + */
  15 +#define MCI_ST_DATA2DIREN (1 << 2)
  16 +#define MCI_ST_CMDDIREN (1 << 3)
  17 +#define MCI_ST_DATA0DIREN (1 << 4)
  18 +#define MCI_ST_DATA31DIREN (1 << 5)
  19 +#define MCI_ST_FBCLKEN (1 << 7)
  20 +#define MCI_ST_DATA74DIREN (1 << 8)
  21 +
9 22 /* Just some dummy forwarding */
10 23 struct dma_chan;
11 24  
... ... @@ -18,7 +31,8 @@
18 31 * @ocr_mask: available voltages on the 4 pins from the block, this
19 32 * is ignored if a regulator is used, see the MMC_VDD_* masks in
20 33 * mmc/host.h
21   - * @vdd_handler: a callback function to translate a MMC_VDD_*
  34 + * @ios_handler: a callback function to act on specfic ios changes,
  35 + * used for example to control a levelshifter
22 36 * mask into a value to be binary (or set some other custom bits
23 37 * in MMCIPWR) or:ed and written into the MMCIPWR register of the
24 38 * block. May also control external power based on the power_mode.
... ... @@ -31,6 +45,8 @@
31 45 * @capabilities: the capabilities of the block as implemented in
32 46 * this platform, signify anything MMC_CAP_* from mmc/host.h
33 47 * @capabilities2: more capabilities, MMC_CAP2_* from mmc/host.h
  48 + * @sigdir: a bit field indicating for what bits in the MMC bus the host
  49 + * should enable signal direction indication.
34 50 * @dma_filter: function used to select an appropriate RX and TX
35 51 * DMA channel to be used for DMA, if and only if you're deploying the
36 52 * generic DMA engine
37 53  
... ... @@ -46,14 +62,14 @@
46 62 struct mmci_platform_data {
47 63 unsigned int f_max;
48 64 unsigned int ocr_mask;
49   - u32 (*vdd_handler)(struct device *, unsigned int vdd,
50   - unsigned char power_mode);
  65 + int (*ios_handler)(struct device *, struct mmc_ios *);
51 66 unsigned int (*status)(struct device *);
52 67 int gpio_wp;
53 68 int gpio_cd;
54 69 bool cd_invert;
55 70 unsigned long capabilities;
56 71 unsigned long capabilities2;
  72 + u32 sigdir;
57 73 bool (*dma_filter)(struct dma_chan *chan, void *filter_param);
58 74 void *dma_rx_param;
59 75 void *dma_tx_param;
... ... @@ -1110,18 +1110,7 @@
1110 1110 .id_table = aaci_ids,
1111 1111 };
1112 1112  
1113   -static int __init aaci_init(void)
1114   -{
1115   - return amba_driver_register(&aaci_driver);
1116   -}
1117   -
1118   -static void __exit aaci_exit(void)
1119   -{
1120   - amba_driver_unregister(&aaci_driver);
1121   -}
1122   -
1123   -module_init(aaci_init);
1124   -module_exit(aaci_exit);
  1113 +module_amba_driver(aaci_driver);
1125 1114  
1126 1115 MODULE_LICENSE("GPL");
1127 1116 MODULE_DESCRIPTION("ARM PrimeCell PL041 Advanced Audio CODEC Interface driver");