Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'mmc-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc

Pull MMC updates from Ulf Hansson:
"This time, this pull request contains changes crossing subsystems and
archs/platforms, which is mainly because of a bigger modernization of
moving from legacy GPIO to GPIO descriptors for MMC (by Linus
Walleij).

Additionally, once again, I am funneling changes to
drivers/misc/cardreader/* and drivers/memstick/* through my MMC tree,
mostly due to that we lack a maintainer for these.

Summary:

MMC core:
- Cleanup BKOPS support
- Introduce MMC_CAP_SYNC_RUNTIME_PM
- slot-gpio: Delete legacy slot GPIO handling

MMC host:
- alcor: Add new mmc host driver for Alcor Micro PCI based cardreader
- bcm2835: Several improvements to better recover from errors
- jz4740: Rework and fixup pre|post_req support
- mediatek: Add support for SDIO IRQs
- meson-gx: Improve clock phase management
- meson-gx: Stop descriptor on errors
- mmci: Complete the sbc error path by sending a stop command
- renesas_sdhi/tmio: Fixup reset/resume operations
- renesas_sdhi: Add support for r8a774c0 and R7S9210
- renesas_sdhi: Whitelist R8A77990 SDHI
- renesas_sdhi: Fixup eMMC HS400 compatibility issues for H3 and M3-W
- rtsx_usb_sdmmc: Re-work card detection/removal support
- rtsx_usb_sdmmc: Re-work runtime PM support
- sdhci: Fix timeout loops for some variant drivers
- sdhci: Improve support for error handling due to failing commands
- sdhci-acpi/pci: Disable LED control for Intel BYT-based controllers
- sdhci_am654: Add new SDHCI variant driver to support TI's AM654 SOCs
- sdhci-of-esdhc: Add support for eMMC HS400 mode
- sdhci-omap: Fixup reset support
- sdhci-omap: Workaround errata regarding SDR104/HS200 tuning failures
- sdhci-msm: Fixup sporadic write transfers issues for SDR104/HS200
- sdhci-msm: Fixup dynamical clock gating issues
- various: Complete converting all hosts into using slot GPIO descriptors

Other:
- Move GPIO mmc platform data for mips/sh/arm to GPIO descriptors
- Add new Alcor Micro cardreader PCI driver
- Support runtime power management for memstick rtsx_usb_ms driver
- Use USB remote wakeups for card detection for rtsx_usb misc driver"

* tag 'mmc-v4.21' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (99 commits)
mmc: mediatek: Add MMC_CAP_SDIO_IRQ support
mmc: renesas_sdhi_internal_dmac: Whitelist r8a774c0
dt-bindings: mmc: renesas_sdhi: Add r8a774c0 support
mmc: core: Cleanup BKOPS support
mmc: core: Drop redundant check in mmc_send_hpi_cmd()
mmc: sdhci-omap: Workaround errata regarding SDR104/HS200 tuning failures (i929)
dt-bindings: sdhci-omap: Add note for cpu_thermal
mmc: sdhci-acpi: Disable LED control for Intel BYT-based controllers
mmc: sdhci-pci: Disable LED control for Intel BYT-based controllers
mmc: sdhci: Add quirk to disable LED control
mmc: mmci: add variant property to set command stop bit
misc: alcor_pci: fix spelling mistake "invailid" -> "invalid"
mmc: meson-gx: add signal resampling
mmc: meson-gx: align default phase on soc vendor tree
mmc: meson-gx: remove useless lock
mmc: meson-gx: make sure the descriptor is stopped on errors
mmc: sdhci_am654: Add Initial Support for AM654 SDHCI driver
dt-bindings: mmc: sdhci-of-arasan: Add deprecated message for AM65
dt-bindings: mmc: sdhci-am654: Document bindings for the host controllers on TI's AM654 SOCs
mmc: sdhci-msm: avoid unused function warning
...

+4019 -1106
+4
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt
··· 16 16 - "rockchip,rk3399-sdhci-5.1", "arasan,sdhci-5.1": rk3399 eMMC PHY 17 17 For this device it is strongly suggested to include arasan,soc-ctl-syscon. 18 18 - "ti,am654-sdhci-5.1", "arasan,sdhci-5.1": TI AM654 MMC PHY 19 + Note: This binding has been deprecated and moved to [5]. 20 + 21 + [5] Documentation/devicetree/bindings/mmc/sdhci-am654.txt 22 + 19 23 - reg: From mmc bindings: Register location and length. 20 24 - clocks: From clock bindings: Handles to clock inputs. 21 25 - clock-names: From clock bindings: Tuple including "clk_xin" and "clk_ahb"
+1
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
··· 16 16 "fsl,imx6sl-usdhc" 17 17 "fsl,imx6sx-usdhc" 18 18 "fsl,imx7d-usdhc" 19 + "fsl,imx8qxp-usdhc" 19 20 20 21 Optional properties: 21 22 - fsl,wp-controller : Indicate to use controller internal write protection
+36
Documentation/devicetree/bindings/mmc/sdhci-am654.txt
··· 1 + Device Tree Bindings for the SDHCI Controllers present on TI's AM654 SOCs 2 + 3 + The bindings follow the mmc[1], clock[2] and interrupt[3] bindings. 4 + Only deviations are documented here. 5 + 6 + [1] Documentation/devicetree/bindings/mmc/mmc.txt 7 + [2] Documentation/devicetree/bindings/clock/clock-bindings.txt 8 + [3] Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 9 + 10 + Required Properties: 11 + - compatible: should be "ti,am654-sdhci-5.1" 12 + - reg: Must be two entries. 13 + - The first should be the sdhci register space 14 + - The second should the subsystem/phy register space 15 + - clocks: Handles to the clock inputs. 16 + - clock-names: Tuple including "clk_xin" and "clk_ahb" 17 + - interrupts: Interrupt specifiers 18 + - ti,otap-del-sel: Output Tap Delay select 19 + - ti,trm-icp: DLL trim select 20 + - ti,driver-strength-ohm: driver strength in ohms. 21 + Valid values are 33, 40, 50, 66 and 100 ohms. 22 + 23 + Example: 24 + 25 + sdhci0: sdhci@4f80000 { 26 + compatible = "ti,am654-sdhci-5.1"; 27 + reg = <0x0 0x4f80000 0x0 0x260>, <0x0 0x4f90000 0x0 0x134>; 28 + power-domains = <&k3_pds 47>; 29 + clocks = <&k3_clks 47 0>, <&k3_clks 47 1>; 30 + clock-names = "clk_ahb", "clk_xin"; 31 + interrupts = <GIC_SPI 136 IRQ_TYPE_LEVEL_HIGH>; 32 + sdhci-caps-mask = <0x80000007 0x0>; 33 + mmc-ddr-1_8v; 34 + ti,otap-del-sel = <0x2>; 35 + ti,trm-icp = <0x8>; 36 + };
+18 -5
Documentation/devicetree/bindings/mmc/sdhci-msm.txt
··· 4 4 and the properties used by the sdhci-msm driver. 5 5 6 6 Required properties: 7 - - compatible: Should contain: 7 + - compatible: Should contain a SoC-specific string and a IP version string: 8 + version strings: 8 9 "qcom,sdhci-msm-v4" for sdcc versions less than 5.0 9 - "qcom,sdhci-msm-v5" for sdcc versions >= 5.0 10 + "qcom,sdhci-msm-v5" for sdcc version 5.0 10 11 For SDCC version 5.0.0, MCI registers are removed from SDCC 11 12 interface and some registers are moved to HC. New compatible 12 13 string is added to support this change - "qcom,sdhci-msm-v5". 14 + full compatible strings with SoC and version: 15 + "qcom,apq8084-sdhci", "qcom,sdhci-msm-v4" 16 + "qcom,msm8974-sdhci", "qcom,sdhci-msm-v4" 17 + "qcom,msm8916-sdhci", "qcom,sdhci-msm-v4" 18 + "qcom,msm8992-sdhci", "qcom,sdhci-msm-v4" 19 + "qcom,msm8996-sdhci", "qcom,sdhci-msm-v4" 20 + "qcom,sdm845-sdhci", "qcom,sdhci-msm-v5" 21 + "qcom,qcs404-sdhci", "qcom,sdhci-msm-v5" 22 + NOTE that some old device tree files may be floating around that only 23 + have the string "qcom,sdhci-msm-v4" without the SoC compatible string 24 + but doing that should be considered a deprecated practice. 25 + 13 26 - reg: Base address and length of the register in the following order: 14 27 - Host controller register map (required) 15 - - SD Core register map (required) 28 + - SD Core register map (required for msm-v4 and below) 16 29 - interrupts: Should contain an interrupt-specifiers for the interrupts: 17 30 - Host controller interrupt (required) 18 31 - pinctrl-names: Should contain only one value - "default". ··· 42 29 Example: 43 30 44 31 sdhc_1: sdhci@f9824900 { 45 - compatible = "qcom,sdhci-msm-v4"; 32 + compatible = "qcom,msm8974-sdhci", "qcom,sdhci-msm-v4"; 46 33 reg = <0xf9824900 0x11c>, <0xf9824000 0x800>; 47 34 interrupts = <0 123 0>; 48 35 bus-width = <8>; ··· 59 46 }; 60 47 61 48 sdhc_2: sdhci@f98a4900 { 62 - compatible = "qcom,sdhci-msm-v4"; 49 + compatible = "qcom,msm8974-sdhci", "qcom,sdhci-msm-v4"; 63 50 reg = <0xf98a4900 0x11c>, <0xf98a4000 0x800>; 64 51 interrupts = <0 125 0>; 65 52 bus-width = <4>;
+2
Documentation/devicetree/bindings/mmc/sdhci-omap.txt
··· 2 2 3 3 Refer to mmc.txt for standard MMC bindings. 4 4 5 + For UHS devices which require tuning, the device tree should have a "cpu_thermal" node which maps to the appropriate thermal zone. This is used to get the temperature of the zone during tuning. 6 + 5 7 Required properties: 6 8 - compatible: Should be "ti,dra7-sdhci" for DRA7 and DRA72 controllers 7 9 Should be "ti,k2g-sdhci" for K2G
+3 -1
Documentation/devicetree/bindings/mmc/tmio_mmc.txt
··· 13 13 - compatible: should contain one or more of the following: 14 14 "renesas,sdhi-sh73a0" - SDHI IP on SH73A0 SoC 15 15 "renesas,sdhi-r7s72100" - SDHI IP on R7S72100 SoC 16 + "renesas,sdhi-r7s9210" - SDHI IP on R7S9210 SoC 16 17 "renesas,sdhi-r8a73a4" - SDHI IP on R8A73A4 SoC 17 18 "renesas,sdhi-r8a7740" - SDHI IP on R8A7740 SoC 18 19 "renesas,sdhi-r8a7743" - SDHI IP on R8A7743 SoC 19 20 "renesas,sdhi-r8a7744" - SDHI IP on R8A7744 SoC 20 21 "renesas,sdhi-r8a7745" - SDHI IP on R8A7745 SoC 21 22 "renesas,sdhi-r8a774a1" - SDHI IP on R8A774A1 SoC 23 + "renesas,sdhi-r8a774c0" - SDHI IP on R8A774C0 SoC 22 24 "renesas,sdhi-r8a77470" - SDHI IP on R8A77470 SoC 23 25 "renesas,sdhi-mmc-r8a77470" - SDHI/MMC IP on R8A77470 SoC 24 26 "renesas,sdhi-r8a7778" - SDHI IP on R8A7778 SoC ··· 58 56 "core" and "cd". If the controller only has 1 clock, naming is not 59 57 required. 60 58 Devices which have more than 1 clock are listed below: 61 - 2: R7S72100 59 + 2: R7S72100, R7S9210 62 60 63 61 Optional properties: 64 62 - pinctrl-names: should be "default", "state_uhs"
+11 -3
arch/arm/mach-ep93xx/simone.c
··· 25 25 #include <linux/platform_data/video-ep93xx.h> 26 26 #include <linux/platform_data/spi-ep93xx.h> 27 27 #include <linux/gpio.h> 28 + #include <linux/gpio/machine.h> 28 29 29 30 #include <mach/hardware.h> 30 31 #include <mach/gpio-ep93xx.h> ··· 46 45 static struct mmc_spi_platform_data simone_mmc_spi_data = { 47 46 .detect_delay = 500, 48 47 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 49 - .flags = MMC_SPI_USE_CD_GPIO, 50 - .cd_gpio = EP93XX_GPIO_LINE_EGPIO0, 51 - .cd_debounce = 1, 48 + }; 49 + 50 + static struct gpiod_lookup_table simone_mmc_spi_gpio_table = { 51 + .dev_id = "mmc_spi.0", /* "mmc_spi" @ CS0 */ 52 + .table = { 53 + /* Card detect */ 54 + GPIO_LOOKUP_IDX("A", 0, NULL, 0, GPIO_ACTIVE_LOW), 55 + { }, 56 + }, 52 57 }; 53 58 54 59 static struct spi_board_info simone_spi_devices[] __initdata = { ··· 112 105 ep93xx_register_fb(&simone_fb_info); 113 106 ep93xx_register_i2c(simone_i2c_board_info, 114 107 ARRAY_SIZE(simone_i2c_board_info)); 108 + gpiod_add_lookup_table(&simone_mmc_spi_gpio_table); 115 109 ep93xx_register_spi(&simone_spi_info, simone_spi_devices, 116 110 ARRAY_SIZE(simone_spi_devices)); 117 111 simone_register_audio();
+13 -4
arch/arm/mach-ep93xx/vision_ep9307.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/irq.h> 20 20 #include <linux/gpio.h> 21 + #include <linux/gpio/machine.h> 21 22 #include <linux/fb.h> 22 23 #include <linux/io.h> 23 24 #include <linux/mtd/partitions.h> ··· 203 202 .detect_delay = 100, 204 203 .powerup_msecs = 100, 205 204 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 206 - .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO, 207 - .cd_gpio = EP93XX_GPIO_LINE_EGPIO15, 208 - .cd_debounce = 1, 209 - .ro_gpio = EP93XX_GPIO_LINE_F(0), 210 205 .caps2 = MMC_CAP2_RO_ACTIVE_HIGH, 206 + }; 207 + 208 + static struct gpiod_lookup_table vision_spi_mmc_gpio_table = { 209 + .dev_id = "mmc_spi.2", /* "mmc_spi @ CS2 */ 210 + .table = { 211 + /* Card detect */ 212 + GPIO_LOOKUP_IDX("B", 7, NULL, 0, GPIO_ACTIVE_LOW), 213 + /* Write protect */ 214 + GPIO_LOOKUP_IDX("F", 0, NULL, 1, GPIO_ACTIVE_HIGH), 215 + { }, 216 + }, 211 217 }; 212 218 213 219 /************************************************************************* ··· 294 286 295 287 ep93xx_register_i2c(vision_i2c_info, 296 288 ARRAY_SIZE(vision_i2c_info)); 289 + gpiod_add_lookup_table(&vision_spi_mmc_gpio_table); 297 290 ep93xx_register_spi(&vision_spi_master, vision_spi_board_info, 298 291 ARRAY_SIZE(vision_spi_board_info)); 299 292 vision_register_i2s();
+13 -4
arch/arm/mach-imx/mach-pcm043.c
··· 20 20 #include <linux/mtd/plat-ram.h> 21 21 #include <linux/memory.h> 22 22 #include <linux/gpio.h> 23 + #include <linux/gpio/machine.h> 23 24 #include <linux/smc911x.h> 24 25 #include <linux/interrupt.h> 25 26 #include <linux/delay.h> ··· 215 214 #define AC97_GPIO_TXFS IMX_GPIO_NR(2, 31) 216 215 #define AC97_GPIO_TXD IMX_GPIO_NR(2, 28) 217 216 #define AC97_GPIO_RESET IMX_GPIO_NR(2, 0) 218 - #define SD1_GPIO_WP IMX_GPIO_NR(2, 23) 219 - #define SD1_GPIO_CD IMX_GPIO_NR(2, 24) 220 217 221 218 static void pcm043_ac97_warm_reset(struct snd_ac97 *ac97) 222 219 { ··· 340 341 __setup("otg_mode=", pcm043_otg_mode); 341 342 342 343 static struct esdhc_platform_data sd1_pdata = { 343 - .wp_gpio = SD1_GPIO_WP, 344 - .cd_gpio = SD1_GPIO_CD, 345 344 .wp_type = ESDHC_WP_GPIO, 346 345 .cd_type = ESDHC_CD_GPIO, 346 + }; 347 + 348 + static struct gpiod_lookup_table sd1_gpio_table = { 349 + .dev_id = "sdhci-esdhc-imx35.0", 350 + .table = { 351 + /* Card detect: bank 2 offset 24 */ 352 + GPIO_LOOKUP("imx35-gpio.2", 24, "cd", GPIO_ACTIVE_LOW), 353 + /* Write protect: bank 2 offset 23 */ 354 + GPIO_LOOKUP("imx35-gpio.2", 23, "wp", GPIO_ACTIVE_LOW), 355 + { }, 356 + }, 347 357 }; 348 358 349 359 /* ··· 399 391 { 400 392 imx35_add_imx_ssi(0, &pcm043_ssi_pdata); 401 393 394 + gpiod_add_lookup_table(&sd1_gpio_table); 402 395 imx35_add_sdhci_esdhc_imx(0, &sd1_pdata); 403 396 } 404 397
-3
arch/arm/mach-pxa/balloon3.c
··· 290 290 291 291 static struct pxamci_platform_data balloon3_mci_platform_data = { 292 292 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 293 - .gpio_card_detect = -1, 294 - .gpio_card_ro = -1, 295 - .gpio_power = -1, 296 293 .detect_delay_ms = 200, 297 294 }; 298 295
+14 -4
arch/arm/mach-pxa/cm-x270.c
··· 12 12 #include <linux/platform_device.h> 13 13 #include <linux/irq.h> 14 14 #include <linux/gpio.h> 15 + #include <linux/gpio/machine.h> 15 16 #include <linux/delay.h> 16 17 17 18 #include <linux/platform_data/rtc-v3020.h> ··· 289 288 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) 290 289 static struct pxamci_platform_data cmx270_mci_platform_data = { 291 290 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 292 - .gpio_card_detect = GPIO83_MMC_IRQ, 293 - .gpio_card_ro = -1, 294 - .gpio_power = GPIO105_MMC_POWER, 295 - .gpio_power_invert = 1, 291 + }; 292 + 293 + static struct gpiod_lookup_table cmx270_mci_gpio_table = { 294 + .dev_id = "pxa2xx-mci.0", 295 + .table = { 296 + /* Card detect on GPIO 83 */ 297 + GPIO_LOOKUP("gpio-pxa", GPIO83_MMC_IRQ, "cd", GPIO_ACTIVE_LOW), 298 + /* Power on GPIO 105 */ 299 + GPIO_LOOKUP("gpio-pxa", GPIO105_MMC_POWER, 300 + "power", GPIO_ACTIVE_LOW), 301 + { }, 302 + }, 296 303 }; 297 304 298 305 static void __init cmx270_init_mmc(void) 299 306 { 307 + gpiod_add_lookup_table(&cmx270_mci_gpio_table); 300 308 pxa_set_mci_info(&cmx270_mci_platform_data); 301 309 } 302 310 #else
+12 -6
arch/arm/mach-pxa/cm-x300.c
··· 459 459 static struct pxamci_platform_data cm_x300_mci_platform_data = { 460 460 .detect_delay_ms = 200, 461 461 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 462 - .gpio_card_detect = GPIO82_MMC_IRQ, 463 - .gpio_card_ro = GPIO85_MMC_WP, 464 - .gpio_power = -1, 462 + }; 463 + 464 + static struct gpiod_lookup_table cm_x300_mci_gpio_table = { 465 + .dev_id = "pxa2xx-mci.0", 466 + .table = { 467 + /* Card detect on GPIO 82 */ 468 + GPIO_LOOKUP("gpio-pxa", GPIO82_MMC_IRQ, "cd", GPIO_ACTIVE_LOW), 469 + /* Write protect on GPIO 85 */ 470 + GPIO_LOOKUP("gpio-pxa", GPIO85_MMC_WP, "wp", GPIO_ACTIVE_LOW), 471 + { }, 472 + }, 465 473 }; 466 474 467 475 /* The second MMC slot of CM-X300 is hardwired to Libertas card and has ··· 490 482 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 491 483 .init = cm_x300_mci2_init, 492 484 .exit = cm_x300_mci2_exit, 493 - .gpio_card_detect = -1, 494 - .gpio_card_ro = -1, 495 - .gpio_power = -1, 496 485 }; 497 486 498 487 static void __init cm_x300_init_mmc(void) 499 488 { 489 + gpiod_add_lookup_table(&cm_x300_mci_gpio_table); 500 490 pxa_set_mci_info(&cm_x300_mci_platform_data); 501 491 pxa3xx_set_mci2_info(&cm_x300_mci2_platform_data); 502 492 }
+31 -9
arch/arm/mach-pxa/colibri-evalboard.c
··· 14 14 #include <linux/kernel.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/interrupt.h> 17 - #include <linux/gpio.h> 17 + #include <linux/gpio/machine.h> 18 18 #include <asm/mach-types.h> 19 19 #include <mach/hardware.h> 20 20 #include <asm/mach/arch.h> ··· 37 37 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 38 38 static struct pxamci_platform_data colibri_mci_platform_data = { 39 39 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 40 - .gpio_power = -1, 41 - .gpio_card_ro = -1, 42 40 .detect_delay_ms = 200, 41 + }; 42 + 43 + static struct gpiod_lookup_table colibri_pxa270_mci_gpio_table = { 44 + .dev_id = "pxa2xx-mci.0", 45 + .table = { 46 + GPIO_LOOKUP("gpio-pxa", GPIO0_COLIBRI_PXA270_SD_DETECT, 47 + "cd", GPIO_ACTIVE_LOW), 48 + { }, 49 + }, 50 + }; 51 + 52 + static struct gpiod_lookup_table colibri_pxa300_mci_gpio_table = { 53 + .dev_id = "pxa2xx-mci.0", 54 + .table = { 55 + GPIO_LOOKUP("gpio-pxa", GPIO13_COLIBRI_PXA300_SD_DETECT, 56 + "cd", GPIO_ACTIVE_LOW), 57 + { }, 58 + }, 59 + }; 60 + 61 + static struct gpiod_lookup_table colibri_pxa320_mci_gpio_table = { 62 + .dev_id = "pxa2xx-mci.0", 63 + .table = { 64 + GPIO_LOOKUP("gpio-pxa", GPIO28_COLIBRI_PXA320_SD_DETECT, 65 + "cd", GPIO_ACTIVE_LOW), 66 + { }, 67 + }, 43 68 }; 44 69 45 70 static void __init colibri_mmc_init(void) 46 71 { 47 72 if (machine_is_colibri()) /* PXA270 Colibri */ 48 - colibri_mci_platform_data.gpio_card_detect = 49 - GPIO0_COLIBRI_PXA270_SD_DETECT; 73 + gpiod_add_lookup_table(&colibri_pxa270_mci_gpio_table); 50 74 if (machine_is_colibri300()) /* PXA300 Colibri */ 51 - colibri_mci_platform_data.gpio_card_detect = 52 - GPIO13_COLIBRI_PXA300_SD_DETECT; 75 + gpiod_add_lookup_table(&colibri_pxa300_mci_gpio_table); 53 76 else /* PXA320 Colibri */ 54 - colibri_mci_platform_data.gpio_card_detect = 55 - GPIO28_COLIBRI_PXA320_SD_DETECT; 77 + gpiod_add_lookup_table(&colibri_pxa320_mci_gpio_table); 56 78 57 79 pxa_set_mci_info(&colibri_mci_platform_data); 58 80 }
+15 -4
arch/arm/mach-pxa/colibri-pxa270-income.c
··· 14 14 15 15 #include <linux/bitops.h> 16 16 #include <linux/delay.h> 17 - #include <linux/gpio.h> 17 + #include <linux/gpio/machine.h> 18 18 #include <linux/init.h> 19 19 #include <linux/interrupt.h> 20 20 #include <linux/leds.h> ··· 51 51 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 52 52 static struct pxamci_platform_data income_mci_platform_data = { 53 53 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 54 - .gpio_power = -1, 55 - .gpio_card_detect = GPIO0_INCOME_SD_DETECT, 56 - .gpio_card_ro = GPIO0_INCOME_SD_RO, 57 54 .detect_delay_ms = 200, 55 + }; 56 + 57 + static struct gpiod_lookup_table income_mci_gpio_table = { 58 + .dev_id = "pxa2xx-mci.0", 59 + .table = { 60 + /* Card detect on GPIO 0 */ 61 + GPIO_LOOKUP("gpio-pxa", GPIO0_INCOME_SD_DETECT, 62 + "cd", GPIO_ACTIVE_LOW), 63 + /* Write protect on GPIO 1 */ 64 + GPIO_LOOKUP("gpio-pxa", GPIO0_INCOME_SD_RO, 65 + "wp", GPIO_ACTIVE_LOW), 66 + { }, 67 + }, 58 68 }; 59 69 60 70 static void __init income_mmc_init(void) 61 71 { 72 + gpiod_add_lookup_table(&income_mci_gpio_table); 62 73 pxa_set_mci_info(&income_mci_platform_data); 63 74 } 64 75 #else
+17 -3
arch/arm/mach-pxa/corgi.c
··· 24 24 #include <linux/mtd/physmap.h> 25 25 #include <linux/pm.h> 26 26 #include <linux/gpio.h> 27 + #include <linux/gpio/machine.h> 27 28 #include <linux/backlight.h> 28 29 #include <linux/i2c.h> 29 30 #include <linux/platform_data/i2c-pxa.h> ··· 494 493 static struct pxamci_platform_data corgi_mci_platform_data = { 495 494 .detect_delay_ms = 250, 496 495 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 497 - .gpio_card_detect = CORGI_GPIO_nSD_DETECT, 498 - .gpio_card_ro = CORGI_GPIO_nSD_WP, 499 - .gpio_power = CORGI_GPIO_SD_PWR, 500 496 }; 501 497 498 + static struct gpiod_lookup_table corgi_mci_gpio_table = { 499 + .dev_id = "pxa2xx-mci.0", 500 + .table = { 501 + /* Card detect on GPIO 9 */ 502 + GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_DETECT, 503 + "cd", GPIO_ACTIVE_LOW), 504 + /* Write protect on GPIO 7 */ 505 + GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_nSD_WP, 506 + "wp", GPIO_ACTIVE_LOW), 507 + /* Power on GPIO 33 */ 508 + GPIO_LOOKUP("gpio-pxa", CORGI_GPIO_SD_PWR, 509 + "power", GPIO_ACTIVE_HIGH), 510 + { }, 511 + }, 512 + }; 502 513 503 514 /* 504 515 * Irda ··· 744 731 corgi_init_spi(); 745 732 746 733 pxa_set_udc_info(&udc_info); 734 + gpiod_add_lookup_table(&corgi_mci_gpio_table); 747 735 pxa_set_mci_info(&corgi_mci_platform_data); 748 736 pxa_set_ficp_info(&corgi_ficp_platform_data); 749 737 pxa_set_i2c_info(NULL);
+15 -4
arch/arm/mach-pxa/csb726.c
··· 11 11 #include <linux/kernel.h> 12 12 #include <linux/init.h> 13 13 #include <linux/io.h> 14 - #include <linux/gpio.h> 14 + #include <linux/gpio/machine.h> 15 15 #include <linux/platform_device.h> 16 16 #include <linux/mtd/physmap.h> 17 17 #include <linux/mtd/partitions.h> ··· 129 129 .detect_delay_ms = 500, 130 130 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 131 131 /* FIXME setpower */ 132 - .gpio_card_detect = CSB726_GPIO_MMC_DETECT, 133 - .gpio_card_ro = CSB726_GPIO_MMC_RO, 134 - .gpio_power = -1, 132 + }; 133 + 134 + static struct gpiod_lookup_table csb726_mci_gpio_table = { 135 + .dev_id = "pxa2xx-mci.0", 136 + .table = { 137 + /* Card detect on GPIO 100 */ 138 + GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_DETECT, 139 + "cd", GPIO_ACTIVE_LOW), 140 + /* Write protect on GPIO 101 */ 141 + GPIO_LOOKUP("gpio-pxa", CSB726_GPIO_MMC_RO, 142 + "wp", GPIO_ACTIVE_LOW), 143 + { }, 144 + }, 135 145 }; 136 146 137 147 static struct pxaohci_platform_data csb726_ohci_platform_data = { ··· 274 264 pxa_set_stuart_info(NULL); 275 265 pxa_set_i2c_info(NULL); 276 266 pxa27x_set_i2c_power_info(NULL); 267 + gpiod_add_lookup_table(&csb726_mci_gpio_table); 277 268 pxa_set_mci_info(&csb726_mci); 278 269 pxa_set_ohci_info(&csb726_ohci_platform_data); 279 270 pxa_set_ac97_info(NULL);
+13 -21
arch/arm/mach-pxa/em-x270.c
··· 20 20 #include <linux/input.h> 21 21 #include <linux/gpio_keys.h> 22 22 #include <linux/gpio.h> 23 + #include <linux/gpio/machine.h> 23 24 #include <linux/mfd/da903x.h> 24 25 #include <linux/regulator/machine.h> 25 26 #include <linux/regulator/fixed.h> ··· 547 546 #if defined(CONFIG_MMC) || defined(CONFIG_MMC_MODULE) 548 547 static struct regulator *em_x270_sdio_ldo; 549 548 549 + static struct gpiod_lookup_table em_x270_mci_wp_gpio_table = { 550 + .dev_id = "pxa2xx-mci.0", 551 + .table = { 552 + /* Write protect on GPIO 95 */ 553 + GPIO_LOOKUP("gpio-pxa", GPIO95_MMC_WP, "wp", GPIO_ACTIVE_LOW), 554 + { }, 555 + }, 556 + }; 557 + 550 558 static int em_x270_mci_init(struct device *dev, 551 559 irq_handler_t em_x270_detect_int, 552 560 void *data) ··· 577 567 goto err_irq; 578 568 } 579 569 580 - if (machine_is_em_x270()) { 581 - err = gpio_request(GPIO95_MMC_WP, "MMC WP"); 582 - if (err) { 583 - dev_err(dev, "can't request MMC write protect: %d\n", 584 - err); 585 - goto err_gpio_wp; 586 - } 587 - gpio_direction_input(GPIO95_MMC_WP); 588 - } else { 570 + if (!machine_is_em_x270()) { 589 571 err = gpio_request(GPIO38_SD_PWEN, "sdio power"); 590 572 if (err) { 591 573 dev_err(dev, "can't request MMC power control : %d\n", ··· 617 615 free_irq(gpio_to_irq(mmc_cd), data); 618 616 regulator_put(em_x270_sdio_ldo); 619 617 620 - if (machine_is_em_x270()) 621 - gpio_free(GPIO95_MMC_WP); 622 - else 618 + if (!machine_is_em_x270()) 623 619 gpio_free(GPIO38_SD_PWEN); 624 - } 625 - 626 - static int em_x270_mci_get_ro(struct device *dev) 627 - { 628 - return gpio_get_value(GPIO95_MMC_WP); 629 620 } 630 621 631 622 static struct pxamci_platform_data em_x270_mci_platform_data = { ··· 630 635 .init = em_x270_mci_init, 631 636 .setpower = em_x270_mci_setpower, 632 637 .exit = em_x270_mci_exit, 633 - .gpio_card_detect = -1, 634 - .gpio_card_ro = -1, 635 - .gpio_power = -1, 636 638 }; 637 639 638 640 static void __init em_x270_init_mmc(void) 639 641 { 640 642 if (machine_is_em_x270()) 641 - em_x270_mci_platform_data.get_ro = em_x270_mci_get_ro; 643 + gpiod_add_lookup_table(&em_x270_mci_wp_gpio_table); 642 644 643 645 pxa_set_mci_info(&em_x270_mci_platform_data); 644 646 }
-3
arch/arm/mach-pxa/gumstix.c
··· 90 90 #ifdef CONFIG_MMC_PXA 91 91 static struct pxamci_platform_data gumstix_mci_platform_data = { 92 92 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 93 - .gpio_card_detect = -1, 94 - .gpio_card_ro = -1, 95 - .gpio_power = -1, 96 93 }; 97 94 98 95 static void __init gumstix_mmc_init(void)
-3
arch/arm/mach-pxa/idp.c
··· 160 160 161 161 static struct pxamci_platform_data idp_mci_platform_data = { 162 162 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 163 - .gpio_card_detect = -1, 164 - .gpio_card_ro = -1, 165 - .gpio_power = -1, 166 163 }; 167 164 168 165 static void __init idp_init(void)
+12 -6
arch/arm/mach-pxa/littleton.c
··· 20 20 #include <linux/delay.h> 21 21 #include <linux/platform_device.h> 22 22 #include <linux/clk.h> 23 - #include <linux/gpio.h> 23 + #include <linux/gpio/machine.h> 24 24 #include <linux/spi/spi.h> 25 25 #include <linux/spi/pxa2xx_spi.h> 26 26 #include <linux/smc91x.h> ··· 50 50 #include <linux/platform_data/mtd-nand-pxa3xx.h> 51 51 52 52 #include "generic.h" 53 - 54 - #define GPIO_MMC1_CARD_DETECT mfp_to_gpio(MFP_PIN_GPIO15) 55 53 56 54 /* Littleton MFP configurations */ 57 55 static mfp_cfg_t littleton_mfp_cfg[] __initdata = { ··· 276 278 static struct pxamci_platform_data littleton_mci_platform_data = { 277 279 .detect_delay_ms = 200, 278 280 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 279 - .gpio_card_detect = GPIO_MMC1_CARD_DETECT, 280 - .gpio_card_ro = -1, 281 - .gpio_power = -1, 281 + }; 282 + 283 + static struct gpiod_lookup_table littleton_mci_gpio_table = { 284 + .dev_id = "pxa2xx-mci.0", 285 + .table = { 286 + /* Card detect on MFP (gpio-pxa) GPIO 15 */ 287 + GPIO_LOOKUP("gpio-pxa", MFP_PIN_GPIO15, 288 + "cd", GPIO_ACTIVE_LOW), 289 + { }, 290 + }, 282 291 }; 283 292 284 293 static void __init littleton_init_mmc(void) 285 294 { 295 + gpiod_add_lookup_table(&littleton_mci_gpio_table); 286 296 pxa_set_mci_info(&littleton_mci_platform_data); 287 297 } 288 298 #else
-3
arch/arm/mach-pxa/lubbock.c
··· 440 440 .init = lubbock_mci_init, 441 441 .get_ro = lubbock_mci_get_ro, 442 442 .exit = lubbock_mci_exit, 443 - .gpio_card_detect = -1, 444 - .gpio_card_ro = -1, 445 - .gpio_power = -1, 446 443 }; 447 444 448 445 static void lubbock_irda_transceiver_mode(struct device *dev, int mode)
+23 -3
arch/arm/mach-pxa/magician.c
··· 775 775 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 776 776 .init = magician_mci_init, 777 777 .exit = magician_mci_exit, 778 - .gpio_card_detect = -1, 779 - .gpio_card_ro = EGPIO_MAGICIAN_nSD_READONLY, 780 778 .gpio_card_ro_invert = 1, 781 - .gpio_power = EGPIO_MAGICIAN_SD_POWER, 782 779 }; 783 780 781 + /* 782 + * Write protect on EGPIO register 5 index 4, this is on the second HTC 783 + * EGPIO chip which starts at register 4, so we need offset 8+4=12 on that 784 + * particular chip. 785 + */ 786 + #define EGPIO_MAGICIAN_nSD_READONLY_OFFSET 12 787 + /* 788 + * Power on EGPIO register 2 index 0, so this is on the first HTC EGPIO chip 789 + * starting at register 0 so we need offset 2*8+0 = 16 on that chip. 790 + */ 791 + #define EGPIO_MAGICIAN_nSD_POWER_OFFSET 16 792 + 793 + static struct gpiod_lookup_table magician_mci_gpio_table = { 794 + .dev_id = "pxa2xx-mci.0", 795 + .table = { 796 + GPIO_LOOKUP("htc-egpio-1", EGPIO_MAGICIAN_nSD_READONLY_OFFSET, 797 + "wp", GPIO_ACTIVE_HIGH), 798 + GPIO_LOOKUP("htc-egpio-0", EGPIO_MAGICIAN_nSD_POWER_OFFSET, 799 + "power", GPIO_ACTIVE_HIGH), 800 + { }, 801 + }, 802 + }; 784 803 785 804 /* 786 805 * USB OHCI ··· 998 979 i2c_register_board_info(1, 999 980 ARRAY_AND_SIZE(magician_pwr_i2c_board_info)); 1000 981 982 + gpiod_add_lookup_table(&magician_mci_gpio_table); 1001 983 pxa_set_mci_info(&magician_mci_info); 1002 984 pxa_set_ohci_info(&magician_ohci_info); 1003 985 pxa_set_udc_info(&magician_udc_info);
-3
arch/arm/mach-pxa/mainstone.c
··· 361 361 .init = mainstone_mci_init, 362 362 .setpower = mainstone_mci_setpower, 363 363 .exit = mainstone_mci_exit, 364 - .gpio_card_detect = -1, 365 - .gpio_card_ro = -1, 366 - .gpio_power = -1, 367 364 }; 368 365 369 366 static void mainstone_irda_transceiver_mode(struct device *dev, int mode)
+18 -3
arch/arm/mach-pxa/mioa701.c
··· 31 31 #include <linux/rtc.h> 32 32 #include <linux/leds.h> 33 33 #include <linux/gpio.h> 34 + #include <linux/gpio/machine.h> 34 35 #include <linux/interrupt.h> 35 36 #include <linux/irq.h> 36 37 #include <linux/pda_power.h> ··· 398 397 static struct pxamci_platform_data mioa701_mci_info = { 399 398 .detect_delay_ms = 250, 400 399 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 401 - .gpio_card_detect = GPIO15_SDIO_INSERT, 402 - .gpio_card_ro = GPIO78_SDIO_RO, 403 - .gpio_power = GPIO91_SDIO_EN, 400 + }; 401 + 402 + static struct gpiod_lookup_table mioa701_mci_gpio_table = { 403 + .dev_id = "pxa2xx-mci.0", 404 + .table = { 405 + /* Card detect on GPIO 15 */ 406 + GPIO_LOOKUP("gpio-pxa", GPIO15_SDIO_INSERT, 407 + "cd", GPIO_ACTIVE_LOW), 408 + /* Write protect on GPIO 78 */ 409 + GPIO_LOOKUP("gpio-pxa", GPIO78_SDIO_RO, 410 + "wp", GPIO_ACTIVE_LOW), 411 + /* Power on GPIO 91 */ 412 + GPIO_LOOKUP("gpio-pxa", GPIO91_SDIO_EN, 413 + "power", GPIO_ACTIVE_HIGH), 414 + { }, 415 + }, 404 416 }; 405 417 406 418 /* FlashRAM */ ··· 757 743 pr_err("MioA701: Failed to request GPIOs: %d", rc); 758 744 bootstrap_init(); 759 745 pxa_set_fb_info(NULL, &mioa701_pxafb_info); 746 + gpiod_add_lookup_table(&mioa701_mci_gpio_table); 760 747 pxa_set_mci_info(&mioa701_mci_info); 761 748 pxa_set_keypad_info(&mioa701_keypad_info); 762 749 pxa_set_udc_info(&mioa701_udc_info);
+15 -4
arch/arm/mach-pxa/mxm8x10.c
··· 21 21 22 22 #include <linux/serial_8250.h> 23 23 #include <linux/dm9000.h> 24 - #include <linux/gpio.h> 24 + #include <linux/gpio/machine.h> 25 25 #include <linux/platform_data/i2c-pxa.h> 26 26 27 27 #include <linux/platform_data/mtd-nand-pxa3xx.h> ··· 326 326 static struct pxamci_platform_data mxm_8x10_mci_platform_data = { 327 327 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 328 328 .detect_delay_ms = 10, 329 - .gpio_card_detect = MXM_8X10_SD_nCD, 330 - .gpio_card_ro = MXM_8X10_SD_WP, 331 - .gpio_power = -1 329 + }; 330 + 331 + static struct gpiod_lookup_table mxm_8x10_mci_gpio_table = { 332 + .dev_id = "pxa2xx-mci.0", 333 + .table = { 334 + /* Card detect on GPIO 72 */ 335 + GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_nCD, 336 + "cd", GPIO_ACTIVE_LOW), 337 + /* Write protect on GPIO 84 */ 338 + GPIO_LOOKUP("gpio-pxa", MXM_8X10_SD_WP, 339 + "wp", GPIO_ACTIVE_LOW), 340 + { }, 341 + }, 332 342 }; 333 343 334 344 void __init mxm_8x10_mmc_init(void) 335 345 { 346 + gpiod_add_lookup_table(&mxm_8x10_mci_gpio_table); 336 347 pxa_set_mci_info(&mxm_8x10_mci_platform_data); 337 348 } 338 349 #endif
+3 -7
arch/arm/mach-pxa/palm27x.c
··· 49 49 .detect_delay_ms = 200, 50 50 }; 51 51 52 - void __init palm27x_mmc_init(int detect, int ro, int power, 53 - int power_inverted) 52 + void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable) 54 53 { 55 - palm27x_mci_platform_data.gpio_card_detect = detect; 56 - palm27x_mci_platform_data.gpio_card_ro = ro; 57 - palm27x_mci_platform_data.gpio_power = power; 58 - palm27x_mci_platform_data.gpio_power_invert = power_inverted; 59 - 54 + if (gtable) 55 + gpiod_add_lookup_table(gtable); 60 56 pxa_set_mci_info(&palm27x_mci_platform_data); 61 57 } 62 58 #endif
+2 -4
arch/arm/mach-pxa/palm27x.h
··· 15 15 #include <linux/gpio/machine.h> 16 16 17 17 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 18 - extern void __init palm27x_mmc_init(int detect, int ro, int power, 19 - int power_inverted); 18 + extern void __init palm27x_mmc_init(struct gpiod_lookup_table *gtable); 20 19 #else 21 - static inline void palm27x_mmc_init(int detect, int ro, int power, 22 - int power_inverted) 20 + static inline void palm27x_mmc_init(struct gpiod_lookup_table *gtable) 23 21 {} 24 22 #endif 25 23
+14 -2
arch/arm/mach-pxa/palmld.c
··· 332 332 iotable_init(palmld_io_desc, ARRAY_SIZE(palmld_io_desc)); 333 333 } 334 334 335 + static struct gpiod_lookup_table palmld_mci_gpio_table = { 336 + .dev_id = "pxa2xx-mci.0", 337 + .table = { 338 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_DETECT_N, 339 + "cd", GPIO_ACTIVE_LOW), 340 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_READONLY, 341 + "wp", GPIO_ACTIVE_LOW), 342 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMLD_SD_POWER, 343 + "power", GPIO_ACTIVE_HIGH), 344 + { }, 345 + }, 346 + }; 347 + 335 348 static void __init palmld_init(void) 336 349 { 337 350 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmld_pin_config)); ··· 352 339 pxa_set_btuart_info(NULL); 353 340 pxa_set_stuart_info(NULL); 354 341 355 - palm27x_mmc_init(GPIO_NR_PALMLD_SD_DETECT_N, GPIO_NR_PALMLD_SD_READONLY, 356 - GPIO_NR_PALMLD_SD_POWER, 0); 342 + palm27x_mmc_init(&palmld_mci_gpio_table); 357 343 palm27x_pm_init(PALMLD_STR_BASE); 358 344 palm27x_lcd_init(-1, &palm_320x480_lcd_mode); 359 345 palm27x_irda_init(GPIO_NR_PALMLD_IR_DISABLE);
+14 -2
arch/arm/mach-pxa/palmt5.c
··· 182 182 memblock_reserve(0xa0200000, 0x1000); 183 183 } 184 184 185 + static struct gpiod_lookup_table palmt5_mci_gpio_table = { 186 + .dev_id = "pxa2xx-mci.0", 187 + .table = { 188 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_DETECT_N, 189 + "cd", GPIO_ACTIVE_LOW), 190 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_READONLY, 191 + "wp", GPIO_ACTIVE_LOW), 192 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMT5_SD_POWER, 193 + "power", GPIO_ACTIVE_HIGH), 194 + { }, 195 + }, 196 + }; 197 + 185 198 static void __init palmt5_init(void) 186 199 { 187 200 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmt5_pin_config)); ··· 202 189 pxa_set_btuart_info(NULL); 203 190 pxa_set_stuart_info(NULL); 204 191 205 - palm27x_mmc_init(GPIO_NR_PALMT5_SD_DETECT_N, GPIO_NR_PALMT5_SD_READONLY, 206 - GPIO_NR_PALMT5_SD_POWER, 0); 192 + palm27x_mmc_init(&palmt5_mci_gpio_table); 207 193 palm27x_pm_init(PALMT5_STR_BASE); 208 194 palm27x_lcd_init(-1, &palm_320x480_lcd_mode); 209 195 palm27x_udc_init(GPIO_NR_PALMT5_USB_DETECT_N,
+15 -4
arch/arm/mach-pxa/palmtc.c
··· 20 20 #include <linux/input.h> 21 21 #include <linux/pwm.h> 22 22 #include <linux/pwm_backlight.h> 23 - #include <linux/gpio.h> 23 + #include <linux/gpio/machine.h> 24 24 #include <linux/input/matrix_keypad.h> 25 25 #include <linux/ucb1400.h> 26 26 #include <linux/power_supply.h> ··· 120 120 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 121 121 static struct pxamci_platform_data palmtc_mci_platform_data = { 122 122 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 123 - .gpio_power = GPIO_NR_PALMTC_SD_POWER, 124 - .gpio_card_ro = GPIO_NR_PALMTC_SD_READONLY, 125 - .gpio_card_detect = GPIO_NR_PALMTC_SD_DETECT_N, 126 123 .detect_delay_ms = 200, 124 + }; 125 + 126 + static struct gpiod_lookup_table palmtc_mci_gpio_table = { 127 + .dev_id = "pxa2xx-mci.0", 128 + .table = { 129 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_DETECT_N, 130 + "cd", GPIO_ACTIVE_LOW), 131 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_READONLY, 132 + "wp", GPIO_ACTIVE_LOW), 133 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTC_SD_POWER, 134 + "power", GPIO_ACTIVE_HIGH), 135 + { }, 136 + }, 127 137 }; 128 138 129 139 static void __init palmtc_mmc_init(void) 130 140 { 141 + gpiod_add_lookup_table(&palmtc_mci_gpio_table); 131 142 pxa_set_mci_info(&palmtc_mci_platform_data); 132 143 } 133 144 #else
+15 -3
arch/arm/mach-pxa/palmte2.c
··· 19 19 #include <linux/delay.h> 20 20 #include <linux/irq.h> 21 21 #include <linux/gpio_keys.h> 22 + #include <linux/gpio/machine.h> 22 23 #include <linux/input.h> 23 24 #include <linux/pda_power.h> 24 25 #include <linux/pwm.h> ··· 102 101 ******************************************************************************/ 103 102 static struct pxamci_platform_data palmte2_mci_platform_data = { 104 103 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 105 - .gpio_card_detect = GPIO_NR_PALMTE2_SD_DETECT_N, 106 - .gpio_card_ro = GPIO_NR_PALMTE2_SD_READONLY, 107 - .gpio_power = GPIO_NR_PALMTE2_SD_POWER, 104 + }; 105 + 106 + static struct gpiod_lookup_table palmte2_mci_gpio_table = { 107 + .dev_id = "pxa2xx-mci.0", 108 + .table = { 109 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_DETECT_N, 110 + "cd", GPIO_ACTIVE_LOW), 111 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_READONLY, 112 + "wp", GPIO_ACTIVE_LOW), 113 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTE2_SD_POWER, 114 + "power", GPIO_ACTIVE_HIGH), 115 + { }, 116 + }, 108 117 }; 109 118 110 119 #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE) ··· 365 354 pxa_set_stuart_info(NULL); 366 355 367 356 pxa_set_fb_info(NULL, &palmte2_lcd_screen); 357 + gpiod_add_lookup_table(&palmte2_mci_gpio_table); 368 358 pxa_set_mci_info(&palmte2_mci_platform_data); 369 359 palmte2_udc_init(); 370 360 pxa_set_ac97_info(&palmte2_ac97_pdata);
+27 -4
arch/arm/mach-pxa/palmtreo.c
··· 480 480 gpio_free(GPIO_NR_TREO680_LCD_EN_N); 481 481 } 482 482 483 + static struct gpiod_lookup_table treo680_mci_gpio_table = { 484 + .dev_id = "pxa2xx-mci.0", 485 + .table = { 486 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N, 487 + "cd", GPIO_ACTIVE_LOW), 488 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_READONLY, 489 + "wp", GPIO_ACTIVE_LOW), 490 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO680_SD_POWER, 491 + "power", GPIO_ACTIVE_HIGH), 492 + { }, 493 + }, 494 + }; 495 + 483 496 static void __init treo680_init(void) 484 497 { 485 498 pxa2xx_mfp_config(ARRAY_AND_SIZE(treo680_pin_config)); 486 499 palmphone_common_init(); 487 500 treo680_gpio_init(); 488 - palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, GPIO_NR_TREO680_SD_READONLY, 489 - GPIO_NR_TREO680_SD_POWER, 0); 501 + palm27x_mmc_init(&treo680_mci_gpio_table); 490 502 } 491 503 #endif 492 504 493 505 #ifdef CONFIG_MACH_CENTRO 506 + 507 + static struct gpiod_lookup_table centro685_mci_gpio_table = { 508 + .dev_id = "pxa2xx-mci.0", 509 + .table = { 510 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_TREO_SD_DETECT_N, 511 + "cd", GPIO_ACTIVE_LOW), 512 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_CENTRO_SD_POWER, 513 + "power", GPIO_ACTIVE_LOW), 514 + { }, 515 + }, 516 + }; 517 + 494 518 static void __init centro_init(void) 495 519 { 496 520 pxa2xx_mfp_config(ARRAY_AND_SIZE(centro685_pin_config)); 497 521 palmphone_common_init(); 498 - palm27x_mmc_init(GPIO_NR_TREO_SD_DETECT_N, -1, 499 - GPIO_NR_CENTRO_SD_POWER, 1); 522 + palm27x_mmc_init(&centro685_mci_gpio_table); 500 523 } 501 524 #endif 502 525
+14 -2
arch/arm/mach-pxa/palmtx.c
··· 337 337 iotable_init(palmtx_io_desc, ARRAY_SIZE(palmtx_io_desc)); 338 338 } 339 339 340 + static struct gpiod_lookup_table palmtx_mci_gpio_table = { 341 + .dev_id = "pxa2xx-mci.0", 342 + .table = { 343 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_DETECT_N, 344 + "cd", GPIO_ACTIVE_LOW), 345 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_READONLY, 346 + "wp", GPIO_ACTIVE_LOW), 347 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMTX_SD_POWER, 348 + "power", GPIO_ACTIVE_HIGH), 349 + { }, 350 + }, 351 + }; 352 + 340 353 static void __init palmtx_init(void) 341 354 { 342 355 pxa2xx_mfp_config(ARRAY_AND_SIZE(palmtx_pin_config)); ··· 357 344 pxa_set_btuart_info(NULL); 358 345 pxa_set_stuart_info(NULL); 359 346 360 - palm27x_mmc_init(GPIO_NR_PALMTX_SD_DETECT_N, GPIO_NR_PALMTX_SD_READONLY, 361 - GPIO_NR_PALMTX_SD_POWER, 0); 347 + palm27x_mmc_init(&palmtx_mci_gpio_table); 362 348 palm27x_pm_init(PALMTX_STR_BASE); 363 349 palm27x_lcd_init(-1, &palm_320x480_lcd_mode); 364 350 palm27x_udc_init(GPIO_NR_PALMTX_USB_DETECT_N,
+14 -2
arch/arm/mach-pxa/palmz72.c
··· 386 386 static inline void palmz72_camera_init(void) {} 387 387 #endif 388 388 389 + static struct gpiod_lookup_table palmz72_mci_gpio_table = { 390 + .dev_id = "pxa2xx-mci.0", 391 + .table = { 392 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_DETECT_N, 393 + "cd", GPIO_ACTIVE_LOW), 394 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_RO, 395 + "wp", GPIO_ACTIVE_LOW), 396 + GPIO_LOOKUP("gpio-pxa", GPIO_NR_PALMZ72_SD_POWER_N, 397 + "power", GPIO_ACTIVE_LOW), 398 + { }, 399 + }, 400 + }; 401 + 389 402 /****************************************************************************** 390 403 * Machine init 391 404 ******************************************************************************/ ··· 409 396 pxa_set_btuart_info(NULL); 410 397 pxa_set_stuart_info(NULL); 411 398 412 - palm27x_mmc_init(GPIO_NR_PALMZ72_SD_DETECT_N, GPIO_NR_PALMZ72_SD_RO, 413 - GPIO_NR_PALMZ72_SD_POWER_N, 1); 399 + palm27x_mmc_init(&palmz72_mci_gpio_table); 414 400 palm27x_lcd_init(-1, &palm_320x320_lcd_mode); 415 401 palm27x_udc_init(GPIO_NR_PALMZ72_USB_DETECT_N, 416 402 GPIO_NR_PALMZ72_USB_PULLUP, 0);
-3
arch/arm/mach-pxa/pcm990-baseboard.c
··· 370 370 .init = pcm990_mci_init, 371 371 .setpower = pcm990_mci_setpower, 372 372 .exit = pcm990_mci_exit, 373 - .gpio_card_detect = -1, 374 - .gpio_card_ro = -1, 375 - .gpio_power = -1, 376 373 }; 377 374 378 375 static struct pxaohci_platform_data pcm990_ohci_platform_data = {
+12 -3
arch/arm/mach-pxa/poodle.c
··· 23 23 #include <linux/delay.h> 24 24 #include <linux/mtd/physmap.h> 25 25 #include <linux/gpio.h> 26 + #include <linux/gpio/machine.h> 26 27 #include <linux/i2c.h> 27 28 #include <linux/platform_data/i2c-pxa.h> 28 29 #include <linux/regulator/machine.h> ··· 289 288 .init = poodle_mci_init, 290 289 .setpower = poodle_mci_setpower, 291 290 .exit = poodle_mci_exit, 292 - .gpio_card_detect = POODLE_GPIO_nSD_DETECT, 293 - .gpio_card_ro = POODLE_GPIO_nSD_WP, 294 - .gpio_power = -1, 295 291 }; 296 292 293 + static struct gpiod_lookup_table poodle_mci_gpio_table = { 294 + .dev_id = "pxa2xx-mci.0", 295 + .table = { 296 + GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_DETECT, 297 + "cd", GPIO_ACTIVE_LOW), 298 + GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_WP, 299 + "wp", GPIO_ACTIVE_LOW), 300 + { }, 301 + }, 302 + }; 297 303 298 304 /* 299 305 * Irda ··· 447 439 448 440 pxa_set_fb_info(&poodle_locomo_device.dev, &poodle_fb_info); 449 441 pxa_set_udc_info(&udc_info); 442 + gpiod_add_lookup_table(&poodle_mci_gpio_table); 450 443 pxa_set_mci_info(&poodle_mci_platform_data); 451 444 pxa_set_ficp_info(&poodle_ficp_platform_data); 452 445 pxa_set_i2c_info(NULL);
-3
arch/arm/mach-pxa/raumfeld.c
··· 749 749 .init = raumfeld_mci_init, 750 750 .exit = raumfeld_mci_exit, 751 751 .detect_delay_ms = 200, 752 - .gpio_card_detect = -1, 753 - .gpio_card_ro = -1, 754 - .gpio_power = -1, 755 752 }; 756 753 757 754 /*
+13 -3
arch/arm/mach-pxa/spitz.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/gpio_keys.h> 20 20 #include <linux/gpio.h> 21 + #include <linux/gpio/machine.h> 21 22 #include <linux/leds.h> 22 23 #include <linux/i2c.h> 23 24 #include <linux/platform_data/i2c-pxa.h> ··· 616 615 .detect_delay_ms = 250, 617 616 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 618 617 .setpower = spitz_mci_setpower, 619 - .gpio_card_detect = SPITZ_GPIO_nSD_DETECT, 620 - .gpio_card_ro = SPITZ_GPIO_nSD_WP, 621 - .gpio_power = -1, 618 + }; 619 + 620 + static struct gpiod_lookup_table spitz_mci_gpio_table = { 621 + .dev_id = "pxa2xx-mci.0", 622 + .table = { 623 + GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_nSD_DETECT, 624 + "cd", GPIO_ACTIVE_LOW), 625 + GPIO_LOOKUP("gpio-pxa", SPITZ_GPIO_nSD_WP, 626 + "wp", GPIO_ACTIVE_LOW), 627 + { }, 628 + }, 622 629 }; 623 630 624 631 static void __init spitz_mmc_init(void) 625 632 { 633 + gpiod_add_lookup_table(&spitz_mci_gpio_table); 626 634 pxa_set_mci_info(&spitz_mci_platform_data); 627 635 } 628 636 #else
-3
arch/arm/mach-pxa/stargate2.c
··· 436 436 static struct pxamci_platform_data imote2_mci_platform_data = { 437 437 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* default anyway */ 438 438 .get_ro = imote2_mci_get_ro, 439 - .gpio_card_detect = -1, 440 - .gpio_card_ro = -1, 441 - .gpio_power = -1, 442 439 }; 443 440 444 441 static struct gpio_led imote2_led_pins[] = {
+15 -3
arch/arm/mach-pxa/tosa.c
··· 31 31 #include <linux/gpio_keys.h> 32 32 #include <linux/input.h> 33 33 #include <linux/gpio.h> 34 + #include <linux/gpio/machine.h> 34 35 #include <linux/power/gpio-charger.h> 35 36 #include <linux/spi/spi.h> 36 37 #include <linux/spi/pxa2xx_spi.h> ··· 292 291 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 293 292 .init = tosa_mci_init, 294 293 .exit = tosa_mci_exit, 295 - .gpio_card_detect = TOSA_GPIO_nSD_DETECT, 296 - .gpio_card_ro = TOSA_GPIO_SD_WP, 297 - .gpio_power = TOSA_GPIO_PWR_ON, 294 + }; 295 + 296 + static struct gpiod_lookup_table tosa_mci_gpio_table = { 297 + .dev_id = "pxa2xx-mci.0", 298 + .table = { 299 + GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_nSD_DETECT, 300 + "cd", GPIO_ACTIVE_LOW), 301 + GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_SD_WP, 302 + "wp", GPIO_ACTIVE_LOW), 303 + GPIO_LOOKUP("gpio-pxa", TOSA_GPIO_PWR_ON, 304 + "power", GPIO_ACTIVE_HIGH), 305 + { }, 306 + }, 298 307 }; 299 308 300 309 /* ··· 919 908 /* enable batt_fault */ 920 909 PMCR = 0x01; 921 910 911 + gpiod_add_lookup_table(&tosa_mci_gpio_table); 922 912 pxa_set_mci_info(&tosa_mci_platform_data); 923 913 pxa_set_ficp_info(&tosa_ficp_platform_data); 924 914 pxa_set_i2c_info(NULL);
-3
arch/arm/mach-pxa/trizeps4.c
··· 355 355 .exit = trizeps4_mci_exit, 356 356 .get_ro = NULL, /* write-protection not supported */ 357 357 .setpower = NULL, /* power-switching not supported */ 358 - .gpio_card_detect = -1, 359 - .gpio_card_ro = -1, 360 - .gpio_power = -1, 361 358 }; 362 359 363 360 /****************************************************************************
+13 -3
arch/arm/mach-pxa/vpac270.c
··· 17 17 #include <linux/input.h> 18 18 #include <linux/leds.h> 19 19 #include <linux/gpio.h> 20 + #include <linux/gpio/machine.h> 20 21 #include <linux/usb/gpio_vbus.h> 21 22 #include <linux/mtd/mtd.h> 22 23 #include <linux/mtd/partitions.h> ··· 241 240 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 242 241 static struct pxamci_platform_data vpac270_mci_platform_data = { 243 242 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 244 - .gpio_power = -1, 245 - .gpio_card_detect = GPIO53_VPAC270_SD_DETECT_N, 246 - .gpio_card_ro = GPIO52_VPAC270_SD_READONLY, 247 243 .detect_delay_ms = 200, 244 + }; 245 + 246 + static struct gpiod_lookup_table vpac270_mci_gpio_table = { 247 + .dev_id = "pxa2xx-mci.0", 248 + .table = { 249 + GPIO_LOOKUP("gpio-pxa", GPIO53_VPAC270_SD_DETECT_N, 250 + "cd", GPIO_ACTIVE_LOW), 251 + GPIO_LOOKUP("gpio-pxa", GPIO52_VPAC270_SD_READONLY, 252 + "wp", GPIO_ACTIVE_LOW), 253 + { }, 254 + }, 248 255 }; 249 256 250 257 static void __init vpac270_mmc_init(void) 251 258 { 259 + gpiod_add_lookup_table(&vpac270_mci_gpio_table); 252 260 pxa_set_mci_info(&vpac270_mci_platform_data); 253 261 } 254 262 #else
+11 -3
arch/arm/mach-pxa/z2.c
··· 27 27 #include <linux/power_supply.h> 28 28 #include <linux/mtd/physmap.h> 29 29 #include <linux/gpio.h> 30 + #include <linux/gpio/machine.h> 30 31 #include <linux/gpio_keys.h> 31 32 #include <linux/delay.h> 32 33 #include <linux/regulator/machine.h> ··· 291 290 #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) 292 291 static struct pxamci_platform_data z2_mci_platform_data = { 293 292 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, 294 - .gpio_card_detect = GPIO96_ZIPITZ2_SD_DETECT, 295 - .gpio_power = -1, 296 - .gpio_card_ro = -1, 297 293 .detect_delay_ms = 200, 294 + }; 295 + 296 + static struct gpiod_lookup_table z2_mci_gpio_table = { 297 + .dev_id = "pxa2xx-mci.0", 298 + .table = { 299 + GPIO_LOOKUP("gpio-pxa", GPIO96_ZIPITZ2_SD_DETECT, 300 + "cd", GPIO_ACTIVE_LOW), 301 + { }, 302 + }, 298 303 }; 299 304 300 305 static void __init z2_mmc_init(void) 301 306 { 307 + gpiod_add_lookup_table(&z2_mci_gpio_table); 302 308 pxa_set_mci_info(&z2_mci_platform_data); 303 309 } 304 310 #else
+12 -3
arch/arm/mach-pxa/zeus.c
··· 663 663 static struct pxamci_platform_data zeus_mci_platform_data = { 664 664 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 665 665 .detect_delay_ms = 250, 666 - .gpio_card_detect = ZEUS_MMC_CD_GPIO, 667 - .gpio_card_ro = ZEUS_MMC_WP_GPIO, 668 666 .gpio_card_ro_invert = 1, 669 - .gpio_power = -1 667 + }; 668 + 669 + static struct gpiod_lookup_table zeus_mci_gpio_table = { 670 + .dev_id = "pxa2xx-mci.0", 671 + .table = { 672 + GPIO_LOOKUP("gpio-pxa", ZEUS_MMC_CD_GPIO, 673 + "cd", GPIO_ACTIVE_LOW), 674 + GPIO_LOOKUP("gpio-pxa", ZEUS_MMC_WP_GPIO, 675 + "wp", GPIO_ACTIVE_HIGH), 676 + { }, 677 + }, 670 678 }; 671 679 672 680 /* ··· 891 883 else 892 884 pxa_set_fb_info(NULL, &zeus_fb_info); 893 885 886 + gpiod_add_lookup_table(&zeus_mci_gpio_table); 894 887 pxa_set_mci_info(&zeus_mci_platform_data); 895 888 pxa_set_udc_info(&zeus_udc_info); 896 889 pxa_set_ac97_info(&zeus_ac97_info);
+46 -11
arch/arm/mach-pxa/zylonite.c
··· 19 19 #include <linux/leds.h> 20 20 #include <linux/init.h> 21 21 #include <linux/platform_device.h> 22 - #include <linux/gpio.h> 22 + #include <linux/gpio/machine.h> 23 23 #include <linux/pwm.h> 24 24 #include <linux/pwm_backlight.h> 25 25 #include <linux/smc91x.h> ··· 227 227 static struct pxamci_platform_data zylonite_mci_platform_data = { 228 228 .detect_delay_ms= 200, 229 229 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 230 - .gpio_card_detect = EXT_GPIO(0), 231 - .gpio_card_ro = EXT_GPIO(2), 232 - .gpio_power = -1, 230 + }; 231 + 232 + #define PCA9539A_MCI_CD 0 233 + #define PCA9539A_MCI1_CD 1 234 + #define PCA9539A_MCI_WP 2 235 + #define PCA9539A_MCI1_WP 3 236 + #define PCA9539A_MCI3_CD 30 237 + #define PCA9539A_MCI3_WP 31 238 + 239 + static struct gpiod_lookup_table zylonite_mci_gpio_table = { 240 + .dev_id = "pxa2xx-mci.0", 241 + .table = { 242 + GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI_CD, 243 + "cd", GPIO_ACTIVE_LOW), 244 + GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI_WP, 245 + "wp", GPIO_ACTIVE_LOW), 246 + { }, 247 + }, 233 248 }; 234 249 235 250 static struct pxamci_platform_data zylonite_mci2_platform_data = { 236 251 .detect_delay_ms= 200, 237 252 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 238 - .gpio_card_detect = EXT_GPIO(1), 239 - .gpio_card_ro = EXT_GPIO(3), 240 - .gpio_power = -1, 253 + }; 254 + 255 + static struct gpiod_lookup_table zylonite_mci2_gpio_table = { 256 + .dev_id = "pxa2xx-mci.1", 257 + .table = { 258 + GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI1_CD, 259 + "cd", GPIO_ACTIVE_LOW), 260 + GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI1_WP, 261 + "wp", GPIO_ACTIVE_LOW), 262 + { }, 263 + }, 241 264 }; 242 265 243 266 static struct pxamci_platform_data zylonite_mci3_platform_data = { 244 267 .detect_delay_ms= 200, 245 268 .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, 246 - .gpio_card_detect = EXT_GPIO(30), 247 - .gpio_card_ro = EXT_GPIO(31), 248 - .gpio_power = -1, 269 + }; 270 + 271 + static struct gpiod_lookup_table zylonite_mci3_gpio_table = { 272 + .dev_id = "pxa2xx-mci.2", 273 + .table = { 274 + GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI3_CD, 275 + "cd", GPIO_ACTIVE_LOW), 276 + GPIO_LOOKUP("i2c-pca9539-a", PCA9539A_MCI3_WP, 277 + "wp", GPIO_ACTIVE_LOW), 278 + { }, 279 + }, 249 280 }; 250 281 251 282 static void __init zylonite_init_mmc(void) 252 283 { 284 + gpiod_add_lookup_table(&zylonite_mci_gpio_table); 253 285 pxa_set_mci_info(&zylonite_mci_platform_data); 286 + gpiod_add_lookup_table(&zylonite_mci2_gpio_table); 254 287 pxa3xx_set_mci2_info(&zylonite_mci2_platform_data); 255 - if (cpu_is_pxa310()) 288 + if (cpu_is_pxa310()) { 289 + gpiod_add_lookup_table(&zylonite_mci3_gpio_table); 256 290 pxa3xx_set_mci3_info(&zylonite_mci3_platform_data); 291 + } 257 292 } 258 293 #else 259 294 static inline void zylonite_init_mmc(void) {}
+2
arch/arm/mach-pxa/zylonite_pxa300.c
··· 230 230 static struct i2c_board_info zylonite_i2c_board_info[] = { 231 231 { 232 232 .type = "pca9539", 233 + .dev_name = "pca9539-a", 233 234 .addr = 0x74, 234 235 .platform_data = &gpio_exp[0], 235 236 .irq = PXA_GPIO_TO_IRQ(18), 236 237 }, { 237 238 .type = "pca9539", 239 + .dev_name = "pca9539-b", 238 240 .addr = 0x75, 239 241 .platform_data = &gpio_exp[1], 240 242 .irq = PXA_GPIO_TO_IRQ(19),
+12 -2
arch/arm/mach-s3c24xx/mach-at2440evb.c
··· 9 9 10 10 #include <linux/kernel.h> 11 11 #include <linux/types.h> 12 - #include <linux/gpio.h> 12 + #include <linux/gpio/machine.h> 13 13 #include <linux/interrupt.h> 14 14 #include <linux/list.h> 15 15 #include <linux/timer.h> ··· 136 136 }; 137 137 138 138 static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = { 139 - .gpio_detect = S3C2410_GPG(10), 139 + /* Intentionally left blank */ 140 + }; 141 + 142 + static struct gpiod_lookup_table at2440evb_mci_gpio_table = { 143 + .dev_id = "s3c2410-sdi", 144 + .table = { 145 + /* Card detect S3C2410_GPG(10) */ 146 + GPIO_LOOKUP("GPG", 10, "cd", GPIO_ACTIVE_LOW), 147 + { }, 148 + }, 140 149 }; 141 150 142 151 /* 7" LCD panel */ ··· 209 200 static void __init at2440evb_init(void) 210 201 { 211 202 s3c24xx_fb_set_platdata(&at2440evb_fb_info); 203 + gpiod_add_lookup_table(&at2440evb_mci_gpio_table); 212 204 s3c24xx_mci_set_platdata(&at2440evb_mci_pdata); 213 205 s3c_nand_set_platdata(&at2440evb_nand_info); 214 206 s3c_i2c0_set_platdata(NULL);
+13 -2
arch/arm/mach-s3c24xx/mach-h1940.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/io.h> 20 20 #include <linux/gpio.h> 21 + #include <linux/gpio/machine.h> 21 22 #include <linux/input.h> 22 23 #include <linux/gpio_keys.h> 23 24 #include <linux/pwm.h> ··· 460 459 } 461 460 462 461 static struct s3c24xx_mci_pdata h1940_mmc_cfg __initdata = { 463 - .gpio_detect = S3C2410_GPF(5), 464 - .gpio_wprotect = S3C2410_GPH(8), 465 462 .set_power = h1940_set_mmc_power, 466 463 .ocr_avail = MMC_VDD_32_33, 464 + }; 465 + 466 + static struct gpiod_lookup_table h1940_mmc_gpio_table = { 467 + .dev_id = "s3c2410-sdi", 468 + .table = { 469 + /* Card detect S3C2410_GPF(5) */ 470 + GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW), 471 + /* Write protect S3C2410_GPH(8) */ 472 + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW), 473 + { }, 474 + }, 467 475 }; 468 476 469 477 static struct pwm_lookup h1940_pwm_lookup[] = { ··· 690 680 u32 tmp; 691 681 692 682 s3c24xx_fb_set_platdata(&h1940_fb_info); 683 + gpiod_add_lookup_table(&h1940_mmc_gpio_table); 693 684 s3c24xx_mci_set_platdata(&h1940_mmc_cfg); 694 685 s3c24xx_udc_set_platdata(&h1940_udc_cfg); 695 686 s3c24xx_ts_set_platdata(&h1940_ts_cfg);
+13 -2
arch/arm/mach-s3c24xx/mach-mini2440.c
··· 15 15 #include <linux/timer.h> 16 16 #include <linux/init.h> 17 17 #include <linux/gpio.h> 18 + #include <linux/gpio/machine.h> 18 19 #include <linux/input.h> 19 20 #include <linux/io.h> 20 21 #include <linux/serial_core.h> ··· 235 234 /* MMC/SD */ 236 235 237 236 static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { 238 - .gpio_detect = S3C2410_GPG(8), 239 - .gpio_wprotect = S3C2410_GPH(8), 240 237 .wprotect_invert = 1, 241 238 .set_power = NULL, 242 239 .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, 240 + }; 241 + 242 + static struct gpiod_lookup_table mini2440_mmc_gpio_table = { 243 + .dev_id = "s3c2410-sdi", 244 + .table = { 245 + /* Card detect S3C2410_GPG(8) */ 246 + GPIO_LOOKUP("GPG", 8, "cd", GPIO_ACTIVE_LOW), 247 + /* Write protect S3C2410_GPH(8) */ 248 + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_HIGH), 249 + { }, 250 + }, 243 251 }; 244 252 245 253 /* NAND Flash on MINI2440 board */ ··· 706 696 } 707 697 708 698 s3c24xx_udc_set_platdata(&mini2440_udc_cfg); 699 + gpiod_add_lookup_table(&mini2440_mmc_gpio_table); 709 700 s3c24xx_mci_set_platdata(&mini2440_mmc_cfg); 710 701 s3c_nand_set_platdata(&mini2440_nand_info); 711 702 s3c_i2c0_set_platdata(NULL);
+13 -2
arch/arm/mach-s3c24xx/mach-n30.c
··· 17 17 #include <linux/gpio_keys.h> 18 18 #include <linux/init.h> 19 19 #include <linux/gpio.h> 20 + #include <linux/gpio/machine.h> 20 21 #include <linux/input.h> 21 22 #include <linux/interrupt.h> 22 23 #include <linux/platform_device.h> ··· 351 350 } 352 351 353 352 static struct s3c24xx_mci_pdata n30_mci_cfg __initdata = { 354 - .gpio_detect = S3C2410_GPF(1), 355 - .gpio_wprotect = S3C2410_GPG(10), 356 353 .ocr_avail = MMC_VDD_32_33, 357 354 .set_power = n30_sdi_set_power, 355 + }; 356 + 357 + static struct gpiod_lookup_table n30_mci_gpio_table = { 358 + .dev_id = "s3c2410-sdi", 359 + .table = { 360 + /* Card detect S3C2410_GPF(1) */ 361 + GPIO_LOOKUP("GPF", 1, "cd", GPIO_ACTIVE_LOW), 362 + /* Write protect S3C2410_GPG(10) */ 363 + GPIO_LOOKUP("GPG", 10, "wp", GPIO_ACTIVE_LOW), 364 + { }, 365 + }, 358 366 }; 359 367 360 368 static struct platform_device *n30_devices[] __initdata = { ··· 559 549 560 550 s3c24xx_fb_set_platdata(&n30_fb_info); 561 551 s3c24xx_udc_set_platdata(&n30_udc_cfg); 552 + gpiod_add_lookup_table(&n30_mci_gpio_table); 562 553 s3c24xx_mci_set_platdata(&n30_mci_cfg); 563 554 s3c_i2c0_set_platdata(&n30_i2ccfg); 564 555
+13 -2
arch/arm/mach-s3c24xx/mach-rx1950.c
··· 14 14 #include <linux/timer.h> 15 15 #include <linux/init.h> 16 16 #include <linux/gpio.h> 17 + #include <linux/gpio/machine.h> 17 18 #include <linux/platform_device.h> 18 19 #include <linux/serial_core.h> 19 20 #include <linux/serial_s3c.h> ··· 559 558 } 560 559 561 560 static struct s3c24xx_mci_pdata rx1950_mmc_cfg __initdata = { 562 - .gpio_detect = S3C2410_GPF(5), 563 - .gpio_wprotect = S3C2410_GPH(8), 564 561 .set_power = rx1950_set_mmc_power, 565 562 .ocr_avail = MMC_VDD_32_33, 563 + }; 564 + 565 + static struct gpiod_lookup_table rx1950_mmc_gpio_table = { 566 + .dev_id = "s3c2410-sdi", 567 + .table = { 568 + /* Card detect S3C2410_GPF(5) */ 569 + GPIO_LOOKUP("GPF", 5, "cd", GPIO_ACTIVE_LOW), 570 + /* Write protect S3C2410_GPH(8) */ 571 + GPIO_LOOKUP("GPH", 8, "wp", GPIO_ACTIVE_LOW), 572 + { }, 573 + }, 566 574 }; 567 575 568 576 static struct mtd_partition rx1950_nand_part[] = { ··· 772 762 s3c24xx_fb_set_platdata(&rx1950_lcd_cfg); 773 763 s3c24xx_udc_set_platdata(&rx1950_udc_cfg); 774 764 s3c24xx_ts_set_platdata(&rx1950_ts_cfg); 765 + gpiod_add_lookup_table(&rx1950_mmc_gpio_table); 775 766 s3c24xx_mci_set_platdata(&rx1950_mmc_cfg); 776 767 s3c_i2c0_set_platdata(NULL); 777 768 s3c_nand_set_platdata(&rx1950_nand_info);
-4
arch/mips/include/asm/mach-jz4740/jz4740_mmc.h
··· 3 3 #define __LINUX_MMC_JZ4740_MMC 4 4 5 5 struct jz4740_mmc_platform_data { 6 - int gpio_power; 7 - int gpio_card_detect; 8 - int gpio_read_only; 9 6 unsigned card_detect_active_low:1; 10 7 unsigned read_only_active_low:1; 11 - unsigned power_active_low:1; 12 8 13 9 unsigned data_1bit:1; 14 10 };
+11 -7
arch/mips/jz4740/board-qi_lb60.c
··· 43 43 #include "clock.h" 44 44 45 45 /* GPIOs */ 46 - #define QI_LB60_GPIO_SD_CD JZ_GPIO_PORTD(0) 47 - #define QI_LB60_GPIO_SD_VCC_EN_N JZ_GPIO_PORTD(2) 48 - 49 46 #define QI_LB60_GPIO_KEYOUT(x) (JZ_GPIO_PORTC(10) + (x)) 50 47 #define QI_LB60_GPIO_KEYIN(x) (JZ_GPIO_PORTD(18) + (x)) 51 48 #define QI_LB60_GPIO_KEYIN8 JZ_GPIO_PORTD(26) ··· 383 386 }; 384 387 385 388 static struct jz4740_mmc_platform_data qi_lb60_mmc_pdata = { 386 - .gpio_card_detect = QI_LB60_GPIO_SD_CD, 387 - .gpio_read_only = -1, 388 - .gpio_power = QI_LB60_GPIO_SD_VCC_EN_N, 389 - .power_active_low = 1, 389 + /* Intentionally left blank */ 390 + }; 391 + 392 + static struct gpiod_lookup_table qi_lb60_mmc_gpio_table = { 393 + .dev_id = "jz4740-mmc.0", 394 + .table = { 395 + GPIO_LOOKUP("GPIOD", 0, "cd", GPIO_ACTIVE_HIGH), 396 + GPIO_LOOKUP("GPIOD", 2, "power", GPIO_ACTIVE_LOW), 397 + { }, 398 + }, 390 399 }; 391 400 392 401 /* beeper */ ··· 503 500 gpiod_add_lookup_table(&qi_lb60_audio_gpio_table); 504 501 gpiod_add_lookup_table(&qi_lb60_nand_gpio_table); 505 502 gpiod_add_lookup_table(&qi_lb60_spigpio_gpio_table); 503 + gpiod_add_lookup_table(&qi_lb60_mmc_gpio_table); 506 504 507 505 spi_register_board_info(qi_lb60_spi_board_info, 508 506 ARRAY_SIZE(qi_lb60_spi_board_info));
+36 -7
arch/sh/boards/mach-ecovec24/setup.c
··· 696 696 }, 697 697 }; 698 698 699 + static struct gpiod_lookup_table sdhi0_gpio_table = { 700 + .dev_id = "sh_mobile_sdhi.0", 701 + .table = { 702 + /* Card detect */ 703 + GPIO_LOOKUP("sh7724_pfc", GPIO_PTY7, "cd", GPIO_ACTIVE_LOW), 704 + { }, 705 + }, 706 + }; 707 + 699 708 static struct tmio_mmc_data sdhi0_info = { 700 709 .chan_priv_tx = (void *)SHDMA_SLAVE_SDHI0_TX, 701 710 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI0_RX, 702 711 .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 703 712 MMC_CAP_NEEDS_POLL, 704 - .flags = TMIO_MMC_USE_GPIO_CD, 705 - .cd_gpio = GPIO_PTY7, 706 713 }; 707 714 708 715 static struct resource sdhi0_resources[] = { ··· 742 735 .chan_priv_rx = (void *)SHDMA_SLAVE_SDHI1_RX, 743 736 .capabilities = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | 744 737 MMC_CAP_NEEDS_POLL, 745 - .flags = TMIO_MMC_USE_GPIO_CD, 746 - .cd_gpio = GPIO_PTW7, 738 + }; 739 + 740 + static struct gpiod_lookup_table sdhi1_gpio_table = { 741 + .dev_id = "sh_mobile_sdhi.1", 742 + .table = { 743 + /* Card detect */ 744 + GPIO_LOOKUP("sh7724_pfc", GPIO_PTW7, "cd", GPIO_ACTIVE_LOW), 745 + { }, 746 + }, 747 747 }; 748 748 749 749 static struct resource sdhi1_resources[] = { ··· 790 776 .caps2 = MMC_CAP2_RO_ACTIVE_HIGH, 791 777 .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, /* 3.3V only */ 792 778 .setpower = mmc_spi_setpower, 793 - .flags = MMC_SPI_USE_CD_GPIO | MMC_SPI_USE_RO_GPIO, 794 - .cd_gpio = GPIO_PTY7, 795 - .ro_gpio = GPIO_PTY6, 779 + }; 780 + 781 + static struct gpiod_lookup_table mmc_spi_gpio_table = { 782 + .dev_id = "mmc_spi.0", /* device "mmc_spi" @ CS0 */ 783 + .table = { 784 + /* Card detect */ 785 + GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY7, NULL, 0, 786 + GPIO_ACTIVE_LOW), 787 + /* Write protect */ 788 + GPIO_LOOKUP_IDX("sh7724_pfc", GPIO_PTY6, NULL, 1, 789 + GPIO_ACTIVE_HIGH), 790 + { }, 791 + }, 796 792 }; 797 793 798 794 static struct spi_board_info spi_bus[] = { ··· 1306 1282 gpio_request(GPIO_PTB6, NULL); /* 3.3V power control */ 1307 1283 gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ 1308 1284 1285 + gpiod_add_lookup_table(&mmc_spi_gpio_table); 1309 1286 spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); 1310 1287 #endif 1311 1288 ··· 1459 1434 gpiod_add_lookup_table(&cn12_power_gpiod_table); 1460 1435 #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) 1461 1436 gpiod_add_lookup_table(&sdhi0_power_gpiod_table); 1437 + gpiod_add_lookup_table(&sdhi0_gpio_table); 1438 + #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) 1439 + gpiod_add_lookup_table(&sdhi1_gpio_table); 1440 + #endif 1462 1441 #endif 1463 1442 1464 1443 return platform_add_devices(ecovec_devices,
+1 -1
drivers/gpio/gpio-pca953x.c
··· 449 449 450 450 gc->base = chip->gpio_start; 451 451 gc->ngpio = gpios; 452 - gc->label = chip->client->name; 452 + gc->label = dev_name(&chip->client->dev); 453 453 gc->parent = &chip->client->dev; 454 454 gc->owner = THIS_MODULE; 455 455 gc->names = chip->names;
+3
drivers/memstick/core/memstick.c
··· 18 18 #include <linux/delay.h> 19 19 #include <linux/slab.h> 20 20 #include <linux/module.h> 21 + #include <linux/pm_runtime.h> 21 22 22 23 #define DRIVER_NAME "memstick" 23 24 ··· 437 436 struct memstick_dev *card; 438 437 439 438 dev_dbg(&host->dev, "memstick_check started\n"); 439 + pm_runtime_get_noresume(host->dev.parent); 440 440 mutex_lock(&host->lock); 441 441 if (!host->card) { 442 442 if (memstick_power_on(host)) ··· 481 479 host->set_param(host, MEMSTICK_POWER, MEMSTICK_POWER_OFF); 482 480 483 481 mutex_unlock(&host->lock); 482 + pm_runtime_put(host->dev.parent); 484 483 dev_dbg(&host->dev, "memstick_check finished\n"); 485 484 } 486 485
+107 -69
drivers/memstick/host/rtsx_usb_ms.c
··· 40 40 41 41 struct mutex host_mutex; 42 42 struct work_struct handle_req; 43 - 44 - struct task_struct *detect_ms; 45 - struct completion detect_ms_exit; 43 + struct delayed_work poll_card; 46 44 47 45 u8 ssc_depth; 48 46 unsigned int clock; 49 47 int power_mode; 50 48 unsigned char ifmode; 51 49 bool eject; 50 + bool system_suspending; 52 51 }; 53 52 54 53 static inline struct device *ms_dev(struct rtsx_usb_ms *host) ··· 544 545 host->req->error); 545 546 } 546 547 } while (!rc); 547 - pm_runtime_put(ms_dev(host)); 548 + pm_runtime_put_sync(ms_dev(host)); 548 549 } 549 550 550 551 } ··· 584 585 break; 585 586 586 587 if (value == MEMSTICK_POWER_ON) { 587 - pm_runtime_get_sync(ms_dev(host)); 588 + pm_runtime_get_noresume(ms_dev(host)); 588 589 err = ms_power_on(host); 590 + if (err) 591 + pm_runtime_put_noidle(ms_dev(host)); 589 592 } else if (value == MEMSTICK_POWER_OFF) { 590 593 err = ms_power_off(host); 591 - if (host->msh->card) 594 + if (!err) 592 595 pm_runtime_put_noidle(ms_dev(host)); 593 - else 594 - pm_runtime_put(ms_dev(host)); 595 596 } else 596 597 err = -EINVAL; 597 598 if (!err) ··· 637 638 } 638 639 out: 639 640 mutex_unlock(&ucr->dev_mutex); 640 - pm_runtime_put(ms_dev(host)); 641 + pm_runtime_put_sync(ms_dev(host)); 641 642 642 643 /* power-on delay */ 643 - if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) 644 + if (param == MEMSTICK_POWER && value == MEMSTICK_POWER_ON) { 644 645 usleep_range(10000, 12000); 646 + 647 + if (!host->eject) 648 + schedule_delayed_work(&host->poll_card, 100); 649 + } 645 650 646 651 dev_dbg(ms_dev(host), "%s: return = %d\n", __func__, err); 647 652 return err; ··· 657 654 struct rtsx_usb_ms *host = dev_get_drvdata(dev); 658 655 struct memstick_host *msh = host->msh; 659 656 660 - dev_dbg(ms_dev(host), "--> %s\n", __func__); 657 + /* Since we use rtsx_usb's resume callback to runtime resume its 658 + * children to implement remote wakeup signaling, this causes 659 + * rtsx_usb_ms' runtime resume callback runs after its suspend 660 + * callback: 661 + * rtsx_usb_ms_suspend() 662 + * rtsx_usb_resume() 663 + * -> rtsx_usb_ms_runtime_resume() 664 + * -> memstick_detect_change() 665 + * 666 + * rtsx_usb_suspend() 667 + * 668 + * To avoid this, skip runtime resume/suspend if system suspend is 669 + * underway. 670 + */ 661 671 672 + host->system_suspending = true; 662 673 memstick_suspend_host(msh); 674 + 663 675 return 0; 664 676 } 665 677 ··· 683 665 struct rtsx_usb_ms *host = dev_get_drvdata(dev); 684 666 struct memstick_host *msh = host->msh; 685 667 686 - dev_dbg(ms_dev(host), "--> %s\n", __func__); 687 - 688 668 memstick_resume_host(msh); 669 + host->system_suspending = false; 670 + 689 671 return 0; 690 672 } 691 673 #endif /* CONFIG_PM_SLEEP */ 692 674 693 - /* 694 - * Thread function of ms card slot detection. The thread starts right after 695 - * successful host addition. It stops while the driver removal function sets 696 - * host->eject true. 697 - */ 698 - static int rtsx_usb_detect_ms_card(void *__host) 675 + #ifdef CONFIG_PM 676 + static int rtsx_usb_ms_runtime_suspend(struct device *dev) 699 677 { 700 - struct rtsx_usb_ms *host = (struct rtsx_usb_ms *)__host; 678 + struct rtsx_usb_ms *host = dev_get_drvdata(dev); 679 + 680 + if (host->system_suspending) 681 + return 0; 682 + 683 + if (host->msh->card || host->power_mode != MEMSTICK_POWER_OFF) 684 + return -EAGAIN; 685 + 686 + return 0; 687 + } 688 + 689 + static int rtsx_usb_ms_runtime_resume(struct device *dev) 690 + { 691 + struct rtsx_usb_ms *host = dev_get_drvdata(dev); 692 + 693 + 694 + if (host->system_suspending) 695 + return 0; 696 + 697 + memstick_detect_change(host->msh); 698 + 699 + return 0; 700 + } 701 + #endif /* CONFIG_PM */ 702 + 703 + static const struct dev_pm_ops rtsx_usb_ms_pm_ops = { 704 + SET_SYSTEM_SLEEP_PM_OPS(rtsx_usb_ms_suspend, rtsx_usb_ms_resume) 705 + SET_RUNTIME_PM_OPS(rtsx_usb_ms_runtime_suspend, rtsx_usb_ms_runtime_resume, NULL) 706 + }; 707 + 708 + 709 + static void rtsx_usb_ms_poll_card(struct work_struct *work) 710 + { 711 + struct rtsx_usb_ms *host = container_of(work, struct rtsx_usb_ms, 712 + poll_card.work); 701 713 struct rtsx_ucr *ucr = host->ucr; 702 - u8 val = 0; 703 714 int err; 715 + u8 val; 704 716 705 - for (;;) { 706 - pm_runtime_get_sync(ms_dev(host)); 707 - mutex_lock(&ucr->dev_mutex); 717 + if (host->eject || host->power_mode != MEMSTICK_POWER_ON) 718 + return; 708 719 709 - /* Check pending MS card changes */ 710 - err = rtsx_usb_read_register(ucr, CARD_INT_PEND, &val); 711 - if (err) { 712 - mutex_unlock(&ucr->dev_mutex); 713 - goto poll_again; 714 - } 720 + pm_runtime_get_sync(ms_dev(host)); 721 + mutex_lock(&ucr->dev_mutex); 715 722 716 - /* Clear the pending */ 717 - rtsx_usb_write_register(ucr, CARD_INT_PEND, 718 - XD_INT | MS_INT | SD_INT, 719 - XD_INT | MS_INT | SD_INT); 720 - 723 + /* Check pending MS card changes */ 724 + err = rtsx_usb_read_register(ucr, CARD_INT_PEND, &val); 725 + if (err) { 721 726 mutex_unlock(&ucr->dev_mutex); 722 - 723 - if (val & MS_INT) { 724 - dev_dbg(ms_dev(host), "MS slot change detected\n"); 725 - memstick_detect_change(host->msh); 726 - } 727 - 728 - poll_again: 729 - pm_runtime_put(ms_dev(host)); 730 - if (host->eject) 731 - break; 732 - 733 - schedule_timeout_idle(HZ); 727 + goto poll_again; 734 728 } 735 729 736 - complete(&host->detect_ms_exit); 737 - return 0; 730 + /* Clear the pending */ 731 + rtsx_usb_write_register(ucr, CARD_INT_PEND, 732 + XD_INT | MS_INT | SD_INT, 733 + XD_INT | MS_INT | SD_INT); 734 + 735 + mutex_unlock(&ucr->dev_mutex); 736 + 737 + if (val & MS_INT) { 738 + dev_dbg(ms_dev(host), "MS slot change detected\n"); 739 + memstick_detect_change(host->msh); 740 + } 741 + 742 + poll_again: 743 + pm_runtime_put_sync(ms_dev(host)); 744 + 745 + if (!host->eject && host->power_mode == MEMSTICK_POWER_ON) 746 + schedule_delayed_work(&host->poll_card, 100); 738 747 } 739 748 740 749 static int rtsx_usb_ms_drv_probe(struct platform_device *pdev) ··· 792 747 mutex_init(&host->host_mutex); 793 748 INIT_WORK(&host->handle_req, rtsx_usb_ms_handle_req); 794 749 795 - init_completion(&host->detect_ms_exit); 796 - host->detect_ms = kthread_create(rtsx_usb_detect_ms_card, host, 797 - "rtsx_usb_ms_%d", pdev->id); 798 - if (IS_ERR(host->detect_ms)) { 799 - dev_dbg(&(pdev->dev), 800 - "Unable to create polling thread.\n"); 801 - err = PTR_ERR(host->detect_ms); 802 - goto err_out; 803 - } 750 + INIT_DELAYED_WORK(&host->poll_card, rtsx_usb_ms_poll_card); 804 751 805 752 msh->request = rtsx_usb_ms_request; 806 753 msh->set_param = rtsx_usb_ms_set_param; 807 754 msh->caps = MEMSTICK_CAP_PAR4; 808 755 809 - pm_runtime_enable(&pdev->dev); 756 + pm_runtime_get_noresume(ms_dev(host)); 757 + pm_runtime_set_active(ms_dev(host)); 758 + pm_runtime_enable(ms_dev(host)); 759 + 810 760 err = memstick_add_host(msh); 811 761 if (err) 812 762 goto err_out; 813 763 814 - wake_up_process(host->detect_ms); 764 + pm_runtime_put(ms_dev(host)); 765 + 815 766 return 0; 816 767 err_out: 817 768 memstick_free_host(msh); 769 + pm_runtime_disable(ms_dev(host)); 770 + pm_runtime_put_noidle(ms_dev(host)); 818 771 return err; 819 772 } 820 773 821 774 static int rtsx_usb_ms_drv_remove(struct platform_device *pdev) 822 775 { 823 776 struct rtsx_usb_ms *host = platform_get_drvdata(pdev); 824 - struct memstick_host *msh; 777 + struct memstick_host *msh = host->msh; 825 778 int err; 826 779 827 - msh = host->msh; 828 780 host->eject = true; 829 781 cancel_work_sync(&host->handle_req); 830 782 831 783 mutex_lock(&host->host_mutex); 832 784 if (host->req) { 833 - dev_dbg(&(pdev->dev), 785 + dev_dbg(ms_dev(host), 834 786 "%s: Controller removed during transfer\n", 835 787 dev_name(&msh->dev)); 836 788 host->req->error = -ENOMEDIUM; ··· 839 797 } 840 798 mutex_unlock(&host->host_mutex); 841 799 842 - wait_for_completion(&host->detect_ms_exit); 843 800 memstick_remove_host(msh); 844 801 memstick_free_host(msh); 845 802 ··· 848 807 if (pm_runtime_active(ms_dev(host))) 849 808 pm_runtime_put(ms_dev(host)); 850 809 851 - pm_runtime_disable(&pdev->dev); 810 + pm_runtime_disable(ms_dev(host)); 852 811 platform_set_drvdata(pdev, NULL); 853 812 854 - dev_dbg(&(pdev->dev), 813 + dev_dbg(ms_dev(host), 855 814 ": Realtek USB Memstick controller has been removed\n"); 856 815 857 816 return 0; 858 817 } 859 - 860 - static SIMPLE_DEV_PM_OPS(rtsx_usb_ms_pm_ops, 861 - rtsx_usb_ms_suspend, rtsx_usb_ms_resume); 862 818 863 819 static struct platform_device_id rtsx_usb_ms_ids[] = { 864 820 {
+1 -1
drivers/misc/Makefile
··· 57 57 obj-$(CONFIG_ASPEED_LPC_SNOOP) += aspeed-lpc-snoop.o 58 58 obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o 59 59 obj-$(CONFIG_OCXL) += ocxl/ 60 - obj-$(CONFIG_MISC_RTSX) += cardreader/ 60 + obj-y += cardreader/
+11
drivers/misc/cardreader/Kconfig
··· 1 + config MISC_ALCOR_PCI 2 + tristate "Alcor Micro/Alcor Link PCI-E card reader" 3 + depends on PCI 4 + select MFD_CORE 5 + help 6 + This supports for Alcor Micro PCI-Express card reader including au6601, 7 + au6621. 8 + Alcor Micro card readers support access to many types of memory cards, 9 + such as Memory Stick, Memory Stick Pro, Secure Digital and 10 + MultiMediaCard. 11 + 1 12 config MISC_RTSX_PCI 2 13 tristate "Realtek PCI-E card reader" 3 14 depends on PCI
+2 -2
drivers/misc/cardreader/Makefile
··· 1 - rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o rts5260.o 2 - 1 + obj-$(CONFIG_MISC_ALCOR_PCI) += alcor_pci.o 3 2 obj-$(CONFIG_MISC_RTSX_PCI) += rtsx_pci.o 3 + rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o rts5260.o 4 4 obj-$(CONFIG_MISC_RTSX_USB) += rtsx_usb.o
+371
drivers/misc/cardreader/alcor_pci.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright (C) 2018 Oleksij Rempel <linux@rempel-privat.de> 4 + * 5 + * Driver for Alcor Micro AU6601 and AU6621 controllers 6 + */ 7 + 8 + #include <linux/delay.h> 9 + #include <linux/interrupt.h> 10 + #include <linux/io.h> 11 + #include <linux/irq.h> 12 + #include <linux/mfd/core.h> 13 + #include <linux/module.h> 14 + #include <linux/pci.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/pm.h> 17 + 18 + #include <linux/alcor_pci.h> 19 + 20 + #define DRV_NAME_ALCOR_PCI "alcor_pci" 21 + 22 + static DEFINE_IDA(alcor_pci_idr); 23 + 24 + static struct mfd_cell alcor_pci_cells[] = { 25 + [ALCOR_SD_CARD] = { 26 + .name = DRV_NAME_ALCOR_PCI_SDMMC, 27 + }, 28 + [ALCOR_MS_CARD] = { 29 + .name = DRV_NAME_ALCOR_PCI_MS, 30 + }, 31 + }; 32 + 33 + static const struct alcor_dev_cfg alcor_cfg = { 34 + .dma = 0, 35 + }; 36 + 37 + static const struct alcor_dev_cfg au6621_cfg = { 38 + .dma = 1, 39 + }; 40 + 41 + static const struct pci_device_id pci_ids[] = { 42 + { PCI_DEVICE(PCI_ID_ALCOR_MICRO, PCI_ID_AU6601), 43 + .driver_data = (kernel_ulong_t)&alcor_cfg }, 44 + { PCI_DEVICE(PCI_ID_ALCOR_MICRO, PCI_ID_AU6621), 45 + .driver_data = (kernel_ulong_t)&au6621_cfg }, 46 + { }, 47 + }; 48 + MODULE_DEVICE_TABLE(pci, pci_ids); 49 + 50 + void alcor_write8(struct alcor_pci_priv *priv, u8 val, unsigned int addr) 51 + { 52 + writeb(val, priv->iobase + addr); 53 + } 54 + EXPORT_SYMBOL_GPL(alcor_write8); 55 + 56 + void alcor_write16(struct alcor_pci_priv *priv, u16 val, unsigned int addr) 57 + { 58 + writew(val, priv->iobase + addr); 59 + } 60 + EXPORT_SYMBOL_GPL(alcor_write16); 61 + 62 + void alcor_write32(struct alcor_pci_priv *priv, u32 val, unsigned int addr) 63 + { 64 + writel(val, priv->iobase + addr); 65 + } 66 + EXPORT_SYMBOL_GPL(alcor_write32); 67 + 68 + void alcor_write32be(struct alcor_pci_priv *priv, u32 val, unsigned int addr) 69 + { 70 + iowrite32be(val, priv->iobase + addr); 71 + } 72 + EXPORT_SYMBOL_GPL(alcor_write32be); 73 + 74 + u8 alcor_read8(struct alcor_pci_priv *priv, unsigned int addr) 75 + { 76 + return readb(priv->iobase + addr); 77 + } 78 + EXPORT_SYMBOL_GPL(alcor_read8); 79 + 80 + u32 alcor_read32(struct alcor_pci_priv *priv, unsigned int addr) 81 + { 82 + return readl(priv->iobase + addr); 83 + } 84 + EXPORT_SYMBOL_GPL(alcor_read32); 85 + 86 + u32 alcor_read32be(struct alcor_pci_priv *priv, unsigned int addr) 87 + { 88 + return ioread32be(priv->iobase + addr); 89 + } 90 + EXPORT_SYMBOL_GPL(alcor_read32be); 91 + 92 + static int alcor_pci_find_cap_offset(struct alcor_pci_priv *priv, 93 + struct pci_dev *pci) 94 + { 95 + int where; 96 + u8 val8; 97 + u32 val32; 98 + 99 + where = ALCOR_CAP_START_OFFSET; 100 + pci_read_config_byte(pci, where, &val8); 101 + if (!val8) 102 + return 0; 103 + 104 + where = (int)val8; 105 + while (1) { 106 + pci_read_config_dword(pci, where, &val32); 107 + if (val32 == 0xffffffff) { 108 + dev_dbg(priv->dev, "find_cap_offset invalid value %x.\n", 109 + val32); 110 + return 0; 111 + } 112 + 113 + if ((val32 & 0xff) == 0x10) { 114 + dev_dbg(priv->dev, "pcie cap offset: %x\n", where); 115 + return where; 116 + } 117 + 118 + if ((val32 & 0xff00) == 0x00) { 119 + dev_dbg(priv->dev, "pci_find_cap_offset invalid value %x.\n", 120 + val32); 121 + break; 122 + } 123 + where = (int)((val32 >> 8) & 0xff); 124 + } 125 + 126 + return 0; 127 + } 128 + 129 + static void alcor_pci_init_check_aspm(struct alcor_pci_priv *priv) 130 + { 131 + struct pci_dev *pci; 132 + int where; 133 + u32 val32; 134 + 135 + priv->pdev_cap_off = alcor_pci_find_cap_offset(priv, priv->pdev); 136 + priv->parent_cap_off = alcor_pci_find_cap_offset(priv, 137 + priv->parent_pdev); 138 + 139 + if ((priv->pdev_cap_off == 0) || (priv->parent_cap_off == 0)) { 140 + dev_dbg(priv->dev, "pci_cap_off: %x, parent_cap_off: %x\n", 141 + priv->pdev_cap_off, priv->parent_cap_off); 142 + return; 143 + } 144 + 145 + /* link capability */ 146 + pci = priv->pdev; 147 + where = priv->pdev_cap_off + ALCOR_PCIE_LINK_CAP_OFFSET; 148 + pci_read_config_dword(pci, where, &val32); 149 + priv->pdev_aspm_cap = (u8)(val32 >> 10) & 0x03; 150 + 151 + pci = priv->parent_pdev; 152 + where = priv->parent_cap_off + ALCOR_PCIE_LINK_CAP_OFFSET; 153 + pci_read_config_dword(pci, where, &val32); 154 + priv->parent_aspm_cap = (u8)(val32 >> 10) & 0x03; 155 + 156 + if (priv->pdev_aspm_cap != priv->parent_aspm_cap) { 157 + u8 aspm_cap; 158 + 159 + dev_dbg(priv->dev, "pdev_aspm_cap: %x, parent_aspm_cap: %x\n", 160 + priv->pdev_aspm_cap, priv->parent_aspm_cap); 161 + aspm_cap = priv->pdev_aspm_cap & priv->parent_aspm_cap; 162 + priv->pdev_aspm_cap = aspm_cap; 163 + priv->parent_aspm_cap = aspm_cap; 164 + } 165 + 166 + dev_dbg(priv->dev, "ext_config_dev_aspm: %x, pdev_aspm_cap: %x\n", 167 + priv->ext_config_dev_aspm, priv->pdev_aspm_cap); 168 + priv->ext_config_dev_aspm &= priv->pdev_aspm_cap; 169 + } 170 + 171 + static void alcor_pci_aspm_ctrl(struct alcor_pci_priv *priv, u8 aspm_enable) 172 + { 173 + struct pci_dev *pci; 174 + u8 aspm_ctrl, i; 175 + int where; 176 + u32 val32; 177 + 178 + if ((!priv->pdev_cap_off) || (!priv->parent_cap_off)) { 179 + dev_dbg(priv->dev, "pci_cap_off: %x, parent_cap_off: %x\n", 180 + priv->pdev_cap_off, priv->parent_cap_off); 181 + return; 182 + } 183 + 184 + if (!priv->pdev_aspm_cap) 185 + return; 186 + 187 + aspm_ctrl = 0; 188 + if (aspm_enable) { 189 + aspm_ctrl = priv->ext_config_dev_aspm; 190 + 191 + if (!aspm_ctrl) { 192 + dev_dbg(priv->dev, "aspm_ctrl == 0\n"); 193 + return; 194 + } 195 + } 196 + 197 + for (i = 0; i < 2; i++) { 198 + 199 + if (i) { 200 + pci = priv->parent_pdev; 201 + where = priv->parent_cap_off 202 + + ALCOR_PCIE_LINK_CTRL_OFFSET; 203 + } else { 204 + pci = priv->pdev; 205 + where = priv->pdev_cap_off 206 + + ALCOR_PCIE_LINK_CTRL_OFFSET; 207 + } 208 + 209 + pci_read_config_dword(pci, where, &val32); 210 + val32 &= (~0x03); 211 + val32 |= (aspm_ctrl & priv->pdev_aspm_cap); 212 + pci_write_config_byte(pci, where, (u8)val32); 213 + } 214 + 215 + } 216 + 217 + static inline void alcor_mask_sd_irqs(struct alcor_pci_priv *priv) 218 + { 219 + alcor_write32(priv, 0, AU6601_REG_INT_ENABLE); 220 + } 221 + 222 + static inline void alcor_unmask_sd_irqs(struct alcor_pci_priv *priv) 223 + { 224 + alcor_write32(priv, AU6601_INT_CMD_MASK | AU6601_INT_DATA_MASK | 225 + AU6601_INT_CARD_INSERT | AU6601_INT_CARD_REMOVE | 226 + AU6601_INT_OVER_CURRENT_ERR, 227 + AU6601_REG_INT_ENABLE); 228 + } 229 + 230 + static inline void alcor_mask_ms_irqs(struct alcor_pci_priv *priv) 231 + { 232 + alcor_write32(priv, 0, AU6601_MS_INT_ENABLE); 233 + } 234 + 235 + static inline void alcor_unmask_ms_irqs(struct alcor_pci_priv *priv) 236 + { 237 + alcor_write32(priv, 0x3d00fa, AU6601_MS_INT_ENABLE); 238 + } 239 + 240 + static int alcor_pci_probe(struct pci_dev *pdev, 241 + const struct pci_device_id *ent) 242 + { 243 + struct alcor_dev_cfg *cfg; 244 + struct alcor_pci_priv *priv; 245 + int ret, i, bar = 0; 246 + 247 + cfg = (void *)ent->driver_data; 248 + 249 + ret = pcim_enable_device(pdev); 250 + if (ret) 251 + return ret; 252 + 253 + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); 254 + if (!priv) 255 + return -ENOMEM; 256 + 257 + ret = ida_simple_get(&alcor_pci_idr, 0, 0, GFP_KERNEL); 258 + if (ret < 0) 259 + return ret; 260 + priv->id = ret; 261 + 262 + priv->pdev = pdev; 263 + priv->parent_pdev = pdev->bus->self; 264 + priv->dev = &pdev->dev; 265 + priv->cfg = cfg; 266 + priv->irq = pdev->irq; 267 + 268 + ret = pci_request_regions(pdev, DRV_NAME_ALCOR_PCI); 269 + if (ret) { 270 + dev_err(&pdev->dev, "Cannot request region\n"); 271 + return -ENOMEM; 272 + } 273 + 274 + if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { 275 + dev_err(&pdev->dev, "BAR %d is not iomem. Aborting.\n", bar); 276 + ret = -ENODEV; 277 + goto error_release_regions; 278 + } 279 + 280 + priv->iobase = pcim_iomap(pdev, bar, 0); 281 + if (!priv->iobase) { 282 + ret = -ENOMEM; 283 + goto error_release_regions; 284 + } 285 + 286 + /* make sure irqs are disabled */ 287 + alcor_write32(priv, 0, AU6601_REG_INT_ENABLE); 288 + alcor_write32(priv, 0, AU6601_MS_INT_ENABLE); 289 + 290 + ret = dma_set_mask_and_coherent(priv->dev, AU6601_SDMA_MASK); 291 + if (ret) { 292 + dev_err(priv->dev, "Failed to set DMA mask\n"); 293 + goto error_release_regions; 294 + } 295 + 296 + pci_set_master(pdev); 297 + pci_set_drvdata(pdev, priv); 298 + alcor_pci_init_check_aspm(priv); 299 + 300 + for (i = 0; i < ARRAY_SIZE(alcor_pci_cells); i++) { 301 + alcor_pci_cells[i].platform_data = priv; 302 + alcor_pci_cells[i].pdata_size = sizeof(*priv); 303 + } 304 + ret = mfd_add_devices(&pdev->dev, priv->id, alcor_pci_cells, 305 + ARRAY_SIZE(alcor_pci_cells), NULL, 0, NULL); 306 + if (ret < 0) 307 + goto error_release_regions; 308 + 309 + alcor_pci_aspm_ctrl(priv, 0); 310 + 311 + return 0; 312 + 313 + error_release_regions: 314 + pci_release_regions(pdev); 315 + return ret; 316 + } 317 + 318 + static void alcor_pci_remove(struct pci_dev *pdev) 319 + { 320 + struct alcor_pci_priv *priv; 321 + 322 + priv = pci_get_drvdata(pdev); 323 + 324 + alcor_pci_aspm_ctrl(priv, 1); 325 + 326 + mfd_remove_devices(&pdev->dev); 327 + 328 + ida_simple_remove(&alcor_pci_idr, priv->id); 329 + 330 + pci_release_regions(pdev); 331 + pci_set_drvdata(pdev, NULL); 332 + } 333 + 334 + #ifdef CONFIG_PM_SLEEP 335 + static int alcor_suspend(struct device *dev) 336 + { 337 + struct pci_dev *pdev = to_pci_dev(dev); 338 + struct alcor_pci_priv *priv = pci_get_drvdata(pdev); 339 + 340 + alcor_pci_aspm_ctrl(priv, 1); 341 + return 0; 342 + } 343 + 344 + static int alcor_resume(struct device *dev) 345 + { 346 + 347 + struct pci_dev *pdev = to_pci_dev(dev); 348 + struct alcor_pci_priv *priv = pci_get_drvdata(pdev); 349 + 350 + alcor_pci_aspm_ctrl(priv, 0); 351 + return 0; 352 + } 353 + #endif /* CONFIG_PM_SLEEP */ 354 + 355 + static SIMPLE_DEV_PM_OPS(alcor_pci_pm_ops, alcor_suspend, alcor_resume); 356 + 357 + static struct pci_driver alcor_driver = { 358 + .name = DRV_NAME_ALCOR_PCI, 359 + .id_table = pci_ids, 360 + .probe = alcor_pci_probe, 361 + .remove = alcor_pci_remove, 362 + .driver = { 363 + .pm = &alcor_pci_pm_ops 364 + }, 365 + }; 366 + 367 + module_pci_driver(alcor_driver); 368 + 369 + MODULE_AUTHOR("Oleksij Rempel <linux@rempel-privat.de>"); 370 + MODULE_DESCRIPTION("PCI driver for Alcor Micro AU6601 Secure Digital Host Controller Interface"); 371 + MODULE_LICENSE("GPL");
+8
drivers/misc/cardreader/rtsx_usb.c
··· 723 723 return 0; 724 724 } 725 725 726 + static int rtsx_usb_resume_child(struct device *dev, void *data) 727 + { 728 + pm_request_resume(dev); 729 + return 0; 730 + } 731 + 726 732 static int rtsx_usb_resume(struct usb_interface *intf) 727 733 { 734 + device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child); 728 735 return 0; 729 736 } 730 737 ··· 741 734 (struct rtsx_ucr *)usb_get_intfdata(intf); 742 735 743 736 rtsx_usb_reset_chip(ucr); 737 + device_for_each_child(&intf->dev, NULL, rtsx_usb_resume_child); 744 738 return 0; 745 739 } 746 740
+1 -1
drivers/mmc/core/block.c
··· 1960 1960 struct mmc_queue_req *mqrq) 1961 1961 { 1962 1962 if (mmc_blk_urgent_bkops_needed(mq, mqrq)) 1963 - mmc_start_bkops(mq->card, true); 1963 + mmc_run_bkops(mq->card); 1964 1964 } 1965 1965 1966 1966 void mmc_blk_mq_complete(struct request *req)
+1 -5
drivers/mmc/core/card.h
··· 23 23 #define MMC_STATE_BLOCKADDR (1<<2) /* card uses block-addressing */ 24 24 #define MMC_CARD_SDXC (1<<3) /* card is SDXC */ 25 25 #define MMC_CARD_REMOVED (1<<4) /* card has been removed */ 26 - #define MMC_STATE_DOING_BKOPS (1<<5) /* card is doing BKOPS */ 27 - #define MMC_STATE_SUSPENDED (1<<6) /* card is suspended */ 26 + #define MMC_STATE_SUSPENDED (1<<5) /* card is suspended */ 28 27 29 28 #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) 30 29 #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) 31 30 #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) 32 31 #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC) 33 32 #define mmc_card_removed(c) ((c) && ((c)->state & MMC_CARD_REMOVED)) 34 - #define mmc_card_doing_bkops(c) ((c)->state & MMC_STATE_DOING_BKOPS) 35 33 #define mmc_card_suspended(c) ((c)->state & MMC_STATE_SUSPENDED) 36 34 37 35 #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) ··· 37 39 #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) 38 40 #define mmc_card_set_ext_capacity(c) ((c)->state |= MMC_CARD_SDXC) 39 41 #define mmc_card_set_removed(c) ((c)->state |= MMC_CARD_REMOVED) 40 - #define mmc_card_set_doing_bkops(c) ((c)->state |= MMC_STATE_DOING_BKOPS) 41 - #define mmc_card_clr_doing_bkops(c) ((c)->state &= ~MMC_STATE_DOING_BKOPS) 42 42 #define mmc_card_set_suspended(c) ((c)->state |= MMC_STATE_SUSPENDED) 43 43 #define mmc_card_clr_suspended(c) ((c)->state &= ~MMC_STATE_SUSPENDED) 44 44
+4 -15
drivers/mmc/core/core.c
··· 887 887 spin_unlock_irqrestore(&host->lock, flags); 888 888 wake_up(&host->wq); 889 889 pm_runtime_mark_last_busy(mmc_dev(host)); 890 - pm_runtime_put_autosuspend(mmc_dev(host)); 890 + if (host->caps & MMC_CAP_SYNC_RUNTIME_PM) 891 + pm_runtime_put_sync_suspend(mmc_dev(host)); 892 + else 893 + pm_runtime_put_autosuspend(mmc_dev(host)); 891 894 } 892 895 } 893 896 EXPORT_SYMBOL(mmc_release_host); ··· 2415 2412 return mmc_wait_for_cmd(card->host, &cmd, 5); 2416 2413 } 2417 2414 EXPORT_SYMBOL(mmc_set_blocklen); 2418 - 2419 - int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount, 2420 - bool is_rel_write) 2421 - { 2422 - struct mmc_command cmd = {}; 2423 - 2424 - cmd.opcode = MMC_SET_BLOCK_COUNT; 2425 - cmd.arg = blockcount & 0x0000FFFF; 2426 - if (is_rel_write) 2427 - cmd.arg |= 1 << 31; 2428 - cmd.flags = MMC_RSP_SPI_R1 | MMC_RSP_R1 | MMC_CMD_AC; 2429 - return mmc_wait_for_cmd(card->host, &cmd, 5); 2430 - } 2431 - EXPORT_SYMBOL(mmc_set_blockcount); 2432 2415 2433 2416 static void mmc_hw_reset_for_init(struct mmc_host *host) 2434 2417 {
-2
drivers/mmc/core/core.h
··· 118 118 unsigned int mmc_calc_max_discard(struct mmc_card *card); 119 119 120 120 int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen); 121 - int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount, 122 - bool is_rel_write); 123 121 124 122 int __mmc_claim_host(struct mmc_host *host, struct mmc_ctx *ctx, 125 123 atomic_t *abort);
+3 -6
drivers/mmc/core/mmc.c
··· 1181 1181 if (err) 1182 1182 goto out_err; 1183 1183 1184 + if (host->ops->hs400_prepare_ddr) 1185 + host->ops->hs400_prepare_ddr(host); 1186 + 1184 1187 /* Switch card to DDR */ 1185 1188 err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 1186 1189 EXT_CSD_BUS_WIDTH, ··· 2013 2010 2014 2011 if (mmc_card_suspended(host->card)) 2015 2012 goto out; 2016 - 2017 - if (mmc_card_doing_bkops(host->card)) { 2018 - err = mmc_stop_bkops(host->card); 2019 - if (err) 2020 - goto out; 2021 - } 2022 2013 2023 2014 err = mmc_flush_cache(host->card); 2024 2015 if (err)
+18 -75
drivers/mmc/core/mmc_ops.c
··· 802 802 unsigned int opcode; 803 803 int err; 804 804 805 - if (!card->ext_csd.hpi) { 806 - pr_warn("%s: Card didn't support HPI command\n", 807 - mmc_hostname(card->host)); 808 - return -EINVAL; 809 - } 810 - 811 805 opcode = card->ext_csd.hpi_cmd; 812 806 if (opcode == MMC_STOP_TRANSMISSION) 813 807 cmd.flags = MMC_RSP_R1B | MMC_CMD_AC; ··· 891 897 return (card && card->csd.mmca_vsn > CSD_SPEC_VER_3); 892 898 } 893 899 894 - /** 895 - * mmc_stop_bkops - stop ongoing BKOPS 896 - * @card: MMC card to check BKOPS 897 - * 898 - * Send HPI command to stop ongoing background operations to 899 - * allow rapid servicing of foreground operations, e.g. read/ 900 - * writes. Wait until the card comes out of the programming state 901 - * to avoid errors in servicing read/write requests. 902 - */ 903 - int mmc_stop_bkops(struct mmc_card *card) 904 - { 905 - int err = 0; 906 - 907 - err = mmc_interrupt_hpi(card); 908 - 909 - /* 910 - * If err is EINVAL, we can't issue an HPI. 911 - * It should complete the BKOPS. 912 - */ 913 - if (!err || (err == -EINVAL)) { 914 - mmc_card_clr_doing_bkops(card); 915 - mmc_retune_release(card->host); 916 - err = 0; 917 - } 918 - 919 - return err; 920 - } 921 - 922 900 static int mmc_read_bkops_status(struct mmc_card *card) 923 901 { 924 902 int err; ··· 907 941 } 908 942 909 943 /** 910 - * mmc_start_bkops - start BKOPS for supported cards 911 - * @card: MMC card to start BKOPS 912 - * @from_exception: A flag to indicate if this function was 913 - * called due to an exception raised by the card 944 + * mmc_run_bkops - Run BKOPS for supported cards 945 + * @card: MMC card to run BKOPS for 914 946 * 915 - * Start background operations whenever requested. 916 - * When the urgent BKOPS bit is set in a R1 command response 917 - * then background operations should be started immediately. 947 + * Run background operations synchronously for cards having manual BKOPS 948 + * enabled and in case it reports urgent BKOPS level. 918 949 */ 919 - void mmc_start_bkops(struct mmc_card *card, bool from_exception) 950 + void mmc_run_bkops(struct mmc_card *card) 920 951 { 921 952 int err; 922 - int timeout; 923 - bool use_busy_signal; 924 953 925 - if (!card->ext_csd.man_bkops_en || mmc_card_doing_bkops(card)) 954 + if (!card->ext_csd.man_bkops_en) 926 955 return; 927 956 928 957 err = mmc_read_bkops_status(card); ··· 927 966 return; 928 967 } 929 968 930 - if (!card->ext_csd.raw_bkops_status) 969 + if (!card->ext_csd.raw_bkops_status || 970 + card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2) 931 971 return; 932 - 933 - if (card->ext_csd.raw_bkops_status < EXT_CSD_BKOPS_LEVEL_2 && 934 - from_exception) 935 - return; 936 - 937 - if (card->ext_csd.raw_bkops_status >= EXT_CSD_BKOPS_LEVEL_2) { 938 - timeout = MMC_OPS_TIMEOUT_MS; 939 - use_busy_signal = true; 940 - } else { 941 - timeout = 0; 942 - use_busy_signal = false; 943 - } 944 972 945 973 mmc_retune_hold(card->host); 946 974 947 - err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 948 - EXT_CSD_BKOPS_START, 1, timeout, 0, 949 - use_busy_signal, true, false); 950 - if (err) { 975 + /* 976 + * For urgent BKOPS status, LEVEL_2 and higher, let's execute 977 + * synchronously. Future wise, we may consider to start BKOPS, for less 978 + * urgent levels by using an asynchronous background task, when idle. 979 + */ 980 + err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL, 981 + EXT_CSD_BKOPS_START, 1, MMC_OPS_TIMEOUT_MS); 982 + if (err) 951 983 pr_warn("%s: Error %d starting bkops\n", 952 984 mmc_hostname(card->host), err); 953 - mmc_retune_release(card->host); 954 - return; 955 - } 956 985 957 - /* 958 - * For urgent bkops status (LEVEL_2 and more) 959 - * bkops executed synchronously, otherwise 960 - * the operation is in progress 961 - */ 962 - if (!use_busy_signal) 963 - mmc_card_set_doing_bkops(card); 964 - else 965 - mmc_retune_release(card->host); 986 + mmc_retune_release(card->host); 966 987 } 967 - EXPORT_SYMBOL(mmc_start_bkops); 988 + EXPORT_SYMBOL(mmc_run_bkops); 968 989 969 990 /* 970 991 * Flush the cache to the non-volatile storage.
+1 -2
drivers/mmc/core/mmc_ops.h
··· 40 40 bool use_busy_signal, bool send_status, bool retry_crc_err); 41 41 int mmc_switch(struct mmc_card *card, u8 set, u8 index, u8 value, 42 42 unsigned int timeout_ms); 43 - int mmc_stop_bkops(struct mmc_card *card); 44 - void mmc_start_bkops(struct mmc_card *card, bool from_exception); 43 + void mmc_run_bkops(struct mmc_card *card); 45 44 int mmc_flush_cache(struct mmc_card *card); 46 45 int mmc_cmdq_enable(struct mmc_card *card); 47 46 int mmc_cmdq_disable(struct mmc_card *card);
+2 -12
drivers/mmc/core/mmc_test.c
··· 3145 3145 return 0; 3146 3146 } 3147 3147 3148 - static int mtf_testlist_open(struct inode *inode, struct file *file) 3149 - { 3150 - return single_open(file, mtf_testlist_show, inode->i_private); 3151 - } 3152 - 3153 - static const struct file_operations mmc_test_fops_testlist = { 3154 - .open = mtf_testlist_open, 3155 - .read = seq_read, 3156 - .llseek = seq_lseek, 3157 - .release = single_release, 3158 - }; 3148 + DEFINE_SHOW_ATTRIBUTE(mtf_testlist); 3159 3149 3160 3150 static void mmc_test_free_dbgfs_file(struct mmc_card *card) 3161 3151 { ··· 3206 3216 goto err; 3207 3217 3208 3218 ret = __mmc_test_register_dbgfs_file(card, "testlist", S_IRUGO, 3209 - &mmc_test_fops_testlist); 3219 + &mtf_testlist_fops); 3210 3220 if (ret) 3211 3221 goto err; 3212 3222
+11 -86
drivers/mmc/core/slot-gpio.c
··· 9 9 */ 10 10 11 11 #include <linux/err.h> 12 - #include <linux/gpio.h> 13 12 #include <linux/gpio/consumer.h> 14 13 #include <linux/interrupt.h> 15 14 #include <linux/jiffies.h> ··· 26 27 bool override_cd_active_level; 27 28 irqreturn_t (*cd_gpio_isr)(int irq, void *dev_id); 28 29 char *ro_label; 30 + char *cd_label; 29 31 u32 cd_debounce_delay_ms; 30 - char cd_label[]; 31 32 }; 32 33 33 34 static irqreturn_t mmc_gpio_cd_irqt(int irq, void *dev_id) ··· 44 45 45 46 int mmc_gpio_alloc(struct mmc_host *host) 46 47 { 47 - size_t len = strlen(dev_name(host->parent)) + 4; 48 48 struct mmc_gpio *ctx = devm_kzalloc(host->parent, 49 - sizeof(*ctx) + 2 * len, GFP_KERNEL); 49 + sizeof(*ctx), GFP_KERNEL); 50 50 51 51 if (ctx) { 52 - ctx->ro_label = ctx->cd_label + len; 53 52 ctx->cd_debounce_delay_ms = 200; 54 - snprintf(ctx->cd_label, len, "%s cd", dev_name(host->parent)); 55 - snprintf(ctx->ro_label, len, "%s ro", dev_name(host->parent)); 53 + ctx->cd_label = devm_kasprintf(host->parent, GFP_KERNEL, 54 + "%s cd", dev_name(host->parent)); 55 + if (!ctx->cd_label) 56 + return -ENOMEM; 57 + ctx->ro_label = devm_kasprintf(host->parent, GFP_KERNEL, 58 + "%s ro", dev_name(host->parent)); 59 + if (!ctx->ro_label) 60 + return -ENOMEM; 56 61 host->slot.handler_priv = ctx; 57 62 host->slot.cd_irq = -EINVAL; 58 63 } ··· 100 97 gpiod_get_value(ctx->cd_gpio); 101 98 } 102 99 EXPORT_SYMBOL(mmc_gpio_get_cd); 103 - 104 - /** 105 - * mmc_gpio_request_ro - request a gpio for write-protection 106 - * @host: mmc host 107 - * @gpio: gpio number requested 108 - * 109 - * As devm_* managed functions are used in mmc_gpio_request_ro(), client 110 - * drivers do not need to worry about freeing up memory. 111 - * 112 - * Returns zero on success, else an error. 113 - */ 114 - int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio) 115 - { 116 - struct mmc_gpio *ctx = host->slot.handler_priv; 117 - int ret; 118 - 119 - if (!gpio_is_valid(gpio)) 120 - return -EINVAL; 121 - 122 - ret = devm_gpio_request_one(host->parent, gpio, GPIOF_DIR_IN, 123 - ctx->ro_label); 124 - if (ret < 0) 125 - return ret; 126 - 127 - ctx->override_ro_active_level = true; 128 - ctx->ro_gpio = gpio_to_desc(gpio); 129 - 130 - return 0; 131 - } 132 - EXPORT_SYMBOL(mmc_gpio_request_ro); 133 100 134 101 void mmc_gpiod_request_cd_irq(struct mmc_host *host) 135 102 { ··· 170 197 EXPORT_SYMBOL(mmc_gpio_set_cd_isr); 171 198 172 199 /** 173 - * mmc_gpio_request_cd - request a gpio for card-detection 174 - * @host: mmc host 175 - * @gpio: gpio number requested 176 - * @debounce: debounce time in microseconds 177 - * 178 - * As devm_* managed functions are used in mmc_gpio_request_cd(), client 179 - * drivers do not need to worry about freeing up memory. 180 - * 181 - * If GPIO debouncing is desired, set the debounce parameter to a non-zero 182 - * value. The caller is responsible for ensuring that the GPIO driver associated 183 - * with the GPIO supports debouncing, otherwise an error will be returned. 184 - * 185 - * Returns zero on success, else an error. 186 - */ 187 - int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio, 188 - unsigned int debounce) 189 - { 190 - struct mmc_gpio *ctx = host->slot.handler_priv; 191 - int ret; 192 - 193 - ret = devm_gpio_request_one(host->parent, gpio, GPIOF_DIR_IN, 194 - ctx->cd_label); 195 - if (ret < 0) 196 - /* 197 - * don't bother freeing memory. It might still get used by other 198 - * slot functions, in any case it will be freed, when the device 199 - * is destroyed. 200 - */ 201 - return ret; 202 - 203 - if (debounce) { 204 - ret = gpio_set_debounce(gpio, debounce); 205 - if (ret < 0) 206 - return ret; 207 - } 208 - 209 - ctx->override_cd_active_level = true; 210 - ctx->cd_gpio = gpio_to_desc(gpio); 211 - 212 - return 0; 213 - } 214 - EXPORT_SYMBOL(mmc_gpio_request_cd); 215 - 216 - /** 217 200 * mmc_gpiod_request_cd - request a gpio descriptor for card-detection 218 201 * @host: mmc host 219 202 * @con_id: function within the GPIO consumer ··· 179 250 * @gpio_invert: will return whether the GPIO line is inverted or not, set 180 251 * to NULL to ignore 181 252 * 182 - * Use this function in place of mmc_gpio_request_cd() to use the GPIO 183 - * descriptor API. Note that it must be called prior to mmc_add_host() 253 + * Note that this must be called prior to mmc_add_host() 184 254 * otherwise the caller must also call mmc_gpiod_request_cd_irq(). 185 255 * 186 256 * Returns zero on success, else an error. ··· 229 301 * @debounce: debounce time in microseconds 230 302 * @gpio_invert: will return whether the GPIO line is inverted or not, 231 303 * set to NULL to ignore 232 - * 233 - * Use this function in place of mmc_gpio_request_ro() to use the GPIO 234 - * descriptor API. 235 304 * 236 305 * Returns zero on success, else an error. 237 306 */
+25 -3
drivers/mmc/host/Kconfig
··· 441 441 442 442 If unsure, say N. 443 443 444 + config MMC_ALCOR 445 + tristate "Alcor Micro/Alcor Link SD/MMC controller" 446 + depends on MISC_ALCOR_PCI 447 + help 448 + Say Y here to include driver code to support SD/MMC card interface 449 + of Alcor Micro PCI-E card reader 450 + 444 451 config MMC_AU1X 445 452 tristate "Alchemy AU1XX0 MMC Card Interface support" 446 453 depends on MIPS_ALCHEMY ··· 653 646 654 647 config MMC_SDHI_INTERNAL_DMAC 655 648 tristate "DMA for SDHI SD/SDIO controllers using on-chip bus mastering" 656 - depends on ARM64 || ARCH_R8A77470 || COMPILE_TEST 649 + depends on ARM64 || ARCH_R7S9210 || ARCH_R8A77470 || COMPILE_TEST 657 650 depends on MMC_SDHI 658 - default MMC_SDHI if (ARM64 || ARCH_R8A77470) 651 + default MMC_SDHI if (ARM64 || ARCH_R7S9210 || ARCH_R8A77470) 659 652 help 660 653 This provides DMA support for SDHI SD/SDIO controllers 661 654 using on-chip bus mastering. This supports the controllers 662 - found in arm64 based SoCs. 655 + found in arm64 based SoCs. This controller is also found in 656 + some RZ family SoCs. 663 657 664 658 config MMC_UNIPHIER 665 659 tristate "UniPhier SD/eMMC Host Controller support" ··· 977 969 config MMC_SDHCI_OMAP 978 970 tristate "TI SDHCI Controller Support" 979 971 depends on MMC_SDHCI_PLTFM && OF 972 + select THERMAL 973 + select TI_SOC_THERMAL 980 974 help 981 975 This selects the Secure Digital Host Controller Interface (SDHCI) 982 976 support present in TI's DRA7 SOCs. The controller supports 977 + SD/MMC/SDIO devices. 978 + 979 + If you have a controller with this interface, say Y or M here. 980 + 981 + If unsure, say N. 982 + 983 + config MMC_SDHCI_AM654 984 + tristate "Support for the SDHCI Controller in TI's AM654 SOCs" 985 + depends on MMC_SDHCI_PLTFM && OF 986 + help 987 + This selects the Secure Digital Host Controller Interface (SDHCI) 988 + support present in TI's AM654 SOCs. The controller supports 983 989 SD/MMC/SDIO devices. 984 990 985 991 If you have a controller with this interface, say Y or M here.
+2
drivers/mmc/host/Makefile
··· 22 22 obj-$(CONFIG_MMC_SDHCI_SIRF) += sdhci-sirf.o 23 23 obj-$(CONFIG_MMC_SDHCI_F_SDH30) += sdhci_f_sdh30.o 24 24 obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o 25 + obj-$(CONFIG_MMC_SDHCI_AM654) += sdhci_am654.o 25 26 obj-$(CONFIG_MMC_WBSD) += wbsd.o 26 27 obj-$(CONFIG_MMC_AU1X) += au1xmmc.o 28 + obj-$(CONFIG_MMC_ALCOR) += alcor.o 27 29 obj-$(CONFIG_MMC_MTK) += mtk-sd.o 28 30 obj-$(CONFIG_MMC_OMAP) += omap.o 29 31 obj-$(CONFIG_MMC_OMAP_HS) += omap_hsmmc.o
+1162
drivers/mmc/host/alcor.c
··· 1 + // SPDX-License-Identifier: GPL-2.0+ 2 + /* 3 + * Copyright (C) 2018 Oleksij Rempel <linux@rempel-privat.de> 4 + * 5 + * Driver for Alcor Micro AU6601 and AU6621 controllers 6 + */ 7 + 8 + /* Note: this driver was created without any documentation. Based 9 + * on sniffing, testing and in some cases mimic of original driver. 10 + * As soon as some one with documentation or more experience in SD/MMC, or 11 + * reverse engineering then me, please review this driver and question every 12 + * thing what I did. 2018 Oleksij Rempel <linux@rempel-privat.de> 13 + */ 14 + 15 + #include <linux/delay.h> 16 + #include <linux/pci.h> 17 + #include <linux/module.h> 18 + #include <linux/io.h> 19 + #include <linux/pm.h> 20 + #include <linux/irq.h> 21 + #include <linux/interrupt.h> 22 + #include <linux/platform_device.h> 23 + 24 + #include <linux/mmc/host.h> 25 + #include <linux/mmc/mmc.h> 26 + 27 + #include <linux/alcor_pci.h> 28 + 29 + enum alcor_cookie { 30 + COOKIE_UNMAPPED, 31 + COOKIE_PRE_MAPPED, 32 + COOKIE_MAPPED, 33 + }; 34 + 35 + struct alcor_pll_conf { 36 + unsigned int clk_src_freq; 37 + unsigned int clk_src_reg; 38 + unsigned int min_div; 39 + unsigned int max_div; 40 + }; 41 + 42 + struct alcor_sdmmc_host { 43 + struct device *dev; 44 + struct alcor_pci_priv *alcor_pci; 45 + 46 + struct mmc_host *mmc; 47 + struct mmc_request *mrq; 48 + struct mmc_command *cmd; 49 + struct mmc_data *data; 50 + unsigned int dma_on:1; 51 + unsigned int early_data:1; 52 + 53 + struct mutex cmd_mutex; 54 + 55 + struct delayed_work timeout_work; 56 + 57 + struct sg_mapping_iter sg_miter; /* SG state for PIO */ 58 + struct scatterlist *sg; 59 + unsigned int blocks; /* remaining PIO blocks */ 60 + int sg_count; 61 + 62 + u32 irq_status_sd; 63 + unsigned char cur_power_mode; 64 + }; 65 + 66 + static const struct alcor_pll_conf alcor_pll_cfg[] = { 67 + /* MHZ, CLK src, max div, min div */ 68 + { 31250000, AU6601_CLK_31_25_MHZ, 1, 511}, 69 + { 48000000, AU6601_CLK_48_MHZ, 1, 511}, 70 + {125000000, AU6601_CLK_125_MHZ, 1, 511}, 71 + {384000000, AU6601_CLK_384_MHZ, 1, 511}, 72 + }; 73 + 74 + static inline void alcor_rmw8(struct alcor_sdmmc_host *host, unsigned int addr, 75 + u8 clear, u8 set) 76 + { 77 + struct alcor_pci_priv *priv = host->alcor_pci; 78 + u32 var; 79 + 80 + var = alcor_read8(priv, addr); 81 + var &= ~clear; 82 + var |= set; 83 + alcor_write8(priv, var, addr); 84 + } 85 + 86 + /* As soon as irqs are masked, some status updates may be missed. 87 + * Use this with care. 88 + */ 89 + static inline void alcor_mask_sd_irqs(struct alcor_sdmmc_host *host) 90 + { 91 + struct alcor_pci_priv *priv = host->alcor_pci; 92 + 93 + alcor_write32(priv, 0, AU6601_REG_INT_ENABLE); 94 + } 95 + 96 + static inline void alcor_unmask_sd_irqs(struct alcor_sdmmc_host *host) 97 + { 98 + struct alcor_pci_priv *priv = host->alcor_pci; 99 + 100 + alcor_write32(priv, AU6601_INT_CMD_MASK | AU6601_INT_DATA_MASK | 101 + AU6601_INT_CARD_INSERT | AU6601_INT_CARD_REMOVE | 102 + AU6601_INT_OVER_CURRENT_ERR, 103 + AU6601_REG_INT_ENABLE); 104 + } 105 + 106 + static void alcor_reset(struct alcor_sdmmc_host *host, u8 val) 107 + { 108 + struct alcor_pci_priv *priv = host->alcor_pci; 109 + int i; 110 + 111 + alcor_write8(priv, val | AU6601_BUF_CTRL_RESET, 112 + AU6601_REG_SW_RESET); 113 + for (i = 0; i < 100; i++) { 114 + if (!(alcor_read8(priv, AU6601_REG_SW_RESET) & val)) 115 + return; 116 + udelay(50); 117 + } 118 + dev_err(host->dev, "%s: timeout\n", __func__); 119 + } 120 + 121 + static void alcor_data_set_dma(struct alcor_sdmmc_host *host) 122 + { 123 + struct alcor_pci_priv *priv = host->alcor_pci; 124 + u32 addr; 125 + 126 + if (!host->sg_count) 127 + return; 128 + 129 + if (!host->sg) { 130 + dev_err(host->dev, "have blocks, but no SG\n"); 131 + return; 132 + } 133 + 134 + if (!sg_dma_len(host->sg)) { 135 + dev_err(host->dev, "DMA SG len == 0\n"); 136 + return; 137 + } 138 + 139 + 140 + addr = (u32)sg_dma_address(host->sg); 141 + 142 + alcor_write32(priv, addr, AU6601_REG_SDMA_ADDR); 143 + host->sg = sg_next(host->sg); 144 + host->sg_count--; 145 + } 146 + 147 + static void alcor_trigger_data_transfer(struct alcor_sdmmc_host *host, 148 + bool early) 149 + { 150 + struct alcor_pci_priv *priv = host->alcor_pci; 151 + struct mmc_data *data = host->data; 152 + u8 ctrl = 0; 153 + 154 + if (data->flags & MMC_DATA_WRITE) 155 + ctrl |= AU6601_DATA_WRITE; 156 + 157 + if (data->host_cookie == COOKIE_MAPPED) { 158 + if (host->early_data) { 159 + host->early_data = false; 160 + return; 161 + } 162 + 163 + host->early_data = early; 164 + 165 + alcor_data_set_dma(host); 166 + ctrl |= AU6601_DATA_DMA_MODE; 167 + host->dma_on = 1; 168 + alcor_write32(priv, data->sg_count * 0x1000, 169 + AU6601_REG_BLOCK_SIZE); 170 + } else { 171 + alcor_write32(priv, data->blksz, AU6601_REG_BLOCK_SIZE); 172 + } 173 + 174 + alcor_write8(priv, ctrl | AU6601_DATA_START_XFER, 175 + AU6601_DATA_XFER_CTRL); 176 + } 177 + 178 + static void alcor_trf_block_pio(struct alcor_sdmmc_host *host, bool read) 179 + { 180 + struct alcor_pci_priv *priv = host->alcor_pci; 181 + size_t blksize, len; 182 + u8 *buf; 183 + 184 + if (!host->blocks) 185 + return; 186 + 187 + if (host->dma_on) { 188 + dev_err(host->dev, "configured DMA but got PIO request.\n"); 189 + return; 190 + } 191 + 192 + if (!!(host->data->flags & MMC_DATA_READ) != read) { 193 + dev_err(host->dev, "got unexpected direction %i != %i\n", 194 + !!(host->data->flags & MMC_DATA_READ), read); 195 + } 196 + 197 + if (!sg_miter_next(&host->sg_miter)) 198 + return; 199 + 200 + blksize = host->data->blksz; 201 + len = min(host->sg_miter.length, blksize); 202 + 203 + dev_dbg(host->dev, "PIO, %s block size: 0x%zx\n", 204 + read ? "read" : "write", blksize); 205 + 206 + host->sg_miter.consumed = len; 207 + host->blocks--; 208 + 209 + buf = host->sg_miter.addr; 210 + 211 + if (read) 212 + ioread32_rep(priv->iobase + AU6601_REG_BUFFER, buf, len >> 2); 213 + else 214 + iowrite32_rep(priv->iobase + AU6601_REG_BUFFER, buf, len >> 2); 215 + 216 + sg_miter_stop(&host->sg_miter); 217 + } 218 + 219 + static void alcor_prepare_sg_miter(struct alcor_sdmmc_host *host) 220 + { 221 + unsigned int flags = SG_MITER_ATOMIC; 222 + struct mmc_data *data = host->data; 223 + 224 + if (data->flags & MMC_DATA_READ) 225 + flags |= SG_MITER_TO_SG; 226 + else 227 + flags |= SG_MITER_FROM_SG; 228 + sg_miter_start(&host->sg_miter, data->sg, data->sg_len, flags); 229 + } 230 + 231 + static void alcor_prepare_data(struct alcor_sdmmc_host *host, 232 + struct mmc_command *cmd) 233 + { 234 + struct mmc_data *data = cmd->data; 235 + 236 + if (!data) 237 + return; 238 + 239 + 240 + host->data = data; 241 + host->data->bytes_xfered = 0; 242 + host->blocks = data->blocks; 243 + host->sg = data->sg; 244 + host->sg_count = data->sg_count; 245 + dev_dbg(host->dev, "prepare DATA: sg %i, blocks: %i\n", 246 + host->sg_count, host->blocks); 247 + 248 + if (data->host_cookie != COOKIE_MAPPED) 249 + alcor_prepare_sg_miter(host); 250 + 251 + alcor_trigger_data_transfer(host, true); 252 + } 253 + 254 + static void alcor_send_cmd(struct alcor_sdmmc_host *host, 255 + struct mmc_command *cmd, bool set_timeout) 256 + { 257 + struct alcor_pci_priv *priv = host->alcor_pci; 258 + unsigned long timeout = 0; 259 + u8 ctrl = 0; 260 + 261 + host->cmd = cmd; 262 + alcor_prepare_data(host, cmd); 263 + 264 + dev_dbg(host->dev, "send CMD. opcode: 0x%02x, arg; 0x%08x\n", 265 + cmd->opcode, cmd->arg); 266 + alcor_write8(priv, cmd->opcode | 0x40, AU6601_REG_CMD_OPCODE); 267 + alcor_write32be(priv, cmd->arg, AU6601_REG_CMD_ARG); 268 + 269 + switch (mmc_resp_type(cmd)) { 270 + case MMC_RSP_NONE: 271 + ctrl = AU6601_CMD_NO_RESP; 272 + break; 273 + case MMC_RSP_R1: 274 + ctrl = AU6601_CMD_6_BYTE_CRC; 275 + break; 276 + case MMC_RSP_R1B: 277 + ctrl = AU6601_CMD_6_BYTE_CRC | AU6601_CMD_STOP_WAIT_RDY; 278 + break; 279 + case MMC_RSP_R2: 280 + ctrl = AU6601_CMD_17_BYTE_CRC; 281 + break; 282 + case MMC_RSP_R3: 283 + ctrl = AU6601_CMD_6_BYTE_WO_CRC; 284 + break; 285 + default: 286 + dev_err(host->dev, "%s: cmd->flag (0x%02x) is not valid\n", 287 + mmc_hostname(host->mmc), mmc_resp_type(cmd)); 288 + break; 289 + } 290 + 291 + if (set_timeout) { 292 + if (!cmd->data && cmd->busy_timeout) 293 + timeout = cmd->busy_timeout; 294 + else 295 + timeout = 10000; 296 + 297 + schedule_delayed_work(&host->timeout_work, 298 + msecs_to_jiffies(timeout)); 299 + } 300 + 301 + dev_dbg(host->dev, "xfer ctrl: 0x%02x; timeout: %lu\n", ctrl, timeout); 302 + alcor_write8(priv, ctrl | AU6601_CMD_START_XFER, 303 + AU6601_CMD_XFER_CTRL); 304 + } 305 + 306 + static void alcor_request_complete(struct alcor_sdmmc_host *host, 307 + bool cancel_timeout) 308 + { 309 + struct mmc_request *mrq; 310 + 311 + /* 312 + * If this work gets rescheduled while running, it will 313 + * be run again afterwards but without any active request. 314 + */ 315 + if (!host->mrq) 316 + return; 317 + 318 + if (cancel_timeout) 319 + cancel_delayed_work(&host->timeout_work); 320 + 321 + mrq = host->mrq; 322 + 323 + host->mrq = NULL; 324 + host->cmd = NULL; 325 + host->data = NULL; 326 + host->dma_on = 0; 327 + 328 + mmc_request_done(host->mmc, mrq); 329 + } 330 + 331 + static void alcor_finish_data(struct alcor_sdmmc_host *host) 332 + { 333 + struct mmc_data *data; 334 + 335 + data = host->data; 336 + host->data = NULL; 337 + host->dma_on = 0; 338 + 339 + /* 340 + * The specification states that the block count register must 341 + * be updated, but it does not specify at what point in the 342 + * data flow. That makes the register entirely useless to read 343 + * back so we have to assume that nothing made it to the card 344 + * in the event of an error. 345 + */ 346 + if (data->error) 347 + data->bytes_xfered = 0; 348 + else 349 + data->bytes_xfered = data->blksz * data->blocks; 350 + 351 + /* 352 + * Need to send CMD12 if - 353 + * a) open-ended multiblock transfer (no CMD23) 354 + * b) error in multiblock transfer 355 + */ 356 + if (data->stop && 357 + (data->error || 358 + !host->mrq->sbc)) { 359 + 360 + /* 361 + * The controller needs a reset of internal state machines 362 + * upon error conditions. 363 + */ 364 + if (data->error) 365 + alcor_reset(host, AU6601_RESET_CMD | AU6601_RESET_DATA); 366 + 367 + alcor_unmask_sd_irqs(host); 368 + alcor_send_cmd(host, data->stop, false); 369 + return; 370 + } 371 + 372 + alcor_request_complete(host, 1); 373 + } 374 + 375 + static void alcor_err_irq(struct alcor_sdmmc_host *host, u32 intmask) 376 + { 377 + dev_dbg(host->dev, "ERR IRQ %x\n", intmask); 378 + 379 + if (host->cmd) { 380 + if (intmask & AU6601_INT_CMD_TIMEOUT_ERR) 381 + host->cmd->error = -ETIMEDOUT; 382 + else 383 + host->cmd->error = -EILSEQ; 384 + } 385 + 386 + if (host->data) { 387 + if (intmask & AU6601_INT_DATA_TIMEOUT_ERR) 388 + host->data->error = -ETIMEDOUT; 389 + else 390 + host->data->error = -EILSEQ; 391 + 392 + host->data->bytes_xfered = 0; 393 + } 394 + 395 + alcor_reset(host, AU6601_RESET_CMD | AU6601_RESET_DATA); 396 + alcor_request_complete(host, 1); 397 + } 398 + 399 + static int alcor_cmd_irq_done(struct alcor_sdmmc_host *host, u32 intmask) 400 + { 401 + struct alcor_pci_priv *priv = host->alcor_pci; 402 + 403 + intmask &= AU6601_INT_CMD_END; 404 + 405 + if (!intmask) 406 + return true; 407 + 408 + /* got CMD_END but no CMD is in progress, wake thread an process the 409 + * error 410 + */ 411 + if (!host->cmd) 412 + return false; 413 + 414 + if (host->cmd->flags & MMC_RSP_PRESENT) { 415 + struct mmc_command *cmd = host->cmd; 416 + 417 + cmd->resp[0] = alcor_read32be(priv, AU6601_REG_CMD_RSP0); 418 + dev_dbg(host->dev, "RSP0: 0x%04x\n", cmd->resp[0]); 419 + if (host->cmd->flags & MMC_RSP_136) { 420 + cmd->resp[1] = 421 + alcor_read32be(priv, AU6601_REG_CMD_RSP1); 422 + cmd->resp[2] = 423 + alcor_read32be(priv, AU6601_REG_CMD_RSP2); 424 + cmd->resp[3] = 425 + alcor_read32be(priv, AU6601_REG_CMD_RSP3); 426 + dev_dbg(host->dev, "RSP1,2,3: 0x%04x 0x%04x 0x%04x\n", 427 + cmd->resp[1], cmd->resp[2], cmd->resp[3]); 428 + } 429 + 430 + } 431 + 432 + host->cmd->error = 0; 433 + 434 + /* Processed actual command. */ 435 + if (!host->data) 436 + return false; 437 + 438 + alcor_trigger_data_transfer(host, false); 439 + host->cmd = NULL; 440 + return true; 441 + } 442 + 443 + static void alcor_cmd_irq_thread(struct alcor_sdmmc_host *host, u32 intmask) 444 + { 445 + intmask &= AU6601_INT_CMD_END; 446 + 447 + if (!intmask) 448 + return; 449 + 450 + if (!host->cmd && intmask & AU6601_INT_CMD_END) { 451 + dev_dbg(host->dev, "Got command interrupt 0x%08x even though no command operation was in progress.\n", 452 + intmask); 453 + } 454 + 455 + /* Processed actual command. */ 456 + if (!host->data) 457 + alcor_request_complete(host, 1); 458 + else 459 + alcor_trigger_data_transfer(host, false); 460 + host->cmd = NULL; 461 + } 462 + 463 + static int alcor_data_irq_done(struct alcor_sdmmc_host *host, u32 intmask) 464 + { 465 + u32 tmp; 466 + 467 + intmask &= AU6601_INT_DATA_MASK; 468 + 469 + /* nothing here to do */ 470 + if (!intmask) 471 + return 1; 472 + 473 + /* we was too fast and got DATA_END after it was processed? 474 + * lets ignore it for now. 475 + */ 476 + if (!host->data && intmask == AU6601_INT_DATA_END) 477 + return 1; 478 + 479 + /* looks like an error, so lets handle it. */ 480 + if (!host->data) 481 + return 0; 482 + 483 + tmp = intmask & (AU6601_INT_READ_BUF_RDY | AU6601_INT_WRITE_BUF_RDY 484 + | AU6601_INT_DMA_END); 485 + switch (tmp) { 486 + case 0: 487 + break; 488 + case AU6601_INT_READ_BUF_RDY: 489 + alcor_trf_block_pio(host, true); 490 + if (!host->blocks) 491 + break; 492 + alcor_trigger_data_transfer(host, false); 493 + return 1; 494 + case AU6601_INT_WRITE_BUF_RDY: 495 + alcor_trf_block_pio(host, false); 496 + if (!host->blocks) 497 + break; 498 + alcor_trigger_data_transfer(host, false); 499 + return 1; 500 + case AU6601_INT_DMA_END: 501 + if (!host->sg_count) 502 + break; 503 + 504 + alcor_data_set_dma(host); 505 + break; 506 + default: 507 + dev_err(host->dev, "Got READ_BUF_RDY and WRITE_BUF_RDY at same time\n"); 508 + break; 509 + } 510 + 511 + if (intmask & AU6601_INT_DATA_END) 512 + return 0; 513 + 514 + return 1; 515 + } 516 + 517 + static void alcor_data_irq_thread(struct alcor_sdmmc_host *host, u32 intmask) 518 + { 519 + intmask &= AU6601_INT_DATA_MASK; 520 + 521 + if (!intmask) 522 + return; 523 + 524 + if (!host->data) { 525 + dev_dbg(host->dev, "Got data interrupt 0x%08x even though no data operation was in progress.\n", 526 + intmask); 527 + alcor_reset(host, AU6601_RESET_DATA); 528 + return; 529 + } 530 + 531 + if (alcor_data_irq_done(host, intmask)) 532 + return; 533 + 534 + if ((intmask & AU6601_INT_DATA_END) || !host->blocks || 535 + (host->dma_on && !host->sg_count)) 536 + alcor_finish_data(host); 537 + } 538 + 539 + static void alcor_cd_irq(struct alcor_sdmmc_host *host, u32 intmask) 540 + { 541 + dev_dbg(host->dev, "card %s\n", 542 + intmask & AU6601_INT_CARD_REMOVE ? "removed" : "inserted"); 543 + 544 + if (host->mrq) { 545 + dev_dbg(host->dev, "cancel all pending tasks.\n"); 546 + 547 + if (host->data) 548 + host->data->error = -ENOMEDIUM; 549 + 550 + if (host->cmd) 551 + host->cmd->error = -ENOMEDIUM; 552 + else 553 + host->mrq->cmd->error = -ENOMEDIUM; 554 + 555 + alcor_request_complete(host, 1); 556 + } 557 + 558 + mmc_detect_change(host->mmc, msecs_to_jiffies(1)); 559 + } 560 + 561 + static irqreturn_t alcor_irq_thread(int irq, void *d) 562 + { 563 + struct alcor_sdmmc_host *host = d; 564 + irqreturn_t ret = IRQ_HANDLED; 565 + u32 intmask, tmp; 566 + 567 + mutex_lock(&host->cmd_mutex); 568 + 569 + intmask = host->irq_status_sd; 570 + 571 + /* some thing bad */ 572 + if (unlikely(!intmask || AU6601_INT_ALL_MASK == intmask)) { 573 + dev_dbg(host->dev, "unexpected IRQ: 0x%04x\n", intmask); 574 + ret = IRQ_NONE; 575 + goto exit; 576 + } 577 + 578 + tmp = intmask & (AU6601_INT_CMD_MASK | AU6601_INT_DATA_MASK); 579 + if (tmp) { 580 + if (tmp & AU6601_INT_ERROR_MASK) 581 + alcor_err_irq(host, tmp); 582 + else { 583 + alcor_cmd_irq_thread(host, tmp); 584 + alcor_data_irq_thread(host, tmp); 585 + } 586 + intmask &= ~(AU6601_INT_CMD_MASK | AU6601_INT_DATA_MASK); 587 + } 588 + 589 + if (intmask & (AU6601_INT_CARD_INSERT | AU6601_INT_CARD_REMOVE)) { 590 + alcor_cd_irq(host, intmask); 591 + intmask &= ~(AU6601_INT_CARD_INSERT | AU6601_INT_CARD_REMOVE); 592 + } 593 + 594 + if (intmask & AU6601_INT_OVER_CURRENT_ERR) { 595 + dev_warn(host->dev, 596 + "warning: over current detected!\n"); 597 + intmask &= ~AU6601_INT_OVER_CURRENT_ERR; 598 + } 599 + 600 + if (intmask) 601 + dev_dbg(host->dev, "got not handled IRQ: 0x%04x\n", intmask); 602 + 603 + exit: 604 + mutex_unlock(&host->cmd_mutex); 605 + alcor_unmask_sd_irqs(host); 606 + return ret; 607 + } 608 + 609 + 610 + static irqreturn_t alcor_irq(int irq, void *d) 611 + { 612 + struct alcor_sdmmc_host *host = d; 613 + struct alcor_pci_priv *priv = host->alcor_pci; 614 + u32 status, tmp; 615 + irqreturn_t ret; 616 + int cmd_done, data_done; 617 + 618 + status = alcor_read32(priv, AU6601_REG_INT_STATUS); 619 + if (!status) 620 + return IRQ_NONE; 621 + 622 + alcor_write32(priv, status, AU6601_REG_INT_STATUS); 623 + 624 + tmp = status & (AU6601_INT_READ_BUF_RDY | AU6601_INT_WRITE_BUF_RDY 625 + | AU6601_INT_DATA_END | AU6601_INT_DMA_END 626 + | AU6601_INT_CMD_END); 627 + if (tmp == status) { 628 + cmd_done = alcor_cmd_irq_done(host, tmp); 629 + data_done = alcor_data_irq_done(host, tmp); 630 + /* use fast path for simple tasks */ 631 + if (cmd_done && data_done) { 632 + ret = IRQ_HANDLED; 633 + goto alcor_irq_done; 634 + } 635 + } 636 + 637 + host->irq_status_sd = status; 638 + ret = IRQ_WAKE_THREAD; 639 + alcor_mask_sd_irqs(host); 640 + alcor_irq_done: 641 + return ret; 642 + } 643 + 644 + static void alcor_set_clock(struct alcor_sdmmc_host *host, unsigned int clock) 645 + { 646 + struct alcor_pci_priv *priv = host->alcor_pci; 647 + int i, diff = 0x7fffffff, tmp_clock = 0; 648 + u16 clk_src = 0; 649 + u8 clk_div = 0; 650 + 651 + if (clock == 0) { 652 + alcor_write16(priv, 0, AU6601_CLK_SELECT); 653 + return; 654 + } 655 + 656 + for (i = 0; i < ARRAY_SIZE(alcor_pll_cfg); i++) { 657 + unsigned int tmp_div, tmp_diff; 658 + const struct alcor_pll_conf *cfg = &alcor_pll_cfg[i]; 659 + 660 + tmp_div = DIV_ROUND_UP(cfg->clk_src_freq, clock); 661 + if (cfg->min_div > tmp_div || tmp_div > cfg->max_div) 662 + continue; 663 + 664 + tmp_clock = DIV_ROUND_UP(cfg->clk_src_freq, tmp_div); 665 + tmp_diff = abs(clock - tmp_clock); 666 + 667 + if (tmp_diff >= 0 && tmp_diff < diff) { 668 + diff = tmp_diff; 669 + clk_src = cfg->clk_src_reg; 670 + clk_div = tmp_div; 671 + } 672 + } 673 + 674 + clk_src |= ((clk_div - 1) << 8); 675 + clk_src |= AU6601_CLK_ENABLE; 676 + 677 + dev_dbg(host->dev, "set freq %d cal freq %d, use div %d, mod %x\n", 678 + clock, tmp_clock, clk_div, clk_src); 679 + 680 + alcor_write16(priv, clk_src, AU6601_CLK_SELECT); 681 + 682 + } 683 + 684 + static void alcor_set_timing(struct mmc_host *mmc, struct mmc_ios *ios) 685 + { 686 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 687 + 688 + if (ios->timing == MMC_TIMING_LEGACY) { 689 + alcor_rmw8(host, AU6601_CLK_DELAY, 690 + AU6601_CLK_POSITIVE_EDGE_ALL, 0); 691 + } else { 692 + alcor_rmw8(host, AU6601_CLK_DELAY, 693 + 0, AU6601_CLK_POSITIVE_EDGE_ALL); 694 + } 695 + } 696 + 697 + static void alcor_set_bus_width(struct mmc_host *mmc, struct mmc_ios *ios) 698 + { 699 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 700 + struct alcor_pci_priv *priv = host->alcor_pci; 701 + 702 + if (ios->bus_width == MMC_BUS_WIDTH_1) { 703 + alcor_write8(priv, 0, AU6601_REG_BUS_CTRL); 704 + } else if (ios->bus_width == MMC_BUS_WIDTH_4) { 705 + alcor_write8(priv, AU6601_BUS_WIDTH_4BIT, 706 + AU6601_REG_BUS_CTRL); 707 + } else 708 + dev_err(host->dev, "Unknown BUS mode\n"); 709 + 710 + } 711 + 712 + static int alcor_card_busy(struct mmc_host *mmc) 713 + { 714 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 715 + struct alcor_pci_priv *priv = host->alcor_pci; 716 + u8 status; 717 + 718 + /* Check whether dat[0:3] low */ 719 + status = alcor_read8(priv, AU6601_DATA_PIN_STATE); 720 + 721 + return !(status & AU6601_BUS_STAT_DAT_MASK); 722 + } 723 + 724 + static int alcor_get_cd(struct mmc_host *mmc) 725 + { 726 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 727 + struct alcor_pci_priv *priv = host->alcor_pci; 728 + u8 detect; 729 + 730 + detect = alcor_read8(priv, AU6601_DETECT_STATUS) 731 + & AU6601_DETECT_STATUS_M; 732 + /* check if card is present then send command and data */ 733 + return (detect == AU6601_SD_DETECTED); 734 + } 735 + 736 + static int alcor_get_ro(struct mmc_host *mmc) 737 + { 738 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 739 + struct alcor_pci_priv *priv = host->alcor_pci; 740 + u8 status; 741 + 742 + /* get write protect pin status */ 743 + status = alcor_read8(priv, AU6601_INTERFACE_MODE_CTRL); 744 + 745 + return !!(status & AU6601_SD_CARD_WP); 746 + } 747 + 748 + static void alcor_request(struct mmc_host *mmc, struct mmc_request *mrq) 749 + { 750 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 751 + 752 + mutex_lock(&host->cmd_mutex); 753 + 754 + host->mrq = mrq; 755 + 756 + /* check if card is present then send command and data */ 757 + if (alcor_get_cd(mmc)) 758 + alcor_send_cmd(host, mrq->cmd, true); 759 + else { 760 + mrq->cmd->error = -ENOMEDIUM; 761 + alcor_request_complete(host, 1); 762 + } 763 + 764 + mutex_unlock(&host->cmd_mutex); 765 + } 766 + 767 + static void alcor_pre_req(struct mmc_host *mmc, 768 + struct mmc_request *mrq) 769 + { 770 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 771 + struct mmc_data *data = mrq->data; 772 + struct mmc_command *cmd = mrq->cmd; 773 + struct scatterlist *sg; 774 + unsigned int i, sg_len; 775 + 776 + if (!data || !cmd) 777 + return; 778 + 779 + data->host_cookie = COOKIE_UNMAPPED; 780 + 781 + /* FIXME: looks like the DMA engine works only with CMD18 */ 782 + if (cmd->opcode != 18) 783 + return; 784 + /* 785 + * We don't do DMA on "complex" transfers, i.e. with 786 + * non-word-aligned buffers or lengths. Also, we don't bother 787 + * with all the DMA setup overhead for short transfers. 788 + */ 789 + if (data->blocks * data->blksz < AU6601_MAX_DMA_BLOCK_SIZE) 790 + return; 791 + 792 + if (data->blksz & 3) 793 + return; 794 + 795 + for_each_sg(data->sg, sg, data->sg_len, i) { 796 + if (sg->length != AU6601_MAX_DMA_BLOCK_SIZE) 797 + return; 798 + } 799 + 800 + /* This data might be unmapped at this time */ 801 + 802 + sg_len = dma_map_sg(host->dev, data->sg, data->sg_len, 803 + mmc_get_dma_dir(data)); 804 + if (sg_len) 805 + data->host_cookie = COOKIE_MAPPED; 806 + 807 + data->sg_count = sg_len; 808 + } 809 + 810 + static void alcor_post_req(struct mmc_host *mmc, 811 + struct mmc_request *mrq, 812 + int err) 813 + { 814 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 815 + struct mmc_data *data = mrq->data; 816 + 817 + if (!data) 818 + return; 819 + 820 + if (data->host_cookie == COOKIE_MAPPED) { 821 + dma_unmap_sg(host->dev, 822 + data->sg, 823 + data->sg_len, 824 + mmc_get_dma_dir(data)); 825 + } 826 + 827 + data->host_cookie = COOKIE_UNMAPPED; 828 + } 829 + 830 + static void alcor_set_power_mode(struct mmc_host *mmc, struct mmc_ios *ios) 831 + { 832 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 833 + struct alcor_pci_priv *priv = host->alcor_pci; 834 + 835 + switch (ios->power_mode) { 836 + case MMC_POWER_OFF: 837 + alcor_set_clock(host, ios->clock); 838 + /* set all pins to input */ 839 + alcor_write8(priv, 0, AU6601_OUTPUT_ENABLE); 840 + /* turn of VDD */ 841 + alcor_write8(priv, 0, AU6601_POWER_CONTROL); 842 + break; 843 + case MMC_POWER_UP: 844 + break; 845 + case MMC_POWER_ON: 846 + /* This is most trickiest part. The order and timings of 847 + * instructions seems to play important role. Any changes may 848 + * confuse internal state engine if this HW. 849 + * FIXME: If we will ever get access to documentation, then this 850 + * part should be reviewed again. 851 + */ 852 + 853 + /* enable SD card mode */ 854 + alcor_write8(priv, AU6601_SD_CARD, 855 + AU6601_ACTIVE_CTRL); 856 + /* set signal voltage to 3.3V */ 857 + alcor_write8(priv, 0, AU6601_OPT); 858 + /* no documentation about clk delay, for now just try to mimic 859 + * original driver. 860 + */ 861 + alcor_write8(priv, 0x20, AU6601_CLK_DELAY); 862 + /* set BUS width to 1 bit */ 863 + alcor_write8(priv, 0, AU6601_REG_BUS_CTRL); 864 + /* set CLK first time */ 865 + alcor_set_clock(host, ios->clock); 866 + /* power on VDD */ 867 + alcor_write8(priv, AU6601_SD_CARD, 868 + AU6601_POWER_CONTROL); 869 + /* wait until the CLK will get stable */ 870 + mdelay(20); 871 + /* set CLK again, mimic original driver. */ 872 + alcor_set_clock(host, ios->clock); 873 + 874 + /* enable output */ 875 + alcor_write8(priv, AU6601_SD_CARD, 876 + AU6601_OUTPUT_ENABLE); 877 + /* The clk will not work on au6621. We need to trigger data 878 + * transfer. 879 + */ 880 + alcor_write8(priv, AU6601_DATA_WRITE, 881 + AU6601_DATA_XFER_CTRL); 882 + /* configure timeout. Not clear what exactly it means. */ 883 + alcor_write8(priv, 0x7d, AU6601_TIME_OUT_CTRL); 884 + mdelay(100); 885 + break; 886 + default: 887 + dev_err(host->dev, "Unknown power parameter\n"); 888 + } 889 + } 890 + 891 + static void alcor_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 892 + { 893 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 894 + 895 + mutex_lock(&host->cmd_mutex); 896 + 897 + dev_dbg(host->dev, "set ios. bus width: %x, power mode: %x\n", 898 + ios->bus_width, ios->power_mode); 899 + 900 + if (ios->power_mode != host->cur_power_mode) { 901 + alcor_set_power_mode(mmc, ios); 902 + host->cur_power_mode = ios->power_mode; 903 + } else { 904 + alcor_set_timing(mmc, ios); 905 + alcor_set_bus_width(mmc, ios); 906 + alcor_set_clock(host, ios->clock); 907 + } 908 + 909 + mutex_unlock(&host->cmd_mutex); 910 + } 911 + 912 + static int alcor_signal_voltage_switch(struct mmc_host *mmc, 913 + struct mmc_ios *ios) 914 + { 915 + struct alcor_sdmmc_host *host = mmc_priv(mmc); 916 + 917 + mutex_lock(&host->cmd_mutex); 918 + 919 + switch (ios->signal_voltage) { 920 + case MMC_SIGNAL_VOLTAGE_330: 921 + alcor_rmw8(host, AU6601_OPT, AU6601_OPT_SD_18V, 0); 922 + break; 923 + case MMC_SIGNAL_VOLTAGE_180: 924 + alcor_rmw8(host, AU6601_OPT, 0, AU6601_OPT_SD_18V); 925 + break; 926 + default: 927 + /* No signal voltage switch required */ 928 + break; 929 + } 930 + 931 + mutex_unlock(&host->cmd_mutex); 932 + return 0; 933 + } 934 + 935 + static const struct mmc_host_ops alcor_sdc_ops = { 936 + .card_busy = alcor_card_busy, 937 + .get_cd = alcor_get_cd, 938 + .get_ro = alcor_get_ro, 939 + .post_req = alcor_post_req, 940 + .pre_req = alcor_pre_req, 941 + .request = alcor_request, 942 + .set_ios = alcor_set_ios, 943 + .start_signal_voltage_switch = alcor_signal_voltage_switch, 944 + }; 945 + 946 + static void alcor_timeout_timer(struct work_struct *work) 947 + { 948 + struct delayed_work *d = to_delayed_work(work); 949 + struct alcor_sdmmc_host *host = container_of(d, struct alcor_sdmmc_host, 950 + timeout_work); 951 + mutex_lock(&host->cmd_mutex); 952 + 953 + dev_dbg(host->dev, "triggered timeout\n"); 954 + if (host->mrq) { 955 + dev_err(host->dev, "Timeout waiting for hardware interrupt.\n"); 956 + 957 + if (host->data) { 958 + host->data->error = -ETIMEDOUT; 959 + } else { 960 + if (host->cmd) 961 + host->cmd->error = -ETIMEDOUT; 962 + else 963 + host->mrq->cmd->error = -ETIMEDOUT; 964 + } 965 + 966 + alcor_reset(host, AU6601_RESET_CMD | AU6601_RESET_DATA); 967 + alcor_request_complete(host, 0); 968 + } 969 + 970 + mmiowb(); 971 + mutex_unlock(&host->cmd_mutex); 972 + } 973 + 974 + static void alcor_hw_init(struct alcor_sdmmc_host *host) 975 + { 976 + struct alcor_pci_priv *priv = host->alcor_pci; 977 + struct alcor_dev_cfg *cfg = priv->cfg; 978 + 979 + /* FIXME: This part is a mimics HW init of original driver. 980 + * If we will ever get access to documentation, then this part 981 + * should be reviewed again. 982 + */ 983 + 984 + /* reset command state engine */ 985 + alcor_reset(host, AU6601_RESET_CMD); 986 + 987 + alcor_write8(priv, 0, AU6601_DMA_BOUNDARY); 988 + /* enable sd card mode */ 989 + alcor_write8(priv, AU6601_SD_CARD, AU6601_ACTIVE_CTRL); 990 + 991 + /* set BUS width to 1 bit */ 992 + alcor_write8(priv, 0, AU6601_REG_BUS_CTRL); 993 + 994 + /* reset data state engine */ 995 + alcor_reset(host, AU6601_RESET_DATA); 996 + /* Not sure if a voodoo with AU6601_DMA_BOUNDARY is really needed */ 997 + alcor_write8(priv, 0, AU6601_DMA_BOUNDARY); 998 + 999 + alcor_write8(priv, 0, AU6601_INTERFACE_MODE_CTRL); 1000 + /* not clear what we are doing here. */ 1001 + alcor_write8(priv, 0x44, AU6601_PAD_DRIVE0); 1002 + alcor_write8(priv, 0x44, AU6601_PAD_DRIVE1); 1003 + alcor_write8(priv, 0x00, AU6601_PAD_DRIVE2); 1004 + 1005 + /* for 6601 - dma_boundary; for 6621 - dma_page_cnt 1006 + * exact meaning of this register is not clear. 1007 + */ 1008 + alcor_write8(priv, cfg->dma, AU6601_DMA_BOUNDARY); 1009 + 1010 + /* make sure all pins are set to input and VDD is off */ 1011 + alcor_write8(priv, 0, AU6601_OUTPUT_ENABLE); 1012 + alcor_write8(priv, 0, AU6601_POWER_CONTROL); 1013 + 1014 + alcor_write8(priv, AU6601_DETECT_EN, AU6601_DETECT_STATUS); 1015 + /* now we should be safe to enable IRQs */ 1016 + alcor_unmask_sd_irqs(host); 1017 + } 1018 + 1019 + static void alcor_hw_uninit(struct alcor_sdmmc_host *host) 1020 + { 1021 + struct alcor_pci_priv *priv = host->alcor_pci; 1022 + 1023 + alcor_mask_sd_irqs(host); 1024 + alcor_reset(host, AU6601_RESET_CMD | AU6601_RESET_DATA); 1025 + 1026 + alcor_write8(priv, 0, AU6601_DETECT_STATUS); 1027 + 1028 + alcor_write8(priv, 0, AU6601_OUTPUT_ENABLE); 1029 + alcor_write8(priv, 0, AU6601_POWER_CONTROL); 1030 + 1031 + alcor_write8(priv, 0, AU6601_OPT); 1032 + } 1033 + 1034 + static void alcor_init_mmc(struct alcor_sdmmc_host *host) 1035 + { 1036 + struct mmc_host *mmc = host->mmc; 1037 + 1038 + mmc->f_min = AU6601_MIN_CLOCK; 1039 + mmc->f_max = AU6601_MAX_CLOCK; 1040 + mmc->ocr_avail = MMC_VDD_33_34; 1041 + mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED 1042 + | MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 1043 + | MMC_CAP_UHS_SDR104 | MMC_CAP_UHS_DDR50; 1044 + mmc->caps2 = MMC_CAP2_NO_SDIO; 1045 + mmc->ops = &alcor_sdc_ops; 1046 + 1047 + /* Hardware cannot do scatter lists */ 1048 + mmc->max_segs = AU6601_MAX_DMA_SEGMENTS; 1049 + mmc->max_seg_size = AU6601_MAX_DMA_BLOCK_SIZE; 1050 + 1051 + mmc->max_blk_size = mmc->max_seg_size; 1052 + mmc->max_blk_count = mmc->max_segs; 1053 + 1054 + mmc->max_req_size = mmc->max_seg_size * mmc->max_segs; 1055 + } 1056 + 1057 + static int alcor_pci_sdmmc_drv_probe(struct platform_device *pdev) 1058 + { 1059 + struct alcor_pci_priv *priv = pdev->dev.platform_data; 1060 + struct mmc_host *mmc; 1061 + struct alcor_sdmmc_host *host; 1062 + int ret; 1063 + 1064 + mmc = mmc_alloc_host(sizeof(*host), &pdev->dev); 1065 + if (!mmc) { 1066 + dev_err(&pdev->dev, "Can't allocate MMC\n"); 1067 + return -ENOMEM; 1068 + } 1069 + 1070 + host = mmc_priv(mmc); 1071 + host->mmc = mmc; 1072 + host->dev = &pdev->dev; 1073 + host->cur_power_mode = MMC_POWER_UNDEFINED; 1074 + host->alcor_pci = priv; 1075 + 1076 + /* make sure irqs are disabled */ 1077 + alcor_write32(priv, 0, AU6601_REG_INT_ENABLE); 1078 + alcor_write32(priv, 0, AU6601_MS_INT_ENABLE); 1079 + 1080 + ret = devm_request_threaded_irq(&pdev->dev, priv->irq, 1081 + alcor_irq, alcor_irq_thread, IRQF_SHARED, 1082 + DRV_NAME_ALCOR_PCI_SDMMC, host); 1083 + 1084 + if (ret) { 1085 + dev_err(&pdev->dev, "Failed to get irq for data line\n"); 1086 + return ret; 1087 + } 1088 + 1089 + mutex_init(&host->cmd_mutex); 1090 + INIT_DELAYED_WORK(&host->timeout_work, alcor_timeout_timer); 1091 + 1092 + alcor_init_mmc(host); 1093 + alcor_hw_init(host); 1094 + 1095 + dev_set_drvdata(&pdev->dev, host); 1096 + mmc_add_host(mmc); 1097 + return 0; 1098 + } 1099 + 1100 + static int alcor_pci_sdmmc_drv_remove(struct platform_device *pdev) 1101 + { 1102 + struct alcor_sdmmc_host *host = dev_get_drvdata(&pdev->dev); 1103 + 1104 + if (cancel_delayed_work_sync(&host->timeout_work)) 1105 + alcor_request_complete(host, 0); 1106 + 1107 + alcor_hw_uninit(host); 1108 + mmc_remove_host(host->mmc); 1109 + mmc_free_host(host->mmc); 1110 + 1111 + return 0; 1112 + } 1113 + 1114 + #ifdef CONFIG_PM_SLEEP 1115 + static int alcor_pci_sdmmc_suspend(struct device *dev) 1116 + { 1117 + struct alcor_sdmmc_host *host = dev_get_drvdata(dev); 1118 + 1119 + if (cancel_delayed_work_sync(&host->timeout_work)) 1120 + alcor_request_complete(host, 0); 1121 + 1122 + alcor_hw_uninit(host); 1123 + 1124 + return 0; 1125 + } 1126 + 1127 + static int alcor_pci_sdmmc_resume(struct device *dev) 1128 + { 1129 + struct alcor_sdmmc_host *host = dev_get_drvdata(dev); 1130 + 1131 + alcor_hw_init(host); 1132 + 1133 + return 0; 1134 + } 1135 + #endif /* CONFIG_PM_SLEEP */ 1136 + 1137 + static SIMPLE_DEV_PM_OPS(alcor_mmc_pm_ops, alcor_pci_sdmmc_suspend, 1138 + alcor_pci_sdmmc_resume); 1139 + 1140 + static const struct platform_device_id alcor_pci_sdmmc_ids[] = { 1141 + { 1142 + .name = DRV_NAME_ALCOR_PCI_SDMMC, 1143 + }, { 1144 + /* sentinel */ 1145 + } 1146 + }; 1147 + MODULE_DEVICE_TABLE(platform, alcor_pci_sdmmc_ids); 1148 + 1149 + static struct platform_driver alcor_pci_sdmmc_driver = { 1150 + .probe = alcor_pci_sdmmc_drv_probe, 1151 + .remove = alcor_pci_sdmmc_drv_remove, 1152 + .id_table = alcor_pci_sdmmc_ids, 1153 + .driver = { 1154 + .name = DRV_NAME_ALCOR_PCI_SDMMC, 1155 + .pm = &alcor_mmc_pm_ops 1156 + }, 1157 + }; 1158 + module_platform_driver(alcor_pci_sdmmc_driver); 1159 + 1160 + MODULE_AUTHOR("Oleksij Rempel <linux@rempel-privat.de>"); 1161 + MODULE_DESCRIPTION("PCI driver for Alcor Micro AU6601 Secure Digital Host Controller Interface"); 1162 + MODULE_LICENSE("GPL");
+7 -27
drivers/mmc/host/atmel-mci.c
··· 446 446 return 0; 447 447 } 448 448 449 - static int atmci_req_open(struct inode *inode, struct file *file) 450 - { 451 - return single_open(file, atmci_req_show, inode->i_private); 452 - } 453 - 454 - static const struct file_operations atmci_req_fops = { 455 - .owner = THIS_MODULE, 456 - .open = atmci_req_open, 457 - .read = seq_read, 458 - .llseek = seq_lseek, 459 - .release = single_release, 460 - }; 449 + DEFINE_SHOW_ATTRIBUTE(atmci_req); 461 450 462 451 static void atmci_show_status_reg(struct seq_file *s, 463 452 const char *regname, u32 value) ··· 572 583 return ret; 573 584 } 574 585 575 - static int atmci_regs_open(struct inode *inode, struct file *file) 576 - { 577 - return single_open(file, atmci_regs_show, inode->i_private); 578 - } 579 - 580 - static const struct file_operations atmci_regs_fops = { 581 - .owner = THIS_MODULE, 582 - .open = atmci_regs_open, 583 - .read = seq_read, 584 - .llseek = seq_lseek, 585 - .release = single_release, 586 - }; 586 + DEFINE_SHOW_ATTRIBUTE(atmci_regs); 587 587 588 588 static void atmci_init_debugfs(struct atmel_mci_slot *slot) 589 589 { ··· 586 608 return; 587 609 588 610 node = debugfs_create_file("regs", S_IRUSR, root, host, 589 - &atmci_regs_fops); 611 + &atmci_regs_fops); 590 612 if (IS_ERR(node)) 591 613 return; 592 614 if (!node) 593 615 goto err; 594 616 595 - node = debugfs_create_file("req", S_IRUSR, root, slot, &atmci_req_fops); 617 + node = debugfs_create_file("req", S_IRUSR, root, slot, 618 + &atmci_req_fops); 596 619 if (!node) 597 620 goto err; 598 621 ··· 1933 1954 } 1934 1955 1935 1956 atmci_request_end(host, host->mrq); 1936 - state = STATE_IDLE; 1957 + goto unlock; /* atmci_request_end() sets host->state */ 1937 1958 break; 1938 1959 } 1939 1960 } while (state != prev_state); 1940 1961 1941 1962 host->state = state; 1942 1963 1964 + unlock: 1943 1965 spin_unlock(&host->lock); 1944 1966 } 1945 1967
+39 -32
drivers/mmc/host/bcm2835.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 1 2 /* 2 3 * bcm2835 sdhost driver. 3 4 * ··· 26 25 * sdhci-bcm2708.c by Broadcom 27 26 * sdhci-bcm2835.c by Stephen Warren and Oleksandr Tymoshenko 28 27 * sdhci.c and sdhci-pci.c by Pierre Ossman 29 - * 30 - * This program is free software; you can redistribute it and/or modify it 31 - * under the terms and conditions of the GNU General Public License, 32 - * version 2, as published by the Free Software Foundation. 33 - * 34 - * This program is distributed in the hope it will be useful, but WITHOUT 35 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 36 - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 37 - * more details. 38 - * 39 - * You should have received a copy of the GNU General Public License 40 - * along with this program. If not, see <http://www.gnu.org/licenses/>. 41 28 */ 42 29 #include <linux/clk.h> 43 30 #include <linux/delay.h> ··· 275 286 276 287 if (host->dma_chan) 277 288 dmaengine_terminate_sync(host->dma_chan); 289 + host->dma_chan = NULL; 278 290 bcm2835_reset_internal(host); 279 291 } 280 292 ··· 453 463 static 454 464 void bcm2835_prepare_dma(struct bcm2835_host *host, struct mmc_data *data) 455 465 { 456 - int len, dir_data, dir_slave; 466 + int sg_len, dir_data, dir_slave; 457 467 struct dma_async_tx_descriptor *desc = NULL; 458 468 struct dma_chan *dma_chan; 459 469 ··· 499 509 &host->dma_cfg_rx : 500 510 &host->dma_cfg_tx); 501 511 502 - len = dma_map_sg(dma_chan->device->dev, data->sg, data->sg_len, 503 - dir_data); 512 + sg_len = dma_map_sg(dma_chan->device->dev, data->sg, data->sg_len, 513 + dir_data); 514 + if (!sg_len) 515 + return; 504 516 505 - if (len > 0) { 506 - desc = dmaengine_prep_slave_sg(dma_chan, data->sg, 507 - len, dir_slave, 508 - DMA_PREP_INTERRUPT | 509 - DMA_CTRL_ACK); 517 + desc = dmaengine_prep_slave_sg(dma_chan, data->sg, sg_len, dir_slave, 518 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 519 + 520 + if (!desc) { 521 + dma_unmap_sg(dma_chan->device->dev, data->sg, sg_len, dir_data); 522 + return; 510 523 } 511 524 512 - if (desc) { 513 - desc->callback = bcm2835_dma_complete; 514 - desc->callback_param = host; 515 - host->dma_desc = desc; 516 - host->dma_chan = dma_chan; 517 - host->dma_dir = dir_data; 518 - } 525 + desc->callback = bcm2835_dma_complete; 526 + desc->callback_param = host; 527 + host->dma_desc = desc; 528 + host->dma_chan = dma_chan; 529 + host->dma_dir = dir_data; 519 530 } 520 531 521 532 static void bcm2835_start_dma(struct bcm2835_host *host) ··· 598 607 struct dma_chan *terminate_chan = NULL; 599 608 struct mmc_request *mrq; 600 609 601 - cancel_delayed_work(&host->timeout_work); 610 + cancel_delayed_work_sync(&host->timeout_work); 602 611 603 612 mrq = host->mrq; 604 613 ··· 763 772 764 773 if (!(sdhsts & SDHSTS_CRC7_ERROR) || 765 774 (host->cmd->opcode != MMC_SEND_OP_COND)) { 775 + u32 edm, fsm; 776 + 766 777 if (sdhsts & SDHSTS_CMD_TIME_OUT) { 767 778 host->cmd->error = -ETIMEDOUT; 768 779 } else { ··· 773 780 bcm2835_dumpregs(host); 774 781 host->cmd->error = -EILSEQ; 775 782 } 783 + edm = readl(host->ioaddr + SDEDM); 784 + fsm = edm & SDEDM_FSM_MASK; 785 + if (fsm == SDEDM_FSM_READWAIT || 786 + fsm == SDEDM_FSM_WRITESTART1) 787 + /* Kick the FSM out of its wait */ 788 + writel(edm | SDEDM_FORCE_DATA_MODE, 789 + host->ioaddr + SDEDM); 776 790 bcm2835_finish_request(host); 777 791 return; 778 792 } ··· 836 836 if (host->mrq) { 837 837 dev_err(dev, "timeout waiting for hardware interrupt.\n"); 838 838 bcm2835_dumpregs(host); 839 + 840 + bcm2835_reset(host->mmc); 839 841 840 842 if (host->data) { 841 843 host->data->error = -ETIMEDOUT; ··· 1054 1052 { 1055 1053 struct bcm2835_host *host = 1056 1054 container_of(work, struct bcm2835_host, dma_work); 1057 - struct mmc_data *data = host->data; 1055 + struct mmc_data *data; 1058 1056 1059 1057 mutex_lock(&host->mutex); 1058 + 1059 + data = host->data; 1060 1060 1061 1061 if (host->dma_chan) { 1062 1062 dma_unmap_sg(host->dma_chan->device->dev, ··· 1184 1180 return; 1185 1181 } 1186 1182 1187 - if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD)) 1188 - bcm2835_prepare_dma(host, mrq->data); 1189 - 1190 1183 mutex_lock(&host->mutex); 1191 1184 1192 1185 WARN_ON(host->mrq); ··· 1206 1205 mutex_unlock(&host->mutex); 1207 1206 return; 1208 1207 } 1208 + 1209 + if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD)) 1210 + bcm2835_prepare_dma(host, mrq->data); 1209 1211 1210 1212 host->use_sbc = !!mrq->sbc && host->mrq->data && 1211 1213 (host->mrq->data->flags & MMC_DATA_READ); ··· 1448 1444 1449 1445 cancel_work_sync(&host->dma_work); 1450 1446 cancel_delayed_work_sync(&host->timeout_work); 1447 + 1448 + if (host->dma_chan_rxtx) 1449 + dma_release_channel(host->dma_chan_rxtx); 1451 1450 1452 1451 mmc_free_host(host->mmc); 1453 1452 platform_set_drvdata(pdev, NULL);
+1 -10
drivers/mmc/host/dw_mmc-bluefield.c
··· 52 52 53 53 static int dw_mci_bluefield_probe(struct platform_device *pdev) 54 54 { 55 - const struct dw_mci_drv_data *drv_data = NULL; 56 - const struct of_device_id *match; 57 - 58 - if (pdev->dev.of_node) { 59 - match = of_match_node(dw_mci_bluefield_match, 60 - pdev->dev.of_node); 61 - drv_data = match->data; 62 - } 63 - 64 - return dw_mci_pltfm_register(pdev, drv_data); 55 + return dw_mci_pltfm_register(pdev, &bluefield_drv_data); 65 56 } 66 57 67 58 static struct platform_driver dw_mci_bluefield_pltfm_driver = {
+78 -124
drivers/mmc/host/jz4740_mmc.c
··· 21 21 #include <linux/dmaengine.h> 22 22 #include <linux/dma-mapping.h> 23 23 #include <linux/err.h> 24 - #include <linux/gpio.h> 24 + #include <linux/gpio/consumer.h> 25 25 #include <linux/interrupt.h> 26 26 #include <linux/io.h> 27 27 #include <linux/irq.h> ··· 126 126 JZ4740_MMC_STATE_DONE, 127 127 }; 128 128 129 - struct jz4740_mmc_host_next { 130 - int sg_len; 131 - s32 cookie; 129 + /* 130 + * The MMC core allows to prepare a mmc_request while another mmc_request 131 + * is in-flight. This is used via the pre_req/post_req hooks. 132 + * This driver uses the pre_req/post_req hooks to map/unmap the mmc_request. 133 + * Following what other drivers do (sdhci, dw_mmc) we use the following cookie 134 + * flags to keep track of the mmc_request mapping state. 135 + * 136 + * COOKIE_UNMAPPED: the request is not mapped. 137 + * COOKIE_PREMAPPED: the request was mapped in pre_req, 138 + * and should be unmapped in post_req. 139 + * COOKIE_MAPPED: the request was mapped in the irq handler, 140 + * and should be unmapped before mmc_request_done is called.. 141 + */ 142 + enum jz4780_cookie { 143 + COOKIE_UNMAPPED = 0, 144 + COOKIE_PREMAPPED, 145 + COOKIE_MAPPED, 132 146 }; 133 147 134 148 struct jz4740_mmc_host { ··· 150 136 struct platform_device *pdev; 151 137 struct jz4740_mmc_platform_data *pdata; 152 138 struct clk *clk; 139 + struct gpio_desc *power; 153 140 154 141 enum jz4740_mmc_version version; 155 142 ··· 177 162 /* DMA support */ 178 163 struct dma_chan *dma_rx; 179 164 struct dma_chan *dma_tx; 180 - struct jz4740_mmc_host_next next_data; 181 165 bool use_dma; 182 - int sg_len; 183 166 184 167 /* The DMA trigger level is 8 words, that is to say, the DMA read 185 168 * trigger is when data words in MSC_RXFIFO is >= 8 and the DMA write ··· 239 226 return PTR_ERR(host->dma_rx); 240 227 } 241 228 242 - /* Initialize DMA pre request cookie */ 243 - host->next_data.cookie = 1; 244 - 245 229 return 0; 246 230 } 247 231 ··· 255 245 enum dma_data_direction dir = mmc_get_dma_dir(data); 256 246 257 247 dma_unmap_sg(chan->device->dev, data->sg, data->sg_len, dir); 248 + data->host_cookie = COOKIE_UNMAPPED; 258 249 } 259 250 260 - /* Prepares DMA data for current/next transfer, returns non-zero on failure */ 251 + /* Prepares DMA data for current or next transfer. 252 + * A request can be in-flight when this is called. 253 + */ 261 254 static int jz4740_mmc_prepare_dma_data(struct jz4740_mmc_host *host, 262 255 struct mmc_data *data, 263 - struct jz4740_mmc_host_next *next, 264 - struct dma_chan *chan) 256 + int cookie) 265 257 { 266 - struct jz4740_mmc_host_next *next_data = &host->next_data; 258 + struct dma_chan *chan = jz4740_mmc_get_dma_chan(host, data); 267 259 enum dma_data_direction dir = mmc_get_dma_dir(data); 268 - int sg_len; 260 + int sg_count; 269 261 270 - if (!next && data->host_cookie && 271 - data->host_cookie != host->next_data.cookie) { 272 - dev_warn(mmc_dev(host->mmc), 273 - "[%s] invalid cookie: data->host_cookie %d host->next_data.cookie %d\n", 274 - __func__, 275 - data->host_cookie, 276 - host->next_data.cookie); 277 - data->host_cookie = 0; 278 - } 262 + if (data->host_cookie == COOKIE_PREMAPPED) 263 + return data->sg_count; 279 264 280 - /* Check if next job is already prepared */ 281 - if (next || data->host_cookie != host->next_data.cookie) { 282 - sg_len = dma_map_sg(chan->device->dev, 283 - data->sg, 284 - data->sg_len, 285 - dir); 265 + sg_count = dma_map_sg(chan->device->dev, 266 + data->sg, 267 + data->sg_len, 268 + dir); 286 269 287 - } else { 288 - sg_len = next_data->sg_len; 289 - next_data->sg_len = 0; 290 - } 291 - 292 - if (sg_len <= 0) { 270 + if (sg_count <= 0) { 293 271 dev_err(mmc_dev(host->mmc), 294 272 "Failed to map scatterlist for DMA operation\n"); 295 273 return -EINVAL; 296 274 } 297 275 298 - if (next) { 299 - next->sg_len = sg_len; 300 - data->host_cookie = ++next->cookie < 0 ? 1 : next->cookie; 301 - } else 302 - host->sg_len = sg_len; 276 + data->sg_count = sg_count; 277 + data->host_cookie = cookie; 303 278 304 - return 0; 279 + return data->sg_count; 305 280 } 306 281 307 282 static int jz4740_mmc_start_dma_transfer(struct jz4740_mmc_host *host, 308 283 struct mmc_data *data) 309 284 { 310 - int ret; 311 - struct dma_chan *chan; 285 + struct dma_chan *chan = jz4740_mmc_get_dma_chan(host, data); 312 286 struct dma_async_tx_descriptor *desc; 313 287 struct dma_slave_config conf = { 314 288 .src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES, ··· 300 306 .src_maxburst = JZ4740_MMC_FIFO_HALF_SIZE, 301 307 .dst_maxburst = JZ4740_MMC_FIFO_HALF_SIZE, 302 308 }; 309 + int sg_count; 303 310 304 311 if (data->flags & MMC_DATA_WRITE) { 305 312 conf.direction = DMA_MEM_TO_DEV; 306 313 conf.dst_addr = host->mem_res->start + JZ_REG_MMC_TXFIFO; 307 314 conf.slave_id = JZ4740_DMA_TYPE_MMC_TRANSMIT; 308 - chan = host->dma_tx; 309 315 } else { 310 316 conf.direction = DMA_DEV_TO_MEM; 311 317 conf.src_addr = host->mem_res->start + JZ_REG_MMC_RXFIFO; 312 318 conf.slave_id = JZ4740_DMA_TYPE_MMC_RECEIVE; 313 - chan = host->dma_rx; 314 319 } 315 320 316 - ret = jz4740_mmc_prepare_dma_data(host, data, NULL, chan); 317 - if (ret) 318 - return ret; 321 + sg_count = jz4740_mmc_prepare_dma_data(host, data, COOKIE_MAPPED); 322 + if (sg_count < 0) 323 + return sg_count; 319 324 320 325 dmaengine_slave_config(chan, &conf); 321 - desc = dmaengine_prep_slave_sg(chan, 322 - data->sg, 323 - host->sg_len, 324 - conf.direction, 325 - DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 326 + desc = dmaengine_prep_slave_sg(chan, data->sg, sg_count, 327 + conf.direction, 328 + DMA_PREP_INTERRUPT | DMA_CTRL_ACK); 326 329 if (!desc) { 327 330 dev_err(mmc_dev(host->mmc), 328 331 "Failed to allocate DMA %s descriptor", ··· 333 342 return 0; 334 343 335 344 dma_unmap: 336 - jz4740_mmc_dma_unmap(host, data); 345 + if (data->host_cookie == COOKIE_MAPPED) 346 + jz4740_mmc_dma_unmap(host, data); 337 347 return -ENOMEM; 338 348 } 339 349 ··· 343 351 { 344 352 struct jz4740_mmc_host *host = mmc_priv(mmc); 345 353 struct mmc_data *data = mrq->data; 346 - struct jz4740_mmc_host_next *next_data = &host->next_data; 347 354 348 - BUG_ON(data->host_cookie); 355 + if (!host->use_dma) 356 + return; 349 357 350 - if (host->use_dma) { 351 - struct dma_chan *chan = jz4740_mmc_get_dma_chan(host, data); 352 - 353 - if (jz4740_mmc_prepare_dma_data(host, data, next_data, chan)) 354 - data->host_cookie = 0; 355 - } 358 + data->host_cookie = COOKIE_UNMAPPED; 359 + if (jz4740_mmc_prepare_dma_data(host, data, COOKIE_PREMAPPED) < 0) 360 + data->host_cookie = COOKIE_UNMAPPED; 356 361 } 357 362 358 363 static void jz4740_mmc_post_request(struct mmc_host *mmc, ··· 359 370 struct jz4740_mmc_host *host = mmc_priv(mmc); 360 371 struct mmc_data *data = mrq->data; 361 372 362 - if (host->use_dma && data->host_cookie) { 373 + if (data && data->host_cookie != COOKIE_UNMAPPED) 363 374 jz4740_mmc_dma_unmap(host, data); 364 - data->host_cookie = 0; 365 - } 366 375 367 376 if (err) { 368 377 struct dma_chan *chan = jz4740_mmc_get_dma_chan(host, data); ··· 423 436 static void jz4740_mmc_request_done(struct jz4740_mmc_host *host) 424 437 { 425 438 struct mmc_request *req; 439 + struct mmc_data *data; 426 440 427 441 req = host->req; 442 + data = req->data; 428 443 host->req = NULL; 429 444 445 + if (data && data->host_cookie == COOKIE_MAPPED) 446 + jz4740_mmc_dma_unmap(host, data); 430 447 mmc_request_done(host->mmc, req); 431 448 } 432 449 ··· 894 903 switch (ios->power_mode) { 895 904 case MMC_POWER_UP: 896 905 jz4740_mmc_reset(host); 897 - if (host->pdata && gpio_is_valid(host->pdata->gpio_power)) 898 - gpio_set_value(host->pdata->gpio_power, 899 - !host->pdata->power_active_low); 906 + if (host->power) 907 + gpiod_set_value(host->power, 1); 900 908 host->cmdat |= JZ_MMC_CMDAT_INIT; 901 909 clk_prepare_enable(host->clk); 902 910 break; 903 911 case MMC_POWER_ON: 904 912 break; 905 913 default: 906 - if (host->pdata && gpio_is_valid(host->pdata->gpio_power)) 907 - gpio_set_value(host->pdata->gpio_power, 908 - host->pdata->power_active_low); 914 + if (host->power) 915 + gpiod_set_value(host->power, 0); 909 916 clk_disable_unprepare(host->clk); 910 917 break; 911 918 } ··· 936 947 .enable_sdio_irq = jz4740_mmc_enable_sdio_irq, 937 948 }; 938 949 939 - static int jz4740_mmc_request_gpio(struct device *dev, int gpio, 940 - const char *name, bool output, int value) 941 - { 942 - int ret; 943 - 944 - if (!gpio_is_valid(gpio)) 945 - return 0; 946 - 947 - ret = gpio_request(gpio, name); 948 - if (ret) { 949 - dev_err(dev, "Failed to request %s gpio: %d\n", name, ret); 950 - return ret; 951 - } 952 - 953 - if (output) 954 - gpio_direction_output(gpio, value); 955 - else 956 - gpio_direction_input(gpio); 957 - 958 - return 0; 959 - } 960 - 961 - static int jz4740_mmc_request_gpios(struct mmc_host *mmc, 962 - struct platform_device *pdev) 950 + static int jz4740_mmc_request_gpios(struct jz4740_mmc_host *host, 951 + struct mmc_host *mmc, 952 + struct platform_device *pdev) 963 953 { 964 954 struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev); 965 955 int ret = 0; ··· 951 983 if (!pdata->read_only_active_low) 952 984 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 953 985 954 - if (gpio_is_valid(pdata->gpio_card_detect)) { 955 - ret = mmc_gpio_request_cd(mmc, pdata->gpio_card_detect, 0); 956 - if (ret) 957 - return ret; 958 - } 986 + /* 987 + * Get optional card detect and write protect GPIOs, 988 + * only back out on probe deferral. 989 + */ 990 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); 991 + if (ret == -EPROBE_DEFER) 992 + return ret; 959 993 960 - if (gpio_is_valid(pdata->gpio_read_only)) { 961 - ret = mmc_gpio_request_ro(mmc, pdata->gpio_read_only); 962 - if (ret) 963 - return ret; 964 - } 994 + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); 995 + if (ret == -EPROBE_DEFER) 996 + return ret; 965 997 966 - return jz4740_mmc_request_gpio(&pdev->dev, pdata->gpio_power, 967 - "MMC read only", true, pdata->power_active_low); 968 - } 969 - 970 - static void jz4740_mmc_free_gpios(struct platform_device *pdev) 971 - { 972 - struct jz4740_mmc_platform_data *pdata = dev_get_platdata(&pdev->dev); 973 - 974 - if (!pdata) 975 - return; 976 - 977 - if (gpio_is_valid(pdata->gpio_power)) 978 - gpio_free(pdata->gpio_power); 998 + host->power = devm_gpiod_get_optional(&pdev->dev, "power", 999 + GPIOD_OUT_HIGH); 1000 + return PTR_ERR_OR_ZERO(host->power); 979 1001 } 980 1002 981 1003 static const struct of_device_id jz4740_mmc_of_match[] = { ··· 1011 1053 mmc->caps |= MMC_CAP_SDIO_IRQ; 1012 1054 if (!(pdata && pdata->data_1bit)) 1013 1055 mmc->caps |= MMC_CAP_4_BIT_DATA; 1014 - ret = jz4740_mmc_request_gpios(mmc, pdev); 1056 + ret = jz4740_mmc_request_gpios(host, mmc, pdev); 1015 1057 if (ret) 1016 1058 goto err_free_host; 1017 1059 } ··· 1062 1104 dev_name(&pdev->dev), host); 1063 1105 if (ret) { 1064 1106 dev_err(&pdev->dev, "Failed to request irq: %d\n", ret); 1065 - goto err_free_gpios; 1107 + goto err_free_host; 1066 1108 } 1067 1109 1068 1110 jz4740_mmc_clock_disable(host); ··· 1093 1135 jz4740_mmc_release_dma_channels(host); 1094 1136 err_free_irq: 1095 1137 free_irq(host->irq, host); 1096 - err_free_gpios: 1097 - jz4740_mmc_free_gpios(pdev); 1098 1138 err_free_host: 1099 1139 mmc_free_host(mmc); 1100 1140 ··· 1110 1154 mmc_remove_host(host->mmc); 1111 1155 1112 1156 free_irq(host->irq, host); 1113 - 1114 - jz4740_mmc_free_gpios(pdev); 1115 1157 1116 1158 if (host->use_dma) 1117 1159 jz4740_mmc_release_dma_channels(host);
+76 -26
drivers/mmc/host/meson-gx-mmc.c
··· 21 21 #include <linux/kernel.h> 22 22 #include <linux/module.h> 23 23 #include <linux/init.h> 24 + #include <linux/delay.h> 24 25 #include <linux/device.h> 25 26 #include <linux/of_device.h> 26 27 #include <linux/platform_device.h> 27 28 #include <linux/ioport.h> 28 - #include <linux/spinlock.h> 29 29 #include <linux/dma-mapping.h> 30 30 #include <linux/mmc/host.h> 31 31 #include <linux/mmc/mmc.h> ··· 66 66 67 67 #define SD_EMMC_DELAY 0x4 68 68 #define SD_EMMC_ADJUST 0x8 69 + #define ADJUST_ADJ_DELAY_MASK GENMASK(21, 16) 70 + #define ADJUST_DS_EN BIT(15) 71 + #define ADJUST_ADJ_EN BIT(13) 69 72 70 73 #define SD_EMMC_DELAY1 0x4 71 74 #define SD_EMMC_DELAY2 0x8 ··· 93 90 #define CFG_CLK_ALWAYS_ON BIT(18) 94 91 #define CFG_CHK_DS BIT(20) 95 92 #define CFG_AUTO_CLK BIT(23) 93 + #define CFG_ERR_ABORT BIT(27) 96 94 97 95 #define SD_EMMC_STATUS 0x48 98 96 #define STATUS_BUSY BIT(31) 97 + #define STATUS_DESC_BUSY BIT(30) 99 98 #define STATUS_DATI GENMASK(23, 16) 100 99 101 100 #define SD_EMMC_IRQ_EN 0x4c ··· 146 141 unsigned int tx_delay_mask; 147 142 unsigned int rx_delay_mask; 148 143 unsigned int always_on; 144 + unsigned int adjust; 149 145 }; 150 146 151 147 struct sd_emmc_desc { ··· 162 156 struct mmc_host *mmc; 163 157 struct mmc_command *cmd; 164 158 165 - spinlock_t lock; 166 159 void __iomem *regs; 167 160 struct clk *core_clk; 168 161 struct clk *mmc_clk; ··· 638 633 if (ret) 639 634 return ret; 640 635 641 - /* 642 - * Set phases : These values are mostly the datasheet recommended ones 643 - * except for the Tx phase. Datasheet recommends 180 but some cards 644 - * fail at initialisation with it. 270 works just fine, it fixes these 645 - * initialisation issues and enable eMMC DDR52 mode. 646 - */ 647 636 clk_set_phase(host->mmc_clk, 180); 648 - clk_set_phase(host->tx_clk, 270); 637 + clk_set_phase(host->tx_clk, 0); 649 638 clk_set_phase(host->rx_clk, 0); 650 639 651 640 return clk_prepare_enable(host->mmc_clk); ··· 927 928 928 929 cmd_cfg |= FIELD_PREP(CMD_CFG_CMD_INDEX_MASK, cmd->opcode); 929 930 cmd_cfg |= CMD_CFG_OWNER; /* owned by CPU */ 931 + cmd_cfg |= CMD_CFG_ERROR; /* stop in case of error */ 930 932 931 933 meson_mmc_set_response_bits(cmd, &cmd_cfg); 932 934 ··· 1022 1022 u32 irq_en, status, raw_status; 1023 1023 irqreturn_t ret = IRQ_NONE; 1024 1024 1025 - if (WARN_ON(!host) || WARN_ON(!host->cmd)) 1026 - return IRQ_NONE; 1027 - 1028 - spin_lock(&host->lock); 1029 - 1030 - cmd = host->cmd; 1031 - data = cmd->data; 1032 1025 irq_en = readl(host->regs + SD_EMMC_IRQ_EN); 1033 1026 raw_status = readl(host->regs + SD_EMMC_STATUS); 1034 1027 status = raw_status & irq_en; 1035 1028 1029 + if (!status) { 1030 + dev_dbg(host->dev, 1031 + "Unexpected IRQ! irq_en 0x%08x - status 0x%08x\n", 1032 + irq_en, raw_status); 1033 + return IRQ_NONE; 1034 + } 1035 + 1036 + if (WARN_ON(!host) || WARN_ON(!host->cmd)) 1037 + return IRQ_NONE; 1038 + 1039 + cmd = host->cmd; 1040 + data = cmd->data; 1036 1041 cmd->error = 0; 1037 1042 if (status & IRQ_CRC_ERR) { 1038 1043 dev_dbg(host->dev, "CRC Error - status 0x%08x\n", status); 1039 1044 cmd->error = -EILSEQ; 1040 - ret = IRQ_HANDLED; 1045 + ret = IRQ_WAKE_THREAD; 1041 1046 goto out; 1042 1047 } 1043 1048 1044 1049 if (status & IRQ_TIMEOUTS) { 1045 1050 dev_dbg(host->dev, "Timeout - status 0x%08x\n", status); 1046 1051 cmd->error = -ETIMEDOUT; 1047 - ret = IRQ_HANDLED; 1052 + ret = IRQ_WAKE_THREAD; 1048 1053 goto out; 1049 1054 } 1050 1055 ··· 1074 1069 /* ack all enabled interrupts */ 1075 1070 writel(irq_en, host->regs + SD_EMMC_STATUS); 1076 1071 1072 + if (cmd->error) { 1073 + /* Stop desc in case of errors */ 1074 + u32 start = readl(host->regs + SD_EMMC_START); 1075 + 1076 + start &= ~START_DESC_BUSY; 1077 + writel(start, host->regs + SD_EMMC_START); 1078 + } 1079 + 1077 1080 if (ret == IRQ_HANDLED) 1078 1081 meson_mmc_request_done(host->mmc, cmd->mrq); 1079 - else if (ret == IRQ_NONE) 1080 - dev_warn(host->dev, 1081 - "Unexpected IRQ! status=0x%08x, irq_en=0x%08x\n", 1082 - raw_status, irq_en); 1083 1082 1084 - spin_unlock(&host->lock); 1085 1083 return ret; 1084 + } 1085 + 1086 + static int meson_mmc_wait_desc_stop(struct meson_host *host) 1087 + { 1088 + int loop; 1089 + u32 status; 1090 + 1091 + /* 1092 + * It may sometimes take a while for it to actually halt. Here, we 1093 + * are giving it 5ms to comply 1094 + * 1095 + * If we don't confirm the descriptor is stopped, it might raise new 1096 + * IRQs after we have called mmc_request_done() which is bad. 1097 + */ 1098 + for (loop = 50; loop; loop--) { 1099 + status = readl(host->regs + SD_EMMC_STATUS); 1100 + if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) 1101 + udelay(100); 1102 + else 1103 + break; 1104 + } 1105 + 1106 + if (status & (STATUS_BUSY | STATUS_DESC_BUSY)) { 1107 + dev_err(host->dev, "Timed out waiting for host to stop\n"); 1108 + return -ETIMEDOUT; 1109 + } 1110 + 1111 + return 0; 1086 1112 } 1087 1113 1088 1114 static irqreturn_t meson_mmc_irq_thread(int irq, void *dev_id) ··· 1125 1089 1126 1090 if (WARN_ON(!cmd)) 1127 1091 return IRQ_NONE; 1092 + 1093 + if (cmd->error) { 1094 + meson_mmc_wait_desc_stop(host); 1095 + meson_mmc_request_done(host->mmc, cmd->mrq); 1096 + 1097 + return IRQ_HANDLED; 1098 + } 1128 1099 1129 1100 data = cmd->data; 1130 1101 if (meson_mmc_bounce_buf_read(data)) { ··· 1166 1123 1167 1124 static void meson_mmc_cfg_init(struct meson_host *host) 1168 1125 { 1169 - u32 cfg = 0; 1126 + u32 cfg = 0, adj = 0; 1170 1127 1171 1128 cfg |= FIELD_PREP(CFG_RESP_TIMEOUT_MASK, 1172 1129 ilog2(SD_EMMC_CFG_RESP_TIMEOUT)); 1173 1130 cfg |= FIELD_PREP(CFG_RC_CC_MASK, ilog2(SD_EMMC_CFG_CMD_GAP)); 1174 1131 cfg |= FIELD_PREP(CFG_BLK_LEN_MASK, ilog2(SD_EMMC_CFG_BLK_SIZE)); 1175 1132 1133 + /* abort chain on R/W errors */ 1134 + cfg |= CFG_ERR_ABORT; 1135 + 1176 1136 writel(cfg, host->regs + SD_EMMC_CFG); 1137 + 1138 + /* enable signal resampling w/o delay */ 1139 + adj = ADJUST_ADJ_EN; 1140 + writel(adj, host->regs + host->data->adjust); 1177 1141 } 1178 1142 1179 1143 static int meson_mmc_card_busy(struct mmc_host *mmc) ··· 1240 1190 host->mmc = mmc; 1241 1191 host->dev = &pdev->dev; 1242 1192 dev_set_drvdata(&pdev->dev, host); 1243 - 1244 - spin_lock_init(&host->lock); 1245 1193 1246 1194 /* Get regulators and the supported OCR mask */ 1247 1195 host->vqmmc_enabled = false; ··· 1404 1356 .tx_delay_mask = CLK_V2_TX_DELAY_MASK, 1405 1357 .rx_delay_mask = CLK_V2_RX_DELAY_MASK, 1406 1358 .always_on = CLK_V2_ALWAYS_ON, 1359 + .adjust = SD_EMMC_ADJUST, 1407 1360 }; 1408 1361 1409 1362 static const struct meson_mmc_data meson_axg_data = { 1410 1363 .tx_delay_mask = CLK_V3_TX_DELAY_MASK, 1411 1364 .rx_delay_mask = CLK_V3_RX_DELAY_MASK, 1412 1365 .always_on = CLK_V3_ALWAYS_ON, 1366 + .adjust = SD_EMMC_V3_ADJUST, 1413 1367 }; 1414 1368 1415 1369 static const struct of_device_id meson_mmc_of_match[] = {
+6
drivers/mmc/host/meson-mx-sdio.c
··· 596 596 init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL, 597 597 "%s#fixed_factor", 598 598 dev_name(host->controller_dev)); 599 + if (!init.name) 600 + return -ENOMEM; 601 + 599 602 init.ops = &clk_fixed_factor_ops; 600 603 init.flags = 0; 601 604 init.parent_names = &clk_fixed_factor_parent; ··· 615 612 clk_div_parent = __clk_get_name(host->fixed_factor_clk); 616 613 init.name = devm_kasprintf(host->controller_dev, GFP_KERNEL, 617 614 "%s#div", dev_name(host->controller_dev)); 615 + if (!init.name) 616 + return -ENOMEM; 617 + 618 618 init.ops = &clk_divider_ops; 619 619 init.flags = CLK_SET_RATE_PARENT; 620 620 init.parent_names = &clk_div_parent;
+15 -12
drivers/mmc/host/mmc_spi.c
··· 1434 1434 if (status != 0) 1435 1435 goto fail_add_host; 1436 1436 1437 - if (host->pdata && host->pdata->flags & MMC_SPI_USE_CD_GPIO) { 1438 - status = mmc_gpio_request_cd(mmc, host->pdata->cd_gpio, 1439 - host->pdata->cd_debounce); 1440 - if (status != 0) 1441 - goto fail_add_host; 1442 - 1443 - /* The platform has a CD GPIO signal that may support 1437 + /* 1438 + * Index 0 is card detect 1439 + * Old boardfiles were specifying 1 ms as debounce 1440 + */ 1441 + status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1, NULL); 1442 + if (status == -EPROBE_DEFER) 1443 + goto fail_add_host; 1444 + if (!status) { 1445 + /* 1446 + * The platform has a CD GPIO signal that may support 1444 1447 * interrupts, so let mmc_gpiod_request_cd_irq() decide 1445 1448 * if polling is needed or not. 1446 1449 */ ··· 1451 1448 mmc_gpiod_request_cd_irq(mmc); 1452 1449 } 1453 1450 1454 - if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) { 1451 + /* Index 1 is write protect/read only */ 1452 + status = mmc_gpiod_request_ro(mmc, NULL, 1, false, 0, NULL); 1453 + if (status == -EPROBE_DEFER) 1454 + goto fail_add_host; 1455 + if (!status) 1455 1456 has_ro = true; 1456 - status = mmc_gpio_request_ro(mmc, host->pdata->ro_gpio); 1457 - if (status != 0) 1458 - goto fail_add_host; 1459 - } 1460 1457 1461 1458 dev_info(&spi->dev, "SD/MMC host %s%s%s%s%s\n", 1462 1459 dev_name(&mmc->class_dev),
+8 -3
drivers/mmc/host/mmci.c
··· 21 21 #include <linux/err.h> 22 22 #include <linux/highmem.h> 23 23 #include <linux/log2.h> 24 + #include <linux/mmc/mmc.h> 24 25 #include <linux/mmc/pm.h> 25 26 #include <linux/mmc/host.h> 26 27 #include <linux/mmc/card.h> ··· 275 274 .cmdreg_lrsp_crc = MCI_CPSM_STM32_LRSP_CRC, 276 275 .cmdreg_srsp_crc = MCI_CPSM_STM32_SRSP_CRC, 277 276 .cmdreg_srsp = MCI_CPSM_STM32_SRSP, 277 + .cmdreg_stop = MCI_CPSM_STM32_CMDSTOP, 278 278 .data_cmd_enable = MCI_CPSM_STM32_CMDTRANS, 279 279 .irq_pio_mask = MCI_IRQ_PIO_STM32_MASK, 280 280 .datactrl_first = true, ··· 1102 1100 mmci_reg_delay(host); 1103 1101 } 1104 1102 1103 + if (host->variant->cmdreg_stop && 1104 + cmd->opcode == MMC_STOP_TRANSMISSION) 1105 + c |= host->variant->cmdreg_stop; 1106 + 1105 1107 c |= cmd->opcode | host->variant->cmdreg_cpsm_enable; 1106 1108 if (cmd->flags & MMC_RSP_PRESENT) { 1107 1109 if (cmd->flags & MMC_RSP_136) ··· 1196 1190 /* The error clause is handled above, success! */ 1197 1191 data->bytes_xfered = data->blksz * data->blocks; 1198 1192 1199 - if (!data->stop || host->mrq->sbc) { 1193 + if (!data->stop || (host->mrq->sbc && !data->error)) 1200 1194 mmci_request_end(host, data->mrq); 1201 - } else { 1195 + else 1202 1196 mmci_start_command(host, data->stop, 0); 1203 - } 1204 1197 } 1205 1198 } 1206 1199
+2
drivers/mmc/host/mmci.h
··· 264 264 * @cmdreg_lrsp_crc: enable value for long response with crc 265 265 * @cmdreg_srsp_crc: enable value for short response with crc 266 266 * @cmdreg_srsp: enable value for short response without crc 267 + * @cmdreg_stop: enable value for stop and abort transmission 267 268 * @datalength_bits: number of bits in the MMCIDATALENGTH register 268 269 * @fifosize: number of bytes that can be written when MMCI_TXFIFOEMPTY 269 270 * is asserted (likewise for RX) ··· 317 316 unsigned int cmdreg_lrsp_crc; 318 317 unsigned int cmdreg_srsp_crc; 319 318 unsigned int cmdreg_srsp; 319 + unsigned int cmdreg_stop; 320 320 unsigned int datalength_bits; 321 321 unsigned int fifosize; 322 322 unsigned int fifohalfsize;
+50 -3
drivers/mmc/host/mtk-sd.c
··· 1114 1114 struct mmc_request *mrq, struct mmc_command *cmd) 1115 1115 { 1116 1116 u32 rawcmd; 1117 + unsigned long flags; 1117 1118 1118 1119 WARN_ON(host->cmd); 1119 1120 host->cmd = cmd; ··· 1132 1131 cmd->error = 0; 1133 1132 rawcmd = msdc_cmd_prepare_raw_cmd(host, mrq, cmd); 1134 1133 1134 + spin_lock_irqsave(&host->lock, flags); 1135 1135 sdr_set_bits(host->base + MSDC_INTEN, cmd_ints_mask); 1136 + spin_unlock_irqrestore(&host->lock, flags); 1137 + 1136 1138 writel(cmd->arg, host->base + SDC_ARG); 1137 1139 writel(rawcmd, host->base + SDC_CMD); 1138 1140 } ··· 1355 1351 } 1356 1352 } 1357 1353 1354 + static void __msdc_enable_sdio_irq(struct mmc_host *mmc, int enb) 1355 + { 1356 + unsigned long flags; 1357 + struct msdc_host *host = mmc_priv(mmc); 1358 + 1359 + spin_lock_irqsave(&host->lock, flags); 1360 + if (enb) 1361 + sdr_set_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ); 1362 + else 1363 + sdr_clr_bits(host->base + MSDC_INTEN, MSDC_INTEN_SDIOIRQ); 1364 + spin_unlock_irqrestore(&host->lock, flags); 1365 + } 1366 + 1367 + static void msdc_enable_sdio_irq(struct mmc_host *mmc, int enb) 1368 + { 1369 + struct msdc_host *host = mmc_priv(mmc); 1370 + 1371 + __msdc_enable_sdio_irq(mmc, enb); 1372 + 1373 + if (enb) 1374 + pm_runtime_get_noresume(host->dev); 1375 + else 1376 + pm_runtime_put_noidle(host->dev); 1377 + } 1378 + 1358 1379 static irqreturn_t msdc_irq(int irq, void *dev_id) 1359 1380 { 1360 1381 struct msdc_host *host = (struct msdc_host *) dev_id; ··· 1402 1373 data = host->data; 1403 1374 spin_unlock_irqrestore(&host->lock, flags); 1404 1375 1405 - if (!(events & event_mask)) 1376 + if ((events & event_mask) & MSDC_INT_SDIOIRQ) { 1377 + __msdc_enable_sdio_irq(host->mmc, 0); 1378 + sdio_signal_irq(host->mmc); 1379 + } 1380 + 1381 + if (!(events & (event_mask & ~MSDC_INT_SDIOIRQ))) 1406 1382 break; 1407 1383 1408 1384 if (!mrq) { ··· 1527 1493 */ 1528 1494 sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIO); 1529 1495 1530 - /* disable detect SDIO device interrupt function */ 1531 - sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE); 1496 + /* Config SDIO device detect interrupt function */ 1497 + if (host->mmc->caps & MMC_CAP_SDIO_IRQ) 1498 + sdr_set_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE); 1499 + else 1500 + sdr_clr_bits(host->base + SDC_CFG, SDC_CFG_SDIOIDE); 1532 1501 1533 1502 /* Configure to default data timeout */ 1534 1503 sdr_set_field(host->base + SDC_CFG, SDC_CFG_DTOC, 3); ··· 2050 2013 sdr_clr_bits(host->base + EMMC_IOCON, 1); 2051 2014 } 2052 2015 2016 + static void msdc_ack_sdio_irq(struct mmc_host *mmc) 2017 + { 2018 + __msdc_enable_sdio_irq(mmc, 1); 2019 + } 2020 + 2053 2021 static const struct mmc_host_ops mt_msdc_ops = { 2054 2022 .post_req = msdc_post_req, 2055 2023 .pre_req = msdc_pre_req, ··· 2062 2020 .set_ios = msdc_ops_set_ios, 2063 2021 .get_ro = mmc_gpio_get_ro, 2064 2022 .get_cd = mmc_gpio_get_cd, 2023 + .enable_sdio_irq = msdc_enable_sdio_irq, 2024 + .ack_sdio_irq = msdc_ack_sdio_irq, 2065 2025 .start_signal_voltage_switch = msdc_ops_switch_volt, 2066 2026 .card_busy = msdc_card_busy, 2067 2027 .execute_tuning = msdc_execute_tuning, ··· 2190 2146 mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 255); 2191 2147 else 2192 2148 mmc->f_min = DIV_ROUND_UP(host->src_clk_freq, 4 * 4095); 2149 + 2150 + if (mmc->caps & MMC_CAP_SDIO_IRQ) 2151 + mmc->caps2 |= MMC_CAP2_SDIO_IRQ_NOTHREAD; 2193 2152 2194 2153 mmc->caps |= MMC_CAP_ERASE | MMC_CAP_CMD23; 2195 2154 /* MMC core transfer sizes tunable parameters */
-34
drivers/mmc/host/of_mmc_spi.c
··· 16 16 #include <linux/device.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/irq.h> 19 - #include <linux/gpio.h> 20 19 #include <linux/of.h> 21 - #include <linux/of_gpio.h> 22 20 #include <linux/of_irq.h> 23 21 #include <linux/spi/spi.h> 24 22 #include <linux/spi/mmc_spi.h> ··· 30 32 31 33 MODULE_LICENSE("GPL"); 32 34 33 - enum { 34 - CD_GPIO = 0, 35 - WP_GPIO, 36 - NUM_GPIOS, 37 - }; 38 - 39 35 struct of_mmc_spi { 40 - int gpios[NUM_GPIOS]; 41 - bool alow_gpios[NUM_GPIOS]; 42 36 int detect_irq; 43 37 struct mmc_spi_platform_data pdata; 44 38 }; ··· 90 100 goto err_ocr; 91 101 } 92 102 oms->pdata.ocr_mask |= mask; 93 - } 94 - 95 - for (i = 0; i < ARRAY_SIZE(oms->gpios); i++) { 96 - enum of_gpio_flags gpio_flags; 97 - 98 - oms->gpios[i] = of_get_gpio_flags(np, i, &gpio_flags); 99 - if (!gpio_is_valid(oms->gpios[i])) 100 - continue; 101 - 102 - if (gpio_flags & OF_GPIO_ACTIVE_LOW) 103 - oms->alow_gpios[i] = true; 104 - } 105 - 106 - if (gpio_is_valid(oms->gpios[CD_GPIO])) { 107 - oms->pdata.cd_gpio = oms->gpios[CD_GPIO]; 108 - oms->pdata.flags |= MMC_SPI_USE_CD_GPIO; 109 - if (!oms->alow_gpios[CD_GPIO]) 110 - oms->pdata.caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 111 - } 112 - if (gpio_is_valid(oms->gpios[WP_GPIO])) { 113 - oms->pdata.ro_gpio = oms->gpios[WP_GPIO]; 114 - oms->pdata.flags |= MMC_SPI_USE_RO_GPIO; 115 - if (!oms->alow_gpios[WP_GPIO]) 116 - oms->pdata.caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 117 103 } 118 104 119 105 oms->detect_irq = irq_of_parse_and_map(np, 0);
+2 -12
drivers/mmc/host/omap_hsmmc.c
··· 1652 1652 1653 1653 #ifdef CONFIG_DEBUG_FS 1654 1654 1655 - static int omap_hsmmc_regs_show(struct seq_file *s, void *data) 1655 + static int mmc_regs_show(struct seq_file *s, void *data) 1656 1656 { 1657 1657 struct mmc_host *mmc = s->private; 1658 1658 struct omap_hsmmc_host *host = mmc_priv(mmc); ··· 1691 1691 return 0; 1692 1692 } 1693 1693 1694 - static int omap_hsmmc_regs_open(struct inode *inode, struct file *file) 1695 - { 1696 - return single_open(file, omap_hsmmc_regs_show, inode->i_private); 1697 - } 1698 - 1699 - static const struct file_operations mmc_regs_fops = { 1700 - .open = omap_hsmmc_regs_open, 1701 - .read = seq_read, 1702 - .llseek = seq_lseek, 1703 - .release = single_release, 1704 - }; 1694 + DEFINE_SHOW_ATTRIBUTE(mmc_regs); 1705 1695 1706 1696 static void omap_hsmmc_debugfs(struct mmc_host *mmc) 1707 1697 {
+30 -46
drivers/mmc/host/pxamci.c
··· 30 30 #include <linux/mmc/slot-gpio.h> 31 31 #include <linux/io.h> 32 32 #include <linux/regulator/consumer.h> 33 - #include <linux/gpio.h> 33 + #include <linux/gpio/consumer.h> 34 34 #include <linux/gfp.h> 35 35 #include <linux/of.h> 36 - #include <linux/of_gpio.h> 37 36 #include <linux/of_device.h> 38 37 39 38 #include <asm/sizes.h> ··· 62 63 unsigned int imask; 63 64 unsigned int power_mode; 64 65 unsigned long detect_delay_ms; 66 + bool use_ro_gpio; 67 + struct gpio_desc *power; 65 68 struct pxamci_platform_data *pdata; 66 69 67 70 struct mmc_request *mrq; ··· 102 101 { 103 102 struct mmc_host *mmc = host->mmc; 104 103 struct regulator *supply = mmc->supply.vmmc; 105 - int on; 106 104 107 105 if (!IS_ERR(supply)) 108 106 return mmc_regulator_set_ocr(mmc, supply, vdd); 109 107 110 - if (host->pdata && 111 - gpio_is_valid(host->pdata->gpio_power)) { 112 - on = ((1 << vdd) & host->pdata->ocr_mask); 113 - gpio_set_value(host->pdata->gpio_power, 114 - !!on ^ host->pdata->gpio_power_invert); 108 + if (host->power) { 109 + bool on = !!((1 << vdd) & host->pdata->ocr_mask); 110 + gpiod_set_value(host->power, on); 115 111 } 116 112 117 113 if (host->pdata && host->pdata->setpower) ··· 430 432 { 431 433 struct pxamci_host *host = mmc_priv(mmc); 432 434 433 - if (host->pdata && gpio_is_valid(host->pdata->gpio_card_ro)) 435 + if (host->use_ro_gpio) 434 436 return mmc_gpio_get_ro(mmc); 435 437 if (host->pdata && host->pdata->get_ro) 436 438 return !!host->pdata->get_ro(mmc_dev(mmc)); ··· 728 730 } 729 731 730 732 if (host->pdata) { 731 - int gpio_cd = host->pdata->gpio_card_detect; 732 - int gpio_ro = host->pdata->gpio_card_ro; 733 - int gpio_power = host->pdata->gpio_power; 734 - 735 733 host->detect_delay_ms = host->pdata->detect_delay_ms; 736 734 737 - if (gpio_is_valid(gpio_power)) { 738 - ret = devm_gpio_request(dev, gpio_power, 739 - "mmc card power"); 740 - if (ret) { 741 - dev_err(dev, 742 - "Failed requesting gpio_power %d\n", 743 - gpio_power); 744 - goto out; 745 - } 746 - gpio_direction_output(gpio_power, 747 - host->pdata->gpio_power_invert); 748 - } 749 - 750 - if (gpio_is_valid(gpio_ro)) { 751 - ret = mmc_gpio_request_ro(mmc, gpio_ro); 752 - if (ret) { 753 - dev_err(dev, 754 - "Failed requesting gpio_ro %d\n", 755 - gpio_ro); 756 - goto out; 757 - } else { 758 - mmc->caps2 |= host->pdata->gpio_card_ro_invert ? 759 - 0 : MMC_CAP2_RO_ACTIVE_HIGH; 760 - } 761 - } 762 - 763 - if (gpio_is_valid(gpio_cd)) 764 - ret = mmc_gpio_request_cd(mmc, gpio_cd, 0); 765 - if (ret) { 766 - dev_err(dev, "Failed requesting gpio_cd %d\n", 767 - gpio_cd); 735 + host->power = devm_gpiod_get_optional(dev, "power", GPIOD_OUT_LOW); 736 + if (IS_ERR(host->power)) { 737 + dev_err(dev, "Failed requesting gpio_power\n"); 768 738 goto out; 739 + } 740 + 741 + /* FIXME: should we pass detection delay to debounce? */ 742 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); 743 + if (ret && ret != -ENOENT) { 744 + dev_err(dev, "Failed requesting gpio_cd\n"); 745 + goto out; 746 + } 747 + 748 + ret = mmc_gpiod_request_ro(mmc, "wp", 0, false, 0, NULL); 749 + if (ret && ret != -ENOENT) { 750 + dev_err(dev, "Failed requesting gpio_ro\n"); 751 + goto out; 752 + } 753 + if (!ret) { 754 + host->use_ro_gpio = true; 755 + mmc->caps2 |= host->pdata->gpio_card_ro_invert ? 756 + 0 : MMC_CAP2_RO_ACTIVE_HIGH; 769 757 } 770 758 771 759 if (host->pdata->init) 772 760 host->pdata->init(dev, pxamci_detect_irq, mmc); 773 761 774 - if (gpio_is_valid(gpio_power) && host->pdata->setpower) 762 + if (host->power && host->pdata->setpower) 775 763 dev_warn(dev, "gpio_power and setpower() both defined\n"); 776 - if (gpio_is_valid(gpio_ro) && host->pdata->get_ro) 764 + if (host->use_ro_gpio && host->pdata->get_ro) 777 765 dev_warn(dev, "gpio_ro and get_ro() both defined\n"); 778 766 } 779 767
+41 -9
drivers/mmc/host/renesas_sdhi_core.c
··· 32 32 #include <linux/pinctrl/consumer.h> 33 33 #include <linux/pinctrl/pinctrl-state.h> 34 34 #include <linux/regulator/consumer.h> 35 + #include <linux/sys_soc.h> 35 36 36 37 #include "renesas_sdhi.h" 37 38 #include "tmio_mmc.h" ··· 45 44 #define SDHI_VER_GEN2_SDR104 0xcb0d 46 45 #define SDHI_VER_GEN3_SD 0xcc10 47 46 #define SDHI_VER_GEN3_SDMMC 0xcd10 47 + 48 + struct renesas_sdhi_quirks { 49 + bool hs400_disabled; 50 + bool hs400_4taps; 51 + }; 48 52 49 53 static void renesas_sdhi_sdbuf_width(struct tmio_mmc_host *host, int width) 50 54 { ··· 168 162 169 163 if (new_clock == 0) 170 164 goto out; 171 - 172 - /* 173 - * Both HS400 and HS200/SD104 set 200MHz, but some devices need to 174 - * set 400MHz to distinguish the CPG settings in HS400. 175 - */ 176 - if (host->mmc->ios.timing == MMC_TIMING_MMC_HS400 && 177 - host->pdata->flags & TMIO_MMC_HAVE_4TAP_HS400 && 178 - new_clock == 200000000) 179 - new_clock = 400000000; 180 165 181 166 clock = renesas_sdhi_clk_update(host, new_clock) / 512; 182 167 ··· 529 532 sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL, 530 533 ~SH_MOBILE_SDHI_SCC_RVSCNTL_RVSEN & 531 534 sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_RVSCNTL)); 535 + 536 + if (host->pdata->flags & TMIO_MMC_MIN_RCAR2) 537 + sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, 538 + TMIO_MASK_INIT_RCAR2); 532 539 } 533 540 534 541 static int renesas_sdhi_wait_idle(struct tmio_mmc_host *host, u32 bit) ··· 603 602 renesas_sdhi_sdbuf_width(host, enable ? width : 16); 604 603 } 605 604 605 + static const struct renesas_sdhi_quirks sdhi_quirks_h3_m3w_es1 = { 606 + .hs400_disabled = true, 607 + .hs400_4taps = true, 608 + }; 609 + 610 + static const struct renesas_sdhi_quirks sdhi_quirks_h3_es2 = { 611 + .hs400_disabled = false, 612 + .hs400_4taps = true, 613 + }; 614 + 615 + static const struct soc_device_attribute sdhi_quirks_match[] = { 616 + { .soc_id = "r8a7795", .revision = "ES1.*", .data = &sdhi_quirks_h3_m3w_es1 }, 617 + { .soc_id = "r8a7795", .revision = "ES2.0", .data = &sdhi_quirks_h3_es2 }, 618 + { .soc_id = "r8a7796", .revision = "ES1.0", .data = &sdhi_quirks_h3_m3w_es1 }, 619 + { .soc_id = "r8a7796", .revision = "ES1.1", .data = &sdhi_quirks_h3_m3w_es1 }, 620 + { /* Sentinel. */ }, 621 + }; 622 + 606 623 int renesas_sdhi_probe(struct platform_device *pdev, 607 624 const struct tmio_mmc_dma_ops *dma_ops) 608 625 { 609 626 struct tmio_mmc_data *mmd = pdev->dev.platform_data; 627 + const struct renesas_sdhi_quirks *quirks = NULL; 610 628 const struct renesas_sdhi_of_data *of_data; 629 + const struct soc_device_attribute *attr; 611 630 struct tmio_mmc_data *mmc_data; 612 631 struct tmio_mmc_dma *dma_priv; 613 632 struct tmio_mmc_host *host; ··· 636 615 int irq, ret, i; 637 616 638 617 of_data = of_device_get_match_data(&pdev->dev); 618 + 619 + attr = soc_device_match(sdhi_quirks_match); 620 + if (attr) 621 + quirks = attr->data; 639 622 640 623 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 641 624 if (!res) ··· 706 681 host->multi_io_quirk = renesas_sdhi_multi_io_quirk; 707 682 host->dma_ops = dma_ops; 708 683 684 + if (quirks && quirks->hs400_disabled) 685 + host->mmc->caps2 &= ~(MMC_CAP2_HS400 | MMC_CAP2_HS400_ES); 686 + 687 + if (quirks && quirks->hs400_4taps) 688 + mmc_data->flags |= TMIO_MMC_HAVE_4TAP_HS400; 689 + 709 690 /* For some SoC, we disable internal WP. GPIO may override this */ 710 691 if (mmc_can_gpio_ro(host->mmc)) 711 692 mmc_data->capabilities2 &= ~MMC_CAP2_NO_WRITE_PROTECT; ··· 722 691 host->ops.card_busy = renesas_sdhi_card_busy; 723 692 host->ops.start_signal_voltage_switch = 724 693 renesas_sdhi_start_signal_voltage_switch; 694 + host->sdcard_irq_setbit_mask = TMIO_STAT_ALWAYS_SET_27; 725 695 } 726 696 727 697 /* Orginally registers were 16 bit apart, could be 32 or 64 nowadays */
+19 -9
drivers/mmc/host/renesas_sdhi_internal_dmac.c
··· 34 34 #define DTRAN_MODE_CH_NUM_CH0 0 /* "downstream" = for write commands */ 35 35 #define DTRAN_MODE_CH_NUM_CH1 BIT(16) /* "upstream" = for read commands */ 36 36 #define DTRAN_MODE_BUS_WIDTH (BIT(5) | BIT(4)) 37 - #define DTRAN_MODE_ADDR_MODE BIT(0) /* 1 = Increment address */ 37 + #define DTRAN_MODE_ADDR_MODE BIT(0) /* 1 = Increment address, 0 = Fixed */ 38 38 39 39 /* DM_CM_DTRAN_CTRL */ 40 40 #define DTRAN_CTRL_DM_START BIT(0) ··· 73 73 #define SDHI_INTERNAL_DMAC_ONE_RX_ONLY 0 74 74 #define SDHI_INTERNAL_DMAC_RX_IN_USE 1 75 75 76 + /* RZ/A2 does not have the ADRR_MODE bit */ 77 + #define SDHI_INTERNAL_DMAC_ADDR_MODE_FIXED_ONLY 2 78 + 76 79 /* Definitions for sampling clocks */ 77 80 static struct renesas_sdhi_scc rcar_gen3_scc_taps[] = { 78 81 { ··· 84 81 }, 85 82 }; 86 83 87 - static const struct renesas_sdhi_of_data of_rcar_r8a7795_compatible = { 84 + static const struct renesas_sdhi_of_data of_rza2_compatible = { 88 85 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | 89 - TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 | 90 - TMIO_MMC_HAVE_4TAP_HS400, 86 + TMIO_MMC_HAVE_CBSY, 87 + .tmio_ocr_mask = MMC_VDD_32_33, 91 88 .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | 92 89 MMC_CAP_CMD23, 93 - .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, 94 90 .bus_shift = 2, 95 - .scc_offset = 0x1000, 91 + .scc_offset = 0 - 0x1000, 96 92 .taps = rcar_gen3_scc_taps, 97 93 .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps), 98 94 /* DMAC can handle 0xffffffff blk count but only 1 segment */ ··· 115 113 }; 116 114 117 115 static const struct of_device_id renesas_sdhi_internal_dmac_of_match[] = { 116 + { .compatible = "renesas,sdhi-r7s9210", .data = &of_rza2_compatible, }, 118 117 { .compatible = "renesas,sdhi-mmc-r8a77470", .data = &of_rcar_gen3_compatible, }, 119 - { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_r8a7795_compatible, }, 120 - { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_r8a7795_compatible, }, 118 + { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_gen3_compatible, }, 119 + { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_gen3_compatible, }, 121 120 { .compatible = "renesas,rcar-gen3-sdhi", .data = &of_rcar_gen3_compatible, }, 122 121 {}, 123 122 }; ··· 175 172 struct mmc_data *data) 176 173 { 177 174 struct scatterlist *sg = host->sg_ptr; 178 - u32 dtran_mode = DTRAN_MODE_BUS_WIDTH | DTRAN_MODE_ADDR_MODE; 175 + u32 dtran_mode = DTRAN_MODE_BUS_WIDTH; 176 + 177 + if (!test_bit(SDHI_INTERNAL_DMAC_ADDR_MODE_FIXED_ONLY, &global_flags)) 178 + dtran_mode |= DTRAN_MODE_ADDR_MODE; 179 179 180 180 if (!dma_map_sg(&host->pdev->dev, sg, host->sg_len, 181 181 mmc_get_dma_dir(data))) ··· 298 292 */ 299 293 static const struct soc_device_attribute soc_whitelist[] = { 300 294 /* specific ones */ 295 + { .soc_id = "r7s9210", 296 + .data = (void *)BIT(SDHI_INTERNAL_DMAC_ADDR_MODE_FIXED_ONLY) }, 301 297 { .soc_id = "r8a7795", .revision = "ES1.*", 302 298 .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) }, 303 299 { .soc_id = "r8a7796", .revision = "ES1.0", 304 300 .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) }, 305 301 /* generic ones */ 306 302 { .soc_id = "r8a774a1" }, 303 + { .soc_id = "r8a774c0" }, 307 304 { .soc_id = "r8a77470" }, 308 305 { .soc_id = "r8a7795" }, 309 306 { .soc_id = "r8a7796" }, 310 307 { .soc_id = "r8a77965" }, 311 308 { .soc_id = "r8a77970" }, 312 309 { .soc_id = "r8a77980" }, 310 + { .soc_id = "r8a77990" }, 313 311 { .soc_id = "r8a77995" }, 314 312 { /* sentinel */ } 315 313 };
+3 -17
drivers/mmc/host/renesas_sdhi_sys_dmac.c
··· 75 75 }, 76 76 }; 77 77 78 - static const struct renesas_sdhi_of_data of_rcar_r8a7795_compatible = { 79 - .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | 80 - TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2 | 81 - TMIO_MMC_HAVE_4TAP_HS400, 82 - .capabilities = MMC_CAP_SD_HIGHSPEED | MMC_CAP_SDIO_IRQ | 83 - MMC_CAP_CMD23, 84 - .capabilities2 = MMC_CAP2_NO_WRITE_PROTECT, 85 - .bus_shift = 2, 86 - .scc_offset = 0x1000, 87 - .taps = rcar_gen3_scc_taps, 88 - .taps_num = ARRAY_SIZE(rcar_gen3_scc_taps), 89 - }; 90 - 91 78 static const struct renesas_sdhi_of_data of_rcar_gen3_compatible = { 92 79 .tmio_flags = TMIO_MMC_HAS_IDLE_WAIT | TMIO_MMC_CLK_ACTUAL | 93 80 TMIO_MMC_HAVE_CBSY | TMIO_MMC_MIN_RCAR2, ··· 101 114 { .compatible = "renesas,sdhi-r8a7792", .data = &of_rcar_gen2_compatible, }, 102 115 { .compatible = "renesas,sdhi-r8a7793", .data = &of_rcar_gen2_compatible, }, 103 116 { .compatible = "renesas,sdhi-r8a7794", .data = &of_rcar_gen2_compatible, }, 104 - { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_r8a7795_compatible, }, 105 - { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_r8a7795_compatible, }, 117 + { .compatible = "renesas,sdhi-r8a7795", .data = &of_rcar_gen3_compatible, }, 118 + { .compatible = "renesas,sdhi-r8a7796", .data = &of_rcar_gen3_compatible, }, 106 119 { .compatible = "renesas,rcar-gen1-sdhi", .data = &of_rcar_gen1_compatible, }, 107 120 { .compatible = "renesas,rcar-gen2-sdhi", .data = &of_rcar_gen2_compatible, }, 108 121 { .compatible = "renesas,rcar-gen3-sdhi", .data = &of_rcar_gen3_compatible, }, ··· 480 493 481 494 static int renesas_sdhi_sys_dmac_probe(struct platform_device *pdev) 482 495 { 483 - if ((of_device_get_match_data(&pdev->dev) == &of_rcar_gen3_compatible || 484 - of_device_get_match_data(&pdev->dev) == &of_rcar_r8a7795_compatible) && 496 + if (of_device_get_match_data(&pdev->dev) == &of_rcar_gen3_compatible && 485 497 !soc_device_match(gen3_soc_whitelist)) 486 498 return -ENODEV; 487 499
+36 -8
drivers/mmc/host/rtsx_usb_sdmmc.c
··· 28 28 #include <linux/mmc/sd.h> 29 29 #include <linux/mmc/card.h> 30 30 #include <linux/scatterlist.h> 31 + #include <linux/pm.h> 31 32 #include <linux/pm_runtime.h> 32 33 33 34 #include <linux/rtsx_usb.h> ··· 1043 1042 1044 1043 if (power_mode == MMC_POWER_OFF) { 1045 1044 err = sd_power_off(host); 1046 - pm_runtime_put(sdmmc_dev(host)); 1045 + pm_runtime_put_noidle(sdmmc_dev(host)); 1047 1046 } else { 1048 - pm_runtime_get_sync(sdmmc_dev(host)); 1047 + pm_runtime_get_noresume(sdmmc_dev(host)); 1049 1048 err = sd_power_on(host); 1050 1049 } 1051 1050 ··· 1298 1297 container_of(work, struct rtsx_usb_sdmmc, led_work); 1299 1298 struct rtsx_ucr *ucr = host->ucr; 1300 1299 1301 - pm_runtime_get_sync(sdmmc_dev(host)); 1300 + pm_runtime_get_noresume(sdmmc_dev(host)); 1302 1301 mutex_lock(&ucr->dev_mutex); 1302 + 1303 + if (host->power_mode == MMC_POWER_OFF) 1304 + goto out; 1303 1305 1304 1306 if (host->led.brightness == LED_OFF) 1305 1307 rtsx_usb_turn_off_led(ucr); 1306 1308 else 1307 1309 rtsx_usb_turn_on_led(ucr); 1308 1310 1311 + out: 1309 1312 mutex_unlock(&ucr->dev_mutex); 1310 - pm_runtime_put(sdmmc_dev(host)); 1313 + pm_runtime_put_sync_suspend(sdmmc_dev(host)); 1311 1314 } 1312 1315 #endif 1313 1316 ··· 1325 1320 mmc->caps = MMC_CAP_4_BIT_DATA | MMC_CAP_SD_HIGHSPEED | 1326 1321 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_BUS_WIDTH_TEST | 1327 1322 MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | MMC_CAP_UHS_SDR50 | 1328 - MMC_CAP_NEEDS_POLL | MMC_CAP_ERASE; 1323 + MMC_CAP_ERASE | MMC_CAP_SYNC_RUNTIME_PM; 1329 1324 mmc->caps2 = MMC_CAP2_NO_PRESCAN_POWERUP | MMC_CAP2_FULL_PWR_CYCLE | 1330 1325 MMC_CAP2_NO_SDIO; 1331 1326 ··· 1368 1363 1369 1364 mutex_init(&host->host_mutex); 1370 1365 rtsx_usb_init_host(host); 1371 - pm_runtime_use_autosuspend(&pdev->dev); 1372 - pm_runtime_set_autosuspend_delay(&pdev->dev, 50); 1373 1366 pm_runtime_enable(&pdev->dev); 1374 1367 1375 1368 #ifdef RTSX_USB_USE_LEDS_CLASS ··· 1422 1419 1423 1420 mmc_free_host(mmc); 1424 1421 pm_runtime_disable(&pdev->dev); 1425 - pm_runtime_dont_use_autosuspend(&pdev->dev); 1426 1422 platform_set_drvdata(pdev, NULL); 1427 1423 1428 1424 dev_dbg(&(pdev->dev), ··· 1429 1427 1430 1428 return 0; 1431 1429 } 1430 + 1431 + #ifdef CONFIG_PM 1432 + static int rtsx_usb_sdmmc_runtime_suspend(struct device *dev) 1433 + { 1434 + struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev); 1435 + 1436 + host->mmc->caps &= ~MMC_CAP_NEEDS_POLL; 1437 + return 0; 1438 + } 1439 + 1440 + static int rtsx_usb_sdmmc_runtime_resume(struct device *dev) 1441 + { 1442 + struct rtsx_usb_sdmmc *host = dev_get_drvdata(dev); 1443 + 1444 + host->mmc->caps |= MMC_CAP_NEEDS_POLL; 1445 + if (sdmmc_get_cd(host->mmc) == 1) 1446 + mmc_detect_change(host->mmc, 0); 1447 + return 0; 1448 + } 1449 + #endif 1450 + 1451 + static const struct dev_pm_ops rtsx_usb_sdmmc_dev_pm_ops = { 1452 + SET_RUNTIME_PM_OPS(rtsx_usb_sdmmc_runtime_suspend, 1453 + rtsx_usb_sdmmc_runtime_resume, NULL) 1454 + }; 1432 1455 1433 1456 static const struct platform_device_id rtsx_usb_sdmmc_ids[] = { 1434 1457 { ··· 1470 1443 .id_table = rtsx_usb_sdmmc_ids, 1471 1444 .driver = { 1472 1445 .name = "rtsx_usb_sdmmc", 1446 + .pm = &rtsx_usb_sdmmc_dev_pm_ops, 1473 1447 }, 1474 1448 }; 1475 1449 module_platform_driver(rtsx_usb_sdmmc_driver);
+15 -44
drivers/mmc/host/s3cmci.c
··· 26 26 #include <linux/io.h> 27 27 #include <linux/of.h> 28 28 #include <linux/of_device.h> 29 - #include <linux/of_gpio.h> 30 29 #include <linux/mmc/slot-gpio.h> 31 30 32 31 #include <plat/gpio-cfg.h> ··· 1405 1406 return 0; 1406 1407 } 1407 1408 1408 - static int s3cmci_state_open(struct inode *inode, struct file *file) 1409 - { 1410 - return single_open(file, s3cmci_state_show, inode->i_private); 1411 - } 1412 - 1413 - static const struct file_operations s3cmci_fops_state = { 1414 - .owner = THIS_MODULE, 1415 - .open = s3cmci_state_open, 1416 - .read = seq_read, 1417 - .llseek = seq_lseek, 1418 - .release = single_release, 1419 - }; 1409 + DEFINE_SHOW_ATTRIBUTE(s3cmci_state); 1420 1410 1421 1411 #define DBG_REG(_r) { .addr = S3C2410_SDI##_r, .name = #_r } 1422 1412 ··· 1447 1459 return 0; 1448 1460 } 1449 1461 1450 - static int s3cmci_regs_open(struct inode *inode, struct file *file) 1451 - { 1452 - return single_open(file, s3cmci_regs_show, inode->i_private); 1453 - } 1454 - 1455 - static const struct file_operations s3cmci_fops_regs = { 1456 - .owner = THIS_MODULE, 1457 - .open = s3cmci_regs_open, 1458 - .read = seq_read, 1459 - .llseek = seq_lseek, 1460 - .release = single_release, 1461 - }; 1462 + DEFINE_SHOW_ATTRIBUTE(s3cmci_regs); 1462 1463 1463 1464 static void s3cmci_debugfs_attach(struct s3cmci_host *host) 1464 1465 { ··· 1461 1484 1462 1485 host->debug_state = debugfs_create_file("state", 0444, 1463 1486 host->debug_root, host, 1464 - &s3cmci_fops_state); 1487 + &s3cmci_state_fops); 1465 1488 1466 1489 if (IS_ERR(host->debug_state)) 1467 1490 dev_err(dev, "failed to create debug state file\n"); 1468 1491 1469 1492 host->debug_regs = debugfs_create_file("regs", 0444, 1470 1493 host->debug_root, host, 1471 - &s3cmci_fops_regs); 1494 + &s3cmci_regs_fops); 1472 1495 1473 1496 if (IS_ERR(host->debug_regs)) 1474 1497 dev_err(dev, "failed to create debug regs file\n"); ··· 1522 1545 if (pdata->wprotect_invert) 1523 1546 mmc->caps2 |= MMC_CAP2_RO_ACTIVE_HIGH; 1524 1547 1525 - if (pdata->detect_invert) 1526 - mmc->caps2 |= MMC_CAP2_CD_ACTIVE_HIGH; 1527 - 1528 - if (gpio_is_valid(pdata->gpio_detect)) { 1529 - ret = mmc_gpio_request_cd(mmc, pdata->gpio_detect, 0); 1530 - if (ret) { 1531 - dev_err(&pdev->dev, "error requesting GPIO for CD %d\n", 1532 - ret); 1533 - return ret; 1534 - } 1548 + /* If we get -ENOENT we have no card detect GPIO line */ 1549 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); 1550 + if (ret != -ENOENT) { 1551 + dev_err(&pdev->dev, "error requesting GPIO for CD %d\n", 1552 + ret); 1553 + return ret; 1535 1554 } 1536 1555 1537 - if (gpio_is_valid(pdata->gpio_wprotect)) { 1538 - ret = mmc_gpio_request_ro(mmc, pdata->gpio_wprotect); 1539 - if (ret) { 1540 - dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", 1541 - ret); 1542 - return ret; 1543 - } 1556 + ret = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL); 1557 + if (ret != -ENOENT) { 1558 + dev_err(&pdev->dev, "error requesting GPIO for WP %d\n", 1559 + ret); 1560 + return ret; 1544 1561 } 1545 1562 1546 1563 return 0;
+5 -2
drivers/mmc/host/sdhci-acpi.c
··· 437 437 MMC_CAP_HW_RESET | MMC_CAP_1_8V_DDR | 438 438 MMC_CAP_CMD_DURING_TFR | MMC_CAP_WAIT_WHILE_BUSY, 439 439 .flags = SDHCI_ACPI_RUNTIME_PM, 440 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 440 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 441 + SDHCI_QUIRK_NO_LED, 441 442 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 442 443 SDHCI_QUIRK2_STOP_WITH_TC | 443 444 SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400, ··· 449 448 450 449 static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sdio = { 451 450 .quirks = SDHCI_QUIRK_BROKEN_CARD_DETECTION | 451 + SDHCI_QUIRK_NO_LED | 452 452 SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 453 453 .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON, 454 454 .caps = MMC_CAP_NONREMOVABLE | MMC_CAP_POWER_OFF_CARD | ··· 464 462 static const struct sdhci_acpi_slot sdhci_acpi_slot_int_sd = { 465 463 .flags = SDHCI_ACPI_SD_CD | SDHCI_ACPI_SD_CD_OVERRIDE_LEVEL | 466 464 SDHCI_ACPI_RUNTIME_PM, 467 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 465 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 466 + SDHCI_QUIRK_NO_LED, 468 467 .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON | 469 468 SDHCI_QUIRK2_STOP_WITH_TC, 470 469 .caps = MMC_CAP_WAIT_WHILE_BUSY | MMC_CAP_AGGRESSIVE_PM,
+1 -1
drivers/mmc/host/sdhci-cadence.c
··· 14 14 */ 15 15 16 16 #include <linux/bitfield.h> 17 - #include <linux/bitops.h> 17 + #include <linux/bits.h> 18 18 #include <linux/iopoll.h> 19 19 #include <linux/module.h> 20 20 #include <linux/mmc/host.h>
+14 -12
drivers/mmc/host/sdhci-esdhc-imx.c
··· 12 12 #include <linux/delay.h> 13 13 #include <linux/err.h> 14 14 #include <linux/clk.h> 15 - #include <linux/gpio.h> 16 15 #include <linux/module.h> 17 16 #include <linux/slab.h> 18 17 #include <linux/mmc/host.h> ··· 20 21 #include <linux/mmc/slot-gpio.h> 21 22 #include <linux/of.h> 22 23 #include <linux/of_device.h> 23 - #include <linux/of_gpio.h> 24 24 #include <linux/pinctrl/consumer.h> 25 25 #include <linux/platform_data/mmc-esdhc-imx.h> 26 26 #include <linux/pm_runtime.h> ··· 427 429 val = readl(host->ioaddr + ESDHC_MIX_CTRL); 428 430 else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) 429 431 /* the std tuning bits is in ACMD12_ERR for imx6sl */ 430 - val = readl(host->ioaddr + SDHCI_ACMD12_ERR); 432 + val = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); 431 433 } 432 434 433 435 if (val & ESDHC_MIX_CTRL_EXE_TUNE) ··· 492 494 } 493 495 writel(new_val , host->ioaddr + ESDHC_MIX_CTRL); 494 496 } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { 495 - u32 v = readl(host->ioaddr + SDHCI_ACMD12_ERR); 497 + u32 v = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); 496 498 u32 m = readl(host->ioaddr + ESDHC_MIX_CTRL); 497 499 if (val & SDHCI_CTRL_TUNED_CLK) { 498 500 v |= ESDHC_MIX_CTRL_SMPCLK_SEL; ··· 510 512 v &= ~ESDHC_MIX_CTRL_EXE_TUNE; 511 513 } 512 514 513 - writel(v, host->ioaddr + SDHCI_ACMD12_ERR); 515 + writel(v, host->ioaddr + SDHCI_AUTO_CMD_STATUS); 514 516 writel(m, host->ioaddr + ESDHC_MIX_CTRL); 515 517 } 516 518 return; ··· 955 957 writel(ctrl, host->ioaddr + ESDHC_MIX_CTRL); 956 958 writel(0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 957 959 } else if (imx_data->socdata->flags & ESDHC_FLAG_STD_TUNING) { 958 - ctrl = readl(host->ioaddr + SDHCI_ACMD12_ERR); 960 + ctrl = readl(host->ioaddr + SDHCI_AUTO_CMD_STATUS); 959 961 ctrl &= ~ESDHC_MIX_CTRL_SMPCLK_SEL; 960 - writel(ctrl, host->ioaddr + SDHCI_ACMD12_ERR); 962 + writel(ctrl, host->ioaddr + SDHCI_AUTO_CMD_STATUS); 961 963 } 962 964 } 963 965 } ··· 1137 1139 if (of_get_property(np, "fsl,wp-controller", NULL)) 1138 1140 boarddata->wp_type = ESDHC_WP_CONTROLLER; 1139 1141 1140 - boarddata->wp_gpio = of_get_named_gpio(np, "wp-gpios", 0); 1141 - if (gpio_is_valid(boarddata->wp_gpio)) 1142 + /* 1143 + * If we have this property, then activate WP check. 1144 + * Retrieveing and requesting the actual WP GPIO will happen 1145 + * in the call to mmc_of_parse(). 1146 + */ 1147 + if (of_property_read_bool(np, "wp-gpios")) 1142 1148 boarddata->wp_type = ESDHC_WP_GPIO; 1143 1149 1144 1150 of_property_read_u32(np, "fsl,tuning-step", &boarddata->tuning_step); ··· 1200 1198 host->mmc->parent->platform_data); 1201 1199 /* write_protect */ 1202 1200 if (boarddata->wp_type == ESDHC_WP_GPIO) { 1203 - err = mmc_gpio_request_ro(host->mmc, boarddata->wp_gpio); 1201 + err = mmc_gpiod_request_ro(host->mmc, "wp", 0, false, 0, NULL); 1204 1202 if (err) { 1205 1203 dev_err(mmc_dev(host->mmc), 1206 1204 "failed to request write-protect gpio!\n"); ··· 1212 1210 /* card_detect */ 1213 1211 switch (boarddata->cd_type) { 1214 1212 case ESDHC_CD_GPIO: 1215 - err = mmc_gpio_request_cd(host->mmc, boarddata->cd_gpio, 0); 1213 + err = mmc_gpiod_request_cd(host->mmc, "cd", 0, false, 0, NULL); 1216 1214 if (err) { 1217 1215 dev_err(mmc_dev(host->mmc), 1218 1216 "failed to request card-detect gpio!\n"); ··· 1319 1317 1320 1318 /* clear tuning bits in case ROM has set it already */ 1321 1319 writel(0x0, host->ioaddr + ESDHC_MIX_CTRL); 1322 - writel(0x0, host->ioaddr + SDHCI_ACMD12_ERR); 1320 + writel(0x0, host->ioaddr + SDHCI_AUTO_CMD_STATUS); 1323 1321 writel(0x0, host->ioaddr + ESDHC_TUNE_CTRL_STATUS); 1324 1322 } 1325 1323
+24
drivers/mmc/host/sdhci-esdhc.h
··· 59 59 60 60 /* Tuning Block Control Register */ 61 61 #define ESDHC_TBCTL 0x120 62 + #define ESDHC_HS400_WNDW_ADJUST 0x00000040 63 + #define ESDHC_HS400_MODE 0x00000010 62 64 #define ESDHC_TB_EN 0x00000004 63 65 #define ESDHC_TBPTR 0x128 66 + 67 + /* SD Clock Control Register */ 68 + #define ESDHC_SDCLKCTL 0x144 69 + #define ESDHC_LPBK_CLK_SEL 0x80000000 70 + #define ESDHC_CMD_CLK_CTL 0x00008000 71 + 72 + /* SD Timing Control Register */ 73 + #define ESDHC_SDTIMNGCTL 0x148 74 + #define ESDHC_FLW_CTL_BG 0x00008000 75 + 76 + /* DLL Config 0 Register */ 77 + #define ESDHC_DLLCFG0 0x160 78 + #define ESDHC_DLL_ENABLE 0x80000000 79 + #define ESDHC_DLL_FREQ_SEL 0x08000000 80 + 81 + /* DLL Config 1 Register */ 82 + #define ESDHC_DLLCFG1 0x164 83 + #define ESDHC_DLL_PD_PULSE_STRETCH_SEL 0x80000000 84 + 85 + /* DLL Status 0 Register */ 86 + #define ESDHC_DLLSTAT0 0x170 87 + #define ESDHC_DLL_STS_SLV_LOCK 0x08000000 64 88 65 89 /* Control Register for DMA transfer */ 66 90 #define ESDHC_DMA_SYSCTL 0x40c
+111 -15
drivers/mmc/host/sdhci-msm.c
··· 232 232 */ 233 233 struct sdhci_msm_variant_info { 234 234 bool mci_removed; 235 + bool restore_dll_config; 235 236 const struct sdhci_msm_variant_ops *var_ops; 236 237 const struct sdhci_msm_offset *offset; 237 238 }; ··· 257 256 bool pwr_irq_flag; 258 257 u32 caps_0; 259 258 bool mci_removed; 259 + bool restore_dll_config; 260 260 const struct sdhci_msm_variant_ops *var_ops; 261 261 const struct sdhci_msm_offset *offset; 262 + bool use_cdr; 263 + u32 transfer_mode; 262 264 }; 263 265 264 266 static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct sdhci_host *host) ··· 1029 1025 return ret; 1030 1026 } 1031 1027 1028 + static bool sdhci_msm_is_tuning_needed(struct sdhci_host *host) 1029 + { 1030 + struct mmc_ios *ios = &host->mmc->ios; 1031 + 1032 + /* 1033 + * Tuning is required for SDR104, HS200 and HS400 cards and 1034 + * if clock frequency is greater than 100MHz in these modes. 1035 + */ 1036 + if (host->clock <= CORE_FREQ_100MHZ || 1037 + !(ios->timing == MMC_TIMING_MMC_HS400 || 1038 + ios->timing == MMC_TIMING_MMC_HS200 || 1039 + ios->timing == MMC_TIMING_UHS_SDR104) || 1040 + ios->enhanced_strobe) 1041 + return false; 1042 + 1043 + return true; 1044 + } 1045 + 1046 + static int sdhci_msm_restore_sdr_dll_config(struct sdhci_host *host) 1047 + { 1048 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1049 + struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); 1050 + int ret; 1051 + 1052 + /* 1053 + * SDR DLL comes into picture only for timing modes which needs 1054 + * tuning. 1055 + */ 1056 + if (!sdhci_msm_is_tuning_needed(host)) 1057 + return 0; 1058 + 1059 + /* Reset the tuning block */ 1060 + ret = msm_init_cm_dll(host); 1061 + if (ret) 1062 + return ret; 1063 + 1064 + /* Restore the tuning block */ 1065 + ret = msm_config_cm_dll_phase(host, msm_host->saved_tuning_phase); 1066 + 1067 + return ret; 1068 + } 1069 + 1070 + static void sdhci_msm_set_cdr(struct sdhci_host *host, bool enable) 1071 + { 1072 + const struct sdhci_msm_offset *msm_offset = sdhci_priv_msm_offset(host); 1073 + u32 config, oldconfig = readl_relaxed(host->ioaddr + 1074 + msm_offset->core_dll_config); 1075 + 1076 + config = oldconfig; 1077 + if (enable) { 1078 + config |= CORE_CDR_EN; 1079 + config &= ~CORE_CDR_EXT_EN; 1080 + } else { 1081 + config &= ~CORE_CDR_EN; 1082 + config |= CORE_CDR_EXT_EN; 1083 + } 1084 + 1085 + if (config != oldconfig) { 1086 + writel_relaxed(config, host->ioaddr + 1087 + msm_offset->core_dll_config); 1088 + } 1089 + } 1090 + 1032 1091 static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode) 1033 1092 { 1034 1093 struct sdhci_host *host = mmc_priv(mmc); ··· 1102 1035 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 1103 1036 struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); 1104 1037 1105 - /* 1106 - * Tuning is required for SDR104, HS200 and HS400 cards and 1107 - * if clock frequency is greater than 100MHz in these modes. 1108 - */ 1109 - if (host->clock <= CORE_FREQ_100MHZ || 1110 - !(ios.timing == MMC_TIMING_MMC_HS400 || 1111 - ios.timing == MMC_TIMING_MMC_HS200 || 1112 - ios.timing == MMC_TIMING_UHS_SDR104)) 1038 + if (!sdhci_msm_is_tuning_needed(host)) { 1039 + msm_host->use_cdr = false; 1040 + sdhci_msm_set_cdr(host, false); 1113 1041 return 0; 1042 + } 1043 + 1044 + /* Clock-Data-Recovery used to dynamically adjust RX sampling point */ 1045 + msm_host->use_cdr = true; 1114 1046 1115 1047 /* 1116 1048 * For HS400 tuning in HS200 timing requires: ··· 1135 1069 if (rc) 1136 1070 return rc; 1137 1071 1138 - msm_host->saved_tuning_phase = phase; 1139 1072 rc = mmc_send_tuning(mmc, opcode, NULL); 1140 1073 if (!rc) { 1141 1074 /* Tuning is successful at this tuning point */ ··· 1159 1094 rc = msm_config_cm_dll_phase(host, phase); 1160 1095 if (rc) 1161 1096 return rc; 1097 + msm_host->saved_tuning_phase = phase; 1162 1098 dev_dbg(mmc_dev(mmc), "%s: Setting the tuning phase to %d\n", 1163 1099 mmc_hostname(mmc), phase); 1164 1100 } else { ··· 1591 1525 case SDHCI_POWER_CONTROL: 1592 1526 req_type = !val ? REQ_BUS_OFF : REQ_BUS_ON; 1593 1527 break; 1528 + case SDHCI_TRANSFER_MODE: 1529 + msm_host->transfer_mode = val; 1530 + break; 1531 + case SDHCI_COMMAND: 1532 + if (!msm_host->use_cdr) 1533 + break; 1534 + if ((msm_host->transfer_mode & SDHCI_TRNS_READ) && 1535 + SDHCI_GET_CMD(val) != MMC_SEND_TUNING_BLOCK_HS200 && 1536 + SDHCI_GET_CMD(val) != MMC_SEND_TUNING_BLOCK) 1537 + sdhci_msm_set_cdr(host, true); 1538 + else 1539 + sdhci_msm_set_cdr(host, false); 1540 + break; 1594 1541 } 1595 1542 1596 1543 if (req_type) { ··· 1695 1616 }; 1696 1617 1697 1618 static const struct sdhci_msm_variant_info sdhci_msm_mci_var = { 1698 - .mci_removed = false, 1699 1619 .var_ops = &mci_var_ops, 1700 1620 .offset = &sdhci_msm_mci_offset, 1701 1621 }; ··· 1705 1627 .offset = &sdhci_msm_v5_offset, 1706 1628 }; 1707 1629 1630 + static const struct sdhci_msm_variant_info sdm845_sdhci_var = { 1631 + .mci_removed = true, 1632 + .restore_dll_config = true, 1633 + .var_ops = &v5_var_ops, 1634 + .offset = &sdhci_msm_v5_offset, 1635 + }; 1636 + 1708 1637 static const struct of_device_id sdhci_msm_dt_match[] = { 1709 1638 {.compatible = "qcom,sdhci-msm-v4", .data = &sdhci_msm_mci_var}, 1710 1639 {.compatible = "qcom,sdhci-msm-v5", .data = &sdhci_msm_v5_var}, 1640 + {.compatible = "qcom,sdm845-sdhci", .data = &sdm845_sdhci_var}, 1711 1641 {}, 1712 1642 }; 1713 1643 ··· 1775 1689 var_info = of_device_get_match_data(&pdev->dev); 1776 1690 1777 1691 msm_host->mci_removed = var_info->mci_removed; 1692 + msm_host->restore_dll_config = var_info->restore_dll_config; 1778 1693 msm_host->var_ops = var_info->var_ops; 1779 1694 msm_host->offset = var_info->offset; 1780 1695 ··· 1997 1910 return 0; 1998 1911 } 1999 1912 2000 - #ifdef CONFIG_PM 2001 - static int sdhci_msm_runtime_suspend(struct device *dev) 1913 + static __maybe_unused int sdhci_msm_runtime_suspend(struct device *dev) 2002 1914 { 2003 1915 struct sdhci_host *host = dev_get_drvdata(dev); 2004 1916 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 2009 1923 return 0; 2010 1924 } 2011 1925 2012 - static int sdhci_msm_runtime_resume(struct device *dev) 1926 + static __maybe_unused int sdhci_msm_runtime_resume(struct device *dev) 2013 1927 { 2014 1928 struct sdhci_host *host = dev_get_drvdata(dev); 2015 1929 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 2016 1930 struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); 1931 + int ret; 2017 1932 2018 - return clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), 1933 + ret = clk_bulk_prepare_enable(ARRAY_SIZE(msm_host->bulk_clks), 2019 1934 msm_host->bulk_clks); 1935 + if (ret) 1936 + return ret; 1937 + /* 1938 + * Whenever core-clock is gated dynamically, it's needed to 1939 + * restore the SDR DLL settings when the clock is ungated. 1940 + */ 1941 + if (msm_host->restore_dll_config && msm_host->clk_rate) 1942 + return sdhci_msm_restore_sdr_dll_config(host); 1943 + 1944 + return 0; 2020 1945 } 2021 - #endif 2022 1946 2023 1947 static const struct dev_pm_ops sdhci_msm_pm_ops = { 2024 1948 SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend,
-46
drivers/mmc/host/sdhci-of-arasan.c
··· 231 231 } 232 232 } 233 233 234 - static void sdhci_arasan_am654_set_clock(struct sdhci_host *host, 235 - unsigned int clock) 236 - { 237 - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 238 - struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host); 239 - 240 - if (sdhci_arasan->is_phy_on) { 241 - phy_power_off(sdhci_arasan->phy); 242 - sdhci_arasan->is_phy_on = false; 243 - } 244 - 245 - sdhci_set_clock(host, clock); 246 - 247 - if (clock > PHY_CLK_TOO_SLOW_HZ) { 248 - phy_power_on(sdhci_arasan->phy); 249 - sdhci_arasan->is_phy_on = true; 250 - } 251 - } 252 - 253 234 static void sdhci_arasan_hs400_enhanced_strobe(struct mmc_host *mmc, 254 235 struct mmc_ios *ios) 255 236 { ··· 314 333 315 334 static struct sdhci_arasan_of_data sdhci_arasan_data = { 316 335 .pdata = &sdhci_arasan_pdata, 317 - }; 318 - 319 - static const struct sdhci_ops sdhci_arasan_am654_ops = { 320 - .set_clock = sdhci_arasan_am654_set_clock, 321 - .get_max_clock = sdhci_pltfm_clk_get_max_clock, 322 - .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, 323 - .set_bus_width = sdhci_set_bus_width, 324 - .reset = sdhci_arasan_reset, 325 - .set_uhs_signaling = sdhci_set_uhs_signaling, 326 - }; 327 - 328 - static const struct sdhci_pltfm_data sdhci_arasan_am654_pdata = { 329 - .ops = &sdhci_arasan_am654_ops, 330 - .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN | 331 - SDHCI_QUIRK_INVERTED_WRITE_PROTECT | 332 - SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12, 333 - .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 334 - SDHCI_QUIRK2_CLOCK_DIV_ZERO_BROKEN | 335 - SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400, 336 - }; 337 - 338 - static const struct sdhci_arasan_of_data sdhci_arasan_am654_data = { 339 - .pdata = &sdhci_arasan_am654_pdata, 340 336 }; 341 337 342 338 static u32 sdhci_arasan_cqhci_irq(struct sdhci_host *host, u32 intmask) ··· 477 519 { 478 520 .compatible = "rockchip,rk3399-sdhci-5.1", 479 521 .data = &sdhci_arasan_rk3399_data, 480 - }, 481 - { 482 - .compatible = "ti,am654-sdhci-5.1", 483 - .data = &sdhci_arasan_am654_data, 484 522 }, 485 523 /* Generic compatible below here */ 486 524 {
+138 -15
drivers/mmc/host/sdhci-of-esdhc.c
··· 78 78 u8 vendor_ver; 79 79 u8 spec_ver; 80 80 bool quirk_incorrect_hostver; 81 + bool quirk_limited_clk_division; 82 + bool quirk_unreliable_pulse_detection; 81 83 bool quirk_fixup_tuning; 82 84 unsigned int peripheral_clock; 83 85 const struct esdhc_clk_fixup *clk_fixup; ··· 530 528 /* Wait max 20 ms */ 531 529 timeout = ktime_add_ms(ktime_get(), 20); 532 530 val = ESDHC_CLOCK_STABLE; 533 - while (!(sdhci_readl(host, ESDHC_PRSSTAT) & val)) { 534 - if (ktime_after(ktime_get(), timeout)) { 531 + while (1) { 532 + bool timedout = ktime_after(ktime_get(), timeout); 533 + 534 + if (sdhci_readl(host, ESDHC_PRSSTAT) & val) 535 + break; 536 + if (timedout) { 535 537 pr_err("%s: Internal clock never stabilised.\n", 536 538 mmc_hostname(host->mmc)); 537 539 break; ··· 550 544 struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 551 545 int pre_div = 1; 552 546 int div = 1; 547 + int division; 553 548 ktime_t timeout; 554 549 long fixup = 0; 555 550 u32 temp; ··· 586 579 while (host->max_clk / pre_div / div > clock && div < 16) 587 580 div++; 588 581 582 + if (esdhc->quirk_limited_clk_division && 583 + clock == MMC_HS200_MAX_DTR && 584 + (host->mmc->ios.timing == MMC_TIMING_MMC_HS400 || 585 + host->flags & SDHCI_HS400_TUNING)) { 586 + division = pre_div * div; 587 + if (division <= 4) { 588 + pre_div = 4; 589 + div = 1; 590 + } else if (division <= 8) { 591 + pre_div = 4; 592 + div = 2; 593 + } else if (division <= 12) { 594 + pre_div = 4; 595 + div = 3; 596 + } else { 597 + pr_warn("%s: using unsupported clock division.\n", 598 + mmc_hostname(host->mmc)); 599 + } 600 + } 601 + 589 602 dev_dbg(mmc_dev(host->mmc), "desired SD clock: %d, actual: %d\n", 590 603 clock, host->max_clk / pre_div / div); 591 604 host->mmc->actual_clock = host->max_clk / pre_div / div; ··· 619 592 | (pre_div << ESDHC_PREDIV_SHIFT)); 620 593 sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL); 621 594 595 + if (host->mmc->ios.timing == MMC_TIMING_MMC_HS400 && 596 + clock == MMC_HS200_MAX_DTR) { 597 + temp = sdhci_readl(host, ESDHC_TBCTL); 598 + sdhci_writel(host, temp | ESDHC_HS400_MODE, ESDHC_TBCTL); 599 + temp = sdhci_readl(host, ESDHC_SDCLKCTL); 600 + sdhci_writel(host, temp | ESDHC_CMD_CLK_CTL, ESDHC_SDCLKCTL); 601 + esdhc_clock_enable(host, true); 602 + 603 + temp = sdhci_readl(host, ESDHC_DLLCFG0); 604 + temp |= ESDHC_DLL_ENABLE; 605 + if (host->mmc->actual_clock == MMC_HS200_MAX_DTR) 606 + temp |= ESDHC_DLL_FREQ_SEL; 607 + sdhci_writel(host, temp, ESDHC_DLLCFG0); 608 + temp = sdhci_readl(host, ESDHC_TBCTL); 609 + sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL); 610 + 611 + esdhc_clock_enable(host, false); 612 + temp = sdhci_readl(host, ESDHC_DMA_SYSCTL); 613 + temp |= ESDHC_FLUSH_ASYNC_FIFO; 614 + sdhci_writel(host, temp, ESDHC_DMA_SYSCTL); 615 + } 616 + 622 617 /* Wait max 20 ms */ 623 618 timeout = ktime_add_ms(ktime_get(), 20); 624 - while (!(sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE)) { 625 - if (ktime_after(ktime_get(), timeout)) { 619 + while (1) { 620 + bool timedout = ktime_after(ktime_get(), timeout); 621 + 622 + if (sdhci_readl(host, ESDHC_PRSSTAT) & ESDHC_CLOCK_STABLE) 623 + break; 624 + if (timedout) { 626 625 pr_err("%s: Internal clock never stabilised.\n", 627 626 mmc_hostname(host->mmc)); 628 627 return; ··· 656 603 udelay(10); 657 604 } 658 605 606 + temp = sdhci_readl(host, ESDHC_SYSTEM_CONTROL); 659 607 temp |= ESDHC_CLOCK_SDCLKEN; 660 608 sdhci_writel(host, temp, ESDHC_SYSTEM_CONTROL); 661 609 } ··· 685 631 686 632 static void esdhc_reset(struct sdhci_host *host, u8 mask) 687 633 { 634 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 635 + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 688 636 u32 val; 689 637 690 638 sdhci_reset(host, mask); ··· 698 642 val = sdhci_readl(host, ESDHC_TBCTL); 699 643 val &= ~ESDHC_TB_EN; 700 644 sdhci_writel(host, val, ESDHC_TBCTL); 645 + 646 + if (esdhc->quirk_unreliable_pulse_detection) { 647 + val = sdhci_readl(host, ESDHC_DLLCFG1); 648 + val &= ~ESDHC_DLL_PD_PULSE_STRETCH_SEL; 649 + sdhci_writel(host, val, ESDHC_DLLCFG1); 650 + } 701 651 } 702 652 } 703 653 ··· 790 728 { }, 791 729 }; 792 730 793 - static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) 731 + static void esdhc_tuning_block_enable(struct sdhci_host *host, bool enable) 794 732 { 795 - struct sdhci_host *host = mmc_priv(mmc); 796 - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 797 - struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 798 733 u32 val; 799 734 800 - /* Use tuning block for tuning procedure */ 801 735 esdhc_clock_enable(host, false); 736 + 802 737 val = sdhci_readl(host, ESDHC_DMA_SYSCTL); 803 738 val |= ESDHC_FLUSH_ASYNC_FIFO; 804 739 sdhci_writel(host, val, ESDHC_DMA_SYSCTL); 805 740 806 741 val = sdhci_readl(host, ESDHC_TBCTL); 807 - val |= ESDHC_TB_EN; 742 + if (enable) 743 + val |= ESDHC_TB_EN; 744 + else 745 + val &= ~ESDHC_TB_EN; 808 746 sdhci_writel(host, val, ESDHC_TBCTL); 809 - esdhc_clock_enable(host, true); 810 747 811 - sdhci_execute_tuning(mmc, opcode); 748 + esdhc_clock_enable(host, true); 749 + } 750 + 751 + static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) 752 + { 753 + struct sdhci_host *host = mmc_priv(mmc); 754 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 755 + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 756 + bool hs400_tuning; 757 + u32 val; 758 + int ret; 759 + 760 + if (esdhc->quirk_limited_clk_division && 761 + host->flags & SDHCI_HS400_TUNING) 762 + esdhc_of_set_clock(host, host->clock); 763 + 764 + esdhc_tuning_block_enable(host, true); 765 + 766 + hs400_tuning = host->flags & SDHCI_HS400_TUNING; 767 + ret = sdhci_execute_tuning(mmc, opcode); 768 + 769 + if (hs400_tuning) { 770 + val = sdhci_readl(host, ESDHC_SDTIMNGCTL); 771 + val |= ESDHC_FLW_CTL_BG; 772 + sdhci_writel(host, val, ESDHC_SDTIMNGCTL); 773 + } 774 + 812 775 if (host->tuning_err == -EAGAIN && esdhc->quirk_fixup_tuning) { 813 776 814 777 /* program TBPTR[TB_WNDW_END_PTR] = 3*DIV_RATIO and ··· 852 765 sdhci_writel(host, val, ESDHC_TBCTL); 853 766 sdhci_execute_tuning(mmc, opcode); 854 767 } 855 - return 0; 768 + return ret; 769 + } 770 + 771 + static void esdhc_set_uhs_signaling(struct sdhci_host *host, 772 + unsigned int timing) 773 + { 774 + if (timing == MMC_TIMING_MMC_HS400) 775 + esdhc_tuning_block_enable(host, true); 776 + else 777 + sdhci_set_uhs_signaling(host, timing); 856 778 } 857 779 858 780 #ifdef CONFIG_PM_SLEEP ··· 910 814 .adma_workaround = esdhc_of_adma_workaround, 911 815 .set_bus_width = esdhc_pltfm_set_bus_width, 912 816 .reset = esdhc_reset, 913 - .set_uhs_signaling = sdhci_set_uhs_signaling, 817 + .set_uhs_signaling = esdhc_set_uhs_signaling, 914 818 }; 915 819 916 820 static const struct sdhci_ops sdhci_esdhc_le_ops = { ··· 927 831 .adma_workaround = esdhc_of_adma_workaround, 928 832 .set_bus_width = esdhc_pltfm_set_bus_width, 929 833 .reset = esdhc_reset, 930 - .set_uhs_signaling = sdhci_set_uhs_signaling, 834 + .set_uhs_signaling = esdhc_set_uhs_signaling, 931 835 }; 932 836 933 837 static const struct sdhci_pltfm_data sdhci_esdhc_be_pdata = { ··· 953 857 { }, 954 858 }; 955 859 860 + static struct soc_device_attribute soc_fixup_sdhc_clkdivs[] = { 861 + { .family = "QorIQ LX2160A", .revision = "1.0", }, 862 + { }, 863 + }; 864 + 865 + static struct soc_device_attribute soc_unreliable_pulse_detection[] = { 866 + { .family = "QorIQ LX2160A", .revision = "1.0", }, 867 + { }, 868 + }; 869 + 956 870 static void esdhc_init(struct platform_device *pdev, struct sdhci_host *host) 957 871 { 958 872 const struct of_device_id *match; ··· 984 878 esdhc->quirk_incorrect_hostver = true; 985 879 else 986 880 esdhc->quirk_incorrect_hostver = false; 881 + 882 + if (soc_device_match(soc_fixup_sdhc_clkdivs)) 883 + esdhc->quirk_limited_clk_division = true; 884 + else 885 + esdhc->quirk_limited_clk_division = false; 886 + 887 + if (soc_device_match(soc_unreliable_pulse_detection)) 888 + esdhc->quirk_unreliable_pulse_detection = true; 889 + else 890 + esdhc->quirk_unreliable_pulse_detection = false; 987 891 988 892 match = of_match_node(sdhci_esdhc_of_match, pdev->dev.of_node); 989 893 if (match) ··· 1025 909 } 1026 910 } 1027 911 912 + static int esdhc_hs400_prepare_ddr(struct mmc_host *mmc) 913 + { 914 + esdhc_tuning_block_enable(mmc_priv(mmc), false); 915 + return 0; 916 + } 917 + 1028 918 static int sdhci_esdhc_probe(struct platform_device *pdev) 1029 919 { 1030 920 struct sdhci_host *host; ··· 1054 932 host->mmc_host_ops.start_signal_voltage_switch = 1055 933 esdhc_signal_voltage_switch; 1056 934 host->mmc_host_ops.execute_tuning = esdhc_execute_tuning; 935 + host->mmc_host_ops.hs400_prepare_ddr = esdhc_hs400_prepare_ddr; 1057 936 host->tuning_delay = 1; 1058 937 1059 938 esdhc_init(pdev, host);
+120 -10
drivers/mmc/host/sdhci-omap.c
··· 27 27 #include <linux/regulator/consumer.h> 28 28 #include <linux/pinctrl/consumer.h> 29 29 #include <linux/sys_soc.h> 30 + #include <linux/thermal.h> 30 31 31 32 #include "sdhci-pltfm.h" 32 33 ··· 116 115 117 116 struct pinctrl *pinctrl; 118 117 struct pinctrl_state **pinctrl_state; 118 + bool is_tuning; 119 119 }; 120 120 121 121 static void sdhci_omap_start_clock(struct sdhci_omap_host *omap_host); ··· 222 220 223 221 /* wait 1ms */ 224 222 timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT); 225 - while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP)) { 226 - if (WARN_ON(ktime_after(ktime_get(), timeout))) 223 + while (1) { 224 + bool timedout = ktime_after(ktime_get(), timeout); 225 + 226 + if (sdhci_omap_readl(omap_host, SDHCI_OMAP_HCTL) & HCTL_SDBP) 227 + break; 228 + if (WARN_ON(timedout)) 227 229 return; 228 230 usleep_range(5, 10); 229 231 } ··· 291 285 struct sdhci_host *host = mmc_priv(mmc); 292 286 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 293 287 struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); 288 + struct thermal_zone_device *thermal_dev; 294 289 struct device *dev = omap_host->dev; 295 290 struct mmc_ios *ios = &mmc->ios; 296 291 u32 start_window = 0, max_window = 0; 292 + bool single_point_failure = false; 297 293 bool dcrc_was_enabled = false; 298 294 u8 cur_match, prev_match = 0; 299 295 u32 length = 0, max_len = 0; 300 296 u32 phase_delay = 0; 297 + int temperature; 301 298 int ret = 0; 302 299 u32 reg; 303 - 304 - pltfm_host = sdhci_priv(host); 305 - omap_host = sdhci_pltfm_priv(pltfm_host); 306 - dev = omap_host->dev; 300 + int i; 307 301 308 302 /* clock tuning is not needed for upto 52MHz */ 309 303 if (ios->clock <= 52000000) ··· 312 306 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_CAPA2); 313 307 if (ios->timing == MMC_TIMING_UHS_SDR50 && !(reg & CAPA2_TSDR50)) 314 308 return 0; 309 + 310 + thermal_dev = thermal_zone_get_zone_by_name("cpu_thermal"); 311 + if (IS_ERR(thermal_dev)) { 312 + dev_err(dev, "Unable to get thermal zone for tuning\n"); 313 + return PTR_ERR(thermal_dev); 314 + } 315 + 316 + ret = thermal_zone_get_temp(thermal_dev, &temperature); 317 + if (ret) 318 + return ret; 315 319 316 320 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_DLL); 317 321 reg |= DLL_SWT; ··· 338 322 dcrc_was_enabled = true; 339 323 } 340 324 325 + omap_host->is_tuning = true; 326 + 327 + /* 328 + * Stage 1: Search for a maximum pass window ignoring any 329 + * any single point failures. If the tuning value ends up 330 + * near it, move away from it in stage 2 below 331 + */ 341 332 while (phase_delay <= MAX_PHASE_DELAY) { 342 333 sdhci_omap_set_dll(omap_host, phase_delay); 343 334 ··· 352 329 if (cur_match) { 353 330 if (prev_match) { 354 331 length++; 332 + } else if (single_point_failure) { 333 + /* ignore single point failure */ 334 + length++; 355 335 } else { 356 336 start_window = phase_delay; 357 337 length = 1; 358 338 } 339 + } else { 340 + single_point_failure = prev_match; 359 341 } 360 342 361 343 if (length > max_len) { ··· 378 350 goto tuning_error; 379 351 } 380 352 353 + /* 354 + * Assign tuning value as a ratio of maximum pass window based 355 + * on temperature 356 + */ 357 + if (temperature < -20000) 358 + phase_delay = min(max_window + 4 * max_len - 24, 359 + max_window + 360 + DIV_ROUND_UP(13 * max_len, 16) * 4); 361 + else if (temperature < 20000) 362 + phase_delay = max_window + DIV_ROUND_UP(9 * max_len, 16) * 4; 363 + else if (temperature < 40000) 364 + phase_delay = max_window + DIV_ROUND_UP(8 * max_len, 16) * 4; 365 + else if (temperature < 70000) 366 + phase_delay = max_window + DIV_ROUND_UP(7 * max_len, 16) * 4; 367 + else if (temperature < 90000) 368 + phase_delay = max_window + DIV_ROUND_UP(5 * max_len, 16) * 4; 369 + else if (temperature < 120000) 370 + phase_delay = max_window + DIV_ROUND_UP(4 * max_len, 16) * 4; 371 + else 372 + phase_delay = max_window + DIV_ROUND_UP(3 * max_len, 16) * 4; 373 + 374 + /* 375 + * Stage 2: Search for a single point failure near the chosen tuning 376 + * value in two steps. First in the +3 to +10 range and then in the 377 + * +2 to -10 range. If found, move away from it in the appropriate 378 + * direction by the appropriate amount depending on the temperature. 379 + */ 380 + for (i = 3; i <= 10; i++) { 381 + sdhci_omap_set_dll(omap_host, phase_delay + i); 382 + 383 + if (mmc_send_tuning(mmc, opcode, NULL)) { 384 + if (temperature < 10000) 385 + phase_delay += i + 6; 386 + else if (temperature < 20000) 387 + phase_delay += i - 12; 388 + else if (temperature < 70000) 389 + phase_delay += i - 8; 390 + else 391 + phase_delay += i - 6; 392 + 393 + goto single_failure_found; 394 + } 395 + } 396 + 397 + for (i = 2; i >= -10; i--) { 398 + sdhci_omap_set_dll(omap_host, phase_delay + i); 399 + 400 + if (mmc_send_tuning(mmc, opcode, NULL)) { 401 + if (temperature < 10000) 402 + phase_delay += i + 12; 403 + else if (temperature < 20000) 404 + phase_delay += i + 8; 405 + else if (temperature < 70000) 406 + phase_delay += i + 8; 407 + else if (temperature < 90000) 408 + phase_delay += i + 10; 409 + else 410 + phase_delay += i + 12; 411 + 412 + goto single_failure_found; 413 + } 414 + } 415 + 416 + single_failure_found: 381 417 reg = sdhci_omap_readl(omap_host, SDHCI_OMAP_AC12); 382 418 if (!(reg & AC12_SCLK_SEL)) { 383 419 ret = -EIO; 384 420 goto tuning_error; 385 421 } 386 422 387 - phase_delay = max_window + 4 * (max_len >> 1); 388 423 sdhci_omap_set_dll(omap_host, phase_delay); 424 + 425 + omap_host->is_tuning = false; 389 426 390 427 goto ret; 391 428 392 429 tuning_error: 430 + omap_host->is_tuning = false; 393 431 dev_err(dev, "Tuning failed\n"); 394 432 sdhci_omap_disable_tuning(omap_host); 395 433 ··· 747 653 748 654 /* wait 1ms */ 749 655 timeout = ktime_add_ms(ktime_get(), SDHCI_OMAP_TIMEOUT); 750 - while (!(sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN)) { 751 - if (WARN_ON(ktime_after(ktime_get(), timeout))) 656 + while (1) { 657 + bool timedout = ktime_after(ktime_get(), timeout); 658 + 659 + if (sdhci_omap_readl(omap_host, SDHCI_OMAP_STAT) & INT_CC_EN) 660 + break; 661 + if (WARN_ON(timedout)) 752 662 return; 753 663 usleep_range(5, 10); 754 664 } ··· 785 687 sdhci_omap_start_clock(omap_host); 786 688 } 787 689 690 + void sdhci_omap_reset(struct sdhci_host *host, u8 mask) 691 + { 692 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 693 + struct sdhci_omap_host *omap_host = sdhci_pltfm_priv(pltfm_host); 694 + 695 + /* Don't reset data lines during tuning operation */ 696 + if (omap_host->is_tuning) 697 + mask &= ~SDHCI_RESET_DATA; 698 + 699 + sdhci_reset(host, mask); 700 + } 701 + 788 702 static struct sdhci_ops sdhci_omap_ops = { 789 703 .set_clock = sdhci_omap_set_clock, 790 704 .set_power = sdhci_omap_set_power, ··· 805 695 .get_min_clock = sdhci_omap_get_min_clock, 806 696 .set_bus_width = sdhci_omap_set_bus_width, 807 697 .platform_send_init_74_clocks = sdhci_omap_init_74_clocks, 808 - .reset = sdhci_reset, 698 + .reset = sdhci_omap_reset, 809 699 .set_uhs_signaling = sdhci_omap_set_uhs_signaling, 810 700 }; 811 701
+14 -5
drivers/mmc/host/sdhci-pci-core.c
··· 710 710 static void byt_probe_slot(struct sdhci_pci_slot *slot) 711 711 { 712 712 struct mmc_host_ops *ops = &slot->host->mmc_host_ops; 713 + struct device *dev = &slot->chip->pdev->dev; 714 + struct mmc_host *mmc = slot->host->mmc; 713 715 714 716 byt_read_dsm(slot); 715 717 716 718 ops->execute_tuning = intel_execute_tuning; 717 719 ops->start_signal_voltage_switch = intel_start_signal_voltage_switch; 720 + 721 + device_property_read_u32(dev, "max-frequency", &mmc->f_max); 718 722 } 719 723 720 724 static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot) ··· 941 937 static const struct sdhci_pci_fixes sdhci_intel_byt_emmc = { 942 938 .allow_runtime_pm = true, 943 939 .probe_slot = byt_emmc_probe_slot, 944 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 940 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 941 + SDHCI_QUIRK_NO_LED, 945 942 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 946 943 SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 | 947 944 SDHCI_QUIRK2_STOP_WITH_TC, ··· 962 957 .runtime_suspend = glk_runtime_suspend, 963 958 .runtime_resume = glk_runtime_resume, 964 959 #endif 965 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 960 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 961 + SDHCI_QUIRK_NO_LED, 966 962 .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 967 963 SDHCI_QUIRK2_CAPS_BIT63_FOR_HS400 | 968 964 SDHCI_QUIRK2_STOP_WITH_TC, ··· 972 966 }; 973 967 974 968 static const struct sdhci_pci_fixes sdhci_ni_byt_sdio = { 975 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 969 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 970 + SDHCI_QUIRK_NO_LED, 976 971 .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON | 977 972 SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 978 973 .allow_runtime_pm = true, ··· 983 976 }; 984 977 985 978 static const struct sdhci_pci_fixes sdhci_intel_byt_sdio = { 986 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 979 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 980 + SDHCI_QUIRK_NO_LED, 987 981 .quirks2 = SDHCI_QUIRK2_HOST_OFF_CARD_ON | 988 982 SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 989 983 .allow_runtime_pm = true, ··· 994 986 }; 995 987 996 988 static const struct sdhci_pci_fixes sdhci_intel_byt_sd = { 997 - .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC, 989 + .quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 990 + SDHCI_QUIRK_NO_LED, 998 991 .quirks2 = SDHCI_QUIRK2_CARD_ON_NEEDS_BUS_ON | 999 992 SDHCI_QUIRK2_PRESET_VALUE_BROKEN | 1000 993 SDHCI_QUIRK2_STOP_WITH_TC,
+7 -3
drivers/mmc/host/sdhci-xenon-phy.c
··· 357 357 358 358 /* Wait max 32 ms */ 359 359 timeout = ktime_add_ms(ktime_get(), 32); 360 - while (!(sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) & 361 - XENON_DLL_LOCK_STATE)) { 362 - if (ktime_after(ktime_get(), timeout)) { 360 + while (1) { 361 + bool timedout = ktime_after(ktime_get(), timeout); 362 + 363 + if (sdhci_readw(host, XENON_SLOT_EXT_PRESENT_STATE) & 364 + XENON_DLL_LOCK_STATE) 365 + break; 366 + if (timedout) { 363 367 dev_err(mmc_dev(host->mmc), "Wait for DLL Lock time-out\n"); 364 368 return -ETIMEDOUT; 365 369 }
+7 -3
drivers/mmc/host/sdhci-xenon.c
··· 34 34 sdhci_writel(host, reg, SDHCI_CLOCK_CONTROL); 35 35 /* Wait max 20 ms */ 36 36 timeout = ktime_add_ms(ktime_get(), 20); 37 - while (!((reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL)) 38 - & SDHCI_CLOCK_INT_STABLE)) { 39 - if (ktime_after(ktime_get(), timeout)) { 37 + while (1) { 38 + bool timedout = ktime_after(ktime_get(), timeout); 39 + 40 + reg = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 41 + if (reg & SDHCI_CLOCK_INT_STABLE) 42 + break; 43 + if (timedout) { 40 44 dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n"); 41 45 return -ETIMEDOUT; 42 46 }
+69 -37
drivers/mmc/host/sdhci.c
··· 82 82 SDHCI_DUMP("Int enab: 0x%08x | Sig enab: 0x%08x\n", 83 83 sdhci_readl(host, SDHCI_INT_ENABLE), 84 84 sdhci_readl(host, SDHCI_SIGNAL_ENABLE)); 85 - SDHCI_DUMP("AC12 err: 0x%08x | Slot int: 0x%08x\n", 86 - sdhci_readw(host, SDHCI_ACMD12_ERR), 85 + SDHCI_DUMP("ACmd stat: 0x%08x | Slot int: 0x%08x\n", 86 + sdhci_readw(host, SDHCI_AUTO_CMD_STATUS), 87 87 sdhci_readw(host, SDHCI_SLOT_INT_STATUS)); 88 88 SDHCI_DUMP("Caps: 0x%08x | Caps_1: 0x%08x\n", 89 89 sdhci_readl(host, SDHCI_CAPABILITIES), ··· 349 349 { 350 350 u8 ctrl; 351 351 352 + if (host->quirks & SDHCI_QUIRK_NO_LED) 353 + return; 354 + 352 355 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); 353 356 ctrl |= SDHCI_CTRL_LED; 354 357 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); ··· 360 357 static void __sdhci_led_deactivate(struct sdhci_host *host) 361 358 { 362 359 u8 ctrl; 360 + 361 + if (host->quirks & SDHCI_QUIRK_NO_LED) 362 + return; 363 363 364 364 ctrl = sdhci_readb(host, SDHCI_HOST_CONTROL); 365 365 ctrl &= ~SDHCI_CTRL_LED; ··· 393 387 { 394 388 struct mmc_host *mmc = host->mmc; 395 389 390 + if (host->quirks & SDHCI_QUIRK_NO_LED) 391 + return 0; 392 + 396 393 snprintf(host->led_name, sizeof(host->led_name), 397 394 "%s::", mmc_hostname(mmc)); 398 395 ··· 409 400 410 401 static void sdhci_led_unregister(struct sdhci_host *host) 411 402 { 403 + if (host->quirks & SDHCI_QUIRK_NO_LED) 404 + return; 405 + 412 406 led_classdev_unregister(&host->led); 413 407 } 414 408 ··· 945 933 else 946 934 host->ier = (host->ier & ~dma_irqs) | pio_irqs; 947 935 936 + if (host->flags & (SDHCI_AUTO_CMD23 | SDHCI_AUTO_CMD12)) 937 + host->ier |= SDHCI_INT_AUTO_CMD_ERR; 938 + else 939 + host->ier &= ~SDHCI_INT_AUTO_CMD_ERR; 940 + 948 941 sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); 949 942 sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); 950 943 } ··· 1208 1191 return (!(host->flags & SDHCI_DEVICE_DEAD) && 1209 1192 ((mrq->cmd && mrq->cmd->error) || 1210 1193 (mrq->sbc && mrq->sbc->error) || 1211 - (mrq->data && ((mrq->data->error && !mrq->data->stop) || 1212 - (mrq->data->stop && mrq->data->stop->error))) || 1194 + (mrq->data && mrq->data->stop && mrq->data->stop->error) || 1213 1195 (host->quirks & SDHCI_QUIRK_RESET_AFTER_REQUEST))); 1214 1196 } 1215 1197 ··· 1260 1244 host->data = NULL; 1261 1245 host->data_cmd = NULL; 1262 1246 1247 + /* 1248 + * The controller needs a reset of internal state machines upon error 1249 + * conditions. 1250 + */ 1251 + if (data->error) { 1252 + if (!host->cmd || host->cmd == data_cmd) 1253 + sdhci_do_reset(host, SDHCI_RESET_CMD); 1254 + sdhci_do_reset(host, SDHCI_RESET_DATA); 1255 + } 1256 + 1263 1257 if ((host->flags & (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) == 1264 1258 (SDHCI_REQ_USE_DMA | SDHCI_USE_ADMA)) 1265 1259 sdhci_adma_table_post(host, data); ··· 1294 1268 if (data->stop && 1295 1269 (data->error || 1296 1270 !data->mrq->sbc)) { 1297 - 1298 - /* 1299 - * The controller needs a reset of internal state machines 1300 - * upon error conditions. 1301 - */ 1302 - if (data->error) { 1303 - if (!host->cmd || host->cmd == data_cmd) 1304 - sdhci_do_reset(host, SDHCI_RESET_CMD); 1305 - sdhci_do_reset(host, SDHCI_RESET_DATA); 1306 - } 1307 - 1308 1271 /* 1309 1272 * 'cap_cmd_during_tfr' request must not use the command line 1310 1273 * after mmc_command_done() has been called. It is upper layer's ··· 2772 2757 * * 2773 2758 \*****************************************************************************/ 2774 2759 2775 - static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask) 2760 + static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *intmask_p) 2776 2761 { 2762 + /* Handle auto-CMD12 error */ 2763 + if (intmask & SDHCI_INT_AUTO_CMD_ERR && host->data_cmd) { 2764 + struct mmc_request *mrq = host->data_cmd->mrq; 2765 + u16 auto_cmd_status = sdhci_readw(host, SDHCI_AUTO_CMD_STATUS); 2766 + int data_err_bit = (auto_cmd_status & SDHCI_AUTO_CMD_TIMEOUT) ? 2767 + SDHCI_INT_DATA_TIMEOUT : 2768 + SDHCI_INT_DATA_CRC; 2769 + 2770 + /* Treat auto-CMD12 error the same as data error */ 2771 + if (!mrq->sbc && (host->flags & SDHCI_AUTO_CMD12)) { 2772 + *intmask_p |= data_err_bit; 2773 + return; 2774 + } 2775 + } 2776 + 2777 2777 if (!host->cmd) { 2778 2778 /* 2779 2779 * SDHCI recovers from errors by resetting the cmd and data ··· 2810 2780 else 2811 2781 host->cmd->error = -EILSEQ; 2812 2782 2813 - /* 2814 - * If this command initiates a data phase and a response 2815 - * CRC error is signalled, the card can start transferring 2816 - * data - the card may have received the command without 2817 - * error. We must not terminate the mmc_request early. 2818 - * 2819 - * If the card did not receive the command or returned an 2820 - * error which prevented it sending data, the data phase 2821 - * will time out. 2822 - */ 2783 + /* Treat data command CRC error the same as data CRC error */ 2823 2784 if (host->cmd->data && 2824 2785 (intmask & (SDHCI_INT_CRC | SDHCI_INT_TIMEOUT)) == 2825 2786 SDHCI_INT_CRC) { 2826 2787 host->cmd = NULL; 2788 + *intmask_p |= SDHCI_INT_DATA_CRC; 2827 2789 return; 2828 2790 } 2829 2791 2830 2792 sdhci_finish_mrq(host, host->cmd->mrq); 2831 2793 return; 2794 + } 2795 + 2796 + /* Handle auto-CMD23 error */ 2797 + if (intmask & SDHCI_INT_AUTO_CMD_ERR) { 2798 + struct mmc_request *mrq = host->cmd->mrq; 2799 + u16 auto_cmd_status = sdhci_readw(host, SDHCI_AUTO_CMD_STATUS); 2800 + int err = (auto_cmd_status & SDHCI_AUTO_CMD_TIMEOUT) ? 2801 + -ETIMEDOUT : 2802 + -EILSEQ; 2803 + 2804 + if (mrq->sbc && (host->flags & SDHCI_AUTO_CMD23)) { 2805 + mrq->sbc->error = err; 2806 + sdhci_finish_mrq(host, mrq); 2807 + return; 2808 + } 2832 2809 } 2833 2810 2834 2811 if (intmask & SDHCI_INT_RESPONSE) ··· 3058 3021 } 3059 3022 3060 3023 if (intmask & SDHCI_INT_CMD_MASK) 3061 - sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK); 3024 + sdhci_cmd_irq(host, intmask & SDHCI_INT_CMD_MASK, &intmask); 3062 3025 3063 3026 if (intmask & SDHCI_INT_DATA_MASK) 3064 3027 sdhci_data_irq(host, intmask & SDHCI_INT_DATA_MASK); ··· 3578 3541 } 3579 3542 EXPORT_SYMBOL_GPL(__sdhci_read_caps); 3580 3543 3581 - static int sdhci_allocate_bounce_buffer(struct sdhci_host *host) 3544 + static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) 3582 3545 { 3583 3546 struct mmc_host *mmc = host->mmc; 3584 3547 unsigned int max_blocks; ··· 3616 3579 * Exiting with zero here makes sure we proceed with 3617 3580 * mmc->max_segs == 1. 3618 3581 */ 3619 - return 0; 3582 + return; 3620 3583 } 3621 3584 3622 3585 host->bounce_addr = dma_map_single(mmc->parent, ··· 3626 3589 ret = dma_mapping_error(mmc->parent, host->bounce_addr); 3627 3590 if (ret) 3628 3591 /* Again fall back to max_segs == 1 */ 3629 - return 0; 3592 + return; 3630 3593 host->bounce_buffer_size = bounce_size; 3631 3594 3632 3595 /* Lie about this since we're bouncing */ ··· 3636 3599 3637 3600 pr_info("%s bounce up to %u segments into one, max segment size %u bytes\n", 3638 3601 mmc_hostname(mmc), max_blocks, bounce_size); 3639 - 3640 - return 0; 3641 3602 } 3642 3603 3643 3604 static inline bool sdhci_can_64bit_dma(struct sdhci_host *host) ··· 4169 4134 */ 4170 4135 mmc->max_blk_count = (host->quirks & SDHCI_QUIRK_NO_MULTIBLOCK) ? 1 : 65535; 4171 4136 4172 - if (mmc->max_segs == 1) { 4137 + if (mmc->max_segs == 1) 4173 4138 /* This may alter mmc->*_blk_* parameters */ 4174 - ret = sdhci_allocate_bounce_buffer(host); 4175 - if (ret) 4176 - return ret; 4177 - } 4139 + sdhci_allocate_bounce_buffer(host); 4178 4140 4179 4141 return 0; 4180 4142
+10 -3
drivers/mmc/host/sdhci.h
··· 146 146 #define SDHCI_INT_DATA_CRC 0x00200000 147 147 #define SDHCI_INT_DATA_END_BIT 0x00400000 148 148 #define SDHCI_INT_BUS_POWER 0x00800000 149 - #define SDHCI_INT_ACMD12ERR 0x01000000 149 + #define SDHCI_INT_AUTO_CMD_ERR 0x01000000 150 150 #define SDHCI_INT_ADMA_ERROR 0x02000000 151 151 152 152 #define SDHCI_INT_NORMAL_MASK 0x00007FFF 153 153 #define SDHCI_INT_ERROR_MASK 0xFFFF8000 154 154 155 155 #define SDHCI_INT_CMD_MASK (SDHCI_INT_RESPONSE | SDHCI_INT_TIMEOUT | \ 156 - SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX) 156 + SDHCI_INT_CRC | SDHCI_INT_END_BIT | SDHCI_INT_INDEX | \ 157 + SDHCI_INT_AUTO_CMD_ERR) 157 158 #define SDHCI_INT_DATA_MASK (SDHCI_INT_DATA_END | SDHCI_INT_DMA_END | \ 158 159 SDHCI_INT_DATA_AVAIL | SDHCI_INT_SPACE_AVAIL | \ 159 160 SDHCI_INT_DATA_TIMEOUT | SDHCI_INT_DATA_CRC | \ ··· 169 168 170 169 #define SDHCI_CQE_INT_MASK (SDHCI_CQE_INT_ERR_MASK | SDHCI_INT_CQE) 171 170 172 - #define SDHCI_ACMD12_ERR 0x3C 171 + #define SDHCI_AUTO_CMD_STATUS 0x3C 172 + #define SDHCI_AUTO_CMD_TIMEOUT 0x00000002 173 + #define SDHCI_AUTO_CMD_CRC 0x00000004 174 + #define SDHCI_AUTO_CMD_END_BIT 0x00000008 175 + #define SDHCI_AUTO_CMD_INDEX 0x00000010 173 176 174 177 #define SDHCI_HOST_CONTROL2 0x3E 175 178 #define SDHCI_CTRL_UHS_MASK 0x0007 ··· 408 403 #define SDHCI_QUIRK_INVERTED_WRITE_PROTECT (1<<16) 409 404 /* Controller does not like fast PIO transfers */ 410 405 #define SDHCI_QUIRK_PIO_NEEDS_DELAY (1<<18) 406 + /* Controller does not have a LED */ 407 + #define SDHCI_QUIRK_NO_LED (1<<19) 411 408 /* Controller has to be forced to use block size of 2048 bytes */ 412 409 #define SDHCI_QUIRK_FORCE_BLK_SZ_2048 (1<<20) 413 410 /* Controller cannot do multi-block transfers */
+374
drivers/mmc/host/sdhci_am654.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * sdhci_am654.c - SDHCI driver for TI's AM654 SOCs 4 + * 5 + * Copyright (C) 2018 Texas Instruments Incorporated - http://www.ti.com 6 + * 7 + */ 8 + #include <linux/clk.h> 9 + #include <linux/module.h> 10 + #include <linux/pm_runtime.h> 11 + #include <linux/property.h> 12 + #include <linux/regmap.h> 13 + 14 + #include "sdhci-pltfm.h" 15 + 16 + /* CTL_CFG Registers */ 17 + #define CTL_CFG_2 0x14 18 + 19 + #define SLOTTYPE_MASK GENMASK(31, 30) 20 + #define SLOTTYPE_EMBEDDED BIT(30) 21 + 22 + /* PHY Registers */ 23 + #define PHY_CTRL1 0x100 24 + #define PHY_CTRL2 0x104 25 + #define PHY_CTRL3 0x108 26 + #define PHY_CTRL4 0x10C 27 + #define PHY_CTRL5 0x110 28 + #define PHY_CTRL6 0x114 29 + #define PHY_STAT1 0x130 30 + #define PHY_STAT2 0x134 31 + 32 + #define IOMUX_ENABLE_SHIFT 31 33 + #define IOMUX_ENABLE_MASK BIT(IOMUX_ENABLE_SHIFT) 34 + #define OTAPDLYENA_SHIFT 20 35 + #define OTAPDLYENA_MASK BIT(OTAPDLYENA_SHIFT) 36 + #define OTAPDLYSEL_SHIFT 12 37 + #define OTAPDLYSEL_MASK GENMASK(15, 12) 38 + #define STRBSEL_SHIFT 24 39 + #define STRBSEL_MASK GENMASK(27, 24) 40 + #define SEL50_SHIFT 8 41 + #define SEL50_MASK BIT(SEL50_SHIFT) 42 + #define SEL100_SHIFT 9 43 + #define SEL100_MASK BIT(SEL100_SHIFT) 44 + #define DLL_TRIM_ICP_SHIFT 4 45 + #define DLL_TRIM_ICP_MASK GENMASK(7, 4) 46 + #define DR_TY_SHIFT 20 47 + #define DR_TY_MASK GENMASK(22, 20) 48 + #define ENDLL_SHIFT 1 49 + #define ENDLL_MASK BIT(ENDLL_SHIFT) 50 + #define DLLRDY_SHIFT 0 51 + #define DLLRDY_MASK BIT(DLLRDY_SHIFT) 52 + #define PDB_SHIFT 0 53 + #define PDB_MASK BIT(PDB_SHIFT) 54 + #define CALDONE_SHIFT 1 55 + #define CALDONE_MASK BIT(CALDONE_SHIFT) 56 + #define RETRIM_SHIFT 17 57 + #define RETRIM_MASK BIT(RETRIM_SHIFT) 58 + 59 + #define DRIVER_STRENGTH_50_OHM 0x0 60 + #define DRIVER_STRENGTH_33_OHM 0x1 61 + #define DRIVER_STRENGTH_66_OHM 0x2 62 + #define DRIVER_STRENGTH_100_OHM 0x3 63 + #define DRIVER_STRENGTH_40_OHM 0x4 64 + 65 + #define CLOCK_TOO_SLOW_HZ 400000 66 + 67 + static struct regmap_config sdhci_am654_regmap_config = { 68 + .reg_bits = 32, 69 + .val_bits = 32, 70 + .reg_stride = 4, 71 + .fast_io = true, 72 + }; 73 + 74 + struct sdhci_am654_data { 75 + struct regmap *base; 76 + int otap_del_sel; 77 + int trm_icp; 78 + int drv_strength; 79 + bool dll_on; 80 + }; 81 + 82 + static void sdhci_am654_set_clock(struct sdhci_host *host, unsigned int clock) 83 + { 84 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 85 + struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); 86 + int sel50, sel100; 87 + u32 mask, val; 88 + int ret; 89 + 90 + if (sdhci_am654->dll_on) { 91 + regmap_update_bits(sdhci_am654->base, PHY_CTRL1, 92 + ENDLL_MASK, 0); 93 + 94 + sdhci_am654->dll_on = false; 95 + } 96 + 97 + sdhci_set_clock(host, clock); 98 + 99 + if (clock > CLOCK_TOO_SLOW_HZ) { 100 + /* Setup DLL Output TAP delay */ 101 + mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK; 102 + val = (1 << OTAPDLYENA_SHIFT) | 103 + (sdhci_am654->otap_del_sel << OTAPDLYSEL_SHIFT); 104 + regmap_update_bits(sdhci_am654->base, PHY_CTRL4, 105 + mask, val); 106 + switch (clock) { 107 + case 200000000: 108 + sel50 = 0; 109 + sel100 = 0; 110 + break; 111 + case 100000000: 112 + sel50 = 0; 113 + sel100 = 1; 114 + break; 115 + default: 116 + sel50 = 1; 117 + sel100 = 0; 118 + } 119 + 120 + /* Configure PHY DLL frequency */ 121 + mask = SEL50_MASK | SEL100_MASK; 122 + val = (sel50 << SEL50_SHIFT) | (sel100 << SEL100_SHIFT); 123 + regmap_update_bits(sdhci_am654->base, PHY_CTRL5, 124 + mask, val); 125 + /* Configure DLL TRIM */ 126 + mask = DLL_TRIM_ICP_MASK; 127 + val = sdhci_am654->trm_icp << DLL_TRIM_ICP_SHIFT; 128 + 129 + /* Configure DLL driver strength */ 130 + mask |= DR_TY_MASK; 131 + val |= sdhci_am654->drv_strength << DR_TY_SHIFT; 132 + regmap_update_bits(sdhci_am654->base, PHY_CTRL1, 133 + mask, val); 134 + /* Enable DLL */ 135 + regmap_update_bits(sdhci_am654->base, PHY_CTRL1, 136 + ENDLL_MASK, 0x1 << ENDLL_SHIFT); 137 + /* 138 + * Poll for DLL ready. Use a one second timeout. 139 + * Works in all experiments done so far 140 + */ 141 + ret = regmap_read_poll_timeout(sdhci_am654->base, 142 + PHY_STAT1, val, 143 + val & DLLRDY_MASK, 144 + 1000, 1000000); 145 + 146 + sdhci_am654->dll_on = true; 147 + } 148 + } 149 + 150 + static void sdhci_am654_set_power(struct sdhci_host *host, unsigned char mode, 151 + unsigned short vdd) 152 + { 153 + if (!IS_ERR(host->mmc->supply.vmmc)) { 154 + struct mmc_host *mmc = host->mmc; 155 + 156 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); 157 + } 158 + sdhci_set_power_noreg(host, mode, vdd); 159 + } 160 + 161 + struct sdhci_ops sdhci_am654_ops = { 162 + .get_max_clock = sdhci_pltfm_clk_get_max_clock, 163 + .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, 164 + .set_uhs_signaling = sdhci_set_uhs_signaling, 165 + .set_bus_width = sdhci_set_bus_width, 166 + .set_power = sdhci_am654_set_power, 167 + .set_clock = sdhci_am654_set_clock, 168 + .reset = sdhci_reset, 169 + }; 170 + 171 + static const struct sdhci_pltfm_data sdhci_am654_pdata = { 172 + .ops = &sdhci_am654_ops, 173 + .quirks = SDHCI_QUIRK_INVERTED_WRITE_PROTECT | 174 + SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12, 175 + .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, 176 + }; 177 + 178 + static int sdhci_am654_init(struct sdhci_host *host) 179 + { 180 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 181 + struct sdhci_am654_data *sdhci_am654 = sdhci_pltfm_priv(pltfm_host); 182 + u32 ctl_cfg_2 = 0; 183 + u32 mask; 184 + u32 val; 185 + int ret; 186 + 187 + /* Reset OTAP to default value */ 188 + mask = OTAPDLYENA_MASK | OTAPDLYSEL_MASK; 189 + regmap_update_bits(sdhci_am654->base, PHY_CTRL4, 190 + mask, 0x0); 191 + 192 + regmap_read(sdhci_am654->base, PHY_STAT1, &val); 193 + if (~val & CALDONE_MASK) { 194 + /* Calibrate IO lines */ 195 + regmap_update_bits(sdhci_am654->base, PHY_CTRL1, 196 + PDB_MASK, PDB_MASK); 197 + ret = regmap_read_poll_timeout(sdhci_am654->base, PHY_STAT1, 198 + val, val & CALDONE_MASK, 1, 20); 199 + if (ret) 200 + return ret; 201 + } 202 + 203 + /* Enable pins by setting IO mux to 0 */ 204 + regmap_update_bits(sdhci_am654->base, PHY_CTRL1, 205 + IOMUX_ENABLE_MASK, 0); 206 + 207 + /* Set slot type based on SD or eMMC */ 208 + if (host->mmc->caps & MMC_CAP_NONREMOVABLE) 209 + ctl_cfg_2 = SLOTTYPE_EMBEDDED; 210 + 211 + regmap_update_bits(sdhci_am654->base, CTL_CFG_2, 212 + ctl_cfg_2, SLOTTYPE_MASK); 213 + 214 + return sdhci_add_host(host); 215 + } 216 + 217 + static int sdhci_am654_get_of_property(struct platform_device *pdev, 218 + struct sdhci_am654_data *sdhci_am654) 219 + { 220 + struct device *dev = &pdev->dev; 221 + int drv_strength; 222 + int ret; 223 + 224 + ret = device_property_read_u32(dev, "ti,trm-icp", 225 + &sdhci_am654->trm_icp); 226 + if (ret) 227 + return ret; 228 + 229 + ret = device_property_read_u32(dev, "ti,otap-del-sel", 230 + &sdhci_am654->otap_del_sel); 231 + if (ret) 232 + return ret; 233 + 234 + ret = device_property_read_u32(dev, "ti,driver-strength-ohm", 235 + &drv_strength); 236 + if (ret) 237 + return ret; 238 + 239 + switch (drv_strength) { 240 + case 50: 241 + sdhci_am654->drv_strength = DRIVER_STRENGTH_50_OHM; 242 + break; 243 + case 33: 244 + sdhci_am654->drv_strength = DRIVER_STRENGTH_33_OHM; 245 + break; 246 + case 66: 247 + sdhci_am654->drv_strength = DRIVER_STRENGTH_66_OHM; 248 + break; 249 + case 100: 250 + sdhci_am654->drv_strength = DRIVER_STRENGTH_100_OHM; 251 + break; 252 + case 40: 253 + sdhci_am654->drv_strength = DRIVER_STRENGTH_40_OHM; 254 + break; 255 + default: 256 + dev_err(dev, "Invalid driver strength\n"); 257 + return -EINVAL; 258 + } 259 + 260 + sdhci_get_of_property(pdev); 261 + 262 + return 0; 263 + } 264 + 265 + static int sdhci_am654_probe(struct platform_device *pdev) 266 + { 267 + struct sdhci_pltfm_host *pltfm_host; 268 + struct sdhci_am654_data *sdhci_am654; 269 + struct sdhci_host *host; 270 + struct resource *res; 271 + struct clk *clk_xin; 272 + struct device *dev = &pdev->dev; 273 + void __iomem *base; 274 + int ret; 275 + 276 + host = sdhci_pltfm_init(pdev, &sdhci_am654_pdata, sizeof(*sdhci_am654)); 277 + if (IS_ERR(host)) 278 + return PTR_ERR(host); 279 + 280 + pltfm_host = sdhci_priv(host); 281 + sdhci_am654 = sdhci_pltfm_priv(pltfm_host); 282 + 283 + clk_xin = devm_clk_get(dev, "clk_xin"); 284 + if (IS_ERR(clk_xin)) { 285 + dev_err(dev, "clk_xin clock not found.\n"); 286 + ret = PTR_ERR(clk_xin); 287 + goto err_pltfm_free; 288 + } 289 + 290 + pltfm_host->clk = clk_xin; 291 + 292 + /* Clocks are enabled using pm_runtime */ 293 + pm_runtime_enable(dev); 294 + ret = pm_runtime_get_sync(dev); 295 + if (ret < 0) { 296 + pm_runtime_put_noidle(dev); 297 + goto pm_runtime_disable; 298 + } 299 + 300 + res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 301 + base = devm_ioremap_resource(dev, res); 302 + if (IS_ERR(base)) { 303 + ret = PTR_ERR(base); 304 + goto pm_runtime_put; 305 + } 306 + 307 + sdhci_am654->base = devm_regmap_init_mmio(dev, base, 308 + &sdhci_am654_regmap_config); 309 + if (IS_ERR(sdhci_am654->base)) { 310 + dev_err(dev, "Failed to initialize regmap\n"); 311 + ret = PTR_ERR(sdhci_am654->base); 312 + goto pm_runtime_put; 313 + } 314 + 315 + ret = sdhci_am654_get_of_property(pdev, sdhci_am654); 316 + if (ret) 317 + goto pm_runtime_put; 318 + 319 + ret = mmc_of_parse(host->mmc); 320 + if (ret) { 321 + dev_err(dev, "parsing dt failed (%d)\n", ret); 322 + goto pm_runtime_put; 323 + } 324 + 325 + ret = sdhci_am654_init(host); 326 + if (ret) 327 + goto pm_runtime_put; 328 + 329 + return 0; 330 + 331 + pm_runtime_put: 332 + pm_runtime_put_sync(dev); 333 + pm_runtime_disable: 334 + pm_runtime_disable(dev); 335 + err_pltfm_free: 336 + sdhci_pltfm_free(pdev); 337 + return ret; 338 + } 339 + 340 + static int sdhci_am654_remove(struct platform_device *pdev) 341 + { 342 + struct sdhci_host *host = platform_get_drvdata(pdev); 343 + int ret; 344 + 345 + sdhci_remove_host(host, true); 346 + ret = pm_runtime_put_sync(&pdev->dev); 347 + if (ret < 0) 348 + return ret; 349 + 350 + pm_runtime_disable(&pdev->dev); 351 + sdhci_pltfm_free(pdev); 352 + 353 + return 0; 354 + } 355 + 356 + static const struct of_device_id sdhci_am654_of_match[] = { 357 + { .compatible = "ti,am654-sdhci-5.1" }, 358 + { /* sentinel */ } 359 + }; 360 + 361 + static struct platform_driver sdhci_am654_driver = { 362 + .driver = { 363 + .name = "sdhci-am654", 364 + .of_match_table = sdhci_am654_of_match, 365 + }, 366 + .probe = sdhci_am654_probe, 367 + .remove = sdhci_am654_remove, 368 + }; 369 + 370 + module_platform_driver(sdhci_am654_driver); 371 + 372 + MODULE_DESCRIPTION("Driver for SDHCI Controller on TI's AM654 devices"); 373 + MODULE_AUTHOR("Faiz Abbas <faiz_abbas@ti.com>"); 374 + MODULE_LICENSE("GPL");
+6
drivers/mmc/host/tmio_mmc.h
··· 70 70 #define TMIO_STAT_DAT0 BIT(23) /* only known on R-Car so far */ 71 71 #define TMIO_STAT_RXRDY BIT(24) 72 72 #define TMIO_STAT_TXRQ BIT(25) 73 + #define TMIO_STAT_ALWAYS_SET_27 BIT(27) /* only known on R-Car 2+ so far */ 73 74 #define TMIO_STAT_ILL_FUNC BIT(29) /* only when !TMIO_MMC_HAS_IDLE_WAIT */ 74 75 #define TMIO_STAT_SCLKDIVEN BIT(29) /* only when TMIO_MMC_HAS_IDLE_WAIT */ 75 76 #define TMIO_STAT_CMD_BUSY BIT(30) ··· 97 96 98 97 /* Define some IRQ masks */ 99 98 /* This is the mask used at reset by the chip */ 99 + #define TMIO_MASK_INIT_RCAR2 0x8b7f031d /* Initial value for R-Car Gen2+ */ 100 100 #define TMIO_MASK_ALL 0x837f031d 101 101 #define TMIO_MASK_READOP (TMIO_STAT_RXRDY | TMIO_STAT_DATAEND) 102 102 #define TMIO_MASK_WRITEOP (TMIO_STAT_TXRQ | TMIO_STAT_DATAEND) ··· 155 153 u32 sdcard_irq_mask; 156 154 u32 sdio_irq_mask; 157 155 unsigned int clk_cache; 156 + u32 sdcard_irq_setbit_mask; 158 157 159 158 spinlock_t lock; /* protect host private data */ 160 159 unsigned long last_req_ts; ··· 270 267 static inline void sd_ctrl_write32_as_16_and_16(struct tmio_mmc_host *host, 271 268 int addr, u32 val) 272 269 { 270 + if (addr == CTL_IRQ_MASK || addr == CTL_STATUS) 271 + val |= host->sdcard_irq_setbit_mask; 272 + 273 273 iowrite16(val & 0xffff, host->ctl + (addr << host->bus_shift)); 274 274 iowrite16(val >> 16, host->ctl + ((addr + 2) << host->bus_shift)); 275 275 }
+22 -19
drivers/mmc/host/tmio_mmc_core.c
··· 171 171 } 172 172 } 173 173 174 + static void tmio_mmc_hw_reset(struct mmc_host *mmc) 175 + { 176 + struct tmio_mmc_host *host = mmc_priv(mmc); 177 + 178 + host->reset(host); 179 + 180 + tmio_mmc_abort_dma(host); 181 + 182 + if (host->hw_reset) 183 + host->hw_reset(host); 184 + } 185 + 174 186 static void tmio_mmc_reset_work(struct work_struct *work) 175 187 { 176 188 struct tmio_mmc_host *host = container_of(work, struct tmio_mmc_host, ··· 221 209 222 210 spin_unlock_irqrestore(&host->lock, flags); 223 211 224 - host->reset(host); 212 + tmio_mmc_hw_reset(host->mmc); 225 213 226 214 /* Ready for new calls */ 227 215 host->mrq = NULL; 228 216 229 - tmio_mmc_abort_dma(host); 230 217 mmc_request_done(host->mmc, mrq); 231 218 } 232 219 ··· 707 696 return 0; 708 697 } 709 698 710 - static void tmio_mmc_hw_reset(struct mmc_host *mmc) 711 - { 712 - struct tmio_mmc_host *host = mmc_priv(mmc); 713 - 714 - if (host->hw_reset) 715 - host->hw_reset(host); 716 - } 717 - 718 699 static int tmio_mmc_execute_tuning(struct mmc_host *mmc, u32 opcode) 719 700 { 720 701 struct tmio_mmc_host *host = mmc_priv(mmc); ··· 737 734 ret = mmc_send_tuning(mmc, opcode, NULL); 738 735 if (ret == 0) 739 736 set_bit(i, host->taps); 740 - 741 - usleep_range(1000, 1200); 742 737 } 743 738 744 739 ret = host->select_tuning(host); ··· 1168 1167 if (ret < 0) 1169 1168 return ret; 1170 1169 1171 - if (pdata->flags & TMIO_MMC_USE_GPIO_CD) { 1172 - ret = mmc_gpio_request_cd(mmc, pdata->cd_gpio, 0); 1173 - if (ret) 1174 - return ret; 1175 - } 1170 + /* 1171 + * Look for a card detect GPIO, if it fails with anything 1172 + * else than a probe deferral, just live without it. 1173 + */ 1174 + ret = mmc_gpiod_request_cd(mmc, "cd", 0, false, 0, NULL); 1175 + if (ret == -EPROBE_DEFER) 1176 + return ret; 1176 1177 1177 1178 mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; 1178 1179 mmc->caps2 |= pdata->capabilities2; ··· 1231 1228 _host->sdio_irq_mask = TMIO_SDIO_MASK_ALL; 1232 1229 1233 1230 _host->set_clock(_host, 0); 1234 - _host->reset(_host); 1231 + tmio_mmc_hw_reset(mmc); 1235 1232 1236 1233 _host->sdcard_irq_mask = sd_ctrl_read16_and_16_as_32(_host, CTL_IRQ_MASK); 1237 1234 tmio_mmc_disable_mmc_irqs(_host, TMIO_MASK_ALL); ··· 1331 1328 { 1332 1329 struct tmio_mmc_host *host = dev_get_drvdata(dev); 1333 1330 1334 - host->reset(host); 1335 1331 tmio_mmc_clk_enable(host); 1332 + tmio_mmc_hw_reset(host->mmc); 1336 1333 1337 1334 if (host->clk_cache) 1338 1335 host->set_clock(host, host->clk_cache);
+286
include/linux/alcor_pci.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0+ */ 2 + /* 3 + * Copyright (C) 2018 Oleksij Rempel <linux@rempel-privat.de> 4 + * 5 + * Driver for Alcor Micro AU6601 and AU6621 controllers 6 + */ 7 + 8 + #ifndef __ALCOR_PCI_H 9 + #define __ALCOR_PCI_H 10 + 11 + #define ALCOR_SD_CARD 0 12 + #define ALCOR_MS_CARD 1 13 + 14 + #define DRV_NAME_ALCOR_PCI_SDMMC "alcor_sdmmc" 15 + #define DRV_NAME_ALCOR_PCI_MS "alcor_ms" 16 + 17 + #define PCI_ID_ALCOR_MICRO 0x1AEA 18 + #define PCI_ID_AU6601 0x6601 19 + #define PCI_ID_AU6621 0x6621 20 + 21 + #define MHZ_TO_HZ(freq) ((freq) * 1000 * 1000) 22 + 23 + #define AU6601_BASE_CLOCK 31000000 24 + #define AU6601_MIN_CLOCK 150000 25 + #define AU6601_MAX_CLOCK 208000000 26 + #define AU6601_MAX_DMA_SEGMENTS 1 27 + #define AU6601_MAX_PIO_SEGMENTS 1 28 + #define AU6601_MAX_DMA_BLOCK_SIZE 0x1000 29 + #define AU6601_MAX_PIO_BLOCK_SIZE 0x200 30 + #define AU6601_MAX_DMA_BLOCKS 1 31 + #define AU6601_DMA_LOCAL_SEGMENTS 1 32 + 33 + /* registers spotter by reverse engineering but still 34 + * with unknown functionality: 35 + * 0x10 - ADMA phy address. AU6621 only? 36 + * 0x51 - LED ctrl? 37 + * 0x52 - unknown 38 + * 0x61 - LED related? Always toggled BIT0 39 + * 0x63 - Same as 0x61? 40 + * 0x77 - unknown 41 + */ 42 + 43 + /* SDMA phy address. Higher then 0x0800.0000? 44 + * The au6601 and au6621 have different DMA engines with different issues. One 45 + * For example au6621 engine is triggered by addr change. No other interaction 46 + * is needed. This means, if we get two buffers with same address, then engine 47 + * will stall. 48 + */ 49 + #define AU6601_REG_SDMA_ADDR 0x00 50 + #define AU6601_SDMA_MASK 0xffffffff 51 + 52 + #define AU6601_DMA_BOUNDARY 0x05 53 + #define AU6621_DMA_PAGE_CNT 0x05 54 + /* PIO */ 55 + #define AU6601_REG_BUFFER 0x08 56 + /* ADMA ctrl? AU6621 only. */ 57 + #define AU6621_DMA_CTRL 0x0c 58 + #define AU6621_DMA_ENABLE BIT(0) 59 + /* CMD index */ 60 + #define AU6601_REG_CMD_OPCODE 0x23 61 + /* CMD parametr */ 62 + #define AU6601_REG_CMD_ARG 0x24 63 + /* CMD response 4x4 Bytes */ 64 + #define AU6601_REG_CMD_RSP0 0x30 65 + #define AU6601_REG_CMD_RSP1 0x34 66 + #define AU6601_REG_CMD_RSP2 0x38 67 + #define AU6601_REG_CMD_RSP3 0x3C 68 + /* default timeout set to 125: 125 * 40ms = 5 sec 69 + * how exactly it is calculated? 70 + */ 71 + #define AU6601_TIME_OUT_CTRL 0x69 72 + /* Block size for SDMA or PIO */ 73 + #define AU6601_REG_BLOCK_SIZE 0x6c 74 + /* Some power related reg, used together with AU6601_OUTPUT_ENABLE */ 75 + #define AU6601_POWER_CONTROL 0x70 76 + 77 + /* PLL ctrl */ 78 + #define AU6601_CLK_SELECT 0x72 79 + #define AU6601_CLK_OVER_CLK 0x80 80 + #define AU6601_CLK_384_MHZ 0x30 81 + #define AU6601_CLK_125_MHZ 0x20 82 + #define AU6601_CLK_48_MHZ 0x10 83 + #define AU6601_CLK_EXT_PLL 0x04 84 + #define AU6601_CLK_X2_MODE 0x02 85 + #define AU6601_CLK_ENABLE 0x01 86 + #define AU6601_CLK_31_25_MHZ 0x00 87 + 88 + #define AU6601_CLK_DIVIDER 0x73 89 + 90 + #define AU6601_INTERFACE_MODE_CTRL 0x74 91 + #define AU6601_DLINK_MODE 0x80 92 + #define AU6601_INTERRUPT_DELAY_TIME 0x40 93 + #define AU6601_SIGNAL_REQ_CTRL 0x30 94 + #define AU6601_MS_CARD_WP BIT(3) 95 + #define AU6601_SD_CARD_WP BIT(0) 96 + 97 + /* same register values are used for: 98 + * - AU6601_OUTPUT_ENABLE 99 + * - AU6601_POWER_CONTROL 100 + */ 101 + #define AU6601_ACTIVE_CTRL 0x75 102 + #define AU6601_XD_CARD BIT(4) 103 + /* AU6601_MS_CARD_ACTIVE - will cativate MS card section? */ 104 + #define AU6601_MS_CARD BIT(3) 105 + #define AU6601_SD_CARD BIT(0) 106 + 107 + /* card slot state. It should automatically detect type of 108 + * the card 109 + */ 110 + #define AU6601_DETECT_STATUS 0x76 111 + #define AU6601_DETECT_EN BIT(7) 112 + #define AU6601_MS_DETECTED BIT(3) 113 + #define AU6601_SD_DETECTED BIT(0) 114 + #define AU6601_DETECT_STATUS_M 0xf 115 + 116 + #define AU6601_REG_SW_RESET 0x79 117 + #define AU6601_BUF_CTRL_RESET BIT(7) 118 + #define AU6601_RESET_DATA BIT(3) 119 + #define AU6601_RESET_CMD BIT(0) 120 + 121 + #define AU6601_OUTPUT_ENABLE 0x7a 122 + 123 + #define AU6601_PAD_DRIVE0 0x7b 124 + #define AU6601_PAD_DRIVE1 0x7c 125 + #define AU6601_PAD_DRIVE2 0x7d 126 + /* read EEPROM? */ 127 + #define AU6601_FUNCTION 0x7f 128 + 129 + #define AU6601_CMD_XFER_CTRL 0x81 130 + #define AU6601_CMD_17_BYTE_CRC 0xc0 131 + #define AU6601_CMD_6_BYTE_WO_CRC 0x80 132 + #define AU6601_CMD_6_BYTE_CRC 0x40 133 + #define AU6601_CMD_START_XFER 0x20 134 + #define AU6601_CMD_STOP_WAIT_RDY 0x10 135 + #define AU6601_CMD_NO_RESP 0x00 136 + 137 + #define AU6601_REG_BUS_CTRL 0x82 138 + #define AU6601_BUS_WIDTH_4BIT 0x20 139 + #define AU6601_BUS_WIDTH_8BIT 0x10 140 + #define AU6601_BUS_WIDTH_1BIT 0x00 141 + 142 + #define AU6601_DATA_XFER_CTRL 0x83 143 + #define AU6601_DATA_WRITE BIT(7) 144 + #define AU6601_DATA_DMA_MODE BIT(6) 145 + #define AU6601_DATA_START_XFER BIT(0) 146 + 147 + #define AU6601_DATA_PIN_STATE 0x84 148 + #define AU6601_BUS_STAT_CMD BIT(15) 149 + /* BIT(4) - BIT(7) are permanently 1. 150 + * May be reserved or not attached DAT4-DAT7 151 + */ 152 + #define AU6601_BUS_STAT_DAT3 BIT(3) 153 + #define AU6601_BUS_STAT_DAT2 BIT(2) 154 + #define AU6601_BUS_STAT_DAT1 BIT(1) 155 + #define AU6601_BUS_STAT_DAT0 BIT(0) 156 + #define AU6601_BUS_STAT_DAT_MASK 0xf 157 + 158 + #define AU6601_OPT 0x85 159 + #define AU6601_OPT_CMD_LINE_LEVEL 0x80 160 + #define AU6601_OPT_NCRC_16_CLK BIT(4) 161 + #define AU6601_OPT_CMD_NWT BIT(3) 162 + #define AU6601_OPT_STOP_CLK BIT(2) 163 + #define AU6601_OPT_DDR_MODE BIT(1) 164 + #define AU6601_OPT_SD_18V BIT(0) 165 + 166 + #define AU6601_CLK_DELAY 0x86 167 + #define AU6601_CLK_DATA_POSITIVE_EDGE 0x80 168 + #define AU6601_CLK_CMD_POSITIVE_EDGE 0x40 169 + #define AU6601_CLK_POSITIVE_EDGE_ALL (AU6601_CLK_CMD_POSITIVE_EDGE \ 170 + | AU6601_CLK_DATA_POSITIVE_EDGE) 171 + 172 + 173 + #define AU6601_REG_INT_STATUS 0x90 174 + #define AU6601_REG_INT_ENABLE 0x94 175 + #define AU6601_INT_DATA_END_BIT_ERR BIT(22) 176 + #define AU6601_INT_DATA_CRC_ERR BIT(21) 177 + #define AU6601_INT_DATA_TIMEOUT_ERR BIT(20) 178 + #define AU6601_INT_CMD_INDEX_ERR BIT(19) 179 + #define AU6601_INT_CMD_END_BIT_ERR BIT(18) 180 + #define AU6601_INT_CMD_CRC_ERR BIT(17) 181 + #define AU6601_INT_CMD_TIMEOUT_ERR BIT(16) 182 + #define AU6601_INT_ERROR BIT(15) 183 + #define AU6601_INT_OVER_CURRENT_ERR BIT(8) 184 + #define AU6601_INT_CARD_INSERT BIT(7) 185 + #define AU6601_INT_CARD_REMOVE BIT(6) 186 + #define AU6601_INT_READ_BUF_RDY BIT(5) 187 + #define AU6601_INT_WRITE_BUF_RDY BIT(4) 188 + #define AU6601_INT_DMA_END BIT(3) 189 + #define AU6601_INT_DATA_END BIT(1) 190 + #define AU6601_INT_CMD_END BIT(0) 191 + 192 + #define AU6601_INT_NORMAL_MASK 0x00007FFF 193 + #define AU6601_INT_ERROR_MASK 0xFFFF8000 194 + 195 + #define AU6601_INT_CMD_MASK (AU6601_INT_CMD_END | \ 196 + AU6601_INT_CMD_TIMEOUT_ERR | AU6601_INT_CMD_CRC_ERR | \ 197 + AU6601_INT_CMD_END_BIT_ERR | AU6601_INT_CMD_INDEX_ERR) 198 + #define AU6601_INT_DATA_MASK (AU6601_INT_DATA_END | AU6601_INT_DMA_END | \ 199 + AU6601_INT_READ_BUF_RDY | AU6601_INT_WRITE_BUF_RDY | \ 200 + AU6601_INT_DATA_TIMEOUT_ERR | AU6601_INT_DATA_CRC_ERR | \ 201 + AU6601_INT_DATA_END_BIT_ERR) 202 + #define AU6601_INT_ALL_MASK ((u32)-1) 203 + 204 + /* MS_CARD mode registers */ 205 + 206 + #define AU6601_MS_STATUS 0xa0 207 + 208 + #define AU6601_MS_BUS_MODE_CTRL 0xa1 209 + #define AU6601_MS_BUS_8BIT_MODE 0x03 210 + #define AU6601_MS_BUS_4BIT_MODE 0x01 211 + #define AU6601_MS_BUS_1BIT_MODE 0x00 212 + 213 + #define AU6601_MS_TPC_CMD 0xa2 214 + #define AU6601_MS_TPC_READ_PAGE_DATA 0x02 215 + #define AU6601_MS_TPC_READ_REG 0x04 216 + #define AU6601_MS_TPC_GET_INT 0x07 217 + #define AU6601_MS_TPC_WRITE_PAGE_DATA 0x0D 218 + #define AU6601_MS_TPC_WRITE_REG 0x0B 219 + #define AU6601_MS_TPC_SET_RW_REG_ADRS 0x08 220 + #define AU6601_MS_TPC_SET_CMD 0x0E 221 + #define AU6601_MS_TPC_EX_SET_CMD 0x09 222 + #define AU6601_MS_TPC_READ_SHORT_DATA 0x03 223 + #define AU6601_MS_TPC_WRITE_SHORT_DATA 0x0C 224 + 225 + #define AU6601_MS_TRANSFER_MODE 0xa3 226 + #define AU6601_MS_XFER_INT_TIMEOUT_CHK BIT(2) 227 + #define AU6601_MS_XFER_DMA_ENABLE BIT(1) 228 + #define AU6601_MS_XFER_START BIT(0) 229 + 230 + #define AU6601_MS_DATA_PIN_STATE 0xa4 231 + 232 + #define AU6601_MS_INT_STATUS 0xb0 233 + #define AU6601_MS_INT_ENABLE 0xb4 234 + #define AU6601_MS_INT_OVER_CURRENT_ERROR BIT(23) 235 + #define AU6601_MS_INT_DATA_CRC_ERROR BIT(21) 236 + #define AU6601_MS_INT_INT_TIMEOUT BIT(20) 237 + #define AU6601_MS_INT_INT_RESP_ERROR BIT(19) 238 + #define AU6601_MS_INT_CED_ERROR BIT(18) 239 + #define AU6601_MS_INT_TPC_TIMEOUT BIT(16) 240 + #define AU6601_MS_INT_ERROR BIT(15) 241 + #define AU6601_MS_INT_CARD_INSERT BIT(7) 242 + #define AU6601_MS_INT_CARD_REMOVE BIT(6) 243 + #define AU6601_MS_INT_BUF_READ_RDY BIT(5) 244 + #define AU6601_MS_INT_BUF_WRITE_RDY BIT(4) 245 + #define AU6601_MS_INT_DMA_END BIT(3) 246 + #define AU6601_MS_INT_TPC_END BIT(1) 247 + 248 + #define AU6601_MS_INT_DATA_MASK 0x00000038 249 + #define AU6601_MS_INT_TPC_MASK 0x003d8002 250 + #define AU6601_MS_INT_TPC_ERROR 0x003d0000 251 + 252 + #define ALCOR_PCIE_LINK_CTRL_OFFSET 0x10 253 + #define ALCOR_PCIE_LINK_CAP_OFFSET 0x0c 254 + #define ALCOR_CAP_START_OFFSET 0x34 255 + 256 + struct alcor_dev_cfg { 257 + u8 dma; 258 + }; 259 + 260 + struct alcor_pci_priv { 261 + struct pci_dev *pdev; 262 + struct pci_dev *parent_pdev; 263 + struct device *dev; 264 + void __iomem *iobase; 265 + unsigned int irq; 266 + 267 + unsigned long id; /* idr id */ 268 + 269 + struct alcor_dev_cfg *cfg; 270 + 271 + /* PCI ASPM related vars */ 272 + int pdev_cap_off; 273 + u8 pdev_aspm_cap; 274 + int parent_cap_off; 275 + u8 parent_aspm_cap; 276 + u8 ext_config_dev_aspm; 277 + }; 278 + 279 + void alcor_write8(struct alcor_pci_priv *priv, u8 val, unsigned int addr); 280 + void alcor_write16(struct alcor_pci_priv *priv, u16 val, unsigned int addr); 281 + void alcor_write32(struct alcor_pci_priv *priv, u32 val, unsigned int addr); 282 + void alcor_write32be(struct alcor_pci_priv *priv, u32 val, unsigned int addr); 283 + u8 alcor_read8(struct alcor_pci_priv *priv, unsigned int addr); 284 + u32 alcor_read32(struct alcor_pci_priv *priv, unsigned int addr); 285 + u32 alcor_read32be(struct alcor_pci_priv *priv, unsigned int addr); 286 + #endif
+2 -7
include/linux/mfd/tmio.h
··· 54 54 * idle before writing to some registers. 55 55 */ 56 56 #define TMIO_MMC_HAS_IDLE_WAIT BIT(4) 57 - /* 58 - * A GPIO is used for card hotplug detection. We need an extra flag for this, 59 - * because 0 is a valid GPIO number too, and requiring users to specify 60 - * cd_gpio < 0 to disable GPIO hotplug would break backwards compatibility. 61 - */ 62 - #define TMIO_MMC_USE_GPIO_CD BIT(5) 57 + 58 + /* BIT(5) is unused */ 63 59 64 60 /* 65 61 * Some controllers have CMD12 automatically ··· 100 104 unsigned long capabilities2; 101 105 unsigned long flags; 102 106 u32 ocr_mask; /* available voltages */ 103 - unsigned int cd_gpio; 104 107 int alignment_shift; 105 108 dma_addr_t dma_rx_offset; 106 109 unsigned int max_blk_count;
+4 -1
include/linux/mmc/host.h
··· 147 147 /* Prepare HS400 target operating frequency depending host driver */ 148 148 int (*prepare_hs400_tuning)(struct mmc_host *host, struct mmc_ios *ios); 149 149 150 + /* Prepare switch to DDR during the HS400 init sequence */ 151 + int (*hs400_prepare_ddr)(struct mmc_host *host); 152 + 150 153 /* Prepare for switching from HS400 to HS200 */ 151 154 void (*hs400_downgrade)(struct mmc_host *host); 152 155 ··· 334 331 #define MMC_CAP_UHS (MMC_CAP_UHS_SDR12 | MMC_CAP_UHS_SDR25 | \ 335 332 MMC_CAP_UHS_SDR50 | MMC_CAP_UHS_SDR104 | \ 336 333 MMC_CAP_UHS_DDR50) 337 - /* (1 << 21) is free for reuse */ 334 + #define MMC_CAP_SYNC_RUNTIME_PM (1 << 21) /* Synced runtime PM suspends. */ 338 335 #define MMC_CAP_DRIVER_TYPE_A (1 << 23) /* Host supports Driver Type A */ 339 336 #define MMC_CAP_DRIVER_TYPE_C (1 << 24) /* Host supports Driver Type C */ 340 337 #define MMC_CAP_DRIVER_TYPE_D (1 << 25) /* Host supports Driver Type D */
-5
include/linux/mmc/slot-gpio.h
··· 17 17 struct mmc_host; 18 18 19 19 int mmc_gpio_get_ro(struct mmc_host *host); 20 - int mmc_gpio_request_ro(struct mmc_host *host, unsigned int gpio); 21 - 22 20 int mmc_gpio_get_cd(struct mmc_host *host); 23 - int mmc_gpio_request_cd(struct mmc_host *host, unsigned int gpio, 24 - unsigned int debounce); 25 - 26 21 int mmc_gpiod_request_cd(struct mmc_host *host, const char *con_id, 27 22 unsigned int idx, bool override_active_level, 28 23 unsigned int debounce, bool *gpio_invert);
-4
include/linux/platform_data/mmc-esdhc-imx.h
··· 30 30 * 31 31 * ESDHC_WP(CD)_CONTROLLER type is not available on i.MX25/35. 32 32 * 33 - * @wp_gpio: gpio for write_protect 34 - * @cd_gpio: gpio for card_detect interrupt 35 33 * @wp_type: type of write_protect method (see wp_types enum above) 36 34 * @cd_type: type of card_detect method (see cd_types enum above) 37 35 */ 38 36 39 37 struct esdhc_platform_data { 40 - unsigned int wp_gpio; 41 - unsigned int cd_gpio; 42 38 enum wp_types wp_type; 43 39 enum cd_types cd_type; 44 40 int max_bus_width;
-4
include/linux/platform_data/mmc-pxamci.h
··· 15 15 int (*get_ro)(struct device *); 16 16 int (*setpower)(struct device *, unsigned int); 17 17 void (*exit)(struct device *, void *); 18 - int gpio_card_detect; /* gpio detecting card insertion */ 19 - int gpio_card_ro; /* gpio detecting read only toggle */ 20 18 bool gpio_card_ro_invert; /* gpio ro is inverted */ 21 - int gpio_power; /* gpio powering up MMC bus */ 22 - bool gpio_power_invert; /* gpio power is inverted */ 23 19 }; 24 20 25 21 extern void pxa_set_mci_info(struct pxamci_platform_data *info);
-4
include/linux/platform_data/mmc-s3cmci.h
··· 7 7 * @no_wprotect: Set this to indicate there is no write-protect switch. 8 8 * @no_detect: Set this if there is no detect switch. 9 9 * @wprotect_invert: Invert the default sense of the write protect switch. 10 - * @detect_invert: Invert the default sense of the write protect switch. 11 10 * @use_dma: Set to allow the use of DMA. 12 11 * @gpio_detect: GPIO number for the card detect line. 13 12 * @gpio_wprotect: GPIO number for the write protect line. ··· 30 31 unsigned int no_wprotect:1; 31 32 unsigned int no_detect:1; 32 33 unsigned int wprotect_invert:1; 33 - unsigned int detect_invert:1; /* set => detect active high */ 34 34 unsigned int use_dma:1; 35 35 36 - unsigned int gpio_detect; 37 - unsigned int gpio_wprotect; 38 36 unsigned long ocr_avail; 39 37 void (*set_power)(unsigned char power_mode, 40 38 unsigned short vdd);
-15
include/linux/spi/mmc_spi.h
··· 8 8 struct device; 9 9 struct mmc_host; 10 10 11 - #define MMC_SPI_USE_CD_GPIO (1 << 0) 12 - #define MMC_SPI_USE_RO_GPIO (1 << 1) 13 - #define MMC_SPI_CD_GPIO_ACTIVE_LOW (1 << 2) 14 - #define MMC_SPI_RO_GPIO_ACTIVE_LOW (1 << 3) 15 - 16 11 /* Put this in platform_data of a device being used to manage an MMC/SD 17 12 * card slot. (Modeled after PXA mmc glue; see that for usage examples.) 18 13 * ··· 21 26 irqreturn_t (*)(int, void *), 22 27 void *); 23 28 void (*exit)(struct device *, void *); 24 - 25 - /* 26 - * Card Detect and Read Only GPIOs. To enable debouncing on the card 27 - * detect GPIO, set the cd_debounce to the debounce time in 28 - * microseconds. 29 - */ 30 - unsigned int flags; 31 - unsigned int cd_gpio; 32 - unsigned int cd_debounce; 33 - unsigned int ro_gpio; 34 29 35 30 /* Capabilities to pass into mmc core (e.g. MMC_CAP_NEEDS_POLL). */ 36 31 unsigned long caps;
+4 -1
include/uapi/linux/mmc/ioctl.h
··· 5 5 #include <linux/types.h> 6 6 7 7 struct mmc_ioc_cmd { 8 - /* Implies direction of data. true = write, false = read */ 8 + /* 9 + * Direction of data: nonzero = write, zero = read. 10 + * Bit 31 selects 'Reliable Write' for RPMB. 11 + */ 9 12 int write_flag; 10 13 11 14 /* Application-specific command. true = precede with CMD55 */