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

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

Pull MMC updates from Ulf Hansson:
"These are the updates for MMC and MEMSTICK for v5.5.

Note that this also contains quite some additional changes reaching
beyond both the MMC and MEMSTICK subsystems. This is primarily because
of fixing an old regression for a WiFi driver based on the SDIO
interface on an OMAP openpandora board

MMC core:
- Add CMD13 polling for MMC IOCTLS with R1B response.
- Add common DT properties for clk-phase-delays for various speed
modes.
- Fix size overflow for mmc gp-partitions.
- Re-work HW reset for SDIO cards, which also includes a re-work for
Marvell's WiFi mwifiex SDIO func driver.

MMC host:
- jz4740: Add support for X1000 and JZ4760.
- jz4740: Add support for 8-bit bus and for low power mode.
- mmci: Add support for HW busy timeout for the stm32_sdmmc variant.
- owl-mmc: Add driver for Actions Semi Owl SoCs SD/MMC controller.
- renesas_sdhi: Add support for r8a774b1.
- sdhci_am654: Add support for Command Queuing Engine for J721E.
- sdhci-milbeaut: Add driver for the Milbeaut SD controller.
- sdhci-of-arasan: Add support for ZynqMP tap-delays.
- sdhci-of-arasan: Add support for clk-phase-delays for SD cards.
- sdhci-of-arasan: Add support for Intel LGM SDXC.
- sdhci-of-aspeed: Allow inversion of the internal card detect
signal.
- sdhci-of-esdhc: Fixup workaround for erratum A-008171 for tunings.
- sdhci-of-at91: Improve support for calibration.
- sdhci-pci: Add support for Intel JSL.
- sdhci-pci: Add quirk for AMD SDHC Device 0x7906.
- tmio: Enable support for erase/discard/trim requests.

MMC/OMAP/pandora/wl1251:

The TI wl1251 WiFi driver for SDIO on the OMAP openpandora board has
been broken since v4.7. To fix the problems, changes have been made
cross subsystems, but also to OMAP2 machine code and to openpandora
DTS files, as summarized below. Relevant changes have been tagged for
stable.

- mmc/wl1251: Re-introduce lost SDIO quirks and vendor-id for wl1251
- omap/omap_hsmmc: Remove redundant platform config for openpandora
- omap_hsmmc: Initialize non-std SDIO card for wl1251 for pandora
- omap/dts/pandora: Specify wl1251 through a child node of mmc3
- wl1251: Add devicetree support for TI wl1251 SDIO"

* tag 'mmc-v5.5' of git://git.kernel.org/pub/scm/linux/kernel/git/ulfh/mmc: (73 commits)
dt-bindings: mmc: Correct the type of the clk phase properties
Revert "mmc: tmio: remove workaround for NON_REMOVABLE"
memstick: Fix Kconfig indentation
mmc: sdhci-of-arasan: Add support for ZynqMP Platform Tap Delays Setup
dt-bindings: mmc: arasan: Document 'xlnx,zynqmp-8.9a' controller
firmware: xilinx: Add SDIO Tap Delay nodes
mmc: sdhci-of-arasan: Add support to set clock phase delays for SD
dt-bindings: mmc: Add optional generic properties for mmc
mmc: sdhci-of-arasan: Add sampling clock for a phy to use
dt-bindings: mmc: arasan: Update Documentation for the input clock
mmc: sdhci-of-arasan: Separate out clk related data to another structure
mmc: sdhci: Fix grammar in warning message
mmc: sdhci-of-aspeed: add inversion signal presence
mmc: sdhci-of-aspeed: enable CONFIG_MMC_SDHCI_IO_ACCESSORS
mmc: sdhci_am654: Add Support for Command Queuing Engine to J721E
mmc: core: Fix size overflow for mmc partitions
mmc: tmio: Add MMC_CAP_ERASE to allow erase/discard/trim requests
net: wireless: ti: remove local VENDOR_ID and DEVICE_ID definitions
net: wireless: ti: wl1251 use new SDIO_VENDOR_ID_TI_WL1251 definition
mmc: core: fix wl1251 sdio quirks
...

+2652 -715
+39 -3
Documentation/devicetree/bindings/mmc/arasan,sdhci.txt
··· 15 15 - "arasan,sdhci-5.1": generic Arasan SDHCI 5.1 PHY 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 + - "xlnx,zynqmp-8.9a": ZynqMP SDHCI 8.9a PHY 19 + For this device it is strongly suggested to include clock-output-names and 20 + #clock-cells. 18 21 - "ti,am654-sdhci-5.1", "arasan,sdhci-5.1": TI AM654 MMC PHY 19 22 Note: This binding has been deprecated and moved to [5]. 20 23 - "intel,lgm-sdhci-5.1-emmc", "arasan,sdhci-5.1": Intel LGM eMMC PHY 24 + For this device it is strongly suggested to include arasan,soc-ctl-syscon. 25 + - "intel,lgm-sdhci-5.1-sdxc", "arasan,sdhci-5.1": Intel LGM SDXC PHY 21 26 For this device it is strongly suggested to include arasan,soc-ctl-syscon. 22 27 23 28 [5] Documentation/devicetree/bindings/mmc/sdhci-am654.txt ··· 43 38 - clock-output-names: If specified, this will be the name of the card clock 44 39 which will be exposed by this device. Required if #clock-cells is 45 40 specified. 46 - - #clock-cells: If specified this should be the value <0>. With this property 47 - in place we will export a clock representing the Card Clock. This clock 48 - is expected to be consumed by our PHY. You must also specify 41 + - #clock-cells: If specified this should be the value <0> or <1>. With this 42 + property in place we will export one or two clocks representing the Card 43 + Clock. These clocks are expected to be consumed by our PHY. 49 44 - xlnx,fails-without-test-cd: when present, the controller doesn't work when 50 45 the CD line is not connected properly, and the line is not connected 51 46 properly. Test mode can be used to force the controller to function. 52 47 - xlnx,int-clock-stable-broken: when present, the controller always reports 53 48 that the internal clock is stable even when it is not. 49 + 50 + - xlnx,mio-bank: When specified, this will indicate the MIO bank number in 51 + which the command and data lines are configured. If not specified, driver 52 + will assume this as 0. 54 53 55 54 Example: 56 55 sdhci@e0100000 { ··· 92 83 #clock-cells = <0>; 93 84 }; 94 85 86 + sdhci: mmc@ff160000 { 87 + compatible = "xlnx,zynqmp-8.9a", "arasan,sdhci-8.9a"; 88 + interrupt-parent = <&gic>; 89 + interrupts = <0 48 4>; 90 + reg = <0x0 0xff160000 0x0 0x1000>; 91 + clocks = <&clk200>, <&clk200>; 92 + clock-names = "clk_xin", "clk_ahb"; 93 + clock-output-names = "clk_out_sd0", "clk_in_sd0"; 94 + #clock-cells = <1>; 95 + clk-phase-sd-hs = <63>, <72>; 96 + }; 97 + 95 98 emmc: sdhci@ec700000 { 96 99 compatible = "intel,lgm-sdhci-5.1-emmc", "arasan,sdhci-5.1"; 97 100 reg = <0xec700000 0x300>; ··· 115 94 clock-output-names = "emmc_cardclock"; 116 95 #clock-cells = <0>; 117 96 phys = <&emmc_phy>; 97 + phy-names = "phy_arasan"; 98 + arasan,soc-ctl-syscon = <&sysconf>; 99 + }; 100 + 101 + sdxc: sdhci@ec600000 { 102 + compatible = "arasan,sdhci-5.1", "intel,lgm-sdhci-5.1-sdxc"; 103 + reg = <0xec600000 0x300>; 104 + interrupt-parent = <&ioapic1>; 105 + interrupts = <43 1>; 106 + clocks = <&cgu0 LGM_CLK_SDIO>, <&cgu0 LGM_CLK_NGI>, 107 + <&cgu0 LGM_GCLK_SDXC>; 108 + clock-names = "clk_xin", "clk_ahb", "gate"; 109 + clock-output-names = "sdxc_cardclock"; 110 + #clock-cells = <0>; 111 + phys = <&sdxc_phy>; 118 112 phy-names = "phy_arasan"; 119 113 arasan,soc-ctl-syscon = <&sysconf>; 120 114 };
+3
Documentation/devicetree/bindings/mmc/fsl-imx-esdhc.txt
··· 18 18 "fsl,imx6ull-usdhc" 19 19 "fsl,imx7d-usdhc" 20 20 "fsl,imx7ulp-usdhc" 21 + "fsl,imx8mq-usdhc" 22 + "fsl,imx8mm-usdhc" 23 + "fsl,imx8mn-usdhc" 21 24 "fsl,imx8qxp-usdhc" 22 25 23 26 Optional properties:
+5 -3
Documentation/devicetree/bindings/mmc/jz4740.txt
··· 1 - * Ingenic JZ47xx MMC controllers 1 + * Ingenic XBurst MMC controllers 2 2 3 3 This file documents the device tree properties used for the MMC controller in 4 - Ingenic JZ4740/JZ4780 SoCs. These are in addition to the core MMC properties 5 - described in mmc.txt. 4 + Ingenic JZ4740/JZ4760/JZ4780/X1000 SoCs. These are in addition to the core MMC 5 + properties described in mmc.txt. 6 6 7 7 Required properties: 8 8 - compatible: Should be one of the following: 9 9 - "ingenic,jz4740-mmc" for the JZ4740 10 10 - "ingenic,jz4725b-mmc" for the JZ4725B 11 + - "ingenic,jz4760-mmc" for the JZ4760 11 12 - "ingenic,jz4780-mmc" for the JZ4780 13 + - "ingenic,x1000-mmc" for the X1000 12 14 - reg: Should contain the MMC controller registers location and length. 13 15 - interrupts: Should contain the interrupt specifier of the MMC controller. 14 16 - clocks: Clock for the MMC controller.
+14
Documentation/devicetree/bindings/mmc/mmc-controller.yaml
··· 333 333 required: 334 334 - reg 335 335 336 + "^clk-phase-(legacy|sd-hs|mmc-(hs|hs[24]00|ddr52)|uhs-(sdr(12|25|50|104)|ddr50))$": 337 + allOf: 338 + - $ref: /schemas/types.yaml#/definitions/uint32-array 339 + minItems: 2 340 + maxItems: 2 341 + items: 342 + minimum: 0 343 + maximum: 359 344 + description: 345 + Set the clock (phase) delays which are to be configured in the 346 + controller while switching to particular speed mode. These values 347 + are in pair of degrees. 348 + 336 349 dependencies: 337 350 cd-debounce-delay-ms: [ cd-gpios ] 338 351 fixed-emmc-driver-type: [ non-removable ] ··· 364 351 keep-power-in-suspend; 365 352 wakeup-source; 366 353 mmc-pwrseq = <&sdhci0_pwrseq>; 354 + clk-phase-sd-hs = <63>, <72>; 367 355 }; 368 356 369 357 - |
+59
Documentation/devicetree/bindings/mmc/owl-mmc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/mmc/owl-mmc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Actions Semi Owl SoCs SD/MMC/SDIO controller 8 + 9 + allOf: 10 + - $ref: "mmc-controller.yaml" 11 + 12 + maintainers: 13 + - Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 14 + 15 + properties: 16 + compatible: 17 + const: actions,owl-mmc 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + clocks: 26 + minItems: 1 27 + 28 + resets: 29 + maxItems: 1 30 + 31 + dmas: 32 + maxItems: 1 33 + 34 + dma-names: 35 + const: mmc 36 + 37 + required: 38 + - compatible 39 + - reg 40 + - interrupts 41 + - clocks 42 + - resets 43 + - dmas 44 + - dma-names 45 + 46 + examples: 47 + - | 48 + mmc0: mmc@e0330000 { 49 + compatible = "actions,owl-mmc"; 50 + reg = <0x0 0xe0330000 0x0 0x4000>; 51 + interrupts = <0 42 4>; 52 + clocks = <&cmu 56>; 53 + resets = <&cmu 23>; 54 + dmas = <&dma 2>; 55 + dma-names = "mmc"; 56 + bus-width = <4>; 57 + }; 58 + 59 + ...
+1
Documentation/devicetree/bindings/mmc/renesas,sdhi.txt
··· 11 11 "renesas,sdhi-r8a7744" - SDHI IP on R8A7744 SoC 12 12 "renesas,sdhi-r8a7745" - SDHI IP on R8A7745 SoC 13 13 "renesas,sdhi-r8a774a1" - SDHI IP on R8A774A1 SoC 14 + "renesas,sdhi-r8a774b1" - SDHI IP on R8A774B1 SoC 14 15 "renesas,sdhi-r8a774c0" - SDHI IP on R8A774C0 SoC 15 16 "renesas,sdhi-r8a77470" - SDHI IP on R8A77470 SoC 16 17 "renesas,sdhi-mmc-r8a77470" - SDHI/MMC IP on R8A77470 SoC
+5
Documentation/devicetree/bindings/mmc/sdhci-atmel.txt
··· 9 9 - clocks: Phandlers to the clocks. 10 10 - clock-names: Must be "hclock", "multclk", "baseclk"; 11 11 12 + Optional properties: 13 + - microchip,sdcal-inverted: when present, polarity on the SDCAL SoC pin is 14 + inverted. The default polarity for this signal is described in the datasheet. 15 + For instance on SAMA5D2, the pin is usually tied to the GND with a resistor 16 + and a capacitor (see "SDMMC I/O Calibration" chapter). 12 17 13 18 Example: 14 19
+30
Documentation/devicetree/bindings/mmc/sdhci-milbeaut.txt
··· 1 + * SOCIONEXT Milbeaut SDHCI controller 2 + 3 + This file documents differences between the core properties in mmc.txt 4 + and the properties used by the sdhci_milbeaut driver. 5 + 6 + Required properties: 7 + - compatible: "socionext,milbeaut-m10v-sdhci-3.0" 8 + - clocks: Must contain an entry for each entry in clock-names. It is a 9 + list of phandles and clock-specifier pairs. 10 + See ../clocks/clock-bindings.txt for details. 11 + - clock-names: Should contain the following two entries: 12 + "iface" - clock used for sdhci interface 13 + "core" - core clock for sdhci controller 14 + 15 + Optional properties: 16 + - fujitsu,cmd-dat-delay-select: boolean property indicating that this host 17 + requires the CMD_DAT_DELAY control to be enabled. 18 + 19 + Example: 20 + sdhci3: mmc@1b010000 { 21 + compatible = "socionext,milbeaut-m10v-sdhci-3.0"; 22 + reg = <0x1b010000 0x10000>; 23 + interrupts = <0 265 0x4>; 24 + voltage-ranges = <3300 3300>; 25 + bus-width = <4>; 26 + clocks = <&clk 7>, <&ahb_clk>; 27 + clock-names = "core", "iface"; 28 + cap-sdio-irq; 29 + fujitsu,cmd-dat-delay-select; 30 + };
+26
Documentation/devicetree/bindings/net/wireless/ti,wl1251.txt
··· 35 35 ti,power-gpio = <&gpio3 23 GPIO_ACTIVE_HIGH>; /* 87 */ 36 36 }; 37 37 }; 38 + 39 + &mmc3 { 40 + vmmc-supply = <&wlan_en>; 41 + 42 + bus-width = <4>; 43 + non-removable; 44 + ti,non-removable; 45 + cap-power-off-card; 46 + 47 + pinctrl-names = "default"; 48 + pinctrl-0 = <&mmc3_pins>; 49 + 50 + #address-cells = <1>; 51 + #size-cells = <0>; 52 + 53 + wlan: wifi@1 { 54 + compatible = "ti,wl1251"; 55 + 56 + reg = <1>; 57 + 58 + interrupt-parent = <&gpio1>; 59 + interrupts = <21 IRQ_TYPE_LEVEL_HIGH>; /* GPIO_21 */ 60 + 61 + ti,wl1251-has-eeprom; 62 + }; 63 + };
+3 -3
MAINTAINERS
··· 1399 1399 F: drivers/clocksource/timer-owl* 1400 1400 F: drivers/dma/owl-dma.c 1401 1401 F: drivers/i2c/busses/i2c-owl.c 1402 + F: drivers/mmc/host/owl-mmc.c 1402 1403 F: drivers/pinctrl/actions/* 1403 1404 F: drivers/soc/actions/ 1404 1405 F: include/dt-bindings/power/owl-* ··· 1408 1407 F: Documentation/devicetree/bindings/clock/actions,owl-cmu.txt 1409 1408 F: Documentation/devicetree/bindings/dma/owl-dma.txt 1410 1409 F: Documentation/devicetree/bindings/i2c/i2c-owl.txt 1410 + F: Documentation/devicetree/bindings/mmc/owl-mmc.yaml 1411 1411 F: Documentation/devicetree/bindings/pinctrl/actions,s900-pinctrl.txt 1412 1412 F: Documentation/devicetree/bindings/power/actions,owl-sps.txt 1413 1413 F: Documentation/devicetree/bindings/timer/actions,owl-timer.txt ··· 17614 17612 F: drivers/hwmon/vt8231.c 17615 17613 17616 17614 VUB300 USB to SDIO/SD/MMC bridge chip 17617 - M: Tony Olech <tony.olech@elandigitalsystems.com> 17618 17615 L: linux-mmc@vger.kernel.org 17619 - L: linux-usb@vger.kernel.org 17620 - S: Supported 17616 + S: Orphan 17621 17617 F: drivers/mmc/host/vub300.c 17622 17618 17623 17619 W1 DALLAS'S 1-WIRE BUS
+34 -2
arch/arm/boot/dts/omap3-pandora-common.dtsi
··· 226 226 gpio = <&gpio6 4 GPIO_ACTIVE_HIGH>; /* GPIO_164 */ 227 227 }; 228 228 229 + /* wl1251 wifi+bt module */ 230 + wlan_en: fixed-regulator-wg7210_en { 231 + compatible = "regulator-fixed"; 232 + regulator-name = "vwlan"; 233 + regulator-min-microvolt = <1800000>; 234 + regulator-max-microvolt = <1800000>; 235 + startup-delay-us = <50000>; 236 + enable-active-high; 237 + gpio = <&gpio1 23 GPIO_ACTIVE_HIGH>; 238 + }; 239 + 229 240 /* wg7210 (wifi+bt module) 32k clock buffer */ 230 241 wg7210_32k: fixed-regulator-wg7210_32k { 231 242 compatible = "regulator-fixed"; ··· 533 522 /*wp-gpios = <&gpio4 31 GPIO_ACTIVE_HIGH>;*/ /* GPIO_127 */ 534 523 }; 535 524 536 - /* mmc3 is probed using pdata-quirks to pass wl1251 card data */ 537 525 &mmc3 { 538 - status = "disabled"; 526 + vmmc-supply = <&wlan_en>; 527 + 528 + bus-width = <4>; 529 + non-removable; 530 + ti,non-removable; 531 + cap-power-off-card; 532 + 533 + pinctrl-names = "default"; 534 + pinctrl-0 = <&mmc3_pins>; 535 + 536 + #address-cells = <1>; 537 + #size-cells = <0>; 538 + 539 + wlan: wifi@1 { 540 + compatible = "ti,wl1251"; 541 + 542 + reg = <1>; 543 + 544 + interrupt-parent = <&gpio1>; 545 + interrupts = <21 IRQ_TYPE_LEVEL_HIGH>; /* GPIO_21 */ 546 + 547 + ti,wl1251-has-eeprom; 548 + }; 539 549 }; 540 550 541 551 /* bluetooth*/
-3
arch/arm/mach-omap2/Makefile
··· 216 216 217 217 # Platform specific device init code 218 218 219 - omap-hsmmc-$(CONFIG_MMC_OMAP_HS) := hsmmc.o 220 - obj-y += $(omap-hsmmc-m) $(omap-hsmmc-y) 221 - 222 219 obj-y += omap_phy_internal.o 223 220 224 221 obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o
-1
arch/arm/mach-omap2/common.h
··· 352 352 struct omap_sdrc_params; 353 353 extern void omap_sdrc_init(struct omap_sdrc_params *sdrc_cs0, 354 354 struct omap_sdrc_params *sdrc_cs1); 355 - struct omap2_hsmmc_info; 356 355 extern void omap_reserve(void); 357 356 358 357 struct omap_hwmod;
-171
arch/arm/mach-omap2/hsmmc.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-only 2 - /* 3 - * linux/arch/arm/mach-omap2/hsmmc.c 4 - * 5 - * Copyright (C) 2007-2008 Texas Instruments 6 - * Copyright (C) 2008 Nokia Corporation 7 - * Author: Texas Instruments 8 - */ 9 - #include <linux/kernel.h> 10 - #include <linux/slab.h> 11 - #include <linux/string.h> 12 - #include <linux/delay.h> 13 - #include <linux/mmc/host.h> 14 - #include <linux/platform_data/hsmmc-omap.h> 15 - 16 - #include "soc.h" 17 - #include "omap_device.h" 18 - 19 - #include "hsmmc.h" 20 - #include "control.h" 21 - 22 - #if IS_ENABLED(CONFIG_MMC_OMAP_HS) 23 - 24 - static u16 control_pbias_offset; 25 - static u16 control_devconf1_offset; 26 - 27 - #define HSMMC_NAME_LEN 9 28 - 29 - static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c, 30 - struct omap_hsmmc_platform_data *mmc) 31 - { 32 - char *hc_name; 33 - 34 - hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL); 35 - if (!hc_name) 36 - return -ENOMEM; 37 - 38 - snprintf(hc_name, (HSMMC_NAME_LEN + 1), "mmc%islot%i", c->mmc, 1); 39 - mmc->name = hc_name; 40 - mmc->caps = c->caps; 41 - mmc->reg_offset = 0; 42 - 43 - return 0; 44 - } 45 - 46 - static int omap_hsmmc_done; 47 - 48 - void omap_hsmmc_late_init(struct omap2_hsmmc_info *c) 49 - { 50 - struct platform_device *pdev; 51 - int res; 52 - 53 - if (omap_hsmmc_done) 54 - return; 55 - 56 - omap_hsmmc_done = 1; 57 - 58 - for (; c->mmc; c++) { 59 - pdev = c->pdev; 60 - if (!pdev) 61 - continue; 62 - res = omap_device_register(pdev); 63 - if (res) 64 - pr_err("Could not late init MMC\n"); 65 - } 66 - } 67 - 68 - #define MAX_OMAP_MMC_HWMOD_NAME_LEN 16 69 - 70 - static void __init omap_hsmmc_init_one(struct omap2_hsmmc_info *hsmmcinfo, 71 - int ctrl_nr) 72 - { 73 - struct omap_hwmod *oh; 74 - struct omap_hwmod *ohs[1]; 75 - struct omap_device *od; 76 - struct platform_device *pdev; 77 - char oh_name[MAX_OMAP_MMC_HWMOD_NAME_LEN]; 78 - struct omap_hsmmc_platform_data *mmc_data; 79 - struct omap_hsmmc_dev_attr *mmc_dev_attr; 80 - char *name; 81 - int res; 82 - 83 - mmc_data = kzalloc(sizeof(*mmc_data), GFP_KERNEL); 84 - if (!mmc_data) 85 - return; 86 - 87 - res = omap_hsmmc_pdata_init(hsmmcinfo, mmc_data); 88 - if (res < 0) 89 - goto free_mmc; 90 - 91 - name = "omap_hsmmc"; 92 - res = snprintf(oh_name, MAX_OMAP_MMC_HWMOD_NAME_LEN, 93 - "mmc%d", ctrl_nr); 94 - WARN(res >= MAX_OMAP_MMC_HWMOD_NAME_LEN, 95 - "String buffer overflow in MMC%d device setup\n", ctrl_nr); 96 - 97 - oh = omap_hwmod_lookup(oh_name); 98 - if (!oh) { 99 - pr_err("Could not look up %s\n", oh_name); 100 - goto free_name; 101 - } 102 - ohs[0] = oh; 103 - if (oh->dev_attr != NULL) { 104 - mmc_dev_attr = oh->dev_attr; 105 - mmc_data->controller_flags = mmc_dev_attr->flags; 106 - } 107 - 108 - pdev = platform_device_alloc(name, ctrl_nr - 1); 109 - if (!pdev) { 110 - pr_err("Could not allocate pdev for %s\n", name); 111 - goto free_name; 112 - } 113 - dev_set_name(&pdev->dev, "%s.%d", pdev->name, pdev->id); 114 - 115 - od = omap_device_alloc(pdev, ohs, 1); 116 - if (IS_ERR(od)) { 117 - pr_err("Could not allocate od for %s\n", name); 118 - goto put_pdev; 119 - } 120 - 121 - res = platform_device_add_data(pdev, mmc_data, 122 - sizeof(struct omap_hsmmc_platform_data)); 123 - if (res) { 124 - pr_err("Could not add pdata for %s\n", name); 125 - goto put_pdev; 126 - } 127 - 128 - hsmmcinfo->pdev = pdev; 129 - 130 - res = omap_device_register(pdev); 131 - if (res) { 132 - pr_err("Could not register od for %s\n", name); 133 - goto free_od; 134 - } 135 - 136 - goto free_mmc; 137 - 138 - free_od: 139 - omap_device_delete(od); 140 - 141 - put_pdev: 142 - platform_device_put(pdev); 143 - 144 - free_name: 145 - kfree(mmc_data->name); 146 - 147 - free_mmc: 148 - kfree(mmc_data); 149 - } 150 - 151 - void __init omap_hsmmc_init(struct omap2_hsmmc_info *controllers) 152 - { 153 - if (omap_hsmmc_done) 154 - return; 155 - 156 - omap_hsmmc_done = 1; 157 - 158 - if (cpu_is_omap2430()) { 159 - control_pbias_offset = OMAP243X_CONTROL_PBIAS_LITE; 160 - control_devconf1_offset = OMAP243X_CONTROL_DEVCONF1; 161 - } else { 162 - control_pbias_offset = OMAP343X_CONTROL_PBIAS_LITE; 163 - control_devconf1_offset = OMAP343X_CONTROL_DEVCONF1; 164 - } 165 - 166 - for (; controllers->mmc; controllers++) 167 - omap_hsmmc_init_one(controllers, controllers->mmc); 168 - 169 - } 170 - 171 - #endif
-32
arch/arm/mach-omap2/hsmmc.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0-only */ 2 - /* 3 - * MMC definitions for OMAP2 4 - */ 5 - 6 - struct mmc_card; 7 - 8 - struct omap2_hsmmc_info { 9 - u8 mmc; /* controller 1/2/3 */ 10 - u32 caps; /* 4/8 wires and any additional host 11 - * capabilities OR'd (ref. linux/mmc/host.h) */ 12 - struct platform_device *pdev; /* mmc controller instance */ 13 - /* init some special card */ 14 - void (*init_card)(struct mmc_card *card); 15 - }; 16 - 17 - #if IS_ENABLED(CONFIG_MMC_OMAP_HS) 18 - 19 - void omap_hsmmc_init(struct omap2_hsmmc_info *); 20 - void omap_hsmmc_late_init(struct omap2_hsmmc_info *); 21 - 22 - #else 23 - 24 - static inline void omap_hsmmc_init(struct omap2_hsmmc_info *info) 25 - { 26 - } 27 - 28 - static inline void omap_hsmmc_late_init(struct omap2_hsmmc_info *info) 29 - { 30 - } 31 - 32 - #endif
-105
arch/arm/mach-omap2/pdata-quirks.c
··· 7 7 #include <linux/clk.h> 8 8 #include <linux/davinci_emac.h> 9 9 #include <linux/gpio.h> 10 - #include <linux/gpio/machine.h> 11 10 #include <linux/init.h> 12 11 #include <linux/kernel.h> 13 12 #include <linux/of_platform.h> ··· 32 33 #include "omap_device.h" 33 34 #include "omap-secure.h" 34 35 #include "soc.h" 35 - #include "hsmmc.h" 36 36 37 37 static struct omap_hsmmc_platform_data __maybe_unused mmc_pdata[2]; 38 38 ··· 298 300 } 299 301 300 302 /* omap3pandora legacy devices */ 301 - #define PANDORA_WIFI_IRQ_GPIO 21 302 - #define PANDORA_WIFI_NRESET_GPIO 23 303 303 304 304 static struct platform_device pandora_backlight = { 305 305 .name = "pandora-backlight", 306 306 .id = -1, 307 307 }; 308 308 309 - static struct regulator_consumer_supply pandora_vmmc3_supply[] = { 310 - REGULATOR_SUPPLY("vmmc", "omap_hsmmc.2"), 311 - }; 312 - 313 - static struct regulator_init_data pandora_vmmc3 = { 314 - .constraints = { 315 - .valid_ops_mask = REGULATOR_CHANGE_STATUS, 316 - }, 317 - .num_consumer_supplies = ARRAY_SIZE(pandora_vmmc3_supply), 318 - .consumer_supplies = pandora_vmmc3_supply, 319 - }; 320 - 321 - static struct fixed_voltage_config pandora_vwlan = { 322 - .supply_name = "vwlan", 323 - .microvolts = 1800000, /* 1.8V */ 324 - .startup_delay = 50000, /* 50ms */ 325 - .init_data = &pandora_vmmc3, 326 - }; 327 - 328 - static struct platform_device pandora_vwlan_device = { 329 - .name = "reg-fixed-voltage", 330 - .id = 1, 331 - .dev = { 332 - .platform_data = &pandora_vwlan, 333 - }, 334 - }; 335 - 336 - static struct gpiod_lookup_table pandora_vwlan_gpiod_table = { 337 - .dev_id = "reg-fixed-voltage.1", 338 - .table = { 339 - /* 340 - * As this is a low GPIO number it should be at the first 341 - * GPIO bank. 342 - */ 343 - GPIO_LOOKUP("gpio-0-31", PANDORA_WIFI_NRESET_GPIO, 344 - NULL, GPIO_ACTIVE_HIGH), 345 - { }, 346 - }, 347 - }; 348 - 349 - static void pandora_wl1251_init_card(struct mmc_card *card) 350 - { 351 - /* 352 - * We have TI wl1251 attached to MMC3. Pass this information to 353 - * SDIO core because it can't be probed by normal methods. 354 - */ 355 - if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) { 356 - card->quirks |= MMC_QUIRK_NONSTD_SDIO; 357 - card->cccr.wide_bus = 1; 358 - card->cis.vendor = 0x104c; 359 - card->cis.device = 0x9066; 360 - card->cis.blksize = 512; 361 - card->cis.max_dtr = 24000000; 362 - card->ocr = 0x80; 363 - } 364 - } 365 - 366 - static struct omap2_hsmmc_info pandora_mmc3[] = { 367 - { 368 - .mmc = 3, 369 - .caps = MMC_CAP_4_BIT_DATA | MMC_CAP_POWER_OFF_CARD, 370 - .init_card = pandora_wl1251_init_card, 371 - }, 372 - {} /* Terminator */ 373 - }; 374 - 375 - static void __init pandora_wl1251_init(void) 376 - { 377 - struct wl1251_platform_data pandora_wl1251_pdata; 378 - int ret; 379 - 380 - memset(&pandora_wl1251_pdata, 0, sizeof(pandora_wl1251_pdata)); 381 - 382 - pandora_wl1251_pdata.power_gpio = -1; 383 - 384 - ret = gpio_request_one(PANDORA_WIFI_IRQ_GPIO, GPIOF_IN, "wl1251 irq"); 385 - if (ret < 0) 386 - goto fail; 387 - 388 - pandora_wl1251_pdata.irq = gpio_to_irq(PANDORA_WIFI_IRQ_GPIO); 389 - if (pandora_wl1251_pdata.irq < 0) 390 - goto fail_irq; 391 - 392 - pandora_wl1251_pdata.use_eeprom = true; 393 - ret = wl1251_set_platform_data(&pandora_wl1251_pdata); 394 - if (ret < 0) 395 - goto fail_irq; 396 - 397 - return; 398 - 399 - fail_irq: 400 - gpio_free(PANDORA_WIFI_IRQ_GPIO); 401 - fail: 402 - pr_err("wl1251 board initialisation failed\n"); 403 - } 404 - 405 309 static void __init omap3_pandora_legacy_init(void) 406 310 { 407 311 platform_device_register(&pandora_backlight); 408 - gpiod_add_lookup_table(&pandora_vwlan_gpiod_table); 409 - platform_device_register(&pandora_vwlan_device); 410 - omap_hsmmc_init(pandora_mmc3); 411 - omap_hsmmc_late_init(pandora_mmc3); 412 - pandora_wl1251_init(); 413 312 } 414 313 #endif /* CONFIG_ARCH_OMAP3 */ 415 314
+9 -9
drivers/memstick/core/Kconfig
··· 6 6 comment "MemoryStick drivers" 7 7 8 8 config MEMSTICK_UNSAFE_RESUME 9 - bool "Allow unsafe resume (DANGEROUS)" 10 - help 11 - If you say Y here, the MemoryStick layer will assume that all 12 - cards stayed in their respective slots during the suspend. The 13 - normal behaviour is to remove them at suspend and 14 - redetecting them at resume. Breaking this assumption will 15 - in most cases result in data corruption. 9 + bool "Allow unsafe resume (DANGEROUS)" 10 + help 11 + If you say Y here, the MemoryStick layer will assume that all 12 + cards stayed in their respective slots during the suspend. The 13 + normal behaviour is to remove them at suspend and 14 + redetecting them at resume. Breaking this assumption will 15 + in most cases result in data corruption. 16 16 17 - This option is usually just for embedded systems which use 18 - a MemoryStick card for rootfs. Most people should say N here. 17 + This option is usually just for embedded systems which use 18 + a MemoryStick card for rootfs. Most people should say N here. 19 19 20 20 config MSPRO_BLOCK 21 21 tristate "MemoryStick Pro block device driver"
+2 -2
drivers/memstick/host/Kconfig
··· 18 18 'Misc devices: TI Flash Media PCI74xx/PCI76xx host adapter support 19 19 (TIFM_7XX1)'. 20 20 21 - To compile this driver as a module, choose M here: the 21 + To compile this driver as a module, choose M here: the 22 22 module will be called tifm_ms. 23 23 24 24 config MEMSTICK_JMICRON_38X ··· 29 29 Say Y here if you want to be able to access MemoryStick cards with 30 30 the JMicron(R) JMB38X MemoryStick card reader. 31 31 32 - To compile this driver as a module, choose M here: the 32 + To compile this driver as a module, choose M here: the 33 33 module will be called jmb38x_ms. 34 34 35 35 config MEMSTICK_R592
+6 -6
drivers/memstick/host/jmb38x_ms.c
··· 433 433 writel(((1 << 16) & BLOCK_COUNT_MASK) 434 434 | (data_len & BLOCK_SIZE_MASK), 435 435 host->addr + BLOCK); 436 - t_val = readl(host->addr + INT_STATUS_ENABLE); 437 - t_val |= host->req->data_dir == READ 438 - ? INT_STATUS_FIFO_RRDY 439 - : INT_STATUS_FIFO_WRDY; 436 + t_val = readl(host->addr + INT_STATUS_ENABLE); 437 + t_val |= host->req->data_dir == READ 438 + ? INT_STATUS_FIFO_RRDY 439 + : INT_STATUS_FIFO_WRDY; 440 440 441 - writel(t_val, host->addr + INT_STATUS_ENABLE); 442 - writel(t_val, host->addr + INT_SIGNAL_ENABLE); 441 + writel(t_val, host->addr + INT_STATUS_ENABLE); 442 + writel(t_val, host->addr + INT_SIGNAL_ENABLE); 443 443 } else { 444 444 cmd &= ~(TPC_DATA_SEL | 0xf); 445 445 host->cmd_flags |= REG_DATA;
+57 -94
drivers/mmc/core/block.c
··· 408 408 return 0; 409 409 } 410 410 411 - static int ioctl_rpmb_card_status_poll(struct mmc_card *card, u32 *status, 412 - u32 retries_max) 413 - { 414 - int err; 415 - u32 retry_count = 0; 416 - 417 - if (!status || !retries_max) 418 - return -EINVAL; 419 - 420 - do { 421 - err = __mmc_send_status(card, status, 5); 422 - if (err) 423 - break; 424 - 425 - if (!R1_STATUS(*status) && 426 - (R1_CURRENT_STATE(*status) != R1_STATE_PRG)) 427 - break; /* RPMB programming operation complete */ 428 - 429 - /* 430 - * Rechedule to give the MMC device a chance to continue 431 - * processing the previous command without being polled too 432 - * frequently. 433 - */ 434 - usleep_range(1000, 5000); 435 - } while (++retry_count < retries_max); 436 - 437 - if (retry_count == retries_max) 438 - err = -EPERM; 439 - 440 - return err; 441 - } 442 - 443 411 static int ioctl_do_sanitize(struct mmc_card *card) 444 412 { 445 413 int err; ··· 436 468 return err; 437 469 } 438 470 471 + static inline bool mmc_blk_in_tran_state(u32 status) 472 + { 473 + /* 474 + * Some cards mishandle the status bits, so make sure to check both the 475 + * busy indication and the card state. 476 + */ 477 + return status & R1_READY_FOR_DATA && 478 + (R1_CURRENT_STATE(status) == R1_STATE_TRAN); 479 + } 480 + 481 + static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, 482 + u32 *resp_errs) 483 + { 484 + unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms); 485 + int err = 0; 486 + u32 status; 487 + 488 + do { 489 + bool done = time_after(jiffies, timeout); 490 + 491 + err = __mmc_send_status(card, &status, 5); 492 + if (err) { 493 + dev_err(mmc_dev(card->host), 494 + "error %d requesting status\n", err); 495 + return err; 496 + } 497 + 498 + /* Accumulate any response error bits seen */ 499 + if (resp_errs) 500 + *resp_errs |= status; 501 + 502 + /* 503 + * Timeout if the device never becomes ready for data and never 504 + * leaves the program state. 505 + */ 506 + if (done) { 507 + dev_err(mmc_dev(card->host), 508 + "Card stuck in wrong state! %s status: %#x\n", 509 + __func__, status); 510 + return -ETIMEDOUT; 511 + } 512 + 513 + /* 514 + * Some cards mishandle the status bits, 515 + * so make sure to check both the busy 516 + * indication and the card state. 517 + */ 518 + } while (!mmc_blk_in_tran_state(status)); 519 + 520 + return err; 521 + } 522 + 439 523 static int __mmc_blk_ioctl_cmd(struct mmc_card *card, struct mmc_blk_data *md, 440 524 struct mmc_blk_ioc_data *idata) 441 525 { ··· 497 477 struct scatterlist sg; 498 478 int err; 499 479 unsigned int target_part; 500 - u32 status = 0; 501 480 502 481 if (!card || !md || !idata) 503 482 return -EINVAL; ··· 630 611 631 612 memcpy(&(idata->ic.response), cmd.resp, sizeof(cmd.resp)); 632 613 633 - if (idata->rpmb) { 614 + if (idata->rpmb || (cmd.flags & MMC_RSP_R1B)) { 634 615 /* 635 - * Ensure RPMB command has completed by polling CMD13 616 + * Ensure RPMB/R1B command has completed by polling CMD13 636 617 * "Send Status". 637 618 */ 638 - err = ioctl_rpmb_card_status_poll(card, &status, 5); 639 - if (err) 640 - dev_err(mmc_dev(card->host), 641 - "%s: Card Status=0x%08X, error %d\n", 642 - __func__, status, err); 619 + err = card_busy_detect(card, MMC_BLK_TIMEOUT_MS, NULL); 643 620 } 644 621 645 622 return err; ··· 983 968 } 984 969 985 970 return ms; 986 - } 987 - 988 - static inline bool mmc_blk_in_tran_state(u32 status) 989 - { 990 - /* 991 - * Some cards mishandle the status bits, so make sure to check both the 992 - * busy indication and the card state. 993 - */ 994 - return status & R1_READY_FOR_DATA && 995 - (R1_CURRENT_STATE(status) == R1_STATE_TRAN); 996 - } 997 - 998 - static int card_busy_detect(struct mmc_card *card, unsigned int timeout_ms, 999 - struct request *req, u32 *resp_errs) 1000 - { 1001 - unsigned long timeout = jiffies + msecs_to_jiffies(timeout_ms); 1002 - int err = 0; 1003 - u32 status; 1004 - 1005 - do { 1006 - bool done = time_after(jiffies, timeout); 1007 - 1008 - err = __mmc_send_status(card, &status, 5); 1009 - if (err) { 1010 - pr_err("%s: error %d requesting status\n", 1011 - req->rq_disk->disk_name, err); 1012 - return err; 1013 - } 1014 - 1015 - /* Accumulate any response error bits seen */ 1016 - if (resp_errs) 1017 - *resp_errs |= status; 1018 - 1019 - /* 1020 - * Timeout if the device never becomes ready for data and never 1021 - * leaves the program state. 1022 - */ 1023 - if (done) { 1024 - pr_err("%s: Card stuck in wrong state! %s %s status: %#x\n", 1025 - mmc_hostname(card->host), 1026 - req->rq_disk->disk_name, __func__, status); 1027 - return -ETIMEDOUT; 1028 - } 1029 - 1030 - /* 1031 - * Some cards mishandle the status bits, 1032 - * so make sure to check both the busy 1033 - * indication and the card state. 1034 - */ 1035 - } while (!mmc_blk_in_tran_state(status)); 1036 - 1037 - return err; 1038 971 } 1039 972 1040 973 static int mmc_blk_reset(struct mmc_blk_data *md, struct mmc_host *host, ··· 1634 1671 1635 1672 mmc_blk_send_stop(card, timeout); 1636 1673 1637 - err = card_busy_detect(card, timeout, req, NULL); 1674 + err = card_busy_detect(card, timeout, NULL); 1638 1675 1639 1676 mmc_retune_release(card->host); 1640 1677 ··· 1858 1895 if (mmc_host_is_spi(card->host) || rq_data_dir(req) == READ) 1859 1896 return 0; 1860 1897 1861 - err = card_busy_detect(card, MMC_BLK_TIMEOUT_MS, req, &status); 1898 + err = card_busy_detect(card, MMC_BLK_TIMEOUT_MS, &status); 1862 1899 1863 1900 /* 1864 1901 * Do not assume data transferred correctly if there are any error bits
+4 -8
drivers/mmc/core/core.c
··· 1469 1469 mmc_bus_put(host); 1470 1470 } 1471 1471 1472 - static void _mmc_detect_change(struct mmc_host *host, unsigned long delay, 1473 - bool cd_irq) 1472 + void _mmc_detect_change(struct mmc_host *host, unsigned long delay, bool cd_irq) 1474 1473 { 1475 1474 /* 1476 1475 * If the device is configured as wakeup, we prevent a new sleep for ··· 2128 2129 ret = host->bus_ops->hw_reset(host); 2129 2130 mmc_bus_put(host); 2130 2131 2131 - if (ret) 2132 + if (ret < 0) 2132 2133 pr_warn("%s: tried to HW reset card, got error %d\n", 2133 2134 mmc_hostname(host), ret); 2134 2135 ··· 2296 2297 2297 2298 mmc_bus_get(host); 2298 2299 2299 - /* 2300 - * if there is a _removable_ card registered, check whether it is 2301 - * still present 2302 - */ 2303 - if (host->bus_ops && !host->bus_dead && mmc_card_is_removable(host)) 2300 + /* Verify a registered card to be functional, else remove it. */ 2301 + if (host->bus_ops && !host->bus_dead) 2304 2302 host->bus_ops->detect(host); 2305 2303 2306 2304 host->detect_change = 0;
+2
drivers/mmc/core/core.h
··· 70 70 void mmc_start_host(struct mmc_host *host); 71 71 void mmc_stop_host(struct mmc_host *host); 72 72 73 + void _mmc_detect_change(struct mmc_host *host, unsigned long delay, 74 + bool cd_irq); 73 75 int _mmc_detect_card_removed(struct mmc_host *host); 74 76 int mmc_detect_card_removed(struct mmc_host *host); 75 77
+4 -5
drivers/mmc/core/mmc.c
··· 297 297 } 298 298 } 299 299 300 - static void mmc_part_add(struct mmc_card *card, unsigned int size, 300 + static void mmc_part_add(struct mmc_card *card, u64 size, 301 301 unsigned int part_cfg, char *name, int idx, bool ro, 302 302 int area_type) 303 303 { ··· 313 313 { 314 314 int idx; 315 315 u8 hc_erase_grp_sz, hc_wp_grp_sz; 316 - unsigned int part_size; 316 + u64 part_size; 317 317 318 318 /* 319 319 * General purpose partition feature support -- ··· 343 343 (ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3 + 1] 344 344 << 8) + 345 345 ext_csd[EXT_CSD_GP_SIZE_MULT + idx * 3]; 346 - part_size *= (size_t)(hc_erase_grp_sz * 347 - hc_wp_grp_sz); 346 + part_size *= (hc_erase_grp_sz * hc_wp_grp_sz); 348 347 mmc_part_add(card, part_size << 19, 349 348 EXT_CSD_PART_CONFIG_ACC_GP0 + idx, 350 349 "gp%d", idx, false, ··· 361 362 static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) 362 363 { 363 364 int err = 0, idx; 364 - unsigned int part_size; 365 + u64 part_size; 365 366 struct device_node *np; 366 367 bool broken_hpi = false; 367 368
+7
drivers/mmc/core/quirks.h
··· 119 119 END_FIXUP 120 120 }; 121 121 122 + 122 123 static const struct mmc_fixup sdio_fixup_methods[] = { 124 + SDIO_FIXUP(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251, 125 + add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), 126 + 127 + SDIO_FIXUP(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251, 128 + add_quirk, MMC_QUIRK_DISABLE_CD), 129 + 123 130 SDIO_FIXUP(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1271, 124 131 add_quirk, MMC_QUIRK_NONSTD_FUNC_IF), 125 132
+27 -1
drivers/mmc/core/sdio.c
··· 1048 1048 return ret; 1049 1049 } 1050 1050 1051 + /* 1052 + * SDIO HW reset 1053 + * 1054 + * Returns 0 if the HW reset was executed synchronously, returns 1 if the HW 1055 + * reset was asynchronously scheduled, else a negative error code. 1056 + */ 1051 1057 static int mmc_sdio_hw_reset(struct mmc_host *host) 1052 1058 { 1053 - mmc_power_cycle(host, host->card->ocr); 1059 + struct mmc_card *card = host->card; 1060 + 1061 + /* 1062 + * In case the card is shared among multiple func drivers, reset the 1063 + * card through a rescan work. In this way it will be removed and 1064 + * re-detected, thus all func drivers becomes informed about it. 1065 + */ 1066 + if (atomic_read(&card->sdio_funcs_probed) > 1) { 1067 + if (mmc_card_removed(card)) 1068 + return 1; 1069 + host->rescan_entered = 0; 1070 + mmc_card_set_removed(card); 1071 + _mmc_detect_change(host, 0, false); 1072 + return 1; 1073 + } 1074 + 1075 + /* 1076 + * A single func driver has been probed, then let's skip the heavy 1077 + * hotplug dance above and execute the reset immediately. 1078 + */ 1079 + mmc_power_cycle(host, card->ocr); 1054 1080 return mmc_sdio_reinit_card(host); 1055 1081 } 1056 1082
+8 -1
drivers/mmc/core/sdio_bus.c
··· 138 138 if (ret) 139 139 return ret; 140 140 141 + atomic_inc(&func->card->sdio_funcs_probed); 142 + 141 143 /* Unbound SDIO functions are always suspended. 142 144 * During probe, the function is set active and the usage count 143 145 * is incremented. If the driver supports runtime PM, ··· 155 153 /* Set the default block size so the driver is sure it's something 156 154 * sensible. */ 157 155 sdio_claim_host(func); 158 - ret = sdio_set_block_size(func, 0); 156 + if (mmc_card_removed(func->card)) 157 + ret = -ENOMEDIUM; 158 + else 159 + ret = sdio_set_block_size(func, 0); 159 160 sdio_release_host(func); 160 161 if (ret) 161 162 goto disable_runtimepm; ··· 170 165 return 0; 171 166 172 167 disable_runtimepm: 168 + atomic_dec(&func->card->sdio_funcs_probed); 173 169 if (func->card->host->caps & MMC_CAP_POWER_OFF_CARD) 174 170 pm_runtime_put_noidle(dev); 175 171 dev_pm_domain_detach(dev, false); ··· 187 181 pm_runtime_get_sync(dev); 188 182 189 183 drv->remove(func); 184 + atomic_dec(&func->card->sdio_funcs_probed); 190 185 191 186 if (func->irq_handler) { 192 187 pr_warn("WARNING: driver %s did not remove its interrupt handler!\n",
+21
drivers/mmc/host/Kconfig
··· 159 159 tristate "SDHCI OF support for the ASPEED SDHCI controller" 160 160 depends on MMC_SDHCI_PLTFM 161 161 depends on OF && OF_ADDRESS 162 + select MMC_SDHCI_IO_ACCESSORS 162 163 help 163 164 This selects the ASPEED Secure Digital Host Controller Interface. 164 165 ··· 365 364 help 366 365 This selects the Secure Digital Host Controller Interface (SDHCI) 367 366 Needed by some Fujitsu SoC for MMC / SD / SDIO support. 367 + If you have a controller with this interface, say Y or M here. 368 + 369 + If unsure, say N. 370 + 371 + config MMC_SDHCI_MILBEAUT 372 + tristate "SDHCI support for Socionext Milbeaut Serieas using F_SDH30" 373 + depends on MMC_SDHCI_PLTFM 374 + depends on OF 375 + help 376 + This selects the Secure Digital Host Controller Interface (SDHCI) 377 + Needed by Milbeaut SoC for MMC / SD / SDIO support. 368 378 If you have a controller with this interface, say Y or M here. 369 379 370 380 If unsure, say N. ··· 1023 1011 tristate "Support for the SDHCI Controller in TI's AM654 SOCs" 1024 1012 depends on MMC_SDHCI_PLTFM && OF && REGMAP_MMIO 1025 1013 select MMC_SDHCI_IO_ACCESSORS 1014 + select MMC_CQHCI 1026 1015 help 1027 1016 This selects the Secure Digital Host Controller Interface (SDHCI) 1028 1017 support present in TI's AM654 SOCs. The controller supports ··· 1032 1019 If you have a controller with this interface, say Y or M here. 1033 1020 1034 1021 If unsure, say N. 1022 + 1023 + config MMC_OWL 1024 + tristate "Actions Semi Owl SD/MMC Host Controller support" 1025 + depends on HAS_DMA 1026 + depends on ARCH_ACTIONS || COMPILE_TEST 1027 + help 1028 + This selects support for the SD/MMC Host Controller on 1029 + Actions Semi Owl SoCs.
+2
drivers/mmc/host/Makefile
··· 21 21 obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o 22 22 obj-$(CONFIG_MMC_SDHCI_SIRF) += sdhci-sirf.o 23 23 obj-$(CONFIG_MMC_SDHCI_F_SDH30) += sdhci_f_sdh30.o 24 + obj-$(CONFIG_MMC_SDHCI_MILBEAUT) += sdhci-milbeaut.o 24 25 obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o 25 26 obj-$(CONFIG_MMC_SDHCI_AM654) += sdhci_am654.o 26 27 obj-$(CONFIG_MMC_WBSD) += wbsd.o ··· 74 73 obj-$(CONFIG_MMC_USDHI6ROL0) += usdhi6rol0.o 75 74 obj-$(CONFIG_MMC_TOSHIBA_PCI) += toshsd.o 76 75 obj-$(CONFIG_MMC_BCM2835) += bcm2835.o 76 + obj-$(CONFIG_MMC_OWL) += owl-mmc.o 77 77 78 78 obj-$(CONFIG_MMC_REALTEK_PCI) += rtsx_pci_sdmmc.o 79 79 obj-$(CONFIG_MMC_REALTEK_USB) += rtsx_usb_sdmmc.o
+1 -2
drivers/mmc/host/atmel-mci.c
··· 2347 2347 2348 2348 static int atmci_configure_dma(struct atmel_mci *host) 2349 2349 { 2350 - host->dma.chan = dma_request_slave_channel_reason(&host->pdev->dev, 2351 - "rxtx"); 2350 + host->dma.chan = dma_request_chan(&host->pdev->dev, "rxtx"); 2352 2351 2353 2352 if (PTR_ERR(host->dma.chan) == -ENODEV) { 2354 2353 struct mci_platform_data *pdata = host->pdev->dev.platform_data;
+1 -3
drivers/mmc/host/bcm2835.c
··· 1357 1357 { 1358 1358 struct device *dev = &pdev->dev; 1359 1359 struct clk *clk; 1360 - struct resource *iomem; 1361 1360 struct bcm2835_host *host; 1362 1361 struct mmc_host *mmc; 1363 1362 const __be32 *regaddr_p; ··· 1372 1373 host->pdev = pdev; 1373 1374 spin_lock_init(&host->lock); 1374 1375 1375 - iomem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1376 - host->ioaddr = devm_ioremap_resource(dev, iomem); 1376 + host->ioaddr = devm_platform_ioremap_resource(pdev, 0); 1377 1377 if (IS_ERR(host->ioaddr)) { 1378 1378 ret = PTR_ERR(host->ioaddr); 1379 1379 goto err;
+2 -13
drivers/mmc/host/cavium-octeon.c
··· 148 148 { 149 149 struct device_node *cn, *node = pdev->dev.of_node; 150 150 struct cvm_mmc_host *host; 151 - struct resource *res; 152 151 void __iomem *base; 153 152 int mmc_irq[9]; 154 153 int i, ret = 0; ··· 204 205 205 206 host->last_slot = -1; 206 207 207 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 208 - if (!res) { 209 - dev_err(&pdev->dev, "Platform resource[0] is missing\n"); 210 - return -ENXIO; 211 - } 212 - base = devm_ioremap_resource(&pdev->dev, res); 208 + base = devm_platform_ioremap_resource(pdev, 0); 213 209 if (IS_ERR(base)) 214 210 return PTR_ERR(base); 215 211 host->base = (void __iomem *)base; 216 212 host->reg_off = 0; 217 213 218 - res = platform_get_resource(pdev, IORESOURCE_MEM, 1); 219 - if (!res) { 220 - dev_err(&pdev->dev, "Platform resource[1] is missing\n"); 221 - return -EINVAL; 222 - } 223 - base = devm_ioremap_resource(&pdev->dev, res); 214 + base = devm_platform_ioremap_resource(pdev, 1); 224 215 if (IS_ERR(base)) 225 216 return PTR_ERR(base); 226 217 host->dma_base = (void __iomem *)base;
+2 -2
drivers/mmc/host/dw_mmc.c
··· 3441 3441 * Restore the initial value at FIFOTH register 3442 3442 * And Invalidate the prev_blksz with zero 3443 3443 */ 3444 - mci_writel(host, FIFOTH, host->fifoth_val); 3445 - host->prev_blksz = 0; 3444 + mci_writel(host, FIFOTH, host->fifoth_val); 3445 + host->prev_blksz = 0; 3446 3446 3447 3447 /* Put in max timeout */ 3448 3448 mci_writel(host, TMOUT, 0xFFFFFFFF);
+38 -3
drivers/mmc/host/jz4740_mmc.c
··· 41 41 #define JZ_REG_MMC_RESP_FIFO 0x34 42 42 #define JZ_REG_MMC_RXFIFO 0x38 43 43 #define JZ_REG_MMC_TXFIFO 0x3C 44 + #define JZ_REG_MMC_LPM 0x40 44 45 #define JZ_REG_MMC_DMAC 0x44 45 46 46 47 #define JZ_MMC_STRPCL_EXIT_MULTIPLE BIT(7) ··· 78 77 79 78 #define JZ_MMC_CMDAT_IO_ABORT BIT(11) 80 79 #define JZ_MMC_CMDAT_BUS_WIDTH_4BIT BIT(10) 80 + #define JZ_MMC_CMDAT_BUS_WIDTH_8BIT (BIT(10) | BIT(9)) 81 + #define JZ_MMC_CMDAT_BUS_WIDTH_MASK (BIT(10) | BIT(9)) 81 82 #define JZ_MMC_CMDAT_DMA_EN BIT(8) 82 83 #define JZ_MMC_CMDAT_INIT BIT(7) 83 84 #define JZ_MMC_CMDAT_BUSY BIT(6) ··· 101 98 #define JZ_MMC_DMAC_DMA_SEL BIT(1) 102 99 #define JZ_MMC_DMAC_DMA_EN BIT(0) 103 100 101 + #define JZ_MMC_LPM_DRV_RISING BIT(31) 102 + #define JZ_MMC_LPM_DRV_RISING_QTR_PHASE_DLY BIT(31) 103 + #define JZ_MMC_LPM_DRV_RISING_1NS_DLY BIT(30) 104 + #define JZ_MMC_LPM_SMP_RISING_QTR_OR_HALF_PHASE_DLY BIT(29) 105 + #define JZ_MMC_LPM_LOW_POWER_MODE_EN BIT(0) 106 + 104 107 #define JZ_MMC_CLK_RATE 24000000 105 108 106 109 enum jz4740_mmc_version { 107 110 JZ_MMC_JZ4740, 108 111 JZ_MMC_JZ4725B, 112 + JZ_MMC_JZ4760, 109 113 JZ_MMC_JZ4780, 114 + JZ_MMC_X1000, 110 115 }; 111 116 112 117 enum jz4740_mmc_state { ··· 863 852 } 864 853 865 854 writew(div, host->base + JZ_REG_MMC_CLKRT); 855 + 856 + if (real_rate > 25000000) { 857 + if (host->version >= JZ_MMC_X1000) { 858 + writel(JZ_MMC_LPM_DRV_RISING_QTR_PHASE_DLY | 859 + JZ_MMC_LPM_SMP_RISING_QTR_OR_HALF_PHASE_DLY | 860 + JZ_MMC_LPM_LOW_POWER_MODE_EN, 861 + host->base + JZ_REG_MMC_LPM); 862 + } else if (host->version >= JZ_MMC_JZ4760) { 863 + writel(JZ_MMC_LPM_DRV_RISING | 864 + JZ_MMC_LPM_LOW_POWER_MODE_EN, 865 + host->base + JZ_REG_MMC_LPM); 866 + } else if (host->version >= JZ_MMC_JZ4725B) 867 + writel(JZ_MMC_LPM_LOW_POWER_MODE_EN, 868 + host->base + JZ_REG_MMC_LPM); 869 + } 870 + 866 871 return real_rate; 867 872 } 868 873 ··· 922 895 923 896 switch (ios->bus_width) { 924 897 case MMC_BUS_WIDTH_1: 925 - host->cmdat &= ~JZ_MMC_CMDAT_BUS_WIDTH_4BIT; 898 + host->cmdat &= ~JZ_MMC_CMDAT_BUS_WIDTH_MASK; 926 899 break; 927 900 case MMC_BUS_WIDTH_4: 901 + host->cmdat &= ~JZ_MMC_CMDAT_BUS_WIDTH_MASK; 928 902 host->cmdat |= JZ_MMC_CMDAT_BUS_WIDTH_4BIT; 903 + break; 904 + case MMC_BUS_WIDTH_8: 905 + host->cmdat &= ~JZ_MMC_CMDAT_BUS_WIDTH_MASK; 906 + host->cmdat |= JZ_MMC_CMDAT_BUS_WIDTH_8BIT; 929 907 break; 930 908 default: 931 909 break; ··· 956 924 static const struct of_device_id jz4740_mmc_of_match[] = { 957 925 { .compatible = "ingenic,jz4740-mmc", .data = (void *) JZ_MMC_JZ4740 }, 958 926 { .compatible = "ingenic,jz4725b-mmc", .data = (void *)JZ_MMC_JZ4725B }, 927 + { .compatible = "ingenic,jz4760-mmc", .data = (void *) JZ_MMC_JZ4760 }, 959 928 { .compatible = "ingenic,jz4780-mmc", .data = (void *) JZ_MMC_JZ4780 }, 929 + { .compatible = "ingenic,x1000-mmc", .data = (void *) JZ_MMC_X1000 }, 960 930 {}, 961 931 }; 962 932 MODULE_DEVICE_TABLE(of, jz4740_mmc_of_match); ··· 1059 1025 dev_err(&pdev->dev, "Failed to add mmc host: %d\n", ret); 1060 1026 goto err_release_dma; 1061 1027 } 1062 - dev_info(&pdev->dev, "JZ SD/MMC card driver registered\n"); 1028 + dev_info(&pdev->dev, "Ingenic SD/MMC card driver registered\n"); 1063 1029 1064 1030 dev_info(&pdev->dev, "Using %s, %d-bit mode\n", 1065 1031 host->use_dma ? "DMA" : "PIO", 1066 - (mmc->caps & MMC_CAP_4_BIT_DATA) ? 4 : 1); 1032 + (mmc->caps & MMC_CAP_8_BIT_DATA) ? 8 : 1033 + ((mmc->caps & MMC_CAP_4_BIT_DATA) ? 4 : 1)); 1067 1034 1068 1035 return 0; 1069 1036
+1 -1
drivers/mmc/host/mmc_spi.c
··· 1421 1421 * Index 0 is card detect 1422 1422 * Old boardfiles were specifying 1 ms as debounce 1423 1423 */ 1424 - status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1, NULL); 1424 + status = mmc_gpiod_request_cd(mmc, NULL, 0, false, 1000, NULL); 1425 1425 if (status == -EPROBE_DEFER) 1426 1426 goto fail_add_host; 1427 1427 if (!status) {
+122 -76
drivers/mmc/host/mmci.c
··· 44 44 #define DRIVER_NAME "mmci-pl18x" 45 45 46 46 static void mmci_variant_init(struct mmci_host *host); 47 + static void ux500_variant_init(struct mmci_host *host); 47 48 static void ux500v2_variant_init(struct mmci_host *host); 48 49 49 50 static unsigned int fmax = 515633; ··· 185 184 .irq_pio_mask = MCI_IRQ_PIO_MASK, 186 185 .start_err = MCI_STARTBITERR, 187 186 .opendrain = MCI_OD, 188 - .init = mmci_variant_init, 187 + .init = ux500_variant_init, 189 188 }; 190 189 191 190 static struct variant_data variant_ux500v2 = { ··· 262 261 .datalength_bits = 25, 263 262 .datactrl_blocksz = 14, 264 263 .stm32_idmabsize_mask = GENMASK(12, 5), 264 + .busy_timeout = true, 265 + .busy_detect = true, 266 + .busy_detect_flag = MCI_STM32_BUSYD0, 267 + .busy_detect_mask = MCI_STM32_BUSYD0ENDMASK, 265 268 .init = sdmmc_variant_init, 266 269 }; 267 270 ··· 424 419 mmci_write_clkreg(host, clk); 425 420 } 426 421 427 - void mmci_dma_release(struct mmci_host *host) 422 + static void mmci_dma_release(struct mmci_host *host) 428 423 { 429 424 if (host->ops && host->ops->dma_release) 430 425 host->ops->dma_release(host); ··· 432 427 host->use_dma = false; 433 428 } 434 429 435 - void mmci_dma_setup(struct mmci_host *host) 430 + static void mmci_dma_setup(struct mmci_host *host) 436 431 { 437 432 if (!host->ops || !host->ops->dma_setup) 438 433 return; ··· 467 462 return 0; 468 463 } 469 464 470 - int mmci_prep_data(struct mmci_host *host, struct mmc_data *data, bool next) 465 + static int mmci_prep_data(struct mmci_host *host, struct mmc_data *data, bool next) 471 466 { 472 467 int err; 473 468 ··· 483 478 return err; 484 479 } 485 480 486 - void mmci_unprep_data(struct mmci_host *host, struct mmc_data *data, 481 + static void mmci_unprep_data(struct mmci_host *host, struct mmc_data *data, 487 482 int err) 488 483 { 489 484 if (host->ops && host->ops->unprep_data) ··· 492 487 data->host_cookie = 0; 493 488 } 494 489 495 - void mmci_get_next_data(struct mmci_host *host, struct mmc_data *data) 490 + static void mmci_get_next_data(struct mmci_host *host, struct mmc_data *data) 496 491 { 497 492 WARN_ON(data->host_cookie && data->host_cookie != host->next_cookie); 498 493 ··· 500 495 host->ops->get_next_data(host, data); 501 496 } 502 497 503 - int mmci_dma_start(struct mmci_host *host, unsigned int datactrl) 498 + static int mmci_dma_start(struct mmci_host *host, unsigned int datactrl) 504 499 { 505 500 struct mmc_data *data = host->data; 506 501 int ret; ··· 535 530 return 0; 536 531 } 537 532 538 - void mmci_dma_finalize(struct mmci_host *host, struct mmc_data *data) 533 + static void mmci_dma_finalize(struct mmci_host *host, struct mmc_data *data) 539 534 { 540 535 if (!host->use_dma) 541 536 return; ··· 544 539 host->ops->dma_finalize(host, data); 545 540 } 546 541 547 - void mmci_dma_error(struct mmci_host *host) 542 + static void mmci_dma_error(struct mmci_host *host) 548 543 { 549 544 if (!host->use_dma) 550 545 return; ··· 613 608 static u32 ux500v2_get_dctrl_cfg(struct mmci_host *host) 614 609 { 615 610 return MCI_DPSM_ENABLE | (host->data->blksz << 16); 611 + } 612 + 613 + static bool ux500_busy_complete(struct mmci_host *host, u32 status, u32 err_msk) 614 + { 615 + void __iomem *base = host->base; 616 + 617 + /* 618 + * Before unmasking for the busy end IRQ, confirm that the 619 + * command was sent successfully. To keep track of having a 620 + * command in-progress, waiting for busy signaling to end, 621 + * store the status in host->busy_status. 622 + * 623 + * Note that, the card may need a couple of clock cycles before 624 + * it starts signaling busy on DAT0, hence re-read the 625 + * MMCISTATUS register here, to allow the busy bit to be set. 626 + * Potentially we may even need to poll the register for a 627 + * while, to allow it to be set, but tests indicates that it 628 + * isn't needed. 629 + */ 630 + if (!host->busy_status && !(status & err_msk) && 631 + (readl(base + MMCISTATUS) & host->variant->busy_detect_flag)) { 632 + writel(readl(base + MMCIMASK0) | 633 + host->variant->busy_detect_mask, 634 + base + MMCIMASK0); 635 + 636 + host->busy_status = status & (MCI_CMDSENT | MCI_CMDRESPEND); 637 + return false; 638 + } 639 + 640 + /* 641 + * If there is a command in-progress that has been successfully 642 + * sent, then bail out if busy status is set and wait for the 643 + * busy end IRQ. 644 + * 645 + * Note that, the HW triggers an IRQ on both edges while 646 + * monitoring DAT0 for busy completion, but there is only one 647 + * status bit in MMCISTATUS for the busy state. Therefore 648 + * both the start and the end interrupts needs to be cleared, 649 + * one after the other. So, clear the busy start IRQ here. 650 + */ 651 + if (host->busy_status && 652 + (status & host->variant->busy_detect_flag)) { 653 + writel(host->variant->busy_detect_mask, base + MMCICLEAR); 654 + return false; 655 + } 656 + 657 + /* 658 + * If there is a command in-progress that has been successfully 659 + * sent and the busy bit isn't set, it means we have received 660 + * the busy end IRQ. Clear and mask the IRQ, then continue to 661 + * process the command. 662 + */ 663 + if (host->busy_status) { 664 + writel(host->variant->busy_detect_mask, base + MMCICLEAR); 665 + 666 + writel(readl(base + MMCIMASK0) & 667 + ~host->variant->busy_detect_mask, base + MMCIMASK0); 668 + host->busy_status = 0; 669 + } 670 + 671 + return true; 616 672 } 617 673 618 674 /* ··· 1014 948 }; 1015 949 #endif 1016 950 1017 - void mmci_variant_init(struct mmci_host *host) 951 + static void mmci_variant_init(struct mmci_host *host) 1018 952 { 1019 953 host->ops = &mmci_variant_ops; 1020 954 } 1021 955 1022 - void ux500v2_variant_init(struct mmci_host *host) 956 + static void ux500_variant_init(struct mmci_host *host) 1023 957 { 1024 958 host->ops = &mmci_variant_ops; 959 + host->ops->busy_complete = ux500_busy_complete; 960 + } 961 + 962 + static void ux500v2_variant_init(struct mmci_host *host) 963 + { 964 + host->ops = &mmci_variant_ops; 965 + host->ops->busy_complete = ux500_busy_complete; 1025 966 host->ops->get_datactrl_cfg = ux500v2_get_dctrl_cfg; 1026 967 } 1027 968 ··· 1148 1075 mmci_start_command(struct mmci_host *host, struct mmc_command *cmd, u32 c) 1149 1076 { 1150 1077 void __iomem *base = host->base; 1078 + unsigned long long clks; 1151 1079 1152 1080 dev_dbg(mmc_dev(host->mmc), "op %02x arg %08x flags %08x\n", 1153 1081 cmd->opcode, cmd->arg, cmd->flags); ··· 1171 1097 else 1172 1098 c |= host->variant->cmdreg_srsp; 1173 1099 } 1100 + 1101 + if (host->variant->busy_timeout && cmd->flags & MMC_RSP_BUSY) { 1102 + if (!cmd->busy_timeout) 1103 + cmd->busy_timeout = 10 * MSEC_PER_SEC; 1104 + 1105 + clks = (unsigned long long)cmd->busy_timeout * host->cclk; 1106 + do_div(clks, MSEC_PER_SEC); 1107 + writel_relaxed(clks, host->base + MMCIDATATIMER); 1108 + } 1109 + 1174 1110 if (/*interrupt*/0) 1175 1111 c |= MCI_CPSM_INTERRUPT; 1176 1112 ··· 1285 1201 mmci_cmd_irq(struct mmci_host *host, struct mmc_command *cmd, 1286 1202 unsigned int status) 1287 1203 { 1204 + u32 err_msk = MCI_CMDCRCFAIL | MCI_CMDTIMEOUT; 1288 1205 void __iomem *base = host->base; 1289 1206 bool sbc, busy_resp; 1290 1207 ··· 1300 1215 * handling. Note that we tag on any latent IRQs postponed 1301 1216 * due to waiting for busy status. 1302 1217 */ 1303 - if (!((status|host->busy_status) & 1304 - (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT|MCI_CMDSENT|MCI_CMDRESPEND))) 1218 + if (host->variant->busy_timeout && busy_resp) 1219 + err_msk |= MCI_DATATIMEOUT; 1220 + 1221 + if (!((status | host->busy_status) & 1222 + (err_msk | MCI_CMDSENT | MCI_CMDRESPEND))) 1305 1223 return; 1306 1224 1307 1225 /* Handle busy detection on DAT0 if the variant supports it. */ 1308 - if (busy_resp && host->variant->busy_detect) { 1309 - 1310 - /* 1311 - * Before unmasking for the busy end IRQ, confirm that the 1312 - * command was sent successfully. To keep track of having a 1313 - * command in-progress, waiting for busy signaling to end, 1314 - * store the status in host->busy_status. 1315 - * 1316 - * Note that, the card may need a couple of clock cycles before 1317 - * it starts signaling busy on DAT0, hence re-read the 1318 - * MMCISTATUS register here, to allow the busy bit to be set. 1319 - * Potentially we may even need to poll the register for a 1320 - * while, to allow it to be set, but tests indicates that it 1321 - * isn't needed. 1322 - */ 1323 - if (!host->busy_status && 1324 - !(status & (MCI_CMDCRCFAIL|MCI_CMDTIMEOUT)) && 1325 - (readl(base + MMCISTATUS) & host->variant->busy_detect_flag)) { 1326 - 1327 - writel(readl(base + MMCIMASK0) | 1328 - host->variant->busy_detect_mask, 1329 - base + MMCIMASK0); 1330 - 1331 - host->busy_status = 1332 - status & (MCI_CMDSENT|MCI_CMDRESPEND); 1226 + if (busy_resp && host->variant->busy_detect) 1227 + if (!host->ops->busy_complete(host, status, err_msk)) 1333 1228 return; 1334 - } 1335 - 1336 - /* 1337 - * If there is a command in-progress that has been successfully 1338 - * sent, then bail out if busy status is set and wait for the 1339 - * busy end IRQ. 1340 - * 1341 - * Note that, the HW triggers an IRQ on both edges while 1342 - * monitoring DAT0 for busy completion, but there is only one 1343 - * status bit in MMCISTATUS for the busy state. Therefore 1344 - * both the start and the end interrupts needs to be cleared, 1345 - * one after the other. So, clear the busy start IRQ here. 1346 - */ 1347 - if (host->busy_status && 1348 - (status & host->variant->busy_detect_flag)) { 1349 - writel(host->variant->busy_detect_mask, 1350 - host->base + MMCICLEAR); 1351 - return; 1352 - } 1353 - 1354 - /* 1355 - * If there is a command in-progress that has been successfully 1356 - * sent and the busy bit isn't set, it means we have received 1357 - * the busy end IRQ. Clear and mask the IRQ, then continue to 1358 - * process the command. 1359 - */ 1360 - if (host->busy_status) { 1361 - 1362 - writel(host->variant->busy_detect_mask, 1363 - host->base + MMCICLEAR); 1364 - 1365 - writel(readl(base + MMCIMASK0) & 1366 - ~host->variant->busy_detect_mask, 1367 - base + MMCIMASK0); 1368 - host->busy_status = 0; 1369 - } 1370 - } 1371 1229 1372 1230 host->cmd = NULL; 1373 1231 ··· 1318 1290 cmd->error = -ETIMEDOUT; 1319 1291 } else if (status & MCI_CMDCRCFAIL && cmd->flags & MMC_RSP_CRC) { 1320 1292 cmd->error = -EILSEQ; 1293 + } else if (host->variant->busy_timeout && busy_resp && 1294 + status & MCI_DATATIMEOUT) { 1295 + cmd->error = -ETIMEDOUT; 1321 1296 } else { 1322 1297 cmd->resp[0] = readl(base + MMCIRESPONSE0); 1323 1298 cmd->resp[1] = readl(base + MMCIRESPONSE1); ··· 1614 1583 spin_unlock_irqrestore(&host->lock, flags); 1615 1584 } 1616 1585 1586 + static void mmci_set_max_busy_timeout(struct mmc_host *mmc) 1587 + { 1588 + struct mmci_host *host = mmc_priv(mmc); 1589 + u32 max_busy_timeout = 0; 1590 + 1591 + if (!host->variant->busy_detect) 1592 + return; 1593 + 1594 + if (host->variant->busy_timeout && mmc->actual_clock) 1595 + max_busy_timeout = ~0UL / (mmc->actual_clock / MSEC_PER_SEC); 1596 + 1597 + mmc->max_busy_timeout = max_busy_timeout; 1598 + } 1599 + 1617 1600 static void mmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 1618 1601 { 1619 1602 struct mmci_host *host = mmc_priv(mmc); ··· 1731 1686 host->ops->set_clkreg(host, ios->clock); 1732 1687 else 1733 1688 mmci_set_clkreg(host, ios->clock); 1689 + 1690 + mmci_set_max_busy_timeout(mmc); 1734 1691 1735 1692 if (host->ops && host->ops->set_pwrreg) 1736 1693 host->ops->set_pwrreg(host, pwr); ··· 2004 1957 mmci_write_datactrlreg(host, 2005 1958 host->variant->busy_dpsm_flag); 2006 1959 mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; 2007 - mmc->max_busy_timeout = 0; 2008 1960 } 2009 1961 2010 1962 /* Prepare a CMD12 - needed to clear the DPSM on some variants. */
+5
drivers/mmc/host/mmci.h
··· 164 164 #define MCI_ST_CARDBUSY (1 << 24) 165 165 /* Extended status bits for the STM32 variants */ 166 166 #define MCI_STM32_BUSYD0 BIT(20) 167 + #define MCI_STM32_BUSYD0END BIT(21) 167 168 168 169 #define MMCICLEAR 0x038 169 170 #define MCI_CMDCRCFAILCLR (1 << 0) ··· 288 287 * @signal_direction: input/out direction of bus signals can be indicated 289 288 * @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock 290 289 * @busy_detect: true if the variant supports busy detection on DAT0. 290 + * @busy_timeout: true if the variant starts data timer when the DPSM 291 + * enter in Wait_R or Busy state. 291 292 * @busy_dpsm_flag: bitmask enabling busy detection in the DPSM 292 293 * @busy_detect_flag: bitmask identifying the bit in the MMCISTATUS register 293 294 * indicating that the card is busy ··· 336 333 u8 signal_direction:1; 337 334 u8 pwrreg_clkgate:1; 338 335 u8 busy_detect:1; 336 + u8 busy_timeout:1; 339 337 u32 busy_dpsm_flag; 340 338 u32 busy_detect_flag; 341 339 u32 busy_detect_mask; ··· 370 366 void (*dma_error)(struct mmci_host *host); 371 367 void (*set_clkreg)(struct mmci_host *host, unsigned int desired); 372 368 void (*set_pwrreg)(struct mmci_host *host, unsigned int pwr); 369 + bool (*busy_complete)(struct mmci_host *host, u32 status, u32 err_msk); 373 370 }; 374 371 375 372 struct mmci_host {
+44 -2
drivers/mmc/host/mmci_stm32_sdmmc.c
··· 25 25 void *sg_cpu; 26 26 }; 27 27 28 - int sdmmc_idma_validate_data(struct mmci_host *host, 29 - struct mmc_data *data) 28 + static int sdmmc_idma_validate_data(struct mmci_host *host, 29 + struct mmc_data *data) 30 30 { 31 31 struct scatterlist *sg; 32 32 int i; ··· 282 282 return datactrl; 283 283 } 284 284 285 + static bool sdmmc_busy_complete(struct mmci_host *host, u32 status, u32 err_msk) 286 + { 287 + void __iomem *base = host->base; 288 + u32 busy_d0, busy_d0end, mask, sdmmc_status; 289 + 290 + mask = readl_relaxed(base + MMCIMASK0); 291 + sdmmc_status = readl_relaxed(base + MMCISTATUS); 292 + busy_d0end = sdmmc_status & MCI_STM32_BUSYD0END; 293 + busy_d0 = sdmmc_status & MCI_STM32_BUSYD0; 294 + 295 + /* complete if there is an error or busy_d0end */ 296 + if ((status & err_msk) || busy_d0end) 297 + goto complete; 298 + 299 + /* 300 + * On response the busy signaling is reflected in the BUSYD0 flag. 301 + * if busy_d0 is in-progress we must activate busyd0end interrupt 302 + * to wait this completion. Else this request has no busy step. 303 + */ 304 + if (busy_d0) { 305 + if (!host->busy_status) { 306 + writel_relaxed(mask | host->variant->busy_detect_mask, 307 + base + MMCIMASK0); 308 + host->busy_status = status & 309 + (MCI_CMDSENT | MCI_CMDRESPEND); 310 + } 311 + return false; 312 + } 313 + 314 + complete: 315 + if (host->busy_status) { 316 + writel_relaxed(mask & ~host->variant->busy_detect_mask, 317 + base + MMCIMASK0); 318 + writel_relaxed(host->variant->busy_detect_mask, 319 + base + MMCICLEAR); 320 + host->busy_status = 0; 321 + } 322 + 323 + return true; 324 + } 325 + 285 326 static struct mmci_host_ops sdmmc_variant_ops = { 286 327 .validate_data = sdmmc_idma_validate_data, 287 328 .prep_data = sdmmc_idma_prep_data, ··· 333 292 .dma_finalize = sdmmc_idma_finalize, 334 293 .set_clkreg = mmci_sdmmc_set_clkreg, 335 294 .set_pwrreg = mmci_sdmmc_set_pwrreg, 295 + .busy_complete = sdmmc_busy_complete, 336 296 }; 337 297 338 298 void sdmmc_variant_init(struct mmci_host *host)
+2 -2
drivers/mmc/host/moxart-mmc.c
··· 608 608 host->timeout = msecs_to_jiffies(1000); 609 609 host->sysclk = clk_get_rate(clk); 610 610 host->fifo_width = readl(host->base + REG_FEATURE) << 2; 611 - host->dma_chan_tx = dma_request_slave_channel_reason(dev, "tx"); 612 - host->dma_chan_rx = dma_request_slave_channel_reason(dev, "rx"); 611 + host->dma_chan_tx = dma_request_chan(dev, "tx"); 612 + host->dma_chan_rx = dma_request_chan(dev, "rx"); 613 613 614 614 spin_lock_init(&host->lock); 615 615
+29 -2
drivers/mmc/host/omap_hsmmc.c
··· 1510 1510 { 1511 1511 struct omap_hsmmc_host *host = mmc_priv(mmc); 1512 1512 1513 - if (mmc_pdata(host)->init_card) 1514 - mmc_pdata(host)->init_card(card); 1513 + if (card->type == MMC_TYPE_SDIO || card->type == MMC_TYPE_SD_COMBO) { 1514 + struct device_node *np = mmc_dev(mmc)->of_node; 1515 + 1516 + /* 1517 + * REVISIT: should be moved to sdio core and made more 1518 + * general e.g. by expanding the DT bindings of child nodes 1519 + * to provide a mechanism to provide this information: 1520 + * Documentation/devicetree/bindings/mmc/mmc-card.txt 1521 + */ 1522 + 1523 + np = of_get_compatible_child(np, "ti,wl1251"); 1524 + if (np) { 1525 + /* 1526 + * We have TI wl1251 attached to MMC3. Pass this 1527 + * information to the SDIO core because it can't be 1528 + * probed by normal methods. 1529 + */ 1530 + 1531 + dev_info(host->dev, "found wl1251\n"); 1532 + card->quirks |= MMC_QUIRK_NONSTD_SDIO; 1533 + card->cccr.wide_bus = 1; 1534 + card->cis.vendor = 0x104c; 1535 + card->cis.device = 0x9066; 1536 + card->cis.blksize = 512; 1537 + card->cis.max_dtr = 24000000; 1538 + card->ocr = 0x80; 1539 + of_node_put(np); 1540 + } 1541 + } 1515 1542 } 1516 1543 1517 1544 static void omap_hsmmc_enable_sdio_irq(struct mmc_host *mmc, int enable)
+696
drivers/mmc/host/owl-mmc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Actions Semi Owl SoCs SD/MMC driver 4 + * 5 + * Copyright (c) 2014 Actions Semi Inc. 6 + * Copyright (c) 2019 Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> 7 + * 8 + * TODO: SDIO support 9 + */ 10 + 11 + #include <linux/clk.h> 12 + #include <linux/delay.h> 13 + #include <linux/dmaengine.h> 14 + #include <linux/dma-direction.h> 15 + #include <linux/dma-mapping.h> 16 + #include <linux/interrupt.h> 17 + #include <linux/mmc/host.h> 18 + #include <linux/mmc/slot-gpio.h> 19 + #include <linux/module.h> 20 + #include <linux/of_platform.h> 21 + #include <linux/reset.h> 22 + #include <linux/spinlock.h> 23 + 24 + /* 25 + * SDC registers 26 + */ 27 + #define OWL_REG_SD_EN 0x0000 28 + #define OWL_REG_SD_CTL 0x0004 29 + #define OWL_REG_SD_STATE 0x0008 30 + #define OWL_REG_SD_CMD 0x000c 31 + #define OWL_REG_SD_ARG 0x0010 32 + #define OWL_REG_SD_RSPBUF0 0x0014 33 + #define OWL_REG_SD_RSPBUF1 0x0018 34 + #define OWL_REG_SD_RSPBUF2 0x001c 35 + #define OWL_REG_SD_RSPBUF3 0x0020 36 + #define OWL_REG_SD_RSPBUF4 0x0024 37 + #define OWL_REG_SD_DAT 0x0028 38 + #define OWL_REG_SD_BLK_SIZE 0x002c 39 + #define OWL_REG_SD_BLK_NUM 0x0030 40 + #define OWL_REG_SD_BUF_SIZE 0x0034 41 + 42 + /* SD_EN Bits */ 43 + #define OWL_SD_EN_RANE BIT(31) 44 + #define OWL_SD_EN_RAN_SEED(x) (((x) & 0x3f) << 24) 45 + #define OWL_SD_EN_S18EN BIT(12) 46 + #define OWL_SD_EN_RESE BIT(10) 47 + #define OWL_SD_EN_DAT1_S BIT(9) 48 + #define OWL_SD_EN_CLK_S BIT(8) 49 + #define OWL_SD_ENABLE BIT(7) 50 + #define OWL_SD_EN_BSEL BIT(6) 51 + #define OWL_SD_EN_SDIOEN BIT(3) 52 + #define OWL_SD_EN_DDREN BIT(2) 53 + #define OWL_SD_EN_DATAWID(x) (((x) & 0x3) << 0) 54 + 55 + /* SD_CTL Bits */ 56 + #define OWL_SD_CTL_TOUTEN BIT(31) 57 + #define OWL_SD_CTL_TOUTCNT(x) (((x) & 0x7f) << 24) 58 + #define OWL_SD_CTL_DELAY_MSK GENMASK(23, 16) 59 + #define OWL_SD_CTL_RDELAY(x) (((x) & 0xf) << 20) 60 + #define OWL_SD_CTL_WDELAY(x) (((x) & 0xf) << 16) 61 + #define OWL_SD_CTL_CMDLEN BIT(13) 62 + #define OWL_SD_CTL_SCC BIT(12) 63 + #define OWL_SD_CTL_TCN(x) (((x) & 0xf) << 8) 64 + #define OWL_SD_CTL_TS BIT(7) 65 + #define OWL_SD_CTL_LBE BIT(6) 66 + #define OWL_SD_CTL_C7EN BIT(5) 67 + #define OWL_SD_CTL_TM(x) (((x) & 0xf) << 0) 68 + 69 + #define OWL_SD_DELAY_LOW_CLK 0x0f 70 + #define OWL_SD_DELAY_MID_CLK 0x0a 71 + #define OWL_SD_DELAY_HIGH_CLK 0x09 72 + #define OWL_SD_RDELAY_DDR50 0x0a 73 + #define OWL_SD_WDELAY_DDR50 0x08 74 + 75 + /* SD_STATE Bits */ 76 + #define OWL_SD_STATE_DAT1BS BIT(18) 77 + #define OWL_SD_STATE_SDIOB_P BIT(17) 78 + #define OWL_SD_STATE_SDIOB_EN BIT(16) 79 + #define OWL_SD_STATE_TOUTE BIT(15) 80 + #define OWL_SD_STATE_BAEP BIT(14) 81 + #define OWL_SD_STATE_MEMRDY BIT(12) 82 + #define OWL_SD_STATE_CMDS BIT(11) 83 + #define OWL_SD_STATE_DAT1AS BIT(10) 84 + #define OWL_SD_STATE_SDIOA_P BIT(9) 85 + #define OWL_SD_STATE_SDIOA_EN BIT(8) 86 + #define OWL_SD_STATE_DAT0S BIT(7) 87 + #define OWL_SD_STATE_TEIE BIT(6) 88 + #define OWL_SD_STATE_TEI BIT(5) 89 + #define OWL_SD_STATE_CLNR BIT(4) 90 + #define OWL_SD_STATE_CLC BIT(3) 91 + #define OWL_SD_STATE_WC16ER BIT(2) 92 + #define OWL_SD_STATE_RC16ER BIT(1) 93 + #define OWL_SD_STATE_CRC7ER BIT(0) 94 + 95 + struct owl_mmc_host { 96 + struct device *dev; 97 + struct reset_control *reset; 98 + void __iomem *base; 99 + struct clk *clk; 100 + struct completion sdc_complete; 101 + spinlock_t lock; 102 + int irq; 103 + u32 clock; 104 + bool ddr_50; 105 + 106 + enum dma_data_direction dma_dir; 107 + struct dma_chan *dma; 108 + struct dma_async_tx_descriptor *desc; 109 + struct dma_slave_config dma_cfg; 110 + struct completion dma_complete; 111 + 112 + struct mmc_host *mmc; 113 + struct mmc_request *mrq; 114 + struct mmc_command *cmd; 115 + struct mmc_data *data; 116 + }; 117 + 118 + static void owl_mmc_update_reg(void __iomem *reg, unsigned int val, bool state) 119 + { 120 + unsigned int regval; 121 + 122 + regval = readl(reg); 123 + 124 + if (state) 125 + regval |= val; 126 + else 127 + regval &= ~val; 128 + 129 + writel(regval, reg); 130 + } 131 + 132 + static irqreturn_t owl_irq_handler(int irq, void *devid) 133 + { 134 + struct owl_mmc_host *owl_host = devid; 135 + unsigned long flags; 136 + u32 state; 137 + 138 + spin_lock_irqsave(&owl_host->lock, flags); 139 + 140 + state = readl(owl_host->base + OWL_REG_SD_STATE); 141 + if (state & OWL_SD_STATE_TEI) { 142 + state = readl(owl_host->base + OWL_REG_SD_STATE); 143 + state |= OWL_SD_STATE_TEI; 144 + writel(state, owl_host->base + OWL_REG_SD_STATE); 145 + complete(&owl_host->sdc_complete); 146 + } 147 + 148 + spin_unlock_irqrestore(&owl_host->lock, flags); 149 + 150 + return IRQ_HANDLED; 151 + } 152 + 153 + static void owl_mmc_finish_request(struct owl_mmc_host *owl_host) 154 + { 155 + struct mmc_request *mrq = owl_host->mrq; 156 + struct mmc_data *data = mrq->data; 157 + 158 + /* Should never be NULL */ 159 + WARN_ON(!mrq); 160 + 161 + owl_host->mrq = NULL; 162 + 163 + if (data) 164 + dma_unmap_sg(owl_host->dma->device->dev, data->sg, data->sg_len, 165 + owl_host->dma_dir); 166 + 167 + /* Finally finish request */ 168 + mmc_request_done(owl_host->mmc, mrq); 169 + } 170 + 171 + static void owl_mmc_send_cmd(struct owl_mmc_host *owl_host, 172 + struct mmc_command *cmd, 173 + struct mmc_data *data) 174 + { 175 + u32 mode, state, resp[2]; 176 + u32 cmd_rsp_mask = 0; 177 + 178 + init_completion(&owl_host->sdc_complete); 179 + 180 + switch (mmc_resp_type(cmd)) { 181 + case MMC_RSP_NONE: 182 + mode = OWL_SD_CTL_TM(0); 183 + break; 184 + 185 + case MMC_RSP_R1: 186 + if (data) { 187 + if (data->flags & MMC_DATA_READ) 188 + mode = OWL_SD_CTL_TM(4); 189 + else 190 + mode = OWL_SD_CTL_TM(5); 191 + } else { 192 + mode = OWL_SD_CTL_TM(1); 193 + } 194 + cmd_rsp_mask = OWL_SD_STATE_CLNR | OWL_SD_STATE_CRC7ER; 195 + 196 + break; 197 + 198 + case MMC_RSP_R1B: 199 + mode = OWL_SD_CTL_TM(3); 200 + cmd_rsp_mask = OWL_SD_STATE_CLNR | OWL_SD_STATE_CRC7ER; 201 + break; 202 + 203 + case MMC_RSP_R2: 204 + mode = OWL_SD_CTL_TM(2); 205 + cmd_rsp_mask = OWL_SD_STATE_CLNR | OWL_SD_STATE_CRC7ER; 206 + break; 207 + 208 + case MMC_RSP_R3: 209 + mode = OWL_SD_CTL_TM(1); 210 + cmd_rsp_mask = OWL_SD_STATE_CLNR; 211 + break; 212 + 213 + default: 214 + dev_warn(owl_host->dev, "Unknown MMC command\n"); 215 + cmd->error = -EINVAL; 216 + return; 217 + } 218 + 219 + /* Keep current WDELAY and RDELAY */ 220 + mode |= (readl(owl_host->base + OWL_REG_SD_CTL) & (0xff << 16)); 221 + 222 + /* Start to send corresponding command type */ 223 + writel(cmd->arg, owl_host->base + OWL_REG_SD_ARG); 224 + writel(cmd->opcode, owl_host->base + OWL_REG_SD_CMD); 225 + 226 + /* Set LBE to send clk at the end of last read block */ 227 + if (data) { 228 + mode |= (OWL_SD_CTL_TS | OWL_SD_CTL_LBE | 0x64000000); 229 + } else { 230 + mode &= ~(OWL_SD_CTL_TOUTEN | OWL_SD_CTL_LBE); 231 + mode |= OWL_SD_CTL_TS; 232 + } 233 + 234 + owl_host->cmd = cmd; 235 + 236 + /* Start transfer */ 237 + writel(mode, owl_host->base + OWL_REG_SD_CTL); 238 + 239 + if (data) 240 + return; 241 + 242 + if (!wait_for_completion_timeout(&owl_host->sdc_complete, 30 * HZ)) { 243 + dev_err(owl_host->dev, "CMD interrupt timeout\n"); 244 + cmd->error = -ETIMEDOUT; 245 + return; 246 + } 247 + 248 + state = readl(owl_host->base + OWL_REG_SD_STATE); 249 + if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) { 250 + if (cmd_rsp_mask & state) { 251 + if (state & OWL_SD_STATE_CLNR) { 252 + dev_err(owl_host->dev, "Error CMD_NO_RSP\n"); 253 + cmd->error = -EILSEQ; 254 + return; 255 + } 256 + 257 + if (state & OWL_SD_STATE_CRC7ER) { 258 + dev_err(owl_host->dev, "Error CMD_RSP_CRC\n"); 259 + cmd->error = -EILSEQ; 260 + return; 261 + } 262 + } 263 + 264 + if (mmc_resp_type(cmd) & MMC_RSP_136) { 265 + cmd->resp[3] = readl(owl_host->base + OWL_REG_SD_RSPBUF0); 266 + cmd->resp[2] = readl(owl_host->base + OWL_REG_SD_RSPBUF1); 267 + cmd->resp[1] = readl(owl_host->base + OWL_REG_SD_RSPBUF2); 268 + cmd->resp[0] = readl(owl_host->base + OWL_REG_SD_RSPBUF3); 269 + } else { 270 + resp[0] = readl(owl_host->base + OWL_REG_SD_RSPBUF0); 271 + resp[1] = readl(owl_host->base + OWL_REG_SD_RSPBUF1); 272 + cmd->resp[0] = resp[1] << 24 | resp[0] >> 8; 273 + cmd->resp[1] = resp[1] >> 8; 274 + } 275 + } 276 + } 277 + 278 + static void owl_mmc_dma_complete(void *param) 279 + { 280 + struct owl_mmc_host *owl_host = param; 281 + struct mmc_data *data = owl_host->data; 282 + 283 + if (data) 284 + complete(&owl_host->dma_complete); 285 + } 286 + 287 + static int owl_mmc_prepare_data(struct owl_mmc_host *owl_host, 288 + struct mmc_data *data) 289 + { 290 + u32 total; 291 + 292 + owl_mmc_update_reg(owl_host->base + OWL_REG_SD_EN, OWL_SD_EN_BSEL, 293 + true); 294 + writel(data->blocks, owl_host->base + OWL_REG_SD_BLK_NUM); 295 + writel(data->blksz, owl_host->base + OWL_REG_SD_BLK_SIZE); 296 + total = data->blksz * data->blocks; 297 + 298 + if (total < 512) 299 + writel(total, owl_host->base + OWL_REG_SD_BUF_SIZE); 300 + else 301 + writel(512, owl_host->base + OWL_REG_SD_BUF_SIZE); 302 + 303 + if (data->flags & MMC_DATA_WRITE) { 304 + owl_host->dma_dir = DMA_TO_DEVICE; 305 + owl_host->dma_cfg.direction = DMA_MEM_TO_DEV; 306 + } else { 307 + owl_host->dma_dir = DMA_FROM_DEVICE; 308 + owl_host->dma_cfg.direction = DMA_DEV_TO_MEM; 309 + } 310 + 311 + dma_map_sg(owl_host->dma->device->dev, data->sg, 312 + data->sg_len, owl_host->dma_dir); 313 + 314 + dmaengine_slave_config(owl_host->dma, &owl_host->dma_cfg); 315 + owl_host->desc = dmaengine_prep_slave_sg(owl_host->dma, data->sg, 316 + data->sg_len, 317 + owl_host->dma_cfg.direction, 318 + DMA_PREP_INTERRUPT | 319 + DMA_CTRL_ACK); 320 + if (!owl_host->desc) { 321 + dev_err(owl_host->dev, "Can't prepare slave sg\n"); 322 + return -EBUSY; 323 + } 324 + 325 + owl_host->data = data; 326 + 327 + owl_host->desc->callback = owl_mmc_dma_complete; 328 + owl_host->desc->callback_param = (void *)owl_host; 329 + data->error = 0; 330 + 331 + return 0; 332 + } 333 + 334 + static void owl_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq) 335 + { 336 + struct owl_mmc_host *owl_host = mmc_priv(mmc); 337 + struct mmc_data *data = mrq->data; 338 + int ret; 339 + 340 + owl_host->mrq = mrq; 341 + if (mrq->data) { 342 + ret = owl_mmc_prepare_data(owl_host, data); 343 + if (ret < 0) { 344 + data->error = ret; 345 + goto err_out; 346 + } 347 + 348 + init_completion(&owl_host->dma_complete); 349 + dmaengine_submit(owl_host->desc); 350 + dma_async_issue_pending(owl_host->dma); 351 + } 352 + 353 + owl_mmc_send_cmd(owl_host, mrq->cmd, data); 354 + 355 + if (data) { 356 + if (!wait_for_completion_timeout(&owl_host->sdc_complete, 357 + 10 * HZ)) { 358 + dev_err(owl_host->dev, "CMD interrupt timeout\n"); 359 + mrq->cmd->error = -ETIMEDOUT; 360 + dmaengine_terminate_all(owl_host->dma); 361 + goto err_out; 362 + } 363 + 364 + if (!wait_for_completion_timeout(&owl_host->dma_complete, 365 + 5 * HZ)) { 366 + dev_err(owl_host->dev, "DMA interrupt timeout\n"); 367 + mrq->cmd->error = -ETIMEDOUT; 368 + dmaengine_terminate_all(owl_host->dma); 369 + goto err_out; 370 + } 371 + 372 + if (data->stop) 373 + owl_mmc_send_cmd(owl_host, data->stop, NULL); 374 + 375 + data->bytes_xfered = data->blocks * data->blksz; 376 + } 377 + 378 + err_out: 379 + owl_mmc_finish_request(owl_host); 380 + } 381 + 382 + static int owl_mmc_set_clk_rate(struct owl_mmc_host *owl_host, 383 + unsigned int rate) 384 + { 385 + unsigned long clk_rate; 386 + int ret; 387 + u32 reg; 388 + 389 + reg = readl(owl_host->base + OWL_REG_SD_CTL); 390 + reg &= ~OWL_SD_CTL_DELAY_MSK; 391 + 392 + /* Set RDELAY and WDELAY based on the clock */ 393 + if (rate <= 1000000) { 394 + writel(reg | OWL_SD_CTL_RDELAY(OWL_SD_DELAY_LOW_CLK) | 395 + OWL_SD_CTL_WDELAY(OWL_SD_DELAY_LOW_CLK), 396 + owl_host->base + OWL_REG_SD_CTL); 397 + } else if ((rate > 1000000) && (rate <= 26000000)) { 398 + writel(reg | OWL_SD_CTL_RDELAY(OWL_SD_DELAY_MID_CLK) | 399 + OWL_SD_CTL_WDELAY(OWL_SD_DELAY_MID_CLK), 400 + owl_host->base + OWL_REG_SD_CTL); 401 + } else if ((rate > 26000000) && (rate <= 52000000) && !owl_host->ddr_50) { 402 + writel(reg | OWL_SD_CTL_RDELAY(OWL_SD_DELAY_HIGH_CLK) | 403 + OWL_SD_CTL_WDELAY(OWL_SD_DELAY_HIGH_CLK), 404 + owl_host->base + OWL_REG_SD_CTL); 405 + /* DDR50 mode has special delay chain */ 406 + } else if ((rate > 26000000) && (rate <= 52000000) && owl_host->ddr_50) { 407 + writel(reg | OWL_SD_CTL_RDELAY(OWL_SD_RDELAY_DDR50) | 408 + OWL_SD_CTL_WDELAY(OWL_SD_WDELAY_DDR50), 409 + owl_host->base + OWL_REG_SD_CTL); 410 + } else { 411 + dev_err(owl_host->dev, "SD clock rate not supported\n"); 412 + return -EINVAL; 413 + } 414 + 415 + clk_rate = clk_round_rate(owl_host->clk, rate << 1); 416 + ret = clk_set_rate(owl_host->clk, clk_rate); 417 + 418 + return ret; 419 + } 420 + 421 + static void owl_mmc_set_clk(struct owl_mmc_host *owl_host, struct mmc_ios *ios) 422 + { 423 + if (!ios->clock) 424 + return; 425 + 426 + owl_host->clock = ios->clock; 427 + owl_mmc_set_clk_rate(owl_host, ios->clock); 428 + } 429 + 430 + static void owl_mmc_set_bus_width(struct owl_mmc_host *owl_host, 431 + struct mmc_ios *ios) 432 + { 433 + u32 reg; 434 + 435 + reg = readl(owl_host->base + OWL_REG_SD_EN); 436 + reg &= ~0x03; 437 + switch (ios->bus_width) { 438 + case MMC_BUS_WIDTH_1: 439 + break; 440 + case MMC_BUS_WIDTH_4: 441 + reg |= OWL_SD_EN_DATAWID(1); 442 + break; 443 + case MMC_BUS_WIDTH_8: 444 + reg |= OWL_SD_EN_DATAWID(2); 445 + break; 446 + } 447 + 448 + writel(reg, owl_host->base + OWL_REG_SD_EN); 449 + } 450 + 451 + static void owl_mmc_ctr_reset(struct owl_mmc_host *owl_host) 452 + { 453 + reset_control_assert(owl_host->reset); 454 + udelay(20); 455 + reset_control_deassert(owl_host->reset); 456 + } 457 + 458 + static void owl_mmc_power_on(struct owl_mmc_host *owl_host) 459 + { 460 + u32 mode; 461 + 462 + init_completion(&owl_host->sdc_complete); 463 + 464 + /* Enable transfer end IRQ */ 465 + owl_mmc_update_reg(owl_host->base + OWL_REG_SD_STATE, 466 + OWL_SD_STATE_TEIE, true); 467 + 468 + /* Send init clk */ 469 + mode = (readl(owl_host->base + OWL_REG_SD_CTL) & (0xff << 16)); 470 + mode |= OWL_SD_CTL_TS | OWL_SD_CTL_TCN(5) | OWL_SD_CTL_TM(8); 471 + writel(mode, owl_host->base + OWL_REG_SD_CTL); 472 + 473 + if (!wait_for_completion_timeout(&owl_host->sdc_complete, HZ)) { 474 + dev_err(owl_host->dev, "CMD interrupt timeout\n"); 475 + return; 476 + } 477 + } 478 + 479 + static void owl_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) 480 + { 481 + struct owl_mmc_host *owl_host = mmc_priv(mmc); 482 + 483 + switch (ios->power_mode) { 484 + case MMC_POWER_UP: 485 + dev_dbg(owl_host->dev, "Powering card up\n"); 486 + 487 + /* Reset the SDC controller to clear all previous states */ 488 + owl_mmc_ctr_reset(owl_host); 489 + clk_prepare_enable(owl_host->clk); 490 + writel(OWL_SD_ENABLE | OWL_SD_EN_RESE, 491 + owl_host->base + OWL_REG_SD_EN); 492 + 493 + break; 494 + 495 + case MMC_POWER_ON: 496 + dev_dbg(owl_host->dev, "Powering card on\n"); 497 + owl_mmc_power_on(owl_host); 498 + 499 + break; 500 + 501 + case MMC_POWER_OFF: 502 + dev_dbg(owl_host->dev, "Powering card off\n"); 503 + clk_disable_unprepare(owl_host->clk); 504 + 505 + return; 506 + 507 + default: 508 + dev_dbg(owl_host->dev, "Ignoring unknown card power state\n"); 509 + break; 510 + } 511 + 512 + if (ios->clock != owl_host->clock) 513 + owl_mmc_set_clk(owl_host, ios); 514 + 515 + owl_mmc_set_bus_width(owl_host, ios); 516 + 517 + /* Enable DDR mode if requested */ 518 + if (ios->timing == MMC_TIMING_UHS_DDR50) { 519 + owl_host->ddr_50 = 1; 520 + owl_mmc_update_reg(owl_host->base + OWL_REG_SD_EN, 521 + OWL_SD_EN_DDREN, true); 522 + } else { 523 + owl_host->ddr_50 = 0; 524 + } 525 + } 526 + 527 + static int owl_mmc_start_signal_voltage_switch(struct mmc_host *mmc, 528 + struct mmc_ios *ios) 529 + { 530 + struct owl_mmc_host *owl_host = mmc_priv(mmc); 531 + 532 + /* It is enough to change the pad ctrl bit for voltage switch */ 533 + switch (ios->signal_voltage) { 534 + case MMC_SIGNAL_VOLTAGE_330: 535 + owl_mmc_update_reg(owl_host->base + OWL_REG_SD_EN, 536 + OWL_SD_EN_S18EN, false); 537 + break; 538 + case MMC_SIGNAL_VOLTAGE_180: 539 + owl_mmc_update_reg(owl_host->base + OWL_REG_SD_EN, 540 + OWL_SD_EN_S18EN, true); 541 + break; 542 + default: 543 + return -ENOTSUPP; 544 + } 545 + 546 + return 0; 547 + } 548 + 549 + static const struct mmc_host_ops owl_mmc_ops = { 550 + .request = owl_mmc_request, 551 + .set_ios = owl_mmc_set_ios, 552 + .get_ro = mmc_gpio_get_ro, 553 + .get_cd = mmc_gpio_get_cd, 554 + .start_signal_voltage_switch = owl_mmc_start_signal_voltage_switch, 555 + }; 556 + 557 + static int owl_mmc_probe(struct platform_device *pdev) 558 + { 559 + struct owl_mmc_host *owl_host; 560 + struct mmc_host *mmc; 561 + struct resource *res; 562 + int ret; 563 + 564 + mmc = mmc_alloc_host(sizeof(struct owl_mmc_host), &pdev->dev); 565 + if (!mmc) { 566 + dev_err(&pdev->dev, "mmc alloc host failed\n"); 567 + return -ENOMEM; 568 + } 569 + platform_set_drvdata(pdev, mmc); 570 + 571 + owl_host = mmc_priv(mmc); 572 + owl_host->dev = &pdev->dev; 573 + owl_host->mmc = mmc; 574 + spin_lock_init(&owl_host->lock); 575 + 576 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 577 + owl_host->base = devm_ioremap_resource(&pdev->dev, res); 578 + if (IS_ERR(owl_host->base)) { 579 + dev_err(&pdev->dev, "Failed to remap registers\n"); 580 + ret = PTR_ERR(owl_host->base); 581 + goto err_free_host; 582 + } 583 + 584 + owl_host->clk = devm_clk_get(&pdev->dev, NULL); 585 + if (IS_ERR(owl_host->clk)) { 586 + dev_err(&pdev->dev, "No clock defined\n"); 587 + ret = PTR_ERR(owl_host->clk); 588 + goto err_free_host; 589 + } 590 + 591 + owl_host->reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); 592 + if (IS_ERR(owl_host->reset)) { 593 + dev_err(&pdev->dev, "Could not get reset control\n"); 594 + ret = PTR_ERR(owl_host->reset); 595 + goto err_free_host; 596 + } 597 + 598 + mmc->ops = &owl_mmc_ops; 599 + mmc->max_blk_count = 512; 600 + mmc->max_blk_size = 512; 601 + mmc->max_segs = 256; 602 + mmc->max_seg_size = 262144; 603 + mmc->max_req_size = 262144; 604 + /* 100kHz ~ 52MHz */ 605 + mmc->f_min = 100000; 606 + mmc->f_max = 52000000; 607 + mmc->caps |= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED | 608 + MMC_CAP_4_BIT_DATA; 609 + mmc->caps2 = (MMC_CAP2_BOOTPART_NOACC | MMC_CAP2_NO_SDIO); 610 + mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34 | 611 + MMC_VDD_165_195; 612 + 613 + ret = mmc_of_parse(mmc); 614 + if (ret) 615 + goto err_free_host; 616 + 617 + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); 618 + pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; 619 + owl_host->dma = dma_request_slave_channel(&pdev->dev, "mmc"); 620 + if (!owl_host->dma) { 621 + dev_err(owl_host->dev, "Failed to get external DMA channel.\n"); 622 + ret = -ENXIO; 623 + goto err_free_host; 624 + } 625 + 626 + dev_info(&pdev->dev, "Using %s for DMA transfers\n", 627 + dma_chan_name(owl_host->dma)); 628 + 629 + owl_host->dma_cfg.src_addr = res->start + OWL_REG_SD_DAT; 630 + owl_host->dma_cfg.dst_addr = res->start + OWL_REG_SD_DAT; 631 + owl_host->dma_cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 632 + owl_host->dma_cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; 633 + owl_host->dma_cfg.device_fc = false; 634 + 635 + owl_host->irq = platform_get_irq(pdev, 0); 636 + if (owl_host->irq < 0) { 637 + ret = -EINVAL; 638 + goto err_free_host; 639 + } 640 + 641 + ret = devm_request_irq(&pdev->dev, owl_host->irq, owl_irq_handler, 642 + 0, dev_name(&pdev->dev), owl_host); 643 + if (ret) { 644 + dev_err(&pdev->dev, "Failed to request irq %d\n", 645 + owl_host->irq); 646 + goto err_free_host; 647 + } 648 + 649 + ret = mmc_add_host(mmc); 650 + if (ret) { 651 + dev_err(&pdev->dev, "Failed to add host\n"); 652 + goto err_free_host; 653 + } 654 + 655 + dev_dbg(&pdev->dev, "Owl MMC Controller Initialized\n"); 656 + 657 + return 0; 658 + 659 + err_free_host: 660 + mmc_free_host(mmc); 661 + 662 + return ret; 663 + } 664 + 665 + static int owl_mmc_remove(struct platform_device *pdev) 666 + { 667 + struct mmc_host *mmc = platform_get_drvdata(pdev); 668 + struct owl_mmc_host *owl_host = mmc_priv(mmc); 669 + 670 + mmc_remove_host(mmc); 671 + disable_irq(owl_host->irq); 672 + mmc_free_host(mmc); 673 + 674 + return 0; 675 + } 676 + 677 + static const struct of_device_id owl_mmc_of_match[] = { 678 + {.compatible = "actions,owl-mmc",}, 679 + { /* sentinel */ } 680 + }; 681 + MODULE_DEVICE_TABLE(of, owl_mmc_of_match); 682 + 683 + static struct platform_driver owl_mmc_driver = { 684 + .driver = { 685 + .name = "owl_mmc", 686 + .of_match_table = of_match_ptr(owl_mmc_of_match), 687 + }, 688 + .probe = owl_mmc_probe, 689 + .remove = owl_mmc_remove, 690 + }; 691 + module_platform_driver(owl_mmc_driver); 692 + 693 + MODULE_DESCRIPTION("Actions Semi Owl SoCs SD/MMC Driver"); 694 + MODULE_AUTHOR("Actions Semi"); 695 + MODULE_AUTHOR("Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>"); 696 + MODULE_LICENSE("GPL");
+1
drivers/mmc/host/renesas_sdhi_internal_dmac.c
··· 308 308 .data = (void *)BIT(SDHI_INTERNAL_DMAC_ONE_RX_ONLY) }, 309 309 /* generic ones */ 310 310 { .soc_id = "r8a774a1" }, 311 + { .soc_id = "r8a774b1" }, 311 312 { .soc_id = "r8a774c0" }, 312 313 { .soc_id = "r8a77470" }, 313 314 { .soc_id = "r8a7795" },
+14
drivers/mmc/host/sdhci-esdhc.h
··· 51 51 #define ESDHC_CLOCK_HCKEN 0x00000002 52 52 #define ESDHC_CLOCK_IPGEN 0x00000001 53 53 54 + /* System Control 2 Register */ 55 + #define ESDHC_SYSTEM_CONTROL_2 0x3c 56 + #define ESDHC_SMPCLKSEL 0x00800000 57 + #define ESDHC_EXTN 0x00400000 58 + 54 59 /* Host Controller Capabilities Register 2 */ 55 60 #define ESDHC_CAPABILITIES_1 0x114 56 61 ··· 64 59 #define ESDHC_HS400_WNDW_ADJUST 0x00000040 65 60 #define ESDHC_HS400_MODE 0x00000010 66 61 #define ESDHC_TB_EN 0x00000004 62 + #define ESDHC_TB_MODE_MASK 0x00000003 63 + #define ESDHC_TB_MODE_SW 0x00000003 64 + #define ESDHC_TB_MODE_3 0x00000002 65 + 66 + #define ESDHC_TBSTAT 0x124 67 + 67 68 #define ESDHC_TBPTR 0x128 69 + #define ESDHC_WNDW_STRT_PTR_SHIFT 8 70 + #define ESDHC_WNDW_STRT_PTR_MASK (0x7f << 8) 71 + #define ESDHC_WNDW_END_PTR_MASK 0x7f 68 72 69 73 /* SD Clock Control Register */ 70 74 #define ESDHC_SDCLKCTL 0x144
+362
drivers/mmc/host/sdhci-milbeaut.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Copyright (C) 2013 - 2015 Fujitsu Semiconductor, Ltd 4 + * Vincent Yang <vincent.yang@tw.fujitsu.com> 5 + * Copyright (C) 2015 Linaro Ltd Andy Green <andy.green@linaro.org> 6 + * Copyright (C) 2019 Socionext Inc. 7 + * Takao Orito <orito.takao@socionext.com> 8 + */ 9 + 10 + #include <linux/bits.h> 11 + #include <linux/clk.h> 12 + #include <linux/delay.h> 13 + #include <linux/err.h> 14 + #include <linux/gpio/consumer.h> 15 + #include <linux/module.h> 16 + #include <linux/of.h> 17 + #include <linux/property.h> 18 + 19 + #include "sdhci-pltfm.h" 20 + #include "sdhci_f_sdh30.h" 21 + 22 + /* milbeaut bridge controller register */ 23 + #define MLB_SOFT_RESET 0x0200 24 + #define MLB_SOFT_RESET_RSTX BIT(0) 25 + 26 + #define MLB_WP_CD_LED_SET 0x0210 27 + #define MLB_WP_CD_LED_SET_LED_INV BIT(2) 28 + 29 + #define MLB_CR_SET 0x0220 30 + #define MLB_CR_SET_CR_TOCLKUNIT BIT(24) 31 + #define MLB_CR_SET_CR_TOCLKFREQ_SFT (16) 32 + #define MLB_CR_SET_CR_TOCLKFREQ_MASK (0x3F << MLB_CR_SET_CR_TOCLKFREQ_SFT) 33 + #define MLB_CR_SET_CR_BCLKFREQ_SFT (8) 34 + #define MLB_CR_SET_CR_BCLKFREQ_MASK (0xFF << MLB_CR_SET_CR_BCLKFREQ_SFT) 35 + #define MLB_CR_SET_CR_RTUNTIMER_SFT (4) 36 + #define MLB_CR_SET_CR_RTUNTIMER_MASK (0xF << MLB_CR_SET_CR_RTUNTIMER_SFT) 37 + 38 + #define MLB_SD_TOCLK_I_DIV 16 39 + #define MLB_TOCLKFREQ_UNIT_THRES 16000000 40 + #define MLB_CAL_TOCLKFREQ_MHZ(rate) (rate / MLB_SD_TOCLK_I_DIV / 1000000) 41 + #define MLB_CAL_TOCLKFREQ_KHZ(rate) (rate / MLB_SD_TOCLK_I_DIV / 1000) 42 + #define MLB_TOCLKFREQ_MAX 63 43 + #define MLB_TOCLKFREQ_MIN 1 44 + 45 + #define MLB_SD_BCLK_I_DIV 4 46 + #define MLB_CAL_BCLKFREQ(rate) (rate / MLB_SD_BCLK_I_DIV / 1000000) 47 + #define MLB_BCLKFREQ_MAX 255 48 + #define MLB_BCLKFREQ_MIN 1 49 + 50 + #define MLB_CDR_SET 0x0230 51 + #define MLB_CDR_SET_CLK2POW16 3 52 + 53 + struct f_sdhost_priv { 54 + struct clk *clk_iface; 55 + struct clk *clk; 56 + struct device *dev; 57 + bool enable_cmd_dat_delay; 58 + }; 59 + 60 + static void sdhci_milbeaut_soft_voltage_switch(struct sdhci_host *host) 61 + { 62 + u32 ctrl = 0; 63 + 64 + usleep_range(2500, 3000); 65 + ctrl = sdhci_readl(host, F_SDH30_IO_CONTROL2); 66 + ctrl |= F_SDH30_CRES_O_DN; 67 + sdhci_writel(host, ctrl, F_SDH30_IO_CONTROL2); 68 + ctrl |= F_SDH30_MSEL_O_1_8; 69 + sdhci_writel(host, ctrl, F_SDH30_IO_CONTROL2); 70 + 71 + ctrl &= ~F_SDH30_CRES_O_DN; 72 + sdhci_writel(host, ctrl, F_SDH30_IO_CONTROL2); 73 + usleep_range(2500, 3000); 74 + 75 + ctrl = sdhci_readl(host, F_SDH30_TUNING_SETTING); 76 + ctrl |= F_SDH30_CMD_CHK_DIS; 77 + sdhci_writel(host, ctrl, F_SDH30_TUNING_SETTING); 78 + } 79 + 80 + static unsigned int sdhci_milbeaut_get_min_clock(struct sdhci_host *host) 81 + { 82 + return F_SDH30_MIN_CLOCK; 83 + } 84 + 85 + static void sdhci_milbeaut_reset(struct sdhci_host *host, u8 mask) 86 + { 87 + struct f_sdhost_priv *priv = sdhci_priv(host); 88 + u16 clk; 89 + u32 ctl; 90 + ktime_t timeout; 91 + 92 + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 93 + clk = (clk & ~SDHCI_CLOCK_CARD_EN) | SDHCI_CLOCK_INT_EN; 94 + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); 95 + 96 + sdhci_reset(host, mask); 97 + 98 + clk |= SDHCI_CLOCK_CARD_EN; 99 + sdhci_writew(host, clk, SDHCI_CLOCK_CONTROL); 100 + 101 + timeout = ktime_add_ms(ktime_get(), 10); 102 + while (1) { 103 + bool timedout = ktime_after(ktime_get(), timeout); 104 + 105 + clk = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 106 + if (clk & SDHCI_CLOCK_INT_STABLE) 107 + break; 108 + if (timedout) { 109 + pr_err("%s: Internal clock never stabilised.\n", 110 + mmc_hostname(host->mmc)); 111 + sdhci_dumpregs(host); 112 + return; 113 + } 114 + udelay(10); 115 + } 116 + 117 + if (priv->enable_cmd_dat_delay) { 118 + ctl = sdhci_readl(host, F_SDH30_ESD_CONTROL); 119 + ctl |= F_SDH30_CMD_DAT_DELAY; 120 + sdhci_writel(host, ctl, F_SDH30_ESD_CONTROL); 121 + } 122 + } 123 + 124 + static void sdhci_milbeaut_set_power(struct sdhci_host *host, 125 + unsigned char mode, unsigned short vdd) 126 + { 127 + if (!IS_ERR(host->mmc->supply.vmmc)) { 128 + struct mmc_host *mmc = host->mmc; 129 + 130 + mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); 131 + } 132 + sdhci_set_power_noreg(host, mode, vdd); 133 + } 134 + 135 + static const struct sdhci_ops sdhci_milbeaut_ops = { 136 + .voltage_switch = sdhci_milbeaut_soft_voltage_switch, 137 + .get_min_clock = sdhci_milbeaut_get_min_clock, 138 + .reset = sdhci_milbeaut_reset, 139 + .set_clock = sdhci_set_clock, 140 + .set_bus_width = sdhci_set_bus_width, 141 + .set_uhs_signaling = sdhci_set_uhs_signaling, 142 + .set_power = sdhci_milbeaut_set_power, 143 + }; 144 + 145 + static void sdhci_milbeaut_bridge_reset(struct sdhci_host *host, 146 + int reset_flag) 147 + { 148 + if (reset_flag) 149 + sdhci_writel(host, 0, MLB_SOFT_RESET); 150 + else 151 + sdhci_writel(host, MLB_SOFT_RESET_RSTX, MLB_SOFT_RESET); 152 + } 153 + 154 + static void sdhci_milbeaut_bridge_init(struct sdhci_host *host, 155 + int rate) 156 + { 157 + u32 val, clk; 158 + 159 + /* IO_SDIO_CR_SET should be set while reset */ 160 + val = sdhci_readl(host, MLB_CR_SET); 161 + val &= ~(MLB_CR_SET_CR_TOCLKFREQ_MASK | MLB_CR_SET_CR_TOCLKUNIT | 162 + MLB_CR_SET_CR_BCLKFREQ_MASK); 163 + if (rate >= MLB_TOCLKFREQ_UNIT_THRES) { 164 + clk = MLB_CAL_TOCLKFREQ_MHZ(rate); 165 + clk = min_t(u32, MLB_TOCLKFREQ_MAX, clk); 166 + val |= MLB_CR_SET_CR_TOCLKUNIT | 167 + (clk << MLB_CR_SET_CR_TOCLKFREQ_SFT); 168 + } else { 169 + clk = MLB_CAL_TOCLKFREQ_KHZ(rate); 170 + clk = min_t(u32, MLB_TOCLKFREQ_MAX, clk); 171 + clk = max_t(u32, MLB_TOCLKFREQ_MIN, clk); 172 + val |= clk << MLB_CR_SET_CR_TOCLKFREQ_SFT; 173 + } 174 + 175 + clk = MLB_CAL_BCLKFREQ(rate); 176 + clk = min_t(u32, MLB_BCLKFREQ_MAX, clk); 177 + clk = max_t(u32, MLB_BCLKFREQ_MIN, clk); 178 + val |= clk << MLB_CR_SET_CR_BCLKFREQ_SFT; 179 + val &= ~MLB_CR_SET_CR_RTUNTIMER_MASK; 180 + sdhci_writel(host, val, MLB_CR_SET); 181 + 182 + sdhci_writel(host, MLB_CDR_SET_CLK2POW16, MLB_CDR_SET); 183 + 184 + sdhci_writel(host, MLB_WP_CD_LED_SET_LED_INV, MLB_WP_CD_LED_SET); 185 + } 186 + 187 + static void sdhci_milbeaut_vendor_init(struct sdhci_host *host) 188 + { 189 + struct f_sdhost_priv *priv = sdhci_priv(host); 190 + u32 ctl; 191 + 192 + ctl = sdhci_readl(host, F_SDH30_IO_CONTROL2); 193 + ctl |= F_SDH30_CRES_O_DN; 194 + sdhci_writel(host, ctl, F_SDH30_IO_CONTROL2); 195 + ctl &= ~F_SDH30_MSEL_O_1_8; 196 + sdhci_writel(host, ctl, F_SDH30_IO_CONTROL2); 197 + ctl &= ~F_SDH30_CRES_O_DN; 198 + sdhci_writel(host, ctl, F_SDH30_IO_CONTROL2); 199 + 200 + ctl = sdhci_readw(host, F_SDH30_AHB_CONFIG); 201 + ctl |= F_SDH30_SIN | F_SDH30_AHB_INCR_16 | F_SDH30_AHB_INCR_8 | 202 + F_SDH30_AHB_INCR_4; 203 + ctl &= ~(F_SDH30_AHB_BIGED | F_SDH30_BUSLOCK_EN); 204 + sdhci_writew(host, ctl, F_SDH30_AHB_CONFIG); 205 + 206 + if (priv->enable_cmd_dat_delay) { 207 + ctl = sdhci_readl(host, F_SDH30_ESD_CONTROL); 208 + ctl |= F_SDH30_CMD_DAT_DELAY; 209 + sdhci_writel(host, ctl, F_SDH30_ESD_CONTROL); 210 + } 211 + } 212 + 213 + static const struct of_device_id mlb_dt_ids[] = { 214 + { 215 + .compatible = "socionext,milbeaut-m10v-sdhci-3.0", 216 + }, 217 + { /* sentinel */ } 218 + }; 219 + MODULE_DEVICE_TABLE(of, mlb_dt_ids); 220 + 221 + static void sdhci_milbeaut_init(struct sdhci_host *host) 222 + { 223 + struct f_sdhost_priv *priv = sdhci_priv(host); 224 + int rate = clk_get_rate(priv->clk); 225 + u16 ctl; 226 + 227 + sdhci_milbeaut_bridge_reset(host, 0); 228 + 229 + ctl = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 230 + ctl &= ~(SDHCI_CLOCK_CARD_EN | SDHCI_CLOCK_INT_EN); 231 + sdhci_writew(host, ctl, SDHCI_CLOCK_CONTROL); 232 + 233 + sdhci_milbeaut_bridge_reset(host, 1); 234 + 235 + sdhci_milbeaut_bridge_init(host, rate); 236 + sdhci_milbeaut_bridge_reset(host, 0); 237 + 238 + sdhci_milbeaut_vendor_init(host); 239 + } 240 + 241 + static int sdhci_milbeaut_probe(struct platform_device *pdev) 242 + { 243 + struct sdhci_host *host; 244 + struct device *dev = &pdev->dev; 245 + struct resource *res; 246 + int irq, ret = 0; 247 + struct f_sdhost_priv *priv; 248 + 249 + irq = platform_get_irq(pdev, 0); 250 + if (irq < 0) { 251 + dev_err(dev, "%s: no irq specified\n", __func__); 252 + return irq; 253 + } 254 + 255 + host = sdhci_alloc_host(dev, sizeof(struct f_sdhost_priv)); 256 + if (IS_ERR(host)) 257 + return PTR_ERR(host); 258 + 259 + priv = sdhci_priv(host); 260 + priv->dev = dev; 261 + 262 + host->quirks = SDHCI_QUIRK_NO_ENDATTR_IN_NOPDESC | 263 + SDHCI_QUIRK_INVERTED_WRITE_PROTECT | 264 + SDHCI_QUIRK_CLOCK_BEFORE_RESET | 265 + SDHCI_QUIRK_DELAY_AFTER_POWER; 266 + host->quirks2 = SDHCI_QUIRK2_SUPPORT_SINGLE | 267 + SDHCI_QUIRK2_TUNING_WORK_AROUND | 268 + SDHCI_QUIRK2_PRESET_VALUE_BROKEN; 269 + 270 + priv->enable_cmd_dat_delay = device_property_read_bool(dev, 271 + "fujitsu,cmd-dat-delay-select"); 272 + 273 + ret = mmc_of_parse(host->mmc); 274 + if (ret) 275 + goto err; 276 + 277 + platform_set_drvdata(pdev, host); 278 + 279 + host->hw_name = "f_sdh30"; 280 + host->ops = &sdhci_milbeaut_ops; 281 + host->irq = irq; 282 + 283 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 284 + host->ioaddr = devm_ioremap_resource(&pdev->dev, res); 285 + if (IS_ERR(host->ioaddr)) { 286 + ret = PTR_ERR(host->ioaddr); 287 + goto err; 288 + } 289 + 290 + if (dev_of_node(dev)) { 291 + sdhci_get_of_property(pdev); 292 + 293 + priv->clk_iface = devm_clk_get(&pdev->dev, "iface"); 294 + if (IS_ERR(priv->clk_iface)) { 295 + ret = PTR_ERR(priv->clk_iface); 296 + goto err; 297 + } 298 + 299 + ret = clk_prepare_enable(priv->clk_iface); 300 + if (ret) 301 + goto err; 302 + 303 + priv->clk = devm_clk_get(&pdev->dev, "core"); 304 + if (IS_ERR(priv->clk)) { 305 + ret = PTR_ERR(priv->clk); 306 + goto err_clk; 307 + } 308 + 309 + ret = clk_prepare_enable(priv->clk); 310 + if (ret) 311 + goto err_clk; 312 + } 313 + 314 + sdhci_milbeaut_init(host); 315 + 316 + ret = sdhci_add_host(host); 317 + if (ret) 318 + goto err_add_host; 319 + 320 + return 0; 321 + 322 + err_add_host: 323 + clk_disable_unprepare(priv->clk); 324 + err_clk: 325 + clk_disable_unprepare(priv->clk_iface); 326 + err: 327 + sdhci_free_host(host); 328 + return ret; 329 + } 330 + 331 + static int sdhci_milbeaut_remove(struct platform_device *pdev) 332 + { 333 + struct sdhci_host *host = platform_get_drvdata(pdev); 334 + struct f_sdhost_priv *priv = sdhci_priv(host); 335 + 336 + sdhci_remove_host(host, readl(host->ioaddr + SDHCI_INT_STATUS) == 337 + 0xffffffff); 338 + 339 + clk_disable_unprepare(priv->clk_iface); 340 + clk_disable_unprepare(priv->clk); 341 + 342 + sdhci_free_host(host); 343 + platform_set_drvdata(pdev, NULL); 344 + 345 + return 0; 346 + } 347 + 348 + static struct platform_driver sdhci_milbeaut_driver = { 349 + .driver = { 350 + .name = "sdhci-milbeaut", 351 + .of_match_table = of_match_ptr(mlb_dt_ids), 352 + }, 353 + .probe = sdhci_milbeaut_probe, 354 + .remove = sdhci_milbeaut_remove, 355 + }; 356 + 357 + module_platform_driver(sdhci_milbeaut_driver); 358 + 359 + MODULE_DESCRIPTION("MILBEAUT SD Card Controller driver"); 360 + MODULE_AUTHOR("Takao Orito <orito.takao@socionext.com>"); 361 + MODULE_LICENSE("GPL v2"); 362 + MODULE_ALIAS("platform:sdhci-milbeaut");
+485 -48
drivers/mmc/host/sdhci-of-arasan.c
··· 22 22 #include <linux/phy/phy.h> 23 23 #include <linux/regmap.h> 24 24 #include <linux/of.h> 25 + #include <linux/firmware/xlnx-zynqmp.h> 25 26 26 27 #include "cqhci.h" 27 28 #include "sdhci-pltfm.h" ··· 32 31 #define VENDOR_ENHANCED_STROBE BIT(0) 33 32 34 33 #define PHY_CLK_TOO_SLOW_HZ 400000 34 + 35 + /* Default settings for ZynqMP Clock Phases */ 36 + #define ZYNQMP_ICLK_PHASE {0, 63, 63, 0, 63, 0, 0, 183, 54, 0, 0} 37 + #define ZYNQMP_OCLK_PHASE {0, 72, 60, 0, 60, 72, 135, 48, 72, 135, 0} 35 38 36 39 /* 37 40 * On some SoCs the syscon area has a feature where the upper 16-bits of ··· 77 72 }; 78 73 79 74 /** 75 + * struct sdhci_arasan_clk_data 76 + * @sdcardclk_hw: Struct for the clock we might provide to a PHY. 77 + * @sdcardclk: Pointer to normal 'struct clock' for sdcardclk_hw. 78 + * @sampleclk_hw: Struct for the clock we might provide to a PHY. 79 + * @sampleclk: Pointer to normal 'struct clock' for sampleclk_hw. 80 + * @clk_phase_in: Array of Input Clock Phase Delays for all speed modes 81 + * @clk_phase_out: Array of Output Clock Phase Delays for all speed modes 82 + * @set_clk_delays: Function pointer for setting Clock Delays 83 + * @clk_of_data: Platform specific runtime clock data storage pointer 84 + */ 85 + struct sdhci_arasan_clk_data { 86 + struct clk_hw sdcardclk_hw; 87 + struct clk *sdcardclk; 88 + struct clk_hw sampleclk_hw; 89 + struct clk *sampleclk; 90 + int clk_phase_in[MMC_TIMING_MMC_HS400 + 1]; 91 + int clk_phase_out[MMC_TIMING_MMC_HS400 + 1]; 92 + void (*set_clk_delays)(struct sdhci_host *host); 93 + void *clk_of_data; 94 + }; 95 + 96 + struct sdhci_arasan_zynqmp_clk_data { 97 + const struct zynqmp_eemi_ops *eemi_ops; 98 + }; 99 + 100 + /** 80 101 * struct sdhci_arasan_data 81 102 * @host: Pointer to the main SDHCI host structure. 82 103 * @clk_ahb: Pointer to the AHB clock 83 104 * @phy: Pointer to the generic phy 84 105 * @is_phy_on: True if the PHY is on; false if not. 85 - * @sdcardclk_hw: Struct for the clock we might provide to a PHY. 86 - * @sdcardclk: Pointer to normal 'struct clock' for sdcardclk_hw. 106 + * @clk_data: Struct for the Arasan Controller Clock Data. 87 107 * @soc_ctl_base: Pointer to regmap for syscon for soc_ctl registers. 88 108 * @soc_ctl_map: Map to get offsets into soc_ctl registers. 89 109 */ ··· 119 89 bool is_phy_on; 120 90 121 91 bool has_cqe; 122 - struct clk_hw sdcardclk_hw; 123 - struct clk *sdcardclk; 92 + struct sdhci_arasan_clk_data clk_data; 124 93 125 94 struct regmap *soc_ctl_base; 126 95 const struct sdhci_arasan_soc_ctl_map *soc_ctl_map; ··· 145 116 146 117 static const struct sdhci_arasan_soc_ctl_map intel_lgm_emmc_soc_ctl_map = { 147 118 .baseclkfreq = { .reg = 0xa0, .width = 8, .shift = 2 }, 119 + .clockmultiplier = { .reg = 0, .width = -1, .shift = -1 }, 120 + .hiword_update = false, 121 + }; 122 + 123 + static const struct sdhci_arasan_soc_ctl_map intel_lgm_sdxc_soc_ctl_map = { 124 + .baseclkfreq = { .reg = 0x80, .width = 8, .shift = 2 }, 148 125 .clockmultiplier = { .reg = 0, .width = -1, .shift = -1 }, 149 126 .hiword_update = false, 150 127 }; ··· 209 174 { 210 175 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 211 176 struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host); 177 + struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data; 212 178 bool ctrl_phy = false; 213 179 214 180 if (!IS_ERR(sdhci_arasan->phy)) { ··· 250 214 phy_power_off(sdhci_arasan->phy); 251 215 sdhci_arasan->is_phy_on = false; 252 216 } 217 + 218 + /* Set the Input and Output Clock Phase Delays */ 219 + if (clk_data->set_clk_delays) 220 + clk_data->set_clk_delays(host); 253 221 254 222 sdhci_set_clock(host, clock); 255 223 ··· 424 384 .pdata = &sdhci_arasan_cqe_pdata, 425 385 }; 426 386 387 + static struct sdhci_arasan_of_data intel_lgm_sdxc_data = { 388 + .soc_ctl_map = &intel_lgm_sdxc_soc_ctl_map, 389 + .pdata = &sdhci_arasan_cqe_pdata, 390 + }; 391 + 427 392 #ifdef CONFIG_PM_SLEEP 428 393 /** 429 394 * sdhci_arasan_suspend - Suspend method for the driver ··· 534 489 .compatible = "intel,lgm-sdhci-5.1-emmc", 535 490 .data = &intel_lgm_emmc_data, 536 491 }, 492 + { 493 + .compatible = "intel,lgm-sdhci-5.1-sdxc", 494 + .data = &intel_lgm_sdxc_data, 495 + }, 537 496 /* Generic compatible below here */ 538 497 { 539 498 .compatible = "arasan,sdhci-8.9a", ··· 549 500 }, 550 501 { 551 502 .compatible = "arasan,sdhci-4.9a", 503 + .data = &sdhci_arasan_data, 504 + }, 505 + { 506 + .compatible = "xlnx,zynqmp-8.9a", 552 507 .data = &sdhci_arasan_data, 553 508 }, 554 509 { /* sentinel */ } ··· 573 520 unsigned long parent_rate) 574 521 575 522 { 523 + struct sdhci_arasan_clk_data *clk_data = 524 + container_of(hw, struct sdhci_arasan_clk_data, sdcardclk_hw); 576 525 struct sdhci_arasan_data *sdhci_arasan = 577 - container_of(hw, struct sdhci_arasan_data, sdcardclk_hw); 526 + container_of(clk_data, struct sdhci_arasan_data, clk_data); 578 527 struct sdhci_host *host = sdhci_arasan->host; 579 528 580 529 return host->mmc->actual_clock; ··· 584 529 585 530 static const struct clk_ops arasan_sdcardclk_ops = { 586 531 .recalc_rate = sdhci_arasan_sdcardclk_recalc_rate, 532 + }; 533 + 534 + /** 535 + * sdhci_arasan_sampleclk_recalc_rate - Return the sampling clock rate 536 + * 537 + * Return the current actual rate of the sampling clock. This can be used 538 + * to communicate with out PHY. 539 + * 540 + * @hw: Pointer to the hardware clock structure. 541 + * @parent_rate The parent rate (should be rate of clk_xin). 542 + * Returns the sample clock rate. 543 + */ 544 + static unsigned long sdhci_arasan_sampleclk_recalc_rate(struct clk_hw *hw, 545 + unsigned long parent_rate) 546 + 547 + { 548 + struct sdhci_arasan_clk_data *clk_data = 549 + container_of(hw, struct sdhci_arasan_clk_data, sampleclk_hw); 550 + struct sdhci_arasan_data *sdhci_arasan = 551 + container_of(clk_data, struct sdhci_arasan_data, clk_data); 552 + struct sdhci_host *host = sdhci_arasan->host; 553 + 554 + return host->mmc->actual_clock; 555 + } 556 + 557 + static const struct clk_ops arasan_sampleclk_ops = { 558 + .recalc_rate = sdhci_arasan_sampleclk_recalc_rate, 559 + }; 560 + 561 + /** 562 + * sdhci_zynqmp_sdcardclk_set_phase - Set the SD Output Clock Tap Delays 563 + * 564 + * Set the SD Output Clock Tap Delays for Output path 565 + * 566 + * @hw: Pointer to the hardware clock structure. 567 + * @degrees The clock phase shift between 0 - 359. 568 + * Return: 0 on success and error value on error 569 + */ 570 + static int sdhci_zynqmp_sdcardclk_set_phase(struct clk_hw *hw, int degrees) 571 + 572 + { 573 + struct sdhci_arasan_clk_data *clk_data = 574 + container_of(hw, struct sdhci_arasan_clk_data, sdcardclk_hw); 575 + struct sdhci_arasan_data *sdhci_arasan = 576 + container_of(clk_data, struct sdhci_arasan_data, clk_data); 577 + struct sdhci_host *host = sdhci_arasan->host; 578 + struct sdhci_arasan_zynqmp_clk_data *zynqmp_clk_data = 579 + clk_data->clk_of_data; 580 + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_clk_data->eemi_ops; 581 + const char *clk_name = clk_hw_get_name(hw); 582 + u32 node_id = !strcmp(clk_name, "clk_out_sd0") ? NODE_SD_0 : NODE_SD_1; 583 + u8 tap_delay, tap_max = 0; 584 + int ret; 585 + 586 + /* 587 + * This is applicable for SDHCI_SPEC_300 and above 588 + * ZynqMP does not set phase for <=25MHz clock. 589 + * If degrees is zero, no need to do anything. 590 + */ 591 + if (host->version < SDHCI_SPEC_300 || 592 + host->timing == MMC_TIMING_LEGACY || 593 + host->timing == MMC_TIMING_UHS_SDR12 || !degrees) 594 + return 0; 595 + 596 + switch (host->timing) { 597 + case MMC_TIMING_MMC_HS: 598 + case MMC_TIMING_SD_HS: 599 + case MMC_TIMING_UHS_SDR25: 600 + case MMC_TIMING_UHS_DDR50: 601 + case MMC_TIMING_MMC_DDR52: 602 + /* For 50MHz clock, 30 Taps are available */ 603 + tap_max = 30; 604 + break; 605 + case MMC_TIMING_UHS_SDR50: 606 + /* For 100MHz clock, 15 Taps are available */ 607 + tap_max = 15; 608 + break; 609 + case MMC_TIMING_UHS_SDR104: 610 + case MMC_TIMING_MMC_HS200: 611 + /* For 200MHz clock, 8 Taps are available */ 612 + tap_max = 8; 613 + default: 614 + break; 615 + } 616 + 617 + tap_delay = (degrees * tap_max) / 360; 618 + 619 + /* Set the Clock Phase */ 620 + ret = eemi_ops->ioctl(node_id, IOCTL_SET_SD_TAPDELAY, 621 + PM_TAPDELAY_OUTPUT, tap_delay, NULL); 622 + if (ret) 623 + pr_err("Error setting Output Tap Delay\n"); 624 + 625 + return ret; 626 + } 627 + 628 + static const struct clk_ops zynqmp_sdcardclk_ops = { 629 + .recalc_rate = sdhci_arasan_sdcardclk_recalc_rate, 630 + .set_phase = sdhci_zynqmp_sdcardclk_set_phase, 631 + }; 632 + 633 + /** 634 + * sdhci_zynqmp_sampleclk_set_phase - Set the SD Input Clock Tap Delays 635 + * 636 + * Set the SD Input Clock Tap Delays for Input path 637 + * 638 + * @hw: Pointer to the hardware clock structure. 639 + * @degrees The clock phase shift between 0 - 359. 640 + * Return: 0 on success and error value on error 641 + */ 642 + static int sdhci_zynqmp_sampleclk_set_phase(struct clk_hw *hw, int degrees) 643 + 644 + { 645 + struct sdhci_arasan_clk_data *clk_data = 646 + container_of(hw, struct sdhci_arasan_clk_data, sampleclk_hw); 647 + struct sdhci_arasan_data *sdhci_arasan = 648 + container_of(clk_data, struct sdhci_arasan_data, clk_data); 649 + struct sdhci_host *host = sdhci_arasan->host; 650 + struct sdhci_arasan_zynqmp_clk_data *zynqmp_clk_data = 651 + clk_data->clk_of_data; 652 + const struct zynqmp_eemi_ops *eemi_ops = zynqmp_clk_data->eemi_ops; 653 + const char *clk_name = clk_hw_get_name(hw); 654 + u32 node_id = !strcmp(clk_name, "clk_in_sd0") ? NODE_SD_0 : NODE_SD_1; 655 + u8 tap_delay, tap_max = 0; 656 + int ret; 657 + 658 + /* 659 + * This is applicable for SDHCI_SPEC_300 and above 660 + * ZynqMP does not set phase for <=25MHz clock. 661 + * If degrees is zero, no need to do anything. 662 + */ 663 + if (host->version < SDHCI_SPEC_300 || 664 + host->timing == MMC_TIMING_LEGACY || 665 + host->timing == MMC_TIMING_UHS_SDR12 || !degrees) 666 + return 0; 667 + 668 + switch (host->timing) { 669 + case MMC_TIMING_MMC_HS: 670 + case MMC_TIMING_SD_HS: 671 + case MMC_TIMING_UHS_SDR25: 672 + case MMC_TIMING_UHS_DDR50: 673 + case MMC_TIMING_MMC_DDR52: 674 + /* For 50MHz clock, 120 Taps are available */ 675 + tap_max = 120; 676 + break; 677 + case MMC_TIMING_UHS_SDR50: 678 + /* For 100MHz clock, 60 Taps are available */ 679 + tap_max = 60; 680 + break; 681 + case MMC_TIMING_UHS_SDR104: 682 + case MMC_TIMING_MMC_HS200: 683 + /* For 200MHz clock, 30 Taps are available */ 684 + tap_max = 30; 685 + default: 686 + break; 687 + } 688 + 689 + tap_delay = (degrees * tap_max) / 360; 690 + 691 + /* Set the Clock Phase */ 692 + ret = eemi_ops->ioctl(node_id, IOCTL_SET_SD_TAPDELAY, 693 + PM_TAPDELAY_INPUT, tap_delay, NULL); 694 + if (ret) 695 + pr_err("Error setting Input Tap Delay\n"); 696 + 697 + return ret; 698 + } 699 + 700 + static const struct clk_ops zynqmp_sampleclk_ops = { 701 + .recalc_rate = sdhci_arasan_sampleclk_recalc_rate, 702 + .set_phase = sdhci_zynqmp_sampleclk_set_phase, 587 703 }; 588 704 589 705 /** ··· 835 609 sdhci_arasan_syscon_write(host, &soc_ctl_map->baseclkfreq, mhz); 836 610 } 837 611 612 + static void sdhci_arasan_set_clk_delays(struct sdhci_host *host) 613 + { 614 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 615 + struct sdhci_arasan_data *sdhci_arasan = sdhci_pltfm_priv(pltfm_host); 616 + struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data; 617 + 618 + clk_set_phase(clk_data->sampleclk, 619 + clk_data->clk_phase_in[host->timing]); 620 + clk_set_phase(clk_data->sdcardclk, 621 + clk_data->clk_phase_out[host->timing]); 622 + } 623 + 624 + static void arasan_dt_read_clk_phase(struct device *dev, 625 + struct sdhci_arasan_clk_data *clk_data, 626 + unsigned int timing, const char *prop) 627 + { 628 + struct device_node *np = dev->of_node; 629 + 630 + int clk_phase[2] = {0}; 631 + 632 + /* 633 + * Read Tap Delay values from DT, if the DT does not contain the 634 + * Tap Values then use the pre-defined values. 635 + */ 636 + if (of_property_read_variable_u32_array(np, prop, &clk_phase[0], 637 + 2, 0)) { 638 + dev_dbg(dev, "Using predefined clock phase for %s = %d %d\n", 639 + prop, clk_data->clk_phase_in[timing], 640 + clk_data->clk_phase_out[timing]); 641 + return; 642 + } 643 + 644 + /* The values read are Input and Output Clock Delays in order */ 645 + clk_data->clk_phase_in[timing] = clk_phase[0]; 646 + clk_data->clk_phase_out[timing] = clk_phase[1]; 647 + } 648 + 838 649 /** 839 - * sdhci_arasan_register_sdclk - Register the sdclk for a PHY to use 650 + * arasan_dt_parse_clk_phases - Read Clock Delay values from DT 651 + * 652 + * Called at initialization to parse the values of Clock Delays. 653 + * 654 + * @dev: Pointer to our struct device. 655 + * @clk_data: Pointer to the Clock Data structure 656 + */ 657 + static void arasan_dt_parse_clk_phases(struct device *dev, 658 + struct sdhci_arasan_clk_data *clk_data) 659 + { 660 + int *iclk_phase, *oclk_phase; 661 + u32 mio_bank = 0; 662 + int i; 663 + 664 + /* 665 + * This has been kept as a pointer and is assigned a function here. 666 + * So that different controller variants can assign their own handling 667 + * function. 668 + */ 669 + clk_data->set_clk_delays = sdhci_arasan_set_clk_delays; 670 + 671 + if (of_device_is_compatible(dev->of_node, "xlnx,zynqmp-8.9a")) { 672 + iclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) ZYNQMP_ICLK_PHASE; 673 + oclk_phase = (int [MMC_TIMING_MMC_HS400 + 1]) ZYNQMP_OCLK_PHASE; 674 + 675 + of_property_read_u32(dev->of_node, "xlnx,mio-bank", &mio_bank); 676 + if (mio_bank == 2) { 677 + oclk_phase[MMC_TIMING_UHS_SDR104] = 90; 678 + oclk_phase[MMC_TIMING_MMC_HS200] = 90; 679 + } 680 + 681 + for (i = 0; i <= MMC_TIMING_MMC_HS400; i++) { 682 + clk_data->clk_phase_in[i] = iclk_phase[i]; 683 + clk_data->clk_phase_out[i] = oclk_phase[i]; 684 + } 685 + } 686 + 687 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_LEGACY, 688 + "clk-phase-legacy"); 689 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_MMC_HS, 690 + "clk-phase-mmc-hs"); 691 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_SD_HS, 692 + "clk-phase-sd-hs"); 693 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_UHS_SDR12, 694 + "clk-phase-uhs-sdr12"); 695 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_UHS_SDR25, 696 + "clk-phase-uhs-sdr25"); 697 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_UHS_SDR50, 698 + "clk-phase-uhs-sdr50"); 699 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_UHS_SDR104, 700 + "clk-phase-uhs-sdr104"); 701 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_UHS_DDR50, 702 + "clk-phase-uhs-ddr50"); 703 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_MMC_DDR52, 704 + "clk-phase-mmc-ddr52"); 705 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_MMC_HS200, 706 + "clk-phase-mmc-hs200"); 707 + arasan_dt_read_clk_phase(dev, clk_data, MMC_TIMING_MMC_HS400, 708 + "clk-phase-mmc-hs400"); 709 + } 710 + 711 + /** 712 + * sdhci_arasan_register_sdcardclk - Register the sdcardclk for a PHY to use 713 + * 714 + * Some PHY devices need to know what the actual card clock is. In order for 715 + * them to find out, we'll provide a clock through the common clock framework 716 + * for them to query. 717 + * 718 + * @sdhci_arasan: Our private data structure. 719 + * @clk_xin: Pointer to the functional clock 720 + * @dev: Pointer to our struct device. 721 + * Returns 0 on success and error value on error 722 + */ 723 + static int 724 + sdhci_arasan_register_sdcardclk(struct sdhci_arasan_data *sdhci_arasan, 725 + struct clk *clk_xin, 726 + struct device *dev) 727 + { 728 + struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data; 729 + struct device_node *np = dev->of_node; 730 + struct clk_init_data sdcardclk_init; 731 + const char *parent_clk_name; 732 + int ret; 733 + 734 + ret = of_property_read_string_index(np, "clock-output-names", 0, 735 + &sdcardclk_init.name); 736 + if (ret) { 737 + dev_err(dev, "DT has #clock-cells but no clock-output-names\n"); 738 + return ret; 739 + } 740 + 741 + parent_clk_name = __clk_get_name(clk_xin); 742 + sdcardclk_init.parent_names = &parent_clk_name; 743 + sdcardclk_init.num_parents = 1; 744 + sdcardclk_init.flags = CLK_GET_RATE_NOCACHE; 745 + if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) 746 + sdcardclk_init.ops = &zynqmp_sdcardclk_ops; 747 + else 748 + sdcardclk_init.ops = &arasan_sdcardclk_ops; 749 + 750 + clk_data->sdcardclk_hw.init = &sdcardclk_init; 751 + clk_data->sdcardclk = 752 + devm_clk_register(dev, &clk_data->sdcardclk_hw); 753 + clk_data->sdcardclk_hw.init = NULL; 754 + 755 + ret = of_clk_add_provider(np, of_clk_src_simple_get, 756 + clk_data->sdcardclk); 757 + if (ret) 758 + dev_err(dev, "Failed to add sdcard clock provider\n"); 759 + 760 + return ret; 761 + } 762 + 763 + /** 764 + * sdhci_arasan_register_sampleclk - Register the sampleclk for a PHY to use 765 + * 766 + * Some PHY devices need to know what the actual card clock is. In order for 767 + * them to find out, we'll provide a clock through the common clock framework 768 + * for them to query. 769 + * 770 + * @sdhci_arasan: Our private data structure. 771 + * @clk_xin: Pointer to the functional clock 772 + * @dev: Pointer to our struct device. 773 + * Returns 0 on success and error value on error 774 + */ 775 + static int 776 + sdhci_arasan_register_sampleclk(struct sdhci_arasan_data *sdhci_arasan, 777 + struct clk *clk_xin, 778 + struct device *dev) 779 + { 780 + struct sdhci_arasan_clk_data *clk_data = &sdhci_arasan->clk_data; 781 + struct device_node *np = dev->of_node; 782 + struct clk_init_data sampleclk_init; 783 + const char *parent_clk_name; 784 + int ret; 785 + 786 + ret = of_property_read_string_index(np, "clock-output-names", 1, 787 + &sampleclk_init.name); 788 + if (ret) { 789 + dev_err(dev, "DT has #clock-cells but no clock-output-names\n"); 790 + return ret; 791 + } 792 + 793 + parent_clk_name = __clk_get_name(clk_xin); 794 + sampleclk_init.parent_names = &parent_clk_name; 795 + sampleclk_init.num_parents = 1; 796 + sampleclk_init.flags = CLK_GET_RATE_NOCACHE; 797 + if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) 798 + sampleclk_init.ops = &zynqmp_sampleclk_ops; 799 + else 800 + sampleclk_init.ops = &arasan_sampleclk_ops; 801 + 802 + clk_data->sampleclk_hw.init = &sampleclk_init; 803 + clk_data->sampleclk = 804 + devm_clk_register(dev, &clk_data->sampleclk_hw); 805 + clk_data->sampleclk_hw.init = NULL; 806 + 807 + ret = of_clk_add_provider(np, of_clk_src_simple_get, 808 + clk_data->sampleclk); 809 + if (ret) 810 + dev_err(dev, "Failed to add sample clock provider\n"); 811 + 812 + return ret; 813 + } 814 + 815 + /** 816 + * sdhci_arasan_unregister_sdclk - Undoes sdhci_arasan_register_sdclk() 817 + * 818 + * Should be called any time we're exiting and sdhci_arasan_register_sdclk() 819 + * returned success. 820 + * 821 + * @dev: Pointer to our struct device. 822 + */ 823 + static void sdhci_arasan_unregister_sdclk(struct device *dev) 824 + { 825 + struct device_node *np = dev->of_node; 826 + 827 + if (!of_find_property(np, "#clock-cells", NULL)) 828 + return; 829 + 830 + of_clk_del_provider(dev->of_node); 831 + } 832 + 833 + /** 834 + * sdhci_arasan_register_sdclk - Register the sdcardclk for a PHY to use 840 835 * 841 836 * Some PHY devices need to know what the actual card clock is. In order for 842 837 * them to find out, we'll provide a clock through the common clock framework ··· 1081 634 struct device *dev) 1082 635 { 1083 636 struct device_node *np = dev->of_node; 1084 - struct clk_init_data sdcardclk_init; 1085 - const char *parent_clk_name; 637 + u32 num_clks = 0; 1086 638 int ret; 1087 639 1088 640 /* Providing a clock to the PHY is optional; no error if missing */ 1089 - if (!of_find_property(np, "#clock-cells", NULL)) 641 + if (of_property_read_u32(np, "#clock-cells", &num_clks) < 0) 1090 642 return 0; 1091 643 1092 - ret = of_property_read_string_index(np, "clock-output-names", 0, 1093 - &sdcardclk_init.name); 1094 - if (ret) { 1095 - dev_err(dev, "DT has #clock-cells but no clock-output-names\n"); 644 + ret = sdhci_arasan_register_sdcardclk(sdhci_arasan, clk_xin, dev); 645 + if (ret) 1096 646 return ret; 647 + 648 + if (num_clks) { 649 + ret = sdhci_arasan_register_sampleclk(sdhci_arasan, clk_xin, 650 + dev); 651 + if (ret) { 652 + sdhci_arasan_unregister_sdclk(dev); 653 + return ret; 654 + } 1097 655 } 1098 656 1099 - parent_clk_name = __clk_get_name(clk_xin); 1100 - sdcardclk_init.parent_names = &parent_clk_name; 1101 - sdcardclk_init.num_parents = 1; 1102 - sdcardclk_init.flags = CLK_GET_RATE_NOCACHE; 1103 - sdcardclk_init.ops = &arasan_sdcardclk_ops; 1104 - 1105 - sdhci_arasan->sdcardclk_hw.init = &sdcardclk_init; 1106 - sdhci_arasan->sdcardclk = 1107 - devm_clk_register(dev, &sdhci_arasan->sdcardclk_hw); 1108 - sdhci_arasan->sdcardclk_hw.init = NULL; 1109 - 1110 - ret = of_clk_add_provider(np, of_clk_src_simple_get, 1111 - sdhci_arasan->sdcardclk); 1112 - if (ret) 1113 - dev_err(dev, "Failed to add clock provider\n"); 1114 - 1115 - return ret; 1116 - } 1117 - 1118 - /** 1119 - * sdhci_arasan_unregister_sdclk - Undoes sdhci_arasan_register_sdclk() 1120 - * 1121 - * Should be called any time we're exiting and sdhci_arasan_register_sdclk() 1122 - * returned success. 1123 - * 1124 - * @dev: Pointer to our struct device. 1125 - */ 1126 - static void sdhci_arasan_unregister_sdclk(struct device *dev) 1127 - { 1128 - struct device_node *np = dev->of_node; 1129 - 1130 - if (!of_find_property(np, "#clock-cells", NULL)) 1131 - return; 1132 - 1133 - of_clk_del_provider(dev->of_node); 657 + return 0; 1134 658 } 1135 659 1136 660 static int sdhci_arasan_add_host(struct sdhci_arasan_data *sdhci_arasan) ··· 1231 813 ret = sdhci_arasan_register_sdclk(sdhci_arasan, clk_xin, &pdev->dev); 1232 814 if (ret) 1233 815 goto clk_disable_all; 816 + 817 + if (of_device_is_compatible(np, "xlnx,zynqmp-8.9a")) { 818 + struct sdhci_arasan_zynqmp_clk_data *zynqmp_clk_data; 819 + const struct zynqmp_eemi_ops *eemi_ops; 820 + 821 + zynqmp_clk_data = devm_kzalloc(&pdev->dev, 822 + sizeof(*zynqmp_clk_data), 823 + GFP_KERNEL); 824 + eemi_ops = zynqmp_pm_get_eemi_ops(); 825 + if (IS_ERR(eemi_ops)) { 826 + ret = PTR_ERR(eemi_ops); 827 + goto unreg_clk; 828 + } 829 + 830 + zynqmp_clk_data->eemi_ops = eemi_ops; 831 + sdhci_arasan->clk_data.clk_of_data = zynqmp_clk_data; 832 + } 833 + 834 + arasan_dt_parse_clk_phases(&pdev->dev, &sdhci_arasan->clk_data); 1234 835 1235 836 ret = mmc_of_parse(host->mmc); 1236 837 if (ret) {
+12
drivers/mmc/host/sdhci-of-aspeed.c
··· 111 111 sdhci_writeb(host, ctrl, SDHCI_HOST_CONTROL); 112 112 } 113 113 114 + static u32 aspeed_sdhci_readl(struct sdhci_host *host, int reg) 115 + { 116 + u32 val = readl(host->ioaddr + reg); 117 + 118 + if (unlikely(reg == SDHCI_PRESENT_STATE) && 119 + (host->mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)) 120 + val ^= SDHCI_CARD_PRESENT; 121 + 122 + return val; 123 + } 124 + 114 125 static const struct sdhci_ops aspeed_sdhci_ops = { 126 + .read_l = aspeed_sdhci_readl, 115 127 .set_clock = aspeed_sdhci_set_clock, 116 128 .get_max_clock = aspeed_sdhci_get_max_clock, 117 129 .set_bus_width = aspeed_sdhci_set_bus_width,
+19
drivers/mmc/host/sdhci-of-at91.c
··· 27 27 #define SDMMC_CACR 0x230 28 28 #define SDMMC_CACR_CAPWREN BIT(0) 29 29 #define SDMMC_CACR_KEY (0x46 << 8) 30 + #define SDMMC_CALCR 0x240 31 + #define SDMMC_CALCR_EN BIT(0) 32 + #define SDMMC_CALCR_ALWYSON BIT(4) 30 33 31 34 #define SDHCI_AT91_PRESET_COMMON_CONF 0x400 /* drv type B, programmable clock mode */ 32 35 ··· 38 35 struct clk *gck; 39 36 struct clk *mainck; 40 37 bool restore_needed; 38 + bool cal_always_on; 41 39 }; 42 40 43 41 static void sdhci_at91_set_force_card_detect(struct sdhci_host *host) ··· 120 116 121 117 static void sdhci_at91_reset(struct sdhci_host *host, u8 mask) 122 118 { 119 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 120 + struct sdhci_at91_priv *priv = sdhci_pltfm_priv(pltfm_host); 121 + 123 122 sdhci_reset(host, mask); 124 123 125 124 if (host->mmc->caps & MMC_CAP_NONREMOVABLE) 126 125 sdhci_at91_set_force_card_detect(host); 126 + 127 + if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) 128 + sdhci_writel(host, SDMMC_CALCR_ALWYSON | SDMMC_CALCR_EN, 129 + SDMMC_CALCR); 127 130 } 128 131 129 132 static const struct sdhci_ops sdhci_at91_sama5d2_ops = { ··· 355 344 goto sdhci_pltfm_free; 356 345 357 346 priv->restore_needed = false; 347 + 348 + /* 349 + * if SDCAL pin is wrongly connected, we must enable 350 + * the analog calibration cell permanently. 351 + */ 352 + priv->cal_always_on = 353 + device_property_read_bool(&pdev->dev, 354 + "microchip,sdcal-inverted"); 358 355 359 356 ret = mmc_of_parse(host->mmc); 360 357 if (ret)
+217 -40
drivers/mmc/host/sdhci-of-esdhc.c
··· 77 77 bool quirk_incorrect_hostver; 78 78 bool quirk_limited_clk_division; 79 79 bool quirk_unreliable_pulse_detection; 80 - bool quirk_fixup_tuning; 80 + bool quirk_tuning_erratum_type1; 81 + bool quirk_tuning_erratum_type2; 81 82 bool quirk_ignore_data_inhibit; 83 + bool in_sw_tuning; 82 84 unsigned int peripheral_clock; 83 85 const struct esdhc_clk_fixup *clk_fixup; 84 86 u32 div_ratio; ··· 410 408 411 409 static void esdhc_be_writew(struct sdhci_host *host, u16 val, int reg) 412 410 { 411 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 412 + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 413 413 int base = reg & ~0x3; 414 414 u32 value; 415 415 u32 ret; ··· 420 416 ret = esdhc_writew_fixup(host, reg, val, value); 421 417 if (reg != SDHCI_TRANSFER_MODE) 422 418 iowrite32be(ret, host->ioaddr + base); 419 + 420 + /* Starting SW tuning requires ESDHC_SMPCLKSEL to be set 421 + * 1us later after ESDHC_EXTN is set. 422 + */ 423 + if (base == ESDHC_SYSTEM_CONTROL_2) { 424 + if (!(value & ESDHC_EXTN) && (ret & ESDHC_EXTN) && 425 + esdhc->in_sw_tuning) { 426 + udelay(1); 427 + ret |= ESDHC_SMPCLKSEL; 428 + iowrite32be(ret, host->ioaddr + base); 429 + } 430 + } 423 431 } 424 432 425 433 static void esdhc_le_writew(struct sdhci_host *host, u16 val, int reg) 426 434 { 435 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 436 + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 427 437 int base = reg & ~0x3; 428 438 u32 value; 429 439 u32 ret; ··· 446 428 ret = esdhc_writew_fixup(host, reg, val, value); 447 429 if (reg != SDHCI_TRANSFER_MODE) 448 430 iowrite32(ret, host->ioaddr + base); 431 + 432 + /* Starting SW tuning requires ESDHC_SMPCLKSEL to be set 433 + * 1us later after ESDHC_EXTN is set. 434 + */ 435 + if (base == ESDHC_SYSTEM_CONTROL_2) { 436 + if (!(value & ESDHC_EXTN) && (ret & ESDHC_EXTN) && 437 + esdhc->in_sw_tuning) { 438 + udelay(1); 439 + ret |= ESDHC_SMPCLKSEL; 440 + iowrite32(ret, host->ioaddr + base); 441 + } 442 + } 449 443 } 450 444 451 445 static void esdhc_be_writeb(struct sdhci_host *host, u8 val, int reg) ··· 590 560 } 591 561 } 592 562 563 + static void esdhc_flush_async_fifo(struct sdhci_host *host) 564 + { 565 + ktime_t timeout; 566 + u32 val; 567 + 568 + val = sdhci_readl(host, ESDHC_DMA_SYSCTL); 569 + val |= ESDHC_FLUSH_ASYNC_FIFO; 570 + sdhci_writel(host, val, ESDHC_DMA_SYSCTL); 571 + 572 + /* Wait max 20 ms */ 573 + timeout = ktime_add_ms(ktime_get(), 20); 574 + while (1) { 575 + bool timedout = ktime_after(ktime_get(), timeout); 576 + 577 + if (!(sdhci_readl(host, ESDHC_DMA_SYSCTL) & 578 + ESDHC_FLUSH_ASYNC_FIFO)) 579 + break; 580 + if (timedout) { 581 + pr_err("%s: flushing asynchronous FIFO timeout.\n", 582 + mmc_hostname(host->mmc)); 583 + break; 584 + } 585 + usleep_range(10, 20); 586 + } 587 + } 588 + 593 589 static void esdhc_of_set_clock(struct sdhci_host *host, unsigned int clock) 594 590 { 595 591 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 708 652 sdhci_writel(host, temp | ESDHC_HS400_WNDW_ADJUST, ESDHC_TBCTL); 709 653 710 654 esdhc_clock_enable(host, false); 711 - temp = sdhci_readl(host, ESDHC_DMA_SYSCTL); 712 - temp |= ESDHC_FLUSH_ASYNC_FIFO; 713 - sdhci_writel(host, temp, ESDHC_DMA_SYSCTL); 655 + esdhc_flush_async_fifo(host); 714 656 } 715 657 716 658 /* Wait max 20 ms */ ··· 850 796 } 851 797 } 852 798 853 - static struct soc_device_attribute soc_fixup_tuning[] = { 799 + static struct soc_device_attribute soc_tuning_erratum_type1[] = { 800 + { .family = "QorIQ T1023", .revision = "1.0", }, 854 801 { .family = "QorIQ T1040", .revision = "1.0", }, 855 802 { .family = "QorIQ T2080", .revision = "1.0", }, 856 - { .family = "QorIQ T1023", .revision = "1.0", }, 857 803 { .family = "QorIQ LS1021A", .revision = "1.0", }, 858 - { .family = "QorIQ LS1080A", .revision = "1.0", }, 859 - { .family = "QorIQ LS2080A", .revision = "1.0", }, 804 + { }, 805 + }; 806 + 807 + static struct soc_device_attribute soc_tuning_erratum_type2[] = { 860 808 { .family = "QorIQ LS1012A", .revision = "1.0", }, 861 809 { .family = "QorIQ LS1043A", .revision = "1.*", }, 862 810 { .family = "QorIQ LS1046A", .revision = "1.0", }, 811 + { .family = "QorIQ LS1080A", .revision = "1.0", }, 812 + { .family = "QorIQ LS2080A", .revision = "1.0", }, 813 + { .family = "QorIQ LA1575A", .revision = "1.0", }, 863 814 { }, 864 815 }; 865 816 ··· 873 814 u32 val; 874 815 875 816 esdhc_clock_enable(host, false); 876 - 877 - val = sdhci_readl(host, ESDHC_DMA_SYSCTL); 878 - val |= ESDHC_FLUSH_ASYNC_FIFO; 879 - sdhci_writel(host, val, ESDHC_DMA_SYSCTL); 817 + esdhc_flush_async_fifo(host); 880 818 881 819 val = sdhci_readl(host, ESDHC_TBCTL); 882 820 if (enable) ··· 885 829 esdhc_clock_enable(host, true); 886 830 } 887 831 832 + static void esdhc_prepare_sw_tuning(struct sdhci_host *host, u8 *window_start, 833 + u8 *window_end) 834 + { 835 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 836 + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 837 + u8 tbstat_15_8, tbstat_7_0; 838 + u32 val; 839 + 840 + if (esdhc->quirk_tuning_erratum_type1) { 841 + *window_start = 5 * esdhc->div_ratio; 842 + *window_end = 3 * esdhc->div_ratio; 843 + return; 844 + } 845 + 846 + /* Write TBCTL[11:8]=4'h8 */ 847 + val = sdhci_readl(host, ESDHC_TBCTL); 848 + val &= ~(0xf << 8); 849 + val |= 8 << 8; 850 + sdhci_writel(host, val, ESDHC_TBCTL); 851 + 852 + mdelay(1); 853 + 854 + /* Read TBCTL[31:0] register and rewrite again */ 855 + val = sdhci_readl(host, ESDHC_TBCTL); 856 + sdhci_writel(host, val, ESDHC_TBCTL); 857 + 858 + mdelay(1); 859 + 860 + /* Read the TBSTAT[31:0] register twice */ 861 + val = sdhci_readl(host, ESDHC_TBSTAT); 862 + val = sdhci_readl(host, ESDHC_TBSTAT); 863 + 864 + /* Reset data lines by setting ESDHCCTL[RSTD] */ 865 + sdhci_reset(host, SDHCI_RESET_DATA); 866 + /* Write 32'hFFFF_FFFF to IRQSTAT register */ 867 + sdhci_writel(host, 0xFFFFFFFF, SDHCI_INT_STATUS); 868 + 869 + /* If TBSTAT[15:8]-TBSTAT[7:0] > 4 * div_ratio 870 + * or TBSTAT[7:0]-TBSTAT[15:8] > 4 * div_ratio, 871 + * then program TBPTR[TB_WNDW_END_PTR] = 4 * div_ratio 872 + * and program TBPTR[TB_WNDW_START_PTR] = 8 * div_ratio. 873 + */ 874 + tbstat_7_0 = val & 0xff; 875 + tbstat_15_8 = (val >> 8) & 0xff; 876 + 877 + if (abs(tbstat_15_8 - tbstat_7_0) > (4 * esdhc->div_ratio)) { 878 + *window_start = 8 * esdhc->div_ratio; 879 + *window_end = 4 * esdhc->div_ratio; 880 + } else { 881 + *window_start = 5 * esdhc->div_ratio; 882 + *window_end = 3 * esdhc->div_ratio; 883 + } 884 + } 885 + 886 + static int esdhc_execute_sw_tuning(struct mmc_host *mmc, u32 opcode, 887 + u8 window_start, u8 window_end) 888 + { 889 + struct sdhci_host *host = mmc_priv(mmc); 890 + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 891 + struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 892 + u32 val; 893 + int ret; 894 + 895 + /* Program TBPTR[TB_WNDW_END_PTR] and TBPTR[TB_WNDW_START_PTR] */ 896 + val = ((u32)window_start << ESDHC_WNDW_STRT_PTR_SHIFT) & 897 + ESDHC_WNDW_STRT_PTR_MASK; 898 + val |= window_end & ESDHC_WNDW_END_PTR_MASK; 899 + sdhci_writel(host, val, ESDHC_TBPTR); 900 + 901 + /* Program the software tuning mode by setting TBCTL[TB_MODE]=2'h3 */ 902 + val = sdhci_readl(host, ESDHC_TBCTL); 903 + val &= ~ESDHC_TB_MODE_MASK; 904 + val |= ESDHC_TB_MODE_SW; 905 + sdhci_writel(host, val, ESDHC_TBCTL); 906 + 907 + esdhc->in_sw_tuning = true; 908 + ret = sdhci_execute_tuning(mmc, opcode); 909 + esdhc->in_sw_tuning = false; 910 + return ret; 911 + } 912 + 888 913 static int esdhc_execute_tuning(struct mmc_host *mmc, u32 opcode) 889 914 { 890 915 struct sdhci_host *host = mmc_priv(mmc); 891 916 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 892 917 struct sdhci_esdhc *esdhc = sdhci_pltfm_priv(pltfm_host); 918 + u8 window_start, window_end; 919 + int ret, retries = 1; 893 920 bool hs400_tuning; 894 921 unsigned int clk; 895 922 u32 val; 896 - int ret; 897 923 898 924 /* For tuning mode, the sd clock divisor value 899 925 * must be larger than 3 according to reference manual. ··· 984 846 if (host->clock > clk) 985 847 esdhc_of_set_clock(host, clk); 986 848 987 - if (esdhc->quirk_limited_clk_division && 988 - host->flags & SDHCI_HS400_TUNING) 989 - esdhc_of_set_clock(host, host->clock); 990 - 991 849 esdhc_tuning_block_enable(host, true); 992 850 993 851 hs400_tuning = host->flags & SDHCI_HS400_TUNING; 994 - ret = sdhci_execute_tuning(mmc, opcode); 995 852 996 - if (hs400_tuning) { 853 + do { 854 + if (esdhc->quirk_limited_clk_division && 855 + hs400_tuning) 856 + esdhc_of_set_clock(host, host->clock); 857 + 858 + /* Do HW tuning */ 859 + val = sdhci_readl(host, ESDHC_TBCTL); 860 + val &= ~ESDHC_TB_MODE_MASK; 861 + val |= ESDHC_TB_MODE_3; 862 + sdhci_writel(host, val, ESDHC_TBCTL); 863 + 864 + ret = sdhci_execute_tuning(mmc, opcode); 865 + if (ret) 866 + break; 867 + 868 + /* If HW tuning fails and triggers erratum, 869 + * try workaround. 870 + */ 871 + ret = host->tuning_err; 872 + if (ret == -EAGAIN && 873 + (esdhc->quirk_tuning_erratum_type1 || 874 + esdhc->quirk_tuning_erratum_type2)) { 875 + /* Recover HS400 tuning flag */ 876 + if (hs400_tuning) 877 + host->flags |= SDHCI_HS400_TUNING; 878 + pr_info("%s: Hold on to use fixed sampling clock. Try SW tuning!\n", 879 + mmc_hostname(mmc)); 880 + /* Do SW tuning */ 881 + esdhc_prepare_sw_tuning(host, &window_start, 882 + &window_end); 883 + ret = esdhc_execute_sw_tuning(mmc, opcode, 884 + window_start, 885 + window_end); 886 + if (ret) 887 + break; 888 + 889 + /* Retry both HW/SW tuning with reduced clock. */ 890 + ret = host->tuning_err; 891 + if (ret == -EAGAIN && retries) { 892 + /* Recover HS400 tuning flag */ 893 + if (hs400_tuning) 894 + host->flags |= SDHCI_HS400_TUNING; 895 + 896 + clk = host->max_clk / (esdhc->div_ratio + 1); 897 + esdhc_of_set_clock(host, clk); 898 + pr_info("%s: Hold on to use fixed sampling clock. Try tuning with reduced clock!\n", 899 + mmc_hostname(mmc)); 900 + } else { 901 + break; 902 + } 903 + } else { 904 + break; 905 + } 906 + } while (retries--); 907 + 908 + if (ret) { 909 + esdhc_tuning_block_enable(host, false); 910 + } else if (hs400_tuning) { 997 911 val = sdhci_readl(host, ESDHC_SDTIMNGCTL); 998 912 val |= ESDHC_FLW_CTL_BG; 999 913 sdhci_writel(host, val, ESDHC_SDTIMNGCTL); 1000 914 } 1001 915 1002 - if (host->tuning_err == -EAGAIN && esdhc->quirk_fixup_tuning) { 1003 - 1004 - /* program TBPTR[TB_WNDW_END_PTR] = 3*DIV_RATIO and 1005 - * program TBPTR[TB_WNDW_START_PTR] = 5*DIV_RATIO 1006 - */ 1007 - val = sdhci_readl(host, ESDHC_TBPTR); 1008 - val = (val & ~((0x7f << 8) | 0x7f)) | 1009 - (3 * esdhc->div_ratio) | ((5 * esdhc->div_ratio) << 8); 1010 - sdhci_writel(host, val, ESDHC_TBPTR); 1011 - 1012 - /* program the software tuning mode by setting 1013 - * TBCTL[TB_MODE]=2'h3 1014 - */ 1015 - val = sdhci_readl(host, ESDHC_TBCTL); 1016 - val |= 0x3; 1017 - sdhci_writel(host, val, ESDHC_TBCTL); 1018 - sdhci_execute_tuning(mmc, opcode); 1019 - } 1020 916 return ret; 1021 917 } 1022 918 ··· 1286 1114 1287 1115 pltfm_host = sdhci_priv(host); 1288 1116 esdhc = sdhci_pltfm_priv(pltfm_host); 1289 - if (soc_device_match(soc_fixup_tuning)) 1290 - esdhc->quirk_fixup_tuning = true; 1117 + if (soc_device_match(soc_tuning_erratum_type1)) 1118 + esdhc->quirk_tuning_erratum_type1 = true; 1291 1119 else 1292 - esdhc->quirk_fixup_tuning = false; 1120 + esdhc->quirk_tuning_erratum_type1 = false; 1121 + 1122 + if (soc_device_match(soc_tuning_erratum_type2)) 1123 + esdhc->quirk_tuning_erratum_type2 = true; 1124 + else 1125 + esdhc->quirk_tuning_erratum_type2 = false; 1293 1126 1294 1127 if (esdhc->vendor_ver == VENDOR_V_22) 1295 1128 host->quirks2 |= SDHCI_QUIRK2_HOST_NO_CMD23;
+52 -1
drivers/mmc/host/sdhci-pci-core.c
··· 21 21 #include <linux/mmc/mmc.h> 22 22 #include <linux/scatterlist.h> 23 23 #include <linux/io.h> 24 + #include <linux/iopoll.h> 24 25 #include <linux/gpio.h> 25 26 #include <linux/pm_runtime.h> 26 27 #include <linux/mmc/slot-gpio.h> ··· 1591 1590 return 0; 1592 1591 } 1593 1592 1593 + static u32 sdhci_read_present_state(struct sdhci_host *host) 1594 + { 1595 + return sdhci_readl(host, SDHCI_PRESENT_STATE); 1596 + } 1597 + 1598 + static void amd_sdhci_reset(struct sdhci_host *host, u8 mask) 1599 + { 1600 + struct sdhci_pci_slot *slot = sdhci_priv(host); 1601 + struct pci_dev *pdev = slot->chip->pdev; 1602 + u32 present_state; 1603 + 1604 + /* 1605 + * SDHC 0x7906 requires a hard reset to clear all internal state. 1606 + * Otherwise it can get into a bad state where the DATA lines are always 1607 + * read as zeros. 1608 + */ 1609 + if (pdev->device == 0x7906 && (mask & SDHCI_RESET_ALL)) { 1610 + pci_clear_master(pdev); 1611 + 1612 + pci_save_state(pdev); 1613 + 1614 + pci_set_power_state(pdev, PCI_D3cold); 1615 + pr_debug("%s: power_state=%u\n", mmc_hostname(host->mmc), 1616 + pdev->current_state); 1617 + pci_set_power_state(pdev, PCI_D0); 1618 + 1619 + pci_restore_state(pdev); 1620 + 1621 + /* 1622 + * SDHCI_RESET_ALL says the card detect logic should not be 1623 + * reset, but since we need to reset the entire controller 1624 + * we should wait until the card detect logic has stabilized. 1625 + * 1626 + * This normally takes about 40ms. 1627 + */ 1628 + readx_poll_timeout( 1629 + sdhci_read_present_state, 1630 + host, 1631 + present_state, 1632 + present_state & SDHCI_CD_STABLE, 1633 + 10000, 1634 + 100000 1635 + ); 1636 + } 1637 + 1638 + return sdhci_reset(host, mask); 1639 + } 1640 + 1594 1641 static const struct sdhci_ops amd_sdhci_pci_ops = { 1595 1642 .set_clock = sdhci_set_clock, 1596 1643 .enable_dma = sdhci_pci_enable_dma, 1597 1644 .set_bus_width = sdhci_set_bus_width, 1598 - .reset = sdhci_reset, 1645 + .reset = amd_sdhci_reset, 1599 1646 .set_uhs_signaling = sdhci_set_uhs_signaling, 1600 1647 }; 1601 1648 ··· 1722 1673 SDHCI_PCI_DEVICE(INTEL, CML_EMMC, intel_glk_emmc), 1723 1674 SDHCI_PCI_DEVICE(INTEL, CML_SD, intel_byt_sd), 1724 1675 SDHCI_PCI_DEVICE(INTEL, CMLH_SD, intel_byt_sd), 1676 + SDHCI_PCI_DEVICE(INTEL, JSL_EMMC, intel_glk_emmc), 1677 + SDHCI_PCI_DEVICE(INTEL, JSL_SD, intel_byt_sd), 1725 1678 SDHCI_PCI_DEVICE(O2, 8120, o2), 1726 1679 SDHCI_PCI_DEVICE(O2, 8220, o2), 1727 1680 SDHCI_PCI_DEVICE(O2, 8221, o2),
+2
drivers/mmc/host/sdhci-pci.h
··· 55 55 #define PCI_DEVICE_ID_INTEL_CML_EMMC 0x02c4 56 56 #define PCI_DEVICE_ID_INTEL_CML_SD 0x02f5 57 57 #define PCI_DEVICE_ID_INTEL_CMLH_SD 0x06f5 58 + #define PCI_DEVICE_ID_INTEL_JSL_EMMC 0x4dc4 59 + #define PCI_DEVICE_ID_INTEL_JSL_SD 0x4df8 58 60 59 61 #define PCI_DEVICE_ID_SYSKONNECT_8000 0x8000 60 62 #define PCI_DEVICE_ID_VIA_95D0 0x95d0
+13 -2
drivers/mmc/host/sdhci.c
··· 337 337 338 338 static void sdhci_reinit(struct sdhci_host *host) 339 339 { 340 + u32 cd = host->ier & (SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT); 341 + 340 342 sdhci_init(host, 0); 341 343 sdhci_enable_card_detection(host); 344 + 345 + /* 346 + * A change to the card detect bits indicates a change in present state, 347 + * refer sdhci_set_card_detection(). A card detect interrupt might have 348 + * been missed while the host controller was being reset, so trigger a 349 + * rescan to check. 350 + */ 351 + if (cd != (host->ier & (SDHCI_INT_CARD_REMOVE | SDHCI_INT_CARD_INSERT))) 352 + mmc_detect_change(host->mmc, msecs_to_jiffies(200)); 342 353 } 343 354 344 355 static void __sdhci_led_activate(struct sdhci_host *host) ··· 2213 2202 if (!(ctrl & SDHCI_CTRL_VDD_180)) 2214 2203 return 0; 2215 2204 2216 - pr_warn("%s: 3.3V regulator output did not became stable\n", 2205 + pr_warn("%s: 3.3V regulator output did not become stable\n", 2217 2206 mmc_hostname(mmc)); 2218 2207 2219 2208 return -EAGAIN; ··· 2245 2234 if (ctrl & SDHCI_CTRL_VDD_180) 2246 2235 return 0; 2247 2236 2248 - pr_warn("%s: 1.8V regulator output did not became stable\n", 2237 + pr_warn("%s: 1.8V regulator output did not become stable\n", 2249 2238 mmc_hostname(mmc)); 2250 2239 2251 2240 return -EAGAIN;
+70 -1
drivers/mmc/host/sdhci_am654.c
··· 12 12 #include <linux/property.h> 13 13 #include <linux/regmap.h> 14 14 15 + #include "cqhci.h" 15 16 #include "sdhci-pltfm.h" 16 17 17 18 /* CTL_CFG Registers */ ··· 68 67 #define DRIVER_STRENGTH_40_OHM 0x4 69 68 70 69 #define CLOCK_TOO_SLOW_HZ 400000 70 + 71 + /* Command Queue Host Controller Interface Base address */ 72 + #define SDHCI_AM654_CQE_BASE_ADDR 0x200 71 73 72 74 static struct regmap_config sdhci_am654_regmap_config = { 73 75 .reg_bits = 32, ··· 263 259 .flags = IOMUX_PRESENT | FREQSEL_2_BIT | STRBSEL_4_BIT | DLL_PRESENT, 264 260 }; 265 261 262 + static u32 sdhci_am654_cqhci_irq(struct sdhci_host *host, u32 intmask) 263 + { 264 + int cmd_error = 0; 265 + int data_error = 0; 266 + 267 + if (!sdhci_cqe_irq(host, intmask, &cmd_error, &data_error)) 268 + return intmask; 269 + 270 + cqhci_irq(host->mmc, intmask, cmd_error, data_error); 271 + 272 + return 0; 273 + } 274 + 266 275 static struct sdhci_ops sdhci_j721e_8bit_ops = { 267 276 .get_max_clock = sdhci_pltfm_clk_get_max_clock, 268 277 .get_timeout_clock = sdhci_pltfm_clk_get_max_clock, ··· 284 267 .set_power = sdhci_am654_set_power, 285 268 .set_clock = sdhci_am654_set_clock, 286 269 .write_b = sdhci_am654_write_b, 270 + .irq = sdhci_am654_cqhci_irq, 287 271 .reset = sdhci_reset, 288 272 }; 289 273 ··· 308 290 .set_power = sdhci_am654_set_power, 309 291 .set_clock = sdhci_j721e_4bit_set_clock, 310 292 .write_b = sdhci_am654_write_b, 293 + .irq = sdhci_am654_cqhci_irq, 311 294 .reset = sdhci_reset, 312 295 }; 313 296 ··· 323 304 .pdata = &sdhci_j721e_4bit_pdata, 324 305 .flags = IOMUX_PRESENT, 325 306 }; 307 + 308 + static void sdhci_am654_dumpregs(struct mmc_host *mmc) 309 + { 310 + sdhci_dumpregs(mmc_priv(mmc)); 311 + } 312 + 313 + static const struct cqhci_host_ops sdhci_am654_cqhci_ops = { 314 + .enable = sdhci_cqe_enable, 315 + .disable = sdhci_cqe_disable, 316 + .dumpregs = sdhci_am654_dumpregs, 317 + }; 318 + 319 + static int sdhci_am654_cqe_add_host(struct sdhci_host *host) 320 + { 321 + struct cqhci_host *cq_host; 322 + int ret; 323 + 324 + cq_host = devm_kzalloc(host->mmc->parent, sizeof(struct cqhci_host), 325 + GFP_KERNEL); 326 + if (!cq_host) 327 + return -ENOMEM; 328 + 329 + cq_host->mmio = host->ioaddr + SDHCI_AM654_CQE_BASE_ADDR; 330 + cq_host->quirks |= CQHCI_QUIRK_SHORT_TXFR_DESC_SZ; 331 + cq_host->caps |= CQHCI_TASK_DESC_SZ_128; 332 + cq_host->ops = &sdhci_am654_cqhci_ops; 333 + 334 + host->mmc->caps2 |= MMC_CAP2_CQE; 335 + 336 + ret = cqhci_init(cq_host, host->mmc, 1); 337 + 338 + return ret; 339 + } 340 + 326 341 static int sdhci_am654_init(struct sdhci_host *host) 327 342 { 328 343 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); ··· 397 344 regmap_update_bits(sdhci_am654->base, CTL_CFG_2, SLOTTYPE_MASK, 398 345 ctl_cfg_2); 399 346 400 - return sdhci_add_host(host); 347 + ret = sdhci_setup_host(host); 348 + if (ret) 349 + return ret; 350 + 351 + ret = sdhci_am654_cqe_add_host(host); 352 + if (ret) 353 + goto err_cleanup_host; 354 + 355 + ret = __sdhci_add_host(host); 356 + if (ret) 357 + goto err_cleanup_host; 358 + 359 + return 0; 360 + 361 + err_cleanup_host: 362 + sdhci_cleanup_host(host); 363 + return ret; 401 364 } 402 365 403 366 static int sdhci_am654_get_of_property(struct platform_device *pdev,
+1 -25
drivers/mmc/host/sdhci_f_sdh30.c
··· 16 16 #include <linux/clk.h> 17 17 18 18 #include "sdhci-pltfm.h" 19 - 20 - /* F_SDH30 extended Controller registers */ 21 - #define F_SDH30_AHB_CONFIG 0x100 22 - #define F_SDH30_AHB_BIGED 0x00000040 23 - #define F_SDH30_BUSLOCK_DMA 0x00000020 24 - #define F_SDH30_BUSLOCK_EN 0x00000010 25 - #define F_SDH30_SIN 0x00000008 26 - #define F_SDH30_AHB_INCR_16 0x00000004 27 - #define F_SDH30_AHB_INCR_8 0x00000002 28 - #define F_SDH30_AHB_INCR_4 0x00000001 29 - 30 - #define F_SDH30_TUNING_SETTING 0x108 31 - #define F_SDH30_CMD_CHK_DIS 0x00010000 32 - 33 - #define F_SDH30_IO_CONTROL2 0x114 34 - #define F_SDH30_CRES_O_DN 0x00080000 35 - #define F_SDH30_MSEL_O_1_8 0x00040000 36 - 37 - #define F_SDH30_ESD_CONTROL 0x124 38 - #define F_SDH30_EMMC_RST 0x00000002 39 - #define F_SDH30_EMMC_HS200 0x01000000 40 - 41 - #define F_SDH30_CMD_DAT_DELAY 0x200 42 - 43 - #define F_SDH30_MIN_CLOCK 400000 19 + #include "sdhci_f_sdh30.h" 44 20 45 21 struct f_sdhost_priv { 46 22 struct clk *clk_iface;
+32
drivers/mmc/host/sdhci_f_sdh30.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Copyright (C) 2013 - 2015 Fujitsu Semiconductor, Ltd 4 + * Vincent Yang <vincent.yang@tw.fujitsu.com> 5 + * Copyright (C) 2015 Linaro Ltd Andy Green <andy.green@linaro.org> 6 + * Copyright (C) 2019 Socionext Inc. 7 + * 8 + */ 9 + 10 + /* F_SDH30 extended Controller registers */ 11 + #define F_SDH30_AHB_CONFIG 0x100 12 + #define F_SDH30_AHB_BIGED BIT(6) 13 + #define F_SDH30_BUSLOCK_DMA BIT(5) 14 + #define F_SDH30_BUSLOCK_EN BIT(4) 15 + #define F_SDH30_SIN BIT(3) 16 + #define F_SDH30_AHB_INCR_16 BIT(2) 17 + #define F_SDH30_AHB_INCR_8 BIT(1) 18 + #define F_SDH30_AHB_INCR_4 BIT(0) 19 + 20 + #define F_SDH30_TUNING_SETTING 0x108 21 + #define F_SDH30_CMD_CHK_DIS BIT(16) 22 + 23 + #define F_SDH30_IO_CONTROL2 0x114 24 + #define F_SDH30_CRES_O_DN BIT(19) 25 + #define F_SDH30_MSEL_O_1_8 BIT(18) 26 + 27 + #define F_SDH30_ESD_CONTROL 0x124 28 + #define F_SDH30_EMMC_RST BIT(1) 29 + #define F_SDH30_CMD_DAT_DELAY BIT(9) 30 + #define F_SDH30_EMMC_HS200 BIT(24) 31 + 32 + #define F_SDH30_MIN_CLOCK 400000
+1 -1
drivers/mmc/host/tmio_mmc_core.c
··· 1185 1185 if (ret == -EPROBE_DEFER) 1186 1186 return ret; 1187 1187 1188 - mmc->caps |= MMC_CAP_4_BIT_DATA | pdata->capabilities; 1188 + mmc->caps |= MMC_CAP_ERASE | MMC_CAP_4_BIT_DATA | pdata->capabilities; 1189 1189 mmc->caps2 |= pdata->capabilities2; 1190 1190 mmc->max_segs = pdata->max_segs ? : 32; 1191 1191 mmc->max_blk_size = TMIO_MAX_BLK_SIZE;
-7
drivers/mmc/host/vub300.c
··· 2070 2070 kref_put(&vub300->kref, vub300_delete); 2071 2071 } 2072 2072 2073 - static void vub300_init_card(struct mmc_host *mmc, struct mmc_card *card) 2074 - { /* NOT irq */ 2075 - struct vub300_mmc_host *vub300 = mmc_priv(mmc); 2076 - dev_info(&vub300->udev->dev, "NO host QUIRKS for this card\n"); 2077 - } 2078 - 2079 2073 static const struct mmc_host_ops vub300_mmc_ops = { 2080 2074 .request = vub300_mmc_request, 2081 2075 .set_ios = vub300_mmc_set_ios, 2082 2076 .get_ro = vub300_mmc_get_ro, 2083 2077 .enable_sdio_irq = vub300_enable_sdio_irq, 2084 - .init_card = vub300_init_card, 2085 2078 }; 2086 2079 2087 2080 static int vub300_probe(struct usb_interface *interface,
+4 -1
drivers/net/wireless/marvell/mwifiex/main.c
··· 631 631 632 632 mwifiex_drv_get_driver_version(adapter, fmt, sizeof(fmt) - 1); 633 633 mwifiex_dbg(adapter, MSG, "driver_version = %s\n", fmt); 634 + adapter->is_up = true; 634 635 goto done; 635 636 636 637 err_add_intf: ··· 1470 1469 mwifiex_deauthenticate(priv, NULL); 1471 1470 1472 1471 mwifiex_uninit_sw(adapter); 1472 + adapter->is_up = false; 1473 1473 1474 1474 if (adapter->if_ops.down_dev) 1475 1475 adapter->if_ops.down_dev(adapter); ··· 1732 1730 if (!adapter) 1733 1731 return 0; 1734 1732 1735 - mwifiex_uninit_sw(adapter); 1733 + if (adapter->is_up) 1734 + mwifiex_uninit_sw(adapter); 1736 1735 1737 1736 if (adapter->irq_wakeup >= 0) 1738 1737 device_init_wakeup(adapter->dev, false);
+1
drivers/net/wireless/marvell/mwifiex/main.h
··· 1017 1017 1018 1018 /* For synchronizing FW initialization with device lifecycle. */ 1019 1019 struct completion *fw_done; 1020 + bool is_up; 1020 1021 1021 1022 bool ext_scan; 1022 1023 u8 fw_api_ver;
+23 -12
drivers/net/wireless/marvell/mwifiex/sdio.c
··· 444 444 return 0; 445 445 } 446 446 447 + if (!adapter->is_up) 448 + return -EBUSY; 449 + 447 450 mwifiex_enable_wake(adapter); 448 451 449 452 /* Enable the Host Sleep */ ··· 2223 2220 struct sdio_func *func = card->func; 2224 2221 int ret; 2225 2222 2223 + /* Prepare the adapter for the reset. */ 2226 2224 mwifiex_shutdown_sw(adapter); 2227 - 2228 - /* power cycle the adapter */ 2229 - sdio_claim_host(func); 2230 - mmc_hw_reset(func->card->host); 2231 - sdio_release_host(func); 2232 - 2233 - /* Previous save_adapter won't be valid after this. We will cancel 2234 - * pending work requests. 2235 - */ 2236 2225 clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); 2237 2226 clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); 2238 2227 2239 - ret = mwifiex_reinit_sw(adapter); 2240 - if (ret) 2241 - dev_err(&func->dev, "reinit failed: %d\n", ret); 2228 + /* Run a HW reset of the SDIO interface. */ 2229 + sdio_claim_host(func); 2230 + ret = mmc_hw_reset(func->card->host); 2231 + sdio_release_host(func); 2232 + 2233 + switch (ret) { 2234 + case 1: 2235 + dev_dbg(&func->dev, "SDIO HW reset asynchronous\n"); 2236 + complete_all(adapter->fw_done); 2237 + break; 2238 + case 0: 2239 + ret = mwifiex_reinit_sw(adapter); 2240 + if (ret) 2241 + dev_err(&func->dev, "reinit failed: %d\n", ret); 2242 + break; 2243 + default: 2244 + dev_err(&func->dev, "SDIO HW reset failed: %d\n", ret); 2245 + break; 2246 + } 2242 2247 } 2243 2248 2244 2249 /* This function read/write firmware */
+16 -9
drivers/net/wireless/ti/wl1251/sdio.c
··· 16 16 #include <linux/irq.h> 17 17 #include <linux/pm_runtime.h> 18 18 #include <linux/gpio.h> 19 + #include <linux/of.h> 20 + #include <linux/of_gpio.h> 21 + #include <linux/of_irq.h> 19 22 20 23 #include "wl1251.h" 21 - 22 - #ifndef SDIO_VENDOR_ID_TI 23 - #define SDIO_VENDOR_ID_TI 0x104c 24 - #endif 25 - 26 - #ifndef SDIO_DEVICE_ID_TI_WL1251 27 - #define SDIO_DEVICE_ID_TI_WL1251 0x9066 28 - #endif 29 24 30 25 struct wl1251_sdio { 31 26 struct sdio_func *func; ··· 44 49 } 45 50 46 51 static const struct sdio_device_id wl1251_devices[] = { 47 - { SDIO_DEVICE(SDIO_VENDOR_ID_TI, SDIO_DEVICE_ID_TI_WL1251) }, 52 + { SDIO_DEVICE(SDIO_VENDOR_ID_TI_WL1251, SDIO_DEVICE_ID_TI_WL1251) }, 48 53 {} 49 54 }; 50 55 MODULE_DEVICE_TABLE(sdio, wl1251_devices); ··· 212 217 struct ieee80211_hw *hw; 213 218 struct wl1251_sdio *wl_sdio; 214 219 const struct wl1251_platform_data *wl1251_board_data; 220 + struct device_node *np = func->dev.of_node; 215 221 216 222 hw = wl1251_alloc_hw(); 217 223 if (IS_ERR(hw)) ··· 244 248 wl->power_gpio = wl1251_board_data->power_gpio; 245 249 wl->irq = wl1251_board_data->irq; 246 250 wl->use_eeprom = wl1251_board_data->use_eeprom; 251 + } else if (np) { 252 + wl->use_eeprom = of_property_read_bool(np, 253 + "ti,wl1251-has-eeprom"); 254 + wl->power_gpio = of_get_named_gpio(np, "ti,power-gpio", 0); 255 + wl->irq = of_irq_get(np, 0); 256 + 257 + if (wl->power_gpio == -EPROBE_DEFER || 258 + wl->irq == -EPROBE_DEFER) { 259 + ret = -EPROBE_DEFER; 260 + goto disable; 261 + } 247 262 } 248 263 249 264 if (gpio_is_valid(wl->power_gpio)) {
-8
drivers/net/wireless/ti/wlcore/sdio.c
··· 26 26 #include "wl12xx_80211.h" 27 27 #include "io.h" 28 28 29 - #ifndef SDIO_VENDOR_ID_TI 30 - #define SDIO_VENDOR_ID_TI 0x0097 31 - #endif 32 - 33 - #ifndef SDIO_DEVICE_ID_TI_WL1271 34 - #define SDIO_DEVICE_ID_TI_WL1271 0x4076 35 - #endif 36 - 37 29 static bool dump = false; 38 30 39 31 struct wl12xx_sdio_glue {
+12 -1
include/linux/firmware/xlnx-zynqmp.h
··· 91 91 }; 92 92 93 93 enum pm_ioctl_id { 94 - IOCTL_SET_PLL_FRAC_MODE = 8, 94 + IOCTL_SET_SD_TAPDELAY = 7, 95 + IOCTL_SET_PLL_FRAC_MODE, 95 96 IOCTL_GET_PLL_FRAC_MODE, 96 97 IOCTL_SET_PLL_FRAC_DATA, 97 98 IOCTL_GET_PLL_FRAC_DATA, ··· 249 248 ZYNQMP_PM_REQUEST_ACK_NO = 1, 250 249 ZYNQMP_PM_REQUEST_ACK_BLOCKING, 251 250 ZYNQMP_PM_REQUEST_ACK_NON_BLOCKING, 251 + }; 252 + 253 + enum pm_node_id { 254 + NODE_SD_0 = 39, 255 + NODE_SD_1, 256 + }; 257 + 258 + enum tap_delay_type { 259 + PM_TAPDELAY_INPUT = 0, 260 + PM_TAPDELAY_OUTPUT, 252 261 }; 253 262 254 263 /**
+2 -1
include/linux/mmc/card.h
··· 226 226 * MMC Physical partitions 227 227 */ 228 228 struct mmc_part { 229 - unsigned int size; /* partition size (in bytes) */ 229 + u64 size; /* partition size (in bytes) */ 230 230 unsigned int part_cfg; /* partition type */ 231 231 char name[MAX_MMC_PART_NAME_LEN]; 232 232 bool force_ro; /* to make boot parts RO by default */ ··· 291 291 struct sd_switch_caps sw_caps; /* switch (CMD6) caps */ 292 292 293 293 unsigned int sdio_funcs; /* number of SDIO functions */ 294 + atomic_t sdio_funcs_probed; /* number of probed SDIO funcs */ 294 295 struct sdio_cccr cccr; /* common card info */ 295 296 struct sdio_cis cis; /* common tuple info */ 296 297 struct sdio_func *sdio_func[SDIO_MAX_FUNCS]; /* SDIO functions (devices) */
+2
include/linux/mmc/sdio_ids.h
··· 71 71 72 72 #define SDIO_VENDOR_ID_TI 0x0097 73 73 #define SDIO_DEVICE_ID_TI_WL1271 0x4076 74 + #define SDIO_VENDOR_ID_TI_WL1251 0x104c 75 + #define SDIO_DEVICE_ID_TI_WL1251 0x9066 74 76 75 77 #define SDIO_VENDOR_ID_STE 0x0020 76 78 #define SDIO_DEVICE_ID_STE_CW1200 0x2280
-3
include/linux/platform_data/hsmmc-omap.h
··· 67 67 /* string specifying a particular variant of hardware */ 68 68 char *version; 69 69 70 - /* if we have special card, init it using this callback */ 71 - void (*init_card)(struct mmc_card *card); 72 - 73 70 const char *name; 74 71 u32 ocr_mask; 75 72 };