mmc: sdhci: host: add new f_sdh30
Subsystems (3)
PATCH 2/8 mmc: sdhci: host: add new f_sdh30
This patch adds new host controller driver for
Fujitsu SDHCI controller f_sdh30.
--- .../devicetree/bindings/mmc/sdhci-fujitsu.txt | 36 ++ drivers/mmc/host/Kconfig | 7 + drivers/mmc/host/Makefile | 1 + drivers/mmc/host/sdhci_f_sdh30.c | 380 +++++++++++++++++++++ 4 files changed, 424 insertions(+) create mode 100644 Documentation/devicetree/bindings/mmc/sdhci-fujitsu.txt create mode 100644 drivers/mmc/host/sdhci_f_sdh30.c
Documentation/devicetree/bindings/mmc/sdhci-fujitsu.txt new file +36 -0
@@ -0,0 +1,36 @@ +* Fujitsu SDHCI controller + +This file documents differences between the core properties in mmc.txt +and the properties used by the sdhci_f_sdh30 driver. + +Required properties: +- compatible: "fujitsu,f-sdh30" +- voltage-ranges : This is a list of pairs. In each pair, two cells + are required. First cell specifies minimum slot voltage (mV), second + cell specifies maximum slot voltage (mV). In case of supported voltage + range is discontinuous, several ranges could be specified as a list. + +Optional properties: +- pwr-mux-gpios: This is one optional gpio for controlling a power mux + which switches between two power supplies. 3.3V is selected when gpio + is high, and 1.8V is selected when gpio is low. This voltage is used + for signal level. +- clocks: Must contain an entry for each entry in clock-names. It is a + list of phandles and clock-specifier pairs. + See ../clocks/clock-bindings.txt for details. +- clock-names: Should contain the following two entries: + "sd_sd4clk" - clock primarily used for tuning process + "sd_bclk" - base clock for sdhci controller + +Example: + + sdhci1: sdio at 36600000 { + compatible = "fujitsu,f-sdh30"; + reg = <0 0x36600000 0x1000>; + interrupts = <0 172 0x4>, + <0 173 0x4>; + voltage-ranges = <1800 1800>, <3300 3300>; + pwr-mux-gpios = <&gpio0 7 0>; + clocks = <&clk_hdmi_2_0>, <&clk_hdmi_3_0>; + clock-names = "sd_sd4clk", "sd_bclk"; + };
drivers/mmc/host/Kconfig +7 -0
@@ -279,6 +279,13 @@ config MMC_SDHCI_BCM2835 This selects the BCM2835 SD/MMC controller. If you have a BCM2835 platform with SD or MMC devices, say Y or M here. +config MMC_SDHCI_F_SDH30 + tristate "SDHCI support for Fujitsu Semiconductor F_SDH30" + depends on MMC_SDHCI && ARCH_MB86S7X + help + This selects the Secure Digital Host Controller Interface (SDHCI) + Needed by some Fujitsu SoC for MMC / SD / SDIO support. + If you have a controller with this interface, say Y or M here. If unsure, say N. config MMC_MOXART
drivers/mmc/host/Makefile +1 -0
@@ -15,6 +15,7 @@ obj-$(CONFIG_MMC_SDHCI_PXAV3) += sdhci-pxav3.o obj-$(CONFIG_MMC_SDHCI_PXAV2) += sdhci-pxav2.o obj-$(CONFIG_MMC_SDHCI_S3C) += sdhci-s3c.o obj-$(CONFIG_MMC_SDHCI_SIRF) += sdhci-sirf.o +obj-$(CONFIG_MMC_SDHCI_F_SDH30) += sdhci_f_sdh30.o obj-$(CONFIG_MMC_SDHCI_SPEAR) += sdhci-spear.o obj-$(CONFIG_MMC_WBSD) += wbsd.o obj-$(CONFIG_MMC_AU1X) += au1xmmc.o
drivers/mmc/host/sdhci_f_sdh30.c new file +380 -0
380 lines not on this page · raw message
Signature · 1 line
1.8.1.2
PATCH 2/8 mmc: sdhci: host: add new f_sdh30
Documentation/devicetree/bindings/mmc/sdhci-fujitsu.txt line 17
Quoted 12 lines · On Sunday 13 July 2014 14:29:31 Mollie Wu wrote:
Documentation/devicetree/bindings/mmc/sdhci-fujitsu.txt new file +12
-0+Required properties: +- compatible: "fujitsu,f-sdh30" +- voltage-ranges : This is a list of pairs. In each pair, two cells + are required. First cell specifies minimum slot voltage (mV), second + cell specifies maximum slot voltage (mV). In case of supported voltage + range is discontinuous, several ranges could be specified as a list. + +Optional properties: +- pwr-mux-gpios: This is one optional gpio for controlling a power mux + which switches between two power supplies. 3.3V is selected when gpio + is high, and 1.8V is selected when gpio is low. This voltage is used + for signal level.
It sounds like what you really want here is a reference to a gpio-regulator node and, and to put the details of the voltage switching in there.
Quoted 25 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +19
-0@@ -0,0 +1,380 @@ +/* +* linux/drivers/mmc/host/sdhci_f_sdh30.c +* +* Copyright (C) 2013 - 2014 Fujitsu Semiconductor, Ltd +* Vincent Yang <[email protected]> +* Copyright (C) 2014 Linaro Ltd Andy Green <[email protected]> +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, version 2 of the License. +*/ + +#include <linux/err.h> +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/mmc/sd.h> +#include <linux/mmc/host.h> +#include <linux/mmc/card.h> +#include <linux/gpio.h>
drivers/mmc/host/sdhci_f_sdh30.c line 29
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+#include <linux/of_gpio.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h> +#include <linux/suspend.h> + +#include "sdhci.h" +#include "sdhci-pltfm.h" +#include "../core/core.h"
Should this be <linux/mmc/core.h>? A device driver should not be looking at the drivers/mmc/core/core.h.
drivers/mmc/host/sdhci_f_sdh30.c line 31
Quoted 1 line
drivers/mmc/host/sdhci_f_sdh30.c new file +1
-0+#define DRIVER_NAME "f_sdh30"
This macro doesn't seem to serve any purpose, it would be easier to read if you open-code this.
Quoted 23 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +23
-0+ +void sdhci_f_sdh30_soft_voltage_switch (struct sdhci_host *host) +{ +struct f_sdhost_priv *priv =sdhci_priv (host); +u32 ctrl =0 ; + +usleep_range (2500 ,3000 ); + ctrl =sdhci_readl (host,F_SDH30_IO_CONTROL2 ); + ctrl |=F_SDH30_CRES_O_DN ; +sdhci_writel (host, ctrl,F_SDH30_IO_CONTROL2 ); + ctrl |=F_SDH30_MSEL_O_1_8 ; +sdhci_writel (host, ctrl,F_SDH30_IO_CONTROL2 ); + +if (gpio_is_valid (priv->gpio_select_1v8)) { +dev_info (priv->dev,"%s: setting gpio\n" , __func__); +gpio_direction_output (priv->gpio_select_1v8,0 ); + } + + ctrl &= ~F_SDH30_CRES_O_DN ; +sdhci_writel (host, ctrl,F_SDH30_IO_CONTROL2 ); +usleep_range (2500 ,3000 ); + +if (priv->vendor_hs200) {
drivers/mmc/host/sdhci_f_sdh30.c line 97
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+dev_info (priv->dev,"%s: setting hs200\n" , __func__); + ctrl =sdhci_readl (host,F_SDH30_ESD_CONTROL ); + ctrl |= priv->vendor_hs200; +sdhci_writel (host, ctrl,F_SDH30_ESD_CONTROL ); + } + + ctrl =sdhci_readl (host,F_SDH30_TUNING_SETTING ); + ctrl |=F_SDH30_CMD_CHK_DIS ; +sdhci_writel (host, ctrl,F_SDH30_TUNING_SETTING ); +}
I think this should really use the regulator API.
If the regular is defined properly, this will work without any extra code.
Quoted 6 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +6
-0+unsigned int sdhci_f_sdh30_get_min_clock (struct sdhci_host *host) +{ +return F_SDH30_MIN_CLOCK ; +} + +void sdhci_f_sdh30_reset (struct sdhci_host *host,u8 mask)
drivers/mmc/host/sdhci_f_sdh30.c line 114
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+{ +struct f_sdhost_priv *priv =sdhci_priv (host); + +if (gpio_is_valid (priv->gpio_select_1v8)) +gpio_direction_output (priv->gpio_select_1v8,1 ); + +if (sdhci_readw (host,SDHCI_CLOCK_CONTROL ) ==0 ) { +sdhci_writew (host,0xBC01 ,SDHCI_CLOCK_CONTROL ); +mmiowb (); + }
Can you explain the mmiowb call here?
Quoted 7 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +7
-0+ +if (!of_property_read_u32 (pdev->dev.of_node,"bus-width" , &bus_width)) { +switch (bus_width) { +case 8 : +dev_info (dev,"Applying 8 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_8_BIT_DATA ; +break ;
drivers/mmc/host/sdhci_f_sdh30.c line 174
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+case 4 : +dev_info (dev,"Applying 4 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_4_BIT_DATA ; +break ; +case 1 : +default : +dev_err (dev,"Invalid bus width: %u\n" , bus_width); +break ; + } + }
This should probably be done in generic sdhci code somewhere. How about adding it to sdhci_get_of_property instead_
Quoted 6 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +6
-0+ priv->clk_sd4 =clk_get (&pdev->dev,"sd_sd4clk" ); +if (!IS_ERR (priv->clk_sd4)) { + ret =clk_prepare_enable (priv->clk_sd4); +if (ret <0 ) { +dev_err (dev,"Failed to enable sd4 clock: %d\n" , ret); + goto err_clk1;
drivers/mmc/host/sdhci_f_sdh30.c line 208
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+ } + } + priv->clk_b =clk_get (&pdev->dev,"sd_bclk" ); +if (!IS_ERR (priv->clk_b)) { + ret =clk_prepare_enable (priv->clk_b); +if (ret <0 ) { +dev_err (dev,"Failed to enable clk_b clock: %d\n" , ret); + goto err_clk2; + } + }
Please pick clock names that match what some of the other drivers use.
Ideally some of that should also move to common code.
Arnd
PATCH 2/8 mmc: sdhci: host: add new f_sdh30
Quoted 18 lines
-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]Documentation/devicetree/bindings/mmc/sdhci-fujitsu.txt line 17
Quoted 12 lines · On Sunday 13 July 2014 14:29:31 Mollie Wu wrote:
Documentation/devicetree/bindings/mmc/sdhci-fujitsu.txt new file +12
-0+Required properties: +- compatible: "fujitsu,f-sdh30" +- voltage-ranges : This is a list of pairs. In each pair, two cells + are required. First cell specifies minimum slot voltage (mV), second + cell specifies maximum slot voltage (mV). In case of supported voltage + range is discontinuous, several ranges could be specified as a list. + +Optional properties: +- pwr-mux-gpios: This is one optional gpio for controlling a power mux + which switches between two power supplies. 3.3V is selected when gpio + is high, and 1.8V is selected when gpio is low. This voltage is used + for signal level.It sounds like what you really want here is a reference to a gpio-regulator node and, and to put the details of the voltage switching in there.
Hi Arnd,
Yes, I'll use a gpio-regulator for it in next version.
Quoted 32 lines
Review
Quoted 2 lines
(quoted diff) +0
-0
b/drivers/mmc/host/sdhci_f_sdh30.cQuoted 29 lines
new file mode 100644
index 0000000..8d23f2ddrivers/mmc/host/sdhci_f_sdh30.c new file +24
-0@@ -0,0 +1,380 @@ +/* +* linux/drivers/mmc/host/sdhci_f_sdh30.c +* +* Copyright (C) 2013 - 2014 Fujitsu Semiconductor, Ltd +* Vincent Yang <[email protected]> +* Copyright (C) 2014 Linaro Ltd Andy Green <[email protected]> +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, version 2 of the License. +*/ + +#include <linux/err.h> +#include <linux/delay.h> +#include <linux/module.h> +#include <linux/mmc/sd.h> +#include <linux/mmc/host.h> +#include <linux/mmc/card.h> +#include <linux/gpio.h> +#include <linux/of_gpio.h> +#include <linux/of_address.h> +#include <linux/platform_device.h> +#include <linux/pm.h> +#include <linux/pm_runtime.h>
Quoted 8 lines
drivers/mmc/host/sdhci_f_sdh30.c line 29
Quoted 5 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +5
-0+#include <linux/suspend.h> + +#include "sdhci.h" +#include "sdhci-pltfm.h" +#include "../core/core.h" Should this be <
linux/mmc/core.h>? A device driver should not be looking at thedrivers/mmc/core/core.h.
Yes, I'll remove it.
Quoted 5 lines
drivers/mmc/host/sdhci_f_sdh30.c line 31
Quoted 2 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +1
-0+#define DRIVER_NAME "f_sdh30"This macro doesn't seem to serve any purpose, it would be easier to read if you open-code this.
Yes, I'll do it.
Quoted 37 lines
Quoted 24 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +23
-0+ +void sdhci_f_sdh30_soft_voltage_switch (struct sdhci_host *host) +{ +struct f_sdhost_priv *priv =sdhci_priv (host); +u32 ctrl =0 ; + +usleep_range (2500 ,3000 ); + ctrl =sdhci_readl (host,F_SDH30_IO_CONTROL2 ); + ctrl |=F_SDH30_CRES_O_DN ; +sdhci_writel (host, ctrl,F_SDH30_IO_CONTROL2 ); + ctrl |=F_SDH30_MSEL_O_1_8 ; +sdhci_writel (host, ctrl,F_SDH30_IO_CONTROL2 ); + +if (gpio_is_valid (priv->gpio_select_1v8)) { +dev_info (priv->dev,"%s: setting gpio\n" , __func__); +gpio_direction_output (priv->gpio_select_1v8,0 ); + } + + ctrl &= ~F_SDH30_CRES_O_DN ; +sdhci_writel (host, ctrl,F_SDH30_IO_CONTROL2 ); +usleep_range (2500 ,3000 ); + +if (priv->vendor_hs200) {drivers/mmc/host/sdhci_f_sdh30.c line 97
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+dev_info (priv->dev,"%s: setting hs200\n" , __func__); + ctrl =sdhci_readl (host,F_SDH30_ESD_CONTROL ); + ctrl |= priv->vendor_hs200; +sdhci_writel (host, ctrl,F_SDH30_ESD_CONTROL ); + } + + ctrl =sdhci_readl (host,F_SDH30_TUNING_SETTING ); + ctrl |=F_SDH30_CMD_CHK_DIS ; +sdhci_writel (host, ctrl,F_SDH30_TUNING_SETTING ); +}I think this should really use the regulator API.
Quoted 1 line
If the regular is defined properly, this will work without any extra code.
Yes, I'll use a gpio-regulator for it.
Quoted 11 lines
Quoted 11 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+unsigned int sdhci_f_sdh30_get_min_clock (struct sdhci_host *host) +{ +return F_SDH30_MIN_CLOCK ; +} + +void sdhci_f_sdh30_reset (struct sdhci_host *host,u8 mask) +{ +struct f_sdhost_priv *priv =sdhci_priv (host); + +if (gpio_is_valid (priv->gpio_select_1v8))
Quoted 8 lines
drivers/mmc/host/sdhci_f_sdh30.c line 114
Quoted 6 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +6
-0+gpio_direction_output (priv->gpio_select_1v8,1 ); + +if (sdhci_readw (host,SDHCI_CLOCK_CONTROL ) ==0 ) { +sdhci_writew (host,0xBC01 ,SDHCI_CLOCK_CONTROL ); +mmiowb (); + }Can you explain the mmiowb call here?
This came from the original 3.0 based driver. It's trying to be a write memory barrier. It wants to ensure the clock control change actually happened before the following code.
I'll change it to a regular wmb in next version.
Quoted 20 lines
drivers/mmc/host/sdhci_f_sdh30.c line 81
Quoted 3 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +2
-0+ +if (!of_property_read_u32 (pdev->dev.of_node,"bus-width" , &bus_width)){
Quoted 5 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +5
-0+switch (bus_width) { +case 8 : +dev_info (dev,"Applying 8 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_8_BIT_DATA ; +break ;drivers/mmc/host/sdhci_f_sdh30.c line 174
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+case 4 : +dev_info (dev,"Applying 4 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_4_BIT_DATA ; +break ; +case 1 : +default : +dev_err (dev,"Invalid bus width: %u\n" , bus_width); +break ; + } + }
Quoted 2 lines
This should probably be done in generic sdhci code somewhere. How about adding it to
sdhci_get_of_propertyinstead_
I should use generic mmc_of_parse for it. I'll update it in next version.
Quoted 17 lines
Quoted 6 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +6
-0+ priv->clk_sd4 =clk_get (&pdev->dev,"sd_sd4clk" ); +if (!IS_ERR (priv->clk_sd4)) { + ret =clk_prepare_enable (priv->clk_sd4); +if (ret <0 ) { +dev_err (dev,"Failed to enable sd4 clock: %d\n" , ret); + goto err_clk1;drivers/mmc/host/sdhci_f_sdh30.c line 208
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+ } + } + priv->clk_b =clk_get (&pdev->dev,"sd_bclk" ); +if (!IS_ERR (priv->clk_b)) { + ret =clk_prepare_enable (priv->clk_b); +if (ret <0 ) { +dev_err (dev,"Failed to enable clk_b clock: %d\n" , ret); + goto err_clk2; + } + }
Quoted 1 line
Please pick clock names that match what some of the other drivers use.
I'll use "iface" and "core" for clock names because they match what used in sdhci-msm driver.
Thanks a lot for your review!
Best regards,
Vincent Yang
Quoted 4 lines
Ideally some of that should also move to common code.
Arnd
PATCH 2/8 mmc: sdhci: host: add new f_sdh30
Quoted 20 lines · On Wednesday 16 July 2014 17:35:41 Vincent. Yang wrote:
Quoted 11 lines
Quoted 11 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+unsigned int sdhci_f_sdh30_get_min_clock (struct sdhci_host *host) +{ +return F_SDH30_MIN_CLOCK ; +} + +void sdhci_f_sdh30_reset (struct sdhci_host *host,u8 mask) +{ +struct f_sdhost_priv *priv =sdhci_priv (host); + +if (gpio_is_valid (priv->gpio_select_1v8))Quoted 8 lines
drivers/mmc/host/sdhci_f_sdh30.c line 114
Quoted 6 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +6
-0+gpio_direction_output (priv->gpio_select_1v8,1 ); + +if (sdhci_readw (host,SDHCI_CLOCK_CONTROL ) ==0 ) { +sdhci_writew (host,0xBC01 ,SDHCI_CLOCK_CONTROL ); +mmiowb (); + }Can you explain the mmiowb call here?
Quoted 4 lines
This came from the original 3.0 based driver. It's trying to be a write memory barrier. It wants to ensure the clock control change actually happened before the following code.
I'll change it to a regular wmb in next version.
Note that with 'readw'/writew', you shouldn't need any extra barriers. If sdhci_writew() is readw_relaxed(), wmb() is the correct barrier.
Quoted 19 lines
Quoted 19 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ + if (!of_property_read_u32(pdev->dev.of_node, "bus-width", &bus_width)){
Quoted 15 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +15
-0+switch (bus_width) { +case 8 : +dev_info (dev,"Applying 8 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_8_BIT_DATA ; +break ; +case 4 : +dev_info (dev,"Applying 4 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_4_BIT_DATA ; +break ; +case 1 : +default : +dev_err (dev,"Invalid bus width: %u\n" , bus_width); +break ; + } + }
Quoted 4 lines
Quoted 2 lines
This should probably be done in generic sdhci code somewhere. How about adding it to
sdhci_get_of_propertyinstead_I should use generic
mmc_of_parsefor it. I'll update it in next version.
Ah right, I thought we had this in common code already but couldn't find it. Using mmc_of_parse() is definitely the correct solution here.
Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +16
-0+ priv->clk_sd4 =clk_get (&pdev->dev,"sd_sd4clk" ); +if (!IS_ERR (priv->clk_sd4)) { + ret =clk_prepare_enable (priv->clk_sd4); +if (ret <0 ) { +dev_err (dev,"Failed to enable sd4 clock: %d\n" , ret); + goto err_clk1; + } + } + priv->clk_b =clk_get (&pdev->dev,"sd_bclk" ); +if (!IS_ERR (priv->clk_b)) { + ret =clk_prepare_enable (priv->clk_b); +if (ret <0 ) { +dev_err (dev,"Failed to enable clk_b clock: %d\n" , ret); + goto err_clk2; + } + }
Quoted 4 lines
Quoted 1 line
Please pick clock names that match what some of the other drivers use.
I'll use "iface" and "core" for clock names because they match what used in sdhci-msm driver.
Ok, makes sense.
Arnd
PATCH 2/8 mmc: sdhci: host: add new f_sdh30
Quoted 24 lines
-----Original Message-----
From: Arnd Bergmann [mailto:arnd at arndb.de]Quoted 20 lines · On Wednesday 16 July 2014 17:35:41 Vincent. Yang wrote:
Quoted 19 lines
Quoted 7 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +6
-0+unsigned int sdhci_f_sdh30_get_min_clock (struct sdhci_host *host) +{ +return F_SDH30_MIN_CLOCK ; +} + +void sdhci_f_sdh30_reset (struct sdhci_host *host,u8 mask)drivers/mmc/host/sdhci_f_sdh30.c line 114
Quoted 10 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +10
-0+{ +struct f_sdhost_priv *priv =sdhci_priv (host); + +if (gpio_is_valid (priv->gpio_select_1v8)) +gpio_direction_output (priv->gpio_select_1v8,1 ); + +if (sdhci_readw (host,SDHCI_CLOCK_CONTROL ) ==0 ) { +sdhci_writew (host,0xBC01 ,SDHCI_CLOCK_CONTROL ); +mmiowb (); + }Can you explain the mmiowb call here?
Quoted 7 lines
Quoted 4 lines
This came from the original 3.0 based driver. It's trying to be a write memory barrier. It wants to ensure the clock control change actually happened before the following code.
I'll change it to a regular wmb in next version.Note that with 'readw'/writew', you shouldn't need any extra barriers. If
sdhci_writew()isreadw_relaxed(),wmb()is the correct barrier.
Hi Arnd,
The sdhci_writew() is using writew(), so I shouldn't need any extra barriers. I'll remove them in next version.
Thanks a lot for your review!
Best regards,
Vincent Yang
Quoted 54 lines
Quoted 3 lines
Quoted 3 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ + if (!of_property_read_u32(pdev->dev.of_node, "bus-width",
&bus_width))Quoted 17 lines
Quoted 17 lines
{
Quoted 15 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +15
-0+switch (bus_width) { +case 8 : +dev_info (dev,"Applying 8 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_8_BIT_DATA ; +break ; +case 4 : +dev_info (dev,"Applying 4 bit bus width\n" ); + host->mmc->caps |=MMC_CAP_4_BIT_DATA ; +break ; +case 1 : +default : +dev_err (dev,"Invalid bus width: %u\n" , bus_width); +break ; + } + }Quoted 4 lines
Quoted 2 lines
This should probably be done in generic sdhci code somewhere. How about adding it to
sdhci_get_of_propertyinstead_I should use generic
mmc_of_parsefor it. I'll update it in next version.Ah right, I thought we had this in common code already but couldn't find it. Using
mmc_of_parse()is definitely the correct solution here.Quoted 17 lines
Quoted 17 lines
Quoted 16 lines
drivers/mmc/host/sdhci_f_sdh30.c new file +16
-0+ priv->clk_sd4 =clk_get (&pdev->dev,"sd_sd4clk" ); +if (!IS_ERR (priv->clk_sd4)) { + ret =clk_prepare_enable (priv->clk_sd4); +if (ret <0 ) { +dev_err (dev,"Failed to enable sd4 clock: %d\n" , ret); + goto err_clk1; + } + } + priv->clk_b =clk_get (&pdev->dev,"sd_bclk" ); +if (!IS_ERR (priv->clk_b)) { + ret =clk_prepare_enable (priv->clk_b); +if (ret <0 ) { +dev_err (dev,"Failed to enable clk_b clock: %d\n" , ret); + goto err_clk2; + } + }Quoted 4 lines
Quoted 1 line
Please pick clock names that match what some of the other drivers use.
I'll use "iface" and "core" for clock names because they match what used in sdhci-msm driver.
Ok, makes sense.
Arnd